一片一片 fdb9deab6d
fix(runtime): report a failed scheduled-goal cleanup on the run stream (#8322)
* fix(runtime): report a failed scheduled-goal cleanup on the run stream

The finalizer flips a finished run to `error` when it cannot remove the
occurrence's scheduled goal, but it published no `error` event. The stream
then ended as a success while the record and `/wait` reported the failure:
the web UI raises its run-failure toast and streaming IM channels mark a
turn failed only on that event.

Set the same deferred `terminal_error_frame` the unpersisted delivery
receipt uses, so both finalizer-side terminal errors end the stream the
way the record does.

* fix(runtime): publish a staged error frame only for an error outcome

An interrupt accepted while scheduled-goal cleanup runs keeps the run slot
active. If cleanup then raises, the error is staged, but the cancellation
branch persists `interrupted`; the stale frame made a cancelled run show a
failure toast while the record and `/wait` reported interruption.

Publish `terminal_error_frame` only when the committed outcome is the
error it describes, which also covers a cancellation that wins after the
delivery receipt staged its frame.

The delta cases now set the worker's checkpoint mode, and a new test
cancels the run from inside a failing cleanup.

* fix(runtime): publish a staged error frame only for the committed error

A rollback also commits `RunStatus.error`, so the status check alone still
sent the staged cleanup message while the row and `/wait` said `Rolled
back by user`. Require the frame's message to equal the committed error.

The cancellation test now covers interrupt and rollback over both run
stores and both checkpoint modes; the rollback cases fail without the
message check.
2026-11-18 14:25:53 +08:00
..