Commit 3111c8e
fix(safety): parseAxmeGate strips trailing quote/punct from pr/repo (B-008)
When the agent placed `#!axme pr=N repo=OWNER/REPO` INSIDE a
`git commit -m "..."` quoted string, the safety hook fail-closed
on every retry with `Cannot verify PR #N status (gh CLI error)` —
because `\S+` is greedy and captured the closing `"` as part of
the repo name. The hook then shelled out to:
gh pr view N --repo "OWNER/REPO\"" --json state --jq .state
which `gh` rejects → execSync throws → fail-closed. Discovered
during axme-blog PR #6 work after ~6 blocked retries before
realising the regex, not the network, was eating the call.
Changes (src/storage/safety.ts):
- Tighten value capture from `\S+` to `[^\s"'`]+` for both `pr=`
and `repo=` so quote/backtick characters never end up inside
the captured value.
- After capture, defensively strip trailing `)`, `]`, `,`, `;`, `.`
via a single regex. Covers $(...) expansions, comment lists,
and other shell punctuation that can sneak in next to the
marker.
- Reject parses where stripping leaves an empty value (returns
null instead of producing a bad lookup).
- Update AXME_GATE_INSTRUCTION to remind the agent to put the
marker AFTER the closing `"` of any -m argument, not inside
it. The previous message described the format but not the
placement, so under retry pressure the agent kept re-emitting
the same broken pattern.
Tests (test/axme-gate.test.ts):
- B-008 reproducer: marker placed inside `-m "..."` parses
cleanly to repo without trailing quote.
- Same for `-m '...'` and `-m \`...\``.
- Trailing `)` and `,` from $(...) / comment list also stripped.
- pr=" alone (nothing left after strip) returns null instead
of constructing a bad gate.
Verified:
- 489/489 unit tests pass (5 new cases; previous baseline 484)
- `tsc --noEmit` clean
- `npm run build` clean
Fixes B-008.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 601c01c commit 3111c8e
2 files changed
Lines changed: 58 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
329 | 329 | | |
330 | 330 | | |
331 | 331 | | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
332 | 338 | | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
333 | 348 | | |
334 | 349 | | |
335 | 350 | | |
| |||
338 | 353 | | |
339 | 354 | | |
340 | 355 | | |
341 | | - | |
342 | | - | |
| 356 | + | |
| 357 | + | |
343 | 358 | | |
344 | | - | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
345 | 363 | | |
346 | 364 | | |
347 | 365 | | |
348 | 366 | | |
349 | 367 | | |
350 | | - | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
351 | 371 | | |
352 | 372 | | |
353 | 373 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
84 | 118 | | |
85 | 119 | | |
86 | 120 | | |
| |||
0 commit comments