# Phase 4: Validation & Handoff

## 4a. Mechanical self-check

Run these commands — do NOT skip to presenting results until they pass:

```text
# 1. Doc consistency
<primary doc validation command>

# 2. Quality gates
<primary quality gate command>
```

If either fails, fix the issue and re-run. Do NOT present to user with failures.

## 4b. Structural self-check

Before presenting to the user, also verify:

- [ ] `docs/harness-manifest.json` exists, is valid JSON, and matches the generated artifact set
- [ ] `docs/feedback-profile.json` exists, is valid JSON, and captures the current feedback surfaces, business-flow coverage, and human-input gaps
- [ ] Every document and script declared in `docs/harness-manifest.json` exists
- [ ] `docs/harness-manifest.json` points to `docs/feedback-profile.json`
- [ ] Every milestone has at least one executable verification command
- [ ] `AGENTS.md` references all generated docs and scripts
- [ ] `docs/prompt.md` scope matches M0 (or M1 if M0 is trivial) from `docs/plan.md`
- [ ] No placeholder/TBD text remains in any generated file
- [ ] No unreplaced template variables remain in installed sub-skills
- [ ] Hard constraints from Phase 1 appear in every generated policy doc that claims to be authoritative
- [ ] Needs Manifest items are either resolved or tracked in a milestone
- [ ] The primary shell and command pair are identical across `AGENTS.md`, `docs/harness-manifest.json`, `docs/feedback-profile.json`, and any generated supporting docs
- [ ] `docs/plan.md` includes an Operations Cadence table with `quality-audit` and `milestone-promote`
- [ ] No repository-wide rollback commands appear in generated docs or sub-skills
- [ ] The primary doc validation command passes
- [ ] The primary quality gate command passes (or documents known pre-existing failures)
- [ ] The sub-skills declared in `docs/harness-manifest.json` are installed in `.agents/skills/`
- [ ] If `docs/compaction-strategy.md` is declared in `docs/harness-manifest.json`, it exists and defines checkpoint rules

## 4c. Present to user

Show the user:
1. Summary of what was generated (file list with one-line descriptions)
2. Results of mechanical validation (primary commands passing, manifest + feedback profile self-consistent)
3. The highest-priority remaining feedback gaps and any remaining items from the Needs Manifest
4. "Ready to start M0?" or "These items need to be resolved first: ..."

## 4d. Outstanding needs

If there are still unresolved needs, present them clearly:

```markdown
## Before starting M0, you need to:

1. Set `DATABASE_URL` in `.env` (I can create .env.example for you)
2. Confirm the deployment target (Vercel / AWS / self-hosted)

## I can start M0 without these (will use mocks):
3. External payment API key (only needed for M3)
```
