Skip to content

feat: story manifest breakdown and folder+id dispatch (spec-to-loop contract)#2549

Merged
alexeyv merged 1 commit into
mainfrom
feat/spec-to-loop-contract
Jul 6, 2026
Merged

feat: story manifest breakdown and folder+id dispatch (spec-to-loop contract)#2549
alexeyv merged 1 commit into
mainfrom
feat/spec-to-loop-contract

Conversation

@alexeyv

@alexeyv alexeyv commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

What

Machine contract between planning and unattended execution, in two halves:

  • bmad-spec gains an optional, interactive-only Story Breakdown step: it derives stories.yaml (fixed-name sibling of SPEC.md, deliberately not a companion) from the memlog: a simple sequence — list order is execution order — with per-entry id, title, description, spec_checkpoint, done_checkpoint, invoke_dev_with; never status. Ids are pinned once a story's spec file exists; un-started stories may be renumbered on re-derive. Schema + validity rules in assets/stories-schema.md.
  • bmad-dev-auto becomes dispatchable per stories.yaml entry: invoked with just a spec folder + story id, step-01 reads its own entry (title/description only — orchestration fields are the caller's), derives the slug, and creates or resumes the story spec at the id-keyed path <spec-folder>/stories/<id>-<slug>.md. All HALT write-back lands at that path (skeletal spec for pre-planning halts — early failures can't masquerade as pending). An invocation-prompt directive halts ready-for-dev after planning for human plan review; re-dispatching the same folder+id resumes via existing status routing. Planning accumulates context from all prior story records in the folder. Reference docs (docs/reference/dev-auto.md, docs/reference/core-tools.md) updated to match.

Story lifecycle lives only in story-spec frontmatter (the existing HALT shape, unchanged — downstream tooling already consumes it); stories.yaml never records status. Dependency graphs deliberately don't exist at this level — they belong to epics within a larger project, outside this contract.

Why

A deterministic orchestrator (bmad-loop) needs dispatchable, machine-readable inputs: identity, ordering, display, and a planner→dev token channel — with story specs created just-in-time by the run that implements them, so plans are never written against repo state that doesn't exist yet.

Validation

  • npm ci && npm run quality green on HEAD in this exact checkout; validate:skills clean.
  • Exercised end-to-end on a real epic: breakdown derived a 6-story stories.yaml; dev-auto dispatched with only folder + id + halt directive; plan-halt, resume-to-implementation, done write-back, and cross-story context accumulation all observed working (the dispatched story landed a real pytest surface, 133 tests green). The stories.yaml fields were simplified in review hardening after that demo; dev-auto's read surface (title/description by id) is unchanged by it.

🤖 Generated with Claude Code

@alexeyv alexeyv marked this pull request as draft July 4, 2026 22:41
@augmentcode

augmentcode Bot commented Jul 4, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: This PR tightens the contract between spec creation and unattended execution by introducing a deterministic stories.yaml manifest and enabling story dispatch by spec-folder + story id.

