Skip to content

feat(#45): consolidation pass — replayed onto main after #100's wrong-base merge - #104

Merged
abogartz merged 2 commits into
mainfrom
feat/consolidation-pass-v2
Oct 25, 2026
Merged

abogartz merged 2 commits into
mainfrom
feat/consolidation-pass-v2

Conversation

@abogartz

Copy link
Copy Markdown
Owner

Why this PR exists

PR #100 was merged into the wrong base. The stack retarget loop had merged #96–#99 into main when #100's base was left pointing at feat/status-self-metrics — a branch already merged — so GitHub merged its head into that stale branch instead of main. The merge "succeeded" (e86e923) but moved nothing into main: after it, main lacked src/consolidate.ts and its three test files. Caught by diffing main against the old branch tip after the last merge.

This branch is the two #45 commits (b5e38a0 feat + a77fbec fix, cherry-picked with content verified byte-identical to the reviewed #100 head) replayed on current main. Full suite: 461 pass / 5 skip / 0 fail (43 files); tsc and Biome clean.

What it ships

Unchanged from #100: deterministic consolidation proposals (cluster by shared vocabulary, survivor = most recently used member, canonical = survivor's prose + absorbed aliases, no model rewrite), accepted only when replayed ledger reads prove the merged row catches ≥ the best single member's reads, unmeasured clusters refused. memory_consolidate is the 14th tool and writes nothing.

Closes #45 (the review record stays in #100: approved approach, adversarial notes all resolved before merge).

review added 2 commits October 25, 2026 13:13
…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
abogartz merged commit 7d0fbe2 into main Oct 25, 2026
3 checks passed
@abogartz-opencode-self-improvement

Copy link
Copy Markdown

🎉 This PR is included in version 0.13.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@WhollyMindless

Copy link
Copy Markdown
Contributor

Post-merge follow-up: I reproduced two differences between the proposal and its printed resolution command at both 8610b45 and current main (43346f0), using the real tools with disposable stores.

  1. A read the proposal says will survive can disappear after resolution. I seeded two settled patterns in the same scope: “Run the saffron task to prepare the benchmark artifacts from the repository root before publishing the report” and the same sentence with “cobalt”. I called memory_recall once for each task name. Both found their row. memory_consolidate then printed 2 logged · best member alone 1 · merged 2. I executed its printed memory_merge_review call successfully. Repeating the original saffron query returned No matching memories. The replay credits a hypothetical survivor with the absorbed row’s keywords, but the resolver only retires the loser. It never adds those keywords to the stored survivor.
  2. A three-row proposal prints only one of the two required retirements. With a third matching pattern for “indigo”, the report listed both rows to absorb and projected 3 rows → 1. Its single resolution call succeeded and left 2 active rows. The rendered call uses only p.losers[0].

The proposal itself stayed read-only; these differences appeared after following its resolution instruction in the fixture. An end-to-end regression that executes the printed instruction, repeats the original queries, and counts the active rows would cover both.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

P3: Consolidation promotion pass (dry-run via memory_merge_review) — gated on #42 usage data

2 participants