Commit 3af569f
fix(maestro): prefer terminal failure over transient retries in parseMaestroFailure (#175)
Closes #118.
PR #115's parseMaestroFailure ran each pattern against the whole buffer
and returned the first lexical match anywhere in the output. On
maestro-runner runs with retry hooks active, this captured a transient
`[INFO] Element with id "X" not found in current screen — retrying` line
earlier in the buffer — even when the actual terminal failure was on a
different selector. The transient (already-resolved) selector then got
sent to cdp_repair_action, burning a 24h-budget slot on a non-existent
problem and missing the real failure.
Fix: nested-loop selection that preserves BOTH invariants:
1. Outer loop walks PATTERNS in order (most-specific first). The first
pattern that hits any line wins, regardless of line position. Keeps
the existing pattern-specificity invariant (e.g. 1.0.9 `id=` shape
outranks the catch-all `Element 'X' not found`).
2. Inner loop scans lines from END to START. Within a single pattern,
the last matching line — the terminal failure — wins over earlier
transient retries.
Falls back to a whole-buffer scan if no line matches a known pattern,
preserving prior behavior for single-line inputs and any future pattern
that spans a `\n`.
Tests:
- Inverted `returns first match` → `returns LAST match` (the existing
test encoded the broken behavior)
- Added GH #118 transient-retry-then-real-failure shape using the issue's
exact example
- Added single-line input test confirming the fallback whole-buffer scan
path still works
- Updated the section comment that documented the old "first-match"
semantic
- Existing 1.0.9 `id=` priority test still passes (proves pattern
specificity is preserved over line position)
Verified: 1467/1467 cdp-bridge unit tests passing (+2 net new).
Note: codex-pair flagged a hypothetical edge case (multiple known
failure snippets on a SINGLE line — `line.match()` returns leftmost).
Not addressing in this PR — no real-world maestro-runner output emits
multiple failure snippets per line, and the recommended fix (collect
all match indexes and return rightmost) materially complicates the
code for an unobserved case. Can revisit with real captures if it
ever surfaces.
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>1 parent 3f23ac6 commit 3af569f
3 files changed
Lines changed: 110 additions & 11 deletions
File tree
- scripts/cdp-bridge
- dist/domain
- src/domain
- test/unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
77 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
78 | 98 | | |
79 | 99 | | |
80 | 100 | | |
81 | 101 | | |
82 | 102 | | |
| 103 | + | |
83 | 104 | | |
84 | | - | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
85 | 118 | | |
86 | 119 | | |
87 | 120 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
90 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
91 | 111 | | |
92 | 112 | | |
93 | 113 | | |
94 | 114 | | |
95 | 115 | | |
| 116 | + | |
96 | 117 | | |
97 | | - | |
98 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
99 | 130 | | |
100 | 131 | | |
101 | 132 | | |
| |||
Lines changed: 39 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | | - | |
123 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
124 | 128 | | |
125 | 129 | | |
126 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
127 | 135 | | |
128 | 136 | | |
129 | 137 | | |
130 | 138 | | |
131 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
132 | 167 | | |
133 | 168 | | |
134 | 169 | | |
| |||
0 commit comments