Skip to content

Commit 2e8173d

Browse files
acn-ericlawclaude
andcommitted
refactor: the ask-person and agent-question routes become rest.yaml entries - the first adopters of REST automation
The two extensions' hand-mounted aiohttp routes (Platform.add_routes) are gone: each gains a resources/rest.yaml and turns rest.automation on, the handlers become private functions reading the engines' AsyncHttpRequest map (ask.page, ask.wait, ask.reply, ask.config; question.config, question.list, question.events, question.decide, transcript.list, transcript.show), and who is asking is resolved once by the entries' authentication functions (ask.identity, ask.reply.identity, question.identity) into the request's session map. The device stream is a streaming entry: an interceptor opens it at once with a day's idle allowance and follows the feed from a task of its own. Two host changes it needed: a keep-alive comment that cannot be written ends a stream and closes its sink (a device that left was otherwise held until the idle allowance), and EventStreamWriter.connected tells a long-lived producer that nobody listens. Platform.add_routes stays as the escape hatch for what an entry cannot express. The shared vectors are unchanged; the tests serve the REST-enabled host; ruff, basedpyright and pytest (916 passed) are clean; both applications were driven live under mercury-serve. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1 parent 099a219 commit 2e8173d

20 files changed

Lines changed: 720 additions & 229 deletions

‎CHANGELOG.md‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,29 @@
373373
(a typing stub, a missing method, as the first run of #84 did on 3.10), the newest the deprecations ahead;
374374
`fail-fast` is off so both results show. **Upgrade note:** an installation on Python 3.10 stays on 4.12.30 until
375375
it moves to a supported interpreter; `pip` refuses the next release there by the declared floor.
376+
10. **The ask-person and agent-question extensions serve their pages, endpoints and the device stream as `rest.yaml`
377+
entries - the first adopters of REST automation in the pack (RFC-0018's open question on the hand-mounted routes;
378+
Eric's direction of 2026-11-25).** Each extension gains a `resources/rest.yaml` and turns `rest.automation` on in
379+
its `application.yml`; the aiohttp handlers behind `Platform.add_routes` are gone, replaced by private functions
380+
of the process that read the engines' `AsyncHttpRequest` map (`ask.page`, `ask.wait`, `ask.reply`, `ask.config`;
381+
`question.config`, `question.list`, `question.events`, `question.decide`, `transcript.list`, `transcript.show`),
382+
and who is asking is resolved once by the entries' authentication functions (`ask.identity`,
383+
`ask.reply.identity`, `question.identity` - the configured mode, the channel app's bearer, `decided_by`) and read
384+
from the request's session map (`who`, `via`). The device stream, `GET /questions/events`, is a streaming entry:
385+
an interceptor opens it at once with a day's idle allowance (the head's `x-ttl`) and follows the feed from a task
386+
of its own, so the devices never hold the function's workers; the stream ends at the application's shutdown as
387+
before. Two host changes it needed: a keep-alive comment that cannot be written ends a stream and closes its
388+
sink (a device that left was otherwise held until the idle allowance), and `EventStreamWriter.connected` tells a
389+
long-lived producer that nobody listens - the pack's counterpart of a Java producer's `po.exists(replyTo)`.
390+
`Platform.add_routes` stays as the escape hatch for what an entry cannot express (a WebSocket). **On the wire:**
391+
an error is the engines' standard body - `{"status", "message", "type": "error"}` - where the handlers sent
392+
`{"type", "message"}` (the ticket's `expired` and the engine's `nothing-waiting` bodies are unchanged), so a
393+
client reading `type` and `message` sees no difference; the stream's frames carry the `question` event name and
394+
the row (whose `seq` is the cursor, as the React UI already reads it) and no `id:` line, which the engines' SSE
395+
dialect has not; the JSON the UI reads keeps its nulls (an advice's `state`, a silent engine's `status`), which
396+
the functions serialize themselves because the engines' renderer omits a null. **Upgrade note:** an installation
397+
that reads these endpoints with its own client sees the error body gain `status`; nothing else changes. The Node
398+
pack follows.
376399

377400
## Version 4.12.30, 11/16/2026
378401

‎README.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,11 @@ static folder: the `no-cache-pages` (default `/` and `/index.html`) are served
290290
first — its headers ride the response, and a status other than 200 (a 302 to a sign-in page)
291291
passes through.
292292

