Make decision knowledge lifecycle-addressable and retrieval-efficient #521

Closed
opened 2026-07-21 01:05:00 +02:00 by timothy · 3 comments
Owner

Problem

docs/decisions.md has the correct intent—preserve why the code behaves as it does so agents do not relitigate or recreate established functionality—but its current form is optimized for append safety rather than current-state retrieval.

Audit evidence:

  • docs/decisions.md is currently about 2,468 lines despite its 1,800-line consolidation warning.
  • Including the four topic files, the decision corpus is about 3,469 lines.
  • The warning measures only the main file, so topic extraction hides aggregate startup/read cost.
  • The release ritual can only prune records already marked > **Superseded …**, but the corpus currently contains no actual supersession banners/index tags.
  • Reversals and obsolescence appear inside prose instead (for example #390's lane move being reversed by #406, and an older #411 measurement being described as superseded).
  • A chronological title index is useful for archaeology but weak for task-driven retrieval.
  • Fresh agents are currently told to read the corpus broadly before their task is known.

This issue comes from a bounded knowledge-retrieval audit in timothy/adversarial-reviewer.

Decision

Keep Git-backed Markdown as the authoritative decision source, but separate the current active view from historical rationale.

MemPalace may retrieve candidate records, but agents must verify status and content against canonical Markdown.

Supersession must be recorded in the same PR that changes the governed behavior. A release is too late to infer it.

Required information model

Use a stable decision identity and explicit lifecycle. The exact syntax may be refined during implementation, but it must support deterministic validation of:

  • Decision key: stable subject identity such as ci.runner-placement.
  • Effective date/version.
  • Status: active, superseded, or retired.
  • Supersedes: predecessor or none.
  • Superseded by: successor or none.
  • Current rule: compact statement placed before long rationale.
  • Retrieval signals: relevant concepts, paths, symbols, endpoints, issue numbers.
  • Canonical mechanics: links to the current convention/source/test anchors.
  • Rationale and rejected alternatives.

Semantics:

  • active: current authority.
  • superseded: replaced by another decision; successor must be explicit.
  • retired: historically valid, but its governed surface no longer exists.
  • “Relocated” and “consolidated” are document-maintenance actions, not decision statuses.
  • Rejected alternatives remain rationale inside an accepted record; they are not active decisions.

Target document architecture

  1. Keep docs/decisions.md small and make it the active catalog/task router.
  2. Keep topic files for coherent current decision clusters.
  3. Move superseded/retired/full historical material outside the default startup path, for example into release-scoped archives.
  4. Preserve links from current records to historical rationale.
  5. Keep current mechanics in convention documents; decision records explain why and point to those mechanics.
  6. Keep issue/PR comments as evidence, not the sole home of a current rule.

The implementation may choose generated or hand-maintained catalog sections, but the active catalog must be mechanically checked against the canonical records.

Write-time lifecycle

When a PR changes a governed decision:

  1. Add the new decision record.
  2. Use the same stable key.
  3. Mark/link the predecessor as superseded in the same PR.
  4. Update the affected current convention document.
  5. Use the existing [decisions-edit] escape only for this explicit lifecycle transition or a factual correction.
  6. Validate that there is no more than one active record per key.

This turns supersession into a transactional write-time responsibility instead of a release-time archaeology task.

Release maintenance

Change the release ritual from “discover superseded entries” to:

  • validate lifecycle metadata and reciprocal links;
  • archive records already marked superseded/retired;
  • refresh/generate the active catalog;
  • check current convention/source/test anchors;
  • enforce an aggregate active-corpus context budget, not only docs/decisions.md line count;
  • report unresolved legacy records separately.

Do not silently delete rationale. Git history and/or explicit archives preserve it without putting it in every fresh agent's default context.

Retrieval contract

A fresh agent should receive only:

  1. the compact active catalog/task map;
  2. active records relevant to the selected issue;
  3. linked convention sections and source/test anchors;
  4. historical records only when rationale or a conflict requires them.

For MemPalace:

  • index active status/key/current-rule near the beginning of every record;
  • constrain search to the ErsatzTV/project wing;
  • retrieve candidates at a bounded k;
  • verify status and exact text against Markdown;
  • never let semantic similarity choose a superseded record over an active record.

Gitea history ingestion is tracked by timothy/server-management#642. Startup/retrieval workflow changes are tracked separately in #520.

Migration plan

  1. Define and validate the record schema prospectively.
  2. Build the compact active catalog and archive structure.
  3. Inventory legacy entries by stable subject—not merely chronology.
  4. Identify explicit reversals/retirements, beginning with known prose-only cases.
  5. Reconcile duplicate or contradictory active rules with their current convention/source evidence.
  6. Migrate in bounded topic batches to avoid a single conflict-heavy rewrite.
  7. Remove the broad legacy corpus from mandatory startup only after the active catalog is complete.
  8. Preserve an auditable mapping from every migrated legacy heading to its active record or archive location.

Validation

Add a lightweight deterministic validator, used locally and in the existing decisions CI job, that checks at least:

  • required metadata on structured records;
  • valid status values;
  • stable-key format;
  • at most one active record per key;
  • resolvable and reciprocal supersession links;
  • active catalog completeness;
  • archive/current placement consistency;
  • aggregate active-corpus line/token budget;
  • broken Markdown/source/test links where practical.

The validator may tolerate explicitly identified unmigrated legacy entries during phased migration, but the remaining count must be visible and trend to zero.

Retrieval evaluation

Create a bounded question bank covering:

  • paraphrased task-to-decision discovery;
  • exact code/path lookups;
  • active vs superseded decisions;
  • retired features;
  • rationale/rejected alternatives;
  • a known convention whose implementation already exists, so the answer prevents reimplementation.

Success must measure correct active-record selection and citation, not merely retrieval of a semantically related passage.

Out of scope

  • Making MemPalace the source of truth.
  • Storing live queue state in decision documents.
  • Treating all issue comments as decisions.
  • Bulk rewriting without an auditable legacy mapping.
  • Deleting historical rationale solely to meet a line target.

Done-when

  • Decision lifecycle/schema is documented with active/superseded/retired semantics.
  • Supersession is required in the same PR as the replacing decision.
  • A compact active decision catalog/task router exists.
  • Topic/current/archive responsibilities are explicit.
  • Every migrated record has stable identity, status, current rule, retrieval signals, and canonical anchors.
  • Known prose-only reversals/retirements are reconciled.
  • A deterministic validator enforces keys, lifecycle links, and catalog completeness.
  • The CI/read-cost check measures the aggregate active corpus rather than only one file.
  • Release docs archive already-classified history instead of asking the releaser to infer supersession.
  • Legacy migration is complete or has an explicit bounded remainder with no ambiguous active rules.
  • The active-vs-superseded retrieval benchmark passes with canonical citations.
  • Startup docs point agents to the compact active view, not the full historical corpus.
  • Relevant docs are updated in the same PR(s).
  • Independent adversarial review passed.
## Problem `docs/decisions.md` has the correct intent—preserve why the code behaves as it does so agents do not relitigate or recreate established functionality—but its current form is optimized for append safety rather than current-state retrieval. Audit evidence: - `docs/decisions.md` is currently about 2,468 lines despite its 1,800-line consolidation warning. - Including the four topic files, the decision corpus is about 3,469 lines. - The warning measures only the main file, so topic extraction hides aggregate startup/read cost. - The release ritual can only prune records already marked `> **Superseded …**`, but the corpus currently contains no actual supersession banners/index tags. - Reversals and obsolescence appear inside prose instead (for example #390's lane move being reversed by #406, and an older #411 measurement being described as superseded). - A chronological title index is useful for archaeology but weak for task-driven retrieval. - Fresh agents are currently told to read the corpus broadly before their task is known. This issue comes from a bounded knowledge-retrieval audit in `timothy/adversarial-reviewer`. ## Decision Keep Git-backed Markdown as the authoritative decision source, but separate the **current active view** from **historical rationale**. MemPalace may retrieve candidate records, but agents must verify status and content against canonical Markdown. Supersession must be recorded in the same PR that changes the governed behavior. A release is too late to infer it. ## Required information model Use a stable decision identity and explicit lifecycle. The exact syntax may be refined during implementation, but it must support deterministic validation of: - **Decision key:** stable subject identity such as `ci.runner-placement`. - **Effective date/version.** - **Status:** `active`, `superseded`, or `retired`. - **Supersedes:** predecessor or `none`. - **Superseded by:** successor or `none`. - **Current rule:** compact statement placed before long rationale. - **Retrieval signals:** relevant concepts, paths, symbols, endpoints, issue numbers. - **Canonical mechanics:** links to the current convention/source/test anchors. - **Rationale and rejected alternatives.** Semantics: - `active`: current authority. - `superseded`: replaced by another decision; successor must be explicit. - `retired`: historically valid, but its governed surface no longer exists. - “Relocated” and “consolidated” are document-maintenance actions, not decision statuses. - Rejected alternatives remain rationale inside an accepted record; they are not active decisions. ## Target document architecture 1. Keep `docs/decisions.md` small and make it the active catalog/task router. 2. Keep topic files for coherent current decision clusters. 3. Move superseded/retired/full historical material outside the default startup path, for example into release-scoped archives. 4. Preserve links from current records to historical rationale. 5. Keep current mechanics in convention documents; decision records explain why and point to those mechanics. 6. Keep issue/PR comments as evidence, not the sole home of a current rule. The implementation may choose generated or hand-maintained catalog sections, but the active catalog must be mechanically checked against the canonical records. ## Write-time lifecycle When a PR changes a governed decision: 1. Add the new decision record. 2. Use the same stable key. 3. Mark/link the predecessor as superseded in the same PR. 4. Update the affected current convention document. 5. Use the existing `[decisions-edit]` escape only for this explicit lifecycle transition or a factual correction. 6. Validate that there is no more than one active record per key. This turns supersession into a transactional write-time responsibility instead of a release-time archaeology task. ## Release maintenance Change the release ritual from “discover superseded entries” to: - validate lifecycle metadata and reciprocal links; - archive records already marked superseded/retired; - refresh/generate the active catalog; - check current convention/source/test anchors; - enforce an aggregate active-corpus context budget, not only `docs/decisions.md` line count; - report unresolved legacy records separately. Do not silently delete rationale. Git history and/or explicit archives preserve it without putting it in every fresh agent's default context. ## Retrieval contract A fresh agent should receive only: 1. the compact active catalog/task map; 2. active records relevant to the selected issue; 3. linked convention sections and source/test anchors; 4. historical records only when rationale or a conflict requires them. For MemPalace: - index active status/key/current-rule near the beginning of every record; - constrain search to the ErsatzTV/project wing; - retrieve candidates at a bounded `k`; - verify status and exact text against Markdown; - never let semantic similarity choose a superseded record over an active record. Gitea history ingestion is tracked by `timothy/server-management#642`. Startup/retrieval workflow changes are tracked separately in #520. ## Migration plan 1. Define and validate the record schema prospectively. 2. Build the compact active catalog and archive structure. 3. Inventory legacy entries by stable subject—not merely chronology. 4. Identify explicit reversals/retirements, beginning with known prose-only cases. 5. Reconcile duplicate or contradictory active rules with their current convention/source evidence. 6. Migrate in bounded topic batches to avoid a single conflict-heavy rewrite. 7. Remove the broad legacy corpus from mandatory startup only after the active catalog is complete. 8. Preserve an auditable mapping from every migrated legacy heading to its active record or archive location. ## Validation Add a lightweight deterministic validator, used locally and in the existing decisions CI job, that checks at least: - required metadata on structured records; - valid status values; - stable-key format; - at most one active record per key; - resolvable and reciprocal supersession links; - active catalog completeness; - archive/current placement consistency; - aggregate active-corpus line/token budget; - broken Markdown/source/test links where practical. The validator may tolerate explicitly identified unmigrated legacy entries during phased migration, but the remaining count must be visible and trend to zero. ## Retrieval evaluation Create a bounded question bank covering: - paraphrased task-to-decision discovery; - exact code/path lookups; - active vs superseded decisions; - retired features; - rationale/rejected alternatives; - a known convention whose implementation already exists, so the answer prevents reimplementation. Success must measure correct **active-record selection and citation**, not merely retrieval of a semantically related passage. ## Out of scope - Making MemPalace the source of truth. - Storing live queue state in decision documents. - Treating all issue comments as decisions. - Bulk rewriting without an auditable legacy mapping. - Deleting historical rationale solely to meet a line target. ## Done-when - [x] Decision lifecycle/schema is documented with active/superseded/retired semantics. - [x] Supersession is required in the same PR as the replacing decision. - [x] A compact active decision catalog/task router exists. - [x] Topic/current/archive responsibilities are explicit. - [x] Every migrated record has stable identity, status, current rule, retrieval signals, and canonical anchors. - [x] Known prose-only reversals/retirements are reconciled. - [x] A deterministic validator enforces keys, lifecycle links, and catalog completeness. - [x] The CI/read-cost check measures the aggregate active corpus rather than only one file. - [x] Release docs archive already-classified history instead of asking the releaser to infer supersession. - [x] Legacy migration is complete or has an explicit bounded remainder with no ambiguous active rules. - [x] The active-vs-superseded retrieval benchmark passes with canonical citations. - [x] Startup docs point agents to the compact active view, not the full historical corpus. - [x] Relevant docs are updated in the same PR(s). - [x] Independent adversarial review passed.
timothy added the enhancementpriority: mediumreview labels 2026-07-21 01:05:00 +02:00
timothy added the in-progress label 2026-07-21 01:18:34 +02:00
Author
Owner

Claiming (Claude Code, Opus 4.8). Working #520 + #521 together as one knowledge-retrieval arc: build #521's keyed decision-lifecycle schema + generated active catalog (docs/decisions/README.md) + lifecycle validator (replacing the append-only line guard while keeping its spirit; retiring the [decisions-edit] token), then rewire #520's startup/kickoff to point at the compact active view + parallel select-queue.sh, with a regression check that blocks re-treating #237 as live state. Full entry migration fanned out to subagents. Single [decisions-edit]-tagged PR.

Claiming (Claude Code, Opus 4.8). Working #520 + #521 together as one knowledge-retrieval arc: build #521's keyed decision-lifecycle schema + generated active catalog (docs/decisions/README.md) + lifecycle validator (replacing the append-only line guard while keeping its spirit; retiring the [decisions-edit] token), then rewire #520's startup/kickoff to point at the compact active view + parallel select-queue.sh, with a regression check that blocks re-treating #237 as live state. Full entry migration fanned out to subagents. Single [decisions-edit]-tagged PR.
Author
Owner

PR1 of 2 landed — #526 merged to main (f4bebd77), green CI including the new decisions lifecycle job.

This ships the machinery (does not close #521 yet):

  • scripts/decisions_lib.py (parser), scripts/decisions_validate.py (lifecycle guard: ≤1 active/key, reciprocal links, no-vanish, rationale body-diff gated by [decisions-edit], archive-placement, demotion; budget = non-blocking warning), scripts/build_decisions_catalog.py (generated docs/decisions/README.md).
  • Guard rework: line-level append-only → validator (Husky + CI decisions lifecycle job); [decisions-edit] kept narrow (rationale-prose edits only).
  • Exemplar migrations + docs/decisions/archive/ + migration-map.md; the append-only→lifecycle supersession dogfooded; the old #303 H9/H3 bundle split so the still-active root-screenshot guard stays in the active wing.
  • docs/decisions.md header + docs/ci-cd.md rewritten to lifecycle framing.

Remaining for #521 (PR2): full ~90-record migration (subagent fan-out by topic batch), the retrieval-eval benchmark, and the archive↔archive reciprocity extension (non-blocking, carried from whole-branch review). PR2 branches off this merged head.

Reviews: per-task + a whole-branch review (caught & fixed a catalog-anchor bug verified against the repo's own 64 working anchors, plus archive-guard/demotion/reciprocal holes) + a non-vacuity re-review of the guard logic. Coordinated with server-management#642 (MemPalace exporter): records front-load key/status, supersession is a validator-enforced move to archive/ (the wing boundary #642 keys off).

**PR1 of 2 landed** — [#526](http://192.168.1.95:3000/timothy/ersatztv/pulls/526) merged to main (`f4bebd77`), green CI including the new `decisions lifecycle` job. This ships the **machinery** (does not close #521 yet): - `scripts/decisions_lib.py` (parser), `scripts/decisions_validate.py` (lifecycle guard: ≤1 active/key, reciprocal links, no-vanish, **rationale body-diff** gated by `[decisions-edit]`, archive-placement, demotion; budget = non-blocking warning), `scripts/build_decisions_catalog.py` (generated `docs/decisions/README.md`). - Guard rework: line-level append-only → validator (Husky + CI `decisions lifecycle` job); `[decisions-edit]` kept narrow (rationale-prose edits only). - Exemplar migrations + `docs/decisions/archive/` + `migration-map.md`; the append-only→lifecycle supersession dogfooded; the old #303 H9/H3 bundle **split** so the still-active root-screenshot guard stays in the active wing. - `docs/decisions.md` header + `docs/ci-cd.md` rewritten to lifecycle framing. **Remaining for #521 (PR2):** full ~90-record migration (subagent fan-out by topic batch), the retrieval-eval benchmark, and the archive↔archive reciprocity extension (non-blocking, carried from whole-branch review). PR2 branches off this merged head. Reviews: per-task + a whole-branch review (caught & fixed a catalog-anchor bug verified against the repo's own 64 working anchors, plus archive-guard/demotion/reciprocal holes) + a non-vacuity re-review of the guard logic. Coordinated with server-management#642 (MemPalace exporter): records front-load `key`/`status`, supersession is a validator-enforced move to `archive/` (the wing boundary #642 keys off).
Author
Owner

Closing record

Outcome: Shipped via PR #527 (merged to main 063017584d7f09619162e818f2db922776bbbdd4). The entire decision corpus (108 records) is migrated to the lifecycle schema — 0 legacy-unmigrated; a generated active catalog (docs/decisions/README.md); superseded/retired records relocated to docs/decisions/archive/; the append-only line guard replaced by a lifecycle validator (scripts/decisions_validate.py) enforcing ≤1-active/key, reciprocal supersession, no-vanish, rationale body-diff (gated by [decisions-edit]), archive-placement, demotion, and a duplicate-metadata-block guard. [decisions-edit] kept narrow (rationale-prose edits only).
Root cause: n/a (enhancement).
Decisions/conventions changed: append-only-by-diff → lifecycle-by-record (docs.append-only-guard superseded by docs.decision-lifecycle). All 108 active records now carry key/status/since/supersedes/superseded-by + Rule/Signals/Mechanics.
Reusable knowledge: A multi-agent migration over a non-chronological file leaves gaps at name-based batch boundaries (caught by the validator legacy count, not luck) and can double-insert on clean merges (caught by the new duplicate-metadata-block guard). Reviewers reasoning theoretically about a slugger were wrong; the repo's own 64 existing anchors were ground truth (Gitea keeps --).
Verification: 0 legacy / 108 active; decisions_validate --base origin/main PASS; catalog --check in sync; 31 pytest; retrieval cold-agent sim 6/6 (active-vs-superseded traps passed); whole-branch adversarial review (SOUND-WITH-FIXES → folded).
Deferred: none (archive↔archive reciprocity guard landed in PR2, not deferred).
Docs updated: docs/decisions.md (header + all records), docs/decisions/README.md (generated catalog), docs/decisions/archive/, docs/decisions/migration-map.md, docs/decisions/retrieval-eval.md, docs/ci-cd.md (release ritual), CLAUDE.md.

## Closing record **Outcome:** Shipped via PR #527 (merged to main `063017584d7f09619162e818f2db922776bbbdd4`). The entire decision corpus (108 records) is migrated to the lifecycle schema — 0 legacy-unmigrated; a generated active catalog (`docs/decisions/README.md`); superseded/retired records relocated to `docs/decisions/archive/`; the append-only line guard replaced by a lifecycle validator (`scripts/decisions_validate.py`) enforcing ≤1-active/key, reciprocal supersession, no-vanish, rationale body-diff (gated by `[decisions-edit]`), archive-placement, demotion, and a duplicate-metadata-block guard. `[decisions-edit]` kept narrow (rationale-prose edits only). **Root cause:** n/a (enhancement). **Decisions/conventions changed:** append-only-by-diff → lifecycle-by-record (`docs.append-only-guard` superseded by `docs.decision-lifecycle`). All 108 active records now carry `key`/`status`/`since`/`supersedes`/`superseded-by` + `Rule`/`Signals`/`Mechanics`. **Reusable knowledge:** A multi-agent migration over a non-chronological file leaves gaps at name-based batch boundaries (caught by the validator legacy count, not luck) and can double-insert on clean merges (caught by the new duplicate-metadata-block guard). Reviewers reasoning theoretically about a slugger were wrong; the repo's own 64 existing anchors were ground truth (Gitea keeps `--`). **Verification:** 0 legacy / 108 active; `decisions_validate --base origin/main` PASS; catalog `--check` in sync; 31 pytest; retrieval cold-agent sim 6/6 (active-vs-superseded traps passed); whole-branch adversarial review (SOUND-WITH-FIXES → folded). **Deferred:** none (archive↔archive reciprocity guard landed in PR2, not deferred). **Docs updated:** `docs/decisions.md` (header + all records), `docs/decisions/README.md` (generated catalog), `docs/decisions/archive/`, `docs/decisions/migration-map.md`, `docs/decisions/retrieval-eval.md`, `docs/ci-cd.md` (release ritual), `CLAUDE.md`.
timothy removed the in-progress label 2026-07-21 18:06:26 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: timothy/ersatztv#521