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
Open
Conversation
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
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 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. Comment |
aarontrowbridge
marked this pull request as ready for review
August 31, 2026 00:35
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 #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
KNOWLEDGE.md— sort/order/cap/malformed-skip covered by new tests (22/22 in the splice suite): cards sort bylast_seenfreshest-first, 60 cards cap to 50 bullets, malformed frontmatter skips, missinglast_seensorts last, zero cards omits the section.toContain('solved 29×'),not.toContain('20×')). Verified end-to-end against the live vault: 23 cards, x-gate reportssolved 29×, best F verbatim0.9999858416888963(the splice never re-rounds a fidelity — the old index's rounded 0.999986 was itself a small lie).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)
pnpm --filter amicode typecheck— cleanorigin/main(pasqal venv sandbox + the terminal env-injection family, known issue test: agent-spawn env test is non-hermetic — fails under OPENCODE_CONFIG_CONTENT (server sessions) #645 class) — zero regressionsstack_state.test.ts— 22/22ea169ec; origin/main advanced past it mid-slice (feat: amicode_session tool — spawn sessions from a session as background tabs #639/skill: open-threads — sweep recent sessions, propose a consolidated spawn plan #646/feat(hub-ops): Amicode: Restart Hub Server — client-initiated atomic hub restart #649-650 merged), so the branch was rebased onto current main before final gating — the rebase was clean (no conflicts; splice files untouched by the new merges).Design choices worth review
stack_state.tsis 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.toFixed(6)would round 0.9999997 up to 1.000000).attempted/failedproblems render "ATTEMPTED (N failed)" fromsolve_count, dropping the old wording that conflated failed runs with solve count.pulse_ref'spulses/prefix is stripped to preserve the historicalpulse: <id>line shape.Leftovers flagged (not this slice)
DEMOS.mdis also frozen-but-spliced — same disease, separate slice.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.