Skip to content

fix(splice): derive recent-problems from problem-card frontmatter — the KNOWLEDGE.md zombie lies to every session (#654) - #656

Open
aarontrowbridge wants to merge 4 commits into
mainfrom
654-fix-splice-recent-problems
Open

fix(splice): derive recent-problems from problem-card frontmatter — the KNOWLEDGE.md zombie lies to every session (#654)#656
aarontrowbridge wants to merge 4 commits into
mainfrom
654-fix-splice-recent-problems

Conversation

@aarontrowbridge

Copy link
Copy Markdown
Member

Closes #654

What

Every session's system prompt derived "Your recent problems" from KNOWLEDGE.md — a vault index file frozen by design (the distiller stopped writing it) whose lines had gone stale: it claimed a problem was "solved 20×" while the problem card it links records 29 solves. The distillate's actual source of truth — the problem cards' frontmatter, maintained, versioned, provenance-clean — was one indirection away and unread.

The splice now derives the section directly from problem-card frontmatter: scan <vault>/amicode/problems/*.md, parse frontmatter (slug, platform, kind, target, status, best fidelity, solve count, last-seen), sort by last-seen freshest-first, cap at the same 50-line budget, render the same section format the prompt already consumes. The zombie index is dead; every future session sees the truth.

Acceptance criteria — evidence

  • Derived from frontmatter, not KNOWLEDGE.md — sort/order/cap/malformed-skip covered by new tests (22/22 in the splice suite): cards sort by last_seen freshest-first, 60 cards cap to 50 bullets, malformed frontmatter skips, missing last_seen sorts last, zero cards omits the section.
  • Format-compatible with the current prompt — a golden test pins the full rendered block byte-for-byte against the distiller spec's documented historical line shape, warm-start guidance footer included.
  • The zombie lie is dead — the named test: a card recording 29 solves is reported even when the frozen index still claims 20 (toContain('solved 29×'), not.toContain('20×')). Verified end-to-end against the live vault: 23 cards, x-gate reports solved 29×, best F verbatim 0.9999858416888963 (the splice never re-rounds a fidelity — the old index's rounded 0.999986 was itself a small lie).
  • No product code reads KNOWLEDGE.md — grep clean: only the test's deliberate stale fixture and doc comments remain. (The distiller agent's prompt-level match-before-create read of the file is documented behavior, out of this slice's scope; DEMOS.md's frozen-but-read status is a separate flagged slice.)

Director gates (run independently on this branch)

Design choices worth review

  • Hand-rolled frontmatter parser rather than reusing the repo's YAML parser: stack_state.ts is pinned node-builtin-only (the plugin's embedded runtime can't resolve the extension's deps — the same reason its TOML marker parsing is regex-lite). The parser is defensive: malformed cards are skipped, never crash the splice.
  • Fidelities render verbatim from the card — no re-rounding (toFixed(6) would round 0.9999997 up to 1.000000).
  • attempted/failed problems render "ATTEMPTED (N failed)" from solve_count, dropping the old wording that conflated failed runs with solve count.
  • pulse_ref's pulses/ prefix is stripped to preserve the historical pulse: <id> line shape.

Leftovers flagged (not this slice)

  • DEMOS.md is also frozen-but-spliced — same disease, separate slice.
  • The distiller agent's prompt-level read of KNOWLEDGE.md (match-before-create) is documented behavior, not a code path — revisit when the distiller transport is re-armed.

Merge

Awaiting human review per the campaign's standing discipline. CI runs on this PR.

The 'Your recent problems' splice read amicode/KNOWLEDGE.md — a flat index
the distiller froze (it no longer writes it), so every session boot inherited
stale numbers: the index claimed 'solved 20×' next to a card recording 29
solves, and the Aug 22+ sweep backlog never reached the prompt.

Derive the bullets from the cards' frontmatter instead (the distiller-
maintained source of truth): scan <vault>/amicode/problems/*.md, parse the
scalar frontmatter fields (slug, platform, problem_kind, target, status,
best_fidelity, solve_count, last_seen), render the same line shape the index
carried (DISTILLER.md historical shape), cap at the same 50-line budget.
best_fidelity renders verbatim — the splice never re-rounds a number.

The frontmatter parser is hand-rolled (node builtins only — stack_state.ts
runs in the plugin's embedded Bun runtime where the yaml package does not
resolve; same reason parseMarker is a regex-lite TOML parse).

#654
The 50-line budget now keeps the 50 most recently touched cards, not the
first 50 filenames. Missing last_seen sorts last; ties keep filename order
(stable sort). last_seen values are ISO dates, so lexicographic order is
chronological.

#654
A card without a well-formed frontmatter block (README, truncated file) is
skipped, and an unreadable card file is skipped — one bad file never takes
down the whole stack-state block. Pins added for the two behaviors the
preceding cycles already delivered: a card missing last_seen sorts last
(ties keep filename order), and a vault with zero cards omits the section.

#654
… splice

No product code path reads the frozen KNOWLEDGE.md any more: the splice
reads problem cards, and the only remaining code mention is distill_batch
.mjs's write-only bootstrap (existsSync + create for the distiller's
migration-pointer append — distiller surface, out of scope). Update the
docs that still described the splice as an index read (extension AGENTS.md
live-context block, DISTILLER.md frozen-section note, vault_store.ts header).

#654
@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7f777300-99ca-4b3c-9a8c-3bb422be8620


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@aarontrowbridge
aarontrowbridge marked this pull request as ready for review August 31, 2026 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

splice: derive recent-problems from problem-card frontmatter — the KNOWLEDGE.md zombie lies to every session

1 participant