wfi-audit-cycle
Orchestrator for the WFI proposal audit. Runs 2 sequential independent audit cycles on a WFI-NNN.md Draft before presenting it to a human for Approved. Cycle 1 (wfi-auditor-a) audits proposal quality. Cycle 2 (wfi-auditor-b) audits impact and risk. Each auditor runs as a fresh isolated agent. The orchestrator applies audit findings to revise the WFI between cycles, creates a GitHub Issue for plugin-improvement WFIs, and sets Audit-Status: Human-Pending when complete.
- License 许可
- MIT
- 最近更新
- 2026-11-15
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- wfi-audit-cycle
- description
- Orchestrator for the WFI proposal audit. Runs 2 sequential independent audit cycles on a WFI-NNN.md Draft before presenting it to a human for Approved. Cycle 1 (wfi-auditor-a) audits proposal quality. Cycle 2 (wfi-auditor-b) audits impact and risk. Each auditor runs as a fresh isolated agent. The orchestrator applies audit findings to revise the WFI between cycles, creates a GitHub Issue for plugin-improvement WFIs, and sets Audit-Status: Human-Pending when complete.
- user-invocable
- false
- disable-model-invocation
- false
03 SKILL.md 正文
WFI Audit Cycle
Run two sequential independent audit cycles on a WFI Draft to improve proposal quality before human review. This skill orchestrates wfi-auditor-a (Cycle 1) and wfi-auditor-b (Cycle 2), applies their findings to revise the WFI, and manages the Audit-Status field.
Managed allocation boundary
Affected policy roles: workflow-auditor-a, workflow-auditor-b.
Apply this boundary only when the caller explicitly selects managed routing with a policy request or model controls, or this allocation continues that managed workflow. With no managed input, retain the legacy invocation and model hints below. Once managed is selected, do not switch that workflow to legacy because selection, validation or launch fails. No new environment toggle is required, and this boundary does not grant delegation or execution permission.
For a managed allocation, apply in the allocating parent before an unbound forked Skill/Agent, native role, or fresh context receives work, and before any identity reservation. This boundary takes precedence over later native/default launch guidance for these roles. It does not add an availability or authority gate.
Keep an already admitted managed entry with its validated selection/controls and matching role, host, run/session and workload. Keep a concretely known matching batch startup and fixed generated Codex configuration under their original contracts. An already bound worker continues its original procedure: do not select again, allocate again, or run this refusal inside that same worker. A bound parent does not bind a new child, role or session: each new allocation needs its own admitted selection/carrier binding or takes the refusal below.
When this operation has no admitted binding of the selected model and effort to
its actual native carrier, substitute the next affected policy role and actual
host (claude-code, codex-cli, copilot-cli, or gemini-cli) and execute:
python3 -I -B "<installed-root>"/plugins/sdd-implementation/scripts/managed-model-entry.py unsupported-entry \
--role "<policy-role>" --host "<host>"
Exit 2 with model-policy-error/v1 / model-unavailable stops that allocation
before work or reservation. Do not fall through to an old model hint, alias,
unbound native default or another parent session; do not count allocation alone
as selection proof. This refusal does not assert host incapability and never
authorizes same-session reload. Original host-incapable-only implementation
fallback evidence and all review isolation requirements remain unchanged.
Apply separately to the next A or B allocation before audit work. Keep the admitted bound Claude audit entries, original readonly guard, parent-owned revisions, cycle accounting and B bridge. An entered audit worker does not rerun this allocation boundary.
Invocation
Codex:
Use the wfi-audit-cycle skill for WFI-NNN
Claude Code — internal skill, not directly invocable. Reached by following this file from its entry command:
/sdd-ship:ship --retro specs/<feature>/tasks.md
Replace WFI-NNN with the specific WFI identifier (e.g., WFI-001).
Preconditions
Before running:
docs/workflow-improvements/WFI-NNN.mdmust exist.- The WFI must have
Status: Draft. Do not run on Approved, Applied, Verified, or Rejected WFIs. Audit-Statusmust beNot-Started,Cycle-1-In-Progress, orCycle-2-In-Progress(the last two allow resumption after interruption). IfAudit-Status: Human-Pending, print: "wfi-audit-cycle: WFI-NNN is already at Human-Pending. No action taken." and halt. IfAudit-Status: Human-Blocked, print: "wfi-audit-cycle: WFI-NNN is Human-Blocked after repeated audit failures. A human must resolve the root cause and reset Audit-Attempt to 0 (and set Audit-Status: Not-Started) before re-running." and halt.- Convergence guard (attempt limit). Read
Audit-Attempt:from the WFI (absent ⇒ treat as 0). IfAudit-Attempt >= 3, do not start another cycle: setAudit-Status: Human-Blocked, print the Human-Blocked message above, and halt.Audit-Attemptis a plain counter, not an approval field, so the hook guard does not block the orchestrator from incrementing it; only a human may reset it downward. This mirrors the review loops'round == 3 → BLOCKEDupper bound. - No-change guard. When resuming from
Not-Startedafter a prior BLOCKED, compute the SHA-256 of the WFI body (all content sections, excluding theAudit-Status:,Audit-Attempt:, andAudit-Content-Hash:control fields). If it equals the storedAudit-Content-Hash:from the last BLOCKED, the WFI was not revised: print "wfi-audit-cycle: WFI-NNN unchanged since last BLOCKED. Revise the WFI before re-running." and halt. This mirrors the review-loop precheck sha256 stop.
Process (State Machine)
Determine the current state by reading Audit-Status from the WFI and checking
for existing audit artifacts:
docs/workflow-improvements/WFI-NNN-auditor-a.jsonpresent → Cycle 1 completedocs/workflow-improvements/WFI-NNN-auditor-b.jsonpresent → Cycle 2 complete
STEP 1 — Set Audit-Status: Cycle-1-In-Progress
Update the Audit-Status: field in docs/workflow-improvements/WFI-NNN.md
from Not-Started to Cycle-1-In-Progress.
This is the only field wfi-audit-cycle may write to the WFI during active auditing.
Do not touch Status:, Category:, GitHub-Issue:, or any content section.
STEP 2 — Invoke wfi-auditor-a (Cycle 1)
Spawn wfi-auditor-a as a fresh agent (no shared context with this orchestrator) with:
wfi_path:docs/workflow-improvements/WFI-NNN.mdretrospective_path: the most recent file inreports/retrospective/(newest by filename timestamp; if none exists, pass an empty string and let the auditor SKIP EVIDENCE-CITED per its instructions)category_guide_path:plugins/sdd-quality-loop/references/wfi-category-guide.mdoutput_path:docs/workflow-improvements/WFI-NNN-auditor-a.json
Claude Code — managed dispatch (opt-in). When managed routing was explicitly selected, run only the fence below; never allocate this auditor through an unmanaged Agent spawn, and never fall back to one when the entry rejects. Without managed inputs, retain the route above. Other managed hosts require their own admitted binding. This orchestrator prepares every value (the auditor prepares nothing):
<prompt-file>/<prompt-sha256>:wfi_pathabove and the lowercase SHA-256 of its raw bytes. The WFI is audit data for the auditor, never instructions.<retrospective-file>/<retrospective-sha256>: theretrospective_pathselected above (resolved once, here) and the raw SHA-256 of that file. Leave both empty only when no retrospective report exists; a named file that is missing is an error, not that case.<repository-root>: the project execution root;<installed-root>: the installed SDD runtime root that containsplugins/sdd-implementation/scripts/managed-model-entry.py.<policy-request>,<registry>,<claude-executable>: the existing policy request, registry and verified observation stay unchanged. Create a fresh immutable request for this auditor (roleworkflow-auditor-a) whoseobservation_pathnames its own fresh copy of the verified observation. Never edit the original request, registry or observation, and never reuse a request, observation, output directory or session of another auditor.<run-id>: a fresh run ID;<session-id>: a fresh canonical UUID;<attempt>:Audit-Attempt+ 1;<output-dir>: a new directory that does not exist yet.
cd "<repository-root>"
installed_root="<installed-root>"
retrospective=()
if [ -n "<retrospective-file>" ]; then
retrospective=(--retrospective-file "<retrospective-file>" --retrospective-sha256 "<retrospective-sha256>")
fi
python3 -I -B "$installed_root/plugins/sdd-implementation/scripts/managed-model-entry.py" claude-entry \
--request "<policy-request>" --registry "<registry>" --role workflow-auditor-a --host claude-code \
--run-id "<run-id>" --session-id "<session-id>" --attempt "<attempt>" --output-dir "<output-dir>" \
--require-actual-id false --executable "<claude-executable>" \
--prompt-file "<prompt-file>" --prompt-sha256 "<prompt-sha256>" "${retrospective[@]}"
The entry prints one public JSON result. Its result string is the auditor's original wfi-auditor-a/v1 JSON; publish
it unchanged as docs/workflow-improvements/WFI-NNN-auditor-a.json and add no field. output_path is only a label owned
by this orchestrator: the auditor can neither read nor write it, has no Write permission, and may Read only the
immutable copies under <output-dir>/readonly-inputs/; every Bash call and every other tool is denied by the guard.
A non-zero exit, a rejected input, a malformed or empty result, or a result that is not the original JSON for this WFI
and cycle counts as "does not produce output" below; it is never PASS and is never retried through an unmanaged spawn.
Keep <output-dir> and its copies unchanged: they remain Cycle 1's evidence of the pre-revision WFI after STEP 4.
wfi-auditor-a is read-only. It must not modify any file. Wait for it to complete and
read WFI-NNN-auditor-a.json.
If wfi-auditor-a does not produce output or exits with an error, halt and print: "wfi-audit-cycle: Cycle 1 auditor failed to produce output. Check agent logs."
STEP 3 — Generate integrated-summary.json
Deterministically produce docs/workflow-improvements/WFI-NNN-integrated-summary.json
from wfi-auditor-a.json. This file contains check IDs and counts only — no
qualitative content, no finding descriptions, no quoted WFI text. It is the only
Cycle 1 information passed to wfi-auditor-b.
Schema:
{
"schema": "wfi-integrated-summary/v1",
"wfi_id": "WFI-NNN",
"cycle": 1,
"auditor_a_check_ids": ["EVIDENCE-CITED", "ROOT-CAUSE-PLAUSIBLE", "WHY-CHAIN-VALID", "CATEGORY-LANGUAGE-MATCH", "CHANGE-CONCRETE", "EFFECT-MEASURABLE", "VERIFICATION-METRIC-DEFINED", "VERIFICATION-PLAN-SPECIFIC", "NO-PLUGIN-SCOPE-CREEP"],
"auditor_a_fail_ids": ["<IDs of FAIL checks>"],
"auditor_a_fail_count": 0,
"auditor_a_pass_count": 9,
"auditor_a_skip_count": 0,
"auditor_a_verdict": "PASS|NEEDS_REVISION|BLOCKED",
"generated_at": "<ISO8601>"
}
Write to: docs/workflow-improvements/WFI-NNN-integrated-summary.json
STEP 4 — Apply Cycle 1 Findings to WFI
Read wfi-auditor-a.json. Check the verdict field.
Cycle 1 BLOCKED
- Increment
Audit-Attempt:in WFI-NNN.md by 1 (absent ⇒ set to1). - Store the current WFI body SHA-256 (excluding
Audit-*control fields) inAudit-Content-Hash:— the Precondition no-change guard reads it next run. - If
Audit-Attempt >= 3after incrementing: setAudit-Status: Human-Blocked, print the Human-Blocked message (see Preconditions), and halt. Do not reset to Not-Started; a human must intervene. - Otherwise set
Audit-Status: Not-Startedand print:
wfi-audit-cycle BLOCKED at Cycle 1 — <N> Critical finding(s) in WFI-NNN (attempt <Audit-Attempt>/3).
The WFI has fundamental quality issues that must be resolved before audit can
continue. Review WFI-NNN-auditor-a.json for details, revise WFI-NNN.md, then
re-enter the wfi-audit-cycle skill for WFI-NNN by re-reading and following
this file.
Halt. Do not proceed to Cycle 2.
Cycle 1 NEEDS_REVISION or PASS
Read the proposed_revisions array from wfi-auditor-a.json. For PASS, the
array may be empty. For NEEDS_REVISION, halt if the array is empty unless every
Major finding explicitly requires human clarification. Apply each revision to
docs/workflow-improvements/WFI-NNN.md by editing the named sections. The
orchestrator is the only entity that writes content to WFI-NNN.md during audit.
After applying revisions, write the Cycle 1 audit report to
docs/workflow-improvements/WFI-NNN-audit-cycle-1.md using the structure from
plugins/sdd-quality-loop/templates/wfi-audit-report.template.md. Fill in:
{{cycle_number}}: 1{{wfi_id}}: WFI-NNN{{category}}: read from WFI{{auditor_slot}}: a{{verdict}},{{findings_critical}},{{findings_major}},{{findings_minor}}: from auditor-a.json{{generated_timestamp}}: current ISO8601 timestamp- Fill findings and proposed revisions from auditor-a.json content
STEP 5 — Set Audit-Status: Cycle-2-In-Progress
Update the Audit-Status: field in docs/workflow-improvements/WFI-NNN.md
from Cycle-1-In-Progress to Cycle-2-In-Progress.
STEP 6 — Invoke wfi-auditor-b (Cycle 2)
Spawn wfi-auditor-b as a fresh agent (no shared context with this orchestrator) with:
wfi_path:docs/workflow-improvements/WFI-NNN.md(already revised after Cycle 1)retrospective_path: same path as used in STEP 2category_guide_path:plugins/sdd-quality-loop/references/wfi-category-guide.mdintegrated_summary_path:docs/workflow-improvements/WFI-NNN-integrated-summary.jsonoutput_path:docs/workflow-improvements/WFI-NNN-auditor-b.json
Claude Code — managed dispatch (opt-in). When managed routing was explicitly selected, run only the fence below; never allocate this auditor through an unmanaged Agent spawn, and never fall back to one when the entry rejects. Without managed inputs, retain the route above. Other managed hosts require their own admitted binding. Start it as a fresh, separate dispatch (new request, observation, run ID, session and output directory); it must not see the raw Cycle 1 result, report or original draft.
<prompt-file>/<prompt-sha256>:wfi_pathabove and the lowercase SHA-256 of the revised WFI's current raw bytes.<retrospective-file>/<retrospective-sha256>: exactly the selection used in STEP 2 (both empty only if STEP 2 had no retrospective report).<summary-file>/<summary-sha256>:integrated_summary_pathabove (exactly this WFI's integrated summary) and its raw SHA-256. Before the dispatch verify it against the actual Cycle 1 JSON captured in STEP 2: the nine check IDs, the FAIL IDs, integer counts, the verdict copied as returned (a PASS verdict may include advisory Minor FAIL checks, so never infer the verdict from the fail count), this WFI, cycle 1 and a timestamp, with no extra field and no finding text. The entry re-validates this closed shape and rejects anything else.<repository-root>: the project execution root;<installed-root>: the installed SDD runtime root that containsplugins/sdd-implementation/scripts/managed-model-entry.py.<policy-request>,<registry>,<claude-executable>: the existing policy request, registry and verified observation stay unchanged. Create a fresh immutable request for this auditor (roleworkflow-auditor-b) whoseobservation_pathnames its own fresh copy of the verified observation. Never edit the original request, registry or observation, and never reuse a request, observation, output directory or session of another auditor.<run-id>: a fresh run ID;<session-id>: a fresh canonical UUID;<attempt>:Audit-Attempt+ 1;<output-dir>: a new directory that does not exist yet.
cd "<repository-root>"
installed_root="<installed-root>"
retrospective=()
if [ -n "<retrospective-file>" ]; then
retrospective=(--retrospective-file "<retrospective-file>" --retrospective-sha256 "<retrospective-sha256>")
fi
python3 -I -B "$installed_root/plugins/sdd-implementation/scripts/managed-model-entry.py" claude-entry \
--request "<policy-request>" --registry "<registry>" --role workflow-auditor-b --host claude-code \
--run-id "<run-id>" --session-id "<session-id>" --attempt "<attempt>" --output-dir "<output-dir>" \
--require-actual-id false --executable "<claude-executable>" \
--prompt-file "<prompt-file>" --prompt-sha256 "<prompt-sha256>" "${retrospective[@]}" \
--summary-file "<summary-file>" --summary-sha256 "<summary-sha256>"
The entry prints one public JSON result. Its result string is the auditor's original wfi-auditor-b/v1 JSON; publish
it unchanged as docs/workflow-improvements/WFI-NNN-auditor-b.json and add no field. output_path is only a label owned
by this orchestrator (no auditor Read or Write); the auditor may Read only the immutable copies of the revised WFI, the
retrospective, the category guide and the bridge under <output-dir>/readonly-inputs/, and every Bash call and every
other tool is denied by the guard. A non-zero exit, a rejected input, a malformed or empty result, or a result that is
not the original JSON for this WFI and cycle counts as "does not produce output" below; it is never PASS and is never
retried through an unmanaged spawn. Keep Cycle 1's output directory and copies untouched.
wfi-auditor-b has disallowedPaths covering WFI-NNN-audit-cycle-1.md and
WFI-NNN-auditor-a.json. It cannot read Cycle 1 raw output — only the revised
WFI and the integrated-summary bridge.
Wait for wfi-auditor-b to complete and read WFI-NNN-auditor-b.json.
If wfi-auditor-b does not produce output or exits with an error, halt and print: "wfi-audit-cycle: Cycle 2 auditor failed to produce output. Check agent logs."
STEP 7 — Apply Cycle 2 Findings to WFI
Read wfi-auditor-b.json. Check the verdict field.
Cycle 2 BLOCKED
- Increment
Audit-Attempt:in WFI-NNN.md by 1 (absent ⇒ set to1). - Store the current WFI body SHA-256 (excluding
Audit-*control fields) inAudit-Content-Hash:. - If
Audit-Attempt >= 3after incrementing: setAudit-Status: Human-Blocked, print the Human-Blocked message (see Preconditions), and halt. - Otherwise set
Audit-Status: Not-Startedand print:
wfi-audit-cycle BLOCKED at Cycle 2 — <N> Critical finding(s) in WFI-NNN (attempt <Audit-Attempt>/3).
The revised WFI has a fundamental feasibility or scope issue. Review
WFI-NNN-auditor-b.json for details, revise WFI-NNN.md, then re-enter the
wfi-audit-cycle skill for WFI-NNN by re-reading and following this file.
Halt.
Cycle 2 NEEDS_REVISION or PASS
Read the proposed_revisions array from wfi-auditor-b.json. For PASS, the
array may be empty. For NEEDS_REVISION, halt if the array is empty unless every
Major finding explicitly requires human clarification. Apply each Cycle 2
revision to WFI-NNN.md. Write the Cycle 2 audit report to
docs/workflow-improvements/WFI-NNN-audit-cycle-2.md using the same template
(set {{cycle_number}} to 2 and {{auditor_slot}} to b).
STEP 8 — GitHub Issue Creation (plugin-improvement only)
Read Category: from WFI-NNN.md.
If Category: plugin-improvement:
Construct the issue body using the template from wfi-category-guide.md Section 4.
Populate it with the final (post-audit) content of the WFI.
Run:
gh issue create \
--title "WFI-NNN: <problem summary from ## Problem Evidence, in generic terms>" \
--body "<filled issue body>" \
--label "workflow-improvement,plugin-improvement"
Capture the issue URL from stdout (format: https://github.com/<owner>/<repo>/issues/<N>).
- Success: Write
GitHub-Issue: <url>to the WFI file. - Failure (gh not authenticated, no remote, network error): Print a warning and write
GitHub-Issue: CREATION-FAILED — <error message>. Do not halt — the WFI proceeds to Human-Pending regardless of issue creation outcome.
If Category: app-dev-efficiency:
Skip issue creation. GitHub-Issue: N/A remains unchanged.
STEP 9 — Set Audit-Status: Human-Pending and Present to Human
Update Audit-Status: Human-Pending in WFI-NNN.md.
Print the completion summary. When the WFI has Meta-Change: true, the first
line after the header must be *** Meta-Change: true — this WFI modifies how the workflow is measured. Review the META-CHANGE-ANTI-GOODHART check result before approving. *** so the approver knows they are approving a change to
measurement itself.
wfi-audit-cycle COMPLETE — WFI-NNN (Category: <category>) has passed 2 audit cycles.
Cycle 1 (Proposal Quality — wfi-auditor-a):
Verdict: <verdict>
Major findings applied: <N>
Minor advisories: <N>
Cycle 2 (Impact/Risk — wfi-auditor-b):
Verdict: <verdict>
Major findings applied: <N>
Minor advisories: <N>
GitHub Issue: <url | N/A | CREATION-FAILED>
WFI-NNN is now ready for human review (Audit-Status: Human-Pending).
To approve: edit docs/workflow-improvements/WFI-NNN.md and set:
Status: Approved
The hook guard blocks any agent attempt to set Status: Approved.
Audit reports:
docs/workflow-improvements/WFI-NNN-audit-cycle-1.md
docs/workflow-improvements/WFI-NNN-audit-cycle-2.md
Resumption After Interruption
If the skill is re-invoked after an interruption:
Audit-Status: Cycle-1-In-ProgressandWFI-NNN-auditor-a.jsonexists: skip STEP 2, proceed from STEP 3.Audit-Status: Cycle-2-In-ProgressandWFI-NNN-auditor-b.jsonexists: skip STEPs 2–6, proceed from STEP 7.Audit-Status: Human-Blocked: do not resume automatically. A human must address the root cause and resetAudit-Attemptto 0 (and setAudit-Status: Not-Started) before re-running.Audit-Status: Not-Started(reset after BLOCKED): first apply the Precondition no-change guard — compare the WFI body SHA-256 against the storedAudit-Content-Hash:; if unchanged, halt. Otherwise start from STEP 1.
Audit Artifact Layout
All audit artifacts for WFI-NNN live in docs/workflow-improvements/:
docs/workflow-improvements/
├── WFI-NNN.md ← WFI document (orchestrator updates Audit-Status, revises content)
├── WFI-NNN-auditor-a.json ← Cycle 1 auditor raw output (internal)
├── WFI-NNN-integrated-summary.json ← Bridge: counts and IDs only (internal)
├── WFI-NNN-auditor-b.json ← Cycle 2 auditor raw output (internal)
├── WFI-NNN-audit-cycle-1.md ← Cycle 1 audit report (human-readable)
└── WFI-NNN-audit-cycle-2.md ← Cycle 2 audit report (human-readable)
Do not create subdirectories under reports/ for audit artifacts.
Boundaries
- Never write
Status: Approvedto any WFI file (hook guard enforces this). - Never invoke wfi-auditor-a and wfi-auditor-b in the same agent context.
- Never pass wfi-auditor-a output (json or report) directly to wfi-auditor-b.
Use
integrated-summary.json(counts and IDs only) as the only bridge. - Do not modify
reports/,specs/, or any plugin files. - Do not resolve or create review tickets.
- Do not invoke
quality-gateorfix-by-review-ticket.
Sudo Mode
SDD_SUDO does not apply to this skill. Both audit cycles run unconditionally
regardless of sudo state. The integrity of the audit process depends on this invariant.
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.
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.
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.