@runa-ai/runa-cli 0.7.1 → 0.7.3

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 (136) hide show
  1. package/dist/{build-HUDIP6KU.js → build-HQMSVN6N.js} +3 -3
  2. package/dist/{check-LOMVIRHX.js → check-PCSQPYDM.js} +2 -2
  3. package/dist/{chunk-QM53IQHM.js → chunk-2QX7T24B.js} +1 -1
  4. package/dist/{chunk-CCW3PLQY.js → chunk-3JO6YP3T.js} +1 -1
  5. package/dist/{chunk-XDCHRVE3.js → chunk-4XHZQRRK.js} +2 -2
  6. package/dist/{chunk-7B5C6U2K.js → chunk-A6A7JIRD.js} +35 -2
  7. package/dist/{chunk-AFY3TX4I.js → chunk-AO554K3G.js} +1 -1
  8. package/dist/{chunk-Z4Z5DNW4.js → chunk-B3POLMII.js} +12 -0
  9. package/dist/chunk-CKRLVEIO.js +119 -0
  10. package/dist/{chunk-HD74F6W2.js → chunk-FWMGC5FP.js} +1 -0
  11. package/dist/{chunk-FHG3ILE4.js → chunk-OBYZDT2E.js} +38 -8
  12. package/dist/{chunk-H2AHNI75.js → chunk-PAWNJA3N.js} +1 -1
  13. package/dist/{chunk-VM3IWOT5.js → chunk-QSEF4T3Y.js} +13 -5
  14. package/dist/{chunk-NPSRD26F.js → chunk-UHDAYPHH.js} +1 -1
  15. package/dist/{chunk-2APB25TT.js → chunk-VSH3IXDQ.js} +7 -3
  16. package/dist/{chunk-644FVGIQ.js → chunk-WPMR7RQ4.js} +9 -2
  17. package/dist/{chunk-EMB6IZFT.js → chunk-XVNDDHAF.js} +20 -1
  18. package/dist/{risk-detector-plpgsql-HWKS4OLR.js → chunk-Y5ANTCKE.js} +3 -412
  19. package/dist/{ci-XY6IKEDC.js → ci-Z4525QW6.js} +2150 -488
  20. package/dist/{cli-UZA4RBNQ.js → cli-SVXOSMW6.js} +72 -54
  21. package/dist/commands/ci/commands/ci-prod-db-operations.d.ts +6 -4
  22. package/dist/commands/ci/commands/ci-prod-types.d.ts +3 -0
  23. package/dist/commands/ci/commands/ci-prod-workflow.d.ts +1 -1
  24. package/dist/commands/ci/commands/ci-resolvers.d.ts +1 -1
  25. package/dist/commands/ci/commands/ci-supabase-local.d.ts +4 -0
  26. package/dist/commands/ci/machine/actors/build/build-and-playwright.d.ts +1 -1
  27. package/dist/commands/ci/machine/actors/db/collect-schema-stats.d.ts +11 -1
  28. package/dist/commands/ci/machine/actors/db/production-preview.d.ts +22 -4
  29. package/dist/commands/ci/machine/actors/db/schema-canonical-diff.d.ts +8 -1
  30. package/dist/commands/ci/machine/actors/db/sync-schema.d.ts +1 -0
  31. package/dist/commands/ci/machine/actors/finalize/index.d.ts +0 -1
  32. package/dist/commands/ci/machine/actors/index.d.ts +1 -1
  33. package/dist/commands/ci/machine/actors/setup/local.d.ts +2 -0
  34. package/dist/commands/ci/machine/actors/setup/pr-common.d.ts +3 -0
  35. package/dist/commands/ci/machine/actors/setup/pr-local.d.ts +2 -0
  36. package/dist/commands/ci/machine/commands/machine-runner.d.ts +5 -1
  37. package/dist/commands/ci/machine/commands/step-telemetry.d.ts +16 -0
  38. package/dist/commands/ci/machine/contract.d.ts +40 -0
  39. package/dist/commands/ci/machine/formatters/github-comment-types.d.ts +7 -2
  40. package/dist/commands/ci/machine/formatters/github-comment.d.ts +2 -1
  41. package/dist/commands/ci/machine/formatters/sections/final-comment.d.ts +2 -1
  42. package/dist/commands/ci/machine/formatters/sections/index.d.ts +1 -1
  43. package/dist/commands/ci/machine/formatters/summary.d.ts +4 -4
  44. package/dist/commands/ci/machine/guards.d.ts +4 -0
  45. package/dist/commands/ci/machine/helpers.d.ts +25 -0
  46. package/dist/commands/ci/machine/machine-state-helpers.d.ts +1 -1
  47. package/dist/commands/ci/machine/machine.d.ts +15 -8
  48. package/dist/commands/ci/machine/types.d.ts +9 -0
  49. package/dist/commands/ci/utils/ci-diagnostics.d.ts +67 -0
  50. package/dist/commands/ci/utils/ci-summary.d.ts +118 -0
  51. package/dist/commands/ci/utils/db-url-utils.d.ts +4 -77
  52. package/dist/commands/ci/utils/github-api.d.ts +14 -0
  53. package/dist/commands/db/apply/contract.d.ts +73 -0
  54. package/dist/commands/db/apply/helpers/alter-statement-parsers.d.ts +95 -0
  55. package/dist/commands/db/apply/helpers/data-compatibility-checker.d.ts +0 -61
  56. package/dist/commands/db/apply/helpers/function-plan-false-positive-filter.d.ts +36 -0
  57. package/dist/commands/db/apply/helpers/hazard-handler.d.ts +4 -4
  58. package/dist/commands/db/apply/helpers/index.d.ts +14 -5
  59. package/dist/commands/db/apply/helpers/partition-acl-cleaner.d.ts +3 -1
  60. package/dist/commands/db/apply/helpers/pg-schema-diff-helpers.d.ts +69 -6
  61. package/dist/commands/db/apply/helpers/plan-ast.d.ts +56 -0
  62. package/dist/commands/db/apply/helpers/plan-check-filter.d.ts +26 -0
  63. package/dist/commands/db/apply/helpers/plan-drop-protection.d.ts +43 -0
  64. package/dist/commands/db/apply/helpers/plan-ordering.d.ts +6 -0
  65. package/dist/commands/db/apply/helpers/plan-statement-parser.d.ts +39 -0
  66. package/dist/commands/db/apply/helpers/plan-validator.d.ts +8 -40
  67. package/dist/commands/db/apply/helpers/retry-logic.d.ts +1 -10
  68. package/dist/commands/db/apply/helpers/temp-db-bootstrap.d.ts +18 -0
  69. package/dist/commands/db/apply/helpers/temp-db-dsn.d.ts +14 -0
  70. package/dist/commands/db/apply/machine.d.ts +56 -32
  71. package/dist/commands/db/commands/db-apply-error.d.ts +5 -0
  72. package/dist/commands/db/commands/db-apply.d.ts +2 -0
  73. package/dist/commands/db/commands/db-sync/directory-placement-check.d.ts +4 -0
  74. package/dist/commands/db/commands/db-sync/error-classifier.d.ts +1 -1
  75. package/dist/commands/db/commands/db-sync/plan-boundary-reconciliation.d.ts +3 -0
  76. package/dist/commands/db/commands/db-sync/precheck-helpers.d.ts +18 -0
  77. package/dist/commands/db/commands/db-sync/production-precheck.d.ts +15 -0
  78. package/dist/commands/db/commands/db-sync/risk-scan-collectors.d.ts +11 -0
  79. package/dist/commands/db/commands/db-sync.d.ts +11 -5
  80. package/dist/commands/db/sync/contract.d.ts +80 -0
  81. package/dist/commands/db/sync/machine.d.ts +60 -1
  82. package/dist/commands/db/types.d.ts +5 -0
  83. package/dist/commands/db/utils/boundary-policy/rule-compiler.d.ts +2 -1
  84. package/dist/commands/db/utils/boundary-policy/types.d.ts +23 -0
  85. package/dist/commands/db/utils/boundary-policy-runtime.d.ts +12 -3
  86. package/dist/commands/db/utils/boundary-policy.d.ts +1 -1
  87. package/dist/commands/db/utils/db-target.d.ts +5 -3
  88. package/dist/commands/db/utils/declarative-dependency-collectors.d.ts +6 -0
  89. package/dist/commands/db/utils/declarative-dependency-contract.d.ts +78 -0
  90. package/dist/commands/db/utils/declarative-dependency-sql-utils.d.ts +49 -0
  91. package/dist/commands/db/utils/declarative-dependency-warning-governance.d.ts +24 -0
  92. package/dist/commands/db/utils/preflight-check.d.ts +1 -1
  93. package/dist/commands/db/utils/preflight-checks/declarative-dependency-checks.d.ts +4 -0
  94. package/dist/commands/db/utils/preflight-checks/idempotent-risk-checks.d.ts +4 -0
  95. package/dist/commands/db/utils/preflight-checks/schema-boundary-checks.d.ts +4 -0
  96. package/dist/commands/db/utils/preflight-checks/schema-risk-policy.d.ts +4 -0
  97. package/dist/commands/db/utils/preflight-checks/supabase-checks.d.ts +12 -0
  98. package/dist/commands/db/utils/psql.d.ts +23 -0
  99. package/dist/commands/db/utils/sql-table-extractor.d.ts +42 -1
  100. package/dist/commands/env/commands/setup/types.d.ts +1 -0
  101. package/dist/commands/env/constants/local-supabase.d.ts +4 -1
  102. package/dist/commands/observability.d.ts +72 -0
  103. package/dist/commands/observability.helpers.d.ts +25 -0
  104. package/dist/commands/template-check/contract.d.ts +3 -3
  105. package/dist/commands/template-check/machine.d.ts +1 -1
  106. package/dist/commands/workflow/commands/deploy-production.d.ts +0 -1
  107. package/dist/constants/versions.d.ts +1 -1
  108. package/dist/{db-Q3GF7JWP.js → db-S4V4ETDR.js} +14629 -11270
  109. package/dist/{dev-5YXNPTCJ.js → dev-MLRKIP7F.js} +5 -5
  110. package/dist/{doctor-MZLOA53G.js → doctor-ROSWSMLH.js} +2 -2
  111. package/dist/{env-GMB3THRG.js → env-WNHJVLOT.js} +37 -20
  112. package/dist/{env-HMMRSYCI.js → env-XPPACZM4.js} +2 -2
  113. package/dist/{env-files-2UIUYLLR.js → env-files-HRNUGZ5O.js} +1 -1
  114. package/dist/{error-handler-HEXBRNVV.js → error-handler-YRQWRDEF.js} +17 -0
  115. package/dist/{hotfix-NDTPY2T4.js → hotfix-Z5EGVSMH.js} +4 -4
  116. package/dist/index.js +4 -4
  117. package/dist/{init-U4VCRHTD.js → init-35JLDFHI.js} +1 -1
  118. package/dist/{inject-test-attrs-P44BVTQS.js → inject-test-attrs-XN4I2AOR.js} +2 -2
  119. package/dist/internal/machines/index.d.ts +1 -1
  120. package/dist/internal/machines/snapshot-helpers.d.ts +6 -0
  121. package/dist/{manifest-TMFLESHW.js → manifest-EGCAZ4TK.js} +1 -1
  122. package/dist/observability-CJA5UFIC.js +721 -0
  123. package/dist/{risk-detector-4U6ZJ2G5.js → risk-detector-S7XQF4I2.js} +1 -1
  124. package/dist/{risk-detector-core-TK4OAI3N.js → risk-detector-core-TGFKWHRS.js} +61 -3
  125. package/dist/risk-detector-plpgsql-O32TUR34.js +736 -0
  126. package/dist/{template-check-FFJVDLBF.js → template-check-BDFMT6ZO.js} +1 -1
  127. package/dist/{upgrade-7TWORWBV.js → upgrade-7L4JIE4K.js} +1 -1
  128. package/dist/utils/db-url-utils.d.ts +81 -0
  129. package/dist/validators/risk-detector-plpgsql.d.ts +3 -1
  130. package/dist/{vuln-check-6CMNPSBR.js → vuln-check-D575VXIQ.js} +1 -1
  131. package/dist/{vuln-checker-EJJTNDNE.js → vuln-checker-QV6XODTJ.js} +1 -1
  132. package/dist/{watch-PNTKZYFB.js → watch-AL4LCBRM.js} +1 -1
  133. package/dist/{workflow-H75N4BXX.js → workflow-UZIZ2JUS.js} +2 -3
  134. package/package.json +3 -3
  135. package/dist/chunk-AKZAN4BC.js +0 -90
  136. package/dist/commands/ci/machine/actors/finalize/summary.d.ts +0 -32
