Skip to content

feat(specs): context optimization + validator hardening (timestamps, sub-criteria, contract drift)#62

Merged
hapo-nghialuu merged 7 commits into
devfrom
feat/specs-context-and-validator-hardening
Jun 21, 2026
Merged

feat(specs): context optimization + validator hardening (timestamps, sub-criteria, contract drift)#62
hapo-nghialuu merged 7 commits into
devfrom
feat/specs-context-and-validator-hardening

Conversation

@hapo-nghialuu

Copy link
Copy Markdown
Member

Summary

Improves the specs skill along two axes surfaced during an audit: runtime cost and quality enforcement. Every change follows one principle — move rules from LLM-must-remember (prompt) to machine-enforced (validator), and keep every new check opt-in / progressive so existing specs never false-fail.

Changes

Context / speed

  • P0spec-state hook emits the full Tollgate block only when spec state (phase + done/total) changes; unchanged turns get a one-line reminder (~460 tok/turn saved). Fingerprint cached, gitignored, fail-open.
  • add review bot by AI #2SKILL.md Step 9.5 + Pre-Finalization Checklist split into "validator-enforced" (collapsed to a pointer) vs "judgment-only". ~290 tok off the always-loaded body; all semantic rules preserved verbatim.

Validator hardening (validate-spec-output.cjs)

  • P1b — fail when requirements_done/design_done/tasks_done reuse timestamps.init.
  • P1d — verify acceptance-criterion coverage at sub-level (R3.4), not just group (R3). Opt-in: only when requirements use explicit R{N}.{M} literals + numeric task mapping.
  • Feat/ai reviewer: add AI review #3 — detect cross-layer contract drift: a <!-- contract:NAME --> block in design.md must be copied verbatim by every task declaring Contracts: NAME; diverging copy or unknown name fails. Opt-in via markers; templates/design.md + SKILL.md document the syntax.

Verification

  • P1d: game spec PASS, game-missing-R3.4 FAIL, rtk (numbered-list) no false-fail.
  • Feat/ai reviewer: add AI review #3: synthetic BE+FE fixture — match PASS, field rename FAIL, unknown name FAIL; both real specs unaffected.
  • All validator edits: node -c clean; src ↔ installed .claude copies synced.

Notes

  • No spec output artifacts changed; only skill instructions + the deterministic validator.
  • Honest limitation: Feat/ai reviewer: add AI review #3 catches syntactic drift (verbatim copy), not semantic agreement if both layers are identically wrong; and it engages only when authors use the contract markers (now routed in SKILL.md).

…sub-criteria)

P0: spec-state hook emits full Tollgate block only on state change;
unchanged turns get a one-line reminder (~460 tok/turn saved). Fingerprint
cached in .claude/hooks/.logs/tollgate-last.txt (gitignored, fail-open).

P1b: validator fails when requirements_done/design_done/tasks_done reuse
timestamps.init — prompt-only rule moved to deterministic backstop.

P1d: validator verifies per-criterion coverage (R3.4), not just group (R3).
Progressive: enforced only when requirements.md uses explicit R{N}.{M} literals
+ numeric task mapping; legacy numbered-list specs skipped (no false failures).
…y validator

Step 9.5 Finalization Audit and Pre-Finalization Checklist now separate
validator-enforced checks (collapsed to one pointer line) from judgment-only
checks the validator cannot see. Removes hand-restated rules the deterministic
validator already hard-fails on; preserves every semantic rule verbatim
(deletion policy, provider drift, decision propagation, EARS measurability,
Mermaid diagrams). ~290 tokens off the always-loaded skill body, no loss of
enforcement.
design.md can declare a named contract via `<!-- contract:NAME -->` + a fenced
block. Every task that declares `Contracts: NAME` must copy that block verbatim.
validate-spec-output.cjs fails the spec when a task's copy diverges from the
canonical definition (e.g. orderId vs order_id) or names an undefined contract.

Closes the BE/FE/DB contract-drift gap where each layer "inherits verbatim" by
hand-copying prose and silent divergence only surfaces at integration.

Opt-in: specs without contract markers are unaffected. templates/design.md
documents the syntax. Verified on a synthetic BE+FE fixture (match PASS, field
rename FAIL, unknown name FAIL) + regression on both real specs (no effect).
…cross-layer specs

Tells the design phase to declare cross-layer data shapes as <!-- contract:NAME -->
blocks so the new validator drift check actually engages on BE/FE/DB specs,
instead of the syntax sitting unused in the template.
Drops Step 8 (Task Hydration) and deletes references/task-hydration.md. It
created session-scoped Claude Tasks that died with the session and were
re-derived from task files regardless; develop reads task files directly, so
the hydration step was effectively dead weight. Pipeline renumbered:
1-7 + Validation (8) + Finalization Audit (8.5) + Completion (9).
Task files + task_registry remain the single source of truth — no behavior loss.
The 34-line rules/tasks-parallel-analysis.md was ~90% a restatement of
tasks-generation.md's Parallel Analysis section. Merged its 3 unique points
(env/setup precondition, (P) outside checkbox brackets, skip container-only
majors) into tasks-generation.md and deleted the file. Step 7 no longer loads
a separate parallel-analysis rule. No behavior change; one fewer file to load.
Specs pipeline streamlined (9 steps, Task Hydration removed), lower per-turn
tollgate context, leaner SKILL.md, and deterministic validator hardening
(timestamps, sub-criteria coverage, cross-layer contract drift — all opt-in).
@hapo-nghialuu
hapo-nghialuu merged commit ec012eb into dev Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant