ralph-teams 1.0.31 → 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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ralph-teams",
3
- "version": "1.0.31",
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.
package/ralph.sh CHANGED
@@ -1599,10 +1599,10 @@ spawn_epic_bg() {
1599
1599
  LAST_SPAWN_LOG="$EPIC_LOG"
1600
1600
  }
1601
1601
 
1602
- # merge_wave: fallback merge pass for completed epic branches that were not already
1603
- # merged by their original Team Lead sessions. Takes epic IDs as arguments.
1604
- # Clean merges succeed without AI intervention. On conflict, hands the repo to a
1605
- # tightly-scoped Team Lead takeover. 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.
1606
1606
  merge_wave() {
1607
1607
  local -a completed_epic_ids=("$@")
1608
1608
 
@@ -1693,84 +1693,18 @@ merge_wave() {
1693
1693
  continue
1694
1694
  fi
1695
1695
 
1696
- # Conflicts detected — hand off the current merge state to the Team Lead.
1697
- echo " [$epic_id] conflicts detectedteam lead takeover..."
1698
- echo "[$epic_id] merge conflicts team lead takeover — $(date)" >> "$PROGRESS_FILE"
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))
1699
1700
 
1700
- local merge_prompt="You are the Team Lead. Take over this merge conflict resolution directly.
1701
-
1702
- ## Context
1703
- - Target branch: ${target_branch}
1704
- - Source branch: ${branch_name}
1705
- - Epic ID: ${epic_id}
1706
-
1707
- ## Conflicted Files
1708
- ${conflicted_files}
1709
-
1710
- ## Instructions
1711
- 1. Stay in the current repository and operate on the existing in-progress merge state.
1712
- 2. Do NOT delegate. Do NOT spawn merger, builder, planner, or validator work.
1713
- 3. For each conflicted file listed above, read the full file and inspect the conflict markers.
1714
- 4. Run: git log --oneline ${target_branch}..${branch_name} to see what the epic branch changed.
1715
- 5. Run: git log --oneline ${branch_name}..${target_branch} to see what changed on the target branch.
1716
- 6. Resolve each conflict by combining both sides' intent where possible.
1717
- 7. Stage each resolved file with: git add <filename>.
1718
- 8. Do NOT commit. ralph.sh will create the merge commit after all conflicts are resolved.
1719
- 9. Do NOT run git merge --abort.
1720
- 10. If you cannot safely resolve a conflict, leave the conflict markers in place.
1721
-
1722
- When you are finished, print exactly one final line:
1723
- - MERGE_SUCCESS
1724
- - MERGE_FAILED
1725
-
1726
- Begin resolving."
1727
-
1728
- local merge_log="${LOGS_DIR}/merge-${epic_id}-$(date +%s).log"
1729
-
1730
- case "$BACKEND" in
1731
- claude)
1732
- echo "$merge_prompt" | $AGENT_CMD --agent team-lead --model "$MODEL_TEAM_LEAD" --dangerously-skip-permissions --print --verbose --output-format stream-json > "$merge_log" 2>&1 || true
1733
- ;;
1734
- copilot)
1735
- COPILOT_MERGE_PROMPT="$merge_prompt" \
1736
- script -q /dev/null /bin/sh -lc 'exec gh copilot -- --agent team-lead --allow-all --no-ask-user --stream on -p "$COPILOT_MERGE_PROMPT"' \
1737
- > "$merge_log" 2>&1 || true
1738
- ;;
1739
- codex)
1740
- run_codex_exec "$ROOT_DIR" "$merge_prompt" > "$merge_log" 2>&1 || true
1741
- ;;
1742
- opencode)
1743
- run_opencode_exec "$ROOT_DIR" "$merge_prompt" team-lead "$MODEL_TEAM_LEAD" > "$merge_log" 2>&1 || true
1744
- ;;
1745
- esac
1746
-
1747
- # Check for remaining unresolved conflicts
1748
- local remaining_conflicts
1749
- remaining_conflicts=$(git diff --name-only --diff-filter=U 2>/dev/null || true)
1750
-
1751
- # Also check if agent aborted the merge (MERGE_HEAD won't exist)
1752
- if [ -z "$remaining_conflicts" ] && [ -f ".git/MERGE_HEAD" ]; then
1753
- # All conflicts resolved — complete the merge commit
1754
- git commit --no-edit 2>/dev/null || true
1755
- echo " [$epic_id] merged (AI-resolved conflicts)"
1756
- echo " [$epic_id] Merge log: ${merge_log}"
1757
- echo "[$epic_id] MERGED (AI-resolved) — $(date)" >> "$PROGRESS_FILE"
1758
- git branch -d "${branch_name}" 2>/dev/null || true
1759
- else
1760
- # AI failed or aborted — ensure clean state
1761
- git merge --abort 2>/dev/null || true
1762
- echo " [$epic_id] Merge FAILED — AI could not resolve conflicts in: ${conflicted_files}"
1763
- echo " [$epic_id] Merge log: ${merge_log}"
1764
- echo "[$epic_id] MERGE FAILED (AI resolution failed, files: ${conflicted_files}) — $(date)" >> "$PROGRESS_FILE"
1765
- merge_failures=$((merge_failures + 1))
1766
-
1767
- # Update epic status to merge-failed
1768
- local epic_index
1769
- epic_index=$(rjq find-index "$PRD_FILE" .epics id "$epic_id")
1770
- if [ -n "$epic_index" ]; then
1771
- rjq set "$PRD_FILE" ".epics[$epic_index].status" '"merge-failed"'
1772
- 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"'
1773
1705
  fi
1706
+
1707
+ continue
1774
1708
  fi
1775
1709
 
1776
1710
  # Clean up the merged branch
@@ -1786,7 +1720,7 @@ collect_pending_merge_epics() {
1786
1720
  for epic_index in $(seq 0 $((TOTAL_EPICS - 1))); do
1787
1721
  local epic_status
1788
1722
  epic_status=$(rjq read "$PRD_FILE" ".epics[$epic_index].status" "pending")
1789
- [ "$epic_status" = "completed" ] || continue
1723
+ [ "$epic_status" = "completed" ] || [ "$epic_status" = "merge-failed" ] || continue
1790
1724
 
1791
1725
  local epic_id
1792
1726
  epic_id=$(rjq read "$PRD_FILE" ".epics[$epic_index].id")
@@ -1903,7 +1837,7 @@ read_final_validation_verdict() {
1903
1837
 
1904
1838
  run_final_validation_cycle() {
1905
1839
  [ "$FINAL_VALIDATION_ENABLED" = "1" ] || return 0
1906
- [ "$COMPLETED" -eq "$TOTAL_EPICS" ] || return 0
1840
+ [ $((COMPLETED + FAILED)) -eq "$TOTAL_EPICS" ] || return 0
1907
1841
  [ "$TOTAL_EPICS" -ge 2 ] || return 0
1908
1842
 
1909
1843
  echo ""