@proofoftech/flowsafe 0.26.2 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/README.md +6 -5
  3. package/dist/agent-host/router.d.ts.map +1 -1
  4. package/dist/agent-host/router.js +5 -11
  5. package/dist/agent-host/router.js.map +1 -1
  6. package/dist/agent-host/thread-host.d.ts.map +1 -1
  7. package/dist/agent-host/thread-host.js +79 -32
  8. package/dist/agent-host/thread-host.js.map +1 -1
  9. package/dist/agent-host/thread-topology.d.ts +3 -1
  10. package/dist/agent-host/thread-topology.d.ts.map +1 -1
  11. package/dist/agent-host/thread-topology.js +65 -33
  12. package/dist/agent-host/thread-topology.js.map +1 -1
  13. package/dist/agent-runner/durable-agent-runner.d.ts +6 -3
  14. package/dist/agent-runner/durable-agent-runner.d.ts.map +1 -1
  15. package/dist/agent-runner/durable-agent-runner.js +57 -14
  16. package/dist/agent-runner/durable-agent-runner.js.map +1 -1
  17. package/dist/approval-api/actor-context.d.ts +18 -3
  18. package/dist/approval-api/actor-context.d.ts.map +1 -1
  19. package/dist/approval-api/actor-context.js.map +1 -1
  20. package/dist/approval-api/principal.d.ts +12 -0
  21. package/dist/approval-api/principal.d.ts.map +1 -1
  22. package/dist/approval-api/principal.js +8 -0
  23. package/dist/approval-api/principal.js.map +1 -1
  24. package/dist/approval-api/router.d.ts.map +1 -1
  25. package/dist/approval-api/router.js +34 -16
  26. package/dist/approval-api/router.js.map +1 -1
  27. package/dist/approval-api/service.d.ts +7 -1
  28. package/dist/approval-api/service.d.ts.map +1 -1
  29. package/dist/approval-api/service.js +31 -11
  30. package/dist/approval-api/service.js.map +1 -1
  31. package/dist/approval-api/types.d.ts +22 -3
  32. package/dist/approval-api/types.d.ts.map +1 -1
  33. package/dist/audit-export/audit-proxy.d.ts.map +1 -1
  34. package/dist/audit-export/audit-proxy.js +4 -0
  35. package/dist/audit-export/audit-proxy.js.map +1 -1
  36. package/dist/do-runner/d1-storage.d.ts +6 -0
  37. package/dist/do-runner/d1-storage.d.ts.map +1 -1
  38. package/dist/do-runner/d1-storage.js +32 -10
  39. package/dist/do-runner/d1-storage.js.map +1 -1
  40. package/dist/do-runner/do-error-response.d.ts +14 -0
  41. package/dist/do-runner/do-error-response.d.ts.map +1 -1
  42. package/dist/do-runner/do-error-response.js +31 -45
  43. package/dist/do-runner/do-error-response.js.map +1 -1
  44. package/dist/do-runner/do-status-error.d.ts +34 -1
  45. package/dist/do-runner/do-status-error.d.ts.map +1 -1
  46. package/dist/do-runner/do-status-error.js +43 -0
  47. package/dist/do-runner/do-status-error.js.map +1 -1
  48. package/dist/do-runner/durable-object.d.ts.map +1 -1
  49. package/dist/do-runner/durable-object.js +44 -21
  50. package/dist/do-runner/durable-object.js.map +1 -1
  51. package/dist/do-runner/fenced-workflows-d1.d.ts.map +1 -1
  52. package/dist/do-runner/fenced-workflows-d1.js +23 -7
  53. package/dist/do-runner/fenced-workflows-d1.js.map +1 -1
  54. package/dist/do-runner/run-input-depth.d.ts +10 -3
  55. package/dist/do-runner/run-input-depth.d.ts.map +1 -1
  56. package/dist/do-runner/run-input-depth.js +12 -3
  57. package/dist/do-runner/run-input-depth.js.map +1 -1
  58. package/dist/do-runner/run-lifecycle.d.ts +5 -2
  59. package/dist/do-runner/run-lifecycle.d.ts.map +1 -1
  60. package/dist/do-runner/run-lifecycle.js +5 -2
  61. package/dist/do-runner/run-lifecycle.js.map +1 -1
  62. package/dist/do-runner/runtime.d.ts +43 -10
  63. package/dist/do-runner/runtime.d.ts.map +1 -1
  64. package/dist/do-runner/runtime.js +111 -32
  65. package/dist/do-runner/runtime.js.map +1 -1
  66. package/dist/goals/objective-routes.d.ts.map +1 -1
  67. package/dist/goals/objective-routes.js +2 -1
  68. package/dist/goals/objective-routes.js.map +1 -1
  69. package/dist/host-kit/do-response.d.ts +21 -1
  70. package/dist/host-kit/do-response.d.ts.map +1 -1
  71. package/dist/host-kit/do-response.js +56 -25
  72. package/dist/host-kit/do-response.js.map +1 -1
  73. package/dist/host-kit/flowsafe-worker.d.ts +25 -3
  74. package/dist/host-kit/flowsafe-worker.d.ts.map +1 -1
  75. package/dist/host-kit/flowsafe-worker.js +93 -102
  76. package/dist/host-kit/flowsafe-worker.js.map +1 -1
  77. package/dist/host-kit/run-route-error.d.ts +11 -0
  78. package/dist/host-kit/run-route-error.d.ts.map +1 -1
  79. package/dist/host-kit/run-route-error.js +13 -5
  80. package/dist/host-kit/run-route-error.js.map +1 -1
  81. package/dist/host-kit/run-router.d.ts.map +1 -1
  82. package/dist/host-kit/run-router.js +18 -40
  83. package/dist/host-kit/run-router.js.map +1 -1
  84. package/dist/host-kit/stream-router.d.ts.map +1 -1
  85. package/dist/host-kit/stream-router.js +11 -15
  86. package/dist/host-kit/stream-router.js.map +1 -1
  87. package/dist/internal-error-response.d.ts +7 -2
  88. package/dist/internal-error-response.d.ts.map +1 -1
  89. package/dist/internal-error-response.js +10 -3
  90. package/dist/internal-error-response.js.map +1 -1
  91. package/dist/schedules/router.d.ts.map +1 -1
  92. package/dist/schedules/router.js +9 -2
  93. package/dist/schedules/router.js.map +1 -1
  94. package/dist/schedules/schedules-d1.d.ts.map +1 -1
  95. package/dist/schedules/schedules-d1.js +4 -1
  96. package/dist/schedules/schedules-d1.js.map +1 -1
  97. package/dist/schedules/tick.d.ts +33 -7
  98. package/dist/schedules/tick.d.ts.map +1 -1
  99. package/dist/schedules/tick.js +259 -327
  100. package/dist/schedules/tick.js.map +1 -1
  101. package/dist/signal-providers/webhook-route.d.ts.map +1 -1
  102. package/dist/signal-providers/webhook-route.js +12 -6
  103. package/dist/signal-providers/webhook-route.js.map +1 -1
  104. package/dist/signals/router.d.ts.map +1 -1
  105. package/dist/signals/router.js +6 -4
  106. package/dist/signals/router.js.map +1 -1
  107. package/dist/signals/thread-do-routes.d.ts.map +1 -1
  108. package/dist/signals/thread-do-routes.js +7 -1
  109. package/dist/signals/thread-do-routes.js.map +1 -1
  110. package/package.json +2 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,84 @@
1
1
  # @proofoftech/flowsafe
2
2
 
3
+ ## 0.28.0
4
+
5
+ ### Minor Changes
6
+
7
+ - d6b836b: The runtime's run refusals carry the HTTP status the run object answers them with as `status`: `UnknownWorkflowError` and `UnknownRunError` `404`, `RunAlreadyExistsError`, `RunTerminalConflictError` and `RunSettledConflictError` `409`, and `InvalidRunRequestError` `400`. The run object and `createRunRouter()` answer them as before. They do not extend `DoStatusError`, so a route that renders a `DoStatusError` with its own status, such as a thread object's signal routes, answers them as before.
8
+
9
+ Breaking: an approval decision whose resume runs in process through `resumeViaRuntime(runtime)` reports such a refusal's message in `DecideResult.resume.error`, and in each batch decide result, instead of `internal error`, as a run object's answer already does; for example `no run '<runId>' found for workflow '<workflowId>'` for a run that no longer exists. Such a refusal is no longer logged as a `route-internal-error` line with route `approvals.resume`; the `approval.resume` audit event still records its message.
10
+
11
+ Breaking: a schedule tick whose `startAgent` seam starts a threadless agent through `RunnerRuntime` in process records a start the runtime refuses with `InvalidRunRequestError` or `UnknownWorkflowError` as `failed` with reason `dispatch-refused` once the `status` lookup states that the run does not exist, as it records the thread object's `400` and `404` answers. Before this change such a fire stayed deferred and was recorded `dispatch-unresolved` an hour after it fired, or stayed deferred while the lookup kept failing. A `status` lookup that lets the runtime's `UnknownWorkflowError` or `UnknownRunError` escape now states that a threadless start's run does not exist. A `signalAgent` seam that calls the thread host in process and lets the runtime's `InvalidRunRequestError` or `UnknownWorkflowError` escape now fails its fire as `dispatch-refused`, where the fire was retried on a later pass before this change; the same refusal through a thread object's signal route still answers `502` and is retried.
12
+
13
+ Breaking: code that reads `status` from a thrown value now finds it on these six classes.
14
+
15
+ ### Patch Changes
16
+
17
+ - a2ab4a0: `RunnerRuntime.start()` and `resume()` refuse with `InvalidRunRequestError` (`400`) carrying Mastra's message only for these failures: a start whose input data, initial state or request context fails the workflow's schema, a resume whose data fails the suspended step's resume schema, a resume that names a step that is not suspended, and a resume of a run Mastra finds no longer suspended or no longer stored. Any other error from the start or resume leg whose message merely contains one of the phrases the runtime used to match, such as `Invalid input` from a validation library failing inside the leg, now propagates as an internal error (`500`, `internal error` to callers) instead of a `400` that published its text, which could name internal schema paths. A start whose initial state or request context fails its schema now always answers `400`; before, it did so only when an issue's text contained `Invalid input`.
18
+ - 15e9f29: The schedule tick audits a deferred fire it settles as `failed` with reason `invalid-deferred-dispatch` as a `schedule.fire` event with outcome `failed` and that reason. Before this change only the trigger history recorded that outcome: a fire whose stored dispatch record does not parse, a fire left claimed without a dispatch record after its run-cap check, claim or claim bookkeeping failed, and a fire whose stored dispatch target nests past the run-input bound and whose lookup throws reached no audit sink. The event names the stored dispatch's target, or its schedule's target as the store reads it when no dispatch record parses. When that schedule cannot be read or is no longer stored (as when it is pending deletion), the tick logs `schedule-tick-bookkeeping-error` instead of auditing the fire.
19
+ - d865cec: `RunTerminalConflictError` states the condition that refused the call instead of reporting every refusal as an ended run. A resume refused because a cancellation or timeout is recorded but has not yet ended the run reads `run '<runId>' of workflow '<workflowId>' is ending with status 'cancelled'` (or `'timed_out'`); before, it read `is already terminal` with the run's stored status, such as `'suspended'`. An approval decision whose resume runs in process through `resumeViaRuntime(runtime)` and races a cancellation or timeout reports that message in `DecideResult.resume.error`. Terminal cleanup requested for a run with no recorded cancellation or timeout reads `run '<runId>' of workflow '<workflowId>' has no recorded cancellation or timeout with status '<status>'`. A refusal for a run that has ended keeps `run '<runId>' of workflow '<workflowId>' is already terminal with status '<status>'`. The status stays `409`, and the constructor takes an optional fourth argument naming the condition: `'terminal'` (the default), `'ending'`, `'leg-running'` or `'no-terminal-transition'`.
20
+ - ba706d6: The schedule tick audits a schedule whose stored target kind is neither `workflow` nor `agent` with `target: 'workflow'`, as the tick dispatches it. Before this change the `schedule.fire` events the tick emitted for such a schedule while firing it carried the stored kind in `target`, outside the `'workflow' | 'agent'` type the audit sink receives.
21
+
22
+ ## 0.27.0
23
+
24
+ ### Minor Changes
25
+
26
+ - a444885: Breaking: the approval router answers an unexpected failure with `500` and `{ "error": "internal error" }`, logging the original, instead of the failure's message, and every approval response carries `cache-control: no-store`. In a batch decide, a record the execution fence refuses reports `code` `unavailable` with the fence's `reason` (`EXECUTION_FENCED` or `EXECUTION_FENCE_UNREADABLE`), as the single-record route answers `503`, instead of `error`, and an unexpected per-record failure reports `error` with the message `internal error` instead of the failure's message. `BatchDecideItem['code']` gains `unavailable`, and the item gains an optional `reason`. `DecideResult.resume.error` carries `internal error` for a failed resume that has neither a reason code nor a 4xx status, such as a storage failure or a `DeploymentIdentityError` thrown in process, instead of the failure's message. The original is logged: for an answer read from a run or thread object, on the reader's `route-internal-error` line, and the `approval.resume` audit event records `internal error` where it recorded the failure's message; for a failure in process, on the `approvals.resume` line and in the `approval.resume` audit event. A refusal `RunnerRuntime` throws in process through `resumeViaRuntime`, such as `UnknownRunError`, carries no status, so it reports `internal error` too.
27
+ - a444885: Breaking: an approval resume of a durable-agent run that has ended, cancelled and timed-out runs included, now answers `409` with `reason.code` `RUN_NOT_SUSPENDED` for the principal that started the run, threaded or unthreaded, and `DecideResult.resume.code` reports it, as for a workflow run. Before this change it answered `404 run not found`, from the thread object or, once the run's ownership claims were released, from `createAgentThreadTopology().resume()`, which now asks the thread object's owner-checked replay read before it answers `404`. Another principal still gets `404`, and so does every principal for an ended run from an earlier version that recorded no execution owner. `RunNotSuspendedError` accepts any `RunStatus`.
28
+ - 187059b: Breaking: more caller-supplied JSON is refused with `400` when nested more than 256 levels deep: a schedule's `metadata` value on create and update, an approval's `payload` on the HTTP create route, a state signal's `value` or `delta` and a notification signal's `payload` at the thread object, a signal-provider subscription's `metadata` value, a `providerOptions` value of an agent start at the thread host, and an event the trusted audit proxy receives. The HTTP approval create route also refuses a `summary` that is not a string with `400`. A signal-provider delivery whose notification payload nests that deep is now recorded as failed, unless the payload nests too deep for the delivery to serialize, which stays deferred as before. Before this change such a value was stored, and one nested past what the Workers runtime can serialize answered `500` or `502`, in some cases after it was stored; the audit proxy answered `503`.
29
+ - ff90acb: The maintenance singleton can run notification dispatch as its own duty. Pass the closure `createNotificationDispatchTick()` returns as `createFlowsafeWorker({ notificationTick })`, with `maintenance.notificationIntervalMs`; `createFlowsafeMaintenanceDurableObject()` refuses one without the other. The duty runs in its own alarm invocation and logs a `notification-dispatch` line, or `notification-dispatch-error` when the tick throws. A host that ran notification dispatch inside its `scheduleTick` closure, as the advanced starter did, skipped delivery on every pass whose schedule work threw, and lost it when that invocation was terminated for exceeding its CPU limit. `MaintenanceDuty` gains `'notification'`, `runMaintenanceDuty('notification', env)` runs it, and `MaintenanceHealth` and the maintenance status gain `nextNotificationAt`, `lastNotificationAt`, `lastNotificationAttemptAt` and `lastNotificationError` while the duty is configured. Upgrade the fleet control plane to `@proofoftech/fleet-control` 0.6.0 before a deployment moves notifications into this duty: an earlier fleet control reads no notification fields, so a failing notification duty, which a failing schedule tick used to surface, raises no finding. `scheduleTick` and `tickIntervalMs` keep their meaning, so a host that still composes notifications into its schedule tick works unchanged; an exhaustive `switch` over `MaintenanceDuty` needs a case for the new member.
30
+ - d2a76bf: Breaking: `FencedWorkflowsStorageD1` refuses a write whose run provenance names another start than the stored row's, by its start token, with `RunSettledConflictError` (HTTP `409`), whether or not the row is settled. Run ids are single-use: never start an id again, even after retention removed its run, because `RunnerRuntime.start` refuses an id only while its run's row exists. Before this change a leg of an earlier run still running on another instance when its id was started again wrote its snapshots over the later run's row until the leg ended, and a leg of the earlier run whose state could not be stored recorded the later run as `failed`; the leg now ends at its next write, and the later run's row stays as that run wrote it. The shipped hosts mint a new id for every start; a custom `newRunId`, which also mints thread ids, that repeats values, or a host that calls `RunnerRuntime.start` or the run object's start route with a chosen id, is affected. A write or a stored row without a start token is not refused for it: a run started without an execution fence stores its first row without one, so a leg of the earlier run can still write over that row, and the later run's own writes then answer `409`. A leg run by an earlier flowsafe version still writes over the later run.
31
+ - a444885: Breaking: `RunStateUnreadableError` now extends `DoStatusError` with `status` `503` and `reason.code` `RUN_STATE_UNREADABLE`, and `AgentRunSelectorMismatchError` inherits both. The run object's `503` for a run whose state cannot be read carries the code, and `DecideResult.resume.code` reports it when a decided approval's resume cannot read the run. `createRunRouter()` now classifies an error through the run object's own mapping, so over an in-process `RunnerRuntime` such a run answers `503` with the code instead of `500` with `{ "error": "internal error" }`, and the agent and stream routers answer it with `503` instead of `500`.
32
+ - 080d34e: Breaking: a durable-agent start or approval resume that fails while its run stays stored `suspended`, for example on a transient storage failure, no longer ends the run's stream with a terminal `error` event and no longer releases the run's thread, when the run's status can be read after the failure. The run, its stream and its thread registration stay as at a suspension until the next resume or a terminate ends them. The resume and `streamUntilPersisted()` still answer with the error; the thread host's start route answers such a start with the run's suspended state, as its start recovery already did. When the status read fails too, the leg publishes its error and releases the thread as before. Before this change that event armed Mastra's 30-second cleanup of the run, which removed the registry entries and stream history of a resume of the run inside that delay, so that resume's observers missed its later events, and the run's thread was released while the run was still suspended. An observer that took that `error` event as the run's end should read the run's status instead.
33
+ - a444885: Breaking: a `5xx` that carries no reason code no longer carries the message of the fault behind it. `doSummary()` and the readers inside `createDoRunTopology()` and `createAgentThreadTopology()` keep the status of such an answer from a run or thread object, replace its message with `internal error`, and log the original as a `route-internal-error` line. The signal ingestion router does the same for a thread object's answer it forwards, the stream router for the run or hub object's answer to a WebSocket upgrade it forwards, and `createRunRouter()` for a `DeploymentIdentityError` thrown in process, which keeps its `503`. Before this change a host that reaches its runs through Durable Objects answered an unclassified run-object failure, such as a D1 error, with its message at `500` on `/api/runs`, and a deployment-identity failure, whose message names deployment tags and bindings, at `503`. The agent and stream routers now pass every `RunRouteError` through with its status, message and reason: a `503` without a reason code, such as `persisted start is not readable` or a permission resolver failure, answers `503` instead of `500`, and the stream router answers any other failure with `500` and `internal error` instead of the failure's message. The stream router now forwards a `RunRouteError`'s reason as written, where it forwarded only a reason that carries a code. A `RunRouteError` or `DoStatusError` whose status is outside `400`-`599` answers `500` from the run, agent, stream, schedule, objective, signal and signal-subscription routers and from the composed Worker's fence and inventory admin routes, which used to throw or answer with that status. A non-ok answer from a run object whose body is not JSON keeps its status in `doSummary()`, where it used to become a `500`.
34
+ - 95e563c: Add `createCloudflareWorkersForPlatformsControlPlane` to the Worker-safe control-plane entry for external artifacts with dispatch-native trusted state. It composes native D1 fleet/quota stores, R2 export receipts, lifecycle continuations, and exact-spec release rollback without exposing provider or storage capabilities.
35
+
36
+ Inventory continuations bind the configured namespace and routing KV, and deployment leases check persisted platform ownership. Use one Fleet database per immutable platform configuration. Provisioning and rollback retain their single-deployment execution model; ordinary-state adoption and platform catalogs remain on the root APIs.
37
+
38
+ Expose FlowSafe's existing maintenance capability and receipt implementation through `@proofoftech/flowsafe/host-kit/maintenance-capability`, allowing control-plane bundles to import it without the host composition graph.
39
+
40
+ Accept Cloudflare’s omitted namespace trust flag as its default untrusted mode during provisioning and inventory. Trusted and malformed trust values remain refused.
41
+
42
+ Handle Cloudflare’s `script` response field when verifying audit queue consumers, avoiding false convergence failures.
43
+
44
+ Allow Cloudflare’s empty prebuilt-pipeline metadata when attesting the shared dispatcher’s outbound binding.
45
+
46
+ Preserve referenced Wasm sidecars in WFP conformance artifacts, verify their digests before upload, and run the exact upload modules in the local verifier.
47
+
48
+ Select trusted-state Durable Object migrations from the owned live Worker, preserving initial class creation and retries after provider commits.
49
+
50
+ Match remote Durable Object bindings to owned namespace IDs when Cloudflare omits dispatch-namespace metadata, while rejecting conflicting targets. Allow external deployments with reserved application R2 buckets to converge.
51
+
52
+ Relay conformance candidate maintenance requests to trusted state and verify signed requests, receipts, and replay refusal against the built artifacts locally.
53
+
54
+ Project trusted state ownership into dispatch inventory. Remove WFP traffic using complete persisted policy and state-egress authority, retaining migration evidence through bounded teardown and using durable bridge identity during switch rollback.
55
+
56
+ Preserve published deployments when the final ready-state write fails or its response is lost, keeping retry and export-backed decommission available without destructive provisioning rollback.
57
+
58
+ Reject unusable credentialed-run export directories before provisioning paid resources.
59
+
60
+ Export `StateEgress` as a named HTTP handler so trusted-state service bindings resolve it in the Workers runtime. Direct JavaScript callers must replace `new StateEgress(context, env).fetch(request)` with `StateEgress.fetch(request, env)`. The service-binding entrypoint name and HTTP contract remain unchanged.
61
+
62
+ Persist platform targets for the shared outbound Worker and omit absent Durable Object tags from migration and switch records so lifecycle state survives reload. Validate candidates against reconciled trusted state resources during migration and rollback.
63
+
64
+ Select paid-run cleanup from the current lifecycle record and preserve the applied migration cursor during same-name trusted-state uploads. Align its CPU failure expectation with the dispatcher’s 503 response, and load trusted JavaScript entry modules as UTF-8 text for the ordinary Worker probe. Operator configurations must set `plainWorkerRouteHostname` to a separate unused hostname.
65
+
66
+ ### Patch Changes
67
+
68
+ - e9f4ada: A workflow start on a runtime without an execution fence, whose workflow's `shouldPersistSnapshot` stores none of the statuses the run passes through (for example only `suspended`, for a run that completes without suspending), now writes the run's outcome as its first stored row and answers with its summary, on storage whose workflow capability has `withStoredRun`, as `FencedWorkflowsStorageD1`'s has. Before this change such a start answered `500` ('completed without a durable snapshot') after the run had done its work, and the run then read as unknown.
69
+
70
+ On storage without `withStoredRun`, such as Mastra's in-memory store, such a start still answers `500`, because the runtime cannot tell a row the start never stored from one removed after another instance settled the run; a resume whose run row is removed while it runs, and a fenced start whose run row is removed, now answer `409` with `RunSettledConflictError` when the workflow stores nothing after the removal, where both answered `500` before.
71
+
72
+ A workflow that can suspend must store `suspended`: the runtime cannot rebuild a suspension the engine did not store, so such a run cannot be resumed.
73
+
74
+ - d2a76bf: With a short `RUN_RETENTION_DAYS` such as `0`, retention no longer removes a run's terminal snapshot before the run object or agent thread object that started the run has read its outcome: `purgeExpiredWorkflowRuns` keeps a terminal snapshot while its run's `run` claim in `resourceOwnerTable` is reserved, and removes it on a later pass. Both objects also record in their start journal that they read the outcome before they commit that claim, so when retention removes the run before the journal clears, as for an unthreaded agent run that ended after suspending, or a start whose instance stopped between the commit and the clear, the object's next wake clears the journal. Before this change such a start answered `409` or `503` and its object kept the journal and woke every minute; the run's `dispatch-status` answered `503`, so a scheduled fire of the run stayed deferred, and an agent thread stayed blocked by the run. This does not repair a start journal an earlier flowsafe version wrote, which records no read: an object already in that state when the deployment upgrades stays in it, and so does one whose run retention removes before the object's first wake on this version reads the run, including a start an earlier version served during the deploy. `purgeExpiredWorkflowRuns` also no longer fails a pass that has a snapshot to remove when the configured `resourceOwnerTable` does not exist: it treats the table as holding no claim and logs one `retention-config` line per pass. A purge by an earlier flowsafe version during a deploy, or by a direct caller that passes no `resourceOwnerTable`, can still remove such a snapshot.
75
+ - 9351f21: A deferred schedule fire that flowsafe 0.26.0 or earlier stored with a target nested more than 256 levels deep is resolved from the `status` lookup. Before this change the tick recorded every such fire as `failed` with reason `invalid-deferred-dispatch` without asking its target, even when its run had started. The tick now records the target's answer: `published` with reason `dispatch-reconciled` for a run the target holds, the receipt's outcome for a threaded signal whose receipt the target stored, or `failed` with reason `start-error-confirmed` when the lookup states that the target holds no such run. It never sends such a dispatch again, and a lookup that throws still settles the fire as `failed` with reason `invalid-deferred-dispatch`, recording the lookup's error as `statusError`. The settled trigger keeps the dispatch's identifiers without its target. A custom `ScheduleTickStatus` seam is now also called with such a dispatch, whose `workflowTarget` or `agentTarget` holds the deep value. Flowsafe 0.26.1 and 0.26.2 settle these fires on their first reconcile pass, so the change reaches deployments that upgrade from 0.26.0 or earlier, and fires an earlier version writes during a gradual deploy or rollback.
76
+
77
+ A run or thread object's read of the schedule fire it is asked to execute finds no fire when the fire's record is one SQLite's JSON functions cannot parse, and the object refuses the start or signal as it refuses a fire it cannot find. Before this change the read failed with `malformed JSON` and the request answered with an internal error.
78
+
79
+ - 9351f21: The schedule tick's per-pass result counts each fire once, in the pass that writes its trigger, except a fire whose run-cap check or claim throws after its claim is stored, which its pass counts `failed` and the pass that settles the claim counts again. Before this change a fire was counted as `fired`, `skipped` or `failed`, and a reconciled fire also as `reconciled`, before its trigger was written, so a failed write still counted it while its trigger stayed `deferred`, and the pass that later recorded it counted it again. A fire whose trigger write fails now counts as `deferred`. A fire that dispatched nothing, a lost claim and an unadvanceable cron were also counted `failed` a second time when their bookkeeping threw; for them a failed trigger write or audit is now logged as a `schedule-tick-bookkeeping-error` line instead of a `schedule-tick-error` line, without a second count.
80
+ - e9f4ada: On `@mastra/core` 1.75.0, a run leg that the liveness touch aborts because another instance settled the run, or because retention removed the run's row, answers `409` with `RunSettledConflictError`, or with the settled summary for a start whose stored row still carries that start, when the workflow's `shouldPersistSnapshot` does not store `waiting`, as the durable-agent loop's does not. Core 1.75.0 reports such an abort as `waiting` instead of `canceled`, so before this change those legs answered `503` with `RunStateUnreadableError`, an agent start or resume whose run row was removed ended its stream with that error, and the resume of a run with legacy (version 1) run provenance answered with status `waiting`.
81
+
3
82
  ## 0.26.2
