Repository navigation
Description
Part of #1326.
Scope
Through a gateway, a slim lease with except reaches only a worker that can serve it: one whose slim set holds every excepted name and, when the request names no mode, whose default mode is slim. When no known worker can, the gateway refuses it BAD_REQUEST at once. A worker advertises its slim set and its default mode in catalog.get (slimCategories and defaultMode on the iOS entry), so a restarting worker, whose last catalog the gateway keeps, is still known.
In short
A worker's iOS catalog entry gains slimCategories (for example ["widgets", ..., "other"]) and defaultMode (slim or full). The gateway uses them to pick a worker for an except request; a request naming a baseline is judged by the baseline's mode, as every stage already narrows it (withBaseline). It never sends such a request to a worker that would refuse it. A worker the new stage drops shows the reason cannot-keep-except ("Cannot keep these slim categories") in the waiting list.
flowchart LR
A[fleet lease.request except] --> B["assess: any worker can? *changed*"]
B -- none --> X[BAD_REQUEST]
B -- yes --> C["routing: drop workers that cannot *new stage*"] --> D[warm-hit, free slot, ...] --> E["forward with except *changed*"]
| Fleet | Request | Today | After |
|---|---|---|---|
A slims [store], B slims every category |
--mode slim --except mdm |
(no except) |
routed to B |
| A default full, B default slim | --except store (no mode) |
(no except) |
routed to B |
| A default full, B default full | --except store (no mode) |
(no except) |
BAD_REQUEST no worker can keep slim categories store (default mode is full on every worker) |
A, B slim [store] |
--mode slim --except other |
(no except) |
BAD_REQUEST no worker slims every category in except: other |
| A, B slim every category | --mode slim --except store |
(no except) |
routed as today; worker receives except: [store] |
A holds slim baseline b, default full |
--baseline b --except store |
(no except) |
routed to A (the baseline's mode is slim) |
A holds full baseline b |
--baseline b --except store |
(no except) |
BAD_REQUEST no worker can keep slim categories store (baseline "b" is full) |
If this goes wrong, a request one worker could serve is refused, or a worker gets a request without except and grants a plain slim device.
Technical spec
Facts
Commit cc39ec8.
| # | Fact | Source |
|---|---|---|
| F1 | platformCatalogSchema has no slim field; modelWorkers is its last additive field |
src/contract/schemas.ts:749-779 |
| F2 | fitPlatformCatalog bounds only some fields; others pass through |
src/contract/schemas.ts:787-815 |
| F3 | The worker fits its catalog on the way out | src/daemon/dispatcher.ts:364-366 |
| F4 | DriverCatalogEntry has no slim field; iOS listCatalog builds it |
src/core/driver.ts:162-171; src/drivers/ios/index.ts:1451-1472 |
| F5 | The iOS driver holds its slim config | src/drivers/ios/index.ts:344 |
| F6 | A starting view keeps the last catalog |
src/gateway/worker-registry.ts:148-156 |
| F7 | RoutableRequest has mode? and requires?, no except |
src/gateway/routing/pipeline.ts:5-15 |
| F8 | routable() copies mode and requires into the routing request |
src/gateway/fleet-coordinator.ts:1632-1644 |
| F9 | assess's rejection codes: eight, no BAD_REQUEST |
src/gateway/routing/serviceability.ts:22-30 |
| F10 | requires narrows the capable views, then the table runs again: the model for this filter |
src/gateway/routing/serviceability.ts:111-116; stage src/gateway/routing/stages/has-capabilities.ts:3-7 |
| F11 | The stage list | src/gateway/routing.ts:71-83 |
| F12 | An assess reject ends the request with no worker tried | src/gateway/fleet-coordinator.ts:889-892 |
| F13 | A worker code outside CANNOT_SERVE_CODES ends the request worker-failed |
src/gateway/fleet-coordinator.ts:118-148, :1191-1210 |
| F14 | The gateway passes requestedDevice(input) whole, and the dispatch to the worker spreads requestedDevice({...}): once #1330 adds except there, it is forwarded with no gateway edit |
src/gateway/dispatcher.ts:724-727; src/gateway/fleet-coordinator.ts:1104-1107 |
| F15 | No view field holds a worker's default mode: workerViewFields keeps only downloads and lease from config.get; servesDefaultMode is a per-device flag |
src/contract/worker-view.ts:120-125; src/contract/schemas.ts:1258-1296; src/gateway/routing/stages/warm-hit.ts:16-21 |
| F16 | Two-worker test model | src/gateway/fleet-coordinator.test.ts:3186-3222 ("requires"); src/gateway/routing/serviceability.test.ts:19-38, :408-419 |
| F17 | A starting worker's view keeps its last catalog, nothing from config.get |
src/gateway/worker-registry.ts:148-160 |
| F18 | The worker's default modes are wired from config.ios.defaultMode; the worker dispatcher builds catalog.get from listCatalog |
src/daemon/main.ts:1626-1630; src/daemon/dispatcher.ts:364-366 |
| F19 | withBaseline narrows a request to the baseline's mode before stages run |
src/gateway/routing/request-match.ts:55-66 |
| F20 | Waiting reasons are a closed enum, and the gateway parses handler results through it; the CLI and the console label each | src/contract/schemas.ts:413-431; src/cli/commands/list.ts:62-80; ui/src/model/waiting.ts:87; website/src/content/docs/docs/gateway/fleet-console.mdx:79 |
| F21 | The gateway's client parses catalog.get with safeParse; fitPlatformCatalog runs only on the worker |
src/simlock-client/client.ts:1003; src/daemon/dispatcher.ts:365 |
Modules touched
Searches: platformCatalogSchema, listCatalog, RoutableRequest, routable(, RejectionCode, has-capabilities, CANNOT_SERVE.
flowchart LR
ios["drivers/ios listCatalog *changed*"] --> core["core DriverCatalogEntry *changed*"]
core --> contract["contract platformCatalogSchema, fit *changed*"]
contract --> gw["gateway dispatcher forward *changed*"]
gw --> fc["fleet-coordinator routable *changed*"]
fc --> routing["routing: assess row, new stage *changed*"]
sequenceDiagram
participant C as Client
participant G as Gateway
participant W as Worker B
C->>G: lease.request except [store], no mode
G->>G: assess over views (slimCategories, default mode)
alt no worker can
G-->>C: BAD_REQUEST
else B can
G->>W: lease.request except [store], noWait
W-->>G: granted, device.except [store]
G-->>C: granted
end
src/core/driver.ts(DriverCatalogEntry.slimCategories?),src/drivers/ios/index.ts(listCatalog),src/core/driver-catalog.tsif it copies entriessrc/daemon/dispatcher.ts(catalog.getadds each platform'sdefaultModefrom the wiring of F18),src/daemon/main.ts(passes it)src/contract/schemas.ts(slimCategorieson the platform entry, bounded infitPlatformCatalog),protocol.ts(+1)src/gateway/fleet-coordinator.ts(routablecopiesexcept),routing/pipeline.ts(except, reasoncannot-keep-except),routing/serviceability.ts(assess row),routing/stages/keeps-except.ts(new filter, afterhas-baseline),routing.ts(stage list),routing/AGENTS.md,aggregate.ts(fleet catalog: union ofslimCategories;defaultModedropped from the union)src/contract/schemas.ts(gatewayWaitingReasonSchemagainscannot-keep-except),src/cli/commands/list.ts(GATEWAY_REASON_TEXT),ui/src/model/waiting.ts(label),website/src/content/docs/docs/gateway/fleet-console.mdx(the reasons list);docs/internal/adr/0009is narrowed by 0066 (no edit)
Contract and event changes
This PR bumps the protocol by one.
catalog.getplatform entry: optionalslimCategories(iOS only, 0 to 32 items, each^[a-z][a-z0-9-]{0,31}$) and optionaldefaultMode(slim|full). Bounded in the schema; a worker answer that breaks it fails that catalog read, as any other field does (F21).- Gateway waiting reason
cannot-keep-except(closed enum, F20). - No new event.
lease.requestedon the gateway carriesexceptfrom T3'srequestedDevice; itsEVENTS.mdentry is T3's.
Other code on the same state
Searched the routing views' readers (routingViews, aggregate, stages) and config.get readers in the gateway:
- The new stage reads
defaultModefrom the view's catalog (F15, F17), so a restarting worker keeps it. - The refusal memo (
viewLoadKey) holds no catalog: the new stage reads the view each walk, so a worker whose slim set changes is seen at the next catalog read. - T3 writes
exceptintorequestedDevice; this task forwards it.
Failure modes
| Call | Outcome | What happens | Limit, counted from |
|---|---|---|---|
| assess, except | no known worker slims every name | BAD_REQUEST no worker slims every category in except: <names> |
none |
| assess, except, no mode | every worker that slims them defaults to full | BAD_REQUEST no worker can keep slim categories <names> (default mode is full on every worker) |
none |
worker without slimCategories or defaultMode (older, or never read) |
dropped for an except request, reason cannot-keep-except |
as a worker that cannot serve it | none |
| starting worker with a kept catalog | judged by that catalog | may be picked once it takes requests | none |
| assess, except, baseline full | refused | BAD_REQUEST no worker can keep slim categories <names> (baseline "<name>" is full) |
none |
| forwarded request | worker answers BAD_REQUEST |
worker-failed, as today (F13) |
gateway.leaseRequestTimeoutMs |
Rules in play
- ADR 0066 §5: route by slim set and default mode;
assessanswersBAD_REQUEST. - ADR 0009 §4 (narrowed by 0066): the fast-fail table's new row.
- routing manual, "
can-serveand the fleet table (assess) ask the same helpers in the same order": the stage and the assess row share one helper. - contract manual, protocol bump per shape change.
Tests
Seam: the gateway's FleetLeaseCoordinator with two scripted workers, modelled on fleet-coordinator.test.ts "FleetLeaseCoordinator: requires" (3186-3222), plus serviceability.test.ts for the assess row.
- A gateway routes
exceptby each worker's slim set and default mode: cases one worker has the set (routed there); mixed default modes, nomode(routed to the slim-default one); slim baseline on a default-full worker (routed); full baseline (BAD_REQUEST); none can (BAD_REQUEST, each message); a dropped worker's reasoncannot-keep-exceptinstatus.getwaiting; the chosen worker receivesexcept. - A client reads
catalog.getand sees the iOS slim set and default mode: cases worker withios.slim.categoriesunset (every category) and set ([store]);defaultModeslim and full; the gateway's fleet catalog holds the union of its workers'slimCategories. Seam: the worker dispatcher'scatalog.get(src/daemon/dispatcher.test.ts) andaggregateCatalog(src/gateway/aggregate.test.ts).
Done when
pnpm exec vitest run --project unit src/gateway/ src/contract/ src/drivers/ios/passes.- The protocol is one above the base branch's.
- The fleet console page lists the
cannot-keep-exceptreason.
Out of scope
- The worker's own refusals and grant (T3).
- A gateway setting of its own for except.
Depends on
- A slim lease keeps named categories running (--except) #1330 (the
exceptfield andrequestedDevice) - Warm pool: a baseline kind is learned on its Nth lease in 24 h and warms its newest version #1261 (bumps the protocol)
Written by an agent.
Activity
test: an except request without a mode goes to the worker whose defau…
feat(gateway): an except request without a mode needs a worker whose …
test: a gateway refuses an except request no worker can keep with BAD…
feat(gateway): assess refuses an except request no worker can keep, B…
test: an except request naming a baseline is judged by the baseline's…
test: a worker the except stage drops shows cannot-keep-except in the…
test: catalog.get shows the iOS slim categories and the default mode (#…
feat(daemon): catalog.get carries the iOS slim categories and the def…
test: the gateway's fleet catalog holds the union of its workers' sli…
feat(gateway): the fleet catalog holds the union of its workers' slim…
5 remaining items
V3RON commentedon Nov 6, 2026
Handoff
Done: PR #1360 (draft, stacked on #1349). Built and audited. Round 1 raised 5 blocking findings and the fix run fixed them. R2, R3 and R4 were confirmed fixed by the fix-check.
Not done: R1 is only partly fixed. The fix-check found two new blocking findings, and they are still open at the round cap:
src/gateway/routing/serviceability.ts:116: the exceptBAD_REQUESTrow runs after the table'sNO_CAPACITYrow. ADR 0066 §5 puts it before. Today a request that can never be served getsNO_CAPACITY.src/gateway/routing/AGENTS.md:25has the same order.src/gateway/fleet-routing.test.ts:1299: the drained-keeper case usesnoWait, so it stays green when the code is broken.Findings: see the
## Review ledgercomment on #1360.Blocked on: a maintainer decides the next step. The usual one is a fix run for R5 and R6 followed by a fix-check. #1332 waits on this task.
Written by an agent.
fix(routing): the except row sits before the capacity row (ADR 0066 §…
docs(routing): the assessExcept comment names the capacity row it rer…
chore: merge task/1330 into task/1331 (#1331)
docs: drop manual lines that restate code (#1331)
V3RON commentedon Nov 6, 2026
Handoff
Done: PR #1360 has passed review after the fix-checks the maintainer approved, and it is ready in stack #1334. The gate for the whole feature (
merge-pr.sh 1368) has run twice. The first run failed Fallow on #1348 (#readBack), which was fixed in 1fffd56 and checked.Not done: the second gate run failed Fallow on #1360:
Function 'routable' has a CRAP score of 31.6 (threshold: 30)(CI run 42204614752). A Fallow gate brought in throughmainnow fails functions over the threshold. Nothing has merged.Findings: see the
## Review ledgercomment on #1360. The failure is deterministic.Blocked on: the gate's second red CI, which parks the run. Next is one fix run that splits
routableinsrc/gateway/routing/with no behaviour change, a coordinator fix-check,stack-sync.sh 1368, thenmerge-pr.sh 1368.Written by an agent.
refactor(gateway): build the routable request from a present() helper…
feat(gateway): route an except lease by each worker's slim set and de…