@prisma-next/family-sql 0.12.0-dev.27 → 0.12.0-dev.29

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.
@@ -1,4 +1,4 @@
1
- import { A as SqlPlannerResult, C as SqlMigrationRunnerResult, D as SqlPlannerConflictKind, E as SqlPlannerConflict, M as StorageTypePlanResult, N as SqlControlFamilyInstance, O as SqlPlannerConflictLocation, S as SqlMigrationRunnerFailure, T as SqlPlanTargetDetails, _ as SqlMigrationPlannerPlanOptions, a as FieldEvent, b as SqlMigrationRunnerExecuteCallbacks, c as SqlControlAdapterDescriptor, d as SqlMigrationPlan, f as SqlMigrationPlanContractInfo, g as SqlMigrationPlanner, h as SqlMigrationPlanOperationTarget, i as ExpandNativeTypeInput, j as SqlPlannerSuccessResult, k as SqlPlannerFailureResult, l as SqlControlExtensionDescriptor, m as SqlMigrationPlanOperationStep, n as CodecControlHooks, o as FieldEventContext, p as SqlMigrationPlanOperation, r as CreateSqlMigrationPlanOptions, s as ResolveIdentityValueInput, t as AnyRecord, u as SqlControlTargetDescriptor, v as SqlMigrationRunner, w as SqlMigrationRunnerSuccessValue, x as SqlMigrationRunnerExecuteOptions, y as SqlMigrationRunnerErrorCode } from "./types-DsdKvKFN.mjs";
1
+ import { A as SqlPlannerResult, C as SqlMigrationRunnerResult, D as SqlPlannerConflictKind, E as SqlPlannerConflict, M as StorageTypePlanResult, N as SqlControlFamilyInstance, O as SqlPlannerConflictLocation, S as SqlMigrationRunnerFailure, T as SqlPlanTargetDetails, _ as SqlMigrationPlannerPlanOptions, a as FieldEvent, b as SqlMigrationRunnerExecuteCallbacks, c as SqlControlAdapterDescriptor, d as SqlMigrationPlan, f as SqlMigrationPlanContractInfo, g as SqlMigrationPlanner, h as SqlMigrationPlanOperationTarget, i as ExpandNativeTypeInput, j as SqlPlannerSuccessResult, k as SqlPlannerFailureResult, l as SqlControlExtensionDescriptor, m as SqlMigrationPlanOperationStep, n as CodecControlHooks, o as FieldEventContext, p as SqlMigrationPlanOperation, r as CreateSqlMigrationPlanOptions, s as ResolveIdentityValueInput, t as AnyRecord, u as SqlControlTargetDescriptor, v as SqlMigrationRunner, w as SqlMigrationRunnerSuccessValue, x as SqlMigrationRunnerExecuteOptions, y as SqlMigrationRunnerErrorCode } from "./types-B084B5kI.mjs";
2
2
  import { ControlFamilyDescriptor, ControlStack, MigrationOperationClass, MigrationOperationPolicy, MigrationOperationPolicy as MigrationOperationPolicy$1, MigrationPlan, MigrationPlanOperation, MigrationPlanner, MigrationPlannerConflict, MigrationPlannerConflict as MigrationPlannerConflict$1, MigrationPlannerResult, MutationDefaultGeneratorDescriptor, OpFactoryCall, TargetMigrationsCapability, assembleAuthoringContributions } from "@prisma-next/framework-components/control";
3
3
  import { SqlStorage, StorageColumn } from "@prisma-next/sql-contract/types";
4
4
  import { ColumnDefault, Contract, ControlPolicy } from "@prisma-next/contract/types";
@@ -347,11 +347,97 @@ interface ControlPolicySubject {
347
347
  */
348
348
  readonly createsNewObject: boolean;
349
349
  }
