@pikku/kysely 0.13.38 → 0.13.39

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 (22) hide show
  1. package/dist/bin/pikku-kysely-pure.js +0 -0
  2. package/package.json +15 -9
  3. package/CHANGELOG.md +0 -2367
  4. package/knowledge/decisions/a-console-role-cannot-take-a-system-roles-name.md +0 -25
  5. package/knowledge/decisions/a-credential-with-no-user-is-one-row-per-name.md +0 -22
  6. package/knowledge/decisions/a-lease-is-taken-by-one-guarded-update.md +0 -30
  7. package/knowledge/decisions/a-virtual-users-schedule-starts-disabled.md +0 -23
  8. package/knowledge/decisions/classification-driven-encryption-happens-in-a-plugin.md +0 -71
  9. package/knowledge/decisions/grants-reference-declared-scopes-and-users-by-foreign-key.md +0 -29
  10. package/knowledge/decisions/index.md +0 -21
  11. package/knowledge/decisions/keks-are-scoped-by-purpose-as-well-as-version.md +0 -45
  12. package/knowledge/decisions/leases-are-judged-by-the-database-clock.md +0 -42
  13. package/knowledge/decisions/the-plugin-is-given-a-resolver-never-a-key.md +0 -45
  14. package/knowledge/decisions/the-secrets-audit-table-is-declared-even-when-auditing-is-off.md +0 -22
  15. package/knowledge/decisions/workflows-own-the-lease-table-too.md +0 -22
  16. package/knowledge/index.md +0 -19
  17. package/knowledge/questions/do-the-kysely-stores-check-who-calls-them.md +0 -27
  18. package/knowledge/questions/does-a-trigger-source-row-hold-only-provider-identifiers.md +0 -26
  19. package/knowledge/questions/index.md +0 -17
  20. package/knowledge/questions/should-pikku-user-sessions-expire-on-their-own.md +0 -21
  21. package/knowledge/questions/should-secret-and-credential-reads-be-audited-by-default.md +0 -32
  22. package/run-tests.sh +0 -61
package/CHANGELOG.md DELETED
@@ -1,2367 +0,0 @@
1
- ## 0.13.38
2
-
3
- ### Patch Changes
4
-
5
- - de9af6a: RPCs for Pikku Studio's migrated screens. Runtime state that must be visible on a deployed app lives in `@pikku/addon-admin`; local-copy tools stay in `@pikku/addon-console`.
6
-
7
- `@pikku/addon-admin`:
8
-
9
- - `admin:getSchedulerHistory` returns each scheduled task's last run, next run and recent runs, from a new `SchedulerService.getTaskRuns()` (empty by default). `InMemorySchedulerService` records the last 50 runs per cron task with status, duration and error. Scope `admin:schedules:read`.
10
- - `admin:getQueueHistory({ queueNames?, limit? })` returns live counts and recent jobs per queue, from a new optional `QueueService.inspect(queueName, { limit })`, implemented by `InMemoryQueueService` and `BullQueueService` and forwarded by `SignedQueueService`. Scope `admin:queues:read`.
11
- - `admin:listIncomingWebhookReceipts` / `admin:getIncomingWebhookReceipt` expose received webhooks, backed by a new `IncomingWebhookService.getReceipt(receiptId)` (null by default; implemented by `KyselyIncomingWebhookService`). Scope `admin:webhooks:read`.
12
-
13
- `@pikku/addon-console`:
14
-
15
- - `console:variableGet` / `console:variableSet` read and write a project variable, gated on `pikku:console:variables:read` / `:write`.
16
- - `console:runScenarios({ names?, environment? })` starts `pikku scenario run` as a detached child process and returns `{ runId }` to follow through `listScenarioRuns` / `getScenarioRun`, gated on the new `pikku:console:scenarios:run` scope. `pikku scenario run` takes `--run-id <id>` to record under a caller-chosen id.
17
-
18
- - Updated dependencies [de9af6a]
19
- - @pikku/core@0.12.143
20
-
21
- ## 0.13.37
22
-
23
- ### Patch Changes
24
-
25
- - fdcc821: Fabric is gone from the open toolchain. The previous names are removed with no aliases.
26
-
27
- The CLI group is `pikku cloud …` and the export is `@pikku/cli/cloud`. The project link is the `cloud` key of `pikku.config.json` (`cloud.projectId`), the CLI keeps its local state in `~/.pikkustudio` (run `pikku cloud login` again), and the project config file is `pikkustudio.config.json`.
28
-
29
- Every environment variable drops the `FABRIC_` prefix for `PIKKUSTUDIO_` with the same suffix: `PIKKUSTUDIO_API_URL`, `PIKKUSTUDIO_PROJECT_ID`, `PIKKUSTUDIO_TOKEN`, `PIKKUSTUDIO_OPERATOR_TOKEN`, `PIKKUSTUDIO_AUTH_PUBLIC_KEY`, `PIKKUSTUDIO_STAGE_ID` and the rest. Rename them wherever you set them.
30
-
31
- Wire ids: the operator sign-in route is `/sign-in/cloud`, the plugin and mode literal is `'cloud'`, the Better Auth plugin is `pikkuCloud`, its session field is `pikkustudioadmin`, and the signature header is `x-cloud-sig`. The cloud API calls are `getCloudLogs`, `getCloudLogsByStageKind`, `cloudCliProjects`, `cloudCliDeployments`, `providedByCloud` and `recordCloudAnalyticsEvents`. Addon packages are `@pikkustudio/*`, scaffolded files live under `scaffold/cloud` and `__cloud_*__`, and the API hosts are the `pikkustudio.app` and `pikkustudio.dev` domains.
32
-
33
- `pikku skills install --fabric` is `--cloud`, the install group is `cloud`, and the skills are `pikku-cloud`, `pikku-cloud-debug`, `pikku-admin-to-cloud` and `pikku-blueprint-to-cloud`.
34
-
35
- The stale analytics forwarder copies are removed from the online-shop example and the starter template.
36
-
37
- The sealed-box salt stays `pikkufabric/sealed-box/v1`: it is a cryptographic constant that already-sealed secrets depend on.
38
-
39
- - 33b102d: Virtual users now have one name everywhere. The id column of `virtual_user_run` and `virtual_user_schedule` is `virtual_user_id` (a migration renames it in place), the CLI group is `pikku virtual-user …`, and the declarations and imports live under `@pikku/core/virtual-user`. The previous names are removed with no aliases.
40
-
41
- The default virtual user email domain is now `virtualuser.invalid`: apps that rely on the default domain get new accounts at the next provisioning (`pikku virtual-user sync`, deploy, or `pikku dev` start), and the old rows stay unused.
42
-
43
- The sign-in surface carries the same name. The route is `/sign-in/virtual-user`, the environment variables are `PIKKU_ALLOW_VIRTUAL_USER_SIGN_IN` and the `PIKKU_DEV_VIRTUAL_USER_SIGN_IN` / `VITE_*` equivalents, the Better Auth plugin is `pikkuVirtualUser`, the scenario step option and wire member are `virtualUser` and `virtualUsers`, and the Better Auth user flag column is `virtual_user`. Rename the environment variables wherever you set them, and add a migration that renames the flag column on the `user` table. Nothing is aliased.
44
-
45
- The conversation runner is now `@pikku/core/virtual-user/conversation`, replacing the old `-flow` subpath. Update the import; the old subpath is gone.
46
-
47
- - Updated dependencies [fdcc821]
48
- - Updated dependencies [33b102d]
49
- - Updated dependencies [6a25c70]
50
- - Updated dependencies [a084c3b]
51
- - @pikku/core@0.12.142
52
-
53
- ## 0.13.36
54
-
55
- ### Patch Changes
56
-
57
- - e0846b5: Saving an agent's tool messages skips a tool call whose result is undefined instead of writing it. When the browser driver for a scenario cannot be loaded, the error now includes the underlying cause and tells you to `bun add -D` it.
58
- - 884a1b5: MySQL: the `@pikku/kysely` stores no longer emit postgres/sqlite-only SQL. Upserts use `on duplicate key update`, insert-or-ignore uses `insert ignore`, `returning` deletes read the rows first, the lease clock casts to `signed`, workflow JSON state uses `CAST(... AS JSON)`, the agent thread owner `LIKE` escapes with `!`, and timestamp columns are written as `Date`s instead of `Z`-suffixed ISO strings. `pikku db generate` now emits the `scope` schema when Better Auth's user model is a mapped table (for example a Rails `users` table), typing the key column from the real `users.id`.
59
- - 51ec3ac: MySQL fixes found moving a Rails database onto pikku.
60
-
61
- - The generated local services (`pikku db baseline`, `pikku dev`, `pikku all`, a local CLI) open MySQL: a `mysql://` `DATABASE_URL` or `mysqlUrl` in the config opens through a Kysely `MysqlDialect` on a `mysql2` pool (declare `mysql2` in the project), with `CamelCasePlugin` and the coercion map like the other dialects. A `mysql://` URL was read as a sqlite file path. `db/mysql` now counts as a project database, and `@pikku/kysely` re-exports `MysqlDialect`.
62
- - MySQL migrations run with `FOREIGN_KEY_CHECKS` off, so a mysqldump whose tables reference ones created later applies as it is.
63
- - `TINYINT(1)` is typed `boolean` and coerced at runtime (mysql2 returns 0/1); an explicit `tsType` in `db/annotations.ts` keeps it a number. `DECIMAL` is read as a number (`decimalNumbers`), as the generated types say. `BIGINT` stays `number`, exact to 2^53, which is mysql2's default.
64
- - `pikku all` no longer throws "db/mysql exists but no mysqlUrl is configured": the server comes from createConfig's `mysqlUrl`, `db.mysqlUrl` or a `mysql://` `DATABASE_URL`, and with none the stub `DB` is written.
65
- - Better Auth schema derivation follows the resolved database rather than the factory's `database.type`, so a factory declaring `type: 'sqlite'` no longer sends SQLite introspection (`pragma index_list`) to a MySQL server. Set `type: 'mysql'` in the factory too, so the runtime matches.
66
-
67
- - Updated dependencies [f396538]
68
- - @pikku/core@0.12.140
69
-
70
- ## 0.13.35
71
-
72
- ### Patch Changes
73
-
74
- - 15c4968: The default runtime path no longer needs `node:*`, `Buffer` or an unguarded `process`, so it loads on edge runtimes (Web APIs only).
75
-
76
- **Breaking:** `FileScenarioRunStore`, `scenarioArtifactContentType` and `scenarioRunSummary` leave the `@pikku/core/services` barrel because they use `node:fs`. Import them from `@pikku/core/services/file-scenario-run-store`. Pre-0.13 breaking changes still ship as a patch.
77
-
78
- **Breaking:** the HMAC helpers in `@pikku/core/hmac` run on Web Crypto, which is async. `hmacSha256Hex`, `hmacDigest`, `verifyHmacSignature` and `verifyPublicKeySignature` now return a Promise; `timingSafeStringEqual` stays synchronous. `WebhookService.sign` and `WebhookService.verify` return a Promise, and so does `verifySlackSignature` in `@pikku/gateway-slack`: `await` them. A function-style `verify` on a webhook source may return a Promise as well. `verifyPublicKeySignature` accepts RSA and EC (P-256, P-384, P-521) PEM keys; Ed25519 and RSA-PSS keys verify as false.
79
-
80
- `isProduction()` (and the `PIKKU_MODEL_ALIASES` and `PIKKU_ENV` reads) now ask the registered singleton services' `variables` service first, then `process.env` when `process` exists. With neither, `isProduction()` is true, so an edge deployment never exposes error details by accident. `LocalVariablesService` resolves its `process.env` default when constructed and falls back to an empty store without `process`.
81
-
82
- Workflow invocation ids use a built-in SHA-1 and stay byte-identical. `@pikku/kysely` and the Cloudflare hibernation server use `globalThis.crypto.randomUUID()` and no `Buffer`; `@pikku/kysely` is marked `sideEffects: false`. `@pikku/ai-deepinfra` reads `DEEPINFRA_API_KEY` only when `process` exists and decodes base64 audio without `Buffer`.
83
-
84
- Runtime tiers. A package declares where it can run in `package.json`: `"pikku": { "runtime": "edge" | "serverless" | "server" }`, with optional per-subpath overrides (`"exports": { "./dev": "server" }`). `server` is the default. `@pikku/core` and the default services are `edge` (core's Node-only subpaths are `server`), `@pikku/better-auth`, `@pikku/addon-admin` and `@pikku/cloudflare` are `serverless` (better-auth statically imports `node:crypto` scrypt), and `@pikku/addon-console` is `server` and must never land in a deployed unit.
85
-
86
- `pikku deploy` now verifies each deployed unit before bundling it. The unit is bundled with esbuild (neutral platform, `workerd`/`worker`/`browser` conditions) under its tier's profile, ahead of the adapter's aliases and stubs so they cannot hide anything, and the build fails when the bundle holds a package declared above the unit's tier or a Node built-in the runtime does not provide. The error names the unit, package, import chain and the fix. A built-in the provider stubs is a warning. On an edge unit, a bundled `InMemory*` class also fails the build. The unit's tier is its `runtime`, else the project's own `pikku.runtime`, else the provider default (`serverless` on Cloudflare). Packages that declare nothing are judged by their imports only.
87
-
88
- `ProviderAdapter.getRuntimeProfile(tier?)` returns the compat date, compat flags, the built-ins the runtime provides (keyed by compat date), the stubbed ones and the externals. The Cloudflare adapter derives `wrangler.toml`, the upload metadata and the bundle externals from it; `node:os` and `node:fs` are not provided before compat date 2025-09-15. The default is `nodejs_compat_v2` with compat date 2024-12-18, which is what `wrangler.toml` and Fabric's live workers already use, so Fabric deploys see no runtime change. Only the direct-API upload in `@pikku/deploy-cloudflare` (`createWorker`, used by its own `deploy()`) moves: it sent `nodejs_compat` with 2024-01-01 before. A newer date or flag is opt-in through the adapter option `new CloudflareProviderAdapter({ compatDate })` or `getCloudflareRuntimeProfile(tier, compatDate)`. From 2025-08-15 `node:http` and `node:https` exist, and from 2025-09-15 `node:os`, `node:fs` (stubbed by the build regardless) and `node:perf_hooks`; the verifier's allowed built-ins follow the effective date. A newer date changes the runtime of every worker deployed with it.
89
-
90
- `declareScopes(['pikku:console'])` (from `@pikku/core/scope`) declares scopes by id without wiring anything. `wireAddon({ scopes })` only requires a scope of an addon's functions; the tree arrives with the addon's metadata, so a role granting `pikku:console` used to fail PKU124 unless the addon was wired, and a wired `@pikku/addon-console` lands in every unit carrying the `/rpc` catch-all. An app that grants the scope without the console now calls `declareScopes` and no longer needs the scaffold or the addon. When the addon is wired its tree and descriptions win and the bare id adds nothing.
91
-
92
- More packages declare a tier after bundling each with the edge profile. `edge`: `@pikku/addon-graph`, `@pikku/pino`, `@pikku/jose`, `@pikku/ai-vercel`, `@pikku/ai-voice`. `serverless`: `@pikku/kysely-postgres` (postgres.js needs `node:buffer`, `stream`, `events`), `@pikku/backblaze` (`copyFile` reads a local file, which the build stubs), `@pikku/gateway-slack` (`@slack/web-api` imports `node:os` and `zlib`). `server`: `@pikku/schedule` (`cron` imports `child_process`), `@pikku/aws-services` (the AWS SDK's Node handler needs `node:http2`), `@pikku/browser` (puppeteer), and `@pikku/modelcontextprotocol` except its `./fetch` subpath, which is `edge`.
93
-
94
- `@pikku/addon-graph` no longer needs `node:crypto` or `Buffer`: the Crypto function hashes and HMACs on Web Crypto (MD5 is built in, since Web Crypto has none) and encodes with `TextEncoder`/`atob`/`btoa`, with output unchanged.
95
-
96
- - Updated dependencies [6f11bb5]
97
- - Updated dependencies [0c67e33]
98
- - Updated dependencies [15c4968]
99
- - Updated dependencies [d75a23d]
100
- - Updated dependencies [9b12c8a]
101
- - @pikku/core@0.12.138
102
-
103
- ## 0.13.34
104
-
105
- ### Patch Changes
106
-
107
- - 80c94f9: MySQL is a third dialect for the `pikku db` commands, beside sqlite and postgres.
108
-
109
- Set `mysqlUrl` in `createConfig` and `db migrate`, `generate`, `check`, `baseline`, `reset`, `codegen` and the dev seed behave as they do elsewhere, with migrations in `db/mysql/` and the seed in `db/mysql-dev-seed.sql`. MySQL has no embedded engine, so a command that needs a throwaway database creates and drops a `pikku_scratch_<hex>` one on your server — the account needs `CREATE` and `DROP`. DDL is not transactional there, so a migration that fails halfway is replayed from the top. `db.schema` is refused, because a MySQL schema is a database.
110
-
111
- `@pikku/migrator-sql` gains `@pikku/migrator-sql/mysql`. The runtime schemas in `@pikku/kysely` now compile for MySQL without changing what sqlite and postgres get: keys are `varchar(255)`, free text is `longtext`, literal text defaults are expressions, and foreign keys are table-level constraints, because MySQL parses an inline `REFERENCES` and silently drops it. A foreign key onto a column another source owns takes that column's full type (`varchar(36)`), not the bare `varchar` the introspector reports.
112
-
113
- An addon that ships `db/mysql` migrations needs `db.mysqlUrl` in its `pikku.config.json` for `pikku all` to publish them. The standalone bundle does not support MySQL yet and refuses a MySQL project by name.
114
-
115
- - Updated dependencies [149faae]
116
- - @pikku/core@0.12.136
117
-
118
- ## 0.13.33
119
-
120
- ### Patch Changes
121
-
122
- - a16b0ba: The workflow run lease takes the app's `leaseService` (`holdLease(leaseService, 'workflow-run:<id>', …)`) in place of `pg_advisory_lock` / `GET_LOCK`, for DSL and graph runs alike. A message for a run already being orchestrated elsewhere wakes the run again a second later instead of failing, so a long pass never spends the retry budget the queue keeps for real failures. An inline run whose lease was lost after its body finished keeps the outcome it wrote. `PgWorkflowQueueOptions` and `RunLockHoldTimeoutError` are removed. `WorkflowService.withRunLock` is renamed `withRunLease`, since what it holds runs out unless renewed; a custom workflow service overriding it renames the method.
123
-
124
- Pass the lease service to the workflow service — `new PgKyselyWorkflowService(db, { leaseService })` — register the same instance as the app's `leaseService`, and migrate `pikku_lease`.
125
-
126
- A step lease is renewed by the same loop as the run lease. A graph node whose worker died is dispatched again once its lease lapses, instead of leaving the run waiting on it. A replayed step on Kysely now sees its lease, as `getStepState` does. The in-memory store refuses a superseded worker's outcome, as the database stores do. The MySQL workflow service can now record a workflow version; it used `ON CONFLICT`, which MySQL does not have.
127
-
128
- `pikku db generate` now writes the `pikku_lease` table for any project that runs workflows, not only one that reaches `leaseService`, since every persistent workflow service holds its runs and steps there.
129
-
130
- - a16b0ba: Give a running workflow step a lease, so a step whose worker dies can be claimed again
131
-
132
- A step moving from `pending` to `running` only proves it was dispatched; it says
133
- nothing about whether the worker holding it is still alive. A worker that died
134
- mid-step therefore left the step wedged in `running` forever: unclaimable by the
135
- next dispatch, and invisible to the stalled-run sweep.
136
-
137
- The dispatch that claims a step now stamps a lease on it, refreshes that lease on
138
- an interval for as long as it is working, and releases it when the step parks on
139
- a child run. A step whose lease has lapsed is claimable again, and counts as
140
- in-flight no longer, so the stalled sweep can pick its run back up. A step that
141
- keeps losing its worker fails with `WorkflowStepLeaseExpiredError` once its
142
- attempts run out, rather than looping.
143
-
144
- The lease duration is taken from the queue the step is dispatched through, so the
145
- lease and the queue lock never disagree about who owns the job.
146
-
147
- The refresh runs at half the lease and never later, even when that is under the
148
- one-second floor the interval otherwise respects: applying that floor as a
149
- maximum would renew a shorter lease for the first time after it had already
150
- lapsed, which is the double-claim the lease exists to prevent. A lease that
151
- short is logged once, pointing at the queue's `lockDuration`.
152
-
153
- The lease is written and judged on the database's clock, never the worker's,
154
- so a worker whose clock runs fast cannot claim a step another worker still
155
- holds. A dispatch whose step has since been claimed by another stops renewing,
156
- and says so: `refreshStepLease(stepId, leaseMs, attempt)` resolves `false` once
157
- the step is no longer that attempt's.
158
-
159
- The lease lives in a new `workflow_step.lease_expires_at` column, in epoch
160
- milliseconds (`bigint`). Run `pikku db generate` and `pikku db migrate` after
161
- upgrading: the runtime does not add columns, and every step read selects this
162
- one.
163
-
164
- - a16b0ba: Persistent workflow services take a required `leaseService` (`WorkflowServiceOptions`) and lock runs and steps on it. The Postgres advisory and MySQL `GET_LOCK` step locks, and Redis's own `SET NX` run and step locks, are removed; `RedisWorkflowService` now takes `(connection, { leaseService, keyPrefix? })`.
165
- - Updated dependencies [a16b0ba]
166
- - Updated dependencies [21e9c3a]
167
- - Updated dependencies [a16b0ba]
168
- - Updated dependencies [a16b0ba]
169
- - @pikku/core@0.12.133
170
-
171
- ## 0.13.32
172
-
173
- ### Patch Changes
174
-
175
- - 942ebdd: Add `LeaseService`: named leases shared by every process on the same store. A lease is not a mutex: a holder that stalls past its expiry loses the key without knowing, so whatever the body writes to should check the lease's `token` and refuse an older one. `acquire` never blocks and answers `null` while someone else holds the key; a lease lapses on its own if its holder dies; and each lease carries a `token` that rises every time the key changes hands, so a stale holder cannot refresh or release its successor's lease. `holdLease` refreshes the lease while its body runs, hands the body an `AbortSignal` that fires the moment the lease is lost, and throws `LeaseLostError` once the body finishes if the lease lapsed or changed hands meanwhile, so a caller never takes that result as produced under the lease.
176
-
177
- Ships as `InMemoryLeaseService`, `PgKyselyLeaseService` (`@pikku/kysely-postgres`), `MySQLKyselyLeaseService` (`@pikku/kysely-mysql`) and `KyselyLeaseService` (SQLite), all on `pikku_lease`. The Postgres and MySQL services judge every lease by the database's clock, so a worker whose clock runs fast cannot take a live lease or stretch its own; `KyselyLeaseService` reads the process clock and is for a single-host SQLite app. `pikku db generate` writes the table for any project that reaches `leaseService`.
178
-
179
- `RedisLeaseService` (`@pikku/redis`) keeps each lease in a hash Redis expires itself, with every check-and-set in one Lua script that reads Redis's `TIME`, so it too judges leases by the server's clock; its token counter outlives release, so the next holder always gets a higher token.
180
-
181
- - Updated dependencies [d327fa5]
182
- - Updated dependencies [942ebdd]
183
- - Updated dependencies [8ac25a8]
184
- - Updated dependencies [6606777]
185
- - @pikku/core@0.12.132
186
-
187
- ## 0.13.31
188
-
189
- ### Patch Changes
190
-
191
- - 01c0209: `@pikku/kysely` re-exports `Kysely`, `PostgresDialect` and `CamelCasePlugin` from its own copy of kysely. The local-services codegen writes these imports into a project, so it now opens and types the database with the same kysely copy the generated services were built against, instead of a second copy the project may resolve on its own.
192
- - 5bce779: Webhook trigger sources are off until someone turns them on, and addons declare their own.
193
-
194
- An addon calls `wireTriggerWebhookSource` in its own package, and an app that wires the addon gets the source (its route included) without declaring it: named and routed after the addon's namespace, so two instances get one each. A source the app declares under the same name wins.
195
-
196
- Every source now has an `enabled` switch in the `triggerSourceStore`, off by default. `reconcileTriggerSources` registers only enabled sources and records each one's `baseUrl` and `labelPrefix`; a disabled source's route answers 404 without running `receive`. New in core: `enableTriggerSource` registers a source with its provider and `disableTriggerSource` stops it receiving, then tears it down, both at the recorded address unless one is given. The admin addon exposes them as `triggerSourceEnable` and `triggerSourceDisable`. The `pikkuTriggerSource` table gains `enabled`, `baseUrl` and `labelPrefix`: run `pikku db generate` for the migration.
197
-
198
- - Updated dependencies [dfcd351]
199
- - Updated dependencies [cf40182]
200
- - Updated dependencies [5bce779]
201
- - Updated dependencies [5bce779]
202
- - @pikku/core@0.12.130
203
-
204
- ## 0.13.30
205
-
206
- ### Patch Changes
207
-
208
- - 658f047: A declared webhook source is a registered one. `reconcileTriggerSources` sets up every declared source with its provider (check, then setup where missing or drifted) and `teardownTriggerSources` removes named ones, recording what was registered in a `TriggerSourceStore` (in-memory, or `KyselyTriggerSourceStore` on `pikku_trigger_source`). The admin addon exposes list, reconcile, teardown and forget under the new `admin:triggers` scopes.
209
- - Updated dependencies [658f047]
210
- - Updated dependencies [de63ab2]
211
- - Updated dependencies [658f047]
212
- - Updated dependencies [658f047]
213
- - Updated dependencies [658f047]
214
- - Updated dependencies [658f047]
215
- - @pikku/core@0.12.128
216
-
217
- ## 0.13.29
218
-
219
- ### Patch Changes
220
-
221
- - 5e93f30: Add `wireTriggerWebhookSource({ name, method?, route?, secret?, events, receive?, check?, setup?, teardown? })` in `#pikku/trigger`. Each source becomes a `POST /webhooks/<name>` route whose events are validated against their schemas and queued on `pikku-incoming-webhooks` through `IncomingWebhookService`; a generated worker runs the matching `wireTrigger({ name: '<source>:<event>' })` and the queue retries it on failure. `pikku webhooks status | setup | teardown --url --labelPrefix [--previous]` registers the routes with the provider and prints one JSON line per source.
222
-
223
- `KyselyIncomingWebhookService` (with the `incoming-webhook` schema) records a receipt per event, drops a provider's redelivery of an event it already accepted, and keeps each dispatch's attempts and last error. `pikku dev` and `pikku serve` use it when a Kysely database is configured.
224
-
225
- - Updated dependencies [5e93f30]
226
- - Updated dependencies [5e93f30]
227
- - @pikku/core@0.12.125
228
-
229
- ## 0.13.28
230
-
231
- ### Patch Changes
232
-
233
- - 4a9dcd2: `admin:listUsers` now pages, counts and can carry roles.
234
-
235
- `ListUsersInput` gains `offset` and `includeRoles`; `ListUsersOutput` gains `total`, and each `User` gains `roles` and `fields`. `total` is how many users match `search`, which is what a pager counts against — `users.length` never was, because it is capped by `limit`.
236
-
237
- ```typescript
238
- const { users, total } = await rpc.invoke('admin:listUsers', {
239
- search: 'example.com',
240
- limit: 50,
241
- offset: 50,
242
- includeRoles: true,
243
- })
244
- ```
245
-
246
- Paging only means something over a stable order, so the query now sorts newest first rather than however the database felt like returning rows.
247
-
248
- Synthetic principals — the platform credential owner, Fabric service users, scenario actors — are excluded by the query instead of dropped from the page afterwards. Filtering after the fact broke both halves of paging: `limit` had already counted the rows it then discarded, so a page came back short, and `offset` skipped synthetic rows as though they were people, so the same person could appear on two pages or on none.
249
-
250
- `includeRoles` is refused without `admin:scopes:read`. `admin:users:list` says who may see the directory; it does not say who may see what each of those users can do.
251
-
252
- `ScopeService` gains `listRolesForUsers(userIds)`, implemented in `@pikku/kysely`. It answers for every id asked for — an empty array for a user holding no roles, so a caller cannot read a missing key as "holds nothing" — and chunks its `in` list to stay inside the bound-parameter cap. A page of users used to cost one query per row, which on a database reached over the network is a round trip per row.
253
-
254
- ```typescript
255
- listRolesForUsers(userIds: string[]): Promise<Record<string, string[]>>
256
- ```
257
-
258
- Anything implementing `ScopeService` outside this repository has to add it.
259
-
260
- - Updated dependencies [4a9dcd2]
261
- - Updated dependencies [5ab24ad]
262
- - Updated dependencies [42b7ac3]
263
- - @pikku/core@0.12.120
264
-
265
- ## 0.13.27
266
-
267
- ### Patch Changes
268
-
269
- - 78237ac: The console shows feature flags as a launch board, and analytics events as a
270
- declared catalog.
271
-
272
- A flag's state is four fields — `enabled`, `rolloutPercent`, `declared`,
273
- `backed` — and none of them is the question an operator actually asks, which is
274
- how far this has got. The board answers that directly: every declared flag sits
275
- in the lane its rollout has reached, `dark` → `rolling` → `live`, with
276
- `attention` for the flags that are not resolving in a way anybody chose.
277
-
278
- Attention is evaluated before every other reading, and that ordering is the
279
- whole point rather than an implementation detail. A flag declared in code with
280
- no row in the store fails open, and it reports `enabled: true` with no rollout
281
- limit — byte-identical to a deliberate full launch. Read the fields in the
282
- obvious order and the one production-severity state on the board renders as the
283
- healthiest one. `groupFlagsByLane` also returns all four lanes whether or not
284
- they hold anything, because a board read by shape must not rearrange itself the
285
- moment a lane empties.
286
-
287
- Selecting a flag opens its controls beside the board rather than over it: the
288
- switch, the rollout bucket, and the subjects pinned on or off past that bucket.
289
- They share one surface because they are read together — "off for everyone except
290
- these three" is a switch and an override row, and an operator who has to leave
291
- one screen to see the other is the operator who turns a flag on for everybody by
292
- mistake. The panel tracks the open flag by name and re-reads it from the list, so
293
- committing a rollout moves the card and the panel together instead of leaving the
294
- panel describing the flag as it was before the operator changed it.
295
-
296
- A board whose flags come from a `FeatureFlagSource` — a provider Pikku reads but
297
- does not own — says so and offers no controls, rather than offering controls that
298
- would fail.
299
-
300
- The analytics screen is a catalog of what the code declares, read from build-time
301
- meta: the events a client may emit and the props each carries, with every prop
302
- rendered as the schema source text the declaration wrote. It is deliberately not
303
- a volume report — nothing here counts what was emitted — and saying which of the
304
- two it is turned out to be the only design question the screen had.
305
-
306
- Turning a flag on while it carries no rollout limit now asks first. That press
307
- is the one irreversible thing the board can do — with no bucket left to hold
308
- anybody back it admits everyone the flag's capabilities allow — and it used to
309
- be a single click on a switch. The panel also reports what a mutation is doing
310
- and what it refused to do: the controls it is waiting on go into a pending
311
- state, and a failed write raises an inline `<Alert>` rather than reverting in
312
- silence. The console mounts no notification provider, so the feedback is inline
313
- where the action is, which is the idiom the rest of the console already uses.
314
-
315
- `@pikku/mantine`'s theme gains four aliases, and they close a contrast defect
316
- that predates this board:
317
-
318
- ```ts
319
- '--mantine-color-orange-light': 'var(--app-surface-warning)',
320
- '--mantine-color-orange-light-color': 'var(--app-amber)',
321
- '--mantine-color-teal-light': 'var(--app-surface-success)',
322
- '--mantine-color-teal-light-color': 'var(--app-green)',
323
- ```
324
-
325
- The theme already documents two colour tiers — TEXT must clear AA, GRAPHIC only
326
- 3:1 — and already pulls Mantine's own variables into that contract rather than
327
- linting call sites. What it had not covered was Mantine's _light variants_:
328
- `<Alert color="orange">` renders #d9480f on #ffe8cc at 3.62:1, and
329
- `<Badge variant="light" color="teal">` at 4.33:1, neither reachable from an
330
- `--app-*` token because the component never asks for one. The ramp itself is
331
- deliberately untouched: Mantine conflates `--mantine-color-orange-filled`
332
- between `c="orange"` text and a `variant="filled"` background, so darkening it
333
- for light-mode text would make an existing filled badge unreadable in dark mode.
334
- Eight pre-existing `c="orange"` call sites moved onto the amber TEXT tier in the
335
- same pass.
336
-
337
- The analytics catalog is grouped by the file that declares each event, and its
338
- rows are real buttons rather than table cells carrying a tabindex.
339
-
340
- `ShellHeaderAction` gains `loading` and `testId`, and `ActionCluster` gains a
341
- `measurement` flag. `ShellHeader` sizes its actions by rendering them a second
342
- time off-screen, and that measuring copy was carrying the same `data-testid` and
343
- `data-help` as the real one — so every action on a page with a collapsing header
344
- resolved to two elements. The flags board also moved its two header actions from
345
- `actionsNode` (documented as the non-collapsing escape hatch) onto the structured
346
- `actions` array, which is what stopped them clipping off the right edge at 400px.
347
-
348
- - Updated dependencies [78237ac]
349
- - Updated dependencies [add56d2]
350
- - @pikku/core@0.12.111
351
-
352
- ## 0.13.26
353
-
354
- ### Patch Changes
355
-
356
- - 1c9a55a: Review fixes across the feature-flag and analytics primitives:
357
-
358
- - An addon function's `featureFlag:` gate now reads the consuming application's
359
- flag source rather than the package's own services, which never carry one.
360
- - A flag named `__proto__`, `constructor` or `prototype` is rejected instead of
361
- being silently dropped from the generated metadata.
362
- - Two declarations of one flag with different descriptions are a hard error,
363
- rather than the inspector's traversal order deciding what operators read.
364
- - `subjectIdOf` falls through an empty organization id to the user, instead of
365
- resolving to no subject and skipping every override and rollout bucket.
366
- - `CachedFlagSource.invalidate()` retires the in-flight read, so a webhook that
367
- lands mid-fetch is not answered by the pre-webhook snapshot for another TTL.
368
- - The generated `/feature-flags` wire resolves against the compiled fallback
369
- when no source is wired, so a scope-gated flag is not reported to a caller
370
- who cannot hold it.
371
- - `pruneFlags()` rechecks `declared = false` in the delete and reports only
372
- what it removed, so a redeclaration between the two keeps its overrides.
373
- - A destination's `accepts` throwing no longer costs every later sink its batch.
374
- - The React analytics client drops events at collection time when analytics is
375
- disabled, so a later consent grant cannot send what was gathered before it.
376
- - The React flag client keeps its map when the wire answers a non-object.
377
- - `KyselyAnalyticsService` mints event ids from `crypto` rather than a
378
- timestamp with a short random tail.
379
-
380
- - 1c9a55a: Add `KyselyAnalyticsService`, so declared events have somewhere to land.
381
-
382
- Every other pikku primitive backed by a table had a Kysely implementation and
383
- analytics did not, which meant a project that declared events either wired a
384
- vendor sink or watched them go to the logger — and the logger is not somewhere
385
- you can answer a question from. The new service appends to `pikkuAnalyticsEvents`,
386
- gated by `ownedBy: ['analyticsService']` so only a project that declares events
387
- carries the table.
388
-
389
- - 1c9a55a: Export `flagSchema` beside the other schemas.
390
-
391
- `KyselyFeatureFlagStore.init()` expects its tables to exist, and the only way
392
- an app creates them is `applyPikkuSchemas(db, [flagSchema])`. Every other store
393
- in this package exports the schema that backs it; this one did not, so the
394
- store was unusable outside the package that defined it.
395
-
396
- - 1c9a55a: Feature flags, declared in source and resolved from two independent booleans.
397
-
398
- `defineFeatureFlags` declares a flag the way `defineScopes` declares a scope —
399
- the inspector collects it, the CLI emits a `FeatureFlagName` union, and a
400
- misspelled `featureFlag:` is a type error rather than a gate that silently fails
401
- open.
402
-
403
- A flag answers two questions that are not the same question. `capable` comes
404
- from the session's scopes and is per-user, advisory, and protects nothing — it
405
- hides UI. `available` comes from one global config snapshot, is caller-blind,
406
- and is the only half the runner enforces: `override(subject) ?? (enabled AND
407
- bucket)`, so "off for everyone except these three organizations" is one row, and
408
- a kill is one write rather than a fan-out. Authorization stays where it was, in
409
- the function's own `scopes:` — enforcing capability would make a flag a second
410
- authorization path OR-ing against them. An unavailable feature throws 503, not
411
- 403, because the caller was allowed; the feature was not on.
412
-
413
- `featureFlag:` is deliberately available on sessionless functions too. It reads
414
- the config, not the session, so the kill switch reaches a cron task, a queue
415
- worker and a webhook — which is where it matters most, since nobody is watching
416
- a UI to notice the feature is off.
417
-
418
- Refresh is pull-on-demand, so the TTL is the kill-switch latency. Where that is
419
- too long, `invalidate()` is public: a provider's change webhook lands on an HTTP
420
- wiring, drops the cache, and the next request does the read. It deliberately
421
- does not fetch — a burst of webhooks would be N round trips, and on a serverless
422
- runtime the isolate that took the signal may be gone before anything reads the
423
- result.
424
-
425
- Availability fails open through three layers: a fresh read, then the last good
426
- cached read, then the compiled declaration. The middle layer is load-bearing —
427
- dropping straight to the compiled fallback on a blip would switch on every flag
428
- that was deliberately dark.
429
-
430
- Backing stores split along what they can honestly do. `FeatureFlagSource` is
431
- read-only (`snapshot()`) and is what a third-party provider implements;
432
- `FeatureFlagStore` adds the write half and is for stores Pikku owns.
433
- `@pikku/kysely` ships the store, with declarations synced additively — a removed
434
- declaration is marked undeclared, never revoked, and a sync never re-enables a
435
- killed flag. Third-party providers implement the read-only half in the addons
436
- repository, over plain `fetch` rather than a vendor SDK — those poll on a timer
437
- belonging to a long-lived process, which a serverless isolate cannot hold
438
- between requests.
439
-
440
- A client asks for its flags once per session rather than per flag:
441
- `scaffold.featureFlags` generates a `GET /feature-flags` returning every
442
- declared flag resolved for the caller, keyed by this app's `FeatureFlagName`.
443
- Generated into the app rather than shipped in an addon precisely for that union
444
- — an addon never sees the host's, and could only answer
445
- `Record<string, boolean>`. It returns `show` alone: sending `available` apart
446
- from `capable` would tell every visitor which features exist but are dark.
447
-
448
- The write half is the operator's, and lives in `@pikku/addon-admin` beside the
449
- scope RPCs, under a new `admin:flags` scope. `flagList` reports `writable:
450
- false` rather than failing when flags come from a provider, because a provider's
451
- own UI is its operator surface and a console full of buttons that 500 is worse
452
- than a read-only tab. It still lists the flags: a source may report its declared
453
- set through `declaredFlags()`, and each row carries `backed`, false where the
454
- provider has never heard of a declared flag. That row is the one worth seeing —
455
- an absent row fails open, so a dark launch nobody created in PostHog is already
456
- live for everyone, and a store pikku owns can reconcile that on deploy where a
457
- provider cannot.
458
-
459
- On the client, `createFeatureFlags` fetches that map once and `useFeatureFlag`
460
- reads it synchronously after, through the same provider the analytics client
461
- hangs off. It takes a `bootstrap` map so a server-rendered page hydrates onto
462
- the answer it already computed: without one there is a gap in which neither
463
- default is right, since false hides a feature the user has and true flashes one
464
- they do not. A failed refresh keeps the map already on screen rather than
465
- relabelling every flag on a blip.
466
-
467
- - Updated dependencies [1c9a55a]
468
- - Updated dependencies [1c9a55a]
469
- - Updated dependencies [1c9a55a]
470
- - @pikku/core@0.12.110
471
-
472
- ## 0.13.25
473
-
474
- ### Patch Changes
475
-
476
- - 4c7a1b5: Run the monorepo's own scripts through bun instead of yarn. What moves is the
477
- package manager each package's `prepublishOnly` and build scripts invoke, plus
478
- the two manifest fixes bun needs to resolve the tree: `uWebSockets.js` is
479
- declared with an explicit `github:` specifier, and `@pikku/uws-handler` marks
480
- its `uWebSockets.js` peer optional so a bun install of a consumer that brings
481
- its own uWS app does not try to fetch it from the registry.
482
-
483
- Three published behaviours change, all of them cases where an isolated
484
- `node_modules` or bun as the runtime had been papered over by yarn's hoisting:
485
-
486
- - `@pikku/migrator-sql` turns foreign keys on when it opens a sqlite database
487
- through bun. `node:sqlite` enforces them by default and `bun:sqlite` does not,
488
- which silently turned every `ON DELETE CASCADE` into a no-op under
489
- `bunx --bun pikku`.
490
- - `@pikku/cli` resolves a deploy provider against the project being deployed
491
- rather than against wherever the CLI itself is installed, which is what its
492
- own "is not installed" error asks the user to arrange.
493
- - `@pikku/cli` treats a specifier a runtime hands straight back — bun does this
494
- for the modules it implements itself — as not resolved from the project, so
495
- it falls back rather than loading the runtime's own copy.
496
-
497
- - Updated dependencies [4c7a1b5]
498
- - @pikku/core@0.12.108
499
-
500
- ## 0.13.24
501
-
502
- ### Patch Changes
503
-
504
- - f10162a: `send()` now reports the delivery id it wrote, not only the broker's job id.
505
-
506
- `KyselyWebhookService.send()` returned `{ jobId }` straight from `queueService.add()`, and callers handed that to `getDelivery()`. That only worked because every queue in the test suite echoed the requested `jobId` back. A broker is free to assign its own identity — the JetStream queue returns a stream sequence — so on those the read-back looked up an id that was never written and 404'd.
507
-
508
- `SendWebhookResult` gains an optional `deliveryId`, which store-backed implementations always populate.
509
-
510
- - Updated dependencies [f10162a]
511
- - @pikku/core@0.12.104
512
-
513
- ## 0.13.23
514
-
515
- ### Patch Changes
516
-
517
- - 80eb5c0: Encrypt classified columns from the generated manifest.
518
-
519
- `ClassificationPlugin` reads the per-column classification manifest and decrypts `wrapped` and `sealed` columns transparently on the way out. Writes are not transparent — Kysely's `transformQuery` is synchronous and WebCrypto is not — so plaintext heading for a classified column **throws** instead, and values are produced by `ClassificationCrypto.encryptColumn()`. A forgotten call site is a loud error rather than a silent plaintext row. The stored envelope is self-describing (`pikku1.<keyId>.<version>.<wrappedDek>.<ciphertext>`), so a row records which key opens it without a schema change to every table.
520
-
521
- `keyId` now flows from the hand-authored `db/annotations.ts` through `pikku db migrate` into `classification.gen.ts`. It is emitted only for `wrapped` and `sealed` columns: naming a key on a plain column would claim a protection it does not have, and a hashed column has no key at all — the hash is the lookup key.
522
-
523
- - Updated dependencies [80eb5c0]
524
- - Updated dependencies [2252016]
525
- - @pikku/core@0.12.98
526
-
527
- ## 0.13.22
528
-
529
- ### Patch Changes
530
-
531
- - 4450b2a: Name the missing key when a secret is not found.
532
-
533
- Every `SecretService` threw a bare `Requested secret not found`. In a deployed
534
- runtime the stack is minified, so the message was the only evidence there was —
535
- and it identified neither the key nor the service. Each implementation now names
536
- the key it looked for; the better-auth middlewares that skip on an absent secret
537
- match the prefix through one shared predicate instead of the whole string.
538
-
539
- - Updated dependencies [4058c3a]
540
- - Updated dependencies [4058c3a]
541
- - Updated dependencies [4058c3a]
542
- - Updated dependencies [4058c3a]
543
- - Updated dependencies [4058c3a]
544
- - Updated dependencies [4058c3a]
545
- - Updated dependencies [114c079]
546
- - Updated dependencies [4450b2a]
547
- - Updated dependencies [4058c3a]
548
- - Updated dependencies [4058c3a]
549
- - @pikku/core@0.12.93
550
-
551
- ## 0.13.21
552
-
553
- ### Patch Changes
554
-
555
- - cfd364a: Remove the last `@pikku/core/ecosystem` references and guard against new ones
556
-
557
- `@pikku/kysely`'s workflow-service test still imported `StepState` from
558
- `@pikku/core/ecosystem/workflow`, a subpath that no longer exists in
559
- `@pikku/core`'s `exports`. Nothing caught it: the import is type-only, so tsx
560
- erases it before it can fail at runtime, and the package tsconfig excludes
561
- `**/*.test.ts`, so `yarn tsc` never saw it either. It now imports from
562
- `@pikku/core/workflow`.
563
-
564
- A new guard test in `@pikku/core` scans the repository for the dead specifier
565
- and fails if one comes back, so the next stale import is a red test rather than
566
- a silent `any`.
567
-
568
- - 05e47cf: feat(virtual-user): keep the transcript a run already produced
569
-
570
- The engine returns `intents` and `steps` on every run — what the user set out
571
- to do, and every turn it took getting there — and `VirtualUserRunOutcome` kept
572
- neither. The record held counts and findings, so the one question anybody
573
- actually asks of a completed run ("what did it _do_?") had no answer anywhere,
574
- even though the answer had been computed and thrown away a moment earlier.
575
-
576
- `VirtualUserRunOutcome` now carries both, and `VirtualUserRunStore` gains a
577
- `steps(runId, options?)` read. Intents ride on the run record: there are a
578
- handful of them and every read of the run wants them. Steps get their own
579
- `virtualUserRunStep` table, because a run at a 500-step budget carries more
580
- transcript than every other column together and `list()` would pay for it on
581
- every row.
582
-
583
- Three things the kysely store had to get right, all of them driver differences
584
- rather than design:
585
-
586
- - steps are inserted in chunks of 50, because a bare sqlite driver binds at
587
- most 999 variables per statement and ten columns times a 500-step budget is
588
- five thousand — an un-chunked insert fails on long runs, which are the
589
- interesting ones;
590
- - `ok` is stored as 0 or 1, since a bare driver cannot bind a boolean at all
591
- and `SerializePlugin` is not installed everywhere;
592
- - `response` is stored JSON-encoded, because a truncated API response usually
593
- starts with a brace and `SerializePlugin` would otherwise read it back as an
594
- object rather than the string the engine saw.
595
-
596
- Completing a run that does not exist no longer writes steps: there is no
597
- foreign key to refuse them and nothing would ever read or reap them.
598
-
599
- **This adds a table to the `virtualUser` schema**, and the runtime creates
600
- nothing: a database that already has `virtualUserRun` gets the store's own
601
- refusal at startup until `pikku db generate` writes the migration and
602
- `pikku db migrate` applies it. Landing it now costs nothing, because
603
- `scaffold.virtualUser` is not yet switched on anywhere.
604
-
605
- - 05e47cf: feat(virtual-user): put each persona on its own clock
606
-
607
- A budget says where one run stops. Nothing said how often a persona should use
608
- the application, so in practice each one ran whenever somebody remembered — and
609
- what actually tells you about a product is the same user coming back over a
610
- fortnight.
611
-
612
- Each persona now gets a row rather than a bigger budget. `virtualUserSchedule`
613
- holds `enabled`, the disposition and goals to run with, an interval **range**,
614
- and `nextRunAt`. `tickVirtualUserSchedules` acts on whichever rows are due:
615
-
616
- ```ts
617
- wireScheduler({
618
- name: 'virtualUsers',
619
- schedule: '0 * * * *',
620
- func: tickVirtualUserSchedules,
621
- })
622
- ```
623
-
624
- The tick is generated and wired by nobody, deliberately. A scaffolded
625
- `wireScheduler` would start spending an application's model budget the moment
626
- somebody ran `pikku all`, on a host that may not run schedulers at all. Tick
627
- resolution bounds how late a due persona is, never how often it runs.
628
-
629
- Three things it does that are easy to leave out:
630
-
631
- - The next due time is written **before** the run is dispatched, so a tick that
632
- dies halfway cannot hand the same persona to the next one. A dispatch that
633
- throws waits a full interval instead of retrying every minute for a week.
634
- That write is a compare-and-set against the `nextRunAt` the tick read, so it
635
- is also how a tick _wins_ the persona: two processes on the same cron see the
636
- same due row, and only the one whose claim lands dispatches.
637
- - A persona whose previous run is still `running` is skipped, not queued. Two
638
- copies of the same user acting at once is a different test, and its findings
639
- do not reproduce.
640
- - A run still `running` after two hours is failed. Without that, one restart
641
- mid-run blocks that persona's schedule permanently — which is where the
642
- stranded-record cost of not using a queue finally gets paid.
643
-
644
- Reschedule-on-completion was the other candidate and is worse in exactly one
645
- way, fatally: a crash between finishing and scheduling ends the persona forever,
646
- and the evidence is an absence.
647
-
648
- New: `VirtualUserScheduleStore` in core (with the tick, `isDue` and `nextRunAt`
649
- as pure functions), `KyselyVirtualUserScheduleStore` and its own schema —
650
- its own rather than a third table in `virtualUserSchema`, and owned by its own
651
- store, so a project that records runs and never wants them unattended carries no
652
- cadence table. `scaffold.virtualUser` gains `setVirtualUserSchedule`,
653
- `listVirtualUserSchedules` and the tick, behind a new `virtualUser:schedule`
654
- scope: starting a run spends money once with a caller watching, while writing a
655
- schedule spends it repeatedly with nobody there.
656
-
657
- The console's Virtual Users screen gains a **Run now** button beside a persona's
658
- run history, gated on `pikku:console:virtualUsers:run`. It dispatches the
659
- project's own `runVirtualUser` rather than starting a run itself, so a run the
660
- application would refuse — an acted-upon persona, a non-accountable disposition
661
- in production — is still refused.
662
-
663
- - Updated dependencies [3c0012c]
664
- - Updated dependencies [05e47cf]
665
- - Updated dependencies [cfd364a]
666
- - Updated dependencies [05e47cf]
667
- - Updated dependencies [05e47cf]
668
- - Updated dependencies [05e47cf]
669
- - @pikku/core@0.12.90
670
-
671
- ## 0.13.20
672
-
673
- ### Patch Changes
674
-
675
- - 274cab3: The singleton intersection moves to the leaves that name it, the runtime stops
676
- creating schema, and `db generate` writes only the runtime tables a project's
677
- services own
678
-
679
- `WiredSingletonServices` was exported from the generated function leaf so the
680
- auth leaf could import it. Nothing outside a generated leaf ever names it —
681
- emit declarations for a project of any size and it appears in none of them —
682
- so the auth and middleware leaves derive the intersection themselves and the
683
- function leaf keeps it private. `WiredServices` stays exported: 147 `.d.ts`
684
- files name it, and unexporting it asks every wired module to name each member
685
- service through a specifier it does not have.
686
-
687
- `ensurePikkuSchema` is gone. `requirePikkuSchema` replaces it: a service calls
688
- it at boot, it looks, and it issues no DDL at all. `pikku db generate` writes
689
- the declaration down as a migration and `pikku db migrate` applies it, and
690
- those two are now the only way pikku's runtime tables come into existence. A
691
- service that finds them missing says so and stops, naming both commands.
692
- Half-present is no longer a distinct case — the remedy is the same migration
693
- either way. `audit` and `virtual-user` join `pikkuSchemas` as a consequence:
694
- boot was the only thing that had ever created them.
695
-
696
- `pikku db generate` applied all of `pikkuSchemas`, so a project with no agents,
697
- no channels and no workflows still had `agent_threads`, `channels` and
698
- `workflow_runs` written into its migrations, and then carried them forever. A
699
- schema now names the services that own it, and generation gates on
700
- `requiredServices` — the set the inspector already builds for service
701
- tree-shaking. The gate is one-sided: a schema that names no owner is always
702
- written, because the session and secret stores and the deployment record are
703
- reached by the runtime itself and nothing in a project's source implies them.
704
- Declared scopes now imply `scopeService`, which nothing destructures because
705
- the generated auth layer is what reaches it.
706
-
707
- Drift keeps asking the unscoped question. A table already in a database has to
708
- stay recognisable as a runtime table after the service that needed it is
709
- dropped — scoping it there would report those tables as unexplained.
710
-
711
- Every project in this repo that had been relying on boot-time creation now says
712
- where its tables come from. `createConfig` moves into its own `config.ts` in the
713
- templates — `pikku db` looks for it there — and the three postgres templates plus
714
- the workflow verifier declare `postgresUrl` and run `pikku db generate && pikku
715
- db migrate` before the server starts, from the single connection string their
716
- runtime opens. The e2e harness cannot: its databases are in-memory sqlite built
717
- inside the services factory, so nothing outside the process can migrate them. It
718
- applies the schemas it owns with `applyPikkuSchemas` instead — the same DDL, run
719
- by the one process that has the database.
720
-
721
- - Updated dependencies [32616af]
722
- - Updated dependencies [6848cd9]
723
- - @pikku/core@0.12.89
724
-
725
- ## 0.13.19
726
-
727
- ### Patch Changes
728
-
729
- - 2d21628: fix(kysely): claim a workflow step atomically in every SQL dialect
730
-
731
- The workflow engine's "atomic claim" was a read-then-write guarded by
732
- `withStepLock`, and `@pikku/kysely` inherited a silent pass-through for that
733
- lock — so on every dialect but Postgres and MySQL a redelivered queue job could
734
- claim a step another dispatch was already running, executing a side-effecting
735
- step twice.
736
-
737
- `@pikku/kysely` now claims the step with a status-guarded `UPDATE` and reads the
738
- affected-row count, which is atomic in every SQL dialect without an
739
- advisory-lock primitive. Relay redispatch is enabled for all Kysely dialects as
740
- a result, not just Postgres and MySQL.
741
-
742
- - Updated dependencies [9687ad1]
743
- - Updated dependencies [2d21628]
744
- - Updated dependencies [985b87b]
745
- - Updated dependencies [3a83f85]
746
- - @pikku/core@0.12.87
747
-
748
- ## 0.13.18
749
-
750
- ### Patch Changes
751
-
752
- - 746ed6a: fix: one coercion plugin, not three
753
-
754
- The Kysely coercion plugin existed in three copies — the CLI's local database,
755
- `@pikku/kysely-node-sqlite` and `@pikku/kysely-bun-sqlite` — and all three had
756
- drifted apart. Only the CLI's resolved a column against the tables the query
757
- actually named, so two tables that disagree on the kind of a same-named column
758
- coerced correctly in local development and silently did not at runtime; only
759
- bun's dropped a genuinely ambiguous column instead of letting the last table
760
- processed win.
761
-
762
- The single implementation now lives in `@pikku/kysely`, which all three already
763
- depended on, and keeps both behaviours: table-qualified resolution first, an
764
- ambiguity-safe bare-name fallback second.
765
-
766
- `ColumnKind` — the value type of the generated `coercion.gen.ts` — is
767
- `'date' | 'bool' | 'json'`. The CLI's fourth member, `uuid`, was never a
768
- coercion kind: the codegen excludes it from the map by construction, because a
769
- UUID is a string in both Postgres and SQLite. It is now `AnnotationKind` in the
770
- CLI, the union a column may declare in `db/annotations.ts`, of which
771
- `ColumnKind` is the coercible subset.
772
-
773
- `@pikku/cli` also drops its unused dependency on the Node-only
774
- `@pikku/kysely-node-sqlite`.
775
-
776
- - Updated dependencies [5a1a962]
777
- - @pikku/core@0.12.86
778
-
779
- ## 0.13.17
780
-
781
- ### Patch Changes
782
-
783
- - 266e3bc: One door per name: `@pikku/core/ecosystem/*` and the package root are gone
784
-
785
- `@pikku/core` published every module twice. `ecosystem/http` re-exported
786
- `./http`, `ecosystem/services` re-exported `./services`, and a name was
787
- reachable through either — so every addition had to be made in two places, and a
788
- consumer's import said nothing about what it actually used. The package root was
789
- the same problem at a larger scale: a single barrel of 206 names that no bundler
790
- could take apart, and the one specifier that revealed nothing at all.
791
-
792
- Both are deleted. Every name now lives on the subpath that owns it, and every
793
- import carries that subpath — `@pikku/core/http`, `@pikku/core/services`,
794
- `@pikku/core/errors`, `@pikku/core/types`.
795
-
796
- Deleting the facades meant the raw subpaths had to become a superset of them,
797
- which they were not: the facade tree had accumulated 25 names with no raw home
798
- and about 26 more filed under a different area than the module they came from.
799
- Those names moved to the area that owns them, and three areas were published as
800
- new entry points rather than left on a root that is going away — `./types` (the
801
- shared type surface, the largest single destination), `./state` and
802
- `./classification`.
803
-
804
- `./classification` is one door onto one subject: what a value is and how it must
805
- be handled. Its three halves would each have been an entry point — the brands
806
- and manifest types, the stored-form helpers (`hashToken`, `unsafeAsSealed` and
807
- friends), and `SecretValue` — split by whether a name happens to be a type or a
808
- value, which is the same defect as the facades. The duration and versioned-id
809
- helpers went to `./utils`, which already published, and `PikkuRequest` went to
810
- `./function`: it is the transport-agnostic request base, not an HTTP one — HTTP
811
- has `PikkuHTTPAbstractRequest`, and the only thing outside core that extends
812
- `PikkuRequest` is Azure's timer request.
813
-
814
- `./types` inherited the root barrel's habit before it inherited its contents, so
815
- the names with an owner elsewhere were moved off it. The middleware types and the
816
- five middleware factories — `pikkuMiddleware`, `pikkuMiddlewareFactory`,
817
- `pikkuChannelMiddleware`, `pikkuChannelMiddlewareFactory` and
818
- `pikkuAgentMiddleware`, runtime values on a types entry point — are now
819
- `@pikku/core/middleware`; the function meta types are `@pikku/core/function`;
820
- `SerializedError` is `@pikku/core/errors`; and the generic TypeScript helpers
821
- (`MakeRequired`, `PickRequired`, `PickOptional`, `RequireAtLeastOne`,
822
- `JSONPrimitive`, `JSONValue`) are `@pikku/core/utils`. What is left on `./types`
823
- is the vocabulary the wirings share, which no single module owns.
824
-
825
- `pikku` was itself a root barrel — `export * from '@pikku/core'` — and
826
- now exports only the services it bundles.
827
-
828
- One module survives at the old specifier, and only for the bootstrap:
829
- `packages/cli` is generated by the _published_ CLI pinned in its `build.sh`, and
830
- that CLI still writes a bare `@pikku/core` into the files it generates for the
831
- CLI itself. `bootstrap-compat/root.ts` carries the eight types it names, a test
832
- in core fails if that list grows, and it goes when the pin moves to a CLI
833
- released from this branch. The adapter names the pinned CLI reaches for —
834
- `pikkuState` and `CreateWireServices` — are rewritten to `@pikku/core/state` and
835
- `@pikku/core/types` by the same `build.sh` patch pass, so no second shim is
836
- needed for them.
837
-
838
- A guard test keeps the root shut: it parses imports and rejects a bare
839
- `@pikku/core` rather than grepping for it, because several tests hold a user's
840
- file as a template literal, where `import … from '@pikku/core'` is fixture text
841
- rather than an import this repo makes.
842
-
843
- An agent scaffold a project generated under an older CLI is refreshed rather
844
- than left to fail: `pikku all` already deleted one importing an entry point
845
- `@pikku/core` no longer publishes, and the `#pikku` hub joins that list.
846
- Without it a project that scaffolds the agent endpoint but
847
- declares no agents keeps the old file forever — the generator that would rewrite
848
- it only runs when agents exist, and the file being present is what stops it
849
- being regenerated as missing.
850
-
851
- `pikku new addon` also wrote a tsconfig `paths` map naming only the deleted hub.
852
- An addon's `imports` map points into `dist`, so `paths` is what resolves
853
- `#pikku/<leaf>` for the addon's own source build — it now names the two leaf
854
- patterns, in both the addon and its test harness.
855
-
856
- - 786dae5: Bump every dependency whose latest release is a major across the monorepo, and
857
- port the code the majors broke: `cookie` 2's `parseCookie`/`stringifySetCookie`
858
- API in `@pikku/core` and the three runtime HTTP adapters, and assistant-ui 0.15's
859
- store client in `@pikku/assistant-ui`.
860
- - 6eef0a0: Bump every dependency to its latest compatible minor/patch across the monorepo.
861
- - Updated dependencies [7722ceb]
862
- - Updated dependencies [375c1ff]
863
- - Updated dependencies [02a70cd]
864
- - Updated dependencies [aeef159]
865
- - Updated dependencies [a281de6]
866
- - Updated dependencies [266e3bc]
867
- - Updated dependencies [02a70cd]
868
- - Updated dependencies [786dae5]
869
- - Updated dependencies [6eef0a0]
870
- - Updated dependencies [3561d67]
871
- - Updated dependencies [a91c433]
872
- - Updated dependencies [02a70cd]
873
- - Updated dependencies [9537f74]
874
- - Updated dependencies [2b57ca8]
875
- - Updated dependencies [266e3bc]
876
- - Updated dependencies [9fce0f1]
877
- - Updated dependencies [83683a0]
878
- - Updated dependencies [456c88b]
879
- - Updated dependencies [456c88b]
880
- - Updated dependencies [c127273]
881
- - @pikku/core@0.12.85
882
-
883
- ## 0.13.16
884
-
885
- ### Patch Changes
886
-
887
- - 7406bfe: Rename the agent runtime from `AI*` to `Agent*` (#596)
888
-
889
- `AI` described the model provider, not the thing being named. Every symbol that
890
- belongs to the agent runtime now says `Agent`; the symbols that genuinely wrap a
891
- model provider — `AIEmbeddingService`, `AIProviderOptions`, `AIEmbedParams`,
892
- `AITranscriptionParams`, `AIGenerateImageParams` and their siblings, and the
893
- `@pikku/ai-vercel` / `@pikku/ai-deepinfra` / `@pikku/ai-voice` packages — keep
894
- their names.
895
-
896
- **Wiring**
897
- - `pikkuAIAgent` → `pikkuAgent`, `pikkuAIScorer` → `pikkuAgentScorer`,
898
- `pikkuAIJudge` → `pikkuAgentJudge`
899
- - `CoreAIAgent` → `CoreAgent`, `AIAgentInput` → `AgentInput`, `AIAgentStep` →
900
- `AgentStep`, `AIMessage` → `AgentMessage`, and the rest of the agent types
901
- - `AIAgentRunnerService` → `AgentRunnerService`, `AIStorageService` →
902
- `AgentStorageService`, `AIRunStateService` → `AgentRunStateService`
903
-
904
- **Entry points**
905
-
906
- `@pikku/core/agent` → `@pikku/core/agent`, `@pikku/core/agent-scorer` →
907
- `@pikku/core/agent-scorer`.
908
-
909
- **Queues**
910
-
911
- The scorer queues are now `agent-score-fast` and `agent-score-slow`. Drain the
912
- old `ai-score-fast` / `ai-score-slow` queues before deploying — jobs still
913
- sitting on them when the new workers start will never be picked up.
914
-
915
- **Scaffolds**
916
-
917
- The agent scaffold pikku wrote for your project — `<scaffold>/agent/agent.gen.ts`
918
- and its schemas file — imports `@pikku/core/ai-agent`, which no longer exists. A
919
- scaffold is normally written once and then left alone, so `pikku all` would find
920
- it present and leave the broken import in place. It now deletes an agent scaffold
921
- importing either removed entry point and regenerates it in the same run. Anything
922
- you added to that file goes with it, so move local edits out first.
923
-
924
- **Database**
925
-
926
- The agent tables are renamed: `ai_threads`, `ai_message`, `ai_tool_call`,
927
- `ai_working_memory`, `ai_run` and `ai_run_score` become `agent_threads`,
928
- `agent_message`, `agent_tool_call`, `agent_working_memory`, `agent_run` and
929
- `agent_run_score`, along with their indexes and the `ai_working_memory_pk`
930
- constraint. The same rename applies to the MongoDB collections.
931
-
932
- `ensurePikkuSchema` creates tables it cannot find, so an existing database will
933
- get empty `agent_*` tables and leave the old data stranded in `ai_*`. Rename
934
- them before the first boot on the new version:
935
-
936
- ```sql
937
- ALTER TABLE ai_threads RENAME TO agent_threads;
938
- ALTER TABLE ai_message RENAME TO agent_message;
939
- ALTER TABLE ai_tool_call RENAME TO agent_tool_call;
940
- ALTER TABLE ai_working_memory RENAME TO agent_working_memory;
941
- ALTER TABLE ai_run RENAME TO agent_run;
942
- ALTER TABLE ai_run_score RENAME TO agent_run_score;
943
- ```
944
-
945
- - 6794681: Publish the ecosystem surface as per-area sub-barrels under `@pikku/core/ecosystem/*`, and point generated code, the CLI, the inspector and the runtime adapters at them.
946
-
947
- 348 names that only generated code, the toolchain or a runtime adapter ever imports now have a second home on `@pikku/core/ecosystem/<area>` — one sub-barrel per area, matching how core already publishes its entrypoints, so no single barrel grows without bound and a consumer only pulls in the area it uses.
948
-
949
- This step is additive: every name is still exported from the entrypoint it was published from before, so nothing downstream breaks. Removing them from the app-facing barrels is a later change, and needs a release carrying `./ecosystem/*` first.
950
-
951
- - a7fcd2e: Declare dependencies that were imported but missing from `package.json`
952
-
953
- `@pikku/openapi-parser` and `@pikku/better-auth` imported `zod`, `@pikku/next`
954
- imported `path-to-regexp`, `@pikku/cli` imported `kysely`, and
955
- `@pikku/assistant-ui` imported `rxjs`, none of which were declared. Each
956
- resolved through Yarn hoisting inside the monorepo and would fail for anyone
957
- installing the package on its own.
958
-
959
- `rxjs`, `kysely` and `path-to-regexp` reach consumers through public
960
- signatures — `Observable<BaseEvent>` is the return type of a published method,
961
- and `createCoercionPlugin` returns a `KyselyPlugin` — so they are runtime
962
- dependencies rather than build-only ones.
963
-
964
- `@pikku/assistant-ui` pins `rxjs` to the exact `7.8.1` that `@ag-ui/client`
965
- pins, rather than a caret range. The two packages exchange `Observable`s, so a
966
- range that floats to a second copy gives them two incompatible `Observable`
967
- types.
968
-
969
- `@pikku/kysely` also drops `SqliteSerializePlugin`, an alias of
970
- `SerializePlugin` that has been marked `@deprecated` in favour of it. Use
971
- `SerializePlugin`.
972
-
973
- - Updated dependencies [7406bfe]
974
- - Updated dependencies [6794681]
975
- - @pikku/core@0.12.84
976
-
977
- ## 0.13.15
978
-
979
- ### Patch Changes
980
-
981
- - fd9d834: Stop publishing internals that only their own package or file used. The declarations stay; only the entrypoint re-export is removed, so nothing that imported a name from where it is declared is affected.
982
- - Updated dependencies [063f43a]
983
- - Updated dependencies [ce66bf8]
984
- - Updated dependencies [d0307a8]
985
- - Updated dependencies [ce66bf8]
986
- - Updated dependencies [3ad2131]
987
- - Updated dependencies [b930dca]
988
- - Updated dependencies [b95e77d]
989
- - Updated dependencies [fd9d834]
990
- - Updated dependencies [8978fbd]
991
- - @pikku/core@0.12.82
992
-
993
- ## 0.13.14
994
-
995
- ### Patch Changes
996
-
997
- - e110c55: Add runtime scoring for AI agents: `pikkuAIScorer` for heuristic grades and
998
- `pikkuAIJudge` for LLM-judged ones, graded off the request path on two queue
999
- lanes so a slow judge cannot starve the cheap checks. Grades are sampled
1000
- deterministically per `(run, scorer)` and persisted to `ai_run_score`.
1001
- - Updated dependencies [e110c55]
1002
- - Updated dependencies [e110c55]
1003
- - Updated dependencies [e110c55]
1004
- - Updated dependencies [acc8077]
1005
- - Updated dependencies [905f737]
1006
- - Updated dependencies [3cc6428]
1007
- - Updated dependencies [c524adf]
1008
- - Updated dependencies [e110c55]
1009
- - @pikku/core@0.12.81
1010
-
1011
- ## 0.13.13
1012
-
1013
- ### Patch Changes
1014
-
1015
- - 6dada45: fix(workflow,ai-agent): make a run's owner, entry node and step function authoritative
1016
-
1017
- A graph run may only start at a node the graph declared in `meta.entryNodeIds`, and
1018
- the generated `POST /workflow/:workflowName/graph/:nodeId` route that let an HTTP
1019
- caller pick the entry node is gone. `startNode` stays for `PikkuTriggerService`,
1020
- which names a declared entry node anyway.
1021
-
1022
- `StepState` now records the `rpcName` the workflow dispatched a step with, and the
1023
- step claim rejects a queue message naming a different function with
1024
- `WorkflowStepFunctionMismatchError` before mutating any status — a step runs under
1025
- the run owner's identity and without the `expose` gate, so the message must not
1026
- choose what runs.
1027
-
1028
- `approveStep` takes the caller's session, and the generated status routes and
1029
- streams assert the same `assertWorkflowRunOwner` check: a run started through a
1030
- session may only be read and approved by that session's user. A run with no
1031
- recorded owner (trigger, scheduler, unauthenticated route) has nobody to compare
1032
- against and is still gated by the entrypoint's own `auth`/`permissions`.
1033
-
1034
- `AIRunStateService.resolveApproval` is now a compare-and-swap returning whether
1035
- _this_ caller made the claim, and both agent resume paths run a tool only for the
1036
- approvals they claimed — concurrent approvals of one tool call no longer all
1037
- execute it.
1038
-
1039
- - Updated dependencies [41c1a95]
1040
- - Updated dependencies [ce96383]
1041
- - Updated dependencies [7e60867]
1042
- - Updated dependencies [f8f1244]
1043
- - Updated dependencies [dcf20cb]
1044
- - Updated dependencies [6512384]
1045
- - Updated dependencies [e3b4c14]
1046
- - Updated dependencies [efd0ed1]
1047
- - Updated dependencies [cba98fb]
1048
- - Updated dependencies [ce96383]
1049
- - Updated dependencies [f8f1244]
1050
- - Updated dependencies [f8f1244]
1051
- - Updated dependencies [6e93a35]
1052
- - Updated dependencies [6dada45]
1053
- - @pikku/core@0.12.80
1054
-
1055
- ## 0.13.12
1056
-
1057
- ### Patch Changes
1058
-
1059
- - e848eb2: Add `relayUndispatchedSteps()`, which re-drives steps whose queue or scheduler
1060
- dispatch was lost.
1061
-
1062
- Arming a step is two writes to two systems — the step row lands `pending`, then
1063
- a job is published — and nothing spans both, so a crash in between leaves a
1064
- durable row nothing will ever pick up. The run then neither finishes nor fails.
1065
-
1066
- The step row is the outbox record and this is the relay. It is safe to
1067
- re-dispatch a step that already has a live job because `executeWorkflowStepInner`
1068
- claims the step under `withStepLock` before invoking anything: the loser reads
1069
- `running` and returns. Stores opt in by overriding `findUndispatchedSteps`; the
1070
- default returns nothing, so a store without an atomic step lock gains no
1071
- re-dispatches. Opted in: `kysely-postgres` and `kysely-mysql` (real locks) and
1072
- in-memory (inline, single-process, no queues). Not opted in: `mongodb` and
1073
- `kysely-sqlite`, whose `withStepLock` is a pass-through.
1074
-
1075
- Not self-starting — call it from a scheduled task.
1076
-
1077
- - Updated dependencies [e848eb2]
1078
- - Updated dependencies [b170489]
1079
- - Updated dependencies [ae4e898]
1080
- - @pikku/core@0.12.79
1081
-
1082
- ## 0.13.11
1083
-
1084
- ### Patch Changes
1085
-
1086
- - f5ce870: Recover workflow runs stalled by a crash mid-dispatch.
1087
-
1088
- Arming a step is two writes to two systems — the step row, then the queue or
1089
- scheduler job — so a process that died between them left a run `running` with
1090
- nothing in flight. It parked on a step that would never complete and never
1091
- error, so the run neither finished nor failed, and nothing swept it up.
1092
-
1093
- `workflowService.recoverStalledRuns()` re-drives those runs through
1094
- `resumeWorkflow`. Replay is memoized per step, so resuming a run that was not
1095
- actually stuck changes nothing; runs mid-sleep or with a step in flight are
1096
- excluded outright. It is not self-starting — call it from a scheduled task.
1097
-
1098
- Stores opt in by overriding `findStalledRunIds`; implemented here for the
1099
- Kysely and in-memory services, and a no-op elsewhere.
1100
-
1101
- - Updated dependencies [f5ce870]
1102
- - @pikku/core@0.12.78
1103
-
1104
- ## 0.13.10
1105
-
1106
- ### Patch Changes
1107
-
1108
- - 3df4f95: Scaffold virtual user runs as RPCs, backed by a run store.
1109
-
1110
- `pikku persona run` could already turn a declared persona loose on a running
1111
- stage, but only from a terminal, and the result only existed in that terminal's
1112
- output. There was no way for CI, a console, or a scheduled job to start a run —
1113
- and nothing kept what a run found, so this week's findings could not be compared
1114
- against last week's.
1115
-
1116
- `scaffold.virtualUser` now generates two RPCs and the function behind them:
1117
- - `runVirtualUser({ persona, goals?, memory?, disposition?, budget?, seed? })
1118
- -> { runId }`
1119
- - `getVirtualUserRun({ runId }) -> { status, findings, tally, memory, … }`
1120
-
1121
- They are gated on separate scopes — `virtualUser:run` and `virtualUser:read` —
1122
- because an adversarial run's findings are working exploits carrying live ids,
1123
- which makes reading them the more sensitive of the two. Production refuses every
1124
- disposition but `accountable`, checked against the effective one so the
1125
- per-run override cannot smuggle another in.
1126
-
1127
- **A run is not a workflow and not a queued job.** It explores, so no two
1128
- attempts take the same steps and there is nothing to replay; and the record
1129
- already carries the progress a queue would only be holding on the way to the
1130
- same place. `runVirtualUser` writes the record, dispatches without awaiting, and
1131
- returns the id. The cost is stated on the type: a restart mid-run strands a
1132
- record at `running`, so a run older than its budget window and still `running`
1133
- is dead rather than working.
1134
-
1135
- `@pikku/core` gains `VirtualUserRunStore` (with `virtualUserRunStore` on
1136
- `CoreSingletonServices`), and `@pikku/kysely` ships
1137
- `KyselyVirtualUserRunStore`, which creates its own table on first use like the
1138
- audit sink — the runtime never needs it, so it arrives with the feature that
1139
- fills it rather than in every database.
1140
-
1141
- Also in core: `prepareVirtualUserRun`, which derives the catalogue, intents,
1142
- scopes and reachable agents in one place. `pikku persona run` reads the
1143
- inspector state and the generated RPC reads `metaService`, and the two have to
1144
- agree — otherwise the same persona and seed explore a different API depending on
1145
- how the run was started. `personaScopes` moved here from the CLI for the same
1146
- reason and is still re-exported from its old home. `PRODUCTION_DISPOSITION` is
1147
- now exported from `@pikku/core/virtual-user`, which it should always have been.
1148
-
1149
- - Updated dependencies [3df4f95]
1150
- - @pikku/core@0.12.77
1151
-
1152
- ## 0.13.9
1153
-
1154
- ### Patch Changes
1155
-
1156
- - 62ea4cc: The audit trail is now readable — in the generated meta, through an RPC, and as
1157
- a page in the console.
1158
-
1159
- `audit: true` reaches `FunctionRuntimeMeta.audit` as its resolved form
1160
- (`{ durability }`), so which functions record anything is answerable without
1161
- running them. It is informational: the runner still resolves audit from the live
1162
- function config, so meta and runtime cannot disagree.
1163
-
1164
- `AuditService` grows an optional read side — `query(AuditQuery)` and `facets()`.
1165
- Optional because a sink can legitimately be write-only: a queue producer that
1166
- hands events to another system has nothing to read back, and a reader that finds
1167
- these absent should say the trail is not readable here rather than that it is
1168
- empty. The two are very different answers to give someone auditing a system.
1169
-
1170
- `KyselyAuditService` implements both, newest first with offset paging, filtered
1171
- by user, action and time window. Two things it now gets right that are easy to
1172
- get wrong: an empty filter array means "match nothing" rather than "no filter",
1173
- and results are read by physical _and_ camelCase key, because `CamelCasePlugin`
1174
- is on most pikku Kysely instances and renames result keys on the way out — the
1175
- mismatch does not throw, it returns a page of `undefined`. `init()` creates the
1176
- `audit` table for projects that do not migrate it themselves, from a new
1177
- exported `auditSchema` that stays out of `pikkuSchemas` because the runtime does
1178
- not need it.
1179
-
1180
- The console addon exposes `console:getAudits` and `console:getAuditFilters`
1181
- behind a new `pikku:audit:read` scope, and forwards the application's `audit`
1182
- service into the addon's own services — without that last part every install
1183
- reported the trail as unreadable, whatever sink it had configured.
1184
-
1185
- The console gets an Audit trail page: an infinite list filtered server-side by
1186
- user and action, and a row that opens the whole event, metadata rendered as a
1187
- JSON tree. Refused, unreadable and empty are three different screens, because
1188
- "you may not read this", "nobody can read this" and "nothing happened" are three
1189
- different facts.
1190
-
1191
- Events name the person who caused them. The trail records a user id — the only
1192
- thing stable enough to record, since a name can change after the event — so
1193
- `getAudits` resolves those ids against better-auth's user directory at read
1194
- time, and the page shows the name while keeping the recorded id on the event.
1195
- The filter follows: pick a colleague by name, filter by the id. A scenario
1196
- actor is labelled as one, so synthetic traffic is not mistaken for real, and a
1197
- caller who was signed out shows the wire identity pikku resolved for them
1198
- rather than being credited to the system.
1199
-
1200
- **Breaking, for anyone already reading `AuditEvent`:** `actor` is now
1201
- `userIdentity`, and its type `AuditActor` is `AuditUserIdentity`; `AuditQuery`
1202
- takes `userIds`/`orgId` in place of `actorUserIds`/`actorOrgId`, and
1203
- `AuditFacets` returns `userIds`. In pikku an _actor_ is a synthetic person a
1204
- scenario drives, flagged on the user row — so naming the causer of an event
1205
- `actor` made the synthetic case unsayable (`actor.actor === true`) and implied
1206
- every recorded action was a test. The overwhelming majority are ordinary
1207
- customers. The `audit` table follows: `actor_user_id` / `actor_org_id`
1208
- are now `user_id` / `org_id`, and a `pikku_user_id` column joins them so the
1209
- wire identity of a caller who never signed in survives the round trip — the
1210
- sink was dropping it, which left the console's Session field permanently
1211
- blank. A project that already migrated the table needs to rename the two
1212
- columns and add the third; `KyselyAuditService.init()` creates the new shape
1213
- for anyone who did not.
1214
-
1215
- - 78b29f0: `SecretService` now returns a `SecretValue<T>` rather than the bare value, so a
1216
- vault secret cannot reach a sink by accident.
1217
-
1218
- `SecretValue` is nominally typed, which means it is not assignable to `string`
1219
- (or to any other concretely-typed field). Every sink with a real type — a
1220
- database column, an email body, a session payload — rejects it with no lint
1221
- rule involved. The sinks typed `any`, `unknown`, or a free generic — the logger,
1222
- queue payloads, webhook and email inputs, and a function's own output — are
1223
- guarded with `Safe<T>`, which collapses a `SecretValue` found anywhere inside
1224
- `T`, however deeply nested, to `never`.
1225
-
1226
- Unwrap deliberately at the point the secret reaches the wire:
1227
-
1228
- ```ts
1229
- const secret = await secrets.getSecret('BETTER_AUTH_SECRET')
1230
- betterAuth({ secret: secret.reveal() })
1231
- ```
1232
-
1233
- Two behaviours cover what types cannot see. Structured serialization redacts —
1234
- `JSON.stringify` and node's inspect both yield `[secret]`, so an audit or log
1235
- write stays honest without crashing the request. String coercion throws
1236
- `SecretCoercionError`, because a template literal is always a leak.
1237
-
1238
- `AuditLog.write` is guarded the same way as the logger, since an audit event
1239
- carries `input` and `metadata` as `unknown` and nominality alone cannot stop a
1240
- secret landing in one.
1241
-
1242
- `.reveal()` is the deliberate escape hatch, and what it hands back is an
1243
- ordinary string as far as every sink signature is concerned. **PKU953** closes
1244
- that gap: under `pikku all --security` the inspector reports a revealed secret
1245
- that flows into a logger, an audit, a queue, an email or a webhook — `console` included.
1246
-
1247
- This also fixed a real one: `remote-addon-auth.ts` called `String(token)` on an
1248
- `unknown` and wrote the result straight into an `Authorization` header.
1249
-
1250
- - Updated dependencies [62ea4cc]
1251
- - Updated dependencies [9dddff8]
1252
- - Updated dependencies [78b29f0]
1253
- - @pikku/core@0.12.76
1254
-
1255
- ## 0.13.8
1256
-
1257
- ### Patch Changes
1258
-
1259
- - cabd9dc: Add a `db.schema` CLI config option, so `pikku db generate` can write the runtime tables into a named postgres schema.
1260
-
1261
- Without it the generator emits unqualified `create table` against the default `search_path` of `"$user", public`. A project that keeps everything in one namespace — `app`, say — gets a second copy of every runtime table in `public` alongside the ones it already has, which is how stray `public.ai_*` tables appear next to the real `app.ai_*` ones.
1262
-
1263
- `compilePikkuSchemas` takes the schema and binds only the rendered SQL, never the caller's connection: that connection is the throwaway database the declaration was just applied to, and qualifying it would create tables in a schema the scratch database has never heard of.
1264
-
1265
- Raw SQL is not rewritten by `withSchema`, so `rawStatement` now also accepts a builder taking a `SchemaContext` — the expression index on `credentials` uses it to qualify its own table. Statements otherwise pick the context up from whatever connection they are handed, so a schema-bound connection needs nothing said twice.
1266
-
1267
- Two fixes fall out of it:
1268
- - The `ALTER TABLE` delta for a partially covered source is written from bare introspected names, so it is qualified explicitly. Unqualified it altered a table in whichever schema `search_path` found.
1269
- - A source was only counted as partially covered on an exact name match, so a project whose migrations already create `app.workflow_step` read as "nothing covered" and had its whole schema re-emitted over tables that were already there. It now matches the schema qualifier the same way the drift diff does.
1270
-
1271
- `db.schema` is postgres only, and is rejected with an explanation on sqlite, whose `REFERENCES` clause takes a bare table name.
1272
-
1273
- - Updated dependencies [32277d5]
1274
- - Updated dependencies [ea8aabf]
1275
- - Updated dependencies [33e96ab]
1276
- - Updated dependencies [fd72e58]
1277
- - Updated dependencies [fd72e58]
1278
- - Updated dependencies [fd72e58]
1279
- - Updated dependencies [894b2f8]
1280
- - Updated dependencies [dd19aa7]
1281
- - Updated dependencies [50ec500]
1282
- - @pikku/core@0.12.75
1283
-
1284
- ## 0.13.7
1285
-
1286
- ### Patch Changes
1287
-
1288
- - 6a307f0: Fix four latent correctness bugs in the function, RPC and error runtimes, and
1289
- remove dead code from the workflow service surface.
1290
-
1291
- `WorkflowService.getNodesWithoutSteps` is gone. It was declared on the abstract
1292
- service and implemented by all five storage backends, and nothing ever called
1293
- it — hence the non-core packages in this changeset, which only lose that method.
1294
-
1295
- **An RPC could execute twice.** `RPCService.invoke`, its addon path, and
1296
- `rpcWithWire` each wrapped the _execution_ of a resolved function in a `try`
1297
- whose `catch` treated `RPCNotFoundError` as "not found locally" and re-dispatched
1298
- the call through `deploymentService`. A nested `rpc.invoke` to a missing name,
1299
- raised from inside an already-running function, therefore re-ran that function on
1300
- a remote instance after its local side effects had already committed. Resolution
1301
- is now separated from execution on all three paths, so only a genuinely
1302
- unresolvable name reaches the fallback. What escapes to callers is unchanged.
1303
-
1304
- **`addonNamespace` leaked between sibling calls.** The function runner's
1305
- middleware path restored `rpc`, `functionId`, `audit` and `addonNamespace` after
1306
- an invocation; the non-middleware path restored the first three but not the
1307
- fourth. A call into an addon function with no middleware left the addon's
1308
- namespace on the wire, so subsequent sibling calls resolved the wrong
1309
- per-instance singletons and `credentialOverrides`.
1310
-
1311
- **Errors registered on a subclass never resolved.** `misc.errors` was typed
1312
- `Map<PikkuError, ErrorDetails>` — instances — while `addError` stores
1313
- constructors, a mismatch hidden by its `error: any` parameter. The instance
1314
- lookup in `getErrorResponse` was consequently dead, and lookup fell through to a
1315
- scan comparing `constructor.name`, so a subclass of a registered error got no
1316
- status mapping at all. The map is now typed `Map<PikkuErrorConstructor, …>` and
1317
- lookup walks the prototype chain first. Name matching is retained, deliberately,
1318
- as the fallback that keeps error mapping working when two copies of
1319
- `@pikku/core` are installed.
1320
-
1321
- **`createWeakUID` collided across instances.** The prefix was
1322
- `Date.now().toString(36)` evaluated at module load, so any two instances loading
1323
- the module in the same millisecond emitted identical `channelId` and `requestId`
1324
- sequences — reproducibly, not just in principle. It is now seeded lazily from
1325
- `crypto.randomUUID()`.
1326
-
1327
- Also: `pikkuState` keys its global map with `Symbol.for` rather than `Symbol`, so
1328
- two copies of the package share registrations instead of silently getting
1329
- disjoint state; and the local channel upgrade path no longer keys its middleware
1330
- cache on the raw request path, which grew the cache without bound while the
1331
- cached value never varied by path.
1332
-
1333
- - afef587: Close eleven security weaknesses found in a review of `@pikku/core`. Most are
1334
- breaking, and two invalidate data or credentials already in the wild — read the
1335
- migration notes before upgrading.
1336
-
1337
- **Breaking: AI agent thread ownership now fails closed.** Reading, listing,
1338
- resuming or approving an existing thread or run requires a resolved session
1339
- principal (`userId`, or `orgId` for `sessionScope: 'org'`), regardless of the
1340
- agent's `auth` setting. Previously a request without a session had no ownership
1341
- model at all: the caller-supplied `resourceId` was accepted as the ownership
1342
- key, so any caller could read or resume another party's thread by naming its
1343
- `resourceId`. Worse, `threadOwnerConstraint` returned `undefined` for a
1344
- sessionless caller, and `undefined` means _no filter_ rather than _no rows_ —
1345
- so `getAgentThreads` returned every thread in the deployment. It now returns
1346
- `string[]`, empty for a sessionless caller, which every storage backend already
1347
- treats as matching nothing. Sessionless agents still run one-shot conversations,
1348
- each with a fresh unguessable owner; what they lose is cross-request continuity.
1349
- Wire a session to restore it.
1350
-
1351
- **Breaking: stored secrets and credentials must be re-entered.** `deriveKey` ran
1352
- a single unsalted round of SHA-256 over the passphrase and used the digest
1353
- directly as the AES-GCM key — roughly one hash per brute-force guess, with one
1354
- rainbow table working against every deployment. It is now PBKDF2-HMAC-SHA256 at
1355
- 600,000 iterations over a random salt. There is no compatibility path: every
1356
- value held by the kysely, mongodb and redis secret services and the kysely
1357
- credential service becomes undecryptable. They fail loud, naming the key and
1358
- `key_version`, so the app hard-fails on first secret read until each is re-set.
1359
-
1360
- The KEK salt is scoped to the key version and stored alongside it, rather than
1361
- per secret, so a bulk read costs one derivation instead of N — `getSecrets` over
1362
- 50 secrets went from ~2.3s to ~48ms, and rotation from ~4.6s to ~94ms. This adds
1363
- a salt table (kysely), hash field (redis) or collection (mongodb), created
1364
- automatically on first use.
1365
-
1366
- **Breaking: `PIKKU_REMOTE_SECRET` must be at least 32 characters.** The
1367
- remote-RPC session envelope moved from PBKDF2 to HKDF, which expands
1368
- high-entropy key material rather than stretching a low-entropy passphrase. That
1369
- took a remote hop from ~269ms to ~0.4ms — PBKDF2 was running twice per request —
1370
- but HKDF supplies no brute-force resistance, so the secret must carry the
1371
- entropy itself. A shorter secret now throws `WeakKeyMaterialError` at both ends.
1372
- Generate one with `openssl rand -base64 32` and roll it out to every service in
1373
- the mesh together: existing bearer tokens are format-incompatible, so a partial
1374
- rollout produces 401s until every instance is updated. The Cloudflare, Lambda
1375
- and Azure deployment services each hand-rolled a copy of `buildRemoteHeaders`
1376
- and now call the shared one, which is what keeps the two sides in step.
1377
-
1378
- **Breaking: previously signed content URLs stop verifying.** `LocalContent`
1379
- signed only `{signedAt, expiresAt, notBefore}`, so a signature proved when a URL
1380
- was issued but never what it was issued for — any valid token was a skeleton
1381
- key, and swapping the pathname from a public thumbnail to a private document
1382
- still verified. The signature now binds the request path. Separately, the
1383
- verifier returned "valid" when no JWT service was wired, which is how
1384
- `pikku serve` ran: a forged `?signedAt=0&expiresAt=99999999999999` was accepted.
1385
- It now rejects with 403, `LocalContent` requires a `JWTService`, and
1386
- `pikku serve`/`pikku dev` mint an ephemeral per-process signing key so local
1387
- development works without shipping a fail-open path. In-flight signed URLs must
1388
- be re-issued.
1389
-
1390
- **Request body size limits now apply to every adapter.** The `maxBodySize` cap
1391
- existed only in `PikkuFetchHTTPRequest`. The real hole was uWebSockets, which
1392
- drove `res.onData` itself and concatenated every chunk with no bound and nothing
1393
- downstream able to intervene; it now drops chunks past the limit and replies 413
1394
- before routing. Fastify delegates to its native `bodyLimit` (set only when
1395
- `maxBodySize` is configured, so fastify's stricter 1 MB default is never
1396
- loosened), and `PikkuExpressServer` feeds the limit into its body parsers. Two
1397
- paths can only reject rather than prevent, and are documented as such:
1398
- `express-middleware` mounted on your own app receives an already-parsed body, so
1399
- that deployment must bound its own parser; Next server actions bottom out at
1400
- `experimental.serverActions.bodySizeLimit`.
1401
-
1402
- **Breaking: the console addon's privileged functions are gated by default.**
1403
- `wireAddon` gains a `scopes` option that applies to every function in the
1404
- addon's namespace, and the console scaffold now generates
1405
- `wireAddon({ name: 'console', package: '@pikku/addon-console', scopes: ['admin'] })`.
1406
- Previously the console's entire privileged surface — around 54 functions
1407
- including `credentialGet`, which returns a resolved OAuth token for an arbitrary
1408
- `userId`, `updateFunctionBody`, and `installAddon`, which shells out to a
1409
- package install — was protected only by an optional host-registered
1410
- `addGlobalPermission`. `resolveGlobalPermissions` returns `[]` when none is
1411
- registered and permission checking then no-ops, so an app that never registered
1412
- one served those functions to anyone, and with the template's default
1413
- `scaffold.rpc: "no-auth"` that meant unauthenticated. All of them now return 403
1414
- `MissingScopeError` without an `admin`, `admin:*` or `*` scope. **Regenerating
1415
- is required** — an app holding an old `console.gen.ts` stays open.
1416
- `installAddon` and `installOpenapiAddon` additionally declare their own
1417
- `auth: true, scopes: ['admin']`, and `getAgentThreads` now scopes its listing to
1418
- the session's own threads unless the caller holds admin.
1419
-
1420
- Addon scopes are enforced in `runPikkuFunc` rather than at the RPC boundary,
1421
- because a wiring can reference an addon function directly — the inspector
1422
- records the addon's `packageName` on HTTP, channel, schedule, queue, CLI,
1423
- trigger, gateway and MCP wirings — and those paths never call `resolveNamespace`.
1424
- Enforcing at the RPC seam would have covered only the `namespace:function` form
1425
- while reading as complete.
1426
-
1427
- **Breaking: `wireAddon`'s `auth` and `tags` now apply on direct wirings too.**
1428
- Both were read only by `resolveAddonFunction`, so they had exactly the hole
1429
- scopes had: `wireAddon({ name: 'console', package: '@pikku/addon-console', auth:
1430
- true, tags: ['admin'] })` gated `rpc('console:credentialGet')` and gated nothing
1431
- at all on an HTTP route wired straight to `credentialGet`. A consumer who
1432
- reached for the documented way to lock an addon down got a control that was
1433
- silently inert on every wiring except one. Both now resolve in `runPikkuFunc`.
1434
- `auth` merges as an OR — `auth: false` from an addon is ignored on a direct
1435
- wiring, because an addon may require a session the wiring did not but must never
1436
- waive one it did. Addon tags resolve to concrete middleware against the **root**
1437
- tag groups before the call rather than being folded into the function's
1438
- inherited middleware: `addTagMiddleware('admin', …)` is written by the consuming
1439
- app and registers under the root package, whereas `combineMiddleware` would look
1440
- the tag up under the addon's own `packageName`, where it does not exist.
1441
-
1442
- One consequence worth naming: an addon that wires `auth: true` and also runs its
1443
- own sessionless internal work — a scheduled task or queue worker inside the
1444
- addon calling a sibling function — is now gated where it previously was not,
1445
- because a bare `rpc('fn')` from inside the addon reaches `runPikkuFunc` with the
1446
- addon's `packageName` like any other call. This reverses a decision that
1447
- deliberately scoped the gate to the namespaced boundary; that reasoning held
1448
- only while the boundary was real, and a direct wiring can enter an addon without
1449
- crossing it, so "already inside" is not something the runtime can infer. Such an
1450
- addon should carry authorization on the function via
1451
- `pikkuFunc({ permissions })`, which has always been enforced on every path. A
1452
- follow-up will add execution provenance so an intra-addon call can be
1453
- distinguished from an external one and skip the addon-level check; that needs a
1454
- marker no caller outside the process can set, which is its own design problem
1455
- and does not belong in a security fix.
1456
-
1457
- **Codegen now warns when an exposed function has no gate (PKU574).** The
1458
- generated `POST /rpc/:rpcName` dispatcher forwards to `rpc.exposed`, which
1459
- refuses anything without `expose: true` — but nothing checked whether the
1460
- target was gated, because a dispatcher cannot know what it dispatches to. The
1461
- console shipped ~54 privileged functions through that gap and the toolchain was
1462
- silent. The inspector now reports every function that is exposed, sessionless,
1463
- and carries no `auth`, `scopes` or `permissions` of its own and none from a
1464
- governing `wireAddon`. It is a `warn`, not a critical: `expose: true` on an
1465
- ungated sessionless function is correct for a genuinely public endpoint, so it
1466
- blocks a build only under `--fail-on-warn`.
1467
-
1468
- Two pieces of metadata were missing for this to be answerable statically, and
1469
- both are now recorded. A `pikkuSessionlessFunc`'s own `auth: true` was read at
1470
- runtime but never written to function meta, so a self-gated function was
1471
- indistinguishable from an ungated one — `sessionless` carries the baseline, and
1472
- `auth` now carries the tightening. And `wireAddon`'s `scopes`, `auth` and `tags`
1473
- were not parsed at all: the inspector recorded the addon's `rpcEndpoint` and its
1474
- secret, variable and credential overrides, and dropped every one of its gates.
1475
- An addon whose gates are not statically knowable is treated as gated, because a
1476
- false positive on a correctly-secured addon costs more than the one case it
1477
- would catch.
1478
-
1479
- **Breaking: an application's global permissions now apply inside addons.**
1480
- `resolveGlobalPermissions` read only the bucket matching the function's own
1481
- package, but the generated `addGlobalPermission` wrapper takes no package
1482
- argument and always registers under the root. An app-wide rule like "every
1483
- request needs a signed-in user" therefore stopped at the addon boundary, and the
1484
- bucket an addon's functions did read was one no host could write to — which is
1485
- why the console addon's recommended `addGlobalPermission([isAdmin],
1486
- '@pikku/addon-console')` was never a gate anybody could actually install. A
1487
- function now resolves the root bucket and its own package's, root first.
1488
- Unioning is safe in a way nothing else here would be: globals AND, so adding the
1489
- root ones can only tighten. Package buckets stay one-way — a package's globals
1490
- never reach root functions, or an installed addon could gate the whole
1491
- application. Apps with both a root global and addon-provided functions will see
1492
- those functions gated where they previously were not.
1493
-
1494
- **Codegen now records whether each HTTP route requires a session, and warns
1495
- about inert addon tags (PKU575).** Four separate things can demand a session —
1496
- the function's `sessionless`, its own `auth`, the route's (or its group's)
1497
- `auth`, and the addon it belongs to — and answering "which routes are open?"
1498
- meant joining all four by hand and knowing which wins. Each route's meta now
1499
- carries the resolved `requiresSession` alongside the route's own `auth`. Scopes
1500
- count as requiring one, since they are matched against the session's and fail
1501
- closed. Anything not statically knowable resolves to `true`, matching PKU574:
1502
- a route that looks stricter than it is costs less than one that looks open and
1503
- isn't. Separately, `wireAddon({ tags: ['admin'] })` reads like a gate and is
1504
- applied like one right up until no `addTagMiddleware('admin', …)` exists, at
1505
- which point it resolves to an empty list and gates nothing; that now warns.
1506
- Only addon tags are reported — a tag on a function is as likely to be
1507
- organizational, and warning about those would bury the case that matters.
1508
-
1509
- **Object-shorthand permissions were missing from meta.** The inspector visited
1510
- `ts.PropertyAssignment` but not `ts.ShorthandPropertyAssignment`, so
1511
- `permissions: { canAdminOrg }` — enforced identically to the longhand form at
1512
- runtime, since `verifyPermissions` has a non-array branch — was recorded as _no
1513
- permissions at all_. That is the most dangerous direction for meta to be wrong
1514
- in: an audit reading it sees an open door where one is shut. It cost this review
1515
- a false IDOR report across ~35 billing and org functions before the source
1516
- contradicted the metadata.
1517
-
1518
- **Functions that authorize in their own body can say so.** A webhook receiver
1519
- verifying a signature, or a handler redeeming a signed invite, is genuinely
1520
- closed while carrying no session, scope or permission — indistinguishable in
1521
- meta from one nobody remembered to gate, and so warned about forever by PKU574.
1522
- `selfAuthenticated: true` on the function config records the claim and silences
1523
- the warning for that function. It is declarative only: nothing at runtime reads
1524
- it and it grants nothing. Detection was rejected deliberately — inferring it
1525
- from the body means a function that _looks_ like it checks something silences
1526
- the warning while checking nothing, and a warning that is usually wrong stops
1527
- being read.
1528
-
1529
- **Breaking: `scaffold.<feature>` is now `boolean | { auth?, path? }`, and `true`
1530
- means authenticated.** The old `'auth' | 'no-auth' | false` read like a
1531
- starter-file preference while being a live authorization decision, set three
1532
- directories from the functions it governed — the shape the console incident
1533
- took. A surface now becomes public only by writing `{ auth: false }`, so
1534
- omitting a field can never open anything: the failure mode of a forgotten flag
1535
- is a locked door. `{ path }` additionally overrides where the file is
1536
- generated, which previously could only be set for all features at once via
1537
- `pikkuDir`.
1538
-
1539
- The legacy strings are **refused, not coerced**. `resolveScaffoldFeature` throws
1540
- naming the key and its replacement (`"rpc": "no-auth"` → `"rpc": { "auth":
1541
- false }`), and it does so at config load, not downstream. An earlier design used
1542
- a bare `string` for the output path, under which `"no-auth"` would have parsed
1543
- as a file named `no-auth` and every unmigrated config would have silently
1544
- produced nonsense; the object form makes any string invalid, so the failure is
1545
- loud.
1546
-
1547
- The collapse is deliberately not uniform in effect. For `rpc` the flag was a
1548
- blanket "no anonymous RPC in this app" set on a dispatcher that cannot know what
1549
- it dispatches to; for `userAdmin` it was redundant, since the generated
1550
- functions are already `pikkuFunc` with `scopes: ['admin:users:list']`. But for
1551
- `agent`, `workflow`, `events` and `scenarios` it is the only gate — those
1552
- generate real endpoints the app never authors — so `true` keeps them
1553
- authenticated rather than opening them as a side effect of a config cleanup.
1554
- `webhook` and `remoteRpc` have no auth dimension at all (`serialize-remote-rpc.ts`
1555
- hardcodes `auth: false`), so an `{ auth }` on them is ignored. The three
1556
- configs in this repo are migrated preserving their current behaviour exactly.
1557
-
1558
- **Queue job identities are signed.** A job carried the producer's `pikkuUserId`
1559
- as a plain string and the worker resolved a session from it with no
1560
- verification, so write access to the queue backend was act-as-any-user. The
1561
- identity is now `pq1.<claim>.<hmac>`, HMAC-SHA256 over the claim and the
1562
- canonicalized job payload, keyed by HKDF expansion of a new
1563
- `PIKKU_QUEUE_IDENTITY_SECRET`. Producers opt in by wrapping their queue service
1564
- with `SignedQueueService`. This fails safe rather than closed: with no secret
1565
- configured the identity is dropped and jobs still process, warning once per
1566
- process, so no existing deployment breaks on upgrade — it simply loses queue
1567
- identity until the secret is set. The payload rather than the job id is bound
1568
- because SQS, Cloudflare Queues, Azure and the in-memory service all mint ids
1569
- after `add` returns.
1570
-
1571
- **Workflow inline state is read from the run record.** `isInline` consulted a
1572
- process-local `Map`, while `WorkflowRun.inline` is durable. Any instance that
1573
- did not start a run disagreed with the record, so one instance could dispatch a
1574
- queued job for a workflow another was already executing in-process. It is now
1575
- async and resolves through the durable identity, cached only when a context
1576
- already exists so a passive reader allocates nothing. The same `Map` also leaked:
1577
- `nextStepKey` fabricated replay state on every step, and `releaseContext`
1578
- refused to free anything carrying it, so runs whose steps executed outside a
1579
- `beginReplay` bracket — the step-worker queue path — stranded their context and
1580
- step state for the process lifetime. Contexts are now released by an explicit
1581
- execution counter. Step ordinals reset per execution rather than accumulating
1582
- across step-worker invocations in one process, which makes step naming
1583
- independent of how work was distributed.
1584
-
1585
- **Secret reads fail loud in every store.** `MongoDBSecretService.getSecrets`
1586
- skipped rows that failed to decrypt, and the redis equivalent dropped every
1587
- rejection via `Promise.allSettled`, including the "No KEK available for
1588
- key_version N" configuration error. Both now throw, naming the key and its key
1589
- version, matching the kysely behaviour. This matters most alongside the KEK
1590
- change above: without it, an upgrade surfaces as a partial secrets map and an
1591
- opaque downstream failure instead of an error naming the secret to re-enter.
1592
-
1593
- **A second middleware registration for a pattern no longer erases the first.**
1594
- `addHTTPMiddleware`, `addTagMiddleware` and `addChannelMiddleware` groups are
1595
- keyed by pattern or tag and held one source file each, so a second file's call
1596
- overwrote the first's. Codegen emits its imports from what is stored, so the
1597
- losing file was never imported and its middleware never registered — the
1598
- runtime composes repeated registrations for a pattern happily, and only codegen
1599
- dropped one. Adding an unrelated `addHTTPMiddleware('*', …)` to an app was
1600
- enough to silently unregister the generated better-auth session bridge, which
1601
- fails open and gives no sign until a request arrives without a session. A group
1602
- now carries every registration made for it, and all of them are imported.
1603
-
1604
- - Updated dependencies [6a307f0]
1605
- - Updated dependencies [afef587]
1606
- - Updated dependencies [8075f6a]
1607
- - @pikku/core@0.12.74
1608
-
1609
- ## 0.13.6
1610
-
1611
- ### Patch Changes
1612
-
1613
- - 8a2c993: Make the workflow service cheaper to run, and fix two ways it lost state.
1614
-
1615
- The SQL workflow tables had no indexes at all, so every step read, every
1616
- history walk and every orchestrator tick was a sequential scan; five indexes
1617
- now cover the columns the engine actually queries by. A replay used to ask for
1618
- each step's row individually — O(N) reads per replay, O(N^2) over a run — and
1619
- now takes one read of the run's steps and serves the walk from it. A step
1620
- transition wrote the step row and its history row as two separate statements,
1621
- so a crash between them left a step saying `succeeded` whose history still said
1622
- `running`; both halves are now one transaction, and the history row is found by
1623
- attempt number rather than by sorting on `created_at`, which two attempts can
1624
- share. Resolving a dynamic workflow read and parsed every AI-generated workflow
1625
- in the deployment to `.find()` one by name; it is a point lookup now.
1626
-
1627
- Waiting on a run no longer polls at a fixed interval. `pollIntervalMs` became a
1628
- ceiling rather than a cadence: polling starts at 10ms and widens towards it, so
1629
- a workflow that finishes in milliseconds is no longer held for a full second,
1630
- and a long-running one is not read at full rate for its whole life.
1631
-
1632
- Two backend-specific defects: Redis kept a run's state as one JSON blob and
1633
- read-modified-wrote it, so parallel branches setting different variables
1634
- overwrote each other — state is a field per variable now, with the old blob
1635
- still read underneath so runs in flight keep what they had. Mongo's
1636
- `setStepScheduled` never wrote history, leaving a queued step reading as never
1637
- dispatched.
1638
-
1639
- Also: dispatch no longer JSON round-trips every step payload before handing it
1640
- to a queue that serialises it anyway — the in-process dev queue, which is the
1641
- only one that was relying on it, does it itself now.
1642
-
1643
- Two more defects. A transition whose step had no live attempt wrote its status
1644
- to the step row and silently nothing to history — the exact divergence the
1645
- transaction exists to prevent — and now repairs the step and writes the
1646
- missing row. And resolving a dynamic workflow was non-deterministic on all
1647
- three backends: a name can hold several active versions, and none of them
1648
- ordered the candidates, so which one ran could change between two calls
1649
- reading identical data. The newest version wins, with the graph hash breaking
1650
- a tie.
1651
-
1652
- The two attempt columns and the five indexes are declared in the workflow
1653
- schema, so a fresh database gets them at boot. An existing one gets them from
1654
- a migration — `pikku db generate` writes the declaration down — rather than
1655
- from DDL issued at boot.
1656
-
1657
- - a261006: **Breaking:** removed dynamic workflows — runtime-defined workflow graphs stored in the database and resolved by name instead of by codegen.
1658
-
1659
- The feature was already half-gone. Its authoring surface (`createAgentWorkflow`, `saveAgentWorkflow`, `listAgentWorkflows`, `executeAgentWorkflow`, and the AI-agent instruction builder) was deleted in April 2026 along with its entire e2e suite, and nothing has written a dynamic workflow since. What remained could not execute one either: `executeAgentWorkflow` gated on `pikkuState('workflows', 'meta')`, which only codegen ever populates, so a graph that existed solely in the database was never findable. The two backend families had also drifted onto different `source` sentinels (`'ai-agent'` vs `'dynamic-workflow'`), and the two Redis implementations disagreed on key escaping — so at least one of them matched nothing. Rather than keep shipping plumbing for a path no caller could complete, it is removed until it can be reintroduced deliberately.
1660
-
1661
- Removed:
1662
- - `getAIGeneratedWorkflows` from `WorkflowService` and `WorkflowRunService`, and from every backend (in-memory, Redis, MongoDB, Kysely, and the Cloudflare Durable Object service and client — the last two were already a `return []` stub and a rejection).
1663
- - The database-lookup fallbacks in `startWorkflow` and `runWorkflowJob` that resolved a workflow name against stored graphs when static meta had no match.
1664
- - `'dynamic-workflow'` from the `WorkflowRuntimeMeta['source']` union.
1665
- - `validateWorkflowWiring` and `computeEntryNodeIds` from `@pikku/core/workflow`. These validated AI-authored graphs and had no callers in core; the inspector keeps its own private entry-node computation for static graph wiring, which is unaffected.
1666
- - The `workflow-created` AI stream event and its AG-UI `pikku:workflow-created` custom event. Its only emitter went with the April deletion, so it could never fire.
1667
- - The console's `console:getAIWorkflows` RPC, the `useAIWorkflows` hook, the "Dynamic" workflow filter and badge, and the trigger-schema scraper that derived an input form from a stored graph's `$ref` bindings.
1668
-
1669
- Kept, because static graph workflows depend on them and this is not a change to versioning:
1670
- - `upsertWorkflowVersion`, `getWorkflowVersion`, `updateWorkflowVersionStatus`, and the `workflowVersions` storage in every backend. These back version-mismatch replay: when a deployed graph's hash changes, in-flight runs continue against the exact graph they started on. No schema migration is needed — the table, its columns, and its `(workflowName, graphHash)` upsert key are unchanged.
1671
- - `generateMermaidDiagram`, which renders any workflow graph and is not specific to dynamic ones.
1672
-
1673
- Static `pikkuWorkflowGraph` and DSL workflows are entirely unaffected: they resolve from codegen'd meta, which was always the only path that worked.
1674
-
1675
- To revive this post-MVP, the deleted authoring code is recoverable in full — its prompt engineering (a compact tool table upfront, full schemas with flattened dotted output paths returned only after a validation failure) is worth reading before rewriting:
1676
-
1677
- ```
1678
- git show f52f3308b^:packages/core/src/wirings/ai-agent/agent-dynamic-workflow.ts
1679
- git show f52f3308b^:packages/core/src/wirings/workflow/graph/graph-validation.ts
1680
- git show f52f3308b --stat # the April removal, incl. the three e2e feature files
1681
- ```
1682
-
1683
- Note that reviving it needs more than restoring those files: the queued-step path (`executeWorkflowStep`), `onError` compensation, and sub-workflow resolution all read static meta only and would need a fallback for a graph that exists solely in the database.
1684
-
1685
- - Updated dependencies [8a2c993]
1686
- - Updated dependencies [a261006]
1687
- - Updated dependencies [09973b9]
1688
- - @pikku/core@0.12.71
1689
-
1690
- ## 0.13.5
1691
-
1692
- ### Patch Changes
1693
-
1694
- - 220a8c4: fix: `ensurePikkuSchema` now sees tables on a `withSchema(...)`-bound connection
1695
-
1696
- It read the table name out of its own compiled DDL with a regex that matched the
1697
- first quoted identifier. On a connection bound to a schema that DDL is
1698
- `create table "app"."workflow_runs"`, so it captured `app` — never a real table
1699
- name — concluded every table was missing, and issued a bare `create table` that
1700
- the database rejected with `relation "workflow_runs" already exists`, on every
1701
- boot.
1702
-
1703
- The schema half of the name is now parsed, and the lookup matches on the pair
1704
- when the DDL is qualified (falling back to the bare name when it is not, since
1705
- an unqualified statement resolves against a `search_path` that is not knowable
1706
- from here). Error messages name the schema too.
1707
-
1708
- Also: applying a schema over a `withSchema(...)`-bound **sqlite** connection now
1709
- explains itself. `withSchema` qualifies foreign key targets along with everything
1710
- else — which postgres requires and sqlite refuses, since a `REFERENCES` clause
1711
- there takes a bare table name — and all the engine says about it is
1712
- `near ".": syntax error`. The failure is now reported with the schema that
1713
- produced it and what to do instead, with the engine error kept as the `cause`.
1714
-
1715
- ## 0.13.4
1716
-
1717
- ### Patch Changes
1718
-
1719
- - 91077ff: Declare the pikku runtime tables instead of creating them at boot.
1720
-
1721
- The tables the runtime needs — workflow, AI, scopes, secrets, credentials, webhooks, channels, deployments, sessions — were created by `createTable(...).ifNotExists()` inside each service's `init()`. A table therefore existed if and only if some service happened to be constructed, in whatever order, with whatever schema qualifier that call site passed. In one deployment that produced a duplicate set of AI tables in `public` shadowing the intended ones in `app`.
1722
-
1723
- `pikkuSchemas` is now the single declaration, exported from `@pikku/kysely`: the same kysely schema-builder chains, moved out of `init()` and never executed at boot. `applyPikkuSchemas` materializes them onto a database, `compilePikkuSchemas` renders them as SQL for a dialect, and both bind `CamelCasePlugin` themselves so a declaration always compiles to the physical names the rest of the package queries.
1724
-
1725
- `applyPikkuSchemas` runs its statements in one transaction, so the promise it makes about a half-applied database holds for the failures the prerequisite check cannot foresee too — a statement colliding with a table something else already created rolls back the ones that ran before it.
1726
-
1727
- Auth is a declared prerequisite. `pikkuUserRole` and `pikkuUserScope` reference `user.id`, which Better Auth owns, so `scopeSchema` says so via `requires` and `applyPikkuSchemas` checks every prerequisite before creating anything — a project without auth gets a sentence naming what is missing and who owns it, not a foreign key error and not a half-applied database. `resolveRequirements` returns the same answer as data for callers that need to describe the gap rather than die on it.
1728
-
1729
- That prerequisite also fixes a fourth disagreement: `user_id` was declared `text`, but `user.id` has no fixed type — Better Auth decides it from config, giving `uuid` under `generateId: 'uuid'` and an identity `integer` under `'serial'`, and postgres refuses a `text` column referencing either. The whole statement was rejected, so `KyselyScopeService.init()` had never actually created these tables on such a project — one had a migration written by hand with a comment explaining why. The column now takes its type from the column it references, whatever that turns out to be.
1730
-
1731
- Three further disagreements the single declaration settled:
1732
- - `aiRun` was created by two services with different columns. `KyselyAIStorageService` omitted `pendingApprovals`; `KyselyAIRunStateService` declared it and read it back through `as any` casts. Whichever ran first decided the shape, and where the storage service won, resolving an approval failed. The column is declared.
1733
- - `workflowRuns`, `workflowStep` and `workflowStepHistory` defaulted their primary keys to `sql.raw("'" + crypto.randomUUID() + "'")`, evaluated once when the statement was built — one shared default for every row, not a generator. Dropped; the services supply the id.
1734
- - `workflowStep.fromStepName` was backfilled by an `alterTable(...).execute().catch(() => {})` bolted on after the fact. It is part of the declaration.
1735
-
1736
- Every service's `init()` now goes through `ensurePikkuSchema`, which looks before it creates: all the tables present is a no-op, none present creates them from the declaration, and some present throws rather than filling in the rest. That last case is the point. `.ifNotExists()` turned every failure into a silent success — it is why nobody noticed the `user_id` type had been rejected since the day it was written — and a schema half-owned by a migration and half by a boot-time create is the condition all of this exists to end. Around 615 lines of duplicated DDL went with it.
1737
-
1738
- Creating at boot is now the fallback rather than the intent: run `pikku db generate` and `init()` takes the `present` path and issues no DDL at all.
1739
-
1740
- `KyselyPikkuDB` stays hand-written, because it carries what introspection cannot recover — `WorkflowStatus` rather than `string`, `Generated<Date>` rather than `Date`. A test materializes the declaration and asserts the two agree on every table and column, which is the drift protection generating it would have bought. It found one on its first run: `ai_run.pending_approvals` was in the DDL and in `KyselyAIRunStateService`, but not in `AIRunTable` — the reason that service read it back through `as any`. Declared, and the casts are gone.
1741
-
1742
- ## 0.13.3
1743
-
1744
- ### Patch Changes
1745
-
1746
- - e3d4454: Add job groups, so one shared queue can stay fair without splitting into one
1747
- queue per producer.
1748
-
1749
- A job may now carry `group: { id, tier }`, and a worker may cap how many jobs
1750
- of any one group run at once via `groupConcurrency`. On pg-boss this maps to
1751
- `localGroupConcurrency`, which excludes at-capacity groups from the fetch query
1752
- itself, so a capped group costs nothing rather than being fetched and restored.
1753
- BullMQ declares it unsupported (groups are a BullMQ Pro feature) — being
1754
- push-based, it can simply use a queue per group at no polling cost.
1755
-
1756
- Workflow services accept a `queueStrategy`. The default `'per-workflow'` is
1757
- unchanged: every workflow gets its own `wf-orchestrator-*` / `wf-step-*` queue,
1758
- which is also what lets serverless providers deploy one unit per workflow. The
1759
- new `'shared-groups'` routes every workflow through the shared
1760
- orchestrator/step-worker queues and isolates them by group instead, so a
1761
- monolith runs one set of pollers rather than one per workflow — on a
1762
- pull-based backend with dozens of workflows that is the difference between
1763
- hundreds of poll loops and twenty. It is for single-process runtimes only; a
1764
- per-unit serverless deploy still needs the per-workflow queues to route to its
1765
- units.
1766
-
1767
- - Updated dependencies [24252b8]
1768
- - Updated dependencies [e3d4454]
1769
- - @pikku/core@0.12.69
1770
-
1771
- ## 0.13.2
1772
-
1773
- ### Patch Changes
1774
-
1775
- - 4324652: Scope AI agent thread reads to the calling session.
1776
-
1777
- The generated thread-management functions (`getAgentThreads`,
1778
- `getAgentThreadMessages`, `getAgentThreadRuns`, `deleteAgentThread`) keyed purely
1779
- off a caller-supplied `threadId` and treated `resourceId` as an optional filter,
1780
- so omitting it enumerated every tenant's threads.
1781
- - `listThreads` gains an `owners` **authorization constraint** (distinct from the
1782
- `resourceId` filter): an empty array matches nothing, and it is always derived
1783
- from the session, never from input. Implemented across the Kysely, Redis and
1784
- MongoDB agent run services, with LIKE/regex metacharacter escaping so an owner
1785
- id containing `_` or `%` cannot match a foreign owner.
1786
- - The three `threadId`-keyed functions are now guarded by an `isThreadOwner`
1787
- `pikkuPermission` rather than an in-body check. A thread that does not exist is
1788
- denied rather than 404'd, so it is indistinguishable from one owned by someone
1789
- else.
1790
- - New `@pikku/core/ai-agent` helpers: `canAccessThread`, `threadOwnerConstraint`,
1791
- `sessionPrincipals`, `isOwnedByPrincipal`.
1792
-
1793
- Services destructured by a wired function are now non-optional inside it.
1794
-
1795
- The inspector already aggregated the services used by every wired `func`,
1796
- `permissions` and `middleware` into `RequiredSingletonServices`, but the
1797
- generated function types defaulted their service parameter to the raw `Services`
1798
- — so a service declared `foo?: Foo` still arrived as possibly-undefined, forcing
1799
- `if (!foo) throw new MissingServiceError(...)` guards that could never fire.
1800
- Generated types now expose `WiredSingletonServices` / `WiredServices`
1801
- (`RequiredSingletonServices & Services`) and default the `RequiredServices`
1802
- generic of functions, permissions, middleware, auth and approval-description
1803
- helpers to them. Optionality now means only what it should: "this service may
1804
- not be created, because nothing uses it".
1805
-
1806
- - Updated dependencies [5f19016]
1807
- - Updated dependencies [78e4778]
1808
- - Updated dependencies [4324652]
1809
- - Updated dependencies [de044f8]
1810
- - Updated dependencies [cd1a811]
1811
- - Updated dependencies [19fa6f0]
1812
- - Updated dependencies [b501612]
1813
- - Updated dependencies [eb37b1e]
1814
- - @pikku/core@0.12.66
1815
-
1816
- ## 0.13.1
1817
-
1818
- ### Patch Changes
1819
-
1820
- - 13474a6: feat(scopes): grant scopes directly to a user, not only through roles
1821
-
1822
- A scope can now be granted to a user directly, outside of any role.
1823
- `resolveScopes` returns the union of a user's role-derived scopes and their
1824
- direct grants, so a one-off capability no longer requires inventing a role.
1825
- - `@pikku/core`: `ScopeService` gains `addScopeToUser` / `removeScopeFromUser` /
1826
- `listUserScopes`.
1827
- - `@pikku/kysely`: a new `pikku_user_scope` table (FK into `pikku_scopes`, so the
1828
- database still refuses an undeclared grant; `ON DELETE CASCADE` from `user`,
1829
- so deleting a user takes their direct grants with it). `resolveScopes` unions
1830
- it with the role join.
1831
- - `@pikku/addon-console`: `scopeAddScopeToUser` / `scopeRemoveScopeFromUser`
1832
- (gated by `pikku:scopes:manage`), and `scopeListUserRoles` now also returns
1833
- `directScopes`.
1834
- - `@pikku/console`: a **Direct scopes** section in the user roles drawer to grant
1835
- and revoke scopes directly, showing them distinctly from the resolved union.
1836
-
1837
- Also: the Scopes page now distinguishes a permission error (a console admin
1838
- without `pikku:scopes:read`) from an actual scope-service outage, instead of
1839
- showing "the scope service may be unavailable" for both.
1840
-
1841
- - 13474a6: feat: KyselyScopeService — resolve and administer user scopes
1842
-
1843
- Adds `KyselyScopeService`, backing the core `ScopeService` interface with four
1844
- self-created tables: `pikku_scopes`, `pikku_roles`, `pikku_role_scopes` and
1845
- `pikku_user_role`.
1846
-
1847
- Scopes are declared in code and synced additively — a scope that is no longer
1848
- declared is marked, never deleted, so a rename or a rolling deploy cannot
1849
- silently revoke a grant. `pikku scopes prune` is the deliberate removal path.
1850
- Roles are data, composed by admins at runtime, and `pikku_role_scopes` has a
1851
- foreign key into `pikku_scopes`, so the database itself refuses to grant a
1852
- scope that was never declared.
1853
-
1854
- - 13474a6: feat: ScopeService.listScopes
1855
-
1856
- Exposes the scope vocabulary held in the store — everything a role can be
1857
- composed from — flagging any scope that is still present but no longer declared
1858
- in code (inert, and awaiting `pikku scopes prune`).
1859
-
1860
- - 70fa400: Add outgoing webhooks — `webhookService.send()` enqueues signed deliveries onto a retrying queue, `@pikku/kysely`'s `KyselyWebhookService` persists per-attempt delivery history, and `@pikku/console` gains a read-only `/webhooks` page; also caches resolved secrets in `TypedSecretService` and registers inline-`func` metadata for queue/scheduler/trigger/gateway wirings.
1861
- - Updated dependencies [7ab5287]
1862
- - Updated dependencies [e86bc17]
1863
- - Updated dependencies [a9b96a0]
1864
- - Updated dependencies [3f7fc54]
1865
- - Updated dependencies [c478794]
1866
- - Updated dependencies [3f04ae4]
1867
- - Updated dependencies [90d9f04]
1868
- - Updated dependencies [cb079cc]
1869
- - Updated dependencies [cb079cc]
1870
- - Updated dependencies [0a7db82]
1871
- - Updated dependencies [981c4db]
1872
- - Updated dependencies [13474a6]
1873
- - Updated dependencies [5a2b0d5]
1874
- - Updated dependencies [13474a6]
1875
- - Updated dependencies [ee040dc]
1876
- - Updated dependencies [cb079cc]
1877
- - Updated dependencies [13474a6]
1878
- - Updated dependencies [9f0d0eb]
1879
- - Updated dependencies [13474a6]
1880
- - Updated dependencies [70fa400]
1881
- - Updated dependencies [7b2ea23]
1882
- - Updated dependencies [1dc77d5]
1883
- - Updated dependencies [416606c]
1884
- - Updated dependencies [d2a6eea]
1885
- - Updated dependencies [30e62ee]
1886
- - @pikku/core@0.12.64
1887
-
1888
- ## 0.13.0
1889
-
1890
- ### Minor Changes
1891
-
1892
- - 241e6cf: Add `KyselyAuditService` — a durable `AuditService` that persists AuditEvents to an `audit` table via Kysely (the companion sink to `createAuditedKysely`). Its column mapping matches Fabric's platform audit-queue consumer, so a locally-run project and a deployed stage produce identical rows. Use it as the local/dev audit sink so audit events persist and are queryable without the platform queue.
1893
-
1894
- ### Patch Changes
1895
-
1896
- - 41ce2cb: Upgrade to TypeScript 6 and raise the minimum Node.js version to 22.
1897
-
1898
- All packages now build against `typescript@^6.0.3` and declare `engines.node >= 22`. Internal tooling (`ts-json-schema-generator`, `zod-to-ts`) was bumped to TypeScript 6-compatible releases.
1899
-
1900
- - Updated dependencies [41ce2cb]
1901
- - @pikku/core@0.12.44
1902
-
1903
- ## 0.12.18
1904
-
1905
- ### Patch Changes
1906
-
1907
- - 5c0ff0f: Fix `getRunHistory` dropping step provenance (`fromStepName`). The value was persisted on the step row and used by the graph planner, but `getRunHistory` built its rows from the per-attempt history and never carried `fromStepName` through — so run history (and any timeline reconstructed from it) reported no predecessors. Redis and Kysely `getRunHistory` now return `fromStepName`. Also adds the missing `from_step_name` column (+ backfill) to the Kysely workflow mirror's `workflow_step` schema and persists it on mirror inserts, so a mirror-side history has identical provenance.
1908
- - 72694f6: feat(workflow): expose per-step attempt count + record running/succeeded/failed timestamps
1909
-
1910
- `getRunStatus` now returns `attempts` (the latest attempt count) per step, so
1911
- consumers can show retry counts without a second history query. It already
1912
- computed `duration` from `runningAt`/`succeededAt`, but the kysely and mongodb
1913
- workflow stores only stamped those timestamps on the _insert_ path — the
1914
- `running` / `succeeded` / `failed` status transitions updated the history row's
1915
- status without setting `runningAt` / `succeededAt` / `failedAt`, so `duration`
1916
- was always undefined. The transitions now stamp the matching timestamp, so step
1917
- duration is populated for kysely- and mongodb-backed runs. (Redis already
1918
- stamped on transition.) A shared service-suite test guards both behaviours.
1919
-
1920
- - Updated dependencies [4be205f]
1921
- - Updated dependencies [061c717]
1922
- - Updated dependencies [2c55e13]
1923
- - Updated dependencies [c745c26]
1924
- - Updated dependencies [57900b5]
1925
- - Updated dependencies [72694f6]
1926
- - @pikku/core@0.12.39
1927
-
1928
- ## 0.12.17
1929
-
1930
- ### Patch Changes
1931
-
1932
- - 92cd5b1: feat(workflow): workflow-owned step retries + stable invocationId
1933
-
1934
- The workflow — not the queue — now owns step retry policy, and each step
1935
- invocation gets a stable idempotency key.
1936
- - **Default `retries: 5` with exponential backoff.** A step with no `retries`
1937
- previously inherited the queue's bare default (e.g. pg-boss `retry_limit 2`,
1938
- no backoff) so retries fired instantly and couldn't outlast a transient
1939
- outage. Retries now default to 5 with backoff, resolved at the workflow layer.
1940
- - **`retries: 0` is honored.** Dispatch previously passed `undefined` options
1941
- for `retries: 0`, letting the queue re-run a non-idempotent step up to its own
1942
- default. The resolved policy now always sets `attempts` (`retries: 0` →
1943
- `attempts: 1`), so the queue never second-guesses the workflow. The persisted
1944
- step retries and the dispatched `attempts` are resolved together so
1945
- "retries exhausted" and "no more redeliveries" are the same event.
1946
- - **`workflowStep.invocationId`** — a deterministic, dependency-free
1947
- `uuidv5(runId:stepName)` handed to every step. Unlike `stepId` (minted per
1948
- attempt), it is identical across retries, so a step can dedupe on it
1949
- (`ON CONFLICT (invocationId)`, Stripe idempotency keys, etc.).
1950
- - **queue-bullmq**: `mapPikkuJobToBull` now maps `backoff` (previously dropped,
1951
- so a step's backoff silently never applied on Redis), and `registerQueues`
1952
- throws a clear error when no logger is available (matching queue-pg-boss).
1953
- - **Dispatch failures are recoverable, not fatal.** A step is now marked
1954
- `scheduled` only _after_ it is successfully handed to its transport (queue or
1955
- scheduler) — a failed hand-off leaves it `pending` so a replay re-dispatches
1956
- it, instead of stranding it in `scheduled` (replay would pause forever on a
1957
- job that was never enqueued). A transport outage (e.g. pg-boss momentarily
1958
- down) is surfaced as a new `WorkflowDispatchException`, which the orchestrator
1959
- treats as transient: the run is left running and the orchestrator job is
1960
- rethrown for redelivery (it replays idempotently from the snapshot) rather
1961
- than the whole run being marked `failed`. The orchestrator job now also
1962
- carries its own retry policy, so this holds even when the orchestrator queue
1963
- is configured `retry_limit 0`. A genuine step error still fails the run.
1964
- - **Same step name can be invoked multiple times in one run.** Step rows are now
1965
- keyed per _invocation_: the Nth reach of a step name in a replay resolves to a
1966
- physical key (`name` for the first, `name#N` for repeats), so a literal
1967
- duplicate name no longer clobbers the earlier step's state. The first reach
1968
- keeps the bare name, so existing rows, graph-node matching and `invocationId`s
1969
- are unchanged. Ordinals are derived deterministically from DSL execution order
1970
- and reset each replay.
1971
- - **Step provenance (`fromStepName`) + graph cycles.** Every step now records
1972
- the predecessor it was scheduled from (`fromStepName`; entry steps have none),
1973
- persisted on the step row across all stores (in-memory, kysely, redis,
1974
- mongodb, cloudflare DO) and carried in the queued payload. The DSL wire
1975
- exposes the derived `fromInvocationId` (`uuidv5(runId:fromStepName)`) so
1976
- consumers get the stable predecessor key without a second persisted id —
1977
- `fromStepName` is the source of truth (it is replay-deterministic; `stepId`,
1978
- minted per row, is not). This makes the walked path reconstructable even when
1979
- a node is reached more than once: in `a → b → a → c` the second `a` is a
1980
- distinct ordinal instance (`a#1`) whose `fromStepName` is `b`.
1981
- The graph runner now supports **cycles**: a forward edge into an
1982
- already-started node still collapses to a single run (joins/diamonds are
1983
- unchanged), but a _back-edge_ — one whose target can reach its source — fires
1984
- a fresh ordinal instance, so a node can loop back to itself. Termination is
1985
- the graph's responsibility (branch routing must converge); the engine enforces
1986
- no visit cap.
1987
-
1988
- - Updated dependencies [92cd5b1]
1989
- - @pikku/core@0.12.38
1990
-
1991
- ## 0.12.16
1992
-
1993
- ### Patch Changes
1994
-
1995
- - 6565b97: Fix `KyselyWorkflowRunService.getRunSteps`: build the `runningAt` /
1996
- `succeededAt` / `failedAt` correlated subqueries through the query builder
1997
- instead of raw `sql` fragments, so the active schema (`withSchema(...)`)
1998
- qualifies `workflow_step_history`. The raw fragments hardcoded an unqualified
1999
- table name and failed with `relation "workflow_step_history" does not exist`
2000
- against a connection whose `search_path` did not include the schema.
2001
- - 34f254e: Bump the `kysely` dependency range to `^0.29.0` so it dedupes onto a single
2002
- copy alongside Better Auth (which bundles kysely 0.29.x), avoiding two
2003
- incompatible `Kysely` classes (the `#private` brand mismatch) when both pikku's
2004
- adapters and Better Auth share a database connection.
2005
-
2006
- kysely 0.29 is ESM-only, which the unmaintained `kysely-plugin-serialize`
2007
- (no `exports` map, CommonJS build) cannot import. Its `SerializePlugin` is now
2008
- maintained directly in `@pikku/kysely` and re-exported, and the external
2009
- dependency is dropped from `@pikku/kysely`, `@pikku/kysely-sqlite`, and
2010
- `@pikku/cloudflare`.
2011
-
2012
- ## 0.12.15
2013
-
2014
- ### Patch Changes
2015
-
2016
- - ea48df2: Include runningAt, succeededAt, and failedAt timestamps in getRunSteps results
2017
- - Updated dependencies [2cf67be]
2018
- - @pikku/core@0.12.28
2019
-
2020
- ## 0.12.14
2021
-
2022
- ### Patch Changes
2023
-
2024
- - 4b5c75b: feat(auth-js): wire OIDC config (issuer/tenantId) as variables, expand provider registry
2025
- - Move `issuer` and `tenantId` out of the secret blob for OIDC providers (auth0, okta, azure-ad, keycloak, cognito, microsoft-entra-id) — they are public config URLs, not secrets. Now registered via `wireVariable` and loaded at runtime via `services.variables.get()`.
2026
- - Expand provider registry from 13 to 31 providers: reddit, notion, instagram, zoom, figma, tiktok, threads, patreon, dropbox, bitbucket, hubspot, salesforce, atlassian, strava, keycloak, cognito, microsoft-entra-id added.
2027
- - `serialize-auth-gen` emits `wireVariable({...})` declarations and `services.variables.get()` calls in the generated factory for OIDC providers.
2028
- - Integration verifier exercises real `/auth/providers` endpoint with `LocalSecretService` + `LocalVariablesService`, including a spy test proving `services.variables.get('AUTH0_ISSUER')` is called at request time.
2029
-
2030
- - Updated dependencies [4b5c75b]
2031
- - Updated dependencies [4b5c75b]
2032
- - @pikku/core@0.12.27
2033
-
2034
- ## 0.12.13
2035
-
2036
- ### Patch Changes
2037
-
2038
- - 909eb25: Add audit logging support for function invocations and database queries.
2039
-
2040
- Introduces `AuditService` and `createAuditedKysely` — configurable audit capture with best-effort and transactional durability modes. Audit logs capture session metadata (user, org), RPC call details, and Kysely query operations (type, tables, changes). Audit context is scoped per-invocation so nested RPC calls are correctly attributed.
2041
-
2042
- - Updated dependencies [909eb25]
2043
- - @pikku/core@0.12.26
2044
-
2045
- ## 0.12.12
2046
-
2047
- ### Patch Changes
2048
-
2049
- - 55ba75a: Update the OSS runtime dependency set for newer Node support by bumping `uWebSockets.js` to `v20.68.0` and `better-sqlite3` to `v12.10.0`.
2050
- - Updated dependencies [c02275f]
2051
- - Updated dependencies [0bd0433]
2052
- - @pikku/core@0.12.24
2053
-
2054
- ## 0.12.11
2055
-
2056
- ### Patch Changes
2057
-
2058
- - b9ed73e: Add deterministic workflow planned-step metadata support and SSE init stream payload generation.
2059
- - Persist `deterministic` and `plannedSteps` on workflow runs in core and service adapters.
2060
- - Expose planned-step metadata on workflow run status responses.
2061
- - Emit an initial `type: 'init'` SSE event for deterministic workflow streams before incremental updates.
2062
- - Add CLI tests covering serialized stream route output for init/update/done event behavior.
2063
-
2064
- - Updated dependencies [b9ed73e]
2065
- - @pikku/core@0.12.19
2066
-
2067
- ## 0.12.0
2068
-
2069
- ## 0.12.10
2070
-
2071
- ### Patch Changes
2072
-
2073
- - 311c0c4: Unify session persistence through SessionStore, remove session blob from ChannelStore
2074
- - PikkuSessionService now persists sessions via SessionStore on set()/clear() instead of every function call
2075
- - ChannelStore no longer stores session data — maps channelId to pikkuUserId only
2076
- - ChannelStore API: setUserSession/getChannelAndSession replaced with setPikkuUserId/getChannel
2077
- - Serverless channel runner resolves sessions from SessionStore using pikkuUserId from ChannelStore
2078
-
2079
- - Updated dependencies [311c0c4]
2080
- - @pikku/core@0.12.18
2081
-
2082
- ## 0.12.9
2083
-
2084
- ### Patch Changes
2085
-
2086
- - 624097e: Add deploy pipeline with provider-agnostic architecture
2087
- - Add MetaService with explicit typed API, absorb WiringService reads
2088
- - Add deployment service, traceId propagation, scoped logger
2089
- - Rewrite analyzer: one function = one worker, gateways dispatch via RPC
2090
- - Add Cloudflare deploy provider with plan/apply commands
2091
- - Add per-unit filtered codegen for deploy pipeline
2092
- - Skip missing metadata in wiring registration for deploy units
2093
- - Fix schema coercion crash when schema has no properties
2094
- - Fix E2E codegen: double-pass resolves cross-package Zod type imports
2095
-
2096
- - Updated dependencies [9e8605f]
2097
- - Updated dependencies [624097e]
2098
- - Updated dependencies [7ab3243]
2099
- - @pikku/core@0.12.15
2100
-
2101
- ## 0.12.8
2102
-
2103
- ### Patch Changes
2104
-
2105
- - f85c234: Add unified credential system with per-user OAuth and AI agent pre-flight checks
2106
- - Unified CredentialService with lazy loading per user via pikkuUserId
2107
- - wire.getCredential() for typed single credential lookup
2108
- - MissingCredentialError with structured payload for client-side connect flows
2109
- - Console UI: Global/Users credential tabs, per-user OAuth connect/revoke
2110
- - AI agent pre-flight check: detects missing OAuth credentials from addon metadata, shows "Connect your accounts" prompt before chat
2111
- - CLI codegen: generates credentialsMeta per addon package for runtime lookup
2112
- - Vercel AI runner: catches MissingCredentialError as runtime fallback
2113
-
2114
- - Updated dependencies [f85c234]
2115
- - Updated dependencies [88d3100]
2116
- - @pikku/core@0.12.14
2117
-
2118
- ## 0.12.7
2119
-
2120
- ### Patch Changes
2121
-
2122
- - c485aab: Fix CamelCasePlugin mismatch: convert all table types, query references, and result property accesses from snake_case to camelCase to match Kysely CamelCasePlugin runtime behavior
2123
-
2124
- ## 0.12.6
2125
-
2126
- ### Patch Changes
2127
-
2128
- - 0f59432: Add per-user credential system with CredentialService, OAuth2 route handlers, and KyselyCredentialService with envelope encryption
2129
- - Updated dependencies [0f59432]
2130
- - Updated dependencies [52b64d1]
2131
- - @pikku/core@0.12.10
2132
-
2133
- ## 0.12.5
2134
-
2135
- ### Patch Changes
2136
-
2137
- - 87433f0: Remove secret key names from error messages to prevent information disclosure.
2138
- - Updated dependencies [e412b4d]
2139
- - Updated dependencies [53dc8c8]
2140
- - Updated dependencies [0a1cc51]
2141
- - Updated dependencies [0a1cc51]
2142
- - Updated dependencies [0a1cc51]
2143
- - Updated dependencies [0a1cc51]
2144
- - Updated dependencies [0a1cc51]
2145
- - Updated dependencies [0a1cc51]
2146
- - Updated dependencies [0a1cc51]
2147
- - Updated dependencies [0a1cc51]
2148
- - Updated dependencies [0a1cc51]
2149
- - Updated dependencies [8b9b2e9]
2150
- - Updated dependencies [8b9b2e9]
2151
- - Updated dependencies [b973d44]
2152
- - Updated dependencies [8b9b2e9]
2153
- - Updated dependencies [8b9b2e9]
2154
- - @pikku/core@0.12.9
2155
-
2156
- ## 0.12.4
2157
-
2158
- ### Patch Changes
2159
-
2160
- - 3e79248: Add setStepChildRunId to workflow service implementations and auto-bootstrap in pikku all
2161
- - Updated dependencies [bb27710]
2162
- - Updated dependencies [a31bc63]
2163
- - Updated dependencies [3e79248]
2164
- - Updated dependencies [b0a81cc]
2165
- - Updated dependencies [6413df7]
2166
- - @pikku/core@0.12.6
2167
-
2168
- ## 0.12.3
2169
-
2170
- ### Patch Changes
2171
-
2172
- - 32ed003: Add envelope encryption utilities and database-backed secret services with KEK rotation support
2173
- - 387b2ee: Add error_message column to agent run storage and queries
2174
- - b2b0af9: Migrate all consumers from @pikku/pg to @pikku/kysely and remove the @pikku/pg package
2175
- - c7ff141: Add WorkflowVersionStatus type with draft→active lifecycle for AI-generated workflows, type all DB status fields with proper unions instead of plain strings
2176
- - Updated dependencies [387b2ee]
2177
- - Updated dependencies [32ed003]
2178
- - Updated dependencies [7d369f3]
2179
- - Updated dependencies [508a796]
2180
- - Updated dependencies [ffe83af]
2181
- - Updated dependencies [c7ff141]
2182
- - @pikku/core@0.12.3
2183
-
2184
- ## 0.12.2
2185
-
2186
- ### Patch Changes
2187
-
2188
- - ce961b5: fix: improve MySQL compatibility in AI storage service by using varchar columns with explicit lengths instead of text for primary keys, foreign keys, and indexed columns, and handle duplicate index errors gracefully
2189
- - 3e04565: chore: update dependencies to latest minor/patch versions
2190
- - Updated dependencies [cc4c9e9]
2191
- - Updated dependencies [3e04565]
2192
- - @pikku/core@0.12.2
2193
-
2194
- ## 0.12.1
2195
-
2196
- ### Patch Changes
2197
-
2198
- - e04531f: Code quality improvements: resolve oxlint warnings and apply autofixes across the codebase (unused bindings, unnecessary constructors, prefer `const` over `let`, etc.). No behaviour changes.
2199
- - Updated dependencies [62a8725]
2200
- - Updated dependencies [a3bdb0d]
2201
- - Updated dependencies [e0349ff]
2202
- - Updated dependencies [62a8725]
2203
- - Updated dependencies [e04531f]
2204
- - Updated dependencies [62a8725]
2205
- - Updated dependencies [a83efb8]
2206
- - Updated dependencies [8eed717]
2207
- - Updated dependencies [62a8725]
2208
- - Updated dependencies [62a8725]
2209
- - Updated dependencies [62a8725]
2210
- - @pikku/core@0.12.1
2211
-
2212
- - Updated dependencies
2213
-
2214
- ## 0.11.0
2215
-
2216
- ### Minor Changes
2217
-
2218
- - Remove Kysely-based channel and eventhub stores (use @pikku/pg instead)
2219
- - Update to support shared connection instances
2220
-
2221
- # @pikku/kysely
2222
-
2223
- ## 0.10.0
2224
-
2225
- This release includes significant improvements across the framework including tree-shaking support, middleware/permission factories, enhanced CLI functionality, improved TypeScript type safety, and comprehensive test strategies.
2226
-
2227
- For complete details, see https://pikku.dev/changelogs/0_10_0.md
2228
-
2229
- ## 0.9.5-next.0
2230
-
2231
- ### Patch Changes
2232
-
2233
- - Updated dependencies
2234
- - @pikku/core@0.9.12-next.0
2235
-
2236
- ## 0.9.4
2237
-
2238
- ### Patch Changes
2239
-
2240
- - 58fe540: fix: kysely pure script should also clean arrays
2241
- - Updated dependencies [85a1c76]
2242
- - @pikku/core@0.9.7
2243
-
2244
- ## 0.9.3
2245
-
2246
- ### Patch Changes
2247
-
2248
- - 917bd6b: feat: fixing number issue with pure generation
2249
- - af95a59: fix: adding a number type (string or number) to db for now. Going forward should probably parse to a number but js and floats..
2250
- - Updated dependencies [9691aba]
2251
- - Updated dependencies [2ab0278]
2252
- - Updated dependencies [81005ba]
2253
- - @pikku/core@0.9.3
2254
-
2255
- ## 0.9.2
2256
-
2257
- ### Patch Changes
2258
-
2259
- - a5905a9: chore: updating all dependencies
2260
- - Updated dependencies [1256238]
2261
- - Updated dependencies [6cf8efd]
2262
- - Updated dependencies [d3a9a09]
2263
- - Updated dependencies [840e078]
2264
- - Updated dependencies [667d23c]
2265
- - Updated dependencies [a5905a9]
2266
- - @pikku/core@0.9.2
2267
-
2268
- ## 0.9.1
2269
-
2270
- ### Patch Changes
2271
-
2272
- - fdb1593: core: bumping everything with a patch to sync up the major release inconsistencies in dependencies
2273
- - Updated dependencies [fdb1593]
2274
- - @pikku/core@0.9.1
2275
-
2276
- ## 0.9.0
2277
-
2278
- ### Breaking Changes
2279
-
2280
- - Normalized all transports to use "wirings" instead of events/routes/transports for consistency across the framework
2281
-
2282
- ## 0.8.0
2283
-
2284
- - Updated to match the 0.8 version
2285
-
2286
- ## 0.7.0
2287
-
2288
- - Updating to match remaining packages
2289
-
2290
- ## 0.6.5
2291
-
2292
- ### Patch Changes
2293
-
2294
- - 9541f42: fix: deleting ssl invalidation
2295
-
2296
- ## 0.6.4
2297
-
2298
- ### Patch Changes
2299
-
2300
- - 8a14f3a: refactor: removing user session from channel object
2301
- - Updated dependencies [ebc04eb]
2302
- - Updated dependencies [8a14f3a]
2303
- - Updated dependencies [2c47386]
2304
- - @pikku/core@0.6.17
2305
-
2306
- ## 0.6.3
2307
-
2308
- ### Patch Changes
2309
-
2310
- - 2c9a6b0: fix: correct reference to pikku-kysely-pure
2311
-
2312
- ## 0.6.2
2313
-
2314
- ### Patch Changes
2315
-
2316
- - 990c2c2: fix: not requiring kysely as a peerDependency
2317
-
2318
- ## 0.6.1
2319
-
2320
- ### Patch Changes
2321
-
2322
- - 8fcaa7e: feat: adding kysely wrapper
2323
- - Updated dependencies [eb8a8b4]
2324
- - @pikku/core@0.6.13
2325
-
2326
- ## 0.6.1
2327
-
2328
- ### Patch Changes
2329
-
2330
- - 0a92fa7: refactor: pulling schema into seperate package since ajv doesnt work on cloudflare (also keeps bundle size small!)
2331
- - Updated dependencies [0a92fa7]
2332
- - @pikku/core@0.6.7
2333
-
2334
- ## 0.6
2335
-
2336
- Marking a major release to include channels and scheduled tasks
2337
-
2338
- ## 0.5.3
2339
-
2340
- ### Patch Changes
2341
-
2342
- - 886a2fb: refactor: moving singletons (like routes and channels) to global to avoid nodemodule overrides
2343
- - Updated dependencies [a768bad]
2344
- - Updated dependencies [886a2fb]
2345
- - Updated dependencies [886a2fb]
2346
- - @pikku/core@0.5.28
2347
-
2348
- ## 0.5.2
2349
-
2350
- ### Patch Changes
2351
-
2352
- - 0f96787: refactor: dropping cjs support
2353
- - c23524a: refactor: bump to versions to ensure correct package usage
2354
- - Updated dependencies [0f96787]
2355
- - Updated dependencies [64e4a1e]
2356
- - Updated dependencies [c23524a]
2357
- - @pikku/core@0.5.25
2358
-
2359
- ## 0.5.1
2360
-
2361
- ### Patch Changes
2362
-
2363
- - bba25cc: chore: updating all packages to reflect major changes
2364
- - Updated dependencies [bba25cc]
2365
- - Updated dependencies [9deb482]
2366
- - Updated dependencies [ee0c6ea]
2367
- - @pikku/core@0.5.24