Projects & workflows

Create a project

tenon init makes a Tenon project in your repo. A project is one folder, flex/ unless you name another, that keeps everything Tenon adds in one place. Inside it are the project file, tenon.toml, which records where your Flex model lives and which workflows you’ve described; a spec/ folder for your .flex files; and a .gitignore that keeps out/, where Tenon writes everything it generates, out of Git.

If your repo already has .flex files, Tenon points the project at them instead of creating spec/, then offers to describe your first workflow straight away. Running tenon init inside an existing project changes nothing.

Once the project exists, every tenon command finds it on its own, whether you run it from the repo root, from the project folder, or from any folder below it.

The examples in these docs use one project, ThermalDiagnostics, whose model is in flex/spec/thermal.flex. Its two components, Radar and CommandPost, exchange temperature readings in two global protocols, Radar has a local protocol of its own, and two requirements are claimed by the protocols that satisfy them.

Command: tenon init [<dir>] [--name <name>]

Arguments

<dir>
The project folder to create. Defaults to flex. Use . to make the current folder the project.

Options

--name <name>
The project’s name, which is also the dashboard’s default title. Defaults to the name of the folder you run tenon init in.
Create a project
tenon init --name ThermalDiagnosticstenon init verification --name ThermalDiagnosticstenon init .
flex/spec/thermal.flex
module thermal.diagnostics

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")
  T1 = "Every temperature request gets a reading";
  @RequirementID("THM_002")
  T2 = "A reading carries the id of its request";
}

component Radar;
component CommandPost;

connection RequestChan from CommandPost to Radar;
connection ReplyChan   from Radar to CommandPost;

message struct ReadTemperature { id: int32; }
message struct Temperature { id: int32; celsius: int32; }
message struct Accept {}
message struct Retry {}
message struct OutOfBand { id: int32; celsius: int32; }

@Satisfies(Thermal.T1)
global protocol AcceptedThermalBand {
  exch any ReadTemperature from CommandPost to Radar;
  exch any Temperature from Radar to CommandPost;
}

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
}

@Satisfies(Thermal.T2)
local protocol ReportTemperature in Radar {
  recv let req: ReadTemperature on RequestChan;
  send let rep: Temperature
    where rep.id == req.id
    on ReplyChan;
}

Describe a workflow

tenon workflow new describes a new workflow: a named, saved list of the tenon commands your project needs, which you can then run in one step on your machine or in CI. Tenon reads your Flex model and asks you five questions about it: which protocols get diagrams, which global protocols to model-check, which components to test, which requirements to trace, and what to title the report.

Each question lists what your model contains, with a default in brackets that Enter accepts. A list takes numbers such as 1,3 or 1-3, all or none, and requirements also take a pattern such as THM_*. Only components with a local protocol can be tested, so Tenon names any others and says why: for ThermalDiagnostics, it offers Radar, and names CommandPost as having no local protocol.

When you’ve answered, Tenon shows what the workflow will do and saves it as a [workflow.<name>] table in the project file; pressing Ctrl-C before then quits without saving. Because it asks questions, tenon workflow new needs an interactive terminal. It reads your model without taking a license seat.

Last, for each component you chose that isn’t set up yet, Tenon offers to run the Verifier’s setup wizard, which writes the component’s verifier.yaml in flex/components/<Name>/, as described in Set up a component test. You can leave a component for later instead: it stays in the workflow, and changing the workflow offers the setup again.

Command: tenon workflow new <name>

Arguments

<name>
The new workflow’s name: letters, digits, - or _. It also names the workflow’s results folder, out/<name>/.
Describe a workflow
tenon workflow new System

Change a workflow

tenon workflow update changes a workflow by asking the same questions as tenon workflow new, with the workflow’s saved settings as the defaults, so Enter keeps each one. A choice of all stays all, so the workflow picks up any protocols, components and requirements you’ve added to the model since. A saved name that the model no longer has is flagged, for you to drop or keep.

Before it saves, Tenon shows only the lines that change, and it rewrites only those keys, leaving the rest of tenon.toml, your comments included, as it was. If nothing changed, nothing is written. A chosen component that still has no verifier.yaml gets the setup offer again.

You can edit the project file by hand, too. Every key names the command it becomes, and tenon workflow show prints the result straight away.

Command: tenon workflow update <name>

Arguments

<name>
The workflow to change.
Change a workflow
tenon workflow update System

Show what a workflow runs

