Skip to content

fix(proof): harden the proof runner against the gaps review found - #92

Merged
TusanHomichi merged 8 commits into
mainfrom
claude/80-proof-hardening
Oct 14, 2026
Merged

TusanHomichi merged 8 commits into
mainfrom
claude/80-proof-hardening

Conversation

@TusanHomichi

@TusanHomichi TusanHomichi commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Primary Issue

Refs #80 (closed by #82). This follow-up fixes the review findings on #82's final commit, plus the findings raised on this PR as it went.

Problem And Outcome

scripts/proof.py could produce receipts that overstated what ran or what was checked. After this PR, each gap below fails closed or keeps its evidence.

Changes

Parsing the gate sequence

  • Exactly one CONSOLEBOOK_E2E_CHROMIUM= alternative is required, and it must invoke the suite.
  • Gate lines are lexed with shlex, so quotes and # comments are honored and an unreadable line is refused. Lines split only at &&. A browser step must contain a command that is exactly npm run e2e, so echo npm run e2e, | true, || true, ; true and : # ; npm run e2e are refused.

Runtime evidence for the browser suite

  • Parsing cannot prove a line reaches the suite (exit 0 && npm run e2e). So the runner points CONSOLEBOOK_E2E_REPORT into the receipt directory, and web/playwright.config.ts adds a JSON reporter when that variable is set.
  • The step passes only with that report, at least one expected test, and no unexpected results. The counts and the report hash go into the receipt.

Candidate state

  • Reads git status --porcelain=v1 -z, so non-ASCII names are hashed under their real names.
  • Rename and copy sources are folded from either status column, including worktree renames.

Interruption

  • Each step leads its own process group. Stopping it sends SIGTERM, then SIGKILL after STOP_GRACE_S, so no child can write after the receipt is taken.
  • During a run, SIGINT and SIGTERM share one handler that raises only once and absorbs repeats, so a second signal cannot preempt cleanup.
  • Finalization holds both signals until the receipt is written, and the previous handlers are restored afterwards.

Threat model, now in the module docstring: the runner catches honest drift. It trusts the reviewed gate definition and code; it cannot authenticate a gate written to deceive it, and the receipt records CONTRIBUTING.md's hash.

Correction rung: 2 (mechanical). Each fix has a --self-test control, and each control was mutation-checked by reverting its fix and watching it fail.

Scope

  • In scope: scripts/proof.py, the reporter hook in web/playwright.config.ts, and the receipt description in .agents/skills/consolebook-proof/SKILL.md.
  • Out of scope: everything else.

Verification

Candidate revision: 1e07ef5.

  • Local full gates passed. 7/7 steps, permission-bypass capabilities dropped, system Chromium. Tree b094731d7d1f, unchanged during the run. The browser suite reported 57 expected, 0 unexpected, report sha256 346e70c8…. receipt.json sha256 8cea762982be3cde7e1d307a1210fda9ffb4b626030f74c7de258b792d6c77e8.
  • Live interrupt. A SIGTERM sent to a real run mid-browser-suite left an interrupted receipt, and no Playwright, Chromium or server processes survived.
  • Hosted: fmt-clippy-test passed on 1e07ef5.
  • Automated review: clean on 1e07ef5. One finding, a forged report written by a deceptive gate line, is declined under the threat model above and left open for the maintainer.
  • Added or updated tests when behavior changed
  • ADR: not applicable

Review And Merge Notes

  • Review focus: stop_group and _interrupt, and the e2e_evidence contract with the Playwright config.
  • Review performed: self-review, plus six rounds of automated review.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TsvZjbz8dTRM8A1NqAP5ts


Generated by Claude Code

- Refuse a gate section without exactly one system-browser alternative;
  only --chromium runs noticed a missing one.
- Recognize the browser suite as an invocation (`npm run e2e` as one
  shell command, after any NAME=value assignments), not a substring, so
  `echo npm run e2e` cannot stand in for it.
