Skip to content

Latest commit

 

History

History
239 lines (189 loc) · 12.5 KB

spec-reference.md

File metadata and controls

239 lines (189 loc) · 12.5 KB

Spec Reference

The Spec is the most important artifact in IDD. It translates human-authored Expectations into structured instructions an AI coding agent can execute. Every Spec must contain five mandatory blocks: Context, Expectations, Boundaries, Deliverables, and Validation.

The Core Principle

A Spec should contain everything an AI agent needs to produce correct, reviewable output without asking clarifying questions. If the AI agent needs to guess, the Spec is incomplete.

The top-level spec: mapping must not contain duplicate keys. Use expectations: once for the linked ID list and expectations_detail: once for the embedded detail objects.

Template

spec:
  id: "SPEC-d12e"                    # generated by `idd-next-id spec`; do not edit after assignment
  product: ""                        # Parent Product name or ID
  intentions: []                     # List of Intention IDs this Spec addresses
  expectations: []                   # Linked Expectation IDs this Spec implements
  status: "draft"                    # draft | ready | in-progress | review | validating | done
  exploration: ""                    # optional — inherited from the parent Intention/Product; Guildhall's fog-cartographer keys on this

  # CONTEXT — everything the AI agent needs to know about your project
  context:
    stack: ""                        # Languages, frameworks, databases, versions
    patterns: ""                     # Architectural patterns (e.g., CQRS, MVC, vertical slice)
    conventions:                     # Coding standards and project-specific rules
      - ""
    existing_code_refs:              # Files or folders the AI should reference or follow
      - path: ""
        note: ""
    auth: ""                         # Authentication/authorization model

  # EXPECTATIONS DETAIL — embedded detail objects for the linked Expectation IDs
  expectations_detail:
    - id: ""
      description: ""                # What must be true
      validation: ""                 # How to verify (pass/fail or measurable)
      edge_cases:
        - ""
        - ""

  # BOUNDARIES — what the AI must NOT do
  boundaries:
    - ""

  # DELIVERABLES — concrete outputs the AI should produce
  deliverables:
    - ""

  # VALIDATION — how to verify the Spec is complete
  validation:
    automated:                       # Things tests can verify
      - ""
    human_review:                    # Things humans must evaluate
      - ""

The Five Mandatory Blocks

1. Context

Everything the AI agent needs to know about your project. Inherited from the Product level; override only what's different for this Spec.

Must include: stack with versions, architectural patterns, coding conventions, auth model, references to existing code.

