Skip to content

feat(setup): constitution with teeth — generated Definition of Done + AC standard replace the boilerplate #943

Closed

Description

@admarble

Motivation

templates/memory/constitution.md is the designated home for a project's agent contract — and it is generic boilerplate ("Quality First — never sacrifice code quality for speed", a command table, naming-convention platitudes). Nothing in it is machine-checked, and no skill references it at a decision point. It is shipped to every consumer project as the always-on prose class that #608 measured at a 0% action rate: words with no consumer.

Meanwhile the actual agent contract exists, scattered and mostly implicit:

Contract element Where it lives Documented for consumers?
Definition of Done /qa §7 gates No — internal skill prose
Scope boundary Non-Goals parsing (parseNonGoals) Partially
Protected paths hardcoded regex in qa/SKILL.md No
Budgets ready/loop iteration + token caps in settings Settings table only
Stop conditions human merge gate, waiting_for_human_merge No

A consumer project adopting sequant cannot currently answer "what will the agent refuse to do, what must every PR satisfy, and where does it stop for me?" without reading skill internals. And issue authors can't distinguish per-issue ACs from the project-wide DoD, which produces the AC-hygiene duplication ("add tests", "CI passes" as issue ACs) that the AC standard tries to lint away.

Proposal

Rewrite the constitution template as the enforceable contract surface — every section either machine-checked or referenced by a named skill at a named decision point; anything that is neither gets deleted.

Sections:

  1. Definition of Done — the §7 gate list, generated (not hand-written): a script renders the gate table from the qa skill's §7 collection list so the constitution cannot drift from the real gates (lint-skill-gates already parses this region; reuse it). States explicitly: these are project-wide; do not restate them as issue ACs.
  2. AC authoring standard — the house AC format: single-line ACs (parser constraint stated as a rule, with the truncation failure mode), named Evidence: where testable, Risk:/Human decision declarations, Non-Goals section. One screen, with one good/bad example pair. This is the human-facing docs home for the AC-field issues.
  3. Boundaries — protected paths (pointing at settings.riskPaths once configurable), force-push/amend prohibitions (already hook-enforced — documented here as contract, with the hook named), worktree-only editing rule.
  4. Budgets & stop conditions — iteration/token caps with their settings keys, the human merge gate, and gap-prompt discipline: diagnostic ("what are the gaps?") is cheap and high-yield; imperative ("fix all gaps") requires triage first (the audited fix(lint): exclude gitignored scripts/dev from the widened lint/typecheck scope #930 regression is the cited incident).
  5. Project-specific notes — unchanged customization region.

Consumers (what makes this not-prose):

  • /spec AC-quality check links its lint warnings to §2 ("see constitution AC standard") — the linter and the doc cite each other.
  • sequant setup/init renders the DoD table at generation time; validate-skills CI job (or a small new check) fails when the generated DoD table drifts from the §7 list.

Non-Goals

  • No new enforcement mechanisms — this issue documents and cross-links existing teeth (hooks, gates, settings); new gates are their own issues (mutation gate, tautology CI, risk override, filed alongside).
  • No consumer-project migration tooling — existing projects keep their customized constitutions; sync semantics below.
  • No principles/values prose — deleted, not rewritten. A value with no consumer is dead weight by measurement.

Tailored caveats

Acceptance Criteria

  • AC-1: The constitution template's DoD section is generated from the qa skill's §7 gate list by a script, and a CI check fails on drift between them. Evidence: delete one gate from the generated table and confirm the check fails (mutation-verified), restore.
  • AC-2: The AC authoring standard section documents single-line ACs, Evidence/Risk/Human-decision clauses, and Non-Goals, with one good/bad example pair, and /spec's lint output references it. Evidence: content-coverage assertion scoped to the section; scoped gate test on the spec skill's reference, mutation-verified.
  • AC-3: Boundaries and budgets sections name their enforcing mechanism (hook, gate, or settings key) for every listed rule — zero unenforced aspirational statements remain in the template. Evidence: review checklist in the PR body mapping each rule to its mechanism; the old boilerplate principles section is gone.
  • AC-4: update/sync preserve an existing customized constitution unchanged and the new template reaches fresh init projects only. Evidence: existing customizable-file integration tests pass; one new case with a modified constitution asserting no overwrite.
  • AC-5: Placeholder substitution ({{PROJECT_NAME}}, {{STACK_NOTES}}) works in the rewritten template. Evidence: templates.test.ts green with the new content.
  • AC-6: README (main + marketplace) and docs/ describe the constitution's role as the agent contract, content-verified in all locations. Evidence: docs-coverage assertions on all three locations.

Human decisions required

  • Should the gap-prompt discipline section (diagnostic vs imperative) live here or in CLAUDE.md-style operator docs? (It is operator guidance, not agent contract — but it has no other durable home today.)

Context

From the 2026-08-13 strategy review (agent-contract consolidation: per-issue clauses live in AC fields; the repo-level contract is this document, with teeth). Related: #708/#814 (customizable-file sync semantics), #834 (lint-skill-gates precedent for parsing §7), #930 (the imperative-prompt incident cited in §4), the Evidence/Risk/Human-decision field issues filed alongside this one.

Activity

  1. admarble commented on Aug 29, 2026

    @admarble
    ContributorAuthor

    Context for the implementation run (2026-08-29) — repo state has moved since this issue was written:

    1. The mutation-verification gate shipped (feat(qa): mutation-verification becomes a parseable §7 gate instead of honor-system prose #939 → PR feat(#939): mutation-verification becomes a parseable /qa §6i gate #949): /qa §6i now parses and enforces Mutation-verified: markers (machine-anchored SEQUANT_MUTATION JSON) in PR bodies for gate-test ACs. AC-1 and AC-2's mutation-verified evidence should use that exact marker format. When mapping rules to enforcement mechanisms (AC-3), the mutation gate is now an existing tooth to cite, not a future issue.
    2. NEEDS_VERIFICATION maps to ready_for_merge, blocking QA re-runs; MCP sequant_run ignores force #972 merged today: awaiting_verification is now a real workflow state and docs/features/qa-verdict-workflow-states.md documents the verdict→state contract. The Budgets & stop-conditions section (§4) should list it among the stop/hold states and cross-link that doc rather than restating it.
    3. Provisional answer to the 'Human decisions required' item (flagged for owner override at PR review): keep the gap-prompt discipline (diagnostic vs imperative, fix(lint): exclude gitignored scripts/dev from the widened lint/typecheck scope #930 incident) in constitution §4 as proposed — the issue itself notes it has no other durable home today. Do not create a new operator-docs surface for it in this PR.
    4. Reminder from the tailored caveats: the constitution template is a CUSTOMIZABLE_FILES entry — AC-4's no-overwrite behavior is load-bearing; and all skill-file changes must be mirrored across the three skill dirs per repo convention.
  2. admarble commented on Aug 29, 2026

    @admarble
    ContributorAuthor

    Complexity: Standard (6 ACs, ~6 directories)

    AC Quality Check

    All six ACs carry a declared Evidence: clause and a measurable outcome — well above the house standard (this issue is itself the source for that standard, §2). Two notes:

    • AC-3 ("zero unenforced aspirational statements remain") is verified by a PR-body review checklist, not an automated test. That's acceptable (it's a subjective completeness claim), but the checklist must map every retained line to a named mechanism, and QA will read it literally per the all-locations discipline.
    • AC-1 / AC-2 name mutation-verified gate tests. Per repo convention and the now-merged feat(qa): mutation-verification becomes a parseable §7 gate instead of honor-system prose #939 gate, their evidence must be recorded with the exact Mutation-verified: AC-N — <mutation>; <test> failed; restored. marker (machine-anchored <!-- SEQUANT_MUTATION: {...} -->) in the PR body, or /qa §6i floors the verdict.

    No vague/unmeasurable/open-ended patterns found. AC lint: clean.


    Scope Assessment

    Non-Goals: Present and strong — (1) no new enforcement mechanisms (documents existing teeth only); (2) no consumer-project migration tooling; (3) no principles/values prose (deleted, not rewritten).

    Metric Value Status
    Feature count ~4 (DoD generation + drift CI check; AC-standard doc + /spec cross-link; boundaries/budgets doc; sync-preservation + docs coverage) ⚠️
    AC items 6 ✅
    Directory spread ~6 (templates/memory/ ×3 mirror, src/lib/, scripts/ ×2, skills/spec/ ×3 mirror, README.md + marketplace, docs/) ⚠️

    Verdict: ⚠️ SCOPE_WARNING — the work is broad but cohesive: everything orbits one artifact (the constitution template) and its cross-links. Not a split candidate. Quality loop auto-enables. The real risk here is mirror drift, not scope creep: every skill/template edit lands in three directories (.claude/, templates/, skills/ for the spec skill; .claude/memory/, templates/memory/, memory/ for the constitution).


    Acceptance Criteria

    AC-1: DoD section generated from qa §7 gate list + CI drift check

    Verification: Integration Test (+ gate test, mutation-verified)
    Scenario: Given qa/SKILL.md §7's status-token collection list → When the generator runs → Then constitution.md's DoD table matches the §7 gates; When a gate is deleted from the generated table → Then the CI drift check exits non-zero.
    Assumptions: The generator reads the delimited §7 region only (the Verdict Determination Algorithm block, ~line 2590 of skills/qa/SKILL.md, step-2 Check verification gates list). Scoping to the block is mandatory — whole-file matching lets unrelated prose satisfy the assertion (CLAUDE.md gate-test scoping rule; #830). The canonical source is one skill dir (§7 is byte-identical across the three; assert on .claude/skills/qa/SKILL.md per lint-skill-gates.ts's SCAN_ROOTS precedent).

    AC-2: AC authoring standard section + /spec lint cross-reference

    Verification: Integration Test (content-coverage + scoped gate test, mutation-verified)
    Scenario: Given the rewritten constitution → When asserting §2 content → Then it documents single-line ACs (with the parser-truncation failure mode), Evidence:/Risk:/Human decision clauses, Non-Goals, and one good/bad example pair; And /spec's AC-quality-check output references the constitution AC standard.
    Assumptions: Content assertion is scoped to the §2 region, not the whole file. The /spec cross-link lands in the AC Quality Check step of spec/SKILL.md — mirrored across all three spec skill dirs.

    AC-3: Boundaries + budgets sections name an enforcing mechanism for every rule

    Verification: Manual Test (PR-body review checklist)
    Scenario: Given the rewritten template → When reviewing §3 (Boundaries) and §4 (Budgets & stop conditions) → Then every listed rule cites its hook / gate / settings key, zero aspirational statements remain, and the old Core-Principles/Naming/Error-Handling boilerplate is gone.
    Assumptions: Mechanisms to cite include: force-push/amend hook (pre-tool.sh), protected paths (settings.riskPaths), worktree-only editing, /qa §7 gates, the mutation gate (#939, now an existing tooth — not a future issue), iteration/token caps (settings keys), the human merge gate + waiting_for_human_merge / awaiting_verification state (cross-link docs/features/qa-verdict-workflow-states.md, #972), and gap-prompt discipline (§4, diagnostic-vs-imperative, #930).

    AC-4: update/sync preserve a customized constitution; new template reaches fresh init only

    Verification: Integration Test
    Scenario: Given an existing project whose constitution.md differs from the template → When sync/update runs → Then the customized file is untouched (it's in CUSTOMIZABLE_FILES); Given a fresh init → Then the new template renders.
    Assumptions: CUSTOMIZABLE_FILES = [".claude/memory/constitution.md"] (src/lib/templates.ts:238) already guards this via isCustomizableFile; the rewrite must not change the path or the guard. Add one new integration case with a modified constitution asserting no overwrite (existing templates.test.ts cases at :178/:364 are the pattern).

    AC-5: Placeholder substitution works in the rewritten template

    Verification: Unit Test
    Scenario: Given the new constitution content → When templates.ts substitution runs → Then {{PROJECT_NAME}} and {{STACK_NOTES}} expand correctly (templates.test.ts green).
    Assumptions: Both placeholders must survive the rewrite verbatim; {{STACK_NOTES}} still fed by stacks.ts note injection.

    AC-6: README (main + marketplace) and docs/ describe the constitution's role

    Verification: Integration Test (docs content-coverage, all three locations)
    Scenario: Given the three doc surfaces → When asserting content → Then each describes the constitution as the project's agent contract (DoD + boundaries + budgets), content-verified (not file-existence).
    Assumptions: The marketplace README is generated from the README_CONTENT constant in scripts/prepare-marketplace.ts:287 — edit that constant, not a static marketplace file. Third location is docs/ (docs/README.md or a dedicated page). Coverage asserts on content, not existence (docs-all-locations rule).


    Implementation Plan

    Phase 1: DoD generator + drift gate (AC-1)

    1. Write a generator (new scripts/generate-constitution-dod.ts, or extend an existing render step) that parses the delimited §7 Check verification gates block from .claude/skills/qa/SKILL.md and renders the DoD table into templates/memory/constitution.md. Reuse lint-skill-gates.ts's region-scoping approach rather than re-inventing a parser.
    2. Add a CI drift check (extend lint-skill-gates or a small sibling script wired into the validate-skills job) that fails when the rendered DoD table diverges from the §7 list. This is the AC-1 mutation-verified gate test.

    Phase 2: Rewrite the constitution template (AC-2, AC-3)

    1. Replace templates/memory/constitution.md wholesale with the five-section structure: (1) generated DoD, (2) AC authoring standard w/ good-bad pair, (3) Boundaries, (4) Budgets & stop conditions, (5) Project-specific notes (preserve {{PROJECT_NAME}}/{{STACK_NOTES}} and the customization region). Delete Core Principles / Naming / Error Handling / Commands boilerplate.
    2. Mirror the rewrite to all three constitution copies (.claude/memory/, templates/memory/, memory/). Note: the drift check and init render from templates/memory/; confirm which copies are load-bearing vs mirrors before assuming byte-identity.
    3. Cross-link: in each of the three spec/SKILL.md copies, make the AC Quality Check step reference the constitution AC standard (AC-2 second half).

    Phase 3: Sync/docs verification (AC-4, AC-5, AC-6)

    1. Add the AC-4 no-overwrite integration case and confirm AC-5 placeholder tests stay green (adjust expected strings to new content, not the assertion shape).
    2. Update main README.md, the README_CONTENT constant in scripts/prepare-marketplace.ts, and a docs/ page to describe the constitution-as-contract; add content-coverage assertions for all three.

    Dependency note: Phase 1 must land before Phase 2's DoD section is meaningful (the section is generated). Phases 2 and 3 can overlap once the template shape is fixed.


    Rule Touchpoints

    AC-3 is itself a touchpoint-enumeration exercise: it requires naming the enforcing site for each documented rule. Rather than run the behavior-rule detector (the ACs document existing rules, they don't implement new ones), the enforcing touchpoints to cite are:

    Rule (constitution §3/§4) Enforcing touchpoint
    Force-push / amend prohibition templates/hooks/pre-tool.sh (hook)
    Protected paths settings.riskPaths (settings key)
    Definition of Done skills/qa/SKILL.md §7 verdict algorithm (gate)
    Gate-test mutation record /qa §6i + SEQUANT_MUTATION marker (gate, #939)
    Iteration / token caps ready-gate + loop caps in .sequant/settings.json (settings keys)
    Human merge gate / hold states waiting_for_human_merge, awaiting_verification (#972); docs/features/qa-verdict-workflow-states.md

    Design Review

    1. Where does this logic belong? The DoD generator belongs in scripts/ alongside lint-skill-gates.ts (same §7-parsing concern, same validate-skills CI home). The template content belongs in templates/memory/constitution.md; the sync guard already lives in src/lib/templates.ts and needs no change beyond a test.
    2. What's the simplest correct approach? Generate only the DoD table (the one section that can drift from live gates); hand-write §2–§5 as static prose. Don't build a general templating engine for the whole constitution — reject that as over-engineering (Non-Goals bar new mechanisms). Reuse lint-skill-gates's region parser instead of a new §7 parser.
    3. What existing pattern does this follow? lint-skill-gates.ts (§7 region parsing + validate-skills gate) and the CUSTOMIZABLE_FILES preservation pattern (fix(update/sync): sync reports 'up to date' on content drift; update overwrites in-place customizations (constitution) #708/fix(sync): plain sync overwrites CUSTOMIZABLE_FILES (constitution) — copyDir ignores force and never consults isCustomizableFile #814). Marketplace docs follow the generated-README_CONTENT pattern.
    4. What would a senior reviewer challenge? "Why a new script instead of extending lint-skill-gates?" — answer in the PR: generation (write) vs linting (read) are different verbs; keep the drift check in the lint job but the render separate, or justify merging. Also: "Did you verify all three constitution mirrors and which one init actually reads?" — the mirror-drift trap is the most likely defect here.

    Feature Quality Planning

    Notable items:

    Derived ACs

    Source Derived AC Priority
    Mirror integrity Constitution + spec-skill edits land byte-consistent across all three dirs each (lint:skill-sync green) High

    Open Questions

    1. Which constitution copy is canonical for init/sync? — Recommendation: templates/memory/constitution.md is the shipped source; .claude/memory/ and memory/ are dev/self-host mirrors. Confirm before editing. Impact if wrong: fresh init projects get the old boilerplate despite a green build.
    2. Merge the DoD drift check into lint-skill-gates or ship a sibling script? — Recommendation: sibling generator script + drift assertion wired into the same validate-skills CI job (keeps write/read verbs separate). Impact: minor; either satisfies AC-1.
    3. Gap-prompt discipline home — already answered by the owner in the 2026-08-29 comment: keep it in constitution §4; do not create a new operator-docs surface. No action needed beyond honoring that.

    Recommended Workflow

    Phases: spec → testgen → exec → qa
    Quality Loop: enabled
    Reasoning: AC-1/AC-4/AC-6 declare Integration-Test evidence and AC-5 declares a Unit-Test — stubbing these (drift check, no-overwrite case, docs-coverage asserts) before implementation is high-yield. SCOPE_WARNING + the six-directory mirror surface auto-enables the quality loop. No UI/.tsx changes → no test phase. Not security-sensitive → no security-review.


    Label Review

    Current: (none)
    Recommended: enhancement, docs, planned
    Reason: It's a feature (feat(setup):) that is largely documentation + one generation script + a CI gate. No complex/breaking label warranted (6 ACs, cohesive), but the mirror surface is why the quality loop runs.
    Quality Loop: Will auto-enable (SCOPE_WARNING).

    → gh issue edit 943 --add-label enhancement --add-label docs


    --- DRAFT GITHUB ISSUE COMMENT (PLAN) ---

    Plan posted. See structured sections above. Key decisions: (1) generate only the DoD table from qa §7, hand-write §2–§5; (2) reuse lint-skill-gates region-parsing for the drift check; (3) edit the marketplace README_CONTENT constant, not a static file; (4) mirror-drift across the two skill/memory triads is the top defect risk; (5) AC-1/AC-2 gate tests must carry SEQUANT_MUTATION markers per #939. Open questions on canonical constitution copy and drift-check placement flagged above.

  3. added
    planned
    on Aug 29, 2026
  4. admarble commented on Aug 29, 2026

    @admarble
    ContributorAuthor

    QA Review for Issue #943

    AC Coverage

    AC Source Description Status Notes
    AC-1 Original DoD generated from §7 by script; CI check fails on drift MET generate-constitution-dod.ts parses §7 step-4 (scoped to the fenced block), check-constitution-dod.ts compares the delimited BEGIN/END:DOD-GATES region; lint:constitution-dod wired in CI. Drift check passes; deleting a row fails the gate test (verified).
    AC-2 Original AC authoring standard (single-line, Evidence/Risk/Human-decision, Non-Goals, good/bad pair) + /spec references it MET Template §2 covers all required fields with a good/bad example pair; /spec AC Quality Check step carries the cross-link in all 3 mirrors (skill-sync 44/44).
    AC-3 Original Boundaries and budgets name their enforcing mechanism; zero unenforced aspirational statements; old principles gone NOT_MET Old principles boilerplate is gone ✅, but two named enforcers do not exist — see Required Fixes.
    AC-4 Original update/sync preserve a customized constitution; new template reaches fresh init only MET New preservation test in templates.test.ts (#943 AC-4); 59 tests pass; CUSTOMIZABLE_FILES already includes the constitution.
    AC-5 Original Placeholder substitution ({{PROJECT_NAME}}, {{STACK_NOTES}}) works MET Both are real substitution tokens (templates.ts:278,280); template carries both; templates.test.ts green.
    AC-6 Original README (main + marketplace) and docs/ describe the constitution as the agent contract, content-verified MET Gate tests assert "agent contract" + "Definition of Done" in README.md, prepare-marketplace.ts README_CONTENT, and docs/guides/customization.md.

    Coverage: 5/6 AC items fully met — AC-3 NOT_MET blocks merge


    CI Status

    Check State Impact
    build (20.x/22.x), typecheck, validate-skills, validate-plugin, Plugin Structure Validation, Hooks Validation, node-floor-guard, Setup Directory Creation, tautology-advisory SUCCESS ✅ MET

    CI Summary: 9 passed, 0 pending, 0 failed. CI is not a blocking factor; the verdict is driven by AC-3.


    Quality Metrics

    Metric Value Status
    Type issues (any) 0 OK
    Deleted tests 0 OK
    Files changed 14 OK
    Lines added +907 -
    Lines deleted -128 -
    Security patterns 0 OK
    build / lint pass / 0 warnings OK

    Code Review

    Strengths:

    • Clean write/read split: generate-constitution-dod.ts (render) vs check-constitution-dod.ts (drift gate), reusing lint-skill-gates.ts's SCAN_ROOTS precedence for the canonical qa skill.
    • Extraction is correctly scoped — §7 fenced block for the generator, BEGIN/END:DOD-GATES delimiters for the drift check — avoiding the feat(#819): shared trust-model block — issue/PR text is data, not agent instructions #830 whole-file-matching trap.
    • 3-mirror discipline maintained (skill-sync 44/44); old principles boilerplate fully removed.

    Issues (blocking — AC-3):

    • §3 Boundaries names a nonexistent settings key. Row: Protected paths require explicit override → \settings.riskPaths` (settings key; override prompt required). riskPathsappears **nowhere** in the codebase except this template — it is not insrc/lib/settings.ts, and no "override prompt" mechanism exists. The issue body itself flags this: the real enforcer today is a "hardcoded regex in qa/SKILL.md", and settings.riskPathsis future work ("pointing atsettings.riskPaths` once configurable"). This is exactly the "unenforced aspirational statement" AC-3 forbids.
    • §4 Budgets names the wrong settings-key path. Row: Quality-loop max iterations → \ready.maxIterations`. That key does not resolve (ready.maxIterations→undefined); maxIterationslives inRunSettingsSchema, so the real key is run.maxIterations(thereadysection only haspolicy). run.autoWaitMinutes` in the same table is correct.

    Suggestions (non-blocking):

    • The PR body's AC checklist renumbers ACs vs the issue (PR "AC-5" describes CI-step ordering; the issue's AC-5 is placeholder substitution). Align the PR checklist to the issue's AC numbering so reviewers can map 1:1.

    Test Coverage Analysis

    Changed File Tier Has Tests? Test File
    scripts/generate-constitution-dod.ts Standard ✅ Yes scripts/check-constitution-dod.test.ts
    scripts/check-constitution-dod.ts Standard ✅ Yes scripts/check-constitution-dod.test.ts
    templates/memory/constitution.md Standard ✅ Yes drift gate + templates.test.ts AC-4

    Coverage: core scripts fully covered (14 gate tests). No critical-path files.


    Anti-Pattern Detection

    No code anti-patterns in the changed .ts files (0 any, 0 security patterns, no empty catches, no N+1). package.json change is an npm-script addition only — no dependency audit needed.


    Trust-Boundary Check

    Finding: Clean — the issue is a normal feature spec; the diff implements only product requirements. No agent-directed instruction embedded in the issue/comments was acted on.

    Status: Clean


    Behavior-Rule Survival Check

    AC Triggered? Survivors Status
    AC-3 ("old principles section is gone") Yes — (0 matches for quality first/never sacrifice/principles in template + byte-identical mirror) Clean

    Status: Clean


    Mutation Verification

    AC Gate Test? Marker Status
    AC-1 Yes AC-1: DoD table matches §7 gates > … Malformed — failedTest names a describe title, not a file
    AC-2 Yes AC-2: spec skill cross-references… > … Malformed — same

    Status: Not-Applicable to the automated §7 floor (no AC state populated for #943 via the state manager), but both markers are malformed: §6i's classifier reads the segment before the first > as the test file (canonical shape <file> > <test name>, e.g. injection.test.ts > rejects payload). These markers put <describe> > <it> with no file path, so parseMutationMarkers classifies both as test_not_in_diff (fabricated). The verification genuinely happened during exec, but the PR's own evidence records would fail the very gate this feature reinforces. Fix the failedTest values to scripts/check-constitution-dod.test.ts > <test name>.


    CHANGELOG Verification

    Result: ⚠️ No [Unreleased] entry found for this user-facing change. Non-blocking on its own (AC-3 already floors the verdict), but add an entry before merge. (Note: recorded as a secondary item, not the gating cause.)


    Risk Assessment

    • Likely failure mode: A consumer reads the contract, looks for settings.riskPaths / ready.maxIterations, finds neither, and concludes the "enforceable contract" is inaccurate — undermining the exact trust the rewrite is meant to establish.
    • Not tested: Nothing asserts that the settings keys / hook paths named in §3–§4 actually resolve. A test that greps each cited settings.X key against the settings schema (and each hook path against the filesystem) would have caught both defects and would prevent regression — consider adding it as the AC-3 enforcement evidence.
    • Sibling sites considered: The two bad keys are mirrored into memory/constitution.md (byte-identical) — any fix must touch both templates/memory/constitution.md and memory/constitution.md. No other cross-file copies. docs/guides/customization.md and README describe the sections but do not repeat the specific keys, so they are unaffected.
    • Sibling-line audit: Audited every enforcer citation in §3–§4: templates/hooks/pre-tool.sh force-push (20 hits) + worktree guard (47 hits) ✅ real; /qa §6i + SEQUANT_MUTATION ✅ real; /qa §7 ✅ real; run.autoWaitMinutes ✅ real. Only settings.riskPaths and ready.maxIterations are wrong.

    Adversarial Re-Read

    Findings: (1) Traced each §3–§4 named enforcer to source — settings.riskPaths and ready.maxIterations do not exist; both mirrored into memory/constitution.md. (2) Audited the PR's mutation-verification evidence claim against mutation-marker.ts — both SEQUANT_MUTATION markers are malformed (test_not_in_diff). (3) Confirmed issue AC-5 (placeholder substitution) is genuinely met despite the PR checklist mislabeling AC-5 as CI-step ordering. (4) Verified old principles boilerplate removed from template and mirror. (5) No Non-Goals were expanded into scope (no new enforcement mechanism added — consistent with the issue's Non-Goals).

    Status: Severe Gap (a contract that names nonexistent enforcers, plus an unverified evidence-record format — the AC-3 requirement "zero unenforced aspirational statements" is literally violated)


    Verdict: AC_NOT_MET

    AC-3 is NOT_MET: the constitution's Boundaries (§3) and Budgets (§4) sections name two enforcing mechanisms that do not exist — settings.riskPaths (no such settings key; the real enforcer is the hardcoded sensitive-path regex in qa/SKILL.md) and ready.maxIterations (wrong path; the key is run.maxIterations). AC-3's explicit requirement is "name their enforcing mechanism … for every listed rule — zero unenforced aspirational statements remain in the template", so these are literal violations, not stylistic nits. The other 5 ACs are met and code quality is otherwise high, but one NOT_MET AC floors the verdict.

    Required Fixes

    1. §3 (both templates/memory/constitution.md and memory/constitution.md): Replace settings.riskPaths with the mechanism that exists today — the hardcoded sensitive-path regex in qa/SKILL.md (grep -iE 'auth|payment|security|server-action|middleware|admin', §Small-Diff / anti-pattern detection) — or drop the row until settings.riskPaths is actually implemented. Also remove/qualify the "override prompt required" claim, which has no mechanism.
    2. §4 (both files): Change ready.maxIterations → run.maxIterations.
    3. PR body: Fix both SEQUANT_MUTATION failedTest values to the <file> > <test name> shape (scripts/check-constitution-dod.test.ts > …, src/lib/templates.test.ts > …) so they classify as valid.
    4. Recommended (AC-3 enforcement evidence): add a test asserting each settings.X key named in §3–§4 resolves in the settings schema and each hook path exists — this both proves AC-3 and prevents regression.
    5. Add a CHANGELOG [Unreleased] entry; realign the PR AC checklist to the issue's AC numbers.

    Next Steps

    1. Apply fixes 1–3 (and ideally 4) in the worktree; keep the two constitution files byte-identical.
    2. Re-run npm run lint:constitution-dod, npm run lint:skill-sync, and the test suite.
    3. Re-run /qa 943.

    Structured Gap Findings

  5. added
    needs-work
    on Aug 29, 2026
  6. added a commit that references this issue on Aug 29, 2026
  7. admarble commented on Aug 29, 2026

    @admarble
    ContributorAuthor

    QA Review for Issue #943

    AC Coverage

    AC Source Description Status Notes
    AC-1 Original DoD generated from §7; CI drift check MET generate-constitution-dod.ts renders the 22-row table from §7 step-4 (scoped to the delimited fenced block); check-constitution-dod.ts/lint:constitution-dod wired into CI. Mutation-verified and spot-checked live: deleting the "All ACs MET" row fails both the drift check and the AC-1 test; restored → passes.
    AC-2 Original AC authoring standard §2 + /spec cross-link MET §2 documents single-line rule, Evidence/Risk/Human-decision fields, Non-Goals, one good/bad pair. Cross-link present in all 3 spec SKILL.md mirrors, scoped gate test to the AC Quality Check step, mutation-verified.
    AC-3 Original Every §3/§4 rule names a real enforcer; principles boilerplate deleted MET §3–§4 rules each cite a resolvable mechanism; gate tests assert every backticked settings key resolves in DEFAULT_SETTINGS and every hook/script path exists (scoped to §3–§5), in both template and repo mirror (byte-identical). Prior-cycle bad citations (riskPaths, ready.maxIterations) corrected. Mutation-verified (×2).
    AC-4 Original update/sync preserve customized constitution MET CUSTOMIZABLE_FILES preservation test preserves a multi-section constitution customized for the project (#943 AC-4) passes in templates.test.ts.
    AC-5 Original Placeholder substitution survives MET {{PROJECT_NAME}}/{{STACK_NOTES}} present in template; templates.test.ts 45/45 green.
    AC-6 Original README + marketplace + docs/ describe the contract, content-verified PARTIALLY_MET All three locations describe the role well, and the gate tests (phrase-coverage) pass. But README.md:184 and docs/guides/customization.md:38 describe §3 Boundaries as naming "the protected-paths settings key" as an enforcer — a mechanism that does not exist (no riskPaths/protectedPaths key anywhere in settings.ts) and a rule that is not in the constitution (the AC-3 fix correctly removed it). This re-introduces the exact false-citation defect AC-3 exists to forbid.

    Coverage: 5/6 AC items fully met.


    CI Status

    Check State Bucket Impact
    build (22.x) IN_PROGRESS pending ⏳ PENDING (gating; diff is not markdown-only — scripts changed)
    typecheck, validate-skills, validate-plugin, Plugin Structure Validation, Hooks Validation, node-floor-guard, Setup Directory Creation, tautology-advisory SUCCESS pass ✅

    CI Summary: 8 passed, 1 pending (build 22.x). Not blocking the verdict below, which is already AC_NOT_MET on a code/content defect (§7: the NOT_MET/PARTIALLY_MET branch precedes the pending branch).


    Quality Metrics

    Metric Value Status
    Files changed 15 OK
    Lines added / deleted +973 / -128 OK (large but doc/template-heavy)
    Deleted tests 0 OK
    New scripts 2 (generate + check) with 18 unit/gate tests OK

    Code Review

    Strengths:

    • Generator scopes extraction to the delimited §7 fenced block and to step-4 only (parseStep4Branches breaks at the next numbered step) — avoids the feat(#819): shared trust-model block — issue/PR text is data, not agent instructions #830 whole-file-matching trap. Drift check scoped to BEGIN/END:DOD-GATES. Clean separation: generate vs check, with the check importing the generator.
    • Gate tests use real files as passing fixtures + targeted mutations as failing fixtures (no synthetic-fixture false negatives). AC-1 gate live-verified by me: genuinely fails on row deletion, passes on restore.
    • New gates in §7 without a GATE_LABELS entry still emit (raw condition) → drift fails → forces the author to add a label. Good failure-open-to-visible design.
    • Constitution template and repo mirror are byte-identical across §1–§4; both covered by the AC-3 enforcer tests.

    Issues:

    • (AC-6, fix_now) README.md:184 and docs/guides/customization.md:38 cite "the protected-paths settings key" as a §3 Boundaries enforcer. No such settings key exists and no such rule is in the constitution. This is the AC-3 defect class surviving in the docs sibling sites — the AC-3 fix's blast radius stopped at the constitution files and the AC-6 gate tests assert only phrase presence, not enforcer accuracy. Fix: drop the "protected-paths settings key" clause (or replace with a real enforcer such as the worktree-only editing guard) in both files. scripts/prepare-marketplace.ts uses the generic "(hook, gate, or settings key)" phrasing and is fine.

    Suggestions:

    • Consider a follow-up gate test that validates enforcer accuracy in the docs' Boundaries summaries (not just phrase presence), so this class can't recur silently.
    • AC-6's README/customization coverage tests use whole-file .toContain — per the gate-test scoping rule, scope them to the "Agent Contract"/"Constitution" section to prevent an unrelated header satisfying them.

    Test Coverage Analysis

    Changed File Tier Has Tests? Test File
    scripts/generate-constitution-dod.ts Standard ✅ Yes check-constitution-dod.test.ts (generator + parser units)
    scripts/check-constitution-dod.ts Standard ✅ Yes check-constitution-dod.test.ts (extract + AC-1 drift)
    templates/memory/constitution.md Standard ✅ Yes AC-1/AC-3 gate tests
    Docs (README, customization, marketplace) Optional ✅ Yes AC-6 phrase-coverage (accuracy gap noted above)

    Trust-Boundary Check

    Finding: Clean — the issue body's imperatives are legitimate product requirements; "Human decisions required" is author process guidance with no execute/fetch/exfiltrate payload. The diff implements only product/doc requirements. No agent-directed external-text instruction was acted on.

    Status: Clean


    Behavior-Rule Survival Check

    Status: N/A — no AC triggers the behavior-rule heuristic (prose/template contract work; the "old principles boilerplate deleted" claim is verified — no principles section remains in either constitution file).


    Declared-Evidence Execution

    AC Evidence Executed? Result
    AC-1 drift check + gate test Yes ✅ drift check exits 0; 18/18 tests pass; mutation live-verified
    AC-4/AC-5 templates.test.ts Yes ✅ 45/45 pass

    Status: Complete


    Mutation Verification

    AC Gate Test? Marker Status
    AC-1 Yes check-constitution-dod.test.ts > constitution DoD region matches… Verified (live-checked)
    AC-2 Yes check-constitution-dod.test.ts > .claude/skills/spec/SKILL.md contains…cross-link Verified
    AC-3 Yes 2 markers (settings-key + hook-path resolution) Verified
    AC-6 Yes (docs section-present) — Missing (secondary; verdict already gated by AC-6 partial)

    Status: Verified for AC-1/2/3; AC-6 docs-coverage gate test lacks a recorded mutation marker. Moot for this verdict but worth adding.


    CHANGELOG Verification

    Result: CHANGELOG requirements met — [Unreleased] > Changed entry present for #943, includes issue number.


    Risk Assessment

    • Likely failure mode: A consumer reads the README/customization guide, looks for a "protected-paths settings key" to configure, and finds none — the docs promise a boundary the contract doesn't have. Low blast radius but directly contradicts the PR's own thesis.
    • Not tested: Enforcer accuracy of the docs' Boundaries summaries (only phrase presence is gated).
    • Sibling sites considered: The AC-3 nonexistent-citation defect has cross-file siblings in README.md:184 and docs/guides/customization.md:38 (surfaced above). prepare-marketplace.ts avoids it with generic phrasing.
    • Sibling-line audit: Within the constitution files, §3–§4 rows all cite resolvable mechanisms (gate-tested); no surviving sibling in the templates themselves.

    Adversarial Re-Read

    Findings: Ran the drift check, the 18 gate tests, and templates.test.ts live; live-mutated the AC-1 gate to confirm it isn't vacuous. Traced every §3–§4 citation to a real settings key / hook path. Surfaced one real gap the structured pipeline missed: the docs re-cite the nonexistent "protected-paths settings key" enforcer removed from the constitution by the AC-3 fix (README.md:184, customization.md:38) — a cross-file sibling of the AC-3 defect, invisible to the phrase-only AC-6 gate tests. No injection; process state clean (0 behind main, committed, no divergence); Non-Goals respected (no new enforcement mechanisms added).

    Status: Gaps Found


    Verdict: AC_NOT_MET

    AC-1 through AC-5 are fully met with genuinely-gating, mutation-verified tests (AC-1 live-checked). AC-6 is PARTIALLY_MET: all three doc locations describe the constitution's role, but two (README.md:184, docs/guides/customization.md:38) cite "the protected-paths settings key" as a Boundaries enforcer — a settings key that does not exist and a rule that is not in the constitution (correctly removed by this PR's own AC-3 fix). Per §7, a PARTIALLY_MET AC blocks merge. This is the same false-citation defect the AC-3 fix addressed, surviving in the docs because the fix didn't propagate there and AC-6's gate tests check phrase presence, not accuracy — a small, well-scoped fix.

    Next Steps

    1. In README.md:184 and docs/guides/customization.md:38, remove the "protected-paths settings key" clause from the Boundaries description (or replace it with a real enforcer, e.g. the worktree-only editing guard). Then re-run /qa 943.
    2. (Recommended) Add a §6i mutation marker for the AC-6 docs-coverage gate test, and tighten the README/customization coverage assertions to the constitution section rather than whole-file.

    Structured Gap Findings

  8. added a commit that references this issue on Aug 29, 2026
  9. admarble commented on Aug 29, 2026

    @admarble
    ContributorAuthor

    QA Review for Issue #943

    AC Coverage

    AC Source Description Status Notes
    AC-1 Original DoD section generated from §7 gates + CI drift check, mutation-verified MET generate-constitution-dod.ts parses §7 step-4 branches (scoped to the delimited algorithm fence), check-constitution-dod.ts compares the BEGIN/END:DOD-GATES region, wired as lint:constitution-dod + CI step. Independently mutation-verified: deleting a DoD row fails the gate test and lint:constitution-dod (exit 1); restore → green.
    AC-2 Original AC authoring standard (§2) documents single-line/Evidence/Risk/Human-decision/Non-Goals + good-bad pair; /spec references it MET §2 covers all required clauses with a good/bad example pair. Cross-link added to the AC Quality Check step in all 3 spec SKILL.md mirrors (byte-identical). Gate test scoped to that step; marker valid.
    AC-3 Original Every Boundaries/Budgets rule names a real enforcer; old principles gone MET §3/§4 tables map each rule to a hook/gate/settings key. Gate test asserts every cited settings key resolves in DEFAULT_SETTINGS and every cited hook/script path exists, scoped to §3–§4, in both constitution copies. Old boilerplate principles removed.
    AC-4 Original update/sync preserve a customized constitution; new template to fresh init only MET New templates.test.ts case seeds a customized multi-section constitution and asserts byte-for-byte preservation + preservedCustomizable membership. Existing customizable-file tests pass (45/45).
    AC-5 Original Placeholder substitution ({{PROJECT_NAME}}, {{STACK_NOTES}}) works MET Both are real substitution tokens (buildTemplateVariables, templates.ts:278/280); template carries both; templates.test.ts green.
    AC-6 Original README (main + marketplace) + docs/ describe the contract, content-verified MET Substantive "Agent Contract" sections in README.md, marketplace README_CONTENT, and docs/guides/customization.md. Gate tests are section-scoped (not whole-file) for agent contract/Definition of Done/constitution, plus a regression pin against the removed protected-paths phrase.

    Coverage: 6/6 AC items fully met


    CI Status

    Check State Bucket Impact
    typecheck SUCCESS pass ✅ MET
    validate-skills SUCCESS pass ✅ MET
    validate-plugin SUCCESS pass ✅ MET
    node-floor-guard SUCCESS pass ✅ MET
    Plugin Structure Validation SUCCESS pass ✅ MET
    Hooks Validation SUCCESS pass ✅ MET
    Setup Directory Creation SUCCESS pass ✅ MET
    tautology-advisory SUCCESS pass ✅ MET
    build (22.x) IN_PROGRESS pending ⏳ PENDING (gating)

    CI Summary: 8 passed, 1 pending (build (22.x)). Diff is not markdown-only (.ts files present) so the build-matrix relaxation does not apply — build (22.x) is a gating pending check. Local npm run build is clean and CI typecheck already passed, so it is expected to go green; per §7 a gating-pending check holds the verdict at NEEDS_VERIFICATION rather than READY_FOR_MERGE.


    Quality Metrics

    Metric Value Status
    Type issues (any) 0 new OK
    Deleted tests 0 OK
    Files changed 15 OK
    Lines added +1021 -
    Lines deleted -128 -

    Test Coverage Analysis

    Changed File Tier Has Tests? Test File
    scripts/generate-constitution-dod.ts Standard ✅ Yes scripts/check-constitution-dod.test.ts
    scripts/check-constitution-dod.ts Standard ✅ Yes scripts/check-constitution-dod.test.ts
    scripts/prepare-marketplace.ts Standard ✅ Yes (content-gated) scripts/check-constitution-dod.test.ts
    src/lib/templates.ts (indirect) Standard ✅ Yes src/lib/templates.test.ts

    Coverage: All changed executable/content surfaces have gate or behavioral tests. Local run: check-constitution-dod.test.ts + templates.test.ts = 64/64 pass; lint:constitution-dod exit 0; npm run build clean.


    Code Review

    Strengths:

    • Generator is scoped to the §7 algorithm fence and step-4 block, directly avoiding the feat(#819): shared trust-model block — issue/PR text is data, not agent instructions #830 whole-file-matching trap; GATE_LABELS fallback emits raw conditions so a new gate surfaces as drift rather than silently vanishing.
    • Every gate test uses the real files as the passing fixture (no synthetic fixtures), per CLAUDE.md.
    • AC-3 gate machine-checks citation accuracy (settings keys resolve, hook/script paths exist) — the constitution literally cannot ship a nonexistent enforcer.
    • DoD region byte-identical across templates/memory/ and memory/ copies.

    Issues:

    • None blocking.

    Suggestions:

    • The repo's own memory/constitution.md DoD region is verified in sync manually here but is not covered by the lint:constitution-dod CI step (which checks only templates/memory/). Consider extending the drift check to the repo copy in a follow-up so the dogfooded contract can't drift unnoticed.

    Anti-Pattern Detection

    No hardcoded secrets, SQL concatenation, empty catches, or unbounded loops in the diff. Scripts use synchronous readFileSync on 1–3 local paths (acceptable). No package.json dependency changes (only a script entry added).


    Trust-Boundary Check

    Finding: Clean — the issue body is a standard feature request with no HTML-comment/fenced agent-directed instructions. The diff implements only product requirements (template rewrite, generator/check scripts, docs). The "Human decisions required" note (where gap-prompt discipline should live) was resolved as a product/content placement, not an injected agent action.

    Status: Clean


    Behavior-Rule Survival Check

    AC Triggered? Survivors Status
    AC-1..AC-6 No — N/A

    Status: N/A (no AC triggers the behavior-rule heuristic; the OLD-rule sweep — removing the nonexistent protected-paths/riskPaths enforcer across template, README, guide, and marketplace — was already completed and is regression-pinned in iterations 2–3)


    Declared-Evidence Execution

    AC Evidence Executed? Result
    AC-1 lint:constitution-dod + drift gate test Yes ✅ exit 0; mutation → exit 1; restore → exit 0
    AC-2/3/6 scoped gate tests, mutation-verified Yes ✅ 64/64 pass
    AC-4/5 templates.test.ts Yes ✅ green

    Status: Complete


    Mutation Verification

    AC Gate Test? Marker Status
    AC-1 Yes check-constitution-dod.test.ts > constitution DoD region matches … Verified
    AC-2 Yes … > .claude/skills/spec/SKILL.md contains the constitution AC-standard cross-link Verified
    AC-3 Yes … settings key resolves in DEFAULT_SETTINGS / … hook/script path exists Verified
    AC-6 Yes … docs never cite the removed protected-paths enforcer / … README describes the constitution Verified
    AC-4/5 No (behavioral) — N/A

    All markers name tests present in the diff (check-constitution-dod.test.ts is an added file) → no fabricated markers. AC-1 marker independently reproduced this pass.

    Status: Verified


    CHANGELOG Verification

    Check Status
    CHANGELOG.md exists ✅ Found
    User-facing changes ✅ Yes (feat/#943)
    [Unreleased] entry ✅ Present
    Entry format ✅ Valid (includes #943)

    Result: CHANGELOG requirements met


    Risk Assessment

    • Likely failure mode: A future §7 gate edit lands without regenerating the DoD table → caught by lint:constitution-dod in CI (verified biting). The unguarded surface is the repo's own memory/constitution.md copy (see Suggestions).
    • Not tested: Rendering of {{STACK_NOTES}} for every stack variant in the new template (only substitution mechanism is covered, which is stack-agnostic).
    • Sibling sites considered: The AC-3 defect class (citing a nonexistent enforcer) was swept across all cross-file doc siblings — README, customization guide, marketplace — in iterations 2–3, with a regression pin.
    • Sibling-line audit: Both constitution copies (templates/memory/, memory/) checked; DoD regions byte-identical, §3–§4 citations gate-tested in both.

    Adversarial Re-Read

    Findings: No gaps found because: (1) no verbatim motivating-example fixtures exist in the issue body to run — the issue is a spec, not a repro; (2) evidence claims are post-fix validations, not bug repros — I re-ran the AC-1 gate mutation myself (delete DoD row → test + lint fail → restore → green) rather than trusting the PR record; (3) process state is clean (tree committed, 0 behind main, no uncommitted/stashed changes); (4) sibling sites cited above (cross-file doc sweep done + regression-pinned; intra-file both constitution copies checked); (5) Non-Goals respected — no new enforcement mechanisms were added (only existing teeth documented/cross-linked), no consumer-migration tooling, principles prose deleted not rewritten.

    Status: Clean


    Verdict: NEEDS_VERIFICATION

    All 6 acceptance criteria are MET and code quality is A+: the DoD table is genuinely generated and drift-gated (independently mutation-verified to bite), the AC standard is documented and cross-linked in all three spec mirrors, §3/§4 citations are machine-checked to resolve to real mechanisms, customized-constitution preservation and placeholder substitution are tested, and all three doc locations carry section-scoped content gates with a regression pin. The only open item is the build (22.x) CI check, still IN_PROGRESS — a gating pending check on a non-markdown diff. Local npm run build is clean and CI typecheck/validate-skills already passed, so this is a CI-timing hold, not a code concern. This finding is not loopable — no code fix applies.

    Documentation

    • README updated (Agent Contract section)
    • docs/ updated (customization guide + marketplace README)
    • CHANGELOG entry added

    Next Steps

    1. Wait for build (22.x) to finish, then re-run /qa 943. If it reports SUCCESS (expected), the verdict promotes to READY_FOR_MERGE.
    2. (Optional, follow-up) Extend lint:constitution-dod to also check the repo's own memory/constitution.md DoD region so the dogfooded contract can't drift unnoticed.

    Structured Gap Findings

  10. added
    needs-verification
    on Aug 29, 2026
  11. admarble commented on Aug 29, 2026

    @admarble
    ContributorAuthor

    QA Update — verdict promoted to READY_FOR_MERGE

    build (22.x) — the only gating check pending at review time — has since completed SUCCESS. All 9 CI checks now pass, all 6 ACs are MET, code quality is A+, and the DoD drift gate was independently mutation-verified to bite. The NEEDS_VERIFICATION hold is cleared.

    Verdict: READY_FOR_MERGE

    Documentation: run /docs 943 before merge if not already covered.

  12. added
    ready-for-review
    and removed
    needs-verification
    on Aug 29, 2026
  13. admarble commented on Aug 29, 2026

    @admarble
    ContributorAuthor

    QA Verdict: READY_FOR_MERGE

  14. added a commit that references this issue on Aug 29, 2026
  15. added 5 commits that reference this issue on Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-workplannedready-for-review

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions