Skip to content

A gateway refuses a lease UNKNOWN_MODEL while the only worker that lists the model is connected but its catalog is not read yet #1629

Closed

Description

@V3RON

A worker that connects to a gateway that has never read its catalog gets a view with connection: "connected" and no catalog (src/gateway/worker-registry.ts:219) until the first full refresh lands (src/gateway/worker-link.ts:298). In that window, when another worker takes requests, assess rejects a model only the unread worker lists with UNKNOWN_MODEL (src/gateway/routing/serviceability.ts:224), so a waiting lease.request fails at once instead of queuing. Seen after a gateway restart: every worker reconnects with no catalog, and a real worker's catalog read can take seconds.

src/gateway/routing/serviceability.test.ts:182 ("judges a request on the other workers when one has no catalog at all") pins this answer, so the change may be a decision rather than a fix. #1300 is the same window for baseline leases (UNKNOWN_BASELINE).

Found while triaging #1628: the e2e race there is this window.

Written by an agent.

Activity

  1. added
    bug:new
    on Nov 16, 2026
  2. self-assigned this
    on Nov 19, 2026
  3. V3RON commented on Nov 19, 2026

    @V3RON
    ContributorAuthor

    Reproduction

    This is a decision: the code does what ADR 0009 §4 says. The test's expectation (wait) is a proposal.

    src/gateway/routing/serviceability.test.ts:204 on bug/1629-repro: "makes a request wait, not fail UNKNOWN_MODEL, NO_DRIVER or RUNTIME_MISSING, while a connected worker's catalog is not read yet". The unread view has the shape WorkerRegistry.connected builds. The other worker lists only iPhone 16 / iOS 26.0. All three rows fail today.

    pnpm exec vitest run --project unit src/gateway/routing/serviceability.test.ts -t "catalog is not read yet"
    AssertionError: expected { code: 'UNKNOWN_MODEL', …(4) } to deeply equal { kind: 'route-or-wait' }
    

    Root cause

    src/gateway/routing/serviceability.ts:207 counts as known only workers that hold a catalog (isKnown :266; listsModel and hasPlatform read worker.catalog). So rows 2–4 (:209, :222, :223) ignore an unread worker, and row 5 (:263) rejects NO_CAPACITY. Every rejection ends the request (fleet-dispatch.ts:205). ADR 0009 §4 says this: a first-time worker "neither takes requests nor is known". It only considers that worker alone. After a gateway restart, every worker is in this state until worker-link.ts:298 finishes.

    Simplest fix

    A connected, undrained view with no catalog acts like an updating worker: rows 2–5 do not reject while one exists, so the request waits. Row 1 is unchanged. This needs an amendment to ADR 0009 §4, and the test at :195 changes with it.

    // assessLeading, after row 1
    if (views.some(isUnread)) return undefined;
    // assessServing
    return fits || views.some(isUnread) ? undefined : noWorker();
    function isUnread(w: WorkerView) { return w.connection === "connected" && !w.drained && w.catalog === undefined; }
    pnpm exec vitest run --project unit src/gateway   # fix applied
    Tests  1 failed | 852 passed — the failure is the pinned test at :195
    

    Alternatives rejected

    • Wait only in row 3: NO_DRIVER and RUNTIME_MISSING keep the same window.
    • Hold the uplink until the first refresh: this moves the window instead of closing it.
    • Persist the last catalogs across a restart: this adds new persisted state, and a first-ever worker is still not covered.

    Risk

    Fast track

    • Defect: no — ADR 0009 §4 decides this answer
    • Fix tried: no — it breaks the pinned test at :195
    • Nothing public added or broken: yes
    • No ADR or rule changed: no — ADR 0009 §4 needs amending
    • One fix: no — the alternatives change what a user sees

    Written by an agent.

  4. removed their assignment
    on Nov 19, 2026
  5. added
    bug:ready
    and removed
    bug:new
    on Nov 20, 2026
  6. self-assigned this
    on Nov 20, 2026
  7. V3RON commented on Nov 20, 2026

    @V3RON
    ContributorAuthor

    Delivery run

    Merged: #1788 (#1629)
    Parked: none
    Waiting: none
    Decided: none

    Written by an agent.

  8. added a commit that references this issue on Nov 22, 2026
    e808cc3
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