@sanoma-ai/workflows 0.5.0 → 0.7.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 (153) hide show
  1. package/README.md +49 -15
  2. package/dist/apply.d.ts +2 -1
  3. package/dist/apply.js +29 -7
  4. package/dist/apply.js.map +1 -1
  5. package/dist/approvals.d.ts +27 -2
  6. package/dist/approvals.js +73 -9
  7. package/dist/approvals.js.map +1 -1
  8. package/dist/call.d.ts +3 -2
  9. package/dist/call.js +38 -30
  10. package/dist/call.js.map +1 -1
  11. package/dist/cedar.js +24 -9
  12. package/dist/cedar.js.map +1 -1
  13. package/dist/change.d.ts +219 -0
  14. package/dist/change.js +150 -0
  15. package/dist/change.js.map +1 -0
  16. package/dist/chats.d.ts +43 -0
  17. package/dist/chats.js +48 -0
  18. package/dist/chats.js.map +1 -0
  19. package/dist/client.d.ts +52 -6
  20. package/dist/client.js +88 -47
  21. package/dist/client.js.map +1 -1
  22. package/dist/config.d.ts +47 -5
  23. package/dist/config.js +71 -7
  24. package/dist/config.js.map +1 -1
  25. package/dist/database.d.ts +83 -0
  26. package/dist/database.js +92 -0
  27. package/dist/database.js.map +1 -0
  28. package/dist/db.d.ts +31 -1
  29. package/dist/db.js +89 -7
  30. package/dist/db.js.map +1 -1
  31. package/dist/deadlines.d.ts +88 -0
  32. package/dist/deadlines.js +171 -0
  33. package/dist/deadlines.js.map +1 -0
  34. package/dist/define.d.ts +25 -4
  35. package/dist/define.js +40 -0
  36. package/dist/define.js.map +1 -1
  37. package/dist/demo.d.ts +28 -0
  38. package/dist/demo.js +72 -0
  39. package/dist/demo.js.map +1 -0
  40. package/dist/describe.d.ts +6 -3
  41. package/dist/describe.js +11 -7
  42. package/dist/describe.js.map +1 -1
  43. package/dist/errors.d.ts +10 -1
  44. package/dist/errors.js +13 -0
  45. package/dist/errors.js.map +1 -1
  46. package/dist/fake.d.ts +8 -0
  47. package/dist/fake.js +11 -1
  48. package/dist/fake.js.map +1 -1
  49. package/dist/grid.d.ts +34 -0
  50. package/dist/grid.js +62 -0
  51. package/dist/grid.js.map +1 -0
  52. package/dist/host.d.ts +13 -2
  53. package/dist/host.js +2 -2
  54. package/dist/host.js.map +1 -1
  55. package/dist/index.d.ts +16 -8
  56. package/dist/index.js +12 -5
  57. package/dist/index.js.map +1 -1
  58. package/dist/ledger.d.ts +11 -2
  59. package/dist/ledger.js.map +1 -1
  60. package/dist/lint.js +1 -1
  61. package/dist/lint.js.map +1 -1
  62. package/dist/op.d.ts +14 -2
  63. package/dist/op.js.map +1 -1
  64. package/dist/policy.d.ts +7 -1
  65. package/dist/policy.js +2 -1
  66. package/dist/policy.js.map +1 -1
  67. package/dist/resource.d.ts +13 -1
  68. package/dist/resource.js +9 -1
  69. package/dist/resource.js.map +1 -1
  70. package/dist/resources.d.ts +2 -0
  71. package/dist/resources.js +10 -1
  72. package/dist/resources.js.map +1 -1
  73. package/dist/run.d.ts +5 -0
  74. package/dist/run.js.map +1 -1
  75. package/dist/sandbox.d.ts +38 -10
  76. package/dist/sandbox.js +66 -35
  77. package/dist/sandbox.js.map +1 -1
  78. package/dist/scenario.d.ts +18 -1
  79. package/dist/scenario.js +77 -27
  80. package/dist/scenario.js.map +1 -1
  81. package/dist/scenarios.d.ts +10 -1
  82. package/dist/scenarios.js +19 -4
  83. package/dist/scenarios.js.map +1 -1
  84. package/dist/schedules.d.ts +66 -0
  85. package/dist/schedules.js +158 -0
  86. package/dist/schedules.js.map +1 -0
  87. package/dist/schema.d.ts +6 -0
  88. package/dist/schema.js +13 -3
  89. package/dist/schema.js.map +1 -1
  90. package/dist/shared.d.ts +38 -2
  91. package/dist/shared.js +50 -4
  92. package/dist/shared.js.map +1 -1
  93. package/dist/sites.d.ts +38 -1
  94. package/dist/sites.js +153 -26
  95. package/dist/sites.js.map +1 -1
  96. package/dist/source.d.ts +61 -2
  97. package/dist/source.js.map +1 -1
  98. package/dist/supervisor.d.ts +38 -0
  99. package/dist/supervisor.js +77 -0
  100. package/dist/supervisor.js.map +1 -0
  101. package/dist/version.d.ts +3 -1
  102. package/dist/version.js +3 -1
  103. package/dist/version.js.map +1 -1
  104. package/dist/wakeup-service.d.ts +83 -0
  105. package/dist/wakeup-service.js +421 -0
  106. package/dist/wakeup-service.js.map +1 -0
  107. package/dist/wakeup.d.ts +84 -0
  108. package/dist/wakeup.js +87 -0
  109. package/dist/wakeup.js.map +1 -0
  110. package/dist/worker.d.ts +39 -1
  111. package/dist/worker.js +130 -39
  112. package/dist/worker.js.map +1 -1
  113. package/oxlint.json +2 -1
  114. package/package.json +8 -2
  115. package/src/apply.ts +25 -6
  116. package/src/approvals.ts +89 -16
  117. package/src/call.ts +40 -29
  118. package/src/cedar.ts +24 -6
  119. package/src/change.ts +222 -0
  120. package/src/chats.ts +114 -0
  121. package/src/client.ts +145 -55
  122. package/src/config.ts +110 -13
  123. package/src/database.ts +152 -0
  124. package/src/db.ts +108 -9
  125. package/src/deadlines.ts +234 -0
  126. package/src/define.ts +71 -4
  127. package/src/demo.ts +87 -0
  128. package/src/describe.ts +19 -7
  129. package/src/errors.ts +14 -0
  130. package/src/fake.ts +12 -0
  131. package/src/grid.ts +100 -0
  132. package/src/host.ts +13 -4
  133. package/src/index.ts +62 -3
  134. package/src/ledger.ts +15 -3
  135. package/src/lint.ts +1 -1
  136. package/src/op.ts +15 -2
  137. package/src/policy.ts +7 -1
  138. package/src/resource.ts +22 -3
  139. package/src/resources.ts +12 -1
  140. package/src/run.ts +5 -0
  141. package/src/sandbox.ts +97 -37
  142. package/src/scenario.ts +97 -28
  143. package/src/scenarios.ts +21 -5
  144. package/src/schedules.ts +206 -0
  145. package/src/schema.ts +16 -3
  146. package/src/shared.ts +62 -4
  147. package/src/sites.ts +198 -33
  148. package/src/source.ts +58 -3
  149. package/src/supervisor.ts +107 -0
  150. package/src/version.ts +3 -1
  151. package/src/wakeup-service.ts +511 -0
  152. package/src/wakeup.ts +150 -0
  153. package/src/worker.ts +181 -44
package/README.md CHANGED
@@ -37,6 +37,8 @@ export default defineWorkflow({
37
37
  });
38
38
  ```
39
39
 
40
+ A workflow's `trigger` is `"manual"` or `{ schedule, timezone? }` (`Trigger`): a five-field cron expression in an IANA time zone, UTC without one. The worker of the app's latest version keeps DBOS's schedules to the config's, one per scheduled workflow named `<app>/<workflow>` on the app's queue, deleting those no longer declared; a tick missed while the instance was stopped fires once when it starts again. Each tick is a run of the workflow under its own name (run id `sched-<app>/<workflow>-<time>`, its `run.started` record's `scheduledFor`), started by the runtime's `schedule` agent with the input `{}`, so `defineWorkflow` refuses a schedule for a workflow whose input refuses `{}`. The policy decides the start as it would a manual start by that agent (`workflow:<name>`, the principal `schedule`, in `agents`): a deny fails the run with its reason, and so does a hold, since a schedule waits for no approval. `nextFire(schedule, timezone, from)` is when a cron fires next, as DBOS's scheduler finds it, and `nextScheduledFire(resolved, from)` the earliest over a config's workflows. A scheduled workflow can still be started by hand.
41
+
40
42
  A third argument says who the vendor is, so the app can show it: `defineConnector("shop", specs, { title: "Shop", logo: { svg, dark }, package, homepage })`. `logo.svg` is the vendor's mark as inline SVG markup, one `<svg>…</svg>` element (`defineConnector` refuses anything else, such as a file path or a URL), and `logo.dark` its variant for dark backgrounds, if it has one. The app shows a logo before each of the vendor's operations, in graphs and lists, and only ever as an image (`<img>` with a `data:` URL), where an SVG's scripts and external references never run or load. A vendor with no logo is shown by its operations' ids alone, as before. `package` is the connector's npm package name (`"@sanoma-ai/connector-resend"`), which the app's Connectors page links to on npm. `homepage` is the connector package's `homepage` from its package.json: where its code and README are, as an https URL (`defineConnector` refuses anything else); the Connectors page links to it as the connector's source. A vendor whose operations are split over several connectors is described by the first connector's info, its package and homepage as well as its title and logo. A connector package writes all of this once, in its package.json, and passes `vendorInfo(import.meta.url)` as the third argument (the nearest package.json is read): it reads the `"sanoma": { "title", "logo", "logoDark"? }` field, whose logos are SVG files in the package (relative `.svg` paths, listed in `files`), and the package's `name` and `homepage`. With the `sanoma-connector` keyword, the same field is how the app lists the package on npm before it is installed.
41
43
 
42
44
  A [driver](#drivers) implements the operations and holds the credentials, and a [fake](#fakes-for-tests) stands in for the vendor in [sandbox runs](#scenarios-and-sandbox-runs). A connector package attaches both to the connector it exports, with `withSetup` (and its [steps](#steps-a-connector-ships) for Gherkin tests, as `steps`), so a config names the connector alone:
@@ -53,6 +55,8 @@ export const shop = withSetup(defineConnector("shop", specs, info), {
53
55
 
54
56
  A connector that signs visitors in to a public site attaches a login half too, as `login`: `withSetup(connector, { login: (context) => half })`. The app calls it once per public site whose `site.ts` names the connector (`defineSite({ public: true, login: "<vendor>" })`), when it starts, with a `LoginContext` (the database, a key of its own derived from `SANOMA_SECRETS_KEY` to sign its cookies with, a vendor's secrets, the site's origins); a login that keeps tables in the database migrates them there, serialized and idempotent. The `LoginHalf` it makes (see its type) answers the provider's stable subject for a request, never a principal: the app makes the visitor's principal from it, so a connector cannot set a visitor's groups. A visitor's address, for rate limits, is the `CLIENT_IP_HEADER` header the app sets, never `X-Forwarded-For`. One vendor's connectors attach one `login`, as for a driver. [`@sanoma-ai/connector-better-auth`](https://www.npmjs.com/package/@sanoma-ai/connector-better-auth) is one, email and password on the company's database. The app makes it as it starts and sends it every request to the site's own host ([public sites](https://www.npmjs.com/package/@sanoma-ai/app#public-sites)).
55
57
 
58
+ A model connector attaches a model half, as `model`: `withSetup(connector, { model: (context) => provider })`, an AI SDK provider (`ProviderV4` from `@ai-sdk/provider`) with the vendor's adapter as the transport. The app makes it for its model registry, once per resolved config and client (again after one that throws), where its models are `<vendor>/<model-id>`; it answers `languageModel("default")` with the connector's own default. Its `ModelContext` gives it the secrets as a login's does (the environment's, then the stored credentials), which it reads when a model is called, so a key set on the connector page is used without a restart (unless the environment sets one, which wins); its driver declares the key in `env`, with no operations if it needs none. One vendor's connectors attach one `model`. [`@sanoma-ai/connector-anthropic`](https://www.npmjs.com/package/@sanoma-ai/connector-anthropic) is one.
59
+
56
60
  A config names the workflows and the connectors:
57
61
 
58
62
  ```ts