4
83
 
5
84
  ### Patch Changes
package/README.md CHANGED
@@ -44,6 +44,7 @@ Compatibility:
44
44
  | `@proofoftech/flowsafe/do-runner/testing` | Timeout resume fixtures for workflow tests |
45
45
  | `@proofoftech/flowsafe/approval-ui` | Styling-library-agnostic React dashboard, DOM-free API client, headless hook, and live transport |
46
46
  | `@proofoftech/flowsafe/host-kit` | Authenticator and verifier seams, topologies, run/stream routers, approval bridges, and composed Worker |
47
+ | `@proofoftech/flowsafe/host-kit/maintenance-capability` | Maintenance capability signing, verification, and result receipts without host composition imports |
47
48
  | `@proofoftech/flowsafe/host-kit/module` | Import-safe workflow module contract |
48
49
  | `@proofoftech/flowsafe/artifacts` | R2 artifact store and in-memory test bucket |
49
50
  | `@proofoftech/flowsafe/audit-export` | Cloudflare Queue producer sink and NDJSON SIEM consumer |
@@ -378,7 +379,7 @@ Use `GET /admin/inventory` while the fence remains `draining`. A drain is proven
378
379
 
379
380
  ### Runtime ids are opaque
380
381
 
381
- The host mints opaque, path-safe run and thread ids. `RunnerRuntime.start()` requires a host-owned run id and has no generation fallback. The id scopes the snapshot, Durable Object, approval lookup, stream address, and artifact path, but it carries no customer identity.
382
+ The host mints opaque, path-safe run and thread ids. `RunnerRuntime.start()` requires a host-owned run id and has no generation fallback. A run id is single-use: never start one again, even after retention removed its run. The id scopes the snapshot, Durable Object, approval lookup, stream address, and artifact path, but it carries no customer identity.
382
383
 
383
384
  Callers that need exactly-once start behavior supply an `idempotencyKey`, never a run ID. The key is available on `POST /runs`, trusted agent-host starts, and `streamUntilPersisted()`. A retry returns the same persisted run. `IDEMPOTENT_START_PENDING` includes `pendingSince`; re-probe the point-in-time `IDEMPOTENT_START_UNRESOLVABLE` result before acting. For an agent start, keep re-probing for at least seven minutes after its last activity before choosing a fresh key: until the thread object repairs a start whose leg stopped or runs on another instance, its replay answers `IDEMPOTENT_START_UNRESOLVABLE`. A key remains valid until its reservation-retention horizon expires.
384
385
 
@@ -595,7 +596,7 @@ A non-owner's notification, and an unbranded agent's owner notification, are che
595
596
 
596
597
  Flowsafe providers route polling and webhook deliveries through the thread topology instead of Mastra's in-process registry.
597
598
 
598
- `SignalProviderHost` runs one alarm-driven host per deployment. `D1SubscriptionStoreFactory` persists subscriptions. External resource ids are opaque, but must be non-empty, contain no ASCII control characters, and fit within 1,024 UTF-8 bytes. Human-only subscription routes reconcile provider alarms after each committed mutation. Webhook routes verify raw bytes before parsing, look up the stored subscription, apply a provider rate cap, and bound forgery audit.
599
+ `SignalProviderHost` runs one alarm-driven host per deployment. `D1SubscriptionStoreFactory` persists subscriptions. External resource ids are opaque, but must be non-empty, contain no ASCII control characters, and fit within 1,024 UTF-8 bytes. A subscription `metadata` value nested more than 256 levels deep is refused with `400`. Human-only subscription routes reconcile provider alarms after each committed mutation. Webhook routes verify raw bytes before parsing, look up the stored subscription, apply a provider rate cap, and bound forgery audit.
599
600
 
600
601
  `githubSignalProvider()` is the reference provider.
601
602
 
@@ -603,17 +604,17 @@ Complete wiring is in the [durable-agents guide](https://github.com/ProofOfTechO
603
604
 
604
605
  ## Deployment and operations
605
606
 
606
- The composed `createFlowsafeWorker()` owns the shared route and maintenance-duty pipeline. Hosts inject workflows, identity verification, topology-backed optional routers, budget wrappers, notification transport, an invocation-scoped artifact-store factory, the storage table prefix, schedule tick, and extra purge duties.
607
+ The composed `createFlowsafeWorker()` owns the shared route and maintenance-duty pipeline. Hosts inject workflows, identity verification, topology-backed optional routers, budget wrappers, notification transport, an invocation-scoped artifact-store factory, the storage table prefix, schedule and notification ticks, and extra purge duties.
607
608
 
608
609
  Configure `mutationEpoch` with a nonnegative safe integer or a synchronous environment callback. The Worker captures it before deployment verification or authentication, then forwards it through trusted contexts and protected internal headers. Start paths preserve the original actor, principal, epoch and selectors across waits, including class-backed context method receivers. Do not accept the epoch from public headers or start JSON.
609
610
 
610
611
  The internal durable-agent host start requires an eighth `AgentStartAuthority` argument, with an explicit `onPreparedStartIdentity` property. This transport does not activate final-write epoch checks or managed recovery; the [deployment reference](https://github.com/ProofOfTechOrg/anchorage/blob/main/docs/deployment-reference.md#configure-the-trusted-caller-epoch) and [durable-agents guide](https://github.com/ProofOfTechOrg/anchorage/blob/main/docs/durable-agents.md) describe the boundary.
611
612
 
612
- Protect `GET` and `POST /admin/execution-fence` plus `GET /admin/inventory` with a distinct `MAINTENANCE_ADMIN_SECRET`. Fence transitions use CAS and return `409` with `FENCE_CAS_CONFLICT` when the expected state is stale. Fenced execution returns `503` with an `EXECUTION_FENCED` reason. The agent-host and stream routers preserve structured `503` and `409` refusals instead of collapsing them to a generic `500`.
613
+ Protect `GET` and `POST /admin/execution-fence` plus `GET /admin/inventory` with a distinct `MAINTENANCE_ADMIN_SECRET`. Fence transitions use CAS and return `409` with `FENCE_CAS_CONFLICT` when the expected state is stale. Fenced execution returns `503` with an `EXECUTION_FENCED` reason. The agent-host and stream routers answer every refusal with its own status, message and reason. The readers of a run or thread object's answer replace the message of a `5xx` that carries no reason code with `internal error` and log the original; a `RunRouteError` a host authors is forwarded as written.
613
614
 
614
615
  Every leaf option that accepts `ExecutionFenceWiring` requires an explicit store or `'none'`. Run-router, agent-thread-topology, and storage initialization also require explicit start-idempotency wiring. Use `'none'` only when no database exists. `BackgroundTaskHost` no longer exposes its manager; call `enqueue()`, `getTask()`, `listTasks()`, or `stream()` on the host and use `BackgroundTaskReads` for read-only route composition.
615
616
 
616
- `createFlowsafeMaintenanceDurableObject()` runs deadline expiry, approval service-level agreement (SLA) sweep, retention purge, and optional schedule fire as separate alarm invocations. Provider polling and background recovery use their own Durable Object alarms.
617
+ `createFlowsafeMaintenanceDurableObject()` runs deadline expiry, approval service-level agreement (SLA) sweep, retention purge, and optional schedule fire and notification dispatch as separate alarm invocations. Provider polling and background recovery use their own Durable Object alarms.
617
618
 
618
619
  Read:
619
620
 
@@ -1 +1 @@
1
- {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/agent-host/router.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,aAAa,EAEnB,MAAM,0BAA0B,CAAC;AAalC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAK5C,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,SAAS,SAAS,EAAE,CAAC;IAC7B,OAAO,EAAE,aAAa,CAAC;IACvB,QAAQ,EAAE,mBAAmB,CAAC;CAC/B;AAED,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;AAiMzE,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,CAsI1E"}
1
+ {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/agent-host/router.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,aAAa,EAEnB,MAAM,0BAA0B,CAAC;AAUlC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAK5C,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,SAAS,SAAS,EAAE,CAAC;IAC7B,OAAO,EAAE,aAAa,CAAC;IACvB,QAAQ,EAAE,mBAAmB,CAAC;CAC/B;AAED,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;AAsLzE,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,CAsI1E"}
@@ -3,7 +3,8 @@ import { captureActorContext } from '../approval-api/actor-context.js';
3
3
  import { ActorResolutionError, RUN_START_ROLES, } from '../approval-api/index.js';
4
4
  import { InvalidMutationEpochError, MutationEpochMismatchError, } from '../do-runner/execution-admission.js';
5
5
  import { isPathSafeId } from '../do-runner/index.js';
6
- import { RunRouteError, requireResourceAccess, runRouteReason, } from '../host-kit/index.js';
6
+ import { RunRouteError, requireResourceAccess } from '../host-kit/index.js';
7
+ import { runRouteErrorBody } from '../host-kit/run-route-error.js';
7
8
  import { readBoundedBody } from '../http-body.js';
8
9
  import { createAgentCatalog } from './catalog.js';
9
10
  const MAX_BODY_BYTES = 16_384;
@@ -136,16 +137,9 @@ function internalError(error, route) {
136
137
  return json({ error: 'forbidden' }, 403);
137
138
  }
138
139
  if (error instanceof RunRouteError) {
139
- // A structured reason is the DO saying what it refused and why, in a code
140
- // it means to publish — so it passes through at ANY status, 5xx included.
141
- // Without this a 503 EXECUTION_FENCED became a bare 500 here and the
142
- // caller could not tell a fenced deployment from a broken one.
143
- if (error.status < 500 || runRouteReason(error) !== undefined) {
144
- return json({
145
- error: error.message,
146
- ...(error.reason === undefined ? {} : { reason: error.reason }),
147
- }, error.status);
148
- }
140
+ const body = runRouteErrorBody(error);
141
+ if (body)
142
+ return json(body, error.status);
149
143
  }
150
144
  console.error(JSON.stringify({
151
145
  type: 'agent-route-error',
@@ -1 +1 @@
1
- {"version":3,"file":"router.js","sourceRoot":"","sources":["../../src/agent-host/router.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACv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CAAC;IACvE,uEAAuE;IACvE,sBAAsB,CACpB,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAC5D,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;IACnC,gBAAgB,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjE,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;CACvE;AA8TD,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,sBAAsB,GAC9B,eAAe,CAi7EjB"}
@@ -7,13 +7,13 @@ import { isPrincipalPermissions } from '@proofoftech/breakwater/rbac';
7
7
  import { AgentRunSelectorMismatchError, } from '../agent-runner/durable-agent-runner.js';
8
8
  import { AGENT_ENTRY_PATHS, AGENT_RUN_STORAGE_KEY_PREFIX, bindAgentThread, createFlowsafeDurableAgent, deleteAgentRunRecord, deleteAgentThreadBinding, readAgentRunRecord, readAgentThreadBinding, writeAgentRunRecord, } from '../agent-runner/index.js';
9
9
  import { canonicalResourceOwner, principalActor, principalAuditFields, principalOwner, RUN_START_ROLES, samePrincipal, } from '../approval-api/index.js';
10
- import { assertExecutionPrincipal, isExecutionPrincipalId, } from '../approval-api/principal.js';
10
+ import { assertExecutionPrincipal, isExecutionPrincipalId, isOwnedBy, } from '../approval-api/principal.js';
11
11
  import { errorMessageOf } from '../do-runner/cause-chain.js';
12
12
  import { ExecutionFenceUnreadableError, isRunStartPendingError, normalizeD1RunExecutionIdentity, normalizeMutationEpoch, normalizeRunExecutionIdentity, RunStartPendingError, } from '../do-runner/execution-admission.js';
13
- import { DoStatusError, isPathSafeId, resolveScheduleStartOwner, resourceIdFromKey, SUSPENSION_TIMEOUT_RESUME_KEY, } from '../do-runner/index.js';
13
+ import { DoStatusError, isPathSafeId, RunNotSuspendedError, resolveScheduleStartOwner, resourceIdFromKey, SUSPENSION_TIMEOUT_RESUME_KEY, } from '../do-runner/index.js';
14
14
  import { isDefinitiveInitialAdmissionRefusal } from '../do-runner/initial-admission-refusal.js';
15
15
  import { mastraRegistryEntries } from '../do-runner/mastra-registry.js';
16
- import { exceedsRunInputDepth, runInputDepthMessage, } from '../do-runner/run-input-depth.js';
16
+ import { exceedsRunInputDepth, runInputDepthMessage, someValueExceedsRunInputDepth, } from '../do-runner/run-input-depth.js';
17
17
  import { lifecycleFromRequestContext, terminalCleanupFor, } from '../do-runner/run-lifecycle.js';
18
18
  import { isTerminalRunStatus, } from '../do-runner/run-terminal-state.js';
19
19
  import { captureReservation, sameReservationIdentity, } from '../do-runner/start-reservation-contract.js';
@@ -109,7 +109,7 @@ function safeContext(value) {
109
109
  if (value === undefined ||
110
110
  (value !== null && typeof value === 'object' && !Array.isArray(value))) {
111
111
  const context = sanitizeStoredAgentContext(value);
112
- if (Object.values(context).some((item) => exceedsRunInputDepth(item)))
112
+ if (someValueExceedsRunInputDepth(context))
113
113
  throw new AgentHostRequestError(400, runInputDepthMessage('a safeContext value'));
114
114
  return context;
115
115
  }
@@ -121,6 +121,8 @@ function providerOptions(value) {
121
121
  if (value === null || typeof value !== 'object' || Array.isArray(value)) {
122
122
  throw new AgentHostRequestError(400, 'providerOptions must be an object');
123
123
  }
124
+ if (someValueExceedsRunInputDepth(value))
125
+ throw new AgentHostRequestError(400, runInputDepthMessage('a providerOptions value'));
124
126
  // The closed provider-options check validates this snapshot's namespaces and keys before use; the model provider validates the values when it parses its options.
125
127
  return structuredClone(value);
126
128
  }
@@ -588,7 +590,8 @@ export function createThreadAgentHost(options) {
588
590
  !isPathSafeId(stored.token) ||
589
591
  ownerRecoveryKey(stored.runId) !== key ||
590
592
  typeof stored.threaded !== 'boolean' ||
591
- typeof stored.bindingPreexisting !== 'boolean')
593
+ typeof stored.bindingPreexisting !== 'boolean' ||
594
+ (stored.outcomeRead !== undefined && stored.outcomeRead !== true))
592
595
  throw new Error('invalid journal');
593
596
  const owner = resourceOwner(persistedStartRecord(stored.owner));
594
597
  const rawRecord = persistedStartRecord(stored.runRecord);
@@ -630,6 +633,7 @@ export function createThreadAgentHost(options) {
630
633
  bindingPreexisting: stored.bindingPreexisting,
631
634
  runRecord,
632
635
  ...(claim ? { startReservation: claim } : {}),
636
+ ...(stored.outcomeRead === true ? { outcomeRead: true } : {}),
633
637
  };
634
638
  if (stored.phase === 'preparing' && !Object.hasOwn(stored, 'execution'))
635
639
  return { ...base, phase: 'preparing' };
@@ -733,11 +737,28 @@ export function createThreadAgentHost(options) {
733
737
  throw new Error('agent owner recovery does not match the execution');
734
738
  return state;
735
739
  };
740
+ /** The stored journal, after checking that it is still `recovery`. */
736
741
  const assertRecoveryCurrent = async (recovery) => {
737
742
  const key = ownerRecoveryKey(recovery.runId), current = await options.stateStorage().get(key);
738
743
  if (current === undefined ||
739
744
  !sameOwnerRecovery(validateOwnerRecovery(recovery.threadId, key, current), recovery))
740
745
  throw new Error('agent owner recovery changed');
746
+ return current;
747
+ };
748
+ /**
749
+ * Commit the start's claims once its outcome was read from the run's row,
750
+ * recording that read in the journal first: retention may remove a terminal
751
+ * row once the run claim commits, and a row missing after the read is then a
752
+ * run that ended, never a start whose admission may yet land. Callers hold
753
+ * the recovery lock.
754
+ */
755
+ const commitOwnerClaims = async (recovery) => {
756
+ if (recovery.outcomeRead !== true)
757
+ await options.stateStorage().put(ownerRecoveryKey(recovery.runId), {
758
+ ...persistedStartRecord(await assertRecoveryCurrent(recovery)),
759
+ outcomeRead: true,
760
+ });
761
+ await options.resourceAccess().settleReservation(recovery.token, []);
741
762
  };
742
763
  const assertLegacyTerminalCurrent = async (scope, ref, state, expectedRecord) => {
743
764
  if (!isTerminalRunStatus(state.snapshot.status) ||
@@ -806,15 +827,15 @@ export function createThreadAgentHost(options) {
806
827
  if (current)
807
828
  await deleteAgentRunRecord(options.stateStorage(), runId);
808
829
  };
809
- const finalizeJournalBookkeeping = async (recovery, summary) => {
830
+ const finalizeJournalBookkeeping = async (recovery, ended) => {
810
831
  await assertRecoveryCurrent(recovery);
811
- if (!recovery.threaded && !isTerminalRunStatus(summary.status)) {
832
+ if (!recovery.threaded && !ended) {
812
833
  await ensureOwnerRecoveryAlarm(options.stateStorage());
813
834
  return false;
814
835
  }
815
836
  if (!recovery.threaded)
816
837
  await releaseEphemeralOwnerClaims(recovery);
817
- if (isTerminalRunStatus(summary.status)) {
838
+ if (ended) {
818
839
  const current = await readRun(recovery.runId);
819
840
  if (current !== undefined && !sameRunRecord(current, recovery.runRecord))
820
841
  throw new Error('agent run record changed');
@@ -828,7 +849,7 @@ export function createThreadAgentHost(options) {
828
849
  const workflowId = recovery.execution?.workflowId;
829
850
  if (!workflowId)
830
851
  throw new Error('agent recovery has no execution');
831
- await options.resourceAccess().settleReservation(recovery.token, []);
852
+ await commitOwnerClaims(recovery);
832
853
  await assertRecoveryCurrent(recovery);
833
854
  if (!transition.cleanup.cleanupCompleted) {
834
855
  await abandonApprovalsForRun(options.approvalService(scope), workflowId, recovery.runId, transition.cleanup.status, systemPrincipalId);
@@ -843,7 +864,7 @@ export function createThreadAgentHost(options) {
843
864
  (await ownership.owner('run', recovery.runId)))
844
865
  throw new Error('run ownership could not be released');
845
866
  }
846
- await finalizeJournalBookkeeping(recovery, transition.summary);
867
+ await finalizeJournalBookkeeping(recovery, isTerminalRunStatus(transition.summary.status));
847
868
  return transition.cleanup.cleanupCompleted
848
869
  ? transition.summary
849
870
  : scope.init.runtime.completeTerminalCleanup(workflowId, recovery.runId, transition.cleanup.revision);
@@ -875,8 +896,8 @@ export function createThreadAgentHost(options) {
875
896
  });
876
897
  return true;
877
898
  }
878
- await options.resourceAccess().settleReservation(recovery.token, []);
879
- return finalizeJournalBookkeeping(recovery, summary);
899
+ await commitOwnerClaims(recovery);
900
+ return finalizeJournalBookkeeping(recovery, isTerminalRunStatus(summary.status));
880
901
  });
881
902
  if (clear)
882
903
  await clearOwnerRecovery(recovery);
@@ -1077,23 +1098,28 @@ export function createThreadAgentHost(options) {
1077
1098
  });
1078
1099
  }
1079
1100
  else {
1080
- const selected = matchRecoveryState(stored, await selectedAgentState(scope, stored));
1081
- if (selected.kind === 'initial')
1082
- throw new RunStartPendingError();
1083
- if (isTerminalRunStatus(selected.summary.status))
1084
- await scope.init.runtime.settleStartExecution(selected, stored.startReservation);
1085
- const cleanup = terminalCleanupFor(lifecycleFromRequestContext(selected.snapshot.requestContext));
1086
- recovered = cleanup
1087
- ? {
1088
- kind: 'lifecycle',
1089
- transition: {
1090
- summary: selected.summary,
1091
- transitioned: false,
1092
- casMatched: true,
1093
- cleanup,
1094
- },
1095
- }
1096
- : { kind: 'ordinary', summary: selected.summary };
1101
+ const read = await selectedAgentState(scope, stored);
1102
+ // A row missing after the outcome was read is handled below as a
1103
+ // run that ended.
1104
+ if (read !== null || stored.outcomeRead !== true) {
1105
+ const selected = matchRecoveryState(stored, read);
1106
+ if (selected.kind === 'initial')
1107
+ throw new RunStartPendingError();
1108
+ if (isTerminalRunStatus(selected.summary.status))
1109
+ await scope.init.runtime.settleStartExecution(selected, stored.startReservation);
1110
+ const cleanup = terminalCleanupFor(lifecycleFromRequestContext(selected.snapshot.requestContext));
1111
+ recovered = cleanup
1112
+ ? {
1113
+ kind: 'lifecycle',
1114
+ transition: {
1115
+ summary: selected.summary,
1116
+ transitioned: false,
1117
+ casMatched: true,
1118
+ cleanup,
1119
+ },
1120
+ }
1121
+ : { kind: 'ordinary', summary: selected.summary };
1122
+ }
1097
1123
  }
1098
1124
  }
1099
1125
  if (recovered) {
@@ -1107,8 +1133,8 @@ export function createThreadAgentHost(options) {
1107
1133
  }
1108
1134
  else {
1109
1135
  await assertRecoveryCurrent(stored);
1110
- await options.resourceAccess().settleReservation(stored.token, []);
1111
- clear = await finalizeJournalBookkeeping(stored, summary);
1136
+ await commitOwnerClaims(stored);
1137
+ clear = await finalizeJournalBookkeeping(stored, isTerminalRunStatus(summary.status));
1112
1138
  }
1113
1139
  if (clear) {
1114
1140
  await assertRecoveryCurrent(stored);
@@ -1117,6 +1143,20 @@ export function createThreadAgentHost(options) {
1117
1143
  return summary;
1118
1144
  }
1119
1145
  await assertRecoveryCurrent(stored);
1146
+ // A row gone after the start read it is a run that ended and that
1147
+ // retention removed: finish its bookkeeping as for an ended run and
1148
+ // clear the journal.
1149
+ if (stored.outcomeRead === true) {
1150
+ await options
1151
+ .resourceAccess()
1152
+ .settleReservation(stored.token, [
1153
+ { kind: 'run', resourceId: stored.runId },
1154
+ ]);
1155
+ await finalizeJournalBookkeeping(stored, true);
1156
+ await assertRecoveryCurrent(stored);
1157
+ await options.stateStorage().delete(key);
1158
+ return null;
1159
+ }
1120
1160
  const localZero = () => stored.phase === 'prepared' &&
1121
1161
  ownFrame !== undefined &&
1122
1162
  executions.get(stored.runId) === ownFrame &&
@@ -1730,7 +1770,14 @@ export function createThreadAgentHost(options) {
1730
1770
  const body = resumeBody;
1731
1771
  const ref = runRef(scope, body);
1732
1772
  const snapshotExecution = await snapshotExecutionFor(scope, ref);
1733
- await statusFor(scope, ref, snapshotExecution.state);
1773
+ const { summary: latest } = await statusFor(scope, ref, snapshotExecution.state);
1774
+ const { state } = snapshotExecution;
1775
+ // An ended run's record is deleted, so only the snapshot's execution
1776
+ // owner tells the principal that started it why its resume is refused.
1777
+ if (isTerminalRunStatus(latest.status) &&
1778
+ state.kind !== 'legacy' &&
1779
+ isOwnedBy(state.execution.owner, scope.principal))
1780
+ throw new RunNotSuspendedError(state.execution.workflowId, ref.runId, latest.status);
1734
1781
  const stored = await readRun(ref.runId);
1735
1782
  if (!stored ||
1736
1783
  stored.agentId !== ref.agentId ||