Skip to content

test(e2e): cover advisory faults and restarts end to end - #210

Merged
gregpriday merged 3 commits into
developfrom
feature/issue-193-cover-advisory-faults-and-restarts-in
Nov 19, 2026
Merged

gregpriday merged 3 commits into
developfrom
feature/issue-193-cover-advisory-faults-and-restarts-in

Conversation

@gregpriday

Copy link
Copy Markdown
Contributor

Adds e2e/tests/advisory-faults.test.ts, covering the fault cases #160 lists end to end. Each runs through the real Worker on the moved clock, the real decisions mcp receiver (the CLI's daemon() run in process, writing notices to a file: sink that cannot wake the agent), an MCP SDK client and the PWA in Chromium. Each case ends in the outcome docs/operations.md describes, recovered by ID, and none of them is a human answer.

Resolves #193

What the two tests cover

  • Offline publish. The question attaches a screenshot, so its reservation fails before the create is ever claimed as sent. Past the deadline it settles as publish-failed / never-published with fallback_due: true, and the never-published notice is written once. The relay answers 404 for it, the phone's inbox stays empty, and decisions wait <id> --pane mcp exits 14. A text-only create is marked possibly published before its first send, so on a relay younger than seven days only the relay's refusal can settle it; that route is covered by packages/client/tests/publish-deadline.test.ts.
  • Lost receipt, retried after the deadline. The first create reaches the Worker and its reply is dropped; later attempts are held before they leave. After the deadline, the retry's request body and the Worker's reply are byte-identical to the first: the original 201 receipt, replayed, and the relay's history still holds one creation, at that receipt's event, and one expiry. The question reads accepted with nothing concluded until the socket brings the expiry, then ends expired with its advisory notice.
  • Phone offline at the deadline, then a late answer. The person answers with the phone offline. Past the deadline the phone shows "The deadline passed on this phone" while the answer waits. Back online, the Worker refuses the answer with 410 expired, the phone shows "Your answer was not applied", and the relay records no action.
  • Restart between the deadline and delivery, and a replayed expiry. The expiry is taken in while the terminal is busy (advisory_timeout.notice: pending, nothing written). The receiver stops, and a new one on the same state directory writes the notice once, byte for byte the frozen fixture, from what the first had stored (the relay sends it nothing more about the question) and with the same MCP token. socket.syncFrom then has the Worker resend the expiry, which is observed on the wire and handled without error, and nothing more is written; a third receiver started after delivery writes nothing either.
  • Recovery by ID. get_decision, decisions --json wait <id> --pane mcp (exit 13 or 14, one result record, no network calls) and decisions --json get <id> --pane mcp agree field for field.

Each test runs on its own relay and moves the clock once, past a 90-second deadline. The CLI's relay client signs on the real clock (openRuntime passes it no now), so the moved clock has to stay inside the relay's two-minute request skew. advisory-loop.test.ts keeps the 15-minute window.

Testing

  • Own: e2e/tests/advisory-faults.test.ts, 2/2 on every run.
  • Adjacent: e2e/tests/advisory-loop.test.ts, 5/5 alongside it.
  • Impact: 0 of 145 unit test files selected. The change is e2e-only, and e2e specs are outside the selector.
  • Prettier clean. The e2e typecheck runs in CI.

Not covered here

  • A replayed receipt that arrives after the expiry is already applied (the publisher's queued-only guard) is pinned by packages/client/tests/publish-safety.test.ts; this suite takes the receipt first, as a reconnecting receiver whose pump runs before its socket catches up does.
  • The phone's queued answer surviving an offline reload under the service worker is outside Cover advisory faults and restarts in the end-to-end suite #193.
  • Open (Low, from review): the replay barrier accepts any live on the same socket, so a gap-recovery sync already queued could resolve it first; an unrelated involvement warning during the replay would fail the no-error check; a pending notice rebuilt over HTTP at startup would pass the restart check (only socket frames are checked); an MCP connect or socket poll that times out keeps running until its own deadline.

…receiver

- Run the real `decisions mcp` receiver in process against the clocked Worker and the PWA
- Settle a question the offline computer never published as never-published, its plan due
- Lose a create's receipt, retry it after the deadline, and get the relay's original receipt back
- Refuse an answer the offline phone queued before the deadline and sent after it
- Restart the receiver between the expiry and its notice, replay the expiry over the socket, type it once
- Recover each outcome by ID with get_decision and `decisions wait --pane mcp`
- Check the relay's history holds one creation, at the replayed receipt's event, and one expiry
- Prove the restarted receiver delivers from its own store, keeps the MCP token, and a later restart types nothing more
- Fail the replay on any bridge error, and bound its barrier to the same socket
- Give each test its own teardown scope with bounded steps, and bound receiver readiness
…nish every teardown

- Count the question's creation and expiry only once the returning socket's catch-up has ended
- Reuse a receiver's stop in flight, so a teardown after a cut-short stop still waits for it
- Wait for late teardown before the next test starts, and fail the hook when a step hangs
@gregpriday
gregpriday merged commit 5c98a1e into develop Nov 19, 2026
2 checks passed
@gregpriday
gregpriday deleted the feature/issue-193-cover-advisory-faults-and-restarts-in branch November 19, 2026 14:55
@gregpriday gregpriday mentioned this pull request Nov 19, 2026
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.

Cover advisory faults and restarts in the end-to-end suite

1 participant