@@ -72,7 +76,7 @@ That is the whole config; the rest is convention, from its `root` (`defineConfig
72
76
 
73
77
  The [data files](#data-files) are `resources/` in the root. `ledger` and `databaseUrl` are the only other fields. `drivers`, `fakes`, `appName`, `scenarios` and `policy` are typed `never` on `SanomaConfig`, each deprecated with where it went, so the compiler and the editor say so; an untyped config that still names `drivers` or `fakes` is refused at run time rather than run live on what it no longer reads, and one that names `policy` rather than run allowing everything.
74
78
 
75
- The audit record goes to the ledger, by default `postgresLedger(databaseUrl)` on the config's database (see [Ledger](#ledger)); `ledger: jsonlLedger(dir)` keeps it in files instead, and `memoryLedger()` in this process only, for tests. `resolveConfig(config)` checks a config and derives what the runtime uses from it: the app name, database, version and queue (`sanoma:<appName>`, for every run, [sandbox runs](#scenarios-and-sandbox-runs) included), the operations by id, the driver each vendor's connector attaches, made once for the resolution (`driversByVendor`, in `connectors` order, and their functions by operation id, `drivers`), the makers of their fakes (`fakes`, by vendor), the scenarios directory, the policy (`policy`, the policies it is made from as `policies`, and what is wrong in them as `policyProblems`), and the config's `ledger` when it gives one; it opens nothing and reads no file outside the root: its `package.json`, whether `scenarios/` is a directory, and the policies with the people files. It throws, with one message, whatever the worker would refuse: a workflow or driver naming an operation the `connectors` don't declare, a workflow redeclaring an operation with another effect, an operation with no driver (`` `shop.order.refund` has no driver: the connector package must attach one ``), two different drivers or fakes for one vendor, two workflows with one name, a `ledger` that is not a store, a `drivers`, `fakes` or `policy` an untyped config still names. `startWorker`, `SanomaClient.connect` and `describeConfig` all call it, so they fail the same way. It adds the built-in [`drift`](#drift) and [`apply`](#apply) workflows when the connectors declare resource types, and [`call`](#direct-calls) when an operation may be called directly. The worker takes each operation's effect, schemas and retry setting from `connectors`, never from the workflow.
79
+ The audit record goes to the ledger, by default `postgresLedger(databaseUrl)` on the config's database (see [Ledger](#ledger)); `ledger: jsonlLedger(dir)` keeps it in files instead, and `memoryLedger()` in this process only, for tests. `resolveConfig(config)` checks a config and derives what the runtime uses from it: the app name, database, version and queue (`sanoma:<appName>`, for every run, [sandbox runs](#scenarios-and-sandbox-runs) included), the operations by id, the driver each vendor's connector attaches, made once for the resolution (`driversByVendor`, in `connectors` order, and their functions by operation id, `drivers`), the makers of their fakes (`fakes`, by vendor), the scenarios directory, the policy (`policy`, the policies it is made from as `policies`, and what is wrong in them as `policyProblems`), and the config's `ledger` when it gives one; it opens nothing and reads no file outside the root: its `package.json`, whether `scenarios/` is a directory, and the policies with the people files. It throws, with one message, whatever the worker would refuse: a workflow or driver naming an operation the `connectors` don't declare, a workflow redeclaring an operation with another effect, an operation with no driver (`` `shop.order.refund` has no driver: the connector package must attach one ``), two different drivers or fakes for one vendor, two workflows with one name, a `ledger` that is not a store, a `drivers`, `fakes` or `policy` an untyped config still names. `startWorker`, `SanomaClient.connect` and `describeConfig` all call it, so they fail the same way. `resolveConfig(config, { fakes: "instance" })` runs the whole instance on the connectors' fakes, as a [demo](#demos) does: each vendor's fake is made once for the resolution (`instanceFakes`, by vendor) and is its driver, so live runs, sandbox runs and direct calls all call it; the collections stay on the database, and a vendor whose connector attaches a driver and no fake is refused, since it would run live. A worker and a client share such a resolution when given it (`startWorker(config, { resolved })`, `SanomaClient.connect(config, { resolved })`), and its `dataStore` is then the caller's to close. It adds the built-in [`drift`](#drift) and [`apply`](#apply) workflows when the connectors declare resource types, and [`call`](#direct-calls) when an operation may be called directly. The worker takes each operation's effect, schemas and retry setting from `connectors`, never from the workflow.
76
80
 
77
81
  An operation names the instance it acts on with `target`, a function of its parsed input, so a policy can decide per post or per order rather than per operation (its Cedar resource, `Sanoma::Target::"order/ord_1"`). TypeScript types its input `any` there, so annotate it to have it checked:
78
82
 
@@ -89,7 +93,7 @@ const shop = defineConnector("shop", {
89
93
  });
90
94
  ```
91
95
 
92
- The ledger gets one record for the start of the run, each operation call with its decision and the vendor's reply, each approval requested and decided (a policy's hold names the call it holds by its `op` and `opSeq`, the `seq` that call's own record has), each message an approval ignored (`approval.refused`: sent by someone who may not decide it, or not a decision), each sleep (`sleep.started` with `until`, when it ends in ms since the epoch: the time asked for, or for a duration, the record's `at` plus the duration, as the runtime saw it; written for a time already past too), and how the run ended, in a JSONL file per run. A decision is recorded with its `reasons` (the ids of the policies behind it) and, with Cedar policies, their `policyVersion`, a hash of their text. Every record carries `v: 1`, the `app` and the `actor`, and one written inside a `ctx.all` member its `group` (see [Built-ins](#built-ins)); each call's record (`op.called`, `approval.requested`, `sleep.started`) carries its step's `name` (see [Step names](#step-names)); an error is recorded as `{ code?, name, message }`, with `retryable` when the error says, the vendor's `status` and `vendorCode` only from a `DriverError`, and `data` only from the runtime's own errors (the operation, the approval, the input's issues), so an HTTP client's error that escapes a driver does not put the vendor's reply in the ledger. A ledger store's failed append is tried again up to three times; a store throws an error with `retryable: false` for a failure that would only repeat. When a call's record still cannot be written after the vendor replied, the call fails with "<op id> succeeded, but the ledger could not record it" and the run makes no further calls (`run_ended`), so a workflow that catches the failure cannot repeat the side effect unrecorded.
96
+ The ledger gets one record for the start of the run, each operation call with its decision and the vendor's reply, each approval requested, decided and withdrawn (`approval.withdrawn` with its `reason`; a policy's hold names the call it holds by its `op` and `opSeq`, the `seq` that call's own record has), each message an approval ignored (`approval.refused`: sent by someone who may not decide it, or not a decision), each sleep (`sleep.started` with `until`, when it ends in ms since the epoch: the time asked for, or for a duration, the record's `at` plus the duration, as the runtime saw it; written for a time already past too), and how the run ended, in a JSONL file per run. A decision is recorded with its `reasons` (the ids of the policies behind it) and, with Cedar policies, their `policyVersion`, a hash of their text. Every record carries `v: 1`, the `app` and the `actor`, and one written inside a `ctx.all` member its `group` (see [Built-ins](#built-ins)); each call's record (`op.called`, `approval.requested`, `sleep.started`) carries its step's `name` (see [Step names](#step-names)); an error is recorded as `{ code?, name, message }`, with `retryable` when the error says, the vendor's `status` and `vendorCode` only from a `DriverError`, and `data` only from the runtime's own errors (the operation, the approval, the input's issues), so an HTTP client's error that escapes a driver does not put the vendor's reply in the ledger. A ledger store's failed append is tried again up to three times; a store throws an error with `retryable: false` for a failure that would only repeat. When a call's record still cannot be written after the vendor replied, the call fails with "<op id> succeeded, but the ledger could not record it" and the run makes no further calls (`run_ended`), so a workflow that catches the failure cannot repeat the side effect unrecorded.
93
97
 
94
98
  People are `Principal`s: `{ id, groups?, onBehalfOf? }`. A run is started as one and a decision is sent as one, by id: the groups are the [people files'](#people), never the caller's.
95
99
 
@@ -100,11 +104,11 @@ const approval = await client.decide(runId, { decision: "approve", by: { id: "fi
100
104
  const run = await client.run(runId); // run.status: "queued" | "running" | "waiting" | "finished" | "failed" | "cancelled"
101
105
  ```
102
106
 
103
- `workflow` is a definition or the name of one in the config's `workflows` (`client.start("refund", …)`); a name the config does not have is refused with `invalid_input`, naming the ones it has. `startedBy` is required. `start(workflow, input, { startedBy, runId })` with a `runId` makes a retried start idempotent: an id that exists returns that run when the workflow, the input (as JSON) and `startedBy` match, and is refused with `invalid_input`, naming what differs, when they do not. Of two starts racing with one new id, the first stands and the second is answered the same way. Errors the runtime and the client throw carry a `code` (`policy_denied`, `approval_rejected`, `not_approver`, `no_pending_approval`, `already_decided`, `run_not_found`, `driver_failed`, `invalid_input`, `run_ended`, `run_running`: `client.result` timed out with the run still going, `approval_pending`: a [direct call](#direct-calls) is held, `not_admitted`: the data files declare people and not this principal's id) and `data`. Read it with `errorCode(err)`, not `instanceof`: a run's error comes back from the database as a copy, so `errorCode(await client.result(runId).catch((e) => e))` is `"policy_denied"` for a denied call.
107
+ `workflow` is a definition or the name of one in the config's `workflows` (`client.start("refund", …)`); a name the config does not have is refused with `invalid_input`, naming the ones it has. `startedBy` is required. `start(workflow, input, { startedBy, runId })` with a `runId` makes a retried start idempotent: an id that exists returns that run when the workflow, the input (as JSON) and `startedBy` match, and is refused with `invalid_input`, naming what differs, when they do not. Of two starts racing with one new id, the first stands and the second is answered the same way. Errors the runtime and the client throw carry a `code` (`policy_denied`, `approval_rejected`, `approval_withdrawn`: the approval a call or step waited on was [withdrawn](#approvals), `not_approver`, `no_pending_approval`, `already_decided`, `run_not_found`, `driver_failed`, `invalid_input`, `run_ended`, `run_running`: `client.result` timed out with the run still going, `approval_pending`: a [direct call](#direct-calls) is held, `not_admitted`: the data files declare people and not this principal's id) and `data`. Read it with `errorCode(err)`, not `instanceof`: a run's error comes back from the database as a copy, so `errorCode(await client.result(runId).catch((e) => e))` is `"policy_denied"` for a denied call.
104
108
 
105
109
  `startWorker(config, { logLevel })` runs workflows and recovers interrupted runs. `SanomaClient` starts runs, lists them, records approval decisions and reads a run's ledger. `describeConfig(config)`, from `@sanoma-ai/workflows/describe`, returns the same config as plain JSON (its version, each workflow's input as JSON Schema, the operations it may call and its [outline](#outline), each operation's effect and contract: its input as a caller sends it, `io: "input"`, and its output as parsed, `io: "output"`), each vendor's title, logo, package and homepage and whether its connector attaches a fake (`vendors`, by vendor id, the logo as `data:image/svg+xml` URLs), the resource types (`resourceTypes`, see [Resources](#resources)), and the resources the data files declare, each with its binding, the lockfile's orphans and what is wrong in them (`resources`, `orphans` and `problems`, see [Data files](#data-files); a workflow's file's problems are on its entry, beside its `file` and `outline`), which is what a UI renders from.
106
110
 
107
- The worker, the client and the app find Postgres at the config's `databaseUrl`, else the `SANOMA_DATABASE_URL` environment variable, else `postgresql://postgres:dbos@localhost:5433/sanoma`, the database `pnpm db:up` starts from this repo's docker compose file. Set one of the first two anywhere but on your own machine.
111
+ The worker, the client and the app find Postgres at the config's `databaseUrl`, else the `SANOMA_DATABASE_URL` environment variable, else `postgresql://postgres:dbos@localhost:5433/sanoma`, the database `pnpm db:up` starts from this repo's docker compose file. The `sanoma` launcher always sets `SANOMA_DATABASE_URL`: when none is named it starts the company's own Postgres ([sanoma's Postgres](../sanoma/README.md#postgres)). Set one of the first two anywhere but on your own machine.
108
112
 
109
113
  ### People
110
114
 
@@ -119,7 +123,7 @@ export const refundBot = sanoma.agent({ id: "refund-bot", onBehalfOf: bo });
119
123
  export const finance = sanoma.group({ name: "finance", members: [ada] });
120
124
  ```
121
125
 
122
- A membership is written on the group alone. An agent is in the group `agents` besides its own, with `onBehalfOf` the person whose instruction it carries; the runtime's own agents (`scenarios`, `host-check`, `schedule`) are declared by no file. They have no vendor object: no driver, no drift. `readPeople(root)` reads them (again only when a data file changed), and `principalOf(id, people)` is who an id is: its groups, by inverting the members, and its `onBehalfOf`. Once a person is declared, `SanomaClient.start`, `call`, `decide`, `setCredential`, `setSecret` and `clearCredential` admit only a declared id (`not_admitted`, "<id> is not declared in resources/people.ts"), as the app's login admits only a declared person; while none is, any id is taken as given; while the people files have problems, nobody is admitted but the runtime's agents.
126
+ A membership is written on the group alone. An agent is in the group `agents` besides its own, with `onBehalfOf` the person whose instruction it carries; the runtime's own agents (`scenarios`, `host-check`, `schedule`, `wakeup`, which registers a wakeup) are declared by no file. They have no vendor object: no driver, no drift. `readPeople(root)` reads them (again only when a data file changed), and `principalOf(id, people)` is who an id is: its groups, by inverting the members, and its `onBehalfOf`. Once a person is declared, `SanomaClient.start`, `call`, `decide`, `setCredential`, `setSecret` and `clearCredential` admit only a declared id (`not_admitted`, "<id> is not declared in resources/people.ts"), as the app's login admits only a declared person; while none is, any id is taken as given; while the people files have problems, nobody is admitted but the runtime's agents.
123
127
 
124
128
  A visitor of a public site is a principal too, which no data file declares: `visitorPrincipal(login, subject)` is one signed in through a visitor login (`visitor:<login>:<subject>`, in the group `visitors`), and `ANONYMOUS_PRINCIPAL` the one a page with nobody signed in runs as (`anonymous`, in no group); `isVisitor(principal)` tells either by its id. `admit` takes a visitor's id whatever the files say and stamps its groups, never the ones given; the staff logins (a sign-in) admit none, and a visitor sets no credential and decides no approval. So `visitors` and `anonymous` are no group's name, and `anonymous` and the `visitor:…` form no person's or agent's id (`readPeople` reports them, as it does `agents`).
125
129
 
@@ -142,9 +146,10 @@ permit (principal in Sanoma::Group::"visitors", action == Sanoma::Action::"workf
142
146
  permit (principal == Sanoma::Principal::"anonymous", action == Sanoma::Action::"data.posts.list", resource);
143
147
  ```
144
148
 
145
- - **The schema**, namespace `Sanoma`: `Principal` in `Group` (an enum of the declared groups, `agents` and `visitors`, so a misspelt group fails validation), with `onBehalfOf`; each operation's id an action in its effect's group (`effect:money`), on a `Target` (its `target`, else its id; a collection's in `Collection::"<name>"`), with `context.input` from its input schema and, for a collection's save or delete, `context.before`; `workflow:<name>` in the group `start`, on a `Workflow`, with the run's input. `schemaText` prints it; the `sanoma` bin writes it to `.sanoma/schema.cedarschema`.
149
+ - **The schema**, namespace `Sanoma`: `Principal` in `Group` (an enum of the declared groups, `agents` and `visitors`, so a misspelt group fails validation), with `onBehalfOf`; each operation's id an action in its effect's group (`effect:money`), on a `Target` (its `target`, else its id; a collection's in `Collection::"<name>"`), with `context.input` from its input schema and, for a collection's save or delete, `context.before`; `sanoma.change.merge` on a `Change` instead, whose attributes are the change's facts; `workflow:<name>` in the group `start`, on a `Workflow`, with the run's input. `schemaText` prints it; the `sanoma` bin writes it to `.sanoma/schema.cedarschema`.
146
150
  - **A hold** is a `forbid` with `@hold("<group>" | "<person id>" | "on-behalf-of")`: the call waits for that approver (`on-behalf-of`: whom the agent acts for), with `@title` as the approval's title. The runtime lifts it once an approval addressed to that approver and covering the operation is approved (`approvedFor`), so a workflow's own `ctx.approval` to the same approver, covering the operation, lets it through. Several holds on one call or start are asked one at a time, in the order written: once one is approved, the policy is asked again. **A deny** is a `forbid` without `@hold`, with `@reason` as its message (else `Refused by <id>`). A policy's id is its `@id`, else `<file>#<n>`; a decision's `reasons` carry the ids into the ledger.
147
151
  - **Where it runs**: before every operation call, a run's node, a [direct call](#direct-calls) and [apply](#apply)'s changes (`decideCall`), and before a run starts (see [Approvals](#approvals)). `policy.preview(requests)` asks the same with the input unknown, through Cedar's partial evaluation: `allow`, `hold` with its approver, `deny`, or `depends` on the input, each with the rule behind it; the app's run form and Permissions page show it. A request with `inRun: true` asks about an operation inside a run, not a direct call, which only a visitor's answer tells apart.
152
+ - **A change** to the company's repository is decided on its merge, `sanoma.change.merge`, one of four operations of the built-in connector `sanoma` (`changeOps`: `sanoma.change.open`, `.review`, `.merge` and `.close`, effect `write`) that every config has and only the built-in `change` workflow may call, so a policy names it in every repo. Its resource is a `Sanoma::Change` whose attributes are the facts of the change (`ChangeFacts`): `touches` (each path it edits and each parent directory, `touchesOf`: `resources/`, `resources/finance/`, `resources/finance/cards.ts`), `strandedRuns` and `stranded` (the waiting runs of a workflow it edits), `checksOk` and `rules`. Cedar has no quantifier over a set and `like` reads one string, so a rule asks `contains` of a directory: `forbid (principal, action == Sanoma::Action::"sanoma.change.merge", resource is Sanoma::Change) when { resource.touches.contains("resources/finance/") } unless { principal in Sanoma::Group::"finance" };`. A preview asks with the facts unknown: a rule on any change holds, a rule on the facts depends. Before any policy, the runtime's own rule (`runtimeHold`): a merge of a change to the rules (`rules`: a policy or a people file) waits for the group `admin`, with the reason `sanoma:rules-wait-for-admin`, under `allowAll` too, and is denied while no data file declares `admin`; the people are the running instance's, so a change cannot add its author to `admin`. The company's policy is asked once an approval addressed to `admin` covering the merge lifts it. The template's `policies/changes.cedar` holds every change for `admin`.
148
153
  - **Problems** (a file that does not parse, two policies with one id, a template, what Cedar's strict validation finds, a `permit` for anyone but the visitors or `anonymous`, or with a `@hold`, a `@hold` naming no declared group or person, `visitors` among them) are `resolveConfig`'s `policyProblems`, one line each, `file:line:col: <policy id>: <message>`. While there are any, the policy refuses every call, start and preview ("The policies do not hold: …"): a repo never runs on part of its rules. `describeConfig(config).policy` carries them as `problems`; `startWorker` warns with them (unless `quiet`), `startApp` lists them and its pages say the policies do not hold, `sanoma check` reports them and runs no scenario, and the `sanoma` bin starts nothing.
149
154
 
150
155
  Later, not yet: the person's numeric GitHub id is stored but unused, so a login renamed and taken by someone else would be admitted as them. The app describes the config when it starts, so a person added while it runs shows in the who-are-you picker and the Permissions grid after a restart (login admits them at once). The Permissions grid asks about workflow starts and direct operations only, not the operations a run calls.
@@ -163,7 +168,7 @@ Every store keeps the first record of an id: a run replayed after a restart writ
163
168
 
164
169
  An approval comes from the workflow (`ctx.approval(title, { approver, covers?, links?, details? })`) or from the policy holding a call (a `@hold`). Each is in `run.approvals` with its `status`, so a later call it covers is let through once it is approved.
165
170
 
166
- `covers` says which operations an approval stands for, as op ids in the approval's state. A policy hold covers the operation it held; a workflow's approval covers the operations it names, or none. The runtime lifts a hold with `approvedFor(run.approvals, op.id, approver)`: approved, covering this operation, and addressed to the hold's approver. The last part matters: a workflow can request an approval covering any operation from anyone it names, so a check on `covers` alone would let a workflow launder a sign-off through its own `ctx.approval`. Covers name operations, not inputs: an approval that covers `shop.order.refund` covers every later refund call in the run.
171
+ `covers` says which operations an approval stands for, as op ids in the approval's state. A policy hold covers the operation it held; a workflow's approval covers the operations it names, or none. The runtime lifts a hold with `approvedFor(run.approvals, op.id, approver)`: approved, covering this operation, and addressed to the hold's approver. The last part matters: a workflow can request an approval covering any operation from anyone it names, so a check on `covers` alone would let a workflow launder a sign-off through its own `ctx.approval`. A withdrawn approval is no longer approved, so it lifts nothing. Covers name operations, not inputs: an approval that covers `shop.order.refund` covers every later refund call in the run.
167
172
 
168
173
  The approver is a person's id (`"finance-lead"`), or `{ group: "finance" }` for anyone whose principal lists that group in `groups`. A group's name is not a person: `{ id: "finance" }` is not in the group `finance`. `mayDecide(approval, principal, run, people)` is the check the run, the client and the app's Inbox all use; it also refuses the run's own actor while someone else could decide, that is while the approver is a group with another declared person in `people` (the declared people resources; an agent in the group, declared or the runtime's own, does not count; `own change`: nobody decides on their own change, though a person may decide on a run an agent started for them). When nobody else could (the approver is the starter by id, or a group they alone are in), the starter decides, and the `approval.decided` record and the approval say `alone: true`. A policy hold's title is its `@title`, else `<op id> needs <approver>`, the approver shown as `group finance` for a group.
169
174
 
@@ -173,6 +178,8 @@ The policy decides a run's start too, as the action `workflow:<name>` with the i
173
178
 
174
179
  `client.decide(runId, { decision, by, note? }, approvalId?, { timeoutSeconds? })` refuses without sending when the approval is decided already (`already_decided`), when the run has finished, failed or been cancelled (`run_ended`: no run would read the decision), when there is nothing pending (`no_pending_approval`, `run_not_found`) or when `by` may not decide (`not_approver`, naming the approver or group). Otherwise it sends the decision and waits for the run to read it, then returns the approval as decided: the run publishes it on the event `decisionEventOf(approvalId)`. If another decision reached the run first (someone else's, or another of yours), it throws `already_decided` with who decided and how: each message carries an `id` (a new one unless `message.id` is given), and the approval records the one it was decided with as `decidedWith`. The id is also the send's idempotency key, scoped to the approval, so a retried send queues one message. If the run does not read the decision within `timeoutSeconds` (30 by default), for instance because no worker is running, it returns the approval still `pending`; the decision stays queued and the run reads it when it next runs. The run checks the sender again and records anything it refuses as `approval.refused`; when it refuses this decision, `decide` throws `not_approver` rather than returning the approval pending.
175
180
 
181
+ An approval that no longer stands, as when its change gets a new commit, is withdrawn: its `status` becomes `withdrawn`, with `withdrawnReason`, `withdrawnAt` and `withdrawnBy` (who, unless its run withdrew it), and the ledger gets `approval.withdrawn` with the same `reason` and `by`. `client.withdraw(runId, approvalId, reason, { by, timeoutSeconds? })` withdraws a pending one, as the run's starter or someone who may decide it (`not_approver` otherwise; a visitor never), and refuses as `decide` does (`already_decided` once it is not pending); the run reads the withdrawal as it would a decision (an `ApprovalWithdrawal` message, `{ withdraw: reason, by, id? }`, on the approval's topic), checks `by` again (refusing as `approval.refused` otherwise), sets `decidedWith`, and the call or `ctx.approval` waiting on it throws `WithdrawnError` (`approval_withdrawn`, with `approvalId` and `reason`); a held call records it as its failed `op.called`, as a rejection. A decision sent after it is `already_decided`. A built-in withdraws its own approved approvals of an operation from its body, so they lift no later hold on it.
182
+
176
183
  ### Calls run one at a time
177
184
 
178
185
  A run's ctx calls run one at a time, in program order. Even inside `Promise.all`, each call waits for the one before it to settle, so two calls a policy holds for approval are asked for one after the other. DBOS matches a replayed call to its recorded result by the order calls reach it, so calls left to race would replay out of step. A call that fails rejects its caller. The calls queued after it still run only if the workflow catches the failure and goes on; otherwise the body has ended, and each queued call is refused with `run_ended` (the run has ended, so the call is never made) instead of reaching its vendor, an approver or a sleep. Write calls one after another, as the workflow means them, and a fan-out with `ctx.all`.
@@ -400,10 +407,24 @@ This package knows nothing of OpenTofu. Resource types from an OpenTofu provider
400
407
 
401
408
  ### Hosts
402
409
 
403
- A host is a resource type that runs the company (a container, a Render service, a Fly app): `defineResource({ …, writable: true, host })`, where `host` (`HostSpec`) says where the type takes the runtime's inputs, by dotted path into its fields (`inputs: { source, ref, secrets, port, domains? }`, `secrets` a write-only field; `domains`, when the type takes it, a public site's domain by site name, which the host hands the app as `SANOMA_DOMAINS` and `describeConfig` reports a problem for, at the declaration, when it names a site that is not public or gives one domain two sites: `sanoma.example is the domain of both www and docs`), which field apply fills with the commit (`revision`, which a data file may not declare: it names a branch, never a commit), what it can do (`capabilities: { lifetime, publicUrl, buildsFromGit, staticEgress }`), and how its state reads (`outputs(state) → { url, revision?, healthy }`). `defineResource` refuses a `host` that names no field, or whose `secrets` is not write-only. A write-only field may be a map of secrets (`secrets: { SANOMA_DATABASE_URL: secret("DATABASE_URL") }`): its markers are kept as one at the field is. A host type is `stateless` (a `ResourceSpec` field, default true for a host): its objects keep no data, so replacing or recreating one is routine. `source` is a clone URL, or a reference to a declared repository with a `by` field holding one.
410
+ A host is a resource type that runs the company (a container, a Render service, a Fly app): `defineResource({ …, writable: true, host })`, where `host` (`HostSpec`) says where the type takes the runtime's inputs, by dotted path into its fields (`inputs: { source, ref, secrets, port, domains? }`, `secrets` a write-only field; `domains`, when the type takes it, a public site's domain by site name, which the host hands the app as `SANOMA_DOMAINS` and `describeConfig` reports a problem for, at the declaration, when it names a site that is not public or gives one domain two sites: `sanoma.example is the domain of both www and docs`), which field apply fills with the commit (`revision`, which a data file may not declare: it names a branch, never a commit), what it can do (`capabilities: { lifetime, publicUrl, buildsFromGit, staticEgress }`, `lifetime` `long-lived`, `stops-on-exit` or `stops-when-quiet`, `HostLifetime`), and how its state reads (`outputs(state) → { url, revision?, healthy }`). `defineResource` refuses a `host` that names no field, or whose `secrets` is not write-only. A write-only field may be a map of secrets (`secrets: { SANOMA_DATABASE_URL: secret("DATABASE_URL") }`): its markers are kept as one at the field is. A host type is `stateless` (a `ResourceSpec` field, default true for a host): its objects keep no data, so replacing or recreating one is routine. `source` is a clone URL, or a reference to a declared repository with a `by` field holding one.
404
411
 
405
412
  A config whose connectors declare a host type has the built-in operation `sanoma.source.resolve` (`SOURCE_RESOLVE`, effect `read`): `{ url, ref } → { revision }`, by `git ls-remote` on this machine (a branch, then a tag, peeled; a full commit id is itself). Apply calls it for each host it plans, and gives the host the commit as its `revision` and the clone URL as its `source` (a referenced repository's, from its `by` field); a host whose ref does not resolve, or whose repository has no clone URL yet (apply the repository first), is a problem of the plan. The drift run calls it for every host it reads. A host's `secrets` map may name sanoma's own secrets (`SANOMA_…`), and no other field of any type may. `resolveRevision(url, ref)` is the same, outside a run.
406
413
 
414
+ A wakeup is a resource type that starts a stopped instance at a time, for what is due while its host is stopped: `defineResource({ …, writable: true, wakeup })`, where `wakeup` (`WakeupSpec`) names the field that references the host (`inputs.host`), the type's own operation the runtime registers each deadline through (`register`, called with `{ at, generation }`) and how its state reads (`outputs(state) → { healthy }`); `defineResource` and `resolveConfig` refuse one that does not meet it. Declaring one in a data file is the switch, with no mode flag: `declaredWakeup(config)` reads it, and several are a problem of the data files. `wakeGeneration(url)` reads the `generation` of the `GET /wake?generation=N` a wakeup sends (digits alone, else undefined), as `sanoma serve` answers it. A config with `wakeup: true` runs the wakeup service itself and must not stop, so `startWorker` refuses it beside a declared wakeup.
415
+
416
+ A worker whose data files declare a wakeup, started with `onStopped` (whoever starts the next one; without it the worker never stops), stops itself when nothing it would run can run soon. Every 15 s (`stopCheckMs`) it asks `worker.idle()`: no run is executing or replaying; none of its version is queued, on its queue or on DBOS's own, where recovery puts runs; every unfinished run of its version is blocked in a `ctx.sleep` or a `ctx.approval`; and the next deadline (the earliest sleep's end, or a source added with `worker.deadlines.addSource`, such as a schedule's next fire) is more than `idleHorizonMs` away (60 s), so short waits never stop it. An approval has no deadline: its decision comes from a request, which starts the worker. Runs of another version or queue are not this worker's and never keep it up. The worker counts the `sanoma_wakeup` row's `generation` up, registers the next deadline through the wakeup type's `register` (`{ at, generation }` as the agent `wakeup`, idempotency key `wakeup:<binding or declaration id>:<generation>`, no ledger record), records `registered_at` and `stopped_at`, stops, and calls `onStopped({ at, generation })`; with no deadline at all it registers nothing and records `at` as null. A failed registration is recorded as `last_error` and logged, and the worker keeps running and tries again at the next check.
417
+
418
+ A stopped worker cannot launch again in its process, so whoever supervises it starts a fresh `startWorker(config)` on the next request, or when the wakeup calls `/wake?generation=N` and `shouldWake(databaseUrl, N)` says that is the generation the worker last stopped with (an older one was replaced by a later stop). `superviseWorker(config, options)` is that supervisor, as `sanoma serve` runs it: one worker at a time, started with `onStopped` (its own `onStopped` hears each stop; `selfStop: false` gives none, so the worker never stops itself), and a fresh one on `resume()` (a write that needs one) or `wake(generation)` once the last stopped itself, a no-op while one starts or runs; a write heard while one starts or runs may land after its last idle check, so a worker that stops after one starts again at once. `SanomaClient.connect(config, { onWrite })` calls `onWrite` right before each change a worker must run (a start, drift, apply and a held call among them, and a decision), never for a read: the app passes it, to resume its process's worker. Apply gives a declared wakeup its host's URL: its `inputs.host` field holds what the host's `outputs(state).url` says, from the host's state found in the run or made by it, where any other reference resolved `by` holds the binding id. Each worker takes the row with an owner of its own when it starts, and a generation of its own, so a wake registered before is stale and a worker another process has replaced since changes nothing; `at` is the deadline registered for the row's generation, null until one is. Every start costs each unfinished run of its version one of DBOS's recovery attempts, so the runtime raises them from DBOS's 100 to 100,000; and a `ctx.sleep` for a duration takes its start from DBOS's clock, so a recovered run keeps the deadline it registered.
419
+
420
+ #### The wakeup service
421
+
422
+ `startWakeupService({ databaseUrl, now?, fetch?, log? })` from `@sanoma-ai/workflows/wakeup-service` (server-side only, refused in workflow files like `/scenario`) is the service a wakeup type registers with: `sanoma wakeup` runs it, and `sanoma serve` does with `wakeup: true` ([the sanoma package](../sanoma/README.md#the-wakeup-service) says how an instance registers). It makes its two tables in `databaseUrl` (and the database, when missing) and returns `{ routes, mintAccount(label), revokeAccount(id), stop() }`: `routes` is one route answering everything under `/wakeup` (a body over 64 KiB is a 413), the shape of the app's `IngressRoute` with `prefix`, for `startApp`'s `ingress` or a server of your own; `mintAccount` returns `{ id, token }`, the token shown that once; `revokeAccount` refuses the account's token and its instances' and wakes them no more. One loop sleeps until the next registered `at` (at most 60 s, or until a `PUT` takes a registration), takes each due instance for 30 s (so two services on one database never call it twice), calls its `GET {url}/wake?generation=N` with a 10 s timeout, eight at a time, and on anything but a 2xx (a redirect, which it never follows, among them) tries again after `min(2^attempts s, 5 min)`, never giving up. A registration replaced during its call is called again. `stop` ends the loop, abandoning the calls in flight (called again once their 30 s lapse), and closes its pool. `mintWakeupAccount(databaseUrl, label)` mints an account without starting the service, for `sanoma wakeup account`. The service never mints an instance's token: `mintInstanceToken()` makes one (`swi_…`) for the company to keep, which it registers with `POST /wakeup/instances { url, token }`. `now` and `fetch` are for tests; `log` takes an `info` line per call and a `warn` per failure (the runtime's logger by default).
423
+
424
+ ### Databases
425
+
426
+ A database is a resource type that holds the company's database (a Neon project, a Supabase project): `defineResource({ …, writable: true, afterCreate, database })`, where `database` (`DatabaseSpec`) says what it can do (`capabilities: { pauses, branch }`: its compute scales to zero and wakes on a connection; it makes copy-on-write branches that carry the data), where it takes going live's choices, by dotted path into its fields (`inputs: { region, size? }`), the regions it takes when known (`regions`), the operation that stores its URL (`storeUrl`) and how its state reads (`outputs(state) → { healthy }`). `storeUrl` is an operation of the type's own vendor, in the type's own group (`neon.project.storeUrl`) or another (`supabase.database.storeUrl`), never one of a resource type's own: it takes `{ ref | id, export }` and stores the URL that carries `LISTEN` as `SANOMA_DATABASE_URL_<EXPORT>` (`databaseUrlSecret(export)`; `storeDatabaseUrl` stores it so, refusing a secret that holds another), never returning it, and the type's `afterCreate` calls it. A database type is not `stateless`: apply asks before it deletes one. `defineResource` refuses a `database` that breaks any of that; `resolveConfig` refuses one whose `storeUrl` is not among the config's operations, or does not take a binding id and an export. Its conformance kit is [`@sanoma-ai/testing/database`](../testing/README.md#a-databases-conformance).
427
+
407
428
  ### Secrets
408
429
 
409
430
  Never put a secret in a workflow's input or an operation's input or output. They are persisted verbatim: DBOS keeps every step's input and output in Postgres, the ledger records each call's input and output, an approval a policy asks for carries the held call's input, and the app shows all of it to anyone who can reach it. A driver reads its credentials when it is called (from the environment or a secret store), and an operation that creates a secret (an API key, a password reset link) returns a reference to where it is stored, not the secret.
@@ -422,7 +443,7 @@ Queues used to be one `sanoma` queue for every app and are now `sanoma:<appName>
422
443
 
423
444
  A run is replayed after a restart by calling the function again and reading each step's result back, so workflows must do the same thing every time, and must reach vendors only through `ctx` so the policy sees every call. Two checks guard against getting that wrong by accident, on files under `workflows/`. They are not a sandbox: they read the source, and code written to get around them can.
424
445
 
425
- oxlint, with the rules this package ships in `oxlint.json`, refuses the clock (`Date.now()`, `new Date()` and `Date()`, through the plugin's rule `sanoma/date`, which allows `new Date(await ctx.now())`; `performance`), randomness (`Math.random`, `crypto`), the network (`fetch`, `WebSocket`), timers, `process`, `globalThis`, `Promise.all` and its kin (use `ctx.all`; nothing races), and imports of `@sanoma-ai/testing`, `@sanoma-ai/app`, `@sanoma-ai/workflows/describe`, `@sanoma-ai/workflows/fake`, `@sanoma-ai/workflows/plugin`, `@sanoma-ai/workflows/scenario`, `@sanoma-ai/workflows/scenarios`, `@sanoma-ai/connector-*/fake` and `@sanoma-ai/connector-*/driver`. From `@sanoma-ai/workflows` it allows only `defineWorkflow`, `mayDecide`, `errorCode`, `z` (which `sanoma` re-exports) and types (the list is `allowImportNames` in `oxlint.json`; the `sanoma` package's own `oxlint.json` allows the same names from `sanoma` and refuses its subpaths): the rest could start runs or approve the run's own approvals (`SanomaClient`, `startWorker`), forge the audit record (`jsonlLedger`, `memoryLedger`: a store keeps the first record per id) or read credentials. Each message names the `ctx` replacement. `sanoma check` runs it, through `sanoma/oxlint.json`, which carries these rules; without `sanoma`, extend this package's from your `.oxlintrc.json` by its path: oxlint resolves `extends` as a file, not a package name, so `@sanoma-ai/workflows/oxlint` would not load. The `workflows/**` glob resolves against your config:
446
+ oxlint, with the rules this package ships in `oxlint.json`, refuses the clock (`Date.now()`, `new Date()` and `Date()`, through the plugin's rule `sanoma/date`, which allows `new Date(await ctx.now())`; `performance`), randomness (`Math.random`, `crypto`), the network (`fetch`, `WebSocket`), timers, `process`, `globalThis`, `Promise.all` and its kin (use `ctx.all`; nothing races), and imports of `@sanoma-ai/testing`, `@sanoma-ai/app`, `@sanoma-ai/workflows/describe`, `@sanoma-ai/workflows/fake`, `@sanoma-ai/workflows/plugin`, `@sanoma-ai/workflows/scenario`, `@sanoma-ai/workflows/scenarios`, `@sanoma-ai/workflows/wakeup-service`, `@sanoma-ai/connector-*/fake` and `@sanoma-ai/connector-*/driver`. From `@sanoma-ai/workflows` it allows only `defineWorkflow`, `mayDecide`, `errorCode`, `z` (which `sanoma` re-exports) and types (the list is `allowImportNames` in `oxlint.json`; the `sanoma` package's own `oxlint.json` allows the same names from `sanoma` and refuses its subpaths): the rest could start runs or approve the run's own approvals (`SanomaClient`, `startWorker`), forge the audit record (`jsonlLedger`, `memoryLedger`: a store keeps the first record per id) or read credentials. Each message names the `ctx` replacement. `sanoma check` runs it, through `sanoma/oxlint.json`, which carries these rules; without `sanoma`, extend this package's from your `.oxlintrc.json` by its path: oxlint resolves `extends` as a file, not a package name, so `@sanoma-ai/workflows/oxlint` would not load. The `workflows/**` glob resolves against your config:
426
447
 
427
448
  ```json
428
449
  {
@@ -447,7 +468,7 @@ it("has no problems", () => {
447
468
 
448
469
  ## Fakes for tests
449
470
 
450
- `@sanoma-ai/workflows/fake` exports `defineFake(connector, { initial, ops }, { calls? })`, the fake a connector package attaches the maker of (`withSetup`), which builds an in-memory vendor for a connector: `ops` implements every operation against the fake's state, typed by the connector as `defineDriver` is, and the fake adds what a real vendor does around them (a repeated idempotency key gets the first reply and changes nothing) and faults a test can inject (`failNext`, `loseReply`, `rateLimit`, `hold`). `update(change)` changes the state as someone at the vendor would, so the next call sees it. `calls` logs into a list given, so several fakes share one ordered log. The connectors' own fakes (`@sanoma-ai/connector-ghost/fake` and the others) are built with it. The entry also declares `ResourceFake`, the contract of a fake that holds its vendor's objects by resource type and import id (`put`, `override`, `remove`, with fields in the resource's shape), which `@sanoma-ai/bridge`'s `tfFake` meets and a scenario's [resource steps](#scenarios-and-sandbox-runs) seed through. It is a separate entry so the runtime carries no test tooling, and the lint refuses it in workflow files.
471
+ `@sanoma-ai/workflows/fake` exports `defineFake(connector, { initial, ops }, { calls? })`, the fake a connector package attaches the maker of (`withSetup`), which builds an in-memory vendor for a connector: `ops` implements every operation against the fake's state, typed by the connector as `defineDriver` is, and the fake adds what a real vendor does around them (a repeated idempotency key gets the first reply and changes nothing) and faults a test can inject (`failNext`, `loseReply`, `rateLimit`, `hold`). `update(change)` changes the state as someone at the vendor would, so the next call sees it. `calls` logs into a list given, so several fakes share one ordered log. The connectors' own fakes (`@sanoma-ai/connector-ghost/fake` and the others) are built with it. The entry also declares `ResourceFake`, the contract of a fake that holds its vendor's objects by resource type and import id (`put`, `override`, `remove`, with fields in the resource's shape), which `@sanoma-ai/bridge`'s `tfFake` meets and a scenario's [resource steps](#scenarios-and-sandbox-runs) seed through. `withFake(connector, fake)` is the connector set up with that fake instead of the one its package attaches, so live runs call it, and sandbox runs too, since its maker gives this very one (`@sanoma-ai/testing` re-exports it). It is a separate entry so the runtime carries no test tooling, and the lint refuses it in workflow files.
451
472
 
452
473
  ## Scenarios and sandbox runs
453
474
 
@@ -569,23 +590,36 @@ Start a sandbox run with `client.start(workflow, input, { startedBy, sandbox: "<
569
590
  - runs it on the app's queue, as any run: sandbox runs share no fakes, so several run at once, and one waiting on an approval holds up no other.
570
591
  - prints nothing of it through DBOS's log: none of DBOS's warnings from inside it (a step's failed try among them: a fake's `fails once` is on purpose), nor the error the run fails with. Its ledger and its status say what happened; a live run's tries and failures print as ever.
571
592
 
572
- A sandbox run does not survive a worker restart: its fakes keep their state in the worker's memory, so a run whose seeding DBOS replays from its checkpoint (after a restart, or in a fork) fails with `invalid_input`, "Sandbox run … was interrupted by a worker restart and the fakes' state is gone; start the scenario again", rather than going on against fakes in some other state.
593
+ A sandbox run does not survive a worker restart: its fakes keep their state in the worker's memory, so a run whose seeding DBOS replays from its checkpoint (after a restart, or in a fork) fails with `invalid_input`, "Sandbox run … was interrupted by a worker restart and the fakes' state is gone; start the scenario again", rather than going on against fakes in some other state. On an instance that runs on fakes ([demos](#demos)) a replayed run goes on with the instance's.
573
594
 
574
595
  `RunSummary.sandbox` names the scenario a sandbox run was seeded from (kept in DBOS's `attributes` for the run). Reusing a run id with another `sandbox`, or none, is `invalid_input`, as with another input.
575
596
 
576
- `runScenarios(config, { databaseUrl, startedBy?, timeoutMs?, log? })` from `@sanoma-ai/workflows/scenarios` (server-side only, like `/scenario`) runs every scenario of the config as a sandbox run, on a worker it starts on `databaseUrl` with an in-memory ledger and stops after, and returns `{ passed, failed }`: the names of the scenarios whose every check held, and one `{ scenario, step, message }` per step that did not (with `check`'s detail), per run that could not be driven to its end (at its `When` step), and per feature file that did not load (`step: "did not load"`); a config whose root has no `scenarios/` passes and fails nothing. `sanoma check` runs it. `startedBy` (an id or a principal) starts each run whose scenario does not say who `is acting`. `runScenario(scenario, { client, scope, startedBy?, timeoutMs? })` runs one against a worker you started, `scope` being what it was loaded from (the resolved config). To run them as tests, a vitest test each, use `describeScenarios` from [`@sanoma-ai/testing/scenarios`](https://github.com/Sanoma-AI/sanoma/blob/main/packages/testing/README.md#scenarios), which wraps the same `runScenario`.
597
+ A scenario with no `When`, in a feature none of whose scenarios has one, is a _world_: its `Given` steps alone, the state a demo's instance starts from, which nothing runs or checks (`workflow` is absent, and a `Then` or a decision in it is refused). A scenario tagged `@moment(<person>,<path>)` (no space: a Gherkin tag has none), such as `@moment(alex,/sites/portal/requests)`, is a _moment_: it needs a `When`, its person must be a declared one (as `is acting`'s), and a demo starts it as that person and leaves it waiting, for a visitor signed in as them to land on at the path. Every scenario keeps its tags as written (`tags`, the feature's and its own), and a moment its `moment`, `{ person, path }`.
598
+
599
+ `runScenarios(config, { databaseUrl, startedBy?, timeoutMs?, log? })` from `@sanoma-ai/workflows/scenarios` (server-side only, like `/scenario`) runs every scenario of the config as a sandbox run, on a worker it starts on `databaseUrl` with an in-memory ledger and stops after, and returns `{ passed, failed }`: the names of the scenarios whose every check held, and one `{ scenario, step, message }` per step that did not (with `check`'s detail), per run that could not be driven to its end (at its `When` step), and per feature file that did not load (`step: "did not load"`); a config whose root has no `scenarios/` passes and fails nothing. `sanoma check` runs it. `startedBy` (an id or a principal) starts each run whose scenario does not say who `is acting`. Worlds, and moments that decide nothing (which would wait at their first approval), are no tests (`isTest`): `runScenarios` leaves them out, logging each as skipped, and `describeScenarios` registers none. `runScenario(scenario, { client, scope, startedBy?, timeoutMs? })` runs one against a worker you started, `scope` being what it was loaded from (the resolved config). To run them as tests, a vitest test each, use `describeScenarios` from [`@sanoma-ai/testing/scenarios`](https://github.com/Sanoma-AI/sanoma/blob/main/packages/testing/README.md#scenarios), which wraps the same `runScenario`.
600
+
601
+ ### Demos
602
+
603
+ A demo is a company repo run on its connectors' fakes, seeded from its scenarios. Resolve the config with `fakes: "instance"` and start the worker and the client on that one resolution, then `reseed(client, resolved)` from `@sanoma-ai/workflows/scenarios`: it empties `sanoma_data`, resets the instance's fakes, applies every world to the instance (its records saved through the collections' driver, its vendor objects and calls into the instance's fakes; a fault is refused, since every run shares them), and starts each moment as a sandbox run by its person, undriven, so its first approval waits in the Inbox. A sandbox run on such an instance seeds and calls the instance's fakes and the collections' table, not fakes of its own. `reseed` resolves to a `DemoState`, `{ seededAt, worlds, moments, problems }`, each moment with its `person`, `path`, `scenario` and `runId`, and a line in `problems` for each feature file that did not load and each world or moment that failed while the rest went on; `demoState(resolved)` is the last one, for a banner. The runs of earlier moments are left as they are.
604
+
605
+ ```ts
606
+ const resolved = resolveConfig(config, { fakes: "instance" });
607
+ const worker = await startWorker(config, { resolved });
608
+ const client = await SanomaClient.connect(config, { resolved });
609
+ const { moments } = await reseed(client, resolved);
610
+ ```
577
611
 
578
612
  ## Building your own UI
579
613
 
580
614
  `@sanoma-ai/app` is one UI over a config; another (a Slack bot, an internal tool) can be built on the same pieces, which the package exports for that:
581
615
 
582
616
  - `describeConfig(config)` and its types (`ConfigDescription`, `WorkflowEntry`, `OpEntry`, `VendorEntry`, `ResourceTypeEntry`, `DeclaredResource`, `ResourceProblem`), and `readDataFiles(root, connectors)` and `readResources(config)`, from `@sanoma-ai/workflows/describe`: what to render, as plain JSON, with each workflow's outline. It is a separate entry so the worker never loads the parser the outline uses, and the lint refuses it in workflow files. `resolveConfig(config)` returns the checked config as a `ResolvedConfig`, with the operations and drivers by id, the resource types by `<vendor>.<type>` (`types`), the workflows by name (the built-ins `drift`, `apply` and `call` among them), its `root` and each vendor's `credentials` (`CredentialStatus`); `isOp(x)` tells an operation from a built-in in a workflow's `uses`.
583
- - `readSites(root, description, connectors, policies?)`, from `@sanoma-ai/workflows/describe`, which `describeConfig` returns as `sites`: what each site calls, read with oxc and never run, for a workflow's **Used by**. A site is a folder of `sites/` with a `routes/`, named as a URL segment; its `routes/**` and `components/**` (`.ts`, `.tsx`, less tests) are read for each `<RunForm workflow="…" />` and each use of `api`, both imported from `sanoma/site`, called or passed on (`queryFn: api.data.leads.list`): `api.<name>` and `api.<name>.<method>` are the workflow whose `apiNameOf` is `<name>`, `api.data.<collection>.<op>` a collection, `api.<vendor>.<resource>.<op>` the operation of that id. Each is a `SiteCall` (`kind`, `target`, `method`, what it calls of a workflow or collection as written (`start`, `latest`, `list`), `via`, `file`, `line`, `column`, and `page`, the page's path from its `createFileRoute` or `createLazyFileRoute` id, in a page's file); a `SiteEntry` holds a site's `name`, its `title` (a string `defineSite({ title })` in `site.ts`), its `calls` and its `problems`: each call to a workflow, collection or operation the config does not have (`calls workflow "<name>", which does not exist`), or to an operation a page may not call directly, and, given the policies (`describeConfig` passes them unless they have problems), on a public site each start (`api.<name>(…)`, `.start(…)`, a `RunForm`) and direct call that no company `permit` could let a visitor make, its `when` and `unless` aside (one naming `anonymous`; on a site with a `login`, `anonymous` or the group `visitors`), whose message ends with the permit to add, and, whatever the policies, its call of a built-in workflow or read of a workflow's runs but `.result` (`.latest`, `.runs`, `.approvals`, `.ledger`), which the app refuses a visitor; which `sanoma check` fails on. A name not written out (a variable, a template with holes, a computed member) is skipped, as is a call through a namespace import or a destructured `api`.
617
+ - `readSites(root, description, connectors, policies?)`, from `@sanoma-ai/workflows/describe`, which `describeConfig` returns as `sites`: what each site calls, read with oxc and never run, for a workflow's **Used by**. A site is a folder of `sites/` with a `routes/`, named as a URL segment; its `routes/**` and `components/**` (`.ts`, `.tsx`, less tests) are read for each `<RunForm workflow="…" />` and each use of `api`, both imported from `sanoma/site`, called or passed on (`queryFn: api.data.leads.list`): `api.<name>` and `api.<name>.<method>` are the workflow whose `apiNameOf` is `<name>`, `api.data.<collection>.<op>` a collection, `api.<vendor>.<resource>.<op>` the operation of that id. Each is a `SiteCall` (`kind`, `target`, `method`, what it calls of a workflow or collection as written (`start`, `latest`, `list`), `via`, `file`, `line`, `column`, and `page`, the page's path from its `createFileRoute` or `createLazyFileRoute` id, in a page's file); a `SiteEntry` holds a site's `name`, its `title` (a string `defineSite({ title })` in `site.ts`), its `pages` (each `SitePage` a `path` from a route file's id, one per path, a layout and its index being one; and on a path with one parameter, such as `/sites/www/blog/$slug`, `content`, the one kind its file reads an entry of by that parameter, `content.<kind>.get(params.slug)` (or `slug`, destructured) with `content` from `sanoma/site`, for the app's sitemap and its pages' languages, which `siteContentPages(root)` gives the app's build alone, path to kind), its `calls`, its `warnings` (on a public site, each page with one parameter whose file reads content but not by that parameter, so the sitemap lists none of its pages: a warning `sanoma check` prints and does not fail on) and its `problems`: each call to a workflow, collection or operation the config does not have (`calls workflow "<name>", which does not exist`), or to an operation a page may not call directly, and, given the policies (`describeConfig` passes them unless they have problems), on a public site each start (`api.<name>(…)`, `.start(…)`, a `RunForm`) and direct call that no company `permit` could let a visitor make, its `when` and `unless` aside (one naming `anonymous`; on a site with a `login`, `anonymous` or the group `visitors`), whose message ends with the permit to add, and, whatever the policies, its call of a built-in workflow or read of a workflow's runs but `.result` (`.latest`, `.runs`, `.approvals`, `.ledger`), which the app refuses a visitor; which `sanoma check` fails on. A name not written out (a variable, a template with holes, a computed member) is skipped, as is a call through a namespace import or a destructured `api`.
584
618
  - `generateApi(description)` and `writeApi(root, description)`, from `@sanoma-ai/workflows/describe`: a site's typed `api`, `.sanoma/api.ts` (`API_FILE`), from a `ConfigDescription`, types and JSDoc only and the same text for the same description. It holds a record type per collection and `CompanyApi`: `<apiNameOf(workflow)>: WorkflowFn<input>` per workflow, built-ins too; `<vendor>: { <resource>: { <op>: OpFn<input> } }` for the operations `direct` marks; `data: { <collection>: CollectionApi<record> }`; each member documented from its title or description. Then it augments `sanoma/site`'s `Register`. Inputs are typed from their JSON Schema for the kinds a start form draws, constants, and unions of them (`null` among them); anything else, and every output, is `unknown`. A workflow with `describeConfig`'s api-name problem is left out (`problems`). `writeApi` writes only when the text differs (`wrote`).
585
- - `SanomaClient`: call an operation directly (`call`, see [Direct calls](#direct-calls)), start runs, list them (`runs({ limit, status, workflow })`) or read a workflow's last result (`latest`), read a run's ledger and approvals, decide approvals, with the checks described above, and start a drift check or an apply and read its report (`drift`, `driftReport`, `apply`, `applyReport`, see [Drift](#drift) and [Apply](#apply)).
619
+ - `SanomaClient`: call an operation directly (`call`, see [Direct calls](#direct-calls)), start runs, list them (`runs({ limit, status, workflow })`) or read a workflow's last result (`latest`), read a run's ledger and approvals, decide approvals, with the checks described above, and start a drift check or an apply and read its report (`drift`, `driftReport`, `apply`, `applyReport`, see [Drift](#drift) and [Apply](#apply)). `client.chats` keeps the operator agent's chats in the config's database: `open({ id, person, engine, title })` (the id the browser gave the new chat), `attach(id, draftId)`, `upsert(id, messages)` (the AI SDK's UI messages, each by its id, a new one after the last), `load(id)`, `get(id)` and `list(person)` (the newest first, `Chat`).
586
620
  - `APPROVALS_EVENT` and `decisionEventOf(approvalId)`: the DBOS events a run publishes its approvals and each decision on, for a UI that reads DBOS directly. `ApprovalMessage` is the zod schema of a decision as a run reads it. `RunArgs` is what a run receives: its input, `startedBy` and, for a sandbox run, its scenario as `sandbox`.
587
621
  - `mayDecide(approval, principal, run, people)` and `approverLabel(approver)`: who may decide, and how to name them, the same way the run does. `isEnded(status)` and `ENDED_STATUSES`: the run statuses that read no more decisions; `RUN_STATUSES`: every run status, in the order a run may pass through them.
588
- - Errors: `errorCode(err)` for the code to branch on, `errorMessage(err)` for the text of anything thrown, `invalidInput(what, issues)` to build an `invalid_input` error from zod issues (`InputIssue` is one issue, without symbols in its path), and the classes `SanomaError`, `PolicyDeniedError`, `RejectedError`, `ApprovalPendingError` and `DriverError`. Read codes with `errorCode`, never `instanceof`.
622
+ - Errors: `errorCode(err)` for the code to branch on, `errorMessage(err)` for the text of anything thrown, `invalidInput(what, issues)` to build an `invalid_input` error from zod issues (`InputIssue` is one issue, without symbols in its path), and the classes `SanomaError`, `PolicyDeniedError`, `RejectedError`, `WithdrawnError`, `ApprovalPendingError` and `DriverError`. Read codes with `errorCode`, never `instanceof`.
589
623
  - `@sanoma-ai/workflows/shared` exports `mayDecide`, `approverLabel`, `errorMessage`, `isEnded`, `ENDED_STATUSES`, `RUN_STATUSES`, `DRIFT_WORKFLOW`, `CALL_WORKFLOW`, `isLoopback` (whether a host is this machine: `localhost`, `127.x.x.x`, `::1`), `problemAt` (a data-file problem's `file:line:column`), `problemLine` (a problem as one line: `file:line:column: message`, `file: message` or the message), `credentialReady` (a variable is set, or optional and unset) and the `RunStatus` and `CredentialStatus` types, the resource types' types (`Resource`, `ResourceSpec`, `ResourceFields`, `References`, `FieldReference`, `Declared`, `Declaring`, `DeclaredResource`, `ResourceProblem`) and the drift report's (`DriftReport`, `DriftResult`, `DriftField`, `DriftStatus`), with nothing else: no DBOS or Node imports, so a browser bundle can use them. The main entry exports them too.
590
624
  - `LedgerRecord` and `LedgerStore` for the audit record (`LedgerBody` is a record without the fields every record carries, and `LedgerGroup` a record's `ctx.all` tag), `postgresLedger(databaseUrl)` (the default), `jsonlLedger(dir)` and `memoryLedger()` to keep it, and `RUNTIME_VERSION`, this package's version as the runtime reports it.
591
625
 
package/dist/apply.d.ts CHANGED
@@ -191,7 +191,8 @@ type ApplyUse = ImportOp | PlanOp | CreateOp | UpdateOp | DeleteOp | ResolveOp |
191
191
  * and right after one that changes a binding, the lockfile written and committed
192
192
  * (`steps.write`), so an object made is never left unbound. An update is given the plan's action
193
193
  * and replace (`expect`), and refuses (`plan_changed`) when the vendor now plans otherwise; a
194
- * reference to a resource made in this run is given its new binding. A failed step is reported
194
+ * reference to a resource made in this run is given its new binding, and a wakeup's `host` the
195
+ * URL its host's state gives (`outputs(state).url`), found or made in this run. A failed step is reported
195
196
  * and the run goes on; a failure that ends the run (`isRunControlError`) ends it.
196
197
  */
197
198
  export declare function applyWorkflow(types: ReadonlyMap<string, Resource>, ops: ReadonlyMap<string, Op>, drivers: ReadonlyMap<string, unknown>, steps: ApplySteps): WorkflowDefinition<readonly ApplyUse[], typeof ApplyInput>;
package/dist/apply.js CHANGED
@@ -54,10 +54,11 @@ function inDependencyOrder(list) {
54
54
  /**
55
55
  * What a change operation is given of a declaration: its fields, where it names a resource the
56
56
  * vendor may hold by another field (`by`, as a repository's node id), that resource's binding id
57
- * when it has one, made in this run or before.
57
+ * when it has one, made in this run or before; a wakeup's `host`, the URL its host answers at
58
+ * (`urls`, by the host's declared id) once its state says.
58
59
  */
59
- function desiredOf(r, types, bindings, hosts) {
60
- const { fields, host } = types.get(`${r.vendor}.${r.type}`);
60
+ function desiredOf(r, types, bindings, hosts, urls) {
61
+ const { fields, host, wakeup } = types.get(`${r.vendor}.${r.type}`);
61
62
  const { references = {} } = fields;
62
63
  const out = structuredClone(r.desired);
63
64
  for (const [at, target] of Object.entries(r.refs)) {
@@ -66,6 +67,12 @@ function desiredOf(r, types, bindings, hosts) {
66
67
  if (references[fieldPathOf(at)]?.by?.length && bound !== undefined && place)
67
68
  place.holder[place.key] = bound;
68
69
  }
70
+ if (wakeup) {
71
+ const url = urls.get(r.refs[wakeup.inputs.host] ?? "");
72
+ const named = holderOf(out, wakeup.inputs.host);
73
+ if (url && named)
74
+ named.holder[named.key] = url;
75
+ }
69
76
  // A host is given its source's clone URL and the commit its ref names now.
70
77
  const run = hosts.get(r.id);
71
78
  if (host && run) {
@@ -247,7 +254,8 @@ function messageOf(step, before, after) {
247
254
  * and right after one that changes a binding, the lockfile written and committed
248
255
  * (`steps.write`), so an object made is never left unbound. An update is given the plan's action
249
256
  * and replace (`expect`), and refuses (`plan_changed`) when the vendor now plans otherwise; a
250
- * reference to a resource made in this run is given its new binding. A failed step is reported
257
+ * reference to a resource made in this run is given its new binding, and a wakeup's `host` the
258
+ * URL its host's state gives (`outputs(state).url`), found or made in this run. A failed step is reported
251
259
  * and the run goes on; a failure that ends the run (`isRunControlError`) ends it.
252
260
  */
253
261
  export function applyWorkflow(types, ops, drivers, steps) {
@@ -301,6 +309,18 @@ export function applyWorkflow(types, ops, drivers, steps) {
301
309
  }
302
310
  }
303
311
  }
312
+ // Where each declared host answers, as its state says, found now or made below: a wakeup is given it.
313
+ const urls = new Map();
314
+ const answersAt = (r, state) => {
315
+ const url = types.get(`${r.vendor}.${r.type}`)?.host?.outputs(state).url;
316
+ if (url)
317
+ urls.set(r.id, url);
318
+ };
319
+ for (const resource of resources) {
320
+ const now = found.get(resource.id);
321
+ if (now && "state" in now)
322
+ answersAt(resource, now.state);
323
+ }
304
324
  // A host wanted runs the commit its ref names now, resolved before planning: a merge is a change
305
325
  // to it. One bound by the input needs none.
306
326
  const revisions = new Map();
@@ -327,7 +347,7 @@ export function applyWorkflow(types, ops, drivers, steps) {
327
347
  }
328
348
  }
329
349
  const drift = new Map(compare(types, resources, found, revisions).map((result) => [result.id, result]));
330
- const desired = new Map(resources.map((r) => [r.id, desiredOf(r, types, locked, hosts)]));
350
+ const desired = new Map(resources.map((r) => [r.id, desiredOf(r, types, locked, hosts, urls)]));
331
351
  const planned = [];
332
352
  for (const resource of inDependencyOrder(resources).filter((r) => wanted(r.id))) {
333
353
  const result = drift.get(resource.id);
@@ -383,7 +403,7 @@ export function applyWorkflow(types, ops, drivers, steps) {
383
403
  try {
384
404
  if (todo === "create") {
385
405
  const made = await ctx[step.vendor][step.type].create({
386
- desired: desiredOf(declared, types, bindings, hosts),
406
+ desired: desiredOf(declared, types, bindings, hosts, urls),
387
407
  });
388
408
  bindings[key] = { type, id: made.id };
389
409
  state = made.state;
@@ -392,7 +412,7 @@ export function applyWorkflow(types, ops, drivers, steps) {
392
412
  const expect = { action: step.action, replace: step.replace };
393
413
  const changed = await ctx[step.vendor][step.type].update({
394
414
  id: binding,
395
- desired: desiredOf(declared, types, bindings, hosts),
415
+ desired: desiredOf(declared, types, bindings, hosts, urls),
396
416
  expect,
397
417
  });
398
418
  bindings[key] = { type, id: changed.id };
@@ -406,6 +426,8 @@ export function applyWorkflow(types, ops, drivers, steps) {
406
426
  bindings[key] = { type, id: binding };
407
427
  else if (todo === "forget")
408
428
  delete bindings[key];
429
+ if (state && declared)
430
+ answersAt(declared, state);
409
431
  const after = bindings[key];
410
432
  if (after?.id !== before?.id) {
411
433
  const wrote = await steps.write(key, after, messageOf(step, before, after));
package/dist/apply.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"apply.js","sourceRoot":"","sources":["../src/apply.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAiB,cAAc,EAA2B,MAAM,aAAa,CAAC;AACrF,OAAO,EACL,OAAO,EAKP,SAAS,EACT,SAAS,EACT,QAAQ,EAGR,SAAS,GACV,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAIhD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAkC,OAAO,EAAE,MAAM,eAAe,CAAC;AAE/F,OAAO,EAAuB,YAAY,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAA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;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { type ApprovalRequest, type ApprovalResult, Principal } from "./define.ts";
2
+ import { type ApprovalRequest, type ApprovalResult, type ApprovalState, Principal } from "./define.ts";
3
3
  import type { Placed } from "./call.ts";
4
4
  import type { Run } from "./run.ts";
5
5
  /** The DBOS event a run publishes its approvals on, as `ApprovalState[]`. */
@@ -28,6 +28,23 @@ export declare const ApprovalMessage: z.ZodObject<{
28
28
  note: z.ZodOptional<z.ZodString>;
29
29
  }, z.core.$strip>;
30
30
  export type ApprovalMessage = z.infer<typeof ApprovalMessage>;
31
+ /**
32
+ * A withdrawal of a pending approval, as sent to a run on the approval's topic: `withdraw` says
33
+ * why, and `by` who withdraws it, which the run checks (`withdrawalRefusal`) and records. `id`
34
+ * names the message as a decision's does; `SanomaClient.withdraw` sets one.
35
+ */
36
+ export declare const ApprovalWithdrawal: z.ZodObject<{
37
+ withdraw: z.ZodString;
38
+ by: z.ZodType<Principal, unknown, z.core.$ZodTypeInternals<Principal, unknown>>;
39
+ id: z.ZodOptional<z.ZodString>;
40
+ }, z.core.$strip>;
41
+ export type ApprovalWithdrawal = z.infer<typeof ApprovalWithdrawal>;
42
+ /**
43
+ * Why `by` may not withdraw the approval of a run `starter` started, or undefined when they may:
44
+ * the starter may withdraw what their own run asks (never a visitor, as every anonymous one shares
45
+ * an id), anyone else only as one who may decide it.
46
+ */
47
+ export declare const withdrawalRefusal: (approval: Pick<ApprovalState, "approver">, by: Principal, starter: string | undefined) => string | undefined;
31
48
  /** An approval request as checked: who may decide it, and the operations it covers, by id. */
32
49
  export interface CheckedApproval extends Omit<ApprovalRequest, "covers"> {
33
50
  covers: string[];
@@ -44,8 +61,16 @@ export interface HeldCall {
44
61
  }
45
62
  /**
46
63
  * Waits, durably, for a decision from someone who may make it (`mayDecide`: the run's own actor
47
- * only while nobody else could). Throws `RejectedError` on a rejection. Without `held`, the workflow asked
64
+ * only while nobody else could). Throws `RejectedError` on a rejection and `WithdrawnError` on a
65
+ * withdrawal (`ApprovalWithdrawal`). Without `held`, the workflow asked
48
66
  * (`ctx.approval`); with it, the policy did, and `place` is the held call's outline node and name
49
67
  * (none for a run's start, which is no call in the outline).
50
68
  */
51
69
  export declare function awaitApproval(run: Run, title: string, req: CheckedApproval, place: Placed | undefined, held?: HeldCall): Promise<ApprovalResult>;
70
+ /**
71
+ * Withdraws every approval of the run that is approved and covers the operation `covering`, so
72
+ * none lifts a hold on it again (`approvedFor` reads only approved ones): as a change does when it
73
+ * gets a new commit. Called from the run's own body, never a step: the approvals it finds and the
74
+ * records it writes depend only on the run's history, so a replay does the same.
75
+ */
76
+ export declare function withdrawApprovals(run: Run, covering: string, reason: string): Promise<void>;