Skip to content

Workflow: replan — handle requirement changes mid-build #16

@santoshrout

Description

@santoshrout

Problem

Today's workflows handle the linear happy path (planbuild-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:

  1. Diff — compare revised PRD against current prd.md. Categorize each change: added / modified / removed / unchanged.
  2. Impact analysis — for each modified or removed item, walk the produces / consumes graph from the existing contracts and stories to identify affected artifacts.
  3. 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
  4. Impact summary as a gate — show the user what will change before doing anything ("you're about to invalidate 4 done stories — confirm?").
  5. 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions