On this page

← Guides

Guides

Close the loop without a deploy

Finalise writes complete from the round's recorded verdicts, on the pull-request branch before the merge. A release Verify then runs the bound end-to-end tests against the release candidate and writes verified. Neither needs production.

Kick the tyres by hand ends with FBS-001 at inProgress, because rcf build mark FBS-001 complete is refused. Running finalise on it straight away produces this refusal:

$ rcf build finalise FBS-001
ci evidence missing: pass --ci-run <ref>

With a CI reference it goes one check further and stops again:

$ rcf build finalise FBS-001 --ci-run <ref>
finalise refused: no REVIEW verdict for FBS-001 on the branch

Both are exit 4, the refused code. The walls are there on purpose. complete means the round ran: a test-author wrote the tests, a builder made them pass, a reviewer and a verifier recorded their verdicts at the same head. Finalise writes it from those records, on the pull-request branch before the merge, and the merge carries it. verified means more again: the item's end-to-end tests passed against the release candidate. That is a release Verify, outside the build cycle, and it alone writes verified. Finalise never does.

Neither step needs production. The round runs against a local server, and the release Verify runs against any URL that serves the candidate, a local server included, or against the packed package installed cold. This page walks both on the same throwaway plant-log project.

What you need

  • The plant-log project from Kick the tyres by hand, with FBS-001 at inProgress. If you deleted it, the rebuild is five minutes of that page.
  • The project in a git repository with a main branch, and a branch for the round. Finalise and rcf audit separation judge the commits from the merge-base with origin/main (else main) up to HEAD, and every verb that records something refuses a working tree with uncommitted changes, because each record names the committed head it is about.
  • A package.json with "type": "module", for the code below. No agent is needed: every step on this page is a command.

Give the round something to prove

The chain's one acceptance criterion is AC-101-1, "Recording a plant with a name and an interval succeeds". Add the Given, When and Then, and flag it external, which says its end-to-end test runs again in the release Verify:

rcf define update US-101 --set acceptanceCriteria.0.given="the Plant log form is open" --set acceptanceCriteria.0.when="the user records a plant with a name and an integer watering interval" --set acceptanceCriteria.0.then="the stored plant and interval appear in the list" --set acceptanceCriteria.0.verification=external

The other value is testOnly, for a criterion its tests settle inside the round; any other value exits 3. rcf define validate refuses a new or amended criterion with no flag at all.

The app is the smallest one that satisfies the criterion. Save it as src/app.js:

// Plant log: the smallest app that satisfies AC-101-1
// ("Recording a plant with a name and an interval succeeds").
import { createServer } from 'node:http';

const esc = (s) => String(s).replace(/[&<>"']/g, (c) => (
  { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]
));

const page = (body) => `<!doctype html>
<html lang="en">
<head><meta charset="utf-8"><title>Plant log</title></head>
<body>
  <h1>Plant log</h1>
  <form method="post" action="/plants">
    <label>Name <input name="name" required></label>
    <label>Watering interval (days) <input name="intervalDays" type="number" min="1" required></label>
    <button type="submit">Record plant</button>
  </form>
  ${body}
</body>
</html>`;

export function validPlant(name, intervalDays) {
  return Boolean(name) && Number.isInteger(intervalDays) && intervalDays >= 1 && intervalDays <= 3650;
}

export function createApp() {
  const plants = [];
  const list = () => plants.length === 0
    ? '<p>No plants recorded yet.</p>'
    : `<ul>${plants.map((p) => `<li>${esc(p.name)}: water every ${p.intervalDays} day(s), next due ${p.nextDue}</li>`).join('')}</ul>`;

  return createServer((req, res) => {
    if (req.method === 'GET' && req.url === '/') {
      res.writeHead(200, { 'content-type': 'text/html' });
      res.end(page(list()));
      return;
    }
    if (req.method === 'POST' && req.url === '/plants') {
      let raw = '';
      req.on('data', (c) => { raw += c; });
      req.on('end', () => {
        const form = new URLSearchParams(raw);
        const name = (form.get('name') ?? '').trim();
        const intervalDays = Number(form.get('intervalDays'));
        if (!validPlant(name, intervalDays)) {
          res.writeHead(400, { 'content-type': 'text/html' });
          res.end(page('<p>A plant needs a name and a whole number of days.</p>'));
          return;
        }
        const nextDue = new Date(Date.now() + intervalDays * 86400000).toISOString().slice(0, 10);
        plants.push({ name, intervalDays, nextDue });
        res.writeHead(303, { location: '/' });
        res.end();
      });
      return;
    }
    res.writeHead(404, { 'content-type': 'text/html' });
    res.end(page('<p>Not found.</p>'));
  });
}

