# Product Audit Workflow

<template_meta>
name: product-audit
version: 1
requires_project: true
artifact_dir: .sf/active/
</template_meta>

<purpose>
End-of-milestone soft gate that compares declared product intent (VISION.md,
RUNBOOKS.md, PRD-style docs) against actual code/test/deploy/docs evidence.
Outputs structured gaps with severity (critical/high/medium/low). Does NOT
hard-block milestone completion — actionable gaps become follow-up slices.
</purpose>

<phases>
1. audit — Inspect code/tests/docs, score gaps, call audit_product
</phases>

<process>

## Phase 1: Audit

**Goal:** Produce a structured PRODUCT-AUDIT artifact for the active milestone.

1. Load the audit prompt at `~/.sf/agent/extensions/sf/prompts/product-audit.md` — that file holds the detailed evidence-collection guidance and output schema for this audit.
2. Treat repo docs (VISION.md, README.md, docs/RUNBOOKS.md, milestone artifacts)
   as the product contract. Do not invent expectations.
3. Inspect the codebase using native `lsp`, AST tools, and `rg`
   to confirm declared capabilities have concrete evidence (code, tests,
   deployment artifacts, runbooks).
4. Score each gap with severity, confidence, and a suggested follow-up slice.
5. Call `audit_product` exactly once with the structured payload. The tool
   writes:
   - `.sf/active/{milestoneId}/PRODUCT-AUDIT.json` (machine-readable)
   - `.sf/active/{milestoneId}/PRODUCT-AUDIT.md` (human-readable)

**Verdicts:**
- `no-gaps` — every material capability has positive evidence
- `gaps-found` — one or more material gaps, captured with suggested slices
- `contract-underspecified` — product docs are too vague to validate against

</process>
