@proofoftech/flowsafe 0.26.2 → 0.27.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.
- package/CHANGELOG.md +60 -0
- package/README.md +6 -5
- package/dist/agent-host/router.d.ts.map +1 -1
- package/dist/agent-host/router.js +5 -11
- package/dist/agent-host/router.js.map +1 -1
- package/dist/agent-host/thread-host.d.ts.map +1 -1
- package/dist/agent-host/thread-host.js +79 -32
- package/dist/agent-host/thread-host.js.map +1 -1
- package/dist/agent-host/thread-topology.d.ts +3 -1
- package/dist/agent-host/thread-topology.d.ts.map +1 -1
- package/dist/agent-host/thread-topology.js +65 -33
- package/dist/agent-host/thread-topology.js.map +1 -1
- package/dist/agent-runner/durable-agent-runner.d.ts +6 -3
- package/dist/agent-runner/durable-agent-runner.d.ts.map +1 -1
- package/dist/agent-runner/durable-agent-runner.js +57 -14
- package/dist/agent-runner/durable-agent-runner.js.map +1 -1
- package/dist/approval-api/actor-context.d.ts +18 -3
- package/dist/approval-api/actor-context.d.ts.map +1 -1
- package/dist/approval-api/actor-context.js.map +1 -1
- package/dist/approval-api/principal.d.ts +12 -0
- package/dist/approval-api/principal.d.ts.map +1 -1
- package/dist/approval-api/principal.js +8 -0
- package/dist/approval-api/principal.js.map +1 -1
- package/dist/approval-api/router.d.ts.map +1 -1
- package/dist/approval-api/router.js +34 -16
- package/dist/approval-api/router.js.map +1 -1
- package/dist/approval-api/service.d.ts +7 -1
- package/dist/approval-api/service.d.ts.map +1 -1
- package/dist/approval-api/service.js +31 -11
- package/dist/approval-api/service.js.map +1 -1
- package/dist/approval-api/types.d.ts +23 -3
- package/dist/approval-api/types.d.ts.map +1 -1
- package/dist/audit-export/audit-proxy.d.ts.map +1 -1
- package/dist/audit-export/audit-proxy.js +4 -0
- package/dist/audit-export/audit-proxy.js.map +1 -1
- package/dist/do-runner/d1-storage.d.ts +6 -0
- package/dist/do-runner/d1-storage.d.ts.map +1 -1
- package/dist/do-runner/d1-storage.js +32 -10
- package/dist/do-runner/d1-storage.js.map +1 -1
- package/dist/do-runner/do-error-response.d.ts +14 -0
- package/dist/do-runner/do-error-response.d.ts.map +1 -1
- package/dist/do-runner/do-error-response.js +23 -37
- package/dist/do-runner/do-error-response.js.map +1 -1
- package/dist/do-runner/do-status-error.d.ts +26 -1
- package/dist/do-runner/do-status-error.d.ts.map +1 -1
- package/dist/do-runner/do-status-error.js +35 -0
- package/dist/do-runner/do-status-error.js.map +1 -1
- package/dist/do-runner/durable-object.d.ts.map +1 -1
- package/dist/do-runner/durable-object.js +44 -21
- package/dist/do-runner/durable-object.js.map +1 -1
- package/dist/do-runner/fenced-workflows-d1.d.ts.map +1 -1
- package/dist/do-runner/fenced-workflows-d1.js +23 -7
- package/dist/do-runner/fenced-workflows-d1.js.map +1 -1
- package/dist/do-runner/run-input-depth.d.ts +10 -3
- package/dist/do-runner/run-input-depth.d.ts.map +1 -1
- package/dist/do-runner/run-input-depth.js +12 -3
- package/dist/do-runner/run-input-depth.js.map +1 -1
- package/dist/do-runner/run-lifecycle.d.ts +3 -2
- package/dist/do-runner/run-lifecycle.d.ts.map +1 -1
- package/dist/do-runner/run-lifecycle.js +3 -2
- package/dist/do-runner/run-lifecycle.js.map +1 -1
- package/dist/do-runner/runtime.d.ts +27 -7
- package/dist/do-runner/runtime.d.ts.map +1 -1
- package/dist/do-runner/runtime.js +60 -14
- package/dist/do-runner/runtime.js.map +1 -1
- package/dist/goals/objective-routes.d.ts.map +1 -1
- package/dist/goals/objective-routes.js +2 -1
- package/dist/goals/objective-routes.js.map +1 -1
- package/dist/host-kit/do-response.d.ts +21 -1
- package/dist/host-kit/do-response.d.ts.map +1 -1
- package/dist/host-kit/do-response.js +56 -25
- package/dist/host-kit/do-response.js.map +1 -1
- package/dist/host-kit/flowsafe-worker.d.ts +25 -3
- package/dist/host-kit/flowsafe-worker.d.ts.map +1 -1
- package/dist/host-kit/flowsafe-worker.js +93 -102
- package/dist/host-kit/flowsafe-worker.js.map +1 -1
- package/dist/host-kit/run-route-error.d.ts +11 -0
- package/dist/host-kit/run-route-error.d.ts.map +1 -1
- package/dist/host-kit/run-route-error.js +13 -5
- package/dist/host-kit/run-route-error.js.map +1 -1
- package/dist/host-kit/run-router.d.ts.map +1 -1
- package/dist/host-kit/run-router.js +18 -40
- package/dist/host-kit/run-router.js.map +1 -1
- package/dist/host-kit/stream-router.d.ts.map +1 -1
- package/dist/host-kit/stream-router.js +11 -15
- package/dist/host-kit/stream-router.js.map +1 -1
- package/dist/internal-error-response.d.ts +7 -2
- package/dist/internal-error-response.d.ts.map +1 -1
- package/dist/internal-error-response.js +10 -3
- package/dist/internal-error-response.js.map +1 -1
- package/dist/schedules/router.d.ts.map +1 -1
- package/dist/schedules/router.js +9 -2
- package/dist/schedules/router.js.map +1 -1
- package/dist/schedules/schedules-d1.d.ts.map +1 -1
- package/dist/schedules/schedules-d1.js +4 -1
- package/dist/schedules/schedules-d1.js.map +1 -1
- package/dist/schedules/tick.d.ts +12 -4
- package/dist/schedules/tick.d.ts.map +1 -1
- package/dist/schedules/tick.js +209 -324
- package/dist/schedules/tick.js.map +1 -1
- package/dist/signal-providers/webhook-route.d.ts.map +1 -1
- package/dist/signal-providers/webhook-route.js +12 -6
- package/dist/signal-providers/webhook-route.js.map +1 -1
- package/dist/signals/router.d.ts.map +1 -1
- package/dist/signals/router.js +6 -4
- package/dist/signals/router.js.map +1 -1
- package/dist/signals/thread-do-routes.d.ts.map +1 -1
- package/dist/signals/thread-do-routes.js +7 -1
- package/dist/signals/thread-do-routes.js.map +1 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,65 @@
|
|
|
1
1
|
# @proofoftech/flowsafe
|
|
2
2
|
|
|
3
|
+
## 0.27.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 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.
|
|
8
|
+
- 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`.
|
|
9
|
+
- 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`.
|
|
10
|
+
- 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.
|
|
11
|
+
- 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.
|
|
12
|
+
- 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`.
|
|
13
|
+
- 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.
|
|
14
|
+
- 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`.
|
|
15
|
+
- 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.
|
|
16
|
+
|
|
17
|
+
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.
|
|
18
|
+
|
|
19
|
+
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.
|
|
20
|
+
|
|
21
|
+
Accept Cloudflare’s omitted namespace trust flag as its default untrusted mode during provisioning and inventory. Trusted and malformed trust values remain refused.
|
|
22
|
+
|
|
23
|
+
Handle Cloudflare’s `script` response field when verifying audit queue consumers, avoiding false convergence failures.
|
|
24
|
+
|
|
25
|
+
Allow Cloudflare’s empty prebuilt-pipeline metadata when attesting the shared dispatcher’s outbound binding.
|
|
26
|
+
|
|
27
|
+
Preserve referenced Wasm sidecars in WFP conformance artifacts, verify their digests before upload, and run the exact upload modules in the local verifier.
|
|
28
|
+
|
|
29
|
+
Select trusted-state Durable Object migrations from the owned live Worker, preserving initial class creation and retries after provider commits.
|
|
30
|
+
|
|
31
|
+
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.
|
|
32
|
+
|
|
33
|
+
Relay conformance candidate maintenance requests to trusted state and verify signed requests, receipts, and replay refusal against the built artifacts locally.
|
|
34
|
+
|
|
35
|
+
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.
|
|
36
|
+
|
|
37
|
+
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.
|
|
38
|
+
|
|
39
|
+
Reject unusable credentialed-run export directories before provisioning paid resources.
|
|
40
|
+
|
|
41
|
+
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.
|
|
42
|
+
|
|
43
|
+
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.
|
|
44
|
+
|
|
45
|
+
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.
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
- 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.
|
|
50
|
+
|
|
51
|
+
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.
|
|
52
|
+
|
|
53
|
+
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.
|
|
54
|
+
|
|
55
|
+
- 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.
|
|
56
|
+
- 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.
|
|
57
|
+
|
|
58
|
+
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.
|
|
59
|
+
|
|
60
|
+
- 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.
|
|
61
|
+
- 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`.
|
|
62
|
+
|
|
3
63
|
## 0.26.2
|
|
4
64
|
|
|
5
65
|
### 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
|
|
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
|
|
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;
|
|
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
|
|
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
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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;AACvE,OAAO,EACL,oBAAoB,EAEpB,eAAe,GAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,cAAc,GACf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAIlD,MAAM,cAAc,GAAG,MAAM,CAAC;AAC9B,MAAM,qBAAqB,GAAG,MAAM,CAAC;AAoCrC,SAAS,IAAI,CAAC,OAAgB,EAAE,MAAM,GAAG,GAAG,EAAE,KAAc;IAC1D,MAAM,OAAO,GAA2B;QACtC,cAAc,EAAE,kBAAkB;QAClC,eAAe,EAAE,UAAU;QAC3B,wBAAwB,EAAE,SAAS;KACpC,CAAC;IACF,IAAI,KAAK;QAAE,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;IACjC,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,OAAO,CAAC,KAAyB;IACxC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,IAAI,CAAC;QACH,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;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C9B,IAAI,MAAM,YAAY,QAAQ;gBAAE,OAAO,MAAM,CAAC;YAC9C,OAAO,MAAM,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;QACvE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACrC,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thread-host.d.ts","sourceRoot":"","sources":["../../src/agent-host/thread-host.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAWjE,OAAO,EAGL,KAAK,cAAc,EAQnB,KAAK,oBAAoB,EACzB,KAAK,2BAA2B,EAIjC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,KAAK,iBAAiB,EAEtB,KAAK,eAAe,EAEpB,KAAK,kBAAkB,EAIvB,KAAK,iCAAiC,EAIvC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,KAAK,2BAA2B,
|
|
1
|
+
{"version":3,"file":"thread-host.d.ts","sourceRoot":"","sources":["../../src/agent-host/thread-host.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAWjE,OAAO,EAGL,KAAK,cAAc,EAQnB,KAAK,oBAAoB,EACzB,KAAK,2BAA2B,EAIjC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,KAAK,iBAAiB,EAEtB,KAAK,eAAe,EAEpB,KAAK,kBAAkB,EAIvB,KAAK,iCAAiC,EAIvC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,KAAK,2BAA2B,EAIjC,MAAM,8BAA8B,CAAC;AAYtC,OAAO,EAGL,KAAK,sBAAsB,EAG3B,KAAK,UAAU,EAIf,KAAK,mBAAmB,E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IACH,2BAA2B,CACzB,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,CAAC,CAAC;IACpB,KAAK,CACH,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC7B,iBAAiB,CACf,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE;QACL,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,cAAc,CAAC;KAC3B,GACA,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC7B;;;;OAIG;IACH,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,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 (
|
|
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,
|
|
830
|
+
const finalizeJournalBookkeeping = async (recovery, ended) => {
|
|
810
831
|
await assertRecoveryCurrent(recovery);
|
|
811
|
-
if (!recovery.threaded && !
|
|
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 (
|
|
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
|
|
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
|
|
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
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
if (
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
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
|
|
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 ||
|