Repository navigation
feat(minimal): report an edited audit chain in min doctor (T34) - #2603
Conversation
Adds verify_chain, a pure verifier over one segment's bytes, and verify_dir, which runs it across every segment of a log. A Kani harness checks the verifier with a collision-free model of the hash.
min doctor verifies the audit log's hash chain across every segment. It names the record and the segment where the chain breaks, and exits 1.
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
|
Approved: no findings at Nothing to do. Verdict APPROVE, posted as a comment: the App cannot review its own pull request; the check and the label carry it. Clobber: none seen. |
There was a problem hiding this comment.
arch-review: CONDITIONS · 3 conditions · the full ruling
The chain verifier and min doctor are in the places that the design gives them (architecture.md line 501, Gatehouse §6.10 line 836). Three items are open. The new direct read of the audit files says "Interim", but it gives no flip and no issue. Make the change in C1, with the label that box_audit.rs uses. The cli-min.md entry and min doctor -o json (architecture.md line 543) have no issue. File them as C2 says. A segment file that a person deletes reads as pruned, and the log then verifies. Declare that residual as C3 says.
Ruled at cbf75aa against gominimal/arch@109541a48c31 by claude-opus-5-5.
A gap in the segment numbers after a segment without a revocation record cannot come from a prune, which keeps only revocation segments out of order. verify_dir now requires the next segment to carry that segment's head, so a deleted middle segment fails in min doctor.
|
Round 1 of 10 on the runtime's review findings, pushed as
Verify Review threads the coder judged:
Editing one audit record makes Notes from the agent: Revise round 1. The finding asked for a break on every gap after a surviving segment. That rule is too wide: prune keeps an old segment that holds a revocation record and removes the segments after it, so such a gap is a healthy prune. verify_dir now restarts the chain after a gap only when the segment before the gap holds a revocation record. After any other segment, the next segment must carry its head. A deletion directly after a kept revocation segment still verifies, because the log cannot tell it from a prune without an external anchor. The kani harness kani_audit_chain_detects_edit is deferred (lane: kani) and this round did not run it. clippy -p bep --all-targets is clean. |
There was a problem hiding this comment.
arch-review: CONDITIONS · 2 conditions · the full ruling
The compare fixes the middle-segment deletion. The verifier now matches what prune() keeps. Two items are open, and the compare does not touch them. The direct read of the log in min doctor is an interim, but its comment names no issue and no flip. Architecture line 501 puts the un-enrolled read behind the local UDS. Make the change in C1. The PR body also names undone work with no issue: the cli-min.md entry, -o json, and the deferred Kani leg. File the issues in C2.
Outside the diff
crates/bep/src/audit.rs:781: C1 · This interim note names onlymin box audit.min doctornow reads this directory directly too. Name both readers here under the same interim.
Ruled at 5e14eb5 against gominimal/arch@109541a48c31 by claude-opus-5-5.
verify_dir lists each segment where the chain starts again after missing segments, so a caller can say so. Only a parsed revocation record now excuses a gap. The doc comment states the prune-or-delete residual.
When files before a segment are missing, min doctor names the segment and says the check cannot tell a cleanup from a deletion. The interim direct read now names its flip and its issues.
…edited-audit-chain-in-min-doctor
There was a problem hiding this comment.
minimal-review — approval withheld
Verdict COMMENT — APPROVE withheld: 9 unresolved threads — minimal-foundry[bot] crates/bep/src/audit.rs:861, minimal-arch[bot] crates/minimal/src/cmd/doctor.rs:68, minimal-arch[bot] crates/minimal/src/cli.rs:104, minimal-arch[bot] crates/bep/src/audit.rs, minimal-foundry[bot] crates/bep/src/audit.rs:861, …. No findings.
Panel: 3 of 3 personas ran (correctness, security, supply-chain).
|
Round 2 of 10 on the runtime's review findings, pushed as
Verify Review threads the coder judged:
Edit one record of the audit log, and Notes from the agent: Deferred: |
There was a problem hiding this comment.
arch-review: PASS_WITH_CONDITIONS · 2 conditions · the full ruling
The change conforms to architecture.md line 501 and Gatehouse §6.10 line 836. min doctor verifies the whole audit log and is not an audit flag. The compare closes the gap and restart cases, and the direct read is now an honest interim with #2459 and #2463. Two items have no owner. C1: file an issue for the cli-min.md entry and the rest of the line-547 min doctor surface, and link it. C2: run the Kani harness, or file an issue for it and link it.
Ruled at 5b65cec against gominimal/arch@109541a48c31 by claude-opus-5-5.
…edited-audit-chain-in-min-doctor Rename the per-segment verifier to verify_segment, because main now owns verify_chain over a directory. verify_dir follows quarantine records across a gap through verify_segments.
Name the file-mode read, the arch#137 ruling and both issues as cmd_box_audit does. Give the test decision the jti field main added, and format the merged audit.rs.
|
A merge of main before round 3, not counted against the cap (1 of 3), pushed as Resolved conflicts in:
Verify Review threads the coder judged:
After the merge with main, an edit of one audit record still makes Notes from the agent: Conflict round. The merge with main conflicted in crates/bep/src/audit.rs. Main added verify_chain(dir), so this branch's byte-level verify_chain(start, contents) is now verify_segment, and verify_chain_with is now verify_segment_with. The kani harness and the proptest use the new names. The harness count in scripts/kani.sh stays at bep 11. The merge took main's holds_revocation (classify), and bytes_hold_parsed_revocation now uses classify too. A record of an unknown kind does not excuse a gap. An edit of |
There was a problem hiding this comment.
arch-review: PASS · the full ruling
The compare conforms, and the change keeps its standing against architecture line 501 and Gatehouse §6.10 line 836. The interim note in cmd_doctor now names the file-mode read, gominimal/arch#137, the interim issue #2459, the flip and the end issue #2463, as min box audit does. The merge moves the quarantine bridge into verify_dir through main's verify_segments. A deleted segment with no quarantine record still breaks the chain. The deferred Kani leg is still open. Run it in the kani lane before you rely on the T2 harness.
Ruled at cc6bd35 against gominimal/arch@109541a48c31 by claude-opus-5-5.
A log whose oldest files are missing no longer prints "chain verified." first, and an empty remainder no longer reads as "no records yet.". The exit stays 0, because a prune also removes old files (T34).
There was a problem hiding this comment.
arch-review: PASS · the full ruling
This push changes only the output of min doctor for an audit log with missing files. The first line no longer says "chain verified." for that log. The design puts whole-log chain verification in min doctor (architecture.md line 501, Gatehouse §6.10 line 836). It does not give the wording for this case. The PASS on cc6bd35 stays in effect for this head.
Ruled at 6e1317e against gominimal/arch@109541a48c31 by claude-opus-5-5.
|
Round 3 of 10 on the runtime's review findings, pushed as
Verify Review threads the coder judged:
Editing one audit record makes Notes from the agent: Revise round 3. Changed only crates/minimal/src/cmd/doctor.rs. A log with restarts now has its own first line, and the restart arm comes before the no-records arm. The line "min removes old audit files..." prints once, not once for each restart. The exit code stays 0 for missing files on purpose: prune() removes old segments in normal use, and verify_dir cannot tell a prune from a deletion (the documented BEP-049 residual). A non-zero exit would fail every log that rotated past its bound. The test now also covers an empty file left past the gap. Deferred: cargo nextest run -p bep kani_audit_chain_detects_edit (lane: kani), not run on this box. |
A corrupt line or a record of an unknown kind keeps its segment in a prune. When the line has a successor in its segment, the chain checks its bytes, so verify_dir now counts it as prune does. The last line of a segment still counts only as a parsed revocation.
There was a problem hiding this comment.
arch-review: PASS · the full ruling
The compare changes one function in crates/bep/src/audit.rs. A corrupt or unknown-kind line now excuses a pruned gap only when a successor in its segment carries its hash. This makes verify_dir agree with prune, and the chain still checks every byte that counts. The last line of a segment still counts only as a parsed revocation, so an edit that nobody recomputed cannot hide a gap. This conforms to the whole-log, hash-chained audit check in architecture.md line 501 and Gatehouse §6.10 line 836.
Ruled at 42d10f0 against gominimal/arch@109541a48c31 by claude-opus-5-5.
|
/revise Close arch conditions C1 and C2 from the ruling at
Generated by Claude Code |
…edited-audit-chain-in-min-doctor
min doctor exited 2 when audit files were missing. A prune leaves a restart on every healthy host, so that failed a healthy host, and 2 is the usage-error code. A broken chain is a verification failure, which the design gives exit 6, not 1.
There was a problem hiding this comment.
arch-review: PASS · the full ruling
The compare fixes the exit codes. A broken chain now exits 6, the verification-failure code in the architecture exit-code table. Missing audit files no longer take the usage-error code 2. They exit 0, with their own first line. The design gives no code for that case, and a deletion that prune cannot make still exits 6. BEP-049 conforms. Update the PR body: it says 11 kani harnesses, and the head has 12.
Ruled at b6f0cc4 against gominimal/arch@109541a48c31 by claude-opus-5-5.
|
Round 1 of 10 on a /revise note, pushed as
Verify Review threads the coder judged:
When a person edits one audit record, Notes from the agent: Revise round 1: C1 and C2 are closed. Outcome::FilesMissing now returns Ok(()) (exit 0) and Outcome::Broken returns TaskExit(6). The first stdout line and the files_missing log field did not change. The doctor.rs comments, the cmd_doctor doc comment, the Doctor doc in cli.rs and the test comment now say: missing files exit 0, a broken chain exits 6, a verified chain exits 0. The directive also asks to change the PR body Proof line from |
norrietaylor
left a comment
There was a problem hiding this comment.
Babysitter review at b6f0cc49. I read crates/minimal/src/cmd/doctor.rs and the Doctor help in crates/minimal/src/cli.rs against T34's plan block and the arch ruling. run returns Outcome { Verified, FilesMissing, Broken }. cmd_doctor exits 0 for a verified chain and for missing files, and 6 for a broken chain through TaskExit(6). That follows the design's exit-code table: 2 is a usage error, 6 is a verification failure, and a pruned host must not fail a min doctor -q gate. The first stdout line and the files_missing log field still tell missing files apart. The tests pin the missing-segment and edited-record outcomes, and the doc and test comments agree with the code. The PR body's Proof line now says exit 6. The LOW verify_dir finding (an emptied oldest segment) traces to the same result as deleting that segment, the documented T31 residual, and the owner accepted it unfixed. No further findings.
Generated by Claude Code
|
/revise Fix the open MEDIUM security thread 4382889358 on
Generated by Claude Code |
…edited-audit-chain-in-min-doctor
quarantine_bridges accepted any verify_segments error past line 1 of the segment after the gap. Now an error bridges the gap only when quarantine records that agree with their moved segments lead the chain across it.
There was a problem hiding this comment.
arch-review: PASS · the full ruling
This head conforms. The new commit changes only quarantine_bridges in crates/bep/src/audit.rs. A chain error now bridges a missing segment only when matched quarantine records lead the hash across the gap. Otherwise min doctor reports the break. This fails closed and keeps the whole-log check that architecture.md line 501 and Gatehouse §6.10 line 836 require. The merge of main does not change the min doctor wiring.
Ruled at 225ecae against gominimal/arch@109541a48c31 by claude-opus-5-5.
|
Round 2 of 10 on a /revise note, pushed as
Verify Editing one audit record makes Notes from the agent: Revise round 2 addresses the /revise note for thread 4382889358. quarantine_bridges now returns true only when verify_segments succeeds, or when gap_bridged shows quarantine records lead the chain across this gap: each record sits in the segment after the gap or later, names a segment numbered between the two, and agrees with that file under quarantine/ (moved_segment_matches), from the hash before the gap to the previous_hash after it. Any other Err bridges nothing. New test deleted_segment_with_error_past_the_gap_still_breaks deletes segment 1, puts an unrelated file under quarantine/, and makes the verify_segments error sit in a later segment. It asserts quarantine_bridges returns false (the old code returned true here) and verify_dir reports the break. In this scenario the old verify_dir still reported the break through its re-verify, so the direct quarantine_bridges assertion is the one that pins the fix. The directive gave no thread handles under an Unresolved threads section, so threads is empty and I cannot post the reply on the thread myself. The commit is 225ecae. Deferred: cargo nextest run -p bep kani_audit_chain_detects_edit (lane: kani), not run. |
norrietaylor
left a comment
There was a problem hiding this comment.
Babysitter review at 225ecaea. Since my review at b6f0cc49 this head merges main and fixes the MEDIUM security thread on quarantine_bridges (crates/bep/src/audit.rs), as the owner ruled. A verify_segments error now bridges a gap only through gap_bridged: quarantine records must chain from the hash of the last line before the gap to the previous_hash of the first line after it, and each record must agree with its moved segment under quarantine/ and be numbered between the two segments. Any other error bridges nothing, so the break reports (BEP-049). deleted_segment_with_error_past_the_gap_still_breaks pins the case the finding described. The min doctor exit codes and audit lines are unchanged from my earlier review. No findings.
Generated by Claude Code
norrietaylor
left a comment
There was a problem hiding this comment.
Babysitter approval at 225ecae: every merge gate passes at this head (arch PASS at 225ecae, zero open threads, every lane aggregator green). Squash title feat(minimal): report an edited audit chain in min doctor (T34) and the squashed message pass commitlint. Queued for squash merge.
Generated by Claude Code
|
/revise Find why
Generated by Claude Code |
|
Round 3 of 10 on a /revise note: the coder changed nothing. The runner already merged origin/main (3bf8275) into the branch as 4a795630, so this round adds no commit. Investigation of minimald exec::tests::a_trickle_reader_fed_one_byte_chunks_is_still_ended: the branch does not cause it. Alone and sequential, 80 runs per tree: HEAD 4a795630 failed 5 of 80, and origin/main 3bf8275 in a worktree failed 6 of 80. All failures were at the 5.01 s timeout. The exec::tests module (end_to_end left out, because it takes more than 2 min) at --test-threads 4 (4 cores here, the nextest default of one thread per core), 10 runs per tree: HEAD 0 of 10, main 1 of 10. Passing runs on both trees spread from about 0.5 s to 4.95 s against a 5 s timeout, so the test is flaky on main itself. The branch does not change crates/minimald or Cargo.lock. Its bep change is pure audit-chain functions that the exec input path does not call. The flake came in with #2625 (5eaef06): the trickle feeder and reader both sleep 50 ms per byte, and the time to reach the …[truncated] |
T34 — Report an edited audit chain in min doctor
slice: S5
kind: task
covers: BEP-049
size: M
est: 220 code, 180 tests
executor: agent
difficulty: needs care
model: standard
diagnostics: the chain check prints "Audit log: the hash chain breaks at record of ; a record was changed or removed." or "Audit log: chain verified." on stdout, pinned by prop_audit_chain_detects_unrecomputed_edit
observability: one info log line per check naming the segments verified and the outcome
layers:
- verify:
- crates/bep/src/audit.rs: chaining and verification as pure functions over bytes, apart from the writer
- scripts/kani.sh: the added harness's count
test: cargo nextest run -p bep prop_audit_chain_detects_unrecomputed_edit
test (deferred: kani): cargo nextest run -p bep kani_audit_chain_detects_edit
- cli:
- crates/minimal/src/cli.rs:
min doctor- crates/minimal/src/cmd/mod.rs: dispatch and module line
- crates/minimal/src/cmd/doctor.rs (new): runs the audit chain check across every segment
test: cargo nextest run -p minimal doctor_reports_a_broken_audit_chain
produces:
- crates/minimal/src/cmd/doctor.rs (entry point)
consumes: none
proof: Editing one audit record makes
min doctorname where the chain breaks.depends on:
- blocked by #2290
Proof
A person who edits one record of the audit log under ~/.minimal/bep/audit and runs
min doctorseesAudit log: the hash chain breaks at record <n> of <segment>; a record was changed or removed.The command exits 6. An unedited log printsAudit log: chain verified.Notes from the agent: Deferred:
cargo nextest run -p bep kani_audit_chain_detects_edit(lane: kani). The harness is in#[cfg(kani)] mod kani_proofsin crates/bep/src/audit.rs, and scripts/kani.sh now expects 11 bep harnesses. I did not run it. A bounded check cannot prove SHA-256 free of collisions, so the verifier is generic (verify_chain_with) and the harness passes a model hash that is collision-free over the lines it builds. The harness uses unwind 70 over 4 records of up to 64 bytes. It is untested, and the lane can need a tighter bound or more unwinding.Behaviour: the reported record is the first one whose
previous_hashdoes not match. For an edited record, that is the record after it. A segment whose previous segment number is gone (pruned) starts the chain again from its own first record. Segment 0 must start at the zero hash. A broken chain exits 6 throughTaskExit(6), the design's verification failure, and missing audit files exit 0. main.rs (outside the layers) prints nothing for that error. I added a third line that the task does not fix,Audit log: no records yet., for an empty or missing log, so thatchain verifiedis never a claim about zero records.Printed text: the task fixes the broken-chain wording, and I copied it exactly. It contains a semicolon, which the house rule for printed text does not allow.
Not done: docs/reference/cli-min.md has no
min doctorentry because it is outside the layers. A follow-up must add one. I did not runjust clippy-strict.Tests
cargo nextest run -p bep prop_audit_chain_detects_unrecomputed_editcargo nextest run -p minimal doctor_reports_a_broken_audit_chainVerify
min task run agent-verifyexited 101 under rustc 1.98.1, which the repository does not pin (1.99.0 in rust-toolchain.toml); the PR is not a draft on that alone — CI, which honours the pin, is the gate.Deferred
The plan marked these test lines deferred: the executor lacks the lane, so nothing here ran them and they still owe evidence.
cargo nextest run -p bep kani_audit_chain_detects_editCloses #2293
Generated by Claude Code