docs/device-api
Document what a paired device is answered with
Review: Claude Fable 5.2, APPROVED WITH FIXES on 21322855; fixed in ea559855.
Paul ruled on 2026-11-19 that Equipo's API is documented: docs/api/equipo-v1.openapi.json must describe what a paired device is answered with. Until now it described the earlier person API's conversation, which a device bearer never sees on the conversation, task and event routes.
What the document now says
- Every route a device bearer calls on the conversation engine (
chat.HTTP.Mount, housekeeping, usage, and the Assistant's two Oficina connect routes) has an operation: 69 engine operations, each with its request body, each success status and its body,401, the specific409bodies (CardConflict,ActionConflict), and adefaultError. Security ispersonBeareralone, exceptGET /events, which also takes a same-origin browser session. The person API's own routes for devices (pairing, devices,/me, notifications, errors) are unchanged. - Answer schemas mirror
internal/wireexactly. A new package,internal/wire/wireschema, generates them from the Go types by reflection, following encoding/json: - a field isrequiredunlessomitemptycan drop it (a struct value never is) oromitzero; - a pointer, slice or map that is written when nil may benull; - every struct isadditionalProperties: false; - each schema carriesx-go-type. The generator refuses, rather than guesses at, what it cannot describe: types with their ownMarshalJSONorMarshalText,,stringfields, embedded pointer structs, and maps without string keys. - Request bodies require nothing.
wire.Strictrejects an unknown field but takes a missing one; the handler checks the fields it needs and answers422 invalid_input. An input type that is also an answer's is named with the suffixInput(BudgetInput,PreferencesInput,QuietHoursInput,ThinkingChoiceInput). - Enums come from the wire constants where the set is closed: turn, task, step, question, connection, advice, specialist and housekeeping states, activity kinds, priorities, usage periods, and event types and resources. A field also takes
""where the server sends a zero value: -Message.roleandTurn.state, in a card answer that starts no turn; -Runner.role, in a snapshot before a primary runner reports. Fields with scattered or open sets (card kind and state, providers) stay plain strings. - The event stream:
GET /eventsdocumentsafter,Last-Event-ID,retry: 2000, the 20 second ping, the 24 hour cursor and410 cursor_expired. Its body isStreamEvent, aoneOfwith one schema for each type and resource pair the engine appends (MessageEvent,DeltaTurnEvent,ActivityTurnEventwithlabel,ActivityStepEvent, ...), plusPingEvent. - Error codes:
Error.codelists every code the engine writes.
How the shared paths are expressed
OpenAPI allows one operation per path and method. So each shared operation describes what a device gets, says in its description which requests are answered differently, and keeps the earlier answer whole under a vendor extension:
"x-earlierPersonAPI": {"servedWhen": "The id does not start with `tk`.", "operation": { ...the earlier operation... }}I chose this over two alternatives:
oneOfresponses would make a generated client decode two unrelated shapes and guess.- Dropping the earlier answer would lose a real answer: a browser still gets it, and so does a device asking with an earlier id.
Generators ignore x- fields, so Swift types come from the device's answer only. The prose says plainly that a client generated from the contract does not see the earlier operations.
The rules:
- By client (
deviceClient):GET /tasks,/needs-you,/runners,/connections,/specialists. - By id prefix:
GET /tasks/{id}andPOST /tasks/{id}/cancel(tk),GET /questions/{id}(q_),GETandDELETE /connections/{id}(cn_). - Replaced:
GETandPOST /projectsare the engine's alone. Their earlier operation and its orphanProjectPageschema are removed.
The earlier schemas that shared a name with a wire type take the prefix PersonAPI (PersonAPITask, PersonAPIMe, ...).
Tests
internal/plan3test TestPersonAPIDeviceContract fails if:
- any generated schema differs from the document;
- the document's operations don't match what the person API and the engine serve;
- an operation's bodies don't match
wireschema.Ops, or its security is wrong; - a shared path's rule disagrees with the router;
- a captured native fixture fails its operation's schema (no unknown property allowed);
- the engine writes an error code missing from
Error; x-eventTypesdiffers from theEventtypes plusping;- any schema is no operation's.
TestPersonAPIDeviceProbes reads a new instance (no runner, task or project) with a device bearer:
- 29 reads, each answer checked against its schema:
/snapshot,/messages,/tasks,/needs-you,/projects,/runners,/connections,/notebook,/thinking,/connections/preference,/specialists,/housekeeping,/housekeeping/actions,/advice, every documented/usageperiod and grouping, and each documentedlimitbound; - one past each documented
limitbound, and an unknownperiodandby, must each answer 422.
TestPersonAPIContractCoverage runs the person API's checks against the earlier operations kept under x-earlierPersonAPI: request DTO $ref, typed 200, required Idempotency-Key, operation ID.
internal/wire/wireschema tests:
TestEnumsAreTheWireConstants: each enum equals its family of wire string constants. Constants that belong to another field are listed, so a new constant fails until it is placed.TestEventDataIsWhatTheEngineAppends: reads everytxn.eventcall ininternal/equipo/chatand fails on a type and resource pair with no schema, or a schema nothing appends.TestOpsAreWhatTheHandlersWrite: reads every engine route's handler source (following helpers such assendWithandserveFile) for its request type and each status and wire type it writes, and compares them withOps. All 66 non-stream routes resolve.- Rules for the generator and validator, refusal of what the generator cannot describe, and input schemas.
What stays unchecked against a live answer: writes and populated reads, which are held by the handler source scan, the generated schemas and the fixtures, and the event data type of each pair.
Mutations, each restored afterwards, every one failing:
- First round: the document on
origin/main;Task.stagetyped integer;GET /needs-youansweringTask; an invented field intasks.json;stagemissing fromtask.json; an event state outside the enum;wire.Deltagrowing a field; the wrong/projectsrule;hold_barmissing fromError; an undocumented route; a missingx-earlierPersonAPI; the card answer documented for a browser session; anomitemptystruct treated as optional; the validator allowing unknown properties. - Review fixes:
Runner.rolewithout""; a newStageParkedconstant;thinking thinkingdropped from, orglance turnadded to,EventData;OpssayingGET /turns/{id}answersTask; the cancel handler answering 200; the earlier cancel operation losing itsIdempotency-Key; the earlier cancel operation getting another DTO; the earlierGET /tasksleft untyped; inputs requiring fields; an orphan schema;stepdropped fromx-eventTypes; the generator taking,string, its ownMarshalJSON, or an embedded pointer; thelimitmaximum documented as 250;yearadded to the usage periods.
To refresh after a wire change, run EQUIPO_DEVICE_SCHEMAS=<file> go test ./internal/wire/wireschema -run TestDump.
Prose
docs/api/equipo-v1.md gains "Talk to your Coordinator from a device", which covers request bodies and the earlier operations. The copy inventory marks it, and the three changed sections, COPY REVIEW REQUIRED.
Server behaviour worth a look (not changed here)
GETandPOST /projectsanswer only a device bearer. The engine replaces the person API's handlers, so a browser session gets401and the earlier handlers never run.- A device can still get the earlier task, question and connection shapes for any id without the engine's prefix. If notifications still carry earlier ids, a device following
task_readygetsPersonAPITask. - Zero values instead of absence: - a card answer that starts no turn returns a zero
messageandturn; - a snapshot with no primary runner returns a zerorunner(role: "", empty id). UndoActionignoresactionView's error on two conflict paths (out, _ = t.actionView(r)). If that read fails, the409body carries a zero action with an emptystate, which is not in the enum. I did not add""for a path that only an error reaches.- Many arrays can be
null, because they are nil slices withoutomitempty.
Discussions
- No discussions on this branch yet.
Tasks
- No tasks yet.
Activity
- No activity yet.