Skip to content

WaitQueue's #armTimeout comment names a timeoutMs gap that its own callers do not have #666

Closed

Description

@V3RON

The doc comment on `WaitQueue##armTimeout` (`src/leasing/wait-queue.ts:365-369`) states:

`markNew` (below) is a public path back to `queued` that arms no timer at all -- a waiter it returns to `queued` sits with no deadline until some other `enqueue` call re-arms it, which is a real gap in `timeoutMs` enforcement for whichever caller uses that path (`LeaseAcquisitionCoordinator`'s own eviction and provision-retry callers, not this module's problem to close on its own).

The named gap does not exist. `markNew` has exactly two callers on `main`, and each re-decides the waiter in the same synchronous decision section, and every branch of that re-decision runs the deadline check:

  • `#provision`'s first-failure retry (`src/leasing/lease-acquisition-coordinator.ts:849`) returns `true` and calls `#drive` on the next line.
  • `#continueAfterEviction` (`src/leasing/lease-acquisition-coordinator.ts:1008`) calls `#decide` inside the same `decisions.run`.

`#decide` reaches `markProcessing` (`:886` or `:900`) or `#defer` → `#enqueue`, and `markProcessing` checks the deadline (`wait-queue.ts:254`) exactly as `enqueue` does (`:236`). Both paths were driven to the `markNew` line in unit tests with the armed deadline falling due mid-attempt; in both the caller received `QueueTimeoutError` and the stored request settled `failed` — see #657 for the reproductions.

So the comment asserts a defect in named code that is not there, and tells a later reader the case is known-and-accepted. It should say what is actually true: `markNew` arms nothing because every caller of it decides the waiter again immediately, and the two paths back into `queued`/`processing` both check the fixed deadline.

Written by an agent.

Activity

  1. added
    bug:new
    and removed
    bug:new
    on Oct 17, 2026
  2. self-assigned this
    on Oct 17, 2026
  3. V3RON commented on Oct 17, 2026

    @V3RON
    ContributorAuthor

    Confirmed: the defect is the comment, not the code. No caller, test, or future markNew-era branch on main can produce the state the paragraph names, so nothing is wrong in timeoutMs enforcement — and the paragraph asserts a defect that is not there and tells the reader it is known-and-accepted (rule 13: a false claim in a comment is a defect). The fix is comment-only: no test artifact, no bug/666-repro branch — there is no assertion that can fail against a comment, exactly as in #657 ("nothing to reproduce means no failing test").

    Reproduction

    Comment-only, so the reproduction is the demonstration that the named state is unreachable and both real deadline re-checks are already pinned. On 7bbc22e5:

    $ pnpm exec vitest run --project unit src/leasing/wait-queue.test.ts \
        src/leasing/lease-acquisition-coordinator.test.ts
    Test Files  2 passed (2)   Tests  178 passed (178)
    

    Deleting markProcessing's deadline check (wait-queue.ts:254) goes red on a named test — wait-queue.test.ts > WaitQueue > rejects QUEUE_TIMEOUT instead of marking processing past the original deadline — and enqueue's check (:236) is pinned by rejects immediately on a re-enqueue past the original deadline…. Both markNew call sites (lease-acquisition-coordinator.ts:849, :1008) re-decide the waiter inside the same synchronous decisions.run, and every branch that keeps the waiter alive passes one of those two checks; #657 drove both sites with the armed deadline falling due mid-attempt and got callerError: 'QueueTimeoutError', stored failed, queueDepth: 0. The waiter does land back in queued (a processing waiter stays in #waiters) — it just never sits there: the window to the re-check is inside one decision section.

    Root cause

    src/leasing/wait-queue.ts:365-369 — the Separately: markNew … paragraph of the #armTimeout doc block was written assuming a markNew caller can park the waiter in queued; both callers on main return it to a decision immediately, so the "real gap" it declares does not exist.

    Simplest fix

    Comment-only, in the #armTimeout doc block (src/leasing/wait-queue.ts), landed verbatim:

    1. Prefix the block's first line with why: (the edit makes comment-lint judge the whole block).
    2. Replace the last paragraph — from Separately: \markNew` (below) is a public paththroughnot this module's problem to close on its own).` — with:
       *
       * `markNew` arms nothing, and that is safe only because its callers hand the waiter straight
       * back to a decision: every branch of that decision that keeps the waiter alive passes
       * `#expireIfPastDeadline` (through `markProcessing`) or `enqueue`'s own upfront check first. A
       * caller that returned without re-deciding would leave a waiter `queued` with a fixed deadline
       * and no timer, and would have to arm here.
    

    Both edits verified on 7bbc22e5: node .agents/scripts/comment-lint.mjs src/leasing/wait-queue.ts exits 0 and the two suites above stay green (178 passed).

    Alternatives rejected

    • Delete the paragraph and nothing else — a bare delete still edits the block, which then fails comment-lint; a rewrite is forced anyway.
    • Keep the false paragraph as a "warning" — a false why: is a claims finding (rule 13); the honest version warns future callers without inventing a present gap.
    • A type/structural guard (e.g. markNew arming its own timer) — the contract holds at both callers today and an extra arm would paper over a hypothetical caller that violates it; the rewritten paragraph names the invariant instead.

    Risk

    Written by an agent.

  4. removed their assignment
    on Oct 17, 2026
  5. added
    bug:ready
    and removed on Oct 17, 2026
  6. self-assigned this
    on Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug:ready

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions