Repository navigation
Description
Part of #1326.
Scope
An agent-device client allocates with deviceExcept: ["store", "other"] and gets the same simlock lease as simlock lease --mode slim --except store,other: the front sends it as except on lease.request, drops it from what it forwards to agent-device, and a value simlock refuses is answered refused by simlock: <message>. On a worker and through a gateway.
In short
The front maps one more allocate key, as it maps deviceMode to mode (#1225). agent-device's CLI sends the key once callstack/agent-device adds --device-except; until then a raw allocate can carry it.
flowchart LR
A["allocate deviceMode, deviceExcept"] --> B["front: leaseCallFields, planOf *changed*"] --> C["lease.request mode, except"]
B --> D["forwarded allocate, no deviceExcept *changed*"]
| Allocate params | Today | After |
|---|---|---|
deviceMode: "slim", deviceExcept: ["store"] |
deviceExcept forwarded to agent-device; lease plain slim |
lease.request mode: slim, except: [store]; not forwarded |
deviceExcept: ["Store"] |
forwarded | refused by simlock: <schema message> |
deviceExcept: "store" (not a list) |
forwarded | refused by simlock: <schema message> |
deviceExcept: null |
forwarded | as absent |
no deviceExcept |
as today | as today |
If this goes wrong, the key is dropped again and the client gets a plain slim device, as deviceMode was in #1223.
Technical spec
Facts
Commit cc39ec8.
| # | Fact | Source |
|---|---|---|
| F1 | leaseCallFields reads deviceMode from the allocate params |
src/agent-device/shared/rpc.ts:102, :110 |
| F2 | stringFields casts deviceMode without validating; the contract refuses a bad value |
src/agent-device/front/allocate.ts:120-126 |
| F3 | leaseInput spreads the plan into lease.request, so a plan field reaches the wire |
src/agent-device/front/allocate.ts:188-198 |
| F4 | A non-timeout lease.request error becomes refused by simlock: <message> |
src/agent-device/front/allocate.ts:260-262 |
| F5 | forwardedBody drops deviceMode from the forwarded params |
src/agent-device/front/allocate.ts:272-297 (:282) |
| F6 | ruleLeaseKeys strips lease keys, deviceMode among them, from batch steps |
src/agent-device/front/request-rules.ts:136-146 |
| F7 | The deviceMode test: describe("the agent-device front's deviceMode"), invalid values answer refused by simlock: and are never forwarded |
src/agent-device/device-mode.test.ts:30-55 |
| F8 | The front manual documents the mapping and the strip list | src/agent-device/AGENTS.md (allocate flow, steps 3-4) |
| F9 | The pinned @agent-device/proxy 0.21.35 has no deviceExcept (nor deviceMode) in dist |
package.json:76; grep -r deviceExcept node_modules/@agent-device/proxy/dist → no match |
| F10 | Through a gateway, the gateway front runs the same rules and allocate code | agent-device manual, "Flow: through a gateway" step 1 |
Modules touched
Searches: deviceMode in src/agent-device/ (rpc.ts, allocate.ts, request-rules.ts, tests, AGENTS.md) and website/.../using-devices/agent-device.mdx.
src/agent-device/shared/rpc.ts,front/allocate.ts,front/request-rules.ts,AGENTS.mdwebsite/src/content/docs/docs/using-devices/agent-device.mdx
Contract and event changes
None: except on lease.request is T3's. deviceExcept is read from agent-device's allocate params (any JSON); null is absent; anything else goes to lease.request as is, and the contract refuses a bad value.
Other code on the same state
Searched forwardedBody, ruleLeaseKeys, planOf callers: the worker front and the gateway front share them (F10). Open PR #1254 (no issue) edits allocate.ts (the reply's granted mode): whichever merges second keeps both changes. The reply's data.lease.device could carry except once #1254 lands; that is not in this task.
Failure modes
| Call | Outcome | What happens | Limit, counted from |
|---|---|---|---|
lease.request with except |
BAD_REQUEST |
refused by simlock: <message>, allocate not forwarded |
none |
lease.request with except |
granted | allocate forwarded without deviceExcept |
allocate queue wait 330 s, as today |
Rules in play
- ADR 0066 §1, "the agent-device front maps its
deviceExceptto it, as it mapsdeviceModetomode". - ADR 0023: the simlock lease is the only clock; unchanged.
- documentation rule 9:
agent-device.mdxnamesdeviceExcept.
Tests
Seam: the agent-device front's allocate on the test rig, modelled on src/agent-device/device-mode.test.ts (30-55).
- An agent-device allocate with
deviceExceptleases withexcept: cases a valid list (the lease request carriesmodeandexcept; the forwarded allocate and batch steps carry nodeviceExcept); an invalid name and a non-list ("store") (eachrefused by simlock:, nothing forwarded, no lease);null(as absent).
Done when
pnpm exec vitest run --project unit src/agent-device/passes.agent-device.mdxand the agent-device manual namedeviceExcept→except.
Out of scope
- agent-device's
--device-exceptflag (callstack/agent-device). - Reporting
exceptin the allocate reply.
Depends on
- A slim lease keeps named categories running (--except) #1330 (the
exceptfield) - A gateway routes an except lease by each worker's slim set and default mode #1331 (a gateway forwards and routes
except; the Scope's gateway case)
Written by an agent.
Activity
docs(agent-device): cut the deviceExcept manual line to what the code…
docs(agent-device): say deviceExcept is not forwarded with the alloca…
docs(adr): 0066 to Accepted (#1332)
feat(agent-device): the front maps deviceExcept to the lease's except (…