@lunora/codegen 1.0.0-alpha.382 → 1.0.0-alpha.383

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 (50) hide show
  1. package/dist/index.d.mts +194 -93
  2. package/dist/index.d.ts +194 -93
  3. package/dist/index.mjs +1 -1
  4. package/dist/packem_shared/{GENERATED_HEADER-DPEvCN8Z.mjs → GENERATED_HEADER-Bzf6ZJ9r.mjs} +1 -1
  5. package/dist/packem_shared/{MUTATORS_FILENAME-Ipxibja6.mjs → MUTATORS_FILENAME-BGvYo46g.mjs} +1 -1
  6. package/dist/packem_shared/{NOTIFY_FILENAME-B-t7jQSm.mjs → NOTIFY_FILENAME-BJJObZHG.mjs} +1 -1
  7. package/dist/packem_shared/{OPENRPC_VERSION-DA0ZNkhl.mjs → OPENRPC_VERSION-CSjT8wJW.mjs} +1 -1
  8. package/dist/packem_shared/{SCHEMA_SNAPSHOT_FILENAME-CQyAtphV.mjs → SCHEMA_SNAPSHOT_FILENAME-kN0pgKNu.mjs} +9 -9
  9. package/dist/packem_shared/SCHEMA_SNAPSHOT_VERSION-BdxZuSxk.mjs +2 -0
  10. package/dist/packem_shared/{SHAPES_FILENAME-mgEi072Z.mjs → SHAPES_FILENAME-KyidzoqS.mjs} +1 -1
  11. package/dist/packem_shared/SchemaSnapshotParseError-ycDz8gOB.mjs +17 -0
  12. package/dist/packem_shared/{buildOpenApiDocument-Ct2wK_Tj.mjs → buildOpenApiDocument-afHH7rN5.mjs} +1 -1
  13. package/dist/packem_shared/{context-property-calls-DKMO9ShK.mjs → context-property-calls-B75cjwpy.mjs} +1 -1
  14. package/dist/packem_shared/{context-root-BPfMNAJM.mjs → context-root-D4Njep-A.mjs} +1 -1
  15. package/dist/packem_shared/{database-calls-hLzaOquW.mjs → database-calls-aAjZJdma.mjs} +1 -1
  16. package/dist/packem_shared/{discoverFunctions-a0IT8OSb.mjs → discoverFunctions-CoQM_L6f.mjs} +1 -1
  17. package/dist/packem_shared/{discoverHttpRoutes-DHDfKLoa.mjs → discoverHttpRoutes-BQM2CPSF.mjs} +1 -1
  18. package/dist/packem_shared/discoverHyperdriveCalls-PUg-BESh.mjs +1 -0
  19. package/dist/packem_shared/{discoverInserts-IAa3lRR4.mjs → discoverInserts-DldQpEfF.mjs} +1 -1
  20. package/dist/packem_shared/discoverMaskProcedures-_Ey4eJLn.mjs +1 -0
  21. package/dist/packem_shared/discoverMigrations-E9k4Ykku.mjs +1 -0
  22. package/dist/packem_shared/{discoverQueries-DZOGiEPs.mjs → discoverQueries-Bq2hqYHP.mjs} +1 -1
  23. package/dist/packem_shared/discoverR2sqlCalls-CeNnalpk.mjs +1 -0
  24. package/dist/packem_shared/{discoverRlsProcedures-B0DYk-gW.mjs → discoverRlsProcedures-MboagP9z.mjs} +1 -1
  25. package/dist/packem_shared/{discoverSchema-DmkjooXZ.mjs → discoverSchema-Cycd1-H0.mjs} +1 -1
  26. package/dist/packem_shared/{emitAgents-D8TkTpNh.mjs → emitAgents-BeM6PZv4.mjs} +1 -1
  27. package/dist/packem_shared/{emitApi-D6uqyYd_.mjs → emitApi-GFmStqmq.mjs} +1 -1
  28. package/dist/packem_shared/{emitApp-D9kGG9Mu.mjs → emitApp-D-6FIpYb.mjs} +10 -6
  29. package/dist/packem_shared/{emitCrons-C3RiGYk7.mjs → emitCrons-Drdn8Mjn.mjs} +1 -1
  30. package/dist/packem_shared/{emitDataModel-BMMht_iZ.mjs → emitDataModel-LTnwnhV6.mjs} +1 -1
  31. package/dist/packem_shared/{emitDrizzleSchema-BmCxM6tO.mjs → emitDrizzleSchema-CM9jh_F0.mjs} +1 -1
  32. package/dist/packem_shared/{emitFunctions-NGByI1FZ.mjs → emitFunctions-CfSXBV_A.mjs} +1 -1
  33. package/dist/packem_shared/{emitServer-4NV3vaOg.mjs → emitServer-4l7MPmK0.mjs} +1 -1
  34. package/dist/packem_shared/emitShard-B4fVJcJA.mjs +1 -0
  35. package/dist/packem_shared/{index-BjDVAPNW.mjs → index-11LAY5JO.mjs} +1 -1
  36. package/dist/packem_shared/parse-validator-BisfC8bR.mjs +1 -0
  37. package/dist/packem_shared/{qualifiers-CPQCkXC4.mjs → qualifiers-D1Q_3wo2.mjs} +1 -1
  38. package/dist/packem_shared/{server-BY1v1bTx.mjs → server-D69SOfX8.mjs} +1 -1
  39. package/dist/packem_shared/{shard-DNXF9VZ5.mjs → shard-CB0Ospyw.mjs} +1 -1
  40. package/dist/packem_shared/{shard-runtime-Bg8MOBzw.mjs → shard-runtime-lkQU8trx.mjs} +1 -1
  41. package/dist/packem_shared/{shared-BErjtci3.mjs → shared-A1XHcT4t.mjs} +1 -1
  42. package/package.json +3 -3
  43. package/dist/packem_shared/SCHEMA_SNAPSHOT_VERSION-SplX7j_9.mjs +0 -2
  44. package/dist/packem_shared/SchemaSnapshotParseError-CjKSMuex.mjs +0 -18
  45. package/dist/packem_shared/discoverHyperdriveCalls-i8Zcf64H.mjs +0 -1
  46. package/dist/packem_shared/discoverMaskProcedures-Bj6fPF4u.mjs +0 -1
  47. package/dist/packem_shared/discoverMigrations-Bv8kNIgy.mjs +0 -1
  48. package/dist/packem_shared/discoverR2sqlCalls-Lq6G--TZ.mjs +0 -1
  49. package/dist/packem_shared/emitShard-9NVueN79.mjs +0 -1
  50. package/dist/packem_shared/parse-validator-CP5CL6Q7.mjs +0 -1
package/dist/index.d.mts CHANGED
@@ -219,11 +219,12 @@ type DriftScope = "schema" | "table";
219
219
  * - `"backfill"` — a `defineMigration` transform rewrites the affected rows.
220
220
  * The ONLY value for which a data migration is the answer.
221
221
  * - `"rehome"` — the rows' physical storage moves (a different Durable Object,
222
- * or a different region). The per-shard runner only ever replaces a row inside
223
- * the shard it was handed, so no transform reaches these; the fix is an
224
- * export/import round trip, or a revert.
222
+ * or a different region), or a table is emptied on cold start. The per-shard
223
+ * runner only ever replaces a row inside the shard it was handed, so the move
224
+ * itself is an export/import round trip; the change clears once a new migration
225
+ * on the table accompanies it (to give each row what its new home needs).
225
226
  * - `"code"` — nothing happens to stored data; a query or a call site has to
226
- * change (a dropped index, a dropped relation).
227
+ * change (a dropped index a query still names).
227
228
  * - `"none"` — additive, nothing to do.
228
229
  *
229
230
  * This lives HERE, next to the change union, for the same reason {@link DriftScope}
@@ -234,6 +235,22 @@ type DriftScope = "schema" | "table";
234
235
  * sends the operator to a tool that cannot work.
235
236
  */
236
237
  type DriftRemediation = "backfill" | "code" | "none" | "rehome";
238
+ /**
239
+ * What a migration's `covers` must say for it to clear a change that moves or empties data: the table (when one is involved) and the
240
+ * target of the change. A `shardMode` is the snapshot's spelling (`root`, `global:d1`, `global:hyperdrive`, `shardBy:<field>`) and
241
+ * `global` stands for any global backend; a `jurisdiction` is the one the schema moves to, `none` when it is removed.
242
+ */
243
+ interface DriftCoverage {
244
+ jurisdiction?: string;
245
+ memory?: true;
246
+ shardMode?: string;
247
+ table?: string;
248
+ /** The TTL policy a table moves to: the column and the offset (`after`, milliseconds; absent is 0). */
249
+ ttl?: {
250
+ after?: number;
251
+ field: string;
252
+ };
253
+ }
237
254
  /** One classified structural change between two snapshots. */
238
255
  interface DriftChange {
239
256
  /** What fixes this change — see {@link DriftRemediation}. `"none"` for every `safe` change. */
@@ -248,8 +265,41 @@ interface DriftChange {
248
265
  severity: "breaking" | "safe";
249
266
  /** Human-readable, actionable description (used in the gate message). */
250
267
  summary: string;
268
+ /**
269
+ * The field this change belongs to, for a change to one field (its kind, shape,
270
+ * optionality, a constraint, or the field being added or removed).
271
+ */
272
+ field?: string;
251
273
  /** The table this change belongs to. Always set when `scope` is `"table"`. */
252
274
  table?: string;
275
+ /**
276
+ * Set on a change that is safe for the stored data but that the operator must hear about: what happens to data the schema
277
+ * no longer describes, or which rows a new TTL will sweep. The gate logs it as a warning when the run proceeds.
278
+ */
279
+ warning?: true;
280
+ /** Set on a change whose backfill a migration returning each row unchanged performs, because rewriting the row is what does it. */
281
+ identityRewrites?: true;
282
+ /** The TTL a change installs, and the one it replaces, so a caller that can read rows can count what the next sweep deletes. */
283
+ expiry?: {
284
+ after?: number;
285
+ field: string;
286
+ previous?: {
287
+ after?: number;
288
+ field: string;
289
+ };
290
+ };
291
+ /**
292
+ * Set on a change that moves or empties data (a shard-mode flip, a table turned `.memory()`, a jurisdiction change): the `covers`
293
+ * a new migration must declare to clear it. Absent when no migration can name the change.
294
+ */
295
+ coverage?: DriftCoverage;
296
+ /** The index a change is about, set on a removed index so a caller can check whether a query still names it. */
297
+ index?: string;
298
+ /**
299
+ * Set when the change adds a uniqueness constraint: the fields whose combined value must not repeat among a table's stored rows.
300
+ * Rows can settle it, so a caller that can read them checks for duplicates instead of asking for a migration.
301
+ */
302
+ uniqueOn?: ReadonlyArray<string>;
253
303
  /** A machine-readable change discriminator. */
254
304
  type: "addedFieldConstraint" | "addedIndex" | "addedOptionalField" | "addedRelation" | "addedRequiredField" | "addedTable" | "changedCommitOrdering" | "changedFieldKind" | "changedFieldShape" | "changedIndex" | "changedJurisdiction" | "changedMemoryMode" | "changedShardMode" | "changedTtlPolicy" | "fieldOptionalToRequired" | "fieldRequiredToOptional" | "relaxedFieldConstraint" | "removedField" | "removedIndex" | "removedRelation" | "removedTable" | "widenedFieldShape";
255
305
  }
@@ -1144,6 +1194,12 @@ interface ValidatorIR {
1144
1194
  * flag, because compiling it would silently skip the predicate.
1145
1195
  */
1146
1196
  unmodelledRefinement?: boolean;
1197
+ /**
1198
+ * `true` on a `v.object(...)` whose `shape` is not the whole validator: the
1199
+ * argument is built at runtime, spreads something unreadable, or is absent. An
1200
+ * empty `shape` then stands for "unknown", not "no properties".
1201
+ */
1202
+ unresolvedShape?: boolean;
1147
1203
  valueType?: ValidatorIR;
1148
1204
  }
1149
1205
  interface IndexIR {
@@ -1415,12 +1471,32 @@ interface ExposeCacheIR {
1415
1471
  * tables with breaking drift, so a migration left at `""` covers nothing.
1416
1472
  */
1417
1473
  interface MigrationIR {
1474
+ /**
1475
+ * The change this migration declares it accounts for, read from `covers: { … }` when every value is a literal. The drift gate
1476
+ * clears a shard-mode flip, a table turned `.memory()` or a jurisdiction change only for a migration naming exactly that change.
1477
+ */
1478
+ covers?: {
1479
+ jurisdiction?: string;
1480
+ memory?: true;
1481
+ shardMode?: string;
1482
+ table?: string;
1483
+ ttl?: {
1484
+ after?: number;
1485
+ field: string;
1486
+ };
1487
+ };
1418
1488
  /** Export binding name, used to reference the module member in generated imports. */
1419
1489
  exportName: string;
1420
1490
  /** Path relative to `<projectRoot>/lunora/` without extension, e.g. "migrations". */
1421
1491
  filePath: string;
1422
1492
  /** Stable migration id — the registry key and per-shard run-state key. */
1423
1493
  id: string;
1494
+ /**
1495
+ * `true` when `up` returns its document unchanged (`(document) => document`, the
1496
+ * shape `lunora migrate create` scaffolds). Such a migration rewrites no row, so it
1497
+ * cannot by itself account for a schema change on its table.
1498
+ */
1499
+ identity?: true;
1424
1500
  /** Table the migration iterates; `""` when not a static string literal. */
1425
1501
  table: string;
1426
1502
  }
@@ -3286,6 +3362,108 @@ interface PlatformDiagnostic {
3286
3362
  /** The requested deploy target. */
3287
3363
  target: string;
3288
3364
  }
3365
+ /**
3366
+ * Build a {@link SchemaSnapshot} from a parsed {@link SchemaIR} and the set of
3367
+ * declared migration ids. Tables and migration ids are sorted so the emitted
3368
+ * JSON is byte-stable across runs AND across machines (no spurious diffs /
3369
+ * churn) — see `sortKeys` in `shared/schema-snapshot.ts` for why that ordering
3370
+ * must not be locale-aware.
3371
+ *
3372
+ * Field / index / relation keys are sorted the same way, by `tableSnapshotOf` —
3373
+ * see there for why declaration order was the wrong default for a hashed file.
3374
+ */
3375
+ declare const buildSchemaSnapshot: (schema: SchemaIR, migrationIds: ReadonlyArray<string>) => SchemaSnapshot;
3376
+ /**
3377
+ * Thrown by {@link parseSchemaSnapshot} when the baseline file exists but is
3378
+ * malformed (bad JSON / wrong version / invalid table shape). Lets the CLI gate
3379
+ * treat a corrupt baseline as a hard error rather than silently degrading to a
3380
+ * "first capture" that would mask drift and then overwrite the bad file.
3381
+ */
3382
+ declare class SchemaSnapshotParseError extends LunoraError {
3383
+ constructor(message: string);
3384
+ }
3385
+ /**
3386
+ * Parse a committed snapshot file. Returns `undefined` ONLY when the content is
3387
+ * absent/empty; throws {@link SchemaSnapshotParseError} when content is present
3388
+ * but malformed (bad JSON, wrong version, or structurally-invalid tables) so the
3389
+ * caller can distinguish "no baseline yet" (a legitimate first capture) from "a
3390
+ * corrupt baseline" (which must not be silently treated as a first capture).
3391
+ *
3392
+ * The parsing itself lives in `shared/schema-snapshot.ts` (the Studio reads the
3393
+ * same JSON out of the DO ledger); this wrapper only applies the CLI's policy of
3394
+ * treating a malformed baseline as fatal.
3395
+ */
3396
+ declare const parseSchemaSnapshot: (content: string | undefined) => SchemaSnapshot | undefined;
3397
+ /**
3398
+ * A `.withIndex(name)` the application's own functions make: the table read, the index named (`undefined` when the name is not a
3399
+ * string literal, so any index of the table may be the one), and where. The drift gate refuses to drop an index one of these names.
3400
+ */
3401
+ interface IndexReference {
3402
+ file: string;
3403
+ /** The exported function (or helper, or `<module>`) containing the read. */
3404
+ function: string;
3405
+ index: string | undefined;
3406
+ line: number;
3407
+ /** `""` when the table is not a string literal, so any table may be the one. */
3408
+ table: string;
3409
+ }
3410
+ /** The `.withIndex` reads among a run's discovered queries, reduced to what the index check needs. */
3411
+ declare const indexReferencesOf: (queries: ReadonlyArray<QueryReadIR>) => IndexReference[];
3412
+ /** The decision the pre-deploy gate returns. */
3413
+ interface SchemaDriftDecision {
3414
+ /** True when the deploy must be blocked (breaking drift no new migration covers, and no override). */
3415
+ blocked: boolean;
3416
+ /** Every classified change (both severities), for reporting. */
3417
+ changes: ReadonlyArray<DriftChange>;
3418
+ /**
3419
+ * Migration ids declared now but absent from the baseline. Reported for
3420
+ * context; the gate acts on which of them cover an affected TABLE, not on how
3421
+ * many there are.
3422
+ */
3423
+ newMigrationIds: ReadonlyArray<string>;
3424
+ /**
3425
+ * A multi-line, actionable explanation. Always present; empty string when
3426
+ * there is no drift at all. Mirrors the D1-placeholder guard's message style.
3427
+ */
3428
+ reason: string;
3429
+ /**
3430
+ * The breaking changes no new migration accounts for. Non-empty exactly when
3431
+ * the run blocks or an override waved it through; a caller that can read the
3432
+ * stored rows checks these.
3433
+ */
3434
+ uncovered: ReadonlyArray<DriftChange>;
3435
+ }
3436
+ /**
3437
+ * Decide whether breaking schema drift should block a deploy.
3438
+ *
3439
+ * Blocks only when the baseline exists (a first-ever capture is never blocking),
3440
+ * there is at least one `breaking` change, no new migration COVERS it, and the
3441
+ * `allowDrift` override is not set. Safe-only drift passes.
3442
+ *
3443
+ * "Covers" is per-table, not per-run: a new migration excuses breaking drift on
3444
+ * the table it iterates, and nothing else. Counting new ids alone let a backfill
3445
+ * on `messages` unblock a required field added to `users` — the gate reported
3446
+ * "accompanied by a migration" for a change that migration would never visit.
3447
+ * The shard-mode diff cites this block to justify the studio not shipping a
3448
+ * stranded-rows detector (see `shared/schema-snapshot.ts`), and that claim only
3449
+ * holds if an unrelated migration cannot wave it through.
3450
+ *
3451
+ * Only a `"backfill"` or `"rehome"` change is coverable. A `"code"` change breaks
3452
+ * a call site (a dropped index a query still names); rewriting rows fixes neither,
3453
+ * so a migration must not excuse it however well its table matches. It is cleared
3454
+ * by fixing the code (`--allow-schema-drift` skips it for one run).
3455
+ */
3456
+ declare const evaluateSchemaDrift: (options: {
3457
+ allowDrift?: boolean;
3458
+ baseline: SchemaSnapshot | undefined;
3459
+ /** The command printing the remediation, so it names only flags that command accepts. */
3460
+ command?: string;
3461
+ current: SchemaSnapshot;
3462
+ /** The `.withIndex` reads the application makes, so a dropped index a query still names is refused. */
3463
+ indexReferences?: ReadonlyArray<IndexReference>;
3464
+ /** This run's declared migrations, so a new one is matched to the table it iterates. */
3465
+ migrations: ReadonlyArray<Pick<MigrationIR, "covers" | "id" | "identity" | "table">>;
3466
+ }) => SchemaDriftDecision;
3289
3467
  interface CodegenOptions {
3290
3468
  /**
3291
3469
  * Which machine-readable API spec(s) to emit into `_generated/`.
@@ -3342,14 +3520,6 @@ interface CodegenOptions {
3342
3520
  * `platform_unknown_target` diagnostic.
3343
3521
  */
3344
3522
  target?: string;
3345
- /**
3346
- * Re-bless the committed schema-drift baseline (`lunora/.lunora-schema.json`)
3347
- * with the current structural snapshot. The baseline is ALWAYS written on
3348
- * first capture (when the file is absent); set this to overwrite an existing
3349
- * one — e.g. after the developer has added the data migration that justifies
3350
- * a breaking change. Ignored when `dryRun` is true.
3351
- */
3352
- updateSchemaBaseline?: boolean;
3353
3523
  /**
3354
3524
  * Every `queues.producers[]` entry of `wrangler.jsonc`, top level and each
3355
3525
  * `env.<name>` block. A producer naming a push queue's binding with another
@@ -3466,6 +3636,11 @@ interface CodegenResult {
3466
3636
  /** WorkflowEntrypoint classes (`_generated/workflows.ts`); `""` (and not written) when no workflows are declared. */
3467
3637
  workflows: string;
3468
3638
  };
3639
+ /**
3640
+ * Every `.withIndex(name)` the application's functions make, so the drift gate can refuse to drop an index a
3641
+ * query still names. Computed on every run, lint or not: the gate must not depend on an advisory opt-out.
3642
+ */
3643
+ indexReferences: ReadonlyArray<IndexReference>;
3469
3644
  /**
3470
3645
  * Data migrations discovered from `defineMigration` exports under `lunora/`,
3471
3646
  * each with the table it iterates. The drift gate matches a NEW id against
@@ -3499,6 +3674,12 @@ interface CodegenResult {
3499
3674
  schemaSnapshot: SchemaSnapshot;
3500
3675
  /** Absolute path of the committed baseline file (`lunora/.lunora-schema.json`). */
3501
3676
  schemaSnapshotPath: string;
3677
+ /**
3678
+ * The parsed tables this run's snapshot was built from. The snapshot keeps a
3679
+ * field's kind but not whether its validator was resolvable, so a caller that
3680
+ * checks stored rows against the schema reads the validators here.
3681
+ */
3682
+ schemaTables: ReadonlyArray<TableIR>;
3502
3683
  /**
3503
3684
  * Workflows discovered from `defineWorkflow` exports in
3504
3685
  * `lunora/workflows.ts` — the list the config layer reconciles into
@@ -4664,86 +4845,6 @@ declare const loadProjectConfig: (projectRoot: string) => Promise<LoadedProjectC
4664
4845
  * module header for what this can and cannot see, and why.
4665
4846
  */
4666
4847
  declare const readProjectConfigLiterals: (projectRoot: string) => ProjectConfigLiterals;
4667
- /**
4668
- * Build a {@link SchemaSnapshot} from a parsed {@link SchemaIR} and the set of
4669
- * declared migration ids. Tables and migration ids are sorted so the emitted
4670
- * JSON is byte-stable across runs AND across machines (no spurious diffs /
4671
- * churn) — see `sortKeys` in `shared/schema-snapshot.ts` for why that ordering
4672
- * must not be locale-aware.
4673
- *
4674
- * Field / index / relation keys are sorted the same way, by `tableSnapshotOf` —
4675
- * see there for why declaration order was the wrong default for a hashed file.
4676
- */
4677
- declare const buildSchemaSnapshot: (schema: SchemaIR, migrationIds: ReadonlyArray<string>) => SchemaSnapshot;
4678
- /**
4679
- * Thrown by {@link parseSchemaSnapshot} when the baseline file exists but is
4680
- * malformed (bad JSON / wrong version / invalid table shape). Lets the CLI gate
4681
- * treat a corrupt baseline as a hard error rather than silently degrading to a
4682
- * "first capture" that would mask drift and then overwrite the bad file.
4683
- */
4684
- declare class SchemaSnapshotParseError extends LunoraError {
4685
- constructor(message: string);
4686
- }
4687
- /**
4688
- * Parse a committed snapshot file. Returns `undefined` ONLY when the content is
4689
- * absent/empty; throws {@link SchemaSnapshotParseError} when content is present
4690
- * but malformed (bad JSON, wrong version, or structurally-invalid tables) so the
4691
- * caller can distinguish "no baseline yet" (a legitimate first capture) from "a
4692
- * corrupt baseline" (which must not be silently treated as a first capture).
4693
- *
4694
- * The parsing itself lives in `shared/schema-snapshot.ts` (the Studio reads the
4695
- * same JSON out of the DO ledger); this wrapper only applies the CLI's policy of
4696
- * treating a malformed baseline as fatal.
4697
- */
4698
- declare const parseSchemaSnapshot: (content: string | undefined) => SchemaSnapshot | undefined;
4699
- /** The decision the pre-deploy gate returns. */
4700
- interface SchemaDriftDecision {
4701
- /** True when the deploy must be blocked (breaking drift no new migration covers, and no override). */
4702
- blocked: boolean;
4703
- /** Every classified change (both severities), for reporting. */
4704
- changes: ReadonlyArray<DriftChange>;
4705
- /**
4706
- * Migration ids declared now but absent from the baseline. Reported for
4707
- * context; the gate acts on which of them cover an affected TABLE, not on how
4708
- * many there are.
4709
- */
4710
- newMigrationIds: ReadonlyArray<string>;
4711
- /**
4712
- * A multi-line, actionable explanation. Always present; empty string when
4713
- * there is no drift at all. Mirrors the D1-placeholder guard's message style.
4714
- */
4715
- reason: string;
4716
- }
4717
- /**
4718
- * Decide whether breaking schema drift should block a deploy.
4719
- *
4720
- * Blocks only when the baseline exists (a first-ever capture is never blocking),
4721
- * there is at least one `breaking` change, no new migration COVERS it, and the
4722
- * `allowDrift` override is not set. Safe-only drift passes.
4723
- *
4724
- * "Covers" is per-table, not per-run: a new migration excuses breaking drift on
4725
- * the table it iterates, and nothing else. Counting new ids alone let a backfill
4726
- * on `messages` unblock a required field added to `users` — the gate reported
4727
- * "accompanied by a migration" for a change that migration would never visit.
4728
- * The shard-mode diff cites this block to justify the studio not shipping a
4729
- * stranded-rows detector (see `shared/schema-snapshot.ts`), and that claim only
4730
- * holds if an unrelated migration cannot wave it through.
4731
- *
4732
- * Only a `"backfill"` change is coverable at all. A `"rehome"` change moves rows
4733
- * to another Durable Object or region and a `"code"` change breaks a call site;
4734
- * rewriting rows fixes neither, so a migration must not excuse them however well
4735
- * its table matches. Those are cleared by fixing the code or accepting the new
4736
- * shape (`--allow-schema-drift` / `--update-schema-baseline`).
4737
- */
4738
- declare const evaluateSchemaDrift: (options: {
4739
- allowDrift?: boolean;
4740
- baseline: SchemaSnapshot | undefined;
4741
- /** The command printing the remediation, so it names only flags that command accepts. */
4742
- command?: string;
4743
- current: SchemaSnapshot;
4744
- /** This run's declared migrations, so a new one is matched to the table it iterates. */
4745
- migrations: ReadonlyArray<Pick<MigrationIR, "id" | "table">>;
4746
- }) => SchemaDriftDecision;
4747
4848
  /**
4748
4849
  * Content hash of the schema directory's TypeScript sources — everything codegen
4749
4850
  * reads, minus its own `_generated/` output.
@@ -4802,4 +4903,4 @@ declare const secretKindOf: (value: string) => string | undefined;
4802
4903
  /** A redacted preview of a secret value — first 4 chars plus its length, never the full value. */
4803
4904
  declare const redact: (value: string) => string;
4804
4905
  declare const VERSION = "0.0.0";
4805
- export { AGENTS_FILENAME, type AgentIR, type ArchitectureManifest, type AuthApiCallIR, CAPABILITY_PROBES, CONTAINERS_FILENAME, type CapabilityKey, type CapabilityProbe, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type ContainerImageIR, type ContainerNamedImageIR, type ContextPropertyCallIR, type CronJobIR, DEFAULT_TARGET, type DefaultScheduledContainerIR, type DriftChange, type DriftRemediation, type DriftScope, type DurableObjectScheduledContainerIR, 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, type LoadedProjectConfig, type LunoraProjectConfig, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, type NotifyChannels, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcEmitInput, PROJECT_CONFIG_FILENAMES, type PlatformDiagnostic, type ProjectConfigLiterals, type ProjectIR, QUEUES_FILENAME, type QueryReadIR, type QueueIR, 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 ServiceBindingIR, type ServiceLiteral, type ShapeIR, type SourceCapabilitySignals, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, type TargetScope, type TopicIR, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, type WranglerQueueProducerIR, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, capabilitiesUsedBy, createCodegenProject, createTargetScope, describeErrorLevelFindings, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverHyperdriveCalls, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyChannels, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitInternalApi, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitScheduler, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, errorAdvisoryNames, errorPlatformDiagnosticNames, evaluateSchemaDrift, findCodegenConfigFile, findProjectConfigFile, findTsconfig, fingerprintSchemaSources, foldCapabilitySignals, formatAdvisories, isD1GlobalTable, isHyperdriveGlobalTable, isTestPath, lintSchema, listLunoraSourceFiles, loadProjectConfig, mayReadCapabilityContext, parseSchemaSnapshot, platformMatrixIds, projectConfigCandidatePaths, readPackageDependencies, readProjectConfigLiterals, readProjectTarget, readServiceBindings, redact, refreshCodegenProject, resolveCodegenTarget, resolveServiceBindings, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, sortedUniqueNames, sourceCapabilitySignals, toAdvisorContext, tsconfigFingerprint, validatorIrToJsonSchema };
4906
+ export { AGENTS_FILENAME, type AgentIR, type ArchitectureManifest, type AuthApiCallIR, CAPABILITY_PROBES, CONTAINERS_FILENAME, type CapabilityKey, type CapabilityProbe, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type ContainerImageIR, type ContainerNamedImageIR, type ContextPropertyCallIR, type CronJobIR, DEFAULT_TARGET, type DefaultScheduledContainerIR, type DriftChange, type DriftRemediation, type DriftScope, type DurableObjectScheduledContainerIR, type EmitAppOptions, FLAGS_FILENAME, type FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexReference, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, type LintSchemaOptions, type LoadedProjectConfig, type LunoraProjectConfig, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, type NotifyChannels, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcEmitInput, PROJECT_CONFIG_FILENAMES, type PlatformDiagnostic, type ProjectConfigLiterals, type ProjectIR, QUEUES_FILENAME, type QueryReadIR, type QueueIR, 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 ServiceBindingIR, type ServiceLiteral, type ShapeIR, type SourceCapabilitySignals, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, type TargetScope, type TopicIR, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, type WranglerQueueProducerIR, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, capabilitiesUsedBy, createCodegenProject, createTargetScope, describeErrorLevelFindings, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverHyperdriveCalls, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyChannels, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitInternalApi, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitScheduler, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, errorAdvisoryNames, errorPlatformDiagnosticNames, evaluateSchemaDrift, findCodegenConfigFile, findProjectConfigFile, findTsconfig, fingerprintSchemaSources, foldCapabilitySignals, formatAdvisories, indexReferencesOf, isD1GlobalTable, isHyperdriveGlobalTable, isTestPath, lintSchema, listLunoraSourceFiles, loadProjectConfig, mayReadCapabilityContext, parseSchemaSnapshot, platformMatrixIds, projectConfigCandidatePaths, readPackageDependencies, readProjectConfigLiterals, readProjectTarget, readServiceBindings, redact, refreshCodegenProject, resolveCodegenTarget, resolveServiceBindings, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, sortedUniqueNames, sourceCapabilitySignals, toAdvisorContext, tsconfigFingerprint, validatorIrToJsonSchema };