@memnexus-ai/cli 1.7.234 → 1.7.236

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.
@@ -1,465 +0,0 @@
1
- #!/bin/bash
2
- # capture-hooks.test.sh — regression suite for the v4.04 error-honesty fixes in
3
- # the customer-shipped capture hooks (capture-session-end.sh,
4
- # capture-precompact.sh) and the dev-tools auto-save hook.
5
- #
6
- # Run with: bash cli/hooks/capture-hooks.test.sh
7
- # Exit: 0 = all pass, 1 = any fail.
8
- #
9
- # What is under test:
10
- # * a FAILED `mx memories create` must leave the debounce watermark alone, so
11
- # the segment is retried instead of being discarded forever
12
- # * a SUCCESSFUL create must advance the watermark
13
- # * the project-hash fallback chain must actually fall back (the old form
14
- # piped into awk and therefore tested awk's exit status, never the hasher's)
15
- # * with no hasher at all, the hook must skip rather than write a state file
16
- # shared by every project
17
- # * every hook still exits 0 in all of these cases (fail-open with Claude Code)
18
- set -u
19
-
20
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
21
- REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
22
- SESSION_END_HOOK="$SCRIPT_DIR/capture-session-end.sh"
23
- PRECOMPACT_HOOK="$SCRIPT_DIR/capture-precompact.sh"
24
- AUTOSAVE_HOOK="$REPO_ROOT/dev-tools/claude-hooks/auto-save-memory.sh"
25
-
26
- PASS=0
27
- FAIL=0
28
-
29
- ok() {
30
- PASS=$((PASS + 1))
31
- echo " PASS: $1"
32
- }
33
-
34
- nope() {
35
- FAIL=$((FAIL + 1))
36
- echo " FAIL: $1"
37
- [[ $# -gt 1 ]] && echo " $2"
38
- }
39
-
40
- assert_eq() { # <expected> <actual> <label>
41
- if [[ "$1" == "$2" ]]; then ok "$3"; else nope "$3" "expected [$1], got [$2]"; fi
42
- }
43
-
44
- assert_contains() { # <haystack> <needle> <label>
45
- if [[ "$1" == *"$2"* ]]; then ok "$3"; else nope "$3" "missing [$2] in: $1"; fi
46
- }
47
-
48
- # ── Fixtures ────────────────────────────────────────────────────────────────
49
-
50
- # A stub `mx` whose exit status is controlled by MX_STUB_EXIT. Every call is
51
- # appended to MX_STUB_LOG so a test can assert that no create was even
52
- # attempted (the bounded-retry cap).
53
- make_stub_bin() { # <dir>
54
- local bin="$1"
55
- mkdir -p "$bin"
56
- cat >"$bin/mx" <<'STUB'
57
- #!/bin/bash
58
- [[ -n "${MX_STUB_LOG:-}" ]] && echo "call" >>"$MX_STUB_LOG"
59
- exit "${MX_STUB_EXIT:-0}"
60
- STUB
61
- chmod +x "$bin/mx"
62
- }
63
-
64
- # A transcript with enough lines (>100) and tool calls (>=5) to clear the
65
- # hooks' debounce and triviality gates.
66
- make_transcript() { # <path> <lines>
67
- local path="$1" lines="${2:-150}" i
68
- : >"$path"
69
- for ((i = 0; i < lines; i++)); do
70
- printf '%s\n' '{"type":"user","message":{"content":"do the thing"}}' >>"$path"
71
- printf '%s\n' '{"type":"assistant","message":{"content":[{"type":"tool_use","name":"Write","input":{"file_path":"/tmp/x.ts"}},{"type":"text","text":"done"}]}}' >>"$path"
72
- done
73
- }
74
-
75
- # Run capture-session-end.sh in an isolated HOME/state dir.
76
- # Echoes the watermark file's contents (empty when absent).
77
- run_session_end() { # <workdir> <path-override> ; uses MX_STUB_EXIT
78
- local work="$1" path_override="$2"
79
- local transcript="$work/transcript.jsonl"
80
- ( cd "$work" && PATH="$path_override" HOME="$work/home" XDG_RUNTIME_DIR="$work/state" \
81
- MX_STUB_LOG="$work/mx-calls.log" \
82
- bash "$SESSION_END_HOOK" \
83
- <<<"{\"transcript_path\":\"$transcript\",\"session_id\":\"s1\",\"stop_hook_active\":false}" \
84
- 2>"$work/stderr.txt" )
85
- echo "$?" >"$work/exit.txt"
86
- }
87
-
88
- # Contents of the watermark file (empty when absent). The sibling ".fails"
89
- # counter is excluded — it lives next to the watermark and must not be mistaken
90
- # for it. Globs, not `ls`: an unmatched glob yields the literal pattern, which
91
- # the -f test filters out.
92
- state_file_contents() { # <workdir>
93
- local f
94
- for f in "$1"/state/.mx-session-capture-*; do
95
- [[ -f "$f" ]] || continue
96
- [[ "$f" == *.fails ]] && continue
97
- cat "$f"
98
- return 0
99
- done
100
- return 0
101
- }
102
-
103
- fail_count_contents() { # <workdir>
104
- local f
105
- for f in "$1"/state/.mx-session-capture-*.fails; do
106
- [[ -f "$f" ]] || continue
107
- cat "$f"
108
- return 0
109
- done
110
- return 0
111
- }
112
-
113
- # Space-separated basenames of everything in the state dir — failure diagnostics
114
- # only. Dotfiles are matched explicitly because the state files are hidden.
115
- list_state_dir() { # <workdir>
116
- local f out=""
117
- for f in "$1"/state/* "$1"/state/.[!.]*; do
118
- [[ -e "$f" ]] || continue
119
- out+="$(basename "$f") "
120
- done
121
- printf '%s' "$out"
122
- }
123
-
124
- # Number of `mx` invocations recorded by the stub (0 when it was never called).
125
- count_mx_calls() { # <workdir>
126
- local log="$1/mx-calls.log"
127
- [[ -f "$log" ]] || { echo 0; return 0; }
128
- wc -l <"$log" | tr -d ' '
129
- }
130
-
131
- REAL_PATH="$PATH"
132
-
133
- # Build a shadow PATH directory: every executable on the current PATH symlinked
134
- # in, MINUS the named tools. Used to simulate a machine without md5sum (or
135
- # without any hasher) while leaving the rest of the environment intact.
136
- make_shadow_path() { # <dir> <tool-to-omit>...
137
- local dir="$1"; shift
138
- local omit=" $* "
139
- local d f name
140
- mkdir -p "$dir"
141
- local IFS=:
142
- for d in $REAL_PATH; do
143
- [[ -d "$d" ]] || continue
144
- for f in "$d"/*; do
145
- [[ -x "$f" && ! -d "$f" ]] || continue
146
- name="$(basename "$f")"
147
- [[ "$omit" == *" $name "* ]] && continue
148
- [[ -e "$dir/$name" ]] && continue
149
- ln -sf "$f" "$dir/$name"
150
- done
151
- done
152
- }
153
-
154
-
155
- echo "── capture-session-end.sh ──"
156
-
157
- # 1. Failed create → watermark unchanged.
158
- work=$(mktemp -d)
159
- make_stub_bin "$work/bin"
160
- make_transcript "$work/transcript.jsonl"
161
- mkdir -p "$work/state" "$work/home"
162
- MX_STUB_EXIT=1 run_session_end "$work" "$work/bin:$REAL_PATH"
163
- assert_eq "0" "$(cat "$work/exit.txt")" "fail-open: hook exits 0 when create fails"
164
- assert_eq "" "$(state_file_contents "$work")" "failed create leaves the watermark unwritten"
165
- assert_contains "$(cat "$work/stderr.txt")" "mx memories create failed" \
166
- "failed create writes one stderr diagnostic"
167
- rm -rf "$work"
168
-
169
- # 2. Successful create → watermark advances to the transcript's line count.
170
- work=$(mktemp -d)
171
- make_stub_bin "$work/bin"
172
- make_transcript "$work/transcript.jsonl"
173
- mkdir -p "$work/state" "$work/home"
174
- MX_STUB_EXIT=0 run_session_end "$work" "$work/bin:$REAL_PATH"
175
- assert_eq "0" "$(cat "$work/exit.txt")" "hook exits 0 on success"
176
- assert_eq "300" "$(state_file_contents "$work")" "successful create advances the watermark"
177
- rm -rf "$work"
178
-
179
- # 3. Retry semantics: a failed run followed by a successful one saves the same
180
- # segment (the watermark only moves on the success).
181
- work=$(mktemp -d)
182
- make_stub_bin "$work/bin"
183
- make_transcript "$work/transcript.jsonl"
184
- mkdir -p "$work/state" "$work/home"
185
- MX_STUB_EXIT=1 run_session_end "$work" "$work/bin:$REAL_PATH"
186
- first="$(state_file_contents "$work")"
187
- MX_STUB_EXIT=0 run_session_end "$work" "$work/bin:$REAL_PATH"
188
- second="$(state_file_contents "$work")"
189
- assert_eq "" "$first" "first (failed) run: no watermark"
190
- assert_eq "300" "$second" "second (successful) run: watermark advances — segment was retried"
191
- rm -rf "$work"
192
-
193
- # 4. The default hasher is sha256sum (cksum was dropped from the chain: a
194
- # 32-bit CRC collision would make two projects share a state file).
195
- work=$(mktemp -d)
196
- make_stub_bin "$work/bin"
197
- make_transcript "$work/transcript.jsonl"
198
- mkdir -p "$work/state" "$work/home"
199
- MX_STUB_EXIT=0 run_session_end "$work" "$work/bin:$REAL_PATH"
200
- expected_hash=$(printf '%s' "$work" | sha256sum | awk '{print $1}')
201
- if [[ -f "$work/state/.mx-session-capture-${expected_hash}" ]]; then
202
- ok "state file is keyed by the sha256 of the project dir"
203
- else
204
- nope "state file is keyed by the sha256 of the project dir" \
205
- "state dir holds: $(list_state_dir "$work")"
206
- fi
207
- rm -rf "$work"
208
-
209
- # 4b. sha256sum absent → the md5sum fallback engages (the old awk-piped chain
210
- # silently produced an EMPTY hash shared by every project).
211
- work=$(mktemp -d)
212
- make_stub_bin "$work/bin"
213
- make_transcript "$work/transcript.jsonl"
214
- mkdir -p "$work/state" "$work/home"
215
- make_shadow_path "$work/nosha" sha256sum
216
- MX_STUB_EXIT=0 run_session_end "$work" "$work/bin:$work/nosha"
217
- expected_hash=$(printf '%s' "$work" | md5sum | awk '{print $1}')
218
- if [[ -f "$work/state/.mx-session-capture-${expected_hash}" ]]; then
219
- ok "sha256sum absent: md5sum fallback produces the project-specific state file"
220
- else
221
- nope "sha256sum absent: md5sum fallback engages" \
222
- "state dir holds: $(list_state_dir "$work")"
223
- fi
224
- rm -rf "$work"
225
-
226
- # 4c. cksum alone is NOT accepted (32-bit CRC — collisions are constructible).
227
- work=$(mktemp -d)
228
- make_stub_bin "$work/bin"
229
- make_transcript "$work/transcript.jsonl"
230
- mkdir -p "$work/state" "$work/home"
231
- make_shadow_path "$work/onlycksum" sha256sum md5sum shasum b2sum
232
- MX_STUB_EXIT=0 run_session_end "$work" "$work/bin:$work/onlycksum"
233
- assert_eq "" "$(ls -A "$work/state" 2>/dev/null)" "cksum-only machine: skips rather than using a 32-bit CRC"
234
- rm -rf "$work"
235
-
236
- # 5. No hasher at all → skip with a diagnostic, and never write a shared
237
- # (hash-less) state file that would suppress every other project.
238
- work=$(mktemp -d)
239
- make_stub_bin "$work/bin"
240
- make_transcript "$work/transcript.jsonl"
241
- mkdir -p "$work/state" "$work/home"
242
- make_shadow_path "$work/nohash" sha256sum md5sum shasum b2sum cksum
243
- MX_STUB_EXIT=0 run_session_end "$work" "$work/bin:$work/nohash"
244
- assert_eq "0" "$(cat "$work/exit.txt")" "no hasher: hook still exits 0"
245
- assert_eq "" "$(ls -A "$work/state" 2>/dev/null)" "no hasher: no shared state file is written"
246
- assert_contains "$(cat "$work/stderr.txt")" "no usable hash tool" \
247
- "no hasher: stderr diagnostic explains the skip"
248
- rm -rf "$work"
249
-
250
- # ── Bounded retry (security review Must Fix) ────────────────────────────────
251
- # Leaving the watermark in place on failure removed the only bound on retry:
252
- # LINES_SINCE_SAVE stays >=100 forever, so every turn re-ran the whole
253
- # extraction and another non-idempotent create. The retry is now capped.
254
-
255
- # 6. Five consecutive retryable failures (exit 5): work stops after the cap.
256
- work=$(mktemp -d)
257
- make_stub_bin "$work/bin"
258
- make_transcript "$work/transcript.jsonl"
259
- mkdir -p "$work/state" "$work/home"
260
- # Per-run observations, indexed by run number. Arrays rather than eval'd
261
- # variable names so the assignment is traceable (by shellcheck and by a reader).
262
- declare -a watermark_after=() calls_after=() stderr_after=()
263
- for run in 1 2 3 4 5; do
264
- MX_STUB_EXIT=5 run_session_end "$work" "$work/bin:$REAL_PATH"
265
- watermark_after[run]="$(state_file_contents "$work")"
266
- calls_after[run]="$(count_mx_calls "$work")"
267
- stderr_after[run]="$(cat "$work/stderr.txt")"
268
- done
269
- assert_eq "" "${watermark_after[1]}" "retryable failure 1/3: watermark not advanced"
270
- assert_eq "" "${watermark_after[2]}" "retryable failure 2/3: watermark not advanced"
271
- assert_eq "300" "${watermark_after[3]}" "retryable failure 3/3: watermark advanced (cap reached)"
272
- assert_contains "${stderr_after[2]}" "retry 2/3 next trigger" "retry counter is reported on stderr"
273
- assert_contains "${stderr_after[3]}" "giving up" "cap is announced on stderr"
274
- assert_eq "3" "${calls_after[3]}" "3 create attempts by the cap"
275
- assert_eq "3" "${calls_after[5]}" "runs 4 and 5 attempt no create at all"
276
- assert_eq "" "$(fail_count_contents "$work")" "fail counter is cleared once the segment is dropped"
277
- rm -rf "$work"
278
-
279
- # 7. Terminal statuses are never retried — the watermark advances immediately.
280
- # 2 = validation (the request is malformed), 3 = auth, 124 = timeout (the
281
- # server may already have persisted the memory; a retry would duplicate it,
282
- # and the create is non-idempotent).
283
- for terminal in 2 3 124; do
284
- work=$(mktemp -d)
285
- make_stub_bin "$work/bin"
286
- make_transcript "$work/transcript.jsonl"
287
- mkdir -p "$work/state" "$work/home"
288
- MX_STUB_EXIT="$terminal" run_session_end "$work" "$work/bin:$REAL_PATH"
289
- assert_eq "300" "$(state_file_contents "$work")" \
290
- "terminal exit ${terminal}: watermark advances on the first failure"
291
- assert_eq "" "$(fail_count_contents "$work")" "terminal exit ${terminal}: no fail counter written"
292
- assert_contains "$(cat "$work/stderr.txt")" "not retryable" \
293
- "terminal exit ${terminal}: stderr names it as not retryable"
294
- assert_contains "$(cat "$work/stderr.txt")" "exit ${terminal}" \
295
- "terminal exit ${terminal}: stderr names the exit code"
296
- rm -rf "$work"
297
- done
298
-
299
- # 8. A success after two failures clears the counter, so the next failure
300
- # streak starts from 1 rather than tripping the cap immediately.
301
- work=$(mktemp -d)
302
- make_stub_bin "$work/bin"
303
- make_transcript "$work/transcript.jsonl"
304
- mkdir -p "$work/state" "$work/home"
305
- MX_STUB_EXIT=5 run_session_end "$work" "$work/bin:$REAL_PATH"
306
- MX_STUB_EXIT=5 run_session_end "$work" "$work/bin:$REAL_PATH"
307
- assert_eq "2" "$(fail_count_contents "$work")" "two failures: counter is at 2"
308
- MX_STUB_EXIT=0 run_session_end "$work" "$work/bin:$REAL_PATH"
309
- assert_eq "300" "$(state_file_contents "$work")" "success after 2 failures: watermark advances"
310
- assert_eq "" "$(fail_count_contents "$work")" "success after 2 failures: fail counter cleared"
311
- rm -rf "$work"
312
-
313
- # 8b. The counter is the only bound on the retry. If it cannot be persisted —
314
- # the path exists but is not writable — the count silently resets to 0 every
315
- # trigger and the cap never trips. Inability to bound must be terminal.
316
- work=$(mktemp -d)
317
- make_stub_bin "$work/bin"
318
- make_transcript "$work/transcript.jsonl"
319
- mkdir -p "$work/state" "$work/home"
320
- # Occupy the counter path with a DIRECTORY so the write can never succeed.
321
- project_hash=$(printf '%s' "$work" | sha256sum | awk '{print $1}')
322
- mkdir -p "$work/state/.mx-session-capture-${project_hash}.fails"
323
- MX_STUB_EXIT=5 run_session_end "$work" "$work/bin:$REAL_PATH"
324
- assert_eq "300" "$(state_file_contents "$work")" \
325
- "unwritable counter: watermark advances on the FIRST failure"
326
- assert_contains "$(cat "$work/stderr.txt")" "cannot persist the retry counter" \
327
- "unwritable counter: stderr names the reason"
328
- calls_after_run1=$(count_mx_calls "$work")
329
- MX_STUB_EXIT=5 run_session_end "$work" "$work/bin:$REAL_PATH"
330
- assert_eq "1" "$calls_after_run1" "unwritable counter: run 1 attempted exactly one create"
331
- assert_eq "1" "$(count_mx_calls "$work")" \
332
- "unwritable counter: run 2 attempts no create"
333
- rm -rf "$work"
334
-
335
- echo "── capture-precompact.sh ──"
336
-
337
- # 6. Failed create → stderr diagnostic, still exit 0. (This hook has no
338
- # watermark; none was invented.)
339
- work2=$(mktemp -d)
340
- make_stub_bin "$work2/bin"
341
- make_transcript "$work2/transcript.jsonl"
342
- mkdir -p "$work2/home"
343
- ( cd "$work2" && PATH="$work2/bin:$REAL_PATH" HOME="$work2/home" MX_STUB_EXIT=1 \
344
- bash "$PRECOMPACT_HOOK" \
345
- <<<"{\"transcript_path\":\"$work2/transcript.jsonl\",\"session_id\":\"s1\",\"trigger\":\"auto\"}" \
346
- 2>"$work2/stderr.txt" >/dev/null )
347
- status2=$?
348
- assert_eq "0" "$status2" "precompact: exits 0 when create fails"
349
- assert_contains "$(cat "$work2/stderr.txt")" "mx memories create failed" \
350
- "precompact: failed create writes a stderr diagnostic"
351
- rm -rf "$work2"
352
-
353
- echo "── dev-tools/claude-hooks/auto-save-memory.sh ──"
354
-
355
- run_autosave() { # <workdir> ; uses MX_STUB_EXIT
356
- local work="$1"
357
- ( cd "$work" && PATH="$work/bin:$REAL_PATH" MX_AUTOSAVE_STATE_FILE="$work/state-line" \
358
- MX_STUB_LOG="$work/mx-calls.log" \
359
- bash "$AUTOSAVE_HOOK" \
360
- <<<"{\"transcript_path\":\"$work/transcript.jsonl\",\"stop_hook_active\":false}" \
361
- 2>"$work/stderr.txt" >/dev/null )
362
- echo "$?" >"$work/exit.txt"
363
- }
364
-
365
- # 7. Failed create → the line-number watermark is not recorded, so the turn is
366
- # retried instead of being skipped as "already saved".
367
- work=$(mktemp -d)
368
- make_stub_bin "$work/bin"
369
- make_transcript "$work/transcript.jsonl"
370
- MX_STUB_EXIT=1 run_autosave "$work"
371
- assert_eq "0" "$(cat "$work/exit.txt")" "auto-save: exits 0 when create fails"
372
- if [[ -f "$work/state-line" ]]; then
373
- nope "auto-save: failed create leaves the watermark unwritten" \
374
- "state-line holds: $(cat "$work/state-line")"
375
- else
376
- ok "auto-save: failed create leaves the watermark unwritten"
377
- fi
378
- assert_contains "$(cat "$work/stderr.txt")" "mx memories create failed" \
379
- "auto-save: failed create writes a stderr diagnostic"
380
- rm -rf "$work"
381
-
382
- # 8. Successful create → the watermark is recorded.
383
- work=$(mktemp -d)
384
- make_stub_bin "$work/bin"
385
- make_transcript "$work/transcript.jsonl"
386
- MX_STUB_EXIT=0 run_autosave "$work"
387
- assert_eq "0" "$(cat "$work/exit.txt")" "auto-save: exits 0 on success"
388
- if [[ -s "$work/state-line" ]]; then
389
- ok "auto-save: successful create records the watermark"
390
- else
391
- nope "auto-save: successful create records the watermark" "state-line missing or empty"
392
- fi
393
- rm -rf "$work"
394
-
395
- # 9. auto-save: the same bounded retry. Five consecutive retryable failures
396
- # stop after the cap; terminal statuses advance immediately.
397
- work=$(mktemp -d)
398
- make_stub_bin "$work/bin"
399
- make_transcript "$work/transcript.jsonl"
400
- for run in 1 2 3 4 5; do
401
- MX_STUB_EXIT=5 run_autosave "$work"
402
- done
403
- if [[ -s "$work/state-line" ]]; then
404
- ok "auto-save: watermark advanced once the retry cap was reached"
405
- else
406
- nope "auto-save: watermark advanced once the retry cap was reached" "state-line missing"
407
- fi
408
- assert_eq "3" "$(count_mx_calls "$work")" \
409
- "auto-save: 3 create attempts across 5 runs (runs 4-5 attempt none)"
410
- if [[ -f "$work/state-line.fails" ]]; then
411
- nope "auto-save: fail counter cleared after giving up" "counter still present"
412
- else
413
- ok "auto-save: fail counter cleared after giving up"
414
- fi
415
- rm -rf "$work"
416
-
417
- work=$(mktemp -d)
418
- make_stub_bin "$work/bin"
419
- make_transcript "$work/transcript.jsonl"
420
- MX_STUB_EXIT=124 run_autosave "$work"
421
- if [[ -s "$work/state-line" ]]; then
422
- ok "auto-save: timeout (124) is terminal — watermark advances, no duplicate-minting retry"
423
- else
424
- nope "auto-save: timeout (124) is terminal" "state-line missing"
425
- fi
426
- assert_contains "$(cat "$work/stderr.txt")" "not retryable" \
427
- "auto-save: timeout diagnostic names it as not retryable"
428
- rm -rf "$work"
429
-
430
- # 9b. auto-save: same unwritable-counter handling.
431
- work=$(mktemp -d)
432
- make_stub_bin "$work/bin"
433
- make_transcript "$work/transcript.jsonl"
434
- mkdir -p "$work/state-line.fails"
435
- MX_STUB_EXIT=5 run_autosave "$work"
436
- if [[ -s "$work/state-line" ]]; then
437
- ok "auto-save: unwritable counter advances the watermark on the first failure"
438
- else
439
- nope "auto-save: unwritable counter advances the watermark" "state-line missing"
440
- fi
441
- assert_contains "$(cat "$work/stderr.txt")" "cannot persist the retry counter" \
442
- "auto-save: unwritable counter names the reason"
443
- MX_STUB_EXIT=5 run_autosave "$work"
444
- assert_eq "1" "$(count_mx_calls "$work")" \
445
- "auto-save: unwritable counter — run 2 attempts no create"
446
- rm -rf "$work"
447
-
448
- # 10. precompact emits exactly one diagnostic per trigger (it has no watermark;
449
- # one line per PreCompact event is inherent and bounded by the event).
450
- work=$(mktemp -d)
451
- make_stub_bin "$work/bin"
452
- make_transcript "$work/transcript.jsonl"
453
- mkdir -p "$work/home"
454
- ( cd "$work" && PATH="$work/bin:$REAL_PATH" HOME="$work/home" MX_STUB_EXIT=5 \
455
- bash "$PRECOMPACT_HOOK" \
456
- <<<"{\"transcript_path\":\"$work/transcript.jsonl\",\"session_id\":\"s1\",\"trigger\":\"auto\"}" \
457
- 2>"$work/stderr.txt" >/dev/null )
458
- assert_eq "1" "$(grep -c 'mx memories create failed' "$work/stderr.txt")" \
459
- "precompact: exactly one diagnostic per trigger"
460
- rm -rf "$work"
461
-
462
- echo ""
463
- echo "capture-hooks.test.sh: $PASS passed, $FAIL failed"
464
- [[ "$FAIL" -eq 0 ]] || exit 1
465
- exit 0