Skip to content

FE-826: Orchestrator resolves greenfield/brownfield from the spec-derived plan, not plan location#181

Merged
kostandinang merged 3 commits into
mainfrom
ka/fe-826-cook-mode-from-spec
Jun 9, 2026
Merged

FE-826: Orchestrator resolves greenfield/brownfield from the spec-derived plan, not plan location#181
kostandinang merged 3 commits into
mainfrom
ka/fe-826-cook-mode-from-spec

Conversation

@kostandinang

@kostandinang kostandinang commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Greenfield/brownfield is now spec-derived plan truth, not an inference from where plan.yaml sits on disk. Mode is a property of the specification, so it travels with the plan and drives the worktree strategy.

What Changed

  • Mode in the planPlan gains mode: 'greenfield' | 'brownfield'; brunch plan <specId> threads specification.mode through snapshot → projection → reconciliation → emitted plan.yaml. loadPlan defaults a missing/legacy mode to greenfield.
  • Resolver splitresolveCookModeresolveCookPlan (locate the plan path) + resolveSandboxPlan (mode-driven worktree: greenfield → empty worktree; brownfield → clone the cwd repo, clean-tree gate). A spec-emitted greenfield plan no longer clones the cwd.
  • Optional dirbrunch cook [dir] defaults to the launch cwd.

Reverses the location-keyed reading of SPEC Requirement 50; adds D164-K, refines I123-K (clone is brownfield-only). Engine/topology plan fixtures regenerated with an explicit mode.

Verification

npm run verify green (1706 tests, build). brownfield-smoke gains a "greenfield-from-spec never clones" oracle alongside the brownfield clone path.

🤖 Generated with Claude Code

@kostandinang kostandinang changed the title FE-826: Resolve cook greenfield/brownfield from the spec-derived plan, not plan location FE-826: Cook resolves greenfield/brownfield from the spec-derived plan, not plan location Jun 9, 2026
@kostandinang kostandinang marked this pull request as ready for review June 9, 2026 08:54

kostandinang commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

@cursor

cursor Bot commented Jun 9, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes when cook clones the repo vs uses an empty worktree; brownfield-only git gates mean behavior shifts for spec-emitted plans under .brunch/cook/.

Overview
Greenfield/brownfield is now read from plan.yaml’s mode, not from where the plan file lives. brunch plan <specId> threads specification.mode through the snapshot → projection → reconciliation pipeline into Plan.mode; loadPlan treats missing or legacy plans as greenfield.

Cook resolver split: resolveCookPlan only finds the plan path (no git checks); resolveSandboxPlan applies plan.mode — greenfield → empty worktree, brownfield → cwd clone with the clean-tree gate. A greenfield plan under .brunch/cook/ no longer clones the repo.

CLI: brunch cook [dir] defaults dir to the launch cwd. SPEC Requirement 50, D164-K, and I123-K are updated to match.

Reviewed by Cursor Bugbot for commit 9f29209. Bugbot is set up for automated code reviews on this repo. Configure here.

@kostandinang kostandinang changed the base branch from main to graphite-base/181 June 9, 2026 09:00
@kostandinang kostandinang force-pushed the ka/fe-826-cook-mode-from-spec branch from 614109d to 1dfa79b Compare June 9, 2026 09:00
@kostandinang kostandinang changed the base branch from graphite-base/181 to ka/fe-819-orchestrator-petrinaut-integration-improvements June 9, 2026 09:00
@kostandinang kostandinang self-assigned this Jun 9, 2026
@kostandinang kostandinang changed the title FE-826: Cook resolves greenfield/brownfield from the spec-derived plan, not plan location FE-826: Orchestrator resolves greenfield/brownfield from the spec-derived plan, not plan location Jun 9, 2026
@kostandinang kostandinang requested a review from lunelson June 9, 2026 11:22
Base automatically changed from ka/fe-819-orchestrator-petrinaut-integration-improvements to main June 9, 2026 14:24
kostandinang and others added 3 commits June 9, 2026 17:35
…, not plan location

Greenfield vs brownfield is now plan truth carried from the spec, not an
inference from where plan.yaml sits on disk.

- `Plan` gains a `mode: 'greenfield' | 'brownfield'`; `brunch plan <specId>`
  threads `specification.mode` through the snapshot → projection →
  reconciliation → emitted plan.yaml. `loadPlan` defaults a missing/legacy
  mode to greenfield.
- `resolveCookMode` splits into `resolveCookPlan` (locates the plan path only)
  and `resolveSandboxPlan` (chooses the worktree strategy from `plan.mode`):
  greenfield → empty worktree, generate from scratch, no git gate; brownfield
  → clone the cwd repo, requiring a clean git working tree.
- A spec-emitted greenfield plan now uses an empty worktree instead of always
  cloning the cwd; brownfield-smoke gains a "never clones" greenfield oracle.

Reverses SPEC §D50 (mode = plan location) and refines I123-K — reconciled
separately via ln-sync. Plan fixtures regenerated with explicit mode.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
`brunch cook` with no positional directory now runs against the launch cwd
(BRUNCH_LAUNCH_CWD || process.cwd()) and looks for `.brunch/` there, instead
of erroring on a missing argument. Help text reads `cook [dir]`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Requirement 46: `brunch cook [dir]` (dir optional, defaults to cwd).
- Requirement 50: mode-driven resolver — locate the plan, then read the
  plan's spec-derived `mode` to choose the worktree strategy; mode is carried
  in plan.yaml from `specification.mode`, not inferred from plan location.
- Add decision D162-K (greenfield/brownfield is spec-derived plan truth);
  refine invariant I123-K (clone is brownfield-only; greenfield uses an empty
  worktree even from a spec plan).
- Lexicon: fixture/codebase mode rows are now mode-selected, not location-keyed.
- PLAN: add FE-826 cook-mode-from-spec frontier (branch-complete).
- Retire memory/CARDS.md (both cards landed).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@kostandinang kostandinang force-pushed the ka/fe-826-cook-mode-from-spec branch from 1dfa79b to 9f29209 Compare June 9, 2026 15:36

@lunelson lunelson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This makes the cook mode source much clearer: plan truth now carries through from the spec instead of depending on where the file happens to live.

One small question: in src/orchestrator/src/plan-loader.ts, plans with a missing mode default to greenfield, which seems right for legacy/authored plans. But an explicit unknown value also falls back to greenfield. Do we want typoed modes to fail loudly instead?

@kostandinang kostandinang added this pull request to the merge queue Jun 9, 2026
Merged via the queue into main with commit e572657 Jun 9, 2026
6 checks passed
@kostandinang kostandinang deleted the ka/fe-826-cook-mode-from-spec branch June 9, 2026 23:05
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.

2 participants