Skip to content

Scripted CLI evidence

Scripted CLI evidence

Run all scenarios from a source checkout on a POSIX host with Node.js and Git. The harness uses a local bare remote and a stub gh. It needs no model credentials, network access, or container runtime. The scenarios run on demand. aloop’s own evidence phase also runs them as advisory scenarios.

Terminal window
npm run e2e -- --scenario all
npm run e2e -- --scenario resume-after-kill --out /tmp/aloop-evidence
ScenarioWhat it checks
happy-pathThe default pipeline creates one PR and pushes the reviewed commit with a passing gate receipt.
repair-loopA blocking finding triggers an address commit and round-two approval.
gate-fixAn initial gate failure triggers a repair and a passing gate receipt on the repaired commit.
round-capThe CLI exits with a saved stall. Resuming at PR description completes that phase and still requires approval to publish.
resume-after-killA process killed after the agent commits resumes the same run without replaying implementation.
parallel-runsOne run can publish while another run reviews in the same repository with a separate branch and worktree.
publish-attestationA commit introduced after approval prevents the driver from pushing or creating a PR.
evidence-phaseEvidence selection produces a scoped evidence commit, and the published PR includes its receipt.

--scenario core runs the seven scenarios preceding evidence-phase. Each scenario writes a summary.json in its own directory under ALOOP_EVIDENCE_OUT or docs/evidence/. The --out flag overrides that destination. The summary records the candidate commit, whether the checkout was dirty before output was written, and one result per assertion. In the evidence phase, the scenario field uses the catalog name and fixtureScenario names the individual check suite. Run from a clean checkout to produce a contract-valid evidence receipt.

Without --out or ALOOP_EVIDENCE_OUT, output goes to docs/evidence/ in the checkout. That directory isn’t git-ignored, so a local run leaves untracked files there. Use --out with a temporary directory for local checks. In aloop’s own loop.config.mjs, the e2e-core and e2e-evidence scenarios run --scenario core and --scenario evidence-phase, and the evidence phase commits their output.

The command exits nonzero if any scenario fails or is blocked. When a scenario fails or is blocked, fixture.json points to the retained temporary fixture, which contains captured CLI output, saved run state, and the local remote. Successful fixtures are removed.

Add a scenario

Add a module under test/e2e/scenarios/ that exports name, description, and async run(h). Add it to the core array in test/e2e/run.mjs to include it in --scenario core. all is core plus evidence-phase, so it also runs under all. Use await h.fixture({ files, config, script, scripts }) to create the fixture and h.check(name, passed, detail) to record each assertion. h.root is a temporary directory for the scenario’s marker files. The fixture’s run(name, args?) returns { code, signal, stdout, stderr }. Its other helpers are state(name), manifest(name), status(name), git(dir, ...args), remoteHead(branch), readGhLog(), cwd, and runDir(name). The script option overrides the default phase steps for every run. The scripts option maps a run name to a script whose phases override both for that run only. Phases it omits keep the defaults. When args is omitted, run passes --task 'Make greet.js return hello.'.

A script maps phase names to ordered arrays of steps. The fake agent identifies the phase from a marker string in the rendered prompt; the phases map in test/e2e/fake-agent.mjs lists the markers, and a prompt with no marker fails. Each run keeps its own phase cursors in its saved run directory. Here is a two-round review script with a repair:

{
"review": [
{
"verdict": "CHANGES_REQUESTED",
"blocking": [{ "file": "greet.js", "line": 1, "issue": "Add a greeting test." }]
},
{ "verdict": "APPROVED" }
],
"address": [
{
"write": { "greet.test.js": "require('node:assert/strict').equal(require('./greet.js')(), 'hello');\n" },
"commit": "test: cover greeting"
}
]
}

The implementation and repair steps can write files relative to the fixture worktree and commit them. The reviewer writes its verdict and prose to the paths in the rendered prompt. Use { "noop": true } to complete a phase without changes, writeOut for pr.md, or plan for the evidence selection. Steps also accept exit (the process exit code), sleepMs, hang, and the file-based hooks started, waitFor, and signal, which exercise failure and interruption paths. Unknown prompts and exhausted scripts fail with an error in the phase log.