Skip to content

desk-hub: a machine POST's answer names the frames it refused (MAWS #88) - #91

Merged
SSFSKIM merged 2 commits into
masterfrom
desk-hub-refused-frames
Oct 21, 2026
Merged

SSFSKIM merged 2 commits into
masterfrom
desk-hub-refused-frames

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Oct 21, 2026

Copy link
Copy Markdown
Owner

Closes #88

What changes

A machine POST (POST /machine/frames) now says, in its own answer, which of its frames the hub refused whole:

200 {"ok": true, "frames": <frames applied>, "refused": [{"index": <n>, "reason": <reason>}]}
  • Which frames. Every frame refused whole: one for a project the stream has not opened (not-open: a session-plane frame, an upload, a rejected report, an rpc-result, a pending), and one the hub cannot read (bad-shape, a frame naming no .smns project id among them). An upload some of whose events were refused (writer-not-yours, conflict, one event's bad-shape) is not refused whole. Those refusals still go down the stream only.
  • index. The frame's place among the POST's frames, from 0, in the numbering frames already counts: each non-blank line is one frame, and each part is one. A set joined in this POST is named by its last part.
  • reason. The same reason the stream refusal carries.
  • Always present. refused is [] when nothing was refused, so a machine can tell "none refused" from a hub older than desk hub: a machine POST's answer names the frames it refused (not-open project) #88, whose answer has no refused at all.
  • 409 and 503. The 409 stale-generation and 503 delivery-failed answers that count frames carry refused for those counted frames too.
  • Several projects in one POST. Each project's run returns its refusals, indexed within the run, together with its applied count. The Machine object maps them to POST indices and lists them in POST order. Only frames counted as applied are named: a frame whose owed reply was not written is still uncounted and unnamed.

Compatibility

  • The status stays 200, and frames keeps its meaning (refused frames still count as applied). A daemon that ignores the new field behaves exactly as today.
  • Every refusal still goes down the stream as before, the session-plane ones on the control lane, so machines running older sminos still get them.
  • No Durable Object storage change: no new table, column or key, and no migration.

The doperpowers follow-up can now drop the held settlements and the 2 s probe, and act on the answer instead.

Contract and tests

  • DX2's answer paragraph in docs/doperpowers/specs/2026-10-15-desk-design.md states the shape.
  • The RefusedFrame and PostAnswer types are in apps/desk-hub/src/protocol/machine.ts.
  • New cases in apps/desk-hub/test/session-plane.test.ts:
    • a settlement for a project the stream has not opened is named {index: 0, reason: "not-open"}, and an applied POST answers refused: [];
    • a mixed POST applies the open project's frames and names only the others. It spans interleaved runs of three projects, the empty-events probe, a part set named by its last part, and a frame naming no project id;
    • the control-lane refused still reaches the stream.

Sminos-Session: smns-erb-71#b4948247 (doperpowers on macbook)

A frame the hub refused whole -- a session-plane frame or an upload for a
project the stream has not opened (`not-open`), or one it cannot read
(`bad-shape`, a frame naming no project id among them) -- was counted as
applied and the POST answered 200 with nothing to say so; the machine
learned of it only from the stream's `refused`, later, if at all. The
answer now names them: `200 {ok, frames, refused: [{index, reason}]}`,
`index` the frame's place among the POST's frames in the numbering
`frames` counts (a part set joined in the POST named by its last part),
`refused` always present (`[]` when none), and carried by the 409 and 503
answers that count `frames` too. Each project returns the refusals of its
run with its applied count; the Machine maps them to POST indices.

Compatible: the status and `frames` are unchanged, and every refusal still
goes down the stream as before (a session-plane frame's on the control
lane), so a daemon that ignores the field behaves as today. No storage
change. DX2's answer paragraph in the desk design states the shape.

Sminos-Session: smns-erb-71#b4948247 (doperpowers on macbook)
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T02:37:51.964890Z 6136527 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6136527722

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if ('run' in item) {
const result = await results.get(item.run)!;
applied += item.run.weights.slice(0, result.applied).reduce((sum, weight) => sum + weight, 0);
for (const { index, reason } of result.refused) refused.push({ index: item.run.indices[index], reason });

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Handle project results that omit the refusal list

In the stalled-stream scenario in test/machine-end.test.ts, the project stub still returns { applied, stale, failed }, so result.refused is undefined. Iterating it throws before the result.failed branch can produce the expected 503 delivery-failed, causing that test—and any mixed-version or alternate fromMachine implementation using the previous contract—to reject the request instead. Default this field to an empty list or update every implementation atomically.

Useful? React with 👍 / 👎.

Comment on lines 380 to +381
await this.send({ t: 'refused', project: String(project), refusal: { reason: 'bad-shape', message: 'the frame names no .smns project id' } }, stream.generation);
refused.push({ index, reason: 'bad-shape' });

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Refuse non-heartbeat frames that omit the project

When a non-session project frame omits project (for example {t: "pending", raised: []}), projectOf returns null, so this code takes the heartbeat-only branch and never reaches the newly added refused.push. The POST therefore returns refused: [] and no stream refusal even though the documented contract says a frame naming no .smns project is refused as bad-shape; reserve null handling for hb-ack and classify every other such frame as refused.

Useful? React with 👍 / 👎.

…e's contract now has it

The suite's hand-written Project (cast `as never`, so the typecheck did not
reach it) answered fromMachine without `refused`, and the Machine's answer
loop read it.

Sminos-Session: smns-erb-71#b4948247 (doperpowers on macbook)
@SSFSKIM
SSFSKIM merged commit 7053a99 into master Oct 21, 2026
SSFSKIM added a commit that referenced this pull request Oct 21, 2026
…#91's test, MAWS #88)

The mixed-run case waited only for the pending list, then asserted the
browser's presence frames at once; under load the frame may not have
arrived. Wait for it the same way. The other cases #91 added assert on a
POST's answer or wait on the exact frame (m.next), so they are unchanged.

Sminos-Session: smns-erb-71#b4948247 (doperpowers on macbook)
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.

desk hub: a machine POST's answer names the frames it refused (not-open project)

1 participant