and server.js beside it, the command that serves it:

import { createApp } from './src/app.js';

const port = Number(process.env.PORT ?? 3000);
createApp().listen(port, () => console.log(`Plant log on http://localhost:${port}`));

The bound test is one end-to-end test. A release Verify sets RCF_TARGET_URL to the target it runs against; without it, the test starts the app in-process, which is also how the test-strength audit runs it against each mutant. Save it as test/rcf/plant.test.js:

import test from 'node:test';
import assert from 'node:assert/strict';
import { once } from 'node:events';
import { createApp } from '../../src/app.js';

test('records a plant with a name and an interval', async () => {
  let base = process.env.RCF_TARGET_URL;
  let server;
  if (!base) {
    server = createApp().listen(0);
    await once(server, 'listening');
    base = `http://127.0.0.1:${server.address().port}`;
  }
  try {
    const post = await fetch(`${base}/plants`, {
      method: 'POST',
      body: new URLSearchParams({ name: 'Fern', intervalDays: '7' }),
      redirect: 'manual',
    });
    assert.equal(post.status, 303);
    const list = await (await fetch(`${base}/`)).text();
    assert.match(list, /Fern: water every 7 day\(s\)/);
  } finally {
    server?.close();
  }
});

Last, rcf/test-strength.json tells the audit what the app entry is, where test helpers live and what the project's RCF suite command is:

{
  "entry": [{ "kind": "module", "path": "src/app.js" }],
  "harness": ["test/helpers/**"],
  "suiteCommand": "node --test --test-reporter=tap"
}

Record the base

No Build starts until the RCF suite is green on the base. On main, with the scaffold and rcf/test-strength.json committed and before the app or its test exist, record that run:

rcf build base-suite --out ../plant-log-base.json

It runs suiteCommand at the clean committed head and prints base-suite: green at <h7> (exit 0, <p> pass, 0 fail) recorded to ../plant-log-base.json. The record never goes inside rcf/, and every rcf build bundle FBS-001 --base-suite ../plant-log-base.json checks it: a missing, stale or red record is refused with exit 4. Then branch for the round.

One round, five commits

Each stage ends in a commit whose subject opens with its prefix, and rcf audit separation judges every commit's prefix against the paths it touches.

  1. DEFINE: The test-author's commit: the flagged criterion, the test file, and the test suite and test case that bind it (rcf define create ts --parent US-101 --title "Record a plant end to end" --acs AC-101-1 --purpose "Prove AC-101-1 against the running app" --test-level e2e, then rcf define create tc --parent <ts-id> --ac AC-101-1 --description "Records a plant with a name and an interval" --test-pointer "test/rcf/plant.test.js::records a plant with a name and an interval"). rcf define create ts asks for the project's UI posture first; for this toy, rcf discover journey declare --ui none --reason "a one-form toy" answers it. The test is red here, because src/app.js does not exist yet, and rcf audit coverage --strict covers the criterion. If the item is not already at inProgress, this commit also carries rcf build mark FBS-001 inProgress.
  2. BUILD: The builder's commit: src/app.js, server.js and the Code Nodes that tie the criterion to the source, rcf define create cn --path "src/app.js#validPlant" --acs AC-101-1 and the same for src/app.js#createApp. The red test is now green.
  3. REVIEW: The reviewer re-validates the tree, runs rcf audit separation, records the test-strength report with rcf audit test-strength --record and records the verdict with rcf build verdict review, here --fbs FBS-001 --acs AC-101-1 --code MERGE --adequacy PASS. The audit breaks validPlant and createApp one way at a time in a scratch copy and needs the bound test to go red against each; its report is for the reviewer to read, and its result never refuses Finalise. The REVIEW: commit adds the verdict files under rcf/verdicts/.
  4. TEST: The verifier starts the app (node server.js), runs the full RCF suite against it with TAP output saved to a file outside the project, and records it with rcf build verdict test, here --fbs FBS-001 --result PASS --tap <file> --runtime "node server.js on localhost:3000". The verb reads the TAP; it never runs the suite. The TEST: commit adds the verdict file.
  5. FINALISE: With CI green on the branch head, the stage-keeper runs the light Finalise on the branch:
