Repository navigation
Explicit push and pull: hooks record locally, save is commit - #9
Merged
Merged
Conversation
The hooks published each turn's edit record, its file index and the transcript to whatever LOCH_STORE named. With S3 unreachable every Stop waited on the 20s timeout (end took 8.3s), and Codex kills SessionEnd at 3s, so the last turn never left the machine. Hooks and backfill now write to ~/.loch/store alone, and blame, log and ask read only that; getting records to and from a remote becomes an explicit push and pull. blame, log, ask and backfill lose --store. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
~/.loch/config maps names to store URIs, git style. A command that reaches past this machine names a remote or a URI, else takes LOCH_REMOTE, then the deprecated LOCH_STORE (with a warning), then `origin`, then the only remote. Several remotes and no origin is ambiguous-remote rather than a guess, since a push to the wrong one publishes transcripts. A scheme the store doesn't know (ssh://, http://) is invalid-uri: create_store takes anything else as a relative path, so ssh://host would have become a local directory a push silently succeeded into. Relative paths are kept absolute. A config that won't parse is config-unreadable and is never overwritten. Nothing uses a remote yet; push and pull come next. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
push sends every saved bundle with its branch entries, and the current project's edit records, file index and transcripts (--all for every project's), to a remote. pull fetches records that know more turns than this machine's copy, with their transcripts. blame, log and ask go on reading only the local store. What a push has sent is remembered locally (~/.loch/pushed/<uri hash>, key -> hash of the local bytes), so the remote gets no manifest and pushes from several machines still commute. Transcripts are redacted on the way out; the local copy stays verbatim. Tombstones (tombstones/bundle/<ref>, tombstones/session/<agent>/<id>) stop a push from sending what a remote deleted, are checked again after uploading to withdraw what a racing delete covered, and make a pull forget loch's local copies. Nothing writes them yet; delete --remote will. A remote's keys are untrusted: FileStore refuses empty, . and .. segments, and pull takes a record only for a known agent, a safe id, and contents that match its key. FileStore writes are now atomic, since the local store is written by hooks and pull while either may be killed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
save is commit: it packs the bundle into ~/.loch/store, and save --push [<remote>] sends that bundle afterwards. restore looks here first, then fetches the one bundle from the remote, checks it hashes to the ref and keeps it. list --saved lists this machine's bundles and list --remote is ls-remote. delete is local; with --remote it writes a tombstone on the remote first, deletes there, and tombstones and deletes here. delete --session <id> does the same for a session's record, file index and transcripts. reindex takes --remote. --store <uri> keeps working as --remote <uri> (save --push <uri>), the meaning callers had. A plain save with LOCH_STORE set is warned that it no longer uploads, and the JSON schema goes to 3. New code: session-not-found. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… transcript - push sends a bundle only if one of its sessions ran in this project (--all for every bundle). Sending every bundle on the machine put one client's transcripts on another's remote. - Edit records merge by turn instead of being replaced. The hook starts from its working copy merged with the store's (which pull fills), pull merges into the local copy, and push merges the remote's copy in before uploading. A session restored under its own id and resumed no longer erases the other machine's turns, here or on the remote. - A transcript whose redaction fails is skipped and named in redactionFailed; the rest is still sent and the push ends redaction-failed, instead of every later push being blocked. - push --force ignores the markers, for a remote emptied by hand. - The local store is compared resolved, so a symlink to it isn't taken for a remote. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A scoped push unpacked every local bundle on every push to place it in a project. A ref is the hash of the bundle's bytes, so its sessions' cwds never change; they are kept in ~/.loch/cache/bundle-cwds/<ref>.json. merge_with_remote PUT the merged record's file entries before the record, duplicating what the plan already queues after it and breaking the record-before-index order. Dropped. CLAUDE.md notes the other side of merging records: a turn removed on one machine comes back from another copy, and only a tombstone removes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Hooks used to publish each turn's edit record, file index and transcript to whatever
LOCH_STOREnamed. Against an unreachable S3, everyStopwaited on the 20s timeout (endtook 8.3s). Codex killsSessionEndat 3s, so the last turn never left the machine. This PR moves loch to git's model: everything is recorded locally, and a remote is reached only by an explicit step.Changes
backfillwrite only to~/.loch/store.blame,logandaskread only that store.hooks_never_wait_on_a_remoterunsstopandendagainst an endpoint that accepts connections and never answers. Both finish in under 3s, and the same endpoint stalls a real S3 call. Refuse bundles whose session id isn't a plain file name; pin Codex review findings #8's SessionEnd test now asserts the fix.loch remote add|remove|liststores them in~/.loch/config. The default isorigin, else the only remote. With several remotes and noorigin, a command fails asambiguous-remoteinstead of guessing. Unknown URI schemes are refused:ssh://hostused to become a local directory a push would "succeed" into.pushandpull(f4f2fdf).--allwidens it to every project,--dry-runsends nothing, and--forceignores the markers.redactionFailed, and the push endsredaction-failedafter sending the rest.tombstones/bundle/<ref>,tombstones/session/<agent>/<id>) stop a push from bringing back something deleted on the remote. Push checks them again after uploading, to withdraw anything a racing delete covered. A pull forgets loch's local copies of what they cover, never the agent's own transcript.FileStorerefuses.,..and empty segments, andpulltakes a record only for a known agent and a safe id, with contents matching its key.FileStorewrites are now atomic.saveis local.save --push [<remote>]sends that one bundle.restorelooks locally, then fetches the single bundle from the remote, checks it hashes to the ref, and keeps a copy.list --savedshows this machine's bundles andlist --remoteis the equivalent ofls-remote.deleteis local. With--remoteit writes the tombstone on the remote first, then deletes there and here.--session <id>does the same for a session's record, file index and transcripts.reindex --remoterepairs the remote's index.Breaking
schemais 3.saveno longer uploads toLOCH_STORE, and itsstorenow names the local store.blame,log,askandbackfillno longer take--store.--store <uri>still works onsave,restore,list,deleteandreindex, meaning what callers intended (--remote <uri>, orsave --push <uri>).savewithLOCH_STOREset is warned that it didn't upload: stderr in text mode,"deprecated": "LOCH_STORE"in JSON.LOCH_REMOTEis the new variable.save --push.restoreon the destination machine then fetches the bundle.no-remote,ambiguous-remote,unknown-remote,remote-exists,invalid-uri,config-unreadable,session-not-found.Not in this PR
ssh://remote (alochhelper run on the far side over a single connection) is planned as a follow-up.Testing
cargo fmt --check,cargo clippy --release --all-targets -- -D warningsandcargo test --releaseall pass. New tests are intests/remote.rs,tests/trace.rs(push/pull, redaction, scope, tombstones, refused keys,LOCH_STOREfallback) andtests/codex.rs(save/push/restore between machines, hash check, bundle and session deletes, a push failing after the save). CLAUDE.md is updated.🤖 Generated with Claude Code