- Read `git status -z`, so untracked names with spaces, quotes, or
  non-ASCII characters are hashed under their real names instead of
  git's quoted display text (which made changes to them invisible).
- Treat SIGTERM like Ctrl-C for the run, so a cancelled CI job or
  stopped container still leaves an interrupted receipt; termination is
  ignored while the receipt is written and the previous handler restored.

--self-test covers each, and reverting each fix fails it.

Refs #80

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TsvZjbz8dTRM8A1NqAP5ts
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-14T18:16:56.113019Z 1e07ef5 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d5e85be59f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/proof.py Resolved

Copy link
Copy Markdown
Member Author

Local proof receipt: passed (d5e85be)

All 7 gates passed, with the permission-bypass capabilities dropped and system Chromium 141:

Step Seconds
guard 0.0
web check + build 21.3
fmt 0.5
clippy 4.3
cargo test 164.5
build 0.4
browser suite (56) 354.5

Generated by Claude Code

Splitting on && || ; by hand accepted `: # ; npm run e2e`, which sh
reads as a comment. Lex with shlex (quotes and comments honored; an
unreadable line is refused) and split commands only at &&, so any other
operator stays inside its command and can never equal the marker.

Refs #80

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TsvZjbz8dTRM8A1NqAP5ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 659cb56056

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/proof.py Resolved
Comment thread scripts/proof.py Resolved
A SIGTERM during a step terminated only the outer sh, so subshells,
npx, or test servers could keep writing after the runner snapshotted
the candidate. Each step now leads its own process group, which is
sent SIGTERM and then SIGKILL before the receipt is written.

git status reports a worktree rename of an intent-to-add file in the
Y column; only X was checked, so its source path was parsed as a
record and the next entry was swallowed as the source. Both columns
are checked now.

Self-test cases cover both; each fails against the previous code.

Refs #80

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TsvZjbz8dTRM8A1NqAP5ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3e14b05685

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/proof.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f5b81243e5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/proof.py Resolved
The parser cannot prove a shell line reaches the suite: `exit 0 && npm
run e2e` reads as an invocation and exits 0 without running anything.
Rather than chase each shell construct, the runner now points
CONSOLEBOOK_E2E_REPORT into the receipt directory, the Playwright
config adds a JSON reporter when it is set, and the browser step passes
only when that report exists with at least one expected test and no
unexpected ones. The counts and report hash go into the receipt.

Self-test: the unreachable-suite line, a zero-test report, and a
passing report; disabling the check fails four cases.

Refs #80

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TsvZjbz8dTRM8A1NqAP5ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bc6fc91296

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/proof.py
Comment on lines +368 to +376
stats = json.loads(report.read_text())["stats"]
counts = {k: int(stats[k]) for k in ("expected", "unexpected", "flaky", "skipped")}
except (OSError, ValueError, KeyError, TypeError) as e:
return None, f"the browser suite's report is unreadable: {e}"
evidence = {"report": report.name, "sha256": sha256_file(report), **counts}
if counts["expected"] < 1:
return evidence, "the browser suite ran no tests"
if counts["unexpected"]:
return evidence, f"the browser suite reported {counts['unexpected']} unexpected results"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Prevent forged reports from passing the browser gate

A gate line such as printf '{"stats":{"expected":3,"unexpected":0,"flaky":0,"skipped":0}}' > "$CONSOLEBOOK_E2E_REPORT" && exit 0 && npm run e2e is recognized by runs_e2e, exits successfully before invoking Playwright, and is accepted here as a passing suite report. The new self-test at lines 595–605 explicitly reproduces this false pass, so an edited CONTRIBUTING.md can again produce a receipt claiming browser verification that was never run. Do not treat JSON at an environment-exposed, gate-writable path as evidence that the suite executed.

