| Metadata | Details |
|---|---|
| Status | Implemented |
| Last Updated | 2026-03-19 |
| Audience | Maintainers, tool authors, prompt authors |
| Related | docs/design.md, docs/tasks.md, docs/plans/2026-03-19-specifica-inspired-evolution.md |
This document defines the canonical workflow contract for pb-spec's existing planning artifacts.
The contract covers:
design.mdtasks.mdfeatures/*.feature- markdown-carried
🛑 Build Blockedand🔄 Design Change Requestblocks
The goal is to make the current markdown workflow explicit, validator-ready, and stable enough to support future parser and validation tooling.
This specification defines:
- required and conditional sections
- task block structure
- allowed task states
- scenario coverage expectations
- blocked-build and DCR block requirements
- validation categories for build eligibility
This specification does not:
- add a new feature-level
spec.md - replace markdown artifacts with YAML or JSON
- change the existing command surface
- redefine prompt behavior beyond the artifact contract
- require one AI platform or runtime
pb-spec's workflow surface remains:
/pb-init -> /pb-plan -> /pb-refine -> /pb-build
This document defines the contract carried by the planning artifacts produced and consumed by that workflow.
The canonical feature-level artifact family is:
specs/<spec-dir>/
├── design.md
├── tasks.md
└── features/
└── *.feature
| Artifact | Primary Role | Consumer |
|---|---|---|
design.md |
Architecture, planning rationale, verification strategy | pb-plan, pb-refine, pb-build, maintainers |
tasks.md |
Task sequencing, execution contract, verification evidence fields | pb-plan, pb-refine, pb-build |
features/*.feature |
Business-visible behavior contract | pb-plan, pb-build, BDD runner |
The current contract does not require or introduce a separate feature-level spec.md artifact. design.md, tasks.md, and features/*.feature remain the contract-carrying artifacts.
This specification uses three requirement levels.
| Level | Meaning |
|---|---|
| Required | Must be present for a build-eligible spec |
| Conditional | Required only when the stated condition applies |
| Optional | Allowed but not required |
design.md supports two planning modes.
| Mode | Trigger | Expectation |
|---|---|---|
| Lightweight | Small, low-complexity change | Compact design with reduced section set |
| Full | Medium or complex feature | Full section set, explicit architecture and verification strategy |
Note: Complexity levels (lightweight, medium, high) are orthogonal to mode. Both medium and high complexity specs use full mode. Test fixtures reflect this: medium_spec and full_spec are both full-mode specs at different complexity levels.
The following sections are required for a build-eligible full-mode design.md:
Executive SummaryRequirements & GoalsArchitecture OverviewDetailed DesignVerification & Testing StrategyImplementation Plan
The following sections are conditional:
| Section | Condition |
|---|---|
Architecture Decisions |
Required when the change introduces a new boundary or is likely to exceed 200 lines of implementation |
Project Identity Alignment |
Required when the repository still exposes template or scaffold identifiers |
Existing Components to Reuse |
Required unless no reusable component exists; if none exists, the section must explicitly say so |
BDD Scenario Inventory |
Required when feature behavior is user-visible or acceptance-tested |
Property Testing planning |
Required for broad input-domain logic unless explicitly justified as unnecessary |
Fuzz Testing planning |
Required only for parser, protocol, unsafe, binary, or untrusted-input crash-safety work |
Benchmark planning |
Required only for performance-sensitive or regression-sensitive paths |
A lightweight design.md must still include:
SummaryApproachArchitecture DecisionsBDD/TDD StrategyCode Simplification ConstraintsBDD Scenario InventoryExisting Components to ReuseVerification
Lightweight mode may omit the full-mode Detailed Design and Implementation Plan sections as standalone top-level sections if the same information is captured compactly in the required lightweight sections.
For validation purposes, lightweight mode satisfies the full contract through the following mapping:
| Lightweight Section | Full-Mode Equivalent Responsibility |
|---|---|
Summary |
Executive Summary |
Approach |
Architecture Overview plus compact Detailed Design |
Architecture Decisions |
Architecture Decisions |
BDD/TDD Strategy |
Verification & Testing Strategy |
Code Simplification Constraints |
Requirements & Goals maintainability constraints |
BDD Scenario Inventory |
BDD Scenario Inventory |
Existing Components to Reuse |
Existing Components to Reuse |
Verification |
compact Verification & Testing Strategy plus compact Implementation Plan closure criteria |
The validator should treat this mapping as authoritative for lightweight mode rather than requiring full-mode section names to appear literally.
For validation purposes:
- headings are matched by section title
- empty placeholders such as
TBD,[To be written], or bracket-only templates do not satisfy a required section - a section may satisfy a conditional requirement by explicitly stating why it is
N/A - repo-specific standards must be grounded in actual repo docs or code, not generic boilerplate
tasks.md must contain one or more task blocks identified by headings of this form:
### Task X.Y: <Task Name>
Where:
Xis the phase numberYis the task number within that phaseTask Nameis free text
The canonical identifier pattern is:
Task ([0-9]+)\.([0-9]+)
The following table is the authoritative source for task field requirement levels.
| Field | Requirement Level | Condition |
|---|---|---|
Context |
Required | Always |
Verification |
Required | Always |
Scenario Coverage |
Required | Always |
Loop Type |
Required | Always |
Behavioral Contract |
Required | Always |
Simplification Focus |
Required | Always |
Status |
Required | Always |
| Step checkboxes | Required | At least one checkbox step must exist |
BDD Verification |
Required | Always; may be N/A with reason for TDD-only tasks |
Advanced Test Verification |
Required | Always; may be N/A with reason when no advanced test category applies |
Runtime Verification |
Required | Always; may be N/A with reason for non-runtime work |
Advanced Test Coverage |
Conditional | Required when the template or plan explicitly classifies advanced test intent |
Priority |
Optional | Recommended but not required for parsing |
Scope |
Optional | Recommended but not required for parsing |
For this contract, advanced test categories are:
- property testing
- fuzz testing
- benchmark testing
If any of these are planned or required by the design, the task should classify that intent explicitly and Advanced Test Verification must contain a concrete command rather than N/A.
Each task block must include at least one checkbox step using markdown checkbox syntax.
Example:
- [ ] Step 1: Write the failing test
Allowed values are:
BDD+TDDTDD-only
Allowed task status values are:
🔴 TODO🟡 IN PROGRESS🟢 DONE⏭️ SKIPPED🔄 DCR⛔ OBSOLETE
Legacy TODO is accepted only as an input-compatibility state and must be treated as 🔴 TODO before execution begins.
The normal transition path is:
🔴 TODO -> 🟡 IN PROGRESS -> 🟢 DONE
Exceptional states are:
⏭️ SKIPPED🔄 DCR⛔ OBSOLETE
Validation rules:
Execution guidance:
- builders should move tasks through
🔴 TODO -> 🟡 IN PROGRESS -> 🟢 DONE 🟢 DONErequires completion evidence for required verification fields⛔ OBSOLETEshould only be applied by refinement or replanning logic🔄 DCRindicates design blockage and should halt normal forward progress for the affected task
Current static validation is intentionally narrower than the execution model. It enforces allowed status values and completion evidence for 🟢 DONE, but it does not attempt to reconstruct prior status history from a single markdown snapshot.
| Field | Requirement Level | Meaning |
|---|---|---|
BDD Verification |
Required | Concrete behavior-level verification command or N/A with reason for TDD-only infrastructure work |
Verification |
Required | Concrete verification command or direct measurable check |
Advanced Test Verification |
Required | Concrete advanced-test command when property, fuzz, or benchmark testing applies, otherwise N/A with reason |
Runtime Verification |
Required | Concrete runtime evidence check for runtime-facing work, otherwise N/A with reason |
For validation purposes:
- at least one valid
### Task X.Y:block must exist - every task block must be independently parseable
- duplicate task IDs are invalid
- a task heading without required fields is invalid
- a required verification field is not satisfied by an empty placeholder
N/Ais valid only when accompanied by a brief reason
A build-eligible spec must contain at least one .feature file under features/ with at least one Scenario.
The contract expects:
- user-visible or acceptance-tested behavior to be represented by Gherkin scenarios
Scenario Coverageintasks.mdto reference concrete scenarios rather than vague summaries- future validator support to confirm that referenced scenarios exist
The minimum current baseline is:
- at least one
.featurefile exists - at least one
Scenarioexists
Stronger scenario-to-task traceability is part of the intended future contract and should be introduced through validator support.
Scenario Coverage is the linkage field between tasks.md and features/*.feature.
For BDD+TDD tasks, Scenario Coverage must name one or more concrete scenarios.
For TDD-only tasks, Scenario Coverage may be:
- a concrete scenario reference, if the task supports a visible scenario
N/Awith reason, if the task is purely internal scaffolding or non-behavioral infrastructure
The following invariant is enforced:
- each executable behavior scenario must map to one or more task blocks
- each
BDD+TDDtask must map to real scenarios - orphaned scenario references are reported as validation errors
pb-spec carries blocked-build and design-change information in markdown blocks, not sidecar files.
The required header format is:
🛑 Build Blocked — Task X.Y: <Task Name>
Required sections:
ReasonLoop TypeScenario CoverageWhat We TriedFailure EvidenceFailing StepSuggested Design ChangeImpactNext Action
Failing Step may be N/A when there is no meaningful Gherkin step to quote.
The required header format is:
🔄 Design Change Request — Task X.Y: <Task Name>
Required sections:
Scenario CoverageProblemWhat We TriedFailure EvidenceFailing StepSuggested ChangeImpact
Failing Step may be N/A when there is no meaningful Gherkin step to quote.
The DCR block is intentionally smaller than the blocked-build block because it does not need Reason, Loop Type, or Next Action as separate mandatory sections when the requested design change itself is the actionable output.
For validation purposes:
- missing required sections make the block incomplete
- incomplete blocks must be rejected by refiner-side validation
- failure evidence must contain concrete command output or quoted error text, not generic summaries alone
A spec is build-eligible when all of the following are true:
- the required
design.mdsections for its mode are present tasks.mdcontains at least one valid task block- each task block contains the required task fields
- task statuses are valid
features/contains at least one.featurefile with at least oneScenario- required verification fields are present and non-empty
Future validator versions may extend build eligibility checks to include stronger cross-link validation.
This section describes the intended evolution of the validation system. The types and functions listed here are roadmap targets, not yet implemented in the current CLI.
A future validation system should use structured types for better error handling and reporting:
| Planned Type | Purpose |
|---|---|
ValidationResult |
Collection of errors and warnings with severity levels |
ValidationError |
Single validation issue with file, line, column context |
ErrorLevel |
Severity enum: ERROR, WARNING, INFO |
A future refactoring should expose validation as a library with both legacy and structured interfaces:
| Planned Function | Return Type | Purpose |
|---|---|---|
validate_design_file() |
list[str] |
Legacy interface returning error strings |
validate_design_file_structured() |
ValidationResult |
New interface with structured errors |
validate_task_file() |
list[str] |
Legacy interface returning error strings |
validate_task_file_structured() |
ValidationResult |
New interface with structured errors |
A future feature parser should expose structured access to Gherkin scenarios:
| Planned Type | Purpose |
|---|---|
FeatureScenario |
Parsed Gherkin scenario with file, line number, and outline flag |
parse_feature_file() |
Returns list[FeatureScenario] for structured access |
get_scenario_by_name() |
Finds a specific scenario by name |
The first validator tranche should prioritize the narrowest high-value checks:
- parse
tasks.mdtask blocks - validate required task fields
- validate task state transitions
- inventory
.featurescenario names - verify
Scenario Coveragereferences resolve when they claim concrete coverage
Later validator stages can expand to:
design.mdsection completeness by mode- blocked-build and DCR block completeness
- stronger scenario-to-task traceability
- placeholder detection and empty-section rejection
This contract is designed to preserve compatibility with the current workflow.
Compatibility notes:
- existing specs using legacy
TODOmay be normalized during execution - stronger validation should prefer explicit diagnostics over silent coercion
- new validator rules should be introduced incrementally and documented clearly when they become mandatory
pb-spec's contract is already richer than a generic single-file spec model. The purpose of this document is not to introduce new workflow artifacts, but to make the current contract explicit enough for:
- maintainers
- prompt authors
- parser and validator implementations
- CI and tooling integrations
The canonical planning surface remains design.md + tasks.md + features/*.feature.