@lunora/codegen 1.0.0-alpha.6 → 1.0.0-alpha.60

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 (71) hide show
  1. package/LICENSE.md +6 -0
  2. package/__assets__/package-og.svg +1 -1
  3. package/dist/index.d.mts +2072 -735
  4. package/dist/index.d.ts +2072 -735
  5. package/dist/index.mjs +1 -29
  6. package/dist/packem_shared/AGENTS_FILENAME-BesaDYkL.mjs +1 -0
  7. package/dist/packem_shared/CONTAINERS_FILENAME-CFwdyaCI.mjs +1 -0
  8. package/dist/packem_shared/CodegenDiagnosticError-DPezpZTz.mjs +1 -0
  9. package/dist/packem_shared/FLAGS_FILENAME-DW5oGq1q.mjs +1 -0
  10. package/dist/packem_shared/GENERATED_HEADER-4TxGhJDQ.mjs +1 -0
  11. package/dist/packem_shared/LUNORA_ERROR_CODES-Um9hC1gr.mjs +1 -0
  12. package/dist/packem_shared/MUTATORS_FILENAME-BKKPROzu.mjs +1 -0
  13. package/dist/packem_shared/NOTIFY_FILENAME-C-c7Lg-U.mjs +1 -0
  14. package/dist/packem_shared/OPENRPC_VERSION-B_EyUGlr.mjs +3 -0
  15. package/dist/packem_shared/QUEUES_FILENAME-CSE6i-ld.mjs +1 -0
  16. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-B-b-ZgwS.mjs +3 -0
  17. package/dist/packem_shared/SCHEMA_SNAPSHOT_VERSION-Bpf1FGMG.mjs +15 -0
  18. package/dist/packem_shared/SHAPES_FILENAME-DTkSJSsg.mjs +1 -0
  19. package/dist/packem_shared/WORKFLOWS_FILENAME-Bk5upkGM.mjs +1 -0
  20. package/dist/packem_shared/buildOpenApiDocument-f291wyY3.mjs +3 -0
  21. package/dist/packem_shared/discover-ast-CezKqEhE.mjs +1 -0
  22. package/dist/packem_shared/discoverAuthApiCalls-DOfSQqVK.mjs +1 -0
  23. package/dist/packem_shared/discoverCrons-B09_uEuL.mjs +1 -0
  24. package/dist/packem_shared/discoverFunctions-BdibLQmc.mjs +1 -0
  25. package/dist/packem_shared/discoverHttpRoutes-BOWz6y_n.mjs +1 -0
  26. package/dist/packem_shared/discoverInserts-BtteTyNy.mjs +1 -0
  27. package/dist/packem_shared/discoverMaskProcedures-COPmwMBm.mjs +1 -0
  28. package/dist/packem_shared/discoverMigrations-iGMlp9YJ.mjs +1 -0
  29. package/dist/packem_shared/discoverNondeterministicCalls-Dmgc4QBx.mjs +1 -0
  30. package/dist/packem_shared/discoverQueries-CcfuGKHh.mjs +1 -0
  31. package/dist/packem_shared/discoverR2sqlCalls-CjZKvg-N.mjs +1 -0
  32. package/dist/packem_shared/discoverRlsMetadata-BXmNOgry.mjs +1 -0
  33. package/dist/packem_shared/discoverSandboxUsage-CDdBqWcM.mjs +1 -0
  34. package/dist/packem_shared/discoverSchema-m2voTncu.mjs +1 -0
  35. package/dist/packem_shared/discoverStorageRulesMetadata-b71cJJHz.mjs +1 -0
  36. package/dist/packem_shared/emit-Cz-5gRp0.mjs +2127 -0
  37. package/dist/packem_shared/emitApp-DbpB1vA1.mjs +413 -0
  38. package/dist/packem_shared/formatAdvisories-DZvv-0MG.mjs +2 -0
  39. package/dist/packem_shared/parse-validator-CSDlMEvE.mjs +1 -0
  40. package/dist/packem_shared/paths-BmX5O1sG.mjs +1 -0
  41. package/dist/packem_shared/redact-CQ8-to6l.mjs +1 -0
  42. package/dist/packem_shared/schemaFromIr-R1ZFzVyy.mjs +1 -0
  43. package/package.json +10 -7
  44. package/dist/packem_shared/CONTAINERS_FILENAME-0K-pjNb8.mjs +0 -224
  45. package/dist/packem_shared/CodegenDiagnosticError-54jWDxA9.mjs +0 -22
  46. package/dist/packem_shared/GENERATED_HEADER-DF1hQcix.mjs +0 -2495
  47. package/dist/packem_shared/LUNORA_ERROR_CODES-CySpQPD3.mjs +0 -61
  48. package/dist/packem_shared/OPENRPC_VERSION-C7zKVeKi.mjs +0 -60
  49. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-TeOosleN.mjs +0 -922
  50. package/dist/packem_shared/SCHEMA_SNAPSHOT_VERSION-DzLDbWk3.mjs +0 -233
  51. package/dist/packem_shared/WORKFLOWS_FILENAME-DRDQdhfq.mjs +0 -84
  52. package/dist/packem_shared/buildOpenApiDocument-Cns1EkCQ.mjs +0 -183
  53. package/dist/packem_shared/discover-ast-CT6BgBr4.mjs +0 -13
  54. package/dist/packem_shared/discoverAuthApiCalls-C35R6z0T.mjs +0 -62
  55. package/dist/packem_shared/discoverCrons-BL6iGuJ3.mjs +0 -254
  56. package/dist/packem_shared/discoverFunctions-DEgAcRuD.mjs +0 -460
  57. package/dist/packem_shared/discoverHttpRoutes-C978pBiG.mjs +0 -131
  58. package/dist/packem_shared/discoverInserts-CRQdXvHO.mjs +0 -39
  59. package/dist/packem_shared/discoverMaskProcedures-B64zA740.mjs +0 -217
  60. package/dist/packem_shared/discoverMigrations-Doj_-BAA.mjs +0 -91
  61. package/dist/packem_shared/discoverNondeterministicCalls-4KiPQxQU.mjs +0 -122
  62. package/dist/packem_shared/discoverQueries-BkIi0dBD.mjs +0 -62
  63. package/dist/packem_shared/discoverR2sqlCalls-BpDqvcUn.mjs +0 -80
  64. package/dist/packem_shared/discoverRlsMetadata-DpRB1HMe.mjs +0 -280
  65. package/dist/packem_shared/discoverSchema-DYl0QfDH.mjs +0 -775
  66. package/dist/packem_shared/discoverStorageRulesMetadata-DAqJUxUv.mjs +0 -97
  67. package/dist/packem_shared/emitApp-Ci_hcJNO.mjs +0 -599
  68. package/dist/packem_shared/formatAdvisories-8NIv1k0I.mjs +0 -69
  69. package/dist/packem_shared/parse-validator-tuQtHrsr.mjs +0 -132
  70. package/dist/packem_shared/paths-BRd6JHuF.mjs +0 -11
  71. package/dist/packem_shared/schemaFromIr-DTYsLBaA.mjs +0 -57
package/dist/index.d.mts CHANGED
@@ -1,14 +1,16 @@
1
- import { Finding } from '@lunora/advisor';
1
+ import { AdvisorExportSink, AdvisorGeoIndexUsage, AdvisorNotifyCall, AdvisorNotifyConfig, Finding } from '@lunora/advisor';
2
2
  export type { Finding } from '@lunora/advisor';
3
+ import { LunoraError } from '@lunora/errors';
4
+ export { MESSAGE_SOLUTIONS as LUNORA_SOLUTION_RULES, type Solution as LunoraSolution, type SolutionRule as LunoraSolutionRule, findSolutionByMessage as findLunoraSolution } from '@lunora/errors';
3
5
  import { Node, Project } from 'ts-morph';
4
6
  import { StudioFeaturesResult } from '@lunora/do';
5
7
  import { Schema } from '@lunora/server';
6
8
  import { JsonSchema } from '@lunora/values';
7
9
  /**
8
- * AST-observable subset of a column's modifier chain (`.unique()`, `.default()`,
9
- * …). Function-valued modifiers (`.$defaultFn`/`.$onUpdateFn`) can't be
10
- * serialized, so only their *presence* is recorded.
11
- */
10
+ * AST-observable subset of a column's modifier chain (`.unique()`, `.default()`,
11
+ * …). Function-valued modifiers (`.$defaultFn`/`.$onUpdateFn`) can't be
12
+ * serialized, so only their *presence* is recorded.
13
+ */
12
14
  interface ColumnMetaIR {
13
15
  /** `.default(...)` or `.$defaultFn(...)` present — field is optional on insert. */
14
16
  hasDefault?: boolean;
@@ -25,6 +27,15 @@ interface ValidatorIR {
25
27
  bucket?: string;
26
28
  /** Column modifiers (`.unique()`, `.default()`, `.nullable()`, …) when present. */
27
29
  column?: ColumnMetaIR;
30
+ /**
31
+ * `true` when this validator carries a `.check(...)` refinement. The predicate
32
+ * is a runtime closure the AST→IR step can't represent, so the node keeps its
33
+ * base `kind` but records the refinement's presence here. The AOT args-validator
34
+ * compiler declines any node with this flag (compiling it would silently skip
35
+ * the predicate). `.meta(...)` is pure metadata with no parse effect and does
36
+ * NOT set this.
37
+ */
38
+ hasRefinement?: boolean;
28
39
  /** For `v.optional(inner)` / `v.array(inner)`. */
29
40
  inner?: ValidatorIR;
30
41
  /** For `v.record(key, value)`. */
@@ -55,6 +66,21 @@ interface SearchIndexIR {
55
66
  filterFields?: ReadonlyArray<string>;
56
67
  name: string;
57
68
  }
69
+ /** A `.geoIndex(name, { field, precision? })` declaration — a geohash companion over a `v.geoPoint()` column. */
70
+ interface GeoIndexIR {
71
+ /** The `v.geoPoint()` column feeding the geohash. */
72
+ field: string;
73
+ name: string;
74
+ /** Geohash precision (characters) maintained on the companion; omitted ⇒ the runtime default. */
75
+ precision?: number;
76
+ }
77
+ /** A `.ttl(field, { after? })` declaration — declarative table-level auto-expiry. */
78
+ interface TtlIR {
79
+ /** Millisecond offset added to `field` to derive the expiry (`field + after`); omitted ⇒ `field` is the absolute expiry. */
80
+ after?: number;
81
+ /** The epoch-millisecond expiry column. */
82
+ field: string;
83
+ }
58
84
  interface VectorIndexIR {
59
85
  dimensions?: number;
60
86
  /** Shape A: the single source column. Shape B: undefined (derived via a `select` fn). */
@@ -67,19 +93,19 @@ interface VectorIndexIR {
67
93
  table: string;
68
94
  }
69
95
  /**
70
- * One ordering key on a rank index's `sortBy`: the column and direction.
71
- * Mirrors the runtime `RankSortKey` (defaults `direction` to `"asc"`).
72
- */
96
+ * One ordering key on a rank index's `sortBy`: the column and direction.
97
+ * Mirrors the runtime `RankSortKey` (defaults `direction` to `"asc"`).
98
+ */
73
99
  interface RankSortKeyIR {
74
100
  direction: "asc" | "desc";
75
101
  field: string;
76
102
  }
77
103
  /**
78
- * A `.rankIndex(name, { sortBy, partitionBy?, where? })` declaration. The owning
79
- * table is always the table the index is declared on, so — unlike a vector index
80
- * — there is no separate `on`/`table` reference to carry: it rides along on its
81
- * {@link TableIR}. Only the fields needed for type emission are captured.
82
- */
104
+ * A `.rankIndex(name, { sortBy, partitionBy?, where? })` declaration. The owning
105
+ * table is always the table the index is declared on, so — unlike a vector index
106
+ * — there is no separate `on`/`table` reference to carry: it rides along on its
107
+ * {@link TableIR}. Only the fields needed for type emission are captured.
108
+ */
83
109
  interface RankIndexIR {
84
110
  name: string;
85
111
  /** Columns scoping each ranking; omitted ⇒ one global rank over the table. */
@@ -100,21 +126,79 @@ interface RelationIR {
100
126
  /** Target table name. */
101
127
  table: string;
102
128
  }
129
+ /**
130
+ * Statically-discovered `.source(...)` config (plan 077). Only the bits the
131
+ * advisor lints + DO wiring need are captured; `map`/`tenantBy` are functions and
132
+ * cannot be serialized, so their presence is recorded as `hasTenantBy` rather than
133
+ * the function itself.
134
+ */
135
+ interface ExternalSourceIR {
136
+ /** The wrangler Hyperdrive binding name. */
137
+ binding: string;
138
+ /** Whether a `columns` projection allow-list was given. */
139
+ columns?: ReadonlyArray<string>;
140
+ /** `true` when a `reconcileEveryMs` was given — one of the two incremental delete-visibility paths the `external_source_incremental_no_delete_path` lint checks. */
141
+ hasReconcile?: boolean;
142
+ /** `true` when a `softDeleteColumn` was given — the other incremental delete-visibility path. */
143
+ hasSoftDelete?: boolean;
144
+ /** `true` when a `tenantBy` mapper was given — the tenant-isolation boundary the `external_source_unscoped` lint checks. */
145
+ hasTenantBy: boolean;
146
+ /** The `idColumn` literal, when given (defaults to `"id"` at runtime). */
147
+ idColumn?: string;
148
+ /** Delete-detection mode literal, when given (`"full-pull"` today). */
149
+ mode?: string;
150
+ /** The membership query literal, when statically knowable. */
151
+ query?: string;
152
+ /**
153
+ * `true` when `.source(...)` was present but its argument was **not** a static
154
+ * object literal (e.g. `.source(buildConfig())`), so none of the fields above
155
+ * could be read. The source still exists — this flag lets `hasSourcedTables`
156
+ * (codegen) and the `external_source_*` lints treat it as a source that can't be
157
+ * verified, instead of mistaking it for no `.source()` at all.
158
+ */
159
+ unanalyzable?: boolean;
160
+ }
103
161
  interface TableIR {
104
162
  /**
105
- * `true` when the table chain carried `.externallyManaged()` its rows are
106
- * written outside Lunora's discoverable insert path (adapter/migration/
107
- * middleware), so advisor insert-path lints skip it. Optional: hand-built
108
- * IR and the runtime `fromServerSchema` path default it to `false`.
109
- */
163
+ * The `defineSchemaExtension` key that contributed this table, set when it
164
+ * arrived through `defineSchema(...).extend(...)`. Absent for a table the app
165
+ * declared itself.
166
+ *
167
+ * Drives the generated `AppTableName` union: an add-on's tables
168
+ * (`ratelimit_buckets`, …) are real tables and stay in `TableName`, but an app
169
+ * enumerating "my tables" should not have to know about them.
170
+ */
171
+ extensionKey?: string;
172
+ /**
173
+ * `true` when the table chain carried `.externallyManaged()` — its rows are
174
+ * written outside Lunora's discoverable insert path (adapter/migration/
175
+ * middleware), so advisor insert-path lints skip it. Optional: hand-built
176
+ * IR and the runtime `fromServerSchema` path default it to `false`.
177
+ */
110
178
  externallyManaged?: boolean;
111
179
  /**
112
- * Storage backend for a `.global()` table: `"d1"` (default) or
113
- * `"hyperdrive"` (a Postgres/MySQL database via Cloudflare Hyperdrive). Only
114
- * meaningful when `shardMode === "global"`; absent for sharded/root tables.
115
- */
180
+ * Set when the chain carried `.source(...)` — the table is materialized from an
181
+ * external Hyperdrive-backed database by a system poll loop (plan 077). Carries
182
+ * the statically-knowable bits the advisor lints read; the functions (`map`,
183
+ * `tenantBy`) are not serialized, only their presence (`hasTenantBy`).
184
+ */
185
+ externalSource?: ExternalSourceIR;
186
+ /**
187
+ * Storage backend for a `.global()` table: `"d1"` (default) or
188
+ * `"hyperdrive"` (a Postgres/MySQL database via Cloudflare Hyperdrive). Only
189
+ * meaningful when `shardMode === "global"`; absent for sharded/root tables.
190
+ */
191
+ /** Geospatial indexes declared inline via `.geoIndex(name, …)`. Optional so hand-built IR may omit it (discovery always sets it). */
192
+ geoIndexes?: ReadonlyArray<GeoIndexIR>;
116
193
  globalBackend?: "d1" | "hyperdrive";
117
194
  indexes: ReadonlyArray<IndexIR>;
195
+ /**
196
+ * `true` when the table chain carried `.public()` — an explicit opt-OUT of
197
+ * the schema's `.rls("required")` enforcement for this one table. Optional:
198
+ * hand-built IR and tables that never called `.public()` default it to
199
+ * `false`.
200
+ */
201
+ isPublic?: boolean;
118
202
  name: string;
119
203
  /** Rank indexes declared inline via `.rankIndex(name, …)`. */
120
204
  rankIndexes: ReadonlyArray<RankIndexIR>;
@@ -126,10 +210,32 @@ interface TableIR {
126
210
  field: string;
127
211
  kind: "shardBy";
128
212
  };
213
+ /** Set when the chain carried `.softDelete()` — the marker column's name (default `deletedAt`). The column is injected into `shape` so `Doc_*` carries it. */
214
+ softDelete?: {
215
+ field: string;
216
+ };
217
+ /** Set when the chain carried `.ttl(field, { after? })` — the declarative auto-expiry policy read by the DO alarm sweep. */
218
+ ttl?: TtlIR;
129
219
  /** Vector indexes declared inline via `.vectorize()` (DSL Shape A). */
130
220
  vectorIndexes: ReadonlyArray<VectorIndexIR>;
131
221
  }
222
+ /** The Cloudflare DO data-residency jurisdictions the schema may declare. Canonical literal set for the codegen package. */
223
+ type JurisdictionIR = "eu" | "fedramp" | "us";
132
224
  interface SchemaIR {
225
+ /**
226
+ * Cloudflare data-residency jurisdiction declared via
227
+ * `defineSchema(...).jurisdiction("…")`. Emitted into the generated worker's
228
+ * `createWorker({ jurisdiction })` (and `ctx.scheduler` / `ctx.containers`).
229
+ * Absent ⇒ un-pinned.
230
+ */
231
+ jurisdiction?: JurisdictionIR;
232
+ /**
233
+ * Set when `defineSchema(...).rls("required")` was chained onto the schema —
234
+ * every table's `ctx.db` write path is denied without an RLS-covering
235
+ * procedure unless the table itself is `.public()` (see {@link TableIR.isPublic}).
236
+ * Absent when the schema never called `.rls("required")`.
237
+ */
238
+ rlsMode?: "required";
133
239
  tables: ReadonlyArray<TableIR>;
134
240
  /** All vector indexes (inline Shape A hoisted + standalone Shape B), flattened. */
135
241
  vectorIndexes: ReadonlyArray<VectorIndexIR>;
@@ -137,37 +243,47 @@ interface SchemaIR {
137
243
  interface FunctionIR {
138
244
  args: Record<string, ValidatorIR>;
139
245
  exportName: string;
246
+ /**
247
+ * Set by the `.expose({ rest: true })` builder modifier (plan 167). When
248
+ * `rest` is `true` the function is published on the public REST surface, so the
249
+ * OpenAPI emitter describes it as a real `/_lunora/rest/&lt;namespace>/&lt;fn>` path
250
+ * (the single source of truth the runtime router also derives from). Absent →
251
+ * RPC-only (the default; not on the REST surface).
252
+ */
253
+ expose?: {
254
+ rest?: boolean;
255
+ };
140
256
  /** Path relative to `&lt;projectRoot>/lunora/` without extension, e.g. "messages". */
141
257
  filePath: string;
142
258
  kind: "action" | "mutation" | "query" | "stream";
143
259
  /**
144
- * Set on connection-lifecycle hooks (`onConnect`/`onDisconnect`): the socket
145
- * side the hook fires on. Such a function is also an internal mutation (so it
146
- * lands in `LUNORA_FUNCTIONS` for path dispatch); emit additionally collects
147
- * it into the `LUNORA_LIFECYCLE_HOOKS` manifest keyed by this side. Absent on
148
- * ordinary functions.
149
- */
260
+ * Set on connection-lifecycle hooks (`onConnect`/`onDisconnect`): the socket
261
+ * side the hook fires on. Such a function is also an internal mutation (so it
262
+ * lands in `LUNORA_FUNCTIONS` for path dispatch); emit additionally collects
263
+ * it into the `LUNORA_LIFECYCLE_HOOKS` manifest keyed by this side. Absent on
264
+ * ordinary functions.
265
+ */
150
266
  lifecycle?: "connect" | "disconnect";
151
267
  /**
152
- * Serialized TS source for the handler's return type, with `Promise&lt;T>`
153
- * unwrapped so callers see `T` directly. Defaults to `"unknown"` when
154
- * ts-morph cannot resolve the type (typically because the consuming
155
- * project lacks a tsconfig that can reach `@lunora/server`).
156
- */
268
+ * Serialized TS source for the handler's return type, with `Promise&lt;T>`
269
+ * unwrapped so callers see `T` directly. Defaults to `"unknown"` when
270
+ * ts-morph cannot resolve the type (typically because the consuming
271
+ * project lacks a tsconfig that can reach `@lunora/server`).
272
+ */
157
273
  returnType: string;
158
274
  /**
159
- * Call surface the function is exposed on. Absent (or `"public"`) means it
160
- * lands in the generated `api`; `"internal"` routes it to the separate
161
- * `internal` object and is rejected by the DO's external RPC path.
162
- */
275
+ * Call surface the function is exposed on. Absent (or `"public"`) means it
276
+ * lands in the generated `api`; `"internal"` routes it to the separate
277
+ * `internal` object and is rejected by the DO's external RPC path.
278
+ */
163
279
  visibility?: "internal" | "public";
164
280
  }
165
281
  /**
166
- * A `defineMigration({...})` declaration discovered in the user's lunora
167
- * sources. The emitted `LUNORA_MIGRATIONS` registry keys on {@link MigrationIR.id}; the
168
- * import wiring needs {@link MigrationIR.exportName}/{@link MigrationIR.filePath}. {@link MigrationIR.table} is
169
- * informational (the runtime object carries the authoritative value).
170
- */
282
+ * A `defineMigration({...})` declaration discovered in the user's lunora
283
+ * sources. The emitted `LUNORA_MIGRATIONS` registry keys on {@link MigrationIR.id}; the
284
+ * import wiring needs {@link MigrationIR.exportName}/{@link MigrationIR.filePath}. {@link MigrationIR.table} is
285
+ * informational (the runtime object carries the authoritative value).
286
+ */
171
287
  interface MigrationIR {
172
288
  /** Export binding name, used to reference the module member in generated imports. */
173
289
  exportName: string;
@@ -179,12 +295,96 @@ interface MigrationIR {
179
295
  table: string;
180
296
  }
181
297
  /**
182
- * A single cron job lifted from a `cronJobs()` builder in `lunora/crons.ts`.
183
- * Mirrors `@lunora/scheduler`'s `CronJob`: {@link CronJobIR.cron} is the compiled
184
- * standard cron expression, {@link CronJobIR.functionPath} is the target
185
- * `__lunoraRef` (`namespace:fn`), and {@link CronJobIR.args} is the static
186
- * argument object passed at registration.
187
- */
298
+ * A `defineShape({...})` declaration discovered in `lunora/shapes.ts`
299
+ * (local-first sync engine, Phase 7). The emitted `LUNORA_SHAPES` registry keys
300
+ * on {@link ShapeIR.exportName}; the generated DO's `resolveShape` override
301
+ * dispatches a `shape_subscribe` to the matching registered shape. Discovery is
302
+ * marker-driven (the `__lunoraShape` brand) — no field metadata is lifted here
303
+ * because the runtime object (`columns`/`compileWhere`) carries the authority.
304
+ */
305
+ interface ShapeIR {
306
+ /**
307
+ * The shape's `args` validator map — its partition selector. Lifted so
308
+ * `_generated/collections.ts` can type the selector a caller passes instead of
309
+ * widening it to `Record&lt;string, unknown>`. `{}` for a parameterless shape.
310
+ */
311
+ args: Record<string, ValidatorIR>;
312
+ /** Export binding name — the shape's registry key and import member. */
313
+ exportName: string;
314
+ /** Path relative to `&lt;projectRoot>/lunora/` without extension — always `"shapes"`. */
315
+ filePath: string;
316
+ /**
317
+ * The `table` string literal from the `defineShape({ table })` call, lifted
318
+ * only for static advisor lints (the runtime object stays authoritative).
319
+ * `undefined` when `table` is not a plain string literal — lints skip those.
320
+ */
321
+ table?: string;
322
+ }
323
+ /**
324
+ * The single `defineIdentity({...})` claim contract discovered in
325
+ * `lunora/identity.ts`. Discovery is **marker-driven** (the `__lunoraIdentity`
326
+ * brand, exactly like {@link ShapeIR}) — no claim metadata is lifted here
327
+ * because the emitted `_generated/server.ts` recovers the claim *type* from the
328
+ * declaration itself (`InferIdentity` over the contract's `typeof`), and the
329
+ * runtime object (`validate`/`onInvalid`) carries the authority at the boundary.
330
+ * Exactly one per app; absent ⇒ generated output is byte-identical to today.
331
+ */
332
+ interface IdentityIR {
333
+ /** Export binding name — the namespace member `_generated/server.ts` reads via `typeof`. */
334
+ exportName: string;
335
+ }
336
+ /**
337
+ * The single `defineEnv({...})` contract discovered in `lunora/env.ts`. Like
338
+ * {@link IdentityIR}, only the export binding is lifted — the emitted
339
+ * `_generated/server.ts` recovers the validated shape from the declaration
340
+ * itself (`ReturnType` over the accessor's `typeof`), and the generated ShardDO
341
+ * applies the same accessor to the worker `env` at ctx-build time to populate
342
+ * `ctx.env`. Exactly one per app; absent ⇒ generated output is byte-identical.
343
+ */
344
+ interface EnvIR {
345
+ /** Export binding name — the namespace member `_generated/server.ts` reads via `typeof`. */
346
+ exportName: string;
347
+ }
348
+ /**
349
+ * A `defineMutator({...})` declaration discovered in `lunora/mutators.ts`
350
+ * (local-first sync engine, Phase 7). The emitted registry registers the
351
+ * authoritative `server` impl into the DO's `LUNORA_FUNCTIONS` table (so
352
+ * `handleRpc` transaction-wraps it) and records its path in
353
+ * `LUNORA_MUTATOR_PATHS` so the DO's `isCustomMutator` override routes the
354
+ * client-watermark push protocol. The client `client` impl is split into the
355
+ * browser bundle separately — only the path crosses to the server side.
356
+ */
357
+ interface MutatorIR {
358
+ /** Export binding name — the mutator's registry key and import member. */
359
+ exportName: string;
360
+ /** Path relative to `&lt;projectRoot>/lunora/` without extension — always `"mutators"`. */
361
+ filePath: string;
362
+ }
363
+ /**
364
+ * A whole-row `ctx.db.replace(id, document)` write discovered inside a custom
365
+ * mutator's inline `server` impl (`lunora/mutators.ts`) — the input the
366
+ * `mutator_full_row_replace` advisor lint consumes. A `replace` overwrites the
367
+ * entire row, so a concurrent edit to a different column on a synced table is
368
+ * clobbered; `ctx.db.patch(id, { field })` merges at the column level instead.
369
+ * Structurally identical to `AdvisorMutatorWrite` so it passes straight through
370
+ * to the advisor without conversion, exactly as `InsertWriteIR` does for
371
+ * `AdvisorInsertWrite`.
372
+ */
373
+ interface MutatorWriteIR {
374
+ /** The mutator export whose `server` impl performs the replace, e.g. `renameChannel`. */
375
+ exportName: string;
376
+ /** Openable source path the replace appears in — always `lunora/mutators.ts`. */
377
+ file: string;
378
+ /** 1-based line of the `replace(...)` call. */
379
+ line: number;
380
+ }
381
+ /**
382
+ * A single cron job lifted from a `cronJobs()` builder in `lunora/crons.ts`.
383
+ * Mirrors `@lunora/scheduler`'s `CronJob`: {@link CronJobIR.cron} is the compiled
384
+ * standard cron expression, {@link CronJobIR.functionPath} is the target
385
+ * `__lunoraRef` (`namespace:fn`), and {@link CronJobIR.args} is the static
386
+ * argument object passed at registration.
387
+ */
188
388
  interface CronJobIR {
189
389
  /** Static args object (source-text JSON), defaults to `{}`. */
190
390
  args: Record<string, unknown>;
@@ -195,25 +395,25 @@ interface CronJobIR {
195
395
  /** Unique, human-readable job name. */
196
396
  name: string;
197
397
  /**
198
- * Set when the job targets a durable workflow (a `lunora/workflows.ts`
199
- * export) instead of a function: the workflow's `WORKFLOW_*` binding name
200
- * plus its export name. On each fire the worker starts a new workflow
201
- * INSTANCE (the {@link CronJobIR.args} become its `params`) rather than
202
- * dispatching a one-shot function.
203
- */
398
+ * Set when the job targets a durable workflow (a `lunora/workflows.ts`
399
+ * export) instead of a function: the workflow's `WORKFLOW_*` binding name
400
+ * plus its export name. On each fire the worker starts a new workflow
401
+ * INSTANCE (the {@link CronJobIR.args} become its `params`) rather than
402
+ * dispatching a one-shot function.
403
+ */
204
404
  workflow?: {
205
405
  binding: string;
206
406
  exportName: string;
207
407
  };
208
408
  }
209
409
  /**
210
- * A container lifted from a `defineContainer()` export in
211
- * `lunora/containers.ts`. Carries everything the emitters and the config layer
212
- * need to wire wrangler (`containers[]` + the Durable Object binding +
213
- * migration class) and the generated `_generated/containers.ts` DO class.
214
- * Names are derived via `@lunora/container`'s shared helpers so codegen and
215
- * the config layer can never disagree.
216
- */
410
+ * A container lifted from a `defineContainer()` export in
411
+ * `lunora/containers.ts`. Carries everything the emitters and the config layer
412
+ * need to wire wrangler (`containers[]` + the Durable Object binding +
413
+ * migration class) and the generated `_generated/containers.ts` DO class.
414
+ * Names are derived via `@lunora/container`'s shared helpers so codegen and
415
+ * the config layer can never disagree.
416
+ */
217
417
  interface ContainerIR {
218
418
  /** Durable Object binding name, e.g. `CONTAINER_TRANSCODER`. */
219
419
  bindingName: string;
@@ -222,18 +422,18 @@ interface ContainerIR {
222
422
  /** Generated DO class name, e.g. `TranscoderContainer`. */
223
423
  className: string;
224
424
  /**
225
- * Whether the container may open outbound internet connections, when the
226
- * value was a static literal. `undefined` means the field was omitted (the
227
- * platform default is `true`) or wasn't a literal. Lifted for the advisor.
228
- */
425
+ * Whether the container may open outbound internet connections, when the
426
+ * value was a static literal. `undefined` means the field was omitted (the
427
+ * platform default is `true`) or wasn't a literal. Lifted for the advisor.
428
+ */
229
429
  enableInternet?: boolean;
230
430
  /** The `lunora/containers.ts` export name, e.g. `transcoder`. */
231
431
  exportName: string;
232
432
  /**
233
- * Normalized image source: a local Dockerfile (`dockerfile`), a pre-built
234
- * registry reference (`registry`), or a Railpack source directory (`build`)
235
- * that the deploy step builds and pushes before wrangler runs.
236
- */
433
+ * Normalized image source: a local Dockerfile (`dockerfile`), a pre-built
434
+ * registry reference (`registry`), or a Railpack source directory (`build`)
435
+ * that the deploy step builds and pushes before wrangler runs.
436
+ */
237
437
  image: {
238
438
  buildContext: string;
239
439
  dockerfilePath: string;
@@ -261,20 +461,20 @@ interface ContainerIR {
261
461
  stepPercentage?: number;
262
462
  };
263
463
  /**
264
- * The static `sleepAfter` value, when it was a literal. `undefined` means
265
- * omitted (platform default `"10m"`) or non-literal. Lifted for the advisor.
266
- */
464
+ * The static `sleepAfter` value, when it was a literal. `undefined` means
465
+ * omitted (platform default `"10m"`) or non-literal. Lifted for the advisor.
466
+ */
267
467
  sleepAfter?: number | string;
268
468
  }
269
469
  /**
270
- * A workflow lifted from a `defineWorkflow()` export in `lunora/workflows.ts`.
271
- * Carries what the emitters and the config layer need to wire the wrangler
272
- * `workflows[]` entry and the generated `_generated/workflows.ts`
273
- * `WorkflowEntrypoint` class. Unlike containers, workflows are NOT Durable
274
- * Objects — wrangler gets only a `workflows[]` entry, never a `durable_objects`
275
- * binding or a migration class. Names are derived via `@lunora/workflow`'s
276
- * shared helpers so codegen and the config layer can never disagree.
277
- */
470
+ * A workflow lifted from a `defineWorkflow()` export in `lunora/workflows.ts`.
471
+ * Carries what the emitters and the config layer need to wire the wrangler
472
+ * `workflows[]` entry and the generated `_generated/workflows.ts`
473
+ * `WorkflowEntrypoint` class. Unlike containers, workflows are NOT Durable
474
+ * Objects — wrangler gets only a `workflows[]` entry, never a `durable_objects`
475
+ * binding or a migration class. Names are derived via `@lunora/workflow`'s
476
+ * shared helpers so codegen and the config layer can never disagree.
477
+ */
278
478
  interface WorkflowIR {
279
479
  /** The Cloudflare `Workflow` binding name, e.g. `WORKFLOW_ORDER_PIPELINE`. */
280
480
  bindingName: string;
@@ -283,21 +483,152 @@ interface WorkflowIR {
283
483
  /** The `lunora/workflows.ts` export name, e.g. `orderPipeline`. */
284
484
  exportName: string;
285
485
  /**
286
- * The stable wrangler `workflows[].name`. Defaults to the kebab-cased export
287
- * name (`orderPipeline` → `order-pipeline`); a static `name:` literal in the
288
- * definition overrides it.
289
- */
486
+ * The stable wrangler `workflows[].name`. Defaults to the kebab-cased export
487
+ * name (`orderPipeline` → `order-pipeline`); a static `name:` literal in the
488
+ * definition overrides it.
489
+ */
490
+ name: string;
491
+ /**
492
+ * Durable step labels lifted from the handler body — the first string-literal
493
+ * argument of every `ctx.step.do` / `.sleep` / `.sleepUntil` / `.waitForEvent`
494
+ * call. Feeds the duplicate-step-name lint, which flags a name used twice
495
+ * (Cloudflare memoizes by name, so the second call silently returns the
496
+ * first's cached result). Calls with a non-literal name are omitted (not
497
+ * statically comparable).
498
+ */
499
+ steps: ReadonlyArray<WorkflowStepIR>;
500
+ }
501
+ /**
502
+ * An agent lifted from a `defineAgent()` export in `lunora/agents.ts`. A
503
+ * `defineAgent` compiles its durable tool-loop onto a Cloudflare Workflow, so —
504
+ * like {@link WorkflowIR} — an agent is NOT a Durable Object: wrangler gets only
505
+ * a `workflows[]` entry, never a `durable_objects` binding or a migration class.
506
+ * Carries what the emitters and the config layer need to wire the generated
507
+ * agent `WorkflowEntrypoint` class (e.g. `SupportAgentWorkflow`), the typed
508
+ * per-agent `ctx.agents` producer, and the reconciled wrangler `workflows[]`
509
+ * entry. Names are derived via `@lunora/agent`'s shared helpers so codegen and
510
+ * the config layer can never disagree.
511
+ */
512
+ interface AgentIR {
513
+ /** The Cloudflare `Workflow` binding name, e.g. `AGENT_SUPPORT`. */
514
+ bindingName: string;
515
+ /** Generated `WorkflowEntrypoint` class name, e.g. `SupportAgentWorkflow`. */
516
+ className: string;
517
+ /** The `lunora/agents.ts` export name, e.g. `support`. */
518
+ exportName: string;
519
+ /**
520
+ * The stable wrangler `workflows[].name`. Defaults to the kebab-cased export
521
+ * name (`support` → `agent-support`); a static `name:` literal in the
522
+ * definition overrides it.
523
+ */
524
+ name: string;
525
+ /**
526
+ * Whether the definition declares an `onEmail` mapper on
527
+ * `defineAgent({ onEmail: … })`. When `true` the emitter wires this agent
528
+ * onto the worker's top-level `email()` handler (via `@lunora/agent/inbound`)
529
+ * so inbound mail starts a durable run. Detected by AST PRESENCE — the
530
+ * closure is never evaluated — and written to IR only when present, so
531
+ * email-free agents (and agent-free projects) stay byte-identical.
532
+ */
533
+ onEmail?: boolean;
534
+ /**
535
+ * Whether the definition opted into public run-starts via
536
+ * `defineAgent({ publicRun: true })` — emitted into the `ctx.agents` wiring
537
+ * spec so the public `agents:agentRun` mutation can gate on it fail-closed.
538
+ * Absent (falsy) means server-side starts only; the field is written to IR
539
+ * only when the literal is `true`, so agent-free and non-opted-in output is
540
+ * byte-identical.
541
+ */
542
+ publicRun?: boolean;
543
+ /**
544
+ * Whether the definition opted into a real-time voice session via a `voice`
545
+ * block on `defineAgent({ voice: … })`. Unlike the durable loop (a Workflow),
546
+ * the voice path IS a Durable Object — so when this is `true` the emitter
547
+ * generates the `voiceClassName` `VoiceSessionDO` subclass and the
548
+ * `api.agents.{name}Voice` client reference, and the config layer reconciles
549
+ * a `durable_objects` binding (`voiceBindingName`) + `new_sqlite_classes`
550
+ * migration. Written to IR only when the literal is present, so voice-free
551
+ * agents (and agent-free projects) stay byte-identical.
552
+ */
553
+ voice?: boolean;
554
+ /** The voice DO's Cloudflare `DurableObjectNamespace` binding name, e.g. `VOICE_SUPPORT`. Present only when `voice`. */
555
+ voiceBindingName?: string;
556
+ /** Generated `VoiceSessionDO` subclass name, e.g. `SupportVoiceDO`. Present only when `voice`. */
557
+ voiceClassName?: string;
558
+ }
559
+ /** One durable step call lifted from a workflow handler body (the use side of {@link WorkflowIR.steps}). */
560
+ interface WorkflowStepIR {
561
+ /** 1-based line of the durable step call. */
562
+ line: number;
563
+ /** The native step method invoked: `do` / `sleep` / `sleepUntil` / `waitForEvent`. */
564
+ method: string;
565
+ /** The step's static label (the first string-literal argument). */
566
+ name: string;
567
+ }
568
+ /**
569
+ * A queue lifted from a `defineQueue()` export in `lunora/queues.ts`. Carries
570
+ * what the emitters and the config layer need to wire the typed `ctx.queues`
571
+ * producer, the generated worker `queue()` dispatch, and the wrangler
572
+ * `queues.producers[]` / `queues.consumers[]` entries. Like workflows, a queue
573
+ * is NOT a Durable Object — wrangler gets only `queues.*` entries. Names are
574
+ * derived via `@lunora/queue`'s shared helpers so codegen and the config layer
575
+ * can never disagree.
576
+ */
577
+ interface QueueIR {
578
+ /** The Cloudflare `Queue` producer binding name, e.g. `QUEUE_EMAIL`. */
579
+ bindingName: string;
580
+ /** The `lunora/queues.ts` export name, e.g. `emailQueue`. */
581
+ exportName: string;
582
+ /** How the queue is consumed: `"push"` (a worker `queue()` handler) or `"pull"` (external HTTP). */
583
+ mode: "pull" | "push";
584
+ /**
585
+ * The stable wrangler queue name (`queues.producers[].queue`). Defaults to
586
+ * the kebab-cased export name (`emailQueue` → `email-queue`); a static
587
+ * `name:` literal in the definition overrides it.
588
+ */
290
589
  name: string;
590
+ /** Push-consumer batch/retry tuning, mirrored onto the wrangler `queues.consumers[]` entry. */
591
+ tuning: {
592
+ deadLetterQueue?: string;
593
+ maxBatchSize?: number;
594
+ maxBatchTimeout?: number;
595
+ maxRetries?: number;
596
+ retryDelay?: number;
597
+ };
598
+ }
599
+ /**
600
+ * The feature-flag provider declared by the default export of `lunora/flags.ts`
601
+ * (`defineFlags({ provider, … })`). Discovery is **metadata-only** — codegen
602
+ * imports the real module at runtime for the provider value; this IR exists so
603
+ * the config layer can reconcile/validate the wrangler `flagship` binding when
604
+ * the app uses Flagship in binding mode. A `custom` provider (any other
605
+ * OpenFeature factory) carries no binding to reconcile.
606
+ */
607
+ interface FlagsIR {
608
+ /**
609
+ * The wrangler `flagship[].binding` name — set **only** for a flagship
610
+ * `provider` in binding mode (`flagshipProvider({ binding: "FLAGS" })`). The
611
+ * config layer hints/validates a matching `flagship` binding from this.
612
+ */
613
+ bindingName?: string;
614
+ /**
615
+ * Flagship operating mode — `"binding"` (wrangler binding, needs a
616
+ * `flagship` entry) or `"http"` (no binding); `undefined` for a `custom`
617
+ * provider or when the mode can't be read statically.
618
+ */
619
+ mode?: "binding" | "http";
620
+ /** `"flagship"` when the provider is `flagshipProvider(...)`, else `"custom"` (any other OpenFeature provider factory). */
621
+ provider: "custom" | "flagship";
291
622
  }
292
623
  /**
293
- * A `ctx.workflows.get("name")…` call discovered in a function body — the
294
- * use-site analog of {@link WorkflowIR} (which is the declaration side). Feeds
295
- * the `workflow_unused` lint (a declared workflow with zero call sites) and the
296
- * `workflow_unknown_target` lint (a `.get("x")` whose `x` isn't declared — a
297
- * typo catcher). {@link WorkflowCallIR.workflow} is `""` when the `get(...)`
298
- * argument is not a string literal (a dynamic name — which suppresses the
299
- * unused-workflow heuristic rather than producing a false positive).
300
- */
624
+ * A `ctx.workflows.get("name")…` call discovered in a function body — the
625
+ * use-site analog of {@link WorkflowIR} (which is the declaration side). Feeds
626
+ * the `workflow_unused` lint (a declared workflow with zero call sites) and the
627
+ * `workflow_unknown_target` lint (a `.get("x")` whose `x` isn't declared — a
628
+ * typo catcher). {@link WorkflowCallIR.workflow} is `""` when the `get(...)`
629
+ * argument is not a string literal (a dynamic name — which suppresses the
630
+ * unused-workflow heuristic rather than producing a false positive).
631
+ */
301
632
  interface WorkflowCallIR {
302
633
  /** Export binding name of the function performing the call, e.g. `create`. */
303
634
  exportName: string;
@@ -309,11 +640,11 @@ interface WorkflowCallIR {
309
640
  workflow: string;
310
641
  }
311
642
  /**
312
- * A `ctx.db.query("table")…` read discovered in a function body, reduced to what
313
- * the `filter_without_index` advisor lint needs: which table, whether the chain
314
- * narrows with an index, and whether it filters. `table` is `""` when the
315
- * `query(...)` argument is not a string literal (a dynamic table — not lintable).
316
- */
643
+ * A `ctx.db.query("table")…` read discovered in a function body, reduced to what
644
+ * the `filter_without_index` advisor lint needs: which table, whether the chain
645
+ * narrows with an index, and whether it filters. `table` is `""` when the
646
+ * `query(...)` argument is not a string literal (a dynamic table — not lintable).
647
+ */
317
648
  interface QueryReadIR {
318
649
  /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
319
650
  file: string;
@@ -327,12 +658,12 @@ interface QueryReadIR {
327
658
  table: string;
328
659
  }
329
660
  /**
330
- * A `ctx.authApi.&lt;method>(...)` call discovered in a function body, attributed
331
- * to the exported function (and its file = api namespace) that performs it.
332
- * Structurally identical to `AdvisorAuthApiCall` so it passes straight through
333
- * to the advisor lint without conversion, exactly as `InsertWriteIR` does for
334
- * `AdvisorInsertWrite`.
335
- */
661
+ * A `ctx.authApi.&lt;method>(...)` call discovered in a function body, attributed
662
+ * to the exported function (and its file = api namespace) that performs it.
663
+ * Structurally identical to `AdvisorAuthApiCall` so it passes straight through
664
+ * to the advisor lint without conversion, exactly as `InsertWriteIR` does for
665
+ * `AdvisorInsertWrite`.
666
+ */
336
667
  interface AuthApiCallIR {
337
668
  /** Export binding name of the function performing the call, e.g. "createOrg". */
338
669
  exportName: string;
@@ -346,12 +677,12 @@ interface AuthApiCallIR {
346
677
  method: string;
347
678
  }
348
679
  /**
349
- * A `ctx.db.insert("table", …)` write discovered in a function body, attributed
350
- * to the exported function (and its file = api namespace) that performs it — the
351
- * write-side analog of {@link QueryReadIR}. Lets tooling wire a table's write
352
- * action by behavior (which function inserts into it) rather than by naming.
353
- * {@link InsertWriteIR.table} is `""` when the argument is not a string literal.
354
- */
680
+ * A `ctx.db.insert("table", …)` write discovered in a function body, attributed
681
+ * to the exported function (and its file = api namespace) that performs it — the
682
+ * write-side analog of {@link QueryReadIR}. Lets tooling wire a table's write
683
+ * action by behavior (which function inserts into it) rather than by naming.
684
+ * {@link InsertWriteIR.table} is `""` when the argument is not a string literal.
685
+ */
355
686
  interface InsertWriteIR {
356
687
  /** Export binding name of the function performing the insert, e.g. "send". */
357
688
  exportName: string;
@@ -363,14 +694,14 @@ interface InsertWriteIR {
363
694
  table: string;
364
695
  }
365
696
  /**
366
- * A non-deterministic API call (`Date.now`, `Math.random`, `crypto.randomUUID`,
367
- * `crypto.getRandomValues`, `fetch`) discovered lexically inside a `query(...)`
368
- * or `mutation(...)` handler body — the `nondeterministic_query_mutation` lint
369
- * input. Structurally identical to `AdvisorNondeterministicCall` so values pass
370
- * straight through to the advisor without conversion, exactly as `AuthApiCallIR`
371
- * does for `AdvisorAuthApiCall`. `action(...)` handlers are never recorded —
372
- * actions are the determinism escape hatch.
373
- */
697
+ * A non-deterministic API call (`Date.now`, `Math.random`, `crypto.randomUUID`,
698
+ * `crypto.getRandomValues`, `fetch`) discovered lexically inside a `query(...)`
699
+ * or `mutation(...)` handler body — the `nondeterministic_query_mutation` lint
700
+ * input. Structurally identical to `AdvisorNondeterministicCall` so values pass
701
+ * straight through to the advisor without conversion, exactly as `AuthApiCallIR`
702
+ * does for `AdvisorAuthApiCall`. `action(...)` handlers are never recorded —
703
+ * actions are the determinism escape hatch.
704
+ */
374
705
  interface NondeterministicCallIR {
375
706
  /** The non-deterministic API invoked, e.g. `Date.now` / `Math.random` / `crypto.randomUUID` / `fetch`. */
376
707
  callee: string;
@@ -384,13 +715,13 @@ interface NondeterministicCallIR {
384
715
  line: number;
385
716
  }
386
717
  /**
387
- * One `ctx.r2sql` access lexically inside a `query`/`mutation` handler — the
388
- * `r2sql_outside_action` advisor lint input. Structurally identical to the
389
- * advisor's `AdvisorR2sqlCall` (same field set) so values pass straight through
390
- * `lintSchema` without conversion, exactly as `NondeterministicCallIR` does.
391
- * Only `query`/`mutation` handlers are recorded; `action(...)` is the intended
392
- * home for `ctx.r2sql` and is skipped.
393
- */
718
+ * One `ctx.r2sql` access lexically inside a `query`/`mutation` handler — the
719
+ * `r2sql_outside_action` advisor lint input. Structurally identical to the
720
+ * advisor's `AdvisorR2sqlCall` (same field set) so values pass straight through
721
+ * `lintSchema` without conversion, exactly as `NondeterministicCallIR` does.
722
+ * Only `query`/`mutation` handlers are recorded; `action(...)` is the intended
723
+ * home for `ctx.r2sql` and is skipped.
724
+ */
394
725
  interface R2sqlCallIR {
395
726
  /** The accessed `ctx.r2sql` surface, e.g. `ctx.r2sql.query` / `ctx.r2sql.from`. */
396
727
  callee: string;
@@ -404,21 +735,21 @@ interface R2sqlCallIR {
404
735
  line: number;
405
736
  }
406
737
  /**
407
- * Per-procedure RLS usage snapshot, produced by `discoverRlsProcedures` for the
408
- * `rls_uncovered_table` advisor lint. Structurally identical to
409
- * `AdvisorRlsProcedure` (they share the same field set) so values pass straight
410
- * through to the advisor without conversion, exactly as `AuthApiCallIR` does for
411
- * `AdvisorAuthApiCall`.
412
- */
738
+ * Per-procedure RLS usage snapshot, produced by `discoverRlsProcedures` for the
739
+ * `rls_uncovered_table` advisor lint. Structurally identical to
740
+ * `AdvisorRlsProcedure` (they share the same field set) so values pass straight
741
+ * through to the advisor without conversion, exactly as `AuthApiCallIR` does for
742
+ * `AdvisorAuthApiCall`.
743
+ */
413
744
  interface RlsProcedureIR {
414
745
  /** Export binding name of the procedure (e.g. `listDocuments`). */
415
746
  exportName: string;
416
747
  /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
417
748
  file: string;
418
749
  /**
419
- * Table names extracted from the `rls(policies)` array literal. Empty when the
420
- * policies argument is not a statically-readable array literal.
421
- */
750
+ * Table names extracted from the `rls(policies)` array literal. Empty when the
751
+ * policies argument is not a statically-readable array literal.
752
+ */
422
753
  rlsTables: string[];
423
754
  /** Tables read by the procedure via `ctx.db.query/findMany/findFirst/…`. */
424
755
  tablesRead: string[];
@@ -430,22 +761,22 @@ interface RlsProcedureIR {
430
761
  visibility: "internal" | "public";
431
762
  }
432
763
  /**
433
- * One procedure reduced to the facts the `mask_uncovered_pii_column` lint needs:
434
- * whether its builder chain includes `.use(mask(...))`, which `(table, column)`
435
- * pairs that mask declares, and which tables the procedure reads/writes. The
436
- * column-level analogue of {@link RlsProcedureIR}. Structurally identical to
437
- * `AdvisorMaskProcedure` so values pass straight through without conversion.
438
- */
764
+ * One procedure reduced to the facts the `mask_uncovered_pii_column` lint needs:
765
+ * whether its builder chain includes `.use(mask(...))`, which `(table, column)`
766
+ * pairs that mask declares, and which tables the procedure reads/writes. The
767
+ * column-level analogue of {@link RlsProcedureIR}. Structurally identical to
768
+ * `AdvisorMaskProcedure` so values pass straight through without conversion.
769
+ */
439
770
  interface MaskProcedureIR {
440
771
  /** Export binding name of the procedure (e.g. `listUsers`). */
441
772
  exportName: string;
442
773
  /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
443
774
  file: string;
444
775
  /**
445
- * `(table, column)` pairs this procedure's `mask(policies)` object literal
446
- * declares. Empty when the policies argument is not a statically-readable
447
- * object literal (conservative: `usesMask` is still `true`).
448
- */
776
+ * `(table, column)` pairs this procedure's `mask(policies)` object literal
777
+ * declares. Empty when the policies argument is not a statically-readable
778
+ * object literal (conservative: `usesMask` is still `true`).
779
+ */
449
780
  maskColumns: {
450
781
  column: string;
451
782
  table: string;
@@ -460,14 +791,14 @@ interface MaskProcedureIR {
460
791
  visibility: "internal" | "public";
461
792
  }
462
793
  /**
463
- * One masked column surfaced to the studio's data-browser mask preview: a
464
- * `(table, column)` pair plus the declared {@link MaskProcedureIR} strategy so
465
- * the preview can pick redact-vs-hash-vs-custom rendering. Aggregated across the
466
- * project's `.use(mask(...))` chains by `discoverMaskMetadata`; the descriptive
467
- * twin of {@link RlsPolicyIR}. `"custom"` covers any non-string strategy (a
468
- * `(value, ctx) => …` function) — its logic is an opaque closure, never read by
469
- * the UI; the preview renders a fixed sentinel for it.
470
- */
794
+ * One masked column surfaced to the studio's data-browser mask preview: a
795
+ * `(table, column)` pair plus the declared {@link MaskProcedureIR} strategy so
796
+ * the preview can pick redact-vs-hash-vs-custom rendering. Aggregated across the
797
+ * project's `.use(mask(...))` chains by `discoverMaskMetadata`; the descriptive
798
+ * twin of {@link RlsPolicyIR}. `"custom"` covers any non-string strategy (a
799
+ * `(value, ctx) => …` function) — its logic is an opaque closure, never read by
800
+ * the UI; the preview renders a fixed sentinel for it.
801
+ */
471
802
  interface MaskColumnMetadataIR {
472
803
  /** Column the mask policy redacts. */
473
804
  column: string;
@@ -477,24 +808,48 @@ interface MaskColumnMetadataIR {
477
808
  table: string;
478
809
  }
479
810
  /**
480
- * Schema-wide masking metadata the codegen emits into the generated ShardDO so
481
- * the studio's data-browser mask toggle can preview what a non-privileged caller
482
- * would see. Aggregated across every `.use(mask(...))` chain in the project —
483
- * purely descriptive (table + column + strategy), never the masking closure. The
484
- * column-level analogue of {@link RlsMetadataIR}.
485
- */
811
+ * Schema-wide masking metadata the codegen emits into the generated ShardDO so
812
+ * the studio's data-browser mask toggle can preview what a non-privileged caller
813
+ * would see. Aggregated across every `.use(mask(...))` chain in the project —
814
+ * purely descriptive (table + column + strategy), never the masking closure. The
815
+ * column-level analogue of {@link RlsMetadataIR}.
816
+ */
486
817
  interface MaskMetadataIR {
487
818
  /** Every statically-discovered masked column, deduped by `(table, column)` (first declaration wins). */
488
819
  columns: MaskColumnMetadataIR[];
489
820
  }
490
821
  /**
491
- * One statically-readable policy entry from an `rls([...])` array literal,
492
- * surfaced to the studio's read-only RLS inspector via the generated
493
- * `rlsPolicies()` hook. Captures the policy's `table` + `on` operation and the
494
- * procedure it guards never the `when` predicate, which is an opaque JS
495
- * closure (its logic stays in code, not the UI). Produced by
496
- * `discoverRlsProcedures` alongside the lint IR.
497
- */
822
+ * One masked column whose `mask(policies)` strategy is a statically-known
823
+ * literal (`"hash"` or `"redact"`) the `mask_weak_hash_strategy_on_pii` lint
824
+ * input. Unlike {@link MaskColumnMetadataIR} (app-wide, deduped by `(table,
825
+ * column)`, studio-preview evidence), this is per declaration site (file + line
826
+ * + enclosing export), undeduped, so the lint can point at the exact
827
+ * `mask(...)` call that applies a weak strategy. A `MaskFn` (custom, non-literal)
828
+ * strategy carries no lint-relevant signal and is never recorded here.
829
+ * Structurally identical to `AdvisorMaskStrategy`.
830
+ */
831
+ interface MaskStrategyIR {
832
+ /** Masked column name. */
833
+ column: string;
834
+ /** Export binding name of the procedure whose `.use(mask(...))` chain declared this column, or `"&lt;module>"` when declared at file scope. */
835
+ exportName: string;
836
+ /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
837
+ file: string;
838
+ /** 1-based line of the masked column's strategy property. */
839
+ line: number;
840
+ /** The statically-known strategy literal: `"hash"` or `"redact"`. */
841
+ strategy: string;
842
+ /** Logical table the masked column belongs to. */
843
+ table: string;
844
+ }
845
+ /**
846
+ * One statically-readable policy entry from an `rls([...])` array literal,
847
+ * surfaced to the studio's read-only RLS inspector via the generated
848
+ * `rlsPolicies()` hook. Captures the policy's `table` + `on` operation and the
849
+ * procedure it guards — never the `when` predicate, which is an opaque JS
850
+ * closure (its logic stays in code, not the UI). Produced by
851
+ * `discoverRlsProcedures` alongside the lint IR.
852
+ */
498
853
  interface RlsPolicyIR {
499
854
  /** Source file (relative to `lunora/`, without extension) the policy is declared in. */
500
855
  file: string;
@@ -506,12 +861,12 @@ interface RlsPolicyIR {
506
861
  table: string;
507
862
  }
508
863
  /**
509
- * One statically-readable role entry from an `rls(policies, { roles: [...] })`
510
- * call, surfaced to the studio's RLS inspector. Captures the role's `name`,
511
- * optional `description`, and the names of the permissions it grants (string
512
- * literals or `definePermission("name")` calls). Produced by
513
- * `discoverRlsProcedures`.
514
- */
864
+ * One statically-readable role entry from an `rls(policies, { roles: [...] })`
865
+ * call, surfaced to the studio's RLS inspector. Captures the role's `name`,
866
+ * optional `description`, and the names of the permissions it grants (string
867
+ * literals or `definePermission("name")` calls). Produced by
868
+ * `discoverRlsProcedures`.
869
+ */
515
870
  interface RlsRoleIR {
516
871
  /** Optional human-readable description from `defineRole(name, { description })`. */
517
872
  description?: string;
@@ -521,11 +876,11 @@ interface RlsRoleIR {
521
876
  permissions: string[];
522
877
  }
523
878
  /**
524
- * Schema-wide RLS metadata the codegen emits into the generated ShardDO so the
525
- * studio's read-only inspector can list, per table, which policies guard it and
526
- * what roles are defined. Aggregated across every `.use(rls(...))` chain in the
527
- * project — purely descriptive, never the predicate logic.
528
- */
879
+ * Schema-wide RLS metadata the codegen emits into the generated ShardDO so the
880
+ * studio's read-only inspector can list, per table, which policies guard it and
881
+ * what roles are defined. Aggregated across every `.use(rls(...))` chain in the
882
+ * project — purely descriptive, never the predicate logic.
883
+ */
529
884
  interface RlsMetadataIR {
530
885
  /** Every statically-discovered policy `(table, on, procedure)` entry. */
531
886
  policies: RlsPolicyIR[];
@@ -544,24 +899,33 @@ interface StorageRuleIR {
544
899
  procedure: string;
545
900
  }
546
901
  /**
547
- * Schema-wide storage-access-rule metadata emitted into the generated ShardDO so
548
- * the studio's read-only inspector can list, per bucket, which operations are
549
- * gated and under what key prefix. Aggregated across every
550
- * `.use(storageRules(...))` chain — descriptive only, never the predicate logic.
551
- */
902
+ * Schema-wide storage-access-rule metadata emitted into the generated ShardDO so
903
+ * the studio's read-only inspector can list, per bucket, which operations are
904
+ * gated and under what key prefix. Aggregated across every
905
+ * `.use(storageRules(...))` chain — descriptive only, never the predicate logic.
906
+ */
552
907
  interface StorageRulesMetadataIR {
553
908
  rules: StorageRuleIR[];
554
909
  }
555
910
  /**
556
- * A typed REST route declared with the `httpRoute.&lt;verb>("/path")…` builder in
557
- * `@lunora/server` and mounted on `httpRouter()`. Captured statically from the
558
- * builder chain so the OpenAPI emitter can render a real `paths` entry: the verb
559
- * + path become the operation's method + URL, and the accumulated validator maps
560
- * become its query parameters, path parameters, and request body.
561
- */
911
+ * A typed REST route declared with the `httpRoute.&lt;verb>("/path")…` builder in
912
+ * `@lunora/server` and mounted on `httpRouter()`. Captured statically from the
913
+ * builder chain so the OpenAPI emitter can render a real `paths` entry: the verb
914
+ * + path become the operation's method + URL, and the accumulated validator maps
915
+ * become its query parameters, path parameters, and request body.
916
+ */
562
917
  interface HttpRouteIR {
563
918
  /** `v.*` validators decoding the JSON request body (`.body({...})`), keyed by field. */
564
919
  body: Record<string, ValidatorIR>;
920
+ /**
921
+ * Rendered TS type of one SSE chunk — the `R` the `.stream(handler)`
922
+ * handler yields — inferred from the handler via the type checker. Present
923
+ * only when {@link HttpRouteIR.stream} is `true`; `"unknown"` when the
924
+ * checker can't resolve enough context. Feeds the emitted
925
+ * `HttpStreamRef&lt;Chunk, …>` so the chunk type flows to the client.
926
+ * @experimental Part of the HTTP-SSE stream surface (the `httpStreams.*` emission).
927
+ */
928
+ chunkType?: string;
565
929
  /** Export binding name of the route handler (used only for diagnostics / dedupe). */
566
930
  exportName: string;
567
931
  /** Path relative to `&lt;projectRoot>/lunora/` without extension, e.g. "http". */
@@ -580,28 +944,36 @@ interface HttpRouteIR {
580
944
  stream: boolean;
581
945
  }
582
946
  /**
583
- * Per-procedure protective-middleware snapshot, produced by
584
- * `discoverProcedureMiddleware` for the security lints
585
- * (`public_mutation_without_ratelimit`, `user_creating_mutation_without_captcha`).
586
- * Records which `.use(...)` guards a procedure's builder chain carries plus the
587
- * behavioural facts that decide whether a guard is *expected* (does it write a
588
- * user/session table, does it send mail). `protectPublic({ rateLimit, captcha })`
589
- * is unwrapped: the bundle's object-literal keys set `usesRateLimit`/`usesCaptcha`
590
- * exactly as the individual `.use(rateLimit(...))` / `.use(verifyTurnstile(...))`
591
- * steps would. Structurally identical to `AdvisorProcedureProtection` so values
592
- * pass straight through to the advisor without conversion.
593
- */
947
+ * Per-procedure protective-middleware snapshot, produced by
948
+ * `discoverProcedureMiddleware` for the security lints
949
+ * (`public_mutation_without_ratelimit`, `user_creating_mutation_without_captcha`).
950
+ * Records which `.use(...)` guards a procedure's builder chain carries plus the
951
+ * behavioural facts that decide whether a guard is *expected* (does it write a
952
+ * user/session table, does it send mail). `protectPublic({ rateLimit, captcha })`
953
+ * is unwrapped: the bundle's object-literal keys set `usesRateLimit`/`usesCaptcha`
954
+ * exactly as the individual `.use(rateLimit(...))` / `.use(verifyTurnstile(...))`
955
+ * steps would. Structurally identical to `AdvisorProcedureProtection` so values
956
+ * pass straight through to the advisor without conversion.
957
+ */
594
958
  interface ProcedureMiddlewareIR {
595
959
  /** `true` when the handler (or a helper inside it) references `ctx.mail` / `ctx.email`. */
596
960
  callsMail: boolean;
597
961
  /** Export binding name of the procedure (e.g. `signUp`). */
598
962
  exportName: string;
963
+ /** `true` when the handler fans work out to a privileged, cost-bearing dispatch surface (scheduler `runAfter`/`runAt`, a queue producer send, or a workflow create). Feeds the privileged-fanout lint. */
964
+ fanOut: boolean;
599
965
  /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
600
966
  file: string;
601
967
  /** Registration kind — only `mutation`/`action` are write-shaped; `query` is read-only. */
602
968
  kind: "action" | "mutation" | "query";
969
+ /** `true` when the handler runs an AI generation (`generateText`/`streamText`/`generateObject`/`streamObject`) with no `maxOutputTokens` bound in its config literal. Feeds the `ai_unbounded_generation_public` lint. */
970
+ unboundedAiGeneration: boolean;
603
971
  /** `true` when the chain carries `.use(verifyTurnstile(...))` or a `protectPublic({ captcha })` bundle. */
604
972
  usesCaptcha: boolean;
973
+ /** `true` when the chain carries `.use(emailGateMiddleware(...))` (`@lunora/auth`). Feeds the `signup_mutation_without_disposable_gating` lint. */
974
+ usesEmailGate: boolean;
975
+ /** `true` when the handler calls `ctx.db.insertManyUnsafe(...)`, bypassing validators and triggers. Feeds the `insert_many_unsafe_user_data` lint. */
976
+ usesInsertManyUnsafe: boolean;
605
977
  /** `true` when the chain carries `.use(mask(...))`. */
606
978
  usesMask: boolean;
607
979
  /** `true` when the chain carries `.use(rateLimit(...))` or a `protectPublic({ rateLimit })` bundle. */
@@ -614,13 +986,13 @@ interface ProcedureMiddlewareIR {
614
986
  writesUserTable: boolean;
615
987
  }
616
988
  /**
617
- * Per-procedure argument-validator snapshot, produced by the
618
- * argument-validator discoverer for the input-hardening lints
619
- * (`public_arg_uses_any`, `unbounded_string_arg`). Only public procedures are
620
- * recorded — internal functions take server-trusted input. Structurally identical
621
- * to `AdvisorArgumentValidator` so it passes straight through to the advisor
622
- * without conversion.
623
- */
989
+ * Per-procedure argument-validator snapshot, produced by the
990
+ * argument-validator discoverer for the input-hardening lints
991
+ * (`public_arg_uses_any`, `unbounded_string_arg`). Only public procedures are
992
+ * recorded — internal functions take server-trusted input. Structurally identical
993
+ * to `AdvisorArgumentValidator` so it passes straight through to the advisor
994
+ * without conversion.
995
+ */
624
996
  interface ArgumentValidatorIR {
625
997
  /** Arg names declared as `v.any()` (unvalidated, untyped input). */
626
998
  anyArgs: string[];
@@ -634,11 +1006,32 @@ interface ArgumentValidatorIR {
634
1006
  unboundedStringArgs: string[];
635
1007
  }
636
1008
  /**
637
- * One secret-shaped string literal discovered in `lunora/` source the
638
- * `hardcoded_secret` lint input. Complements the pre-commit `vis secrets` scan by
639
- * surfacing the same class of finding in-IDE via the studio Advisors table.
640
- * Structurally identical to `AdvisorSecretLiteral`.
641
- */
1009
+ * One factory/constructor call in `lunora/` whose config object literal a
1010
+ * security lint inspects for a present-or-absent key the shared input for the
1011
+ * config-call security lints (payment authorize, inbound-mail verify, rate-limit
1012
+ * store, browser private-targets). Structurally identical to `AdvisorConfigCall`
1013
+ * so it passes straight through to the advisor without conversion.
1014
+ */
1015
+ interface ConfigCallIR {
1016
+ /** `true` when the config argument was a static object literal the feeder could read. */
1017
+ analyzable: boolean;
1018
+ /** The factory function or constructor name at the call site, e.g. `createPayment` / `RateLimiter`. */
1019
+ callee: string;
1020
+ /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
1021
+ file: string;
1022
+ /** 1-based line of the call site, or `0` when unknown. */
1023
+ line: number;
1024
+ /** Keys present in the config object literal (empty when not `analyzable`). */
1025
+ presentKeys: string[];
1026
+ /** Keys in the config object literal explicitly assigned the literal `true`. */
1027
+ trueKeys: string[];
1028
+ }
1029
+ /**
1030
+ * One secret-shaped string literal discovered in `lunora/` source — the
1031
+ * `hardcoded_secret` lint input. Complements the pre-commit `vis secrets` scan by
1032
+ * surfacing the same class of finding in-IDE via the studio Advisors table.
1033
+ * Structurally identical to `AdvisorSecretLiteral`.
1034
+ */
642
1035
  interface SecretLiteralIR {
643
1036
  /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
644
1037
  file: string;
@@ -650,14 +1043,14 @@ interface SecretLiteralIR {
650
1043
  preview: string;
651
1044
  }
652
1045
  /**
653
- * One `ctx.sql.query(text, …)` / `ctx.sql.unsafe(text, …)` call whose `text`
654
- * argument is built in place rather than passed as a fixed statement — the
655
- * `sql_injection_risk` lint input. The Hyperdrive driver binds ONLY the `params`
656
- * array; the `text` string is spliced verbatim into the SQL, so a `text` assembled
657
- * from a string concatenation or a substitution template literal is an injection
658
- * vector. A fixed string literal / no-substitution template is safe. Structurally
659
- * identical to `AdvisorSqlInterpolation`.
660
- */
1046
+ * One `ctx.sql.query(text, …)` / `ctx.sql.unsafe(text, …)` call whose `text`
1047
+ * argument is built in place rather than passed as a fixed statement — the
1048
+ * `sql_injection_risk` lint input. The Hyperdrive driver binds ONLY the `params`
1049
+ * array; the `text` string is spliced verbatim into the SQL, so a `text` assembled
1050
+ * from a string concatenation or a substitution template literal is an injection
1051
+ * vector. A fixed string literal / no-substitution template is safe. Structurally
1052
+ * identical to `AdvisorSqlInterpolation`.
1053
+ */
661
1054
  interface SqlInterpolationIR {
662
1055
  /** Export binding name of the procedure performing the `ctx.sql` call. */
663
1056
  exportName: string;
@@ -667,11 +1060,333 @@ interface SqlInterpolationIR {
667
1060
  line: number;
668
1061
  }
669
1062
  /**
670
- * One discovered `httpRoute.&lt;verb>("/admin/…")` route on an admin/privileged-looking
671
- * path, with whether its builder chain references an auth/admin guard — the
672
- * `admin_route_without_guard` lint input. Structurally identical to
673
- * `AdvisorAdminRoute`.
674
- */
1063
+ * One `ctx.fetch(url, …)` call inside an action whose URL argument is derived
1064
+ * from the handler's `args` the `action_fetch_ssrf` lint input. `ctx.fetch` is
1065
+ * the action-only outbound-request escape hatch with no host allowlist, so a URL
1066
+ * assembled from request input is a server-side request forgery vector (cloud
1067
+ * metadata endpoints, internal services). Only arg-derived URLs reach here; a
1068
+ * fixed literal or a URL built from config/`ctx.*` is not recorded. Structurally
1069
+ * identical to `AdvisorArgumentDerivedFetch`.
1070
+ */
1071
+ interface ArgumentDerivedFetchIR {
1072
+ /** Export binding name of the action performing the `ctx.fetch` call. */
1073
+ exportName: string;
1074
+ /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
1075
+ file: string;
1076
+ /** 1-based line of the `ctx.fetch` call, or `0` when unknown. */
1077
+ line: number;
1078
+ }
1079
+ /**
1080
+ * One `ctx.kv.&lt;method>(key, …)` call whose namespace key is derived from the
1081
+ * handler's `args` with no server-side scoping — the `kv_unscoped_user_key_idor`
1082
+ * lint input. Workers KV is a single flat namespace, so a key taken straight from
1083
+ * request input lets any caller read, overwrite, or delete another user's entry
1084
+ * (IDOR). Only arg-derived, unscoped keys reach here; a fixed literal, or a key
1085
+ * prefixed with a server-trusted identity (`${ctx.auth.userId}:…` — references
1086
+ * `ctx`, so treated as scoped), is not recorded. `list` is excluded (it takes a
1087
+ * prefix, not a per-entry key). Structurally identical to `AdvisorKvKeyAccess`.
1088
+ */
1089
+ interface KvKeyAccessIR {
1090
+ /** Export binding name of the procedure performing the `ctx.kv` access. */
1091
+ exportName: string;
1092
+ /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
1093
+ file: string;
1094
+ /** 1-based line of the `ctx.kv` call, or `0` when unknown. */
1095
+ line: number;
1096
+ /** The `ctx.kv` method invoked: `get` / `getRaw` / `getWithMetadata` / `put` / `delete`. */
1097
+ method: string;
1098
+ }
1099
+ /**
1100
+ * One `ctx.db` write (`insert` / `replace` / `patch` / `insertManyUnsafe`) that sets
1101
+ * an ownership / identity column — `userId`, `ownerId`, `tenantId`, and the like —
1102
+ * from the handler's `args` instead of the server-trusted identity. The
1103
+ * `owner_field_from_args_not_auth` lint input: the ownership column decides who a
1104
+ * row belongs to, so a value taken from request input lets any caller write rows
1105
+ * owned by another user or tenant (the act-as-any-user / cross-tenant IDOR vector).
1106
+ * A column stamped from `ctx.*`, or set to a fixed literal, is not recorded; only an
1107
+ * arg-derived identity write reaches here. Structurally identical to
1108
+ * `AdvisorOwnerFieldWrite`.
1109
+ */
1110
+ /**
1111
+ * One branching `defineShape({ where })` / `definePolicy({ when })` predicate arm
1112
+ * that returns an unrestricted predicate — the `unrestricted_where_branch` lint
1113
+ * input. A denial arm must match NO rows (`deny()` / `{ OR: [] }`); `{}` matches
1114
+ * every row, so the near-miss silently replicates the whole table.
1115
+ */
1116
+ interface UnrestrictedWhereBranchIR {
1117
+ /** Export binding name of the shape / policy the predicate belongs to. */
1118
+ exportName: string;
1119
+ /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
1120
+ file: string;
1121
+ /** Which unrestricted form was returned. */
1122
+ form: "empty-object" | "undefined";
1123
+ /** The config key carrying the predicate (`where` for a shape, `when` for a policy). */
1124
+ key: string;
1125
+ /** 1-based line of the offending returned expression. */
1126
+ line: number;
1127
+ /** The declaring call (`defineShape` / `definePolicy`). */
1128
+ owner: string;
1129
+ }
1130
+ interface OwnerFieldWriteIR {
1131
+ /** Export binding name of the procedure performing the write. */
1132
+ exportName: string;
1133
+ /** The identity column being written from `args` (e.g. `userId`). */
1134
+ field: string;
1135
+ /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
1136
+ file: string;
1137
+ /** 1-based line of the `ctx.db` write call, or `0` when unknown. */
1138
+ line: number;
1139
+ /** The `ctx.db` write method (`insert` / `replace` / `patch` / `insertManyUnsafe`). */
1140
+ method: string;
1141
+ }
1142
+ /**
1143
+ * One `ctx.storage.&lt;bucket>.&lt;method>(key, …)` call whose R2 object key is derived
1144
+ * from the handler's `args` with no server-side scoping — the
1145
+ * `storage_key_from_user_args` lint input. The bucket read/write/URL/delete methods
1146
+ * key by their first argument, so an object key taken straight from request input is
1147
+ * object-level IDOR (read/overwrite/delete anyone's object). A key referencing a
1148
+ * server-trusted `ctx.*` value (e.g. `${ctx.auth.userId}/…`) is treated as scoped
1149
+ * and is not recorded; only an arg-derived, `ctx`-free key reaches here.
1150
+ * Structurally identical to `AdvisorStorageKeyAccess`.
1151
+ */
1152
+ interface StorageKeyAccessIR {
1153
+ /** Export binding name of the procedure performing the storage call. */
1154
+ exportName: string;
1155
+ /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
1156
+ file: string;
1157
+ /** 1-based line of the storage call, or `0` when unknown. */
1158
+ line: number;
1159
+ /** The bucket method invoked with the arg-derived key, e.g. `get` / `put` / `delete` / `download`. */
1160
+ method: string;
1161
+ }
1162
+ /**
1163
+ * One `ctx.containers.&lt;exportName>.get(name, …)` call whose instance key is derived
1164
+ * from the handler's `args` with no server-side scoping — the
1165
+ * `container_instance_key_from_user_input` lint input. Each container definition's
1166
+ * `.get(name)` accessor routes to one instance per `name`, so a key taken straight from
1167
+ * request input lets any caller reach another tenant's container (a cross-tenant IDOR). A
1168
+ * fixed literal key, or one derived from a server-trusted identity (`${ctx.auth.userId}` —
1169
+ * references `ctx`, so treated as scoped), is not recorded; only an arg-derived, unscoped
1170
+ * key reaches here. `.any()`/`.pool()` take no key and are not sinks. Structurally
1171
+ * identical to `AdvisorContainerKeyAccess`.
1172
+ */
1173
+ interface ContainerKeyAccessIR {
1174
+ /** Export binding name of the procedure performing the `ctx.containers` access. */
1175
+ exportName: string;
1176
+ /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
1177
+ file: string;
1178
+ /** 1-based line of the `ctx.containers.*.get` call, or `0` when unknown. */
1179
+ line: number;
1180
+ /** The container accessor method invoked — always `get`. */
1181
+ method: string;
1182
+ }
1183
+ /**
1184
+ * One `ctx.ai.run(model, …)` call whose model-id argument is derived from the handler's
1185
+ * `args` with no server-side scoping — the `ai_raw_run_escape_hatch` lint input.
1186
+ * `ctx.ai.run` is the raw Workers AI binding passthrough, bypassing the typed
1187
+ * `ctx.ai.model(...)` + AI-SDK layer (`generateText`/`streamText`/…) that caps output and
1188
+ * enforces a schema, so an arg-derived model id lets any caller select an arbitrary model.
1189
+ * A fixed literal model, or one scoped by a server-trusted `ctx.*` value, is not recorded;
1190
+ * only an arg-derived, unscoped model id reaches here (an arg-derived `inputs` argument is
1191
+ * normal usage and is never inspected). Structurally identical to `AdvisorAiRawRun`.
1192
+ */
1193
+ interface AiRawRunIR {
1194
+ /** Export binding name of the procedure performing the `ctx.ai.run` call. */
1195
+ exportName: string;
1196
+ /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
1197
+ file: string;
1198
+ /** 1-based line of the `ctx.ai.run` call, or `0` when unknown. */
1199
+ line: number;
1200
+ }
1201
+ /**
1202
+ * One `ctx.vectors.&lt;method>(indexName, input)` call whose `input.namespace` is derived
1203
+ * from the handler's `args` with no server-side scoping — the
1204
+ * `vectors_namespace_from_user_input` lint input. A Vectorize namespace partitions one
1205
+ * index into isolated sub-collections, so a namespace taken straight from request input
1206
+ * lets any caller read or poison another tenant's vectors. A fixed literal namespace, or
1207
+ * one prefixed with a server-trusted identity (`${ctx.auth.orgId}` — references `ctx`, so
1208
+ * treated as scoped), is not recorded; only an arg-derived, unscoped namespace reaches
1209
+ * here. Structurally identical to `AdvisorVectorNamespaceAccess`.
1210
+ */
1211
+ interface VectorNamespaceAccessIR {
1212
+ /** Export binding name of the procedure performing the `ctx.vectors` access. */
1213
+ exportName: string;
1214
+ /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
1215
+ file: string;
1216
+ /** 1-based line of the `ctx.vectors` call, or `0` when unknown. */
1217
+ line: number;
1218
+ /** The `ctx.vectors` method invoked: `query` / `upsert` / `upsertMany`. */
1219
+ method: string;
1220
+ }
1221
+ /**
1222
+ * One `ctx.mail`/`ctx.email` `send`/`queue` call whose recipient field (`to`/`cc`/`bcc`)
1223
+ * is derived from the handler's `args` with no server-side scoping — the
1224
+ * `mail_recipient_from_request_input` lint input. A recipient taken straight from request
1225
+ * input turns the deployment into an open relay / spam amplifier (any caller can direct
1226
+ * mail to an arbitrary address). A fixed literal recipient, or one scoped by a
1227
+ * server-trusted `ctx.*` value (e.g. `ctx.auth.user.email`), is not recorded; only an
1228
+ * arg-derived, unscoped recipient reaches here. Structurally identical to
1229
+ * `AdvisorMailRecipientAccess`.
1230
+ */
1231
+ interface MailRecipientAccessIR {
1232
+ /** Export binding name of the procedure performing the `ctx.mail`/`ctx.email` call. */
1233
+ exportName: string;
1234
+ /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
1235
+ file: string;
1236
+ /** 1-based line of the `ctx.mail`/`ctx.email` call, or `0` when unknown. */
1237
+ line: number;
1238
+ /** The mailer method invoked: `send` / `queue`. */
1239
+ method: string;
1240
+ }
1241
+ /**
1242
+ * One `ctx.browser.&lt;method>(url, …)` call whose navigation URL (`arguments[0]`)
1243
+ * is derived from the handler's `args` with no server-side scoping — the
1244
+ * `browser_user_url_without_allowlist` lint input. The lint additionally
1245
+ * cross-references `createBrowser` config-call evidence to suppress findings
1246
+ * when the browser is hardened with an `allowedHosts` allowlist or
1247
+ * `resolveDns`. Structurally identical to `AdvisorBrowserUrlAccess`.
1248
+ */
1249
+ interface BrowserUrlAccessIR {
1250
+ /** Export binding name of the procedure performing the `ctx.browser` call. */
1251
+ exportName: string;
1252
+ /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
1253
+ file: string;
1254
+ /** 1-based line of the `ctx.browser` call, or `0` when unknown. */
1255
+ line: number;
1256
+ /** The browser method invoked: `content` / `pdf` / `scrape` / `screenshot`. */
1257
+ method: string;
1258
+ }
1259
+ /**
1260
+ * One runtime container-override call: a `&lt;handle>.start({ enableInternet: true, … })`
1261
+ * launch override, or a `&lt;handle>.egress.&lt;method>(...)` runtime firewall mutation
1262
+ * (`allow` / `deny` / `setAllowed`) — the `container_start_enable_internet_override`
1263
+ * and `container_runtime_egress_relaxation` lint input. Both shapes re-open network
1264
+ * access the static `defineContainer` declaration (and its `container_public_internet`
1265
+ * lint) assumes is locked down. Matched structurally by call shape, independent of the
1266
+ * receiver's resolved type. Structurally identical to `AdvisorContainerOverride`.
1267
+ */
1268
+ interface ContainerOverrideIR {
1269
+ /** e.g. the egress method name, or `"enableInternet: true"`. */
1270
+ detail: string;
1271
+ /** Export binding name of the procedure performing the call. */
1272
+ exportName: string;
1273
+ /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
1274
+ file: string;
1275
+ /** Which override shape matched. */
1276
+ kind: "egress_relaxation" | "enable_internet";
1277
+ /** 1-based line of the call, or `0` when unknown. */
1278
+ line: number;
1279
+ }
1280
+ /**
1281
+ * One `buildImageDeliveryUrl({ key, … })` call (`@lunora/bindings/images`) whose
1282
+ * `key` — the CDN transform's source image, an absolute URL or an
1283
+ * origin-relative key — is derived from the handler's `args` with no
1284
+ * server-side scoping — the `images_url_source_from_user_input` lint input.
1285
+ * `ctx.images.transform`/`info` take image *bytes*, never a URL, so they are not
1286
+ * sinks; only the `key` of `buildImageDeliveryUrl` accepts a URL-or-key source
1287
+ * and is inspected. An arg-derived `key` lets any caller point the CDN's
1288
+ * `/cdn-cgi/image/` transform at an attacker-chosen origin (SSRF / open proxy)
1289
+ * or at an arbitrary key under the account's own store. A fixed literal, or a
1290
+ * key scoped by a server-trusted `ctx.*` value, is not recorded. Structurally
1291
+ * identical to `AdvisorImageDeliveryUrlAccess`.
1292
+ */
1293
+ interface ImageDeliveryUrlAccessIR {
1294
+ /** Export binding name of the procedure performing the `buildImageDeliveryUrl` call. */
1295
+ exportName: string;
1296
+ /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
1297
+ file: string;
1298
+ /** 1-based line of the `buildImageDeliveryUrl` call, or `0` when unknown. */
1299
+ line: number;
1300
+ }
1301
+ /**
1302
+ * One `createAuth({...})` call's configuration snapshot — the shared input for
1303
+ * the five `auth_*` security lints (trusted-origins wildcard, CSRF check
1304
+ * disabled, secure cookies disabled, email verification disabled, session
1305
+ * freshAge zero). Matched by callee NAME (an `import`-agnostic, fail-closed
1306
+ * convention the other feeders share), so a re-export or alias still resolves.
1307
+ * When the config argument isn't a statically-analyzable object literal (a
1308
+ * top-level spread, or not an object literal at all), `analyzable` is `false`
1309
+ * and every boolean fact defaults to its SAFE (not-flagged) value — an opaque
1310
+ * config can't be relied on either way. Structurally identical to
1311
+ * `AdvisorAuthConfig`.
1312
+ */
1313
+ interface AuthConfigIR {
1314
+ /** `true` when the call's config argument was a static object literal the feeder could read. */
1315
+ analyzable: boolean;
1316
+ /** `advanced.disableCSRFCheck === true`. */
1317
+ disableCsrfCheck: boolean;
1318
+ /** `emailAndPassword.enabled === true`. */
1319
+ emailPasswordEnabled: boolean;
1320
+ /** Export binding name enclosing the `createAuth(...)` call. */
1321
+ exportName: string;
1322
+ /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
1323
+ file: string;
1324
+ /** 1-based line of the `createAuth(...)` call, or `0` when unknown. */
1325
+ line: number;
1326
+ /** `emailAndPassword.requireEmailVerification === true` present. */
1327
+ requireEmailVerification: boolean;
1328
+ /** `advanced.useSecureCookies === false`. */
1329
+ secureCookiesDisabled: boolean;
1330
+ /** `session.freshAge === 0` (explicit literal). */
1331
+ sessionFreshAgeZero: boolean;
1332
+ /** `trustedOrigins` array literal contains a `"*"` element. */
1333
+ trustedOriginsWildcard: boolean;
1334
+ }
1335
+ /**
1336
+ * One `rateLimit`/`dbRateLimit` middleware call (`@lunora/ratelimit`) whose
1337
+ * `key` selector — the per-caller rate-limit sub-key, `(ctx) => string |
1338
+ * undefined` — is derived from the handler's `args` with no server-side
1339
+ * scoping (no reference to the trusted `ctx` binding anywhere in the selector)
1340
+ * — the `ratelimit_key_spoofable_or_global` lint input. A key an attacker
1341
+ * controls lets them rotate it per request and bypass the limit entirely,
1342
+ * defeating its purpose. A selector scoped by `ctx` (e.g. `ctx.auth.userId`,
1343
+ * `ctx.ip`), or one with no `args` reference at all (a fixed/global bucket —
1344
+ * the "no key" case this lint deliberately does not flag, to keep it low-FP),
1345
+ * is not recorded. Structurally identical to `AdvisorRatelimitKeySelector`.
1346
+ */
1347
+ interface RatelimitKeySelectorIR {
1348
+ /** The `rateLimit`/`dbRateLimit` callee invoked. */
1349
+ callee: string;
1350
+ /** Export binding name of the procedure whose `.use(...)` chain carries the call. */
1351
+ exportName: string;
1352
+ /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
1353
+ file: string;
1354
+ /** The rate limit's `name` argument (the second positional argument), or `""` when not a string literal. */
1355
+ limitName: string;
1356
+ /** 1-based line of the `rateLimit`/`dbRateLimit` call, or `0` when unknown. */
1357
+ line: number;
1358
+ }
1359
+ /**
1360
+ * One payload-derived privileged dispatch — a `ctx.run`/`context.run` back into a
1361
+ * Lunora function from inside a `defineQueue` push handler or a `defineWorkflow`
1362
+ * handler, whose args reference the handler's untrusted payload (`context.params`
1363
+ * for a workflow, a `for (… of batch.messages)` body for a queue) — the
1364
+ * `privileged_dispatch_unvalidated_payload` lint input. Both handler kinds run
1365
+ * under the **system identity** (RLS disabled), so forwarding attacker-influenced
1366
+ * payload into the dispatch bypasses the target's row policy. The resolved
1367
+ * `targetFile`/`targetExport` let the lint join RLS-procedure evidence and fire
1368
+ * only for RLS-gated targets. Structurally identical to `AdvisorPrivilegedDispatch`.
1369
+ */
1370
+ interface PrivilegedDispatchIR {
1371
+ /** `"queue"` for a `defineQueue` handler, `"workflow"` for a `defineWorkflow` handler. */
1372
+ dispatchKind: "queue" | "workflow";
1373
+ /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
1374
+ file: string;
1375
+ /** Export binding name of the handler performing the dispatch. */
1376
+ handlerExport: string;
1377
+ /** 1-based line of the dispatch call, or `0` when unknown. */
1378
+ line: number;
1379
+ /** Export name of the dispatched target (`send` in `api.messages.send`). */
1380
+ targetExport: string;
1381
+ /** File path of the dispatched target relative to `lunora/` (`messages` in `api.messages.send`). */
1382
+ targetFile: string;
1383
+ }
1384
+ /**
1385
+ * One discovered `httpRoute.&lt;verb>("/admin/…")` route on an admin/privileged-looking
1386
+ * path, with whether its builder chain references an auth/admin guard — the
1387
+ * `admin_route_without_guard` lint input. Structurally identical to
1388
+ * `AdvisorAdminRoute`.
1389
+ */
675
1390
  interface AdminRouteIR {
676
1391
  /** Export binding name of the route handler. */
677
1392
  exportName: string;
@@ -684,6 +1399,317 @@ interface AdminRouteIR {
684
1399
  /** `true` when the handler body references an auth/session/admin guard (`ctx.auth`, `getSession`, `requireAdmin`, …). */
685
1400
  usesGuard: boolean;
686
1401
  }
1402
+ /**
1403
+ * One tracked `ctx.storage.&lt;bucket>.&lt;method>(...)` upload/signing call — the
1404
+ * shared input for the storage config-hygiene security lints
1405
+ * (`storage_upload_without_content_type_allowlist`, `storage_upload_without_max_size`,
1406
+ * `storage_generate_upload_url_no_content_type_pin`, `storage_presigned_url_for_private_content`).
1407
+ * `upload`/`store` carry the `UploadOptions` guards (`allowedContentTypes` /
1408
+ * `maxSize`); `generateUploadUrl` carries the signed-PUT `contentType` pin;
1409
+ * `getPresignedUrl`/`getSignedUrl` carry a statically-known `expiresInSeconds`
1410
+ * literal. `presentKeys` is empty (and `expiresInSeconds` unset) when the
1411
+ * options argument was absent, a non-literal, or a spread — see `analyzable`.
1412
+ * Structurally identical to `AdvisorStorageUpload`.
1413
+ */
1414
+ interface StorageUploadIR {
1415
+ /** `true` when the call's options-object argument (or its deliberate absence) was statically resolvable. */
1416
+ analyzable: boolean;
1417
+ /** Numeric literal value of an `expiresInSeconds` option, when statically known (`getSignedUrl` / `getPresignedUrl` only). */
1418
+ expiresInSeconds?: number;
1419
+ /** Export binding name of the procedure performing the call. */
1420
+ exportName: string;
1421
+ /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
1422
+ file: string;
1423
+ /** 1-based line of the call, or `0` when unknown. */
1424
+ line: number;
1425
+ /** The `ctx.storage` method invoked. */
1426
+ method: "generateUploadUrl" | "getPresignedUrl" | "getSignedUrl" | "store" | "upload";
1427
+ /** Options-object keys present at the call site (empty when not `analyzable`, or when no options argument was passed). */
1428
+ presentKeys: string[];
1429
+ }
1430
+ /**
1431
+ * One discovered `httpAction`/`httpRoute` handler in `lunora/` that performs a
1432
+ * side effect (`ctx.runMutation` / `ctx.runAction` / a `ctx.db.{insert,patch,
1433
+ * replace,delete,insertManyUnsafe}` write) from the HTTP edge, with whether it
1434
+ * reads `ctx.auth` — the `http_action_missing_auth_guard` lint input. A handler
1435
+ * that mutates state or dispatches an action without ever consulting the request
1436
+ * identity is an unauthenticated write bypassing identity/RLS. Only handlers with
1437
+ * a statically-resolvable inline body and `ctx` binding are recorded (fail-safe
1438
+ * under-report); read-only handlers are never recorded. Structurally identical to
1439
+ * `AdvisorHttpActionGuard`.
1440
+ */
1441
+ interface HttpActionGuardIR {
1442
+ /** Export binding name of the handler (or `"&lt;module>"` when mounted inline / not a named binding). */
1443
+ exportName: string;
1444
+ /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
1445
+ file: string;
1446
+ /** Which HTTP surface the handler is: a raw `httpAction` or a typed `httpRoute` route. */
1447
+ kind: "httpAction" | "httpRoute";
1448
+ /** 1-based line of the handler call, or `0` when unknown. */
1449
+ line: number;
1450
+ /** For an `httpRoute`, the uppercased verb (`"POST"`); absent for a raw `httpAction`. */
1451
+ method?: string;
1452
+ /** `true` when the handler reads `ctx.auth` (a direct member access or a `const { auth } = ctx` destructure). */
1453
+ readsAuth: boolean;
1454
+ /** The first side effect found, as a stable label: `runMutation`, `runAction`, or `db.&lt;method>`. */
1455
+ sideEffect: string;
1456
+ }
1457
+ /**
1458
+ * One response-header write, inside an `httpAction` handler, whose value is derived
1459
+ * from raw request input (`request.headers`, `request.url`/query, `await
1460
+ * request.json()`) with no CR/LF sanitizer — the
1461
+ * `http_action_response_header_injection` lint input. A `Request`-derived string
1462
+ * placed verbatim into a response header lets a caller smuggle `\r\n` and inject
1463
+ * extra headers or split the response (header injection / response splitting). Only
1464
+ * sites whose value is request-tainted AND unguarded are recorded: a value routed
1465
+ * through a CR/LF guard (`isSafeHeaderValue`), a URL/URI encoder
1466
+ * (`encodeURIComponent`/`encodeURI`), a numeric coercion (`Number`/`parseInt`/
1467
+ * `parseFloat`), or `btoa` is treated as safe and never recorded (`String(...)` /
1468
+ * `.toString()` are NOT sanitizers — they don't strip CR/LF). Structurally
1469
+ * identical to `AdvisorHttpHeaderWrite`.
1470
+ */
1471
+ interface HttpHeaderWriteIR {
1472
+ /** Export binding name of the enclosing handler, or `"&lt;module>"` when mounted inline. */
1473
+ exportName: string;
1474
+ /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
1475
+ file: string;
1476
+ /** The header name being written (`"location"`), or `""` when the key is not a string literal. */
1477
+ headerName: string;
1478
+ /** 1-based line of the request-tainted header value. */
1479
+ line: number;
1480
+ /** How the header was written. */
1481
+ via: "headers-append" | "headers-ctor" | "headers-set" | "response-init";
1482
+ }
1483
+ /**
1484
+ * One rate-limit / Turnstile middleware call in `lunora/` — the
1485
+ * `ratelimit_middleware_fail_open` lint input. `rateLimit`/`dbRateLimit`
1486
+ * (`@lunora/ratelimit`) and `verifyTurnstileMiddleware` (`@lunora/auth`) each
1487
+ * accept a `failOpen` escape hatch that admits every request when the
1488
+ * limiter/siteverify is unavailable; `failOpen` is `true` only when the options
1489
+ * literal set it to the boolean literal `true` (anything else is fail-closed).
1490
+ * The lint escalates a fail-open guard to a finding when the guarded procedure
1491
+ * (`exportName`/`limitName`) looks auth/payment-sensitive. Structurally
1492
+ * identical to `AdvisorFailOpenGuard`.
1493
+ */
1494
+ interface FailOpenGuardIR {
1495
+ /** The middleware factory at the call site: `rateLimit` / `dbRateLimit` / `verifyTurnstileMiddleware`. */
1496
+ callee: string;
1497
+ /** Export binding name of the procedure the guard is attached to, or `"&lt;module>"` at file scope. */
1498
+ exportName: string;
1499
+ /** `true` only when the options literal set `failOpen: true` as a boolean literal; a non-literal or absent option is treated as fail-closed. */
1500
+ failOpen: boolean;
1501
+ /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
1502
+ file: string;
1503
+ /** The rate-limit `name` (second string argument) for `rateLimit`/`dbRateLimit`; `""` for `verifyTurnstileMiddleware`. */
1504
+ limitName: string;
1505
+ /** 1-based line of the middleware call, or `0` when unknown. */
1506
+ line: number;
1507
+ }
1508
+ /**
1509
+ * One `ctx.flags.boolean("key", &lt;boolean-literal>)` read in `lunora/` — the
1510
+ * `flag_gates_security_with_unsafe_default` lint input. OpenFeature returns the
1511
+ * `defaultValue` when the provider errors, so a fail-open default on a
1512
+ * security-shaped key silently opens access during an outage. Only reads with a
1513
+ * statically-known string key and boolean-literal default are recorded; the lint
1514
+ * owns the security-shape + polarity judgment. Structurally identical to
1515
+ * `AdvisorFlagSecurityDefault`.
1516
+ */
1517
+ interface FlagSecurityDefaultIR {
1518
+ /** The boolean-literal default returned on a provider outage (fail-open value). */
1519
+ defaultValue: boolean;
1520
+ /** Export binding name of the procedure performing the flag read, or `"&lt;module>"` at file scope. */
1521
+ exportName: string;
1522
+ /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
1523
+ file: string;
1524
+ /** The flag key — the first string-literal argument of `ctx.flags.boolean`. */
1525
+ key: string;
1526
+ /** 1-based line of the `ctx.flags.boolean` call, or `0` when unknown. */
1527
+ line: number;
1528
+ }
1529
+ /**
1530
+ * One `generateText` / `streamText` call in `lunora/` whose `tools` reach a
1531
+ * privileged side effect (a DB write, function dispatch, or outbound
1532
+ * fetch/mail/queue send). `userInputDerived` records whether the model input
1533
+ * (`prompt`/`messages`/`system`) flows from the handler's `args`; the
1534
+ * `ai_tool_side_effect_prompt_injection` lint fires only when it does.
1535
+ * Structurally identical to `AdvisorAiToolSideEffect`.
1536
+ */
1537
+ interface AiToolSideEffectIR {
1538
+ /** Export binding name of the procedure performing the call. */
1539
+ exportName: string;
1540
+ /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
1541
+ file: string;
1542
+ /** 1-based line of the generation call, or `0` when unknown. */
1543
+ line: number;
1544
+ /** The generation entrypoint invoked. */
1545
+ method: "generateText" | "streamText";
1546
+ /** The privileged side-effect sink a model-callable tool reaches (`ctx.db.insert`, `ctx.run`, `ctx.fetch`, …). */
1547
+ sideEffect: string;
1548
+ /** `true` when a model-input option is derived from the handler's `args` (a bare `args.x`, or a name destructured from `args`). */
1549
+ userInputDerived: boolean;
1550
+ }
1551
+ /**
1552
+ * One `&lt;receiver>.identity.&lt;key>` claim read in `lunora/`, where `&lt;receiver>` is
1553
+ * an RLS/mask policy `auth` (or `ctx.auth`/`context.auth`). `declared` records
1554
+ * whether `&lt;key>` is in the app's `defineIdentity({ ... })` contract (or the
1555
+ * always-present `userId`); the `identity_undeclared_claim_trusted` lint fires on
1556
+ * the undeclared reads. Emitted only when a resolvable identity contract exists.
1557
+ * Structurally identical to `AdvisorIdentityClaimRead`.
1558
+ */
1559
+ interface IdentityClaimReadIR {
1560
+ /** `true` when `key` is a declared claim (in the `defineIdentity` contract, or the always-present `userId`). */
1561
+ declared: boolean;
1562
+ /** Export binding name of the enclosing declaration (`&lt;module>` at file scope). */
1563
+ exportName: string;
1564
+ /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
1565
+ file: string;
1566
+ /** The claim key read off the identity bag. */
1567
+ key: string;
1568
+ /** 1-based line of the read, or `0` when unknown. */
1569
+ line: number;
1570
+ }
1571
+ /**
1572
+ * One payment webhook-adapter construction in `lunora/` (`createStripeAdapter` /
1573
+ * `createPolarAdapter` / `createAutumnAdapter` / `createDodoPaymentsAdapter`).
1574
+ * `toleranceSeconds` carries the statically-known `webhookToleranceSeconds`
1575
+ * replay window when it is a plain numeric literal; the payment-webhook
1576
+ * wide-tolerance lint fires when it exceeds a conservative ceiling. Structurally
1577
+ * identical to `AdvisorPaymentWebhook`.
1578
+ */
1579
+ interface PaymentWebhookIR {
1580
+ /** The adapter factory invoked. */
1581
+ callee: "createAutumnAdapter" | "createDodoPaymentsAdapter" | "createPolarAdapter" | "createStripeAdapter";
1582
+ /** Export binding name of the enclosing declaration (`&lt;module>` at file scope). */
1583
+ exportName: string;
1584
+ /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
1585
+ file: string;
1586
+ /** 1-based line of the construction, or `0` when unknown. */
1587
+ line: number;
1588
+ /** Statically-known `webhookToleranceSeconds` literal, when present and a plain numeric literal. */
1589
+ toleranceSeconds?: number;
1590
+ }
1591
+ /**
1592
+ * One `ctx.db.&lt;table>.findMany({ includeDeleted })` list read whose
1593
+ * `includeDeleted` is either a hardcoded `true` or derived from the handler's
1594
+ * `args` — the `soft_delete_include_deleted_from_args` lint input. The lint joins
1595
+ * `table` against the schema's soft-delete tables and `visibility` against
1596
+ * `.public()` before flagging. Structurally identical to `AdvisorSoftDeleteRead`
1597
+ * so values pass straight through without conversion.
1598
+ */
1599
+ interface SoftDeleteReadIR {
1600
+ /** Export binding name of the procedure performing the read. */
1601
+ exportName: string;
1602
+ /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
1603
+ file: string;
1604
+ /** `true` when `includeDeleted` was derived from the handler's `args` (any caller can flip it). */
1605
+ fromArgs: boolean;
1606
+ /** `true` when `includeDeleted` was a hardcoded `true` literal (always resurfaces soft-deleted rows). */
1607
+ hardcodedTrue: boolean;
1608
+ /** 1-based line of the read call. */
1609
+ line: number;
1610
+ /** Table read, or `""` when the table-arg form's first argument wasn't a string literal. */
1611
+ table: string;
1612
+ /** `"internal"` for `internalQuery` / `internalMutation` / `internalAction`. */
1613
+ visibility: "internal" | "public";
1614
+ }
1615
+ /**
1616
+ * One `ctx.db.&lt;table>.findMany({ with: { &lt;rel> } })` relation-hydrating list read
1617
+ * — the `masked_relation_leak_via_with` lint input. Column masking does not
1618
+ * descend into `with`-hydrated relations, so a masked table surfaced only through
1619
+ * a `with` on an unprotected parent read is returned in the clear. The lint
1620
+ * resolves each relation accessor to its target table and joins it against the
1621
+ * discovered mask evidence before flagging. Structurally identical to
1622
+ * `AdvisorRelationLoad` so values pass straight through without conversion.
1623
+ */
1624
+ interface RelationLoadIR {
1625
+ /** Export binding name of the procedure performing the read. */
1626
+ exportName: string;
1627
+ /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
1628
+ file: string;
1629
+ /** 1-based line of the read call. */
1630
+ line: number;
1631
+ /** Parent table the read targets, or `""` when the table-arg form's first argument wasn't a string literal. */
1632
+ parentTable: string;
1633
+ /** Relation accessor names named in the read's `with: { … }` map — matched against the parent table's declared relations. */
1634
+ relations: string[];
1635
+ /** `"internal"` for `internalQuery` / `internalMutation` / `internalAction`. */
1636
+ visibility: "internal" | "public";
1637
+ }
1638
+ /**
1639
+ * One `query` handler whose `return` hands back the raw rows of a table — the
1640
+ * result of a `ctx.db.&lt;table>.findMany()` / `.findFirst()` / `.get()` read, or a
1641
+ * `ctx.db.query("&lt;table>")…collect()` fluent chain — returned directly (or through
1642
+ * one local `const` hop) with no hand-built projection. The
1643
+ * `output_projection_missing_on_public_read` lint keeps only `visibility ===
1644
+ * "public"` rows with no `.output(...)` / `.use(mask(...))` on the chain, then
1645
+ * joins `table` against the schema and flags one whose columns are PII-named.
1646
+ * Structurally identical to `AdvisorRawRowReturn` so values pass straight through
1647
+ * without conversion.
1648
+ */
1649
+ interface RawRowReturnIR {
1650
+ /** Export binding name of the query returning the raw rows. */
1651
+ exportName: string;
1652
+ /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
1653
+ file: string;
1654
+ /** 1-based line of the `return` (or concise-body) expression. */
1655
+ line: number;
1656
+ /** Table whose raw rows are returned, or `""` when the read's table wasn't a string literal. */
1657
+ table: string;
1658
+ /** `true` when the procedure's builder chain carries a `.use(mask(...))` step. */
1659
+ usesMask: boolean;
1660
+ /** `true` when the procedure's builder chain carries an `.output(...)` return-shape projection. */
1661
+ usesOutput: boolean;
1662
+ /** `"internal"` for `internalQuery`; `"public"` for `query`. */
1663
+ visibility: "internal" | "public";
1664
+ }
1665
+ /**
1666
+ * One `query`/`mutation` handler that gates a `ctx.db.get`/`patch`/`delete` on a
1667
+ * null-checked `ctx.db.normalizeId(table, id)` result — the
1668
+ * `normalize_id_used_as_authorization` lint input. `normalizeId` validates an id's
1669
+ * structural shape only (it never reads the database), so a non-null result proves
1670
+ * the id is well-formed, never that the caller owns the row; gating access on it is
1671
+ * an IDOR. The lint owns the negative proof — it keeps only `visibility === "public"`
1672
+ * rows with no `.use(rls(...))` and no ownership/identity mention (`mentionsOwnership`),
1673
+ * then joins `table` against the schema's RLS mode before flagging. Structurally
1674
+ * identical to `AdvisorNormalizeIdAuthorization` so values pass straight through.
1675
+ */
1676
+ interface NormalizeIdAuthorizationIR {
1677
+ /** Export binding name of the procedure performing the normalize-then-access. */
1678
+ exportName: string;
1679
+ /** Source file relative to `&lt;projectRoot>/lunora/`, without extension. */
1680
+ file: string;
1681
+ /** 1-based line of the `ctx.db.normalizeId(...)` call the access is gated on. */
1682
+ line: number;
1683
+ /** `true` when the handler anywhere reads an ownership-named identifier or `ctx.auth`/`ctx.identity`/… — an intervening ownership signal. */
1684
+ mentionsOwnership: boolean;
1685
+ /** The id-first `ctx.db` sink the normalized id reaches. */
1686
+ sinkMethod: "delete" | "get" | "patch";
1687
+ /** Table named in the `normalizeId` call, or `""` when its table argument wasn't a string literal. */
1688
+ table: string;
1689
+ /** `true` when the procedure's builder chain carries a `.use(rls(...))` step. */
1690
+ usesRls: boolean;
1691
+ /** `"internal"` for `internalQuery`/`internalMutation`; `"public"` for `query`/`mutation`. */
1692
+ visibility: "internal" | "public";
1693
+ }
1694
+ /**
1695
+ * One committed `wrangler.jsonc` `vars` entry whose value is a plaintext secret —
1696
+ * the `plaintext_secret_in_wrangler_vars` lint input. `vars` are baked into the
1697
+ * deployed Worker in cleartext and checked into source control, so a real API key
1698
+ * / token / private key there ships the secret to every reader of the repo and the
1699
+ * bundle; it belongs in a Secrets Store binding or `wrangler secret put`. Produced
1700
+ * by `@lunora/config` (which reads `wrangler.jsonc`), not a ts-morph feeder —
1701
+ * codegen only passes it through. Structurally identical to `AdvisorWranglerVariable`.
1702
+ */
1703
+ interface WranglerVariableIR {
1704
+ /** The `wrangler.jsonc` file the var was read from, relative to the project root. */
1705
+ file: string;
1706
+ /** The offending `vars` key (e.g. `STRIPE_SECRET_KEY`). */
1707
+ key: string;
1708
+ /** Heuristic that matched, e.g. `stripe_live_key` / `private_key` / `secret_named_var`. */
1709
+ kind: string;
1710
+ /** Redacted preview of the value (first few chars + length) for the finding detail — never the full secret. */
1711
+ preview: string;
1712
+ }
687
1713
  interface ProjectIR {
688
1714
  crons: ReadonlyArray<CronJobIR>;
689
1715
  functions: ReadonlyArray<FunctionIR>;
@@ -693,382 +1719,616 @@ interface ProjectIR {
693
1719
  schema: SchemaIR;
694
1720
  }
695
1721
  /**
696
- * Run the static lints against a discovered {@link SchemaIR} and the reads/writes/calls
697
- * found in function bodies: query reads feed `filter_without_index`, insert writes
698
- * feed `table_without_insert`, authApi calls feed `auth_api_call_without_headers`,
699
- * rls procedure snapshots feed `rls_uncovered_table`, and mask procedure
700
- * snapshots feed `mask_uncovered_pii_column`; declared containers
701
- * feed the `container_*` lints; declared workflows + `ctx.workflows.get(...)` call
702
- * sites feed the `workflow_unused` / `workflow_unknown_target` lints; non-deterministic
703
- * calls inside query/mutation handlers feed the `nondeterministic_query_mutation` lint
704
- * (all default empty for callers that don't analyze functions/containers/workflows).
705
- * The IR types are structurally identical to the advisor's evidence types so they
706
- * pass straight through without conversion. Returns the findings; surfacing them
707
- * (console, error overlay, studio Advisors table) is the caller's choice.
708
- */
709
- declare const lintSchema: (schema: SchemaIR, queries?: ReadonlyArray<QueryReadIR>, inserts?: ReadonlyArray<InsertWriteIR>, authApiCalls?: ReadonlyArray<AuthApiCallIR>, rlsProcedures?: ReadonlyArray<RlsProcedureIR>, containers?: ReadonlyArray<ContainerIR>, workflows?: ReadonlyArray<WorkflowIR>, workflowCalls?: ReadonlyArray<WorkflowCallIR>, maskProcedures?: ReadonlyArray<MaskProcedureIR>, nondeterministicCalls?: ReadonlyArray<NondeterministicCallIR>, procedureProtections?: ReadonlyArray<ProcedureMiddlewareIR>, argumentValidators?: ReadonlyArray<ArgumentValidatorIR>, secretLiterals?: ReadonlyArray<SecretLiteralIR>, sqlInterpolations?: ReadonlyArray<SqlInterpolationIR>, adminRoutes?: ReadonlyArray<AdminRouteIR>, r2sqlCalls?: ReadonlyArray<R2sqlCallIR>) => Finding[];
710
- /**
711
- * Render advisor findings as a single multi-line string for console surfacing:
712
- * a one-line summary header followed by one `[LEVEL] name: detail` line per
713
- * finding. Returns `""` when there are no findings.
714
- */
1722
+ * Run the static lints against a discovered {@link SchemaIR} and the reads/writes/calls
1723
+ * found in function bodies: query reads feed `filter_without_index`, insert writes
1724
+ * feed `table_without_insert`, authApi calls feed `auth_api_call_without_headers`,
1725
+ * rls procedure snapshots feed `rls_uncovered_table`, mask procedure
1726
+ * snapshots feed `mask_uncovered_pii_column`, and per-column mask strategies
1727
+ * feed `mask_weak_hash_strategy_on_pii`; declared containers
1728
+ * feed the `container_*` lints; declared workflows (with their durable step labels)
1729
+ * + `ctx.workflows.get(...)` call sites feed the `workflow_unused` /
1730
+ * `workflow_unknown_target` / duplicate-step-name lints; non-deterministic
1731
+ * calls inside query/mutation handlers feed the `nondeterministic_query_mutation` lint
1732
+ * (all default empty for callers that don't analyze functions/containers/workflows).
1733
+ * The IR types are structurally identical to the advisor's evidence types so they
1734
+ * pass straight through without conversion. Returns the findings; surfacing them
1735
+ * (console, error overlay, studio Advisors table) is the caller's choice.
1736
+ */
1737
+ /**
1738
+ * Named inputs for {@link lintSchema}. Every feeder is a discrete key rather than
1739
+ * a positional argument: the feeder list grows every few releases and many IR
1740
+ * types are structurally similar (`{file, exportName, line}`-shaped evidence),
1741
+ * so a positional call was a silent-transposition hazard — swapping two adjacent
1742
+ * arguments could typecheck yet feed the wrong evidence to the wrong lint and
1743
+ * corrupt a security advisory. `schema` is the only required field; every other
1744
+ * feeder defaults to "not analyzed" when omitted.
1745
+ */
1746
+ interface LintSchemaOptions {
1747
+ adminRoutes?: ReadonlyArray<AdminRouteIR>;
1748
+ aiRawRuns?: ReadonlyArray<AiRawRunIR>;
1749
+ aiToolSideEffects?: ReadonlyArray<AiToolSideEffectIR>;
1750
+ argumentDerivedFetches?: ReadonlyArray<ArgumentDerivedFetchIR>;
1751
+ argumentValidators?: ReadonlyArray<ArgumentValidatorIR>;
1752
+ authApiCalls?: ReadonlyArray<AuthApiCallIR>;
1753
+ authConfigs?: ReadonlyArray<AuthConfigIR>;
1754
+ browserUrlAccesses?: ReadonlyArray<BrowserUrlAccessIR>;
1755
+ configCalls?: ReadonlyArray<ConfigCallIR>;
1756
+ containerKeyAccesses?: ReadonlyArray<ContainerKeyAccessIR>;
1757
+ containerOverrides?: ReadonlyArray<ContainerOverrideIR>;
1758
+ containers?: ReadonlyArray<ContainerIR>;
1759
+ exportSinks?: ReadonlyArray<AdvisorExportSink>;
1760
+ failOpenGuards?: ReadonlyArray<FailOpenGuardIR>;
1761
+ flagSecurityDefaults?: ReadonlyArray<FlagSecurityDefaultIR>;
1762
+ geoIndexUsages?: ReadonlyArray<AdvisorGeoIndexUsage>;
1763
+ httpActionGuards?: ReadonlyArray<HttpActionGuardIR>;
1764
+ httpHeaderWrites?: ReadonlyArray<HttpHeaderWriteIR>;
1765
+ identityClaimReads?: ReadonlyArray<IdentityClaimReadIR>;
1766
+ imageDeliveryUrlAccesses?: ReadonlyArray<ImageDeliveryUrlAccessIR>;
1767
+ inserts?: ReadonlyArray<InsertWriteIR>;
1768
+ kvKeyAccesses?: ReadonlyArray<KvKeyAccessIR>;
1769
+ mailRecipientAccesses?: ReadonlyArray<MailRecipientAccessIR>;
1770
+ maskProcedures?: ReadonlyArray<MaskProcedureIR>;
1771
+ maskStrategies?: ReadonlyArray<MaskStrategyIR>;
1772
+ mutatorWrites?: ReadonlyArray<MutatorWriteIR>;
1773
+ nondeterministicCalls?: ReadonlyArray<NondeterministicCallIR>;
1774
+ normalizeIdAuthorizations?: ReadonlyArray<NormalizeIdAuthorizationIR>;
1775
+ notifyCalls?: ReadonlyArray<AdvisorNotifyCall>;
1776
+ notifyConfig?: AdvisorNotifyConfig;
1777
+ ownerFieldWrites?: ReadonlyArray<OwnerFieldWriteIR>;
1778
+ paymentWebhooks?: ReadonlyArray<PaymentWebhookIR>;
1779
+ privilegedDispatches?: ReadonlyArray<PrivilegedDispatchIR>;
1780
+ procedureProtections?: ReadonlyArray<ProcedureMiddlewareIR>;
1781
+ queries?: ReadonlyArray<QueryReadIR>;
1782
+ queues?: ReadonlyArray<QueueIR>;
1783
+ r2sqlCalls?: ReadonlyArray<R2sqlCallIR>;
1784
+ ratelimitKeySelectors?: ReadonlyArray<RatelimitKeySelectorIR>;
1785
+ rawRowReturns?: ReadonlyArray<RawRowReturnIR>;
1786
+ relationLoads?: ReadonlyArray<RelationLoadIR>;
1787
+ rlsProcedures?: ReadonlyArray<RlsProcedureIR>;
1788
+ schema: SchemaIR;
1789
+ secretLiterals?: ReadonlyArray<SecretLiteralIR>;
1790
+ shapes?: ReadonlyArray<ShapeIR>;
1791
+ softDeleteReads?: ReadonlyArray<SoftDeleteReadIR>;
1792
+ sqlInterpolations?: ReadonlyArray<SqlInterpolationIR>;
1793
+ storageKeyAccesses?: ReadonlyArray<StorageKeyAccessIR>;
1794
+ storageUploads?: ReadonlyArray<StorageUploadIR>;
1795
+ unrestrictedWhereBranches?: ReadonlyArray<UnrestrictedWhereBranchIR>;
1796
+ vectorNamespaceAccesses?: ReadonlyArray<VectorNamespaceAccessIR>;
1797
+ workflowCalls?: ReadonlyArray<WorkflowCallIR>;
1798
+ workflows?: ReadonlyArray<WorkflowIR>;
1799
+ wranglerVariables?: ReadonlyArray<WranglerVariableIR>;
1800
+ }
1801
+ declare const lintSchema: (options: LintSchemaOptions) => Finding[];
1802
+ /**
1803
+ * Render advisor findings as a single multi-line string for console surfacing:
1804
+ * a one-line summary header followed by one `[LEVEL] name: detail` line per
1805
+ * finding. Returns `""` when there are no findings.
1806
+ */
715
1807
  declare const formatAdvisories: (findings: ReadonlyArray<Finding>) => string;
716
1808
  /**
717
- * An error thrown by codegen discovery when the user's schema or function
718
- * source has a structural problem that can be pinpointed to a specific source
719
- * location. The `file`, `line`, and `column` properties mirror what Vite's
720
- * error-overlay `loc` field expects so the browser can display the exact spot.
721
- */
722
- declare class CodegenDiagnosticError extends Error {
1809
+ * An error thrown by codegen discovery when the user's schema or function
1810
+ * source has a structural problem that can be pinpointed to a specific source
1811
+ * location. A `LunoraError` subclass (`code: "CODEGEN_DIAGNOSTIC"`); the `file`,
1812
+ * `line`, and `column` properties (also passed through as the base `loc`) mirror
1813
+ * what Vite's error-overlay `loc` field expects so the browser can display the
1814
+ * exact spot.
1815
+ */
1816
+ declare class CodegenDiagnosticError extends LunoraError {
723
1817
  readonly column: number;
724
1818
  readonly file: string;
725
1819
  readonly line: number;
726
1820
  constructor(message: string, file: string, line: number, column: number);
727
1821
  }
728
1822
  /**
729
- * Build a {@link CodegenDiagnosticError} whose message includes the source
730
- * location and whose `file`/`line`/`column` properties are set from the
731
- * ts-morph `Node`'s position in its source file.
732
- *
733
- * Message format: `@lunora/codegen: &lt;detail> (&lt;file>:&lt;line>:&lt;column>)`
734
- */
735
- declare const diagnosticAt: (node: Node, detail: string) => CodegenDiagnosticError;
736
- /**
737
- * Discover `ctx.authApi.&lt;method>(...)` (and bare `authApi.&lt;method>(...)`) calls
738
- * under the lunora source directory and attribute each to the exported function
739
- * (and file) performing it. Calls outside an exported declaration are dropped.
740
- */
1823
+ * Build a {@link CodegenDiagnosticError} whose message includes the source
1824
+ * location and whose `file`/`line`/`column` properties are set from the
1825
+ * ts-morph `Node`'s position in its source file.
1826
+ *
1827
+ * Message format: `@lunora/codegen: &lt;detail> (&lt;file>:&lt;line>:&lt;column>)`
1828
+ *
1829
+ * `meta` is merged onto the returned error for callers that also carry the
1830
+ * project-wide `LunoraError` envelope (`code`/`name`/`status`) — it never
1831
+ * touches `file`/`line`/`column`, and the error stays an instance of
1832
+ * {@link CodegenDiagnosticError} so the Vite overlay's `instanceof` location
1833
+ * lookup is unaffected.
1834
+ */
1835
+ declare const diagnosticAt: (node: Node, detail: string, meta?: Record<string, unknown>) => CodegenDiagnosticError;
1836
+ /** The only file agents may be declared in — mirrors `lunora/workflows.ts`. */
1837
+ declare const AGENTS_FILENAME = "agents.ts";
1838
+ /**
1839
+ * Discover every agent the project declares: exported `defineAgent()` calls in
1840
+ * `lunora/agents.ts`. Returns `[]` when the file doesn't exist. Only four things
1841
+ * are read statically — the optional `name` override (wrangler `workflows[].name`),
1842
+ * the optional `publicRun` opt-in (the `agents:agentRun` capability gate), the
1843
+ * presence of a `voice` block (which turns on the voice-session Durable Object),
1844
+ * and the presence of an `onEmail` mapper (which wires the worker `email()`
1845
+ * handler); the rest of the agent config (model / tools / memory / voice models /
1846
+ * the `onEmail` closure body) is runtime-only, so codegen never evaluates it.
1847
+ */
1848
+ declare const discoverAgents: (project: Project, lunoraDirectory: string) => AgentIR[];
1849
+ /**
1850
+ * Discover `ctx.authApi.&lt;method>(...)` (and bare `authApi.&lt;method>(...)`) calls
1851
+ * under the lunora source directory and attribute each to the exported function
1852
+ * (and file) performing it. Calls outside an exported declaration are dropped.
1853
+ */
741
1854
  declare const discoverAuthApiCalls: (project: Project, lunoraDirectory: string) => AuthApiCallIR[];
742
1855
  /** The only file containers may be declared in — mirrors `lunora/crons.ts`. */
743
1856
  declare const CONTAINERS_FILENAME = "containers.ts";
744
1857
  /**
745
- * Discover every container the project declares: exported `defineContainer()`
746
- * calls in `lunora/containers.ts`. Returns `[]` when the file doesn't exist.
747
- * Wrangler-relevant fields (`image`, `instanceType`, `maxInstances`, `name`)
748
- * must be static literals; runtime-only fields (`env`, `sleepAfter`, …) may be
749
- * any expression since the generated class imports the definition object.
750
- */
1858
+ * Discover every container the project declares: exported `defineContainer()`
1859
+ * calls in `lunora/containers.ts`. Returns `[]` when the file doesn't exist.
1860
+ * Wrangler-relevant fields (`image`, `instanceType`, `maxInstances`, `name`)
1861
+ * must be static literals; runtime-only fields (`env`, `sleepAfter`, …) may be
1862
+ * any expression since the generated class imports the definition object.
1863
+ */
751
1864
  declare const discoverContainers: (project: Project, lunoraDirectory: string) => ContainerIR[];
752
1865
  /**
753
- * Scan every `.ts` file under `lunoraDir` for `cronJobs()` builder registrations
754
- * (`crons.interval(...)`, `crons.daily(...)`, `crons.cron(...)`, …) and lift them
755
- * into {@link CronJobIR}. Schedules are compiled to standard cron expressions;
756
- * function references are resolved to their `namespace:fn` dispatch path, while a
757
- * bare identifier naming a declared workflow (`workflows`) resolves to a durable
758
- * workflow start. Names must be unique across the project.
759
- */
760
- declare const discoverCrons: (project: Project, lunoraDirectory: string, workflows?: ReadonlyArray<WorkflowIR>) => CronJobIR[];
761
- /**
762
- * Scan all .ts files under `lunoraDir` (skipping `_generated/` and `schema.ts`)
763
- * for top-level `export const x = query/mutation/action({...})` registrations.
764
- */
1866
+ * Scan every `.ts` file under `lunoraDir` for `cronJobs()` builder registrations
1867
+ * (`crons.interval(...)`, `crons.daily(...)`, `crons.cron(...)`, …) and lift them
1868
+ * into {@link CronJobIR}. Schedules are compiled to standard cron expressions;
1869
+ * function references are resolved to their `namespace:fn` dispatch path, while a
1870
+ * `workflows.NAME` / `agents.NAME` reference (or a bare identifier naming a
1871
+ * declared workflow) resolves to a durable workflow start. Names must be unique
1872
+ * across the project.
1873
+ */
1874
+ declare const discoverCrons: (project: Project, lunoraDirectory: string, workflows?: ReadonlyArray<WorkflowIR>, agents?: ReadonlyArray<AgentIR>) => CronJobIR[];
1875
+ /** The only file a feature-flag provider may be declared in — mirrors `lunora/queues.ts`. */
1876
+ declare const FLAGS_FILENAME = "flags.ts";
1877
+ /**
1878
+ * Discover the feature-flag provider a project declares in `lunora/flags.ts`.
1879
+ * Returns `undefined` when the file doesn't exist (the app has no flags). The
1880
+ * read is metadata-only and lenient: codegen wires `ctx.flags` purely from the
1881
+ * file's *existence* (`run-codegen.ts`) and imports the real module for the
1882
+ * provider value — this IR exists solely so the config layer can reconcile the
1883
+ * wrangler `flagship` binding for the Flagship binding-mode provider. Anything
1884
+ * it can't read statically degrades to a `custom` provider (no binding), never
1885
+ * a thrown error.
1886
+ */
1887
+ declare const discoverFlags: (project: Project, lunoraDirectory: string) => FlagsIR | undefined;
1888
+ /**
1889
+ * Scan all .ts files under `lunoraDir` (skipping `_generated/` and `schema.ts`)
1890
+ * for top-level `export const x = query/mutation/action({...})` registrations.
1891
+ */
765
1892
  declare const discoverFunctions: (project: Project, lunoraDirectory: string) => FunctionIR[];
766
1893
  /**
767
- * Scan all `.ts` files under `lunoraDir` (skipping `_generated/` and `schema.ts`)
768
- * for `export const x = httpRoute.&lt;verb>(...)…handler(...)` typed REST routes.
769
- * These are the headline OpenAPI target: each becomes a real `paths` entry.
770
- */
1894
+ * Scan all `.ts` files under `lunoraDir` (skipping `_generated/` and `schema.ts`)
1895
+ * for `export const x = httpRoute.&lt;verb>(...)…handler(...)` typed REST routes.
1896
+ * These are the headline OpenAPI target: each becomes a real `paths` entry.
1897
+ */
771
1898
  declare const discoverHttpRoutes: (project: Project, lunoraDirectory: string) => HttpRouteIR[];
772
1899
  /**
773
- * Discover `ctx.db.insert("table", …)` writes under the lunora source directory
774
- * and attribute each to the exported function (and file) performing it. Calls
775
- * with a non-literal table argument, or outside an exported declaration, are
776
- * dropped (`table === ""` / no enclosing export).
777
- */
1900
+ * Discover `ctx.db.insert("table", …)` writes under the lunora source directory
1901
+ * and attribute each to the exported function (and file) performing it. Calls
1902
+ * with a non-literal table argument, or outside an exported declaration, are
1903
+ * dropped (`table === ""` / no enclosing export).
1904
+ */
778
1905
  declare const discoverInserts: (project: Project, lunoraDirectory: string) => InsertWriteIR[];
779
1906
  /**
780
- * Discover masking usage for every exported Lunora procedure under the lunora
781
- * source directory — the column-level twin of `discoverRlsProcedures`. For each
782
- * procedure, records whether its builder chain includes `.use(mask(...))`, which
783
- * `(table, column)` pairs that mask declares, and which tables it reads/writes
784
- * through `ctx.db`. Feeds the `mask_uncovered_pii_column` advisor lint.
785
- */
1907
+ * Discover masking usage for every exported Lunora procedure under the lunora
1908
+ * source directory — the column-level twin of `discoverRlsProcedures`. For each
1909
+ * procedure, records whether its builder chain includes `.use(mask(...))`, which
1910
+ * `(table, column)` pairs that mask declares, and which tables it reads/writes
1911
+ * through `ctx.db`. Feeds the `mask_uncovered_pii_column` advisor lint.
1912
+ */
786
1913
  declare const discoverMaskProcedures: (project: Project, lunoraDirectory: string) => MaskProcedureIR[];
787
1914
  /**
788
- * Aggregate the schema-wide masking metadata the studio's data-browser mask
789
- * toggle reads: every statically-discovered `(table, column, strategy)` masked
790
- * column across the project's `.use(mask(...))` chains. Walks the same builder
791
- * chains as {@link discoverMaskProcedures} but carries the strategy the preview
792
- * needs to choose redact-vs-hash-vs-custom rendering. Deduped by `(table,
793
- * column)` with the first declaration winning, so a column masked by several
794
- * procedures lists once — the same evidence the advisor lint uses.
795
- */
796
- /**
797
- * Scan all `.ts` files under `lunoraDir` for top-level
798
- * `export const x = defineMigration({...})` declarations and lift them into
799
- * {@link MigrationIR}. `id` must be a static string literal (it's the registry
800
- * key); `table` is best-effort and left `""` when not a literal.
801
- */
1915
+ * Scan all `.ts` files under `lunoraDir` for top-level
1916
+ * `export const x = defineMigration({...})` declarations and lift them into
1917
+ * {@link MigrationIR}. `id` must be a static string literal (it's the registry
1918
+ * key); `table` is best-effort and left `""` when not a literal.
1919
+ */
802
1920
  declare const discoverMigrations: (project: Project, lunoraDirectory: string) => MigrationIR[];
803
- /**
804
- * Discover non-deterministic API calls (`Date.now`, `new Date()`, `Date()`,
805
- * `Math.random`, `crypto.randomUUID`, `crypto.getRandomValues` — including
806
- * `globalThis`/`self`/`window`-prefixed receivers and `fetch`) lexically inside
807
- * the handler body of every exported `query(...)` / `mutation(...)` registration
808
- * under the lunora source directory — the `nondeterministic_query_mutation` lint
809
- * input. `action(...)` (and `stream(...)`) registrations are intentionally
810
- * skipped: actions run exactly once and may use ambient APIs freely.
811
- *
812
- * Traversal is scoped to the handler node (not the whole declaration), mirroring
813
- * how the auth-api / insert feeders attribute calls — so a call in a sibling
814
- * helper outside the handler, or in a nested `action(...)` passed elsewhere, is
815
- * not attributed to the query/mutation. One {@link NondeterministicCallIR} is
816
- * produced per call site.
817
- */
1921
+ /** The only file custom mutators may be declared in — mirrors `lunora/queues.ts`. */
1922
+ declare const MUTATORS_FILENAME = "mutators.ts";
1923
+ /**
1924
+ * Discover every custom mutator the project declares: exported
1925
+ * `defineMutator()` calls in `lunora/mutators.ts`. Returns `[]` when the file
1926
+ * doesn't exist. Only the export binding is lifted — the runtime object carries
1927
+ * the authoritative `server` impl + `handler`, so codegen never evaluates the
1928
+ * body. The client `client` impl is split into the browser bundle separately.
1929
+ */
1930
+ declare const discoverMutators: (project: Project, lunoraDirectory: string) => MutatorIR[];
1931
+ /**
1932
+ * Discover non-deterministic API calls (`Date.now`, `new Date()`, `Date()`,
1933
+ * `Math.random`, `crypto.randomUUID`, `crypto.getRandomValues` including
1934
+ * `globalThis`/`self`/`window`-prefixed receivers and `fetch`) lexically inside
1935
+ * the handler body of every exported `query(...)` / `mutation(...)` registration
1936
+ * under the lunora source directory — the `nondeterministic_query_mutation` lint
1937
+ * input. `action(...)` (and `stream(...)`) registrations are intentionally
1938
+ * skipped: actions run exactly once and may use ambient APIs freely.
1939
+ *
1940
+ * Traversal is scoped to the handler node (not the whole declaration), mirroring
1941
+ * how the auth-api / insert feeders attribute calls — so a call in a sibling
1942
+ * helper outside the handler, or in a nested `action(...)` passed elsewhere, is
1943
+ * not attributed to the query/mutation. One {@link NondeterministicCallIR} is
1944
+ * produced per call site.
1945
+ */
818
1946
  declare const discoverNondeterministicCalls: (project: Project, lunoraDirectory: string) => NondeterministicCallIR[];
819
- /**
820
- * Discover `ctx.db.query("table")…` reads under the lunora source directory and
821
- * reduce each to a {@link QueryReadIR}. Only reads that call `.filter()` are
822
- * returned an unfiltered read is never a `filter_without_index` candidate, so
823
- * dropping the rest keeps the lint input small.
824
- */
1947
+ /** The only file a `@lunora/notify` provider may be declared in — mirrors `lunora/flags.ts`. */
1948
+ declare const NOTIFY_FILENAME = "notify.ts";
1949
+ /**
1950
+ * Discover `ctx.notify` / `ctx.push` sends lexically inside the handler body of
1951
+ * every exported `query(...)` / `mutation(...)` registration under the lunora
1952
+ * source directory — the `notify_send_outside_action` lint input. `action(...)`
1953
+ * (and `stream(...)`) registrations are intentionally skipped: a notification
1954
+ * send is external I/O that belongs in actions. One {@link AdvisorNotifyCall} is
1955
+ * produced per send site.
1956
+ */
1957
+ declare const discoverNotifyCalls: (project: Project, lunoraDirectory: string) => AdvisorNotifyCall[];
1958
+ /**
1959
+ * Discover which push channels the project's `lunora/notify.ts` default export
1960
+ * (`defineNotify({...})`) wires plus whether any handler sends a push — the
1961
+ * `notify_missing_push_config` lint input. Returns `undefined` when the file is
1962
+ * absent (the app declares no notify config). The read is metadata-only and
1963
+ * lenient (like `discoverFlags`): a `webPush`/`fcm` property's mere presence
1964
+ * counts as the channel being wired; a non-literal config degrades to "unwired"
1965
+ * rather than throwing.
1966
+ */
1967
+ declare const discoverNotifyConfig: (project: Project, lunoraDirectory: string) => AdvisorNotifyConfig | undefined;
1968
+ /**
1969
+ * Discover `ctx.db.query("table")…` reads under the lunora source directory and
1970
+ * reduce each to a {@link QueryReadIR}. Only reads that call `.filter()` are
1971
+ * returned — an unfiltered read is never a `filter_without_index` candidate, so
1972
+ * dropping the rest keeps the lint input small.
1973
+ */
825
1974
  declare const discoverQueries: (project: Project, lunoraDirectory: string) => QueryReadIR[];
826
- /**
827
- * Discover `ctx.r2sql` accesses lexically inside the handler body of every
828
- * exported `query(...)` / `mutation(...)` registration under the lunora source
829
- * directory the `r2sql_outside_action` lint input. `action(...)` (and
830
- * `stream(...)`) registrations are intentionally skipped: R2 SQL is the
831
- * external, non-reactive surface that belongs in actions.
832
- *
833
- * Traversal is scoped to the handler node (not the whole declaration), mirroring
834
- * `discoverNondeterministicCalls` so a `ctx.r2sql` touch in a sibling helper
835
- * outside the handler is not attributed to the query/mutation. One
836
- * {@link R2sqlCallIR} is produced per access site.
837
- */
1975
+ /** The only file queues may be declared in — mirrors `lunora/workflows.ts`. */
1976
+ declare const QUEUES_FILENAME = "queues.ts";
1977
+ /**
1978
+ * Discover every queue the project declares: exported `defineQueue()` calls in
1979
+ * `lunora/queues.ts`. Returns `[]` when the file doesn't exist. Only the
1980
+ * wrangler-relevant literals (`name`/`mode`/batch tuning) are read; the handler
1981
+ * body is runtime-only, so codegen never evaluates it.
1982
+ */
1983
+ declare const discoverQueues: (project: Project, lunoraDirectory: string) => QueueIR[];
1984
+ /**
1985
+ * Discover `ctx.r2sql` accesses lexically inside the handler body of every
1986
+ * exported `query(...)` / `mutation(...)` registration under the lunora source
1987
+ * directory — the `r2sql_outside_action` lint input. `action(...)` (and
1988
+ * `stream(...)`) registrations are intentionally skipped: R2 SQL is the
1989
+ * external, non-reactive surface that belongs in actions.
1990
+ *
1991
+ * Traversal is scoped to the handler node (not the whole declaration), mirroring
1992
+ * `discoverNondeterministicCalls` — so a `ctx.r2sql` touch in a sibling helper
1993
+ * outside the handler is not attributed to the query/mutation. One
1994
+ * {@link R2sqlCallIR} is produced per access site.
1995
+ */
838
1996
  declare const discoverR2sqlCalls: (project: Project, lunoraDirectory: string) => R2sqlCallIR[];
839
1997
  declare const discoverRlsProcedures: (project: Project, lunoraDirectory: string) => RlsProcedureIR[];
840
1998
  /**
841
- * Aggregate the schema-wide RLS metadata the studio's read-only inspector reads:
842
- * every statically-discovered `(table, on, procedure)` policy entry plus every
843
- * role declared via `rls(policies, { roles })`. Walks the same builder chains as
844
- * {@link discoverRlsProcedures} but extracts the richer `{ on }` operation +
845
- * role/permission shape rather than the lint's table-name set.
846
- *
847
- * Only the **builder** form (`c.use(rls(...)).query(...)`) can declare policies,
848
- * so bare-factory procedures contribute nothing. The `when` predicate is never
849
- * read — it's an opaque JS closure whose logic belongs in code, not the UI.
850
- * Roles are deduped by name (first declaration wins) so a role registered on
851
- * several procedures lists once.
852
- */
1999
+ * Aggregate the schema-wide RLS metadata the studio's read-only inspector reads:
2000
+ * every statically-discovered `(table, on, procedure)` policy entry plus every
2001
+ * role declared via `rls(policies, { roles })`. Walks the same builder chains as
2002
+ * {@link discoverRlsProcedures} but extracts the richer `{ on }` operation +
2003
+ * role/permission shape rather than the lint's table-name set.
2004
+ *
2005
+ * Only the **builder** form (`c.use(rls(...)).query(...)`) can declare policies,
2006
+ * so bare-factory procedures contribute nothing. The `when` predicate is never
2007
+ * read — it's an opaque JS closure whose logic belongs in code, not the UI.
2008
+ * Roles are deduped by name (first declaration wins) so a role registered on
2009
+ * several procedures lists once.
2010
+ */
853
2011
  declare const discoverRlsMetadata: (project: Project, lunoraDirectory: string) => RlsMetadataIR;
854
2012
  /**
855
- * Load `&lt;projectRoot>/lunora/schema.ts`, find `defineSchema({...})`, and
856
- * return a structural IR. Throws if the file or call cannot be found.
857
- */
858
- declare const discoverSchema: (project: Project, schemaPath: string, projectRoot?: string) => SchemaIR;
2013
+ * Which sandbox tools a project imports from `@lunora/agent` (main entry or the
2014
+ * `/sandbox` subpath), detected by NAMED value import. Drives two things:
2015
+ * registering the `sandbox:invoke` dispatcher (either tool) and provisioning the
2016
+ * `BROWSER` wrangler binding (`browserTool` the browser op runs on
2017
+ * `ctx.browser` inside the dispatcher).
2018
+ */
2019
+ interface SandboxUsage {
2020
+ /** `import { browserTool } from "@lunora/agent"` (or `/sandbox`) appears in `lunora/`. */
2021
+ usesSandboxBrowser: boolean;
2022
+ /** `import { containerTool } from "@lunora/agent"` (or `/sandbox`) appears in `lunora/`. */
2023
+ usesSandboxContainer: boolean;
2024
+ }
2025
+ declare const discoverSandboxUsage: (project: Project, lunoraDirectory: string) => SandboxUsage;
859
2026
  /**
860
- * Aggregate the schema-wide storage-rule metadata the studio's inspector reads:
861
- * every statically-discovered `(bucket, on, prefix, procedure)` entry across all
862
- * `.use(storageRules(...))` chains. Only the builder form can declare rules, so
863
- * bare-factory procedures contribute nothing.
864
- */
2027
+ * Load `&lt;projectRoot>/lunora/schema.ts`, find `defineSchema({...})`, and
2028
+ * return a structural IR. Throws if the file or call cannot be found.
2029
+ */
2030
+ declare const discoverSchema: (project: Project, schemaPath: string, projectRoot?: string) => SchemaIR;
2031
+ /** The only file shapes may be declared in — mirrors `lunora/queues.ts`. */
2032
+ declare const SHAPES_FILENAME = "shapes.ts";
2033
+ /**
2034
+ * Discover every replication shape the project declares: exported
2035
+ * `defineShape()` calls in `lunora/shapes.ts`. Returns `[]` when the file
2036
+ * doesn't exist. Only the export binding is lifted — the runtime object carries
2037
+ * the authoritative `table`/`columns`/`compileWhere`, so codegen never
2038
+ * evaluates the predicate.
2039
+ */
2040
+ declare const discoverShapes: (project: Project, lunoraDirectory: string) => ShapeIR[];
2041
+ /**
2042
+ * Aggregate the schema-wide storage-rule metadata the studio's inspector reads:
2043
+ * every statically-discovered `(bucket, on, prefix, procedure)` entry across all
2044
+ * `.use(storageRules(...))` chains. Only the builder form can declare rules, so
2045
+ * bare-factory procedures contribute nothing.
2046
+ */
865
2047
  declare const discoverStorageRulesMetadata: (project: Project, lunoraDirectory: string) => StorageRulesMetadataIR;
866
2048
  /** The only file workflows may be declared in — mirrors `lunora/containers.ts`. */
867
2049
  declare const WORKFLOWS_FILENAME = "workflows.ts";
868
2050
  /**
869
- * Discover every workflow the project declares: exported `defineWorkflow()`
870
- * calls in `lunora/workflows.ts`. Returns `[]` when the file doesn't exist. The
871
- * only wrangler-relevant literal is the optional `name` override; the workflow
872
- * body is runtime-only, so codegen never evaluates it.
873
- */
2051
+ * Discover every workflow the project declares: exported `defineWorkflow()`
2052
+ * calls in `lunora/workflows.ts`. Returns `[]` when the file doesn't exist. The
2053
+ * only wrangler-relevant literal is the optional `name` override; the workflow
2054
+ * body is runtime-only, so codegen never evaluates it.
2055
+ */
874
2056
  declare const discoverWorkflows: (project: Project, lunoraDirectory: string) => WorkflowIR[];
875
2057
  declare const GENERATED_HEADER = "// GENERATED by @lunora/codegen — do not edit.\n// Run `lunora codegen` to regenerate.\n\n";
876
2058
  /** Emit `_generated/dataModel.ts` — `Doc&lt;"name">` + `Id&lt;"name">` for every table. */
877
2059
  declare const emitDataModel: (schema: SchemaIR, useUmbrella?: boolean) => string;
878
2060
  /**
879
- * Emit `_generated/api.ts` — the typed `api.*` registry (public functions), the
880
- * `internal.*` registry, and (when the project declares workflows) the typed
881
- * `workflows.*` reference object. `api`/`internal` are the same `anyApi` proxy
882
- * at runtime (the `__lunoraRef` is identical); visibility is enforced
883
- * server-side at dispatch, not in the reference. Splitting the *types* keeps
884
- * internal functions off the client-facing `api` surface.
885
- */
886
- declare const emitApi: (functions: ReadonlyArray<FunctionIR>, workflows?: ReadonlyArray<WorkflowIR>, useUmbrella?: boolean) => string;
887
- /**
888
- * Emit `_generated/seed.ts` — a project-bound `createSeedClient` with this
889
- * schema's `InsertModel` and runtime schema pre-applied, so a test or script
890
- * calls `createSeedClient({ seed: 1 }).users(5)` with full column types and no
891
- * manual wiring. The runtime schema is the default export of `lunora/schema.ts`
892
- * (the same import the generated ShardDO uses).
893
- *
894
- * Returns `""` when `@lunora/seed` is not a declared dependency, so projects
895
- * that don't use it keep a clean `_generated/` and never import the package.
896
- */
2061
+ * Emit `_generated/api.ts` — the typed `api.*` registry (public functions), the
2062
+ * `internal.*` registry, and (when the project declares them) the typed
2063
+ * `workflows.*` / `agents.*` scheduler-target reference objects. `api`/`internal` are the same `anyApi` proxy
2064
+ * at runtime (the `__lunoraRef` is identical); visibility is enforced
2065
+ * server-side at dispatch, not in the reference. Splitting the *types* keeps
2066
+ * internal functions off the client-facing `api` surface.
2067
+ */
2068
+ interface EmitApiOptions {
2069
+ agents?: ReadonlyArray<AgentIR>;
2070
+ functions: ReadonlyArray<FunctionIR>;
2071
+ /** Typed REST routes; only `.stream()` (SSE) routes emit a `httpStreams.*` reference. */
2072
+ httpRoutes?: ReadonlyArray<HttpRouteIR>;
2073
+ useUmbrella?: boolean;
2074
+ workflows?: ReadonlyArray<WorkflowIR>;
2075
+ }
2076
+ declare const emitApi: (options: EmitApiOptions) => string;
2077
+ /**
2078
+ * Emit `_generated/collections.ts` — a typed TanStack DB binding per `defineShape`
2079
+ * in `lunora/shapes.ts` (the local-first partial-replication surface).
2080
+ *
2081
+ * Each shape emits **two** entry points.
2082
+ *
2083
+ * `&lt;shape>CollectionOptions(options)` is the composable form: it returns the full
2084
+ * `LunoraCollectionOptions` — `config` for `createCollection`, plus `checkpoints`
2085
+ * (which `bindMutators` gates optimistic overlays on) and `scope`. This is what an app
2086
+ * with custom mutators needs, and what the old single-factory form made impossible: it
2087
+ * built the collection internally and dropped `checkpoints` on the floor, so there was
2088
+ * no way to wire mutators to the collection codegen produced.
2089
+ *
2090
+ * `&lt;shape>Collection(options)` is the convenience form for a read-only collection: it
2091
+ * returns `{ checkpoints, collection, scope }` rather than a bare `Collection`, so the
2092
+ * sync controls stay reachable even from the short path.
2093
+ *
2094
+ * Both are typed: `args` comes from the shape's own validators (a parameterless
2095
+ * shape takes none), rows resolve to `Doc&lt;"table">` when the shape names its table
2096
+ * with a literal, and `shardKey` / `getKey` / `load` / `onError` / `checkpoints` are
2097
+ * all threadable — a sharded table needs `shardKey` for its watermark to land in the
2098
+ * right bucket, and a server-minted `_id` that differs from the app's natural key
2099
+ * needs `getKey`.
2100
+ *
2101
+ * Returns `""` (so `writeIfPresent` skips the file) unless the project both
2102
+ * declares shapes AND installs `@lunora/db` — the add-on that ships
2103
+ * `lunoraCollectionOptions`. `@lunora/db` stays a scoped install even under the
2104
+ * `lunorash` umbrella (an opt-in add-on, like `@lunora/auth`), so its import is
2105
+ * always `@lunora/db/collections`; only the in-umbrella `@lunora/client` import
2106
+ * is remapped to `lunorash/client`.
2107
+ */
2108
+ declare const emitCollections: (shapes: ReadonlyArray<ShapeIR>, hasDatabase: boolean, useUmbrella?: boolean) => string;
897
2109
  interface EmitServerOptions {
2110
+ /** Agents declared via `defineAgent` exports — wires the typed `ctx.agents` producers onto Mutation/Action contexts. */
2111
+ agents?: ReadonlyArray<AgentIR>;
898
2112
  containers?: ReadonlyArray<ContainerIR>;
2113
+ /**
2114
+ * The single `defineEnv(...)` contract declared in `lunora/env.ts`. When
2115
+ * present, `ctx.env` is typed as the validated `InferEnv` shape (recovered
2116
+ * via `ReturnType` over the accessor's `typeof`). `undefined` leaves `ctx.env`
2117
+ * the base optional binding record — byte-identical to today.
2118
+ */
2119
+ env?: EnvIR;
2120
+ /**
2121
+ * A `lunora/` source reads `ctx.access` — wires the verified Cloudflare Access
2122
+ * facade (`@lunora/cloudflare-access/context`) onto every ctx. Distinct from
2123
+ * `emitApp`'s `hasAccess` (which gates the worker's `.access()` resolveIdentity
2124
+ * method); this one gates the per-request `ctx.access` read surface.
2125
+ */
2126
+ hasAccessFacade?: boolean;
899
2127
  hasAi?: boolean;
900
- /** A `lunora/` source uses `@lunora/analytics` / `ctx.analytics` — wires the write helper onto every ctx. */
2128
+ /** A `lunora/` source uses `@lunora/bindings/analytics` / `ctx.analytics` — wires the write helper onto every ctx. */
901
2129
  hasAnalytics?: boolean;
902
2130
  /** A `lunora/` source uses `@lunora/browser` / `ctx.browser` — wires `ctx.browser` onto ActionCtx only. */
903
2131
  hasBrowser?: boolean;
2132
+ /** The project declares `lunora/flags.ts` — wires `ctx.flags` (OpenFeature) onto every ctx. */
2133
+ hasFlags?: boolean;
904
2134
  /** A `lunora/` source uses `@lunora/hyperdrive` / `ctx.sql` — wires `ctx.sql` onto ActionCtx only. */
905
2135
  hasHyperdrive?: boolean;
906
- /** A `lunora/` source uses `@lunora/images` / `ctx.images` — wires `ctx.images` onto ActionCtx only. */
2136
+ /** A `lunora/` source uses `@lunora/bindings/images` / `ctx.images` — wires `ctx.images` onto ActionCtx only. */
907
2137
  hasImages?: boolean;
908
- /** A `lunora/` source uses `@lunora/kv` / `ctx.kv` — wires `ctx.kv` onto every ctx. */
2138
+ /** A `lunora/` source uses `@lunora/bindings/kv` / `ctx.kv` — wires `ctx.kv` onto every ctx. */
909
2139
  hasKv?: boolean;
2140
+ /** The project declares `lunora/notify.ts` — wires `ctx.notify` + its `ctx.push` alias (`@lunora/notify`) onto every ctx. */
2141
+ hasNotify?: boolean;
910
2142
  hasPayments?: boolean;
911
- /** A `lunora/` source uses `@lunora/pipelines` / `ctx.pipelines` — wires `ctx.pipelines` onto ActionCtx only. */
2143
+ /** A `lunora/` source uses `@lunora/bindings/pipelines` / `ctx.pipelines` — wires `ctx.pipelines` onto ActionCtx only. */
912
2144
  hasPipelines?: boolean;
913
- /** A `lunora/` source uses `@lunora/r2sql` / `ctx.r2sql` — wires `ctx.r2sql` onto ActionCtx only. */
2145
+ /** A `lunora/` source uses `@lunora/bindings/r2sql` / `ctx.r2sql` — wires `ctx.r2sql` onto ActionCtx only. */
914
2146
  hasR2sql?: boolean;
2147
+ /** A `lunora/` source uses `@lunora/x402/pay` / `ctx.x402` — wires the agent-wallet pay rail onto ActionCtx only. */
2148
+ hasX402?: boolean;
2149
+ /**
2150
+ * The single `defineIdentity(...)` claim contract declared in
2151
+ * `lunora/identity.ts` (Plan 080). When present, `ctx.auth.getIdentity()`,
2152
+ * the RLS policy `ctx.auth.identity`, and the shard-authorization hooks
2153
+ * narrow to the declared shape (recovered via `InferIdentity` over the
2154
+ * contract's `typeof`). `undefined` keeps the identity an untyped bag —
2155
+ * byte-identical to today.
2156
+ */
2157
+ identity?: IdentityIR;
2158
+ /** Queues declared via `defineQueue` exports — wires the typed `ctx.queues` producers onto Mutation/Action contexts. */
2159
+ queues?: ReadonlyArray<QueueIR>;
915
2160
  schema?: SchemaIR;
916
2161
  storageRuleBuckets?: ReadonlyArray<string>;
917
2162
  /** The project depends on the `lunora` umbrella — import base packages via its subpaths. */
918
2163
  useUmbrella?: boolean;
919
2164
  workflows?: ReadonlyArray<WorkflowIR>;
920
2165
  }
921
- declare const emitServer: ({
922
- containers,
923
- hasAi,
924
- hasAnalytics,
925
- hasBrowser,
926
- hasHyperdrive,
927
- hasImages,
928
- hasKv,
929
- hasPayments,
930
- hasPipelines,
931
- hasR2sql,
932
- schema,
933
- storageRuleBuckets,
934
- useUmbrella,
935
- workflows
936
- }?: EmitServerOptions) => string;
937
- declare const emitFunctions: (functions: ReadonlyArray<FunctionIR>, migrations?: ReadonlyArray<MigrationIR>) => string;
938
- /**
939
- * Storage-column map per table for the file browser: `{ table: [field, …] }` for
940
- * every field declared `v.storage(...)` (unwrapping `v.optional(...)`). The
941
- * generated shard hands this to the base `storageColumns` hook so the admin
942
- * `storageReferences` read can join R2 objects back to the rows that own them
943
- * (and flag orphans objects no row references). Only scalar storage columns
944
- * are emitted; an array-of-storage field can't be matched by an equality scan,
945
- * so it is skipped here.
946
- */
947
- /**
948
- * Emit `_generated/containers.ts` one container-enabled Durable Object class
949
- * per `defineContainer` export, each a thin subclass of `LunoraContainer`
950
- * (`@lunora/container/do`) constructed with the user's definition object. The
951
- * worker entry must re-export these classes: wrangler requires every
952
- * `containers[].class_name` to be exported by the deployed worker. Returns ""
953
- * when the project declares no containers (the file is not written then).
954
- */
955
- declare const emitContainers: (containers: ReadonlyArray<ContainerIR>) => string;
956
- /**
957
- * Emit `_generated/workflows.ts` — one `WorkflowEntrypoint` class per
958
- * `defineWorkflow` export, each a thin subclass of `LunoraWorkflow`
959
- * (`@lunora/workflow/do`) constructed with the user's definition object. The
960
- * worker entry must re-export these classes: wrangler requires every
961
- * `workflows[].class_name` to be exported by the deployed worker. Returns ""
962
- * when the project declares no workflows (the file is not written then).
963
- */
2166
+ declare const emitServer: ({ agents, containers, env, hasAccessFacade, hasAi, hasAnalytics, hasBrowser, hasFlags, hasHyperdrive, hasImages, hasKv, hasNotify, hasPayments, hasPipelines, hasR2sql, hasX402, identity, queues, schema, storageRuleBuckets, useUmbrella, workflows }?: EmitServerOptions) => string;
2167
+ interface EmitFunctionsOptions {
2168
+ agents?: ReadonlyArray<AgentIR>;
2169
+ functions: ReadonlyArray<FunctionIR>;
2170
+ migrations?: ReadonlyArray<MigrationIR>;
2171
+ mutators?: ReadonlyArray<MutatorIR>;
2172
+ shapes?: ReadonlyArray<ShapeIR>;
2173
+ /** Import of a sandbox tool (`browserTool`/`containerTool`) auto-registers the `sandbox:invoke` action. */
2174
+ usesSandbox?: boolean;
2175
+ useUmbrella?: boolean;
2176
+ }
2177
+ declare const emitFunctions: (options: EmitFunctionsOptions) => string;
2178
+ /**
2179
+ * Emit `_generated/containers.ts` — one container-enabled Durable Object class
2180
+ * per `defineContainer` export, each a thin subclass of `LunoraContainer`
2181
+ * (`@lunora/container/do`) constructed with the user's definition object. The
2182
+ * worker entry must re-export these classes: wrangler requires every
2183
+ * `containers[].class_name` to be exported by the deployed worker. Returns ""
2184
+ * when the project declares no containers (the file is not written then).
2185
+ */
2186
+ declare const emitContainers: (containers: ReadonlyArray<ContainerIR>, jurisdiction?: JurisdictionIR) => string;
2187
+ /**
2188
+ * Emit `_generated/workflows.ts`one `WorkflowEntrypoint` class per
2189
+ * `defineWorkflow` export, each a thin subclass of `LunoraWorkflow`
2190
+ * (`@lunora/workflow/do`) constructed with the user's definition object. The
2191
+ * worker entry must re-export these classes: wrangler requires every
2192
+ * `workflows[].class_name` to be exported by the deployed worker. Returns ""
2193
+ * when the project declares no workflows (the file is not written then).
2194
+ */
964
2195
  declare const emitWorkflows: (workflows: ReadonlyArray<WorkflowIR>) => string;
2196
+ /**
2197
+ * Emit `_generated/agents.ts` — one `WorkflowEntrypoint` class per `defineAgent`
2198
+ * export, each a thin subclass of `LunoraWorkflow` (`@lunora/workflow/do`)
2199
+ * constructed with the compiled agent tool-loop (`compileAgentWorkflow`). Like
2200
+ * `_generated/workflows.ts`, the worker entry must re-export these classes:
2201
+ * wrangler requires every `workflows[].class_name` to be exported by the
2202
+ * deployed worker. Returns "" when the project declares no agents (the file is
2203
+ * not written then).
2204
+ */
2205
+ declare const emitAgents: (agents: ReadonlyArray<AgentIR>) => string;
965
2206
  interface EmitShardOptions {
966
2207
  advisories?: ReadonlyArray<Finding>;
2208
+ /** Agents declared via `defineAgent` exports in `lunora/agents.ts` — wires the typed `ctx.agents` producers. */
2209
+ agents?: ReadonlyArray<AgentIR>;
967
2210
  containers?: ReadonlyArray<ContainerIR>;
2211
+ /** The single `defineEnv(...)` contract declared in `lunora/env.ts` — applies the accessor to the worker `env` to populate `ctx.env`. */
2212
+ env?: EnvIR;
2213
+ /** Statically-discovered `ctx.flags.&lt;type>("key")` reads — the studio Flags page + reactive evaluation iterate these. */
2214
+ flagKeys?: ReadonlyArray<{
2215
+ key: string;
2216
+ type: "boolean" | "number" | "object" | "string";
2217
+ }>;
2218
+ /** A `lunora/` source reads `ctx.access` — wires the verified Cloudflare Access facade onto every ctx. */
2219
+ hasAccessFacade?: boolean;
968
2220
  hasAi?: boolean;
969
2221
  /** A `lunora/` source reads `ctx.analytics` — wires the Analytics Engine write helper onto every ctx. */
970
2222
  hasAnalytics?: boolean;
971
2223
  /** A `lunora/` source reads `ctx.browser` — wires `ctx.browser` onto the ActionCtx only. */
972
2224
  hasBrowser?: boolean;
2225
+ /** The project declares `lunora/flags.ts` — wires `ctx.flags` (OpenFeature) onto every ctx. */
2226
+ hasFlags?: boolean;
973
2227
  /** A `lunora/` source reads `ctx.sql` (Hyperdrive) — wires `ctx.sql` onto the ActionCtx only. */
974
2228
  hasHyperdrive?: boolean;
975
2229
  /** A `lunora/` source reads `ctx.images` — wires `ctx.images` onto the ActionCtx only. */
976
2230
  hasImages?: boolean;
977
2231
  /** A `lunora/` source reads `ctx.kv` — wires `ctx.kv` onto every ctx. */
978
2232
  hasKv?: boolean;
2233
+ /** The project declares `lunora/notify.ts` — wires `ctx.notify` + its `ctx.push` alias (`@lunora/notify`) onto every ctx. */
2234
+ hasNotify?: boolean;
979
2235
  hasPayments?: boolean;
2236
+ /** A `lunora/` source reads `ctx.pipelines` — wires `ctx.pipelines` onto the ActionCtx only. */
2237
+ hasPipelines?: boolean;
980
2238
  /** A `lunora/` source reads `ctx.r2sql` (R2 SQL) — wires `ctx.r2sql` onto the ActionCtx only. */
981
2239
  hasR2sql?: boolean;
2240
+ /** A `lunora/` source reads `ctx.x402` — wires the agent-wallet pay rail onto the ActionCtx only. */
2241
+ hasX402?: boolean;
982
2242
  maskMetadata?: MaskMetadataIR;
2243
+ /** Custom mutators declared via `defineMutator` in `lunora/mutators.ts` — wires the `isCustomMutator` push-protocol override. */
2244
+ mutators?: ReadonlyArray<MutatorIR>;
2245
+ /** Queues declared via `defineQueue` exports in `lunora/queues.ts` — wires the typed `ctx.queues` producers. */
2246
+ queues?: ReadonlyArray<QueueIR>;
983
2247
  rlsMetadata?: RlsMetadataIR;
984
2248
  schema: SchemaIR;
2249
+ /** Replication shapes declared via `defineShape` in `lunora/shapes.ts` — wires the `resolveShape` subscription override. */
2250
+ shapes?: ReadonlyArray<ShapeIR>;
985
2251
  storageRules?: StorageRulesMetadataIR;
986
2252
  studioFeatures?: StudioFeaturesResult;
987
2253
  /** The project depends on the `lunora` umbrella — import base packages via its subpaths. */
988
2254
  useUmbrella?: boolean;
989
2255
  workflows?: ReadonlyArray<WorkflowIR>;
990
2256
  }
991
- declare const emitShard: ({
992
- advisories,
993
- containers,
994
- hasAi,
995
- hasAnalytics,
996
- hasBrowser,
997
- hasHyperdrive,
998
- hasImages,
999
- hasKv,
1000
- hasPayments,
1001
- hasR2sql,
1002
- maskMetadata,
1003
- rlsMetadata,
1004
- schema,
1005
- storageRules,
1006
- studioFeatures,
1007
- useUmbrella,
1008
- workflows
1009
- }: EmitShardOptions) => string;
1010
- /**
1011
- * Emit drizzle `sqliteTable` definitions for the project schema, split into
1012
- * `global` (D1-backed) and `shard` (DO-SQLite-backed) buckets. Tables marked
1013
- * `.global()` go in the global file; everything else (default root + `.shardBy()`)
1014
- * goes in the shard file.
1015
- *
1016
- * `searchIndexes` are intentionally not emitted — drizzle has no `sqliteTable`
1017
- * abstraction for FTS5 virtual tables. FTS plumbing is handled by the runtime
1018
- * outside of drizzle.
1019
- */
2257
+ declare const emitShard: ({ advisories, agents, containers, env, flagKeys, hasAccessFacade, hasAi, hasAnalytics, hasBrowser, hasFlags, hasHyperdrive, hasImages, hasKv, hasNotify, hasPayments, hasPipelines, hasR2sql, hasX402, maskMetadata, mutators, queues, rlsMetadata, schema, shapes, storageRules, studioFeatures, useUmbrella, workflows }: EmitShardOptions) => string;
2258
+ /**
2259
+ * Emit drizzle `sqliteTable` definitions for the project schema, split into
2260
+ * `global` (D1-backed) and `shard` (DO-SQLite-backed) buckets. Tables marked
2261
+ * `.global()` go in the global file; everything else (default root + `.shardBy()`)
2262
+ * goes in the shard file.
2263
+ *
2264
+ * `searchIndexes` are intentionally not emitted — drizzle has no `sqliteTable`
2265
+ * abstraction for FTS5 virtual tables. FTS plumbing is handled by the runtime
2266
+ * outside of drizzle.
2267
+ */
1020
2268
  declare const emitDrizzleSchema: (schema: SchemaIR, useUmbrella?: boolean) => {
1021
2269
  global: string;
1022
2270
  shard: string;
1023
2271
  };
1024
2272
  /**
1025
- * Emit `_generated/crons.ts` from the discovered cron jobs.
1026
- *
1027
- * `LUNORA_CRON_TRIGGERS` is the deduplicated schedule array — what lands in
1028
- * wrangler's `triggers.crons` (the vite plugin reconciles it into
1029
- * `wrangler.jsonc`, and {@link emitWranglerCronTriggers} renders the same list
1030
- * for the CLI / docs).
1031
- *
1032
- * `LUNORA_CRONS` is the dispatcher map keyed by cron expression, each value a
1033
- * list of `{ name, functionPath, args }`. Cloudflare's `scheduled()` handler
1034
- * receives only the cron string, so multiple jobs sharing one expression must
1035
- * all fire — hence a list per key rather than a single entry.
1036
- *
1037
- * Jobs arrive pre-sorted by name (deterministic output); the trigger array
1038
- * preserves first-seen order of distinct expressions.
1039
- *
1040
- * Cloudflare caps a Worker at **3 Cron Triggers** (i.e. 3 distinct cron
1041
- * expressions). Because the dispatcher fires every job sharing an expression,
1042
- * many jobs can ride a single trigger — only the count of *distinct* schedules
1043
- * matters. `lunora codegen` warns when that count exceeds the limit; for
1044
- * finer-grained scheduling use Durable Object alarms (`@lunora/scheduler`),
1045
- * which have no such cap.
1046
- */
2273
+ * Emit `_generated/crons.ts` from the discovered cron jobs.
2274
+ *
2275
+ * `LUNORA_CRON_TRIGGERS` is the deduplicated schedule array — what lands in
2276
+ * wrangler's `triggers.crons` (the vite plugin reconciles it into
2277
+ * `wrangler.jsonc`, and {@link emitWranglerCronTriggers} renders the same list
2278
+ * for the CLI / docs).
2279
+ *
2280
+ * `LUNORA_CRONS` is the dispatcher map keyed by cron expression, each value a
2281
+ * list of `{ name, functionPath, args }`. Cloudflare's `scheduled()` handler
2282
+ * receives only the cron string, so multiple jobs sharing one expression must
2283
+ * all fire — hence a list per key rather than a single entry.
2284
+ *
2285
+ * Jobs arrive pre-sorted by name (deterministic output); the trigger array
2286
+ * preserves first-seen order of distinct expressions.
2287
+ *
2288
+ * Cloudflare caps a Worker at **3 Cron Triggers** (i.e. 3 distinct cron
2289
+ * expressions). Because the dispatcher fires every job sharing an expression,
2290
+ * many jobs can ride a single trigger — only the count of *distinct* schedules
2291
+ * matters. `lunora codegen` warns when that count exceeds the limit; for
2292
+ * finer-grained scheduling use Durable Object alarms (`@lunora/scheduler`),
2293
+ * which have no such cap.
2294
+ */
1047
2295
  declare const emitCrons: (crons: ReadonlyArray<CronJobIR>) => string;
1048
2296
  /**
1049
- * Render `_generated/vectors.ts` — the static registry of every vector index
1050
- * declared in `schema.ts` (inline `.vectorize()` columns + standalone
1051
- * `defineVectorIndex()` definitions).
1052
- *
1053
- * Cloudflare Vectorize exposes no way to enumerate an account's indexes at
1054
- * runtime — a binding can `describe()` itself but the worker can't ask "which
1055
- * indexes exist". So this generated array is the source of truth the studio's
1056
- * vector browser lists, and the worker's admin route pairs each entry with its
1057
- * live `describe()` stats. Entries are sorted by name for deterministic output.
1058
- */
2297
+ * Render `_generated/vectors.ts` — the static registry of every vector index
2298
+ * declared in `schema.ts` (inline `.vectorize()` columns + standalone
2299
+ * `defineVectorIndex()` definitions).
2300
+ *
2301
+ * Cloudflare Vectorize exposes no way to enumerate an account's indexes at
2302
+ * runtime — a binding can `describe()` itself but the worker can't ask "which
2303
+ * indexes exist". So this generated array is the source of truth the studio's
2304
+ * vector browser lists, and the worker's admin route pairs each entry with its
2305
+ * live `describe()` stats. Entries are sorted by name for deterministic output.
2306
+ */
1059
2307
  declare const emitVectors: (vectorIndexes: ReadonlyArray<VectorIndexIR>) => string;
1060
2308
  /**
1061
- * Render the deduplicated cron schedules as a JSON fragment suitable for
1062
- * splicing into `wrangler.jsonc`'s `triggers.crons`. The vite plugin uses this
1063
- * (plus the parsed wrangler config) to reconcile generated triggers without the
1064
- * user hand-editing the file.
1065
- */
2309
+ * Render the deduplicated cron schedules as a JSON fragment suitable for
2310
+ * splicing into `wrangler.jsonc`'s `triggers.crons`. The vite plugin uses this
2311
+ * (plus the parsed wrangler config) to reconcile generated triggers without the
2312
+ * user hand-editing the file.
2313
+ */
1066
2314
  declare const emitWranglerCronTriggers: (crons: ReadonlyArray<CronJobIR>) => string[];
1067
2315
  /** Which capability methods the generated `defineApp` builder exposes — one flag per package-backed feature the app actually uses. */
1068
2316
  interface EmitAppOptions {
2317
+ /**
2318
+ * Inbound-email agents (`defineAgent({ onEmail })`) → wire the worker's
2319
+ * top-level `email()` handler to `dispatchAgentEmail(...)` (from
2320
+ * `@lunora/agent/inbound`), so received mail starts a durable run. Empty/absent
2321
+ * ⇒ no wiring, byte-identical output for email-free (and agent-free) projects.
2322
+ */
2323
+ emailAgents?: ReadonlyArray<{
2324
+ bindingName: string;
2325
+ exportName: string;
2326
+ }>;
2327
+ /** App depends on `@lunora/cloudflare-access` → emit `.access()` (wire the Cloudflare Access `resolveIdentity`, composed ahead of `@lunora/auth` when both are present). */
2328
+ hasAccess: boolean;
1069
2329
  /** App uses `@lunora/ai` / `ctx.ai` → emit `.ai()` (override the Workers AI binding backing `ctx.ai`). */
1070
2330
  hasAi: boolean;
1071
- /** App uses `@lunora/analytics` / `ctx.analytics` → emit `.analytics()` (override the dataset backing `ctx.analytics`). */
2331
+ /** App uses `@lunora/bindings/analytics` / `ctx.analytics` → emit `.analytics()` (override the dataset backing `ctx.analytics`). */
1072
2332
  hasAnalytics: boolean;
1073
2333
  /** App depends on `@lunora/auth` → emit `.auth()` + the lazy build/migrate dance. */
1074
2334
  hasAuth: boolean;
@@ -1082,13 +2342,17 @@ interface EmitAppOptions {
1082
2342
  hasHyperdrive: boolean;
1083
2343
  /** Schema declares **Hyperdrive-backed** `.global({ backend: "hyperdrive" })` tables → emit `.hyperdriveGlobal()` (reactive Postgres/MySQL ctx-db over Hyperdrive). */
1084
2344
  hasHyperdriveGlobal: boolean;
1085
- /** App uses `@lunora/images` / `ctx.images` → emit `.images()`. */
2345
+ /** App uses `@lunora/bindings/images` / `ctx.images` → emit `.images()`. */
1086
2346
  hasImages: boolean;
1087
- /** App uses `@lunora/kv` / `ctx.kv` → emit `.kv()`. */
2347
+ /** App uses `@lunora/bindings/kv` / `ctx.kv` → emit `.kv()`. */
1088
2348
  hasKv: boolean;
2349
+ /** App declares `lunora/notify.ts` (`@lunora/notify`) → wire `options.notifySubscriptionStore` so the studio Notifications page can read registered devices. */
2350
+ hasNotify: boolean;
1089
2351
  /** App uses `@lunora/payment` / `ctx.payments` → emit `.payment()`. */
1090
2352
  hasPayments: boolean;
1091
- /** App uses `@lunora/r2sql` / `ctx.r2sql` → emit `.r2sql()`. */
2353
+ /** App declares push queues (`defineQueue`)wire `LUNORA_QUEUE_REGISTRY` into the worker's `queue()` consumer entry. */
2354
+ hasQueue: boolean;
2355
+ /** App uses `@lunora/bindings/r2sql` / `ctx.r2sql` → emit `.r2sql()`. */
1092
2356
  hasR2sql: boolean;
1093
2357
  /** App imports `@lunora/scheduler` / declares crons → emit `.scheduler()`. */
1094
2358
  hasScheduler: boolean;
@@ -1098,28 +2362,45 @@ interface EmitAppOptions {
1098
2362
  hasVectors: boolean;
1099
2363
  /** App declares Cloudflare Workflows (`defineWorkflow`) → wire `options.workflowsClient` so the studio's workflow-instance proxy can reach the CF REST API. */
1100
2364
  hasWorkflow: boolean;
2365
+ /** App uses `@lunora/x402/pay` / `ctx.x402` → emit `.x402()` (wire the agent-wallet pay rail). */
2366
+ hasX402: boolean;
2367
+ /** The single `defineIdentity(...)` contract in `lunora/identity.ts` (Plan 080) → import it as a VALUE and wire `options.identity`, so the runtime trust boundary validates every resolved identity before it becomes `ctx.auth`. `undefined` ⇒ no wiring, byte-identical output. */
2368
+ identity?: IdentityIR;
2369
+ /** Schema declares `.jurisdiction("…")` → pin every DO the worker reaches (shards, fan-out, scheduler, containers) to the Cloudflare data-residency jurisdiction. */
2370
+ jurisdiction?: JurisdictionIR;
1101
2371
  /** Project depends on the unscoped `lunorash` umbrella → import the runtime via `lunorash/runtime` instead of `@lunora/runtime`. */
1102
2372
  useUmbrella: boolean;
2373
+ /**
2374
+ * Voice-enabled agents (`defineAgent({ voice: … })`) → wire
2375
+ * `options.voiceAgents`, mapping each agent's export name to its `VOICE_*`
2376
+ * Durable Object namespace binding so the runtime exposes
2377
+ * `/_lunora/voice/&lt;exportName>`. Empty/absent ⇒ no wiring, byte-identical
2378
+ * output for voice-free (and agent-free) projects.
2379
+ */
2380
+ voiceAgents?: ReadonlyArray<{
2381
+ bindingName: string;
2382
+ exportName: string;
2383
+ }>;
1103
2384
  /** An OpenAPI spec is emitted (`openapi.ts`) → wire `openApiSpec` into the worker. */
1104
2385
  wantsOpenApi: boolean;
1105
2386
  /** An OpenRPC spec is emitted (`openrpc.ts`) → wire `openRpcSpec` into the worker. */
1106
2387
  wantsOpenRpc: boolean;
1107
2388
  }
1108
2389
  /**
1109
- * Emit `_generated/app.ts` — a fluent, feature-specialized worker-composition
1110
- * builder. Only the methods for capabilities THIS app uses are emitted, so the
1111
- * builder's type surface (IntelliSense) lists exactly what can be configured.
1112
- *
1113
- * Each capability declaration is fanned into BOTH runtime surfaces: the DO-side
1114
- * `createShardDO(...)` factory that backs `ctx.*`, and the worker-side
1115
- * `createWorker(...)` options that back the studio/admin endpoints — so storage
1116
- * / scheduler / global are declared once instead of twice. The builder is pure
1117
- * sugar over the public `createWorker` / `createShardDO`; both stay usable.
1118
- *
1119
- * Lives in generated code (not `@lunora/runtime`, which is dependency-free) so
1120
- * it can import the add-on packages the app installed (`@lunora/auth`,
1121
- * `@lunora/storage`, …) directly.
1122
- */
2390
+ * Emit `_generated/app.ts` — a fluent, feature-specialized worker-composition
2391
+ * builder. Only the methods for capabilities THIS app uses are emitted, so the
2392
+ * builder's type surface (IntelliSense) lists exactly what can be configured.
2393
+ *
2394
+ * Each capability declaration is fanned into BOTH runtime surfaces: the DO-side
2395
+ * `createShardDO(...)` factory that backs `ctx.*`, and the worker-side
2396
+ * `createWorker(...)` options that back the studio/admin endpoints — so storage
2397
+ * / scheduler / global are declared once instead of twice. The builder is pure
2398
+ * sugar over the public `createWorker` / `createShardDO`; both stay usable.
2399
+ *
2400
+ * Lives in generated code (not `@lunora/runtime`, which is dependency-free) so
2401
+ * it can import the add-on packages the app installed (`@lunora/auth`,
2402
+ * `@lunora/storage`, …) directly.
2403
+ */
1123
2404
  declare const emitApp: (options: EmitAppOptions) => string;
1124
2405
  /** Inputs the OpenAPI emitter needs from a codegen run. */
1125
2406
  interface OpenApiEmitInput {
@@ -1129,40 +2410,40 @@ interface OpenApiEmitInput {
1129
2410
  version?: string;
1130
2411
  }
1131
2412
  /**
1132
- * Emit an OpenAPI 3.1.0 document covering both Lunora function surfaces.
1133
- *
1134
- * `httpRouter()` typed REST routes become real `paths` keyed by their method +
1135
- * URL, with query/path parameters and JSON request bodies derived from their
1136
- * `v.*` validators, and a response schema from `.output()` when declared.
1137
- *
1138
- * RPC `query`/`mutation`/`action` functions become one operation each on
1139
- * `POST /_lunora/rpc` (disambiguated by a `#functionPath` path fragment), with a
1140
- * requestBody pinning `functionPath` + typed `args`. `internal`/`stream`
1141
- * functions are excluded (unreachable / not invocable on the external RPC path).
1142
- *
1143
- * Operations are grouped into `tags` by file namespace, and every operation
1144
- * references a reusable `LunoraError` error-response component enumerating the
1145
- * standard error codes. Borrows oRPC's per-procedure-operation + tag-grouping +
1146
- * internal-filtering structure; the JSON Schema dialect matches `@lunora/values`
1147
- * (Draft 2020-12). Returns the document as a plain object (the single source of
1148
- * truth `emitOpenApi` stringifies and `emitOpenApiModule` inlines, so the
1149
- * `.json` and `.ts` artifacts can never drift).
1150
- */
2413
+ * Emit an OpenAPI 3.1.0 document covering both Lunora function surfaces.
2414
+ *
2415
+ * `httpRouter()` typed REST routes become real `paths` keyed by their method +
2416
+ * URL, with query/path parameters and JSON request bodies derived from their
2417
+ * `v.*` validators, and a response schema from `.output()` when declared.
2418
+ *
2419
+ * RPC `query`/`mutation`/`action` functions become one operation each on
2420
+ * `POST /_lunora/rpc` (disambiguated by a `#functionPath` path fragment), with a
2421
+ * requestBody pinning `functionPath` + typed `args`. `internal`/`stream`
2422
+ * functions are excluded (unreachable / not invocable on the external RPC path).
2423
+ *
2424
+ * Operations are grouped into `tags` by file namespace, and every operation
2425
+ * references a reusable `LunoraError` error-response component enumerating the
2426
+ * standard error codes. Borrows oRPC's per-procedure-operation + tag-grouping +
2427
+ * internal-filtering structure; the JSON Schema dialect matches `@lunora/values`
2428
+ * (Draft 2020-12). Returns the document as a plain object (the single source of
2429
+ * truth `emitOpenApi` stringifies and `emitOpenApiModule` inlines, so the
2430
+ * `.json` and `.ts` artifacts can never drift).
2431
+ */
1151
2432
  declare const buildOpenApiDocument: (input: OpenApiEmitInput) => Record<string, unknown>;
1152
2433
  /**
1153
- * Emit the OpenAPI 3.1 document as a pretty-printed JSON string
1154
- * (`_generated/openapi.json`) — the portable artifact for external tooling.
1155
- */
2434
+ * Emit the OpenAPI 3.1 document as a pretty-printed JSON string
2435
+ * (`_generated/openapi.json`) — the portable artifact for external tooling.
2436
+ */
1156
2437
  declare const emitOpenApi: (input: OpenApiEmitInput) => string;
1157
2438
  /**
1158
- * Emit the OpenAPI document as an importable TS module
1159
- * (`_generated/openapi.ts`) the worker entry imports and passes to
1160
- * `createWorker({ openApiSpec })`. The document object literal is inlined
1161
- * verbatim (same `JSON.stringify` form the `.json` uses), so the `.ts` and
1162
- * `.json` are byte-identical content and regenerate together — closing the gap
1163
- * where a Worker cannot read the JSON file at runtime. `document_` is the object
1164
- * returned by {@link buildOpenApiDocument} (reused, never recomputed).
1165
- */
2439
+ * Emit the OpenAPI document as an importable TS module
2440
+ * (`_generated/openapi.ts`) the worker entry imports and passes to
2441
+ * `createWorker({ openApiSpec })`. The document object literal is inlined
2442
+ * verbatim (same `JSON.stringify` form the `.json` uses), so the `.ts` and
2443
+ * `.json` are byte-identical content and regenerate together — closing the gap
2444
+ * where a Worker cannot read the JSON file at runtime. `document_` is the object
2445
+ * returned by {@link buildOpenApiDocument} (reused, never recomputed).
2446
+ */
1166
2447
  declare const emitOpenApiModule: (document_: Record<string, unknown>) => string;
1167
2448
  /** The OpenRPC dialect version this emitter targets. */
1168
2449
  declare const OPENRPC_VERSION = "1.3.2";
@@ -1173,37 +2454,37 @@ interface OpenRpcEmitInput {
1173
2454
  version?: string;
1174
2455
  }
1175
2456
  /**
1176
- * Emit an OpenRPC 1.x document describing Lunora's JSON-RPC surface.
1177
- *
1178
- * Only the RPC `query`/`mutation`/`action` functions become `methods` — one per
1179
- * function, `name` = `file:fn`. `internal` (off the external RPC path) and
1180
- * `stream` (not invocable over the RPC envelope) are excluded, the same filter
1181
- * the OpenAPI emitter applies. Each method's single `args` param is typed from
1182
- * the function's `v.*` validators (`argsObjectSchema`); `result` is the
1183
- * `.output()` schema when declared, else a best-effort inferred schema. The
1184
- * standard `LunoraError` codes ride along under each method's `errors`.
1185
- *
1186
- * `httpRouter()` typed REST routes are deliberately omitted — OpenRPC is
1187
- * RPC-only and cannot represent REST paths; the OpenAPI document is the spec
1188
- * that covers the REST surface. Methods are sorted by name for stable output.
1189
- * Returns the document as a plain object (the single source of truth
1190
- * `emitOpenRpc` stringifies and `emitOpenRpcModule` inlines, so the `.json` and
1191
- * `.ts` artifacts can never drift).
1192
- */
2457
+ * Emit an OpenRPC 1.x document describing Lunora's JSON-RPC surface.
2458
+ *
2459
+ * Only the RPC `query`/`mutation`/`action` functions become `methods` — one per
2460
+ * function, `name` = `file:fn`. `internal` (off the external RPC path) and
2461
+ * `stream` (not invocable over the RPC envelope) are excluded, the same filter
2462
+ * the OpenAPI emitter applies. Each method's single `args` param is typed from
2463
+ * the function's `v.*` validators (`argsObjectSchema`); `result` is the
2464
+ * `.output()` schema when declared, else a best-effort inferred schema. The
2465
+ * standard `LunoraError` codes ride along under each method's `errors`.
2466
+ *
2467
+ * `httpRouter()` typed REST routes are deliberately omitted — OpenRPC is
2468
+ * RPC-only and cannot represent REST paths; the OpenAPI document is the spec
2469
+ * that covers the REST surface. Methods are sorted by name for stable output.
2470
+ * Returns the document as a plain object (the single source of truth
2471
+ * `emitOpenRpc` stringifies and `emitOpenRpcModule` inlines, so the `.json` and
2472
+ * `.ts` artifacts can never drift).
2473
+ */
1193
2474
  declare const buildOpenRpcDocument: (input: OpenRpcEmitInput) => Record<string, unknown>;
1194
2475
  /**
1195
- * Emit the OpenRPC 1.x document as a pretty-printed JSON string
1196
- * (`_generated/openrpc.json`) — the portable artifact for external tooling.
1197
- */
2476
+ * Emit the OpenRPC 1.x document as a pretty-printed JSON string
2477
+ * (`_generated/openrpc.json`) — the portable artifact for external tooling.
2478
+ */
1198
2479
  declare const emitOpenRpc: (input: OpenRpcEmitInput) => string;
1199
2480
  /**
1200
- * Emit the OpenRPC document as an importable TS module
1201
- * (`_generated/openrpc.ts`) the worker entry imports and passes to
1202
- * `createWorker({ openRpcSpec })`. The document object literal is inlined
1203
- * verbatim (same `JSON.stringify` form the `.json` uses), so the `.ts` and
1204
- * `.json` are byte-identical content and regenerate together. `document_` is
1205
- * the object returned by {@link buildOpenRpcDocument} (reused, never recomputed).
1206
- */
2481
+ * Emit the OpenRPC document as an importable TS module
2482
+ * (`_generated/openrpc.ts`) the worker entry imports and passes to
2483
+ * `createWorker({ openRpcSpec })`. The document object literal is inlined
2484
+ * verbatim (same `JSON.stringify` form the `.json` uses), so the `.ts` and
2485
+ * `.json` are byte-identical content and regenerate together. `document_` is
2486
+ * the object returned by {@link buildOpenRpcDocument} (reused, never recomputed).
2487
+ */
1207
2488
  declare const emitOpenRpcModule: (document_: Record<string, unknown>) => string;
1208
2489
  /** Current snapshot format version. Bumped if the structural shape below changes. */
1209
2490
  declare const SCHEMA_SNAPSHOT_VERSION: 1;
@@ -1234,14 +2515,27 @@ interface TableSnapshot {
1234
2515
  /** Relation accessor name → {@link RelationSnapshot}. */
1235
2516
  relations: Record<string, RelationSnapshot>;
1236
2517
  /**
1237
- * `"root"` (default single-DO), `"global"` (D1-replicated), or
1238
- * `"shardBy:&lt;field>"` (partitioned). Encoded as a string so the snapshot
1239
- * stays a plain JSON-stable value.
1240
- */
2518
+ * `"root"` (default single-DO), `"global"` (D1-replicated), or
2519
+ * `"shardBy:&lt;field>"` (partitioned). Encoded as a string so the snapshot
2520
+ * stays a plain JSON-stable value.
2521
+ */
1241
2522
  shardMode: string;
1242
2523
  }
1243
2524
  /** The committed baseline — a deterministic structural view of the whole schema. */
1244
2525
  interface SchemaSnapshot {
2526
+ /**
2527
+ * Cloudflare DO data-residency jurisdiction declared via `.jurisdiction("…")`,
2528
+ * or absent. Tracked because changing it strands all existing Durable Object
2529
+ * data (a DO name maps to a different ID per jurisdiction). Optional, so old
2530
+ * baselines written before this field parse cleanly (absent ⇒ undefined).
2531
+ *
2532
+ * Typed as a plain `string` (not the authoring union) on purpose: this is
2533
+ * STORED data that a newer Lunora may have written with a jurisdiction this
2534
+ * version doesn't yet know. Preserving the raw value keeps the breaking
2535
+ * `changedJurisdiction` diff correct under a downgrade — coercing an unknown
2536
+ * value to `undefined` would fail OPEN and hide the most destructive change.
2537
+ */
2538
+ jurisdiction?: string;
1245
2539
  /** Sorted list of every declared `defineMigration` id at capture time. */
1246
2540
  migrationIds: ReadonlyArray<string>;
1247
2541
  /** Table name → {@link TableSnapshot}, keys sorted for stable serialization. */
@@ -1255,7 +2549,7 @@ interface DriftChange {
1255
2549
  /** Human-readable, actionable description (used in the gate message). */
1256
2550
  summary: string;
1257
2551
  /** A machine-readable change discriminator. */
1258
- type: "addedIndex" | "addedOptionalField" | "addedRelation" | "addedRequiredField" | "addedTable" | "changedFieldKind" | "changedIndex" | "changedShardMode" | "fieldOptionalToRequired" | "fieldRequiredToOptional" | "removedField" | "removedIndex" | "removedRelation" | "removedTable";
2552
+ type: "addedIndex" | "addedOptionalField" | "addedRelation" | "addedRequiredField" | "addedTable" | "changedJurisdiction" | "changedFieldKind" | "changedIndex" | "changedShardMode" | "fieldOptionalToRequired" | "fieldRequiredToOptional" | "removedField" | "removedIndex" | "removedRelation" | "removedTable";
1259
2553
  }
1260
2554
  /** The result of diffing two snapshots: every classified change. */
1261
2555
  interface SchemaDrift {
@@ -1263,36 +2557,41 @@ interface SchemaDrift {
1263
2557
  changes: ReadonlyArray<DriftChange>;
1264
2558
  }
1265
2559
  /**
1266
- * Build a {@link SchemaSnapshot} from a parsed {@link SchemaIR} and the set of
1267
- * declared migration ids. Tables and migration ids are sorted so the emitted
1268
- * JSON is byte-stable across runs (no spurious diffs / churn).
1269
- */
2560
+ * Build a {@link SchemaSnapshot} from a parsed {@link SchemaIR} and the set of
2561
+ * declared migration ids. Tables and migration ids are sorted so the emitted
2562
+ * JSON is byte-stable across runs AND across machines (no spurious diffs /
2563
+ * churn) — see {@link sortKeys} for why that ordering must not be locale-aware.
2564
+ *
2565
+ * Field / index / relation keys are deliberately NOT sorted: they are emitted in
2566
+ * declaration order from the schema source, which is already deterministic for a
2567
+ * given source file and keeps the snapshot readable next to the schema it mirrors.
2568
+ */
1270
2569
  declare const buildSchemaSnapshot: (schema: SchemaIR, migrationIds: ReadonlyArray<string>) => SchemaSnapshot;
1271
2570
  /** Serialize a snapshot to the exact bytes written to `lunora/.lunora-schema.json` (trailing newline). */
1272
2571
  declare const serializeSchemaSnapshot: (snapshot: SchemaSnapshot) => string;
1273
2572
  /**
1274
- * Thrown by {@link parseSchemaSnapshot} when the baseline file exists but is
1275
- * malformed (bad JSON / wrong version / invalid table shape). Lets the CLI gate
1276
- * treat a corrupt baseline as a hard error rather than silently degrading to a
1277
- * "first capture" that would mask drift and then overwrite the bad file.
1278
- */
1279
- declare class SchemaSnapshotParseError extends Error {
1280
- override readonly name = "SchemaSnapshotParseError";
1281
- }
1282
- /**
1283
- * Parse a committed snapshot file. Returns `undefined` ONLY when the content is
1284
- * absent/empty; throws {@link SchemaSnapshotParseError} when content is present
1285
- * but malformed (bad JSON, wrong version, or structurally-invalid tables) so the
1286
- * caller can distinguish "no baseline yet" (a legitimate first capture) from "a
1287
- * corrupt baseline" (which must not be silently treated as a first capture).
1288
- */
2573
+ * Thrown by {@link parseSchemaSnapshot} when the baseline file exists but is
2574
+ * malformed (bad JSON / wrong version / invalid table shape). Lets the CLI gate
2575
+ * treat a corrupt baseline as a hard error rather than silently degrading to a
2576
+ * "first capture" that would mask drift and then overwrite the bad file.
2577
+ */
2578
+ declare class SchemaSnapshotParseError extends LunoraError {
2579
+ constructor(message: string);
2580
+ }
2581
+ /**
2582
+ * Parse a committed snapshot file. Returns `undefined` ONLY when the content is
2583
+ * absent/empty; throws {@link SchemaSnapshotParseError} when content is present
2584
+ * but malformed (bad JSON, wrong version, or structurally-invalid tables) so the
2585
+ * caller can distinguish "no baseline yet" (a legitimate first capture) from "a
2586
+ * corrupt baseline" (which must not be silently treated as a first capture).
2587
+ */
1289
2588
  declare const parseSchemaSnapshot: (content: string | undefined) => SchemaSnapshot | undefined;
1290
2589
  /**
1291
- * Diff the current snapshot against a committed baseline and classify every
1292
- * structural change. Pure — no I/O. When `baseline` is `undefined` (no committed
1293
- * snapshot yet) there is no drift to report: every table is treated as a fresh
1294
- * additive `addedTable`, so a first deploy is never blocked.
1295
- */
2590
+ * Diff the current snapshot against a committed baseline and classify every
2591
+ * structural change. Pure — no I/O. When `baseline` is `undefined` (no committed
2592
+ * snapshot yet) there is no drift to report: every table is treated as a fresh
2593
+ * additive `addedTable`, so a first deploy is never blocked.
2594
+ */
1296
2595
  declare const diffSchemaSnapshots: (baseline: SchemaSnapshot | undefined, current: SchemaSnapshot) => SchemaDrift;
1297
2596
  /** The decision the pre-deploy gate returns. */
1298
2597
  interface SchemaDriftDecision {
@@ -1303,212 +2602,250 @@ interface SchemaDriftDecision {
1303
2602
  /** Migration ids declared now but absent from the baseline — proof a migration was added. */
1304
2603
  newMigrationIds: ReadonlyArray<string>;
1305
2604
  /**
1306
- * A multi-line, actionable explanation. Always present; empty string when
1307
- * there is no drift at all. Mirrors the D1-placeholder guard's message style.
1308
- */
2605
+ * A multi-line, actionable explanation. Always present; empty string when
2606
+ * there is no drift at all. Mirrors the D1-placeholder guard's message style.
2607
+ */
1309
2608
  reason: string;
1310
2609
  }
1311
2610
  /**
1312
- * Decide whether breaking schema drift should block a deploy.
1313
- *
1314
- * Blocks only when the baseline exists (a first-ever capture is never blocking),
1315
- * there is at least one `breaking` change, no NEW migration id was added since
1316
- * the baseline, and the `allowDrift` override is not set. Safe-only drift (or
1317
- * breaking drift accompanied by a new migration id) passes.
1318
- */
2611
+ * Decide whether breaking schema drift should block a deploy.
2612
+ *
2613
+ * Blocks only when the baseline exists (a first-ever capture is never blocking),
2614
+ * there is at least one `breaking` change, no NEW migration id was added since
2615
+ * the baseline, and the `allowDrift` override is not set. Safe-only drift (or
2616
+ * breaking drift accompanied by a new migration id) passes.
2617
+ */
1319
2618
  declare const evaluateSchemaDrift: (options: {
1320
2619
  allowDrift?: boolean;
1321
2620
  baseline: SchemaSnapshot | undefined;
1322
2621
  current: SchemaSnapshot;
1323
2622
  }) => SchemaDriftDecision;
1324
2623
  /**
1325
- * Committed, tracked baseline file holding the blessed structural schema
1326
- * snapshot the pre-deploy drift gate diffs against. Lives in `lunora/` (NOT the
1327
- * gitignored `_generated/`) so it is committed alongside `schema.ts`. Leading
1328
- * dot keeps it tucked away next to the schema it describes.
1329
- */
2624
+ * Committed, tracked baseline file holding the blessed structural schema
2625
+ * snapshot the pre-deploy drift gate diffs against. Lives in `lunora/` (NOT the
2626
+ * gitignored `_generated/`) so it is committed alongside `schema.ts`. Leading
2627
+ * dot keeps it tucked away next to the schema it describes.
2628
+ */
1330
2629
  declare const SCHEMA_SNAPSHOT_FILENAME = ".lunora-schema.json";
1331
2630
  /**
1332
- * Construct the ts-morph `Project` codegen discovers over. Prefers the user's
1333
- * `tsconfig.json` (when one is found walking up from `lunoraDirectory`) so
1334
- * cross-file type resolution and path aliases work; falls back to an isolated
1335
- * project otherwise. This is the exact construction {@link runCodegen} uses
1336
- * when no `project` is injected — exported so a long-lived caller (the Vite
1337
- * dev-loop) can build one once and reuse it across runs via
1338
- * {@link refreshCodegenProject} instead of re-parsing the user's whole TS
1339
- * program on every save.
1340
- */
2631
+ * Construct the ts-morph `Project` codegen discovers over. Prefers the user's
2632
+ * `tsconfig.json` (when one is found walking up from `lunoraDirectory`) so
2633
+ * cross-file type resolution and path aliases work; falls back to an isolated
2634
+ * project otherwise. This is the exact construction {@link runCodegen} uses
2635
+ * when no `project` is injected — exported so a long-lived caller (the Vite
2636
+ * dev-loop) can build one once and reuse it across runs via
2637
+ * {@link refreshCodegenProject} instead of re-parsing the user's whole TS
2638
+ * program on every save.
2639
+ */
1341
2640
  declare const createCodegenProject: (lunoraDirectory: string) => Project;
1342
2641
  /**
1343
- * Synchronise a reused {@link createCodegenProject} Project with the current
1344
- * on-disk state of `lunoraDirectory`, so the next {@link runCodegen} sees the
1345
- * same files a freshly-constructed Project would — without re-parsing the whole
1346
- * TS program. Adds any on-disk source file the Project doesn't yet have, and
1347
- * `refreshFromFileSystemSync()`es the ones it does (picking up edits); then
1348
- * removes Project source files under `lunoraDirectory` that no longer exist on
1349
- * disk (the classic stale-deleted-file cache bug).
1350
- *
1351
- * Files outside `lunoraDirectory` (e.g. those pulled in by the user's tsconfig)
1352
- * are left untouched — they back type resolution and rarely change in the
1353
- * dev-loop; a tsconfig change invalidates the whole cached Project upstream.
1354
- */
2642
+ * Synchronise a reused {@link createCodegenProject} Project with the current
2643
+ * on-disk state of `lunoraDirectory`, so the next {@link runCodegen} sees the
2644
+ * same files a freshly-constructed Project would — without re-parsing the whole
2645
+ * TS program. Adds any on-disk source file the Project doesn't yet have, and
2646
+ * `refreshFromFileSystemSync()`es the ones it does (picking up edits); then
2647
+ * removes Project source files under `lunoraDirectory` that no longer exist on
2648
+ * disk (the classic stale-deleted-file cache bug).
2649
+ *
2650
+ * Files outside `lunoraDirectory` (e.g. those pulled in by the user's tsconfig)
2651
+ * are left untouched — they back type resolution and rarely change in the
2652
+ * dev-loop; a tsconfig change invalidates the whole cached Project upstream.
2653
+ */
1355
2654
  declare const refreshCodegenProject: (project: Project, lunoraDirectory: string) => void;
1356
2655
  /**
1357
- * Top-level codegen entry. Parses `&lt;projectRoot>/lunora/schema.ts` and every
1358
- * function file under `&lt;projectRoot>/lunora/`, then writes
1359
- * `_generated/{api,server,dataModel}.ts` next to them.
1360
- */
2656
+ * Top-level codegen entry. Parses `&lt;projectRoot>/lunora/schema.ts` and every
2657
+ * function file under `&lt;projectRoot>/lunora/`, then writes
2658
+ * `_generated/{api,server,dataModel}.ts` next to them.
2659
+ *
2660
+ * When `LUNORA_CODEGEN_TIMING` is set (truthy), a single diagnostic summary
2661
+ * line is written to stderr with the total wall time and the discovery-vs-emit
2662
+ * split — opt-in instrumentation that is otherwise zero-cost and side-effect-free
2663
+ * on the returned {@link CodegenResult}.
2664
+ */
1361
2665
  declare const runCodegen: (options: CodegenOptions) => CodegenResult;
1362
2666
  interface CodegenOptions {
1363
2667
  /**
1364
- * Which machine-readable API spec(s) to emit into `_generated/`.
1365
- *
1366
- * `"openapi"` (the default) writes only `openapi.json` (OpenAPI 3.1; covers
1367
- * both the RPC functions and `httpRouter()` REST routes). `"openrpc"` writes
1368
- * only `openrpc.json` (OpenRPC 1.x; the RPC functions only — OpenRPC cannot
1369
- * represent REST routes). `"both"` writes both files; `"none"` writes neither.
1370
- *
1371
- * Regardless of the choice, `CodegenResult.generated.openApi` and `.openRpc`
1372
- * always carry the rendered string (computation is cheap and pure); only the
1373
- * on-disk write is gated by this option.
1374
- */
2668
+ * Which machine-readable API spec(s) to emit into `_generated/`.
2669
+ *
2670
+ * `"openapi"` (the default) writes only `openapi.json` (OpenAPI 3.1; covers
2671
+ * both the RPC functions and `httpRouter()` REST routes). `"openrpc"` writes
2672
+ * only `openrpc.json` (OpenRPC 1.x; the RPC functions only — OpenRPC cannot
2673
+ * represent REST routes). `"both"` writes both files; `"none"` writes neither.
2674
+ *
2675
+ * Regardless of the choice, `CodegenResult.generated.openApi` and `.openRpc`
2676
+ * always carry the rendered string (computation is cheap and pure); only the
2677
+ * on-disk write is gated by this option.
2678
+ */
1375
2679
  apiSpec?: "both" | "none" | "openapi" | "openrpc";
1376
2680
  /**
1377
- * When true, run discovery + emit (so any schema/function parse error
1378
- * surfaces) but skip writing files to `_generated/`. The returned
1379
- * `outputDirectory` is still the path that *would* have been written.
1380
- */
2681
+ * When true, run discovery + emit (so any schema/function parse error
2682
+ * surfaces) but skip writing files to `_generated/`. The returned
2683
+ * `outputDirectory` is still the path that *would* have been written.
2684
+ */
1381
2685
  dryRun?: boolean;
1382
2686
  /**
1383
- * Run the static schema advisor (unindexed FKs, …) during codegen.
1384
- * Defaults to `true`. When `false`, `CodegenResult.advisories` is empty.
1385
- * Computed regardless of `dryRun`; codegen never prints them — see
1386
- * {@link CodegenResult.advisories}.
1387
- */
2687
+ * Run the static schema advisor (unindexed FKs, …) during codegen.
2688
+ * Defaults to `true`. When `false`, `CodegenResult.advisories` is empty.
2689
+ * Computed regardless of `dryRun`; codegen never prints them — see
2690
+ * {@link CodegenResult.advisories}.
2691
+ */
1388
2692
  lint?: boolean;
1389
2693
  /** Override the lunora subdirectory name. Defaults to `"lunora"`. */
1390
2694
  lunoraDirectory?: string;
1391
2695
  /**
1392
- * Reuse a previously-constructed ts-morph {@link Project} instead of building
1393
- * a fresh one each run. The caller owns refreshing its source files from disk
1394
- * (see {@link refreshCodegenProject}) — codegen does not re-read changed files
1395
- * off an injected Project. Built via {@link createCodegenProject} when absent.
1396
- * Used by the Vite dev-loop to avoid re-parsing the whole TS program on every
1397
- * save; omit it (CLI one-shot path) to get the default fresh-Project behaviour.
1398
- */
2696
+ * Reuse a previously-constructed ts-morph {@link Project} instead of building
2697
+ * a fresh one each run. The caller owns refreshing its source files from disk
2698
+ * (see {@link refreshCodegenProject}) — codegen does not re-read changed files
2699
+ * off an injected Project. Built via {@link createCodegenProject} when absent.
2700
+ * Used by the Vite dev-loop to avoid re-parsing the whole TS program on every
2701
+ * save; omit it (CLI one-shot path) to get the default fresh-Project behaviour.
2702
+ */
1399
2703
  project?: Project;
1400
2704
  /** Project root containing the `lunora/` directory. */
1401
2705
  projectRoot: string;
1402
2706
  /**
1403
- * Re-bless the committed schema-drift baseline (`lunora/.lunora-schema.json`)
1404
- * with the current structural snapshot. The baseline is ALWAYS written on
1405
- * first capture (when the file is absent); set this to overwrite an existing
1406
- * one — e.g. after the developer has added the data migration that justifies
1407
- * a breaking change. Ignored when `dryRun` is true.
1408
- */
2707
+ * Re-bless the committed schema-drift baseline (`lunora/.lunora-schema.json`)
2708
+ * with the current structural snapshot. The baseline is ALWAYS written on
2709
+ * first capture (when the file is absent); set this to overwrite an existing
2710
+ * one — e.g. after the developer has added the data migration that justifies
2711
+ * a breaking change. Ignored when `dryRun` is true.
2712
+ */
1409
2713
  updateSchemaBaseline?: boolean;
2714
+ /**
2715
+ * Committed `wrangler.jsonc` `vars` entries that hold plaintext secrets — the
2716
+ * `plaintext_secret_in_wrangler_vars` lint input. Produced by `@lunora/config`
2717
+ * (which reads `wrangler.jsonc`) and threaded through by the CLI / Vite plugin;
2718
+ * codegen only forwards it to the advisor. Absent when no wrangler config is
2719
+ * present or the caller doesn't scan it.
2720
+ */
2721
+ wranglerVariables?: ReadonlyArray<WranglerVariableIR>;
1410
2722
  }
1411
2723
  interface CodegenResult {
1412
2724
  /**
1413
- * Static schema advisor findings (e.g. unindexed foreign keys) produced
1414
- * this run. Empty when `lint` is `false` or the schema is clean. Codegen
1415
- * does not print these itself — each caller presents them through its own
1416
- * channel (the CLI logger, the vite overlay, the studio Advisors table).
1417
- * `formatAdvisories` is exported for a plain multi-line rendering.
1418
- */
2725
+ * Static schema advisor findings (e.g. unindexed foreign keys) produced
2726
+ * this run. Empty when `lint` is `false` or the schema is clean. Codegen
2727
+ * does not print these itself — each caller presents them through its own
2728
+ * channel (the CLI logger, the vite overlay, the studio Advisors table).
2729
+ * `formatAdvisories` is exported for a plain multi-line rendering.
2730
+ */
1419
2731
  advisories: ReadonlyArray<Finding>;
1420
2732
  /**
1421
- * Containers discovered from `defineContainer` exports in
1422
- * `lunora/containers.ts` — the list the config layer reconciles into
1423
- * wrangler's `containers[]`, `CONTAINER_*` Durable Object bindings, and
1424
- * migration classes. Empty when the project declares no containers.
1425
- */
2733
+ * Agents discovered from `defineAgent` exports in `lunora/agents.ts` — the
2734
+ * list the config layer reconciles into wrangler's `workflows[]` array (an
2735
+ * agent compiles onto a Cloudflare Workflow). Agents are NOT Durable Objects,
2736
+ * so this adds no binding or migration. Empty when the project declares none.
2737
+ */
2738
+ agents: ReadonlyArray<AgentIR>;
2739
+ /**
2740
+ * Containers discovered from `defineContainer` exports in
2741
+ * `lunora/containers.ts` — the list the config layer reconciles into
2742
+ * wrangler's `containers[]`, `CONTAINER_*` Durable Object bindings, and
2743
+ * migration classes. Empty when the project declares no containers.
2744
+ */
1426
2745
  containers: ReadonlyArray<ContainerIR>;
1427
2746
  /**
1428
- * Deduplicated cron schedules discovered from `cronJobs()` definitions —
1429
- * the array the vite plugin reconciles into `wrangler.jsonc`'s
1430
- * `triggers.crons`. Empty when the project declares no crons.
1431
- */
2747
+ * Deduplicated cron schedules discovered from `cronJobs()` definitions —
2748
+ * the array the vite plugin reconciles into `wrangler.jsonc`'s
2749
+ * `triggers.crons`. Empty when the project declares no crons.
2750
+ */
1432
2751
  cronTriggers: ReadonlyArray<string>;
1433
2752
  generated: {
1434
- api: string; /** Fluent worker-composition builder (`_generated/app.ts`) `defineApp()`. Always written. */
2753
+ /** WorkflowEntrypoint classes for declared agents (`_generated/agents.ts`); `""` (and not written) when no agents are declared. */
2754
+ agents: string;
2755
+ api: string;
2756
+ /** Fluent worker-composition builder (`_generated/app.ts`) — `defineApp()`. Always written. */
1435
2757
  app: string;
2758
+ /** Partial-replication collection factories (`_generated/collections.ts`); `""` (and not written) unless the project declares shapes and installs `@lunora/db`. */
2759
+ collections: string;
1436
2760
  /** Container DO classes (`_generated/containers.ts`); `""` (and not written) when no containers are declared. */
1437
2761
  containers: string;
1438
2762
  crons: string;
1439
2763
  dataModel: string;
1440
2764
  drizzleGlobal: string;
1441
2765
  drizzleShard: string;
1442
- functions: string; /** OpenAPI 3.1.0 document (`_generated/openapi.json`), pretty-printed JSON. */
2766
+ functions: string;
2767
+ /** OpenAPI 3.1.0 document (`_generated/openapi.json`), pretty-printed JSON. */
1443
2768
  openApi: string;
1444
2769
  /**
1445
- * OpenAPI document as an importable TS module (`_generated/openapi.ts`) —
1446
- * `export const openApiSpec`, the worker imports it for
1447
- * `createWorker({ openApiSpec })`. Same document as `openApi`. Written
1448
- * alongside `openapi.json` whenever `apiSpec` includes `openapi`.
1449
- */
2770
+ * OpenAPI document as an importable TS module (`_generated/openapi.ts`) —
2771
+ * `export const openApiSpec`, the worker imports it for
2772
+ * `createWorker({ openApiSpec })`. Same document as `openApi`. Written
2773
+ * alongside `openapi.json` whenever `apiSpec` includes `openapi`.
2774
+ */
1450
2775
  openApiModule: string;
1451
2776
  /** OpenRPC 1.x document (`_generated/openrpc.json`), pretty-printed JSON. Always computed; written only when `apiSpec` includes `openrpc`. */
1452
2777
  openRpc: string;
1453
2778
  /**
1454
- * OpenRPC document as an importable TS module (`_generated/openrpc.ts`) —
1455
- * `export const openRpcSpec`, for `createWorker({ openRpcSpec })`. Same
1456
- * document as `openRpc`. Written alongside `openrpc.json` whenever
1457
- * `apiSpec` includes `openrpc`.
1458
- */
2779
+ * OpenRPC document as an importable TS module (`_generated/openrpc.ts`) —
2780
+ * `export const openRpcSpec`, for `createWorker({ openRpcSpec })`. Same
2781
+ * document as `openRpc`. Written alongside `openrpc.json` whenever
2782
+ * `apiSpec` includes `openrpc`.
2783
+ */
1459
2784
  openRpcModule: string;
2785
+ /** Push-consumer queue registry (`_generated/queues.ts`); `""` (and not written) when no push queues are declared. */
2786
+ queues: string;
1460
2787
  /** Project-bound seed client (`_generated/seed.ts`); `""` (and not written) when `@lunora/seed` is not a declared dependency. */
1461
2788
  seed: string;
1462
2789
  server: string;
1463
- shard: string; /** Static vector-index registry (`_generated/vectors.ts`) — `LUNORA_VECTOR_INDEXES`. Empty array body when the schema declares none. */
2790
+ shard: string;
2791
+ /** Static vector-index registry (`_generated/vectors.ts`) — `LUNORA_VECTOR_INDEXES`. Empty array body when the schema declares none. */
1464
2792
  vectors: string;
1465
2793
  /** WorkflowEntrypoint classes (`_generated/workflows.ts`); `""` (and not written) when no workflows are declared. */
1466
2794
  workflows: string;
1467
2795
  };
1468
2796
  outputDirectory: string;
1469
2797
  /**
1470
- * The CURRENT structural schema snapshot computed this run (tables + field
1471
- * kinds/optionality + indexes/relations/shard mode + declared migration ids).
1472
- * The pre-deploy drift gate diffs this against the committed baseline read
1473
- * from {@link CodegenResult.schemaSnapshotPath}. Always present, even on a
1474
- * `dryRun`.
1475
- */
2798
+ * Queues discovered from `defineQueue` exports in `lunora/queues.ts` the
2799
+ * list the config layer reconciles into wrangler's `queues.producers[]` /
2800
+ * `queues.consumers[]`. Queues are NOT Durable Objects, so this adds no
2801
+ * binding or migration. Empty when the project declares no queues.
2802
+ */
2803
+ queues: ReadonlyArray<QueueIR>;
2804
+ /**
2805
+ * The CURRENT structural schema snapshot computed this run (tables + field
2806
+ * kinds/optionality + indexes/relations/shard mode + declared migration ids).
2807
+ * The pre-deploy drift gate diffs this against the committed baseline read
2808
+ * from {@link CodegenResult.schemaSnapshotPath}. Always present, even on a
2809
+ * `dryRun`.
2810
+ */
1476
2811
  schemaSnapshot: SchemaSnapshot;
1477
2812
  /** Absolute path of the committed baseline file (`lunora/.lunora-schema.json`). */
1478
2813
  schemaSnapshotPath: string;
1479
2814
  /**
1480
- * Workflows discovered from `defineWorkflow` exports in
1481
- * `lunora/workflows.ts` — the list the config layer reconciles into
1482
- * wrangler's `workflows[]` array. Workflows are NOT Durable Objects, so this
1483
- * adds no binding or migration. Empty when the project declares no workflows.
1484
- */
2815
+ * Workflows discovered from `defineWorkflow` exports in
2816
+ * `lunora/workflows.ts` — the list the config layer reconciles into
2817
+ * wrangler's `workflows[]` array. Workflows are NOT Durable Objects, so this
2818
+ * adds no binding or migration. Empty when the project declares no workflows.
2819
+ */
1485
2820
  workflows: ReadonlyArray<WorkflowIR>;
1486
2821
  }
1487
2822
  /**
1488
- * Convert a {@link SchemaIR} into a synthetic runtime {@link Schema} carrying just
1489
- * the `tables[name].shape` surface `@lunora/seed` introspects. System columns
1490
- * (`_id`, `_creationTime`) are absent from the IR shape, exactly as the seed
1491
- * engine expects (it assigns `_id` itself).
1492
- */
2823
+ * Convert a {@link SchemaIR} into a synthetic runtime {@link Schema} carrying just
2824
+ * the `tables[name].shape` surface `@lunora/seed` introspects. System columns
2825
+ * (`_id`, `_creationTime`) are absent from the IR shape, exactly as the seed
2826
+ * engine expects (it assigns `_id` itself).
2827
+ */
1493
2828
  declare const schemaFromIr: (ir: SchemaIR) => Schema;
1494
2829
  /**
1495
- * Convert a codegen {@link ValidatorIR} into a JSON Schema node. A thin wrapper
1496
- * over the shared {@link jsonSchemaFromNode} core (from `@lunora/values`) with the
1497
- * IR-backed {@link irReader}, so the kind→schema mapping is the *same* algorithm
1498
- * `@lunora/values`' `toJsonSchema` runs — codegen never instantiates the runtime
1499
- * `v.*` objects, it only holds the reflected IR. Shared by the OpenAPI and
1500
- * OpenRPC emitters so both surfaces speak one JSON Schema dialect.
1501
- */
2830
+ * Convert a codegen {@link ValidatorIR} into a JSON Schema node. A thin wrapper
2831
+ * over the shared {@link jsonSchemaFromNode} core (from `@lunora/values`) with the
2832
+ * IR-backed {@link irReader}, so the kind→schema mapping is the *same* algorithm
2833
+ * `@lunora/values`' `toJsonSchema` runs — codegen never instantiates the runtime
2834
+ * `v.*` objects, it only holds the reflected IR. Shared by the OpenAPI and
2835
+ * OpenRPC emitters so both surfaces speak one JSON Schema dialect.
2836
+ */
1502
2837
  declare const validatorIrToJsonSchema: (validator: ValidatorIR) => JsonSchema;
1503
- /** Build `{ type: "object", properties, required }` from an IR shape (mirrors `@lunora/values`' object mapping). */
1504
-
1505
- /**
1506
- * The machine-readable `LunoraError` codes Lunora emits on the RPC + REST
1507
- * surfaces, enumerated from `@lunora/server`'s `CODE_STATUS` map plus the
1508
- * runtime/DO dispatch codes (`FUNCTION_NOT_FOUND`, `PAYLOAD_TOO_LARGE`,
1509
- * `METHOD_NOT_ALLOWED`, the `*_NOT_CONFIGURED` admin gates, …). The list documents
1510
- * the contract; clients switch on `error.code`. Kept sorted for stable output.
1511
- */
2838
+ /**
2839
+ * The machine-readable `LunoraError` codes Lunora emits on the RPC + REST
2840
+ * surfaces, enumerated from `@lunora/server`'s `CODE_STATUS` map plus the
2841
+ * runtime/DO dispatch codes (`FUNCTION_NOT_FOUND`, `PAYLOAD_TOO_LARGE`,
2842
+ * `METHOD_NOT_ALLOWED`, the `*_NOT_CONFIGURED` admin gates, …). The list documents
2843
+ * the contract; clients switch on `error.code`. Kept sorted for stable output.
2844
+ */
1512
2845
  declare const LUNORA_ERROR_CODES: ReadonlyArray<string>;
2846
+ /** The matching secret rule's `kind` for a string value, or `undefined` when none matches. */
2847
+ declare const secretKindOf: (value: string) => string | undefined;
2848
+ /** A redacted preview of a secret value — first 4 chars plus its length, never the full value. */
2849
+ declare const redact: (value: string) => string;
1513
2850
  declare const VERSION = "0.0.0";
1514
- export { type AuthApiCallIR, CONTAINERS_FILENAME, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type CronJobIR, type DriftChange, type EmitAppOptions, type FieldSnapshot, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type MaskProcedureIR, type MigrationIR, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcEmitInput, type ProjectIR, type QueryReadIR, type R2sqlCallIR, type RelationSnapshot, type RlsMetadataIR, type RlsPolicyIR, type RlsProcedureIR, type RlsRoleIR, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, createCodegenProject, diagnosticAt, diffSchemaSnapshots, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFunctions, discoverHttpRoutes, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverNondeterministicCalls, discoverQueries, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSchema, discoverStorageRulesMetadata, discoverWorkflows, emitApi, emitApp, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, evaluateSchemaDrift, formatAdvisories, lintSchema, parseSchemaSnapshot, refreshCodegenProject, runCodegen, schemaFromIr, serializeSchemaSnapshot, validatorIrToJsonSchema };
2851
+ export { AGENTS_FILENAME, type AgentIR, type AuthApiCallIR, CONTAINERS_FILENAME, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type CronJobIR, type DriftChange, type EmitAppOptions, FLAGS_FILENAME, type FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type LintSchemaOptions, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcEmitInput, type ProjectIR, QUEUES_FILENAME, type QueryReadIR, type QueueIR, type R2sqlCallIR, type RelationSnapshot, type RlsMetadataIR, type RlsPolicyIR, type RlsProcedureIR, type RlsRoleIR, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, SHAPES_FILENAME, type SandboxUsage, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type ShapeIR, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, createCodegenProject, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, evaluateSchemaDrift, formatAdvisories, lintSchema, parseSchemaSnapshot, redact, refreshCodegenProject, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, validatorIrToJsonSchema };