Repository navigation
fix(agent): align record_turn detection view with the record view - #94
Merged
Merged
Conversation
record_turn detected changes via status() against the repo's current_view but applied them to session.view_name. The real agent hook flow switches current_view at session start, so production is unaffected — but direct callers that bypass session start (the noname ACP→TurnOrchestrator bridge, tests) leave detection on `dev` while apply targets the session view. A turn whose net effect is invisible from `dev` (deleting the last file recorded on the session view) then early-returns EmptyTurn and silently drops the turn. Fix: align detection with the record view in two places — - before the first status() on the read-only handle, in memory only via the new Repository::set_current_view_in_memory (no txn/lock/disk write, so the read-only anti-hang fast path is preserved); - on the write handle, the persisting set_current_view now tolerates ViewNotFound (first turn) but propagates DB/write failures as RecordFailed instead of swallowing all errors. record()'s filter/apply already used session.view_name, so provenance and attestation landing are unchanged; attestation coverage improves because turns 2..N stop being skipped. Sole production caller (turn.rs) is a no-op in the real flow. Adds modify + delete-only regression tests (the delete-only case is what actually reproduces the bug). Documents a known adjacent racy-mtime hazard in the no-hash status fast path, left unfixed by design.
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.
What
Fixes a
record_turn()view mismatch bug.Before this PR,
record_turn()could detect file changes using one view, but record the change onto a different session view.That could make Atomic think there was no change and return
EmptyTurn, even though files changed.Why
I found this while validating the Sherpa/noname ACP integration.
The normal hook lifecycle usually sets the view correctly first, but direct callers and fallback paths should still be safe.
record_turn()should be internally consistent: it should detect changes on the same view it records to.Testing
Added regression tests for direct
record_turn()callers using a session view.Verified with:
cargo fmt --checkcargo clippy -p atomic-agent -p atomic-repositorycargo test -p atomic-agent --test record_view_mismatch_regressioncargo test -p atomic-repository repository::tests::view_tests