Skip to content

Build the runtime's Node tests on the thread and workflow records the server serves - #1291

Merged
max-sixty merged 2 commits into
mainfrom
served-records
Sep 27, 2026
Merged

max-sixty merged 2 commits into
mainfrom
served-records

Conversation

@max-sixty

@max-sixty max-sixty commented Sep 27, 2026 •

Copy link
Copy Markdown
Owner

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 served records through
model_folds.reading and commits them as tests/served_records.json, and
tests/served.mjs hands them out:

  • servedThread(msgs, changes) and servedWorkflow(changes) start from one
    record 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 rests
    on 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_folds fails when the fold 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 workflow's
    answer matches its input, a failed response's is null, and a widget
    workflow's coordinate is the list the server sends, not a JSON string.

🤖 Generated with Claude Code

… 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 leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>
@max-sixty
max-sixty merged commit 97297d6 into main Sep 27, 2026
5 checks passed
@max-sixty
max-sixty deleted the served-records branch September 27, 2026 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants