Repository navigation
Fix edit_file spec mismatches and test coverage gaps - #254
Merged
Merged
Conversation
… the request The ordering assertion added for EDIT-4 passed against the very code it was written to catch. `second` is the whole request body, and that body carries the planner's own call as well as the result: its `new_text` argument is `CHARLIE`, so `find` matched that copy and never reached the one in the excerpt. The comparison held whichever way round the result itself was assembled, which is what `docs/best-practices/tests.md` TS-003 asks a new test be run against the unfixed code to catch. The unit test in `tools.rs` had been the one check that did pin the order, and the same change relaxed it from `starts_with` to `contains`. So with the turn assertion vacuous, nothing in the suite said where the count goes, which is the gap brave#169 was filed over. Read the order inside the result instead, splitting the body at the `Result of edit_file:` preamble the tool result opens with, and assert at unit level that the headline is last. Both fail against `{headline}\n\n{excerpt}` and pass against the fix. The other three assertions in that test move to the same slice, because `contains("CHARLIE")` was satisfied by the echoed call too. The two new refusal tests gained the doc comment the house style asks for, saying why the property matters rather than restating the body.
bbondy
approved these changes
Sep 12, 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.
Resolves #169.
Summary of Changes
This PR addresses the three coverage and behavior mismatches identified under
docs/specs/tools/edit-file.md:EDIT-4(Excerpt before replacement count):edit_filereturn output incrates/agent/src/tools.rsso the formatted excerpt comes before the replacement count headline (format!("{excerpt}\n\n{headline}")).an_edit_shows_the_lines_it_changedverifying the changed lines appear before1 replacement(s).tools.rsto reflect the new ordering.EDIT-1(Refusals pinned at turn level):an_edit_of_a_missing_passage_is_refusedundertrusting_the_workspace()with an Ask permission rule, asserting both that refusal diagnostics are returned to the planner and that the approval prompt is never reached.a_stale_edit_is_refusedassertingWorkspaceError::Stalediagnostics when the file changes between read and write.an_ambiguous_edit_is_refused_without_askingto run undertrusting_the_workspace()with an Ask rule, asserting that the ambiguity diagnostic is returned and that no approval prompt was presented.verified-by:entries indocs/specs/tools/edit-file.mdfor bothan_edit_of_a_missing_passage_is_refusedanda_stale_edit_is_refused.EDIT-3(Diff review and refusal behavior):an_edit_is_reviewed_as_a_diffto require write approval via permissions rules, verifying thatWriteRequestcarriesIntent::Editandexisting: Some(...).a_refused_edit_does_not_happento ensure the edit reaches the confirmer undertrusting_the_workspace(), confirming rejection prevents writes.Verification
cargo fmt --all -- --checkpasses cleanly.cargo clippy -p bravebot-agent --all-targets -- -D warningspasses with 0 warnings.cargo test -p bravebot-agent --test turn editpasses all 13 tests.python agents/skills/check-spec/check-spec.py --mechanical-only edit-filereports 0 errors and 0 warnings.