Skip to content

Gate: a hard timeout per harness, and CLAUDE.md that worktrees can see - #124

Open
shazz wants to merge 5 commits into
mainfrom
fix/gate-and-rules
Open

shazz wants to merge 5 commits into
mainfrom
fix/gate-and-rules

Conversation

@shazz

@shazz shazz commented Sep 20, 2026

Copy link
Copy Markdown
Owner

Three files, all infrastructure. Not merged directly because build.sh is
modified and uncommitted in the shared checkout by another session's
in-flight replicants_emlyn work — merging would conflict with their
working copy or land silently underneath it.

Full gate green on this branch (355 checks), with the timeout wrapper
itself active during the run.

Why: a wedged gate is worse than a failing one

node apps/union_demo_music_check.mjs --fail-proof wedges INTERMITTENTLY at
0.0% CPU. The same check passes standalone in about 5 s, so it is a race on
the SNDH/audio path, not a hang. It has cost, in this repo, on separate
occasions: 80 minutes, 2h23m, and — on 2026-09-20, which prompted this —
nine hours, at 0.0% CPU and zero seconds of CPU time consumed, while
"still running" was believed because only elapsed time was being checked.

A wedge cannot be told apart from a slow gate, so green never arrives and
nobody is told why. This turns an invisible stall into a red line.

The number is 900, and that is a correction

This branch originally shipped HARNESS_TIMEOUT=300. That is wrong:
rom_abi_check.mjs takes 105 seconds on an idle box, and the gate is
often run while another one is going. At 300 it is killed by its own
watchdog and the gate dies with a spurious red — trading a silent wedge for
a flaky failure is not an improvement.

What would actually be right, written down in the file

A wall clock cannot tell "slow" from "hung". The wedge has a signature that
can: it consumes zero CPU seconds while it hangs, where a slow harness
burns CPU throughout. A watchdog on CPU time would need no arbitrary ceiling
at all. timeout cannot express that, so 900 is the blunt version and
HARNESS_TIMEOUT is an env var so nobody has to edit the file.

The instant diagnosis, for anyone who meets this before the watchdog exists:

ps -o etime=,time=,pcpu=,cmd= -p <pid>

time= is CPU consumed. A wedged harness shows 00:00:00 however long
etime= says.

CLAUDE.md becomes tracked

.claude/, TODOS.md and tools/private_tools/ are gitignored, so a
git worktree contains none of them — and CLAUDE.md used to be in that
list, which meant an agent working in a worktree saw no project rules at
all
. It would happily ship a .ym dump and be correct by its own lights.

The tracked copy here is the LIVE untracked file plus a new section on what
a worktree does not have. It deliberately includes the ./build.sh --fast
rule added since this branch was cut: tracking the older copy over it would
have silently dropped a rule from the file everyone reads, which is this
change's own failure mode in reverse.

Note for whoever merges: the shared checkout still has an untracked
CLAUDE.md at that path. It is byte-identical to the tracked one here, so
if git refuses the checkout, deleting it loses nothing.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PqAQy29kDDSnaSE3eUgEBj

matt-grain and others added 5 commits September 19, 2026 16:53
Two failures from 2026-09-19, both structural, neither caused by a port.

1. A WEDGED GATE IS WORSE THAN A FAILING ONE.

`node apps/union_demo_music_check.mjs --fail-proof` stopped at 0.0% CPU and
./build.sh sat on it for 80 MINUTES before a human looked. A different audio
harness (c_music_check.mjs) did the same for 2h23m earlier. Neither is a
permanent hang — the same check passes standalone in ~5 s — so it is an
intermittent race on the SNDH/audio path. A plausible mechanism: a poll loop
waiting for sound against a player that can legitimately take tens of seconds
to start (digidrum SNDHs may arm their timer via XBIOS Xbtimer; Monty's drums
start at 38.4 s).

The damage is not the lost time, it is that a stalled gate is indistinguishable
from a slow one. Green never arrives and nothing says why.

Every harness now runs under `timeout ${HARNESS_TIMEOUT:-300}`, via a `node()`
shell function rather than editing 48 call sites (`timeout` execs the real node,
so it does not recurse). Verified: a wedged harness aborts the gate with exit
124 and a named message; a normal one is unaffected.

2. AN AGENT IN A WORKTREE COULD NOT SEE THE PROJECT RULES AT ALL.

CLAUDE.md was gitignored AND had never been tracked, so a `git worktree` or a
fresh clone contained no copy. Its one hard rule is "every screen's music is an
SNDH, never a .ym dump" — so an agent working in a worktree would ship a .ym and
be correct by its own lights. Not a rule ignored: a rule that could not be seen
to exist. Two ports today honoured it only because it was hand-carried in the
briefs.

CLAUDE.md is now tracked, and documents what a worktree still does NOT have:
.claude/, TODOS.md, tools/private_tools/ and prototypes/ stay local-only by
design, so it names them, says to run those tools from the main checkout by
absolute path, and tells anyone briefing a worktree agent to put the rules in
the brief. It also corrects the stale `tools/fetch_codef.py` path that two
sessions independently tripped over today.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PqAQy29kDDSnaSE3eUgEBj
The tracked copy was taken before the Building section existed, so merging
this branch would have tracked a CLAUDE.md missing the --only/--changed
usage, one-gate-at-a-time, and "a screen is only covered if its harness is
named in build.sh". All three sections are now present: Music, Building, and
what a git worktree does NOT have.

Caught because buxton pointed out it had added those rules locally and then
realised they were invisible to every worktree agent — which is the same
gitignore problem this branch exists to fix.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PqAQy29kDDSnaSE3eUgEBj
# Conflicts:
#	build.sh
The tracked copy was made before `./build.sh --fast` existed, so tracking it
as it stood would have SILENTLY DROPPED that rule from the file everyone
reads — the exact failure this whole change exists to prevent, in reverse.

The tracked file is now the live untracked one plus the worktree section,
so landing it changes nothing anyone is currently reading.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PqAQy29kDDSnaSE3eUgEBj

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants