@proofoftech/flowsafe 0.11.0 → 0.13.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 +54 -0
- package/README.md +91 -44
- package/deployment-identity-protocol.d.mts +52 -0
- package/deployment-identity-protocol.mjs +231 -0
- package/dist/agent-host/approval-resumer.d.ts +3 -3
- package/dist/agent-host/approval-resumer.d.ts.map +1 -1
- package/dist/agent-host/approval-resumer.js +6 -7
- package/dist/agent-host/approval-resumer.js.map +1 -1
- package/dist/agent-host/catalog.js +2 -2
- package/dist/agent-host/catalog.js.map +1 -1
- package/dist/agent-host/index.d.ts +2 -2
- package/dist/agent-host/index.d.ts.map +1 -1
- package/dist/agent-host/index.js.map +1 -1
- package/dist/agent-host/router.d.ts +2 -2
- package/dist/agent-host/router.d.ts.map +1 -1
- package/dist/agent-host/router.js +22 -54
- package/dist/agent-host/router.js.map +1 -1
- package/dist/agent-host/thread-host.d.ts +42 -8
- package/dist/agent-host/thread-host.d.ts.map +1 -1
- package/dist/agent-host/thread-host.js +533 -106
- package/dist/agent-host/thread-host.js.map +1 -1
- package/dist/agent-host/thread-topology.d.ts +28 -7
- package/dist/agent-host/thread-topology.d.ts.map +1 -1
- package/dist/agent-host/thread-topology.js +97 -39
- package/dist/agent-host/thread-topology.js.map +1 -1
- package/dist/agent-host/trusted-context.d.ts.map +1 -1
- package/dist/agent-host/trusted-context.js +3 -1
- package/dist/agent-host/trusted-context.js.map +1 -1
- package/dist/agent-host/types.d.ts +2 -0
- package/dist/agent-host/types.d.ts.map +1 -1
- package/dist/agent-runner/agent-run-state.d.ts +9 -8
- package/dist/agent-runner/agent-run-state.d.ts.map +1 -1
- package/dist/agent-runner/agent-run-state.js +78 -40
- package/dist/agent-runner/agent-run-state.js.map +1 -1
- package/dist/agent-runner/durable-agent-runner.d.ts +18 -16
- package/dist/agent-runner/durable-agent-runner.d.ts.map +1 -1
- package/dist/agent-runner/durable-agent-runner.js +120 -43
- package/dist/agent-runner/durable-agent-runner.js.map +1 -1
- package/dist/agent-runner/index.d.ts +1 -1
- package/dist/agent-runner/index.d.ts.map +1 -1
- package/dist/agent-runner/index.js +1 -1
- package/dist/agent-runner/index.js.map +1 -1
- package/dist/approval-api/actor-context.d.ts +67 -0
- package/dist/approval-api/actor-context.d.ts.map +1 -0
- package/dist/approval-api/actor-context.js +120 -0
- package/dist/approval-api/actor-context.js.map +1 -0
- package/dist/approval-api/contract.d.ts +12 -23
- package/dist/approval-api/contract.d.ts.map +1 -1
- package/dist/approval-api/d1-store.d.ts +7 -15
- package/dist/approval-api/d1-store.d.ts.map +1 -1
- package/dist/approval-api/d1-store.js +83 -159
- package/dist/approval-api/d1-store.js.map +1 -1
- package/dist/approval-api/grants.d.ts +3 -17
- package/dist/approval-api/grants.d.ts.map +1 -1
- package/dist/approval-api/grants.js +19 -39
- package/dist/approval-api/grants.js.map +1 -1
- package/dist/approval-api/index.d.ts +8 -8
- package/dist/approval-api/index.d.ts.map +1 -1
- package/dist/approval-api/index.js +5 -5
- package/dist/approval-api/index.js.map +1 -1
- package/dist/approval-api/principal.d.ts +29 -30
- package/dist/approval-api/principal.d.ts.map +1 -1
- package/dist/approval-api/principal.js +73 -54
- package/dist/approval-api/principal.js.map +1 -1
- package/dist/approval-api/resource-ownership.d.ts +64 -0
- package/dist/approval-api/resource-ownership.d.ts.map +1 -0
- package/dist/approval-api/resource-ownership.js +329 -0
- package/dist/approval-api/resource-ownership.js.map +1 -0
- package/dist/approval-api/retention.d.ts +6 -11
- package/dist/approval-api/retention.d.ts.map +1 -1
- package/dist/approval-api/retention.js +7 -12
- package/dist/approval-api/retention.js.map +1 -1
- package/dist/approval-api/router.d.ts +9 -8
- package/dist/approval-api/router.d.ts.map +1 -1
- package/dist/approval-api/router.js +50 -18
- package/dist/approval-api/router.js.map +1 -1
- package/dist/approval-api/service.d.ts +26 -36
- package/dist/approval-api/service.d.ts.map +1 -1
- package/dist/approval-api/service.js +104 -166
- package/dist/approval-api/service.js.map +1 -1
- package/dist/approval-api/store-factory.d.ts +19 -0
- package/dist/approval-api/store-factory.d.ts.map +1 -0
- package/dist/approval-api/store-factory.js +49 -0
- package/dist/approval-api/store-factory.js.map +1 -0
- package/dist/approval-api/store.d.ts +22 -36
- package/dist/approval-api/store.d.ts.map +1 -1
- package/dist/approval-api/store.js +48 -66
- package/dist/approval-api/store.js.map +1 -1
- package/dist/approval-api/types.d.ts +28 -22
- package/dist/approval-api/types.d.ts.map +1 -1
- package/dist/approval-api/types.js +51 -3
- package/dist/approval-api/types.js.map +1 -1
- package/dist/approval-ui/client.js +3 -3
- package/dist/approval-ui/client.js.map +1 -1
- package/dist/approval-ui/stream.d.ts +4 -4
- package/dist/approval-ui/stream.d.ts.map +1 -1
- package/dist/approval-ui/stream.js +2 -2
- package/dist/approval-ui/tips.d.ts +1 -1
- package/dist/approval-ui/tips.js +1 -1
- package/dist/approval-ui/tips.js.map +1 -1
- package/dist/approval-ui/use-approval-dashboard.d.ts +3 -3
- package/dist/approval-ui/use-approval-dashboard.js +1 -1
- package/dist/artifacts/index.d.ts +2 -3
- package/dist/artifacts/index.d.ts.map +1 -1
- package/dist/artifacts/index.js +9 -8
- package/dist/artifacts/index.js.map +1 -1
- package/dist/audit-export/audit-proxy.d.ts +71 -0
- package/dist/audit-export/audit-proxy.d.ts.map +1 -0
- package/dist/audit-export/audit-proxy.js +142 -0
- package/dist/audit-export/audit-proxy.js.map +1 -0
- package/dist/audit-export/index.d.ts +4 -7
- package/dist/audit-export/index.d.ts.map +1 -1
- package/dist/audit-export/index.js +1 -4
- package/dist/audit-export/index.js.map +1 -1
- package/dist/audit-export/queue-types.d.ts +5 -0
- package/dist/audit-export/queue-types.d.ts.map +1 -0
- package/dist/audit-export/queue-types.js +3 -0
- package/dist/audit-export/queue-types.js.map +1 -0
- package/dist/background-tasks/d1-storage.d.ts +9 -19
- package/dist/background-tasks/d1-storage.d.ts.map +1 -1
- package/dist/background-tasks/d1-storage.js +22 -52
- package/dist/background-tasks/d1-storage.js.map +1 -1
- package/dist/background-tasks/host.d.ts +4 -6
- package/dist/background-tasks/host.d.ts.map +1 -1
- package/dist/background-tasks/host.js +14 -17
- package/dist/background-tasks/host.js.map +1 -1
- package/dist/background-tasks/index.d.ts +1 -1
- package/dist/background-tasks/index.d.ts.map +1 -1
- package/dist/background-tasks/index.js +3 -3
- package/dist/background-tasks/index.js.map +1 -1
- package/dist/background-tasks/routes.d.ts +8 -4
- package/dist/background-tasks/routes.d.ts.map +1 -1
- package/dist/background-tasks/routes.js +33 -31
- package/dist/background-tasks/routes.js.map +1 -1
- package/dist/deployment-identity-protocol.d.ts +3 -0
- package/dist/deployment-identity-protocol.d.ts.map +1 -0
- package/dist/deployment-identity-protocol.js +3 -0
- package/dist/deployment-identity-protocol.js.map +1 -0
- package/dist/do-runner/breakwater-keys.d.ts +7 -5
- package/dist/do-runner/breakwater-keys.d.ts.map +1 -1
- package/dist/do-runner/breakwater-keys.js +7 -5
- package/dist/do-runner/breakwater-keys.js.map +1 -1
- package/dist/do-runner/cf-types.d.ts +18 -12
- package/dist/do-runner/cf-types.d.ts.map +1 -1
- package/dist/do-runner/cf-types.js.map +1 -1
- package/dist/do-runner/d1-storage.d.ts +51 -189
- package/dist/do-runner/d1-storage.d.ts.map +1 -1
- package/dist/do-runner/d1-storage.js +111 -362
- package/dist/do-runner/d1-storage.js.map +1 -1
- package/dist/do-runner/deployment-identity.d.ts +121 -0
- package/dist/do-runner/deployment-identity.d.ts.map +1 -0
- package/dist/do-runner/deployment-identity.js +272 -0
- package/dist/do-runner/deployment-identity.js.map +1 -0
- package/dist/do-runner/do-error-response.d.ts +1 -1
- package/dist/do-runner/do-error-response.d.ts.map +1 -1
- package/dist/do-runner/do-error-response.js +7 -1
- package/dist/do-runner/do-error-response.js.map +1 -1
- package/dist/do-runner/durable-object.d.ts +23 -16
- package/dist/do-runner/durable-object.d.ts.map +1 -1
- package/dist/do-runner/durable-object.js +303 -70
- package/dist/do-runner/durable-object.js.map +1 -1
- package/dist/do-runner/execution-context.d.ts +1 -0
- package/dist/do-runner/execution-context.d.ts.map +1 -1
- package/dist/do-runner/execution-context.js +4 -7
- package/dist/do-runner/execution-context.js.map +1 -1
- package/dist/do-runner/execution-principal-header.d.ts +16 -0
- package/dist/do-runner/execution-principal-header.d.ts.map +1 -0
- package/dist/do-runner/execution-principal-header.js +20 -0
- package/dist/do-runner/execution-principal-header.js.map +1 -0
- package/dist/do-runner/hub-do.d.ts +17 -25
- package/dist/do-runner/hub-do.d.ts.map +1 -1
- package/dist/do-runner/hub-do.js +63 -59
- package/dist/do-runner/hub-do.js.map +1 -1
- package/dist/do-runner/index.d.ts +12 -10
- package/dist/do-runner/index.d.ts.map +1 -1
- package/dist/do-runner/index.js +10 -9
- package/dist/do-runner/index.js.map +1 -1
- package/dist/do-runner/init.d.ts +0 -7
- package/dist/do-runner/init.d.ts.map +1 -1
- package/dist/do-runner/init.js +1 -2
- package/dist/do-runner/init.js.map +1 -1
- package/dist/do-runner/memory-id.d.ts +8 -25
- package/dist/do-runner/memory-id.d.ts.map +1 -1
- package/dist/do-runner/memory-id.js +25 -52
- package/dist/do-runner/memory-id.js.map +1 -1
- package/dist/do-runner/path-safe-id.d.ts +2 -48
- package/dist/do-runner/path-safe-id.d.ts.map +1 -1
- package/dist/do-runner/path-safe-id.js +3 -93
- package/dist/do-runner/path-safe-id.js.map +1 -1
- package/dist/do-runner/pubsub.d.ts +1 -1
- package/dist/do-runner/pubsub.js +1 -1
- package/dist/do-runner/runtime.d.ts +47 -34
- package/dist/do-runner/runtime.d.ts.map +1 -1
- package/dist/do-runner/runtime.js +281 -143
- package/dist/do-runner/runtime.js.map +1 -1
- package/dist/do-runner/schedule-source.d.ts +81 -0
- package/dist/do-runner/schedule-source.d.ts.map +1 -0
- package/dist/do-runner/schedule-source.js +64 -0
- package/dist/do-runner/schedule-source.js.map +1 -0
- package/dist/do-runner/table-prefix.d.ts +3 -0
- package/dist/do-runner/table-prefix.d.ts.map +1 -0
- package/dist/do-runner/table-prefix.js +17 -0
- package/dist/do-runner/table-prefix.js.map +1 -0
- package/dist/do-runner/thread-do.d.ts +18 -32
- package/dist/do-runner/thread-do.d.ts.map +1 -1
- package/dist/do-runner/thread-do.js +52 -74
- package/dist/do-runner/thread-do.js.map +1 -1
- package/dist/goals/objective-routes.d.ts +7 -4
- package/dist/goals/objective-routes.d.ts.map +1 -1
- package/dist/goals/objective-routes.js +58 -43
- package/dist/goals/objective-routes.js.map +1 -1
- package/dist/host-kit/approval-bridge.d.ts +18 -21
- package/dist/host-kit/approval-bridge.d.ts.map +1 -1
- package/dist/host-kit/approval-bridge.js +37 -37
- package/dist/host-kit/approval-bridge.js.map +1 -1
- package/dist/host-kit/bearer-auth.d.ts +3 -4
- package/dist/host-kit/bearer-auth.d.ts.map +1 -1
- package/dist/host-kit/bearer-auth.js +7 -11
- package/dist/host-kit/bearer-auth.js.map +1 -1
- package/dist/host-kit/do-run-topology.d.ts +14 -5
- package/dist/host-kit/do-run-topology.d.ts.map +1 -1
- package/dist/host-kit/do-run-topology.js +47 -15
- package/dist/host-kit/do-run-topology.js.map +1 -1
- package/dist/host-kit/env-vars.d.ts +1 -1
- package/dist/host-kit/env-vars.js +1 -1
- package/dist/host-kit/flowsafe-worker.d.ts +159 -80
- package/dist/host-kit/flowsafe-worker.d.ts.map +1 -1
- package/dist/host-kit/flowsafe-worker.js +629 -142
- package/dist/host-kit/flowsafe-worker.js.map +1 -1
- package/dist/host-kit/host-approval-service.d.ts +62 -54
- package/dist/host-kit/host-approval-service.d.ts.map +1 -1
- package/dist/host-kit/host-approval-service.js +90 -61
- package/dist/host-kit/host-approval-service.js.map +1 -1
- package/dist/host-kit/hub-topology.d.ts +6 -7
- package/dist/host-kit/hub-topology.d.ts.map +1 -1
- package/dist/host-kit/hub-topology.js +16 -12
- package/dist/host-kit/hub-topology.js.map +1 -1
- package/dist/host-kit/index.d.ts +13 -11
- package/dist/host-kit/index.d.ts.map +1 -1
- package/dist/host-kit/index.js +9 -12
- package/dist/host-kit/index.js.map +1 -1
- package/dist/host-kit/maintenance-capability.d.ts +58 -0
- package/dist/host-kit/maintenance-capability.d.ts.map +1 -0
- package/dist/host-kit/maintenance-capability.js +268 -0
- package/dist/host-kit/maintenance-capability.js.map +1 -0
- package/dist/host-kit/memory-boundary.d.ts +4 -19
- package/dist/host-kit/memory-boundary.d.ts.map +1 -1
- package/dist/host-kit/memory-boundary.js +12 -27
- package/dist/host-kit/memory-boundary.js.map +1 -1
- package/dist/host-kit/resource-access.d.ts +4 -0
- package/dist/host-kit/resource-access.d.ts.map +1 -0
- package/dist/host-kit/resource-access.js +12 -0
- package/dist/host-kit/resource-access.js.map +1 -0
- package/dist/host-kit/run-router.d.ts +25 -15
- package/dist/host-kit/run-router.d.ts.map +1 -1
- package/dist/host-kit/run-router.js +61 -46
- package/dist/host-kit/run-router.js.map +1 -1
- package/dist/host-kit/state-egress.d.ts +51 -0
- package/dist/host-kit/state-egress.d.ts.map +1 -0
- package/dist/host-kit/state-egress.js +120 -0
- package/dist/host-kit/state-egress.js.map +1 -0
- package/dist/host-kit/stream-router.d.ts +9 -4
- package/dist/host-kit/stream-router.d.ts.map +1 -1
- package/dist/host-kit/stream-router.js +45 -38
- package/dist/host-kit/stream-router.js.map +1 -1
- package/dist/host-kit/stream-ticket.d.ts +10 -10
- package/dist/host-kit/stream-ticket.d.ts.map +1 -1
- package/dist/host-kit/stream-ticket.js +60 -90
- package/dist/host-kit/stream-ticket.js.map +1 -1
- package/dist/host-kit/thread-topology.d.ts +17 -11
- package/dist/host-kit/thread-topology.d.ts.map +1 -1
- package/dist/host-kit/thread-topology.js +33 -59
- package/dist/host-kit/thread-topology.js.map +1 -1
- package/dist/host-kit/verifier.d.ts +6 -6
- package/dist/host-kit/verifier.d.ts.map +1 -1
- package/dist/host-kit/verifier.js +51 -119
- package/dist/host-kit/verifier.js.map +1 -1
- package/dist/http-body.d.ts +20 -0
- package/dist/http-body.d.ts.map +1 -0
- package/dist/http-body.js +67 -0
- package/dist/http-body.js.map +1 -0
- package/dist/schedules/index.d.ts +3 -2
- package/dist/schedules/index.d.ts.map +1 -1
- package/dist/schedules/index.js +5 -4
- package/dist/schedules/index.js.map +1 -1
- package/dist/schedules/router.d.ts +16 -10
- package/dist/schedules/router.d.ts.map +1 -1
- package/dist/schedules/router.js +153 -91
- package/dist/schedules/router.js.map +1 -1
- package/dist/schedules/schedules-d1.d.ts +88 -0
- package/dist/schedules/schedules-d1.d.ts.map +1 -1
- package/dist/schedules/schedules-d1.js +411 -50
- package/dist/schedules/schedules-d1.js.map +1 -1
- package/dist/schedules/target-policy.d.ts +29 -0
- package/dist/schedules/target-policy.d.ts.map +1 -0
- package/dist/schedules/target-policy.js +70 -0
- package/dist/schedules/target-policy.js.map +1 -0
- package/dist/schedules/tick.d.ts +125 -21
- package/dist/schedules/tick.d.ts.map +1 -1
- package/dist/schedules/tick.js +637 -160
- package/dist/schedules/tick.js.map +1 -1
- package/dist/signal-providers/delivery.d.ts +0 -19
- package/dist/signal-providers/delivery.d.ts.map +1 -1
- package/dist/signal-providers/delivery.js +5 -54
- package/dist/signal-providers/delivery.js.map +1 -1
- package/dist/signal-providers/github-provider.d.ts.map +1 -1
- package/dist/signal-providers/github-provider.js +9 -16
- package/dist/signal-providers/github-provider.js.map +1 -1
- package/dist/signal-providers/host-do.d.ts +3 -45
- package/dist/signal-providers/host-do.d.ts.map +1 -1
- package/dist/signal-providers/host-do.js +86 -106
- package/dist/signal-providers/host-do.js.map +1 -1
- package/dist/signal-providers/host-topology.d.ts +5 -14
- package/dist/signal-providers/host-topology.d.ts.map +1 -1
- package/dist/signal-providers/host-topology.js +11 -25
- package/dist/signal-providers/host-topology.js.map +1 -1
- package/dist/signal-providers/index.d.ts +3 -3
- package/dist/signal-providers/index.d.ts.map +1 -1
- package/dist/signal-providers/index.js +3 -3
- package/dist/signal-providers/index.js.map +1 -1
- package/dist/signal-providers/provider.d.ts +4 -5
- package/dist/signal-providers/provider.d.ts.map +1 -1
- package/dist/signal-providers/provider.js +5 -6
- package/dist/signal-providers/provider.js.map +1 -1
- package/dist/signal-providers/subscription-d1.d.ts +10 -57
- package/dist/signal-providers/subscription-d1.d.ts.map +1 -1
- package/dist/signal-providers/subscription-d1.js +208 -155
- package/dist/signal-providers/subscription-d1.js.map +1 -1
- package/dist/signal-providers/webhook-route.d.ts +28 -14
- package/dist/signal-providers/webhook-route.d.ts.map +1 -1
- package/dist/signal-providers/webhook-route.js +117 -88
- package/dist/signal-providers/webhook-route.js.map +1 -1
- package/dist/signals/client.js +8 -8
- package/dist/signals/client.js.map +1 -1
- package/dist/signals/d1-shared.js +1 -1
- package/dist/signals/d1-shared.js.map +1 -1
- package/dist/signals/index.d.ts +1 -1
- package/dist/signals/index.d.ts.map +1 -1
- package/dist/signals/index.js.map +1 -1
- package/dist/signals/notification-dispatch.d.ts +12 -6
- package/dist/signals/notification-dispatch.d.ts.map +1 -1
- package/dist/signals/notification-dispatch.js +37 -21
- package/dist/signals/notification-dispatch.js.map +1 -1
- package/dist/signals/notifications-d1.d.ts +5 -8
- package/dist/signals/notifications-d1.d.ts.map +1 -1
- package/dist/signals/notifications-d1.js +8 -13
- package/dist/signals/notifications-d1.js.map +1 -1
- package/dist/signals/router.d.ts +10 -10
- package/dist/signals/router.d.ts.map +1 -1
- package/dist/signals/router.js +49 -51
- package/dist/signals/router.js.map +1 -1
- package/dist/signals/thread-do-routes.d.ts +74 -15
- package/dist/signals/thread-do-routes.d.ts.map +1 -1
- package/dist/signals/thread-do-routes.js +484 -41
- package/dist/signals/thread-do-routes.js.map +1 -1
- package/dist/signals/thread-state-d1.d.ts.map +1 -1
- package/dist/signals/thread-state-d1.js +2 -3
- package/dist/signals/thread-state-d1.js.map +1 -1
- package/package.json +29 -6
- package/scripts/seed-deployment-identity.mjs +252 -0
- package/dist/approval-api/tenant-brand.d.ts +0 -35
- package/dist/approval-api/tenant-brand.d.ts.map +0 -1
- package/dist/approval-api/tenant-brand.js +0 -19
- package/dist/approval-api/tenant-brand.js.map +0 -1
- package/dist/approval-api/tenant-context.d.ts +0 -84
- package/dist/approval-api/tenant-context.d.ts.map +0 -1
- package/dist/approval-api/tenant-context.js +0 -112
- package/dist/approval-api/tenant-context.js.map +0 -1
- package/dist/approval-api/tenant-store.d.ts +0 -36
- package/dist/approval-api/tenant-store.d.ts.map +0 -1
- package/dist/approval-api/tenant-store.js +0 -129
- package/dist/approval-api/tenant-store.js.map +0 -1
- package/dist/do-runner/resume-ledger.d.ts +0 -48
- package/dist/do-runner/resume-ledger.d.ts.map +0 -1
- package/dist/do-runner/resume-ledger.js +0 -60
- package/dist/do-runner/resume-ledger.js.map +0 -1
- package/dist/do-runner/thread-header.d.ts +0 -31
- package/dist/do-runner/thread-header.d.ts.map +0 -1
- package/dist/do-runner/thread-header.js +0 -39
- package/dist/do-runner/thread-header.js.map +0 -1
- package/dist/host-kit/subdomain-check.d.ts +0 -23
- package/dist/host-kit/subdomain-check.d.ts.map +0 -1
- package/dist/host-kit/subdomain-check.js +0 -61
- package/dist/host-kit/subdomain-check.js.map +0 -1
- package/dist/host-kit/tenant-registry.d.ts +0 -51
- package/dist/host-kit/tenant-registry.d.ts.map +0 -1
- package/dist/host-kit/tenant-registry.js +0 -88
- package/dist/host-kit/tenant-registry.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,59 @@
|
|
|
1
1
|
# @proofoftech/flowsafe
|
|
2
2
|
|
|
3
|
+
## 0.13.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 4f0fc9d: Create artifact purgers from the current Worker environment, apply the configured D1 table prefix to built-in maintenance, enforce the shared 39-character prefix limit at every storage and low-level purge boundary, and pin the D1 adapter compatible with the minimum supported Mastra core.
|
|
8
|
+
|
|
9
|
+
Migrate a configured artifact purger from `artifactStore: store` to `artifactStore: () => store`. For R2, use `artifactStore: (env) => new R2ArtifactStore(env.ARTIFACTS)`. If runtime storage uses `tablePrefix`, keep it at 39 characters or fewer and set the identical `storageTablePrefix` on `createFlowsafeWorker()`.
|
|
10
|
+
|
|
11
|
+
## Unreleased
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- Change `FlowsafeWorkerConfig.artifactStore` from a bound purger to an invocation-environment factory. Existing hosts must migrate `artifactStore: store` to `artifactStore: () => store`; R2 hosts use `artifactStore: (env) => new R2ArtifactStore(env.ARTIFACTS)`. R2 deletion still precedes snapshot deletion, while factory or deletion failures keep the enumerable row for retry and remain isolated from sibling duties. Hosts without artifacts remain unchanged.
|
|
16
|
+
|
|
17
|
+
- Add a shared maximum of 39 characters for `tablePrefix` and `storageTablePrefix`, keeping final Mastra table identifiers within 63 characters. Every exported prefix-aware low-level purge now validates the same contract before preparing D1 statements. The host prefix must match the value used by D1 runtime storage; fixed-schema Flowsafe tables remain unprefixed.
|
|
18
|
+
|
|
19
|
+
- Pin `@mastra/cloudflare-d1` to 1.1.1 so clean consumers at the supported `@mastra/core` 1.50.0 minimum import and bundle without an override.
|
|
20
|
+
|
|
21
|
+
## 0.12.0
|
|
22
|
+
|
|
23
|
+
### Minor Changes
|
|
24
|
+
|
|
25
|
+
- 3276c2a: Use `jose` for actor JWT verification and stream-ticket signing. Stream tickets are now standard three-segment JWTs with a dedicated audience and `typ`, so actor tokens and stream tickets cannot cross-verify even if a deployment reuses a secret. Existing verifier injection, actor validation, issuer, audience, expiry, and key-selection behavior remains fail closed.
|
|
26
|
+
|
|
27
|
+
GitHub webhook signatures now require the exact `sha256=<64 hex>` shape before raw-byte WebCrypto verification. Malformed signatures and invalid UTF-8 JSON return stable client errors without throwing, while empty and non-ASCII payloads remain byte-exact.
|
|
28
|
+
|
|
29
|
+
Deployment identity provisioning now recognizes Cloudflare D1's exact `_cf_KV` and `_cf_METADATA` internal tables on a fresh database while continuing to reject arbitrary or lookalike pre-existing application tables.
|
|
30
|
+
|
|
31
|
+
- b3b4b55: Replace pooled request-level tenancy with one physically isolated organization per deployment.
|
|
32
|
+
|
|
33
|
+
This breaking release requires `DEPLOYMENT_TENANT`, a matching D1 sentinel seeded before application migrations, and a per-deployment `DEPLOYMENT_IDENTITY_SECRET`. The Worker validates the strict singleton sentinel, and production Durable Objects also authenticate every Worker caller before reading storage.
|
|
34
|
+
|
|
35
|
+
`ActorContext`, `ActorResolver`, and `createActorResolver()` replace their tenant-named equivalents. Approval and subscription factories now expose `.store()`, run, thread, schedule, and subscription ids are opaque and server-minted, and live hubs, provider hosts, and background-task hosts are deployment singletons.
|
|
36
|
+
|
|
37
|
+
Tenant-branded stores, tenant-prefixed id helpers, the tenant registry, subdomain cross-check, and in-database tenant purge APIs have been removed. First-time sentinel provisioning refuses any database with pre-existing application tables; provision a fresh database for each organization.
|
|
38
|
+
|
|
39
|
+
`createFlowsafeWorker()` no longer exposes the unused `wrapResolve` hook. Authenticate and validate actors in `buildVerifier`, mount deployment-specific routes through `preRoutes`, and enforce final mutation policy through `beforeStart` or `beforeResume`.
|
|
40
|
+
|
|
41
|
+
`createFlowsafeWorker()` now delegates sweep, purge, and optional schedule-tick duties to `createFlowsafeMaintenanceDurableObject()`. Tenant Workers no longer export `scheduled()` or `queue()` handlers and contain no cron triggers or queue consumers. Provisioning must set a distinct `MAINTENANCE_ADMIN_SECRET`, call `POST /admin/ensure-maintenance`, and monitor `GET /admin/maintenance-status`.
|
|
42
|
+
|
|
43
|
+
The maintenance singleton persists and re-arms its next alarm before running one due duty. A failed or terminated duty cannot break the alarm chain, starve another due duty, or update the last-success timestamp.
|
|
44
|
+
|
|
45
|
+
Externally authored fleet releases no longer receive the reusable maintenance administrator secret or a shared audit Queue producer. They relay operation-bound, short-lived maintenance capabilities to trusted state and require signed results, and send untrusted audit events through an authenticated trusted-state proxy that supplies canonical infrastructure attribution.
|
|
46
|
+
|
|
47
|
+
Server-minted runs, threads, and schedules plus validated host-owned resource keys retain per-principal authorization through the deployment-local resource-owner registry. Inaccessible resources return `404` before role checks.
|
|
48
|
+
|
|
49
|
+
The package now ships `flowsafe-provision` for strict D1 sentinel provisioning. The CLI resolves a consumer-installed Wrangler `>=4 <5` optional peer, rejects other Wrangler majors, and maps preview provisioning to Wrangler's remote preview target.
|
|
50
|
+
|
|
51
|
+
The deployment-identity protocol is exported as `@proofoftech/flowsafe/deployment-identity-protocol` for trusted fleet provisioners that must apply the same sentinel rules through another Cloudflare API client.
|
|
52
|
+
|
|
53
|
+
Opt-in HTTP approval creation now requires write access to the named run. Those client-filed records remain decision-only; only trusted suspension-bound, run-scoped, or server-targeted approvals can resume execution.
|
|
54
|
+
|
|
55
|
+
Subscription stores now snapshot caller input before persistence and use the same JSON metadata semantics in D1 and memory. External provider resource ids reject ASCII controls and values larger than 1,024 UTF-8 bytes.
|
|
56
|
+
|
|
3
57
|
## 0.11.0
|
|
4
58
|
|
|
5
59
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @proofoftech/flowsafe
|
|
2
2
|
|
|
3
|
-
Durable approvals and
|
|
3
|
+
Durable approvals and physically isolated long-running execution for Mastra on Cloudflare.
|
|
4
4
|
|
|
5
5
|
Flowsafe runs Mastra workflows and agents through Cloudflare Durable Objects, stores their snapshots in D1, turns suspensions into human approval requests, and derives connector grants from stored decisions when a run resumes.
|
|
6
6
|
|
|
@@ -28,6 +28,7 @@ Compatibility:
|
|
|
28
28
|
- `@mastra/core` in the declared `^1.50.0` peer range
|
|
29
29
|
- `react` and `react-dom` `>=18 <20` (React 18 or 19) for the optional approval UI
|
|
30
30
|
- `@proofoftech/breakwater` `>=0.9.0 <1.0.0` when used
|
|
31
|
+
- `wrangler` `>=4 <5` for the optional `flowsafe-provision` CLI
|
|
31
32
|
|
|
32
33
|
## Choose an export
|
|
33
34
|
|
|
@@ -35,10 +36,10 @@ Compatibility:
|
|
|
35
36
|
| --- | --- |
|
|
36
37
|
| `@proofoftech/flowsafe` | Compatibility barrel for approval API, runner, artifacts, and audit export |
|
|
37
38
|
| `@proofoftech/flowsafe/agent-host` | Server-only guarded-agent catalogs, authenticated run routes, thread hosting, NDJSON observation, and approval-only resume |
|
|
38
|
-
| `@proofoftech/flowsafe/approval-api` | Approval records, service,
|
|
39
|
-
| `@proofoftech/flowsafe/do-runner` | Durable Object runner, D1 storage, run summaries, identities, pub/sub,
|
|
39
|
+
| `@proofoftech/flowsafe/approval-api` | Approval records, actor resolver, service, deployment store, REST router, grants, SLA, retention, notifications, and stream events |
|
|
40
|
+
| `@proofoftech/flowsafe/do-runner` | Durable Object runner, D1 storage, deployment sentinel, run summaries, snapshot provenance, identities, pub/sub, and retention |
|
|
40
41
|
| `@proofoftech/flowsafe/approval-ui` | Styling-library-agnostic React dashboard, DOM-free API client, headless hook, and live transport |
|
|
41
|
-
| `@proofoftech/flowsafe/host-kit` |
|
|
42
|
+
| `@proofoftech/flowsafe/host-kit` | Authenticator and verifier seams, topologies, run/stream routers, approval bridges, and composed Worker |
|
|
42
43
|
| `@proofoftech/flowsafe/host-kit/module` | Import-safe workflow module contract |
|
|
43
44
|
| `@proofoftech/flowsafe/artifacts` | R2 artifact store and in-memory test bucket |
|
|
44
45
|
| `@proofoftech/flowsafe/audit-export` | Cloudflare Queue producer sink and NDJSON SIEM consumer |
|
|
@@ -46,8 +47,8 @@ Compatibility:
|
|
|
46
47
|
| `@proofoftech/flowsafe/signals` | Thread signal routes, ingestion router, D1 notification/state domains, dispatch, and client |
|
|
47
48
|
| `@proofoftech/flowsafe/signals/client` | DOM-free signal client without Worker code |
|
|
48
49
|
| `@proofoftech/flowsafe/goals` | Durable objective router |
|
|
49
|
-
| `@proofoftech/flowsafe/schedules` | D1 schedules,
|
|
50
|
-
| `@proofoftech/flowsafe/background-tasks` |
|
|
50
|
+
| `@proofoftech/flowsafe/schedules` | D1 schedules, deployment router, reserved-context controls, and CAS tick |
|
|
51
|
+
| `@proofoftech/flowsafe/background-tasks` | Deployment task host, D1 task domains, routes, and cleanup |
|
|
51
52
|
| `@proofoftech/flowsafe/signal-providers` | Alarm-driven provider host, topology, subscriptions, verified webhooks, and GitHub reference provider |
|
|
52
53
|
|
|
53
54
|
New host-side and React features are subpath-only. This keeps the root import free of Breakwater, durable-agent-host, and UI dependency graphs.
|
|
@@ -58,13 +59,14 @@ Copy the [reference deployment](https://github.com/ProofOfTechOrg/anchorage/tree
|
|
|
58
59
|
|
|
59
60
|
- one Durable Object per run;
|
|
60
61
|
- D1-backed Mastra snapshots and approvals;
|
|
61
|
-
- bearer-authentication seam and
|
|
62
|
+
- bearer-authentication seam and actor resolver;
|
|
63
|
+
- strict D1 deployment sentinel plus authenticated Worker-to-Durable-Object calls;
|
|
62
64
|
- workflow catalog, start, status, and resume routes;
|
|
63
65
|
- suspension-to-approval bridge;
|
|
64
66
|
- exact suspension-bound breakwater grant derivation;
|
|
65
67
|
- role checks and separation of duties;
|
|
66
68
|
- optional live approval/run WebSockets;
|
|
67
|
-
-
|
|
69
|
+
- alarm-owned SLA sweep and retention purge;
|
|
68
70
|
- structured audit and optional Queue-to-SIEM export;
|
|
69
71
|
- a sample gated workflow.
|
|
70
72
|
|
|
@@ -82,8 +84,12 @@ import {
|
|
|
82
84
|
import { approvalStoreFactoryFor } from '@proofoftech/flowsafe/host-kit';
|
|
83
85
|
|
|
84
86
|
export class AppRunner extends DurableObjectRunner<Env> {
|
|
87
|
+
protected runOwnership(env: Env) {
|
|
88
|
+
return approvalStoreFactoryFor(env.DB).resources();
|
|
89
|
+
}
|
|
90
|
+
|
|
85
91
|
protected build(env: Env): RunnerRuntime {
|
|
86
|
-
const approvals = approvalStoreFactoryFor(env.DB).
|
|
92
|
+
const approvals = approvalStoreFactoryFor(env.DB).store();
|
|
87
93
|
const { createWorkflow, createStep, runtime } = init(env, {
|
|
88
94
|
requestContextForRun: approvalGrantProvider(approvals),
|
|
89
95
|
});
|
|
@@ -95,14 +101,28 @@ export class AppRunner extends DurableObjectRunner<Env> {
|
|
|
95
101
|
}
|
|
96
102
|
```
|
|
97
103
|
|
|
98
|
-
`init()` creates D1-backed Mastra storage from the conventional `DB` binding unless you inject storage. Workflow definitions use the same `createWorkflow()` and `createStep()` shape as Mastra.
|
|
104
|
+
`init()` creates D1-backed Mastra storage from the conventional `DB` binding unless you inject storage. Workflow definitions use the same `createWorkflow()` and `createStep()` shape as Mastra. Flowsafe pins `@mastra/cloudflare-d1` 1.1.1 so the minimum supported `@mastra/core` 1.50.0 peer can import and bundle without a consumer override.
|
|
105
|
+
|
|
106
|
+
If the deployment uses a table prefix, pass one shared constant to storage and host maintenance:
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
const storageTablePrefix = 'agent_';
|
|
110
|
+
|
|
111
|
+
const { runtime } = init(env, { tablePrefix: storageTablePrefix });
|
|
112
|
+
const worker = createFlowsafeWorker({
|
|
113
|
+
...workerConfig,
|
|
114
|
+
storageTablePrefix,
|
|
115
|
+
});
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
The prefix may be empty or must start with an ASCII letter or underscore and continue with ASCII letters, numbers, or underscores. It can contain at most 39 characters because Mastra limits final table identifiers to 63 characters and `mastra_workflow_snapshot` uses the remaining 24. All six exported low-level purge functions validate the same contract before preparing D1 statements. `storageTablePrefix` is not auto-discovered and must match the `tablePrefix` used by `init()` or `createD1Storage()`.
|
|
99
119
|
|
|
100
120
|
## Approval lifecycle
|
|
101
121
|
|
|
102
122
|
When a workflow or durable agent suspends:
|
|
103
123
|
|
|
104
124
|
1. The authoritative run summary captures `stepPath`, `suspendedAt`, and `resumeCount`.
|
|
105
|
-
2. The trusted host bridge creates one open approval in
|
|
125
|
+
2. The trusted host bridge creates one open approval in the deployment store.
|
|
106
126
|
3. The record's connector IDs and optional Mastra `toolCallId` come from a server-authored suspend payload.
|
|
107
127
|
4. A reviewer claims, delegates, approves, or rejects through the service or REST router.
|
|
108
128
|
5. A compare-and-swap commits the mutation.
|
|
@@ -138,9 +158,9 @@ Self-decision is denied by default. A non-exempt actor also cannot approve a lat
|
|
|
138
158
|
|
|
139
159
|
### SLA, notifications, and retention
|
|
140
160
|
|
|
141
|
-
`sweepSLA()` accepts the
|
|
161
|
+
`sweepSLA()` accepts the deployment store and escalates overdue open records. It is intended for a scheduled invocation and is not an HTTP service method.
|
|
142
162
|
|
|
143
|
-
`ApprovalNotificationSink` receives creation and escalation events. Failures are contained and audited. `ApprovalStreamSink` publishes mutations to the optional
|
|
163
|
+
`ApprovalNotificationSink` receives creation and escalation events. Failures are contained and audited. `ApprovalStreamSink` publishes mutations to the optional deployment hub.
|
|
144
164
|
|
|
145
165
|
`purgeExpiredApprovals()` deletes only approved and rejected records past the configured age. Pending, claimed, and escalated records remain live at any age.
|
|
146
166
|
|
|
@@ -180,39 +200,51 @@ The package includes:
|
|
|
180
200
|
|
|
181
201
|
Flowsafe has no Astryx or CSS dependency. The repository showcase injects Astryx in the application only.
|
|
182
202
|
|
|
183
|
-
##
|
|
203
|
+
## Physical deployment isolation
|
|
204
|
+
|
|
205
|
+
Flowsafe serves one organization per Worker, D1 database, and set of Durable Object namespaces. It does not provide a pooled multi-tenant mode.
|
|
206
|
+
|
|
207
|
+
### Deployment identity fails closed
|
|
184
208
|
|
|
185
|
-
|
|
209
|
+
Provisioning writes the same stable tag to the `DEPLOYMENT_TENANT` binding and the singleton `flowsafe_deployment` D1 row. The Worker checks the pair before protected routes and maintenance work. Every Worker topology stamps `DEPLOYMENT_IDENTITY_SECRET` on Durable Object requests; the target compares the credential and validates its own tag and sentinel before reading storage.
|
|
186
210
|
|
|
187
|
-
|
|
211
|
+
Seed the sentinel before application migrations or traffic. First-time provisioning refuses any database that already contains application tables. A missing binding, malformed sentinel schema, non-singleton row set, malformed tag, credential mismatch, or tag mismatch returns `503` at the Worker or prevents Durable Object initialization.
|
|
188
212
|
|
|
189
|
-
The
|
|
213
|
+
The package ships the `flowsafe-provision` CLI. It resolves Wrangler 4 from the application instead of downloading a CLI at runtime:
|
|
190
214
|
|
|
191
|
-
|
|
215
|
+
```bash
|
|
216
|
+
npm install --save-dev wrangler@^4
|
|
217
|
+
npx flowsafe-provision \
|
|
218
|
+
--database <database> \
|
|
219
|
+
--tag <tag> \
|
|
220
|
+
--remote \
|
|
221
|
+
--config wrangler.jsonc
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Fleet control planes can import the same fail-closed sentinel implementation from `@proofoftech/flowsafe/deployment-identity-protocol` instead of duplicating its schema or race handling.
|
|
192
225
|
|
|
193
|
-
###
|
|
226
|
+
### Runtime ids are opaque
|
|
194
227
|
|
|
195
|
-
`
|
|
228
|
+
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.
|
|
196
229
|
|
|
197
|
-
|
|
230
|
+
### Stores are deployment-wide
|
|
198
231
|
|
|
199
|
-
|
|
232
|
+
`D1ApprovalStoreFactory.store()` and `D1SubscriptionStoreFactory.store()` return the store for the bound database. Tables and indexes contain no tenant column. Legacy pooled schemas require a fresh database.
|
|
200
233
|
|
|
201
|
-
|
|
234
|
+
`D1ApprovalStoreFactory.resources()` records ownership of server-minted runs, threads, and schedules plus validated host-owned resource keys. Operators and builders can access only their principal's resources; reviewers and viewers can read existing resources; admins can administer them. Inaccessible resources return `404` before role errors.
|
|
202
235
|
|
|
203
|
-
|
|
236
|
+
`deploymentTag` is audit attribution only. It comes from verified infrastructure and never authorizes a request or scopes a query.
|
|
204
237
|
|
|
205
|
-
## Memory
|
|
238
|
+
## Memory and retention
|
|
206
239
|
|
|
207
|
-
Mastra memory ids are caller-chosen by default.
|
|
240
|
+
Mastra memory ids are caller-chosen by default. A Flowsafe host must:
|
|
208
241
|
|
|
209
|
-
- mint threads with `
|
|
210
|
-
-
|
|
242
|
+
- mint threads with `ActorContext.newThreadId()`;
|
|
243
|
+
- validate host-owned resource keys with `ActorContext.resourceIdFromKey(key)`;
|
|
211
244
|
- reject client bodies that name memory ids;
|
|
212
|
-
- return 404 for foreign stored ids;
|
|
213
245
|
- reach a thread Durable Object only through `createThreadTopology()`.
|
|
214
246
|
|
|
215
|
-
|
|
247
|
+
TTL retention helpers cover:
|
|
216
248
|
|
|
217
249
|
- terminal workflow snapshots;
|
|
218
250
|
- decided approvals;
|
|
@@ -222,9 +254,7 @@ Retention helpers cover:
|
|
|
222
254
|
- schedule trigger history;
|
|
223
255
|
- terminal background tasks.
|
|
224
256
|
|
|
225
|
-
Schedules, resources
|
|
226
|
-
|
|
227
|
-
`purgeTenant()` deletes every adopted tenant domain. Pass the artifact store so R2 objects delete with their owning run rows.
|
|
257
|
+
Schedules, resources, working memory, and provider subscriptions are standing state. The schedule and subscription routes support authorized deletion. Flowsafe does not ship a public resource or permanent thread-deletion route: a host that adds one must remove every authoritative binding and wake source before it calls `ActorContext.releaseResource()` for the thread or resource claim. Run retention and schedule deletion release their ownership claims; idle-thread retention deliberately does not. Deployment decommissioning removes any remainder. TTL retention, explicit teardown, and decommissioning are separate lifecycle mechanisms.
|
|
228
258
|
|
|
229
259
|
## Artifacts
|
|
230
260
|
|
|
@@ -234,7 +264,18 @@ Schedules, resources/working memory, and provider subscriptions are standing sta
|
|
|
234
264
|
[prefix/]workflowId/runId/name
|
|
235
265
|
```
|
|
236
266
|
|
|
237
|
-
Workflow and run ids use the runner's path-safe pattern. Artifact names are validated segment by segment. `deleteRun()` pairs with terminal-run retention
|
|
267
|
+
Workflow and run ids use the runner's path-safe pattern. Artifact names are validated segment by segment. `deleteRun()` pairs with terminal-run retention. Deployment decommissioning removes the remaining bucket data.
|
|
268
|
+
|
|
269
|
+
Construct the retention store from the current maintenance invocation's environment. A module-scoped Worker configuration can safely retain the factory, but must not retain an invocation-specific R2 binding:
|
|
270
|
+
|
|
271
|
+
```typescript
|
|
272
|
+
const worker = createFlowsafeWorker({
|
|
273
|
+
...workerConfig,
|
|
274
|
+
artifactStore: (env) => new R2ArtifactStore(env.ARTIFACTS),
|
|
275
|
+
});
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
The factory and artifact deletion run inside the snapshot-retention failure boundary. Either failure preserves the snapshot row for retry and does not stop sibling maintenance duties. Omitting the factory or returning `undefined` keeps row-only retention.
|
|
238
279
|
|
|
239
280
|
`InMemoryArtifactBucket` is available for tests and offline demos.
|
|
240
281
|
|
|
@@ -242,13 +283,15 @@ Workflow and run ids use the runner's path-safe pattern. Artifact names are vali
|
|
|
242
283
|
|
|
243
284
|
`queueAuditSink(queue)` turns the shared audit contract into Cloudflare Queue messages. `createAuditQueueConsumer()` batches records as NDJSON, posts them to the configured collector, acknowledges the batch on 2xx, and retries otherwise.
|
|
244
285
|
|
|
286
|
+
For an externally authored fleet release, do not expose that shared Queue binding to the candidate. Bind the candidate to the trusted state Worker as `AUDIT_PROXY` and enable the matching candidate and trusted-ingress fleet markers. The adapter authenticates with the deployment identity; trusted state supplies canonical tenant, environment, and script attribution before enqueueing. The envelope marks the candidate event itself as untrusted, so its action, decision, resource, and detail remain claims rather than infrastructure attestations.
|
|
287
|
+
|
|
245
288
|
The types are structural and do not require `@cloudflare/workers-types`. A transform seam can map internal events to your SIEM schema.
|
|
246
289
|
|
|
247
290
|
## Live streaming
|
|
248
291
|
|
|
249
292
|
Live updates are opt-in behind a `HUB` Durable Object binding and `STREAM_TICKET_SECRET`.
|
|
250
293
|
|
|
251
|
-
An authenticated REST request mints a short-lived HMAC ticket. The browser presents it when opening a queue or run WebSocket. The Worker is the only verifier
|
|
294
|
+
An authenticated REST request mints a short-lived HMAC ticket. The browser presents it when opening a queue or run WebSocket. The Worker is the only verifier. The singleton hub and each run Durable Object rebind the addressed channel through their own identities.
|
|
252
295
|
|
|
253
296
|
Tickets carry addressing information only. They contain no connector grant or approval decision. Polling remains available as fallback and reconciliation.
|
|
254
297
|
|
|
@@ -288,17 +331,17 @@ Agent event replay lasts only as long as the configured Mastra cache. The defaul
|
|
|
288
331
|
|
|
289
332
|
### Schedules
|
|
290
333
|
|
|
291
|
-
`D1SchedulesStorage` implements the schedule domain. `createScheduleRouter()` provides
|
|
334
|
+
`D1SchedulesStorage` implements the schedule domain. `createScheduleRouter()` provides deployment-wide role-gated CRUD and read-only trigger history. `createScheduleTick()` claims due fires with compare-and-swap (CAS), protects reserved context keys, consults the configured unattended-run cap, mints an opaque run id, and starts a workflow or agent through the correct topology. Without the optional cap seam, unattended starts are uncapped.
|
|
292
335
|
|
|
293
336
|
### Background tasks
|
|
294
337
|
|
|
295
|
-
`createBackgroundTaskD1Domains()` supplies serialized workflow and
|
|
338
|
+
`createBackgroundTaskD1Domains()` supplies serialized workflow and deployment task storage. `BackgroundTaskHost` owns one singleton manager Durable Object, while `createBackgroundTaskRoutes()` exposes its host surface. Terminal task cleanup is opt-in through the composed Worker.
|
|
296
339
|
|
|
297
340
|
### Signal providers
|
|
298
341
|
|
|
299
342
|
Flowsafe providers route polling and webhook deliveries through the thread topology instead of Mastra's in-process registry.
|
|
300
343
|
|
|
301
|
-
`SignalProviderHost` runs one alarm-driven host per
|
|
344
|
+
`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.
|
|
302
345
|
|
|
303
346
|
`githubSignalProvider()` is the reference provider.
|
|
304
347
|
|
|
@@ -306,9 +349,9 @@ Complete wiring is in the [durable-agents guide](https://github.com/ProofOfTechO
|
|
|
306
349
|
|
|
307
350
|
## Deployment and operations
|
|
308
351
|
|
|
309
|
-
The composed `createFlowsafeWorker()` owns the shared route
|
|
352
|
+
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.
|
|
310
353
|
|
|
311
|
-
|
|
354
|
+
`createFlowsafeMaintenanceDurableObject()` runs 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.
|
|
312
355
|
|
|
313
356
|
Read:
|
|
314
357
|
|
|
@@ -322,19 +365,23 @@ Flowsafe does not authenticate users, execute an identity-provider protocol, pro
|
|
|
322
365
|
|
|
323
366
|
Critical host obligations:
|
|
324
367
|
|
|
325
|
-
-
|
|
326
|
-
-
|
|
368
|
+
- deploy one Worker, D1 database, and set of Durable Object namespaces per organization;
|
|
369
|
+
- seed `flowsafe_deployment` before application migrations, configure `DEPLOYMENT_TENANT`, and keep the values identical;
|
|
370
|
+
- set a distinct `DEPLOYMENT_IDENTITY_SECRET` for internal Durable Object calls;
|
|
371
|
+
- set a separate `MAINTENANCE_ADMIN_SECRET`, bootstrap the fixed maintenance singleton after deploy, and monitor its alarm status; for externally authored releases, keep that secret only in trusted state and relay short-lived signed capabilities through the candidate;
|
|
372
|
+
- derive actors and roles from verified credentials;
|
|
373
|
+
- mint run, thread, schedule, and subscription identities server-side, validate host-owned resource keys, and preserve their principal ownership records;
|
|
327
374
|
- keep connector lists and agent resume targets server-authored;
|
|
328
375
|
- persist the original authorized agent requester and resume execution as that principal;
|
|
329
376
|
- expose decisions only through the approval path;
|
|
330
377
|
- configure shared stores for cross-isolate connector budgets;
|
|
331
378
|
- keep raw Durable Object namespaces behind the exported topologies;
|
|
332
|
-
- schedule every enabled domain's retention and
|
|
379
|
+
- schedule every enabled domain's retention path and define deployment decommissioning;
|
|
333
380
|
- protect model, provider, stream-ticket, webhook, and SIEM secrets separately.
|
|
334
381
|
|
|
335
382
|
## Verification
|
|
336
383
|
|
|
337
|
-
The repository's deterministic workerd spike proves suspend, process restart, resume, forged-resume denial, repeated gates,
|
|
384
|
+
The repository's deterministic workerd spike proves suspend, process restart, resume, forged-resume denial, repeated gates, deployment-sentinel mismatch refusal, live streaming, durable-agent recovery, signals, goals, schedules, providers, notifications, and background-task restart. Durable Object conformance suites separately cover wrong and missing internal caller credentials.
|
|
338
385
|
|
|
339
386
|
```bash
|
|
340
387
|
pnpm --filter @proofoftech/flowsafe spike:verify
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
|
|
3
|
+
export interface DeploymentIdentityProtocolStatement {
|
|
4
|
+
readonly mode: 'read' | 'write';
|
|
5
|
+
readonly sql: string;
|
|
6
|
+
readonly bindings: readonly string[];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type DeploymentIdentityProtocolRow = Readonly<Record<string, unknown>>;
|
|
10
|
+
|
|
11
|
+
export type DeploymentIdentityProtocolExecutor = (
|
|
12
|
+
statement: DeploymentIdentityProtocolStatement,
|
|
13
|
+
) => Promise<readonly DeploymentIdentityProtocolRow[]>;
|
|
14
|
+
|
|
15
|
+
export const DEPLOYMENT_TAG_PATTERN: RegExp;
|
|
16
|
+
export const DEPLOYMENT_ENVIRONMENT_PATTERN: RegExp;
|
|
17
|
+
export const DEPLOYMENT_SENTINEL_TABLE: 'flowsafe_deployment';
|
|
18
|
+
export const DEPLOYMENT_SENTINEL_DDL: string;
|
|
19
|
+
export const DEPLOYMENT_SENTINEL_COLUMNS: readonly Readonly<{
|
|
20
|
+
name: string;
|
|
21
|
+
type: string;
|
|
22
|
+
notnull: number;
|
|
23
|
+
pk: number;
|
|
24
|
+
}>[];
|
|
25
|
+
|
|
26
|
+
export class DeploymentIdentityError extends Error {}
|
|
27
|
+
|
|
28
|
+
export function isDeploymentEnvironment(value: unknown): value is string;
|
|
29
|
+
|
|
30
|
+
export function assertValidDeploymentTag(
|
|
31
|
+
tag: unknown,
|
|
32
|
+
caller: string,
|
|
33
|
+
): asserts tag is string;
|
|
34
|
+
|
|
35
|
+
export function normalizeDeploymentSentinelSql(sql: string): string;
|
|
36
|
+
|
|
37
|
+
export function deploymentIdentityApplicationTables(
|
|
38
|
+
rows: readonly DeploymentIdentityProtocolRow[],
|
|
39
|
+
): string[];
|
|
40
|
+
|
|
41
|
+
export function readDeploymentIdentityProtocol(
|
|
42
|
+
execute: DeploymentIdentityProtocolExecutor,
|
|
43
|
+
): Promise<string | undefined>;
|
|
44
|
+
|
|
45
|
+
export function provisionDeploymentIdentityProtocol(
|
|
46
|
+
execute: DeploymentIdentityProtocolExecutor,
|
|
47
|
+
tag: string,
|
|
48
|
+
options?: {
|
|
49
|
+
caller?: string;
|
|
50
|
+
provisionedAt?: string;
|
|
51
|
+
},
|
|
52
|
+
): Promise<void>;
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
|
|
3
|
+
export const DEPLOYMENT_TAG_PATTERN = /^[a-z0-9]{3,32}$/;
|
|
4
|
+
export const DEPLOYMENT_ENVIRONMENT_PATTERN =
|
|
5
|
+
/^[a-z0-9](?:[a-z0-9-]{0,30}[a-z0-9])?$/;
|
|
6
|
+
export const DEPLOYMENT_SENTINEL_TABLE = 'flowsafe_deployment';
|
|
7
|
+
export const DEPLOYMENT_SENTINEL_DDL = `CREATE TABLE IF NOT EXISTS ${DEPLOYMENT_SENTINEL_TABLE} (
|
|
8
|
+
id INTEGER PRIMARY KEY CHECK (id = 1),
|
|
9
|
+
tenant_tag TEXT NOT NULL,
|
|
10
|
+
provisioned_at TEXT NOT NULL
|
|
11
|
+
)`;
|
|
12
|
+
export const DEPLOYMENT_SENTINEL_COLUMNS = Object.freeze([
|
|
13
|
+
Object.freeze({ name: 'id', type: 'INTEGER', notnull: 0, pk: 1 }),
|
|
14
|
+
Object.freeze({ name: 'tenant_tag', type: 'TEXT', notnull: 1, pk: 0 }),
|
|
15
|
+
Object.freeze({
|
|
16
|
+
name: 'provisioned_at',
|
|
17
|
+
type: 'TEXT',
|
|
18
|
+
notnull: 1,
|
|
19
|
+
pk: 0,
|
|
20
|
+
}),
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
const SENTINEL_SQL_PATTERN =
|
|
24
|
+
/^create table (?:if not exists )?flowsafe_deployment\s*\(\s*id integer primary key check\s*\(\s*id\s*=\s*1\s*\)\s*,\s*tenant_tag text not null\s*,\s*provisioned_at text not null\s*\)$/i;
|
|
25
|
+
const D1_OWNED_INTERNAL_TABLES = Object.freeze(['_cf_KV', '_cf_METADATA']);
|
|
26
|
+
const D1_OWNED_TABLE_EXCLUSIONS = D1_OWNED_INTERNAL_TABLES.map(
|
|
27
|
+
(name) => ` AND name <> '${name}'`,
|
|
28
|
+
).join('\n');
|
|
29
|
+
|
|
30
|
+
const SCAN_TABLES = Object.freeze({
|
|
31
|
+
mode: 'read',
|
|
32
|
+
sql: `SELECT name, sql FROM sqlite_schema WHERE type = 'table' ORDER BY name`,
|
|
33
|
+
bindings: Object.freeze([]),
|
|
34
|
+
});
|
|
35
|
+
const READ_SENTINEL_SCHEMA = Object.freeze({
|
|
36
|
+
mode: 'read',
|
|
37
|
+
sql: `SELECT sql FROM sqlite_schema WHERE type = 'table' AND name = ?`,
|
|
38
|
+
bindings: Object.freeze([DEPLOYMENT_SENTINEL_TABLE]),
|
|
39
|
+
});
|
|
40
|
+
const READ_SENTINEL_COLUMNS = Object.freeze({
|
|
41
|
+
mode: 'read',
|
|
42
|
+
sql: `PRAGMA table_info(${DEPLOYMENT_SENTINEL_TABLE})`,
|
|
43
|
+
bindings: Object.freeze([]),
|
|
44
|
+
});
|
|
45
|
+
const READ_SENTINEL_OWNER = Object.freeze({
|
|
46
|
+
mode: 'read',
|
|
47
|
+
sql: `SELECT id, tenant_tag FROM ${DEPLOYMENT_SENTINEL_TABLE} ORDER BY id`,
|
|
48
|
+
bindings: Object.freeze([]),
|
|
49
|
+
});
|
|
50
|
+
const CREATE_SENTINEL = Object.freeze({
|
|
51
|
+
mode: 'write',
|
|
52
|
+
sql: DEPLOYMENT_SENTINEL_DDL,
|
|
53
|
+
bindings: Object.freeze([]),
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
export class DeploymentIdentityError extends Error {
|
|
57
|
+
constructor(message) {
|
|
58
|
+
super(message);
|
|
59
|
+
this.name = 'DeploymentIdentityError';
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function isDeploymentEnvironment(value) {
|
|
64
|
+
return (
|
|
65
|
+
typeof value === 'string' && DEPLOYMENT_ENVIRONMENT_PATTERN.test(value)
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function assertValidDeploymentTag(tag, caller) {
|
|
70
|
+
if (typeof tag !== 'string' || !DEPLOYMENT_TAG_PATTERN.test(tag)) {
|
|
71
|
+
throw new DeploymentIdentityError(
|
|
72
|
+
`${caller}: deployment tag '${String(tag)}' must match ${DEPLOYMENT_TAG_PATTERN} — fix the DEPLOYMENT_TENANT binding or the provisioning input`,
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function normalizeDeploymentSentinelSql(sql) {
|
|
78
|
+
return sql.replace(/\s+/g, ' ').trim();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function deploymentIdentityApplicationTables(rows) {
|
|
82
|
+
return rows
|
|
83
|
+
.map((row) => rowField(row, 'name'))
|
|
84
|
+
.filter(
|
|
85
|
+
(name) =>
|
|
86
|
+
typeof name === 'string' &&
|
|
87
|
+
name !== DEPLOYMENT_SENTINEL_TABLE &&
|
|
88
|
+
!name.startsWith('sqlite_') &&
|
|
89
|
+
!D1_OWNED_INTERNAL_TABLES.includes(name),
|
|
90
|
+
)
|
|
91
|
+
.sort();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function rowField(row, name) {
|
|
95
|
+
return row !== null && typeof row === 'object' ? row[name] : undefined;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function malformedSentinel(reason) {
|
|
99
|
+
return new DeploymentIdentityError(
|
|
100
|
+
`${DEPLOYMENT_SENTINEL_TABLE} has an invalid ownership schema (${reason}) — recreate the database before serving`,
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function assertSentinelSchemaDefinition(rows) {
|
|
105
|
+
const sql = rowField(rows[0], 'sql');
|
|
106
|
+
if (rows.length !== 1 || typeof sql !== 'string') {
|
|
107
|
+
throw malformedSentinel('table definition is missing or ambiguous');
|
|
108
|
+
}
|
|
109
|
+
if (!SENTINEL_SQL_PATTERN.test(normalizeDeploymentSentinelSql(sql))) {
|
|
110
|
+
throw malformedSentinel('table definition differs from the owned schema');
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function assertSentinelColumns(rows) {
|
|
115
|
+
if (rows.length !== DEPLOYMENT_SENTINEL_COLUMNS.length) {
|
|
116
|
+
throw malformedSentinel('unexpected columns');
|
|
117
|
+
}
|
|
118
|
+
for (let index = 0; index < DEPLOYMENT_SENTINEL_COLUMNS.length; index += 1) {
|
|
119
|
+
const actual = rows[index];
|
|
120
|
+
const expected = DEPLOYMENT_SENTINEL_COLUMNS[index];
|
|
121
|
+
if (
|
|
122
|
+
rowField(actual, 'name') !== expected.name ||
|
|
123
|
+
String(rowField(actual, 'type')).toUpperCase() !== expected.type ||
|
|
124
|
+
Number(rowField(actual, 'notnull')) !== expected.notnull ||
|
|
125
|
+
Number(rowField(actual, 'pk')) !== expected.pk
|
|
126
|
+
) {
|
|
127
|
+
throw malformedSentinel(`column ${expected.name} differs`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function conditionalOwnershipInsert(tag, provisionedAt) {
|
|
133
|
+
return {
|
|
134
|
+
mode: 'write',
|
|
135
|
+
sql: `INSERT OR IGNORE INTO ${DEPLOYMENT_SENTINEL_TABLE} (id, tenant_tag, provisioned_at)
|
|
136
|
+
SELECT 1, ?, ?
|
|
137
|
+
WHERE NOT EXISTS (
|
|
138
|
+
SELECT 1 FROM sqlite_schema
|
|
139
|
+
WHERE type = 'table'
|
|
140
|
+
AND name <> '${DEPLOYMENT_SENTINEL_TABLE}'
|
|
141
|
+
${D1_OWNED_TABLE_EXCLUSIONS}
|
|
142
|
+
AND name NOT GLOB 'sqlite_*'
|
|
143
|
+
)`,
|
|
144
|
+
bindings: [tag, provisionedAt],
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async function scanTables(execute) {
|
|
149
|
+
return execute(SCAN_TABLES);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export async function readDeploymentIdentityProtocol(execute) {
|
|
153
|
+
const schema = await execute(READ_SENTINEL_SCHEMA);
|
|
154
|
+
if (schema.length === 0) return undefined;
|
|
155
|
+
assertSentinelSchemaDefinition(schema);
|
|
156
|
+
assertSentinelColumns(await execute(READ_SENTINEL_COLUMNS));
|
|
157
|
+
|
|
158
|
+
const owners = await execute(READ_SENTINEL_OWNER);
|
|
159
|
+
if (owners.length === 0) return undefined;
|
|
160
|
+
if (owners.length !== 1 || Number(rowField(owners[0], 'id')) !== 1) {
|
|
161
|
+
throw malformedSentinel('the ownership row is not an exact singleton');
|
|
162
|
+
}
|
|
163
|
+
const tag = rowField(owners[0], 'tenant_tag');
|
|
164
|
+
if (typeof tag !== 'string' || !DEPLOYMENT_TAG_PATTERN.test(tag)) {
|
|
165
|
+
throw malformedSentinel('tenant_tag is malformed');
|
|
166
|
+
}
|
|
167
|
+
return tag;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function unownedDatabaseError(caller, applicationTables) {
|
|
171
|
+
return new DeploymentIdentityError(
|
|
172
|
+
`${caller}: unowned database already contains application tables (${applicationTables.join(', ')}) — provision a fresh database instead of adopting pooled or unknown state`,
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function differentOwnerError(caller, stored, tag) {
|
|
177
|
+
return new DeploymentIdentityError(
|
|
178
|
+
`${caller}: database already belongs to deployment '${stored}' — refusing to re-stamp it as '${tag}' (decommission and recreate instead)`,
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export async function provisionDeploymentIdentityProtocol(
|
|
183
|
+
execute,
|
|
184
|
+
tag,
|
|
185
|
+
{ caller = 'seedDeploymentIdentity', provisionedAt } = {},
|
|
186
|
+
) {
|
|
187
|
+
assertValidDeploymentTag(tag, caller);
|
|
188
|
+
const tables = await scanTables(execute);
|
|
189
|
+
const applicationTables = deploymentIdentityApplicationTables(tables);
|
|
190
|
+
const sentinelExists = tables.some(
|
|
191
|
+
(row) => rowField(row, 'name') === DEPLOYMENT_SENTINEL_TABLE,
|
|
192
|
+
);
|
|
193
|
+
const storedBeforeCreate = await readDeploymentIdentityProtocol(execute);
|
|
194
|
+
if (storedBeforeCreate !== undefined) {
|
|
195
|
+
if (storedBeforeCreate !== tag) {
|
|
196
|
+
throw differentOwnerError(caller, storedBeforeCreate, tag);
|
|
197
|
+
}
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
if (applicationTables.length > 0) {
|
|
201
|
+
throw unownedDatabaseError(caller, applicationTables);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (!sentinelExists) await execute(CREATE_SENTINEL);
|
|
205
|
+
const storedAfterCreate = await readDeploymentIdentityProtocol(execute);
|
|
206
|
+
if (storedAfterCreate !== undefined) {
|
|
207
|
+
if (storedAfterCreate !== tag) {
|
|
208
|
+
throw differentOwnerError(caller, storedAfterCreate, tag);
|
|
209
|
+
}
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
await execute(
|
|
214
|
+
conditionalOwnershipInsert(tag, provisionedAt ?? new Date().toISOString()),
|
|
215
|
+
);
|
|
216
|
+
const seeded = await readDeploymentIdentityProtocol(execute);
|
|
217
|
+
if (seeded === undefined) {
|
|
218
|
+
const racedApplicationTables = deploymentIdentityApplicationTables(
|
|
219
|
+
await scanTables(execute),
|
|
220
|
+
);
|
|
221
|
+
if (racedApplicationTables.length > 0) {
|
|
222
|
+
throw unownedDatabaseError(caller, racedApplicationTables);
|
|
223
|
+
}
|
|
224
|
+
throw new DeploymentIdentityError(
|
|
225
|
+
`${caller}: database sentinel is missing or malformed after seeding — recreate the database before serving`,
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
if (seeded !== tag) {
|
|
229
|
+
throw differentOwnerError(caller, seeded, tag);
|
|
230
|
+
}
|
|
231
|
+
}
|