Repository navigation
loch format v1, and blame/log/ask: from a line of code back to its conversation - #2
Merged
Merged
Conversation
The package, console script, env vars (LOCH_STORE, LOCH_S3_ENDPOINT, LOCH_S3_REGION) and default store (~/.loch/store) are now loch. The GitHub repo is still ness-dev/lochy, so release URLs keep that slug. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
loch/format.py defines the hashed turn: a core holding format version, kind, author, parents and the content hash, with content and per-turn facts kept beside it. Ids are sha256 over canonical JSON, and reading a derived file recomputes every one. loch/ingest.py converts a Claude Code session into a derived file. Each chain record becomes one turn whose parent is its parentUuid's turn, so rewind branches survive as separate heads. Compaction boundaries link through logicalParentUuid. Machine-specific strings (cwd, home, project slug, session id) become placeholders, using the same single-pass guarded rewrite restore uses, so turn ids are the same after a session moves machines. The source manifest hashes the transcript and its sidecar directory. loch ingest writes one derived file per session. test_corpus.py is an opt-in check against the local corpus (LOCH_CORPUS=1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SPEC.md covers the three layers (raw source, derived file, tools), the hashed turn core, content blocks, normalization, heads, the derived file layout and the Claude Code mapping with corpus measurements. Storage, git pins and native turns are described as intended shapes, and unsettled questions are listed in section 13. CLAUDE.md now says where the loch format sits relative to the existing non-goals: a derived projection rather than a source of truth, content still kept out of git, and per-turn pins as a deliberate exception to branch-level linking. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-key canonical() is now RFC 8785 written out: ECMAScript number formatting, UTF-16 key order, and lone surrogates escaped. Integers stay exact at any size, the one deliberate departure. System records other than compaction boundaries (hook summaries, turn durations, API retries) no longer become turns. They go into the preceding turn's facts.events, and their uuid resolves to that turn, so ids are the same with or without them. ingest --author-key <key.pub> sets the human author to ssh:SHA256:<fingerprint>, the same string ssh-keygen -l prints. A bad key fails with author-key-unreadable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HcfcCN7pccwK1zeXf9hZqA
The first draft's open questions are now a decisions table in section 13, each with its reason. Section 14 keeps the one still open (salting content hashes) and the known destination-path limit. Section 12 now states that ids may change until the first share, and that after that an id-changing converter change bumps the format version and ships a supersedes map. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HcfcCN7pccwK1zeXf9hZqA
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HcfcCN7pccwK1zeXf9hZqA
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HcfcCN7pccwK1zeXf9hZqA
Claude Code hooks note each agent commit on refs/notes/loch with the session and tool call that made it, and snapshot transcripts into the store before Claude's 30-day cleanup can delete them. backfill links earlier commits by exact match only. blame resolves each line to the prompt behind it; ask forks the conversation right after the commit and resumes it in Claude Code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HcfcCN7pccwK1zeXf9hZqA
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HcfcCN7pccwK1zeXf9hZqA
The hunk list made you map line ranges back to the file in your head. The default is now every line with a margin mark per request and a key at the top; --hunks keeps the old view, and --json gains the key and each hunk's mark. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HcfcCN7pccwK1zeXf9hZqA
The margin-mark terminal view fought the shell. Terminal output is back to one row per block; --html renders every line tinted by its conversation, with a key, click-to-focus, and each line's loch ask command, as one self-contained page. --lines limits it to an excerpt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HcfcCN7pccwK1zeXf9hZqA
blame only shows the last commit to touch each line, so a conversation whose work was later edited over disappears from it. log walks git's own history (-L for a range, --follow for a file) and resolves each commit to its conversation, grouped per request like blame's marks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HcfcCN7pccwK1zeXf9hZqA
Reading every transcript on the machine is the whole cost of backfill, so it now lists and sizes them first and reports each one read. The CLI draws a one-line counter on stderr, only for a terminal and never in JSON mode, which keeps stderr empty. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HcfcCN7pccwK1zeXf9hZqA
Every commit an agent makes here is noted with the conversation that made it, and transcripts are snapshotted at the end of each reply. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HcfcCN7pccwK1zeXf9hZqA
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HcfcCN7pccwK1zeXf9hZqA
frenchie4111
added a commit
that referenced
this pull request
Nov 20, 2026
…view findings (#8) * fix(restore): refuse a bundle whose session id isn't a plain file name A session id from a bundle was joined into the restored transcript's path, so a crafted bundle could write anywhere (`../../x`, `/x`) and inject into resumeCommand. Bundles come from shared stores, so the id is now checked on unpack (bundle-unreadable) and in both find_transcripts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: pin review findings on Codex support (#2 passes, #3 and #4 ignored) - SessionEnd killed at Codex's 3s while the store hangs: the turn is already closed locally; the store copy and the state cleanup are lost. - ask --at-turn on a turn before a move: the fork keeps naming that turn's cwd, which Codex's resume then offers as the session directory. - One directory recorded two ways (resolved, and -C through a link): reported as otherCwds, and only one spelling is rewritten on restore. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- 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.
Two pieces of work, stacked: the conversation format, then the first thing built on it.
loch format v1
SPEC.mdspecifies the format: a content-addressed graph of turns. RFC 8785 is used for canonical JSON. The draft questions are settled in §13: no salt on content hashes, and tombstones rather than git-style rewrites on delete.loch ingestconverts Claude Code sessions into the format. It converts all 3810 sessions in the local corpus, the derived files read back byte-identical, and re-ingest is idempotent.blame, log and ask
loch installadds Claude Code hooks (committed here in.claude/settings.json):refs/notes/lochto every commit an agent makes, naming the session and tool call that made it.loch backfilllinks commits made before the hooks existed. It only links a commit that matches exactly one command in a transcript, and shows progress while it scans.loch blame <file>shows the conversation, and the request, behind each block of lines.--htmlrenders the whole file as one self-contained page, tinted by conversation.loch log <file>[:<line>[-<end>]]lists every conversation that changed a file or a range of lines, following git's own line and rename tracking.loch ask <file:line | commit> [question]forks the conversation that wrote the line and resumes it in Claude Code. It resumes from the end of the conversation by default, or with--at-commitfrom just after the commit. The original session is never modified.--jsonwith stable error codes.ask --jsonreturns the launch command instead of startingclaude, so editors and extensions can drive it.Verified
claude -pdriven over stream-json the way Ness chat mode runs it. No Ness changes are needed.askwas resumed and answered from the original conversation.Known gaps
askresumes in the current checkout rather than at the commit.CLAUDE_CONFIG_DIR.git push origin refs/notes/loch.🤖 Generated with Claude Code
https://claude.ai/code/session_01HcfcCN7pccwK1zeXf9hZqA