Repository navigation
A file is no longer trusted when a run line starts while the person is asked to trust it - #3592
Merged
Merged
Conversation
read_file drew a preview, asked the person, and spent a yes only if the path's revision was unchanged. A program opens files its line does not name and moves no revision, so a yes given while a run line started was spent on a file the program may have rewritten after the person read it, and the next read returned those bytes as trusted text. TRUST-4 says an approval based on a preview cannot be spent after the path changed, and the same stamp already guards the write-back exception in WRITE-4. FileCapture::stamp_of returns the path's Stamp (revision and count of run lines started). read_file takes it beside the preview, and Policy::vouch_if_unchanged compares it whole, as numbers only. A refused vouch is reported as before. Tests: a core test starts a program while the question is open and checks the vouch is refused with revision unmoved; a read_file test does the same through dispatch, with a control that spends the yes when nothing started. TRUST-4 and its verified-by lines name them. Closes brave#3578
netzenbot-reviewer
approved these changes
Oct 30, 2026
bbondy
approved these changes
Oct 30, 2026
bbondy
approved these changes
Oct 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3578
User impact: a file that a
runline may have rewritten while the person was asked to trust it is no longer trusted by that yes; the read says the file changed while the person was being asked, and the file stays untrusted.Decisions to confirm
read_filevouch, and the write sites need their own tests. Commit: A vouch is refused when a run line started after the preview was drawn. To reverse: move the write and edit approval sites tostamp_ofand reword the paragraph. The write approvals are tracked in TRUST-4: a write or edit approval is checked against the path revision alone, so a run line started during the question is not detected #3586.The problem
#3578 A vouch is checked against the file's revision alone. A
runline that starts while the person is asked whether to trust a file can rewrite it without moving the file's revision, because a program opens files its line does not name. The yes was spent on the new bytes, which the next read returned as trusted text.Reproduce
The path needs a delegate running a
runline beside the parent turn while the vouch question is open, so the test is the reproduction.crates/core/src/policy.rs, capturestamp_of("vendor/lib.js")insidecapture_files, as the preview is drawn.note_program_started()on the policy's file authority.vouch_if_unchanged("vendor/lib.js", stamp).Before the change the call returns true and the path becomes trusted. After it, the call returns false, the path stays untrusted and the trail says the file changed while the question was being answered.
cargo test -p bravebot-core a_vouch_is_not_spent_after_a_program_startedcovers it and fails on the parent commit.The fix
#3578.
read_filetakes the path's stamp (its revision and the number ofrunlines started) beside the preview, andvouch_if_unchangedcompares the whole stamp as numbers. Anyrunline that starts during the question voids the yes, and the planner gets the existing "changed while the user was being asked about it" result. TRUST-4 states this and names the new tests.Test plan
BRAVEBOT_ALLOW_UNCONFIGURED_BUILD=1 make check-affectedwithulimit -n 10240, on 05df365 and then d693351, before the final rebase: all recipes passed except the two below. The default limit of 256 abortscrates/cli/tests/running.rswithToo many open files.agents/renumbered-clauses.txt,docs/specs/README.mdanddocs/specs/backends.md, none of which reach the diff. On that treecargo check --workspace --all-targets --locked,cargo fmt --all --check, both new tests andmake check-specpassed.bravebot_core::policy::a_vouch_is_not_spent_after_a_program_started_while_the_question_was_open: rejects a vouch compared on the revision alone; demonstrated on this tree by makingStampequality compare only the revision, which fails it with "an answer was spent on a file a program may have rewritten since it was shown".bravebot_agent::tools::a_yes_is_not_spent_when_a_program_started_while_the_person_was_asked: rejects taking the stamp after the answer, and a read that never vouches (a control case with no program started trusts the file); demonstrated by taking the stamp after the answer, which fails it with "a yes was spent on a file a program may have rewritten". It was not mutated to a revision-only comparison at this level; the core demonstration covers that.a_vouch_for_the_version_shown_is_spent_on_itanda_vouch_is_not_spent_on_a_version_nobody_was_shownnow pass aStampand pass;only_the_path_a_slot_was_read_from_is_a_write_that_changes_nothingstill passes.check-msrv,check-windowsandcheck-linuxare named by the affected-checks script butdockeris not installed on the machine that ran the gates.Failures that are not from this change
check-implement-issues-selftest:test_the_make_target_passes_the_notes_throughtimes out after 60 s whenBRAVEBOTis exported, on upstream/main as well. Tracked in The implement-issues selftest test_the_make_target_passes_the_notes_through hangs when BRAVEBOT is set in the environment, so make check-affected fails for anyone who has it exported #3591.check-specfailed on d693351 withBACKEND-66appearing twice indocs/specs/backends.md, on upstream/main as well (BACKEND-66: check-spec fails on main because the clause id appears twice in docs/specs/backends.md, so a required check is red #3585). Upstream fixed it in c8164c1 andmake check-specpasses on the final tree.runline started during their question is not detected. This change finds it and does not fix it; it is tracked in TRUST-4: a write or edit approval is checked against the path revision alone, so a run line started during the question is not detected #3586.