Skip to content

fix(sync,sandbox): stop prompt replays from edited logs and protect Host stores - #784

Merged
github-actions[bot] merged 4 commits into
mainfrom
fix/sync-replay-session-safety
Nov 24, 2026
Merged

github-actions[bot] merged 4 commits into
mainfrom
fix/sync-replay-session-safety

Conversation

@olibaron

Copy link
Copy Markdown
Contributor

An agent on a new desktop account wrote 22 session logs straight into ~/.aeven/sessions and rewrote them about ten times. Four product defects turned that into 372 runaway turns, a Host that would not start, and a Stop button that did nothing. This PR fixes all four.

Changes

  • Sync no longer replays prompts from edited logs (session-sync). rewrite() asks dropped prompts again only when the accepted events belong to another device's claim. If the log diverges under this device's own claim, the file was changed on disk after it was published, so the log is restored to the accepted history and nothing is re-sent.
  • A corrupt log no longer stops the Host (session-persistence-jsonl). Header failures are now CorruptSessionHeaderError. Listings skip that log with a warning; loading it by id still fails with the cause.
  • Stop and queue edits reach a turn on another device (session-handoff, session-controller). New SessionHandoff.turnElsewhere falls back to the index entry's running mark and writer device. cancel and updateQueue route through it when no agent is attached locally.
  • Host stores are protected (sandbox, sandbox-policy, sandbox-local, fs-sandbox, bash-sandbox, base bundle). New protectedRoots covers $AVN_HOME/{sessions,storages,accounts,session-query,identity,keys}:
    • the file tools refuse writes there in every mode
    • Seatbelt profiles end with a deny rule for them
    • bwrap mounts them read-only
    • on macOS, SandboxProvider.protect confines danger-full-access bash with an allow-default profile that holds only those denials

Tests

Four persistence tests expected a corrupt header to reject the whole listing. They now expect the log to be left out of the listing, which is the new behavior.

Not covered

These are listed in the Agent Note:

  • full-access bash on Linux and Windows still runs unconfined
  • no guard against an agent running pkill on its own Host
  • no way to delete a conversation across devices
  • no supported conversation import

Checks

  • AVN_GATE_FAIL_FAST=1 pnpm run check:ci: 56 passed.
  • pnpm run test: 5 failures while it ran alongside check:ci. All 113 tests in those 4 files pass when rerun alone: oxlint-contract, code-runtime-python, sync-yjs provider-lan, typert tools-catalog.
  • Seatbelt was checked by hand: writes and deletes in a protected directory are denied under full access.

🤖 Generated with Claude Code

olibaron and others added 3 commits November 24, 2026 15:23
…ost stores

- session-sync: a log changed on disk after publication is put back to the
  accepted history without re-asking its prompts
- session-persistence-jsonl: a log with a corrupt header is left out of
  listings instead of failing the whole listing
- session-handoff/session-controller: stop and queue edits reach a turn
  another device runs when only the index marks it running
- sandbox: protectedRoots that no access mode may write, enforced by the
  file tools, Seatbelt, bwrap, and full-access bash on macOS

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…document protectedRoots

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…protected Host stores

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@olibaron olibaron added kind/bug-fix Corrects incorrect behavior area/shell Bash and shell capabilities: Service Definition, providers, and shell consumers area/session Session lifecycle, session log, persistence, projections, and the session working directory labels Nov 24, 2026
@github-actions
github-actions Bot merged commit 87453cd into main Nov 24, 2026
5 checks passed
@github-actions
github-actions Bot deleted the fix/sync-replay-session-safety branch November 24, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/session Session lifecycle, session log, persistence, projections, and the session working directory area/shell Bash and shell capabilities: Service Definition, providers, and shell consumers kind/bug-fix Corrects incorrect behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant