guard.sh fixes (both ours): the memory sum never saw a process three or more levels down the tree (a doubled space became an empty entry in the `ps -p` list, which macOS rejects whole), so cargo -> rustc -> linker and test-spawned servers were never memory-limited — QA re-proved 1.5 GB at depth 3/4 missed by master, killed in 2-4 s now; a closed stdin skipped the command silently, now /dev/null. The stall itself is the host's (syspolicyd on fresh unsigned binaries). tools/gates.sh runs fmt, clippy, the test build, one suite per workspace crate, the doc-tests, the corpus gate and the node tests as separate guarded steps with kept logs and per-step limits; a guard-killed step is retried once and shown as KILLED -> retried; usage errors exit 2 (lead fixes after QA: comments/one-line/glob members, an empty crate list, a missing option value, an empty selection). RELEASING.md step 3, CLAUDE.md and the README's Building section point at it. Ten consecutive green runs recorded (healthy host); full gate on master: PASS, 15 steps, 5 127 tests, corpus 814/820. QA (Sonnet): PASS. docs/features/release-gates. Co-Authored-By: Claude Opus 5.5 <[email protected]>
release-gates — TODO §65.3: a dependable release gate script
Goal
cargo test --workspace under tools/guard.sh kept hitting the guard's
wall clock (2026-09-29 in Doc-tests vlog_linter, 2026-09-30 at the start
of tests/rename_implicit.rs, 2026-10-07 launching
vlog_semantic/tests/struct_members, 2026-10-14 in
vlog_refactor/tests/corpus.rs), while every per-crate run passed. Name
the cause, fix whatever part of it is ours, and replace the three-command
gate in tools/RELEASING.md with tools/gates.sh: fmt, clippy, the test
build, each crate's suites, the doc-tests, the corpus gate and the node
tests as separate guarded steps, each with its own log, a kill retried
once and shown as such, and a summary table — so a stall names the step it
happened in instead of eating a 30-minute guard.
Assumptions
- The gates run on the release Mac (Apple Silicon, 10 cores, 64 GB), the
same host the Gitea runner uses. The
-t/-mlimits are sized for it; a slower machine may need larger clocks (editlimits()). - No gate reads stdin;
gates.shgives every step/dev/null. - The corpus lives at
~/.cache/lucisv-corpusas in CI (.gitea/workflows/ci.yml);-cpoints elsewhere. Absent → the step is skipped with a note, which does not fail the run (CI is where the corpus gate is mandatory). - The workspace
membersin the rootCargo.tomlare all undercrates/, one per line, and each member's firstname =line is its package name.gates.shreads the crate list from there. - A guard kill is identified by exit 137 and guard.sh's
killingline in the step log; a 137 without that line (a test binary SIGKILLed by something else) is an ordinary failure and is not retried.
Handshakes
-
Consumes
tools/guard.sh(-t,-m, exit 137 +guard.sh: … killing: …on stderr),scripts/corpus_gate.sh <dir>(needstarget/release/lucisv, so the corpus step builds it first, as CI does),node --test, cargo. -
Changes
tools/guard.sh(two fixes, both ours, see Work log): a closed stdin no longer makes the command silently not run, and the memory limit now sees processes three or more levels down the tree. The second is a behaviour change for every guarded command: memory that was invisible (rustc/linker processes under cargo, binaries a test spawns, the corpus scorer'slucisvprocesses) is now summed, so a command whose real tree exceeded its-mand used to pass will now be killed. Measured peaks are below; a guard kill after this change is a finding, per CLAUDE.md, not a reason to raise the limit silently. -
Promises
tools/gates.shexit 0 only if every selected step passed (or was the corpus step skipped for a missing corpus); logs kept under the log dir:<step>.log,<step>.killed.logfor a first attempt the guard killed,summary.txt,steps.tsv(step, start, end epoch, result). -
CLAUDE.md request (the lead's file): under "Rust standards", replace the first bullet's tail so it reads:
cargo fmtclean,cargo clippy --all-targetsclean (no#[allow]without a comment explaining why),cargo testgreen — all three before declaring any work finished. Before a release, and whenever the whole workspace is gated, runtools/gates.sh(every gate as a separate guarded step with kept logs;--only/--skipfor a subset) instead of a barecargo test --workspace.
and in "Runaway guard", after the first bullet:
- The release gate is
tools/gates.sh, which guards each step with its own limits; do not wrap it in anotherguard.sh.
-
Request (root
README.md, not this lane's file): its build section (line ~1042) still showstools/guard.sh -- cargo test --workspace; a pointer totools/gates.shthere would match RELEASING.md. -
Request (lane A /
lucisv_server, not this lane's file): the wall-clock assertion incrates/lucisv_server/src/large.rs:884(LOCATE_BUDGET_MS = 150) flaked once under load (Work log); make it relative or widen it so the gate stays deterministic.
Status / TODO
- investigate: stall reproduction attempt, syspolicyd, stuck tree
- doc-test stdin question: closed /
/dev/null/ pipe / tty / tty with job control, under the guard, in the background - fix what is ours: guard.sh closed-stdin, guard.sh deep-tree memory
tools/gates.shwith--only,--skip,--list,-o,-c,--help- kill → retry path exercised (killed → pass, killed → killed, plain failure not retried, corpus skipped)
- two full runs recorded
- ten consecutive green runs (runs 3–12; thirteen green in all, no kills)
tools/RELEASING.mdstep 3 points attools/gates.sh- CLAUDE.md pointer (lead, at merge)
Work log
2026-10-19 — investigation
Base: master ec492cd (the worktree was created one commit behind it, at
75d2d37; fast-forwarded before any work). Lane A (§65.2) ran its own
lucisv_server tests in another worktree throughout: load average 6–10 on
10 cores for the whole session, so every timing below was taken under a
second, unrelated workload — the 2026-10-14 condition.
The stall did not reproduce. The host had been up 1 h 13 min (rebooted
that morning). syspolicyd sat at 0.0 % CPU at the start, never above 0.3 %
in any 1 s sample across the twelve full gate runs, and showed nothing over
1 % in 0.2 s samples during a freshly-linked suite's first run. Five freshly
linked unique binaries (rustc of a one-line main, each with a distinct
constant, i.e. a distinct cdhash as a doc-test's rust_out has) launched in
10 ms the first time and 10 ms the second. cargo clean -p lucisv_server
then a first and second run of its suites: 2.2 s and 2.2 s. So there was no
stuck tree to inspect; the cause recorded on 2026-09-30 (syspolicyd stuck at
~100 % CPU on notarization lookups, -67062, for hours, each first launch of
a new unsigned executable waiting on it) stands unrefuted and unreproduced,
and it fits every recorded stall: each one sat at the first launch of a
freshly linked binary — a test binary just rebuilt
(rename_implicit, struct_members, corpus.rs) or the doc-test phase,
where vlog_linter's lib.rs example is the only runnable doc-test in the
workspace (cargo test --workspace --doc: 1 test), and rustdoc links it
into a new rust_out with a new hash on every run, so it can never hit
syspolicyd's cache. That is why "Doc-tests vlog_linter" is where 2026-09-29
sat. Healthy after a reboot, sick after hours of uptime: the host fix (System
Settings → Privacy & Security → Developer Tools: allow the terminal / Claude
app, or restart syspolicyd) is the owner's, not the repo's. DevToolsSecurity -status reports developer mode disabled; spctl --status: assessments
enabled.
The doc-test stdin question — not the cause. cargo test --workspace --doc under tools/guard.sh, backgrounded, with each kind of stdin (script
kept in the session scratchpad; results):
| stdin | result |
|---|---|
closed (<&-) |
exit 1 in 0 s, nothing ran — guard.sh: line 34: 0: Bad file descriptor, then 3: Bad file descriptor (a guard bug, fixed below) |
/dev/null |
exit 0, 1 s, 1 passed |
| a pipe whose writer never closes | exit 0, 1 s, 1 passed |
a pty (script), no job control |
exit 0, 1 s, 1 passed |
a pty with job control (set -m: the job in a background process group, as guard.sh … & typed at a prompt) |
exit 0, 1 s, 1 passed — no SIGTTIN stop |
The harness never reads stdin: rustdoc feeds each doc-test to rustc over a
pipe of its own and runs rust_out with Command::output(), which gives it
/dev/null. No test in the workspace spawns a child that inherits stdin and
reads it (every spawn() in crates/*/tests pipes stdin; the one inherited
status(), lucisv_server/tests/e2e.rs:571, runs lucisv check --fix <file>, which does not read it).
Fixed — ours, both in tools/guard.sh:
- Closed stdin:
exec 3<&0failed, then"$@" <&3failed, so the command silently never ran (exit 1). Now{ exec 3<&0; } 2>/dev/null || exec 3</dev/null.lucisv -still reads stdin through the guard, foreground and backgrounded (checked: formatted output both ways); with a closed stdin it now reads an empty/dev/nullinstead of not running. - The memory limit was blind three levels down.
tree()appended"$all $next"wherenextended in a space, so from the second level of descendants on the list had a doubled space,tr ' ' ,madea,,b, and macOSps -prejects the whole list on an empty element ("Invalid (zero-length) process id") — RSS summed to 0 and the limit could never fire. Every real guarded command is that deep: cargo → rustc → ld, cargo → test binary → spawnedlucisv-server/lucisv-mcp, the corpus scorer'slucisvprocesses. Reproduction (a perl process holding 1.5 GB for 8 s,-m 1): at depth 1 and 2 killed in 3 s; at depth 3 ran to completion, exit 0 before the fix; killed in 3 s after it. The awk now prints" %s"and the loop appends without a separator, so the list is single- spaced; the kill path uses the same list and was re-checked (depth-3 hog killed, nothing left behind). Not related to the stalls (it can only cause fewer kills), but it is the runaway guard CLAUDE.md relies on.
Also observed, not ours to fix (lane A owns the crate):
lucisv_server large::tests::references_on_one_giant_line_locate_their_hits_in_linear_time
failed once, on the first run after cargo clean -p lucisv_server, under
lane A's load: "locating 800 hits on one line cost 185.450583ms" against
LOCATE_BUDGET_MS = 150 (crates/lucisv_server/src/large.rs:884, budget at
:896); the 400-hit pass on the same run took 17 ms, so it was a scheduling
hiccup, not the quadratic rescan. The immediate rerun passed and so did all
thirteen gate runs. A wall-clock budget in a debug-build unit test is a
flake source for any gate; filed here as a request for the lead (widen the
budget or compare the 800-hit time against the 400-hit time instead of an
absolute).
Also observed: feature unification rebuilds. cargo test -p <crate>
after cargo test --workspace --all-targets --no-run recompiles a few crates
(crossbeam-utils, lsp-server, lucisv_server: 16 s in run 1) because
resolver 2 unifies features per selected package set; both variants are
cached afterwards. The per-crate clocks allow for it.
2026-10-19 — tools/gates.sh
Steps, logs, retry and summary as in the header comment and Handshakes.
Design points: the command for each step is a bash array (no eval); the
crate list comes from the root members, each member's name; a guard
kill is exit 137 and the guard's line, retried once with the first log
kept as <step>.killed.log; every step gets /dev/null as stdin; node 22+
prints ℹ pass N rather than TAP's # pass N and both are counted; the
corpus step builds target/release/lucisv first, as CI does; unknown step
names are a usage error (exit 2).
Exercised paths (a throwaway copy of the script with a 2 s clock on a
sleep 30, deleted after): killed → retried → KILLED (exit 1), killed →
retried → pass (a command that sleeps only on its first call; exit 0, first
log kept), a plain failure (node -e 'process.exit(3)') reported fail and
not retried, the corpus step SKIPPED (no corpus) with -c /nonexistent
and the run still green.
Limits (limits(); measured 2026-10-19 from a cold target/, peak tree RSS
sampled each second over the whole step tree):
| step | measured cold | warm (runs 3–12) | peak RSS | -t / -m |
|---|---|---|---|---|
| fmt | 3 s | 2 s | 0.1 GB | 120 s / 2 GB |
| clippy | 20 s | 1–2 s | 1.6 GB | 900 s / 6 GB |
| build | 31 s | 1–2 s | 2.6 GB | 900 s / 8 GB |
| suite: each small crate | ≤ 3 s | 1–4 s | ≤ 0.15 GB | 300 s / 4 GB |
| suite:lucisv_server | 17–19 s (rebuild) | 2–4 s | 1.1 GB | 600 s / 4 GB |
| suite:lucisv_mcp | 20–22 s | 12–15 s | 1.4 GB | 600 s / 4 GB |
| docs | 1 s | 1 s | 0.1 GB | 300 s / 2 GB |
| corpus (release build + score) | 30 s | 3–4 s | 1.2 GB | 900 s / 6 GB |
| node | 1 s | 1 s | 0.3 GB | 120 s / 2 GB |
The clocks are the cold time times twelve (the CPU-bound slowdown a sick
syspolicyd was measured to cost) rounded up, with a two-minute floor: a
real hang costs at most that step's clock twice, not 30 minutes; a stall
that clears on the retry shows as KILLED → retried → pass.
2026-10-19 — runs
Thirteen full runs, all gates: PASS, zero kills, zero retries, zero
failures: run 1 (warm, before the deep-tree guard fix and with the first
draft limits), run 2 (after cargo clean, limits as drafted), runs 3–12
(final limits, back to back: 33–38 s each), run 13 (the final script, after
a summary-alignment change; default log dir). Runs 3–12 are §65.3's ten
consecutive green runs. Honest caveat: the host was healthy all session
(syspolicyd ≤ 0.3 %), so these runs prove the script and the gates, not
immunity to the host fault — that would show as a KILLED → retried row.
Run 2 (cold):
step result seconds passed/failed
fmt pass 3 -
clippy pass 20 -
build pass 31 -
suite:vlog_parser pass 3 505/0
suite:vlog_semantic pass 1 401/0
suite:vlog_refactor pass 1 727/0
suite:vlog_formatter pass 1 314/0
suite:vlog_linter pass 1 672/0
suite:lucisv_core pass 1 117/0
suite:lucisv pass 2 143/0
suite:lucisv_server pass 17 1862/0
suite:lucisv_mcp pass 22 383/0
docs pass 1 1/0
corpus pass 30 814/6
node pass 1 8/0
gates: PASS
Run 13 (final script, warm except clippy/build after cargo clean -p lucisv_server): fmt 2, clippy 9, build 14, suites 3/1/1/1/1/2/1/2/12,
docs 1, corpus 3, node 1 s — the same counts, gates: PASS. The corpus
"failed" column is total − passing (6 of 820, the documented ceiling).
QA log
2026-10-19 — QA agent (Sonnet)
Verdict: PASS, no blocking findings; no files fixed (log only). Host load
average 5 to 19 (lane A running suites) throughout. Bash: only /bin/bash
3.2.57 exists (which -a bash), so #!/usr/bin/env bash runs 3.2; no
bash-4 feature in either script (grep for declare -A, mapfile,
${v,,}, [[, +=, |&: none).
guard.sh (diff read line by line: three changes, stdin fallback,
awk " %s", all="$all$next"; nothing else touched).
-
Memory depth proof (
nest.sh N: N nested bash layers, python holding 1.5 GB at the bottom,-m 1 -t 40; scratchqaB65/nest.sh):depth master guard new guard 1 137, killed in 3 s 137, 3 s 2 137, 3 s 137, 3 s 3 exit 0 after 31 s, no guard line (missed) 137, 4 s, guard line 4 exit 0 after 31 s (missed) 137, 2 s, guard line No
nest.shsurvivors after any run. -
Wall clock:
-t 3 -- sleep 30gives 137 with the guard line in 6 s. TERM escalation: a script and a child both withtrap '' TERM,-t 3: 137 in 6 s (3 s + 2 s grace + KILL), no survivors. -
Stdin:
echo ... | guard.sh -- lucisv -formats (foreground); formatted in the background with stdin from a file, from a pipe in a subshell, and from a pipe insidebash -c '... &'. Closed stdin (<&-): new guard runs the command (echoran,catexits 0); master guard prints "Bad file descriptor" twice and exits 1 without running it (confirmed). -
exit 3passes through as 3. A 400-subshell fork storm of short-lived children (exiting mid-poll) under-m 2: exit 0, stderr empty. macOS pids are at most 99999, so the awkindex()token match has no prefix-collision risk. -
Cosmetic (info): on a kill the shell prints
tools/guard.sh: line 57: <pid> Terminated: 15 "$@" 0<&3to stderr (seen in the retry logs). It is harmless and gates.sh matches theguard.sh: ... killingline instead.
gates.sh
--helpexit 0;--listprints the 15 steps; unknown flag exit 2;--only nope,--skip suite:nopeexit 2 with "unknown step".--only fmt,node,--only docs --skip corpus,--only corpus -c /nonexistent(SKIPPED (no corpus), exit 0, note in corpus.log) all as documented.-o "dir with space"works (logs, summary.txt, steps.tsv created).- Scratch copies of the script: a failing node test gives
fail, summarygates: FAIL, exit 1, and a single attempt (no.killed.log); a step killed twice (2 s clock onsleep 30) givesKILLED → retried → KILLED, exit 1,node.killed.logkept,steps.tsvrow written; killed once then passing givesKILLED → retried → pass, exit 0,.killed.logkept. - Crate list: the real
members(nine, one per line, no comments, no glob) parses to all nine and matches--list. - Full gate, run once, not wrapped:
tools/gates.shprintedgates: PASS, 36 s wall, zero kills. Warm cache: fmt 2, clippy 1, build 1, suites 3/1/2/1/1/1/1/2/14 (parser, semantic, refactor, formatter, linter, core, lucisv, server, mcp), docs 1, corpus 3 (814/6), node 1 (8/0); counts identical to the dev's run 2 (505, 401, 727, 314, 672, 117, 143, 1862, 383, 1 doc-test).
Findings (all low; none block)
- Low-medium, silent shrink of coverage.
crates()attools/gates.sh:74-79drops members it cannot parse and still reports PASS. Reproduced in a scratch workspace: a trailing comment on a member line ("crates/a", # note) loses that crate (plus onesed: ... No such fileon stderr);members = ["crates/a", "crates/b"]on one line yields no crates;"crates/*"yields no crates. In the last two cases the whole suite phase vanishes and the run is green. The README assumption names the layout, but nothing enforces it. Suggest: fail (exit 2) whencratesis empty or its count differs fromcargo metadata --no-depsmembers. Not a risk with today's Cargo.toml. - Low.
gates.sh:55-57(-o,-c,--only,--skipas the last argument):$2: unbound variableunderset -u, exit 1, not the documented usage error 2. Repro:tools/gates.sh --only. - Low.
--only ''means no filter (all steps run), and a selection that matches nothing (--only suites --skip suites) prints an empty table andgates: PASS, exit 0. A zero-step run being green is misleading; suggest exit 2 or a "no steps selected" line. - Info. The corpus step is skipped green when
~/.cache/lucisv-corpusis absent; documented, but a release run on a fresh host would pass without the corpus gate.RELEASING.mdstep 3 says so, which suffices. - Info / behaviour change (already in Handshakes). After the guard fix,
memory is now enforced for deep trees. The full gate's peaks stayed under
all
-mlimits in this run (no kills), so the limits are sound at least on this host.
Review of docs. tools/RELEASING.md step 3 reads correctly and matches
the script (steps, log names, retry wording, --only/--skip/--list).
Minor: "a line in the release notes' working log" is vague (the repo has a
CHANGELOG and README work logs). The proposed CLAUDE.md lines are sensible
and consistent: gates.sh guards each step itself, so "do not wrap it in
another guard.sh" is right (a nested guard would also hide per-step kills).
Review
2026-10-19 — lead. Accepted. The two guard.sh bugs were the real
find: the memory limit never saw a process three or more levels down the
tree (every cargo → rustc → linker chain), and a closed stdin skipped the
command; QA re-proved both against master's guard. The stall itself is the
host's (syspolicyd on fresh unsigned binaries; the owner's Developer Tools
setting), and gates.sh now survives it by retrying a killed step once and
saying so. QA's three lows are fixed by the lead in the worktree before
merge: the crate list drops comments and handles a one-line list and a
glob, and an empty list is a usage error (exit 2) instead of a green run
with no suites; a missing or empty option value is exit 2; a selection that
runs no step is exit 2. Granted: the CLAUDE.md lines (Rust standards and
Runaway guard) and the root README's Building section now point at
tools/gates.sh. The ten green runs were on a healthy host — the first
KILLED → retried row on a stalled one is the evidence still to come.