Repository navigation
Build the runtime's Node tests on the thread and workflow records the server serves - #1291
Conversation
… server serves
The runtime's Node tests and the publisher's tests each hand-built the
`/api/state` threads and workflows they fed the runtime, and every copy was
partial: `thread-reading`'s thread lacked `title`, `detached_from` and
`user_prompt`, `semantic-news`'s root was `{id}` rather than the opening
message, and `thread-workflow`'s workflow carried 9 of the 21 fields the
server sends. `readThreadRecords` defended against those absences with
`?? null` and `?? []` on seven fields the server always sends.
`tests/served_records.py` now folds one thread and one workflow through
`model_folds.reading` and commits them as `tests/served_records.json`, and
`tests/served.mjs` hands them out as `servedThread(msgs, changes)` and
`servedWorkflow(changes)`. A test changes only the fields its case is about,
and naming a field the server does not send throws.
`test_model_folds` fails when the served shape drifts from the committed file
(`uv run tests/served_records.py` rewrites it). `thread-reading`,
`thread-workflow`, `semantic-news`, `margin-workflow`, and
`scripts/browser/application.test.mjs` build on them.
Behaviour that moved:
- **The runtime reads a served thread's fields directly.**
`readThreadRecords` drops its fallbacks for `title`, `anchor`,
`detached_from`, `resolved`, `user_prompt`, `attention` and `summaries`, and
the panel's search and card drop theirs for `summaries`; news drops its
fallback for a workflow's `seq`. A thread this tab opens (`foldThreads`)
now carries the served thread's complete field set, which a new runtime test
holds against the served record.
- **The publisher's tests state what the server serves.** A resolved thread's
attention is null, as `_apply_thread_attention` makes it, where the test
had kept an Ask on it. A thread holding a user Ask or an agent question
carries the attention and `user_prompt` the server gives it. A widget
workflow's `coordinate` is the list the server sends, not a JSON string.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
left a comment
There was a problem hiding this comment.
The served-record helper only checks top-level field names, so it still builds workflows the server cannot send. In tests/runtime/thread-workflow.test.mjs, the frozen-widget case changes the baseline workflow to subject: {kind: "widget", id: "frozen-choice"} and input: "action-1", but keeps a thread coordinate and an answer addressed to e4. The server derives the subject, coordinate, and answer from the same admitted action. A test using this fixture can therefore pass with an impossible workflow, while the new tests/AGENTS.md rule says these tests cannot construct one. Please make the fixture preserve those relationships (for example, use a server-folded widget workflow for that case) before relying on it as the runtime's served-record contract.
…lates a workflow's fields Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The runtime's Node tests and the publisher's tests each hand-built the
/api/statethreads and workflows they fed the runtime, and every copy waspartial:
thread-reading's thread lackedtitle,detached_fromanduser_prompt,semantic-news's root was{id}rather than the openingmessage, and
thread-workflow's workflow carried 9 of the 21 fields theserver sends.
readThreadRecordsdefended against those absences with?? nulland?? []on seven fields the server always sends.tests/served_records.pynow folds served records throughmodel_folds.readingand commits them astests/served_records.json, andtests/served.mjshands them out:servedThread(msgs, changes)andservedWorkflow(changes)start from onerecord of each, carrying every field the server sends; a test changes only
the fields its case is about, and naming a field the server does not send
throws.
servedReading(name)returns a whole folded reading for a case that restson how the server relates a record's fields, such as a card moved on a board
frozen into a reply, whose subject, coordinate, and answer all come from one
admitted action.
test_model_foldsfails when the fold drifts from the committed file(
uv run tests/served_records.pyrewrites it).thread-reading,thread-workflow,semantic-news,margin-workflow, andscripts/browser/application.test.mjsbuild on them.Behaviour that moved:
readThreadRecordsdrops its fallbacks fortitle,anchor,detached_from,resolved,user_prompt,attentionandsummaries, andthe panel's search and card drop theirs for
summaries; news drops itsfallback for a workflow's
seq. A thread this tab opens (foldThreads)now carries the served thread's complete field set, which a new runtime test
holds against the served record.
attention is null, as
_apply_thread_attentionmakes it, where the testhad kept an Ask on it. A thread holding a user Ask or an agent question
carries the attention and
user_promptthe server gives it. A workflow'sanswermatches its input, a failed response's is null, and a widgetworkflow's
coordinateis the list the server sends, not a JSON string.🤖 Generated with Claude Code