@proofoftech/flowsafe 0.32.0 → 0.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/agent-host/thread-host.d.ts.map +1 -1
  3. package/dist/agent-host/thread-host.js +18 -19
  4. package/dist/agent-host/thread-host.js.map +1 -1
  5. package/dist/approval-api/actor-context.d.ts.map +1 -1
  6. package/dist/approval-api/actor-context.js +2 -0
  7. package/dist/approval-api/actor-context.js.map +1 -1
  8. package/dist/approval-api/d1-store.d.ts.map +1 -1
  9. package/dist/approval-api/d1-store.js +37 -23
  10. package/dist/approval-api/d1-store.js.map +1 -1
  11. package/dist/approval-api/retention.d.ts.map +1 -1
  12. package/dist/approval-api/retention.js +6 -8
  13. package/dist/approval-api/retention.js.map +1 -1
  14. package/dist/approval-api/router.d.ts +1 -1
  15. package/dist/approval-api/router.d.ts.map +1 -1
  16. package/dist/approval-api/router.js +1 -0
  17. package/dist/approval-api/router.js.map +1 -1
  18. package/dist/approval-api/service.d.ts +4 -5
  19. package/dist/approval-api/service.d.ts.map +1 -1
  20. package/dist/approval-api/service.js +28 -51
  21. package/dist/approval-api/service.js.map +1 -1
  22. package/dist/approval-api/store.d.ts +2 -18
  23. package/dist/approval-api/store.d.ts.map +1 -1
  24. package/dist/approval-api/store.js +11 -24
  25. package/dist/approval-api/store.js.map +1 -1
  26. package/dist/approval-api/types.d.ts +6 -0
  27. package/dist/approval-api/types.d.ts.map +1 -1
  28. package/dist/approval-api/types.js.map +1 -1
  29. package/dist/do-runner/d1-storage.d.ts +23 -1
  30. package/dist/do-runner/d1-storage.d.ts.map +1 -1
  31. package/dist/do-runner/d1-storage.js +222 -53
  32. package/dist/do-runner/d1-storage.js.map +1 -1
  33. package/dist/do-runner/durable-object.d.ts +4 -5
  34. package/dist/do-runner/durable-object.d.ts.map +1 -1
  35. package/dist/do-runner/durable-object.js +24 -8
  36. package/dist/do-runner/durable-object.js.map +1 -1
  37. package/dist/do-runner/fenced-workflows-d1.d.ts.map +1 -1
  38. package/dist/do-runner/fenced-workflows-d1.js +5 -1
  39. package/dist/do-runner/fenced-workflows-d1.js.map +1 -1
  40. package/dist/do-runner/index.d.ts +3 -2
  41. package/dist/do-runner/index.d.ts.map +1 -1
  42. package/dist/do-runner/index.js +2 -1
  43. package/dist/do-runner/index.js.map +1 -1
  44. package/dist/do-runner/own-data-copy.d.ts +2 -0
  45. package/dist/do-runner/own-data-copy.d.ts.map +1 -0
  46. package/dist/do-runner/own-data-copy.js +14 -0
  47. package/dist/do-runner/own-data-copy.js.map +1 -0
  48. package/dist/do-runner/run-provenance.d.ts +3 -0
  49. package/dist/do-runner/run-provenance.d.ts.map +1 -1
  50. package/dist/do-runner/run-provenance.js +15 -2
  51. package/dist/do-runner/run-provenance.js.map +1 -1
  52. package/dist/do-runner/run-requester.d.ts +11 -0
  53. package/dist/do-runner/run-requester.d.ts.map +1 -0
  54. package/dist/do-runner/run-requester.js +29 -0
  55. package/dist/do-runner/run-requester.js.map +1 -0
  56. package/dist/do-runner/runtime.d.ts +5 -0
  57. package/dist/do-runner/runtime.d.ts.map +1 -1
  58. package/dist/do-runner/runtime.js +23 -12
  59. package/dist/do-runner/runtime.js.map +1 -1
  60. package/dist/host-kit/approval-bridge.d.ts +12 -13
  61. package/dist/host-kit/approval-bridge.d.ts.map +1 -1
  62. package/dist/host-kit/approval-bridge.js +70 -21
  63. package/dist/host-kit/approval-bridge.js.map +1 -1
  64. package/dist/host-kit/do-response.d.ts.map +1 -1
  65. package/dist/host-kit/do-response.js +12 -10
  66. package/dist/host-kit/do-response.js.map +1 -1
  67. package/dist/host-kit/do-run-topology.d.ts +3 -1
  68. package/dist/host-kit/do-run-topology.d.ts.map +1 -1
  69. package/dist/host-kit/do-run-topology.js +12 -1
  70. package/dist/host-kit/do-run-topology.js.map +1 -1
  71. package/dist/host-kit/flowsafe-worker.d.ts +13 -9
  72. package/dist/host-kit/flowsafe-worker.d.ts.map +1 -1
  73. package/dist/host-kit/flowsafe-worker.js +54 -7
  74. package/dist/host-kit/flowsafe-worker.js.map +1 -1
  75. package/dist/host-kit/host-approval-service.d.ts +2 -2
  76. package/dist/host-kit/host-approval-service.d.ts.map +1 -1
  77. package/dist/host-kit/host-approval-service.js +2 -2
  78. package/dist/host-kit/host-approval-service.js.map +1 -1
  79. package/dist/host-kit/index.d.ts +3 -2
  80. package/dist/host-kit/index.d.ts.map +1 -1
  81. package/dist/host-kit/index.js +1 -0
  82. package/dist/host-kit/index.js.map +1 -1
  83. package/dist/host-kit/memory-boundary.js +4 -2
  84. package/dist/host-kit/memory-boundary.js.map +1 -1
  85. package/dist/host-kit/run-router.d.ts +19 -5
  86. package/dist/host-kit/run-router.d.ts.map +1 -1
  87. package/dist/host-kit/run-router.js +46 -13
  88. package/dist/host-kit/run-router.js.map +1 -1
  89. package/dist/schedules/router.d.ts.map +1 -1
  90. package/dist/schedules/router.js +7 -6
  91. package/dist/schedules/router.js.map +1 -1
  92. package/dist/schedules/target-policy.d.ts +2 -2
  93. package/dist/schedules/target-policy.d.ts.map +1 -1
  94. package/dist/schedules/target-policy.js +3 -0
  95. package/dist/schedules/target-policy.js.map +1 -1
  96. package/dist/schedules/tick.d.ts +3 -4
  97. package/dist/schedules/tick.d.ts.map +1 -1
  98. package/dist/schedules/tick.js +13 -10
  99. package/dist/schedules/tick.js.map +1 -1
  100. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # @proofoftech/flowsafe
2
2
 
3
+ ## 0.34.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 9f33adb: Trusted filing code can set the optional, immutable `onBehalfOf` human principal ID. By default, `decide` refuses both that principal and the human requester. The cross-gate separation-of-duties check bars reviewers who approved or rejected an earlier gate from deciding a later gate in the same run. Review flows that let the same reviewer reject and then decide the next gate now require another reviewer or an `allowSelfDecision` exemption.
8
+
9
+ `ApprovalRecord.superseded` marks a rejection caused by closing a stale approval. The cross-gate check skips these records. The D1 schema adds `on_behalf_of TEXT` and `superseded INTEGER`. Versions 0.31.0 and 0.32.0 ignore both columns on rollback, so `onBehalfOf` alone cannot bar a decision in those versions.
10
+
11
+ - b1585a9: Runs record an optional `runRequester` (a human principal id) supplied by the trusted host on start and carried unchanged across resumes. The starting principal still owns the run and sets `requestedBy` on start. `RunSummary` exposes `runRequester`. Flowsafe 0.31.0 and 0.32.0 drop the field during decoding, and resuming a run under either version permanently erases it from the run.
12
+ - f4e04da: `createRunRouter` and `createFlowsafeWorker` accept `resolveRunRequester` and `runRequesterRoles`. The default roles are `admin` and `operator`. A host can start a run with its operator credential and name the human who requested it. Each approval keeps the starting or resuming principal as `requestedBy` and records the human as `onBehalfOf`. Separation of duties checks both fields. An invalid resolver result returns `500`, and a resolver that throws returns `503`.
13
+
14
+ Enable the resolver in a separate deploy after the upgrade reaches every Worker and run object. Approvals filed by older code retain the `onBehalfOf` value from filing, which can be absent.
15
+
16
+ Breaking change for callers that send attribution fields in a start body. `POST /runs` now returns `400` when the body includes `runRequester`, `requestedBy`, or `requestedByKind`.
17
+
18
+ ## 0.33.0
19
+
20
+ ### Minor Changes
21
+
22
+ - 01b7ecc: The run-deadline sweep also enforces deadlines on runs whose stored snapshot SQLite cannot parse (rows stored before 0.26.0). Each pass scans up to 10 legacy rows. Runs already past their deadline time out as the maintenance passes reach them after upgrade. Before upgrading, count them with `countUnreadableExpiredRunDeadlines()`.
23
+
24
+ After upgrading, the maintenance status route reports the first page in `unreadableExpiredRunDeadlines`. It caches the lookup for 30 seconds and reports count failures in the same field while still returning maintenance health. The sweep skips non-JSON snapshots. Older versions ignore the new cursor key on rollback.
25
+
26
+ ### Patch Changes
27
+
28
+ - 79acfa4: Approval reconciliation treats a stored approval with a later suspension time as current even when the resume count is equal, and withdraws an approval it filed from a status read that the run has already moved past.
29
+ - 9160aae: Admin JSON responses of the Flowsafe Worker and its maintenance object send `cache-control: no-store`. A maintenance duty whose error renders as an empty string records `unknown error`, so health readers no longer reject the record. `assertNoClientMemoryIds` walks wide arrays and objects without spreading them as call arguments, so a large body answers 400 or passes instead of a 500.
30
+ - 3800481: The schedule tick refuses unknown stored target kinds with `unknown-target-kind`, regardless of the host's policy. The built-in schedule target policy also refuses unknown kinds with status 400 and reason `unknown-target-kind`. Both values are now part of `ScheduleTargetDecision`.
31
+ - 98f3053: Agent routes answer `404 run not found` when a run is addressed under a thread or agent it does not belong to, instead of a retryable `503 RUN_STATE_UNREADABLE`.
32
+
3
33
  ## 0.32.0
4
34
 
5
35
  ### Minor Changes
@@ -1 +1 @@
1
- {"version":3,"file":"thread-host.d.ts","sourceRoot":"","sources":["../../src/agent-host/thread-host.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAWjE,OAAO,EAGL,KAAK,cAAc,EAQnB,KAAK,oBAAoB,EACzB,KAAK,2BAA2B,EAIjC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,KAAK,iBAAiB,EAEtB,KAAK,eAAe,EAEpB,KAAK,kBAAkB,EAIvB,KAAK,iCAAiC,EAIvC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,KAAK,2BAA2B,EAIjC,MAAM,8BAA8B,CAAC;AAYtC,OAAO,EAGL,KAAK,sBAAsB,EAG3B,KAAK,UAAU,EAIf,KAAK,mBAAmB,EAExB,KAAK,WAAW,EACjB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAGL,KAAK,iBAAiB,EAEvB,MAAM,qCAAqC,CAAC;AAU7C,OAAO,EAEL,KAAK,SAAS,EACf,MAAM,oCAAoC,CAAC;AAK5C,OAAO,EAEL,KAAK,uBAAuB,EAE7B,MAAM,4CAA4C,CAAC;AAWpD,OAAO,EAGL,KAAK,4BAA4B,EAClC,MAAM,sBAAsB,CAAC;AAM9B,OAAO,KAAK,EACV,WAAW,EAEX,gBAAgB,EAEhB,2BAA2B,EAE5B,MAAM,YAAY,CAAC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C,CAAC,CAAC;IAC9D;;;OAGG;IACH,2BAA2B,CACzB,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,CAAC,CAAC;IACpB,KAAK,CACH,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC7B,iBAAiB,CACf,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE;QACL,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,cAAc,CAAC;KAC3B,GACA,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC7B;;;;OAIG;IACH,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAAC;IACvE,uEAAuE;IACvE,sBAAsB,CACpB,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAC5D,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;IACnC,gBAAgB,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjE,4BAA4B,CAC1B,KAAK,EAAE,WAAW,EAClB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,kBAAkB,GAAG,YAAY,CAAC,CAAC;IAC9C,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;CACvE;AA0WD,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,sBAAsB,GAC9B,eAAe,CA0+FjB"}
@@ -787,9 +787,11 @@ export function createThreadAgentHost(options) {
787
787
  return assertSelectedResource(await durable.authoritativeAgentStartState(scope.init.runtime, scope.threadId, ref.runId, { includeLegacy: true }));
788
788
  return assertSelectedResource(await durable.authoritativeAgentStartState(scope.init.runtime, scope.threadId, ref.runId));
789
789
  }
790
- const publicAgentState = async (scope, ref) => {
790
+ const routeAgentState = async (scope, ref, readOptions) => {
791
791
  try {
792
- return await selectedAgentState(scope, ref, { includeLegacy: true });
792
+ return readOptions
793
+ ? await selectedAgentState(scope, ref, readOptions)
794
+ : await selectedAgentState(scope, ref);
793
795
  }
794
796
  catch (error) {
795
797
  if (error instanceof AgentRunSelectorMismatchError)
@@ -983,7 +985,7 @@ export function createThreadAgentHost(options) {
983
985
  return summary;
984
986
  });
985
987
  const finalizeTerminalAgentState = async (scope, ref, state, expectedRecord) => {
986
- const selected = state ?? (await selectedAgentState(scope, ref, { includeLegacy: true }));
988
+ const selected = state ?? (await routeAgentState(scope, ref, { includeLegacy: true }));
987
989
  if (!selected ||
988
990
  selected.kind === 'initial' ||
989
991
  !isTerminalRunStatus(selected.summary.status))
@@ -1097,10 +1099,8 @@ export function createThreadAgentHost(options) {
1097
1099
  approvals,
1098
1100
  };
1099
1101
  };
1100
- const snapshotExecutionFor = async (scope, ref, knownState) => {
1101
- const state = knownState === undefined
1102
- ? await selectedAgentState(scope, ref, { includeLegacy: true })
1103
- : knownState;
1102
+ const snapshotExecutionFor = async (scope, ref, readAgentState) => {
1103
+ const state = await readAgentState(scope, ref, { includeLegacy: true });
1104
1104
  if (!state)
1105
1105
  throw new AgentHostRequestError(404, 'run not found');
1106
1106
  if (state.kind === 'initial')
@@ -1111,13 +1111,13 @@ export function createThreadAgentHost(options) {
1111
1111
  safeContext: sanitizeStoredAgentContext(state.snapshot.requestContext),
1112
1112
  };
1113
1113
  };
1114
- const readRemoteStepHostAuthority = async (scope, invocation) => {
1114
+ const readRemoteStepHostAuthority = async (scope, invocation, readAgentState) => {
1115
1115
  const ref = {
1116
1116
  agentId: invocation.agentId,
1117
1117
  resourceId: invocation.resourceId,
1118
1118
  runId: invocation.runId,
1119
1119
  };
1120
- const selected = await snapshotExecutionFor(scope, ref);
1120
+ const selected = await snapshotExecutionFor(scope, ref, readAgentState);
1121
1121
  const state = selected.state;
1122
1122
  if (state.kind !== 'result' ||
1123
1123
  state.storage !== 'd1' ||
@@ -1329,7 +1329,7 @@ export function createThreadAgentHost(options) {
1329
1329
  operation.state === 'unresolved' ||
1330
1330
  operation.state === 'prepared')
1331
1331
  return 'unresolved';
1332
- await readRemoteStepHostAuthority(scope, invocation);
1332
+ await readRemoteStepHostAuthority(scope, invocation, selectedAgentState);
1333
1333
  const retained = await profile.journal.readRetainedResult(invocationId);
1334
1334
  if (!retained || invocation.status !== 'result-retained')
1335
1335
  throw new AgentHostRequestError(409, 'remote step result is unavailable');
@@ -1852,6 +1852,7 @@ export function createThreadAgentHost(options) {
1852
1852
  threadId: scope.threadId,
1853
1853
  resourceId: preflightUrl.searchParams.get('resourceId'),
1854
1854
  });
1855
+ // Start admission treats a replay 404 as proof the snapshot is absent.
1855
1856
  const state = await selectedAgentState(scope, ref);
1856
1857
  if (state &&
1857
1858
  (state.execution.owner.kind !== scope.principal.kind ||
@@ -1880,9 +1881,7 @@ export function createThreadAgentHost(options) {
1880
1881
  if (storedRun && storedRun.agentId !== ref.agentId) {
1881
1882
  throw new AgentHostRequestError(404, 'run not found');
1882
1883
  }
1883
- await snapshotExecutionFor(scope, ref, preflightUrl.searchParams.get('replay') === '1'
1884
- ? undefined
1885
- : await publicAgentState(scope, ref));
1884
+ await snapshotExecutionFor(scope, ref, routeAgentState);
1886
1885
  const owner = await options.resourceAccess().owner('run', ref.runId);
1887
1886
  // Cancels outside the dispatch lock, which a running start or resume
1888
1887
  // leg holds; the intent it records refuses a resume queued behind the
@@ -2023,7 +2022,7 @@ export function createThreadAgentHost(options) {
2023
2022
  invocation.status !== 'result-retained' ||
2024
2023
  invocation.deadlineAt <= Date.now())
2025
2024
  throw new AgentHostRequestError(404, 'invocation not found');
2026
- const { ref, selected, state, stored } = await readRemoteStepHostAuthority(scope, invocation);
2025
+ const { ref, selected, state, stored } = await readRemoteStepHostAuthority(scope, invocation, routeAgentState);
2027
2026
  const key = invocation.stepPath.join('.');
2028
2027
  const summary = state.summary;
2029
2028
  const payload = summary.suspendPayload !== null &&
@@ -2166,7 +2165,7 @@ export function createThreadAgentHost(options) {
2166
2165
  if (resumeBody) {
2167
2166
  const body = resumeBody;
2168
2167
  const ref = runRef(scope, body);
2169
- const snapshotExecution = await snapshotExecutionFor(scope, ref);
2168
+ const snapshotExecution = await snapshotExecutionFor(scope, ref, routeAgentState);
2170
2169
  const { summary: latest } = await statusFor(scope, ref, snapshotExecution.state);
2171
2170
  const { state } = snapshotExecution;
2172
2171
  // An ended run's record is deleted, so only the snapshot's execution
@@ -2280,7 +2279,7 @@ export function createThreadAgentHost(options) {
2280
2279
  }
2281
2280
  return json(await statusFor(scope, ref));
2282
2281
  }
2283
- return json(await statusFor(scope, ref, await publicAgentState(scope, ref)));
2282
+ return json(await statusFor(scope, ref, await routeAgentState(scope, ref, { includeLegacy: true })));
2284
2283
  }
2285
2284
  if (segments.length === 4 &&
2286
2285
  segments[3] === 'terminate' &&
@@ -2291,7 +2290,7 @@ export function createThreadAgentHost(options) {
2291
2290
  if (storedRun && storedRun.agentId !== ref.agentId) {
2292
2291
  throw new AgentHostRequestError(404, 'run not found');
2293
2292
  }
2294
- await snapshotExecutionFor(scope, ref, replayOnly ? undefined : await publicAgentState(scope, ref));
2293
+ await snapshotExecutionFor(scope, ref, routeAgentState);
2295
2294
  const owner = await options.resourceAccess().owner('run', ref.runId);
2296
2295
  if (replayOnly) {
2297
2296
  const existing = await scopedRuntime.status(await workflowIdFor(scope, ref.agentId), ref.runId);
@@ -2317,7 +2316,7 @@ export function createThreadAgentHost(options) {
2317
2316
  error: errorMessageOf(error),
2318
2317
  }));
2319
2318
  }
2320
- const selected = await selectedAgentState(scope, ref, {
2319
+ const selected = await routeAgentState(scope, ref, {
2321
2320
  includeLegacy: true,
2322
2321
  });
2323
2322
  if (!selected || selected.kind === 'initial')
@@ -2408,7 +2407,7 @@ export function createThreadAgentHost(options) {
2408
2407
  if (segments.length === 4 &&
2409
2408
  segments[3] === 'stream' &&
2410
2409
  request.method === 'GET') {
2411
- const run = await statusFor(scope, ref, await publicAgentState(scope, ref));
2410
+ const run = await statusFor(scope, ref, await routeAgentState(scope, ref, { includeLegacy: true }));
2412
2411
  const offset = Number(url.searchParams.get('offset') ?? '0');
2413
2412
  if (!Number.isSafeInteger(offset) || offset < 0) {
2414
2413
  throw new AgentHostRequestError(400, 'invalid stream offset');