Repository navigation
Records: sealed shards for every store, readers of packed shards, packed writing off - #124
Merged
Merged
Conversation
…es too A writer appends to .coherence/<store>/<session>.<token>.jsonl and starts a new shard whenever HEAD, the branch, HEAD's reflog or the shard's size moved, or git's index holds the shard (d-3a125a06, d-fe8a26f3). Readers read line and packed shards (.jsonseq, U+001E-separated); packed writing ships off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cs, benches and the shard property Four Journal bullets (rotation, lost state, packed readers, packed off by default) and record stores merge with no driver in Lifecycle, each refuted and witnessed; the union bullet stays for legacy session files. The layout doc says what shipped, how 1.7.x skips a packed shard, the measurements, and when to turn packed writing on. shard is a property of journal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…out before cloning Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 14, 2026
…time, so a rotation in the same millisecond cannot flip them Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ot a failure Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
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.
Builds the record layout #121 designed and the owner approved ("let's do sealed shards and packed format"). Every record store (journal, runs, work) now writes sealed shards. Every reader reads them, packed ones included. Packed writing ships off.
Why: GitHub's merge does not honour
merge=union(d-44ee2214). Two branches of one session that append to<session>.jsonlconflict on GitHub, and CI runs none of its jobs.Shard naming
.coherence/<store>/<session>.<token>.jsonl, one record per line. The token is 8 random lowercase hex characters..coherence/<store>/<session>.<token>.jsonseq. The file starts with U+001E (record separator), each record is followed by U+001E, and the file has no newline. Git and GitHub count it as one line.<session>.jsonlfiles are read as committed and never appended to again..for any session id with no dot in it. Claude Code and Codex ids have none.SESSION_TOKENdoes allow dots; for such an id, the session is the name minus its last two dot-separated parts (sessionOfStoreFileinsrc/journal/stores.ts).sessionandagentfields stay the attribution, and vetting is unchanged.When a shard is sealed, and the writer's state
shardForinsrc/journal/shards.tsis the one place every writer gets its file from:appendRecord,appendWork,appendRunandappendRefutation. A writer reuses its last shard in a store only while all of these hold:index.lockexists, and git's index does not hold the shard, staged or committed.If any of these fails, the writer starts a new shard with a new token. So once a stage or a commit holds a shard, nothing appends to it again.
Where the state lives:
.coherence/cache/shards/<session>.json, one per checkout. It is ignored by git and written to a temp file, then renamed. It is only a hint (c-e23e2e42):Cost on the hot path: everything is read from git's files with no spawn. That covers
.git, a worktree'sgitdir:, the common dir, loose refs andpacked-refs,logs/HEAD, and the index. Most appends pay one stat for the index. A full index read on every append made the work meter's 10× budget test fail (4 KB of reads at 1×, 31 KB at 10×), which is why the identity-and-time test exists. Git is spawned only for a reftable repository, or for an index that is version 4 or split.Packed format, and what 1.7.x does with it
bench/records/old-readers.ts, run against origin/main's 1.7.2 source):*.jsonl, so they skip a.jsonseqshard's records silently: 0 read, 0 damaged;{"id":, and found every record in a line shard.PACKED_BY_DEFAULT = false).COHERENCE_PACKED_RECORDS=1turns it on for one writer. Whether to turn the default on is the owner's call at release time, in the release after the one that ships these readers. The steps are in docs/records-layout.md ("When to write packed shards") and in d-4e3a2564.Readers changed
storeLines/recordTextsnow split on the newline and on U+001E, andisStoreFileaccepts both extensions. Content ordering and dedupe of a record kept twice still hold across shards.loadJournal/loadJournalFiles,journalFileKeys(the peer feed; its seen-memo is per file and works per shard),loadWorkandloadRuns.branches.ts) matches each record within a grep hit.check.ts: record files and their lines) and the vocabulary state's record keys..github/scripts/records-summary.mjs).STATUS_SOURCES) now reads every one of the session's shards, not<session>.jsonl..coherenceout) or telemetry (it reads no store).'.jsonseq'toRECORD_FILE_EXTENSIONSinmods/coherence/hooks/journal.ts. Its splitter already handles U+001E..coherence/.gitattributeskeepsmerge=unionfor the legacy files old releases still append to. Nothing already committed is rewritten.Measurements (
bench/records/shipped.ts,shipped.json; darwin arm64, node 22.21.1)loadJournal1× (1,146 records, 89 files) / 10× (11,460 records, 890 files)appendWholeto one file)appendRecordline / packedappendRunline / packedThis PR on GitHub's terms:
node bench/records/shipped.ts --merge origin/main HEADreads attributes from the empty tree, somerge=uniondoes not apply. Run before merging main in, this branch landed on origin/main (bf7f77a) by merge, squash and rebase with no conflicts. The control (two appends to one legacy file) conflicts with no attributes and merges cleanly withmerge=union.Specs (
spec --check: 453 bullets, all invariants, 0 problems)Each new bullet has a test named by its
vialine and a witnessed refutation (break staged,refute, restored withgit checkout, green batched and alone with--each):recordTextssplits on the newline only. Result: red.PACKED_BY_DEFAULT = true. Result: red.The refutation of "packed writing is off by default" ran with the default staged on, so it wrote a real packed shard:
.coherence/runs/a79f7dfa2c80ee6b9.b5839fdc.jsonseq. It is kept, because records are never removed (d-dada22ac).Bench and probe
docs/records-layout.mdandbench/records/come from #121. The doc gains an As built section, the steps for turning packed writing on, the measurements and the spec changes. Two scripts are new:shipped.tsandold-readers.ts. The probe folder (bench/records/probe/) is left out. Its GitHub counts are recorded ingithub-counts.jsonand stay readable from #121.Vocabulary
shardis declared as a property ofjournal, not as a new concept, so the compact injection is unchanged (d-ea90469a, d-386a2748).lexicon --checkreports 0 rejected names and 0 unknown nouns.Journal (session a79f7dfa2c80ee6b9, agent sealed-shards)
shardas a property of journalCites d-3a125a06, d-fe8a26f3 and d-d5b49709 (#121) in prose.
🤖 Generated with Claude Code