@@ -24,7 +24,7 @@ below it, and the public surface a consumer addresses is the *top* layer
2424 │ depends on
2525 ┌───────────────────────────▼─────────────────────────────────┐
2626 │ segment append-only segment files + ValueHash; │
27- │ (segment.go, the leaf — no deps on the layers above │
27+ │ (segment.go, the leaf - no deps on the layers above │
2828 │ hash.go) │
2929 └─────────────────────────────────────────────────────────────┘
3030```
@@ -36,15 +36,15 @@ files are all internal mechanism the upper layers manage on its behalf.
3636
3737---
3838
39- ## ` segment ` — the leaf
39+ ## ` segment ` : the leaf
4040
4141** File:** ` segment/segment.go ` , ` segment/hash.go `
4242
4343An append-only file framed by a ` SegmentCodec ` . A ` Segment ` owns one
4444file, a ` baseIndex ` , a count, and an in-memory offset index rebuilt by
4545` recover() ` on open (the standard WAL recovery: scan forward, accept
4646clean frames, truncate any torn tail). It has no knowledge of forks,
47- channels, or trunks — it is the bottom of the stack and depends on
47+ channels, or trunks, it is the bottom of the stack and depends on
4848nothing above it.
4949
5050Provides:
@@ -60,12 +60,12 @@ Provides:
6060 canonicalizes JSON (object keys sorted, whitespace stripped, numbers
6161 preserved via ` json.Number ` ) and returns the truncated SHA-256
6262 (16 hex chars / 64 bits) of the canonical form. JSON-equal inputs hash
63- identically regardless of key order or formatting — the property the
63+ identically regardless of key order or formatting, the property the
6464 upper layers rely on to compare entries by value.
6565
6666---
6767
68- ## ` disk.Log ` — the fork engine over segments
68+ ## ` disk.Log ` : the fork engine over segments
6969
7070** File:** ` disk/log.go ` , ` disk/fork.go ` . ** Depends on:** ` segment ` .
7171
@@ -84,7 +84,7 @@ by delegating to the parent chain (`Read`, `Range`, `HeaderAt`,
8484` StateAt ` all walk up when ` idx < forkBase ` ). This is the watermark
8585boundary: own-range entries live in this log's own segments, the
8686inherited prefix lives in ancestors. ` LastIndex ` of an empty-own fork
87- reports ` forkBase-1 ` — it sits immediately after the parent's tail.
87+ reports ` forkBase-1 ` , it sits immediately after the parent's tail.
8888Reducible (header-mode) logs additionally carry a per-segment watermark
8989header computed by ` OnSegmentOpen ` ; ` StateAt(idx) ` folds the segment's
9090watermark with its entries up to ` idx ` .
@@ -108,13 +108,13 @@ only source for indices at and beyond that boundary.
108108 log keeps the prefix ` [FirstIndex, atIdx-1] ` and becomes read-only; the
109109 suffix moves into an "old-future" subdir; a fresh empty child subdir is
110110 created, writable from ` atIdx ` . Branch points are N-ary and
111- re-splittable. The * heuristic* re-home applies — on a re-split (own
111+ re-splittable. The * heuristic* re-home applies, on a re-split (own
112112 segments split) all existing children move into the old-future.
113113- ` ForkRehome(atIdx, child, oldFuture, rehome) ` forks with an * explicit*
114114 re-home list instead of the heuristic. The xwal joint fork uses this so
115115 every channel re-homes the ** same** children (decided once from the
116116 main channel) and the triune's trees stay in lockstep.
117- - ` ChildForkBases() ` returns each child subdir's ` .fork ` base — the input
117+ - ` ChildForkBases() ` returns each child subdir's ` .fork ` base, the input
118118 the joint fork uses to decide which children re-home.
119119
120120** Empty-log handling.** An empty root forks at index 1; an ** empty-own**
@@ -131,7 +131,7 @@ still has the sentinel.
131131
132132---
133133
134- ## ` xwal.XWAL ` — the multi-channel "triune" join
134+ ## ` xwal.XWAL ` : the multi-channel "triune" join
135135
136136** File:** ` xwal/xwal.go ` , ` xwal/fork.go ` . ** Depends on:** ` disk.Log ` .
137137
@@ -147,14 +147,14 @@ provider-owned payload bytes. Decoding accepts both frame shapes.
147147
148148A ` Config ` describes the join at creation:
149149
150- - ` Main ` — the main channel name.
151- - ` Channels ` — the ` ChannelSpec ` list (name, kind, reducer key, runtime
150+ - ` Main ` , the main channel name.
151+ - ` Channels ` , the ` ChannelSpec ` list (name, kind, reducer key, runtime
152152 ` SyncMode ` , persisted ` Opaque ` payload encoding).
153- - ` Registry ` — maps reducer names to ` Reducer{Reduce, Initial} ` ;
153+ - ` Registry ` , maps reducer names to ` Reducer{Reduce, Initial} ` ;
154154 resolved on every open (functions are never persisted).
155- - ` Codec ` — ` "jsonl" ` (default) or ` "binary" ` ; persisted in the manifest.
156- - ` Genesis ` — custom main-channel genesis payload (creation only).
157- - ` MintTrunkID ` — pluggable opaque trunk-id generator (consumed by the
155+ - ` Codec ` , ` "jsonl" ` (default) or ` "binary" ` ; persisted in the manifest.
156+ - ` Genesis ` , custom main-channel genesis payload (creation only).
157+ - ` MintTrunkID ` , pluggable opaque trunk-id generator (consumed by the
158158 Trunks layer).
159159
160160After first open the on-disk ` xwal.json ` manifest is authoritative for channel
@@ -172,7 +172,7 @@ Repeated and last-wins lookups remain O(1) once their suffix is indexed.
172172** Forks all channels as a unit** (` fork.go ` ). `XWAL.Fork(atMainLT,
173173child, oldFuture)` builds a ` forkPlan`: the main channel forks at
174174` atMainLT ` , each related channel forks at its own boundary
175- (` boundaryFor ` — the first own entry whose main LT ≥ ` atMainLT ` , or
175+ (` boundaryFor ` , the first own entry whose main LT ≥ ` atMainLT ` , or
176176own-tail+1 if it has not caught up; empty-own channels fork at their own
177177first index). The re-home set is decided once from the main channel and
178178applied to every channel by name via ` ForkRehome ` . A ` .xwal-fork-pending `
@@ -198,17 +198,17 @@ invalidate the cache.
198198
199199---
200200
201- ## ` xwal.Trunks ` — the trunk-addressed view
201+ ## ` xwal.Trunks ` : the trunk-addressed view
202202
203203** File:** ` xwal/trunks.go ` . ** Depends on:** ` xwal.XWAL ` .
204204
205205` Trunks ` is the surface a consumer addresses. A ** trunk** is one
206- continuation chain across all channels (the triune forked as a unit) —
207- the stable handle — while the per-fork ** node** is plumbing.
206+ continuation chain across all channels (the triune forked as a unit),
207+ the stable handle, while the per-fork ** node** is plumbing.
208208
209209** DISK IS THE SOLE SOURCE OF TRUTH.** The node tree * is* the main
210210channel's directory tree: ` nN ` subdirs plus ` .fork ` markers. Everything
211- about a node is derivable from that tree by walking it — * except* a
211+ about a node is derivable from that tree by walking it, * except* a
212212node's trunk id. That single non-derivable datum, and only that, is
213213persisted: a ` .trunk ` file per node dir (in the main channel), sitting
214214alongside ` .fork ` . The in-memory structure (` nodes ` , ` heads ` , sequence
@@ -270,7 +270,7 @@ invariant.
270270
271271Every record xwal writes carries a server timestamp (` t ` , unix millis) in
272272its frame, stamped at append time from ` Config.Now ` (a test seam;
273- defaults to the real clock). It is mandatory and supplied by xwal itself —
273+ defaults to the real clock). It is mandatory and supplied by xwal itself,
274274callers cannot set or omit it. Records written before timestamps existed
275275simply lack the field and decode with ` TS == 0 ` ; they are tolerated
276276forever and never migrated (the JSONL ` _hash ` covers the payload, so old
@@ -284,7 +284,7 @@ that asks it N times per listing:
284284 per-node ` atomic.Int64 ` counters (16 bytes per node ever addressed,
285285 retained for the life of the ` Trunks ` ). An XWAL opened through Trunks
286286 wires its internal ` lastTS ` pointer to the registry's counter, so every
287- append through any handle — and every ` sharedView ` of it — advances the
287+ append through any handle, and every ` sharedView ` of it, advances the
288288 one counter a listing reads. Open, close, and hot-store eviction do not
289289 touch it. This is not a cache of derived data: it is the same primitive
290290 the appender bumps, merely kept.
@@ -293,19 +293,19 @@ that asks it N times per listing:
293293- ** Cold reads are a file read.** First query for a node this process has
294294 never opened runs a bounded tail probe: the lexically newest segment
295295 file per channel directory the node owns, scan to the last complete
296- frame, decode its ` t ` , take the max — no full ` Open ` , no segment
296+ frame, decode its ` t ` , take the max, no full ` Open ` , no segment
297297 indexing, no watermark folds. Measured: ~ 36µs, ~ 73KB transient, 126
298298 allocs, paid once per node per process (the probe hydrates the retained
299299 counter). A full ` Open ` later merges monotonically (CAS-max) into the
300300 same counter, so probe and hydration can never regress an append.
301301- ** Never a wake.** LastTS opens (at most) segment files. Whether the
302302 consumer's node has an agent, a daemon, or anything else attached is
303- invisible from here — a listing over dormant nodes stays dormant.
303+ invisible from here, a listing over dormant nodes stays dormant.
304304
305305The frame's ` t ` sits in ALPHABETICAL key position (` m, p/p64, t, x ` )
306306because the JSONL codec canonicalizes key order on disk; encoder output
307307and disk output are byte-identical, and the fast-path frame decoder
308308speaks that one grammar. (The first draft ordered the encoder differently
309309from the disk and every meta-carrying segment read silently fell to the
310- reflection path — found by benchmark comparison, not by tests, and pinned
310+ reflection path, found by benchmark comparison, not by tests, and pinned
311311by canaries that round-trip the codec since.)
0 commit comments