Guides
Trace requirements and share results
Write your requirements in Flex, trace them to model checks and component tests, and share the verification matrix.
This guide takes a set of requirements from your requirements document, writes them into your Flex model, and traces each one to the evidence that it’s met: a model check of the design, or a test of the component that implements it. At the end you’ll have a verification matrix to share as a PDF, a JSON report for your own tools, and a pipeline that brings both up to date on every push.
Before you begin
- A Tenon project with a model that checks, such as the example model.
- Your requirements, each with an id and its text, and the name of the document they come from.
- For requirements a component meets, a component test that runs. See Component tests.
1. Write the requirements in Flex
Keep the requirements in a file of their own, so they read like the
document they come from. A requirement set is an enum, with one member
for each requirement and its text as the value.
@RequirementID gives each member the id your document uses,
@RequirementMeta("document", …) names the document, and any
other @RequirementMeta key, such as an id in your
requirements tool, is carried into the JSON report.
module thermal.requirements
annotation RequirementID(id: string) | EnumValue |
annotation RequirementMeta(key: string, value: string)
| Enum EnumValue |
annotation Satisfies(req: Thermal)
| Requirement LocalProtocol GlobalProtocol |
@RequirementMeta("document", "Thermal SRS")
enum Thermal string {
@RequirementID("THM_001")
@RequirementMeta("doorsId", "DR-101")
T1 = "Every temperature request gets a reading";
@RequirementID("THM_002")
@RequirementMeta("doorsId", "DR-102")
T2 = "A reading carries the id of its request";
@RequirementID("THM_003")
T3 = "A reading out of band is reported as one";
}Satisfies is the claim annotation that the protocols use
to claim these requirements. A member’s name must be a Flex identifier,
so THM_001 is spelled T1 there and kept as its
id; tenon verify requirements --docs has every rule. Check
the model with tenon flex check spec.
2. Claim each requirement in a protocol
Import the requirements into the file with your protocols, and put a claim on each protocol that satisfies one. Who answers the claim depends on the protocol. A claim on a global protocol is met when the model check proves it, and is listed with the method Analysis. A claim on a component’s local protocol is met when the component passes its test, and is listed as Test.
module thermal.diagnostics
import thermal.requirements as reqs
@reqs.Satisfies(reqs.Thermal.T1)
global protocol AcceptedThermalBand {
exch any ReadTemperature from CommandPost to Radar;
exch any Temperature from Radar to CommandPost;
}
@reqs.Satisfies(reqs.Thermal.T2)
local protocol ReportTemperature in Radar {
recv let req: ReadTemperature on RequestChan;
send let rep: Temperature
where rep.id == req.id
on ReplyChan;
}A protocol can claim several requirements, with one annotation for each, and several protocols can claim the same one. Then every one of them must pass for the requirement to be supported.
3. Trace the requirements
Run the model check and save its results, then trace the requirements against them. Tenon lists each requirement with its status and the protocol that answers it.
tenon verify model spec --out reports/modelcheck.jsontenon verify requirements spec --modelcheck reports/modelcheck.jsonWith only the model check, THM_001 is supported, and two
need attention. THM_002 is unknown: it’s claimed by Radar’s
local protocol, and nothing has tested Radar yet. THM_003
is unclaimed: no protocol claims it, so there’s nothing that could ever
support it.
4. Close the gaps
Each status that isn’t supported tells you what to do. An
unknown requirement needs more evidence: here, the
results of Radar’s component test. An unclaimed one
needs a claim in the model: THM_003 is about readings out
of band, which RejectedThermalBand handles, so claim it
there. A contradicted requirement is claimed by a
protocol that failed its check or its test, and the trace names
which.
@reqs.Satisfies(reqs.Thermal.T3)
global protocol RejectedThermalBand {
exch any ReadTemperature from CommandPost to Radar;
choice in Radar
| true =>
exch any Temperature from Radar to CommandPost;
exch any Accept from CommandPost to Radar;
| else =>
exch any OutOfBand from Radar to CommandPost;
exch any Retry from CommandPost to Radar;
end
}tenon verify model spec --out reports/modelcheck.jsontenon verify component components/Radar --flex ../../spec \ --report reports/verifier/Radartenon verify requirements spec --modelcheck reports/modelcheck.json \ --verifier reports/verifier/Radar/results.jsonWith the claim and both kinds of evidence, all three requirements are supported. The trace also warns that Radar’s results may not match the current Flex code. A component test’s results don’t record which version of the model they tested, so Tenon can’t confirm them and warns every time: make sure you tested against your current model before you share the report. A warning that the model check’s results don’t match means your sources have changed since, so run the check again.
5. Share the verification matrix
Save the trace as a PDF: a verification matrix with a section for
each requirement set, headed by its source document. Each requirement is
listed with its id, its text, how it’s verified, its result, and the
protocol and result that verify it. Save it as JSON for a requirements
tool or a script: the JSON report carries your
@RequirementMeta keys, such as doorsId, beside
each requirement.
tenon verify requirements spec --modelcheck reports/modelcheck.json \ --verifier reports/verifier/Radar/results.json \ --format pdf --out reportstenon verify requirements spec --modelcheck reports/modelcheck.json \ --verifier reports/verifier/Radar/results.json \ --format json --out reportsBoth are written to reports/, as
trace-report.pdf and trace-report.json. To
share only some requirements, add --requirement with an id
or a pattern, such as THM_*.
6. Keep it up to date
A workflow
that traces requirements does all of this on every run: it runs the
model check and the component tests, traces the requirements against
them, and saves trace.pdf and trace.json in
the run folder, with a dashboard
that shows each requirement’s status. When you add requirements to the
model, a workflow that traces all of them picks them up.
In a pipeline, the same files are in the
reports job’s artifacts on every push, so the matrix always
matches the model and the components as they are.
tenon workflow run Systemopen out/System/latest/trace.pdfNext steps
- Requirements in Flex: requirement sets, ids and claims.
- Trace
requirements: every option of
tenon verify requirements. - Run Tenon in CI: trace requirements on every push.