Skip to content

fix(gateway): a stale worker view no longer brings back a released lease (#898) - #899

Merged
V3RON merged 3 commits into
mainfrom
bug/898
Oct 23, 2026
Merged

V3RON merged 3 commits into
mainfrom
bug/898

Conversation

@V3RON

@V3RON V3RON commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Closes #898

A worker view read before a release can land after it and still list the released lease. The gateway's lease index added it back, so the requester's next request got 409 REQUESTER_ALREADY_LEASED until two more views missed it. That is the gateway-smoke #253 flake.

Now a lease the worker answered released (or UNKNOWN_LEASE) is not added back by a later view. Granting the same caller-chosen id again clears that.

The issue's first diagnosis (release does not record the id in #removedByEvent) was not enough on its own: an id in that set is still re-added, only logged.

Status

Built. Unit tests for the gateway and pnpm test:e2e e2e/gateway-smoke.test.ts pass locally. Review pending.

Assumptions

  • Assumption: relayed lease.expired/lease.released keep today's log-and-re-add — an existing test pins it, and the flake comes from the release path.

Review

Spec review: 0 blocking, 0 fixed, 1 notes. Code review: 1 blocking, 1 fixed, 0 notes. Claims review: 0 blocking, 0 fixed, 0 notes.

Rounds: 2. Tokens: 2.5M.

Round 1 found R1 (the worker-answer mark was set only when the entry still existed); fixed at 5463be2 and verified in round 2 by the Opus code lens. Assessment: complete.

Written by an agent.

@V3RON

V3RON commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Review ledger

Round 1: 72751f8
Round 2: 5463be2

  • R1 code, blocking: FleetLeaseIndex#remove set the "ended by worker answer" mark only when the entry still existed, so a relayed lease.released event that arrived first left the stale-view race open. Fixed 5463be2; verified round 2 by the Opus/high behaviour lens (F0, Assessment complete): remove marks before the entry check; release, releaseAll and the UNKNOWN_LEASE path all go through it; no other site of the class (removeByWorkerLease is the relayed event alone, #reconcileMissing and forgetWorker are not worker answers). Restoring the old lease-index.ts makes the 3 new tests fail.
  • R2 spec, nonblocking: e2e body print in e2e/gateway-smoke.test.ts is unrequested.
  • Round 2 impacts: behavior (lease-index.ts), test-logic (new tests, onReleaseLease hook), claims (src/gateway/AGENTS.md sentence). Tests lens skipped: thin fixture hook plus two regression tests, probed by the behaviour lens. Claims lens (Sonnet/medium) checked the one sentence, the why: comment, the hook doc and both titles: F0, complete.

Runs: 7. Cost USD: 1.8734. Agent seconds: 616.
Tokens input 153, output 35555, cache read 2580468, cache write 259093.

  • review 1 code both: claude-opus-5-5 185 s $0.8799
  • review 1 spec: claude-sonnet-5-5 27 s $0.1006
  • review 1 claims: claude-sonnet-5-5 23 s $0.0874
  • review 2 reviewer: claude-sonnet-5-5 114 s $0.1847
  • review 2 reviewer: claude-sonnet-5-5 174 s $0.1916
  • review 2 code behaviour: claude-opus-5-5 69 s $0.3438
  • review 2 claims: claude-sonnet-5-5 24 s $0.0854
    Finding outcomes: {"fixed":1,"nonblocking":1}. Classes: {"diff does nothing unrequested":1,"relayed event removes entry before mark":1}.
{"findings":[
{"id":"R1","role":"code","class":"relayed event removes entry before mark","outcome":"fixed","path":"src/gateway/lease-index.ts","round":"1","fix":"5463be2052481d0ad57d0f1de1ea2c918c86328c"},
{"id":"R2","role":"spec","class":"diff does nothing unrequested","outcome":"nonblocking","path":"e2e/gateway-smoke.test.ts","round":"1"}
]}

Written by an agent.

@V3RON
V3RON marked this pull request as ready for review October 23, 2026 10:59
@V3RON
V3RON merged commit f6cc13c into main Oct 23, 2026
72 checks passed
@V3RON
V3RON deleted the bug/898 branch October 23, 2026 11:00
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.

flaky: gateway-smoke #253 test gets 409 on the second lease request after a release

1 participant