@lunora/codegen 1.0.0-alpha.7 → 1.0.0-alpha.70

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