---
name: spec-phase-projected
description: "WRAPS gsd-spec-phase to make a phase's SPEC.md a PROJECTION of the Foundation's atomic directives, not a free authoring. Generates a directive->AC scaffold 1:1 (directive IDs preserved as [<CAP>-D<NN>] tags), invokes gsd-spec-phase ELABORATE-ONLY with that scaffold injected as context (it elaborates HOW — test shapes, edge cases — but cannot invent WHAT), then runs Gate-1 /peer-review whose set-diff FAILs on any dropped or invented directive. NEVER edits gsd-spec-phase — enforcement is the gate. This is the anti-drift core: the 80%-that-emerges-mid-roadmap is elaboration bounded by the up-front WHAT the human signed. Activates on /spec-phase-projected, project the spec, spec from the foundation, gate-1 projection check."
---

# /spec-phase-projected — project SPEC-N from the Foundation (WRAP GSD)

You make GSD's per-phase `SPEC.md` a **projection** of the Foundation's directives. spec-phase
elaborates HOW (test shapes, edge cases); it **cannot invent new WHAT**. The Foundation becomes
structurally load-bearing — GSD can't plan a phase without consuming the directives, and the
Gate-1 set-diff catches any drop or invention.

**WRAP, NEVER FORK** (HANDOFF CRITICAL guidance): you do NOT edit `gsd-spec-phase`,
`gsd-roadmapper`, or any global GSD skill. You generate a scaffold, inject it, and gate the
result. Enforcement is the GATE.

**Design source:** INTEGRATION-DESIGN §0.3 + LOCKED #6.
**Core (call it — don't re-implement):** [`lib/projection.js`](lib/projection.js) —
`generateScaffold`, `setDiff`, `gate1Decision`. Reuses B4's directive extraction + B3's `/peer-review`.

## Inputs

| Arg | Required | Description |
|-----|----------|-------------|
| `--phase <NN-name>` | yes | The GSD phase to spec. |
| `--foundation <path>` | yes | The Foundation cap-dir (holds `DIRECTIVES.md`) for this phase's capabilities. |
| `--product <id>` | yes | Product slug (for the GSD `.planning/<product>/phases/<phase>/SPEC.md` path). |
| `--contracts <path>` | no (M2/B5-widen) | JSON file of B14 architecture contracts (`[{concern_id, chosen_gsd_skill, contract_body, depends_on, source_capability_ids}]`) whose capabilities this phase covers. When present, the projection adds contract ACs **parallel** to the directive ACs (one per contract, tagged `[<CONCERN>-C<NN>]`) and Gate-1 set-diffs BOTH surfaces. |

**M2/B5-widen — the projection signature is `project(directives[], contracts[])`.** Architecture
contracts (from B14) are a first-class Foundation input parallel to directives — NOT nested under
them. The DAG never reads SPEC-N back (not circular). Omitting `--contracts` reproduces the
directive-only projection byte-for-byte (full backward compat). `lib/projection.js` exports
`extractContractIds(contracts)` + `extractSpecContractIds(specBody)`; `generateScaffold` accepts
`{contracts}`; `setDiff`/`gate1Decision` accept `contractIds`. A dropped contract → `ALIGNMENT_FAIL`;
an invented contract → `HUMAN_DECISION_REQUIRED` → `ESCALATE_HITL`.

## How to run

### Step 1 — generate the directive→AC scaffold (1:1, IDs preserved)
```bash
node -e '
import("./PLATFORM/AutoPilot/skills/spec-phase-projected/lib/projection.js").then(async m => {
  const fs = await import("node:fs");
  const directives = fs.readFileSync(process.env.FOUNDATION + "/DIRECTIVES.md", "utf8");
  fs.writeFileSync(process.env.SCAFFOLD, m.generateScaffold(directives, { phaseName: process.env.PHASE }));
});'
```
This writes a SPEC scaffold with one AC per directive, each tagged `[<CAP>-D<NN>]` + its
evaluation method. **Do not add or remove rows.**

### Step 2 — invoke gsd-spec-phase ELABORATE-ONLY (the wrap)
```
Skill: /gsd:spec-phase \
  --phase "$PHASE" \
  --product "$PRODUCT" \
  --seed-spec "$SCAFFOLD"          # the projected scaffold injected as context
```
Instruct it: **elaborate the HOW for each existing AC** (test shapes, edge cases, evaluation
detail) — it MUST keep every `[<ID>]` tag and MUST NOT introduce a new directive ID. It is
filling in the "Elaboration" column, not authoring new acceptance criteria.

(If `gsd-spec-phase` lacks a `--seed-spec` arg in the installed GSD version, inject the
scaffold as the phase's pre-existing `SPEC.md` and tell spec-phase to elaborate-in-place — the
gate enforces faithfulness regardless of the injection mechanism.)

### Step 3 — Gate-1: /peer-review set-diff (the enforcement)
```bash
node -e '
import("./PLATFORM/AutoPilot/skills/spec-phase-projected/lib/projection.js").then(async m => {
  const fs = await import("node:fs");
  const { extractDirectiveIds } = await import("./PLATFORM/AutoPilot/skills/foundation/lib/foundation-validate.js");
  const fIds = extractDirectiveIds(fs.readFileSync(process.env.FOUNDATION + "/DIRECTIVES.md","utf8"));
  const specBody = fs.readFileSync(process.env.SPEC_OUT, "utf8");
  const g = m.gate1Decision({ foundationIds: fIds, specBody, oneWayDoor: process.env.ONE_WAY === "1" });
  console.log(JSON.stringify(g, null, 2));
  process.exit(g.verdict === "PROCEED" ? 0 : 1);
});'
```
- **Clean set-diff** (no dropped, no invented IDs) → `PROCEED` → spec-phase output is faithful;
  continue to plan-phase.
- **Dropped directive** → `ALIGNMENT_FAIL` finding → not PROCEED (the SPEC silently narrowed
  the human's intent — exactly the drift the Foundation prevents).
- **Invented directive** → `HUMAN_DECISION_REQUIRED` → `ESCALATE_HITL` (the SPEC asserts a WHAT
  the human never signed — authority it doesn't have).

This wires into the full `/peer-review --gate spec-adr` (Gate 1) — the set-diff is its
machine-checkable core; the SME panel + codex seat review the elaboration quality on top.

## What this skill does NOT do

- Does NOT edit `gsd-spec-phase` / `gsd-roadmapper` / any global GSD skill (WRAP, not fork).
- Does NOT let spec-phase author acceptance criteria the human never saw.
- Does NOT silently pass a projection that dropped or invented a directive.

## Relationship to other skills

- **`/foundation`** (B4) — supplies `DIRECTIVES.md`; this projects its IDs into SPEC ACs.
- **`/peer-review`** (B3) — Gate-1 set-diff composes its `decidePeerReview` taxonomy/verdict.
- **`gsd-spec-phase`** (global GSD) — wrapped elaborate-only; never edited.
- **Gate 2** (tasks⟷SPEC, after plan-phase) — the lighter companion gate, also `/peer-review`.
