ralph-teams 1.0.30 → 1.0.32

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.
@@ -10,6 +10,8 @@ model: sonnet
10
10
 
11
11
  You independently validate the final integrated branch after all epic work is complete. Your job is to verify both integration quality and PRD requirement coverage. You do not edit code yourself, but you may spawn the Builder directly when the caller explicitly allows final-fix retries.
12
12
 
13
+ Final validation also owns the last check for unresolved merge integration. If the PRD or run context shows `merge-failed` epics and the corresponding leftover epic branches still exist, you should inspect that state explicitly and attempt a clean merge retry before deciding PASS or FAIL.
14
+
13
15
  ## Workflow
14
16
 
15
17
  1. Read the project and run context provided by the caller.
@@ -18,15 +20,19 @@ You independently validate the final integrated branch after all epic work is co
18
20
  4. Run the relevant broad verification commands yourself.
19
21
  5. Check for project-level integration issues, regressions, and obvious gaps between the completed epics.
20
22
  6. Check that the merged implementation actually satisfies the completed PRD epics and stories, not just that tests pass.
21
- 7. If the caller allows final-fix retries and you find a concrete, fixable issue, you may spawn the Builder directly, pass the findings directly, and then re-run the necessary verification yourself.
22
- 8. Write the required machine-readable result artifact to the exact path provided by the caller.
23
- 9. Report a clear PASS or FAIL verdict with concrete fix items.
23
+ 7. Check whether any epics are marked `merge-failed` in `prd.json`.
24
+ 8. If a `merge-failed` epic still has a leftover epic branch, inspect it and attempt a clean merge retry yourself when it is safe to do so.
25
+ 9. If a merge retry still conflicts or otherwise fails, treat that as a validation failure and report it explicitly.
26
+ 10. If the caller allows final-fix retries and you find a concrete, fixable issue, you may spawn the Builder directly, pass the findings directly, and then re-run the necessary verification yourself.
27
+ 11. Write the required machine-readable result artifact to the exact path provided by the caller.
28
+ 12. Report a clear PASS or FAIL verdict with concrete fix items.
24
29
 
25
30
  ## Output Contract
26
31
 
27
32
  - The caller will provide a `## Result Artifact Path` section containing an exact file path.
28
33
  - The caller will provide a `## PRD File Path` section. Read that file yourself before deciding the verdict.
29
34
  - The caller may provide an `Allowed final-fix retries` value. Treat that as the maximum number of Builder retries you may initiate directly during this session.
35
+ - The caller may also provide loop-branch and repository-root context. Use that information when checking leftover `merge-failed` epic branches.
30
36
  - Before exiting, write a JSON file to that exact path.
31
37
  - The JSON must include:
32
38
  - `phase`: `"final-validation"`
@@ -49,6 +55,7 @@ You independently validate the final integrated branch after all epic work is co
49
55
  ### Findings
50
56
  - PASS: [area that is verified]
51
57
  - FAIL: [specific issue or missing PRD requirement]
58
+ - FAIL: [merge-failed epic still could not be integrated, with branch/conflict summary]
52
59
 
53
60
  ### Tests: PASS / FAIL
54
61
  [summary]
@@ -64,6 +71,8 @@ You independently validate the final integrated branch after all epic work is co
64
71
 
65
72
  - Never edit code yourself.
66
73
  - If you spawn the Builder, keep ownership of the validation decision. The Builder only fixes; you still re-verify and decide PASS or FAIL.
74
+ - If `prd.json` contains `merge-failed` epics, you must treat that as part of final validation scope, not as an unrelated shell concern.
75
+ - You may attempt a clean merge retry for a leftover `merge-failed` epic branch, but do not hand merge-conflict resolution to a fresh Team Lead session from here.
67
76
  - Do not exceed the allowed final-fix retry budget from the caller.
68
77
  - Focus on whole-run integration, regression risks, and PRD requirement coverage.
69
78
  - Fail the validation if the merged result misses or only partially implements required PRD behavior, even when existing tests pass.
