@memnexus-ai/mx-agent-cli 0.1.261 → 0.1.262
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/coordination-brief-pin.test.js +5 -1
- package/dist/__tests__/coordination-brief-pin.test.js.map +1 -1
- package/dist/agent-config/hooks/HOOK-TIMEOUTS.md +101 -0
- package/dist/agent-config/hooks/auto-capture-precompact.sh +3 -1
- package/dist/agent-config/hooks/auto-capture-session-end.sh +5 -1
- package/dist/agent-config/hooks/auto-checkpoint.sh +3 -1
- package/dist/agent-config/hooks/ci-validate-hook.sh +76 -8
- package/dist/agent-config/hooks/coordination-brief.sh +15 -2
- package/dist/agent-config/hooks/coordination-midsession-drain.sh +13 -0
- package/dist/agent-config/hooks/deploy-verification-reminder.sh +5 -1
- package/dist/agent-config/hooks/memory-checkpoint-reminder.sh +8 -1
- package/dist/agent-config/hooks/mx-guard-hook.sh +30 -4
- package/dist/agent-config/hooks/named-memory-write-guard.sh +5 -0
- package/dist/agent-config/hooks/observability-sync.sh +7 -1
- package/dist/agent-config/hooks/reload-checkpoint.sh +13 -3
- package/dist/agent-config/hooks/workflow-dispatch-guard.sh +11 -2
- package/dist/agent-config/settings.json +40 -20
- package/package.json +1 -1
|
@@ -26,7 +26,11 @@ const here = dirname(fileURLToPath(import.meta.url));
|
|
|
26
26
|
const HOOK_FILE = join(here, '..', '..', '..', 'agent-config', 'hooks', 'coordination-brief.sh');
|
|
27
27
|
// Mirror of the platform PINNED_SHA256 (coordination-brief-drift.test.ts). Bump in
|
|
28
28
|
// lockstep with the other two pin sites named in the header above.
|
|
29
|
-
|
|
29
|
+
// Current value bumped for #4846 (SF-25 hook-timeout change). Site 3 (spearmint)
|
|
30
|
+
// necessarily lags: it is re-landed by config-sync from the PUBLISHED bundle,
|
|
31
|
+
// which this very gate must let through first. See the drift-test header's
|
|
32
|
+
// PROPAGATION ORDERING note.
|
|
33
|
+
const PINNED_SHA256 = '4b0b804a0a6165797c26fe3ef322b68be0a36177cd97816f7440a001437cf54d';
|
|
30
34
|
describe('coordination-brief hook pin — publish-side gate (KI-COORDMT-HOOK-EXPORT-ROBUSTNESS)', () => {
|
|
31
35
|
it('the bundled hook matches its pinned sha256 (else the CLI must not publish)', () => {
|
|
32
36
|
const bytes = readFileSync(HOOK_FILE);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coordination-brief-pin.test.js","sourceRoot":"","sources":["../../src/__tests__/coordination-brief-pin.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACrD,+EAA+E;AAC/E,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,uBAAuB,CAAC,CAAC;AAEjG,mFAAmF;AACnF,mEAAmE;AACnE,MAAM,aAAa,GAAG,kEAAkE,CAAC;AAEzF,QAAQ,CAAC,qFAAqF,EAAE,GAAG,EAAE;IACnG,EAAE,CAAC,4EAA4E,EAAE,GAAG,EAAE;QACpF,MAAM,KAAK,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;QACtC,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAChE,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"coordination-brief-pin.test.js","sourceRoot":"","sources":["../../src/__tests__/coordination-brief-pin.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACrD,+EAA+E;AAC/E,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,uBAAuB,CAAC,CAAC;AAEjG,mFAAmF;AACnF,mEAAmE;AACnE,iFAAiF;AACjF,8EAA8E;AAC9E,2EAA2E;AAC3E,6BAA6B;AAC7B,MAAM,aAAa,GAAG,kEAAkE,CAAC;AAEzF,QAAQ,CAAC,qFAAqF,EAAE,GAAG,EAAE;IACnG,EAAE,CAAC,4EAA4E,EAAE,GAAG,EAAE;QACpF,MAAM,KAAK,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;QACtC,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAChE,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Sizing a hook timeout
|
|
2
|
+
|
|
3
|
+
Read this before adding a hook to `agent-config/settings.json` or changing a
|
|
4
|
+
`timeout` value in it. The rule lives here rather than next to the values
|
|
5
|
+
because `settings.json` is JSON and cannot carry a comment.
|
|
6
|
+
|
|
7
|
+
## The fact everything else follows from
|
|
8
|
+
|
|
9
|
+
**A hook timeout is fail-OPEN.** When a hook exceeds its `timeout`, Claude Code
|
|
10
|
+
kills the process and continues as if the hook had not run. On `PreToolUse` that
|
|
11
|
+
means **the tool call proceeds**. It is not an implicit block — blocking is
|
|
12
|
+
`exit 2`, which is a decision the hook makes, and a killed hook makes no
|
|
13
|
+
decision at all.
|
|
14
|
+
|
|
15
|
+
So a timeout that is too short does not make a hook "fail safe". It deletes the
|
|
16
|
+
hook, silently, exactly when the machine is slow.
|
|
17
|
+
|
|
18
|
+
Unset is not "no limit" either: it inherits the default, **600s** for `command`
|
|
19
|
+
hooks. That default is **event-dependent** — `UserPromptSubmit` lowers it to 30s
|
|
20
|
+
and `MessageDisplay` to 10s. No hook here sits on those events today, but a
|
|
21
|
+
guard added to one later would silently inherit 30s. On those events, always set
|
|
22
|
+
`timeout` explicitly.
|
|
23
|
+
|
|
24
|
+
## Classify by the consequence of a fail-open kill, not by the exit code
|
|
25
|
+
|
|
26
|
+
Do not classify by name, and do not classify by whether the hook can `exit 2`.
|
|
27
|
+
Ask one question: **if this hook is killed and the action proceeds, what is
|
|
28
|
+
lost?**
|
|
29
|
+
|
|
30
|
+
| Tier | A fail-open kill means | Size against | Examples |
|
|
31
|
+
|---|---|---|---|
|
|
32
|
+
| **GUARD** | An action the hook exists to prevent is **permitted**. The kill is a bypass primitive: anything that makes the hook slow becomes a way past it. | **Bypass risk.** Be generous — generous enough that only a genuine hang trips it — and bound the hook's own slow calls internally so the hook decides first, on its own fail direction. | `worktree-guard`, `git-mutation-guard`, `mx-guard-hook`, `ci-validate-hook`, `workflow-dispatch-guard`, `named-memory-write-guard`, `gh-pr-edit-guard`, `session-idle-gate` |
|
|
33
|
+
| **ENFORCED-PROCESS CONTROL** | A **required step is skipped**. No security boundary is crossed, but process discipline the team relies on quietly stops applying. | **False-trip probability.** The risk is not a bypass, it is that a normal slow moment drops the enforcement. Size so ordinary slowness never trips it. | `memory-checkpoint-reminder`, `deploy-verification-reminder` |
|
|
34
|
+
| **ADVISORY** | **Information is lost** and nothing else. No action is permitted, no step is skipped. | Keep it short. A lost reminder or a lost telemetry line is cheap; holding a tool call open is not. | `delegation-audit`, `set-terminal-appearance`, `auto-capture-*`, `auto-checkpoint`, `observability-sync`, `iteration-log-check` |
|
|
35
|
+
|
|
36
|
+
### The middle tier is not "reminders"
|
|
37
|
+
|
|
38
|
+
`memory-checkpoint-reminder` and `deploy-verification-reminder` both end in
|
|
39
|
+
`exit 2`, and on `PreToolUse` that **genuinely blocks the tool call** — during
|
|
40
|
+
the #4846 review this hook blocked two of the reviewer's own tool calls. They
|
|
41
|
+
are not advisory and calling them reminders will get them sized like advisory
|
|
42
|
+
hooks.
|
|
43
|
+
|
|
44
|
+
What separates them from a GUARD is not force, it is consequence. Nothing unsafe
|
|
45
|
+
happens if they are skipped; a step the team wants taken simply is not taken.
|
|
46
|
+
They land on the same generous value as the guards (60s) for a **different
|
|
47
|
+
reason**: not because a bypass is possible, but because at 10s an ordinary slow
|
|
48
|
+
moment trips them and the enforcement silently evaporates.
|
|
49
|
+
|
|
50
|
+
Do not compress this to "emits `exit 2` ⇒ GUARD". That rule over-classifies, and
|
|
51
|
+
the reasoning it discards is the part the next person needs.
|
|
52
|
+
|
|
53
|
+
## Two rules that follow
|
|
54
|
+
|
|
55
|
+
**1. Bound the hook's slow calls inside the hook.** The harness timeout is the
|
|
56
|
+
outer backstop, and its behaviour (kill, allow) is not what most hooks want. An
|
|
57
|
+
internal `timeout N` around each network or subprocess call lets the hook reach
|
|
58
|
+
its own decision — block, warn, or skip — on its own terms. Set the harness
|
|
59
|
+
value comfortably **above** the sum of the internal bounds so the internal ones
|
|
60
|
+
always fire first. `ci-validate-hook` documents this arithmetic explicitly at its
|
|
61
|
+
tunables block; copy that pattern for any hook where the worst case is not
|
|
62
|
+
obvious by inspection.
|
|
63
|
+
|
|
64
|
+
**2. If a failure is indistinguishable from a legitimate result, say so out
|
|
65
|
+
loud.** A network read that returns nothing on failure and nothing on an empty
|
|
66
|
+
result is the worst shape a hook can have: the agent cannot tell "there were no
|
|
67
|
+
escalations" from "delivery failed", and will act on the first reading. Any such
|
|
68
|
+
hook must announce the failure on stderr, name what is unknown, and say what to
|
|
69
|
+
run to find out. Silence is the defect, not the timeout. See
|
|
70
|
+
`coordination-brief.sh` and `coordination-midsession-drain.sh` for the wording.
|
|
71
|
+
|
|
72
|
+
## Current assignment
|
|
73
|
+
|
|
74
|
+
| Hook | Event | Tier | Timeout |
|
|
75
|
+
|---|---|---|---|
|
|
76
|
+
| `ci-validate-hook` | PreToolUse | GUARD | 3600s |
|
|
77
|
+
| `mx-guard-hook` | PreToolUse | GUARD | 300s |
|
|
78
|
+
| `worktree-guard` | PreToolUse | GUARD | 60s |
|
|
79
|
+
| `git-mutation-guard` | PreToolUse | GUARD | 60s |
|
|
80
|
+
| `gh-pr-edit-guard` | PreToolUse | GUARD | 60s |
|
|
81
|
+
| `named-memory-write-guard` | PreToolUse | GUARD | 60s |
|
|
82
|
+
| `workflow-dispatch-guard` | PreToolUse | GUARD | 60s |
|
|
83
|
+
| `session-idle-gate` | Stop | GUARD | 60s |
|
|
84
|
+
| `memory-checkpoint-reminder` | PreToolUse | ENFORCED-PROCESS CONTROL | 60s |
|
|
85
|
+
| `deploy-verification-reminder` | PostToolUse | ENFORCED-PROCESS CONTROL | 60s |
|
|
86
|
+
| `coordination-brief` | SessionStart | ADVISORY (delivery-critical) | 180s |
|
|
87
|
+
| `coordination-midsession-drain` | Stop | ADVISORY (delivery-critical) | 30s |
|
|
88
|
+
| `observability-sync` | Stop | ADVISORY | 30s |
|
|
89
|
+
| `auto-checkpoint` | PreCompact | ADVISORY | 30s |
|
|
90
|
+
| `auto-capture-precompact` | PreCompact | ADVISORY | 30s |
|
|
91
|
+
| `auto-capture-session-end` | Stop | ADVISORY | 30s |
|
|
92
|
+
| `reload-checkpoint` | SessionStart | ADVISORY | 20s |
|
|
93
|
+
| `iteration-log-check` | Stop | ADVISORY | 20s |
|
|
94
|
+
| `delegation-audit` | Stop | ADVISORY | 15s |
|
|
95
|
+
| `set-terminal-appearance` | SessionStart | ADVISORY | 5s |
|
|
96
|
+
|
|
97
|
+
The two coordination hooks are advisory by tier — being killed loses information
|
|
98
|
+
rather than permitting an action — but the information is cross-team escalation
|
|
99
|
+
delivery, so they are sized and instrumented as if the loss were expensive,
|
|
100
|
+
because it is. That is why `coordination-brief` sits at 180s rather than the
|
|
101
|
+
value its tier alone would suggest.
|
|
@@ -230,7 +230,9 @@ mx_verbatim_guard() {
|
|
|
230
230
|
|
|
231
231
|
# ── 6. Save memory ──────────────────────────────────────────────────────
|
|
232
232
|
if mx_verbatim_guard "$TRANSCRIPT_PATH" "$CONTENT"; then
|
|
233
|
-
|
|
233
|
+
# Bounded: network write. On timeout we land on the existing `|| true` path —
|
|
234
|
+
# the capture is lost but compaction still proceeds. Fail-open unchanged.
|
|
235
|
+
timeout "${AUTO_CAPTURE_TIMEOUT_SECS:-20}" mx memories create \
|
|
234
236
|
--conversation-id "NEW" \
|
|
235
237
|
--content "$CONTENT" \
|
|
236
238
|
--topics "auto-captured,context-compaction" \
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
# Output: none (side-effect only — saves memory via mx CLI)
|
|
14
14
|
# Exit: always 0 (never blocks)
|
|
15
15
|
|
|
16
|
+
|
|
17
|
+
|
|
16
18
|
# Fail-open: any error -> allow session to end normally
|
|
17
19
|
trap 'exit 0' ERR
|
|
18
20
|
|
|
@@ -234,7 +236,9 @@ mx_verbatim_guard() {
|
|
|
234
236
|
|
|
235
237
|
# ── 6. Save memory ──────────────────────────────────────────────────────
|
|
236
238
|
if mx_verbatim_guard "$TRANSCRIPT_PATH" "$CONTENT"; then
|
|
237
|
-
|
|
239
|
+
# Bounded: network write. On timeout we land on the existing `|| true` path —
|
|
240
|
+
# the capture is lost but the session still stops. Fail-open unchanged.
|
|
241
|
+
timeout "${AUTO_CAPTURE_TIMEOUT_SECS:-20}" mx memories create \
|
|
238
242
|
--conversation-id "NEW" \
|
|
239
243
|
--content "$CONTENT" \
|
|
240
244
|
--topics "auto-captured,session-summary" \
|
|
@@ -172,7 +172,9 @@ mx_verbatim_guard() {
|
|
|
172
172
|
|
|
173
173
|
if mx_verbatim_guard "$TRANSCRIPT_PATH" "$CONTENT"; then
|
|
174
174
|
# Use a named memory so it's easy to find and gets overwritten each compaction
|
|
175
|
-
|
|
175
|
+
# Bounded: network write. On timeout we land on the existing `|| true` path —
|
|
176
|
+
# the checkpoint is lost but compaction still proceeds. Fail-open unchanged.
|
|
177
|
+
timeout "${AUTO_CHECKPOINT_TIMEOUT_SECS:-20}" mx memories create \
|
|
176
178
|
--name "auto-checkpoint-${WORKTREE_NAME}" \
|
|
177
179
|
--conversation-id "NEW" \
|
|
178
180
|
--content "$CONTENT" \
|
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
# 0 = allow (not a push, or all validations pass, or a load-flake was absorbed)
|
|
27
27
|
# 2 = block (a real validation failure, or the serialization lock timed out)
|
|
28
28
|
|
|
29
|
+
|
|
30
|
+
|
|
29
31
|
# Fail-open: any unexpected error → let the push through. NOTE: the two
|
|
30
32
|
# deliberately fail-CLOSED paths (lock timeout, confirmed real regression) use
|
|
31
33
|
# explicit `exit 2` inside conditionals, so the ERR trap never downgrades them.
|
|
@@ -73,6 +75,22 @@ mx_validate_dir() {
|
|
|
73
75
|
MX_VALIDATE_DIR="$(mx_validate_dir)"
|
|
74
76
|
LOCK_FILE="${MX_VALIDATE_LOCK_FILE:-$MX_VALIDATE_DIR/validate.lock}"
|
|
75
77
|
LOCK_TIMEOUT="${MX_VALIDATE_LOCK_TIMEOUT:-900}" # seconds to wait in queue
|
|
78
|
+
# Per-run bound on a validate script. WORST-CASE BUDGET for this hook, which the
|
|
79
|
+
# settings.json harness timeout (3600s) must stay above, because a harness kill
|
|
80
|
+
# is fail-OPEN and would skip the gate entirely:
|
|
81
|
+
# lock wait LOCK_TIMEOUT 900s (already fail-closed)
|
|
82
|
+
# + first pass CV_VALIDATE_TIMEOUT_SECS 600s (fail-closed, below)
|
|
83
|
+
# + isolation retry CV_VALIDATE_TIMEOUT_SECS 600s (fail-closed, below)
|
|
84
|
+
# + devlog check CV_DEVLOG_TIMEOUT_SECS 60s (advisory, warn only)
|
|
85
|
+
# + two git diffs CV_GIT_TIMEOUT_SECS x2 30s (fail-open)
|
|
86
|
+
# ────────────────────────────────────────────────
|
|
87
|
+
# 2190s floor, 1410s of headroom under the 3600s harness cap.
|
|
88
|
+
# 2190 is a LOWER BOUND, not an exact total: the shared push-target resolver adds
|
|
89
|
+
# up to MXPT_GIT_TIMEOUT_SECS (10s) per rev-parse and the segment count scales
|
|
90
|
+
# with the pushed command, so a pathological command adds more. It would take
|
|
91
|
+
# ~141 segments to close the 1410s of headroom, which is why the cap is 3600.
|
|
92
|
+
CV_VALIDATE_TIMEOUT_SECS="${MX_VALIDATE_TIMEOUT:-600}"
|
|
93
|
+
CV_DEVLOG_TIMEOUT_SECS="${MX_VALIDATE_DEVLOG_TIMEOUT:-60}"
|
|
76
94
|
FLAKE_LOG="${MX_VALIDATE_FLAKE_LOG:-$MX_VALIDATE_DIR/flakes.log}"
|
|
77
95
|
MAX_ISOLATE_FILES="${MX_VALIDATE_MAX_ISOLATE_FILES:-10}" # >this many failed files ⇒ real breakage
|
|
78
96
|
|
|
@@ -191,9 +209,28 @@ run_validate() {
|
|
|
191
209
|
# run and skip lint/build/the full parallel suite — silently turning the gate
|
|
192
210
|
# into a no-op. The deliberate retry below sets MX_VALIDATE_SERIAL explicitly,
|
|
193
211
|
# so nothing legitimate breaks.
|
|
194
|
-
|
|
212
|
+
timeout "$CV_VALIDATE_TIMEOUT_SECS" \
|
|
213
|
+
env -u MX_VALIDATE_SERIAL -u MX_VALIDATE_ISOLATE_FILES bash "$script_path" >"$out" 2>&1 || rc=$?
|
|
195
214
|
cat "$out" >&2
|
|
196
215
|
|
|
216
|
+
# A validation that could not finish has not validated anything, so a timeout
|
|
217
|
+
# BLOCKS — it does not fall through to the flake-retry path below and it is
|
|
218
|
+
# not absorbed as machine noise. This is deliberately fail-CLOSED, for the
|
|
219
|
+
# same reason the lock-wait timeout is: the outer harness timeout is fail-OPEN
|
|
220
|
+
# (a killed PreToolUse hook allows the tool call), so an unbounded run that
|
|
221
|
+
# outlived the harness would let the push through exactly when the machine is
|
|
222
|
+
# most degraded — the moment the gate matters most (#4846 review ruling 1).
|
|
223
|
+
if [[ $rc -eq 124 ]]; then
|
|
224
|
+
{
|
|
225
|
+
echo "✗ $label TIMED OUT after ${CV_VALIDATE_TIMEOUT_SECS}s — push BLOCKED (fail-closed)."
|
|
226
|
+
echo " The validation did not finish, so nothing about this push has been verified."
|
|
227
|
+
echo " Re-run it directly to see where it hangs: bash $script_path"
|
|
228
|
+
echo " If this package is genuinely slower than the budget, raise it:"
|
|
229
|
+
echo " MX_VALIDATE_TIMEOUT=<seconds> git push ..."
|
|
230
|
+
} >&2
|
|
231
|
+
FAILED=1; rm -f "$out"; return
|
|
232
|
+
fi
|
|
233
|
+
|
|
197
234
|
if [[ $rc -eq 0 ]]; then
|
|
198
235
|
echo "✓ $label passed" >&2
|
|
199
236
|
rm -f "$out"
|
|
@@ -253,9 +290,21 @@ run_validate() {
|
|
|
253
290
|
|
|
254
291
|
local iso_out; iso_out="$(mktemp)"
|
|
255
292
|
local iso_rc=0
|
|
256
|
-
MX_VALIDATE_SERIAL=1 bash "$script_path" >"$iso_out" 2>&1 || iso_rc=$?
|
|
293
|
+
MX_VALIDATE_SERIAL=1 timeout "$CV_VALIDATE_TIMEOUT_SECS" bash "$script_path" >"$iso_out" 2>&1 || iso_rc=$?
|
|
257
294
|
cat "$iso_out" >&2
|
|
258
295
|
|
|
296
|
+
# Same rule on the retry: a timed-out isolation run cannot absorb an under-load
|
|
297
|
+
# failure. The absorb condition below already requires iso_rc -eq 0, so 124
|
|
298
|
+
# blocks either way; this branch exists to say why rather than reporting the
|
|
299
|
+
# retry as a plain failure.
|
|
300
|
+
if [[ $iso_rc -eq 124 ]]; then
|
|
301
|
+
{
|
|
302
|
+
echo "✗ $label: isolation re-run TIMED OUT after ${CV_VALIDATE_TIMEOUT_SECS}s — push BLOCKED (fail-closed)."
|
|
303
|
+
echo " The under-load failures above could not be shown to be machine noise."
|
|
304
|
+
} >&2
|
|
305
|
+
FAILED=1; rm -f "$out" "$iso_out"; return
|
|
306
|
+
fi
|
|
307
|
+
|
|
259
308
|
local still_failing
|
|
260
309
|
still_failing="$(parse_failed_test_files "$iso_out")"
|
|
261
310
|
|
|
@@ -411,6 +460,12 @@ fi
|
|
|
411
460
|
# the wrong answer and the right answer coincide, which is why it went unnoticed.
|
|
412
461
|
#
|
|
413
462
|
# >>> SHARED push-target resolver v1 (#4803, #4808) — KEEP BYTE-IDENTICAL ─────
|
|
463
|
+
# Every git call in this resolver is bounded. An unbounded rev-parse on a
|
|
464
|
+
# wedged filesystem would burn the hook's whole harness timeout and then be
|
|
465
|
+
# killed — and a killed PreToolUse hook ALLOWS the tool call, so the push
|
|
466
|
+
# would go through unvalidated. Bounded, a hang instead lands on the existing
|
|
467
|
+
# MXPT_UNRESOLVED path, which already blocks and now says why (#4846 review).
|
|
468
|
+
MXPT_GIT_TIMEOUT_SECS="${MXPT_GIT_TIMEOUT_SECS:-10}"
|
|
414
469
|
# Duplicated verbatim in mx-guard-hook.sh and ci-validate-hook.sh, exactly the
|
|
415
470
|
# way PUSH_RE already is, and pinned byte-for-byte by push-target-parity.test.sh.
|
|
416
471
|
# Deliberately NOT a sourced library: each hook must stay a standalone file (that
|
|
@@ -570,7 +625,7 @@ if [ "${#MXPT_PUSH_RAWS[@]}" -eq 0 ]; then
|
|
|
570
625
|
MXPT_PUSH_REMOTE=(0)
|
|
571
626
|
fi
|
|
572
627
|
|
|
573
|
-
MXPT_BASE_TOP=$(git -C "$MXPT_BASE_DIR" rev-parse --show-toplevel 2>/dev/null) || MXPT_BASE_TOP="$MXPT_BASE_DIR"
|
|
628
|
+
MXPT_BASE_TOP=$(timeout "$MXPT_GIT_TIMEOUT_SECS" git -C "$MXPT_BASE_DIR" rev-parse --show-toplevel 2>/dev/null) || MXPT_BASE_TOP="$MXPT_BASE_DIR"
|
|
574
629
|
|
|
575
630
|
# Resolve every push segment. Remote segments are skipped first and never
|
|
576
631
|
# resolved (SF-1); the first local segment that cannot be resolved stops
|
|
@@ -606,8 +661,14 @@ for mxpt_i in "${!MXPT_PUSH_RAWS[@]}"; do
|
|
|
606
661
|
esac
|
|
607
662
|
if [ ! -d "$MXPT_CAND" ]; then
|
|
608
663
|
mxpt_why="no such directory on this machine"
|
|
609
|
-
|
|
610
|
-
|
|
664
|
+
else
|
|
665
|
+
mxpt_rc=0
|
|
666
|
+
mxpt_dir=$(timeout "$MXPT_GIT_TIMEOUT_SECS" git -C "$MXPT_CAND" rev-parse --show-toplevel 2>/dev/null) || mxpt_rc=$?
|
|
667
|
+
if [ "$mxpt_rc" = "124" ]; then
|
|
668
|
+
mxpt_why="git rev-parse did not answer within ${MXPT_GIT_TIMEOUT_SECS}s, so the tree could not be identified"
|
|
669
|
+
elif [ "$mxpt_rc" != "0" ]; then
|
|
670
|
+
mxpt_why="it is not inside a git work tree"
|
|
671
|
+
fi
|
|
611
672
|
fi ;;
|
|
612
673
|
esac
|
|
613
674
|
fi
|
|
@@ -708,8 +769,12 @@ fi
|
|
|
708
769
|
# ── Detect changed packages ──────────────────────────────────────────────────
|
|
709
770
|
# Use three-dot diff against origin/main to find files changed on this branch.
|
|
710
771
|
# Falls back to HEAD (single-commit diff) if origin/main isn't available.
|
|
711
|
-
|
|
712
|
-
|
|
772
|
+
# Both diffs are bounded so a contended index lock or a slow history walk cannot
|
|
773
|
+
# hold the Bash tool call open. On timeout the substitution is empty and we take
|
|
774
|
+
# the existing no-changed-files branch below: fail-open, unchanged.
|
|
775
|
+
CV_GIT_TIMEOUT_SECS="${CV_GIT_TIMEOUT_SECS:-15}"
|
|
776
|
+
CHANGED_FILES=$(timeout "$CV_GIT_TIMEOUT_SECS" git -C "$REPO_ROOT" diff --name-only "origin/main...HEAD" 2>/dev/null \
|
|
777
|
+
|| timeout "$CV_GIT_TIMEOUT_SECS" git -C "$REPO_ROOT" diff --name-only HEAD 2>/dev/null \
|
|
713
778
|
|| true)
|
|
714
779
|
|
|
715
780
|
if [[ -z "$CHANGED_FILES" ]]; then
|
|
@@ -730,7 +795,10 @@ if [[ -f "$DEVLOG_SCRIPT" ]]; then
|
|
|
730
795
|
DEVLOG_PATHS="$DEVLOG_PATHS $REPO_ROOT/$df"
|
|
731
796
|
done <<< "$DEVLOG_FILES"
|
|
732
797
|
# shellcheck disable=SC2086
|
|
733
|
-
|
|
798
|
+
# Bounded, and deliberately NOT fail-closed: this check is advisory, so a
|
|
799
|
+
# timeout warns exactly as a content failure does rather than blocking.
|
|
800
|
+
# shellcheck disable=SC2086
|
|
801
|
+
if ! timeout "$CV_DEVLOG_TIMEOUT_SECS" bash "$DEVLOG_SCRIPT" $DEVLOG_PATHS 2>&1; then
|
|
734
802
|
echo "ci-validate: NOTE — dev-log section check found issues (advisory, not blocking push)." >&2
|
|
735
803
|
fi
|
|
736
804
|
fi
|
|
@@ -206,14 +206,27 @@ if [ -n "$STDERR_CAP" ]; then
|
|
|
206
206
|
else
|
|
207
207
|
CAP_REDIR="/dev/null"
|
|
208
208
|
fi
|
|
209
|
-
timeout "${MX_COORD_BRIEF_TIMEOUT_SECS:-
|
|
209
|
+
timeout "${MX_COORD_BRIEF_TIMEOUT_SECS:-60}" \
|
|
210
210
|
env \
|
|
211
211
|
MX_COORD_SERVICE_URL="${MX_COORD_SERVICE_URL:-$COORD_URL_DEFAULT}" \
|
|
212
212
|
MX_COORD_SERVICE_TOKEN="$TOKEN" \
|
|
213
213
|
MX_COORD_EXPECT_TEAM="$SLUG" \
|
|
214
214
|
mx-agent coordination brief 2>"$CAP_REDIR" || status=$?
|
|
215
215
|
if [ "$status" -eq 124 ]; then
|
|
216
|
-
|
|
216
|
+
# LOUD BY DESIGN (#4846 SF-25). Everything else in this hook is quietly
|
|
217
|
+
# fail-open, and this branch must not be: a silent timeout is indistinguishable
|
|
218
|
+
# from an empty queue, so the agent reads "no escalations" when the truth is
|
|
219
|
+
# "delivery failed". The drain is destructive server-side, so messages may have
|
|
220
|
+
# been marked delivered without ever being shown. Say so, and say what to run.
|
|
221
|
+
{
|
|
222
|
+
echo "coordination brief: DRAIN DID NOT COMPLETE within ${MX_COORD_BRIEF_TIMEOUT_SECS:-60}s."
|
|
223
|
+
echo " QUEUE STATE UNKNOWN — this is NOT the same as an empty queue."
|
|
224
|
+
echo " Escalations addressed to this team may be undelivered, and because the"
|
|
225
|
+
echo " drain consumes messages server-side, some may already be marked"
|
|
226
|
+
echo " delivered without having been shown to you."
|
|
227
|
+
echo " Before relying on 'no escalations', run: mx-agent coordination history"
|
|
228
|
+
echo " Raise the bound with MX_COORD_BRIEF_TIMEOUT_SECS if the queue is deep."
|
|
229
|
+
} >&2
|
|
217
230
|
elif [ "$status" -ne 0 ]; then
|
|
218
231
|
# Non-timeout failure. ONLY the CLI-too-old case is announced; every other
|
|
219
232
|
# failure stays silently fail-open (a coordination hiccup must not be noise).
|
|
@@ -96,6 +96,19 @@ if [ "$STATUS" -ne 0 ]; then
|
|
|
96
96
|
# the `--min-priority` option → Commander exits non-zero). Fail-open and do NOT
|
|
97
97
|
# update the throttle, so the next turn retries. We deliberately do NOT retry
|
|
98
98
|
# without --min-priority: an unfiltered drain would consume P3s the brief owns.
|
|
99
|
+
#
|
|
100
|
+
# A TIMEOUT IS ANNOUNCED (#4846 SF-25). Failing silently here makes a failed
|
|
101
|
+
# drain look exactly like an empty queue. The retry next turn usually repairs
|
|
102
|
+
# it, which is why this is a note rather than a block — but the agent has to be
|
|
103
|
+
# able to tell the two apart in the meantime. Other non-zero statuses stay
|
|
104
|
+
# quiet: an old CLI would otherwise print this on every single turn.
|
|
105
|
+
if [ "$STATUS" -eq 124 ]; then
|
|
106
|
+
{
|
|
107
|
+
echo "coordination drain: DID NOT COMPLETE within ${TIMEOUT_SECS}s — queue state unknown."
|
|
108
|
+
echo " Not an empty queue. Retrying next turn; if it persists, run:"
|
|
109
|
+
echo " mx-agent coordination history"
|
|
110
|
+
} >&2
|
|
111
|
+
fi
|
|
99
112
|
exit 0
|
|
100
113
|
fi
|
|
101
114
|
|
|
@@ -253,7 +253,11 @@ fi
|
|
|
253
253
|
# behaviour change. Only runs on the reminder path, never the hot Bash path.
|
|
254
254
|
CLI_PACKAGE="${MX_CLI_PACKAGE:-}"
|
|
255
255
|
if [ -z "$CLI_PACKAGE" ]; then
|
|
256
|
-
|
|
256
|
+
# Bounded (#4846 review): only reached when CLAUDE_PROJECT_DIR is unset, but a
|
|
257
|
+
# rev-parse on a wedged filesystem would otherwise hold this hook open. On
|
|
258
|
+
# timeout DVR_ROOT is empty and the config lookup below is skipped, which is
|
|
259
|
+
# the same path as "no config file" — the reminder still fires.
|
|
260
|
+
DVR_ROOT="${CLAUDE_PROJECT_DIR:-$(timeout "${DVR_GIT_TIMEOUT_SECS:-5}" git rev-parse --show-toplevel 2>/dev/null || true)}"
|
|
257
261
|
DVR_CFG="${DVR_ROOT}/mx-agent.config.json"
|
|
258
262
|
if [ -n "$DVR_ROOT" ] && [ -f "$DVR_CFG" ] && command -v jq >/dev/null 2>&1; then
|
|
259
263
|
CLI_PACKAGE="$(jq -r '.cliPackage // empty' "$DVR_CFG" 2>/dev/null || true)"
|
|
@@ -139,7 +139,14 @@ if [[ "$CURRENT" -ge "$THRESHOLD" ]]; then
|
|
|
139
139
|
# a `find` on the hot path would tax all 50 for work that matters once. Bounded
|
|
140
140
|
# by -maxdepth 1 and a fixed name pattern; best-effort, errors ignored (other
|
|
141
141
|
# users' files are simply not ours to delete).
|
|
142
|
-
|
|
142
|
+
# Bounded (#4846 review). This is the one call in this hook that touches a
|
|
143
|
+
# directory it does not own the size of: /tmp on a loaded machine can hold
|
|
144
|
+
# enough entries for the sweep to run for seconds, and this hook's harness
|
|
145
|
+
# timeout is the thing standing between a slow sweep and a lost reminder.
|
|
146
|
+
# Best-effort either way — on timeout the stale files are simply swept on a
|
|
147
|
+
# later run, which is what `|| true` already meant for any other failure.
|
|
148
|
+
timeout "${MCR_SWEEP_TIMEOUT_SECS:-5}" \
|
|
149
|
+
find /tmp -maxdepth 1 -name '.mx-checkpoint-counter-*.session-*' -mmin +1440 -delete 2>/dev/null || true
|
|
143
150
|
|
|
144
151
|
# ── 3a. Resolve codeContext for the suggested command (#4652) ──────────────
|
|
145
152
|
# Deliberately INSIDE the threshold branch. This hook runs on every single
|
|
@@ -38,6 +38,8 @@
|
|
|
38
38
|
# `git -C /treeA push && git -C /treeB push` pushed unlinted. Every push
|
|
39
39
|
# segment is now resolved and every distinct toplevel linted.
|
|
40
40
|
|
|
41
|
+
|
|
42
|
+
|
|
41
43
|
# Read hook input from stdin
|
|
42
44
|
INPUT=$(cat)
|
|
43
45
|
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty')
|
|
@@ -92,6 +94,12 @@ fi
|
|
|
92
94
|
# #4803 test fails against it.
|
|
93
95
|
|
|
94
96
|
# >>> SHARED push-target resolver v1 (#4803, #4808) — KEEP BYTE-IDENTICAL ─────
|
|
97
|
+
# Every git call in this resolver is bounded. An unbounded rev-parse on a
|
|
98
|
+
# wedged filesystem would burn the hook's whole harness timeout and then be
|
|
99
|
+
# killed — and a killed PreToolUse hook ALLOWS the tool call, so the push
|
|
100
|
+
# would go through unvalidated. Bounded, a hang instead lands on the existing
|
|
101
|
+
# MXPT_UNRESOLVED path, which already blocks and now says why (#4846 review).
|
|
102
|
+
MXPT_GIT_TIMEOUT_SECS="${MXPT_GIT_TIMEOUT_SECS:-10}"
|
|
95
103
|
# Duplicated verbatim in mx-guard-hook.sh and ci-validate-hook.sh, exactly the
|
|
96
104
|
# way PUSH_RE already is, and pinned byte-for-byte by push-target-parity.test.sh.
|
|
97
105
|
# Deliberately NOT a sourced library: each hook must stay a standalone file (that
|
|
@@ -251,7 +259,7 @@ if [ "${#MXPT_PUSH_RAWS[@]}" -eq 0 ]; then
|
|
|
251
259
|
MXPT_PUSH_REMOTE=(0)
|
|
252
260
|
fi
|
|
253
261
|
|
|
254
|
-
MXPT_BASE_TOP=$(git -C "$MXPT_BASE_DIR" rev-parse --show-toplevel 2>/dev/null) || MXPT_BASE_TOP="$MXPT_BASE_DIR"
|
|
262
|
+
MXPT_BASE_TOP=$(timeout "$MXPT_GIT_TIMEOUT_SECS" git -C "$MXPT_BASE_DIR" rev-parse --show-toplevel 2>/dev/null) || MXPT_BASE_TOP="$MXPT_BASE_DIR"
|
|
255
263
|
|
|
256
264
|
# Resolve every push segment. Remote segments are skipped first and never
|
|
257
265
|
# resolved (SF-1); the first local segment that cannot be resolved stops
|
|
@@ -287,8 +295,14 @@ for mxpt_i in "${!MXPT_PUSH_RAWS[@]}"; do
|
|
|
287
295
|
esac
|
|
288
296
|
if [ ! -d "$MXPT_CAND" ]; then
|
|
289
297
|
mxpt_why="no such directory on this machine"
|
|
290
|
-
|
|
291
|
-
|
|
298
|
+
else
|
|
299
|
+
mxpt_rc=0
|
|
300
|
+
mxpt_dir=$(timeout "$MXPT_GIT_TIMEOUT_SECS" git -C "$MXPT_CAND" rev-parse --show-toplevel 2>/dev/null) || mxpt_rc=$?
|
|
301
|
+
if [ "$mxpt_rc" = "124" ]; then
|
|
302
|
+
mxpt_why="git rev-parse did not answer within ${MXPT_GIT_TIMEOUT_SECS}s, so the tree could not be identified"
|
|
303
|
+
elif [ "$mxpt_rc" != "0" ]; then
|
|
304
|
+
mxpt_why="it is not inside a git work tree"
|
|
305
|
+
fi
|
|
292
306
|
fi ;;
|
|
293
307
|
esac
|
|
294
308
|
fi
|
|
@@ -381,7 +395,12 @@ if ! cd "$TARGET_DIR"; then
|
|
|
381
395
|
fi
|
|
382
396
|
# <<< #4803 END push-target resolution
|
|
383
397
|
|
|
384
|
-
|
|
398
|
+
# Bounded so a wedged lint cannot hold the Bash tool call open. The bound is
|
|
399
|
+
# internal, not the harness `timeout` in settings.json, because a harness
|
|
400
|
+
# timeout kills the hook and ALLOWS the push — the one outcome a guard must not
|
|
401
|
+
# have. At 124 we stay on the existing non-zero path and still block.
|
|
402
|
+
MX_GUARD_CHECK_TIMEOUT_SECS="${MX_GUARD_CHECK_TIMEOUT_SECS:-120}"
|
|
403
|
+
timeout "$MX_GUARD_CHECK_TIMEOUT_SECS" mx-guard check >&2
|
|
385
404
|
GUARD_EXIT=$?
|
|
386
405
|
if [ "${MXG_PRIOR_FAIL:-0}" -ne 0 ]; then
|
|
387
406
|
GUARD_EXIT=1
|
|
@@ -390,6 +409,13 @@ fi
|
|
|
390
409
|
if [ $GUARD_EXIT -ne 0 ]; then
|
|
391
410
|
{
|
|
392
411
|
echo ""
|
|
412
|
+
if [ $GUARD_EXIT -eq 124 ]; then
|
|
413
|
+
echo "mx-guard: push blocked — mx-guard check did not finish within"
|
|
414
|
+
echo "${MX_GUARD_CHECK_TIMEOUT_SECS}s, so this push is unvalidated. Re-run"
|
|
415
|
+
echo "'mx-guard check' directly to see where it hangs; raise the bound with"
|
|
416
|
+
echo "MX_GUARD_CHECK_TIMEOUT_SECS if the tree is genuinely that slow to lint."
|
|
417
|
+
echo ""
|
|
418
|
+
fi
|
|
393
419
|
echo "mx-guard: push blocked. Fix the errors above before pushing."
|
|
394
420
|
echo " To check specific rules: mx-guard check --rule <category>"
|
|
395
421
|
echo " To see all rules: mx-guard rules"
|
|
@@ -220,6 +220,11 @@ HEAD_LEN=$(printf '%s' "$HEAD_JSON" | sed -n '/{/,$p' | jq -r '(.content // "")
|
|
|
220
220
|
# log the event so we can see how often the head is unreadable.
|
|
221
221
|
if [[ -z "$HEAD_LEN" || ! "$HEAD_LEN" =~ ^[0-9]+$ || "$HEAD_LEN" -eq 0 ]]; then
|
|
222
222
|
emit_telemetry "$NAME" "fetch-fail" "$NEW_LEN" "no" "fetch-fail"
|
|
223
|
+
# Announced as well as recorded (#4846 SF-25). The telemetry line is for us
|
|
224
|
+
# later; the agent needs to know NOW that the shrink check did not run, because
|
|
225
|
+
# a fetch failure is indistinguishable from "no existing head" and the write
|
|
226
|
+
# proceeds unguarded either way.
|
|
227
|
+
echo "named-memory-write-guard: could not read the current head of '${NAME_SAFE}' — shrink check SKIPPED, write allowed unguarded." >&2
|
|
223
228
|
exit 0
|
|
224
229
|
fi
|
|
225
230
|
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
# Logs sync failures to the local startup JSONL so they are visible at next session start.
|
|
4
4
|
# FAIL-OPEN: always exits 0 regardless of sync outcome.
|
|
5
5
|
|
|
6
|
+
|
|
7
|
+
|
|
6
8
|
set -euo pipefail
|
|
7
9
|
|
|
8
10
|
WORKTREE_PATH="${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null || echo '')}"
|
|
@@ -16,7 +18,11 @@ LOG_FILE="$LOG_DIR/${WORKTREE_NAME}.jsonl"
|
|
|
16
18
|
# Run the sync, capture exit code
|
|
17
19
|
SYNC_OUTPUT=""
|
|
18
20
|
SYNC_EXIT=0
|
|
19
|
-
|
|
21
|
+
# Bounded: this is a network call to the observability API. Without a bound a
|
|
22
|
+
# hung or black-holed connection holds the Stop hook open. On timeout `timeout`
|
|
23
|
+
# exits 124, which lands on the existing failure path below — logged to the
|
|
24
|
+
# startup JSONL, still exit 0. Fail-open contract unchanged.
|
|
25
|
+
SYNC_OUTPUT=$(timeout "${OBS_SYNC_TIMEOUT_SECS:-25}" mx-agent sync --api-url "$API_URL" --quiet 2>&1) || SYNC_EXIT=$?
|
|
20
26
|
|
|
21
27
|
if [ "$SYNC_EXIT" -ne 0 ]; then
|
|
22
28
|
# Log failure to the local startup JSONL (v2.58 infrastructure)
|
|
@@ -32,12 +32,22 @@ command -v mx >/dev/null 2>&1 || exit 0
|
|
|
32
32
|
|
|
33
33
|
# ── 2. Retrieve checkpoint memory ───────────────────────────────────────
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
# Bounded: network read. On timeout the result is empty and the next test exits
|
|
36
|
+
# 0 without injecting a checkpoint — the same path as "no checkpoint found".
|
|
37
|
+
CHECKPOINT=$(timeout "${RELOAD_CHECKPOINT_TIMEOUT_SECS:-15}" mx memories get --name "auto-checkpoint-${WORKTREE_NAME}" --format json --detail minimal 2>/dev/null || true)
|
|
38
|
+
|
|
39
|
+
if [[ -z "$CHECKPOINT" ]]; then
|
|
40
|
+
# Announced (#4846 SF-25): an empty result here is either "no checkpoint was
|
|
41
|
+
# saved" or "the fetch failed", and the agent resumes from compaction either
|
|
42
|
+
# way. Only the second case means context it should have had is missing.
|
|
43
|
+
echo "reload-checkpoint: could not read auto-checkpoint-${WORKTREE_NAME} (fetch failed or timed out) — resuming without it." >&2
|
|
38
44
|
exit 0
|
|
39
45
|
fi
|
|
40
46
|
|
|
47
|
+
if [[ "$CHECKPOINT" == *"not found"* || "$CHECKPOINT" == *"404"* ]]; then
|
|
48
|
+
exit 0 # Genuinely no checkpoint saved — nothing to announce.
|
|
49
|
+
fi
|
|
50
|
+
|
|
41
51
|
# Extract just the content field from the JSON response
|
|
42
52
|
CONTENT=$(echo "$CHECKPOINT" | jq -r '.content // empty' 2>/dev/null)
|
|
43
53
|
|
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
# 0 = allow
|
|
22
22
|
# 2 = block (path filters explain why CI didn't trigger — dispatch not needed)
|
|
23
23
|
|
|
24
|
+
|
|
25
|
+
|
|
24
26
|
# Fail-open: any unexpected error → allow the command through
|
|
25
27
|
trap 'exit 0' ERR
|
|
26
28
|
|
|
@@ -68,7 +70,11 @@ WORKFLOW_FILE="$REPO_ROOT/.github/workflows/$WORKFLOW_NAME"
|
|
|
68
70
|
if [[ ! -f "$WORKFLOW_FILE" ]]; then
|
|
69
71
|
# Selector may be a display name or numeric ID — try resolving via gh CLI
|
|
70
72
|
if command -v gh &>/dev/null; then
|
|
71
|
-
|
|
73
|
+
# Network call to the GitHub API — bounded so an unreachable or slow API
|
|
74
|
+
# cannot hold the Bash tool call open. On timeout `timeout` exits 124, the
|
|
75
|
+
# substitution is empty, and we take the existing unresolvable-selector
|
|
76
|
+
# branch below: fail-open, unchanged.
|
|
77
|
+
RESOLVED_PATH=$(timeout "${WDG_GH_TIMEOUT_SECS:-10}" gh workflow view "$WORKFLOW_NAME" --json path -q .path 2>/dev/null || true)
|
|
72
78
|
if [[ -n "$RESOLVED_PATH" && -f "$REPO_ROOT/$RESOLVED_PATH" ]]; then
|
|
73
79
|
WORKFLOW_FILE="$REPO_ROOT/$RESOLVED_PATH"
|
|
74
80
|
else
|
|
@@ -130,7 +136,10 @@ if [[ -z "$PATH_FILTERS" ]]; then
|
|
|
130
136
|
fi
|
|
131
137
|
|
|
132
138
|
# ── Get changed files on this branch ─────────────────────────────────────────
|
|
133
|
-
|
|
139
|
+
# Bounded: a three-dot diff walks history and can be slow on a large repo or a
|
|
140
|
+
# contended index lock. On timeout the result is empty and we take the existing
|
|
141
|
+
# can't-determine-changed-files branch: fail-open, unchanged.
|
|
142
|
+
CHANGED_FILES=$(timeout "${WDG_GIT_TIMEOUT_SECS:-15}" git -C "$REPO_ROOT" diff --name-only "origin/main...HEAD" 2>/dev/null || true)
|
|
134
143
|
|
|
135
144
|
if [[ -z "$CHANGED_FILES" ]]; then
|
|
136
145
|
exit 0 # Can't determine changed files — fail-open
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
"hooks": [
|
|
8
8
|
{
|
|
9
9
|
"type": "command",
|
|
10
|
-
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/memory-checkpoint-reminder.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'"
|
|
10
|
+
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/memory-checkpoint-reminder.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'",
|
|
11
|
+
"timeout": 60
|
|
11
12
|
}
|
|
12
13
|
]
|
|
13
14
|
},
|
|
@@ -16,31 +17,38 @@
|
|
|
16
17
|
"hooks": [
|
|
17
18
|
{
|
|
18
19
|
"type": "command",
|
|
19
|
-
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/worktree-guard.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'"
|
|
20
|
+
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/worktree-guard.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'",
|
|
21
|
+
"timeout": 60
|
|
20
22
|
},
|
|
21
23
|
{
|
|
22
24
|
"type": "command",
|
|
23
|
-
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/mx-guard-hook.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'"
|
|
25
|
+
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/mx-guard-hook.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'",
|
|
26
|
+
"timeout": 300
|
|
24
27
|
},
|
|
25
28
|
{
|
|
26
29
|
"type": "command",
|
|
27
|
-
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/ci-validate-hook.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'"
|
|
30
|
+
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/ci-validate-hook.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'",
|
|
31
|
+
"timeout": 3600
|
|
28
32
|
},
|
|
29
33
|
{
|
|
30
34
|
"type": "command",
|
|
31
|
-
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/workflow-dispatch-guard.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'"
|
|
35
|
+
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/workflow-dispatch-guard.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'",
|
|
36
|
+
"timeout": 60
|
|
32
37
|
},
|
|
33
38
|
{
|
|
34
39
|
"type": "command",
|
|
35
|
-
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/git-mutation-guard.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'"
|
|
40
|
+
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/git-mutation-guard.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'",
|
|
41
|
+
"timeout": 60
|
|
36
42
|
},
|
|
37
43
|
{
|
|
38
44
|
"type": "command",
|
|
39
|
-
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/named-memory-write-guard.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'"
|
|
45
|
+
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/named-memory-write-guard.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'",
|
|
46
|
+
"timeout": 60
|
|
40
47
|
},
|
|
41
48
|
{
|
|
42
49
|
"type": "command",
|
|
43
|
-
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/gh-pr-edit-guard.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'"
|
|
50
|
+
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/gh-pr-edit-guard.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'",
|
|
51
|
+
"timeout": 60
|
|
44
52
|
}
|
|
45
53
|
]
|
|
46
54
|
}
|
|
@@ -51,7 +59,8 @@
|
|
|
51
59
|
"hooks": [
|
|
52
60
|
{
|
|
53
61
|
"type": "command",
|
|
54
|
-
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/deploy-verification-reminder.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'"
|
|
62
|
+
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/deploy-verification-reminder.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'",
|
|
63
|
+
"timeout": 60
|
|
55
64
|
}
|
|
56
65
|
]
|
|
57
66
|
}
|
|
@@ -62,11 +71,13 @@
|
|
|
62
71
|
"hooks": [
|
|
63
72
|
{
|
|
64
73
|
"type": "command",
|
|
65
|
-
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/auto-checkpoint.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'"
|
|
74
|
+
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/auto-checkpoint.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'",
|
|
75
|
+
"timeout": 30
|
|
66
76
|
},
|
|
67
77
|
{
|
|
68
78
|
"type": "command",
|
|
69
|
-
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/auto-capture-precompact.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'"
|
|
79
|
+
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/auto-capture-precompact.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'",
|
|
80
|
+
"timeout": 30
|
|
70
81
|
}
|
|
71
82
|
]
|
|
72
83
|
}
|
|
@@ -77,7 +88,8 @@
|
|
|
77
88
|
"hooks": [
|
|
78
89
|
{
|
|
79
90
|
"type": "command",
|
|
80
|
-
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/reload-checkpoint.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'"
|
|
91
|
+
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/reload-checkpoint.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'",
|
|
92
|
+
"timeout": 20
|
|
81
93
|
}
|
|
82
94
|
]
|
|
83
95
|
},
|
|
@@ -86,11 +98,13 @@
|
|
|
86
98
|
"hooks": [
|
|
87
99
|
{
|
|
88
100
|
"type": "command",
|
|
89
|
-
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/set-terminal-appearance.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'"
|
|
101
|
+
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/set-terminal-appearance.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'",
|
|
102
|
+
"timeout": 5
|
|
90
103
|
},
|
|
91
104
|
{
|
|
92
105
|
"type": "command",
|
|
93
|
-
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/coordination-brief.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'"
|
|
106
|
+
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/coordination-brief.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'",
|
|
107
|
+
"timeout": 180
|
|
94
108
|
}
|
|
95
109
|
]
|
|
96
110
|
}
|
|
@@ -100,27 +114,33 @@
|
|
|
100
114
|
"hooks": [
|
|
101
115
|
{
|
|
102
116
|
"type": "command",
|
|
103
|
-
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/observability-sync.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'"
|
|
117
|
+
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/observability-sync.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'",
|
|
118
|
+
"timeout": 30
|
|
104
119
|
},
|
|
105
120
|
{
|
|
106
121
|
"type": "command",
|
|
107
|
-
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/auto-capture-session-end.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'"
|
|
122
|
+
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/auto-capture-session-end.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'",
|
|
123
|
+
"timeout": 30
|
|
108
124
|
},
|
|
109
125
|
{
|
|
110
126
|
"type": "command",
|
|
111
|
-
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/delegation-audit.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'"
|
|
127
|
+
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/delegation-audit.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'",
|
|
128
|
+
"timeout": 15
|
|
112
129
|
},
|
|
113
130
|
{
|
|
114
131
|
"type": "command",
|
|
115
|
-
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/iteration-log-check.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'"
|
|
132
|
+
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/iteration-log-check.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'",
|
|
133
|
+
"timeout": 20
|
|
116
134
|
},
|
|
117
135
|
{
|
|
118
136
|
"type": "command",
|
|
119
|
-
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/coordination-midsession-drain.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'"
|
|
137
|
+
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/coordination-midsession-drain.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'",
|
|
138
|
+
"timeout": 30
|
|
120
139
|
},
|
|
121
140
|
{
|
|
122
141
|
"type": "command",
|
|
123
|
-
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/session-idle-gate.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'"
|
|
142
|
+
"command": "bash -c 'H=\"${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}/.claude/hooks/session-idle-gate.sh\"; [ -f \"$H\" ] && exec bash \"$H\" || exit 0'",
|
|
143
|
+
"timeout": 60
|
|
124
144
|
}
|
|
125
145
|
]
|
|
126
146
|
}
|