tenon workflow show prints the exact commands a workflow runs, in order, ready to paste into a shell. Lines marked # gate are the checks that decide a run’s result, and the rest only write reports. It’s the quickest way to check an edit to the project file, or to run one step by hand while you fix it.

The printed commands write their results to out/<name>/manual, so they never mix with the workflow’s own runs. tenon workflow show works from any folder in the project and needs no license seat.

Command: tenon workflow show <name>

Arguments

<name>
The workflow to show.
Show what a workflow runs
tenon workflow show System

List workflows

tenon workflow list lists the project’s workflows in the order the project file has them, one line each, with a summary of the steps each one runs.

Command: tenon workflow list

List workflows
tenon workflow list

Run a workflow

tenon workflow run runs a workflow’s commands in order, from the project folder, and then summarises the results. Each step is an ordinary tenon command, printed before it runs, so you see its own output as it goes. The results land in a new run folder, out/<name>/<time>/ (in UTC), with a dashboard that links them all.

Before it runs anything, Tenon checks everything the workflow needs: the Flex sources, each component’s setup and binary, Docker and Tenon’s image, licensing, and python3 for the HTML reports. If it finds a problem, it lists each one with its fix and exits 11 without running a step. Tenon never builds your component, so build it before you run a workflow that tests it.

The model check and each component test are gates, which means their exit codes decide the run’s result. A failed gate doesn’t stop the run: the later steps and the dashboard still run, and the summary ends with the command to re-run the failed step on its own. A licensing or configuration error does stop the run, because every later step would fail the same way, though the dashboard is still built.

out/<name>/latest points at the last run that finished, and Tenon keeps the last 10 runs. If you press Ctrl-C, Tenon stops and keeps what the run has written so far, and latest stays where it was.

Command: tenon workflow run <name> [--dry-run]

Arguments

<name>
The workflow to run.

Options

--dry-run
Print the commands, as tenon workflow show does, and run nothing.

Exit codes

Code Meaning
0 Every gate passed
1 A gate failed: the model doesn’t check, or a component isn’t conformant
3 The model uses something component tests don’t support
10 No license seat; the run stopped there
11 The checks found a problem and nothing ran, or a configuration error stopped the run
12 Tenon couldn’t carry out a component test, or couldn’t trust its results
13 The license server can’t be reached; the run stopped there
130 Cancelled

When several gates fail, the code is the first of 12, 3 and 1 that one of them returned. Report steps never change it. Without require_proven, a model check that isn’t certified is only a warning, and the run still passes.

Run a workflow
tenon workflow run Systemtenon workflow run System --dry-run

Run a workflow in CI

tenon workflow ci writes a pipeline that runs the same commands as tenon workflow run: .gitlab-ci.yml at your repository root for GitLab, or .github/workflows/tenon.yml for GitHub Enterprise Cloud (github.com included) and GitHub Enterprise Server. Every job runs in Tenon’s image from the project folder, so its commands are exactly the ones you run locally, and each job returns its license seat when it finishes. The pipeline has four kinds of job:

  • build-component runs your own build command, from the repository root.
  • design draws the diagrams and runs the model check.
  • verify-<Component> tests one component, with any test broker it needs running beside it as a job service.
  • reports traces requirements and builds the dashboard, even when a check failed.

The jobs keep their results under flex/reports/: as job artifacts in GitLab, where component test results also show up as JUnit reports, and in GitHub as one artifact per job plus tenon-reports, which holds them all.

The first time you run it, Tenon asks which platform hosts your code, and how CI should build your component: the build image, the build command, and the binaries the test jobs need. It saves your answers in [ci] and [ci.build] in the project file, so you’re asked only once. When the workflow changes, run tenon workflow ci again rather than editing the YAML. Tenon asks before it replaces a pipeline file it didn’t generate for this workflow. For GitLab, it also offers to keep its jobs in flex/tenon.gitlab-ci.yml, for your existing .gitlab-ci.yml to include. Without a terminal, Tenon never asks: a missing platform is an error, and it replaces only a file it generated for the same workflow.

In GitLab, the pipeline reads three CI/CD variables:

TENON_IMAGE
Tenon’s image, in a registry your runners can pull. Push it there with ./install.sh --push-image <registry/repo> from the bundle (see Install).
FLEX_LICENSE_SERVER
The license server’s address, reachable from your runners.
FLEX_LICENSE_ROOT_PUBKEY
The trust root, as a File variable.