@@ -0,0 +1,43 @@
1
+ /**
2
+ * AI HINT: pg-schema-diff Plan DROP Protection
3
+ *
4
+ * Purpose: Filter DROP TABLE/INDEX/FUNCTION/TRIGGER/VIEW/TYPE/SEQUENCE statements
5
+ * targeting idempotent-managed objects from pg-schema-diff plans.
6
+ * Also blocks DROP SCHEMA for protected schemas (throws error).
7
+ *
8
+ * Extracted from plan-validator.ts for single responsibility.
9
+ */
10
+ import type { IdempotentProtectedObjects } from './idempotent-object-registry.js';
11
+ import type { PlanStatement, ValidatedPlan } from './plan-validator.js';
12
+ export interface FilterResult {
13
+ filteredPlan: ValidatedPlan;
14
+ removedStatements: PlanStatement[];
15
+ }
16
+ declare function isDropStatementForProtected(sql: string, protectedTables: string[]): boolean;
17
+ /**
18
+ * Check if a DROP FUNCTION/TRIGGER/VIEW/TYPE/SEQUENCE targets a protected object.
19
+ *
20
+ * For FUNCTION: matches schema.name (argument types stripped).
21
+ * For TRIGGER: matches schema.trigger_name via DROP TRIGGER name ON schema.table.
22
+ * For VIEW/TYPE/SEQUENCE: matches schema.name.
23
+ */
24
+ export declare function isDropStatementForProtectedObject(sql: string, protectedObjects: IdempotentProtectedObjects): boolean;
25
+ /**
26
+ * Extract unique schema names from protected table patterns.
27
+ * e.g., ['location_data.events', 'accounts.clients'] → ['location_data', 'accounts']
28
+ */
29
+ declare function extractProtectedSchemas(protectedTables: string[]): string[];
30
+ declare function isDropSchemaForProtected(sql: string, protectedTables: string[]): string | null;
31
+ /**
32
+ * Filter out DROP TABLE/INDEX statements targeting idempotent-managed tables,
33
+ * and optionally DROP FUNCTION/TRIGGER/VIEW/TYPE/SEQUENCE for protected objects.
34
+ * BLOCKS (throws error) on DROP SCHEMA targeting protected schemas.
35
+ *
36
+ * @param protectedObjects - Optional extended protection for non-table objects.
37
+ * When omitted, only DROP TABLE/INDEX are filtered (backward compatible).
38
+ */
39
+ export declare function filterIdempotentProtectedStatements(plan: ValidatedPlan, protectedTables: string[], protectedObjects?: IdempotentProtectedObjects): FilterResult;
40
+ export { isDropStatementForProtected as _isDropStatementForProtected };
41
+ export { extractProtectedSchemas as _extractProtectedSchemas };
42
+ export { isDropSchemaForProtected as _isDropSchemaForProtected };
43
+ //# sourceMappingURL=plan-drop-protection.d.ts.map
@@ -0,0 +1,6 @@
1
+ import type { ValidatedPlan } from './plan-validator.js';
2
+ export declare function stabilizePlanStatementOrder(plan: ValidatedPlan): Promise<{
3
+ plan: ValidatedPlan;
4
+ movedStatements: number;
5
+ }>;
6
+ //# sourceMappingURL=plan-ordering.d.ts.map
@@ -0,0 +1,39 @@
1
+ /**
2
+ * AI HINT: pg-schema-diff Plan Statement Parser
3
+ *
4
+ * Purpose: Parse pg-schema-diff plan output into structured statements.
5
+ * Handles two formats:
6
+ * 1. With `-- Statement Idx. N` markers → split into individual statements
7
+ * 2. Without markers → treat as single statement
8
+ *
9
+ * Extracted from plan-validator.ts for single responsibility.
10
+ * For Zod-validated output, use parsePlanOutput() in plan-validator.ts.
11
+ */
12
+ interface ParsedHazard {
13
+ type: string;
14
+ message: string;
15
+ }
16
+ interface ParsedStatement {
17
+ index: number;
18
+ sql: string;
19
+ hazards: ParsedHazard[];
20
+ }
21
+ export interface ParsedPlanOutput {
22
+ statements: ParsedStatement[];
23
+ totalStatements: number;
24
+ rawSql: string;
25
+ parseConfidence?: 'high' | 'low';
26
+ }
27
+ export declare function stripBlockComments(line: string, inBlockComment: boolean): {
28
+ text: string;
29
+ inBlockComment: boolean;
30
+ };
31
+ /**
32
+ * Parse pg-schema-diff plan output into structured statements.
33
+ *
34
+ * Returns a raw parsed result without Zod validation.
35
+ * For Zod-validated output, use parsePlanOutput() from plan-validator.ts.
36
+ */
37
+ export declare function parsePlanStatements(planOutput: string): ParsedPlanOutput;
38
+ export {};
39
+ //# sourceMappingURL=plan-statement-parser.d.ts.map
@@ -1,10 +1,12 @@
1
1
  /**
2
2
  * AI HINT: pg-schema-diff Plan Output Validator
3
3
  *
4
- * Purpose: Parse pg-schema-diff plan output into structured statements and
5
- * validate with Zod before psql execution (safety gate).
4
+ * Purpose: Zod schemas for plan validation and DDL/hazard safety checks.
6
5
  *
7
- * Pattern: plan Zod validation → psql execution
6
+ * Architecture (split into 3 modules):
7
+ * - plan-statement-parser.ts: Parse raw plan output into structured statements
8
+ * - plan-drop-protection.ts: Filter DROP statements targeting protected objects
9
+ * - plan-validator.ts (this file): Zod schemas, DDL validation, hazard validation
8
10
  *
9
11
  * Safety layers:
10
12
  * 1. handleHazardsWithContext() in actors.ts → blocks unapproved hazards (primary)
@@ -12,7 +14,6 @@
12
14
  * 3. Zod structural validation → ensures plan is well-formed
13
15
  */
