Make agent state durable without live bucket writes - #25
Open
lvwerra wants to merge 2 commits into
Open
Conversation
lvwerra
force-pushed
the
feat/libghostty-session-model
branch
from
August 4, 2026 15:40
ecbb691 to
85b01df
Compare
lvwerra
force-pushed
the
feat/durable-agent-state
branch
from
August 7, 2026 15:59
20f1372 to
673d136
Compare
lvwerra
force-pushed
the
feat/durable-agent-state
branch
from
August 7, 2026 17:31
71419ea to
945b7da
Compare
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.
Why
The mounted
/databucket is an object-backed FUSE filesystem, not a POSIX disk. The current implementation still exposes actively mutated state to failure modes the mount cannot safely support:Design
This PR gives every local CLI the same persistence contract:
$AM_LOCAL.rsync --files-from --delay-updates. The hot loop does not recursively enumerate the bucket..backupinto a local staging database, requirePRAGMA quick_check = ok, then upload the closed database. They publish only when the DB or WAL changed and never publish live WAL/SHM companions.Harness layout
$AM_LOCAL/codex-home/data/state/codex$AM_LOCAL/agent-state/claude/data/state/claude$AM_LOCAL/agent-state/gemini-home/.gemini/data/state/gemini$AM_LOCAL/oc-home/.openclaw/data/state/openclaw-backup$AM_LOCAL/opencode-share/data/state/opencodeopencode.dbbackup$AM_LOCAL/hermes/data/state/hermesstate.dbbackupThe implementation lives in
scripts/agent-state.sh; the full rationale and lifecycle are documented indocs/agent-state-checkpoints.md.Migration and rollback
sessionssymlink is removed only at the known local link path; the durable target is never deleted.*.pre-agent-state(with a timestamped fallback if that name already exists).Rollback therefore does not require reversing destructive migration steps.
Durability semantics
rsync --deleteagainst a transient local view is too risky.--resume latest, which could attach the wrong pane in a shared folder.First production deployment
Before restarting the current Space onto this branch, copy and verify the currently open Codex rollout as a closed migration object through the bucket API. Restarting first could repeat the exact open-writer loss mode this PR addresses.
Verification
npm testpasses, including the existing libghostty migration/resize suite and new recovery tests that:quick_check;