From 42f51eb8a25a0938ca06bce7088740acfb212cdd Mon Sep 17 00:00:00 2001 From: GrillerGeek Date: Sun, 18 Oct 2026 07:23:03 -0400 Subject: [PATCH] feat(quest): pre-RED drift check against the spec's approval base (v0.17.5) A spec approved against one base and built on a later one carried stale line numbers, renamed targets, flipping tests and wrong counts into RED. Mordain now takes the approval base (spec `approved_at`, else the last commit touching the spec as a recorded proxy), walks intervening commits on named paths read-only, routes corrections through docs-writer before test-author, and surfaces design drift to the user. Briefs quote API names from the spec or plan, never from memory. The plan records `approval_base` and the drift-check outcome. Fixes #59 Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 1 + plugin/commands/quest.md | 13 ++++++++++++- plugin/portable/references/quest.md | 8 ++++++++ plugin/skills/guildhall-quest/references/quest.md | 8 ++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f4f1de..3dc9fdb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## 0.17.5 — Unreleased +- Add a pre-RED drift check: when commits since the spec's approval base (`approved_at`, or the last commit touching the spec) touch named paths, Mordain reports stale lines, moved targets, flipping tests, changed counts and design drift, and routes corrections through docs-writer before RED. Briefs quote API names from the spec or plan, never from memory. - Default task preparation to unknown context requirements unless the handoff establishes a hard minimum, on Claude and Codex. - Explain candidate exclusions in local routing receipts without paid diagnostics; preserve hard constraints and legacy receipts. diff --git a/plugin/commands/quest.md b/plugin/commands/quest.md index ca4179f..46b1cab 100644 --- a/plugin/commands/quest.md +++ b/plugin/commands/quest.md @@ -116,8 +116,17 @@ is written; no additional project writes are authorized. Before dispatching adventurers, produce an implementation plan. This is the design-thinking layer — YOU do this work, on Opus. -1. **Read the spec** (if feature mode) entirely. Quote the Expectations block back to yourself. Then **prepare verbatim quotes** of the load-bearing blocks — Expectations, Boundaries, Inputs/Outputs. You will inline these in each adventurer's dispatch prompt under a `## Spec excerpt` heading so they don't all re-read the full spec from disk. **Quote, don't paraphrase** — adventurers treat your quotes as authoritative. +1. **Read the spec** (if feature mode) entirely. Quote the Expectations block back to yourself. Then **prepare verbatim quotes** of the load-bearing blocks — Expectations, Boundaries, Inputs/Outputs. You will inline these in each adventurer's dispatch prompt under a `## Spec excerpt` heading so they don't all re-read the full spec from disk. **Quote, don't paraphrase** — adventurers treat your quotes as authoritative. The same holds for every API name and signature you put in any brief: copy it from the spec or plan, never write it from memory. A misremembered signature handed to Seraphine becomes the contract Bruga must bend to. 2. **Read the relevant code.** Use `Grep` / `Glob` to find existing patterns. Your plan MUST cite the patterns you are matching — no inventing patterns that do not exist in the codebase. + + **Drift check (feature mode, before RED).** A spec or plan approved against an older base may no longer match the tree the quest builds on. Take the approval base from the spec frontmatter's `approved_at: ` if present; otherwise use the last commit that changed the spec file (`git log -1 --format=%H -- `) and record it as a proxy. Do the same for a pre-existing plan. Then list the intervening commits that touch files the spec or plan names: `git log --name-status ..HEAD -- `. Empty → record "drift check: base unchanged" and continue. Otherwise, walk the range read-only and report: + - stale line numbers; + - moved or renamed targets; + - existing tests whose expectations now flip, including any the spec claims will not; + - derived counts that changed (entries, tools, cases); + - intervening behaviour that changes the design. That is a decision, not a correction — surface it to the user (or route to Aldric under item 4) before going on. + + Route the spec and plan corrections through `docs-writer` (Cassian) — Seraphine sees only the spec, so they must land before RED — confirm they are committed, and record each one in the plan's `## Context`. Do NOT dispatch `test-author` against an uncorrected spec. 3. **Read `CLAUDE.md`** at the project root if present — it holds local conventions. Note the section relevant to this quest; you'll inline it in dispatch prompts under a `## Local conventions` heading so adventurers don't all re-read the file. 4. **Decide whether you need Aldric.** If the work is novel or cross-cutting — new module, new schema, new cross-project convention, a choice between two patterns that both exist in the codebase — dispatch `architecture-reviewer` BEFORE producing the plan. Aldric returns 2–3 alternatives with trade-offs and a recommendation. Use that to inform your plan. Do NOT dispatch Aldric for routine features that match an existing pattern — that is overkill. 5. **Identify files to touch.** List them. Be specific. @@ -162,6 +171,7 @@ quest: mode: feature | prototype | debug started: spec: +approval_base: slug: status: in_progress model_check: @@ -174,6 +184,7 @@ parent_model: - Spec Expectations (quoted verbatim) - Cited patterns from the codebase (with file paths) - Any pre-dispatch decisions (Aldric's recommendation, if dispatched) +- Drift check: "base unchanged", or each finding with the correction's commit SHA ## Dispatch sequence diff --git a/plugin/portable/references/quest.md b/plugin/portable/references/quest.md index 06a889f..79dabe0 100644 --- a/plugin/portable/references/quest.md +++ b/plugin/portable/references/quest.md @@ -81,6 +81,14 @@ instructions), existing patterns and the full Spec. Preserve existing edits by recording relevant file contents/modes and Git state before dispatch. Do not reset or remove pre-existing work. +Before RED in feature mode, check for drift: take the Spec's approval base from +`approved_at: ` or, as a recorded proxy, the last commit touching the Spec. +If commits since then touch paths the Spec or plan names, report stale lines, +moved targets, flipping tests, changed counts and design-changing behaviour. +Route corrections through Cassian, committed, before test-author starts; a +design change goes to the user. Quote API names and signatures in briefs from +the Spec or plan, never from memory. + Consult Aldric for genuinely novel or cross-cutting architecture before settling the plan; surface consequential choices to the user. Routine choices matching existing patterns can proceed with a recorded rationale. diff --git a/plugin/skills/guildhall-quest/references/quest.md b/plugin/skills/guildhall-quest/references/quest.md index 06a889f..79dabe0 100644 --- a/plugin/skills/guildhall-quest/references/quest.md +++ b/plugin/skills/guildhall-quest/references/quest.md @@ -81,6 +81,14 @@ instructions), existing patterns and the full Spec. Preserve existing edits by recording relevant file contents/modes and Git state before dispatch. Do not reset or remove pre-existing work. +Before RED in feature mode, check for drift: take the Spec's approval base from +`approved_at: ` or, as a recorded proxy, the last commit touching the Spec. +If commits since then touch paths the Spec or plan names, report stale lines, +moved targets, flipping tests, changed counts and design-changing behaviour. +Route corrections through Cassian, committed, before test-author starts; a +design change goes to the user. Quote API names and signatures in briefs from +the Spec or plan, never from memory. + Consult Aldric for genuinely novel or cross-cutting architecture before settling the plan; surface consequential choices to the user. Routine choices matching existing patterns can proceed with a recorded rationale.