Problem
Today's workflows handle the linear happy path (plan → build-tdd → done) and additive iteration after v1 (extend), but do not handle requirement changes that occur mid-build or that modify/remove existing functionality.
Scenarios we cannot handle today
| Scenario |
Current outcome |
| Mid-build: a requirement changes (e.g. "title max should be 100 not 200", stories 2–3 done) |
No workflow. plan --force wipes everything including done stories. Manual edit is the only option. |
| Mid-build: a feature is added |
Awkward. extend is designed for post-v1, not mid-build. |
| Feature removal ("drop tags entirely") |
No workflow. User manually edits files. No deprecation lifecycle. |
| Bug fix in done work |
Partial — user can re-invoke build-tdd on one story, but there is no formal fix workflow framing it. |
| Tech-stack pivot |
No workflow. Effectively plan --force rebuild from scratch. |
Proposed shape: sam-replan
sam-replan <revised-prd.md>
Pipeline:
- Diff — compare revised PRD against current
prd.md. Categorize each change: added / modified / removed / unchanged.
- Impact analysis — for each modified or removed item, walk the
produces / consumes graph from the existing contracts and stories to identify affected artifacts.
- Per-category action —
- Added → behave like
extend (new contracts + stories appended)
- Modified, story not yet built → update story file in place; if a contract changes, bump version
- Modified, story done → bump contract version, mark story
needs-rebuild, keep code as-is until user confirms rebuild
- Removed → mark story
obsolete, deprecate the contract, do not delete code automatically
- Impact summary as a gate — show the user what will change before doing anything ("you're about to invalidate 4 done stories — confirm?").
- Merge revised PRD into
prd.md with a change-log entry (reuse Phase 4 from extend).
Why this is tractable now
Contracts-first design from v0.8.0 already gives us the dependency graph: every story declares its produces and consumes contracts. replan walks that graph to compute impact. The hard problem (which artifacts are affected by a given PRD change) is already half-solved.
Acceptance criteria
- New workflow registered in
_sam/_config/workflow-manifest.csv and bin/cli.js
- Story status lifecycle gains
needs-rebuild and obsolete
- Contract lifecycle gains
deprecated
- Diff + impact summary printed before any file is touched
- Tested on a real iteration scenario (e.g. modify the sam26 todo PRD mid-build)
Out of scope
- Automatic code deletion when features are removed (defer to user)
- Automatic dependency-graph repair when contracts diverge — keep it explicit
Problem
Today's workflows handle the linear happy path (
plan→build-tdd→ done) and additive iteration after v1 (extend), but do not handle requirement changes that occur mid-build or that modify/remove existing functionality.Scenarios we cannot handle today
plan --forcewipes everything including done stories. Manual edit is the only option.extendis designed for post-v1, not mid-build.build-tddon one story, but there is no formalfixworkflow framing it.plan --forcerebuild from scratch.Proposed shape:
sam-replanPipeline:
prd.md. Categorize each change: added / modified / removed / unchanged.produces/consumesgraph from the existing contracts and stories to identify affected artifacts.extend(new contracts + stories appended)needs-rebuild, keep code as-is until user confirms rebuildobsolete, deprecate the contract, do not delete code automaticallyprd.mdwith a change-log entry (reuse Phase 4 fromextend).Why this is tractable now
Contracts-first design from v0.8.0 already gives us the dependency graph: every story declares its
producesandconsumescontracts.replanwalks that graph to compute impact. The hard problem (which artifacts are affected by a given PRD change) is already half-solved.Acceptance criteria
_sam/_config/workflow-manifest.csvandbin/cli.jsneeds-rebuildandobsoletedeprecatedOut of scope