AGENTS.md reference: AGENTS.md:L93-L95

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not fixing this one; it's outside what a local runner can defend. The path you describe needs a gate line in CONTRIBUTING.md written to forge evidence. Anyone who can land that edit can also edit scripts/proof.py, web/playwright.config.ts, the e2e npm script or the specs. A child process the runner executes can always write whatever bytes the runner would accept, and no check of those bytes can authenticate them. The self-test at those lines is a fixture standing in for Playwright; it is not a demonstration of a gap.

The report check targets honest drift, which it does catch:

  • a suite that finds zero tests (wrong testDir, a stray --grep);
  • an e2e script that no longer runs Playwright;
  • a failure masked by || true;
  • a line that never reaches the suite.

c36bf17 (pushed right after this reply) writes that threat model into the module docstring. It says what the runner trusts and that the receipt records CONTRIBUTING.md's hash, so review sees which definition ran. Future reviewers and agents can then weigh deliberate-forgery findings against it instead of growing the parser.


Generated by Claude Code

Comment thread scripts/proof.py Resolved
A second SIGTERM during stop_group's grace period raised out of it
before the SIGKILL pass, so a TERM-ignoring child could outlive the
receipt. The SIGKILL pass now runs in a finally with SIGINT and SIGTERM
held until the group is reaped. A self-test case sends the runner two
SIGTERMs from a TERM-ignoring step; the previous code fails it.

The module docstring now says what the runner defends against (honest
drift) and what it trusts (the reviewed gate definition and the code it
runs), so a gate written to deceive the runner is not chased as a
parser bug.

Refs #80

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TsvZjbz8dTRM8A1NqAP5ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c36bf17c06

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/proof.py Resolved
Comment thread scripts/proof.py Resolved
Finalization ignored only SIGTERM, so a second Ctrl-C after an
interrupted gate raised during candidate_state or artifact collection
and left the receipt directory with only step logs. Both signals are now
blocked while the receipt is finalized and delivered once it is written.
A self-test case sends a second SIGINT from inside finalization; the
previous code leaves no receipt.

Refs #80

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TsvZjbz8dTRM8A1NqAP5ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3e6502da5c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/proof.py Resolved
Masking signals inside stop_group left a few-instruction window between
the grace-period wait and the mask in which a second Ctrl-C or SIGTERM
could raise before the SIGKILL pass. Rather than narrow windows one at
a time, the run's SIGINT and SIGTERM handler now raises once and absorbs
repeats, so no repeat can preempt the cleanup the first one started.
stop_group drops its own mask; the grace period becomes STOP_GRACE_S.

Self-test: the handler raises once and absorbs the next call (removing
the absorb fails it), both previous handlers are restored, and a
TERM-ignoring step that signals the runner twice cannot write after the
grace period.

Refs #80

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TsvZjbz8dTRM8A1NqAP5ts
@TusanHomichi TusanHomichi changed the title fix(proof): close four gaps the #82 review found after merge fix(proof): harden the proof runner against the gaps review found Oct 14, 2026
@TusanHomichi
TusanHomichi merged commit 2e69769 into main Oct 14, 2026
1 check passed
@TusanHomichi
TusanHomichi deleted the claude/80-proof-hardening branch October 14, 2026 18:32
TusanHomichi pushed a commit that referenced this pull request Oct 14, 2026
Brings #89's latest state (probe follows the bind, release workflow on
every pull request, ADR 0023 for the installation lifecycle, and main
through #92) into this branch.

- release.yml: the upgrade step keeps both the backup warning check and
  the move to 127.0.0.2:7771.
- The backup ADR becomes ADR 0024, since the installer ADR took 0023;
  every reference is renumbered, and ADR 0024 cites ADR 0023 for the
  unit's writable paths.
- ADR 0023 now records --data-dir, --backup-dir, and the paths.conf
  drop-in this branch adds.

Refs #90

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TsvZjbz8dTRM8A1NqAP5ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants