Repository navigation
fix(runtime): resolve shutdown races blocking nightly releases - #262
Merged
Merged
Conversation
Leave pending worker tool calls unanswered during shutdown so reconnect can resume the same approval and inference. Reject old handlers instead of sending an interruption or polling after lease release. The restart regression failed 4/30 loaded runs before and passed 30/30 after, including pending-call and approval assertions. Fixes: #97
Closing discovery now waits for pinned handshakes and route writes, and a handshake finishing after discovery is disabled cannot add a route. Replace the silence check sleep with observed query cycles after draining old work. Fixes: #35
Discard discovery results when an overlapping installation completes. This prevents publishing a successful installation alongside the previous executable and version. A controlled discovery/install overlap reproduced the stale report before the fix; the regression passes 100/100 runs after it. Fixes: #26
Wait for worker bootstrap, command delivery, terminal turns and mirror purge instead of observing earlier routing or stream events. Publish PID markers atomically and distinguish killed zombies from running descendants without a procfs exists/read race. Give only the shell timeout case a short deadline; Stop waits for the gateway running state and retains process-group and no-harness assertions.
nixuuu
added a commit
that referenced
this pull request
Nov 7, 2026
No beta or stable has ever been cut: `next` and `main` are still at 57b87e5 while `dev` is ~290 commits ahead. The dev → next plan shows why. Besides a temporary explicit hold (#262 `Fixes: #26`, released once #262 soaks), the fallback blame of web fix #115 attributes its two adjacent lines in `AGENTS.md` to b7845036 `docs: add AGENTS.md…`, the second commit after `next`. A hold on that commit holds the entire suffix, permanently, because #115 is re-checked every run. A docs/test/ci/chore/style commit changes no shipped behaviour, so it can't be the change a fix corrects. Blame now never attributes to those commit types, and root `AGENTS.md`, `CLAUDE.md`, `README.md` and `CONTRIBUTING.md` join the shared files blame ignores. Explicit `Fixes:`/`Refs:` links and reverts still hold as before. `docs/release.md` describes the rule. Verified: new policy test (types, root files, refactor still holdable, explicit link to a docs commit still holds); `promotion-policy`, `promotion-attribution` and `promote` tests pass (38); typecheck, lint, format clean. Copy audit: no UI text changed.
nixuuu
added a commit
that referenced
this pull request
Nov 7, 2026
Scheduled Release runs on dev were cancelled when one flaky integration
test failed in a test shard. This PR collects every test failure from
the Release runs and PR CI runs of 2026-11-05 to 2026-11-07, finds the
cause of each, and fixes it deterministically. It adds no retries,
skips, global timeout increases or workflow changes.
Evidence was collected locally: gateway suites ran one file at a time,
mostly pinned to one CPU (`taskset -c 3`). Where a race could not be
forced naturally, a temporary delay was injected at the racing point,
and the same test was run with and without the fix. No injected delay is
committed.
### Fixed here
| Test | Cause | Fix | Before → after |
| --- | --- | --- | --- |
| `worker-ssh-command` › fixed SSH stdin … preserves the gateway and TLS
pin (nightly 42352444980) | After enrollment the installer runs `npm
prefix -g`. The test ran the runner's real npm, which cold-starts Node:
the success path took 0.3–4.1 s on CI (the tampering path, which exits
earlier, takes ~10 ms) and once went over the 5 s test timeout ("killed
1 dangling process"). | A stub `npm` in `$HOME/.local/bin`, which the
installer searches before the system paths. | 20 reruns with 6 busy
loops on the same CPU: mean 211 → 133 ms, max 662 → 314 ms; unloaded
mean 62 → 20 ms. |
| `full-access-mode` › an agent's side thread never gets Full access;
plus `agent-bus` › spawn options (PR CI) and the same race in 3 more
`agent-bus`/`agent-bus-cross` assertions | `spawn_thread` answers once
the side thread is stored. The gateway delivers the `createThread`
command to the worker afterwards, and the tests read `worker.created`
right away (Expected: 4, Received: undefined). |
`ScriptedWorker.createdThread(id)` waits for that command. | With the
worker's `createThread` handling delayed 200 ms: full-access 1 fail → 0;
agent-bus 3 relevant fails → 0; agent-bus-cross 2 fails → 0.
full-access-mode with 10 reruns on one CPU: 30/30. |
| `bots` › an expired lease cannot commit an old model answer (PR #318
CI) | The old gateway's 250 ms queue tick could re-claim the turn whose
lease the test expired before the competitor ticked. The held model then
ran again and the turn never settled (10 s timeout, last message "take
over"). | The old gateway drains, like one handing over: it keeps its
running turn but claims nothing. | With a 300 ms gap before the
competitor's tick: fail (identical error) → 3/3 pass. 10/10 on one CPU.
|
| `lan-routes` › routes are tried in order of last success (PR CI) | The
announcement test left B's withdrawn loopback route `127.0.5.2` in A's
routes. It is the newest route, so A's dial after the dead route
succeeded through it (dumped locally). B's next 1 s advertisement then
withdrew it, and the stale `127.0.0.1` route came first. On CI
`lastSuccessMs` was exactly one hour old, the value the test writes. |
The announcement test waits for the withdrawal and removes the route. |
The CI interleaving was not forced locally; the route dumps show each
step. After: 8/8 file runs on one CPU. |
| `config-sync-environment` › a document, a skill and a plugin arrive on
B (PR CI) | The test waited for the plugin only. A skill stays `WAITING`
until its version blob is fetched, one blob at a time (Expected:
`aeb81c…`, Received: undefined). | Wait for the document, the skill
version and the plugin artifact. | With B's blob fetches delayed 400 ms:
1 pass / 7 fail, the first with the exact CI error → 8/8. 5 runs on one
CPU: 8/8 each. |
| `composer-shell` › Codex steer executes at delivery (PR CI) | A watch
snapshot reads items before steers (`core-watch.ts`). When the
provider's user message item is ingested between the two reads, the
steer shows as delivered without its item. The stream sends the event
right after, so clients converge; the test only reads the first
snapshot. | Wait for a snapshot that has both. | 15 reruns on one CPU:
2/15 and 4/15 failed (the debug dump showed an empty item list) → 15/15.
|
| `schedules-new-thread` › offline pools retry the same occurrence (PR
CI) | A test closed a scripted worker's link while a command was on its
way. The worker loop replied on the closed link, and the `ConnectError`
escaped as an unhandled rejection that failed whichever test was
running. | The scripted worker's loop ends quietly on an unavailable
link. | Throwaway repro (close right after `createThread`, 20
iterations): 10/20 fail → 20/20 pass in 7 consecutive runs. The file
with 3 reruns: 21/21. |
| `worker-ssh` › owner-scoped SSH enrollment trust boundary (PR CI) |
ssh2's ed25519 keygen drops a leading zero byte of the public key (1 key
in 256). It writes a 31-byte public and 63-byte private key that neither
ssh2 nor OpenSSH (`ssh-keygen -y`) can read. The test's server host key
failed with "Malformed OpenSSH private key". | Product fix below; the
test uses the same helper. | `generateKeyPairSync`: 60/20000 and
83/20000 unreadable; `ed25519KeyPair`: 0/20000. worker-ssh 6/6. |
### Product fix (separate commit `fix(gateway): never store an
unreadable ssh install key`)
The gateway generates each owner's SSH install key with the same ssh2
call (`apps/gateway/src/core/worker-ssh.ts`, introduced in #5) and keeps
it until rotation. About 1 owner in 256 got a truncated public key and a
private key that can never be parsed, so every SSH install failed until
they rotated the key. `ed25519KeyPair` generates the pair again when it
does not parse. Keys already stored in that state still need Rotate. The
commit body carries `Fixes: #5`. This PR squashes under a `test:` title,
so that link and the patch release only apply if the fix is split out or
the PR is retitled.
### Already fixed by #262 (no change here)
- `config-sync-execution` › an unreachable home fails immediately…: all
6 failures were before #262 merged (last one 2026-11-06 09:01; #262
merged 10:27), and none since. 8/8 runs on one CPU.
- `remote-threads` › a file attached on A… / a file placed in the text
on A…: a cascade from the first test (worker `created` read without
waiting, thread not settled before the next test held turns). #262 fixed
exactly that, and none have recurred since.
- `computer-relay` › Share onward, `process-governor`, `bots-harness` ›
gateway restart: fixed by #262, and none have recurred since.
### Not flakes
Failures from in-progress feature-branch pushes, not on dev: the CLI
import suites on `feat/cli-import-*`, and the migration list and
error-text failures on `feat/linked-shared-config-7`.
### Gates
`bun install`, `bun run gen:check`, `bun run typecheck`, `bun run lint`,
`bun run format:check`, the web build and `bun run check:tmp` (1671
pass, 0 fail, 162 skip; nothing left in the temp dir) are all clean.
One thing to know: if TMPDIR is inside a Git checkout, `add-project` and
`linked-projects` fail locally, because their "folder without Git"
fixtures inherit the checkout's origin. `check:tmp` above ran with
TMPDIR on disk outside any repository.
Copy audit: no UI text changed.
This was referenced Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Nightly releases were cancelled by assertions that observed an earlier asynchronous event, plus three product lifecycle bugs. This change waits for the state each assertion actually needs and fixes the product bugs in separate commits. It adds no test retries, skips, blanket timeout increases or workflow cancellation changes.
Product fixes
Reproduction and results
Rates below are failed executions / attempted executions, not historical workflow frequency. Gateway suites ran one file at a time, pinned to one CPU (
taskset -c 10); process tests used--rerun-each 100. Skill-source checks also ran with two bounded CPU burners on that CPU. Temp data stayed on disk outside the repository. All repetitions execute the assertions normally; no retry wrapper is committed./procexists/read races with reaping (includingESRCH); parent completion also precedes descendant signal delivery. Read once, catch only process disappearance, wait until the owned process cannot execute, retain the no-delayed-write assertion.turnStarted; file creation can precede PID contents; immediate PID existence counts zombies as running. Give only the timeout case its short deadline, await gateway running state for Stop, publish PID atomically and await process termination.finally; preserve byte/content checks. No independent message-loss bug reproduced.The new process wait retains a five-second failure bound and accepts only a missing or non-executable process. Unexpected OS errors still fail the test. Stop still has to terminate its child and persist a user interruption; the timeout case still has to fail without launching a harness.
Historical inventory
Audit snapshot: 189
devRelease runs, 2026-11-03 08:39 UTC through 2026-11-06 08:52 UTC, and 9 failed CI runs. Read failed job logs, including first-attempt logs for the successful rerun of Release42072916585. Counts are distinct failed workflow runs per test, deduplicating run IDs across both listings and Bun's repeated summary lines. They are not a failure percentage: cancelled jobs did not all execute every test. Superseded cancellations with no failed job are excluded from test counts.beforeAllclaude install; output is redacted and secrets never reach the installerAn additional failed CI run (
41914149735) failed migration-ID/lint checks without a test failure; it is not a per-test row. Composer, Grok cleanup and skill sources were also investigated because they were reported in the task, although those names did not appear in this audit's failed-job inventory.Validation and limits
bun install,bun run gen:check,bun run typecheck,bun run lint,bun run format:checkandbun scripts/build-web.tspassed after rebasing onto currentorigin/dev.bun run check:tmp: 1,448 passed, 159 existing skips, 0 failed, 258 files / 1,607 tests, 462.49 s. No test temp directories left behind; tool-owned runtime caches were removed by the runner's private-directory cleanup.Fixes: #97
Fixes: #35
Fixes: #26