Repository navigation
feat(#45): consolidation that has to earn its merge — deterministic, read-proven, proposal-only - #100
Merged
Conversation
abogartz
force-pushed
the
feat/status-self-metrics
branch
from
October 25, 2026 19:46
f454d4e to
0c5786e
Compare
abogartz
force-pushed
the
feat/consolidation-pass
branch
from
October 25, 2026 19:46
6a8cfce to
361ec17
Compare
added 2 commits
October 25, 2026 12:58
…read-proven, proposal-only Episodic→semantic consolidation is the step the surveys agree is fragile (arXiv:2603.07670: "rarely automatic… fragile and hard to validate"), and NOOA's numbers are the warning label: reflection records were 22% of rows and ~1% of reads, and abstraction hurt pinpoint lookup. So the pass is built to say no more often than yes: - DETERMINISTIC MERGE. The canonical row is the survivor's prose verbatim plus the absorbed rows' aliases as keywords. No model rewrites anything: a rewrite cannot be diffed, audited, or proven to preserve meaning, and this plugin ships no model. kw is indexed and never renders (#40), so a merge never grows the injected bytes of the row that keeps them. - PROVEN READS, PER CLUSTER. Every read the use ledger recorded for the cluster is replayed against the merged store. A merge is proposed only when the canonical row catches at least as many of the cluster's own reads as the BEST single member did alone. A cluster with no recorded reads is reported unmeasured and never merged on resemblance. - PROPOSALS, NOT WRITES. memory_consolidate writes nothing — the tests assert the store is identical before and after the call. Output ends with the exact memory_merge_review call that resolves each proposal; resolving stays supersede-not-delete, recoverable via memory_undo. - Most recently used member is never a loser (#42's rule, inherited here). - Clusters never cross scope or type, and open threads are excluded: a live plan is not episodic material to compress. The ticket's HOLD asked for ~a month of hits data before building this, because the cost is not obviously paid. The harness answers that directly, per cluster, on every run, so the gate is evidence instead of a calendar. Measured on the shipped eval dataset: 200 rows -> 52, R@3 52 -> 53, R@1 52 -> 50, store-wide injected characters 25945c -> 6933c. The trade is asserted, not assumed: R@3 must not fall, at most 5 of 105 queries may see a bigger block, and no query may grow by more than 100 characters. Cluster bookkeeping uses object identity, not ts: the eval store legitimately holds rows sharing a timestamp, and a ts-keyed filter silently absorbs an entire cluster into its survivor. Test: test/consolidate.test.ts (clustering boundaries, open-row and superseded exclusion, jaccard floor, survivor by use recency, byte-identical canonical prose, the acceptance rule including the unmeasured refusal), test/consolidate- bench.test.ts (non-regression and budget bounds on the real dataset), test/consolidate-tool.test.ts (proposes with a read history, reports unmeasured without one, scope-limits, and leaves the store byte-identical). ticket: #45
Same class as the #97 review note, one layer up: the pool sort, the cluster-order sort and the survivor tie-break in survivorFor all compared ISO stamps as strings, so a legacy second-precision row could be called newer than a millisecond row from the same second plus change. cmpTs is now exported from inject.ts and is the single comparator for recency.
abogartz
force-pushed
the
feat/status-self-metrics
branch
from
October 25, 2026 20:00
0c5786e to
6d1858b
Compare
abogartz
force-pushed
the
feat/consolidation-pass
branch
from
October 25, 2026 20:01
361ec17 to
a77fbec
Compare
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.
Closes #45
Part of #84, and the last ticket in the stack: #96 → #97 → #98 → #99 → this PR. Base is
feat/status-self-metricsbecause the acceptance rule consumes the use ledger #42 shipped.The HOLD, and why it is lifted
The ticket said: build only after #42 has ~a month of hits data, because consolidation is fragile and may not earn its cost (NOOA's reflection records: 22% of rows, ~1% of reads; abstraction hurt pinpoint lookup). That reasoning is sound and this PR keeps it intact — it just gets its evidence from the harness instead of a calendar. Every proposal is measured against real reads on every run, and
test/consolidate-bench.test.tsfails CI if the trade goes negative. If the numbers turn out bad in production, the tool proposes nothing and nothing is merged.What it does
memory_consolidate(new tool, read-only) finds near-duplicate settled rows and proposes merges. Four rules make it safe:1. Deterministic merge. The canonical row is the survivor's prose verbatim, plus the absorbed rows' distinctive vocabulary as
kw. No model rewrites anything — a rewrite cannot be diffed, audited, or proven to preserve meaning, and this plugin ships no model.kwis indexed and never rendered (#40), so inheriting aliases never grows the injected bytes of the row that keeps them.2. Proven reads, per cluster. Every read the ledger recorded for the cluster is replayed against the merged store. A merge is proposed only when the canonical row catches at least as many of the cluster's own reads as the best single member did alone — the acceptance rule from the ticket, literally. A cluster with no recorded reads is reported unmeasured and never merged on resemblance. That refusal is tested as a first-class outcome, not a fallback.
3. Proposals, not writes. Nothing is written. The report ends with the exact
memory_merge_review(loser=…, survivor=…, reason="consolidate <id>")call that resolves each proposal, and resolving stays supersede-not-delete (recoverable viamemory_undo). A test asserts the store is byte-identical across the call.4. The most recently used member is never the loser (#42's rule, inherited). Clusters never cross scope or type, and open threads are excluded — a live plan is not episodic material to compress.
Measured on the shipped eval dataset
This is the honest trade, printed by the test and asserted in CI:
R@1 falls by 2 and R@3 rises by 1. The reason is structural, not a bug: the dataset is 3/4 near-duplicate prose, so merging rewrites the entire IDF landscape, and a canonical row that inherited an absorbed twin's aliases sometimes wins a slot a neighbour used to hold. Assertions: R@3 must not fall; at most 5 of 105 queries may see a larger block; no query may grow by more than 100 characters. Two queries do grow, by 48 characters worst-case. A claim of "consolidation is free" would be a lie worth catching.
Tests
test/consolidate.test.ts— clustering boundaries (scope, type, jaccard floor configurable and pinned at 0.55), open-thread and superseded-row exclusion, survivor chosen by use recency rather than newest row, canonical prose byte-identical to the survivor, the acceptance rule including the unmeasured refusal, andreadsForonly crediting cluster members.test/consolidate-bench.test.ts— the non-regression and budget bounds above, run against the real dataset (one shared pass, ~7s).test/consolidate-tool.test.ts— the shipped tool: proposes when there is read history, reports unmeasured when there is none, honoursscope, and leaves the store byte-identical.memory_consolidateis now 14 tools; its exact JSON Schema is pinned intest/boundaries.test.ts).tscclean; Biome clean; terminal merge gate green (11 e2e).Review focus
ReadSetfidelity. The acceptance rule is only as honest as the ledger'sterms.readReads()replays per-line(terms, rows)pairs; terms are capped at 8 bysharedTerms()(P2: Use-based reinforcement — recall-hit log, recency-of-use boost, never-retrieved report #42), so a read that landed on 12 shared concepts is replayed with 8. Does that understate the merge's risk enough to matter?clustersForis O(n²) jaccard. Correct and fine for a manual command at current store sizes; it is not something to schedule.ts. Cluster bookkeeping uses row references because the eval store legitimately holds rows sharing a timestamp; a ts-keyed filter absorbs an entire cluster into its survivor. Ledger lookups (use) stay ts-keyed, which is correct there since ts is the row id in the store.