Skip to content

desk-hub: fix two test flakes (the offline sweep's 401, the lease test's margin) - #107

Merged
SSFSKIM merged 2 commits into
masterfrom
desk-hub-flakes
Oct 21, 2026
Merged

SSFSKIM merged 2 commits into
masterfrom
desk-hub-flakes

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Oct 21, 2026

Copy link
Copy Markdown
Owner

Fixes two desk-hub test flakes on master. In both, the test was wrong and the hub's code was right.

provisioning-sweep: "binds each candidate to the enrollment it read…"

It failed in runs 39568222090 and 39582934642 with expected '403 not-enrolled' to be '401 access'.

Cause. Registry.revokeMachine does three things in order:

  1. It deletes the machine's record.
  2. It tells every project of the org (sweepRevocations).
  3. It deletes the Access token (sweepOrphans).

Between steps 1 and 3, the Worker refuses the credential with 403 not-enrolled. Access's 401 comes only after the token is gone. The provisioning-keys spec (§4, "What the credential gets afterwards") sets this order, so the code is right.

The revocation here runs from the Registry's alarm, and the suite doesn't await it. The race test, and the "late" test written the same way, saw the record disappear from the list and asked right away. On a loaded box the token's deletion hadn't landed yet.

Fix. Both tests now wait for the token (tokenGone), as the gone and fenced tests already did.

Evidence:

  • With the stand-in API answering the deletion 400 ms late, master's race and late tests both fail with 403. The fixed tests pass.
  • An amplified pre-fix pool run (below) caught the window directly: one of 20 copies saw the token still held when the record was already gone. It was deleted 28 ms later.

session-plane: "hb-acks of the current generation keep the machine online past its lease"

It failed in run 39568222090: the machine was seen offline once.

Cause. The test ran a 1.2 s lease on a 200 ms heartbeat and asserted that the machine never read offline over 2.5 s. That leaves 1 s for each renewal's round trip:

  1. The Machine object's timer fires.
  2. The heartbeat goes out over SSE to the suite's proxy and client.
  3. The client POSTs hb-ack back through the Worker and the Machine object to Project.renew.

A stall of more than a second anywhere along that path lapses the lease. When the next renewal arrives, the machine comes back online. The deployed lease is 45 s on a 15 s heartbeat, so the hub's behaviour is as designed.

Fix. The test now uses a 3 s lease. Its wait ends 1 s after the lease that the hello started.

Evidence. I paused the client's acks in the middle of the window:

Test Acks paused 1.3 s Acks paused 2.4 s Acks never sent
Master's fails as in CI ("online": false) — —
Fixed passes passes fails

The last column shows the fixed test still detects renewals that don't renew.

Rarity. Across about 90 failed gate runs since 10-19, this test failed once (39568222090) and the sweep test failed twice. The lease flake did not reproduce in 40 amplified copies on the pool, nor locally under CPU load. That is why the evidence above injects the stall rather than waiting for one.

Repeat runs under CI's conditions

Each run was on ci-kit's pool, with the unit job at --maxWorkers=nproc. Each added 20 whole-suite copies of each file to the full suite.

Run Tests File order Result
39587718168 master's vitest's own green
39589271179 master's longest first across projects, as in 39568222090 green
(post-fix runs) fixed both orders results in a comment

The pre-fix runs carried diagnostics (SWEEP-DIAG and LEASE-DIAG lines in their logs).

Gates and review

  • scripts/ci-gate.sh --gates static,unit: result in a comment.
  • Review: doperpowers:reviewer-low, verdict in a comment.

Sminos-Session: smns-erb-71#b4948247 (doperpowers on macbook)

…pool's load breaks

provisioning-sweep: a revocation deletes the machine's record, tells every project, and then deletes its Access token,
so between the record and the token the Worker refuses the credential 403 not-enrolled, and Access's 401 comes only
after (the spec's §3 order). The sweep's revocation is the alarm's, which the suite does not await: the race and late
tests saw the record gone and asked at once, reading 403 when the token's deletion had not landed (runs 39568222090,
39582934642). They now wait for the token as the gone and fenced tests already did (`tokenGone`). With the API's
deletion answered 400 ms late, the old tests fail both and the new ones pass.

session-plane: the lease test ran a 1.2 s lease on a 200 ms heartbeat and asserted the machine never read offline over
2.5 s; one renewal landing more than a second late (a stall anywhere from the hub's timer through the suite's proxy and
client back to the project) lapsed the lease (run 39568222090). A 3 s lease now, and the wait ends a second past the
lease the hello started. With the acks paused 1.3 s, the old test fails as in CI and the new one passes (and at 2.4 s);
with no ack renewing, the new one still fails.

Sminos-Session: smns-erb-71#b4948247 (doperpowers on macbook)
Sminos-Session: smns-erb-71#b4948247 (doperpowers on macbook)
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T11:33:00.403964Z 27de1cf PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@SSFSKIM

SSFSKIM commented Oct 21, 2026

Copy link
Copy Markdown
Owner Author

Gates for head 27de1cf: scripts/ci-gate.sh --gates static,unit is green (run 39592442135).

Post-fix repeat runs, on the pool with 20 whole-suite copies of each file added to the full unit suite, both green:

Counting the gate's own run, that is 42 executions of each fixed test with no failure.

Review (doperpowers:reviewer-low): correct, no findings. The reviewer found no hub defect behind either flake. The 403-before-401 window is the fail-closed order the spec allows. No lease, renew or alarm path takes a machine offline while current-generation renewals arrive in time. The new lease test still fails when renewals don't renew. No other test has the same assert-right-after-gone race.

Sminos-Session: smns-erb-71#b4948247 (doperpowers on macbook)

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.

1 participant