Tasks: Merge Honors Mission Retention Policy (#3131)

Mission: merge-honor-retention-policy-01M1CA0E Planning base / merge target: fix/3131-merge-retention

Subtask completion is event-sourced — record with spec-kitty agent tasks mark-status Txxx --status done. The rows below are reference rows, not checkboxes.

Subtask Index

IDDescriptionWPParallel
T001Add retain_branches/retain_worktrees to MissionMetaOptionalWP01
T002Add read_retention_from_meta (raw, uncoerced) over load_meta_fail_closedWP01
T003Add pure resolve_merge_retention + RetentionDecision (precedence, provenance, coupled coord)WP01
T004Resolver unit tests: 6 precedence cases + malformed value + corrupt metaWP01
T005Red-first @pytest.mark.regression repro: coord retaining mission survives default merge (RED on main)WP02
T006Tri-state cleanup flags (Optional[bool], default None); thread unchanged to the resolver siteWP02
T007Resolve once in unlocked _run_lane_based_merge (primary partition); emit retention warning + override noticeWP02
T008_MergeRunState.teardown_coordination; pass resolved bools into locked driver; couple coord marker-flatten + coord-worktree teardownWP02
T009merge --abort coordination teardown honors retention (skip + warn)WP02
T010Audit orchestrator_api merge entry (C-007): route through resolver or document out-of-scopeWP02
T011Executor + abort unit tests: coupled coord gate, malformed value, override notice, abort-survives, scratch-still-cleanedWP02
T012Forecast: reuse resolve_merge_retention against primary meta; emit resolved values + retention conflict noteWP03[P]
T013Update test_forecast_seam.py golden key set + a resolved-retention forecast assertionWP03[P]
T014create_mission_core keyword-only retain_branches/retain_worktrees; conditional mint (field-absent when false)WP04[P]
T015mission create CLI --retain-branches/--retain-worktrees typer optionsWP04[P]
T016Create-time mint tests: flags → meta fields; no flags → fields absent; meta round-tripWP04[P]
T017Correct stale CLAUDE.md "Merge & Preflight Patterns" doc (C-005) + add retain⇔keep mapping (C-004)WP05
T018Merge docs + CLI help text: retention policy, fail-closed, retain⇔keep mapping, scratch-worktree note (C-006)WP05
T019Specify-interview prompt: create-time retention opt-in note (template source)WP05
T020CHANGELOG.md entry (#3131)WP05

Work Packages

WP01 — Retention meta field + pure resolver (foundation)

consumer shares. Establishes the RetentionDecision contract.

malformed + corrupt without touching git.

  • Goal: The single machine-readable authority + the pure resolver every
  • Priority: P1 (shared dependency of WP02/WP03/WP04).
  • Independent test: resolver unit tests cover all 6 precedence cases +
  • Subtasks: T001, T002, T003, T004
  • Dependencies: none
  • Prompt: tasks/WP01-retention-meta-and-resolver.md (~350 lines)

WP02 — Merge enforcement: honor, couple coord, abort, red-first (core)

couple coordination teardown; abort honors retention; the issue-pinned red-first regression.

this WP through the real _run_lane_based_merge entry point.

  • Goal: Make spec-kitty merge honor the resolved decision fail-closed;
  • Priority: P1 (the data-loss fix itself).
  • Independent test: the red-first regression is RED on main and GREEN after
  • Subtasks: T005 (red-first, committed FIRST), T006, T007, T008, T009, T010, T011
  • Dependencies: WP01
  • Prompt: tasks/WP02-merge-enforcement-and-red-first.md (~600 lines)

WP03 — Dry-run forecast reuses the resolver

retention-conflict note instead of echoing raw flags.

delete_branch: false + retention provenance.

  • Goal: merge --dry-run reports the RESOLVED cleanup decision + a
  • Priority: P2.
  • Independent test: forecast payload for a retaining mission shows
  • Subtasks: T012, T013
  • Dependencies: WP01
  • Prompt: tasks/WP03-forecast-resolver-reuse.md (~250 lines)

WP04 — Create-time retention opt-in

fields into meta.json; field-absent when not requested.

  • Goal: mission create --retain-branches/--retain-worktrees mint the
  • Priority: P2.
  • Independent test: create with flags → fields present; without → absent.
  • Subtasks: T014, T015, T016
  • Dependencies: WP01
  • Prompt: tasks/WP04-create-time-retention-optin.md (~300 lines)

WP05 — Docs, CLAUDE.md correction, CHANGELOG

and fail-closed policy, add the specify opt-in note, CHANGELOG.

longer references the non-existent PreflightResult merge surface.

  • Goal: Correct the stale preflight doc, document the retain⇔keep mapping
  • Priority: P2 (convergence).
  • Independent test: terminology/docs-freshness gates pass; CLAUDE.md no
  • Subtasks: T017, T018, T019, T020
  • Dependencies: WP02, WP03, WP04
  • Prompt: tasks/WP05-docs-and-changelog.md (~250 lines)

MVP scope

WP01 + WP02 deliver the data-loss fix (authority + honored enforcement + red-first proof). WP03/WP04/WP05 complete the lifecycle (preview, authoring, docs).

Parallelization

After WP01 lands, WP02 / WP03 / WP04 touch disjoint files and can run in parallel. WP05 converges last.