·Sami Dahoux

The pillars of the req language#

Considering the huge workload required to design a new language, one must have strong reasons. Especially in a vast field such as specification. That is why I would like to explain the vision behind the req language.

It basically breaks down into three pillars. Together they represent what I believe is the near-future way of writing requirements specifications. The req language is made to enable all three.

Requirement-as-code#

The Infrastructure-as-Code (IaC) approach has become standard practice in DevOps; the equivalent for specifications barely exists. Software teams write specs in markdown, StrictDoc, or directly in code documentation. Systems engineers are turning to SysML v2, but for requirements themselves, the most popular commercial tools host a database on a central server — DOORS, for one, stored all its data in a proprietary database, and a survey of requirements approaches still calls it “widely used in industry”.

Database-backed tools fall short of file-based workflows in one crucial respect: precise versioning and tracking. In software — and especially DevOps — git workflows track every commit and can trigger powerful automation. For requirements, that same data lives inside a vendor tool, with an inherent disconnection from the project’s source files and a hard dependency on (often legacy) software. Automating that software takes custom scripting — with DOORS, you needed to learn DXL, the Doors eXtension Language.

This is why requirements and specifications should be human-readable code — not DOCX, not XML, not an ALM record. A change to a requirement is then an ordinary diff, reviewed like code:

Raising a voltage threshold, as git shows it#
   requirement Voltage_floor top bottom
     on Battery::voltage
   is
-    Battery::voltage >= 2.0
+    Battery::voltage >= 2.4
   requirement

Progressive formalization#

A requirement must often serve both ends of the spectrum: formal and standardized enough for domain experts, yet still capturing a decision made by a non-technical stakeholder. The same survey puts the dilemma plainly: “Most requirements are written in natural language, good for understandability but lacking in precision.” Among the formal methods experts surveyed in 2020, Erik de Vink names it as one of two main challenges: “document requirements specifications formally so that all stakeholders can be involved and understand the specification”. Few existing formats follow a specification all the way from elicitation — initial, back-of-the-envelope writing — through to detailed design. A survey of 22 requirements approaches, SysML among them, still lists seamlessness among its open questions. Traceability research has pointed at the weak link since 1994: the majority of traceability problems are due to inadequate pre-RS traceability, meaning what happens to a requirement before it makes it into the specification. Decisions end up scattered across files and databases, making alignment slower to understand and easier to get wrong.

Start the specification in plain-text markdown and progressively refine it as the solution takes shape. Several levels of abstraction and formalism live in the same set of source files. Modeling falls out of the specification process itself, as a byproduct of introducing glossary terms.

Here is the smallest example: a sentence, and its formal refinement, in the same file.

A sentence, then its formalization#
package System
  part Wheel
    let deceleration_duration in real \ s \
  part

  requirement Wheel_deceleration top
    on Wheel
  is
    @@
      The [[Wheel]] shall decelerate within 3s.
    @@
  requirement

  requirement Deceleration_bound bottom
    on Wheel::deceleration_duration
    refines Wheel_deceleration
  is
    Wheel::deceleration_duration <= 3
  requirement
package

The sentence is the requirement, as the stakeholder wrote it, and Deceleration_bound refines it once the part and its attribute exist. More complete files are in By Examples.

This keeps a single source of truth for the specification, one that can be dispatched to any downstream tool. It also brings real rigor to spec-driven workflows that plain text alone can’t provide.

Specification diagnostic#

Requirements and design are where a large share of defects in software and systems originate, from misunderstandings between stakeholders. On that side, NaPiRE, a survey of 58 German companies, could “corroborate communication flaws or moving targets as problems in practice”. Capers Jones puts them at 45% of defect potential, a NIST report gives an example distribution with 70% of errors introduced in requirements and architectural design, and in Voyager and Galileo spacecraft software misunderstood requirements were the primary cause of the safety-related behavioural faults Lutz analyzed. Agile workflows are no exception: specifications are ephemeral, and recovering intent from archived tickets to understand what the system does is a common, painful example. In one worked example it means going through all the tickets and building a mental model of every incremental change, and tickets accumulate false starts and so much detail that they can be hard to follow. The cost of those defects resurfaces at the test campaign and at every deployment, and it is often much higher than fixing the specification directly. Boehm and Basili put a late fix at often 100 times the cost of fixing it during requirements and design, though nearer 5 to 1 for small noncritical systems, and a study of 171 projects found no evidence of the effect at all.

Make the specification, especially requirements, statically analyzable as it is written, like a programming language — catching everything from phrasing issues to formal contradictions thanks to its progressively formal nature. Make it so that it is at least easy and ideally automated to check if a given solution satisfies the requirements.

Replace the 3 of Deceleration_bound with false and the checker objects at once:

reqtool check#
System::Deceleration_bound
17:4         expected type Number got Boolean
Wheel::deceleration_duration <= false
found 1 issue(s)