@runa-ai/runa-cli 0.8.0 → 0.9.0

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 (109) hide show
  1. package/dist/{build-HQMSVN6N.js → build-P2A6345N.js} +2 -2
  2. package/dist/{check-PCSQPYDM.js → check-4TZHNOZU.js} +4 -4
  3. package/dist/{chunk-DRSUEMAK.js → chunk-B7C7CLW2.js} +2 -5
  4. package/dist/{chunk-B3POLMII.js → chunk-BQ336L5T.js} +1 -1
  5. package/dist/{chunk-6FAU4IGR.js → chunk-ELXXQIGW.js} +4 -1
  6. package/dist/{chunk-RB2ZUS76.js → chunk-EXR4J2JT.js} +52 -16
  7. package/dist/{chunk-GHQH6UC5.js → chunk-GKBE7EIE.js} +1 -1
  8. package/dist/{chunk-JMJP4A47.js → chunk-GT5DMS5R.js} +20 -2
  9. package/dist/{chunk-3JO6YP3T.js → chunk-IEKYTCYA.js} +1 -1
  10. package/dist/{chunk-WPMR7RQ4.js → chunk-IWVXI5O4.js} +2 -2
  11. package/dist/chunk-KUH3G522.js +72 -0
  12. package/dist/{chunk-VSH3IXDQ.js → chunk-MAFJAA2P.js} +1 -1
  13. package/dist/{chunk-CCKG5R4Y.js → chunk-MILCC3B6.js} +1 -1
  14. package/dist/{chunk-5NKWR4FF.js → chunk-OERS32LW.js} +1 -1
  15. package/dist/{chunk-2QX7T24B.js → chunk-QKGL6Q2S.js} +1 -1
  16. package/dist/{chunk-OBYZDT2E.js → chunk-URWDB7YL.js} +15 -78
  17. package/dist/{chunk-ZYT7OQJB.js → chunk-WGRVAGSR.js} +6 -6
  18. package/dist/chunk-YRNQEJQW.js +9043 -0
  19. package/dist/chunk-ZWDWFMOX.js +1514 -0
  20. package/dist/{ci-ZK3LKYFX.js → ci-S5KSBECX.js} +992 -849
  21. package/dist/{cli-ZY5VRIJA.js → cli-TJZCAMB2.js} +30 -30
  22. package/dist/commands/ci/commands/ci-prod-db-operations.d.ts +12 -17
  23. package/dist/commands/ci/commands/ci-prod-utils.d.ts +7 -0
  24. package/dist/commands/ci/commands/layer4-discovery.d.ts +2 -0
  25. package/dist/commands/ci/machine/actors/db/production-preview.d.ts +4 -3
  26. package/dist/commands/ci/machine/actors/db/sync-schema.d.ts +5 -1
  27. package/dist/commands/ci/machine/actors/test/capabilities.d.ts +2 -13
  28. package/dist/commands/ci/machine/actors/test/index.d.ts +1 -0
  29. package/dist/commands/ci/machine/actors/test/layer-content.d.ts +11 -0
  30. package/dist/commands/ci/machine/commands/ci-pr-internal-profile.d.ts +7 -0
  31. package/dist/commands/ci/machine/commands/ci-step-registry.d.ts +25 -0
  32. package/dist/commands/ci/machine/commands/step-telemetry.d.ts +1 -2
  33. package/dist/commands/ci/machine/contract.d.ts +3 -0
  34. package/dist/commands/ci/machine/guards.d.ts +3 -10
  35. package/dist/commands/ci/machine/helpers.d.ts +1 -1
  36. package/dist/commands/ci/machine/machine-execution-helpers.d.ts +5 -2
  37. package/dist/commands/ci/machine/machine.d.ts +24 -30
  38. package/dist/commands/ci/machine/selectors.d.ts +6 -0
  39. package/dist/commands/ci/machine/types.d.ts +3 -1
  40. package/dist/commands/ci/utils/ci-logging.d.ts +16 -0
  41. package/dist/commands/ci/utils/rls-verification.d.ts +3 -2
  42. package/dist/commands/db/apply/actors/pg-schema-diff-actors.d.ts +1 -0
  43. package/dist/commands/db/apply/contract.d.ts +209 -0
  44. package/dist/commands/db/apply/helpers/fresh-db-handler.d.ts +2 -1
  45. package/dist/commands/db/apply/helpers/index.d.ts +3 -1
  46. package/dist/commands/db/apply/helpers/plan-ast-sql-helpers.d.ts +19 -0
  47. package/dist/commands/db/apply/helpers/plan-ast.d.ts +1 -2
  48. package/dist/commands/db/apply/helpers/plan-check-filter.d.ts +0 -14
  49. package/dist/commands/db/apply/helpers/plan-validator.d.ts +34 -0
  50. package/dist/commands/db/apply/helpers/planner-artifact.d.ts +65 -0
  51. package/dist/commands/db/apply/helpers/retry-logic.d.ts +5 -0
  52. package/dist/commands/db/apply/machine.d.ts +50 -15
  53. package/dist/commands/db/commands/db-apply-error.d.ts +6 -1
  54. package/dist/commands/db/commands/db-apply.d.ts +5 -0
  55. package/dist/commands/db/commands/db-plan.d.ts +3 -0
  56. package/dist/commands/db/commands/db-preview-profile.d.ts +23 -0
  57. package/dist/commands/db/commands/db-preview.d.ts +3 -0
  58. package/dist/commands/db/sync/actors.d.ts +1 -0
  59. package/dist/commands/db/sync/contract.d.ts +16 -0
  60. package/dist/commands/db/sync/guardrail-orchestrator.d.ts +15 -0
  61. package/dist/commands/db/sync/guardrail-reporting.d.ts +12 -0
  62. package/dist/commands/db/sync/index.d.ts +4 -0
  63. package/dist/commands/db/sync/machine.d.ts +18 -13
  64. package/dist/commands/db/sync/schema-guardrail-config-test-support.d.ts +15 -0
  65. package/dist/commands/db/sync/schema-guardrail-config.d.ts +11 -0
  66. package/dist/commands/db/sync/schema-guardrail-ddl-order.d.ts +36 -0
  67. package/dist/commands/db/sync/schema-guardrail-graph-guidance.d.ts +15 -0
  68. package/dist/commands/db/sync/schema-guardrail-graph-metadata.d.ts +41 -0
  69. package/dist/commands/db/sync/schema-guardrail-graph-nodes.d.ts +61 -0
  70. package/dist/commands/db/sync/schema-guardrail-graph-sql-helpers.d.ts +31 -0
  71. package/dist/commands/db/sync/schema-guardrail-graph-types.d.ts +56 -0
  72. package/dist/commands/db/sync/schema-guardrail-graph.d.ts +20 -0
  73. package/dist/commands/db/sync/schema-guardrail-local-blockers.d.ts +7 -0
  74. package/dist/commands/db/sync/schema-guardrail-phases.d.ts +26 -0
  75. package/dist/commands/db/sync/schema-guardrail-production-check.d.ts +23 -0
  76. package/dist/commands/db/sync/schema-guardrail-rewrite.d.ts +46 -0
  77. package/dist/commands/db/sync/schema-guardrail-runtime.d.ts +5 -0
  78. package/dist/commands/db/sync/schema-guardrail-semantic-warnings.d.ts +9 -0
  79. package/dist/commands/db/sync/schema-guardrail-types.d.ts +243 -0
  80. package/dist/commands/db/sync/schema-guardrail.d.ts +10 -0
  81. package/dist/commands/db/utils/declarative-dependency-sql-utils.d.ts +1 -1
  82. package/dist/commands/db/utils/duplicate-function-ownership.d.ts +27 -1
  83. package/dist/commands/db/utils/policy-cross-schema-refs.d.ts +12 -0
  84. package/dist/commands/db/utils/sql-table-extractor.d.ts +6 -0
  85. package/dist/commands/test/commands/layer4-prereqs.d.ts +15 -0
  86. package/dist/{config-loader-GT3HAQ7U.js → config-loader-N5ODNMD5.js} +2 -2
  87. package/dist/db-D2OLJDYW.js +12757 -0
  88. package/dist/{dev-GB5ERUVR.js → dev-LGSMDFJN.js} +7 -6
  89. package/dist/{doctor-ROSWSMLH.js → doctor-GYX73IEW.js} +4 -4
  90. package/dist/{env-WP74UUMO.js → env-KYR6Q7WO.js} +15 -10
  91. package/dist/{env-files-HRNUGZ5O.js → env-files-ONBC47I6.js} +3 -3
  92. package/dist/{hotfix-TOSGTVCW.js → hotfix-RJIAPLAM.js} +4 -4
  93. package/dist/index.js +3 -3
  94. package/dist/{init-35JLDFHI.js → init-2O6ODG5Z.js} +2 -2
  95. package/dist/{inject-test-attrs-XN4I2AOR.js → inject-test-attrs-F5A346UV.js} +3 -3
  96. package/dist/{manifest-EGCAZ4TK.js → manifest-CI4BRWEB.js} +2 -2
  97. package/dist/{observability-CJA5UFIC.js → observability-WNSCJ5FV.js} +2 -2
  98. package/dist/pg-schema-diff-helpers-7377FS2D.js +7 -0
  99. package/dist/{sdk-XK6HQU7S.js → sdk-BTIVPEE5.js} +1 -1
  100. package/dist/{test-V4KQL574.js → test-QCPN6Z47.js} +74 -46
  101. package/dist/{upgrade-7L4JIE4K.js → upgrade-QZKEI3NJ.js} +2 -2
  102. package/dist/utils/db-url-utils.d.ts +4 -77
  103. package/dist/{vuln-check-G6I4YYDC.js → vuln-check-5NUTETPW.js} +1 -1
  104. package/dist/{vuln-checker-CT2AYPIS.js → vuln-checker-UV342N66.js} +1 -1
  105. package/dist/{watch-AL4LCBRM.js → watch-RFVCEQLH.js} +3 -3
  106. package/dist/{workflow-UZIZ2JUS.js → workflow-UOG6ZZMH.js} +3 -3
  107. package/package.json +3 -3
  108. package/dist/chunk-6E2DRXIL.js +0 -452
  109. package/dist/db-EPI2DQYN.js +0 -18275
@@ -0,0 +1,65 @@
1
+ import { z } from 'zod';
2
+ import { type RunaDbEnv } from '../../utils/db-target.js';
3
+ import { type DbApplyInput, type DbApplyOutput, type DbApplyPlanner } from '../contract.js';
4
+ export declare const DbPlanArtifactSchema: z.ZodObject<{
5
+ version: z.ZodLiteral<"1">;
6
+ environment: z.ZodEnum<{
7
+ local: "local";
8
+ preview: "preview";
9
+ production: "production";
10
+ }>;
11
+ mode: z.ZodLiteral<"check">;
12
+ previewProfile: z.ZodEnum<{
13
+ full: "full";
14
+ "compare-only": "compare-only";
15
+ }>;
16
+ createdAt: z.ZodString;
17
+ hasChanges: z.ZodBoolean;
18
+ planSql: z.ZodString;
19
+ filteredPlanSql: z.ZodString;
20
+ planSummary: z.ZodOptional<z.ZodObject<{
21
+ rawStatements: z.ZodNumber;
22
+ effectiveStatements: z.ZodNumber;
23
+ noiseStatements: z.ZodNumber;
24
+ categories: z.ZodObject<{
25
+ idempotentDrop: z.ZodNumber;
26
+ idempotentAuthz: z.ZodNumber;
27
+ idempotentRls: z.ZodNumber;
28
+ suppressedFunction: z.ZodNumber;
29
+ }, z.core.$strict>;
30
+ }, z.core.$strict>>;
31
+ hazards: z.ZodArray<z.ZodString>;
32
+ sourceFingerprint: z.ZodString;
33
+ targetFingerprint: z.ZodString;
34
+ toolMetadata: z.ZodObject<{
35
+ cliVersion: z.ZodString;
36
+ pgSchemaDiffVersion: z.ZodOptional<z.ZodString>;
37
+ nodeVersion: z.ZodString;
38
+ }, z.core.$strict>;
39
+ }, z.core.$strict>;
40
+ export type DbPlanArtifact = z.infer<typeof DbPlanArtifactSchema>;
41
+ export declare function detectPlannerSchemas(repoRoot: string): string[];
42
+ export declare function buildTargetFingerprint(params: {
43
+ databaseUrl: string;
44
+ includeSchemas: string[];
45
+ }): string;
46
+ export declare function getDbPlanArtifactPath(params: {
47
+ repoRoot: string;
48
+ environment: RunaDbEnv;
49
+ previewProfile: 'compare-only' | 'full';
50
+ }): string;
51
+ export declare function persistDbPlanArtifact(params: {
52
+ repoRoot: string;
53
+ input: Pick<DbApplyInput, 'env' | 'check' | 'compareOnly' | 'databaseUrl'>;
54
+ output: Pick<DbApplyOutput, 'planSql' | 'filteredPlanSql' | 'planSummary' | 'hazards'>;
55
+ }): DbApplyPlanner;
56
+ export declare function tryReuseDbPlanArtifact(params: {
57
+ repoRoot: string;
58
+ artifactPath: string;
59
+ input: Pick<DbApplyInput, 'env' | 'databaseUrl'>;
60
+ precomputedTargetFingerprint?: string;
61
+ }): {
62
+ artifact: DbPlanArtifact | null;
63
+ planner: DbApplyPlanner;
64
+ };
65
+ //# sourceMappingURL=planner-artifact.d.ts.map
@@ -84,6 +84,11 @@ export interface PlanSqlRetryConfig extends RetryConfig {
84
84
  * Recommended for production to avoid executing ambiguous SQL plans.
85
85
  */
86
86
  failOnLowParseConfidence?: boolean;
87
+ /**
88
+ * Fail immediately when a retryable lock error occurs but re-planning is not allowed.
89
+ * Used by checked planner artifact reuse to avoid replaying stale SQL after partial execution.
90
+ */
91
+ retryRequiresReplanMessage?: string;
87
92
  }
88
93
  /**
89
94
  * Execute plan SQL via psql with retry logic.
@@ -33,11 +33,12 @@
33
33
  import { type CommandWarning } from '@runa-ai/runa';
34
34
  import { type SnapshotFrom } from 'xstate';
35
35
  import * as actors from './actors.js';
36
- import type { DbApplyInput, DbApplyPlanSummary } from './contract.js';
36
+ import type { DbApplyInput, DbApplyPlanner, DbApplyPlanSummary } from './contract.js';
37
37
  interface DbApplyContext {
38
38
  input: DbApplyInput;
39
39
  targetDir: string;
40
40
  lockAcquired: boolean;
41
+ preIdempotentTargetFingerprint: string | null;
41
42
  idempotentPreApplied: number;
42
43
  idempotentPreSkipped: number;
43
44
  idempotentPostApplied: number;
@@ -52,6 +53,7 @@ interface DbApplyContext {
52
53
  planSql: string | null;
53
54
  filteredPlanSql: string | null;
54
55
  planSummary: DbApplyPlanSummary | null;
56
+ planner: DbApplyPlanner | null;
55
57
  ssotWarning: string | null;
56
58
  nonCriticalWarnings: CommandWarning[];
57
59
  idempotentFiles: string[];
@@ -70,7 +72,14 @@ interface DbApplyContext {
70
72
  seedStartTime: number | null;
71
73
  seedEndTime: number | null;
72
74
  retryAttempts: number;
75
+ retryWaitMs: number;
73
76
  }
77
+ interface DbApplyFailureMetadata {
78
+ code: string;
79
+ retryable: boolean;
80
+ }
81
+ export declare function classifyDbApplyFailure(errorMessage: string): DbApplyFailureMetadata;
82
+ export declare function createMachineWarning(code: string, message: string, phase: string): CommandWarning;
74
83
  export declare const dbApplyMachine: import("xstate").StateMachine<DbApplyContext, {
75
84
  type: "START";
76
85
  } | {
@@ -78,12 +87,6 @@ export declare const dbApplyMachine: import("xstate").StateMachine<DbApplyContex
78
87
  error: Error;
79
88
  }, {
80
89
  [x: string]: import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<{
81
- applied: boolean;
82
- warnings: string[];
83
- }, {
84
- input: DbApplyInput;
85
- targetDir: string;
86
- }, import("xstate").EventObject>> | import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<{
87
90
  acquired: boolean;
88
91
  }, {
89
92
  input: DbApplyInput;
@@ -99,23 +102,23 @@ export declare const dbApplyMachine: import("xstate").StateMachine<DbApplyContex
99
102
  }, import("xstate").EventObject>> | import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<actors.PgSchemaDiffResult, {
100
103
  input: DbApplyInput;
101
104
  targetDir: string;
105
+ preIdempotentTargetFingerprint?: string | null;
102
106
  }, import("xstate").EventObject>> | import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<{
103
107
  warnings: string[];
104
108
  }, {
105
109
  input: DbApplyInput;
106
110
  targetDir: string;
107
- }, import("xstate").EventObject>> | undefined;
108
- }, {
109
- src: "applySeeds";
110
- logic: import("xstate").PromiseActorLogic<{
111
+ }, import("xstate").EventObject>> | import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<{
111
112
  applied: boolean;
112
113
  warnings: string[];
113
114
  }, {
114
115
  input: DbApplyInput;
115
116
  targetDir: string;
116
- }, import("xstate").EventObject>;
117
- id: string | undefined;
118
- } | {
117
+ }, import("xstate").EventObject>> | import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<string | null, {
118
+ input: DbApplyInput;
119
+ targetDir: string;
120
+ }, import("xstate").EventObject>> | undefined;
121
+ }, {
119
122
  src: "acquireLock";
120
123
  logic: import("xstate").PromiseActorLogic<{
121
124
  acquired: boolean;
@@ -149,6 +152,7 @@ export declare const dbApplyMachine: import("xstate").StateMachine<DbApplyContex
149
152
  logic: import("xstate").PromiseActorLogic<actors.PgSchemaDiffResult, {
150
153
  input: DbApplyInput;
151
154
  targetDir: string;
155
+ preIdempotentTargetFingerprint?: string | null;
152
156
  }, import("xstate").EventObject>;
153
157
  id: string | undefined;
154
158
  } | {
@@ -160,13 +164,30 @@ export declare const dbApplyMachine: import("xstate").StateMachine<DbApplyContex
160
164
  targetDir: string;
161
165
  }, import("xstate").EventObject>;
162
166
  id: string | undefined;
167
+ } | {
168
+ src: "applySeeds";
169
+ logic: import("xstate").PromiseActorLogic<{
170
+ applied: boolean;
171
+ warnings: string[];
172
+ }, {
173
+ input: DbApplyInput;
174
+ targetDir: string;
175
+ }, import("xstate").EventObject>;
176
+ id: string | undefined;
177
+ } | {
178
+ src: "captureTargetFingerprint";
179
+ logic: import("xstate").PromiseActorLogic<string | null, {
180
+ input: DbApplyInput;
181
+ targetDir: string;
182
+ }, import("xstate").EventObject>;
183
+ id: string | undefined;
163
184
  }, {
164
185
  type: "assignPgSchemaDiffResult";
165
186
  params: import("xstate").NonReducibleUnknown;
166
187
  } | {
167
188
  type: "releaseAdvisoryLockOnFailure";
168
189
  params: unknown;
169
- }, never, never, "done" | "failed" | "idle" | "acquiringLock" | "previewingIdempotent" | "applyingIdempotentPre" | "applyingPgSchemaDiff" | "applyingIdempotentPost" | "validatingPartitions" | "releasingLock" | "applyingSeeds", string, {
190
+ }, never, never, "done" | "failed" | "idle" | "acquiringLock" | "previewingIdempotent" | "capturingTargetFingerprint" | "applyingIdempotentPre" | "applyingPgSchemaDiff" | "applyingIdempotentPost" | "validatingPartitions" | "releasingLock" | "applyingSeeds", string, {
170
191
  input: DbApplyInput;
171
192
  targetDir: string;
172
193
  }, {
@@ -248,6 +269,7 @@ export declare const dbApplyMachine: import("xstate").StateMachine<DbApplyContex
248
269
  };
249
270
  } | undefined;
250
271
  checkOnly?: boolean | undefined;
272
+ previewProfile?: "full" | "compare-only" | undefined;
251
273
  dataViolations?: number | undefined;
252
274
  ssotWarning?: string | undefined;
253
275
  partitionWarnings?: string[] | undefined;
@@ -263,12 +285,25 @@ export declare const dbApplyMachine: import("xstate").StateMachine<DbApplyContex
263
285
  applyMs?: number | undefined;
264
286
  seedMs?: number | undefined;
265
287
  retryAttempts?: number | undefined;
288
+ retryWaitMs?: number | undefined;
289
+ } | undefined;
290
+ planner?: {
291
+ source: "inline" | "artifact";
292
+ path?: string | undefined;
293
+ reuseAttempted?: boolean | undefined;
294
+ reuseReason?: "artifact_missing" | "artifact_invalid" | "profile_ineligible" | "source_fingerprint_mismatch" | "target_fingerprint_unavailable" | "target_fingerprint_mismatch" | "tool_version_mismatch" | undefined;
295
+ reuseMessage?: string | undefined;
296
+ sourceFingerprint?: string | undefined;
297
+ targetFingerprint?: string | undefined;
298
+ targetFingerprintMatched?: boolean | undefined;
299
+ hasChanges?: boolean | undefined;
266
300
  } | undefined;
267
301
  }, import("xstate").EventObject, import("xstate").MetaObject, {
268
302
  id: "dbApply";
269
303
  states: {
270
304
  readonly idle: {};
271
305
  readonly acquiringLock: {};
306
+ readonly capturingTargetFingerprint: {};
272
307
  readonly previewingIdempotent: {};
273
308
  readonly applyingIdempotentPre: {};
274
309
  readonly applyingPgSchemaDiff: {};
@@ -1,5 +1,10 @@
1
1
  import { CLIError } from '@runa-ai/runa';
2
+ import type { DbPreviewProfile } from '../apply/contract.js';
2
3
  type DbApplyEnvironment = 'local' | 'preview' | 'production';
3
- export declare function buildDbApplyCliError(errorMessage: string, environment: DbApplyEnvironment): CLIError;
4
+ interface DbApplyCliErrorOptions {
5
+ previewProfile?: DbPreviewProfile | null;
6
+ fromPlan?: boolean;
7
+ }
8
+ export declare function buildDbApplyCliError(errorMessage: string, environment: DbApplyEnvironment, options?: DbApplyCliErrorOptions): CLIError;
4
9
  export {};
5
10
  //# sourceMappingURL=db-apply-error.d.ts.map
@@ -14,6 +14,11 @@ export interface DbApplyOptions {
14
14
  compareOnly?: boolean;
15
15
  maxLockWaitMs?: number;
16
16
  freshDbCheckSql?: string;
17
+ commandLabel?: string;
18
+ /** Reuse a checked plan artifact generated by `runa db plan`. */
19
+ fromPlan?: string;
20
+ /** Persist the checked plan artifact after a successful full preview. */
21
+ persistPlanArtifact?: boolean;
17
22
  }
18
23
  /**
19
24
  * Run db apply workflow
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare const planCommand: Command;
3
+ //# sourceMappingURL=db-plan.d.ts.map
@@ -0,0 +1,23 @@
1
+ import { z } from 'zod';
2
+ import { type DbApplyOutput, type DbPreviewProfile } from '../apply/contract.js';
3
+ export declare const DEFAULT_DB_PREVIEW_PROFILE: DbPreviewProfile;
4
+ export declare const DbPreviewEnvironmentSchema: z.ZodEnum<{
5
+ local: "local";
6
+ preview: "preview";
7
+ production: "production";
8
+ }>;
9
+ export declare const LEGACY_DB_APPLY_CHECK_REMOVAL_TARGET = "the next major CLI release";
10
+ export declare function parseDbPreviewProfile(value: string): DbPreviewProfile;
11
+ export type DbPreviewEnvironment = z.infer<typeof DbPreviewEnvironmentSchema>;
12
+ export declare function resolveDbPreviewEnvironment(value: string): DbPreviewEnvironment | null;
13
+ export declare function resolveDbPreviewProfile(params: {
14
+ check?: boolean;
15
+ compareOnly?: boolean;
16
+ }): DbPreviewProfile | null;
17
+ export declare function isCompareOnlyPreviewProfile(profile: DbPreviewProfile): boolean;
18
+ export declare function getDbPreviewModeLabel(profile: DbPreviewProfile): string;
19
+ export declare function buildDbPreviewCommandLabel(env: string, profile: DbPreviewProfile): string;
20
+ export declare function buildDbPlanCommandLabel(env: string): string;
21
+ export declare function getDbPreviewIdempotentSchemaCount(result: Pick<DbApplyOutput, 'idempotentFiles' | 'idempotentSchemasApplied'>): number;
22
+ export declare function buildLegacyDbApplyCheckWarning(profile: DbPreviewProfile): string;
23
+ //# sourceMappingURL=db-preview-profile.d.ts.map
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare const previewCommand: Command;
3
+ //# sourceMappingURL=db-preview.d.ts.map
@@ -74,6 +74,7 @@ export interface SyncInput {
74
74
  export declare const syncSchema: import("xstate").PromiseActorLogic<{
75
75
  applied: boolean;
76
76
  stepsCompleted: string[];
77
+ applyCommitted?: boolean | undefined;
77
78
  error?: string | undefined;
78
79
  }, SyncInput, import("xstate").EventObject>;
79
80
  export interface ReportInput {
@@ -13,6 +13,7 @@
13
13
  * - runa db sync --check # Dry-run mode
14
14
  */
15
15
  import { z } from 'zod';
16
+ import type { BoundaryGuidanceWarning, LocalBlindSpotBlocker, RuntimeContradictionIssue, RuntimeWarningIssue, SchemaGuardrailReport, SchemaManagedBlockKind, SchemaGuardrailFailureCode, SchemaGuardrailPhaseId, SemanticDuplicateCandidate, SemanticDuplicateEvidence, SemanticDuplicateWarning } from './schema-guardrail-types.js';
16
17
  /**
17
18
  * Environment type for db sync
18
19
  */
@@ -89,6 +90,7 @@ export type SnapshotResult = z.infer<typeof SnapshotResultSchema>;
89
90
  */
90
91
  export declare const SyncResultSchema: z.ZodObject<{
91
92
  applied: z.ZodBoolean;
93
+ applyCommitted: z.ZodOptional<z.ZodBoolean>;
92
94
  stepsCompleted: z.ZodArray<z.ZodString>;
93
95
  error: z.ZodOptional<z.ZodString>;
94
96
  }, z.core.$strip>;
@@ -123,6 +125,18 @@ export declare const StepContextSchema: z.ZodObject<{
123
125
  configTimeoutMs: z.ZodOptional<z.ZodNumber>;
124
126
  }, z.core.$strip>;
125
127
  export type StepContext = z.infer<typeof StepContextSchema>;
128
+ export declare const SchemaManagedBlockKindSchema: z.ZodType<SchemaManagedBlockKind>;
129
+ export declare const SchemaGuardrailPhaseIdSchema: z.ZodType<SchemaGuardrailPhaseId>;
130
+ export declare const SchemaGuardrailFailureCodeSchema: z.ZodType<SchemaGuardrailFailureCode>;
131
+ export declare const RuntimeWarningIssueSchema: z.ZodType<RuntimeWarningIssue>;
132
+ export declare const RuntimeContradictionIssueSchema: z.ZodType<RuntimeContradictionIssue>;
133
+ export declare const SemanticDuplicateEvidenceSchema: z.ZodType<SemanticDuplicateEvidence>;
134
+ export declare const SemanticDuplicateCandidateSchema: z.ZodType<SemanticDuplicateCandidate>;
135
+ export declare const SemanticDuplicateWarningSchema: z.ZodType<SemanticDuplicateWarning>;
136
+ export declare const BoundaryGuidanceWarningSchema: z.ZodType<BoundaryGuidanceWarning>;
137
+ export declare const LocalBlindSpotBlockerSchema: z.ZodType<LocalBlindSpotBlocker>;
138
+ export declare const SchemaGuardrailReportSchema: z.ZodType<SchemaGuardrailReport>;
139
+ export type { RuntimeContradictionIssue, RuntimeWarningIssue, SchemaGuardrailReport, SchemaManagedBlockKind, SchemaGuardrailFailureCode, SchemaGuardrailPhaseId, SemanticDuplicateCandidate, SemanticDuplicateEvidence, SemanticDuplicateWarning, } from './schema-guardrail-types.js';
126
140
  /**
127
141
  * DB sync command result
128
142
  */
@@ -137,10 +151,12 @@ export declare const DbSyncOutputSchema: z.ZodObject<{
137
151
  preflightPassed: z.ZodBoolean;
138
152
  snapshotCreated: z.ZodBoolean;
139
153
  applied: z.ZodBoolean;
154
+ applyCommitted: z.ZodOptional<z.ZodBoolean>;
140
155
  stepsCompleted: z.ZodArray<z.ZodString>;
141
156
  reportJsonPath: z.ZodOptional<z.ZodString>;
142
157
  exitCode: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>]>;
143
158
  error: z.ZodOptional<z.ZodString>;
159
+ guardrail: z.ZodOptional<z.ZodType<SchemaGuardrailReport, unknown, z.core.$ZodTypeInternals<SchemaGuardrailReport, unknown>>>;
144
160
  outcome: z.ZodObject<{
145
161
  command: z.ZodString;
146
162
  exitMode: z.ZodEnum<{
@@ -0,0 +1,15 @@
1
+ import type { DbSyncOutput } from './contract.js';
2
+ import type { DbCommandOptions } from '../types.js';
3
+ type GuardrailLogger = {
4
+ info(message: string): void;
5
+ warn(message: string): void;
6
+ error(message: string): void;
7
+ };
8
+ export declare function runDbSyncWithGuardrail(params: {
9
+ env: string;
10
+ options: DbCommandOptions;
11
+ logger: GuardrailLogger;
12
+ runDbSyncMachine: () => Promise<DbSyncOutput>;
13
+ }): Promise<DbSyncOutput>;
14
+ export {};
15
+ //# sourceMappingURL=guardrail-orchestrator.d.ts.map
@@ -0,0 +1,12 @@
1
+ import type { DbSyncOutput, SchemaGuardrailReport } from './contract.js';
2
+ export type GuardrailSummaryEntry = {
3
+ level: 'info' | 'warn' | 'error';
4
+ message: string;
5
+ };
6
+ export declare function buildGuardrailSummaryEntries(report: SchemaGuardrailReport): GuardrailSummaryEntry[];
7
+ export declare function buildGuardrailPreApplyEntries(report: SchemaGuardrailReport): GuardrailSummaryEntry[];
8
+ export declare function writeMergedDbSyncReportJson(params: {
9
+ filePath?: string;
10
+ result: DbSyncOutput;
11
+ }): void;
12
+ //# sourceMappingURL=guardrail-reporting.d.ts.map
@@ -6,5 +6,9 @@
6
6
  */
7
7
  export * from './actors.js';
8
8
  export * from './contract.js';
9
+ export * from './guardrail-orchestrator.js';
10
+ export * from './guardrail-reporting.js';
9
11
  export * from './machine.js';
12
+ export type * from './schema-guardrail-types.js';
13
+ export { createGuardrailOutcomePhases, createSyncApplyFailureReport, runSchemaGuardrailRuntime, runSchemaGuardrailStatic, } from './schema-guardrail.js';
10
14
  //# sourceMappingURL=index.d.ts.map
@@ -31,6 +31,7 @@ interface DbSyncContext {
31
31
  preflightPassed: boolean;
32
32
  snapshotCreated: boolean;
33
33
  applied: boolean;
34
+ applyCommitted: boolean;
34
35
  stepsCompleted: string[];
35
36
  reportWritten: boolean;
36
37
  error: string | null;
@@ -51,17 +52,18 @@ export declare const dbSyncMachine: import("xstate").StateMachine<DbSyncContext,
51
52
  }, actors.SnapshotInput, import("xstate").EventObject>> | import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<{
52
53
  applied: boolean;
53
54
  stepsCompleted: string[];
55
+ applyCommitted?: boolean | undefined;
54
56
  error?: string | undefined;
55
57
  }, actors.SyncInput, import("xstate").EventObject>> | import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<{
56
- passed: boolean;
57
- warnings?: string[] | undefined;
58
- error?: string | undefined;
59
- }, actors.PreflightInput, import("xstate").EventObject>> | import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<{
60
58
  passed: boolean;
61
59
  databaseUrl?: string | undefined;
62
60
  dbPackagePath?: string | undefined;
63
61
  error?: string | undefined;
64
- }, actors.ReconcileInput, import("xstate").EventObject>> | import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<actors.SetupOutput, actors.SetupInput, import("xstate").EventObject>> | import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<actors.ReportOutput, actors.ReportInput, import("xstate").EventObject>> | undefined;
62
+ }, actors.ReconcileInput, import("xstate").EventObject>> | import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<{
63
+ passed: boolean;
64
+ warnings?: string[] | undefined;
65
+ error?: string | undefined;
66
+ }, actors.PreflightInput, import("xstate").EventObject>> | import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<actors.SetupOutput, actors.SetupInput, import("xstate").EventObject>> | import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<actors.ReportOutput, actors.ReportInput, import("xstate").EventObject>> | undefined;
65
67
  }, {
66
68
  src: "snapshot";
67
69
  logic: import("xstate").PromiseActorLogic<{
@@ -76,25 +78,26 @@ export declare const dbSyncMachine: import("xstate").StateMachine<DbSyncContext,
76
78
  logic: import("xstate").PromiseActorLogic<{
77
79
  applied: boolean;
78
80
  stepsCompleted: string[];
81
+ applyCommitted?: boolean | undefined;
79
82
  error?: string | undefined;
80
83
  }, actors.SyncInput, import("xstate").EventObject>;
81
84
  id: string | undefined;
82
85
  } | {
83
- src: "preflight";
86
+ src: "reconcile";
84
87
  logic: import("xstate").PromiseActorLogic<{
85
88
  passed: boolean;
86
- warnings?: string[] | undefined;
89
+ databaseUrl?: string | undefined;
90
+ dbPackagePath?: string | undefined;
87
91
  error?: string | undefined;
88
- }, actors.PreflightInput, import("xstate").EventObject>;
92
+ }, actors.ReconcileInput, import("xstate").EventObject>;
89
93
  id: string | undefined;
90
94
  } | {
91
- src: "reconcile";
95
+ src: "preflight";
92
96
  logic: import("xstate").PromiseActorLogic<{
93
97
  passed: boolean;
94
- databaseUrl?: string | undefined;
95
- dbPackagePath?: string | undefined;
98
+ warnings?: string[] | undefined;
96
99
  error?: string | undefined;
97
- }, actors.ReconcileInput, import("xstate").EventObject>;
100
+ }, actors.PreflightInput, import("xstate").EventObject>;
98
101
  id: string | undefined;
99
102
  } | {
100
103
  src: "setupContext";
@@ -104,7 +107,7 @@ export declare const dbSyncMachine: import("xstate").StateMachine<DbSyncContext,
104
107
  src: "writeReport";
105
108
  logic: import("xstate").PromiseActorLogic<actors.ReportOutput, actors.ReportInput, import("xstate").EventObject>;
106
109
  id: string | undefined;
107
- }, never, never, never, "done" | "failed" | "sync" | "setup" | "idle" | "snapshot" | "report" | "preflight" | "reconcile", string, {
110
+ }, never, never, never, "done" | "failed" | "sync" | "setup" | "idle" | "snapshot" | "reconcile" | "report" | "preflight", string, {
108
111
  env?: "local" | "preview" | "production" | undefined;
109
112
  check?: boolean | undefined;
110
113
  force?: boolean | undefined;
@@ -187,8 +190,10 @@ export declare const dbSyncMachine: import("xstate").StateMachine<DbSyncContext,
187
190
  };
188
191
  nextActions?: string[] | undefined;
189
192
  };
193
+ applyCommitted?: boolean | undefined;
190
194
  reportJsonPath?: string | undefined;
191
195
  error?: string | undefined;
196
+ guardrail?: import("./schema-guardrail-types.js").SchemaGuardrailReport | undefined;
192
197
  }, import("xstate").EventObject, import("xstate").MetaObject, {
193
198
  id: "dbSync";
194
199
  states: {
@@ -0,0 +1,15 @@
1
+ import type { SchemaGuardrailConfig } from './schema-guardrail-types.js';
2
+ type GuardrailConfigNormalizers = {
3
+ normalizeAllowlistSignature(value: string): string;
4
+ normalizeFileList(files: Iterable<string>): string[];
5
+ normalizeFunctionQualifiedName(value: string): string;
6
+ normalizePathForMatch(filePath: string): string;
7
+ normalizeSuppressionPair(value: string): string;
8
+ };
9
+ export declare function tryLoadSchemaGuardrailConfigFromText(params: {
10
+ targetDir: string;
11
+ defaults: SchemaGuardrailConfig;
12
+ normalizers: GuardrailConfigNormalizers;
13
+ }): SchemaGuardrailConfig | null;
14
+ export {};
15
+ //# sourceMappingURL=schema-guardrail-config-test-support.d.ts.map
@@ -0,0 +1,11 @@
1
+ import type { SchemaGuardrailConfig } from './schema-guardrail-types.js';
2
+ export declare const DEFAULT_TABLE_HEADER_MAX_WIDTH = 160;
3
+ export declare const DEFAULT_SEMANTIC_WARNING_THRESHOLD = 0.55;
4
+ export declare const DEFAULT_SEMANTIC_WARNING_MAX_CANDIDATES = 3;
5
+ export declare const GENERIC_SIMILARITY_COLUMNS: Set<string>;
6
+ export declare function normalizePathForMatch(filePath: string): string;
7
+ export declare function normalizeFunctionQualifiedName(value: string): string;
8
+ export declare function normalizeAllowlistSignature(value: string): string;
9
+ export declare function normalizeSuppressionPair(value: string): string;
10
+ export declare function loadSchemaGuardrailConfig(targetDir: string): SchemaGuardrailConfig;
11
+ //# sourceMappingURL=schema-guardrail-config.d.ts.map
@@ -0,0 +1,36 @@
1
+ /**
2
+ * AI HINT: Schema Guardrail - DDL Order Validation
3
+ *
4
+ * Purpose: Detect policy→function dependency ordering issues that would
5
+ * cause "function does not exist" errors during production pg-schema-diff apply.
6
+ *
7
+ * Why this matters:
8
+ * - Local `runa db sync` runs against a fresh DB (all CREATE, no ALTER)
9
+ * - Production `runa db apply` generates ALTER POLICY for changed policies
10
+ * - pg-schema-diff may order ALTER POLICY (phase 50) before CREATE FUNCTION (phase 60)
11
+ * - This check catches the issue statically from SQL files, without needing a live DB
12
+ *
13
+ * Detection: For each CREATE POLICY/ALTER POLICY with a schema-qualified function call,
14
+ * verify the function is defined BEFORE the policy in file ordering (by file prefix number).
15
+ */
16
+ export interface DdlOrderWarning {
17
+ policyFile: string;
18
+ policyLine: number;
19
+ functionRef: string;
20
+ functionFile: string;
21
+ message: string;
22
+ }
23
+ /**
24
+ * Scan declarative SQL files for policy→function ordering risks.
25
+ *
26
+ * Returns warnings when a policy references a function that is defined
27
+ * in a later-ordered file (by numeric prefix), which means pg-schema-diff
28
+ * may generate ALTER POLICY before CREATE FUNCTION during incremental apply.
29
+ */
30
+ export declare function detectDdlOrderRisks(declarativeDir: string): DdlOrderWarning[];
31
+ /**
32
+ * Run DDL order check and log warnings.
33
+ * Called from guardrail orchestrator during `runa db sync`.
34
+ */
35
+ export declare function runDdlOrderCheck(targetDir: string): DdlOrderWarning[];
36
+ //# sourceMappingURL=schema-guardrail-ddl-order.d.ts.map
@@ -0,0 +1,15 @@
1
+ /**
2
+ * AI HINT: Schema Guardrail Graph - Boundary Guidance Warnings
3
+ *
4
+ * Purpose: Generate guidance warnings for schema boundary violations,
5
+ * security definer issues, trigger ownership, and managed schema access
6
+ */
7
+ import type { SchemaGuardrailReport, SchemaGraphFunctionClaim, SchemaGraphFileNode, SchemaGraphSchemaNode } from './schema-guardrail-types.js';
8
+ declare function buildBoundaryGuidanceWarnings(params: {
9
+ fileNodes: SchemaGraphFileNode[];
10
+ schemaNodes: SchemaGraphSchemaNode[];
11
+ functionClaims: SchemaGraphFunctionClaim[];
12
+ ownerFileByTable: Map<string, string>;
13
+ }): SchemaGuardrailReport['boundaryGuidanceWarnings'];
14
+ export { buildBoundaryGuidanceWarnings };
15
+ //# sourceMappingURL=schema-guardrail-graph-guidance.d.ts.map
@@ -0,0 +1,41 @@
1
+ /**
2
+ * AI HINT: Schema Guardrail Graph - Metadata Analysis
3
+ *
4
+ * Purpose: Function ownership hashing, allowlist checking, and
5
+ * defined function/boundary metadata extraction
6
+ */
7
+ import { type DuplicateFunctionOwnershipFinding } from '../utils/duplicate-function-ownership.js';
8
+ import { type SqlFile } from '../utils/declarative-dependency-sql-utils.js';
9
+ import { type DefinedFunctionMetadata, type ManagedBoundaryMetadata } from './schema-guardrail-graph-types.js';
10
+ import type { SchemaGuardrailConfig } from './schema-guardrail-types.js';
11
+ declare function normalizeFunctionStatementForHash(statement: string): string;
12
+ declare function buildFunctionBodyHashMap(files: SqlFile[], layer: 'declarative' | 'idempotent'): Map<string, string>;
13
+ declare function isAllowlistedDuplicateFunction(params: {
14
+ finding: DuplicateFunctionOwnershipFinding;
15
+ allowlist: SchemaGuardrailConfig['allowedDuplicateFunctions'];
16
+ bodyHashes: Map<string, string>;
17
+ }): boolean;
18
+ /**
19
+ * Collect qualified object references from SQL function bodies
20
+ */
21
+ declare function normalizeQualifiedObjectRef(schema: string, name: string, isFunctionCall: boolean): string;
22
+ declare function collectQualifiedObjectRefs(params: {
23
+ content: string;
24
+ allowedSchemas: ReadonlySet<string>;
25
+ includeFunctionCalls: boolean;
26
+ }): {
27
+ refs: string[];
28
+ schemas: string[];
29
+ };
30
+ /**
31
+ * Check if function body has SET search_path locked
32
+ */
33
+ declare function isSearchPathLocked(statement: string): boolean;
34
+ declare function buildDefinedFunctionMetadataByFile(params: {
35
+ files: SqlFile[];
36
+ layer: 'declarative' | 'idempotent';
37
+ managedSchemas: Set<string>;
38
+ }): Map<string, DefinedFunctionMetadata[]>;
39
+ declare function buildManagedBoundaryMetadataByFile(files: SqlFile[]): Map<string, ManagedBoundaryMetadata>;
40
+ export { normalizeFunctionStatementForHash, buildFunctionBodyHashMap, isAllowlistedDuplicateFunction, normalizeQualifiedObjectRef, collectQualifiedObjectRefs, isSearchPathLocked, buildDefinedFunctionMetadataByFile, buildManagedBoundaryMetadataByFile, };
41
+ //# sourceMappingURL=schema-guardrail-graph-metadata.d.ts.map