rcf build finalise FBS-001 --ci-run <ref>

It checks, in order, that the tree validates, that --ci-run is given, a Review MERGE and adequacy PASS at the reviewed head, a Test PASS at that same head with no later failure, a test-strength record for that head covering the touched criterion, a Code Node on every touched criterion, and the separation audit over the branch. The first check that fails stops it with its own refusal line and leaves the item unchanged. When every check holds it writes complete and prints finalise: FBS-001 complete at <head7> (reviewed <H7>, ci <ref>, touched 1 criteria). --ci-run names the CI run that passed on the branch head; Finalise records it and never fetches it. Commit the write as FINALISE: and merge: the merge carries complete to main. If you merge main into the branch after the review, subject that merge FINALISE: merge main, record a base suite at it and pass it as --merge-suite <file>.

A failed Review or a failed Test closes the round. The next round starts again at DEFINE:.

Verified: the release Verify against the local server

verified is written by a release Verify, run on main before the promote. It runs the bound end-to-end tests of the live external criteria of every item changed since the last release, plus the smoke suites rcf/release-verify.json names, against the target. Declare the smoke suites first and commit the file:

{ "smoke": ["<ts-id>"] }

Then, with the app running from main, run it against the local server, here with the label plant-log-0.1.0:

The round is merged and complete. Run the release Verify for <label> against my local server at <url>, since the last release, without recording it yet.

The release Verify runs the bound end-to-end tests of the live external criteria of every item changed since <last-release-ref>, plus the smoke suites rcf/release-verify.json names, against the URL (the tests read it as RCF_TARGET_URL). Without --record it writes nothing in the project; with --record it writes rcf/verify-reports/releases/<label>.json and verified on each item whose external criteria all passed, only when the smoke suites passed. Exit 0 PASS, 4 FAIL, 2 usage.

Without --record it writes nothing in the project: it prints AC-101-1 FBS-001 pass (or fail, followed by a reason: line naming the first failure, or blocked with its reason), then verify: release plant-log-0.1.0 PASS 1/1 external criteria, smoke 1/1 (target <target>). Exit 0 is PASS and 4 is FAIL. When it passes, run it again with --record. That writes the release report to rcf/verify-reports/releases/plant-log-0.1.0.json and verified on each item in scope whose external criteria all passed, and prints verify: recorded <path>; verified FBS-001. Commit both in a FINALISE: commit. A release label holds no / or \ and is not . or .., and --since must be a commit that HEAD contains.

A local server is an honest target for a toy, and the report records the target it ran against, so anyone reading it sees that verified rests on a local run. On a real product, run the release Verify against the candidate you are about to promote.

Another target: a preview host

A preview host is any address that serves the release candidate: a pull-request preview, a version URL from your hosting platform, a staging box. It is not production, which is the point. Run the same command with that address as --url; the bound tests read it as RCF_TARGET_URL.

Another target: the packed package

When the thing you build is a package, a library or a CLI, there may be no app to serve at all. The release Verify then installs the bytes you would publish, cold, as a brand-new user would:

rcf verify run --release <label> --since <ref> --package . --record

--package <dir> packs the directory first; --artefact <tgz> takes a tarball you already packed. Either way the package is installed in a fresh scratch directory with its own HOME, an empty npm cache and a reduced environment, so your own npm settings and variables never reach the run, and the bound tests see RCF_TARGET_KIND=package. The report records the package's name, version and tarball hash. --offline is refused, because a cold install cannot be offline, and a failed install exits 1 and writes no report. The run leaves no tarball and no node_modules or lockfile change behind.

An ad hoc look with the agent verifier

rcf verify run --repo . --profile local-dev --url http://localhost:3000 --out <file> still launches a fresh verifier agent against the running app, an agent with none of your build context that drives the app through a real browser and files findings against each criterion. It is an optional probe: it never writes a status, and neither Finalise nor the release Verify reads its report. It is still worth running on anything with a form. Against an earlier draft of this page's server, the verifier crashed the process with an interval large enough to overflow the date arithmetic, then recorded a plant named <img src=x onerror=alert(1)> and watched its own alert fire: a stored XSS its author had not seen. Both fixes are in the code above.