Skip to content

feat: bridge stow sweeps across Claude compaction - #55

Open
ruby-dlee wants to merge 7 commits into
mainfrom
fm/precompact-stow-bridge-s2
Open

feat: bridge stow sweeps across Claude compaction#55
ruby-dlee wants to merge 7 commits into
mainfrom
fm/precompact-stow-bridge-s2

Conversation

@ruby-dlee

@ruby-dlee ruby-dlee commented Jul 31, 2026

Copy link
Copy Markdown
Owner

Intent

Close the Claude context-compaction knowledge gap by making compact-sourced recovery require a scoped stow sweep over the lost transcript, with durable acknowledgement that cannot silently skip unswept conversation.

What changed

  • Capture the pre-compact transcript path and end byte without adding network calls or weakening atomic anchor publication.
  • Inject an actionable recovery directive that names the unswept byte slice and points to the stow skill as the routing owner.
  • Advance the durable marker only through mark-stowed with immutable transcript/boundary arguments and compare-and-swap checks. A stale sweep or changed marker fails closed and leaves the newer boundary pending for re-sweep.
  • Serialize capture and acknowledgement with a crash-safe kernel-released lock.
  • Preserve exit-2 anchor failure blocking, fail-open sweep recovery, non-Firstmate and unmarked-worktree inertness, and valid secondmate scope.
  • Tighten AGENTS.md and docs/autocompact-recovery.md, including a real Claude Code 2.1.220 compaction transcript.

Targeted verification

bash tests/fm-autocompact.test.sh passed all 15 checks:

  1. Tracked Claude settings register both compaction phases without disturbing existing hooks.
  2. PreCompact atomically refreshes all durable pickup surfaces.
  3. The tracked hook is a silent no-op in a crewmate worktree.
  4. Scope excludes non-Firstmate repositories while preserving valid secondmate homes.
  5. An in-scope capture failure blocks compaction instead of silently losing the anchor.
  6. Capture and compact recovery preserve durable context without jq.
  7. Every intermediate render failure blocks partial anchor publication.
  8. Compact SessionStart injects a scoped stow directive, re-reads the anchor, and reconciles durable state.
  9. The durable marker advances only after acknowledgement and suppresses duplicate transcript sweeps.
  10. A stale sweep acknowledgement fails closed and leaves the new boundary pending.
  11. The kernel-released lock recovers stale state and interrupted owners.
  12. Missing and corrupt stow markers fail open to a whole-context sweep.
  13. An unreadable transcript fails open to recovered context without blocking recovery.
  14. Recovery payload failures still emit all durable context.
  15. Ordinary startup and resume events do not run compact recovery.

Additional evidence:

  • Final no-mistakes lint passed on the hardened commit set.
  • Agent Fleet pytest passed: 449 tests.
  • An isolated real Claude Code 2.1.220 session crossed /compact, received the directive in resumed context, loaded stow, read transcript bytes [0, 86349), and advanced the marker through byte 86349. The fixture used project-only settings and its own FM_HOME; live primary settings were untouched.

Unrelated broad-suite failures

The serial broad shell suite still reports the four known unrelated failure areas:

  • account-routing
  • Herdr E2E
  • AFK-wake
  • managed-teardown

These areas fail identically without this change. This branch changes only autocompact recovery, its focused tests, and the owning documentation; it does not touch any of those four areas. Firstmate reviewed the diff and explicitly authorized publishing on the targeted evidence while a separate lane shards and repairs the broad suite.

Review fixes

No-mistakes review caught and fixed two important races before publication:

  • Bound mark-stowed to the exact injected transcript path and end offset with compare-and-swap rejection of stale acknowledgements.
  • Replaced a persistent directory lock with a crash-safe kernel-released lock and added interruption coverage.

Review re-check, documentation, lint, push, and PR creation all passed.

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.

1 participant