quality-gate
Independently verify an Implementation Complete task with a Default-FAIL verification contract, deterministic checks, and an isolated critical reviewer, then decide whether it is Done.
- License 许可
- MIT
- 最近更新
- 2026-11-15
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- quality-gate
- description
- Independently verify an Implementation Complete task with a Default-FAIL verification contract, deterministic checks, and an isolated critical reviewer, then decide whether it is Done.
- user-invocable
- false
- disable-model-invocation
- false
03 SKILL.md 正文
Caller: This skill is invoked by
sdd-ship. Do not invoke directly. Results are returned to the caller; no downstream skill is auto-invoked.
Quality Gate
Use after implement-task has set a task to Implementation Complete.
Preconditions
If AGENTS.md is absent at the repository root, stop immediately and direct
the user to run /sdd-bootstrap:sdd-adopt; do not proceed without it.
Missing reports/quality-gate/ or docs/review-tickets/ directories may be
created on the fly before continuing.
Required Reading
Read the task, implementation report, requirements, design, acceptance tests,
traceability, contracts, ADRs, Git diff, and all bundled references, including
deterministic-check-policy.md, evaluation-rubric.md, risk-gate-matrix.md,
risk-classification-policy.md, and
plugins/sdd-quality-loop/references/quality-gate-calibration.md.
Process
-
Reject any target not in
Implementation Complete. -
Create the Default-FAIL verification contract for the task from
templates/verification-contract.template.jsonfollowingdeterministic-check-policy.md. Treat the implementation report as a claim, not as evidence. -
Compare the implementation and report with the approved task and source artifacts.
-
Detect and run all available CI-equivalent checks using
verification-policy.md. Save real command output as evidence and update the contract. -
Verify tests using
test-policy.md. -
Run the scripted gates with
scripts/*.shorscripts/*.ps1, in this order:check-riskon the task: confirms a validRisk:tier, a non-emptyRisk Rationale:, and — forhigh/critical—Required Workflow: tdd. The tier selects the required-check set perrisk-gate-matrix.md.check-placeholderson the changed production files only.check-design-systemon the changed files when the project carries adesign-system/directory and the task touches UI-layer files: validates the design-tokens.json contract envelope, scans changed files for raw style values, and confirms design.md's## Design System Compliancesection. Warn-phase: findings are recorded in the report and in the contract'sdesign-systemcheck but do not block until the error promotion (SDD_DESIGN_SYSTEM_ENFORCE=error); whendesign-system/is absent the script skips with a note.check-domain-conformanceon the task'srequirements.md/design.mdwhen the project carries adomain/directory: validates theBounded-Context:field's context name(s) againstdomain/domain-contract.json, structured-field canonical-term usage, anddesign.mdaggregate references againstdomain/aggregates/; for a two-contextBounded-Context:, passes only when the context map declares a relation between them. Warn-phase: findings are recorded in the report but do not block until the error promotion (SDD_DOMAIN_ENFORCE=error); whendomain/is absent the script skips with a note.check-workflow-statewithout--feature: validates the canonical persisted-state invariant for every registered specification.check-task-stateon tasks.md.check-contracton the task contract: enforces the tier-minimum required set (superset rule) and, whenrequired_workflowistdd, non-emptyred_evidence+green_evidencefor every test-type check.check-component-coverage(epic-191-a3-path-ownership T-004, REQ-004): the Reverse Coverage Gate. Always runs to completion and always emits acheck-component-coverage-verdict/v1evidence record. Derives one of three states from the project'sworkflow.capability_enforcement(never from Facet Manifest file presence, ADR-0016):disabled-legacy(zero evaluation, a real N/A record, exit 0 — this repository's own current state, since noproject-context.yamlexists yet),advisory(full six-Fail-condition evaluation and recording, always exit 0),required(identical evaluation, exit non-zero iff a Fail condition triggers). This documented invocation is defense-in-depth, not the reachability guarantee —check-component-coverageis registered incheck-contract's own protected tier-minimum required- check-set (INV-017), which is what actually closes the gap were this line to be deleted or the check renamed.check-traceabilityonspecs/<feature>/traceability.json: every REQ → AC → TEST → evidence chain is intact (required forhigh/critical). ForDonetasks, validatespecs/<feature>/verification/<task-id>.evidence.jsonwithcheck-evidence-bundle.(sh|ps1)so the report, contract, and passing evidence artifacts are all bound together. Forhigh/criticalthe bundle must carryspec_revision,build_env, andreview_verdict.verdict == PASS; forcriticalit must additionally carry a verifiable HMACsignatureand a clean tree (git_generated_dirty == trueis a hard fail). Always produce the bundle withgenerate-evidence-bundle.(sh|ps1)— never hand-author sha256 fields or thegit_commitfield. The runner binds the bundle to the current git commit and computes digests automatically.
-
For
refactorandbugfixtasks with abaseline-behavior.md, applydifferential-test-policy.mdand classify every BL diff. -
Run critical review with an isolated evaluator using
evaluation-rubric.md. The evaluator must also applyquality-gate-calibration.md: deterministic command output, bundled scripted gates, line-level inspection, and manual artifacts outrank implementation-report claims; the implementation report never supports PASS by itself. When the change touches the relevant surface, the evaluator also applies the on-demand domain checklists —security-checklist.md(user input, auth, secrets, external systems, AI/LLM),performance-checklist.md(data access, hot paths, rendering),accessibility-checklist.md(user-facing UI), anddesign-system-checklist.md(user-facing UI in projects carrying adesign-system/contract). Load a checklist only when its domain is in scope, to keep review context lean. On Claude Code use thesdd-evaluatorsubagent. Claude Code has no per-invocation effort control (REQ-008, INV-013): the evaluator's effort stays whateverrender-agent-frontmatterlast recorded inevaluator.md'sx-sdd-effort:comment (record-only,effort_applied=null); anyemit-run-recordcall for this run passes--effort-control-main frontmatter(no--effort-applied-main) so the resulting run record shows the degradation explicitly, keyed on the resolvedeffort_controlvalue, never as a silent drop (AC-039, sharing the AC-024/AC-051 field-population rule).On Codex use the shipped
sdd-evaluator(orsdd-investigator) TOML agent; do not create new agent role files under~/.codex/agents/. Codex-host startup wiring (REQ-006, T-006): before launchingcodex, resolve--model/--effortfrom the live registry — never from unsanitized task or spec text (security-spec.md B3) — via:plugins/sdd-implementation/scripts/select-agent-model.sh \ --risk <risk> --registry contracts/agent-model-capabilities.v2.json \ --candidates-file <codex-candidates.json> \ --role sdd-evaluator --host codex-cli --json(substitute
--role sdd-investigatorfor the investigator;--host codex-cliresolves each candidate'seffort_control.codex-cli, and--roleseeds the role'sminimum_tier/fallback effort fromrole_defaults). Cross-check the resolvedmodel/effortagainst the# x-sdd-model:/# x-sdd-effort:reference comments T-003's renderer wrote into.codex/agents/sdd-evaluator.toml(orsdd-investigator.toml): when they diverge, report the divergence (DRIFT: <toml-path> toml=<model>/<effort> live=<model>/<effort>) rather than silently preferring either value — the live selector output is always what launchescodex, the stale reference comment is never silently substituted in either direction (AC-038). Reject any resolved--model/--effortvalue that is not a member of the registry's own enumerated vocabulary: a whitespace-containing value, a value with a leading-/--(flag-injection shape), a value containing;(command-separator shape), or an effort string outside the set{low, medium, high, xhigh}. On rejection: non-zero exit, a diagnostic message, and nocodexinvocation attempted (AC-052;run-panelist-gpt.sh/.ps1implement this same rejection for their own--model/--effortarguments —tests/run-panelist-effort.tests.sh/.ps1TEST-052). Launchcodexwith the resolved, validated flags: these flags configure a fresh Codex CLI caller, which must then spawn the shipped projectsdd-evaluatorTOML agent for independent evaluation. The CLI root is not a substitute for that agent. Before accepting the evaluator's verdict, verify the spawned agent's effective model and reasoning effort against the live selector from its native child session metadata; caller flags and TOML reference comments alone are not proof. If either effective value is unavailable or differs, retain the task state and do not accept a verdict.codex exec --model <live-model> -c model_reasoning_effort=<live-effort> ...Elsewhere, perform the review in a fresh session or a clearly separated critical-review pass. Before launch, persist a canonical allowed-input manifest containing exactly one
reports/implementation/<feature>/T-NNN.md, the task's required specification and calibration files, and only those changed, test, contract, ADR, or deterministic-evidence files whose exact canonical path and lowercase SHA-256 pair appears in that implementation report's## Outputstable, or in the## Post-Fix Artifactstable of a gate report the manifest names ingate_report_declarationand pins by SHA-256 (WFI-036). The implementation report is frozen, so it can never describe bytes produced by a fix this gate itself raised; a cycle that follows a review-ticket or in-gate fix therefore records the post-fix path/hash rows in its own report, and the next cycle names that report. The second channel is checked exactly as the first: the named report's own hash is verified before a single row is read from it, a path in neither document is still unlisted, and a row carrying the wrong hash still fails. Do not add the rows to an earlier cycle's report -- that report recorded a verdict at a point in time and must not later declare bytes that did not exist then. An implementation report with missing pre-reservation provenance must not be repaired by adding historical facts to that frozen report. For an explicitly human-approved recovery, retain the old canonical report's original bytes in a task-scoped archive and record its former path and verified SHA-256 in the new report's supersession note. The archive is historical evidence, not a substitute for a new implementation run. In a fresh isolated implementation context, recheck the current code against hash-pinned inputs, then write a new report and task-input manifest with their actually observed run/session IDs and canonical absolute scratch root. Only after both reports and their hashes have been independently checked may the new report take the canonicalreports/implementation/<feature>/T-NNN.mdpath. Do not edit the archive or rewrite a historical handoff. Declare the archive's exact path/hash in the new report's## Outputsif the evaluator needs to read it; neither supersession nor archival automatically authorizes it as an input. The normal manifest hash, report identity, scratch isolation, reservation, independent evaluation, and Done checks still apply without exception. Broadplugins/,tests/,contracts/, ordocs/adr/membership never authorizes an evaluator input. Reverify every hash immediately before launch and bind the manifest path/hash, a fresh run ID, and a distinct host-session ID into the evaluator result. Persist a one-rolereview-context-invocation/v2manifest for the evaluator. Set itstask_idto the current T-NNN and require the sole implementation report path, report heading, andTask IDfield to match that exact task. Bind it to the current SHA-256 and final record hash of the canonicalreports/review-context/identity-ledger.json. The ledger must already carry every earlier reviewer/evaluator reservation as a valid hash chain. For a new reservation, include the existing hash-pinnedtask-input-manifest/v1as an evaluator input and name its path and SHA-256 inimplementation_manifest. Require its task/run/session to agree with the implementation report and reject their reuse in the canonical ledger. Never fabricate an implementation ledger reservation or accept reserved-ID arrays as a substitute. Before reservation, the caller must prepare any dependency fixture needed by read-only checks in a fresh evaluator-only scratch directory, preserving admitted relative paths. Include every test dependency in the manifest; missing dependencies block launch rather than being created by the evaluator. The scratch copy is only a byte-identical projection of admitted files, not an additional source of authority. Record its canonicalscratch_rootin the invocation and independently read back every copied file against its admitted SHA-256. The evaluator remains read-only inside scratch as well. Freeze the manifest and pin its SHA-256 separately in the launch brief. For the explicitly authorized Claude Code non-TTY Sonnet route, use the shared caller (repository-root-relative paths):rtk proxy python3 -B plugins/sdd-review-loop/scripts/launch-impl-review.py <repository-root> <invocation> <reports/quality-gate/launch-SESSION> --manifest-sha256 <caller-pin>. The canonical Claude evaluator and its generator must both select Sonnet; this does not change the Codex evaluator tier or authorize a host switch to bypass a refusal. This route requires a fresh declared scratch projection. It checks the external raw pin, common required-input/path admission, and this plugin'spreflight-evaluator-delivery.pyscratch readback before creating launch output. It then pins dependencies, checks live CLI argv, and runs the shared native permission probe before reservation. Missing or failedpreflight-host-review.pyHOST_REVIEW_PREFLIGHT_OKproof, or failed admitted-read, outside-read denial, compound-Bash denial, session collision, or ordered-hash proof stops without reserving. Input preflight alone explicitly leaves permission proof unestablished. Immediately before reservation it rechecks dependency bytes, admission, argv, and the same delivery helper's pin/scratch readback; only that helper delegates the canonical atomic reservation. Do not separately reserve this route. The complete receipt and invocation pin reach the child through the shared prompt, and native delivery is validated independently of its verdict. Exact Read/hash permissions do not permit writable tests: list tests not rerun, and never treat delivery or a receipt as quality PASS. A candidate launcher or fixture success does not establish an installed verified baseline or authorize formal execution. For other already-supported host routes, retain the delivery sequence below: runpython3 -B scripts/preflight-evaluator-delivery.py --manifest <manifest> --manifest-sha256 <caller-pin> --repository-root <repository-root>(paths relative to this plugin); append--scratch-root <scratch>when a fixture is needed. RequireEVALUATOR_DELIVERY_OKbefore calling the reservation validator. Failure leaves the ledger untouched. This delivery check does not replace the existing required-input, path, identity or reservation checks. Do not change these bytes between delivery and launch; the evaluator must independently compare the manifest's raw bytes with the caller's pin before parsing, then verify admitted inputs before use. A scratch fixture does not authorize write-requiring tests; those remain caller-owned evidence. Immediately before launch on those other host routes, run the same delivery command with--reserve. It rechecks the pin and fixture before delegating the atomic reservation toscripts/validate-review-context-set.sh; do not reserve directly and then prepare a fixture. RequireEVALUATOR_DELIVERY_OKandREVIEW_CONTEXT_OK, then pass the complete validator receipt and the persisted invocation manifest path/hash in the launch brief to the shipped evaluator. Tell the evaluator to verify identity from that receipt and manifest alone; the ledger is caller-only. Do not ask it to read/hash the ledger, rerun the validator, inspect the process environment, or open raw session logs. Launch exactly the reserved evaluator run/session. A missing canonical ledger, stale chain tip, deterministic runtime, or any non-zero result retainsImplementation Completeand blocks evaluator launch. This boundary validates only the evaluator being launched; it does not require fabricated future or replayed reviewer contexts. Reject a missing manifest, unlisted path, hash mismatch, chat-only input, or any implementation/review/evaluation session reuse. Never direct an evaluator to reach an artifact the manifest does not authorize -- not throughgit show, not through the live tree, and not by reproducing its contents in the launch prompt. Authorization comes from the persisted, validator-checked manifest, never from the launching agent's prose; a launcher that can widen the evaluator's reachable set by asking has removed the boundary this machinery exists to enforce. When a needed artifact is undeclared, declare it and relaunch rather than instructing around it (WFI-036). No same-session fallback is permitted for the evaluator. Use the caller-prepared evaluator scratch directory and name it in the launch brief and the invocation record's optionalscratch_rootfield: a canonical absolute path used by no implementation context for this feature and by no earlier evaluator run. Tell the evaluator to write nothing, including inside scratch; fixture preparation and writable tests belong to the caller. Whenscratch_rootis present, the deterministic reservation boundary compares it with the current implementation report'sScratch Rootand rejects equal or ancestor/descendant paths before launch. This is not housekeeping (WFI-034). Sharing one scratch root across roles puts the implementing agent's intermediates -- a.bakof the suite under review, per-task append scripts, raw red/green logs -- inside reach of the agent grading that work, through a channel the manifest does not describe and the hash checks never see. Observed insdd-domain-concept-contract: the evaluator found exactly those files and disclosed that it had declined to read them. What held there was the reviewer's judgement, not a mechanism, and a boundary that depends on the reviewed party declining an available capability is not a boundary. Forhigh/criticaltasks, record the evaluator's verdict asreview_verdictin the evidence bundle;check-evidence-bundlerequiresreview_verdict.verdict == PASS. -
Classify findings as
Accepted,Rejected, orDeferred. When a finding is that the implementation report's narrative (counts, statuses, or paths) diverges from the gate-time measured reality -- e.g. a later same-feature task's edit, or a gate-phase artifact move, superseded what the report described -- record the current values directly in this quality-gate report and classify the findingAccepted; do not edit the frozen implementation report to reconcile it. -
Apply only safe fixes allowed by
auto-fix-policy.md. -
Repeat critical review for a maximum of 3 cycles. Stop earlier when the remaining issue requires human decision, missing evidence cannot be produced, or the fix belongs to
fix-by-review-ticketor an upstream review loop. Do not downgrade a finding merely to end the loop. -
For UI changes, use available browser or Playwright tooling to verify the rendered screen, DOM, and console, and when feasible perform the smoke run described in
deterministic-check-policy.md. -
Create review-ticket YAML for unresolved or non-auto-fixable findings.
-
Update traceability and detect drift using
integrity-policy.md. -
Create
reports/quality-gate/<timestamp>.mdfromplugins/sdd-quality-loop/templates/quality-report.template.md— the template exists and is parity-tested (tests/template-validator-parity.tests.{sh,ps1}); do not author the report freeform. Its identity header block (Task ID:/Feature:/Run ID:/VERDICT:/Critical:/Major:/Minor:) is parsed by deterministic consumers (check-evidence-bundle, emit-run-record, generate-evidence-bundle, the retrospective's artifact rules): keep each as a bare line before any prose, and never start a later body line withFeature:orTask ID:— two consumers require exactly one match each. Record the same- Model:/- Effort:two-line requirement the implementation report carries (implementation-report.template.md,validate-implementation-report.shpresent-and-format-only check): name the model and effort the gate's own critical-review pass ran under. (WFI-020)
Sudo Mode
If a valid SDD_SUDO flag file exists at the project root (see
plugins/sdd-quality-loop/references/sudo-mode-policy.md), routine approval
checkpoints auto-pass: record Approval: Approved (sudo <ISO8601 UTC>) in
tasks.md and continue. A refactor/bugfix BL diff classified accepted also
auto-passes (mark (sudo <ISO8601 UTC>) and update baseline-behavior.md).
Sudo never auto-passes genuine judgment: requires_human_decision: true
findings, architecture/auth/authz/breaking-API/security decisions, and a
fix-required baseline diff still stop the gate and require a human. All
deterministic gates apply; every check runs as normal.
Done Decision
Set the task to Done only when:
check-riskpasses: valid tier + rationale, andhigh/criticaldeclaresRequired Workflow: tddcheck-contractpasses: every required contract check (the tier-minimum superset) is true with existing evidence files; fortdd, test checks carryred_evidence+green_evidencecheck-traceabilitypasses forhigh/critical(REQ → AC → TEST → evidence)check-evidence-bundlepasses: the bundle names the report, contract, and contract-passing artifacts, with matching hashes and task id; forhigh/criticalit carriesspec_revision,build_env, andreview_verdict.verdict == PASS; forcriticalit carries a verified HMACsignatureover a clean tree- for
critical, a second distinct named approver recordedSecond Approval: Approved(enforced bycheck-task-state; never sudo-bypassed) - acceptance criteria have tests
- no unresolved Critical or Major finding remains
- required UI verification succeeds
- contracts and ADRs agree with the implementation
- traceability is current
- every in-scope "cannot verify" item has been resolved by evidence or recorded as a blocking review ticket
Otherwise set the task to Blocked or retain Implementation Complete, and
create review tickets. Do not commit, push, or create a PR/MR unless explicitly
requested.
Post-Done: Automatic Retrospective
When the task transitions to Done (all conditions in the Done Decision section
are met), automatically invoke the retrospective flow:
- Confirm
reports/quality-gate/<timestamp>.mdhas been written (step 15 must complete first so the new report is included in retrospective metrics). - Determine the feature path from the task's spec directory (e.g.
specs/<feature>). - Check
tasks.mdfor the feature: if any task withApproval: Approvedis not yetStatus: Done, append[INFO] retrospective deferred: N approved task(s) still pending Doneto the quality-gate report and stop here. Invoke retrospective only when every approved task in the feature isDone. - Invoke
workflow-retrospectivefor that feature path:- Claude Code:
/sdd-quality-loop:workflow-retrospective specs/<feature> - Codex:
Use the workflow-retrospective skill for specs/<feature>
- Claude Code:
- The retrospective runs in read-only mode and does not affect
Donestatus or any other task field. - If the feature path cannot be determined, skip the retrospective and append a
[WARN] retrospective skipped: feature path unknownline to the quality-gate report.
Do not invoke this flow when the gate exits with Blocked or retains
Implementation Complete.
Common Rationalizations
The gate exists because generators grade their own work generously. Reject
these excuses — each one launders a claim into a Done.
- "The report says all tests pass, so they pass" — the report is a claim; rerun
the checks and read the output yourself (
evaluation-rubric.md). - "The checks are green, the review can be light" — green checks do not cover spec compliance, untested acceptance criteria, or completion-faking.
- "This finding is probably fine, downgrade it to Minor" — never weaken a severity without recording why in the report.
- "A check doesn't apply, I'll just delete it from the contract" — mark it
required: falsewith a non-emptywaiver_reason; never remove a check to pass. - "The evidence file is missing but the result is obviously right" — Default-FAIL: no saved evidence means the check stays false.
- "I cannot verify this, but no failure is visible" — cannot-verify is not PASS; keep the check false or create a review ticket.
- "sudo is on, so I can wave this through" — sudo auto-passes routine approval only; judgment findings and architecture/auth/security decisions still stop the gate.
Red Flags
- Flipping a contract check to
passes: truewithout a saved evidence path. - A handler returning data shaped like the test fixture (completion-faking —
Critical). - Skipped/
todo/xittests covering in-scope behavior left unaddressed. - An acceptance criterion with no test traced to it.
- Setting
Donewhile a Critical or Major finding is unresolved. - Running the critical review in the same context as the implementation.
04 同仓库更多 Skills
status
Show a read-only Jira-style six-view SDD dashboard in the initiating parent's Sites or Claude Artifacts, with source freshness and failure visibility.
verify-review-reservation
Recheck the bounded identity-ledger reservation invariant after lock, hash-check or publication changes.
aws-cdk
Authors, deploys, and troubleshoots AWS infrastructure using CDK with TypeScript or Python. Covers best practices, stack architecture, and construct patterns. Applies when writing CDK constructs, bootstrapping environments, running cdk deploy/synth/diff, fixing CDK or CloudFormation errors, planning stack structure, importing existing resources, resolving drift, or refactoring stacks without resource replacement.
ship
Implement approved SDD tasks through the quality gate to Done — the second of the two-command workflow. Run after /sdd-bootstrap:bootstrap and human task approval.
ship
Implement approved SDD tasks through the quality gate to Done — the second of the two-command workflow. Run after /sdd-bootstrap:bootstrap and human task approval.
ship
Implement approved SDD tasks through the quality gate to Done — the second of the two-command workflow. Run after /sdd-bootstrap:bootstrap and human task approval.