350
- declare function filterCallsByControlPolicy<TCall>(options: {
350
+ /**
351
+ * The control policy that governs a single call. The `external` default is an
352
+ * un-overridable namespace floor: when the contract default is `external`, no
353
+ * per-object `managed` override can escalate DDL above the floor, so the
354
+ * policy is forced to `external` regardless of the node's own declaration.
355
+ * Every other default defers to the node's effective control policy.
356
+ */
357
+ declare function controlPolicyForCall(subject: ControlPolicySubject | undefined, defaultControlPolicy: ControlPolicy | undefined): ControlPolicy;
358
+ /**
359
+ * Partition the calls produced for a single set of subjects into those the
360
+ * effective control policy permits (`kept`) and a list of
361
+ * {@link SqlPlannerConflict} warnings describing the suppressed calls.
362
+ *
363
+ * **Prefer {@link partitionIssuesByControlPolicy}** for the schema-issue
364
+ * pipeline: it filters subjects out of the planner's *input* so the planner
365
+ * never has to reason about un-modeled state on `external`/`observed`
366
+ * subjects. This call-level helper remains for paths that bypass the issue
367
+ * pipeline — currently the codec-emitted field-event ops, which originate
368
+ * from declared contract fields rather than from introspected schema state
369
+ * and therefore cannot trip the diff engine.
370
+ */
371
+ declare function partitionCallsByControlPolicy<TCall>(options: {
351
372
  readonly calls: readonly TCall[];
352
373
  readonly contract: Contract<SqlStorage>;
353
374
  readonly resolveControlPolicySubject: (call: TCall) => ControlPolicySubject | undefined;
354
- }): readonly TCall[];
375
+ readonly resolveFactoryName: (call: TCall) => string;
376
+ readonly formatSubjectLabel?: (factoryName: string, subject: ControlPolicySubject | undefined) => string;
377
+ }): {
378
+ readonly kept: readonly TCall[];
379
+ readonly warnings: readonly SqlPlannerConflict[];
380
+ };
381
+ /**
382
+ * Partition a list of schema-issue-shaped inputs by the effective control
383
+ * policy of each issue's subject *before* the planner is invoked.
384
+ *
385
+ * `plannable` is the list of issues whose subject's effective policy permits
386
+ * the planner to act on them (`managed`, or `tolerated` for whole-object
387
+ * creation issues only). Issues for `external`/`observed` subjects, and
388
+ * non-creation issues for `tolerated` subjects, are dropped from the planner's
389
+ * input entirely — they never enter introspection-driven planning, never feed
390
+ * the diff engine, and never produce DDL calls that would have to be
391
+ * post-filtered. This sidesteps a class of failure where the diff engine
392
+ * cannot reason about the live shape of a subject the user marked as
393
+ * out-of-scope (`external`).
394
+ *
395
+ * `warnings` is one {@link SqlPlannerConflict} per suppressed subject (not per
396
+ * suppressed issue). `factoryName` is inferred from the subject's issue mix:
397
+ * if any of the subject's issues is whole-object creation, the warning takes
398
+ * the corresponding creation factoryName (e.g. `createTable`,
399
+ * `createEnumType`, `createSchema`); otherwise it falls back to
400
+ * `defaultModificationFactoryName(subject)` — a synthetic label that names
401
+ * the *kind* of mutation that would have run, since no concrete DDL call was
402
+ * generated.
403
+ *
404
+ * Unresolved-subject issues (`resolveControlPolicySubject` returns
405
+ * `undefined`) emit one warning each; they cannot be deduplicated because
406
+ * they carry no subject coordinate.
407
+ */
408
+ declare function partitionIssuesByControlPolicy<TIssue>(options: {
409
+ readonly issues: readonly TIssue[];
410
+ readonly contract: Contract<SqlStorage>;
411
+ /**
412
+ * Resolve the subject targeted by this issue (or `undefined` to fail-closed:
413
+ * any policy stricter than `managed` drops the issue).
414
+ */
415
+ readonly resolveControlPolicySubject: (issue: TIssue) => ControlPolicySubject | undefined;
416
+ /**
417
+ * Resolve a creation factoryName for this issue if it represents the
418
+ * absence of the whole top-level object (e.g. `'createTable'` for a
419
+ * missing-table issue). When the issue describes a modification to an
420
+ * existing object, return `undefined`. Both decisions feed off this signal:
421
+ *
422
+ * 1. Under `tolerated`, only issues whose `resolveCreationFactoryName`
423
+ * returns a value flow into the planner (create-if-absent).
424
+ * 2. Subjects that have at least one creation-flavoured issue use the
425
+ * resolved creation factoryName for their suppression warning;
426
+ * otherwise they fall back to `defaultModificationFactoryName`.
427
+ */
428
+ readonly resolveCreationFactoryName: (issue: TIssue) => string | undefined;
429
+ /**
430
+ * Default modification factoryName for a suppressed subject whose issues
431
+ * are all non-creation (the subject exists but has a different shape).
432
+ * Defaults to `'alterTable'` / `'alterType'` / `'alterSchema'` based on the
433
+ * subject's populated coordinates.
434
+ */
435
+ readonly defaultModificationFactoryName?: (subject: ControlPolicySubject) => string;
436
+ readonly formatSubjectLabel?: (factoryName: string, subject: ControlPolicySubject | undefined) => string;
437
+ }): {
438
+ readonly plannable: readonly TIssue[];
439
+ readonly warnings: readonly SqlPlannerConflict[];
440
+ };
355
441
  //#endregion
356
442
  //#region src/core/migrations/field-event-planner.d.ts
357
443
  interface PlanFieldEventOperationsOptions {
@@ -379,7 +465,7 @@ declare function planFieldEventOperations(options: PlanFieldEventOperationsOptio
379
465
  //#endregion
380
466
  //#region src/core/migrations/plan-helpers.d.ts
381
467
  declare function createMigrationPlan<TTargetDetails>(options: CreateSqlMigrationPlanOptions<TTargetDetails>): SqlMigrationPlan<TTargetDetails>;
382
- declare function plannerSuccess<TTargetDetails>(plan: SqlMigrationPlan<TTargetDetails>): SqlPlannerSuccessResult<TTargetDetails>;
468
+ declare function plannerSuccess<TTargetDetails>(plan: SqlMigrationPlan<TTargetDetails>, warnings?: readonly SqlPlannerConflict[]): SqlPlannerSuccessResult<TTargetDetails>;
383
469
  declare function plannerFailure(conflicts: readonly SqlPlannerConflict[]): SqlPlannerFailureResult;
384
470
  /**
385
471
  * Creates a successful migration runner result.
@@ -462,5 +548,5 @@ declare function temporalAuthoringPresets<const CodecId extends string, const Na
462
548
  //#region src/exports/control.d.ts
463
549
  declare const _default: SqlFamilyDescriptor;
464
550
  //#endregion
465
- export { type CodecControlHooks, type ContractToSchemaIROptions, type ControlPolicySubject, type CreateSqlMigrationPlanOptions, type DefaultRenderer, type EnumStorageKeyResolver, type ExpandNativeTypeInput, type FieldEvent, type FieldEventContext, INIT_ADDITIVE_POLICY, type MigrationOperationClass, type MigrationOperationPolicy, type MigrationPlan, type MigrationPlanOperation, type MigrationPlanner, type MigrationPlannerConflict, type MigrationPlannerResult, type NativeTypeExpander, type PlanFieldEventOperationsOptions, type ResolveIdentityValueInput, type SqlControlAdapterDescriptor, type SqlControlExtensionDescriptor, type SqlControlFamilyInstance, type SqlControlTargetDescriptor, type SqlMigrationPlan, type SqlMigrationPlanContractInfo, type SqlMigrationPlanOperation, type SqlMigrationPlanOperationStep, type SqlMigrationPlanOperationTarget, type SqlMigrationPlanner, type SqlMigrationPlannerPlanOptions, type SqlMigrationRunner, type SqlMigrationRunnerErrorCode, type SqlMigrationRunnerExecuteCallbacks, type SqlMigrationRunnerExecuteOptions, type SqlMigrationRunnerFailure, type SqlMigrationRunnerResult, type SqlMigrationRunnerSuccessValue, type SqlPlanTargetDetails, type SqlPlannerConflict, type SqlPlannerConflictKind, type SqlPlannerConflictLocation, type SqlPlannerFailureResult, type SqlPlannerResult, type SqlPlannerSuccessResult, type StorageTypePlanResult, type TargetMigrationsCapability, assembleAuthoringContributions, contractToSchemaIR, createMigrationPlan, _default as default, detectDestructiveChanges, extractCodecControlHooks, filterCallsByControlPolicy, planFieldEventOperations, plannerFailure, plannerSuccess, runnerFailure, runnerSuccess, temporalAuthoringPresets, timestampNowControlDescriptor };
551
+ export { type CodecControlHooks, type ContractToSchemaIROptions, type ControlPolicySubject, type CreateSqlMigrationPlanOptions, type DefaultRenderer, type EnumStorageKeyResolver, type ExpandNativeTypeInput, type FieldEvent, type FieldEventContext, INIT_ADDITIVE_POLICY, type MigrationOperationClass, type MigrationOperationPolicy, type MigrationPlan, type MigrationPlanOperation, type MigrationPlanner, type MigrationPlannerConflict, type MigrationPlannerResult, type NativeTypeExpander, type PlanFieldEventOperationsOptions, type ResolveIdentityValueInput, type SqlControlAdapterDescriptor, type SqlControlExtensionDescriptor, type SqlControlFamilyInstance, type SqlControlTargetDescriptor, type SqlMigrationPlan, type SqlMigrationPlanContractInfo, type SqlMigrationPlanOperation, type SqlMigrationPlanOperationStep, type SqlMigrationPlanOperationTarget, type SqlMigrationPlanner, type SqlMigrationPlannerPlanOptions, type SqlMigrationRunner, type SqlMigrationRunnerErrorCode, type SqlMigrationRunnerExecuteCallbacks, type SqlMigrationRunnerExecuteOptions, type SqlMigrationRunnerFailure, type SqlMigrationRunnerResult, type SqlMigrationRunnerSuccessValue, type SqlPlanTargetDetails, type SqlPlannerConflict, type SqlPlannerConflictKind, type SqlPlannerConflictLocation, type SqlPlannerFailureResult, type SqlPlannerResult, type SqlPlannerSuccessResult, type StorageTypePlanResult, type TargetMigrationsCapability, assembleAuthoringContributions, contractToSchemaIR, controlPolicyForCall, createMigrationPlan, _default as default, detectDestructiveChanges, extractCodecControlHooks, partitionCallsByControlPolicy, partitionIssuesByControlPolicy, planFieldEventOperations, plannerFailure, plannerSuccess, runnerFailure, runnerSuccess, temporalAuthoringPresets, timestampNowControlDescriptor };
466
552
  //# sourceMappingURL=control.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"control.d.mts","names":[],"sources":["../src/core/control-descriptor.ts","../src/core/assembly.ts","../src/core/migrations/contract-to-schema-ir.ts","../src/core/migrations/control-policy.ts","../src/core/migrations/field-event-planner.ts","../src/core/migrations/plan-helpers.ts","../src/core/migrations/policies.ts","../src/core/timest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AY,UAAA;AAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cCwBlB,QAAA"}
1
+ {"version":3,"file":"control.d.mts","names":[],"sources":["../src/core/control-descriptor.ts","../src/core/assembly.ts","../src/core/migrations/contract-to-schema-ir.ts","../src/core/migrations/control-policy.ts","../src/core/migrations/field-event-planner.ts","../src/core/migrations/plan-helpers.ts","../src/core/migrations/policies.ts","../src/core/timestamp-now-generator.ts","../src/exports/control.ts"],"mappings":";;;;;;;;;;cAUa,mBAAA,YACA,uBAAA,QAA+B,wBAAA;EAAA,SAEjC,IAAA;EAAA,SACA,EAAA;EAAA,SACA,QAAA;EAAA,SACA,OAAA;EAAA,SACA,QAAA,EAAU,WAAA;EAAA,SACV,SAAA;IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKT,MAAA,0BAAA,CACE,KAAA,EAAO,YAAA,QAAoB,SAAA,IAC1B,wBAAA;AAAA;;;iBCHW,wBAAA,CACd,WAAA,EAAa,aAAA,CAAc,8BAAA,mBAC1B,GAAA,SAAY,iBAAA;;;;;;;;;ADdf;;;;KE4BY,kBAAA,IAAsB,KAAA;EAAA,SACvB,UAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA,GAAa,MAAM;AAAA;;;;;;;;;;KAYlB,eAAA,IAAmB,GAAA,EAAK,aAAA,EAAe,MAAA,EAAQ,aAAa;;;;;;;;;;;;;;;KAgB5D,sBAAA,IACV,OAAA,EAAS,UAAU,EACnB,WAAA,UACA,UAAA;;;;;;;;;;iBAmKc,wBAAA,CACd,IAAA,EAAM,UAAA,SACN,EAAA,EAAI,U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AAA;EAAA,SAGF,SAAA,WAAoB,MAAA;EAAA,SACpB,QAAA,WAAmB,kBAAA;AAAA;;;UCpNb,+BAAA;EJZI;;;;EAAA,SIiBV,aAAA,EAAe,QAAA,CAAS,UAAA;;;;WAIxB,WAAA,EAAa,QAAA,CAAS,UAAA;;;;;;;;;;WAUtB,UAAA,EAAY,WAAA,SAAoB,iBAAA;AAAA;AAAA,iBAa3B,wBAAA,CACd,OAAA,EAAS,+BAAA,YACC,aAAa;;;iBCgCT,mBAAA,gBAAA,CACd,OAAA,EAAS,6BAAA,CAA8B,cAAA,IACtC,gBAAA,CAAiB,cAAA;AAAA,iBAcJ,cAAA,gBAAA,CACd,IAAA,EAAM,gBAAA,CAAiB,cAAA,GACvB,QAAA,YAAoB,kBAAA,KACnB,uBAAA,CAAwB,cAAA;AAAA,iBAsBX,cAAA,CAAe,SAAA,WAAoB,kBAAA,KAAuB,uBAAuB;;;;iBAoBjF,aAAA,CAAc,KAAA;EAC5B,iBAAA;EACA,kBAAA;AAAA,IACE,EAAE,CAAC,8BAAA;;;;iBAYS,aAAA,CACd,IAAA,EAAM,2BAAA,EACN,OAAA,UACA,OAAA;EAAY,GAAA;EAAc,IAAA,GAAO,SAAA;AAAA,IAChC,KAAA,CAAM,yBAAA;;;;;;cC1KI,oBAAA,EAAsB,0BAEjC;;;;;;;;;;;;;;iBCoBc,6BAAA,CAAA,GAAiC,kCAAkC;;;;;;;;;;;iBAqBnE,wBAAA,+DAAA,CAGd,KAAA;EAAA,SAAkB,OAAA,EAAS,OAAA;EAAA,SAAkB,UAAA,EAAY,UAAA;AAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cC4BlB,QAAA"}
package/dist/control.mjs CHANGED
@@ -1654,14 +1654,144 @@ function callAllowedUnderControlPolicy(policy, subject) {
1654
1654
  case "observed": return false;
1655
1655
  }
1656
1656
  }
1657
- function filterCallsByControlPolicy(options) {
1657
+ function defaultSubjectLabel(factoryName, subject) {
1658
+ if (subject?.table) return `${factoryName}(${subject.table})`;
1659
+ if (subject?.typeName) return `${factoryName}(${subject.typeName})`;
1660
+ return factoryName;
1661
+ }
1662
+ function suppressionSummary(subjectLabel, subject, effectivePolicy) {
1663
+ const namespace = subject?.namespaceId ?? "unknown";
1664
+ const declared = subject?.explicitNodeControlPolicy;
1665
+ if (effectivePolicy === "external" && declared === "managed") return `control policy suppressed: ${subjectLabel} — namespace '${namespace}' has effective control 'external' but table declared 'managed'`;
1666
+ return `control policy suppressed: ${subjectLabel} — namespace '${namespace}' has effective control '${effectivePolicy}'${declared ? ` but table declared '${declared}'` : ""}`;
1667
+ }
1668
+ function buildSubjectSuppressionWarning(subject, effectivePolicy, factoryName, formatSubjectLabel) {
1669
+ return {
1670
+ kind: "controlPolicySuppressedCall",
1671
+ summary: suppressionSummary(formatSubjectLabel(factoryName, subject), subject, effectivePolicy),
1672
+ location: {
1673
+ ...ifDefined("namespace", subject?.namespaceId),
1674
+ ...ifDefined("table", subject?.table),
1675
+ ...ifDefined("column", subject?.column),
1676
+ ...ifDefined("type", subject?.typeName)
1677
+ },
1678
+ meta: {
1679
+ controlPolicy: effectivePolicy,
1680
+ factoryName,
1681
+ ...ifDefined("declaredControlPolicy", subject?.explicitNodeControlPolicy)
1682
+ }
1683
+ };
1684
+ }
1685
+ function defaultModificationFactoryNameForSubject(subject) {
1686
+ if (subject.table) return "alterTable";
1687
+ if (subject.typeName) return "alterType";
1688
+ return "alterSchema";
1689
+ }
1690
+ /**
1691
+ * Partition the calls produced for a single set of subjects into those the
1692
+ * effective control policy permits (`kept`) and a list of
1693
+ * {@link SqlPlannerConflict} warnings describing the suppressed calls.
1694
+ *
1695
+ * **Prefer {@link partitionIssuesByControlPolicy}** for the schema-issue
1696
+ * pipeline: it filters subjects out of the planner's *input* so the planner
1697
+ * never has to reason about un-modeled state on `external`/`observed`
1698
+ * subjects. This call-level helper remains for paths that bypass the issue
1699
+ * pipeline — currently the codec-emitted field-event ops, which originate
1700
+ * from declared contract fields rather than from introspected schema state
1701
+ * and therefore cannot trip the diff engine.
1702
+ */
1703
+ function partitionCallsByControlPolicy(options) {
1658
1704
  const defaultControlPolicy = options.contract.defaultControlPolicy;
1705
+ const formatSubjectLabel = options.formatSubjectLabel ?? defaultSubjectLabel;
1659
1706
  const kept = [];
1707
+ const warnings = [];
1660
1708
  for (const call of options.calls) {
1661
1709
  const subject = options.resolveControlPolicySubject(call);
1662
- if (callAllowedUnderControlPolicy(controlPolicyForCall(subject, defaultControlPolicy), subject)) kept.push(call);
1710
+ const policy = controlPolicyForCall(subject, defaultControlPolicy);
1711
+ if (callAllowedUnderControlPolicy(policy, subject)) kept.push(call);
1712
+ else {
1713
+ const factoryName = options.resolveFactoryName(call);
1714
+ warnings.push(buildSubjectSuppressionWarning(subject, policy, factoryName, formatSubjectLabel));
1715
+ }
1716
+ }
1717
+ return Object.freeze({
1718
+ kept: Object.freeze(kept),
1719
+ warnings: Object.freeze(warnings)
1720
+ });
1721
+ }
1722
+ /**
1723
+ * Partition a list of schema-issue-shaped inputs by the effective control
1724
+ * policy of each issue's subject *before* the planner is invoked.
1725
+ *
1726
+ * `plannable` is the list of issues whose subject's effective policy permits
1727
+ * the planner to act on them (`managed`, or `tolerated` for whole-object
1728
+ * creation issues only). Issues for `external`/`observed` subjects, and
1729
+ * non-creation issues for `tolerated` subjects, are dropped from the planner's
1730
+ * input entirely — they never enter introspection-driven planning, never feed
1731
+ * the diff engine, and never produce DDL calls that would have to be
1732
+ * post-filtered. This sidesteps a class of failure where the diff engine
1733
+ * cannot reason about the live shape of a subject the user marked as
1734
+ * out-of-scope (`external`).
1735
+ *
1736
+ * `warnings` is one {@link SqlPlannerConflict} per suppressed subject (not per
1737
+ * suppressed issue). `factoryName` is inferred from the subject's issue mix:
1738
+ * if any of the subject's issues is whole-object creation, the warning takes
1739
+ * the corresponding creation factoryName (e.g. `createTable`,
1740
+ * `createEnumType`, `createSchema`); otherwise it falls back to
1741
+ * `defaultModificationFactoryName(subject)` — a synthetic label that names
1742
+ * the *kind* of mutation that would have run, since no concrete DDL call was
1743
+ * generated.
1744
+ *
1745
+ * Unresolved-subject issues (`resolveControlPolicySubject` returns
1746
+ * `undefined`) emit one warning each; they cannot be deduplicated because
1747
+ * they carry no subject coordinate.
1748
+ */
1749
+ function partitionIssuesByControlPolicy(options) {
1750
+ const defaultControlPolicy = options.contract.defaultControlPolicy;
1751
+ const formatSubjectLabel = options.formatSubjectLabel ?? defaultSubjectLabel;
1752
+ const inferModificationFactoryName = options.defaultModificationFactoryName ?? defaultModificationFactoryNameForSubject;
1753
+ const plannable = [];
1754
+ const suppressedSubjects = /* @__PURE__ */ new Map();
1755
+ const unresolvedSuppressions = [];
1756
+ for (const issue of options.issues) {
1757
+ const subject = options.resolveControlPolicySubject(issue);
1758
+ const policy = controlPolicyForCall(subject, defaultControlPolicy);
1759
+ const creationFactoryName = options.resolveCreationFactoryName(issue);
1760
+ if (policy === "managed") {
1761
+ plannable.push(issue);
1762
+ continue;
1763
+ }
1764
+ if (policy === "tolerated" && subject !== void 0 && creationFactoryName !== void 0 && subject.createsNewObject) {
1765
+ plannable.push(issue);
1766
+ continue;
1767
+ }
1768
+ if (subject === void 0) {
1769
+ const factoryName = creationFactoryName ?? "unknown";
1770
+ unresolvedSuppressions.push(buildSubjectSuppressionWarning(void 0, policy, factoryName, formatSubjectLabel));
1771
+ continue;
1772
+ }
1773
+ const key = subjectKey(subject);
1774
+ const existing = suppressedSubjects.get(key);
1775
+ if (existing) {
1776
+ if (existing.creationFactoryName === void 0 && creationFactoryName !== void 0) existing.creationFactoryName = creationFactoryName;
1777
+ } else suppressedSubjects.set(key, {
1778
+ subject,
1779
+ policy,
1780
+ ...ifDefined("creationFactoryName", creationFactoryName)
1781
+ });
1663
1782
  }
1664
- return Object.freeze(kept);
1783
+ const warnings = [...unresolvedSuppressions];
1784
+ for (const entry of suppressedSubjects.values()) {
1785
+ const factoryName = entry.creationFactoryName ?? inferModificationFactoryName(entry.subject);
1786
+ warnings.push(buildSubjectSuppressionWarning(entry.subject, entry.policy, factoryName, formatSubjectLabel));
1787
+ }
1788
+ return Object.freeze({
1789
+ plannable: Object.freeze(plannable),
1790
+ warnings: Object.freeze(warnings)
1791
+ });
1792
+ }
1793
+ function subjectKey(subject) {
1794
+ return `${subject.namespaceId}\u0000${subject.table ?? ""}\u0000${subject.typeName ?? ""}`;
1665
1795
  }
1666
1796
  //#endregion
1667
1797
  //#region src/core/migrations/field-event-planner.ts
@@ -1844,10 +1974,17 @@ function createMigrationPlan(options) {
1844
1974
  ...options.meta ? { meta: cloneRecord(options.meta) } : {}
1845
1975
  });
1846
1976
  }
1847
- function plannerSuccess(plan) {
1977
+ function plannerSuccess(plan, warnings) {
1848
1978
  return Object.freeze({
1849
1979
  kind: "success",
1850
- plan
1980
+ plan,
1981
+ ...warnings && warnings.length > 0 ? { warnings: Object.freeze(warnings.map((conflict) => Object.freeze({
1982
+ kind: conflict.kind,
1983
+ summary: conflict.summary,
1984
+ ...conflict.why ? { why: conflict.why } : {},
1985
+ ...conflict.location ? { location: Object.freeze({ ...conflict.location }) } : {},
1986
+ ...conflict.meta ? { meta: cloneRecord(conflict.meta) } : {}
1987
+ }))) } : {}
1851
1988
  });
1852
1989
  }
1853
1990
  function plannerFailure(conflicts) {
@@ -1892,6 +2029,6 @@ const INIT_ADDITIVE_POLICY = Object.freeze({ allowedOperationClasses: Object.fre
1892
2029
  //#region src/exports/control.ts
1893
2030
  var control_default = new SqlFamilyDescriptor();
1894
2031
  //#endregion
1895
- export { INIT_ADDITIVE_POLICY, assembleAuthoringContributions, contractToSchemaIR, createMigrationPlan, control_default as default, detectDestructiveChanges, extractCodecControlHooks, filterCallsByControlPolicy, planFieldEventOperations, plannerFailure, plannerSuccess, runnerFailure, runnerSuccess, temporalAuthoringPresets, timestampNowControlDescriptor };
2032
+ export { INIT_ADDITIVE_POLICY, assembleAuthoringContributions, contractToSchemaIR, controlPolicyForCall, createMigrationPlan, control_default as default, detectDestructiveChanges, extractCodecControlHooks, partitionCallsByControlPolicy, partitionIssuesByControlPolicy, planFieldEventOperations, plannerFailure, plannerSuccess, runnerFailure, runnerSuccess, temporalAuthoringPresets, timestampNowControlDescriptor };
1896
2033
 
1897
2034
  //# sourceMappingURL=control.mjs.map