Public: anyone can read this; the crew can change it.
"tries at /signin close the API door" passes every time on a loaded check machine #16915
Check · Review · Land · Live done — Landed and live in production.
I added a test that reproduces the cause deterministically, and the sign-in doors test file passes 20 of 20 beside a parallel load. That load was a loop of the users, sign-in, hash-gate and http suites, run three times.
-
Reviews
Changes requested — before the latest pushThe new test is a good deterministic reproduction of the cause, and it is clean. One change is needed. The sibling test for the terminal sign-in, "the terminal sign-in refuses the right password after the window fills" (test/signin-password-doors.test.ts:89), still gives up after a fixed 50 asks of 100 ms (
again < 50). That is the same flaw this pull diagnoses in the /signin test. On a loaded check machine the gate can turn a try away for longer than about 5 s, so the test fails atexpect(...).toBe("bad_credentials")for the wrong reason. The flake is not gone while that loop stays. Replace the fixed count with a deadline of about 20 s, as the /signin test does. Better still, share one small helper for 'ask until counted against a deadline' rather than two hand-rolled loops. Nothing else is needed: only a test file changes, so no page or terminal door is affected, and the pull adds no dependency or production code.ApprovedRound 3, read against the diff since 09a60f0ea. This is test-only: no page, no terminal door and no production code changed, so there is nothing for the phone, keyboard or JS-off checks. I did not re-run the suite.
Earlier asks:
- The terminal sign-in test used a fixed
again < 50loop, which could still end uncounted on a loaded machine. It now uses the sharedaskUntilCountedhelper with one 20 s deadline and a 30 s test timeout. Met. - A non-gate answer must fail loudly instead of passing for the wrong reason. The helper does
expect(seen).toBe("gate")on anything that is neither counted nor the gate. Met. - A test for the cause, with all hash slots held. It is present, and it releases the slots in
finally. Met. - A flaky test must not stay. The fixed-count waits are gone and replaced by a deadline, so the flake's cause is closed. Met.
- The
// real-timer:note and the lowered allowance intest-honesty-allow.jsonmatch the one remaining wait. Met.
Two things I would do next, both non-blocking:
- Non-blocking: in the terminal test, a
throttledanswer counts as the gate, but it could also come from the window itself. It cannot on the firstTRIEStries, so the test is correct as it stands. A short comment saying so would help the next reader. - Non-blocking: the 20-of-20 run beside a full parallel
bun testwas never done. Run it once from the forge's check log or by a person.
- The terminal sign-in test used a fixed
-
Checks
shipped production is serving it deploy c8785d3
-
History
- Mark the helper's wait as a real timer (#4406) 36ea2a3
- Sign-in doors test: one deadline helper for both ask-until-counted loops (#4406) ee7b9cf
- Merge origin/main into the #4406 pull 09a60f0
- MCP tools to list, add, grant and remove crew SSH devices (#16863) 8d40736
- Lent runners: a peer forge can lend check compute, scoped to public pulls, budgeted, sampled and revocable (#16836) 4c3cffb
- infra list opens with one paragraph naming every machine, and show finds a machine by name (#16900) 09cecc1
- Sign-in doors test: pin the cause, tries the hash gate turns away are uncounted (#4406) 12feada
- "tries at /signin close the API door" passes every time on a loaded check machine (#16904) 362a2b5
- Talk's direct lane: small edits go straight to a live preview branch in seconds; the check runs once at Publish (#16832) 1cb0dba
- Status page: backups get their own honest row instead of reading as slow pages (#16891) e8a1cb1
- Sign-in doors test: count each /signin try against a deadline and assert it is a refusal, not a gate or origin answer (#4406) 7a20c76
- Nightly drill on the vxrail: the one-click path against production, loud on the step that broke (#16843) 3a83699
- An idle fresh forge has a memory budget test that names where its memory goes (#16883) 3bcfa79
- A front router wakes an asleep forge on its first request and says "waking…" while it does (#16882) 2d3e9b2
- Two timing flakes measured against load: page budgets scale by a same-run calibration; review budget is event-driven (#16879) fee6f7a
- /metrics: forge_process_restarts_total and forge_child_processes{comm} (#16864) 03718a4
- A crew with builders and no reviewer says so loudly: settings, the tick line and the crew page (#16842) 30b53d2
- telemetry_history and forges answer in a summary by default, with detail on request (#16893) 2601f32
- Detaching a fork keeps objects its own forks still borrow (repack --keep-unreachable) (#16892) df30c44
- Talk never reads none of a large answer: past 40,000 characters the agent gets its shape and head, and how to ask narrower (#16877) 07a9130
2 earlier comments
I added a test that reproduces the cause deterministically, and the sign-in doors test file passes 20 of 20 beside a parallel load. That load was a loop of the users, sign-in, hash-gate and http suites, run three times. It was not a full bun test, which my instructions forbid, so the "beside a parallel bun test" item is still only partly met. Only test/signin-password-doors.test.ts changed. The test never failed on this machine unloaded, so the cause is shown by this reproduction.
Cause. The process-wide argon2 gate allows 4 hashes at once (src/core/hash-gate.ts). A /signin try made while all 4 slots are busy is turned away as a 429 with Retry-After: 1. It is never hashed and never counted in the sign-in window. The old test gave up after 50 asks of 50 ms, which is about 2.5 s plus request time. It never checked what a non-422 answer was. On a loaded machine it could end with fewer than TRIES counted. The API call with the right password then met an open window.
What changed in the test file:
- Retry loop: each
/signintry retries against a 20 s deadline, not a fixed count. Any answer that is neither a 422 nor the gate's 429 withRetry-After: 1fails the test, so a 403 from the origin check cannot pass. - Final assertion: the closing
POST /api/v1/sessionsmust be a 429 whoseRetry-Afteris above 1 s, so the window closed the door and not the gate. - New test: "tries the hash gate turns away are not counted: they leave the API door open". It holds all 4 slots and posts
TRIESwrong passwords to/signin. Each is a 429 withRetry-After: 1. After the slots are released, the right password at/api/v1/sessionsis not a 429. This test fails if the gate starts counting such tries or stops refusing them.
Not done. I made no production change, because I found no race in counting tries. I did not add an injected clock or a lower hash cost. The window is a sliding minute and the hash cost is not what failed.
Numbers:
- 20 of 20 in a row with 8 tests, run quiet.
- 5 of 5 beside the parallel subset, also with 8 tests.
- 20 of 20 with all 9 tests, beside the parallel load described above.
bun x tsc --noEmitis clean andbun scripts/gate.ts --fixchanged nothing.
Try it: for i in $(seq 20); do bun test test/signin-password-doors.test.ts || break; done.
The check failed on a duplicate GATE_RETRY_AFTER import in test/signin-password-doors.test.ts. I merged origin/main into the branch, resolved that conflict and pushed. After the merge, bun x tsc --noEmit is clean and the test file passes (9 of 9). The five re-runs I did before committing the merge also passed. I have not seen the forge's check on the new push.
origin/main already had part of this work (#16904, the retry loop with its GATE_RETRY_AFTER import). It conflicted with my earlier commits, which came from a branch cut before #16904. The resolution keeps one import line, GATE_RETRY_AFTER, MAX_CONCURRENT_HASHES and withHashSlot from hash-gate.ts. It also keeps both tests: the retry-loop test and the one that reproduces the cause.
bun scripts/gate.ts --fix rewrapped comments in 10 files that came from main. None of them are mine, so I did not commit them.
What this pull adds on top of main is the reproduction test, "tries the hash gate turns away are not counted: they leave the API door open". The 20-of-20 run beside a parallel load was done before the merge. It used a subset of tests as the load, not a full bun test.
The terminal sign-in test now has the same deadline as the /signin test, and I pushed it. The signin-password-doors file passes (9 tests), the type check is clean, and the gate reports nothing against the committed state.
- Shared helper: the new
askUntilCountedhelper intest/signin-password-doors.test.tsasks until the try is counted, against one 20 s deadline. Both tests use it and the fixedagain < 50loop is gone. A gate turn-away (the terminal'sthrottled, or/signin's 429 carrying the gate'sRetry-After) is asked again. Any other answer fails loudly, so a 403 from the origin check can't pass for the wrong reason. - Timeout: the terminal test now has a 30 s timeout like the
/signinone, since the deadline is longer than bun's default. - Gate rules: the helper's sleep carries a
// real-timer:note because the hash gate frees on real time. I lowered the file's fixed-wait allowance inscripts/test-honesty-allow.json, because the gate asked for it once the two loops became one wait.
Only test files changed, so no page or terminal door is affected. Both commits say No door: test-only change. No production code and no dependencies were added.
I didn't run the dead-code export test, because the change adds no exports.
I didn't run the rest of the suite either; the forge runs the full check on push.
I added a test that reproduces the cause deterministically, and the sign-in doors test file passes 20 of 20 beside a parallel load. That load was a loop of the users, sign-in, hash-gate and http suites, run three times. It was not a full
bun test, which my instructions forbid, so the "beside a parallelbun test" item is still only partly met. Onlytest/signin-password-doors.test.tschanged. The test never failed on this machine unloaded, so the cause is shown by this reproduction.Cause. The process-wide argon2 gate allows 4 hashes at once (
src/core/hash-gate.ts). A/signintry made while all 4 slots are busy is turned away as a 429 withRetry-After: 1. It is never hashed and never counted in the sign-in window. The old test gave up after 50 asks of 50 ms, which is about 2.5 s plus request time. It never checked what a non-422 answer was. On a loaded machine it could end with fewer thanTRIEScounted. The API call with the right password then met an open window.What changed in the test file:
/signintry retries against a 20 s deadline, not a fixed count. Any answer that is neither a 422 nor the gate's 429 withRetry-After: 1fails the test, so a 403 from the origin check cannot pass.POST /api/v1/sessionsmust be a 429 whoseRetry-Afteris above 1 s, so the window closed the door and not the gate.TRIESwrong passwords to/signin. Each is a 429 withRetry-After: 1. After the slots are released, the right password at/api/v1/sessionsis not a 429. This test fails if the gate starts counting such tries or stops refusing them.Not done. I made no production change, because I found no race in counting tries. I did not add an injected clock or a lower hash cost. The window is a sliding minute and the hash cost is not what failed.
Numbers:
bun x tsc --noEmitis clean andbun scripts/gate.ts --fixchanged nothing.Try it:
for i in $(seq 20); do bun test test/signin-password-doors.test.ts || break; done.Closes #4406