PostgreSQL backup tool with Point-In-Time-Recovery and restore verification
The hook test command below runs from the repository root: python3 -m unittest discover -s .agent-hooks -p '*_test.py'.
1. Hook launch
1.1 Pin
python = "3.14.7"and"npm:@fission-ai/openspec" = "1.11.0"inmise.toml. Verify withmise install, thenmise exec -- python3 --versionprintingPython 3.14.7andmise exec -- openspec --versionprinting1.11.0.1.2 Add
.agent-hooks/run.shper design.md. It findsmiseonPATHor in$HOME/.local/bin, refuses to start whenmise ls --current --missingreports the pinnedpythonornpm:@fission-ai/openspecmissing, setsMISE_EXEC_AUTO_INSTALL=falseand runsreview_gate.pythroughmise exec. Whenmiseis missing, a pinned tool is missing or the hook fails, it prints an escaped stop JSON with exit code 0. Fordoctorit passes the exit code through and exits with code 1 whenmiseor a pinned tool is missing. AddLauncherTesttoreview_gate_test.py. It runs the script with a stubmise, which records its arguments and environment, and a temporaryHOME:- with no
miseonPATHbut a stub in$HOME/.local/bin, the hook runs through the stub (review-hook-launchscenario "A client started from an IDE"); - the stub sees
MISE_EXEC_AUTO_INSTALL=false, and when itsls --missingreports a missing pinned tool while itsexecstill succeeds, like realmise, the output is valid JSON withcontinue: falsethat namesmise installandjust doctor, andexecnever runs ("A pinned version is not installed"); - with no
miseanywhere, the output is valid JSON withcontinue: falsethat names the version manager andjust doctor("The version manager is missing"); - with a stub that exits with code 3, the output is valid JSON that names the action, the code and
just doctor("The hook crashes"); - a message containing a double quote stays valid JSON;
run.sh doctorexits with the code of the stub, and with code 1 when nomiseis found ("No version manager").
Verify with the hook test command.
- with no
1.3 In
review_gate.py, raiseMissingToolErrorwhenopenspeccannot start inis_planning_complete, and turn it into a stop message that names the tool andjust doctor. Add thedoctoraction, which reports Python,git,openspecand the reviewer CLIs, and keep--clientrequired for every other action. Update the module docstring and the comment aboveis_planning_complete. Add these tests:MissingToolTest, covering "OpenSpec is missing" withopenspecremoved from the testPATH;DoctorTest, covering "Every tool is present" and "No reviewer CLI".
Verify with the hook test command.
1.4 Add the
doctorrecipe (.agent-hooks/run.sh doctor) to the rootJustfileand its row to the command table in the rootAGENTS.md. Verify withjust doctorexiting with code 0, and withPATH=/usr/bin HOME=$(mktemp -d) .agent-hooks/run.sh doctorexiting with a non-zero code.1.5 Switch every hook in
.claude/settings.jsonand.codex/hooks.jsontorun.sh, and set the timeouts of theimplementationandproposalhooks to 7200 in both files. Verify withpython3 -m json.toolon both files, and withecho '{"hook_event_name":"Stop","session_id":"manual-check","cwd":"'$PWD'"}' | .agent-hooks/run.sh naming --client claudeprinting{}.
2. Checks, time budget and change verification commands
2.1 Rewrite
run_checksper design.md: start every check in its own process group, kill the group on timeout, and enforce the shared 1800-second total limit on top of the 900-second limit per check. The failure message names the exceeded limit. Make the limits parameters so tests can shrink them. AddRunChecksTest:- a check whose child process outlives the timeout leaves no process behind (
implementation-reviewscenario "A test hangs"); - two checks that each stay under their own limit but together pass the total limit fail with a message naming the total limit, and the second check's process group is gone ("The checks together exceed the total limit").
Verify with the hook test command.
- a check whose child process outlives the timeout leaves no process behind (
2.2 Add the time budget of both full reviews per design.md: 6600 seconds from the hook's start, with checks inside it, and a reviewer job that starts only when the budget still holds its whole limit. A job that cannot start returns the "review time budget ran out" error. Make the budget a parameter. Add tests to
ImplementationGateReviewTestandProposalGateReviewTestwith a shrunk budget and reviewer limit:- a third wave of reviewers does not start, and the turn is blocked with the budget reason (both "Too many reviewers for the budget" scenarios);
- two waves that fit both run ("Two waves of reviewers after slow checks").
Verify with the hook test command.
2.3 Add the change verification parser per the
implementation-reviewrequirement "Which change verification commands the hook runs" and design.md. It reads the firstsh-fenced block under## Change verification, skips empty and comment lines, accepts the three allowed forms with their directories, and checks every argument against the character set. Every error message carries the list of allowed forms. AddChangeVerificationParsingTestwith one test per scenario of that requirement except "Two changes name the same command", plus tests for:just test-packagewith no package;- a package path without
./; - extra arguments after the verification agent's form;
- a
bash-fenced block, which does not count; - an unclosed block;
- an empty block;
- a missing section, which yields no commands.
Verify with the hook test command.
2.4 Make the implementation review parse the sections of every change it reviews before any check, run the de-duplicated commands after the module checks, and block on a parse error or a failing command. Update
test_never_runs_formatters_or_justso thatjustruns only from a change verification block. Add tests toImplementationGateChecksTestfor theseimplementation-reviewscenarios:- "A package test fails": no reviewer runs and the output tail is passed;
- "Backend package tests": the command runs in
backend/; - "Two changes name the same command": the command runs once;
- "The linters pass and the change has no verification commands": reviewers start and no test runs;
- a malformed section, after which no check and no reviewer runs.
Verify with the hook test command.
2.5 Make the proposal review parse the section of each change before
openspec validate --strict, without running its commands, and block on a parse error. Add a test toProposalGateValidationTestfor theproposal-reviewscenario "A forbidden command in the verification section": the turn is blocked, the stubjustis never called and no reviewer runs. Verify with the hook test command.
3. Reviewers and prompts
3.1 Add the
testsrole to the implementation review'sfirst_rolesand a "Role: tests" section toimplementation-prompt.mdper design.md, including the exemption for tests that a module check runs. Rewrite the prompt's opening so it says the hook ran the linters and the change verification commands. Raise by one the reviewer counts that the existing implementation review tests assert (review_gate_test.py:447,:493,:591,:621,:632,:657,:680). Add tests toImplementationGateReviewTest:- a change with two delta specs starts four reviewers (
implementation-reviewscenario "A change with two delta specs"); - the
testsrole's prompt requires checking that a test fails without its behavior, that a bug fix has a reproducing test, that tests wait for conditions instead of fixed pauses, and that the change verification commands cover every package with changed tests that an allowed form runs, with hook tests counted as covered. This covers "A test that waits with a fixed pause", "A bug fix without a reproducing test", "Changed tests outside the verification commands" and "A change with only hook tests".
Verify with the hook test command.
- a change with two delta specs starts four reviewers (
3.2 Extend the tasks role in
proposal-prompt.md. A change whose tasks add or change tests in a backend package, a verification agent package or the frontend needs a## Change verificationsection that covers every such package the tasks' verifications name. Hook tests need no section. Add a test toProposalGateReviewTestthat the task reviewer's prompt requires this and states the exemption. It covers theproposal-reviewscenarios "The task reviewer's role", "Tests without a verification section", "A section that leaves out a package" and "A change with only hook tests". Verify with the hook test command.3.3 Add the testing skill as a reading step to
common-prompt.mdfor work that involves tests, and point the tests line ofdiff-prompt.mdat the skill and the module docs. Verify withgrep -n "skills/testing/SKILL.md" .agent-hooks/common-prompt.md .agent-hooks/diff-prompt.mdfinding both.
4. Testing skill and documentation
- 4.1 Write
.agents/skills/testing/SKILL.mdwith the rules design.md lists, in the repository's skill format withnameanddescriptionfront matter, linking the module docs for stack-specific rules. Create.claude/skills/testing/SKILL.mdas a relative symlink to../../../.agents/skills/testing/SKILL.md. Verify withreadlink .claude/skills/testing/SKILL.mdprinting that target andhead -4 .claude/skills/testing/SKILL.mdprinting the front matter. - 4.2 Add the "Tests" section to the root
AGENTS.md. Replace the shared opening sentence of the "Testing" sections inbackend/AGENTS.mdandagent/verification/AGENTS.mdwith a link to the skill. Add the tasks rule for the## Change verificationsection toopenspec/config.yaml: last section, no checkboxes, onesh-fenced block, one command per line, the three allowed forms, and no section needed for hook tests. Rewrite the comment aboveMODULE_CHECKSto match the new behavior. Verify with these searches:grep -rn "Always run tests after writing them" AGENTS.md backend/AGENTS.md agent/verification/AGENTS.mdreturns nothing;grep -n "Change verification" openspec/config.yamlfinds the rule.
- 4.3 Search the repository for statements the change made untrue and bring them in line per "Documentation consistency". Look for the hook not running tests, the 3600-second full review timeouts, and
python3as the hook command. Verify withgrep -rn "does not run the Go test suites\|never runs here" .agent-hooks AGENTS.md backend/AGENTS.mdandgrep -n "review_gate.py" .claude/settings.json .codex/hooks.jsonboth returning nothing.
5. Change validation
- 5.1 Verify with
openspec validate run-change-tests-in-review --strictpassing, the hook test command passing andjust doctorexiting with code 0.