@proofoftech/flowsafe 0.10.0 → 0.12.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 +50 -0
- package/README.md +77 -47
- 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.d.ts +1 -1
- package/dist/agent-host/catalog.d.ts.map +1 -1
- package/dist/agent-host/catalog.js +26 -2
- package/dist/agent-host/catalog.js.map +1 -1
- package/dist/agent-host/index.d.ts +4 -3
- package/dist/agent-host/index.d.ts.map +1 -1
- package/dist/agent-host/index.js +1 -0
- 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 +53 -9
- package/dist/agent-host/thread-host.d.ts.map +1 -1
- package/dist/agent-host/thread-host.js +624 -109
- 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 +9 -2
- package/dist/agent-host/trusted-context.js.map +1 -1
- package/dist/agent-host/types.d.ts +48 -0
- package/dist/agent-host/types.d.ts.map +1 -1
- package/dist/agent-host/types.js +1 -1
- package/dist/agent-host/types.js.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 +13 -24
- package/dist/approval-api/contract.d.ts.map +1 -1
- package/dist/approval-api/contract.js +1 -1
- package/dist/approval-api/contract.js.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 +9 -9
- package/dist/approval-api/index.d.ts.map +1 -1
- package/dist/approval-api/index.js +6 -6
- 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 +16 -5
- package/dist/do-runner/breakwater-keys.d.ts.map +1 -1
- package/dist/do-runner/breakwater-keys.js +16 -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 +44 -182
- package/dist/do-runner/d1-storage.d.ts.map +1 -1
- package/dist/do-runner/d1-storage.js +102 -353
- 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 +6 -8
- 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/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 +149 -73
- package/dist/host-kit/flowsafe-worker.d.ts.map +1 -1
- package/dist/host-kit/flowsafe-worker.js +619 -141
- 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 +30 -7
- 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,55 @@
|
|
|
1
1
|
# @proofoftech/flowsafe
|
|
2
2
|
|
|
3
|
+
## 0.12.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 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.
|
|
8
|
+
|
|
9
|
+
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.
|
|
10
|
+
|
|
11
|
+
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.
|
|
12
|
+
|
|
13
|
+
- b3b4b55: Replace pooled request-level tenancy with one physically isolated organization per deployment.
|
|
14
|
+
|
|
15
|
+
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.
|
|
16
|
+
|
|
17
|
+
`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.
|
|
18
|
+
|
|
19
|
+
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.
|
|
20
|
+
|
|
21
|
+
`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`.
|
|
22
|
+
|
|
23
|
+
`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`.
|
|
24
|
+
|
|
25
|
+
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.
|
|
26
|
+
|
|
27
|
+
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.
|
|
28
|
+
|
|
29
|
+
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.
|
|
30
|
+
|
|
31
|
+
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.
|
|
32
|
+
|
|
33
|
+
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.
|
|
34
|
+
|
|
35
|
+
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.
|
|
36
|
+
|
|
37
|
+
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.
|
|
38
|
+
|
|
39
|
+
## 0.11.0
|
|
40
|
+
|
|
41
|
+
### Minor Changes
|
|
42
|
+
|
|
43
|
+
- 52d6836: Add server-owned, fine-grained permission resolution to the guarded agent host.
|
|
44
|
+
|
|
45
|
+
Agents can declare `requiredPermissions` with all-of semantics. The thread host resolves effective permissions from the trusted human or automated principal, records the required identifiers and policy version in authorization audit detail, and denies execution when any permission is missing. Agents that use only `allowedRoles` and `allowedAutomation` keep their existing behavior and do not require or invoke a resolver.
|
|
46
|
+
|
|
47
|
+
- d78e779: Project server-resolved principal permissions into trusted agent-run context.
|
|
48
|
+
|
|
49
|
+
The thread agent host now runs a configured `resolvePrincipalPermissions` on every authorized entry — role-only agents included — and mints the resolution into derived request context as `breakwater.principalPermissions` on every start and resume leg, where breakwater's connector `requiredPermissions` gate enforces it. When no resolution exists the host projects an explicit `null`, so a resume retires a stale persisted projection and permission-declaring connectors fail closed. A failed resolution still denies a permission-requiring agent; on a role-only agent it is audited as a new `agent.permissions.resolve` error event and the run proceeds without a projection.
|
|
50
|
+
|
|
51
|
+
`TrustedAgentExecution` gains a required `principalPermissions` field, `Permission` and `isPermissionIdentifier` are now re-exported from `@proofoftech/breakwater/rbac`, and the root/approval-api barrels export `BREAKWATER_PRINCIPAL_PERMISSIONS_KEY`. The optional `@proofoftech/breakwater` peer range moves to `>=0.9.0 <1.0.0` for the shared permission vocabulary.
|
|
52
|
+
|
|
3
53
|
## 0.10.0
|
|
4
54
|
|
|
5
55
|
### 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
|
|
|
@@ -27,7 +27,8 @@ Compatibility:
|
|
|
27
27
|
- TypeScript `moduleResolution: "NodeNext"`, `"Node16"`, or `"Bundler"`
|
|
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
|
-
- `@proofoftech/breakwater` `>=0.
|
|
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
|
});
|
|
@@ -102,12 +108,12 @@ export class AppRunner extends DurableObjectRunner<Env> {
|
|
|
102
108
|
When a workflow or durable agent suspends:
|
|
103
109
|
|
|
104
110
|
1. The authoritative run summary captures `stepPath`, `suspendedAt`, and `resumeCount`.
|
|
105
|
-
2. The trusted host bridge creates one open approval in
|
|
106
|
-
3. The record
|
|
111
|
+
2. The trusted host bridge creates one open approval in the deployment store.
|
|
112
|
+
3. The record's connector IDs and optional Mastra `toolCallId` come from a server-authored suspend payload.
|
|
107
113
|
4. A reviewer claims, delegates, approves, or rejects through the service or REST router.
|
|
108
114
|
5. A compare-and-swap commits the mutation.
|
|
109
115
|
6. An approval re-enters the owning runtime.
|
|
110
|
-
7. `approvalGrantProvider()` reads D1 and writes only the matching structured grants into the resumed leg
|
|
116
|
+
7. `approvalGrantProvider()` reads D1 and writes only the matching structured grants into the resumed leg's request context.
|
|
111
117
|
8. Another suspension creates a new approval. A completed or failed run ends the loop.
|
|
112
118
|
|
|
113
119
|
Durable-agent records produce `tool-call` scope. Workflow gates produce exact `suspension` scope. Trusted `runScoped` records produce explicit `run` scope. Grants never travel in public request bodies. A raw or forged resume finds no stored capability and fails at the Breakwater connector gate.
|
|
@@ -138,9 +144,9 @@ Self-decision is denied by default. A non-exempt actor also cannot approve a lat
|
|
|
138
144
|
|
|
139
145
|
### SLA, notifications, and retention
|
|
140
146
|
|
|
141
|
-
`sweepSLA()` accepts the
|
|
147
|
+
`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
148
|
|
|
143
|
-
`ApprovalNotificationSink` receives creation and escalation events. Failures are contained and audited. `ApprovalStreamSink` publishes mutations to the optional
|
|
149
|
+
`ApprovalNotificationSink` receives creation and escalation events. Failures are contained and audited. `ApprovalStreamSink` publishes mutations to the optional deployment hub.
|
|
144
150
|
|
|
145
151
|
`purgeExpiredApprovals()` deletes only approved and rejected records past the configured age. Pending, claimed, and escalated records remain live at any age.
|
|
146
152
|
|
|
@@ -180,39 +186,51 @@ The package includes:
|
|
|
180
186
|
|
|
181
187
|
Flowsafe has no Astryx or CSS dependency. The repository showcase injects Astryx in the application only.
|
|
182
188
|
|
|
183
|
-
##
|
|
189
|
+
## Physical deployment isolation
|
|
190
|
+
|
|
191
|
+
Flowsafe serves one organization per Worker, D1 database, and set of Durable Object namespaces. It does not provide a pooled multi-tenant mode.
|
|
192
|
+
|
|
193
|
+
### Deployment identity fails closed
|
|
184
194
|
|
|
185
|
-
|
|
195
|
+
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
196
|
|
|
187
|
-
|
|
197
|
+
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
198
|
|
|
189
|
-
The
|
|
199
|
+
The package ships the `flowsafe-provision` CLI. It resolves Wrangler 4 from the application instead of downloading a CLI at runtime:
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
npm install --save-dev wrangler@^4
|
|
203
|
+
npx flowsafe-provision \
|
|
204
|
+
--database <database> \
|
|
205
|
+
--tag <tag> \
|
|
206
|
+
--remote \
|
|
207
|
+
--config wrangler.jsonc
|
|
208
|
+
```
|
|
190
209
|
|
|
191
|
-
|
|
210
|
+
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
211
|
|
|
193
|
-
###
|
|
212
|
+
### Runtime ids are opaque
|
|
194
213
|
|
|
195
|
-
`
|
|
214
|
+
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
215
|
|
|
197
|
-
|
|
216
|
+
### Stores are deployment-wide
|
|
198
217
|
|
|
199
|
-
|
|
218
|
+
`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
219
|
|
|
201
|
-
|
|
220
|
+
`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
221
|
|
|
203
|
-
|
|
222
|
+
`deploymentTag` is audit attribution only. It comes from verified infrastructure and never authorizes a request or scopes a query.
|
|
204
223
|
|
|
205
|
-
## Memory
|
|
224
|
+
## Memory and retention
|
|
206
225
|
|
|
207
|
-
Mastra memory ids are caller-chosen by default.
|
|
226
|
+
Mastra memory ids are caller-chosen by default. A Flowsafe host must:
|
|
208
227
|
|
|
209
|
-
- mint threads with `
|
|
210
|
-
-
|
|
228
|
+
- mint threads with `ActorContext.newThreadId()`;
|
|
229
|
+
- validate host-owned resource keys with `ActorContext.resourceIdFromKey(key)`;
|
|
211
230
|
- reject client bodies that name memory ids;
|
|
212
|
-
- return 404 for foreign stored ids;
|
|
213
231
|
- reach a thread Durable Object only through `createThreadTopology()`.
|
|
214
232
|
|
|
215
|
-
|
|
233
|
+
TTL retention helpers cover:
|
|
216
234
|
|
|
217
235
|
- terminal workflow snapshots;
|
|
218
236
|
- decided approvals;
|
|
@@ -222,9 +240,7 @@ Retention helpers cover:
|
|
|
222
240
|
- schedule trigger history;
|
|
223
241
|
- terminal background tasks.
|
|
224
242
|
|
|
225
|
-
Schedules, resources
|
|
226
|
-
|
|
227
|
-
`purgeTenant()` deletes every adopted tenant domain. Pass the artifact store so R2 objects delete with their owning run rows.
|
|
243
|
+
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
244
|
|
|
229
245
|
## Artifacts
|
|
230
246
|
|
|
@@ -234,7 +250,7 @@ Schedules, resources/working memory, and provider subscriptions are standing sta
|
|
|
234
250
|
[prefix/]workflowId/runId/name
|
|
235
251
|
```
|
|
236
252
|
|
|
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
|
|
253
|
+
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.
|
|
238
254
|
|
|
239
255
|
`InMemoryArtifactBucket` is available for tests and offline demos.
|
|
240
256
|
|
|
@@ -242,13 +258,15 @@ Workflow and run ids use the runner's path-safe pattern. Artifact names are vali
|
|
|
242
258
|
|
|
243
259
|
`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
260
|
|
|
261
|
+
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.
|
|
262
|
+
|
|
245
263
|
The types are structural and do not require `@cloudflare/workers-types`. A transform seam can map internal events to your SIEM schema.
|
|
246
264
|
|
|
247
265
|
## Live streaming
|
|
248
266
|
|
|
249
267
|
Live updates are opt-in behind a `HUB` Durable Object binding and `STREAM_TICKET_SECRET`.
|
|
250
268
|
|
|
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
|
|
269
|
+
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
270
|
|
|
253
271
|
Tickets carry addressing information only. They contain no connector grant or approval decision. Polling remains available as fallback and reconciliation.
|
|
254
272
|
|
|
@@ -260,9 +278,17 @@ The following surfaces are supported and opt-in: they are tested and covered by
|
|
|
260
278
|
|
|
261
279
|
Use `@proofoftech/flowsafe/agent-host` for a public protected surface. `createAgentRouter()` lists server-owned metadata and exposes authenticated start, status, and newline-delimited JSON observation routes. The router mints every ID and rejects trusted context and execution overrides. Authenticated human starts must satisfy both the global start roles and the selected agent's `allowedRoles`. Automated entry uses trusted host paths instead: it never consults human roles and requires a matching principal kind and entry path in the selected agent's `allowedAutomation`.
|
|
262
280
|
|
|
281
|
+
Agents can add `AgentMeta.requiredPermissions` as an all-of list of `Permission` identifiers. Each identifier uses canonical lowercase dotted form. Catalog construction rejects a non-array, an empty list, duplicates, and malformed identifiers.
|
|
282
|
+
|
|
283
|
+
Configure `ThreadAgentHostOptions.resolvePrincipalPermissions` with a server-owned `PrincipalPermissionResolver`. The resolver receives only the trusted `ExecutionPrincipal` and returns a `PrincipalPermissionResolution` containing effective permissions and `policyVersion`. The host evaluates permissions after the existing human-role or automated-entry gate. A missing resolver, a resolver failure, or malformed output denies an agent that requires permissions.
|
|
284
|
+
|
|
285
|
+
A configured resolver runs on every authorized entry, and its resolution is projected into the run's derived request context as `breakwater.principalPermissions` on every start and resume leg (an explicit `null` when no resolution exists). Breakwater connectors that declare `PermissionManifest.requiredPermissions` enforce their own all-of list against that projection before their dry-run branch and approval grant. Agents that use only `allowedRoles` and `allowedAutomation` invoke a configured resolver but do not require it: a failed resolution still starts the run, is audited as `agent.permissions.resolve`, and leaves the projection `null`, so permission-declaring connectors inside that run fail closed.
|
|
286
|
+
|
|
287
|
+
Permission authorization audit detail records `requiredPermissions` and `permissionPolicyVersion`; it does not record effective permissions or identity-provider groups.
|
|
288
|
+
|
|
263
289
|
`createThreadAgentHost()` validates Breakwater's guarded-handle brand before it registers the agent with Mastra. It persists the thread/agent binding and original run principal, so eviction recovery and approval resume cannot switch agents or actors.
|
|
264
290
|
|
|
265
|
-
Agent resume is approval-only. `createAgentApprovalResumer()` rejects legacy agent targets without the original principal, then rechecks that principal against the current catalog. A human must still satisfy the selected agent's `allowedRoles`. An automated principal's kind must still appear in `allowedAutomation`; `approval.resume` is implied for a declared kind. The resumer delegates non-agent workflow records to the existing resume function.
|
|
291
|
+
Agent resume is approval-only. `createAgentApprovalResumer()` rejects legacy agent targets without the original principal, then rechecks that principal against the current catalog. A human must still satisfy the selected agent's `allowedRoles`. An automated principal's kind must still appear in `allowedAutomation`; `approval.resume` is implied for a declared kind. The thread host then enforces any `requiredPermissions` through the current resolver policy. The resumer delegates non-agent workflow records to the existing resume function.
|
|
266
292
|
|
|
267
293
|
`createFlowsafeDurableAgent()` remains the lower-level compatibility API. It routes Mastra's durable-agent workflow through `RunnerRuntime`, but it does not guard an arbitrary raw agent. Use `agent-host` when an HTTP surface must enforce catalog and Breakwater invariants.
|
|
268
294
|
|
|
@@ -280,17 +306,17 @@ Agent event replay lasts only as long as the configured Mastra cache. The defaul
|
|
|
280
306
|
|
|
281
307
|
### Schedules
|
|
282
308
|
|
|
283
|
-
`D1SchedulesStorage` implements the schedule domain. `createScheduleRouter()` provides
|
|
309
|
+
`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.
|
|
284
310
|
|
|
285
311
|
### Background tasks
|
|
286
312
|
|
|
287
|
-
`createBackgroundTaskD1Domains()` supplies serialized workflow and
|
|
313
|
+
`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.
|
|
288
314
|
|
|
289
315
|
### Signal providers
|
|
290
316
|
|
|
291
317
|
Flowsafe providers route polling and webhook deliveries through the thread topology instead of Mastra's in-process registry.
|
|
292
318
|
|
|
293
|
-
`SignalProviderHost` runs one alarm-driven host per
|
|
319
|
+
`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.
|
|
294
320
|
|
|
295
321
|
`githubSignalProvider()` is the reference provider.
|
|
296
322
|
|
|
@@ -298,9 +324,9 @@ Complete wiring is in the [durable-agents guide](https://github.com/ProofOfTechO
|
|
|
298
324
|
|
|
299
325
|
## Deployment and operations
|
|
300
326
|
|
|
301
|
-
The composed `createFlowsafeWorker()` owns the shared route
|
|
327
|
+
The composed `createFlowsafeWorker()` owns the shared route and maintenance-duty pipeline. Hosts inject workflows, identity verification, topology-backed optional routers, budget wrappers, notification transport, artifact pairing, schedule tick, and extra purge duties.
|
|
302
328
|
|
|
303
|
-
|
|
329
|
+
`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.
|
|
304
330
|
|
|
305
331
|
Read:
|
|
306
332
|
|
|
@@ -314,19 +340,23 @@ Flowsafe does not authenticate users, execute an identity-provider protocol, pro
|
|
|
314
340
|
|
|
315
341
|
Critical host obligations:
|
|
316
342
|
|
|
317
|
-
-
|
|
318
|
-
-
|
|
343
|
+
- deploy one Worker, D1 database, and set of Durable Object namespaces per organization;
|
|
344
|
+
- seed `flowsafe_deployment` before application migrations, configure `DEPLOYMENT_TENANT`, and keep the values identical;
|
|
345
|
+
- set a distinct `DEPLOYMENT_IDENTITY_SECRET` for internal Durable Object calls;
|
|
346
|
+
- 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;
|
|
347
|
+
- derive actors and roles from verified credentials;
|
|
348
|
+
- mint run, thread, schedule, and subscription identities server-side, validate host-owned resource keys, and preserve their principal ownership records;
|
|
319
349
|
- keep connector lists and agent resume targets server-authored;
|
|
320
350
|
- persist the original authorized agent requester and resume execution as that principal;
|
|
321
351
|
- expose decisions only through the approval path;
|
|
322
352
|
- configure shared stores for cross-isolate connector budgets;
|
|
323
353
|
- keep raw Durable Object namespaces behind the exported topologies;
|
|
324
|
-
- schedule every enabled domain's retention and
|
|
354
|
+
- schedule every enabled domain's retention path and define deployment decommissioning;
|
|
325
355
|
- protect model, provider, stream-ticket, webhook, and SIEM secrets separately.
|
|
326
356
|
|
|
327
357
|
## Verification
|
|
328
358
|
|
|
329
|
-
The repository's deterministic workerd spike proves suspend, process restart, resume, forged-resume denial, repeated gates,
|
|
359
|
+
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.
|
|
330
360
|
|
|
331
361
|
```bash
|
|
332
362
|
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 unknown[];
|
|
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
|
+
}
|