14
16
  import { z } from 'zod';
15
- import type { IdempotentProtectedObjects } from './pg-schema-diff-helpers.js';
16
17
  export declare const PlanHazardSchema: z.ZodObject<{
17
18
  type: z.ZodString;
18
19
  message: z.ZodString;
@@ -45,7 +46,7 @@ export type PlanHazard = z.infer<typeof PlanHazardSchema>;
45
46
  export type PlanStatement = z.infer<typeof PlanStatementSchema>;
46
47
  export type ValidatedPlan = z.infer<typeof ValidatedPlanSchema>;
47
48
  /**
48
- * Parse pg-schema-diff plan output into structured statements.
49
+ * Parse pg-schema-diff plan output into structured, Zod-validated statements.
49
50
  *
50
51
  * Handles two formats:
51
52
  * 1. With `-- Statement Idx. N` markers → split into individual statements
@@ -54,41 +55,6 @@ export type ValidatedPlan = z.infer<typeof ValidatedPlanSchema>;
54
55
  * @throws ZodError if parsed result fails structural validation
55
56
  */
56
57
  export declare function parsePlanOutput(planOutput: string): ValidatedPlan;
57
- export interface FilterResult {
58
- filteredPlan: ValidatedPlan;
59
- removedStatements: PlanStatement[];
60
- }
61
- declare function isDropStatementForProtected(sql: string, protectedTables: string[]): boolean;
62
- /**
63
- * Check if a DROP FUNCTION/TRIGGER/VIEW/TYPE/SEQUENCE targets a protected object.
64
- *
65
- * For FUNCTION: matches schema.name (argument types stripped).
66
- * For TRIGGER: matches schema.trigger_name via DROP TRIGGER name ON schema.table.
67
- * For VIEW/TYPE/SEQUENCE: matches schema.name.
68
- */
69
- export declare function isDropStatementForProtectedObject(sql: string, protectedObjects: IdempotentProtectedObjects): boolean;
70
- /**
71
- * Extract unique schema names from protected table patterns.
72
- * e.g., ['location_data.events', 'accounts.clients'] → ['location_data', 'accounts']
73
- */
74
- declare function extractProtectedSchemas(protectedTables: string[]): string[];
75
- /**
76
- * Check if a SQL statement is a DROP SCHEMA targeting a protected schema.
77
- * Returns the schema name if protected, null otherwise.
78
- */
79
- declare function isDropSchemaForProtected(sql: string, protectedTables: string[]): string | null;
80
- /**
81
- * Filter out DROP TABLE/INDEX statements targeting idempotent-managed tables,
82
- * and optionally DROP FUNCTION/TRIGGER/VIEW/TYPE/SEQUENCE for protected objects.
83
- * BLOCKS (throws error) on DROP SCHEMA targeting protected schemas.
84
- *
85
- * @param protectedObjects - Optional extended protection for non-table objects.
86
- * When omitted, only DROP TABLE/INDEX are filtered (backward compatible).
87
- */
88
- export declare function filterIdempotentProtectedStatements(plan: ValidatedPlan, protectedTables: string[], protectedObjects?: IdempotentProtectedObjects): FilterResult;
89
- export { isDropStatementForProtected as _isDropStatementForProtected };
90
- export { extractProtectedSchemas as _extractProtectedSchemas };
91
- export { isDropSchemaForProtected as _isDropSchemaForProtected };
92
58
  /**
93
59
  * Allowed DDL statement prefixes. Only these statement types are permitted
94
60
  * in pg-schema-diff plan output. Checked against the normalized first keyword(s)
@@ -124,4 +90,6 @@ export declare function validateStatementTypes(plan: ValidatedPlan): void;
124
90
  * @throws Error if unresolved hazards are found
125
91
  */
126
92
  export declare function validatePlanForExecution(plan: ValidatedPlan, allowedHazardTypes: string[]): void;
93
+ export type { FilterResult } from './plan-drop-protection.js';
94
+ export { filterIdempotentProtectedStatements, isDropStatementForProtectedObject, _isDropStatementForProtected, _extractProtectedSchemas, _isDropSchemaForProtected, } from './plan-drop-protection.js';
127
95
  //# sourceMappingURL=plan-validator.d.ts.map
@@ -4,7 +4,7 @@
4
4
  * Purpose: Retry pg-schema-diff operations on lock_timeout errors
5
5
  * Pattern: Exponential backoff with jitter (configurable max delay)
6
6
  */
7
- import type { IdempotentProtectedObjects } from './pg-schema-diff-helpers.js';
7
+ import type { IdempotentProtectedObjects } from './idempotent-object-registry.js';
8
8
  export declare const MAX_RETRIES = 5;
9
9
  export declare const BASE_DELAY_MS = 1000;
10
10
  export declare const DEFAULT_MAX_DELAY_MS = 30000;
@@ -53,15 +53,6 @@ export declare function calculateBackoffDelay(attempt: number, maxDelayMs?: numb
53
53
  * because it can fire for advisory lock failures or other non-DDL lock types.
54
54
  */
55
55
  export declare function isLockTimeoutError(errorOutput: string): boolean;
56
- /**
57
- * Wrap plan SQL for execution.
58
- *
59
- * PostgreSQL DDL is transactional (except CREATE INDEX CONCURRENTLY),
60
- * so we wrap in BEGIN/COMMIT to prevent partial apply on failure.
61
- *
62
- * If the plan contains CREATE INDEX CONCURRENTLY, we skip the transaction
63
- * wrapper because CONCURRENTLY cannot run inside a transaction block.
64
- */
65
56
  export declare function wrapPlanSql(planSql: string): string;
66
57
  /**
67
58
  * Options for plan+psql execution with retry.
@@ -0,0 +1,18 @@
1
+ interface DefaultAclRow {
2
+ grantor: string;
3
+ schemaName: string;
4
+ objType: string;
5
+ grantee: string;
6
+ privType: string;
7
+ isGrantable: string;
8
+ }
9
+ export declare function buildTempDbBootstrapStatements(params: {
10
+ roleNames: string[];
11
+ defaultAclRows: DefaultAclRow[];
12
+ }): string[];
13
+ export declare function bootstrapTempDbFromSource(params: {
14
+ sourceDbUrl: string;
15
+ tempDbDsn: string;
16
+ }): void;
17
+ export {};
18
+ //# sourceMappingURL=temp-db-bootstrap.d.ts.map
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Resolve the temp DB DSN passed to pg-schema-diff.
3
+ *
4
+ * Priority:
5
+ * 1. Explicit shadow DB DSN created by runa
6
+ * 2. External temp DB DSN from environment (for CI-local temp databases)
7
+ * 3. Local Supabase DB DSN fallback (for remote checks from a developer machine)
8
+ */
9
+ export declare function resolvePgSchemaDiffTempDbDsn(params: {
10
+ shadowDbDsn?: string;
11
+ envTempDbDsn?: string;
12
+ localTempDbDsn?: string;
13
+ }): string | undefined;
14
+ //# sourceMappingURL=temp-db-dsn.d.ts.map
@@ -1,35 +1,3 @@
1
- /**
2
- * AI HINT: db apply State Machine (Declarative Schema Management)
3
- *
4
- * Purpose: Orchestrate schema application to any DB (local, Branch DB, Production)
5
- *
6
- * User Journey (2-pass idempotent):
7
- * 1. Apply idempotent schemas (1st pass: extensions, roles - may skip dependent tables)
8
- * 2. Run pg-schema-diff (current DB → desired state)
9
- * 3. Apply idempotent schemas (2nd pass: dependent tables now succeed)
10
- * 4. Validate partitions (non-blocking drift detection)
11
- * 5. Apply seeds
12
- *
13
- * Why 2-pass idempotent?
14
- * - Some idempotent SQL depends on declarative tables (e.g., areas → floors)
15
- * - 1st pass: extensions/roles succeed, dependent tables are skipped (no error)
16
- * - 2nd pass: dependent tables succeed because declarative tables now exist
17
- *
18
- * Architecture:
19
- * - No migration files needed
20
- * - pg-schema-diff runs at runtime against actual DB state
21
- * - Same logic for all environments
22
- *
23
- * E2E Test Mapping (CLI observable behavior):
24
- * - idle → expect(log).toContain('Starting db apply')
25
- * - applyingIdempotentPre → expect(log).toContain('Applied idempotent schema')
26
- * - applyingPgSchemaDiff → expect(log).toContain('pg-schema-diff')
27
- * - applyingIdempotentPost → expect(log).toContain('Applied idempotent schema')
28
- * - validatingPartitions → expect(log).toContain('partition')
29
- * - applyingSeeds → expect(log).toContain('Applying seeds')
30
- * - done → expect(exitCode).toBe(0)
31
- * - failed → expect(exitCode).toBe(1)
32
- */
33
1
  import { type SnapshotFrom } from 'xstate';
34
2
  import * as actors from './actors.js';
35
3
  import type { DbApplyInput } from './contract.js';
@@ -167,6 +135,62 @@ export declare const dbApplyMachine: import("xstate").StateMachine<DbApplyContex
167
135
  schemaChangesApplied: boolean;
168
136
  hazards: string[];
169
137
  seedsApplied: boolean;
138
+ outcome: {
139
+ command: string;
140
+ exitMode: "success" | "timeout" | "failed" | "cancelled" | "success_with_warnings";
141
+ startedAt: string;
142
+ endedAt: string;
143
+ durationMs: number;
144
+ phases: {
145
+ id: string;
146
+ label: string;
147
+ status: "timeout" | "warning" | "skipped" | "failed" | "pending" | "running" | "passed" | "cancelled";
148
+ startedAt?: string | undefined;
149
+ endedAt?: string | undefined;
150
+ durationMs?: number | undefined;
151
+ timeoutMs?: number | undefined;
152
+ warningCount?: number | undefined;
153
+ error?: {
154
+ code: string;
155
+ message: string;
156
+ retryable: boolean;
157
+ statusCode?: number | undefined;
158
+ retryAfterMs?: number | undefined;
159
+ phase?: string | undefined;
160
+ details?: Record<string, unknown> | undefined;
161
+ } | undefined;
162
+ warnings?: {
163
+ code: string;
164
+ message: string;
165
+ phase: string;
166
+ details?: Record<string, unknown> | undefined;
167
+ }[] | undefined;
168
+ metrics?: Record<string, number> | undefined;
169
+ }[];
170
+ warnings: {
171
+ code: string;
172
+ message: string;
173
+ phase: string;
174
+ details?: Record<string, unknown> | undefined;
175
+ }[];
176
+ errors: {
177
+ code: string;
178
+ message: string;
179
+ retryable: boolean;
180
+ statusCode?: number | undefined;
181
+ retryAfterMs?: number | undefined;
182
+ phase?: string | undefined;
183
+ details?: Record<string, unknown> | undefined;
184
+ }[];
185
+ summary: {
186
+ passed: number;
187
+ warnings: number;
188
+ failed: number;
189
+ skipped: number;
190
+ timedOut: number;
191
+ };
192
+ nextActions?: string[] | undefined;
193
+ };
170
194
  idempotentSchemasSkipped?: number | undefined;
171
195
  rolePasswordsSet?: number | undefined;
172
196
  error?: string | undefined;
@@ -0,0 +1,5 @@
1
+ import { CLIError } from '@runa-ai/runa';
2
+ type DbApplyEnvironment = 'local' | 'preview' | 'production';
3
+ export declare function buildDbApplyCliError(errorMessage: string, environment: DbApplyEnvironment): CLIError;
4
+ export {};
5
+ //# sourceMappingURL=db-apply-error.d.ts.map
@@ -9,7 +9,9 @@ export interface DbApplyOptions {
9
9
  allowDataLoss?: boolean;
10
10
  confirmAuthzUpdate?: boolean;
11
11
  check?: boolean;
12
+ strict?: boolean;
12
13
  skipDataCheck?: boolean;
14
+ compareOnly?: boolean;
13
15
  maxLockWaitMs?: number;
14
16
  freshDbCheckSql?: string;
15
17
  }
@@ -0,0 +1,4 @@
1
+ import type { AllowlistAwareReport, ExtensionCheckReport } from './types.js';
2
+ export declare function collectDirectoryPlacementReport(): Promise<AllowlistAwareReport>;
3
+ export declare function collectExtensionPlacementReport(): ExtensionCheckReport;
4
+ //# sourceMappingURL=directory-placement-check.d.ts.map
@@ -1,4 +1,4 @@
1
- import { type RunaDbEnv } from '../../utils/db-target.js';
1
+ import type { RunaDbEnv } from '../../utils/db-target.js';
2
2
  export interface DbSyncCommandFailure {
3
3
  code: string;
4
4
  message: string;
@@ -0,0 +1,3 @@
1
+ import type { AllowlistAwareReport } from './types.js';
2
+ export declare function collectPlanBoundaryReconciliationReport(planSql: string | undefined): Promise<AllowlistAwareReport>;
3
+ //# sourceMappingURL=plan-boundary-reconciliation.d.ts.map
@@ -0,0 +1,18 @@
1
+ /**
2
+ * AI HINT: Shared helpers for production precheck reporting
3
+ *
4
+ * Purpose: Small utility functions and constants shared across precheck modules
5
+ * Used by: plan-boundary-reconciliation, directory-placement-check, risk-scan-collectors, production-precheck
6
+ */
7
+ import type { DeclarativeRiskAllowlistRule, DirectoryPlacementAllowlistRule } from '../../utils/boundary-policy.js';
8
+ import type { ExtensionCheckReport } from './types.js';
9
+ export declare const SHOW_ALLOWLIST_REPORT: boolean;
10
+ export declare const DIRECTORY_PLACEMENT_WARNING_PREFIX = " [misplacement] ";
11
+ export declare function applyStrictModeToReport(report: ExtensionCheckReport, strict: boolean): ExtensionCheckReport;
12
+ export declare function formatAllowlistReason({ label, ruleId, reason, rule, }: {
13
+ label: string;
14
+ ruleId: string;
15
+ reason: string;
16
+ rule?: DeclarativeRiskAllowlistRule | DirectoryPlacementAllowlistRule;
17
+ }): string;
18
+ //# sourceMappingURL=precheck-helpers.d.ts.map
@@ -0,0 +1,15 @@
1
+ /**
2
+ * AI HINT: Production apply precheck orchestration
3
+ *
4
+ * Purpose: Run full production precheck pipeline: local risk checks + plan boundary reconciliation.
5
+ * Collects findings, applies strict mode, logs results, and throws on blockers.
6
+ *
7
+ * Used by: db-sync.ts (maybeRunProductionApplyPrecheck)
8
+ */
9
+ import { type createCLILogger } from '@runa-ai/runa';
10
+ import type { DbApplyOutput } from '../../apply/contract.js';
11
+ import type { RunaDbEnv } from '../../utils/db-target.js';
12
+ import type { SyncOptions } from './types.js';
13
+ export declare function collectProductionApplyRiskReasons(output: DbApplyOutput): string[];
14
+ export declare function maybeRunProductionApplyPrecheck(logger: ReturnType<typeof createCLILogger>, runaEnv: RunaDbEnv, options: SyncOptions): Promise<void>;
15
+ //# sourceMappingURL=production-precheck.d.ts.map
@@ -0,0 +1,11 @@
1
+ export declare function collectDeclarativeRiskReport(): Promise<{
2
+ blockers: string[];
3
+ warnings: string[];
4
+ allowlist: string[];
5
+ }>;
6
+ export declare function collectIdempotentRiskReport(): Promise<{
7
+ blockers: string[];
8
+ warnings: string[];
9
+ allowlist: string[];
10
+ }>;
11
+ //# sourceMappingURL=risk-scan-collectors.d.ts.map
@@ -6,11 +6,17 @@
6
6
  * plan boundary reconciliation).
7
7
  *
8
8
  * Submodules (db-sync/):
9
- * types.ts — Shared type definitions
10
- * sql-parser.ts — SQL text parsing & embedded SQL extraction
11
- * boundary-classifier.ts — DDL statement boundary classification
12
- * plan-hazard-analyzer.ts— pg-schema-diff plan hazard analysis
13
- * risk-reporter.ts — Risk formatting, deduplication, display
9
+ * types.ts — Shared type definitions
10
+ * sql-parser.ts — SQL text parsing & embedded SQL extraction
11
+ * boundary-classifier.ts — DDL statement boundary classification
12
+ * plan-hazard-analyzer.ts — pg-schema-diff plan hazard analysis
13
+ * risk-reporter.ts — Risk formatting, deduplication, display
14
+ * error-classifier.ts — Error classification for sync failures
15
+ * precheck-helpers.ts — Shared constants and utilities for prechecks
16
+ * plan-boundary-reconciliation.ts — Plan boundary analysis and reconciliation
17
+ * directory-placement-check.ts — Directory placement scanning
18
+ * risk-scan-collectors.ts — Declarative/idempotent risk scanning
19
+ * production-precheck.ts — Production precheck orchestration
14
20
  */
15
21
  import { Command } from 'commander';
16
22
  export declare const checkCommand: Command;
@@ -37,10 +37,13 @@ export declare const DbSyncInputSchema: z.ZodObject<{
37
37
  verbose: z.ZodDefault<z.ZodBoolean>;
38
38
  skipCodegen: z.ZodDefault<z.ZodBoolean>;
39
39
  strictIntrospect: z.ZodDefault<z.ZodBoolean>;
40
+ strict: z.ZodDefault<z.ZodBoolean>;
40
41
  targetDir: z.ZodOptional<z.ZodString>;
41
42
  fromProduction: z.ZodDefault<z.ZodBoolean>;
42
43
  autoSnapshot: z.ZodDefault<z.ZodBoolean>;
43
44
  reportJson: z.ZodOptional<z.ZodString>;
45
+ snapshotTimeoutMs: z.ZodOptional<z.ZodNumber>;
46
+ syncTimeoutMs: z.ZodOptional<z.ZodNumber>;
44
47
  }, z.core.$strict>;
45
48
  export type DbSyncInput = z.infer<typeof DbSyncInputSchema>;
46
49
  /**
@@ -109,11 +112,14 @@ export declare const StepContextSchema: z.ZodObject<{
109
112
  verbose: z.ZodBoolean;
110
113
  skipCodegen: z.ZodBoolean;
111
114
  strictIntrospect: z.ZodBoolean;
115
+ strict: z.ZodBoolean;
112
116
  fromProduction: z.ZodBoolean;
113
117
  autoSnapshot: z.ZodBoolean;
114
118
  noSeed: z.ZodBoolean;
115
119
  reportJson: z.ZodOptional<z.ZodString>;
116
120
  timeoutMs: z.ZodOptional<z.ZodNumber>;
121
+ snapshotTimeoutMs: z.ZodOptional<z.ZodNumber>;
122
+ syncTimeoutMs: z.ZodOptional<z.ZodNumber>;
117
123
  configTimeoutMs: z.ZodOptional<z.ZodNumber>;
118
124
  }, z.core.$strip>;
119
125
  export type StepContext = z.infer<typeof StepContextSchema>;
@@ -135,6 +141,77 @@ export declare const DbSyncOutputSchema: z.ZodObject<{
135
141
  reportJsonPath: z.ZodOptional<z.ZodString>;
136
142
  exitCode: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>]>;
137
143
  error: z.ZodOptional<z.ZodString>;
144
+ outcome: z.ZodObject<{
145
+ command: z.ZodString;
146
+ exitMode: z.ZodEnum<{
147
+ success: "success";
148
+ success_with_warnings: "success_with_warnings";
149
+ failed: "failed";
150
+ timeout: "timeout";
151
+ cancelled: "cancelled";
152
+ }>;
153
+ startedAt: z.ZodString;
154
+ endedAt: z.ZodString;
155
+ durationMs: z.ZodNumber;
156
+ phases: z.ZodArray<z.ZodObject<{
157
+ id: z.ZodString;
158
+ label: z.ZodString;
159
+ status: z.ZodEnum<{
160
+ failed: "failed";
161
+ timeout: "timeout";
162
+ cancelled: "cancelled";
163
+ pending: "pending";
164
+ running: "running";
165
+ passed: "passed";
166
+ warning: "warning";
167
+ skipped: "skipped";
168
+ }>;
169
+ startedAt: z.ZodOptional<z.ZodString>;
170
+ endedAt: z.ZodOptional<z.ZodString>;
171
+ durationMs: z.ZodOptional<z.ZodNumber>;
172
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
173
+ warningCount: z.ZodOptional<z.ZodNumber>;
174
+ error: z.ZodOptional<z.ZodObject<{
175
+ code: z.ZodString;
176
+ message: z.ZodString;
177
+ statusCode: z.ZodOptional<z.ZodNumber>;
178
+ retryable: z.ZodBoolean;
179
+ retryAfterMs: z.ZodOptional<z.ZodNumber>;
180
+ phase: z.ZodOptional<z.ZodString>;
181
+ details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
182
+ }, z.core.$strict>>;
183
+ warnings: z.ZodOptional<z.ZodArray<z.ZodObject<{
184
+ code: z.ZodString;
185
+ message: z.ZodString;
186
+ phase: z.ZodString;
187
+ details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
188
+ }, z.core.$strict>>>;
189
+ metrics: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
190
+ }, z.core.$strict>>;
191
+ warnings: z.ZodArray<z.ZodObject<{
192
+ code: z.ZodString;
193
+ message: z.ZodString;
194
+ phase: z.ZodString;
195
+ details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
196
+ }, z.core.$strict>>;
197
+ errors: z.ZodArray<z.ZodObject<{
198
+ code: z.ZodString;
199
+ message: z.ZodString;
200
+ statusCode: z.ZodOptional<z.ZodNumber>;
201
+ retryable: z.ZodBoolean;
202
+ retryAfterMs: z.ZodOptional<z.ZodNumber>;
203
+ phase: z.ZodOptional<z.ZodString>;
204
+ details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
205
+ }, z.core.$strict>>;
206
+ summary: z.ZodObject<{
207
+ passed: z.ZodNumber;
208
+ warnings: z.ZodNumber;
209
+ failed: z.ZodNumber;
210
+ skipped: z.ZodNumber;
211
+ timedOut: z.ZodNumber;
212
+ }, z.core.$strict>;
213
+ nextActions: z.ZodOptional<z.ZodArray<z.ZodString>>;
214
+ }, z.core.$strict>;
138
215
  }, z.core.$strict>;
139
216
  export type DbSyncOutput = z.infer<typeof DbSyncOutputSchema>;
140
217
  /**
@@ -152,6 +229,7 @@ export declare const DbSyncMachineInputSchema: z.ZodObject<{
152
229
  verbose: z.ZodOptional<z.ZodBoolean>;
153
230
  skipCodegen: z.ZodOptional<z.ZodBoolean>;
154
231
  strictIntrospect: z.ZodOptional<z.ZodBoolean>;
232
+ strict: z.ZodOptional<z.ZodBoolean>;
155
233
  targetDir: z.ZodOptional<z.ZodString>;
156
234
  fromProduction: z.ZodOptional<z.ZodBoolean>;
157
235
  autoSnapshot: z.ZodOptional<z.ZodBoolean>;
@@ -159,6 +237,8 @@ export declare const DbSyncMachineInputSchema: z.ZodObject<{
159
237
  reportJson: z.ZodOptional<z.ZodString>;
160
238
  reconcile: z.ZodOptional<z.ZodBoolean>;
161
239
  timeoutMs: z.ZodOptional<z.ZodNumber>;
240
+ snapshotTimeoutMs: z.ZodOptional<z.ZodNumber>;
241
+ syncTimeoutMs: z.ZodOptional<z.ZodNumber>;
162
242
  }, z.core.$strict>;
163
243
  export type DbSyncMachineInput = z.infer<typeof DbSyncMachineInputSchema>;
164
244
  //# sourceMappingURL=contract.d.ts.map
@@ -104,7 +104,7 @@ export declare const dbSyncMachine: import("xstate").StateMachine<DbSyncContext,
104
104
  src: "writeReport";
105
105
  logic: import("xstate").PromiseActorLogic<actors.ReportOutput, actors.ReportInput, import("xstate").EventObject>;
106
106
  id: string | undefined;
107
- }, never, never, never, "done" | "failed" | "sync" | "setup" | "idle" | "snapshot" | "preflight" | "reconcile" | "report", string, {
107
+ }, never, never, never, "done" | "failed" | "sync" | "setup" | "idle" | "snapshot" | "report" | "preflight" | "reconcile", string, {
108
108
  env?: "local" | "preview" | "production" | undefined;
109
109
  check?: boolean | undefined;
110
110
  force?: boolean | undefined;
@@ -112,6 +112,7 @@ export declare const dbSyncMachine: import("xstate").StateMachine<DbSyncContext,
112
112
  verbose?: boolean | undefined;
113
113
  skipCodegen?: boolean | undefined;
114
114
  strictIntrospect?: boolean | undefined;
115
+ strict?: boolean | undefined;
115
116
  targetDir?: string | undefined;
116
117
  fromProduction?: boolean | undefined;
117
118
  autoSnapshot?: boolean | undefined;
@@ -119,6 +120,8 @@ export declare const dbSyncMachine: import("xstate").StateMachine<DbSyncContext,
119
120
  reportJson?: string | undefined;
120
121
  reconcile?: boolean | undefined;
121
122
  timeoutMs?: number | undefined;
123
+ snapshotTimeoutMs?: number | undefined;
124
+ syncTimeoutMs?: number | undefined;
122
125
  }, {
123
126
  env: "local" | "preview" | "production";
124
127
  check: boolean;
@@ -128,6 +131,62 @@ export declare const dbSyncMachine: import("xstate").StateMachine<DbSyncContext,
128
131
  applied: boolean;
129
132
  stepsCompleted: string[];
130
133
  exitCode: 0 | 1;
134
+ outcome: {
135
+ command: string;
136
+ exitMode: "success" | "timeout" | "failed" | "cancelled" | "success_with_warnings";
137
+ startedAt: string;
138
+ endedAt: string;
139
+ durationMs: number;
140
+ phases: {
141
+ id: string;
142
+ label: string;
143
+ status: "timeout" | "warning" | "skipped" | "failed" | "pending" | "running" | "passed" | "cancelled";
144
+ startedAt?: string | undefined;
145
+ endedAt?: string | undefined;
146
+ durationMs?: number | undefined;
147
+ timeoutMs?: number | undefined;
148
+ warningCount?: number | undefined;
149
+ error?: {
150
+ code: string;
151
+ message: string;
152
+ retryable: boolean;
153
+ statusCode?: number | undefined;
154
+ retryAfterMs?: number | undefined;
155
+ phase?: string | undefined;
156
+ details?: Record<string, unknown> | undefined;
157
+ } | undefined;
158
+ warnings?: {
159
+ code: string;
160
+ message: string;
161
+ phase: string;
162
+ details?: Record<string, unknown> | undefined;
163
+ }[] | undefined;
164
+ metrics?: Record<string, number> | undefined;
165
+ }[];
166
+ warnings: {
167
+ code: string;
168
+ message: string;
169
+ phase: string;
170
+ details?: Record<string, unknown> | undefined;
171
+ }[];
172
+ errors: {
173
+ code: string;
174
+ message: string;
175
+ retryable: boolean;
176
+ statusCode?: number | undefined;
177
+ retryAfterMs?: number | undefined;
178
+ phase?: string | undefined;
179
+ details?: Record<string, unknown> | undefined;
180
+ }[];
181
+ summary: {
182
+ passed: number;
183
+ warnings: number;
184
+ failed: number;
185
+ skipped: number;
186
+ timedOut: number;
187
+ };
188
+ nextActions?: string[] | undefined;
189
+ };
131
190
  reportJsonPath?: string | undefined;
132
191
  error?: string | undefined;
133
192
  }, import("xstate").EventObject, import("xstate").MetaObject, {