Common mistakes:

  • Saying "use our standard patterns" (AI doesn't know your standards)
  • Omitting the auth model (AI will guess or skip it)
  • Not referencing existing code (AI invents its own structure)

2. Expectations

What must be true when the Spec is complete. Each Expectation needs: description, validation criteria, and at least 2 edge cases.

The edge case rule: AI agents build the happy path well. Your quality lives in edge cases.

3. Boundaries

What the AI must NOT do. Without boundaries, AI agents will modify files you didn't want touched, add unapproved dependencies, and implement adjacent features.

Write boundaries as clear prohibitions:

  • "Do not modify any files in /src/auth/"
  • "Do not add new database tables — use existing schema only"
  • "Do not implement the admin view — that is SPEC-7e15"

4. Deliverables

Concrete outputs the AI should produce. If it's not listed, the AI may not produce it.

5. Validation

How to verify the Spec is complete. Split into automated (tests, contract checks) and human review (UX, architecture, data accuracy).

Completeness Checklist

A Spec cannot enter Ready status until every item passes:

  • Context: stack is non-empty
  • Context: patterns is non-empty
  • Context: conventions has at least one entry
  • Context: auth is non-empty
  • At least one Expectation is linked
  • All Expectations have validation criteria
  • All Expectations have at least 2 edge cases
  • Boundaries block has at least one entry
  • Deliverables block has at least one entry
  • Validation block has at least one automated and one human review item
  • Spec has been peer-reviewed by at least one other person

Anti-Patterns

Anti-Pattern Why It's a Problem Fix
"Make it responsive" with no detail AI guesses at breakpoints and behavior Specify breakpoints, layouts, and test criteria
Copy-pasting Context into every Spec Drift between copies; maintenance burden Use Product-level Context inheritance
Zero Boundaries AI modifies anything it wants Always include at least scope exclusions
One giant Spec covering an entire feature Agent attention quality degrades; early context is crowded out by later sections Split when a reviewer can no longer hold all Expectations in mind simultaneously; each Spec should produce 1-3 deliverables
Expectations without edge cases Happy path only Minimum 2 edge cases per Expectation
Validation with only automated checks UX and architecture issues slip through Always include human review items

Attention Quality

A Spec that covers too much ground degrades the quality of the executing agent's attention across the full document — early context receives less weight as later sections push it out. No token count determines when this happens; the right signal is whether a reviewer can hold all Expectations in mind simultaneously. If not, split the Spec. Practical self-check: can every Boundary, every Deliverable, and every edge case be kept active in one focused review pass? If not, the Spec is doing the work of two. Each Spec should produce 1–3 deliverables.

Status Lifecycle

Use only these lifecycle values, in this order:

draft → ready → in-progress → review → validating → done

This bundled contract is available without the framework checkout. It prescribes agent behavior; it is not a runtime validator or an automatic edit-tracking system.

Readiness and review ownership

The author or orchestrator may enter ready after all eleven checklist items are satisfied. Record actual human peer approval separately from AI findings. Tech and deep review write a review outcome and leave the incoming lifecycle and the five content blocks intact; approved technical findings do not mean the human reviewed it. Recommend correcting findings, finishing readiness, then running gap-check. Carry unaddressed technical warnings into that analysis for classification.

After the build, the orchestrator may enter review only under the completion conditions below. Human implementation approval from the Reviewer/Tech Lead permits review → validating. QA/Product Owner evidence for Expectations and the required validation permits validating → done. Review agents and implementers do not make these transitions themselves.

Gate result and coverage

The gap-check reviewer never edits the Spec; its output is a report. The command maintains one additive gap_check mapping, replacing it on rerun:

  gap_check:
    status: "passed"              # passed | warnings | blocked
    blockers: 0                   # unresolved count
    warnings: 0                   # unresolved count
    report: "docs/reviews/SPEC-d12e-gap-check.md" # null without a valid result
    date: "YYYY-MM-DD"

passed requires both counts to be zero. Outstanding warnings with no blockers produce warnings; any blocker produces blocked. A report headed PASS with warnings cannot be executed. Correct the Spec and obtain a new clean result. Legacy pass or warned annotations may be retained in older artifacts; run a new check to obtain authorization. Missing annotations do not invalidate historical artifacts, but do prevent execution.

For omitted impact-surface files, read author coverage_dispositions entries: files is a list of paths, disposition names the scoping decision, and reason explains it. Independently check an accept-omission against the validation criteria. If no dependency is unmet, retain the candidate in Coverage with file, evidence, original severity, suggested disposition and a resolution note, and omit that resolved finding from counts. An unaddressed omission remains a Warning; an unmet validation dependency without a Deliverable owner remains a Blocker. Acknowledging a content warning is insufficient to resolve it.

Every check starts without authorization

Select targets before review. Report missing targets rather than making files. Before checking completeness or starting a reviewer, the command updates each safely readable target's annotation to blocked, one operational blocker, zero warnings, null report and today's date. This denotes an unfinished invocation, not a content defect. An unsafe/unparseable Spec is reported and left untouched; it cannot pass execution preflight.

The reviewer assesses checklist items 1–10 only. A precondition failure returns Spec ID and failed-item numbers and produces no finding report. The command sets blockers to the number of failed items, retaining blocked, zero warnings and null report. This cannot reuse an older passing report. Continue other complete Specs in a mixed selection; portfolio coverage excludes the incomplete ones and names the exclusions.

For complete Specs, write docs/reviews/<SPEC-ID>-gap-check.md with line 1 BLOCKED — N blockers, M warnings or PASS — 0 blockers, M warnings, mandatory GC fields for content findings, and ## Coverage even when empty. Return the Spec ID, path and counts to the command. It accepts only a successful return from this invocation whose report structure and counts match. Errors, interruption, missing or malformed output leave the operational blocker and null report in place; request a rerun. Neither timestamps nor file presence prove a fresh review. Keep previous report files until a completed review replaces the canonical file; never change lifecycle or content while updating the annotation.

Starting and finishing implementation

Resolve a single Spec before directory creation or other writes. Read the Spec, annotation and report. Require ready, passed, both counts zero, and a readable report at docs/reviews/<SPEC-ID>-gap-check.md beginning exactly PASS — 0 blockers, 0 warnings and containing ## Coverage. Missing or invalid inputs cause a conversational refusal without file changes. Content revisions require a new gap-check; these instructions cannot detect every unnoticed manual edit without additional provenance tooling.

The command quotes every Boundary verbatim before initialization or ready → in-progress. It dispatches only after that transition, including the verified Spec identity and report evidence. The implementer confirms the handed-off evidence and in-progress status, then repeats every Boundary verbatim with an explanation of its meaning before its own writes. Capture pre-run file contents and diffs in addition to porcelain status. Compare actual changes to Deliverables; an already-modified file can change again without a different Git status code. Preserve edits that existed before the run.

Use the blocker-grade test during implementation: would plausible alternatives alter validation, cross a Boundary, or alter the visible form of a Deliverable? If yes, stop and report to the author. Otherwise make a reasonable choice and record the minor gap and reasoning in spec_gaps_encountered.

The report covers every edge case, Boundary, Deliverable and automated check with evidence. Moving in-progress → review requires a report, passing Deliverables, Boundaries and automated checks, and no remaining blocker-grade gap. Only checks explicitly reserved for human review may be unverifiable at build time, with a reason and follow-up; pending human validation does not fail an automated check. An incomplete, failed, or interrupted run stays in-progress. Return failure evidence, saving a partial report if possible. Do not reset to ready or undo user work. The normal command cannot resume in-progress: a recovery decision is needed, and a general resume procedure is outside this contract.

A done Spec can be classified for the archive workflow, with completion spot-checked first. Archive application distills it to docs/idd-ledger.yaml and removes its live file; retrieve full text from the archive Git tag. Do not add an archived lifecycle value.