In GitHub, it reads the same three as Actions variables, with the trust root’s text pasted in rather than as a file, plus TENON_IMAGE_PULL_USERNAME, a variable, and TENON_IMAGE_PULL_TOKEN, a secret, which every job uses to log in to your registry.

Run Tenon in CI takes you through setting up a pipeline from start to finish.

Command: tenon workflow ci <name>

Arguments

<name>
The workflow the pipeline runs.
Write the pipeline
tenon workflow ci System

Build a dashboard

tenon report builds one page that links every report in a folder: the model check, component test results, the requirements trace and the diagrams. It writes the page as <dir>/index.html, with only relative links, so it works opened from disk or from a CI job’s artifacts. A report that isn’t in the folder shows as not run.

Every workflow run ends by building its own dashboard, so you need tenon report only for reports you’ve made by hand. Run it from the project folder, so the dashboard can find your Flex sources. It needs no license seat, but it does need python3.

The dashboard for a workflow run

Command: tenon report <dir> [--title <text>]

Arguments

<dir>
The folder of reports, such as one from tenon verify component --report <dir>.

Options

--title <text>
The page’s title. Defaults to your Flex model’s package name (thermal for module thermal.diagnostics).
Build a dashboard
tenon report out/System/latest --title "Thermal Diagnostics"
Build a dashboard for a component test
tenon verify component components/Radar --flex ../../spec --report reportstenon report reports --title Radar

The project file

tenon.toml, in the project folder, is the project file. It holds the project, its workflows, and how CI builds your components. tenon init creates it and the tenon workflow commands add to it, but it’s small enough to edit by hand: every workflow setting becomes one option on one command, and tenon workflow show prints the result.

Paths in the file are relative to its own folder. A key Tenon doesn’t recognise is an error that lists the keys it allows, and nothing in the file can change which programs Tenon runs.

The [project] table names the project and its model:

name
The project’s name, and the dashboard’s default title.
flex
Your Flex files or folders, as a list. A workflow that tests components needs exactly one entry.

Each [workflow.<name>] table is one workflow, named with letters, digits, - or _. Every key in it is optional, and leaving a key out skips its step. An empty table, {}, runs the step with its command’s defaults, which cover every protocol or every requirement.

sequence_diagrams = { protocols = [...] }
Draw a sequence diagram of each protocol, with tenon flex diagram --kind sequence. A name matches any part of a protocol’s full name, or, as a glob with * or ?, the whole of it.
block_diagram = {}
Draw one block diagram of every protocol, with tenon flex diagram --kind block.
model = { protocols = [...], require_proven = true }
Model-check these global protocols, named exactly. With require_proven = true, a protocol that isn’t certified fails the run, so only Proven passes. Defaults to false, where not certified is a warning.
components = ["components/<Name>", ...]
Test each component in these folders, from the project folder. Each folder’s name, which must be unique, names its results.
requirements = { select = [...] }
Trace the requirements with these ids or patterns. It needs model or components too, for evidence.
report = { title = "..." }
Build the dashboard, with this title.

The [ci] table says which CI your pipeline is for. Only tenon workflow ci reads it, and it asks for any value that’s missing, so delete a value to be asked again.

platform
The platform the pipeline is for: gitlab writes .gitlab-ci.yml, and github (GitHub Enterprise Cloud, github.com included) and github-server (GitHub Enterprise Server) write .github/workflows/tenon.yml.
gitlab
Where a GitLab pipeline goes: greenfield writes a standalone .gitlab-ci.yml, and brownfield writes flex/tenon.gitlab-ci.yml, for an existing .gitlab-ci.yml to include. Tenon asks only when your repository has a .gitlab-ci.yml it didn’t write; otherwise it writes the standalone file.

The [ci.build] table tells your pipeline how to build your components. Only tenon workflow ci reads it; a local run never builds anything.

image
The container image the build job runs in.
command
Your build command, run from the repository root.
binaries
What the build job hands to the test jobs: each component’s binary, or its folder, from the project folder.
flex/tenon.toml
[project]
name = "ThermalDiagnostics"
flex = ["spec"]

[workflow.System]
sequence_diagrams = {}
block_diagram     = {}
model             = { require_proven = true }
components        = ["components/Radar"]
requirements      = { select = ["THM_*"] }
report            = { title = "Thermal Diagnostics" }

[ci]
platform = "gitlab"

[ci.build]
image    = "debian:bookworm-slim"
command  = "./scripts/build-radar.sh"
binaries = ["../build/radar"]