Changes:

  • Extends bmad-spec with an optional, interactive-only “Story Breakdown” that derives a fixed-name stories.yaml sibling of SPEC.md.
  • Adds a documented schema and validity rules for stories.yaml (id, title, description, optional checkpoint flags, and invoke_dev_with).
  • Updates bmad-dev-auto to support folder+id dispatch: locate the target story entry in stories.yaml, resolve/create the story spec at stories/<id>-<slug>.md, and route based on its status.
  • Introduces cross-story context accumulation by loading other stories/*.md records when planning runs.
  • Adds an optional “halt after planning” directive that can stop at ready-for-dev for human plan review and resume later.
  • Updates reference docs (docs/reference/*) to describe the new dispatch mode, artifact locations, and new blocking conditions.

Technical Notes: Folder+id dispatch relies on stories.yaml for title/description only; orchestration fields remain caller-owned, and story lifecycle state continues to live solely in the story spec frontmatter.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 2 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.


| Field | Type | Required | Meaning |
|---|---|---|---|
| `id` | string | yes | Stable identity, unique in the manifest, machine-opaque — compared for equality and prefix-matched in filenames, never parsed. Convention: unpadded integers (`"1"`), optionally epic-qualified composites (`"3-2"`) when the epic sits inside a larger project spec. No zero-padding — execution order comes from the manifest, not filename sort. Never reused or renumbered once assigned. |

@augmentcode augmentcode Bot Jul 4, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In src/core-skills/bmad-spec/assets/story-manifest-schema.md line 9, id is treated as an opaque string but is also used for equality checks and as a filename prefix; if YAML parses id: 1 as a number (or if an id contains path/glob characters like /, .., *), folder+id dispatch can fail to match or write/read outside the intended stories/ directory. Consider explicitly requiring ids to parse as strings (e.g., quoted) and restricting them to a safe filename-segment character set in the schema validity rules.

Severity: high

Other Locations
  • src/bmm-skills/4-implementation/bmad-dev-auto/step-01-clarify-and-route.md:29
  • src/bmm-skills/4-implementation/bmad-dev-auto/SKILL.md:18

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taken. Validity rule 4 now requires ids to be YAML strings, always quoted, containing only letters, digits, and dashes — that covers both the id: 1 number coercion and path/glob characters. In 174887e (the schema file is now assets/stories-schema.md).

- `blocked` → HALT with status `blocked` and blocking condition `blocked spec supplied`.
- `done` → set `review_loop_iteration` to `0` in the frontmatter, then **EARLY EXIT** to `./step-04-review.md` for a fresh review pass. (A `done` spec is a completed run, so this starts a follow-up review, not a resumption.)

If the invocation prompt instead supplies a spec folder and a story id, with no specific spec file path, this is a **folder+id dispatch**: set `spec_folder` (a `{project-root}`-relative or absolute path) and `story_id` from the prompt. Any further prompt text (e.g. `invoke_dev_with` guidance the caller appended) is additional planning context to carry into step-02 — not a competing description of what to implement.

@augmentcode augmentcode Bot Jul 4, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In src/bmm-skills/4-implementation/bmad-dev-auto/step-01-clarify-and-route.md line 27, allowing {spec_folder} to be an absolute path means the skill may read/write outside {project-root}, which can break portability and is easy to misuse in unattended runs. Consider constraining {spec_folder} to be {project-root}-relative (or explicitly validating it’s inside {project-root}) before using it for filesystem reads/writes.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not taken. An absolute spec folder is deliberate: the caller is the trust boundary, and real layouts keep the spec folder and the code checkout under different roots — this PR was itself developed that way. Restricting the path to {project-root}-relative would break that layout without adding safety the caller needs.

@alexeyv

alexeyv commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator Author

Full spec this branch was derived from (kernel, companions, story manifest, append-only memlog, and all five story records including the end-to-end demonstration): https://gist.github.com/alexeyv/0d80e3b4cd79bb4423c22846fe36f610

The memlog is the interesting read — it carries the complete decision trail from the original Discord thread through every design reversal (status home, slug demotion, handoff collapse, fixed-name discovery) to the final contract.

@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds a "folder+id dispatch" mode to bmad-dev-auto, letting invocations supply a spec folder plus story id instead of a spec path, with new routing, HALT write-back, and ready-for-dev halt logic. It also adds an optional Story Breakdown workflow and stories.yaml schema to bmad-spec, updating both skills' reference documentation.

Changes

bmad-dev-auto folder+id dispatch and HALT handling

Layer / File(s) Summary
Folder+id dispatch routing setup
src/bmm-skills/4-implementation/bmad-dev-auto/step-01-clarify-and-route.md
Initializes runtime placeholders for spec_file, spec_folder, story_id; adds logic to read/validate stories.yaml, resolve the story entry, locate/handle ambiguous story files, and route based on status, including HALT conditions for missing/invalid manifest data.
READY-FOR-DEVELOPMENT and HALT write-back updates
src/bmm-skills/4-implementation/bmad-dev-auto/step-02-plan.md, .../SKILL.md
Adds conditional HALT-after-planning when spec meets standard with ready-for-dev; reworks HALT to add a folder+id dispatch write-back path (id-keyed story spec) alongside the existing otherwise path.
dev-auto.md reference documentation updates
docs/reference/dev-auto.md
Documents the new folder+id dispatch intent, dispatch resolution, context inputs, ready-for-dev halt behavior, expanded blocking condition labels, story spec artifact write-back rules, and orchestrator guidance.

Story manifest schema and Story Breakdown workflow

Layer / File(s) Summary
Story manifest schema definition
src/core-skills/bmad-spec/assets/stories-schema.md
New document defining stories.yaml fields, validity rules, an example, and update semantics tied to .memlog.md and story spec files.
Story Breakdown workflow in bmad-spec SKILL.md
src/core-skills/bmad-spec/SKILL.md
Adds the "break this into stories" trigger, documents stories.yaml in the workspace layout and companions notes, adds the interactive-only Story Breakdown workflow, and updates Output reporting.
core-tools.md Story Breakdown documentation
docs/reference/core-tools.md
Updates the "How it works", Output, and mutation-contract sections to describe the optional Story Breakdown step and stories.yaml.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Invoker
  participant Step01 as step-01-clarify-and-route.md
  participant Manifest as stories.yaml
  participant StorySpec as story spec file
  participant SkillHalt as SKILL.md HALT

  Invoker->>Step01: invoke with spec_folder + story_id
  Step01->>Manifest: read and validate manifest
  Manifest-->>Step01: matching entry by id
  Step01->>StorySpec: locate spec_folder/stories/story_id-*.md
  StorySpec-->>Step01: status (draft or other)
  Step01->>Step01: derive slug from title/description, set spec_file
  alt draft or early routing
    Step01-->>Invoker: route to step-02-plan.md
  else blocking condition
    Step01->>SkillHalt: trigger HALT
    SkillHalt->>StorySpec: update or create story spec, append Auto Run Result
    SkillHalt-->>Invoker: report blocking condition
  end
Loading

Possibly related PRs

  • bmad-code-org/BMAD-METHOD#2500: Original introduction of bmad-dev-auto SKILL.md HALT behavior and step-01/step-02 workflow files that this PR extends.
  • bmad-code-org/BMAD-METHOD#2508: Also modifies routing logic in step-01-clarify-and-route.md, adjusting the status: done branch alongside this PR's new folder+id dispatch routing.
  • bmad-code-org/BMAD-METHOD#2536: Both PRs change terminal frontmatter status write behavior in bmad-dev-auto, this PR in the HALT macro and #2536 in step-04-review's Finalize.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: story breakdown plus folder+id dispatch.
Description check ✅ Passed The description is directly related to the changeset and accurately describes the new story manifest and dispatch flow.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/spec-to-loop-contract

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/bmm-skills/4-implementation/bmad-dev-auto/SKILL.md`:
- Around line 16-34: The folder+id write-back in the Bmad auto flow is placing
HALT sentinel files in the same canonical stories glob as real story specs,
which causes later resolution in the Route/step-01 path to pick the sentinel
instead of the intended story. Update the logic in the folder+id dispatch flow
so `{spec_file}` for unresolved or ambiguous halts is generated outside the
`stories/{story_id}-*.md` namespace, while keeping the existing resolved
`{story_id}-{slug}.md` path for normal cases. Make sure the change is applied in
the write-back path that decides `{spec_file}` and the skeletal story
creation/update behavior remains unchanged for the real story file.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d7ec3706-87c7-4f4d-b994-0a136c9df25a

📥 Commits

Reviewing files that changed from the base of the PR and between 50b3238 and aa20d17.

📒 Files selected for processing (6)
  • src/bmm-skills/4-implementation/bmad-dev-auto/SKILL.md
  • src/bmm-skills/4-implementation/bmad-dev-auto/step-01-clarify-and-route.md
  • src/bmm-skills/4-implementation/bmad-dev-auto/step-02-plan.md
  • src/core-skills/bmad-spec/SKILL.md
  • src/core-skills/bmad-spec/assets/story-manifest-schema.md
  • src/core-skills/bmad-spec/customize.toml

Comment thread src/bmm-skills/4-implementation/bmad-dev-auto/SKILL.md
@alexeyv alexeyv force-pushed the feat/spec-to-loop-contract branch 3 times, most recently from 0de7eed to 844a092 Compare July 5, 2026 00:45
@alexeyv alexeyv marked this pull request as ready for review July 5, 2026 01:03
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 2 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

- **If more than one matches**, HALT with status `blocked` and blocking condition `ambiguous story file match`.
- **If exactly one matches**, set `spec_file` to that path.
- `draft` (planning was interrupted mid-flight): accumulate cross-story context before resuming — load every other file matching `{spec_folder}/stories/*.md` (every match except `{spec_file}` itself), regardless of `status`, and carry forward each one's **Code Map**, **Design Notes**, **Spec Change Log**, **Tasks & Acceptance** checklist state, and **Auto Run Result** details, where present, as additional planning context for step-02. Then **EARLY EXIT** to `./step-02-plan.md`.
- Any other recognized `status`: **EARLY EXIT** using the same routing as above. One difference: a `blocked` story HALTs with blocking condition `story already blocked`, not `blocked spec supplied` — the caller did not supply this file; dev-auto found it by id.

@augmentcode augmentcode Bot Jul 5, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In src/bmm-skills/4-implementation/bmad-dev-auto/step-01-clarify-and-route.md line 35, the folder+id resume path says it uses the same routing as explicit spec-file resumes, but the done route above also resets review_loop_iteration to 0; it’s unclear whether that reset is intended/required here too when a done story is discovered by id. If the review loop logic relies on review_loop_iteration, this ambiguity could lead to an incorrect follow-up review pass.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taken. The folder+id resume routing now explicitly includes the review_loop_iteration reset for done. In 174887e.


| Field | Type | Required | Meaning |
|---|---|---|---|
| `id` | string | yes | Identity, unique within the file. Compared for equality and used as a filename prefix; carries no other meaning. Use unpadded integers (`"1"`), or composites (`"3-2"`) when the epic sits inside a larger project spec. No zero-padding — execution order is the list order, not filename sort. Pinned once work on the story has started (see Update semantics); until then it may be renumbered. |

@augmentcode augmentcode Bot Jul 5, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In src/core-skills/bmad-spec/assets/stories-schema.md line 9, id is specified as a string but YAML will parse unquoted scalars like id: 1 as a number, which can break equality matching against a string {story_id} and any filename-prefix logic downstream. Since id is also used as a filename prefix, allowing path/glob characters (e.g. /, .., *, [ ) can cause unintended matches or writes outside the intended stories/ namespace unless constrained/validated.

Severity: medium

Other Locations
  • docs/reference/core-tools.md:158
  • src/bmm-skills/4-implementation/bmad-dev-auto/step-01-clarify-and-route.md:31

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taken — same fix as the earlier copy of this finding: validity rule 4 in assets/stories-schema.md (quoted YAML strings, letters/digits/dashes only). In 174887e.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/core-skills/bmad-spec/assets/stories-schema.md`:
- Line 9: The pinning rule in the story schema description is inconsistent with
Update semantics. Update the `id` field guidance so it says a story is pinned
once its story spec file exists, and before that point it may still be
renumbered; keep the wording aligned with the Update semantics reference and
remove the current “work on the story has started” phrasing.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 316335fb-984d-4cda-a8fb-812ffb079599

📥 Commits

Reviewing files that changed from the base of the PR and between aa20d17 and 844a092.

📒 Files selected for processing (7)
  • docs/reference/core-tools.md
  • docs/reference/dev-auto.md
  • src/bmm-skills/4-implementation/bmad-dev-auto/SKILL.md
  • src/bmm-skills/4-implementation/bmad-dev-auto/step-01-clarify-and-route.md
  • src/bmm-skills/4-implementation/bmad-dev-auto/step-02-plan.md
  • src/core-skills/bmad-spec/SKILL.md
  • src/core-skills/bmad-spec/assets/stories-schema.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/bmm-skills/4-implementation/bmad-dev-auto/step-01-clarify-and-route.md

Comment thread src/core-skills/bmad-spec/assets/stories-schema.md Outdated
@alexeyv alexeyv force-pushed the feat/spec-to-loop-contract branch from 844a092 to 174887e Compare July 5, 2026 01:27
bmad-spec gains an optional, interactive-only Story Breakdown step that
derives stories.yaml from the memlog: a fixed-name sibling of SPEC.md
listing stories as a simple sequence (list order = execution order),
each with id, title, description, and orchestration fields
spec_checkpoint, done_checkpoint, and invoke_dev_with. Field definitions and validity rules live in
assets/stories-schema.md. Ids are pinned only once a story's spec file
exists; un-started stories may be renumbered on re-derive. stories.yaml
never carries status.

bmad-dev-auto becomes dispatchable per stories.yaml entry: invoked with a
spec folder and story id, it reads only that entry's title and
description, derives the slug, and creates or resumes the story spec at
stories/<id>-<slug>.md just in time. All HALT write-back lands at that
id-keyed path (skeletal spec for pre-planning halts). An
invocation-prompt directive halts ready-for-dev after planning;
re-dispatching the same folder+id resumes via existing status routing.
Planning accumulates context from all prior story records in the
folder. Reference docs updated to cover both halves.
@alexeyv alexeyv force-pushed the feat/spec-to-loop-contract branch from 91ae2eb to 814e3fc Compare July 6, 2026 16:47
@alexeyv alexeyv merged commit 52e4c63 into main Jul 6, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant