Repository navigation
#758: 2.0 PostgreSQL storage (ancestor-location lists, group-ranged reads) - #774
Merged
Merged
Conversation
Adds the release-gate benchmark harness for #758 (spec section 5) as the example `storage_gate_bench` in layerfs-persistence, plus a diagnostic PostgreSQL client profile. Tooling only: no product code changes. - B1/B2: the prototype storage bench (delta_hint_bench, built from 343c59b) with its workload, seeds, sizes, Save pattern, cache-state declaration and write/catalog/cold_read lines unchanged, so rows compare 1:1 with pg-parent-0ms/1ms and sqlite-parent. The hinted and nulled arms are gone; `hinted=` counts rows with a non-empty ancestors list. Added lines: RTT, WAL, server time by statement class, wire bytes, the needed-groups model and its ratios. `netem add|del` applies the +1 ms arm exactly as the baselines did. - B3/B4: one 256 MiB file over 10 versions (S1 edits) in resumable build steps and a cold read with locate waves, round trips, A8 budget, wire and product bytes; then one Save adding >= 578 packs, with base-fetch and publication calls attributed by pg_stat_statements statement class. - Needed-groups model computed independently of the product read plan: reference closure from content, delta chains from record headers over bench-fetched bodies, group extents from each pack's own directory. - B7: the 72-file history grown to 1,600 versions in resumable steps, with probes (catalog per Commit, cold read, chain statement, cold-cache Save, row-update counts). - B8: 1x and 10x synthetic catalogs from r758.lvar (quarry distribution of pack ids, roles, lists, groups; fresh ids for copies 1-9; real-length directories), resumable load, index, analyze, samples (random and depth >= 14), EXPLAIN-based measurement of a statement taken from a file, guest free-space guard, drop. - Hooks for later phases: the strict_hints switch (refused as NOT_WIRED until Phase 1), the chain statement file (Phase 2), extra DDL (b8 sql); new Diagnostics counters are read by name and print NA until present. - pg_client_profile and pg_copy_probe.py: the per-byte cost is the macOS Docker Desktop published-port transport (Rust and Python clients both about 4.1-4.4 ms/MB over it; in-VM paths 0.38-0.52 ms/MB), not the Rust driver. Smoke-checked at small sizes against today's product; no gate rows run. No tests deleted. Production LOC: 207,613 -> 207,613 (delta 0) core 40,989 -> 40,989 (0) engine 96,933 -> 96,933 (0) control 59,366 -> 59,366 (0) api 10,325 -> 10,325 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on parent 8676948 and the staged tree (examples are excluded) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Core (layerfs-storage), backend-neutral; SQLite and PostgreSQL take the
defaults, so their statements and behaviour are unchanged.
- Publish carries the logical base: ObjectLocation.base (Save Member.base
replaces prefix: bool). Read rows carry None; both engines ignore it.
- Port: locate_chains(roots, rows, chains) (superset of locate, called for
every locate wave; default locate + no chains) and read_groups(reads, out)
(whole groups of several packs in request order, <= 2 MiB requested per
call; default read_packs per 2 MiB of whole packs). Types ChainMember,
LocatedChain, PackDirectory, LocatedChains, GroupRead, GroupReadAnswer.
- Reader (read/hints.rs): chain answers validated hard ("port chain
locator"), rows and chains both checked before any row is cached (one
shared position check, bad_position, for rows and members); roots' and
members' uncached groups fetched in one read_groups call (GroupPlan ranges
with whole_bytes = PACK_READ_PREFIX_BYTES where a directory is known, else
whole packs; Ranges answers through AcquiredPackRead::acquire) and
admitted as they came through PackCache::admit_groups (acquire_groups is
split into acquisition and admission; no staging hook, no second read);
stored_base binds each decoded base to its member and keeps it as a
hinted locator, so the walk sends no locate.
- Verification: a member whose id differs, whose descriptor contradicts a
known one, or a list that does not end at the FULL record, is stale
(chain_hint_stale) and the walk locates on. A hint-shaped failure
(ObjectMissing, a provider Missing, an Integrity that is not a provider
defect) on a chain holding a hinted locator evicts hinted locators,
disables hints for the demand and rebuilds once; a second failure stands
and a provider defect (malformed answer) is never rebuilt. A hinted
locator serves only its demand: every demand begins by evicting them
(LocatorCache counts them, so a demand with none scans nothing). Pooled
leaves and program pages bind no member (their pool reader has no
rebuild). A pack only members name is a hint: members contradicting a
known descriptor are not fetched, and a Missing/Malformed call or a failed
admission for such a pack makes the hints stale while the read goes on;
failures of the rows' own packs stay hard. Save demands, and the read of
a Save's lost registrations' winners (Fetch::save_reads), use chains only
for group prefetch, so selection depth/cost walks see authoritative
locators only.
- Local chains behind a port knob, batched_chain_reads() (default false;
a provider whose every read is a network round trip returns true): the
same group read also follows the base of rows this handle published
through authoritative cached locators (lost rows are invalidated, so the
walk stops there), and each Save slice prefetches its stored
predecessors' chains in one wave. A single writer never re-locates its
own rows, so this is what batches its Saves' base fetches. SQLite takes
the default; PostgresStorage states false until phase 2 turns it on.
- Storage::set_strict_hints (tests and benches only): stale hint fails
Integrity("delta chain hint").
- PackCache keeps Integrity("immutable cached descriptor changed").
- Counters: chain_rows, chain_members, chain_hinted_bases, chain_hint_stale,
chain_unhinted_roots, group_reads, group_read_packs, group_read_ranges,
group_read_bytes, group_read_whole.
Engine: layerfs-persistence only `base: None` on read rows and test
literals plus the explicit PostgreSQL knob (false); no SQL change.
layerfs-store-service: since() reports the ten new counters per Commit
instead of cumulatively.
New tests: chain_hints (15, including one writer handle whose Save of the
next version costs one read_groups and no per-level pack reads with the
knob on, and exactly today's calls with it off; a Save losing every
registration binds no member reading the winners; a hinted locator serves
one demand; a misplaced member cannot break a program page's read; member
packs that are absent or come back under another digest are stale; a
provider defect on a hinted walk is not replayed; a refused chain answer
keeps no row; a group read into a dense cached pack is admitted with no
second read), group_reads (5, a cached range refusing its pack under
another digest), shared support tests/support/chain_provider.rs (Missing
for absent packs, asked roots, a publish hook, history_with).
Phase-0 bench (examples/storage_gate_bench): ObjectLocation literal gains
`base: None`; common::strict calls Storage::set_strict_hints instead of
exiting NOT_WIRED.
Prototype pieces not carried over (storage-measure worktree): the SQLite
base column, migration and fill and their SQLite cases, the PostgreSQL base
column, the recursive CTEs, the `location.base != base` refusal, the
`locate_chains(bases)` shape, tests/delta_base_hints.rs and the
delta_hint_bench example (used uncommitted only for the SQLite counter
check below; still identical with the knob, default off, and after the
review fixes).
Deleted tests: none.
SQLite counters (delta_hint_bench sqlite, 72 files x 24 versions), parent
vs this change: write statements 3091 / 3091, cold-read statements
1401 / 1401; cold read locate 609 / 609, read_packs 0 / 0,
read_pack_selections 789 / 789; write locate 121 / 121,
read_pack_selections 2542 / 2542; every pre-existing Diagnostics field
equal except locator_bookkeeping_live_peak_bytes 7432 / 7440 and
14352 / 14360, the 8-byte hinted count added to LocatorCache.
Production LOC: 207,613 -> 208,340 (delta +727)
core 40,989 -> 41,696 (+707) layerfs-storage +707
engine 96,933 -> 96,953 (+20) layerfs-persistence +10, layerfs-store-service +10
control 59,366 -> 59,366 (0)
api 10,325 -> 10,325 (0)
reference absent (retired R9c; last counted 65,417 at tree 498dd19)
Method: tools/production_loc.py --detail on parent 6c247c5 (phase 0, no production change; same totals as 8676948) and the staged tree
The core growth is over the spec's 100-135 estimate: read/hints.rs holds
validation, binding, the stale and rebuild fallback, group planning, the
local chain walk, ranged-answer admission and the hint-only fallback; the
port types, knob and
defaults, and the Fetch, Source, Resolver and Save wiring make the rest.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…2.0 schema PostgreSQL Store schema 3 (SQLite unchanged): - object_location.ancestors: each row's delta chain as a D1 physical list (varint(zigzag(pack - previous)) || u8 group || varint(record) || varint(length - 1), nearest base first, '' for FULL, NULL unrecorded, at most 850 bytes), filled by the publish statement from ObjectLocation.base (stored bases by one prefix probe, in-batch bases by a recursive CTE); rows stay insert-only. - pack.directory: body[0..body_offset), written by the pack COPY, held to the body prefix by pack_directory_check. - ancestor_varint / ancestor_entry / ancestor_entries SQL functions; early-freeze reloptions on pack (and its TOAST) and object_location. - A schema-2 Store is refused (Refused, not migrated) before the source comparison on the Full, Light and diagnostic paths. Chain locate (owner design B): locate_chains is statement 1 (sql/postgresql/chain_roots.sql: roots, raw lists and the roots' pack rows with directories), D1 decoded in Rust, then statement 2 (chain_packs.sql: member packs by pack_pkey, only those statement 1 did not return). Over-cap, malformed and unrecorded lists are dropped in the provider; no cross-call descriptor cache. batched_chain_reads is true. read_groups on PostgreSQL returns whole packs (read_packs per 2 MiB) in request order in this phase. The locate and publish statements moved into sql/postgresql/locate.sql and publish_rows.sql (relocation); the bench's b8_locate.sql is test-checked equal to locate.sql, and the bench binds chain statement 2's $1 (member pack ids, bigint[]) from statement 1. Compaction verifies every rebuilt list names a stored pack and group (Integrity "compaction ancestor lists"); the fingerprint covers TOAST reloptions. Doctor: store.catalog.chain_lists, chain_entries and chain_hints. Phase 3, not here: the history-scaling test (parked unchanged; its equal-cost criteria fail on core behaviour: group reads are not paged in 2 MiB calls and a fresh-session Save locates every chain level per object), core group-read paging, Save batching and PostgreSQL ranged group reads. Tests: new postgresql_ancestor_lists (7), postgresql_group_directory (3), postgresql_chain_property (40 histories), and postgresql_compact_fixtures::ancestor_lists_stay_exact_across_two_compactions. postgresql_open_check's version literal is now 3. No tests deleted. Docs: engine/store/postgresql.md (delta chains), diagnostics.md, core physical-storage README. tools/ci_tests.py lists postgresql_chain_property as slow. Production LOC: 208,340 -> 208,748 (delta +408) core 41,696 -> 41,696 (0) engine 96,953 -> 97,361 (+408) layerfs-persistence +408 (includes relocation of the locate and publish statements from Rust strings to sql/postgresql/) control 59,366 -> 59,366 (0) api 10,325 -> 10,325 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on parent ca3d225 and the staged tree Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ranged reads Group reads are paged: a demand wave's consumers are taken in order while their uncached groups, chain members and already-held needed entries fit 2 MiB (Hints::page); each page is read with one read_groups call and consumed before the next. Group reads plan ranges without the density rule (GroupPlan::ranged), and a paged wave skips the whole-pack pass, which was why phase 2 ranges re-read packs whole. Published packs keep their directories in the hints so a Save's own chains plan ranges. The planner is inactive without trusted hints, so SQLite runs today's path unchanged. A Save no longer locates per object per chain level: it pages the bases of objects not already located (none for exact reuse), and promotes hinted locators to authoritative only after rebuilding each chained base with binding on, so every chain element was hashed to its id (verify_bases, chain_verified_bases). A failed check falls back to authoritative locates once (counted stale; strict hints refuse). Pooled leaves and program pages are not verified this way. PostgreSQL read_groups answers groups with the multi-range substring reader, one statement per 2 MiB page; a whole read is one range checked by PersistedPack::authenticate. The session keeps a bounded ChainPacks cache (per catalog incarnation) so chain_packs reads only unseen member packs. Tests: chain_hints gains a fresh-handle Save counter test (identical objects and packs; locate calls == waves; group reads <= waves + bytes/2 MiB); postgresql_group_directory gains a multi-page A8 test; ancestor_lists checks fresh and warmed session round trips; postgresql_history_scaling restored with unchanged assertions in five stages (stages 2-5 #[ignore], order in the file and tools/ci_tests.py). Stage 5 fails: real growth with history (root rebasing); not weakened. Deleted tests: none. SQLite: write statements 3091, cold read 1401, all Diagnostics fields equal to the parent (new chain_verified_bases 0). Production LOC: 208,748 -> 208,978 (delta +230) core 41,696 -> 41,864 (+168) layerfs-storage +168 engine 97,361 -> 97,423 (+62) layerfs-persistence +61, layerfs-store-service +1 control 59,366 -> 59,366 (0) api 10,325 -> 10,325 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on parent f881fe6 and the staged tree Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…h only
Two corrections to the storage_gate_bench tooling so the release-gate rows
measure what the spec defines. Thresholds are unchanged; every affected
line prints the corrected and the phase-0 figure side by side.
- B1/B3 bytes (A11): the needed-groups model is now per read, as the
read-path spec 6.2 defines it ("the cache is unbounded within one read")
and as the product reads (one PackCache per Reader; common::cold_read
opens one reader per root, as the baseline bench did). The gate figure
model_per_read sums each root's own model; model_union (phase 0: every
(pack, group) and directory once over all roots) is printed beside it,
with ratio_product (per read) and ratio_union. B3 reads one root, so the
two are equal (models_equal=true).
- B4 base fetch: a pass-through port wrapper attributes the Save's port
calls on the client by the layerfs-storage call sites: membership (the
per-wave locate in save/wave.rs, one per READ_OBJECT_LIMIT ids, its
chain_roots statement), closure (save/publication.rs reference check),
base locates (selection-walk and proposed-base locates, chain_packs) and
base reads (read_groups/read_packs/read_scoped_pack/read_pack_selection).
base_fetch_round_trips = base locates + base reads; membership_locates,
old_base_fetch_round_trips (every server locate + pack_read call, phase 0)
and server_locate_calls are printed beside it, and attributed round trips
are checked against the Save's total. The classification is in large.rs's
header comment.
Bench example code only; no product change.
Deleted tests: none
Production LOC: 208,978 -> 208,978 (delta 0)
core 41,864 -> 41,864 (0)
engine 97,423 -> 97,423 (0)
control 59,366 -> 59,366 (0)
api 10,325 -> 10,325 (0)
reference absent (retired R9c; last counted 65,417 at tree 498dd19)
Method: tools/production_loc.py --detail on parent 38b027b and the staged tree
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ocating each level B4 at 9b144a8 spent 195 of its 218 base-fetch round trips on base locates. A call-stack trace of every locate in that Save showed 177 of them in one place: the pool reader rebuilding a program-page base (here the large file's extent pages) for selection's COPY/INSERT trial (delta::branch::acquire -> PoolReader::branch_canonical_with_caches -> base_location), one single-id locate per chain level per page. Phase 3's verify_bases skipped program pages because their pool reader has no rebuild, so on a fresh handle these chains were walked level by level even though the wave's membership locate had already returned their chain lists. Fix: verify_bases (save/wave.rs) now also checks program-page bases (directory, extent and inode-table branch pages; pooled leaves stay excluded). Under the new Fetch::binding_pages guard, held only for this check, Fetch::bind accepts program roles, and the pool reader's walk calls bind_base for each record it reads, so each base it decodes is bound to the chain member the membership wave located. The check runs in a pool reader of the Save's own (its counters are discarded, so Save outcome counts are unchanged). When the rebuild succeeds, the bound locators are promoted to authoritative (promote_hints). When a failure could have been caused by a hint (hint_failure) and a hinted locator was in use, every hint is dropped and counted (strict hints refuse); there is no rebuild, because selection's own branch::acquire later walks that chain from authoritative locates, exactly as before. Any other failure is returned. Reads are unchanged: outside the guard, Fetch::bind still returns before binding a program page, so the read-path pool reader binds nothing, and the existing misplaced-member test is unchanged and passes. Safety (the Save rule: no depth, cost, selection, exact-reuse or closure decision rests on an unverified physical hint). This is hash-verified promotion. The chain's root is the authoritative membership row. Each deeper element's id comes from its child's record, which is already verified, not from the hint; the hint supplies only a position and a canonical length. reconstruct_branch decodes base first and checks every element's canonical length and ObjectId::for_bytes against that id before it returns Ok, and its role against the root's. Promotion happens only after Ok. So every promoted locator names a position whose record rebuilds exactly that object, and a list names only catalog-row positions: publish copies the base's row entry and list, and a lost row keeps the winner's list. Selection then charges the depth, canonical bytes and record bytes a reader walks from those records. A wrong position fails the hash and is never kept. Without trusted chains (SQLite, or after a stale hint until the next demand) nothing is checked or bound. Counters (one sample each, lfs-bench-758-pg, synchronous_commit local, LAYERFS_CONSTRUCTION_WORKERS=1, release storage_gate_bench, frozen bench code, own schemas f1_b1 and f1_b3): - B4 base_fetch_round_trips 218 -> 41 (gate <= 40: still FAILED by 1). base locates 195 -> 18, base reads 23 -> 23, Save round trips 667 -> 490, packs_added 1832, attribution_complete=true. The 18 remaining base locates are 17 chain_packs second statements inside membership waves (design B, provider) and 1 publication closure locate (register_ready) of 48 chunk delta bases evicted from the 4,096-entry locator cache. The frozen bench counts that call as a base locate because its ids include delta bases, which are not content references. The 23 base reads are one read_groups per 2 MiB page. - B1 write: statements 265, round trips 399 (unchanged: one writer handle, whose own rows are cached); cold read 302/305, stale 0. - B3 Save round trips v0-v9: 210 184 227 165 122 158 190 215 163 180 (gate run: 210 184 302 300 267 362 441 504 447 378). Same decisions: decisions_digest.sql output on f1_b1, f1_b3 (B3 before b4) and f1_b3 (after b4) is byte-identical to reference-decisions-raw dig_ref_b1/b3/b4 (decisions_sha256, depth histograms, objects, packs, pack_bytes, and also placement_sha256, pack_set_sha256 and pack_bodies_sha256). SQLite: b1 sqlite with the phase-3 write-Diagnostics print (not committed) gives every Diagnostics field identical on 9b144a8 and on this change: write statements 3091, cold read 1401, locate 121/609, read_pack_selections 2542/789, read_packs 0, chain_verified_bases 0. Tests: chain_hints gains a_fresh_handle_save_rebuilds_its_program_page_bases_without_a_locate_per_level. The fixture is a 4,000-name directory changed in seven Saves, with program chains of depth 5. The change is Saved by a fresh handle, which must store the same records and byte-identical packs as the default port, send <= 2 locates, verify >= 2 x 5 bases, and count no stale hint. On 9b144a8 the test fails with 16 locates; it passes here with 1. Assertions only added: git diff 9b144a8 -- '*/tests/*' removes no line, and no inline test module changed. Full layerfs-storage target set passes. PostgreSQL ancestor_lists, group_directory, chain_property, commit_round_trips, identical_ids and narrow_locations pass, as do sqlite_publication and concurrent_pooled_saves. fmt and Clippy -D warnings --all-targets on layerfs-storage are clean. Deleted tests: none. Production LOC: 208,978 -> 209,008 (delta +30) core 41,864 -> 41,894 (+30) layerfs-storage +30 engine 97,423 -> 97,423 (0) control 59,366 -> 59,366 (0) api 10,325 -> 10,325 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on parent 9b144a8 and the staged tree Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d, client memory Bench tooling only (examples/storage_gate_bench); no product code. New rows and printed fields only: every line and field printed at 9b144a8 keeps its name and value. Bench edits: - b8 samples: optional `--commit-packs FILE` adds samples `early` and `late` (4,096 r758.lvar rows each, first by sha256(id), from the objects of the first and last 10 % of quarry's commits; pack id is the proxy for an object's commit). FILE is one `history_serial created_ms root_pack_id` line per commit. Prints three new `b8 samples` lines. - b8 measure: also prints `b8_statement:` for `early`/`late` when they exist, and one new `b5_real_history:` line (late/early exec and buffer ratios, plans_equal), or that line as NOT_RUN without the samples. The `random` and `deep` lines are unchanged. - b7 probe: steps 5-7 after the unchanged step 4. `b7_lane_hold:` reports the step-4 Save's lane holds: the total (`lane_hold_server_ms`, `lane_hold_upper_ms`, `lane_holds`) and each hold (`reservation_hold_*` for the pack/ordinal reservation write, `publication_hold_*` for the publication, `lane_lock_*` for the row lock and barrier statements of all holds, `holds_attributed`); a Save at shipped defaults holds the lane twice. `b7_head_mount:` reads the reference closure of the fixed 72-file tree through one reader on a fresh Storage. `b7_client_memory:` peak and current RSS after steps 2, 3, 4 and 6 plus the product's locator bookkeeping peaks. Steps 2-4 only take memory samples, outside timed regions. - storage_gate_bench.rs: the doc table names the new option and line. Note: pg_stat_statements_reset() is server-wide (existing steps reset it too), so one bench at a time on the bench server. Checks: release build, Clippy -D warnings on the example, rustfmt clean on the changed files, product boundary guard PASS. Smoke (t2_ schemas on lfs-bench-758-pg, dropped after, not gate samples): B7 grow 20 + two probes (lane_holds=2, holds_attributed=true), B8 1x samples with --commit-packs and three measures. Deleted tests: none. Production LOC: 209,008 -> 209,008 (delta 0) core 41,894 -> 41,894 (0) engine 97,423 -> 97,423 (0) control 59,366 -> 59,366 (0) api 10,325 -> 10,325 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on parent 3257a5d and the staged tree Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…base Formatting only, rustfmt 1.85.1 (edition 2021) on exactly the five files that failed `cargo +1.85.1 fmt -p layerfs-persistence -- --check` at 9b144a8 (last changed by base commit e56ec6c, not by #758): src/backend/sqlite/snapshot.rs, tests/acquisition_reads.rs, tests/kept_objects_edges.rs, tests/sqlite_compact_capacity.rs, tests/support/mod.rs. No token changes; `fmt --check -p layerfs-persistence` now passes; Clippy -D warnings --all-targets on the package passes. Production LOC moves +10 only because rustfmt breaks two one-line `query::run(...)` calls in snapshot.rs over six lines each (layout, not code). Deleted tests: none. Production LOC: 209,008 -> 209,018 (delta +10) core 41,894 -> 41,894 (0) engine 97,423 -> 97,433 (+10) layerfs-persistence +10 (rustfmt line breaks) control 59,366 -> 59,366 (0) api 10,325 -> 10,325 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on parent d977351 and the staged tree Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Addresses the independent review of fix 1 (3257a5d). Product changes are in layerfs-storage only. 1. Test gap (Save-side failure on a program page). chain_hints gains a_misplaced_member_of_a_program_base_fails_its_hash_and_the_save_walks_it_from_locates: a fresh-handle Save of the directory_change(6) fixture, with members[0] of one program base's chain moved onto another page of its role. Non-strict: same records and byte-identical packs as the default port, chain_hint_stale >= 1, and the element below the base reads back through the Save's handle (no locator at the moved position was kept). Strict: the Save refuses with Integrity("delta chain hint"). 2. Role check for hinted levels. Fetch::bind gives a hinted locator the root's role, because a chain member carries no role, so the walk's `location.role != root.role` could not fail at a hinted level. Now reconstruct_branch records which elements came from a hint (Source::hinted, false by default and for this Save's private objects). After an element's hash passes, its role is checked against the root's from the role its authenticated page header declares (directory or inode-table page role byte, or extent leaf or branch), failing with Integrity("branch chain role"). A locator is promoted only after that check. Authoritative levels and reads are unchanged. Limit: a hinted level's catalog row is not read, so a row whose role alone disagrees with its own bytes is found by the next authoritative walk, not by this Save. 3. Narrower stale-hint classification. The program-page check counted any hint_failure as a stale hint whenever any hinted locator was cached. Now the pool reader records whether the failure is attributable to a hinted element (PoolReader::hint_blamed): the element being read or decoded, or any element of a walk past the depth cap. Elements below the one being decoded are already authenticated. Only then are hints dropped and counted (Fetch::hint_stale; strict refuses). Any other failure, for example one at the authoritative root, returns the Save's real error, so strict hints no longer mask it as "delta chain hint". 4. Verification walks only the chain selection walks. For a program page, the checked base is the first advisory predecessor when it is stored with the page's role, exactly as delta::branch::trial takes it. A private first predecessor or another role means no check. Other objects keep phase 3's rule (first stored predecessor, not a pooled leaf, depth unknown), and again exclude program-role bases, which their selection never takes. A chain selection never reads can no longer fail a Save that succeeded before. 5. Pack descriptors from hints. Fetch::bind no longer remembers a member's pack descriptor as authoritative. A descriptor that only a bound member gave is marked. It is forgotten with the hints (forget_hints) and at the next demand, and is confirmed by promotion or by an equal authoritative descriptor. An authoritative descriptor that contradicts a marked one makes the hint stale (counted, strict refuses) instead of failing as "inconsistent pack descriptor". Descriptors that group reads admit are unchanged (phase 3). 6. Docs: "Without trusted chains (SQLite, or after a stale hint until the next demand)". physical-storage/README.md also describes 2-5 and the new tests. Not changed: "each verified program base is rebuilt twice" (CPU only, belongs to fix 2's profile). Tests (fail before, pass after; product source reverted to b919920 with the new test file, then restored): - a_hinted_element_whose_page_header_names_another_role_is_not_kept (2): before: chain_hint_stale 0, chain_verified_bases 1; after: 1 / 0, strict refuses, default-port bytes. - a_program_base_whose_own_row_is_wrong_fails_with_its_own_error_not_as_a_stale_hint (3): before: chain_hint_stale 1, strict error "delta chain hint"; after: Integrity("branch delta length") in both modes, stale 0, the same error as the default port. - a_save_checks_only_the_chain_selection_walks (4): before: chain_hint_stale 1 (strict: "delta chain hint"); after: Ok, stale 0, default-port bytes. - a_pack_descriptor_only_a_stale_member_gave_is_forgotten_with_the_hints (5): before: the read fails Integrity("inconsistent pack descriptor"); after: expected bytes, stale 1 (strict refuses). - Finding 1's test covers fix 1's existing behaviour and passes on both. chain_hints: 18 of 22 before, 22 of 22 after. The existing wrong-hint and stale-hint tests are unchanged and pass. git diff of '*/tests/*' adds 298 lines and removes none. No inline test module changed. Full layerfs-storage set passes (157 tests). PostgreSQL ancestor_lists (7), group_directory (4), chain_property (1), commit_round_trips (1) and identical_ids (3) pass, with no NOT_RUN, as does sqlite_publication (13). fmt and Clippy -D warnings --all-targets on layerfs-storage are clean. Same decisions (lfs-bench-758-pg, synchronous_commit local, LAYERFS_CONSTRUCTION_WORKERS=1, frozen release storage_gate_bench, one sample each, schemas f1b_b1 and f1b_b3): decisions_digest.sql output on f1b_b1, f1b_b3 (B3 before b4) and f1b_b3 (after b4) is byte-identical to reference-decisions-raw dig_ref_b1/b3/b4. - B4: base_fetch_round_trips 41 (unchanged from fix 1), base locates 18, base reads 23, Save round trips 490, packs_added 1832, attribution_complete=true. - B1 write: statements 265, round trips 399; cold read 302/305, chain_hint_stale 0. - B3 Save round trips v0-v9: 210 184 227 165 122 158 190 215 163 180 (identical to fix 1). SQLite: b1 sqlite with the phase-3 write-Diagnostics print (not committed) gives every non-timing output field identical on b919920 and on this change: write statements 3091, cold read 1401, locate 121/609, read_pack_selections 2542/789, chain_verified_bases 0. Deleted tests: none. Production LOC: 209,018 -> 209,138 (delta +120) core 41,894 -> 42,014 (+120) layerfs-storage +120 engine 97,433 -> 97,433 (0) control 59,366 -> 59,366 (0) api 10,325 -> 10,325 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on parent b919920 and the staged tree Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cached records name Profile first (758-impl/fix3-profile.md): of the B1 cold read's 168 locate waves, 56 were one locate per delta level of the 8 chunked files' mapping root pages (ExtentLeaf, chains of 7). A read binds no member of a program page (or pooled leaf) chain, so each level's base, known only after the level above is decoded, was located alone, although every level's record was already in the pack cache from the page's one group read. Now a `prefetch::chains` level that has to locate also carries guesses for the levels below it (`Fetch::chain_ahead`): member k gives the position of the level-k base, and the base id the record there names, read only from bytes the pack and decoded-group caches already hold and leaving both untouched (`PackCache::peek_group`, `GroupCache::peek`, `delta::read::cached_base`), is the guess for level k+1. Nothing is trusted: the guesses are located as ordinary authoritative rows, every level still takes its base id from the record at its base's authoritative location, and a wrong guess only leaves the next level to locate as before (nothing counted stale, strict unaffected). Guesses fill at most the rest of that locate's 4,096-id page and only join a locate the level makes anyway, so no statement is ever added. No hint binding, no fused locate-and-read, no server-side resolution; design B unchanged. Bases a member binds are cached already, so SQLite (no chains) and hint-bound chains are unaffected. Counters (one sample each, same host window, strict hints): - B1 cold read: locate waves 168 -> 120, statements 302 -> 254, round trips 305 -> 257; fetched bytes 22,877,946 unchanged (ratio_product 0.999), server 25.0 -> 25.2 ms. Wall 259.85 -> 244.53 ms with host control: construct_ms 466.6 / 452.4, SQLite cold read 52.43 / 55.45 ms. - B3 cold read: waves 474 -> 443, statements 935 -> 904, round trips 938 -> 907; fetched bytes 286,713,013 unchanged. - Save counters unchanged (B1 265/399; B3 per-version and B4 299/490, base fetch 41, as fix 1b); construction reads through a reader drop (B3 construct round trips 449 -> 344 over 10 versions, B4 116 -> 83). - Same decisions: B1, B3 and B4 digests byte-identical to the 9b144a8 references (decisions_sha256 9e843ede...5956 for B1). - SQLite B1 unchanged: write 3,091 statements, cold read 1,401; locate 121 / 609, read_pack_selections 2,542 / 789. Test: chain_hints a_program_page_read_locates_every_deeper_level_of_its_chain_in_one_locate (fails at the parent: locate 6 vs 2 on a depth-5 program page; passes now); a member moved off the chain keeps the read byte-identical, brings back per-level locates and counts nothing stale, strict or not. No test deleted or changed. Production LOC: 209,138 -> 209,227 (delta +89) core 42,014 -> 42,103 (+89) layerfs-storage +89 engine 97,433 -> 97,433 (0) control 59,366 -> 59,366 (0) api 10,325 -> 10,325 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on parent dd9c855 and the staged tree Deleted tests: none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1. SHOULD-FIX, confirmed and fixed: a stale hint could fail a Save hard.
In the program-page walk (encoding/pool/branch.rs) only the element
being read counted as a hint's, so a hinted element whose record named
an element already located authoritatively (member[0] of R's chain on
the record of S, a stored descendant of R) failed one iteration later
as Integrity("branch dependency cycle") with suspect false: the Save's
error, where it had succeeded before fix 1. Now every element at or
below the first hinted one is suspect, in the walk (`current_hinted ||
hinted.contains(&true)`) and in the decode (position at or below the
first hinted element); elements above it stay the Save's own failures.
Test a_hinted_element_whose_record_leads_back_to_an_authoritative_one_is_a_stale_hint
(new fixture directory_change_with_sibling: a sibling change Saved
after the returned objects were built, so their program bases have
stored descendants): before, the non-strict Save fails
Err(Integrity("branch dependency cycle")) with chain_hint_stale 0;
after, it succeeds with the default port's records and packs and
chain_hint_stale 1; strict refuses "delta chain hint".
2. SHOULD-FIX, confirmed; docs narrowed (no behaviour change).
remember_pack confirms a marked descriptor from every caller, including
a group read's ranged admission (read.pack is the member's own
descriptor for a member-only pack) and pack-cache hits
(validate_cached_pack with the entry's descriptor), so a member's
descriptor confirms itself once its group is read, and a later
contradicting authoritative descriptor fails hard. A real fix needs the
descriptor's provenance on every pack-cache entry: after a contradiction
is made stale, the entry admitted under the member's descriptor is still
hit by the authoritative walk and fails in validate_cached_pack, so
marking at admission alone does not help. Not small, so the
physical-storage README and remember_pack's doc now say what the code
guarantees: confirmation by promotion or any equal remember_pack,
including ranged admission and cache hits; a contradiction of a marked
descriptor is a stale hint, of a confirmed one `inconsistent pack
descriptor`. Pack ids are never reused, so either contradiction means a
provider answered a chain unlike its own pack row (PostgreSQL reads both
from the same `pack` rows).
3. Test gap and count, fixed. New test
an_authoritative_descriptor_that_contradicts_a_member_s_makes_the_hint_stale
reaches remember_pack's contradiction-of-a-marked-descriptor branch:
two roots read together whose bases share pack P; the first root's
member names P under another digest at a group P lacks (no group read
reaches it, so its descriptor stays marked); the second root has no
chain, so its base is located at the next level with P's real
descriptor. Non-strict: stale 1, the member was bound first, bytes
correct; strict refuses. (Coverage of existing behaviour: it passes on
the parent too.) Docs now state that the contradiction drops every
hint, so a later failure of that walk at a hinted element is not
rebuilt on a read. In the Save's program-page check, a blamed failure
after the walk already counted its stale hint (bind's member mismatch,
or this contradiction) no longer counts it again: Fetch::hint_stale
takes `counted`, set when chain_hint_stale rose during the walk.
Gap: no test drives that double-count path itself.
4. Nit, docs narrowed. The verification rule is wider than selection:
bases are taken for objects later found private to the Save or
repeated in the wave, and for ordinary roles whose selection walks no
base. walked_base/verify_bases docs and the README now say "may walk"
and list those cases; fix 1b's claim "a chain selection never reads can
no longer fail a Save that succeeded before" does not hold for them (a
failure that is not a hint's is the Save's). Aligning would change
which group reads a Save plans, so it is left as a follow-up.
Checks: chain_hints 24 of 25 at the parent with the new tests (item 1's
test fails as above), 25 of 25 now; full layerfs-storage set passes (160
tests); PostgreSQL group_directory (4), ancestor_lists (7),
chain_property (1), commit_round_trips (1), identical_ids (3) and
sqlite_publication (13) pass, no NOT_RUN. fmt and Clippy -D warnings
--all-targets on layerfs-storage clean. git diff dd9c855 of
'*/tests/*' adds lines only (fix 3's and this commit's tests).
Same decisions (release storage_gate_bench, lfs-bench-758-pg,
synchronous_commit local, LAYERFS_CONSTRUCTION_WORKERS=1, one sample
each): decisions_digest.sql on f1c_b1, f1c_b3 (before b4) and f1c_b3
(after b4) byte-identical to dig_ref_b1/b3/b4. B1 write 265/399, cold
read 254/257 over 120 waves, stale 0; B3 Save statements/round trips
v0-v9 identical to fix 3; B4 Save 299/490, base fetch 41. SQLite B1 (with
the uncommitted write-Diagnostics print): write 3,091 statements, cold
read 1,401, locate 121/609, read_pack_selections 2,542/789.
Production LOC: 209,227 -> 209,233 (delta +6)
core 42,103 -> 42,109 (+6) layerfs-storage +6
engine 97,433 -> 97,433 (0)
control 59,366 -> 59,366 (0)
api 10,325 -> 10,325 (0)
reference absent (retired R9c; last counted 65,417 at tree 498dd19)
Method: tools/production_loc.py --detail on parent 1b4868b and the staged tree
Deleted tests: none.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review findings on 1b4868b (fix 3) and 22f6892 (fix 1c), each checked against the code first. 1. Fix 3 said hint-bound chains were unaffected; they were not. Once a level had a missing id, Fetch::chain_ahead followed every edge's chain, including chains the read binds: their deeper bases are bound only one level later, so they became guesses, were located authoritatively and bind then returned early. Now only the chains of edges whose base this level has to locate are followed (a cached base was bound from a member or located earlier). Reviewer probe: two chained roots, the second answered without its chain: locates [2, 7] -> [2, 1]; the first chain's six deeper bases are bound with no locate. 2. The guess path decompressed a member's group for every edge unless the operation's decoded-group cache held it, counted nothing, and checked the 4,096-id room only after decoding (and left only the inner loop). Now the room is checked before any decode and ends the whole walk; a decompressed group is kept in a decoded-group cache of the call's own (the existing GroupCache, bounded by DECODED_GROUP_CACHE_BYTES = 512 KiB, dropped on return; a larger body is used once and not kept), so it is decoded at most once per level; every such decompression is counted in prefetch_group_decodes. 3. Presence checks in chain_ahead used LocatorCache::contains_key, which sets the second-chance referenced bit. A new LocatorCache::holds checks presence only, and chain_ahead returns before any check when hints are off. Docs (hints.rs, physical-storage README) now state the remaining effects instead of "untouched / no statement added": the guesses join only a locate the level makes anyway, a wrong guess's row is cached or remembered absent (locator-cache pressure), and a guessed row's authoritative descriptor that contradicts a still-marked member descriptor makes the hint stale, as any authoritative row does. 4. pool/branch.rs `branch chain work`: the totals include the elements below, so a hinted element's record or canonical length could cross the metadata limit at an authoritative element above the first hinted one with suspect=false (hard failure). The check is now suspect whenever any element of the walk was hinted. 5. Docs: remember_pack and the README no longer say a later failure at a hinted element "fails, as before #758" (before #758 a read never used members); it now says the failure stands. save/wave.rs doc line rewrapped under 100 columns. 6. Not changed: `counted` in verify_bases. Every counted stale event evicts every hint, so after one the walk binds nothing more; the failure that ends the walk at a hinted element is reached through elements bound before that eviction and may be the consequence of the same event (for example the member that disagreed). Counting it as a second event would need per-element attribution in the pool reader; it affects only the non-strict diagnostic count (strict refuses at the first event either way). Tests (chain_hints, both fail at 22f6892 and pass now): - a_chain_a_read_binds_adds_no_guesses_to_another_chain_s_locate (from the reviewer's probe): before, locate 1 carried 6 ids of the bound chain; now none. - guesses_decode_each_group_once_per_level_and_count_it: every program page of a changed directory read at once; the guesses' decodes are counted (before: 0 counted) and at most once per distinct chain group. Finding 4 has no dedicated test: reaching it needs a member that names a second stored copy of the right page with a longer record, in a chain near the 139,281-byte metadata limit; the change only reclassifies an already failing walk. No test deleted or changed; chain_hints 27 pass, full layerfs-storage set (41 targets) pass, Clippy -D warnings --all-targets and fmt clean. Counters (lfs-bench-758-pg, synchronous_commit local, LAYERFS_CONSTRUCTION_WORKERS=1, release storage_gate_bench, --strict-hints, one sample each, own schemas f3b_b1 and f3b_b3): - B1 write 265/399; cold read 254 statements, 257 round trips, 120 waves, stale 0 (as fix 3); prefetch_group_decodes now includes the guesses' decodes. - B3 Save round trips v0-v9 210 184 227 165 122 158 190 215 163 180 (as fix 1); B4 Save 299/490, base fetch 41, construct 83 round trips. - Same decisions: B1, B3 and B4 decisions_digest.sql output byte-identical to the 9b144a8 references (decisions_sha256 9e843ede...5956 for B1). - SQLite B1 (temporary write-Diagnostics print, not committed): write 3,091 statements, cold read 1,401; locate 121 / 609, read_pack_selections 2,542 / 789, read_packs 0, chain_verified_bases 0: identical. Production LOC: 209,233 -> 209,266 (delta +33) core 42,109 -> 42,142 (+33) layerfs-storage +33 engine 97,433 -> 97,433 (0) control 59,366 -> 59,366 (0) api 10,325 -> 10,325 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on parent 22f6892 and the staged tree Deleted tests: none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#89 (27f72e3) re-bases a candidate whose chain is at its depth cap (16 whole file, 8 chunk, 8 metadata) or over a chain budget onto the FULL root of that chain. That root delta is the one record of a chain whose base can be any number of versions older than its target, so as an object drifts it grows with history, up to the only limit the comparison set (PREFIX < FULL), and every read of the chain pays it: history-scaling stage 5 read bytes 2.84 -> 3.39 -> 4.46 MB at 50/200/800, B7 cold-read fetched bytes 30.6 -> 91.6 MB from 100 to 1,600 versions. One size rule, written down before any measurement (758-impl/fix4-bound.md, 00:12:00; first fix-4 test run 00:28:55): A re-based trial keeps its delta only when 2 x delta record <= FULL record; otherwise the FULL is stored and starts a new chain. Bound (k = 1.5): the anchor of a re-based chain (root plus the one delta against it) costs a read at most F_root + F_target/2, 1.5 FULL records for equal sizes (before: up to 2). A member at depth d reads at most that plus its d - 1 one-version deltas: whole file <= 1.5 F + 15 delta_v, chunk and metadata <= 1.5 F + 7 delta_v. The caps enter only through those inner deltas, which the rule does not touch. Why 1/2: storing the FULL costs F - D more bytes once and saves about D on every later read through that record, so it repays itself within one read exactly when D > F/2. Storage bound: a firing adds < F/2 and can only happen at a re-base, at most once per C + 1 versions of a lineage: < F/(2(C + 1)) per version (1/34 F whole file, 1/18 F chunk/metadata); later re-based deltas compare against a newer root, which only shrinks them. Where: payload PREFIX of whole-file and chunk lanes (delta/select.rs, the base trial_base re-based) and COPY/INSERT programs of program pages (inode-table branch, directory and extent pages; delta/branch.rs, on top of `worth`). Measured at selection time with no extra I/O: the PREFIX record length (or program length) against the target's own prepared FULL record (or whole page record), the stored-record quantities the existing comparisons use. Not: a trial against the candidate the caller named, even a FULL one (one version's change); pooled inode leaves (never re-base); readers, decoders, record forms, the format (a FULL is an existing record). The fraction is a constant (REBASED_DELTA_DIVISOR = 2): no branch on size, count, history, Commit size, role or engine. Counters: a firing counts in full_losses and the new DeltaCounters::rebased_full (BranchCounters:: rebased_full for program pages); the chunk losing-base memo notes a firing as a lost trial (its delta is not stored; unchanged otherwise). SQLITE WRITE-BEHAVIOUR CHANGE: core encoding is shared, so a SQLite Store also stores a FULL where a re-based delta would exceed half the FULL. On the SQLite B1 bench it does not fire: write 3,091 statements, cold read 1,401; locate 121 / 609, read_pack_selections 2,542 / 789, read_packs 0, chain_verified_bases 0 (temporary write-Diagnostics print, not committed): identical. The owner may veto this item. Decisions vs the 9b144a8 references (decisions_digest.sql, schemas f4_b1, f4_b3): B1, B3 and B4 byte-identical (decisions_sha256 9e843ede... for B1): the rule fires on none of them, 0 FULLs added, depth histograms, objects, packs and pack bytes unchanged. Storage cost next to read gain, B7 (one history to 1,600 versions, probes without --strict-hints, chain_hint_stale 0 throughout; gate = 9b144a8, whose decisions fixes 1-3 kept; fixes 1-3 changed waves and statements): | probe | gate @100 | fix 4 @100 | gate @400 | fix 4 @400 | gate @1600 | fix 4 @1600 | | pack body bytes | 23,573,989 | 23,627,734 | 56,461,653 | 53,621,691 | 285,128,987 | 181,701,471 | | catalog bytes total | 26,566,656 | 26,607,616 | 66,076,672 | 63,119,360 | 325,042,176 | 217,407,488 | | packs | 383 | 383 | 1,324 | 1,308 | 5,414 | 4,939 | | delta rows (FULL rows = rows - delta) | 9,549 | 9,537 | 38,459 | 38,328 | 153,905 | 153,360 | | bytes per locator | 152.4 | 152.4 | 152.2 | 152.0 | 153.0 | 152.6 | | list bytes per delta row | 39.0 | 39.0 | 40.3 | 40.2 | 41.5 | 41.2 | | cold read fetched bytes | 30,598,828 | 30,776,419 | 59,067,922 | 57,979,428 | 91,627,304 | 75,470,626 | | cold read statements / round trips | 276/279 | 261/264 | 329/332 | 303/306 | 344/347 | 340/343 | | cold read ms (1-min load) | 409.75 | 307.06 (5.0) | 677.68 | 559.81 (9.8) | 844.11 | 594.62 (7.2) | | probe Save statements / round trips | 11/19 | 11/19 | 12/20 | 12/20 | 12/20 | 13/24 | The rule added 12 / 131 / 545 FULL rows by 100 / 400 / 1,600 versions and cut pack bytes by 36 % at 1,600 (the growing root deltas it replaces were larger than the FULLs). Fetched bytes fall 18 % at 1,600 but still grow 2.45x from 100 to 1,600 (gate 2.99x): packs read 1,220 -> 3,186, so the remaining growth is in how many packs and groups the 72 heads' chains span (group-granular reads), not in record bytes, which the rule bounds. B7 constant rows therefore still fail; the bound is not retuned. History scaling (postgresql_history_scaling, staged, port 55759): stages 1-4 pass; stage 5 still FAILS on its unchanged equality asserts. @50 read (4,7,3,1) save (11,19,3) read_bytes 2,840,418 packs 2 @200 read (4,7,3,1) save (12,23,4) read_bytes 3,427,039 packs 2 @800 read (4,7,3,1) save (12,20,3) read_bytes 3,586,855 packs 2 (gate: @200 save (14,25,3) 3,392,789; @800 read (5,8,3,1) save (15,26,3) 4,463,241 packs 3). Read statements and packs are now equal at all three probes; read bytes at 800 fall 20 % and grow 4.7 % from 200 to 800 (gate 31.5 %), but the test asserts byte-exact equality across checkpoints, which a drift-dependent root delta (bounded, not constant) cannot give, and the Save counts differ. At 800 the Store holds 84,626 objects, 7,744 FULL, 2,529 packs, 96,094,720 pack bytes. Tests: - New rebased_delta_fraction (both fail at the parent and pass now): a drifting whole file (cap 2, one eighth replaced per version) stores FULL at the re-base whose delta passes half the FULL (parent: depths [0,1,2,1,2,1,2,1], now [0,1,2,1,2,0,1,2]) and every version reads within F + F/2 + one-version deltas; a drifting 1 MiB file's extent page (metadata cap 2) is stored whole when its re-based program passes half (parent: version 9 page chain 3,676 B > 1.5 x 2,365 B). - DECISION CHANGE, existing test now failing, left unchanged for the coordinator: inode_branch_deltas branch_chains_grow_to_the_cap_re_base_onto_their_root_and_read_back asserts full_branches == 0 and depths[0] == 0 ("no branch is stored whole after the initial table (#89)"). On its 50,000-inode two-level table both re-based inode-branch programs (rebased 2) exceed half the whole branch (rows are incompressible object ids, nine spread edits later) and are stored whole (rebased_full 2, full_branches 2). Every other assertion of the test holds. Not edited: allowing whole branches would loosen it. - Full layerfs-storage set: 41 targets pass, inode_branch_deltas fails as above. layerfs-persistence: postgresql_ancestor_lists 7, postgresql_compact_fixtures 10, postgresql_chain_property 1, sqlite_publication 13, sqlite_compact_repack 12, old_format_open 2, postgresql_commit_round_trips 1, signature_ring_order 1, inode_branch_delta_custody 2; layerfs-store-service sdk_append_deltas, sdk_chunk_deltas, postgresql_round_trips 2, sdk_large_file_budget 5: all pass, none NOT_RUN. Clippy -D warnings --all-targets and fmt clean on layerfs-storage. Production LOC: 209,266 -> 209,285 (delta +19) core 42,142 -> 42,161 (+19) layerfs-storage +19 engine 97,433 -> 97,433 (0) control 59,366 -> 59,366 (0) api 10,325 -> 10,325 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on parent f0b1941 and the staged tree Deleted tests: none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review findings on f0b1941 (fix 3b) and e6d8bea (fix 4), each checked against the code first. One counter change; everything else is documentation. No decision path changes. B-2 (fix 4 storage bound). The bound "a firing at most once per C + 1 versions, < F/(2(C + 1)) per version (1/34 F whole file, 1/18 F chunk and metadata)" in encoding.md, fix 4's message and fix4-bound.md held only for depth-cap re-bases. trial_base (and branch.rs trial) also re-bases when the chain does not fit the canonical (4 x cutoff) or encoded (2 x cutoff) budget. Corrected bound, per effective chain length L = min(C, 1 + largest d whose candidate fits), where a depth-d candidate fits when (d + 2)·S <= 4K and E + sum(e_i, i <= d) + S <= 2K (program page: (d + 2)·P <= 65,536): a firing adds < F/2, the next re-base of the lineage is L + 1 versions after it, so < F/(2(L + 1)) per version; a depth-0 candidate is never re-based, so L >= 1 and the worst case is < F/4 per version. At the 128 KiB default: incompressible whole file near the cutoff L = 1 (2S + e_1 > 256 KiB), < F/4; compressible S <= K, L >= 3 (4S <= 512 KiB), < F/8; just over K with its envelope, L = 2, < F/6; L = 16 (< F/34) only at S <= 30,840 B (17S <= 512 KiB); chunks L >= 6 (7 x ~32.8 KiB <= 256 KiB), < F/14, L = 8 (< F/18) with small deltas; 8,192 B program pages L = 7 (9P > 65,536), < F/16; pages <= 7,281 B L = 8, < F/18. Restated in encoding.md (with the table) and in an appended, dated "Correction after review" section of fix4-bound.md (the pre-measurement text is unchanged). The claim that later re-based deltas "can only shrink" is withdrawn as a bound. B-3 (counter). DeltaCounters::rebased_full counted every re-based PREFIX over half the FULL, including ones not shorter than the FULL that lost the comparison anyway; BranchCounters::rebased_full counted only changed decisions (after `worth`). select.rs now counts only when the PREFIX was shorter than the FULL and the rule rejected it, and both counters are documented as "decisions the rule changed". Decisions are unchanged: `won` was shorter && !(rebased && over half) and is now shorter && !(shorter && rebased && over half), the same predicate; the losing-base memo takes the same `won`; full_losses is unchanged. So B1, B3 and B4 decisions equal fix 4's (themselves equal to the 9b144a8 references); no digest rerun (no decision path touched). SQLite: same code path, decisions unchanged, counter only. B-4 (wording). The physical-storage README row and the handbook said a chain's anchor reads at most 1.5 FULL records; that holds only for equal sizes. Both now state F_root + F_target/2. B-5 (fix4-bound.md). The read bound took every inner delta as one version's change; a delta against a ring-proposed base (a whole file at a new path), or a first delta tried directly against a FULL candidate, is held only by PREFIX < FULL. Noted in the correction section and encoding.md; a firing on a re-based ring proposal adds < F_t/2 for that object with no per-version spreading. A-1 (fix 3b wording). The README hints row, the hints.rs chain_ahead doc and the cached_base doc said guesses decode a group at most once per level / call. The per-call GroupCache evicts least recently used bodies at DECODED_GROUP_CACHE_BYTES (512 KiB) and never keeps a larger body, so a level interleaving more distinct groups than fit decodes an evicted one again. Wording fixed (counts were already right); the chain_hints test row now says "count every decode and, when a level's groups fit, decode each group once". No test renamed. A-4 (GroupCache::insert). The contract said it retains authenticated input; the per-call cache of chain_ahead holds unauthenticated decoded bytes (private, dropped on return). The doc now says what each owner holds. A-2, A-3: no change. Tests (additions only; inode_branch_deltas.rs untouched): - New rebased_delta_fraction a_re_based_prefix_that_loses_anyway_is_not_counted_as_the_rule_firing: whole-file cap 2, versions 1-2 drift, version 3 fresh noise re-based onto version 0, its PREFIX loses on its own (depths [0,1,2,0], rebased 1, trials 1, full_losses 1). At e6d8bea's select.rs it fails (rebased_full left 1, right 0); now passes. - layerfs-storage full set (t.py -t 100, --no-fail-fast): 41 targets ok; inode_branch_deltas branch_chains_grow_to_the_cap_re_base_onto_their_ root_and_read_back still fails as at fix 4 (full_branches 2, rebased_full 2; awaiting the owner's ruling), unchanged. - Clippy -D warnings --all-targets and fmt --check clean on layerfs-storage. Production LOC: 209,285 -> 209,287 (delta +2) core 42,161 -> 42,163 (+2) layerfs-storage +2 engine 97,433 -> 97,433 (0) control 59,366 -> 59,366 (0) api 10,325 -> 10,325 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on parent e6d8bea and the staged tree Deleted tests: none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ule; new firing test Fix 4 (e6d8bea) stores a FULL where a #89 re-based program would be over half the whole record. On inode_branch_deltas' branch_chains_grow_to_the_cap_re_base_onto_their_root_and_read_back fixture both re-based root-branch programs are over half (the spread edits replace most of the root branch's child references before the cap), so the rule stores them whole and the test failed at HEAD 795bbae on its full_branches == 0 assertion (line 200: left 2, right 0; counters rebased 2, rebased_full 2, full_branches 2, depths [2,18,7,3,2,2,2,2,2]). Owner decision (option C, "C, keep fixture too"): keep fix 4; keep every assertion of that test; change only its fixture so its re-based programs stay within half; put the ORIGINAL fixture, unchanged, into a new test that asserts the firing exactly. Fixture, old and new, side by side (everything else is the same in both tests: StoragePolicy::default(), the 50,000-inode initial table, 20 rounds, one edit per round, value(serial, version) with the version bumped): | parameter | old (795bbae) and new firing test | adjusted old test | | helper | small_commits (unchanged) | clustered_commits (new) | | serial | 1 + (round * 7_919) % 50_000 | 1 + (round * 7_919) % 16 | | edits reach | whole table (many leaves/children) | serials 1..16 (one leaf) | | rounds | 0..20, one edit each | 0..20, one edit each | | rebased | 2 (root branch only) | 4 (root and its child) | | rebased_full | 2 at HEAD (0 before fix 4) | 0 | | full_branches | 2 at HEAD (0 before fix 4) | 0 | | depths[0..9] | [2,18,7,3,2,2,2,2,2] at HEAD | [0,6,6,6,6,4,4,4,4] | With edits in one leaf the root branch and the one child branch each differ from their chain's root in one child reference, so every re-based program stays far below half the whole branch: chains still grow to the cap (depth_capped 4) and re-base onto their root (rebased 4), and every program is kept. Tests (core/crates/layerfs-storage/tests/inode_branch_deltas.rs): - branch_chains_grow_to_the_cap_re_base_onto_their_root_and_read_back: the fixture call small_commits -> clustered_commits; every existing assertion byte-identical; two assertions added: rebased >= 1 and rebased_full == 0. - New re_based_branch_programs_over_half_the_whole_are_stored_whole_and_read_back: the original input (small_commits, unchanged, 20 rounds from the default initial table); asserts per round full_branches == rebased_full and depths[0] == full_branches, and in total rebased == depth_capped == 2, full_branches == rebased_full == 2 (the exact count observed on that input), depths[0] == full_branches, depths[0..9] == [2,18,7,3,2,2,2,2,2], depths[9..] empty, one trial per branch, and that every table reads back value for value (read_all) and every branch page byte for byte (fresh reader; ObjectId::for_bytes(page) == id for the root and each child branch page). - New helpers clustered_commits and branch_pages_match_their_ids; small_commits, commit, initial and every other test unchanged. Assertion diff (git diff 795bbae -- '*/tests/*'): the only removed lines are the fixture call - let outcome = small_commits(&storage, &mut root, &mut versions, 1, round).remove(0); two comment lines, rewritten, and the import line (now also importing decode_inode_page, InodePage). No assert line was removed or changed; added in the old test: + assert!(total.rebased >= 1, "{total:?}"); + assert_eq!(total.rebased_full, 0, "{total:?}"); Evidence (t.py -t 100, one run each): - HEAD 795bbae, original test file: branch_chains_grow... FAILED at line 200 (full_branches left 2, right 0). - This tree: inode_branch_deltas 5/5 pass. - Parent of fix 4 (f0b1941, scratch git archive with a cloned target): the full new file does not compile there (E0609: no field rebased_full, four sites). With exactly those four rebased_full assertion lines dropped (DIAGNOSTIC copy): the adjusted old test passes with all its original assertions (the #89 re-base is covered independently of fix 4), and the new firing test FAILS on full_branches == 2 (left 0, right 2; depths [0,18,7,4,3,2,2,2,2]): before the rule nothing is stored whole. - Full layerfs-storage set: 42 result lines (41 test targets and the doc tests), all ok, 0 failed, wall 8.7 s. cargo +1.85.1 fmt --check and Clippy -D warnings --all-targets on layerfs-storage clean. Docs: docs/architecture/core/physical-storage/README.md gains the inode_branch_deltas row in its Demonstration table (it had none). Production LOC: 209,287 -> 209,287 (delta 0) core 42,163 -> 42,163 (0) engine 97,433 -> 97,433 (0) control 59,366 -> 59,366 (0) api 10,325 -> 10,325 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on parent 795bbae and the staged tree Deleted tests: none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 24, 2026
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.
Summary
#758: 2.0 PostgreSQL storage with ancestor-location lists and group-ranged reads, built to design B (gate amendment of 2026-11-23).
locate_chainson PostgreSQL is two statements:ancestorslists and the roots' own pack rows;storage_gate_bench) and the history-scaling test.15 commits on
8676948f10, 106 files, +10,626 / −262. Each commit carries its production LOC block.Gate result and owner decision
The one frozen gate run (2026-11-24,
960a823691) does not pass. The full table is in the #758 status comment.Owner decision, 2026-11-24: "merge 758 and accept b6 regression". The other failed rows were accepted as minor ("i think others are quite minor?" → "proceed"):
Also accepted:
Tracked, not accepted silently: #773, B7 history growth (cold read 2.03× and fetched bytes 2.45× from 100 to 1,600 versions; head mount 1.68×; mostly between 100 and 400 versions).
Related:
Tests
960a823691: every layerfs-storage and layerfs-persistence target passes, except history-scaling stage 5 (accepted above). clippy and fmt are clean on both crates.--no-fail-fast:8676948f10's own set.87e46c652a):87e46c652a, or passed on re-run.layerfs_v2_0_0+ this PR + the private-network branch. layerfs-storage 166/0 and layerfs-persistence 566/0 on macOS.🤖 Generated with Claude Code