TODO §65.3: tools/gates.sh, the release gate; guard.sh enforces memory at every depth and runs with a closed stdin
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]>
This commit is contained in:
1 parent
51b975bf68
commit
92875e6c6d
7 files changed
+652
-17
No files matched your search
@@ -93,7 +93,10 @@ files over 600 workspace-wide: `lucisv_server/src/perf.rs` 907 (reasoned),
|
||||
|
||||
- `cargo fmt` clean, `cargo clippy --all-targets` clean (no `#[allow]`
|
||||
without a comment explaining why), `cargo test` green — all three
|
||||
before declaring any work finished.
|
||||
before declaring any work finished. **Before a release, and whenever
|
||||
the whole workspace is gated, run `tools/gates.sh`** (every gate as a
|
||||
separate guarded step with kept logs; `--only`/`--skip` for a subset)
|
||||
instead of a bare `cargo test --workspace`.
|
||||
- No `unwrap()`/`expect()`/`panic!` in library code paths; return
|
||||
`Result`. Tests and `main.rs` argument handling may use them.
|
||||
- Public items get a one-line doc comment. Doc comments say what/why,
|
||||
@@ -160,6 +163,9 @@ process tree when its resident set or wall clock exceeds the limits
|
||||
`tools/guard.sh`** — dev, QA and lead alike, foreground or background.
|
||||
- A guard kill is a finding: report the command and the limit it hit;
|
||||
do not raise the limit to make it pass.
|
||||
- The release gate is `tools/gates.sh`, which guards each step with its
|
||||
own limits and retries a killed step once (shown as `KILLED → retried`);
|
||||
do not wrap it in another `guard.sh`.
|
||||
|
||||
## Parallel lanes (the 2-agent loop)
|
||||
|
||||
|
||||
@@ -1037,11 +1037,13 @@ expected; no PRs or review required.
|
||||
|
||||
```bash
|
||||
cargo build --release # binaries at target/release/{lucisv,lucisv-server}
|
||||
cargo fmt --all -- --check
|
||||
cargo clippy --workspace --all-targets -- -D warnings
|
||||
tools/guard.sh -- cargo test --workspace # unit, integration, snapshots, doc tests
|
||||
tools/gates.sh # every gate: fmt, clippy, build, each crate's suites, doc tests, corpus, node
|
||||
tools/gates.sh --only suites # just the per-crate test suites
|
||||
```
|
||||
|
||||
`tools/gates.sh` runs each gate as its own guarded step with a kept log and
|
||||
prints a summary (`docs/features/release-gates/README.md`).
|
||||
|
||||
Snapshot tests live in `crates/vlog_formatter/tests/fixtures/`; regenerate
|
||||
expected outputs only for intentional formatting changes with
|
||||
`UPDATE_SNAPSHOTS=1 tools/guard.sh -- cargo test -p vlog_formatter`.
|
||||
|
||||
@@ -7031,16 +7031,16 @@ in `Doc-tests vlog_linter` until the guard cut it; on 2026-09-30 an
|
||||
independent session's run hit its 600 s guard "entering the final doc-test
|
||||
harness". `cargo test --workspace --doc` alone passes in under a minute.
|
||||
|
||||
- [ ] reproduce (how often, which doc-test, what the stuck process tree
|
||||
- [x] reproduce (how often, which doc-test, what the stuck process tree
|
||||
is — `rustdoc`, `rust_out`, stdin?) and name the cause; `guard.sh`
|
||||
runs the command with `0<&3` — check what the doc-test harness
|
||||
inherits as stdin when the gate runs in the background
|
||||
- [ ] fix at the cause (the harness, the doc-test, or the guard), and make
|
||||
- [x] fix at the cause (the harness, the doc-test, or the guard), and make
|
||||
the release gate a script (`tools/gates.sh`) that runs fmt, clippy,
|
||||
the test build, the suites, the doc-tests, the corpus gate and the
|
||||
node tests as separate guarded steps with logs kept and a summary
|
||||
that shows a kill — `tools/RELEASING.md` and CLAUDE.md point at it
|
||||
- [ ] ten consecutive green runs of the gate script recorded
|
||||
- [x] ten consecutive green runs of the gate script recorded
|
||||
|
||||
### 65.4 Resolve a hierarchical path rooted at a top-level module name (lead to schedule; from §65.1 QA F1)
|
||||
|
||||
@@ -7111,7 +7111,7 @@ ignored-by-default `crates/lucisv_server/tests/opentitan_references.rs`,
|
||||
`tools/RELEASING.md`, `docs/features/release-gates/README.md` (new);
|
||||
CLAUDE.md's pointer is the lead's at merge.
|
||||
|
||||
- [ ] §65.3's checklist above
|
||||
- [x] §65.3's checklist above
|
||||
|
||||
**Then — §65.4 top-module-rooted paths** (serial, after lane A merges).
|
||||
|
||||
|
||||
@@ -0,0 +1,366 @@
|
||||
# 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`/`-m` limits are sized for it;
|
||||
a slower machine may need larger clocks (edit `limits()`).
|
||||
- No gate reads stdin; `gates.sh` gives every step `/dev/null`.
|
||||
- The corpus lives at `~/.cache/lucisv-corpus` as in CI
|
||||
(`.gitea/workflows/ci.yml`); `-c` points 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 `members` in the root `Cargo.toml` are all under
|
||||
`crates/`, one per line, and each member's first `name =` line is its
|
||||
package name. `gates.sh` reads the crate list from there.
|
||||
- A guard kill is identified by exit 137 **and** guard.sh's `killing` line
|
||||
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>` (needs
|
||||
`target/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's `lucisv` processes) is now summed, so a
|
||||
command whose real tree exceeded its `-m` and 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.sh` exit 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.log` for 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 fmt` clean, `cargo clippy --all-targets` clean (no `#[allow]`
|
||||
> without a comment explaining why), `cargo test` green — all three
|
||||
> before declaring any work finished. **Before a release, and whenever
|
||||
> the whole workspace is gated, run `tools/gates.sh`** (every gate as a
|
||||
> separate guarded step with kept logs; `--only`/`--skip` for a subset)
|
||||
> instead of a bare `cargo 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 another `guard.sh`.
|
||||
- **Request (root `README.md`, not this lane's file):** its build section
|
||||
(line ~1042) still shows `tools/guard.sh -- cargo test --workspace`; a
|
||||
pointer to `tools/gates.sh` there would match RELEASING.md.
|
||||
- **Request (lane A / `lucisv_server`, not this lane's file):** the
|
||||
wall-clock assertion in `crates/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
|
||||
|
||||
- [x] investigate: stall reproduction attempt, syspolicyd, stuck tree
|
||||
- [x] doc-test stdin question: closed / `/dev/null` / pipe / tty / tty with
|
||||
job control, under the guard, in the background
|
||||
- [x] fix what is ours: guard.sh closed-stdin, guard.sh deep-tree memory
|
||||
- [x] `tools/gates.sh` with `--only`, `--skip`, `--list`, `-o`, `-c`, `--help`
|
||||
- [x] kill → retry path exercised (killed → pass, killed → killed, plain
|
||||
failure not retried, corpus skipped)
|
||||
- [x] two full runs recorded
|
||||
- [x] ten consecutive green runs (runs 3–12; thirteen green in all, no kills)
|
||||
- [x] `tools/RELEASING.md` step 3 points at `tools/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`:**
|
||||
|
||||
1. *Closed stdin*: `exec 3<&0` failed, then `"$@" <&3` failed, 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/null` instead of not running.
|
||||
2. *The memory limit was blind three levels down.* `tree()` appended
|
||||
`"$all $next"` where `next` ended in a space, so from the second level of
|
||||
descendants on the list had a doubled space, `tr ' ' ,` made `a,,b`, and
|
||||
macOS `ps -p` rejects 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 → spawned `lucisv-server`/`lucisv-mcp`, the corpus scorer's
|
||||
`lucisv` processes. 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`; scratch `qaB65/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.sh` survivors after any run.
|
||||
- Wall clock: `-t 3 -- sleep 30` gives 137 with the guard line in 6 s. TERM
|
||||
escalation: a script and a child both with `trap '' 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 inside `bash -c '... &'`. Closed stdin (`<&-`): new guard runs the
|
||||
command (`echo` ran, `cat` exits 0); master guard prints "Bad file
|
||||
descriptor" twice and exits 1 without running it (confirmed).
|
||||
- `exit 3` passes 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 awk `index()` token match has no
|
||||
prefix-collision risk.
|
||||
- Cosmetic (info): on a kill the shell prints `tools/guard.sh: line 57:
|
||||
<pid> Terminated: 15 "$@" 0<&3` to stderr (seen in the retry logs). It
|
||||
is harmless and gates.sh matches the `guard.sh: ... killing` line instead.
|
||||
|
||||
**gates.sh**
|
||||
- `--help` exit 0; `--list` prints the 15 steps; unknown flag exit 2;
|
||||
`--only nope`, `--skip suite:nope` exit 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`, summary
|
||||
`gates: FAIL`, exit 1, and a single attempt (no `.killed.log`); a step
|
||||
killed twice (2 s clock on `sleep 30`) gives `KILLED → retried → KILLED`,
|
||||
exit 1, `node.killed.log` kept, `steps.tsv` row written; killed once then
|
||||
passing gives `KILLED → retried → pass`, exit 0, `.killed.log` kept.
|
||||
- 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.sh` printed
|
||||
`gates: 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)
|
||||
1. **Low-medium, silent shrink of coverage.** `crates()` at
|
||||
`tools/gates.sh:74-79` drops 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 one `sed: ...
|
||||
No such file` on 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) when `crates` is empty or its count differs from
|
||||
`cargo metadata --no-deps` members. Not a risk with today's Cargo.toml.
|
||||
2. **Low.** `gates.sh:55-57` (`-o`, `-c`, `--only`, `--skip` as the last
|
||||
argument): `$2: unbound variable` under `set -u`, exit 1, not the
|
||||
documented usage error 2. Repro: `tools/gates.sh --only`.
|
||||
3. **Low.** `--only ''` means no filter (all steps run), and a selection
|
||||
that matches nothing (`--only suites --skip suites`) prints an empty
|
||||
table and `gates: PASS`, exit 0. A zero-step run being green is
|
||||
misleading; suggest exit 2 or a "no steps selected" line.
|
||||
4. **Info.** The corpus step is skipped green when `~/.cache/lucisv-corpus`
|
||||
is absent; documented, but a release run on a fresh host would pass
|
||||
without the corpus gate. `RELEASING.md` step 3 says so, which suffices.
|
||||
5. **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 `-m` limits 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.
|
||||
|
||||
+24
-6
@@ -105,16 +105,34 @@ under `docs/features/` that hold the detail. Not a commit log, not a round log.
|
||||
|
||||
## 3. Gate
|
||||
|
||||
All three must be clean before anything is built for distribution:
|
||||
Every gate must be green before anything is built for distribution:
|
||||
|
||||
```bash
|
||||
cargo fmt --check
|
||||
cargo clippy --all-targets
|
||||
cargo test --workspace
|
||||
tools/gates.sh # logs in target/gates/<timestamp>/
|
||||
```
|
||||
|
||||
Optionally re-run the real-world corpus check and quote the result in the
|
||||
changelog (`tools/corpus_fetch.sh` once, then `tools/corpus_check.sh`); a
|
||||
It runs each gate as a separate `tools/guard.sh` step with its own clock,
|
||||
memory limit and log: `cargo fmt --all -- --check`, `cargo clippy
|
||||
--workspace --all-targets -- -D warnings`, the test build (`cargo test
|
||||
--workspace --all-targets --no-run`), `cargo test -p <crate> --all-targets`
|
||||
for each workspace member in turn, the doc-tests (`cargo test --workspace
|
||||
--doc`), the corpus gate (`scripts/corpus_gate.sh` over
|
||||
`~/.cache/lucisv-corpus`, as CI runs it; skipped with a note when the corpus
|
||||
is absent — fetch it once with `tools/corpus_fetch.sh ~/.cache/lucisv-corpus`)
|
||||
and the extension's `node --test editors/vscode/*_test.js`. It prints one line
|
||||
per step start and end, then a table (step, result, seconds, passed/failed,
|
||||
log); it exits non-zero if any step failed. A step the guard killed is
|
||||
retried once and reported as `KILLED → retried → pass|fail` — a kill that
|
||||
passes on retry is still worth a line in the release notes' working log,
|
||||
and one that does not is a release blocker like any failure. The first
|
||||
attempt's log is kept as `<step>.killed.log`.
|
||||
|
||||
`tools/gates.sh --only suites,docs` or `--skip corpus` runs a subset
|
||||
(`--list` names the steps, `--help` the options). Do not replace it with a
|
||||
bare `cargo test --workspace`: that one command hid which binary stalled
|
||||
(TODO §65.3, `docs/features/release-gates/README.md`).
|
||||
|
||||
Quote the corpus step's numbers in the changelog when they changed; a
|
||||
verification error or a crash there is a release blocker by definition.
|
||||
|
||||
## 4. Build the artifacts
|
||||
|
||||
Executable
+237
@@ -0,0 +1,237 @@
|
||||
#!/usr/bin/env bash
|
||||
# Run lucisv's release gates, each as a separate tools/guard.sh step.
|
||||
#
|
||||
# Steps, in order (names for --only/--skip):
|
||||
# fmt cargo fmt --all -- --check
|
||||
# clippy cargo clippy --workspace --all-targets -- -D warnings
|
||||
# build cargo test --workspace --all-targets --no-run
|
||||
# suite:<crate> cargo test -p <crate> --all-targets, one step per crate of
|
||||
# the workspace Cargo.toml `members` ("suites" selects all)
|
||||
# docs cargo test --workspace --doc
|
||||
# corpus cargo build --release -p lucisv, then scripts/corpus_gate.sh
|
||||
# over ~/.cache/lucisv-corpus as CI does (skipped, with a
|
||||
# note, when that directory is absent; -c overrides it)
|
||||
# node node --test editors/vscode/*_test.js
|
||||
#
|
||||
# Each step's output goes to its own log under the log dir (default
|
||||
# target/gates/<timestamp>/, -o overrides); the terminal gets one line per
|
||||
# step start and end, then a summary table. A step the GUARD killed (exit
|
||||
# 137 plus guard.sh's "killing" line in its log) is retried once and shows
|
||||
# as "KILLED → retried → pass|fail"; an ordinary failure is not retried.
|
||||
# The per-step -t/-m limits are in limits() below, sized from measured runs
|
||||
# (docs/features/release-gates/README.md has the numbers).
|
||||
#
|
||||
# Why separate steps: the combined `cargo test --workspace` hid where a stall
|
||||
# was (TODO §65.3); a step per crate shows which binary hung, keeps its log,
|
||||
# and a retry costs one crate, not the whole suite.
|
||||
#
|
||||
# Usage: tools/gates.sh [-o log-dir] [-c corpus-dir] [--only a,b] [--skip a,b]
|
||||
# [--list] [--help]
|
||||
# tools/gates.sh # everything
|
||||
# tools/gates.sh --only suites,docs # the per-crate suites and doc-tests
|
||||
# tools/gates.sh --skip corpus # all but the corpus gate
|
||||
#
|
||||
# Exit status: 0 if every selected step passed (or was skipped for a missing
|
||||
# corpus), 1 if any failed or stayed killed, 2 on a usage error.
|
||||
# Standard tooling only (bash, awk, date, sed).
|
||||
|
||||
set -u
|
||||
|
||||
repo_root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
||||
cd "$repo_root" || exit 2
|
||||
log_dir=
|
||||
corpus=$HOME/.cache/lucisv-corpus
|
||||
only=
|
||||
skip=
|
||||
|
||||
usage() {
|
||||
sed -n '/^# Usage:/,/^# Exit status/p' "$0" | sed '$d; s/^# \{0,1\}//'
|
||||
}
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
-o | -c | --only | --skip)
|
||||
# A missing or empty value is a usage error, never "no filter".
|
||||
if [ $# -lt 2 ] || [ -z "$2" ]; then usage >&2; exit 2; fi
|
||||
case $1 in
|
||||
-o) log_dir=$2 ;;
|
||||
-c) corpus=$2 ;;
|
||||
--only) only=$2 ;;
|
||||
--skip) skip=$2 ;;
|
||||
esac
|
||||
shift 2 ;;
|
||||
--list) list=1; shift ;;
|
||||
-h|--help) usage; exit 0 ;;
|
||||
*) usage >&2; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# The workspace crates, from the root Cargo.toml `members` list: each
|
||||
# member directory's package name. Comments are dropped, a one-line list
|
||||
# and a glob member (`crates/*`) work; an empty answer is fatal below.
|
||||
crates() {
|
||||
local pattern dir
|
||||
for pattern in $(awk '/^members *= *\[/ { f = 1 } f { print } f && /\]/ { exit }' Cargo.toml |
|
||||
sed 's/#.*//; s/^members *= *//' | tr ',[]' '\n\n\n' | tr -d ' "'); do
|
||||
for dir in $pattern; do
|
||||
[ -f "$dir/Cargo.toml" ] || continue
|
||||
sed -n 's/^name *= *"\(.*\)"/\1/p' "$dir/Cargo.toml" | head -1
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
all_steps() {
|
||||
local c
|
||||
echo fmt clippy build
|
||||
for c in $(crates); do echo "suite:$c"; done
|
||||
echo docs corpus node
|
||||
}
|
||||
|
||||
# Does step $1 match the comma list $2? "suites" matches every suite:<crate>.
|
||||
in_list() {
|
||||
local item
|
||||
for item in $(echo "$2" | tr ',' ' '); do
|
||||
[ "$item" = "$1" ] && return 0
|
||||
[ "$item" = suites ] && case $1 in suite:*) return 0 ;; esac
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
selected() {
|
||||
[ -n "$only" ] && ! in_list "$1" "$only" && return 1
|
||||
[ -n "$skip" ] && in_list "$1" "$skip" && return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
# Guard limits per step: "<seconds> <GB>". Measured on the release Mac
|
||||
# 2026-10-19 from a cold target/ (seconds, peak tree RSS): fmt 3 s; clippy
|
||||
# 20 s, 1.6 GB; build 31 s, 2.6 GB; each small suite <= 3 s, <= 0.15 GB;
|
||||
# lucisv_server 19 s, 1.1 GB; lucisv_mcp 22 s, 1.4 GB; docs 1 s; corpus
|
||||
# (release build + score) 30 s, 1.2 GB; node 1 s. The clocks allow a 12x
|
||||
# slowdown (what a busy syspolicyd costs, §65.3) on top, with a floor of
|
||||
# two minutes; memory is the peak plus headroom. README has the runs.
|
||||
limits() {
|
||||
case $1 in
|
||||
fmt | node) echo "120 2" ;;
|
||||
clippy) echo "900 6" ;;
|
||||
build) echo "900 8" ;;
|
||||
suite:lucisv_server | suite:lucisv_mcp) echo "600 4" ;;
|
||||
suite:*) echo "300 4" ;;
|
||||
docs) echo "300 2" ;;
|
||||
corpus) echo "900 6" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# The command for step $1, into the array `cmd`.
|
||||
set_command() {
|
||||
case $1 in
|
||||
fmt) cmd=(cargo fmt --all -- --check) ;;
|
||||
clippy) cmd=(cargo clippy --workspace --all-targets -- -D warnings) ;;
|
||||
build) cmd=(cargo test --workspace --all-targets --no-run) ;;
|
||||
suite:*) cmd=(cargo test -p "${1#suite:}" --all-targets) ;;
|
||||
docs) cmd=(cargo test --workspace --doc) ;;
|
||||
corpus) cmd=(bash -c 'cargo build --release -p lucisv && scripts/corpus_gate.sh "$1"'
|
||||
corpus-gate "$corpus") ;;
|
||||
node) cmd=(node --test editors/vscode/*_test.js) ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# "passed N failed M" from a step log, where that is cheap to read off:
|
||||
# libtest's "test result:" lines, node's "# pass"/"# fail" (TAP; node 22+
|
||||
# prints "ℹ pass" instead), the corpus JSON.
|
||||
counts() {
|
||||
awk '
|
||||
/^test result:/ { for (i = 1; i <= NF; i++) { if ($(i+1) ~ /^passed/) p += $i; if ($(i+1) ~ /^failed/) f += $i }; n = 1 }
|
||||
($1 == "#" || $1 == "ℹ") && NF == 3 && $2 == "pass" { p += $3; n = 1 }
|
||||
($1 == "#" || $1 == "ℹ") && NF == 3 && $2 == "fail" { f += $3; n = 1 }
|
||||
/^\{"passing":/ { match($0, /"passing":[0-9]+/); pp = substr($0, RSTART + 10, RLENGTH - 10)
|
||||
match($0, /"total":[0-9]+/); t = substr($0, RSTART + 8, RLENGTH - 8)
|
||||
p += pp; f += t - pp; n = 1 }
|
||||
END { if (n) printf "%d/%d", p, f; else printf "-" }' "$1"
|
||||
}
|
||||
|
||||
# Run step $1 once under the guard into log $2, ending the log with a
|
||||
# "gate exit N" line. No gate reads stdin, so it is /dev/null.
|
||||
run_once() {
|
||||
local step=$1 log=$2 lim secs gb
|
||||
lim=$(limits "$step")
|
||||
secs=${lim% *} gb=${lim#* }
|
||||
set_command "$step"
|
||||
{
|
||||
echo "\$ tools/guard.sh -t $secs -m $gb -- ${cmd[*]}"
|
||||
tools/guard.sh -t "$secs" -m "$gb" -- "${cmd[@]}" </dev/null
|
||||
echo "gate exit $?"
|
||||
} >"$log" 2>&1
|
||||
}
|
||||
|
||||
status_of() { sed -n 's/^gate exit //p' "$1" | tail -1; }
|
||||
was_killed() { [ "$(status_of "$1")" = 137 ] && grep -q '^guard.sh: .*killing' "$1"; }
|
||||
|
||||
if [ -z "$(crates)" ]; then
|
||||
echo "gates.sh: no workspace crates found in Cargo.toml members" >&2
|
||||
exit 2
|
||||
fi
|
||||
[ "${list:-0}" = 1 ] && { all_steps | tr ' ' '\n'; exit 0; }
|
||||
|
||||
steps=$(all_steps)
|
||||
for s in $(echo "$only,$skip" | tr ',' ' '); do
|
||||
[ "$s" = suites ] && continue
|
||||
echo "$steps" | tr ' ' '\n' | grep -qx -- "$s" - || { echo "gates.sh: unknown step '$s' (see --list)" >&2; exit 2; }
|
||||
done
|
||||
|
||||
picked=0
|
||||
for step in $steps; do selected "$step" && picked=$((picked + 1)); done
|
||||
if [ "$picked" = 0 ]; then
|
||||
echo "gates.sh: the selection runs no step (see --list)" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
[ -n "$log_dir" ] || log_dir=target/gates/$(date +%Y%m%d-%H%M%S)
|
||||
mkdir -p "$log_dir" || exit 2
|
||||
summary=$log_dir/summary.txt
|
||||
: >"$log_dir/steps.tsv"
|
||||
echo "gates: logs in $log_dir"
|
||||
|
||||
failed=0
|
||||
rows=
|
||||
for step in $steps; do
|
||||
selected "$step" || continue
|
||||
log=$log_dir/$(echo "$step" | tr ':' '-').log
|
||||
if [ "$step" = corpus ] && [ ! -d "$corpus" ]; then
|
||||
echo "skipped: no corpus at $corpus (tools/corpus_fetch.sh \"$corpus\")" >"$log"
|
||||
echo " skip $step (no corpus at $corpus)"
|
||||
rows="$rows$step|SKIPPED (no corpus)|0|-|$log
|
||||
"
|
||||
continue
|
||||
fi
|
||||
echo " start $step ($(limits "$step" | sed 's/ / s, /') GB)"
|
||||
t0=$(date +%s)
|
||||
run_once "$step" "$log"
|
||||
result=pass
|
||||
[ "$(status_of "$log")" = 0 ] || result=fail
|
||||
if was_killed "$log"; then
|
||||
mv "$log" "${log%.log}.killed.log"
|
||||
run_once "$step" "$log"
|
||||
if [ "$(status_of "$log")" = 0 ]; then result="KILLED → retried → pass"
|
||||
elif was_killed "$log"; then result="KILLED → retried → KILLED"
|
||||
else result="KILLED → retried → fail"; fi
|
||||
fi
|
||||
t1=$(date +%s)
|
||||
case $result in *pass) ;; *) failed=1 ;; esac
|
||||
printf '%s\t%s\t%s\t%s\n' "$step" "$t0" "$t1" "$result" >>"$log_dir/steps.tsv"
|
||||
echo " end $step: $result ($((t1 - t0)) s)"
|
||||
rows="$rows$step|$result|$((t1 - t0))|$(counts "$log")|$log
|
||||
"
|
||||
done
|
||||
|
||||
{
|
||||
printf '%-22s %-26s %6s %-13s %s\n' step result seconds passed/failed log
|
||||
printf '%s' "$rows" | while IFS='|' read -r s r t c l; do
|
||||
[ -n "$s" ] || continue
|
||||
# printf pads by bytes; widen the column by what the arrows add.
|
||||
w=$((26 + $(printf %s "$r" | LC_ALL=C wc -c) - $(printf %s "$r" | LC_ALL=en_US.UTF-8 wc -m)))
|
||||
printf "%-22s %-${w}s %6s %-13s %s\n" "$s" "$r" "$t" "$c" "$l"
|
||||
done
|
||||
[ "$failed" = 0 ] && echo "gates: PASS" || echo "gates: FAIL"
|
||||
} | tee "$summary"
|
||||
exit "$failed"
|
||||
+9
-3
@@ -31,19 +31,25 @@ done
|
||||
|
||||
# Keep the command's stdin: a plain `cmd &` in a non-interactive shell
|
||||
# gives the job /dev/null, which silently empties any stdin-fed `lucisv`.
|
||||
exec 3<&0
|
||||
# A CLOSED stdin (`<&-`, some launchers) would make both redirections fail
|
||||
# and the command never run (exit 1, nothing executed); it gets /dev/null.
|
||||
{ exec 3<&0; } 2>/dev/null || exec 3</dev/null
|
||||
"$@" <&3 &
|
||||
root=$!
|
||||
start=$(date +%s)
|
||||
|
||||
# The command's process tree: descendants by parent pid, transitively.
|
||||
# Single spaces only: the list becomes `ps -p a,b,c`, and macOS ps rejects
|
||||
# the WHOLE list on an empty element ("a,,b") — which a doubled space made
|
||||
# for any tree three levels deep (cargo → rustc → ld, a test spawning
|
||||
# lucisv), summing 0 kB and silently disabling the memory limit (§65.3).
|
||||
tree() {
|
||||
local all="$1" next
|
||||
while :; do
|
||||
next=$(ps -axo pid=,ppid= | awk -v set=" $all " '
|
||||
{ if (index(set, " " $2 " ") > 0 && index(set, " " $1 " ") == 0) printf "%s ", $1 }')
|
||||
{ if (index(set, " " $2 " ") > 0 && index(set, " " $1 " ") == 0) printf " %s", $1 }')
|
||||
[ -z "$next" ] && break
|
||||
all="$all $next"
|
||||
all="$all$next"
|
||||
done
|
||||
echo "$all"
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user