293-
Precedence: a `rest.yaml` entry, then an extension's mounted routes, then the static folder, then
294-
the engines' error shape. Refused by name at load, so the grammar shows the scope fence: a `flow`
293+
Precedence: a `rest.yaml` entry, then an extension's mounted routes (`Platform.add_routes`, the
294+
escape hatch for what an entry cannot express - a WebSocket), then the static folder, then the
295+
engines' error shape. The ask-person and agent-question extensions are written this way: their
296+
pages, endpoints and the device's Server-Sent Events stream are `rest.yaml` entries behind
297+
private functions, with an authentication function resolving who is asking. Refused by name at load, so the grammar shows the scope fence: a `flow`
295298
binding (`flow:` or `service: http.flow.adapter` — flows run in the engines), the HTTP relay (an
296299
`http(s)://` service) and the A/B dual service. `upload: true` on a `POST` entry is the pack's bounded
297300
form of the engines' streaming upload: the files of a `multipart/form-data` body arrive in the request

‎extensions/agent-question/README.md‎

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,24 @@ application is one of those routes. It is a standalone application on the packag
1111
- **Intake.** `agent.question.inbox` is a composable function reached over Event-over-HTTP like any peer function. It
1212
writes nothing - the record is the recorder's (`question.audit` in the ask-person process) - it checks the event and
1313
wakes the feed, so a connected device sees the row the moment it is recorded.
14-
- **The person's side**, under the pack's host: `GET /questions/config` tells the UI how to sign in (the auth mode,
15-
the title and, under `oauth2`, the issuer, the public client id, the scopes and the audience); `GET /questions?since=<seq>`
16-
is the **replay** a reconnecting device calls first - every row that changed since its cursor, oldest change first,
17-
with the cursor to continue from; `GET /questions?before=<seq>&limit=<n>` the **history's older page**, newest change
18-
first, with the cursor of the page before it - the infinite scroll; `GET /questions/events` the **stream** a connected
19-
device holds, each event a changed row, `Last-Event-ID` the same cursor, so a browser's reconnect misses nothing;
20-
`GET /transcripts?before=<iso>&limit=<n>&correlation_id=&graph_id=` and `GET /transcripts/{conversation}` browse the
21-
**transcript audit store** - the conversations newest first, one conversation with its turns as the model exchanged
22-
them. The person selects which card to answer, in any order; the card's button **automates the click**:
23-
`POST /questions/{id}/decide` posts `{ticket, decisions, decided_by}` to the main flow's reply endpoint - the link's
24-
own base, under this app's bearer - and answers with the row as the recorder then left it and the engine's outcome;
25-
the feed carries the change to every device.
14+
- **The person's side** is `resources/rest.yaml` - the engines' REST automation (RFC-0018), served by the pack's host
15+
in front of this process's private functions, with `rest.automation: true` in `application.yml`: `GET /questions/config`
16+
(`question.config`) tells the UI how to sign in (the auth mode, the title and, under `oauth2`, the issuer, the public
17+
client id, the scopes and the audience); `GET /questions?since=<seq>` (`question.list`) is the **replay** a
18+
reconnecting device calls first - every row that changed since its cursor, oldest change first, with the cursor to
19+
continue from; `GET /questions?before=<seq>&limit=<n>` the **history's older page**, newest change first, with the
20+
cursor of the page before it - the infinite scroll; `GET /questions/events` (`question.events`, a `stream: true`
21+
entry) the **stream** a connected device holds, each `question` event a changed row whose `seq` is the cursor,
22+
`Last-Event-ID` the same cursor, so a browser's reconnect misses nothing (the engines' Server-Sent Events dialect: an
23+
event name and the data, no `id:` line); `GET /transcripts?before=<iso>&limit=<n>&correlation_id=&graph_id=` and
24+
`GET /transcripts/{conversation}` (`transcript.list`, `transcript.show`) browse the **transcript audit store** - the
25+
conversations newest first, one conversation with its turns as the model exchanged them. The person selects which
26+
card to answer, in any order; the card's button **automates the click**: `POST /questions/{id}/decide`
27+
(`question.decide`) posts `{ticket, decisions, decided_by}` to the main flow's reply endpoint - the link's own base,
28+
under this app's bearer - and answers with the row as the recorder then left it and the engine's outcome; the feed
29+
carries the change to every device. Every entry but the sign-in configuration names `question.identity` as its
30+
authentication function: it resolves who is at the UI once, by the configured mode, and the functions read `who` and
31+
`via` from the request's session map. An error is the engines' standard body, `{"status", "message", "type": "error"}`.
2632
- **The feed** reads the record's change sequence: a poll every `question.poll` (1 s) and a wake-up from the intake or a
2733
click, whichever comes first. A wait is `open` until the engine accepts the decision (`answered`) or finds nothing
2834
waiting (`expired`); an advice has no state - whether a person has read it is the device's, kept by the UI. The

0 commit comments

Comments
 (0)