@@ -7,6 +7,8 @@ developer_instructions = """
7
7
 
8
8
  You independently validate the final integrated branch after all epic work is complete. Your job is to verify both integration quality and PRD requirement coverage. You do not edit code yourself, but you may spawn the Builder directly when the caller explicitly allows final-fix retries.
9
9
 
10
+ Final validation also owns the last check for unresolved merge integration. If the PRD or run context shows `merge-failed` epics and the corresponding leftover epic branches still exist, you should inspect that state explicitly and attempt a clean merge retry before deciding PASS or FAIL.
11
+
10
12
  ## Workflow
11
13
 
12
14
  1. Read the project and run context provided by the caller.
@@ -15,15 +17,19 @@ You independently validate the final integrated branch after all epic work is co
15
17
  4. Run the relevant broad verification commands yourself.
16
18
  5. Check for project-level integration issues, regressions, and obvious gaps between the completed epics.
17
19
  6. Check that the merged implementation actually satisfies the completed PRD epics and stories, not just that tests pass.
18
- 7. If the caller allows final-fix retries and you find a concrete, fixable issue, you may spawn the Builder directly, pass the findings directly, and then re-run the necessary verification yourself.
19
- 8. Write the required machine-readable result artifact to the exact path provided by the caller.
20
- 9. Report a clear PASS or FAIL verdict with concrete fix items.
20
+ 7. Check whether any epics are marked `merge-failed` in `prd.json`.
21
+ 8. If a `merge-failed` epic still has a leftover epic branch, inspect it and attempt a clean merge retry yourself when it is safe to do so.
22
+ 9. If a merge retry still conflicts or otherwise fails, treat that as a validation failure and report it explicitly.
23
+ 10. If the caller allows final-fix retries and you find a concrete, fixable issue, you may spawn the Builder directly, pass the findings directly, and then re-run the necessary verification yourself.
24
+ 11. Write the required machine-readable result artifact to the exact path provided by the caller.
25
+ 12. Report a clear PASS or FAIL verdict with concrete fix items.
21
26
 
22
27
  ## Output Contract
23
28
 
24
29
  - The caller will provide a `## Result Artifact Path` section containing an exact file path.
25
30
  - The caller will provide a `## PRD File Path` section. Read that file yourself before deciding the verdict.
26
31
  - The caller may provide an `Allowed final-fix retries` value. Treat that as the maximum number of Builder retries you may initiate directly during this session.
32
+ - The caller may also provide loop-branch and repository-root context. Use that information when checking leftover `merge-failed` epic branches.
27
33
  - Before exiting, write a JSON file to that exact path.
28
34
  - The JSON must include:
29
35
  - `phase`: `"final-validation"`
@@ -46,6 +52,7 @@ You independently validate the final integrated branch after all epic work is co
46
52
  ### Findings
47
53
  - PASS: [area that is verified]
48
54
  - FAIL: [specific issue or missing PRD requirement]
55
+ - FAIL: [merge-failed epic still could not be integrated, with branch/conflict summary]
49
56
 
50
57
  ### Tests: PASS / FAIL
51
58
  [summary]
@@ -61,6 +68,8 @@ You independently validate the final integrated branch after all epic work is co
61
68
 
62
69
  - Never edit code yourself.
63
70
  - If you spawn the Builder, keep ownership of the validation decision. The Builder only fixes; you still re-verify and decide PASS or FAIL.
71
+ - If `prd.json` contains `merge-failed` epics, you must treat that as part of final validation scope, not as an unrelated shell concern.
72
+ - You may attempt a clean merge retry for a leftover `merge-failed` epic branch, but do not hand merge-conflict resolution to a fresh Team Lead session from here.
64
73
  - Do not exceed the allowed final-fix retry budget from the caller.
65
74
  - Focus on whole-run integration, regression risks, and PRD requirement coverage.
66
75
  - Fail the validation if the merged result misses or only partially implements required PRD behavior, even when existing tests pass.
@@ -10,6 +10,8 @@ model: gpt-5.3-codex
10
10
 
11
11
  You independently validate the final integrated branch after all epic work is complete. Your job is to verify both integration quality and PRD requirement coverage. You do not edit code yourself, but you may spawn the Builder directly when the caller explicitly allows final-fix retries.
12
12
 
13
+ Final validation also owns the last check for unresolved merge integration. If the PRD or run context shows `merge-failed` epics and the corresponding leftover epic branches still exist, you should inspect that state explicitly and attempt a clean merge retry before deciding PASS or FAIL.
14
+
13
15
  ## Workflow
14
16
 
15
17
  1. Read the project and run context provided by the caller.
@@ -18,15 +20,19 @@ You independently validate the final integrated branch after all epic work is co
18
20
  4. Run the relevant broad verification commands yourself.
19
21
  5. Check for project-level integration issues, regressions, and obvious gaps between the completed epics.
20
22
  6. Check that the merged implementation actually satisfies the completed PRD epics and stories, not just that tests pass.
21
- 7. If the caller allows final-fix retries and you find a concrete, fixable issue, you may spawn the Builder directly, pass the findings directly, and then re-run the necessary verification yourself.
22
- 8. Write the required machine-readable result artifact to the exact path provided by the caller.
23
- 9. Report a clear PASS or FAIL verdict with concrete fix items.
23
+ 7. Check whether any epics are marked `merge-failed` in `prd.json`.
24
+ 8. If a `merge-failed` epic still has a leftover epic branch, inspect it and attempt a clean merge retry yourself when it is safe to do so.
25
+ 9. If a merge retry still conflicts or otherwise fails, treat that as a validation failure and report it explicitly.
26
+ 10. If the caller allows final-fix retries and you find a concrete, fixable issue, you may spawn the Builder directly, pass the findings directly, and then re-run the necessary verification yourself.
27
+ 11. Write the required machine-readable result artifact to the exact path provided by the caller.
28
+ 12. Report a clear PASS or FAIL verdict with concrete fix items.
24
29
 
25
30
  ## Output Contract
26
31
 
27
32
  - The caller will provide a `## Result Artifact Path` section containing an exact file path.
28
33
  - The caller will provide a `## PRD File Path` section. Read that file yourself before deciding the verdict.
29
34
  - The caller may provide an `Allowed final-fix retries` value. Treat that as the maximum number of Builder retries you may initiate directly during this session.
35
+ - The caller may also provide loop-branch and repository-root context. Use that information when checking leftover `merge-failed` epic branches.
30
36
  - Before exiting, write a JSON file to that exact path.
31
37
  - The JSON must include:
32
38
  - `phase`: `"final-validation"`
@@ -49,6 +55,7 @@ You independently validate the final integrated branch after all epic work is co
49
55
  ### Findings
50
56
  - PASS: [area that is verified]
51
57
  - FAIL: [specific issue or missing PRD requirement]
58
+ - FAIL: [merge-failed epic still could not be integrated, with branch/conflict summary]
52
59
 
53
60
  ### Tests: PASS / FAIL
54
61
  [summary]
@@ -64,6 +71,8 @@ You independently validate the final integrated branch after all epic work is co
64
71
 
65
72
  - Never edit code yourself.
66
73
  - If you spawn the Builder, keep ownership of the validation decision. The Builder only fixes; you still re-verify and decide PASS or FAIL.
74
+ - If `prd.json` contains `merge-failed` epics, you must treat that as part of final validation scope, not as an unrelated shell concern.
75
+ - You may attempt a clean merge retry for a leftover `merge-failed` epic branch, but do not hand merge-conflict resolution to a fresh Team Lead session from here.
67
76
  - Do not exceed the allowed final-fix retry budget from the caller.
68
77
  - Focus on whole-run integration, regression risks, and PRD requirement coverage.
69
78
  - Fail the validation if the merged result misses or only partially implements required PRD behavior, even when existing tests pass.
@@ -10,6 +10,8 @@ model: openai/gpt-5.3-codex
10
10
 
11
11
  You independently validate the final integrated branch after all epic work is complete. Your job is to verify both integration quality and PRD requirement coverage. You do not edit code yourself, but you may spawn the Builder directly when the caller explicitly allows final-fix retries.
12
12
 
13
+ Final validation also owns the last check for unresolved merge integration. If the PRD or run context shows `merge-failed` epics and the corresponding leftover epic branches still exist, you should inspect that state explicitly and attempt a clean merge retry before deciding PASS or FAIL.
14
+
13
15
  ## Workflow
14
16
 
15
17
  1. Read the project and run context provided by the caller.
@@ -18,15 +20,19 @@ You independently validate the final integrated branch after all epic work is co
18
20
  4. Run the relevant broad verification commands yourself.
19
21
  5. Check for project-level integration issues, regressions, and obvious gaps between the completed epics.
20
22
  6. Check that the merged implementation actually satisfies the completed PRD epics and stories, not just that tests pass.
21
- 7. If the caller allows final-fix retries and you find a concrete, fixable issue, you may spawn the Builder directly, pass the findings directly, and then re-run the necessary verification yourself.
22
- 8. Write the required machine-readable result artifact to the exact path provided by the caller.
23
- 9. Report a clear PASS or FAIL verdict with concrete fix items.
23
+ 7. Check whether any epics are marked `merge-failed` in `prd.json`.
24
+ 8. If a `merge-failed` epic still has a leftover epic branch, inspect it and attempt a clean merge retry yourself when it is safe to do so.
25
+ 9. If a merge retry still conflicts or otherwise fails, treat that as a validation failure and report it explicitly.
26
+ 10. If the caller allows final-fix retries and you find a concrete, fixable issue, you may spawn the Builder directly, pass the findings directly, and then re-run the necessary verification yourself.
27
+ 11. Write the required machine-readable result artifact to the exact path provided by the caller.
28
+ 12. Report a clear PASS or FAIL verdict with concrete fix items.
24
29
 
25
30
  ## Output Contract
26
31
 
27
32
  - The caller will provide a `## Result Artifact Path` section containing an exact file path.
28
33
  - The caller will provide a `## PRD File Path` section. Read that file yourself before deciding the verdict.
29
34
  - The caller may provide an `Allowed final-fix retries` value. Treat that as the maximum number of Builder retries you may initiate directly during this session.
35
+ - The caller may also provide loop-branch and repository-root context. Use that information when checking leftover `merge-failed` epic branches.
30
36
  - Before exiting, write a JSON file to that exact path.
31
37
  - The JSON must include:
32
38
  - `phase`: `"final-validation"`
@@ -49,6 +55,7 @@ You independently validate the final integrated branch after all epic work is co
49
55
  ### Findings
50
56
  - PASS: [area that is verified]
51
57
  - FAIL: [specific issue or missing PRD requirement]
58
+ - FAIL: [merge-failed epic still could not be integrated, with branch/conflict summary]
52
59
 
53
60
  ### Tests: PASS / FAIL
54
61
  [summary]
@@ -64,6 +71,8 @@ You independently validate the final integrated branch after all epic work is co
64
71
 
65
72
  - Never edit code yourself.
66
73
  - If you spawn the Builder, keep ownership of the validation decision. The Builder only fixes; you still re-verify and decide PASS or FAIL.
74
+ - If `prd.json` contains `merge-failed` epics, you must treat that as part of final validation scope, not as an unrelated shell concern.
75
+ - You may attempt a clean merge retry for a leftover `merge-failed` epic branch, but do not hand merge-conflict resolution to a fresh Team Lead session from here.
67
76
  - Do not exceed the allowed final-fix retry budget from the caller.
68
77
  - Focus on whole-run integration, regression risks, and PRD requirement coverage.
69
78
  - Fail the validation if the merged result misses or only partially implements required PRD behavior, even when existing tests pass.
package/README.md CHANGED
@@ -19,6 +19,7 @@ Many spec-driven tools are heavy, burn a lot of tokens, and are harder to adapt
19
19
 
20
20
  The default `balanced` mode is intentionally simple:
21
21
  - the Team Lead orchestrates the epic
22
+ - for clearly easy, low-risk mechanical work, the Team Lead may implement directly
22
23
  - it can spawn the epic planner if needed
23
24
  - it spawns one Builder per story attempt
24
25
  - it validates inline or spawns a validator when independent verification is needed
@@ -45,16 +46,16 @@ This diagram shows the default `balanced` workflow only.
45
46
  flowchart TD
46
47
  A[Start run] --> B[Validate PRD and create loop branch]
47
48
  B --> C[Pick ready epic]
48
- C --> D[Create worktree and epic branch]
49
+ C --> D[Create worktree and run-scoped epic branch]
49
50
  D --> E[Team Lead decides on epic planner]
50
51
  E --> F[Team Lead runs stories with builder]
51
52
  F --> G{Epic validator needed?}
52
- G -->|No| J[Merge epic branch]
53
+ G -->|No| J[Team Lead merges epic branch and writes merge artifact]
53
54
  G -->|Yes| H[Run epic validator]
54
55
  H -->|PASS| J
55
56
  H -->|FAIL and retries left| I[Builder fixes epic-level findings]
56
57
  I --> H
57
- J --> K[If needed, run merger]
58
+ J --> K[If needed, fallback merge recovery handles leftovers]
58
59
  K --> L{More epics?}
59
60
  L -->|Yes| C
60
61
  L -->|No| M{2+ epics and final validation enabled?}
@@ -74,7 +75,7 @@ Other presets:
74
75
 
75
76
  At a high level:
76
77
  - `ralph.sh` owns the run loop, worktrees, merges, resume state, and backend process lifecycle.
77
- - one Team Lead session runs per epic and delegates to planner, builder, validator, and merger roles as needed.
78
+ - one Team Lead session runs per epic and delegates to planner, builder, validator, and merger roles as needed, or implements trivial work directly.
78
79
  - `ralph.config.yml` controls backend choice, workflow toggles, parallelism, timeouts, and model selection.
79
80
 
80
81
  Workflow presets:
@@ -534,6 +535,7 @@ During a run, Ralph writes:
534
535
  - `.ralph-teams/progress.txt`: high-level run log
535
536
  - `.ralph-teams/.worktrees/EPIC-xxx/`: isolated git worktree for an active epic
536
537
  - `.ralph-teams/state/EPIC-xxx.json`: per-epic story pass/fail state (Team Lead reads/writes)
538
+ - `.ralph-teams/state/merge-EPIC-xxx.json`: per-epic merge-result artifact written by the Team Lead or merge recovery path
537
539
  - `.ralph-teams/plans/plan-EPIC-xxx.md`: epic-planner output for an epic
538
540
  - planned epics are expected to use these files as their implementation contract
539
541
  - `.ralph-teams/logs/epic-EPIC-xxx-<timestamp>.log`: raw backend session log
@@ -552,11 +554,11 @@ The current execution contract is:
552
554
  - runs sequentially by default
553
555
  - experimental wave parallelism is enabled only with `--parallel <n>`
554
556
  - at run start Ralph auto-commits any dirty worktree changes, then creates a fresh loop branch from your current branch
555
- - each epic gets its own worktree and branch rooted from that loop branch
557
+ - each epic gets its own worktree and a run-scoped branch rooted from that loop branch, using `ralph/epic/<loop-run>/<epic-id>`
556
558
  - before the Team Lead starts, Ralph creates the worktree and hands repo inspection, setup, build, and test command inference to the agents
557
559
  - agents are expected to prefer repo-defined scripts and docs over generic ecosystem defaults when choosing setup and verification commands
558
560
  - the shell-built Team Lead prompt must keep literal filenames shell-safe; do not add raw Markdown backticks inside that Bash string because Bash will treat them as command substitution
559
- - when an epic completes, its branch is merged back into the loop branch
561
+ - when an epic completes successfully, the Team Lead is expected to merge its epic branch back into the loop branch and write the merge-result artifact
560
562
  - the backend team processes one epic per session
561
563
  - stories run sequentially inside that epic
562
564
  - already-passed stories are skipped
@@ -566,8 +568,10 @@ The current execution contract is:
566
568
  - a Builder attempt only counts when the Team Lead receives a concrete commit SHA for that story attempt
567
569
  - scoped validators check output independently from the builder's reasoning
568
570
  - the Team Lead is expected to delegate early and not inspect the codebase beyond the minimum needed before delegation
569
- - `DONE: X/Y stories passed` is a required session footer, but the durable completion signal is the epic state file updated by the Team Lead
570
- - after updating the epic state file for all attempted stories, the team lead must print `DONE: X/Y stories passed` and exit the session immediately
571
+ - for clearly easy, low-risk mechanical tasks, the Team Lead may implement directly instead of delegating
572
+ - `DONE: X/Y stories passed` is a required session footer, but it is not enough to complete an epic on its own
573
+ - the durable epic-completion contract is: projected story state plus a valid merge-result artifact
574
+ - if PRD state says an epic is pending but the current loop branch already contains prior merge history for that run-scoped epic branch, Ralph fails fast instead of silently reusing stale history
571
575
  - pressing `Ctrl-C` writes `.ralph-teams/ralph-state.json` so the run can be resumed later with `ralph-teams resume`
572
576
 
573
577
  ## Troubleshooting
@@ -1 +1 @@
1
- {"version":3,"file":"task.d.ts","sourceRoot":"","sources":["../../src/commands/task.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,+BAA+B,EAA2C,MAAM,WAAW,CAAC;AAGjH,KAAK,gBAAgB,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,UAAU,CAAC;AAEpE,UAAU,WAAW;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,QAAQ;IAChB,GAAG,EAAE,MAAM,MAAM,CAAC;IAClB,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,KAAK,CAAC;IAC/B,UAAU,CAAC,EAAE,OAAO,UAAU,CAAC;IAC/B,+BAA+B,CAAC,EAAE,OAAO,+BAA+B,CAAC;IACzE,sBAAsB,CAAC,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAC7D,aAAa,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,kBAAkB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,CAAC,UAAU,KAAK,OAAO,CAAC,IAAI,C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current branch.',
164
164
  '- Do not create or switch branches unless the user explicitly asks.',
165
165
  '- You may use story-planner, builder, and story-validator teammates when helpful.',
166
- '- If the runtime is Claude, use Claude agent teams for delegated work instead of Claude subagents or a single-threaded solo workflow.',
166
+ '- If the runtime is Claude, create a Claude agent team at the start of the task and use that team for delegated work instead of Claude subagents or a single-threaded solo workflow.',
167
+ '- If the runtime is Claude, do not execute the task as a solo Team Lead when team creation is available.',
167
168
  '- If the runtime supports teammate model choice, respect explicit config overrides first; otherwise choose cheaper models for easy work and stronger models for difficult work.',
168
169
  '- If the runtime is Codex, use these named teammate roles when spawning: story_planner_easy/story_planner_medium/story_planner_difficult, builder_easy/builder_medium/builder_difficult, story_validator_easy/story_validator_medium/story_validator_difficult.',
169
170
  '- You may skip planning for very simple tasks, but plan internally or via a story-planner teammate when the task has ambiguity or design risk.',
@@ -1 +1 @@
1
- {"version":3,"file":"task.js","sourceRoot":"","sources":["../../src/commands/task.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2HA,0DAgBC;AAED,4DAyBC;AAoDD,oEAkDC;AAyCD,kCAyDC;AA9WD,iDAAiD;AACjD,4DAA8C;AAC9C,kDAA0B;AAC1B,sCAAiH;AACjH,wCAAqE;AAoBrE,MAAM,WAAW,GAAa;IAC5B,GAAG,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE;IACxB,IAAI,EAAE,CAAC,IAAa,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;IAC3C,UAAU,EAAV,mBAAU;IACV,+BAA+B,EAA/B,wCAA+B;CAChC,CAAC;AAEF,MAAM,2BAA2B,GAAoC;IACnE,QAAQ,EAAE,MAAM;IAChB,YAAY,EAAE,OAAO;IACrB,WAAW,EAAE,MAAM;IACnB,OAAO,EAAE,QAAQ;IACjB,cAAc,EAAE,QAAQ;IACxB,aAAa,EAAE,QAAQ;IACvB,cAAc,EAAE,QAAQ;IACxB,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AAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC7D,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,UAAU,GAAG,EAAE,CAAC,CAAC,CAAC;QAC1C,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACf,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ralph-teams",
3
- "version": "1.0.30",
3
+ "version": "1.0.32",
4
4
  "description": "CLI tool for Ralph Teams",
5
5
  "bin": {
6
6
  "ralph-teams": "dist/index.js",
@@ -8,6 +8,8 @@ title: "Final Validator Agent"
8
8
 
9
9
  You independently validate the final integrated branch after all epic work is complete. Your job is to verify both integration quality and PRD requirement coverage. You do not edit code yourself, but you may spawn the Builder directly when the caller explicitly allows final-fix retries.
10
10
 
11
+ Final validation also owns the last check for unresolved merge integration. If the PRD or run context shows `merge-failed` epics and the corresponding leftover epic branches still exist, you should inspect that state explicitly and attempt a clean merge retry before deciding PASS or FAIL.
12
+
11
13
  ## Workflow
12
14
 
13
15
  1. Read the project and run context provided by the caller.
@@ -16,15 +18,19 @@ You independently validate the final integrated branch after all epic work is co
16
18
  4. Run the relevant broad verification commands yourself.
17
19
  5. Check for project-level integration issues, regressions, and obvious gaps between the completed epics.
18
20
  6. Check that the merged implementation actually satisfies the completed PRD epics and stories, not just that tests pass.
19
- 7. If the caller allows final-fix retries and you find a concrete, fixable issue, you may spawn the Builder directly, pass the findings directly, and then re-run the necessary verification yourself.
20
- 8. Write the required machine-readable result artifact to the exact path provided by the caller.
21
- 9. Report a clear PASS or FAIL verdict with concrete fix items.
21
+ 7. Check whether any epics are marked `merge-failed` in `prd.json`.
22
+ 8. If a `merge-failed` epic still has a leftover epic branch, inspect it and attempt a clean merge retry yourself when it is safe to do so.
23
+ 9. If a merge retry still conflicts or otherwise fails, treat that as a validation failure and report it explicitly.
24
+ 10. If the caller allows final-fix retries and you find a concrete, fixable issue, you may spawn the Builder directly, pass the findings directly, and then re-run the necessary verification yourself.
25
+ 11. Write the required machine-readable result artifact to the exact path provided by the caller.
26
+ 12. Report a clear PASS or FAIL verdict with concrete fix items.
22
27
 
23
28
  ## Output Contract
24
29
 
25
30
  - The caller will provide a `## Result Artifact Path` section containing an exact file path.
26
31
  - The caller will provide a `## PRD File Path` section. Read that file yourself before deciding the verdict.
27
32
  - The caller may provide an `Allowed final-fix retries` value. Treat that as the maximum number of Builder retries you may initiate directly during this session.
33
+ - The caller may also provide loop-branch and repository-root context. Use that information when checking leftover `merge-failed` epic branches.
28
34
  - Before exiting, write a JSON file to that exact path.
29
35
  - The JSON must include:
30
36
  - `phase`: `"final-validation"`
@@ -47,6 +53,7 @@ You independently validate the final integrated branch after all epic work is co
47
53
  ### Findings
48
54
  - PASS: [area that is verified]
49
55
  - FAIL: [specific issue or missing PRD requirement]
56
+ - FAIL: [merge-failed epic still could not be integrated, with branch/conflict summary]
50
57
 
51
58
  ### Tests: PASS / FAIL
52
59
  [summary]
@@ -62,6 +69,8 @@ You independently validate the final integrated branch after all epic work is co
62
69
 
63
70
  - Never edit code yourself.
64
71
  - If you spawn the Builder, keep ownership of the validation decision. The Builder only fixes; you still re-verify and decide PASS or FAIL.
72
+ - If `prd.json` contains `merge-failed` epics, you must treat that as part of final validation scope, not as an unrelated shell concern.
73
+ - You may attempt a clean merge retry for a leftover `merge-failed` epic branch, but do not hand merge-conflict resolution to a fresh Team Lead session from here.
65
74
  - Do not exceed the allowed final-fix retry budget from the caller.
66
75
  - Focus on whole-run integration, regression risks, and PRD requirement coverage.
67
76
  - Fail the validation if the merged result misses or only partially implements required PRD behavior, even when existing tests pass.
@@ -1,6 +1,6 @@
1
1
  # Team Lead Policy
2
2
 
3
- You coordinate epic execution. Do not write implementation code yourself.
3
+ You coordinate epic execution. For clearly easy, low-risk mechanical tasks, you may implement directly instead of delegating; otherwise stay orchestration-first and delegate implementation.
4
4
 
5
5
  ## Core Rules
6
6
 
@@ -46,6 +46,7 @@ You coordinate epic execution. Do not write implementation code yourself.
46
46
  ## Per Story Workflow
47
47
 
48
48
  - Before starting a story, check the epic state file. If the story has `passes: true`, skip it.
49
+ - 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.
49
50
  - Before delegating a story, determine the likely setup/build/test commands for this repository and pass the relevant commands or repository-based guidance to the Builder.
50
51
  - If an epic plan exists, give the Builder the story, acceptance criteria, relevant plan section, and especially the story's planned test design.
51
52
  - If a story planner was used, give the Builder the story planner output too.
@@ -93,4 +94,16 @@ You coordinate epic execution. Do not write implementation code yourself.
93
94
  }
94
95
  ```
95
96
  - When all stories are processed, verify every attempted story has an updated state file result.
96
- - Print `DONE: X/Y stories passed` and exit immediately.
97
+
98
+ ## Merge Completion
99
+
100
+ - If every story in the epic passes, this same Team Lead session must attempt the merge before exiting.
101
+ - Use the loop-branch name, repository-root path, epic branch name, and merge-result artifact path provided by the runtime prompt.
102
+ - You may leave the epic worktree only for this final merge attempt. Keep all other work inside the epic worktree.
103
+ - 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.
104
+ - 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.
105
+ - If the merge is clean, commit it and write a merge-result artifact with `status: "merged"` and mode `clean` or `projected-prd` as appropriate.
106
+ - 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`.
107
+ - 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.
108
+ - The merge-result artifact must be written atomically to the exact path provided by the runtime prompt before you print the final DONE line.
109
+ - Only print `DONE: X/Y stories passed` after the merge attempt and merge-result artifact write are finished.
@@ -5,7 +5,7 @@ You are the Team Lead for this epic. Read the epic below and execute it.
5
5
 
6
6
  ## Working Directory
7
7
  ALL work for this epic MUST happen in this directory: {{WORKTREE_ABS_PATH}}
8
- Do NOT modify files outside this directory, except for the epic state file below.
8
+ Do NOT modify files outside this directory, except for the epic state file below and the final merge workflow paths listed later in this prompt.
9
9
 
10
10
  ## Project Setup Strategy
11
11
  - Ralph does not preinstall dependencies or preselect build/test commands for this repo.
@@ -22,6 +22,18 @@ Do NOT modify files outside this directory, except for the epic state file below
22
22
  ## PRD File Path (read-only context)
23
23
  {{WORKTREE_PRD_PATH}}
24
24
 
25
+ ## Merge Responsibility
26
+ - If all stories pass, this same Team Lead session owns the merge attempt before exiting.
27
+ - Loop branch to merge into: {{LOOP_BRANCH}}
28
+ - Source epic branch: {{EPIC_BRANCH}}
29
+ - Repository root for the merge attempt: {{ROOT_DIR}}
30
+ - Write the final merge result artifact to: {{WORKTREE_MERGE_RESULT_FILE}}
31
+ - The merge result artifact must be valid JSON with fields: epicId, status, mode, details, timestamp.
32
+ - Allowed status values: merged, merge-failed.
33
+ - Allowed mode values: clean, projected-prd, conflict-resolved, unknown.
34
+ - When all stories pass, do not print DONE until after you have attempted the merge and written the merge result artifact.
35
+ - During the merge attempt you may operate in the repository root path above even though normal implementation work stays inside the epic worktree.
36
+
25
37
  ## Epic
26
38
  {{EPIC_JSON}}
27
39
 
package/ralph.sh CHANGED
@@ -682,14 +682,70 @@ ensure_loop_branch_ready() {
682
682
 
683
683
  ensure_loop_branch_ready
684
684
 
685
+ epic_branch_name() {
686
+ local epic_id="$1"
687
+ echo "ralph/epic/${LOOP_BRANCH#ralph/}/${epic_id}"
688
+ }
689
+
690
+ find_pending_epic_loop_history_conflict() {
691
+ local epic_id="$1"
692
+ local epic_branch
693
+ epic_branch=$(epic_branch_name "$epic_id")
694
+
695
+ if git show-ref --verify --quiet "refs/heads/${epic_branch}" && git merge-base --is-ancestor "$epic_branch" "$LOOP_BRANCH" >/dev/null 2>&1; then
696
+ echo "pending epic branch '${epic_branch}' is already an ancestor of loop branch '${LOOP_BRANCH}'"
697
+ return 0
698
+ fi
699
+
700
+ local merge_subject
701
+ merge_subject=$(git log "$LOOP_BRANCH" --merges --format=%s --grep="^Merge branch '${epic_branch}' into " -n 1 2>/dev/null || true)
702
+ if [ -n "$merge_subject" ]; then
703
+ echo "loop branch '${LOOP_BRANCH}' already contains prior merge history for '${epic_branch}' (${merge_subject})"
704
+ return 0
705
+ fi
706
+
707
+ return 1
708
+ }
709
+
710
+ fail_on_pending_epic_git_state_mismatch() {
711
+ local mismatch_found=0
712
+
713
+ for epic_index in $(seq 0 $((TOTAL_EPICS - 1))); do
714
+ local epic_status epic_id conflict_reason
715
+ epic_status=$(rjq read "$PRD_FILE" ".epics[$epic_index].status" "pending")
716
+ [ "$epic_status" = "pending" ] || continue
717
+
718
+ epic_id=$(rjq read "$PRD_FILE" ".epics[$epic_index].id")
719
+ conflict_reason=$(find_pending_epic_loop_history_conflict "$epic_id" || true)
720
+ [ -n "$conflict_reason" ] || continue
721
+
722
+ if [ "$mismatch_found" -eq 0 ]; then
723
+ echo "Error: pending epics in '$PRD_FILE' conflict with the current loop branch state." >&2
724
+ fi
725
+ mismatch_found=1
726
+ echo " [$epic_id] $conflict_reason" >&2
727
+ done
728
+
729
+ if [ "$mismatch_found" -eq 1 ]; then
730
+ echo "Fix the mismatch before rerunning Ralph:" >&2
731
+ echo " 1. Mark the already-merged epic(s) completed in '$PRD_FILE', or" >&2
732
+ echo " 2. Start from a fresh loop branch that does not already contain those merges." >&2
733
+ exit 1
734
+ fi
735
+ }
736
+
737
+ fail_on_pending_epic_git_state_mismatch
738
+
685
739
  # --- Worktree Management ---
686
- # Creates a git worktree at .worktrees/<epic_id> on branch ralph/<epic_id>,
740
+ # Creates a git worktree at .worktrees/<epic_id> on a run-scoped branch under
741
+ # the current loop branch name, rooted from the loop branch for this run.
687
742
  # rooted from the loop branch for this run.
688
743
  # If the worktree already exists and is valid (e.g. from an interrupted run),
689
744
  # it is reused as-is. Otherwise, any stale entries are cleaned up first.
690
745
  create_epic_worktree() {
691
746
  local epic_id="$1"
692
- local branch_name="ralph/${epic_id}"
747
+ local branch_name
748
+ branch_name=$(epic_branch_name "$epic_id")
693
749
  local worktree_path="${RALPH_RUNTIME_DIRNAME}/.worktrees/${epic_id}"
694
750
  local add_output
695
751
  local retry_output
@@ -1257,6 +1313,10 @@ render_team_lead_prompt() {
1257
1313
  TEAM_LEAD_TEMPLATE_WORKTREE_ABS_PATH="$WORKTREE_ABS_PATH" \
1258
1314
  TEAM_LEAD_TEMPLATE_WORKTREE_STATE_FILE="$WORKTREE_STATE_FILE" \
1259
1315
  TEAM_LEAD_TEMPLATE_WORKTREE_PRD_PATH="$WORKTREE_PRD_PATH" \
1316
+ TEAM_LEAD_TEMPLATE_LOOP_BRANCH="$LOOP_BRANCH" \
1317
+ TEAM_LEAD_TEMPLATE_EPIC_BRANCH="$EPIC_BRANCH" \
1318
+ TEAM_LEAD_TEMPLATE_ROOT_DIR="$ROOT_DIR" \
1319
+ TEAM_LEAD_TEMPLATE_WORKTREE_MERGE_RESULT_FILE="$WORKTREE_MERGE_RESULT_FILE" \
1260
1320
  TEAM_LEAD_TEMPLATE_EPIC_JSON="$EPIC_JSON" \
1261
1321
  TEAM_LEAD_TEMPLATE_WORKTREE_PLAN_FILE="$WORKTREE_PLAN_FILE" \
1262
1322
  TEAM_LEAD_TEMPLATE_EPIC_PLANNED="$EPIC_PLANNED" \
@@ -1290,6 +1350,12 @@ process_epic_result() {
1290
1350
  local epic_index="$1"
1291
1351
  local epic_id
1292
1352
  epic_id=$(rjq read "$PRD_FILE" ".epics[$epic_index].id")
1353
+ local merge_status=""
1354
+ merge_status=$(read_epic_merge_result_field "$epic_id" .status "" 2>/dev/null || true)
1355
+ local merge_mode=""
1356
+ merge_mode=$(read_epic_merge_result_field "$epic_id" .mode "unknown" 2>/dev/null || true)
1357
+ local merge_details=""
1358
+ merge_details=$(read_epic_merge_result_field "$epic_id" .details "" 2>/dev/null || true)
1293
1359
 
1294
1360
  local total_stories
1295
1361
  total_stories=$(rjq length "$PRD_FILE" ".epics[$epic_index].userStories")
@@ -1297,11 +1363,34 @@ process_epic_result() {
1297
1363
  passed_stories=$(rjq count-where "$PRD_FILE" ".epics[$epic_index].userStories" "passes=true")
1298
1364
 
1299
1365
  if [ "$passed_stories" -eq "$total_stories" ] && [ "$total_stories" -gt 0 ]; then
1366
+ if [ "$merge_status" = "merge-failed" ]; then
1367
+ echo ""
1368
+ echo " [$epic_id] MERGE FAILED — all stories passed but merge did not complete"
1369
+ [ -n "$merge_details" ] && echo " [$epic_id] Merge details: $merge_details"
1370
+ rjq set "$PRD_FILE" ".epics[$epic_index].status" '"merge-failed"'
1371
+ FAILED=$((FAILED + 1))
1372
+ echo "[$epic_id] MERGE FAILED (${merge_details:-team lead merge failed}) — $(date)" >> "$PROGRESS_FILE"
1373
+ return
1374
+ fi
1375
+
1376
+ if [ "$merge_status" != "merged" ]; then
1377
+ echo ""
1378
+ echo " [$epic_id] MERGE FAILED — all stories passed but Team Lead did not record a merge result"
1379
+ rjq set "$PRD_FILE" ".epics[$epic_index].status" '"merge-failed"'
1380
+ FAILED=$((FAILED + 1))
1381
+ echo "[$epic_id] MERGE FAILED (missing team lead merge result artifact) — $(date)" >> "$PROGRESS_FILE"
1382
+ return
1383
+ fi
1384
+
1300
1385
  echo ""
1301
1386
  echo " [$epic_id] PASSED — all stories completed ($passed_stories/$total_stories)"
1302
1387
  rjq set "$PRD_FILE" ".epics[$epic_index].status" '"completed"'
1303
1388
  COMPLETED=$((COMPLETED + 1))
1304
1389
  echo "[$epic_id] PASSED — $(date)" >> "$PROGRESS_FILE"
1390
+ if [ "$merge_status" = "merged" ]; then
1391
+ echo " [$epic_id] Merge successful (team lead, ${merge_mode:-unknown})"
1392
+ echo "[$epic_id] MERGED (team lead ${merge_mode:-unknown}) — $(date)" >> "$PROGRESS_FILE"
1393
+ fi
1305
1394
  elif [ "$passed_stories" -gt 0 ]; then
1306
1395
  echo ""
1307
1396
  echo " [$epic_id] PARTIAL — $passed_stories/$total_stories stories passed"
@@ -1345,6 +1434,38 @@ NODE
1345
1434
  mv "$tmp_file" "$state_file"
1346
1435
  }
1347
1436
 
1437
+ reset_epic_merge_result_file() {
1438
+ local epic_id="$1"
1439
+ rm -f "${STATE_DIR}/merge-${epic_id}.json"
1440
+ }
1441
+
1442
+ read_epic_merge_result_field() {
1443
+ local epic_id="$1"
1444
+ local field_path="$2"
1445
+ local default_value="$3"
1446
+ local result_file="${STATE_DIR}/merge-${epic_id}.json"
1447
+
1448
+ [ -f "$result_file" ] || return 1
1449
+ rjq read "$result_file" "$field_path" "$default_value"
1450
+ }
1451
+
1452
+ delete_epic_branch() {
1453
+ local epic_id="$1"
1454
+ local branch_name
1455
+ branch_name=$(epic_branch_name "$epic_id")
1456
+ git branch -d "$branch_name" 2>/dev/null || true
1457
+ }
1458
+
1459
+ verify_epic_branch_merged() {
1460
+ local epic_id="$1"
1461
+ local branch_name
1462
+ branch_name=$(epic_branch_name "$epic_id")
1463
+
1464
+ git show-ref --verify --quiet "refs/heads/${branch_name}" || return 1
1465
+ git show-ref --verify --quiet "refs/heads/${LOOP_BRANCH}" || return 1
1466
+ git merge-base --is-ancestor "$branch_name" "$LOOP_BRANCH" 2>/dev/null
1467
+ }
1468
+
1348
1469
  read_epic_state_passed() {
1349
1470
  local epic_id="$1"
1350
1471
  local state_file="${STATE_DIR}/${epic_id}.json"
@@ -1430,16 +1551,20 @@ spawn_epic_bg() {
1430
1551
  WORKTREE_PATH=$(create_epic_worktree "$EPIC_ID")
1431
1552
  local WORKTREE_ABS_PATH
1432
1553
  WORKTREE_ABS_PATH="$(cd "${ROOT_DIR}/${WORKTREE_PATH}" && pwd)"
1554
+ local EPIC_BRANCH
1555
+ EPIC_BRANCH=$(epic_branch_name "$EPIC_ID")
1433
1556
  ensure_worktree_runtime_link "$WORKTREE_ABS_PATH"
1434
1557
  local WORKTREE_PRD_PATH="${WORKTREE_ABS_PATH}/${PRD_REL_PATH}"
1435
1558
  local WORKTREE_STATE_FILE="${WORKTREE_ABS_PATH}/${RALPH_RUNTIME_DIRNAME}/state/${EPIC_ID}.json"
1436
1559
  local WORKTREE_PLAN_FILE="${WORKTREE_ABS_PATH}/${RALPH_RUNTIME_DIRNAME}/plans/plan-${EPIC_ID}.md"
1560
+ local WORKTREE_MERGE_RESULT_FILE="${WORKTREE_ABS_PATH}/${RALPH_RUNTIME_DIRNAME}/state/merge-${EPIC_ID}.json"
1437
1561
  local WORKTREE_PLAN_EXISTS="false"
1438
1562
  if [ -f "$WORKTREE_PLAN_FILE" ]; then
1439
1563
  WORKTREE_PLAN_EXISTS="true"
1440
1564
  fi
1441
1565
 
1442
1566
  init_epic_state_file "$EPIC_ID" "$EPIC_INDEX"
1567
+ reset_epic_merge_result_file "$EPIC_ID"
1443
1568
 
1444
1569
  echo " Spawning [$EPIC_ID] in worktree $WORKTREE_PATH"
1445
1570
 
@@ -1474,9 +1599,10 @@ spawn_epic_bg() {
1474
1599
  LAST_SPAWN_LOG="$EPIC_LOG"
1475
1600
  }
1476
1601
 
1477
- # merge_wave: merges completed epic branches back to the loop branch sequentially.
1478
- # Takes epic IDs as arguments. Clean merges succeed without AI intervention.
1479
- # On conflict, spawns the merger agent. Logs all outcomes to progress.txt.
1602
+ # merge_wave: fallback merge pass for epic branches that still exist after
1603
+ # their original Team Lead session. Takes epic IDs as arguments.
1604
+ # Clean merges succeed without AI intervention. On conflict, Ralph records the
1605
+ # merge failure and leaves the branch in place for a later clean retry.
1480
1606
  merge_wave() {
1481
1607
  local -a completed_epic_ids=("$@")
1482
1608
 
@@ -1495,7 +1621,8 @@ merge_wave() {
1495
1621
  fi
1496
1622
 
1497
1623
  for epic_id in "${completed_epic_ids[@]}"; do
1498
- local branch_name="ralph/${epic_id}"
1624
+ local branch_name
1625
+ branch_name=$(epic_branch_name "$epic_id")
1499
1626
 
1500
1627
  # Check if branch exists
1501
1628
  if ! git show-ref --verify --quiet "refs/heads/${branch_name}"; then
@@ -1566,78 +1693,18 @@ merge_wave() {
1566
1693
  continue
1567
1694
  fi
1568
1695
 
1569
- # Conflicts detected attempt AI resolution via merger agent
1570
- echo " [$epic_id] conflicts detectedspawning merger agent..."
1571
- echo "[$epic_id] merge conflicts attempting AI resolution — $(date)" >> "$PROGRESS_FILE"
1572
-
1573
- local merge_prompt="You are the Merger Agent. Resolve the git merge conflicts.
1574
-
1575
- ## Context
1576
- - Target branch: ${target_branch}
1577
- - Source branch: ${branch_name}
1578
- - Epic ID: ${epic_id}
1579
-
1580
- ## Conflicted Files
1581
- ${conflicted_files}
1582
-
1583
- ## Instructions
1584
- 1. For each conflicted file listed above, read the full file to see the conflict markers
1585
- 2. Run: git log --oneline ${target_branch}..${branch_name} (what the epic branch changed)
1586
- 3. Run: git log --oneline ${branch_name}..${target_branch} (what target changed since branch point)
1587
- 4. Resolve each conflict by combining both sides' intent
1588
- 5. Stage each resolved file with: git add <filename>
1589
- 6. Do NOT commit — ralph.sh will create the merge commit
1590
- 7. Do NOT run git merge --abort
1591
- 8. If you cannot safely resolve a conflict, leave the conflict markers in place
1592
-
1593
- Begin resolving."
1594
-
1595
- local merge_log="${LOGS_DIR}/merge-${epic_id}-$(date +%s).log"
1596
-
1597
- case "$BACKEND" in
1598
- claude)
1599
- echo "$merge_prompt" | $AGENT_CMD --agent merger --model "$MODEL_MERGER" --dangerously-skip-permissions --print --verbose --output-format stream-json > "$merge_log" 2>&1 || true
1600
- ;;
1601
- copilot)
1602
- COPILOT_MERGE_PROMPT="$merge_prompt" \
1603
- script -q /dev/null /bin/sh -lc 'exec gh copilot -- --agent merger --allow-all --no-ask-user --stream on -p "$COPILOT_MERGE_PROMPT"' \
1604
- > "$merge_log" 2>&1 || true
1605
- ;;
1606
- codex)
1607
- MODEL_TEAM_LEAD="$MODEL_MERGER" run_codex_exec "$ROOT_DIR" "$merge_prompt" > "$merge_log" 2>&1 || true
1608
- ;;
1609
- opencode)
1610
- run_opencode_exec "$ROOT_DIR" "$merge_prompt" merger "$MODEL_MERGER" > "$merge_log" 2>&1 || true
1611
- ;;
1612
- esac
1613
-
1614
- # Check for remaining unresolved conflicts
1615
- local remaining_conflicts
1616
- remaining_conflicts=$(git diff --name-only --diff-filter=U 2>/dev/null || true)
1617
-
1618
- # Also check if agent aborted the merge (MERGE_HEAD won't exist)
1619
- if [ -z "$remaining_conflicts" ] && [ -f ".git/MERGE_HEAD" ]; then
1620
- # All conflicts resolved — complete the merge commit
1621
- git commit --no-edit 2>/dev/null || true
1622
- echo " [$epic_id] merged (AI-resolved conflicts)"
1623
- echo " [$epic_id] Merge log: ${merge_log}"
1624
- echo "[$epic_id] MERGED (AI-resolved) — $(date)" >> "$PROGRESS_FILE"
1625
- git branch -d "${branch_name}" 2>/dev/null || true
1626
- else
1627
- # AI failed or aborted — ensure clean state
1628
- git merge --abort 2>/dev/null || true
1629
- echo " [$epic_id] Merge FAILED — AI could not resolve conflicts in: ${conflicted_files}"
1630
- echo " [$epic_id] Merge log: ${merge_log}"
1631
- echo "[$epic_id] MERGE FAILED (AI resolution failed, files: ${conflicted_files}) — $(date)" >> "$PROGRESS_FILE"
1632
- merge_failures=$((merge_failures + 1))
1696
+ git merge --abort 2>/dev/null || true
1697
+ echo " [$epic_id] Merge FAILEDconflicts remain; leaving ${branch_name} for a later clean retry"
1698
+ echo "[$epic_id] MERGE FAILED (conflicts remain, files: ${conflicted_files}) — $(date)" >> "$PROGRESS_FILE"
1699
+ merge_failures=$((merge_failures + 1))
1633
1700
 
1634
- # Update epic status to merge-failed
1635
- local epic_index
1636
- epic_index=$(rjq find-index "$PRD_FILE" .epics id "$epic_id")
1637
- if [ -n "$epic_index" ]; then
1638
- rjq set "$PRD_FILE" ".epics[$epic_index].status" '"merge-failed"'
1639
- fi
1701
+ local epic_index
1702
+ epic_index=$(rjq find-index "$PRD_FILE" .epics id "$epic_id")
1703
+ if [ -n "$epic_index" ]; then
1704
+ rjq set "$PRD_FILE" ".epics[$epic_index].status" '"merge-failed"'
1640
1705
  fi
1706
+
1707
+ continue
1641
1708
  fi
1642
1709
 
1643
1710
  # Clean up the merged branch
@@ -1653,13 +1720,14 @@ collect_pending_merge_epics() {
1653
1720
  for epic_index in $(seq 0 $((TOTAL_EPICS - 1))); do
1654
1721
  local epic_status
1655
1722
  epic_status=$(rjq read "$PRD_FILE" ".epics[$epic_index].status" "pending")
1656
- [ "$epic_status" = "completed" ] || continue
1723
+ [ "$epic_status" = "completed" ] || [ "$epic_status" = "merge-failed" ] || continue
1657
1724
 
1658
1725
  local epic_id
1659
1726
  epic_id=$(rjq read "$PRD_FILE" ".epics[$epic_index].id")
1660
1727
  [ -n "$epic_id" ] || continue
1661
1728
 
1662
- local branch_name="ralph/${epic_id}"
1729
+ local branch_name
1730
+ branch_name=$(epic_branch_name "$epic_id")
1663
1731
  if git show-ref --verify --quiet "refs/heads/${branch_name}"; then
1664
1732
  pending_merge_ids+=("$epic_id")
1665
1733
  fi
@@ -1684,7 +1752,9 @@ recover_pending_merges() {
1684
1752
  echo " --- Recovering completed epic branches before ${context} ---"
1685
1753
  local epic_id
1686
1754
  for epic_id in "${pending_merge_ids[@]}"; do
1687
- echo " [$epic_id] Recovered pending merge from existing epic branch"
1755
+ local branch_name
1756
+ branch_name=$(epic_branch_name "$epic_id")
1757
+ echo " [$epic_id] Recovered pending merge from existing epic branch (${branch_name})"
1688
1758
  echo "[$epic_id] RECOVERED PENDING MERGE (${context}) — $(date)" >> "$PROGRESS_FILE"
1689
1759
  done
1690
1760
 
@@ -1767,7 +1837,7 @@ read_final_validation_verdict() {
1767
1837
 
1768
1838
  run_final_validation_cycle() {
1769
1839
  [ "$FINAL_VALIDATION_ENABLED" = "1" ] || return 0
1770
- [ "$COMPLETED" -eq "$TOTAL_EPICS" ] || return 0
1840
+ [ $((COMPLETED + FAILED)) -eq "$TOTAL_EPICS" ] || return 0
1771
1841
  [ "$TOTAL_EPICS" -ge 2 ] || return 0
1772
1842
 
1773
1843
  echo ""
@@ -2096,18 +2166,30 @@ while true; do
2096
2166
  [ "$passed_s_prd" -gt "$passed_s" ] && passed_s="$passed_s_prd"
2097
2167
  local all_done=false
2098
2168
  [ "$passed_s" -eq "$total_s" ] && [ "$total_s" -gt 0 ] && all_done=true
2169
+ local live_merge_status=""
2170
+ live_merge_status=$(read_epic_merge_result_field "$finished_epic_id" .status "" 2>/dev/null || true)
2171
+ local merge_recorded=false
2172
+ if [ "$live_merge_status" = "merged" ] || [ "$live_merge_status" = "merge-failed" ]; then
2173
+ merge_recorded=true
2174
+ fi
2175
+ local epic_flow_complete=false
2176
+ if [ "$all_done" = true ] && [ "$merge_recorded" = true ]; then
2177
+ epic_flow_complete=true
2178
+ fi
2099
2179
 
2100
- if [ "$process_finished" = true ] || [ "$all_done" = true ]; then
2101
- # Treat fully-passed stories in the PRD as the authoritative completion
2102
- # signal, even if the backend session is still idling.
2103
- if [ "$process_finished" = false ]; then
2180
+ if [ "$process_finished" = true ] || [ "$epic_flow_complete" = true ]; then
2181
+ # Only terminate an in-flight session early after the Team Lead has
2182
+ # written the merge result artifact. Fully-passed stories alone are
2183
+ # not enough to declare the epic session complete.
2184
+ if [ "$process_finished" = false ] && [ "$epic_flow_complete" = true ]; then
2104
2185
  terminate_process_tree "${active_pids[$slot]}"
2105
2186
  fi
2106
2187
  wait "${active_pids[$slot]}" 2>/dev/null || true
2107
2188
 
2108
- # If the process exited before the epic reached all stories passed,
2109
- # consider it a crash and retry when possible.
2110
- if [ "$all_done" = false ]; then
2189
+ # If the process exited before the epic reached full completion
2190
+ # (stories passed plus merge result recorded), consider it a crash
2191
+ # and retry when possible.
2192
+ if [ "$epic_flow_complete" = false ]; then
2111
2193
  local retry_count
2112
2194
  retry_count="$(get_crash_retry_count "$finished_epic_id")"
2113
2195
  if [ "$retry_count" -lt "$MAX_CRASH_RETRIES" ]; then
@@ -2132,14 +2214,25 @@ while true; do
2132
2214
 
2133
2215
  echo " [$finished_epic_id] finished — processing result"
2134
2216
  project_state_to_prd "$finished_epic_id" || true
2217
+ local merge_status
2218
+ merge_status=$(read_epic_merge_result_field "$finished_epic_id" .status "" 2>/dev/null || true)
2219
+ if [ "$merge_status" = "merged" ] && ! verify_epic_branch_merged "$finished_epic_id"; then
2220
+ echo " [$finished_epic_id] Team Lead reported merge success but scripted check failed"
2221
+ echo "[$finished_epic_id] MERGE CHECK FAILED (team lead reported merged) — $(date)" >> "$PROGRESS_FILE"
2222
+ reset_epic_merge_result_file "$finished_epic_id"
2223
+ merge_status=""
2224
+ fi
2135
2225
  process_epic_result "${active_indices[$slot]}"
2136
- # Track completed epics for merge_wave
2226
+ # Track completed epics for merge_wave only when the Team Lead did not already merge.
2137
2227
  local post_status
2138
2228
  post_status=$(rjq read "$PRD_FILE" ".epics[${active_indices[$slot]}].status" "pending")
2139
- if [ "$post_status" = "completed" ]; then
2229
+ if [ "$post_status" = "completed" ] && [ "$merge_status" != "merged" ]; then
2140
2230
  wave_completed_ids+=("$finished_epic_id")
2141
2231
  fi
2142
2232
  cleanup_epic_worktree "$finished_epic_id"
2233
+ if [ "$merge_status" = "merged" ]; then
2234
+ delete_epic_branch "$finished_epic_id"
2235
+ fi
2143
2236
  unset 'active_pids[$slot]'
2144
2237
  unset 'active_indices[$slot]'
2145
2238
  unset 'active_start_times[$slot]'