ralph-teams 1.0.34 → 1.0.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -24,7 +24,7 @@ The default `balanced` mode is intentionally simple:
24
24
  - it spawns one Builder per story attempt
25
25
  - it validates inline or spawns a validator when independent verification is needed
26
26
  - it works through the user stories sequentially until the epic is done
27
- - Ralph then moves to the next epic, and after all epics finish, runs final validation
27
+ - Ralph then moves to the next epic until all epics are done
28
28
 
29
29
  ## Quickest Start
30
30
 
@@ -58,12 +58,7 @@ flowchart TD
58
58
  J --> K[If needed, fallback merge recovery handles leftovers]
59
59
  K --> L{More epics?}
60
60
  L -->|Yes| C
61
- L -->|No| M{2+ epics and final validation enabled?}
62
- M -->|No| P[Finish]
63
- M -->|Yes| N[Run final validator]
64
- N -->|PASS| P
65
- N -->|FAIL and retries left| O[Builder fixes final-validation findings]
66
- O --> N
61
+ L -->|No| P[Finish]
67
62
  ```
68
63
 
69
64
  Other presets:
@@ -79,8 +74,8 @@ At a high level:
79
74
  - `ralph.config.yml` controls backend choice, workflow toggles, parallelism, timeouts, and model selection.
80
75
 
81
76
  Workflow presets:
82
- - `balanced`: epic planning enabled, heuristic epic validation enabled, and final validation enabled
83
- - `full`: `balanced`, plus story planning and heuristic story validation
77
+ - `balanced`: epic planning enabled, heuristic epic validation enabled (no final validation)
78
+ - `full`: `balanced`, plus story planning, heuristic story validation, and final validation
84
79
  - `minimal`: planning and validation toggles disabled; no planner or validator subagents are spawned
85
80
 
86
81
  Default agent model assignments:
@@ -209,8 +204,8 @@ Prompts for:
209
204
  - Agent model overrides (optional)
210
205
 
211
206
  Workflow presets:
212
- - `balanced`: epic planning enabled, heuristic epic validation enabled, and final validation enabled
213
- - `full`: `balanced`, plus story planning and heuristic story validation
207
+ - `balanced`: epic planning enabled, heuristic epic validation enabled (no final validation)
208
+ - `full`: `balanced`, plus story planning, heuristic story validation, and final validation
214
209
  - `minimal`: planning and validation toggles disabled; no planner or validator subagents are spawned
215
210
 
216
211
  Preset behavior notes:
@@ -538,12 +533,13 @@ During a run, Ralph writes:
538
533
  - `.ralph-teams/state/merge-EPIC-xxx.json`: per-epic merge-result artifact written by the Team Lead or merge recovery path
539
534
  - `.ralph-teams/plans/plan-EPIC-xxx.md`: epic-planner output for an epic
540
535
  - planned epics are expected to use these files as their implementation contract
536
+ - `.ralph-teams/logs/loop-<timestamp>.log`: outer `ralph-teams run` orchestration log mirroring terminal output
541
537
  - `.ralph-teams/logs/epic-EPIC-xxx-<timestamp>.log`: raw backend session log
542
538
  - `.ralph-teams/ralph-state.json`: saved interrupt/resume state
543
539
 
544
540
  Ralph also updates the original `prd.json` in place as epic status changes.
545
541
 
546
- The team lead agent log for each epic is written to `.ralph-teams/logs/` regardless of backend.
542
+ The outer run log and the team lead agent log for each epic are written to `.ralph-teams/logs/` regardless of backend.
547
543
 
548
544
  ## Runtime Rules
549
545
 
package/dist/config.js CHANGED
@@ -82,7 +82,7 @@ function presetExecution(preset) {
82
82
  storyValidation: { enabled: false, maxFixCycles: 1 },
83
83
  epicPlanning: { enabled: true },
84
84
  epicValidation: { enabled: true, maxFixCycles: 1 },
85
- finalValidation: { enabled: true, maxFixCycles: 1 },
85
+ finalValidation: { enabled: false, maxFixCycles: 1 },
86
86
  };
87
87
  }
88
88
  }
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsLA,4CAEC;AAED,sEAoBC;AAOD,wCAoOC;AAED,gCA6BC;AAED,8CAkBC;AAED,0EA+DC;AA7iBD,uCAAyB;AACzB,2CAA6B;AAC7B,8CAAgC;AAkEhC,MAAM,aAAa,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,CAAU,CAAC;AAE/D,SAAS,eAAe,CAAC,KAAc;IACrC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC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AY,EAAE,CAAC;gBACjC,QAAQ,CAAC,KAAK,CAAC,GAAG,cAAc,CAAC;YACnC,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3E,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,MAAM,QAAQ,GAAG,MAAiC,CAAC;IAEnD,KAAK,MAAM,KAAK,IAAI,YAAY,EAAE,CAAC;QACjC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC9B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,QAAQ,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;QAC1B,CAAC;IACH,CAAC;IAED,IAAI,QAAQ,CAAC,WAAW,KAAK,SAAS,IAAI,OAAO,QAAQ,CAAC,SAAS,CAAC,KAAK,QAAQ,EAAE,CAAC;QAClF,QAAQ,CAAC,WAAW,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;IACD,IAAI,QAAQ,CAAC,cAAc,KAAK,SAAS,IAAI,OAAO,QAAQ,CAAC,WAAW,CAAC,KAAK,QAAQ,EAAE,CAAC;QACvF,QAAQ,CAAC,cAAc,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC;IAClD,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ralph-teams",
3
- "version": "1.0.34",
3
+ "version": "1.0.36",
4
4
  "description": "CLI tool for Ralph Teams",
5
5
  "bin": {
6
6
  "ralph-teams": "dist/index.js",
@@ -16,13 +16,13 @@ You coordinate epic execution. For clearly easy, low-risk mechanical tasks, you
16
16
 
17
17
  ## Command Inference
18
18
 
19
- - Ralph does not centrally bootstrap project dependencies for the worktree. You must infer the right setup, build, and test commands from the repository itself.
19
+ - Ralph does not centrally bootstrap project dependencies for the epic workspace. You must infer the right setup, build, and test commands from the repository itself.
20
20
  - Start with repository instructions: `AGENTS.md`, `README*`, contributor docs, and any project-local guidance files referenced there. Then prefer repository-defined task runners and scripts over language defaults: `Makefile`, `justfile`, `Taskfile.yml`, package scripts, wrapper scripts, or documented commands.
21
21
  - Then inspect ecosystem manifests such as `package.json`, `pyproject.toml`, `requirements.txt`, `Cargo.toml`, `go.mod`, `Gemfile`, `pom.xml`, `build.gradle*`, `mix.exs`, `Dockerfile`, and `docker-compose*.yml`.
22
22
  - Prefer explicit repository commands over generic ecosystem defaults even when the language is obvious.
23
- - Before the first Builder for an epic, prepare the epic worktree environment once. Do not make each Builder rediscover basic setup from scratch.
24
- - Start by checking whether the source checkout path provided in the runtime prompt already contains reusable dependency or generated setup artifacts that the epic worktree can safely reuse.
25
- - If safe reuse is possible, materialize that reuse inside the epic worktree and continue. If reuse is not possible, run the repository's native bootstrap or install command inside the epic worktree before delegating implementation.
23
+ - Before the first Builder for an epic, prepare the epic workspace environment once. Do not make each Builder rediscover basic setup from scratch.
24
+ - Start by checking whether the source checkout path provided in the runtime prompt already contains reusable dependency or generated setup artifacts that the epic workspace can safely reuse.
25
+ - If safe reuse is possible, materialize that reuse inside the epic workspace and continue. If reuse is not possible, run the repository's native bootstrap or install command inside the epic workspace before delegating implementation.
26
26
  - Once the bootstrap, build, and test commands are established, pass the exact commands and any required environment-prep steps to every Builder for that epic.
27
27
  - Only use generic defaults when the repository is unambiguous.
28
28
  - If setup or verification remains ambiguous after inspection, do not guess wildly. Mark the attempt failed with a short concrete reason describing the ambiguity.
@@ -51,7 +51,7 @@ You coordinate epic execution. For clearly easy, low-risk mechanical tasks, you
51
51
 
52
52
  - Before starting a story, check the epic state file. If the story has `passes: true`, skip it.
53
53
  - For clearly easy, low-risk mechanical stories, you may implement directly in the Team Lead session when delegation overhead would exceed the work. Keep the change narrowly scoped and still run the required verification yourself before counting the story complete.
54
- - Before delegating the first story, ensure the epic worktree environment is actually runnable.
54
+ - Before delegating the first story, ensure the epic workspace environment is actually runnable.
55
55
  - Before delegating any story, pass the exact bootstrap, build, and test commands already established for this epic to the Builder.
56
56
  - If an epic plan exists, give the Builder the story, acceptance criteria, relevant plan section, and especially the story's planned test design.
57
57
  - If a story planner was used, give the Builder the story planner output too.
@@ -102,13 +102,14 @@ You coordinate epic execution. For clearly easy, low-risk mechanical tasks, you
102
102
 
103
103
  ## Merge Completion
104
104
 
105
- - If every story in the epic passes, this same Team Lead session must attempt the merge before exiting.
105
+ - The Team Lead always owns the first merge attempt before exiting.
106
106
  - Use the loop-branch name, repository-root path, epic branch name, and merge-result artifact path provided by the runtime prompt.
107
- - You may leave the epic worktree only for this final merge attempt. Keep all other work inside the epic worktree.
107
+ - You may leave the epic workspace only for this final merge attempt. Keep all other work inside the epic workspace.
108
108
  - Attempt the merge on the repository root branch with `git merge <epic-branch> --no-commit --no-ff` so you can resolve conflicts before the final commit.
109
- - Before the merge attempt, check the repository root for uncommitted changes. If it is dirty, create a checkpoint commit so the merge can proceed cleanly.
110
- - If the merge is clean, commit it and write a merge-result artifact with `status: "merged"` and mode `clean` or `projected-prd` as appropriate.
111
- - If there are conflicts, resolve them yourself in this same session. Do not delegate to another merger role or any other teammate. If you resolve the conflicts, commit the merge and write `status: "merged"` with mode `conflict-resolved`.
112
- - If you cannot resolve the merge safely, abort the merge, write a merge-result artifact with `status: "merge-failed"`, include a short concrete `details` string, and then exit.
113
- - The merge-result artifact must be written atomically to the exact path provided by the runtime prompt before you print the final DONE line.
114
- - Only print `DONE: X/Y stories passed` after the merge attempt and merge-result artifact write are finished.
109
+ - Before the Team Lead-owned merge attempt, check the repository root for uncommitted changes. If it is dirty, create a checkpoint commit so the merge can proceed cleanly.
110
+ - If the Team Lead-owned merge is clean, commit it and write a merge-result artifact with `status: "merged"` and mode `clean` or `projected-prd` as appropriate.
111
+ - If there are conflicts during a Team Lead-owned merge, resolve them yourself in this same session. Do not delegate to another merger role or any other teammate. If you resolve the conflicts, commit the merge and write `status: "merged"` with mode `conflict-resolved`.
112
+ - If you cannot resolve a Team Lead-owned merge safely, abort the merge, write a merge-result artifact with `status: "merge-failed"`, include a short concrete `details` string, and then exit.
113
+ - Write the merge-result artifact atomically to the exact path provided by the runtime prompt before you print the final DONE line.
114
+ - Ralph will verify the merge result after your session exits and may attempt a scripted fallback merge if the branch is still unmerged.
115
+ - Only print `DONE: X/Y stories passed` after the required final action for this runtime mode is finished.
@@ -9,17 +9,17 @@ Do NOT modify files outside this directory, except for the epic state file below
9
9
 
10
10
  ## Source Checkout
11
11
  - Source checkout path: {{SOURCE_ROOT_DIR}}
12
- - You may inspect this source checkout read-only to understand repo-level setup and to reuse existing dependency or build artifacts when that is safer or faster than reinstalling inside the epic worktree.
13
- - Do NOT modify the source checkout during normal implementation. Any reuse should materialize inside the epic worktree, for example by creating a symlink there or copying a cacheable artifact into the worktree.
12
+ - You may inspect this source checkout read-only to understand repo-level setup and to reuse existing dependency or build artifacts when that is safer or faster than reinstalling inside the epic workspace.
13
+ - Do NOT modify the source checkout during normal implementation. Any reuse should materialize inside the epic workspace, for example by creating a symlink there or copying a cacheable artifact into the workspace.
14
14
 
15
15
  ## Project Setup Strategy
16
16
  - Ralph does not preinstall dependencies or preselect build/test commands for this repo.
17
- - Before delegating implementation, establish the epic worktree environment once for this epic: determine the setup, build, and test commands, then make the worktree runnable before the first Builder starts.
17
+ - Before delegating implementation, establish the epic workspace environment once for this epic: determine the setup, build, and test commands, then make the workspace runnable before the first Builder starts.
18
18
  - Check repo instructions first: 'AGENTS.md', 'README*', contributor docs, and project-local guidance files. Then check repo-defined task runners or scripts such as 'Makefile', 'justfile', 'Taskfile.yml', package scripts, wrapper scripts, or documented commands.
19
19
  - Then inspect ecosystem manifests such as 'package.json', 'pyproject.toml', 'requirements.txt', 'Cargo.toml', 'go.mod', 'Gemfile', 'pom.xml', 'build.gradle*', 'mix.exs', 'Dockerfile', and 'docker-compose*.yml'.
20
20
  - Prefer explicit repository commands over generic ecosystem defaults.
21
- - If the epic worktree is missing dependencies or other generated setup artifacts, first check whether the source checkout already has reusable artifacts that can be safely reused from the worktree.
22
- - Prefer safe reuse from the source checkout when the repository structure and lockfiles make that reuse trustworthy; otherwise run the repository's native bootstrap/install step inside the epic worktree.
21
+ - If the epic workspace is missing dependencies or other generated setup artifacts, first check whether the source checkout already has reusable artifacts that can be safely reused from the workspace.
22
+ - Prefer safe reuse from the source checkout when the repository structure and lockfiles make that reuse trustworthy; otherwise run the repository's native bootstrap/install step inside the epic workspace.
23
23
  - After you determine the correct bootstrap, build, and test commands, pass those exact commands to every Builder for this epic and tell Builders not to rediscover them unless the provided commands fail.
24
24
  - Only fall back to generic defaults when the repository is unambiguous.
25
25
  - If setup remains ambiguous after inspection, stop guessing and fail the story attempt with a short concrete reason describing what you found.
@@ -31,16 +31,7 @@ Do NOT modify files outside this directory, except for the epic state file below
31
31
  {{WORKTREE_PRD_PATH}}
32
32
 
33
33
  ## Merge Responsibility
34
- - If all stories pass, this same Team Lead session owns the merge attempt before exiting.
35
- - Loop branch to merge into: {{LOOP_BRANCH}}
36
- - Source epic branch: {{EPIC_BRANCH}}
37
- - Repository root for the merge attempt: {{ROOT_DIR}}
38
- - Write the final merge result artifact to: {{WORKTREE_MERGE_RESULT_FILE}}
39
- - The merge result artifact must be valid JSON with fields: epicId, status, mode, details, timestamp.
40
- - Allowed status values: merged, merge-failed.
41
- - Allowed mode values: clean, projected-prd, conflict-resolved, unknown.
42
- - When all stories pass, do not print DONE until after you have attempted the merge and written the merge result artifact.
43
- - During the merge attempt you may operate in the repository root path above even though normal implementation work stays inside the epic worktree.
34
+ {{MERGE_RESPONSIBILITY}}
44
35
 
45
36
  ## Epic
46
37
  {{EPIC_JSON}}
package/ralph.sh CHANGED
@@ -340,6 +340,8 @@ PLANS_DIR="${RALPH_RUNTIME_DIR}/plans"
340
340
  LOGS_DIR="${RALPH_RUNTIME_DIR}/logs"
341
341
  STATE_DIR="${RALPH_RUNTIME_DIR}/state"
342
342
  WORKTREES_DIR="${RALPH_RUNTIME_DIR}/.worktrees"
343
+ OUTER_LOOP_LOG=""
344
+ RALPH_VERSION="unknown"
343
345
 
344
346
  repair_source_runtime_dir_if_needed() {
345
347
  if [ -L "$RALPH_RUNTIME_DIR" ]; then
@@ -362,6 +364,36 @@ unstage_runtime_artifacts() {
362
364
  repair_source_runtime_dir_if_needed
363
365
  mkdir -p "$RALPH_RUNTIME_DIR" "$PLANS_DIR" "$LOGS_DIR" "$STATE_DIR" "$WORKTREES_DIR"
364
366
 
367
+ enable_outer_loop_logging() {
368
+ if [ "${RALPH_OUTER_LOOP_LOGGING_ACTIVE:-0}" = "1" ]; then
369
+ return 0
370
+ fi
371
+
372
+ OUTER_LOOP_LOG="${LOGS_DIR}/loop-$(date +%s).log"
373
+ export RALPH_OUTER_LOOP_LOGGING_ACTIVE="1"
374
+ export RALPH_OUTER_LOOP_LOG="$OUTER_LOOP_LOG"
375
+
376
+ exec > >(tee -a "$OUTER_LOOP_LOG")
377
+ exec 2>&1
378
+
379
+ echo "Outer loop log: $OUTER_LOOP_LOG"
380
+ }
381
+
382
+ enable_outer_loop_logging
383
+
384
+ resolve_ralph_version() {
385
+ local package_json="${SCRIPT_DIR}/package.json"
386
+
387
+ if [ -f "$package_json" ] && command -v node >/dev/null 2>&1; then
388
+ node -p "try { require(process.argv[1]).version || 'unknown' } catch { 'unknown' }" "$package_json" 2>/dev/null || echo "unknown"
389
+ return 0
390
+ fi
391
+
392
+ echo "unknown"
393
+ }
394
+
395
+ RALPH_VERSION="$(resolve_ralph_version)"
396
+
365
397
  ensure_runtime_rjq_bin() {
366
398
  if [ "${RALPH_SKIP_RUNTIME_RJQ:-}" = "1" ]; then
367
399
  RJQ_BIN=""
@@ -541,7 +573,7 @@ fi
541
573
 
542
574
  echo ""
543
575
  echo "========================================================"
544
- echo " Ralph Teams — Project Manager"
576
+ echo " Ralph Teams v${RALPH_VERSION} — Project Manager"
545
577
  echo " Project: $PROJECT"
546
578
  echo " Source Branch: ${SOURCE_BRANCH:-<unknown>}"
547
579
  echo " Loop Branch: $LOOP_BRANCH"
@@ -654,8 +686,15 @@ ensure_repo_has_initial_commit
654
686
 
655
687
  mkdir -p "$RALPH_RUNTIME_DIR" "$PLANS_DIR" "$LOGS_DIR" "$STATE_DIR" "$WORKTREES_DIR"
656
688
 
689
+ loop_worktree_path() {
690
+ local loop_suffix="${LOOP_BRANCH#ralph/loop/}"
691
+ loop_suffix=$(printf '%s' "$loop_suffix" | tr '/:' '--')
692
+ echo "${WORKTREES_DIR}/loop-${loop_suffix}"
693
+ }
694
+
657
695
  ensure_loop_worktree_ready() {
658
- local loop_worktree_path="${WORKTREES_DIR}/loop"
696
+ local loop_worktree_path
697
+ loop_worktree_path="$(loop_worktree_path)"
659
698
  local add_output=""
660
699
  local retry_output=""
661
700
  local existing_worktree=""
@@ -772,6 +811,10 @@ fail_on_pending_epic_git_state_mismatch() {
772
811
  fail_on_pending_epic_git_state_mismatch
773
812
 
774
813
  # --- Worktree Management ---
814
+ use_dedicated_epic_worktrees() {
815
+ [ -n "$PARALLEL" ] && [ "$PARALLEL" -gt 1 ]
816
+ }
817
+
775
818
  # Creates a git worktree at .worktrees/<epic_id> on a run-scoped branch under
776
819
  # the current loop branch name, rooted from the loop branch for this run.
777
820
  # rooted from the loop branch for this run.
@@ -811,6 +854,56 @@ create_epic_worktree() {
811
854
  echo "$worktree_path"
812
855
  }
813
856
 
857
+ restore_loop_worktree_branch() {
858
+ local current_branch=""
859
+ current_branch=$(git -C "$LOOP_ROOT_DIR" branch --show-current 2>/dev/null || echo "")
860
+
861
+ if [ -z "$current_branch" ] || [ "$current_branch" = "$LOOP_BRANCH" ]; then
862
+ return 0
863
+ fi
864
+
865
+ local dirty_status=""
866
+ dirty_status=$(git -C "$LOOP_ROOT_DIR" status --porcelain 2>/dev/null || true)
867
+ if [ -n "$dirty_status" ]; then
868
+ git -C "$LOOP_ROOT_DIR" add -A
869
+ (
870
+ cd "$LOOP_ROOT_DIR"
871
+ unstage_runtime_artifacts
872
+ )
873
+ if git -C "$LOOP_ROOT_DIR" commit -m "chore: checkpoint ${current_branch} before returning to loop branch" >/dev/null 2>&1; then
874
+ echo " [${current_branch}] Auto-committed dirty workspace before returning to ${LOOP_BRANCH}"
875
+ fi
876
+ fi
877
+
878
+ git -C "$LOOP_ROOT_DIR" checkout "$LOOP_BRANCH" >/dev/null 2>&1
879
+ }
880
+
881
+ prepare_sequential_epic_workspace() {
882
+ local epic_id="$1"
883
+ local branch_name
884
+ branch_name=$(epic_branch_name "$epic_id")
885
+
886
+ restore_loop_worktree_branch
887
+
888
+ if git show-ref --verify --quiet "refs/heads/${branch_name}"; then
889
+ git -C "$LOOP_ROOT_DIR" checkout "$branch_name" >/dev/null 2>&1
890
+ else
891
+ git -C "$LOOP_ROOT_DIR" checkout -b "$branch_name" "$LOOP_BRANCH" >/dev/null 2>&1
892
+ fi
893
+
894
+ echo "$LOOP_ROOT_DIR"
895
+ }
896
+
897
+ prepare_epic_workspace() {
898
+ local epic_id="$1"
899
+
900
+ if use_dedicated_epic_worktrees; then
901
+ create_epic_worktree "$epic_id"
902
+ else
903
+ prepare_sequential_epic_workspace "$epic_id"
904
+ fi
905
+ }
906
+
814
907
  compute_file_checksum() {
815
908
  local file_path="$1"
816
909
  cksum "$file_path" | awk '{print $1 ":" $2}'
@@ -852,6 +945,16 @@ cleanup_epic_worktree() {
852
945
  git worktree remove "${WORKTREES_DIR}/${epic_id}" --force 2>/dev/null || true
853
946
  }
854
947
 
948
+ cleanup_epic_workspace() {
949
+ local epic_id="$1"
950
+
951
+ if use_dedicated_epic_worktrees; then
952
+ cleanup_epic_worktree "$epic_id"
953
+ else
954
+ restore_loop_worktree_branch
955
+ fi
956
+ }
957
+
855
958
  # Removes ALL .worktrees/* entries (used on EXIT).
856
959
  cleanup_all_worktrees() {
857
960
  for dir in "${WORKTREES_DIR}"/*/; do
@@ -1373,6 +1476,7 @@ render_team_lead_prompt() {
1373
1476
  TEAM_LEAD_TEMPLATE_EPIC_PLANNED="$EPIC_PLANNED" \
1374
1477
  TEAM_LEAD_TEMPLATE_WORKTREE_PLAN_EXISTS="$WORKTREE_PLAN_EXISTS" \
1375
1478
  TEAM_LEAD_TEMPLATE_PENDING_STORIES_JSON="$PENDING_STORIES_JSON" \
1479
+ TEAM_LEAD_TEMPLATE_MERGE_RESPONSIBILITY="$MERGE_RESPONSIBILITY" \
1376
1480
  TEAM_LEAD_TEMPLATE_TEAM_LEAD_POLICY="$TEAM_LEAD_POLICY" \
1377
1481
  TEAM_LEAD_TEMPLATE_STORY_PLANNING_ENABLED="$STORY_PLANNING_ENABLED" \
1378
1482
  TEAM_LEAD_TEMPLATE_STORY_VALIDATION_ENABLED="$STORY_VALIDATION_ENABLED" \
@@ -1400,7 +1504,7 @@ NODE
1400
1504
  process_epic_result() {
1401
1505
  local epic_index="$1"
1402
1506
  local epic_id
1403
- epic_id=$(rjq read "$PRD_FILE" ".epics[$epic_index].id")
1507
+ epic_id=$(rjq read "$PRD_FILE" ".epics[$epic_index].id" 2>/dev/null) || epic_id="EPIC-???"
1404
1508
  local merge_status=""
1405
1509
  merge_status=$(read_epic_merge_result_field "$epic_id" .status "" 2>/dev/null || true)
1406
1510
  local merge_mode=""
@@ -1409,48 +1513,36 @@ process_epic_result() {
1409
1513
  merge_details=$(read_epic_merge_result_field "$epic_id" .details "" 2>/dev/null || true)
1410
1514
 
1411
1515
  local total_stories
1412
- total_stories=$(rjq length "$PRD_FILE" ".epics[$epic_index].userStories")
1516
+ total_stories=$(rjq length "$PRD_FILE" ".epics[$epic_index].userStories" 2>/dev/null) || total_stories=0
1413
1517
  local passed_stories
1414
- passed_stories=$(rjq count-where "$PRD_FILE" ".epics[$epic_index].userStories" "passes=true")
1518
+ passed_stories=$(rjq count-where "$PRD_FILE" ".epics[$epic_index].userStories" "passes=true" 2>/dev/null) || passed_stories=0
1415
1519
 
1416
1520
  if [ "$passed_stories" -eq "$total_stories" ] && [ "$total_stories" -gt 0 ]; then
1417
- if [ "$merge_status" = "merge-failed" ]; then
1418
- echo ""
1419
- echo " [$epic_id] MERGE FAILED — all stories passed but merge did not complete"
1420
- [ -n "$merge_details" ] && echo " [$epic_id] Merge details: $merge_details"
1421
- rjq set "$PRD_FILE" ".epics[$epic_index].status" '"merge-failed"'
1422
- FAILED=$((FAILED + 1))
1423
- echo "[$epic_id] MERGE FAILED (${merge_details:-team lead merge failed}) — $(date)" >> "$PROGRESS_FILE"
1424
- return
1425
- fi
1426
-
1427
- if [ "$merge_status" != "merged" ]; then
1428
- echo ""
1429
- echo " [$epic_id] MERGE FAILED — all stories passed but Team Lead did not record a merge result"
1430
- rjq set "$PRD_FILE" ".epics[$epic_index].status" '"merge-failed"'
1431
- FAILED=$((FAILED + 1))
1432
- echo "[$epic_id] MERGE FAILED (missing team lead merge result artifact) — $(date)" >> "$PROGRESS_FILE"
1433
- return
1434
- fi
1435
-
1436
1521
  echo ""
1437
1522
  echo " [$epic_id] PASSED — all stories completed ($passed_stories/$total_stories)"
1438
- rjq set "$PRD_FILE" ".epics[$epic_index].status" '"completed"'
1523
+ rjq set "$PRD_FILE" ".epics[$epic_index].status" '"completed"' 2>/dev/null || echo " [WARN] Failed to set epic $epic_index status" >&2
1439
1524
  COMPLETED=$((COMPLETED + 1))
1440
1525
  echo "[$epic_id] PASSED — $(date)" >> "$PROGRESS_FILE"
1441
1526
  if [ "$merge_status" = "merged" ]; then
1442
1527
  echo " [$epic_id] Merge successful (team lead, ${merge_mode:-unknown})"
1443
1528
  echo "[$epic_id] MERGED (team lead ${merge_mode:-unknown}) — $(date)" >> "$PROGRESS_FILE"
1529
+ elif [ "$merge_status" = "merge-failed" ]; then
1530
+ echo " [$epic_id] Team Lead merge did not complete — Ralph will verify and may retry on ${LOOP_BRANCH}"
1531
+ [ -n "$merge_details" ] && echo " [$epic_id] Merge details: $merge_details"
1532
+ echo "[$epic_id] PENDING MERGE VERIFICATION (${merge_details:-team lead merge failed}) — $(date)" >> "$PROGRESS_FILE"
1533
+ else
1534
+ echo " [$epic_id] Merge result missing — Ralph will verify and may retry on ${LOOP_BRANCH}"
1535
+ echo "[$epic_id] PENDING MERGE VERIFICATION (missing team lead merge result artifact) — $(date)" >> "$PROGRESS_FILE"
1444
1536
  fi
1445
1537
  elif [ "$passed_stories" -gt 0 ]; then
1446
1538
  echo ""
1447
1539
  echo " [$epic_id] PARTIAL — $passed_stories/$total_stories stories passed"
1448
- rjq set "$PRD_FILE" ".epics[$epic_index].status" '"partial"'
1540
+ rjq set "$PRD_FILE" ".epics[$epic_index].status" '"partial"' 2>/dev/null || echo " [WARN] Failed to set epic $epic_index status" >&2
1449
1541
  echo "[$epic_id] PARTIAL ($passed_stories/$total_stories) — $(date)" >> "$PROGRESS_FILE"
1450
1542
  else
1451
1543
  echo ""
1452
1544
  echo " [$epic_id] FAILED — 0/$total_stories stories passed"
1453
- rjq set "$PRD_FILE" ".epics[$epic_index].status" '"failed"'
1545
+ rjq set "$PRD_FILE" ".epics[$epic_index].status" '"failed"' 2>/dev/null || echo " [WARN] Failed to set epic $epic_index status" >&2
1454
1546
  FAILED=$((FAILED + 1))
1455
1547
  echo "[$epic_id] FAILED (0/$total_stories) — $(date)" >> "$PROGRESS_FILE"
1456
1548
  fi
@@ -1500,6 +1592,31 @@ read_epic_merge_result_field() {
1500
1592
  rjq read "$result_file" "$field_path" "$default_value"
1501
1593
  }
1502
1594
 
1595
+ write_epic_merge_result_file() {
1596
+ local epic_id="$1"
1597
+ local status="$2"
1598
+ local mode="$3"
1599
+ local details="$4"
1600
+ local result_file="${STATE_DIR}/merge-${epic_id}.json"
1601
+ local tmp_file
1602
+ tmp_file=$(mktemp "${STATE_DIR}/.merge-${epic_id}.json.XXXXXX")
1603
+
1604
+ node - "$tmp_file" "$epic_id" "$status" "$mode" "$details" <<'NODE'
1605
+ const fs = require('fs');
1606
+ const [filePath, epicId, status, mode, details] = process.argv.slice(2);
1607
+ const payload = {
1608
+ epicId,
1609
+ status,
1610
+ mode,
1611
+ details,
1612
+ timestamp: new Date().toISOString(),
1613
+ };
1614
+ fs.writeFileSync(filePath, `${JSON.stringify(payload, null, 2)}\n`);
1615
+ NODE
1616
+
1617
+ mv "$tmp_file" "$result_file"
1618
+ }
1619
+
1503
1620
  delete_epic_branch() {
1504
1621
  local epic_id="$1"
1505
1622
  local branch_name
@@ -1532,7 +1649,7 @@ NODE
1532
1649
 
1533
1650
  read_epic_prd_passed() {
1534
1651
  local epic_index="$1"
1535
- rjq count-where "$PRD_FILE" ".epics[$epic_index].userStories" "passes=true"
1652
+ rjq count-where "$PRD_FILE" ".epics[$epic_index].userStories" "passes=true" 2>/dev/null || echo 0
1536
1653
  }
1537
1654
 
1538
1655
  project_state_to_prd() {
@@ -1580,26 +1697,36 @@ NODE
1580
1697
 
1581
1698
  # spawn_epic_bg: create worktree, build prompt, and run team lead in the background.
1582
1699
  # Sets LAST_SPAWN_PID to the background PID.
1583
- # Callers must wait on that PID and then call cleanup_epic_worktree + process_epic_result.
1700
+ # Callers must wait on that PID and then call cleanup_epic_workspace + process_epic_result.
1584
1701
  spawn_epic_bg() {
1585
1702
  local EPIC_INDEX="$1"
1586
1703
  local EPIC_ID
1587
- EPIC_ID=$(rjq read "$PRD_FILE" ".epics[$EPIC_INDEX].id")
1704
+ EPIC_ID=$(rjq read "$PRD_FILE" ".epics[$EPIC_INDEX].id" 2>/dev/null) || {
1705
+ echo " [ERROR] Cannot read epic id for index $EPIC_INDEX — skipping spawn" >&2
1706
+ LAST_SPAWN_PID=0
1707
+ LAST_SPAWN_LOG="/dev/null"
1708
+ return 1
1709
+ }
1588
1710
  local EPIC_TITLE
1589
- EPIC_TITLE=$(rjq read "$PRD_FILE" ".epics[$EPIC_INDEX].title")
1711
+ EPIC_TITLE=$(rjq read "$PRD_FILE" ".epics[$EPIC_INDEX].title" 2>/dev/null) || EPIC_TITLE="(unknown)"
1590
1712
  local EPIC_JSON
1591
- EPIC_JSON=$(rjq read "$PRD_FILE" ".epics[$EPIC_INDEX]")
1713
+ EPIC_JSON=$(rjq read "$PRD_FILE" ".epics[$EPIC_INDEX]" 2>/dev/null) || {
1714
+ echo " [ERROR] Cannot read epic JSON for $EPIC_ID — skipping spawn" >&2
1715
+ LAST_SPAWN_PID=0
1716
+ LAST_SPAWN_LOG="/dev/null"
1717
+ return 1
1718
+ }
1592
1719
  local EPIC_PLANNED
1593
- EPIC_PLANNED=$(rjq read "$PRD_FILE" ".epics[$EPIC_INDEX].planned" "false")
1720
+ EPIC_PLANNED=$(rjq read "$PRD_FILE" ".epics[$EPIC_INDEX].planned" "false" 2>/dev/null) || EPIC_PLANNED="false"
1594
1721
  local PENDING_STORIES_JSON
1595
- PENDING_STORIES_JSON=$(rjq read "$PRD_FILE" ".epics[$EPIC_INDEX].userStories" | \
1596
- node -e 'const fs=require("fs"); const stories=JSON.parse(fs.readFileSync(0,"utf8")); process.stdout.write(JSON.stringify(stories.filter(s => s.passes !== true)));')
1722
+ PENDING_STORIES_JSON=$(rjq read "$PRD_FILE" ".epics[$EPIC_INDEX].userStories" 2>/dev/null | \
1723
+ node -e 'const fs=require("fs"); const stories=JSON.parse(fs.readFileSync(0,"utf8")); process.stdout.write(JSON.stringify(stories.filter(s => s.passes !== true)));') || PENDING_STORIES_JSON="[]"
1597
1724
 
1598
1725
  local EPIC_LOG="${LOGS_DIR}/epic-${EPIC_ID}-$(date +%s).log"
1599
1726
 
1600
- # Create isolated worktree for this epic
1727
+ # Create or reuse the workspace for this epic.
1601
1728
  local WORKTREE_PATH
1602
- WORKTREE_PATH=$(create_epic_worktree "$EPIC_ID")
1729
+ WORKTREE_PATH=$(prepare_epic_workspace "$EPIC_ID")
1603
1730
  local WORKTREE_ABS_PATH
1604
1731
  WORKTREE_ABS_PATH="$WORKTREE_PATH"
1605
1732
  local EPIC_BRANCH
@@ -1613,11 +1740,30 @@ spawn_epic_bg() {
1613
1740
  if [ -f "$WORKTREE_PLAN_FILE" ]; then
1614
1741
  WORKTREE_PLAN_EXISTS="true"
1615
1742
  fi
1743
+ local MERGE_RESPONSIBILITY
1744
+ MERGE_RESPONSIBILITY=$(cat <<EOF
1745
+ - If all stories pass, this Team Lead session owns the merge attempt before exiting.
1746
+ - Loop branch to merge into: ${LOOP_BRANCH}
1747
+ - Source epic branch: ${EPIC_BRANCH}
1748
+ - Repository root for the merge attempt: ${ROOT_DIR}
1749
+ - Write the final merge result artifact to: ${WORKTREE_MERGE_RESULT_FILE}
1750
+ - The merge result artifact must be valid JSON with fields: epicId, status, mode, details, timestamp.
1751
+ - Allowed status values: merged, merge-failed.
1752
+ - Allowed mode values: clean, projected-prd, conflict-resolved, unknown.
1753
+ - When all stories pass, do not print DONE until after you have attempted the merge and written the merge result artifact.
1754
+ - During the merge attempt you may operate in the repository root path above even though normal implementation work stays inside the epic workspace.
1755
+ - If the merge does not complete in this session, Ralph will verify the result and may attempt a scripted fallback merge afterward.
1756
+ EOF
1757
+ )
1616
1758
 
1617
1759
  init_epic_state_file "$EPIC_ID" "$EPIC_INDEX"
1618
1760
  reset_epic_merge_result_file "$EPIC_ID"
1619
1761
 
1620
- echo " Spawning [$EPIC_ID] in worktree $WORKTREE_PATH"
1762
+ if use_dedicated_epic_worktrees; then
1763
+ echo " Spawning [$EPIC_ID] in worktree $WORKTREE_PATH"
1764
+ else
1765
+ echo " Spawning [$EPIC_ID] on branch ${EPIC_BRANCH} in loop worktree $WORKTREE_PATH"
1766
+ fi
1621
1767
 
1622
1768
  local TEAM_LEAD_POLICY
1623
1769
  TEAM_LEAD_POLICY="$(cat "$TEAM_LEAD_POLICY_FILE")"
@@ -1671,7 +1817,22 @@ merge_wave() {
1671
1817
  local merge_failures=0
1672
1818
  local target_branch="$LOOP_BRANCH"
1673
1819
 
1674
- if [ "$(git branch --show-current 2>/dev/null || echo "")" != "$target_branch" ]; then
1820
+ local current_branch=""
1821
+ current_branch=$(git branch --show-current 2>/dev/null || echo "")
1822
+ if [ -n "$current_branch" ] && [ "$current_branch" != "$target_branch" ]; then
1823
+ local current_branch_dirty=""
1824
+ current_branch_dirty=$(git status --porcelain 2>/dev/null || true)
1825
+ if [ -n "$current_branch_dirty" ]; then
1826
+ git add -A
1827
+ unstage_runtime_artifacts
1828
+ if git commit -m "chore: checkpoint ${current_branch} before scripted merge" >/dev/null 2>&1; then
1829
+ echo " [${current_branch}] Auto-committed dirty branch before scripted merge"
1830
+ echo "[${current_branch}] AUTO-COMMIT before scripted merge — $(date)" >> "$PROGRESS_FILE"
1831
+ fi
1832
+ fi
1833
+ fi
1834
+
1835
+ if [ "$current_branch" != "$target_branch" ]; then
1675
1836
  git checkout "$target_branch" >/dev/null 2>&1
1676
1837
  fi
1677
1838
 
@@ -1711,6 +1872,7 @@ merge_wave() {
1711
1872
  if [ -n "$epic_index" ]; then
1712
1873
  rjq set "$PRD_FILE" ".epics[$epic_index].status" '"completed"'
1713
1874
  fi
1875
+ write_epic_merge_result_file "$epic_id" "merged" "clean" "Scripted merge of ${branch_name} into ${target_branch}"
1714
1876
  echo " [$epic_id] Merge successful (clean)"
1715
1877
  echo "[$epic_id] MERGED (clean) — $(date)" >> "$PROGRESS_FILE"
1716
1878
  else
@@ -1728,6 +1890,7 @@ merge_wave() {
1728
1890
  echo "[$epic_id] MERGE FAILED (merge did not enter conflict state) — $(date)" >> "$PROGRESS_FILE"
1729
1891
  [ -n "$merge_error" ] && echo " [$epic_id] Working tree state:" && printf '%s\n' "$merge_error" | sed 's/^/ /'
1730
1892
  merge_failures=$((merge_failures + 1))
1893
+ write_epic_merge_result_file "$epic_id" "merge-failed" "unknown" "Scripted merge did not enter a merge state"
1731
1894
 
1732
1895
  if [ -n "$epic_index" ]; then
1733
1896
  rjq set "$PRD_FILE" ".epics[$epic_index].status" '"merge-failed"'
@@ -1748,6 +1911,7 @@ merge_wave() {
1748
1911
  if [ -n "$epic_index" ]; then
1749
1912
  rjq set "$PRD_FILE" ".epics[$epic_index].status" '"completed"'
1750
1913
  fi
1914
+ write_epic_merge_result_file "$epic_id" "merged" "projected-prd" "Scripted merge kept the projected prd.json from ${target_branch}"
1751
1915
  echo " [$epic_id] Merge successful (kept projected prd.json)"
1752
1916
  echo "[$epic_id] MERGED (projected prd.json) — $(date)" >> "$PROGRESS_FILE"
1753
1917
  git branch -d "${branch_name}" 2>/dev/null || true
@@ -1755,6 +1919,7 @@ merge_wave() {
1755
1919
  fi
1756
1920
 
1757
1921
  git merge --abort 2>/dev/null || true
1922
+ write_epic_merge_result_file "$epic_id" "merge-failed" "unknown" "Scripted merge left conflicts in: ${conflicted_files}"
1758
1923
  echo " [$epic_id] Merge FAILED — conflicts remain; leaving ${branch_name} for a later clean retry"
1759
1924
  echo "[$epic_id] MERGE FAILED (conflicts remain, files: ${conflicted_files}) — $(date)" >> "$PROGRESS_FILE"
1760
1925
  merge_failures=$((merge_failures + 1))
@@ -2007,7 +2172,7 @@ WAVE_NUM=0
2007
2172
  # Count total stories across all epics for running estimate calculations
2008
2173
  TOTAL_STORIES=0
2009
2174
  for i in $(seq 0 $((TOTAL_EPICS - 1))); do
2010
- sc=$(rjq length "$PRD_FILE" ".epics[$i].userStories")
2175
+ sc=$(rjq length "$PRD_FILE" ".epics[$i].userStories" 2>/dev/null) || sc=0
2011
2176
  TOTAL_STORIES=$((TOTAL_STORIES + sc))
2012
2177
  done
2013
2178
 
@@ -2016,20 +2181,20 @@ while true; do
2016
2181
  WAVE_EPICS=()
2017
2182
 
2018
2183
  for EPIC_INDEX in $(seq 0 $((TOTAL_EPICS - 1))); do
2019
- EPIC_STATUS=$(rjq read "$PRD_FILE" ".epics[$EPIC_INDEX].status" "pending")
2184
+ EPIC_STATUS=$(rjq read "$PRD_FILE" ".epics[$EPIC_INDEX].status" "pending" 2>/dev/null) || EPIC_STATUS="pending"
2020
2185
  [ "$EPIC_STATUS" != "pending" ] && continue
2021
2186
 
2022
2187
  # Check all dependencies
2023
2188
  ALL_DEPS_MET=true
2024
- DEPS=$(rjq list "$PRD_FILE" ".epics[$EPIC_INDEX].dependsOn")
2189
+ DEPS=$(rjq list "$PRD_FILE" ".epics[$EPIC_INDEX].dependsOn" 2>/dev/null) || DEPS=""
2025
2190
  for DEP in $DEPS; do
2026
- DEP_STATUS=$(rjq read-where "$PRD_FILE" .epics id "$DEP" status "pending")
2191
+ DEP_STATUS=$(rjq read-where "$PRD_FILE" .epics id "$DEP" status "pending" 2>/dev/null) || DEP_STATUS="pending"
2027
2192
  if [ "$DEP_STATUS" = "failed" ] || [ "$DEP_STATUS" = "partial" ] || [ "$DEP_STATUS" = "merge-failed" ]; then
2028
2193
  # Dependency failed — skip this epic permanently
2029
- EPIC_ID=$(rjq read "$PRD_FILE" ".epics[$EPIC_INDEX].id")
2030
- EPIC_TITLE=$(rjq read "$PRD_FILE" ".epics[$EPIC_INDEX].title")
2194
+ EPIC_ID=$(rjq read "$PRD_FILE" ".epics[$EPIC_INDEX].id" 2>/dev/null) || EPIC_ID="EPIC-???"
2195
+ EPIC_TITLE=$(rjq read "$PRD_FILE" ".epics[$EPIC_INDEX].title" 2>/dev/null) || EPIC_TITLE="(unknown)"
2031
2196
  echo " [$EPIC_ID] $EPIC_TITLE — skipped (dependency $DEP has status: $DEP_STATUS)"
2032
- rjq set "$PRD_FILE" ".epics[$EPIC_INDEX].status" '"failed"'
2197
+ rjq set "$PRD_FILE" ".epics[$EPIC_INDEX].status" '"failed"' 2>/dev/null || echo " [WARN] Failed to set epic $EPIC_INDEX status to failed" >&2
2033
2198
  FAILED=$((FAILED + 1))
2034
2199
  echo "[$EPIC_ID] SKIPPED (dependency $DEP failed) — $(date)" >> "$PROGRESS_FILE"
2035
2200
  ALL_DEPS_MET=false
@@ -2057,7 +2222,7 @@ while true; do
2057
2222
  if [ -n "$PARALLEL" ]; then
2058
2223
  echo " Wave $WAVE_NUM — ${#WAVE_EPICS[@]} epic(s), $PARALLEL at a time"
2059
2224
  else
2060
- REMAINING_EPICS=$(rjq count-where "$PRD_FILE" .epics "status=pending" --default pending)
2225
+ REMAINING_EPICS=$(rjq count-where "$PRD_FILE" .epics "status=pending" --default pending 2>/dev/null) || REMAINING_EPICS="?"
2061
2226
  echo " ${REMAINING_EPICS} epic(s) remaining to run sequentially"
2062
2227
  fi
2063
2228
  echo "========================================================"
@@ -2070,7 +2235,7 @@ while true; do
2070
2235
  echo "=== Run — $(date) ===" >> "$PROGRESS_FILE"
2071
2236
  fi
2072
2237
  for IDX in "${WAVE_EPICS[@]}"; do
2073
- W_EPIC_ID=$(rjq read "$PRD_FILE" ".epics[$IDX].id")
2238
+ W_EPIC_ID=$(rjq read "$PRD_FILE" ".epics[$IDX].id" 2>/dev/null) || W_EPIC_ID="EPIC-???"
2074
2239
  echo " $W_EPIC_ID" >> "$PROGRESS_FILE"
2075
2240
  done
2076
2241
 
@@ -2134,7 +2299,10 @@ while true; do
2134
2299
  now=$(date +%s)
2135
2300
  for slot in "${!active_pids[@]}"; do
2136
2301
  local finished_epic_id
2137
- finished_epic_id=$(rjq read "$PRD_FILE" ".epics[${active_indices[$slot]}].id")
2302
+ finished_epic_id=$(rjq read "$PRD_FILE" ".epics[${active_indices[$slot]}].id" 2>/dev/null) || {
2303
+ echo " [WARN] rjq failed reading epic id for index ${active_indices[$slot]} — skipping slot" >&2
2304
+ continue
2305
+ }
2138
2306
  local process_finished=false
2139
2307
 
2140
2308
  emit_new_log_output "$finished_epic_id" "${active_logs[$slot]}" "${active_log_lines[$slot]:-0}"
@@ -2149,7 +2317,7 @@ while true; do
2149
2317
  wait "${active_pids[$slot]}" 2>/dev/null || true
2150
2318
  # Check progress and retry if possible
2151
2319
  local _to_total _to_state_passed _to_prd_passed _to_passed
2152
- _to_total=$(rjq length "$PRD_FILE" ".epics[${active_indices[$slot]}].userStories")
2320
+ _to_total=$(rjq length "$PRD_FILE" ".epics[${active_indices[$slot]}].userStories" 2>/dev/null) || _to_total=0
2153
2321
  _to_state_passed=$(read_epic_state_passed "$finished_epic_id")
2154
2322
  _to_prd_passed=$(read_epic_prd_passed "${active_indices[$slot]}")
2155
2323
  _to_passed="$_to_state_passed"
@@ -2161,16 +2329,21 @@ while true; do
2161
2329
  echo " [$finished_epic_id] Timeout with $_to_passed/$_to_total passed — retry $((_to_retry_count + 1))/$MAX_CRASH_RETRIES"
2162
2330
  echo "[$finished_epic_id] TIMEOUT RETRY $((_to_retry_count + 1))/$MAX_CRASH_RETRIES ($_to_passed/$_to_total passed) — $(date)" >> "$PROGRESS_FILE"
2163
2331
  project_state_to_prd "$finished_epic_id" || true
2164
- cleanup_epic_worktree "$finished_epic_id"
2165
- spawn_epic_bg "${active_indices[$slot]}"
2166
- active_pids[$slot]="$LAST_SPAWN_PID"
2167
- active_start_times[$slot]="$(date +%s)"
2168
- active_logs[$slot]="$LAST_SPAWN_LOG"
2169
- active_log_lines[$slot]="0"
2170
- continue
2332
+ cleanup_epic_workspace "$finished_epic_id"
2333
+ if spawn_epic_bg "${active_indices[$slot]}"; then
2334
+ active_pids[$slot]="$LAST_SPAWN_PID"
2335
+ active_start_times[$slot]="$(date +%s)"
2336
+ active_logs[$slot]="$LAST_SPAWN_LOG"
2337
+ active_log_lines[$slot]="0"
2338
+ continue
2339
+ fi
2340
+ echo " [$finished_epic_id] Retry spawn failed — treating as timeout failure" >&2
2171
2341
  fi
2172
2342
  project_state_to_prd "$finished_epic_id" || true
2173
- cleanup_epic_worktree "$finished_epic_id"
2343
+ cleanup_epic_workspace "$finished_epic_id"
2344
+ if ! use_dedicated_epic_worktrees; then
2345
+ project_state_to_prd "$finished_epic_id" || true
2346
+ fi
2174
2347
  echo "TIMEOUT: Epic exceeded ${EPIC_TIMEOUT}s limit" >> "${active_logs[$slot]}"
2175
2348
  # Log timeout-specific message before generic result
2176
2349
  echo "[$finished_epic_id] FAILED (epic timeout after ${EPIC_TIMEOUT}s) — $(date)" >> "$PROGRESS_FILE"
@@ -2207,7 +2380,7 @@ while true; do
2207
2380
  wait "${active_pids[$slot]}" 2>/dev/null || true
2208
2381
  # Check progress and retry if possible
2209
2382
  local _it_total _it_state_passed _it_prd_passed _it_passed
2210
- _it_total=$(rjq length "$PRD_FILE" ".epics[${active_indices[$slot]}].userStories")
2383
+ _it_total=$(rjq length "$PRD_FILE" ".epics[${active_indices[$slot]}].userStories" 2>/dev/null) || _it_total=0
2211
2384
  _it_state_passed=$(read_epic_state_passed "$finished_epic_id")
2212
2385
  _it_prd_passed=$(read_epic_prd_passed "${active_indices[$slot]}")
2213
2386
  _it_passed="$_it_state_passed"
@@ -2219,16 +2392,21 @@ while true; do
2219
2392
  echo " [$finished_epic_id] Idle timeout with $_it_passed/$_it_total passed — retry $((_it_retry_count + 1))/$MAX_CRASH_RETRIES"
2220
2393
  echo "[$finished_epic_id] IDLE RETRY $((_it_retry_count + 1))/$MAX_CRASH_RETRIES ($_it_passed/$_it_total passed) — $(date)" >> "$PROGRESS_FILE"
2221
2394
  project_state_to_prd "$finished_epic_id" || true
2222
- cleanup_epic_worktree "$finished_epic_id"
2223
- spawn_epic_bg "${active_indices[$slot]}"
2224
- active_pids[$slot]="$LAST_SPAWN_PID"
2225
- active_start_times[$slot]="$(date +%s)"
2226
- active_logs[$slot]="$LAST_SPAWN_LOG"
2227
- active_log_lines[$slot]="0"
2228
- continue
2395
+ cleanup_epic_workspace "$finished_epic_id"
2396
+ if spawn_epic_bg "${active_indices[$slot]}"; then
2397
+ active_pids[$slot]="$LAST_SPAWN_PID"
2398
+ active_start_times[$slot]="$(date +%s)"
2399
+ active_logs[$slot]="$LAST_SPAWN_LOG"
2400
+ active_log_lines[$slot]="0"
2401
+ continue
2402
+ fi
2403
+ echo " [$finished_epic_id] Retry spawn failed — treating as idle timeout failure" >&2
2229
2404
  fi
2230
2405
  project_state_to_prd "$finished_epic_id" || true
2231
- cleanup_epic_worktree "$finished_epic_id"
2406
+ cleanup_epic_workspace "$finished_epic_id"
2407
+ if ! use_dedicated_epic_worktrees; then
2408
+ project_state_to_prd "$finished_epic_id" || true
2409
+ fi
2232
2410
  # Log idle-timeout-specific message before generic result
2233
2411
  echo "[$finished_epic_id] FAILED (idle timeout — no output for ${IDLE_TIMEOUT}s) — $(date)" >> "$PROGRESS_FILE"
2234
2412
  process_epic_result "${active_indices[$slot]}"
@@ -2251,7 +2429,7 @@ while true; do
2251
2429
  fi
2252
2430
 
2253
2431
  local total_s passed_s_state passed_s_prd passed_s
2254
- total_s=$(rjq length "$PRD_FILE" ".epics[${active_indices[$slot]}].userStories")
2432
+ total_s=$(rjq length "$PRD_FILE" ".epics[${active_indices[$slot]}].userStories" 2>/dev/null) || total_s=0
2255
2433
  passed_s_state=$(read_epic_state_passed "$finished_epic_id")
2256
2434
  passed_s_prd=$(read_epic_prd_passed "${active_indices[$slot]}")
2257
2435
  passed_s="$passed_s_state"
@@ -2268,6 +2446,13 @@ while true; do
2268
2446
  if [ "$all_done" = true ] && [ "$merge_recorded" = true ]; then
2269
2447
  epic_flow_complete=true
2270
2448
  fi
2449
+ local process_exit_complete=false
2450
+ if [ "$all_done" = true ]; then
2451
+ # Once all stories pass, accept a normal Team Lead exit even if the
2452
+ # merge result is still missing. Ralph will verify the merge result
2453
+ # and attempt a scripted fallback merge when needed.
2454
+ process_exit_complete=true
2455
+ fi
2271
2456
 
2272
2457
  if [ "$process_finished" = true ] || [ "$epic_flow_complete" = true ]; then
2273
2458
  # Only terminate an in-flight session early after the Team Lead has
@@ -2278,10 +2463,10 @@ while true; do
2278
2463
  fi
2279
2464
  wait "${active_pids[$slot]}" 2>/dev/null || true
2280
2465
 
2281
- # If the process exited before the epic reached full completion
2282
- # (stories passed plus merge result recorded), consider it a crash
2466
+ # If the process exited before the Team Lead session reached the
2467
+ # expected completion point for this run mode, consider it a crash
2283
2468
  # and retry when possible.
2284
- if [ "$epic_flow_complete" = false ]; then
2469
+ if [ "$process_exit_complete" = false ]; then
2285
2470
  local retry_count
2286
2471
  retry_count="$(get_crash_retry_count "$finished_epic_id")"
2287
2472
  if [ "$retry_count" -lt "$MAX_CRASH_RETRIES" ]; then
@@ -2290,14 +2475,16 @@ while true; do
2290
2475
  echo " [$finished_epic_id] CRASH DETECTED ($passed_s/$total_s passed) — retry $((retry_count + 1))/$MAX_CRASH_RETRIES"
2291
2476
  echo "[$finished_epic_id] CRASH RETRY $((retry_count + 1))/$MAX_CRASH_RETRIES ($passed_s/$total_s passed so far) — $(date)" >> "$PROGRESS_FILE"
2292
2477
  project_state_to_prd "$finished_epic_id" || true
2293
- cleanup_epic_worktree "$finished_epic_id"
2294
- spawn_epic_bg "${active_indices[$slot]}"
2295
- active_pids[$slot]="$LAST_SPAWN_PID"
2296
- active_start_times[$slot]="$(date +%s)"
2297
- active_logs[$slot]="$LAST_SPAWN_LOG"
2298
- active_log_lines[$slot]="0"
2299
- # Don't free slot — respawned epic reuses it. Continue polling.
2300
- continue
2478
+ cleanup_epic_workspace "$finished_epic_id"
2479
+ if spawn_epic_bg "${active_indices[$slot]}"; then
2480
+ active_pids[$slot]="$LAST_SPAWN_PID"
2481
+ active_start_times[$slot]="$(date +%s)"
2482
+ active_logs[$slot]="$LAST_SPAWN_LOG"
2483
+ active_log_lines[$slot]="0"
2484
+ # Don't free slot — respawned epic reuses it. Continue polling.
2485
+ continue
2486
+ fi
2487
+ echo " [$finished_epic_id] Retry spawn failed — treating as crash failure" >&2
2301
2488
  fi
2302
2489
  echo ""
2303
2490
  echo " [$finished_epic_id] CRASH — retries exhausted ($passed_s/$total_s stories passed)"
@@ -2317,11 +2504,17 @@ while true; do
2317
2504
  process_epic_result "${active_indices[$slot]}"
2318
2505
  # Track completed epics for merge_wave only when the Team Lead did not already merge.
2319
2506
  local post_status
2320
- post_status=$(rjq read "$PRD_FILE" ".epics[${active_indices[$slot]}].status" "pending")
2321
- if [ "$post_status" = "completed" ] && [ "$merge_status" != "merged" ]; then
2507
+ post_status=$(rjq read "$PRD_FILE" ".epics[${active_indices[$slot]}].status" "pending" 2>/dev/null) || post_status="pending"
2508
+ if [ "$post_status" = "completed" ] && [ "$merge_status" != "merged" ] && use_dedicated_epic_worktrees; then
2322
2509
  wave_completed_ids+=("$finished_epic_id")
2323
2510
  fi
2324
- cleanup_epic_worktree "$finished_epic_id"
2511
+
2512
+ if [ "$post_status" = "completed" ] && [ "$merge_status" != "merged" ] && ! use_dedicated_epic_worktrees; then
2513
+ merge_wave "$finished_epic_id" || true
2514
+ merge_status=$(read_epic_merge_result_field "$finished_epic_id" .status "" 2>/dev/null || true)
2515
+ fi
2516
+
2517
+ cleanup_epic_workspace "$finished_epic_id"
2325
2518
  if [ "$merge_status" = "merged" ]; then
2326
2519
  delete_epic_branch "$finished_epic_id"
2327
2520
  fi
@@ -2354,10 +2547,10 @@ while true; do
2354
2547
  break
2355
2548
  fi
2356
2549
 
2357
- EPIC_STATUS=$(rjq read "$PRD_FILE" ".epics[$EPIC_INDEX].status" "pending")
2550
+ EPIC_STATUS=$(rjq read "$PRD_FILE" ".epics[$EPIC_INDEX].status" "pending" 2>/dev/null) || EPIC_STATUS="pending"
2358
2551
  if [ "$EPIC_STATUS" = "completed" ]; then
2359
- local_epic_id=$(rjq read "$PRD_FILE" ".epics[$EPIC_INDEX].id")
2360
- local_epic_title=$(rjq read "$PRD_FILE" ".epics[$EPIC_INDEX].title")
2552
+ local_epic_id=$(rjq read "$PRD_FILE" ".epics[$EPIC_INDEX].id" 2>/dev/null) || local_epic_id="EPIC-???"
2553
+ local_epic_title=$(rjq read "$PRD_FILE" ".epics[$EPIC_INDEX].title" 2>/dev/null) || local_epic_title="(unknown)"
2361
2554
  echo " [$local_epic_id] $local_epic_title — already completed, skipping"
2362
2555
  COMPLETED=$((COMPLETED + 1))
2363
2556
  continue
@@ -2369,7 +2562,11 @@ while true; do
2369
2562
  done
2370
2563
 
2371
2564
  PROCESSED=$((PROCESSED + 1))
2372
- spawn_epic_bg "$EPIC_INDEX"
2565
+ if ! spawn_epic_bg "$EPIC_INDEX"; then
2566
+ echo " [WARN] Failed to spawn epic at index $EPIC_INDEX — skipping" >&2
2567
+ FAILED=$((FAILED + 1))
2568
+ continue
2569
+ fi
2373
2570
  active_pids+=("$LAST_SPAWN_PID")
2374
2571
  active_indices+=("$EPIC_INDEX")
2375
2572
  active_start_times+=("$(date +%s)")
@@ -2385,7 +2582,7 @@ while true; do
2385
2582
 
2386
2583
  # Merge completed epic branches back to starting branch
2387
2584
  if [ ${#wave_completed_ids[@]} -gt 0 ]; then
2388
- merge_wave "${wave_completed_ids[@]}"
2585
+ merge_wave "${wave_completed_ids[@]}" || true
2389
2586
  fi
2390
2587
 
2391
2588
  # If we hit --max-epics mid-wave, stop processing further waves