Repository navigation
Closed
Labels
task:readySpec checked. An agent may implement it once its Depends on allow.
Description
Part of #326.
Scope
After this PR a class or range request through a gateway is served by any worker that has something fitting, warm devices first, and fails at once with the code a single worker would give when nothing in the fleet can serve it. The gateway forwards the class and the range untouched; the worker applies its own rules. The two BAD_REQUEST stubs of the previous tasks are gone.
Technical spec
File and line references are to main at 82fd554. ADR 0015 §8 and §9 are the rule, on top of ADR 0009 §3 to §6.
Modules touched
src/gateway/routing/pipeline.ts(RoutableRequest, :10-16):model?,class?;osVersionstays the string as typed.src/gateway/routing/request-match.ts(:18-66):findModelis replaced byfindCatalogModelfromsrc/core/catalog-match.ts.matchRequestanswers, for an exact model, the worker's own name as today; for a class (the classrequestedClassgives,phonefor neither), whether any model of that class inmodelClassespairs with a runtime thatsatisfiesthe request's constraint (src/contract/os-range.ts); an exact version keeps theincludestest.listsModelbecomes "lists the model, or any model of the class".src/gateway/routing/serviceability.ts(:40-76): rows 3 and 4 keep their codes;UNKNOWN_MODELdetails carryclassfor a class request,RUNTIME_MISSINGdetails carry the range as typed.src/gateway/routing/stages/warm-hit.ts(:11-27): areadydevice is a hit when the core'sfitsholds with the worker's catalog asclassOf, and the mode rule of Warm hits respect the request's mode and the runtime the worker would pick #194 holds. For an exact model with no version, Warm hits respect the request's mode and the runtime the worker would pick #194's default-runtime rule stands; for a class with no version, any version fits.src/gateway/fleet-coordinator.ts:routable()(:1229-1236) copiesclass;#attempt(:881-900) forwardsclassand theosVersionstring as they arrived and setsmodelonly for an exact request (forwardedModel, :1219-1227);request.dispatched(:855-864) carriesclassandmodelonly when present.src/gateway/dispatcher.ts(#leaseRequest, :427-450): the two stubs and their tests are removed.src/bus/index.ts(request.dispatched, :277-286):model?,class?.docs/EVENTS.md(:101) anddocs/internal/EVENTS.md(:144) rows, and the 0.x note.src/gateway/test-support.ts: fixtures withmodelClassesand devices of several classes.- e2e:
e2e/gateway-fleet.test.tsande2e/gateway-fast-fail.test.ts. - Docs:
docs/CLI.md(against a gateway, :627-671 on),docs/HTTP-API.md(gateway matching, :385-402),docs/internal/ARCHITECTURE.md(routing, :632-720),docs/internal/KNOWN-PITFALLS.mdif a gap remains.
Contract and event changes
- No request or response shape changes; no protocol bump.
request.dispatched:modeloptional,classadded. Update bothEVENTS.mdrows under the exception ADR 0015 §9 takes.
Rules in play
- ADR 0015 §1, §8, §9. ADR 0009 §3, §4, §5, §6.
architecture.mdrule 10: the gateway importsfitsandfindCatalogModelfrom the core andos-rangefrom the contract, and keeps only the mode rule of its own.events.mdrule 6 and the exception.testing.mdrules 1 to 3.
Tests
- A worker whose catalog lists a model of the class paired with a runtime satisfying the constraint passes
can-serve; one whose class models pair only outside the range does not; one with no model of the class does not. - A request with neither model nor class is matched as
phone. - A
readydevice of another model in the requested class is a warm hit; a device of another class is not; one whose OS is outside the range is not; one in a mode the Warm hits respect the request's mode and the runtime the worker would pick #194 rule refuses is not. - For a class request, row 3 gives
UNKNOWN_MODELwith the class in its details and row 4 givesRUNTIME_MISSINGwith the range as typed. - The forwarded request carries the class and the range as they arrived and no
model; an exact model is still forwarded under the worker's own name. request.dispatchedcarriesclassand nomodelfor a class request, andmodeland noclassfor an exact one.- A worker's
UNKNOWN_MODELfor a class request before any progress is retried on another worker. - With a warm Pixel on worker A and free capacity on worker B, an Android
phonerequest is dispatched to A. - E2E, on the fake drivers: completion condition 8 of A lease request can leave the model open or name a device class #326, both halves.
Done when
- Every test above passes and
pnpm checkis green. - The gateway e2e suites pass, and no test asserts the two stubs.
- The PR body walks every completion condition of A lease request can leave the model open or name a device class #326, this being the last task (delivery rule 9).
Out of scope
- Preferring one worker over another for anything but fit and warmth.
- A class default on the gateway itself.
Depends on
- --os accepts a version range #335
- Warm hits respect the request's mode and the runtime the worker would pick #194 (both change
src/gateway/routing/stages/warm-hit.ts,src/gateway/routing/pipeline.tsandsrc/gateway/fleet-coordinator.ts)
Approval
- Approved for delivery
Written by an agent.
Metadata
Metadata
Assignees
Labels
task:readySpec checked. An agent may implement it once its Depends on allow.
Activity
docs(adr): 0015 — a lease request is a set of constraints, and the ca…
feat(catalog): the catalog shows the default model per class (#333) (#…
feat(lease): a request names a class or nothing, and is served by a f…
github-actions commentedon Oct 5, 2026
Now
task:ready: approved, technical spec present, #335, #194 closed.V3RON commentedon Oct 5, 2026
Delivery run
Merged: #357 (#336)
Parked: none
Waiting: none
Written by an agent.