@runa-ai/runa-cli 0.8.0 → 0.10.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 (110) 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-JMJP4A47.js → chunk-GT5DMS5R.js} +20 -2
  8. package/dist/{chunk-3JO6YP3T.js → chunk-IEKYTCYA.js} +1 -1
  9. package/dist/{chunk-WPMR7RQ4.js → chunk-IWVXI5O4.js} +2 -2
  10. package/dist/chunk-KUH3G522.js +72 -0
  11. package/dist/{chunk-VSH3IXDQ.js → chunk-MAFJAA2P.js} +1 -1
  12. package/dist/{chunk-CCKG5R4Y.js → chunk-MILCC3B6.js} +1 -1
  13. package/dist/{chunk-5NKWR4FF.js → chunk-OERS32LW.js} +1 -1
  14. package/dist/{chunk-GHQH6UC5.js → chunk-OXQISY3J.js} +1 -1
  15. package/dist/chunk-QDOR3GTD.js +9043 -0
  16. package/dist/{chunk-2QX7T24B.js → chunk-QKGL6Q2S.js} +1 -1
  17. package/dist/{chunk-OBYZDT2E.js → chunk-URWDB7YL.js} +15 -78
  18. package/dist/{chunk-ZYT7OQJB.js → chunk-WGRVAGSR.js} +6 -6
  19. package/dist/chunk-ZWDWFMOX.js +1514 -0
  20. package/dist/{ci-ZK3LKYFX.js → ci-FLTJ2UXB.js} +992 -849
  21. package/dist/{cli-ZY5VRIJA.js → cli-THEA6T7N.js} +31 -31
  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-IDKQ44VX.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/{template-check-BDFMT6ZO.js → template-check-VNNQQXCX.js} +10 -0
  101. package/dist/{test-V4KQL574.js → test-QCPN6Z47.js} +74 -46
  102. package/dist/{upgrade-7L4JIE4K.js → upgrade-QZKEI3NJ.js} +2 -2
  103. package/dist/utils/db-url-utils.d.ts +4 -77
  104. package/dist/{vuln-check-G6I4YYDC.js → vuln-check-JRPMUHLF.js} +1 -1
  105. package/dist/{vuln-checker-CT2AYPIS.js → vuln-checker-Q7LSHUHJ.js} +1 -1
  106. package/dist/{watch-AL4LCBRM.js → watch-RFVCEQLH.js} +3 -3
  107. package/dist/{workflow-UZIZ2JUS.js → workflow-UOG6ZZMH.js} +3 -3
  108. package/package.json +3 -3
  109. package/dist/chunk-6E2DRXIL.js +0 -452
  110. package/dist/db-EPI2DQYN.js +0 -18275
@@ -0,0 +1,61 @@
1
+ /**
2
+ * AI HINT: Schema Guardrail Graph - Node Building
3
+ *
4
+ * Purpose: Build graph nodes from declarative SQL files
5
+ * Includes: Trigger extraction, declarative file parsing,
6
+ * table/FK/dependency/file node construction
7
+ */
8
+ import { type SqlFile } from '../utils/declarative-dependency-sql-utils.js';
9
+ import { type DeclarativeFileRecord, type DefinedFunctionMetadata, type ManagedBoundaryMetadata, type IdempotentTouchMetadata } from './schema-guardrail-graph-types.js';
10
+ import type { SchemaGuardrailConfig, SchemaGraphFileDependencyEdge, SchemaGraphFileNode, SchemaGraphFunctionClaim, SchemaGraphPolicyClaim, SchemaGraphPolicyRef, SchemaGraphTableNode, SchemaGraphTriggerRef, SchemaGuardrailReport } from './schema-guardrail-types.js';
11
+ declare function parseCreateTriggerStatement(statement: string): {
12
+ qualifiedTable: string;
13
+ trigger: SchemaGraphTriggerRef;
14
+ } | null;
15
+ declare function appendTriggerRef(triggerMap: Map<string, SchemaGraphTriggerRef[]>, qualifiedTable: string, trigger: SchemaGraphTriggerRef): void;
16
+ declare function extractCreateTriggers(content: string): Map<string, SchemaGraphTriggerRef[]>;
17
+ declare function buildDeclarativeFileRecord(file: SqlFile): Promise<DeclarativeFileRecord>;
18
+ declare function collectDeclarativeClaims(records: DeclarativeFileRecord[]): {
19
+ tableOwnerClaims: Map<string, Set<string>>;
20
+ schemaClaims: Map<string, Set<string>>;
21
+ createSchemaClaims: Map<string, Set<string>>;
22
+ tablePolicies: Map<string, SchemaGraphPolicyRef[]>;
23
+ policyClaims: SchemaGraphPolicyClaim[];
24
+ };
25
+ declare function createDuplicateTableOwners(tableOwnerClaims: Map<string, Set<string>>): SchemaGuardrailReport['duplicateTableOwners'];
26
+ declare function buildFunctionValidationArtifacts(params: {
27
+ targetDir: string;
28
+ config: SchemaGuardrailConfig;
29
+ declarativeFiles: SqlFile[];
30
+ idempotentFiles: SqlFile[];
31
+ }): {
32
+ duplicateFunctionOwners: SchemaGuardrailReport['duplicateFunctionOwners'];
33
+ functionClaims: SchemaGraphFunctionClaim[];
34
+ };
35
+ declare function buildOwnerFileByTable(tableOwnerClaims: Map<string, Set<string>>): Map<string, string>;
36
+ declare function buildPolicyOwnershipConflicts(params: {
37
+ policyClaims: SchemaGraphPolicyClaim[];
38
+ ownerFileByTable: Map<string, string>;
39
+ }): SchemaGuardrailReport['policyOwnershipConflicts'];
40
+ declare function buildTableNodesByName(params: {
41
+ records: DeclarativeFileRecord[];
42
+ tablePolicies: Map<string, SchemaGraphPolicyRef[]>;
43
+ }): Map<string, SchemaGraphTableNode>;
44
+ declare function attachInboundForeignKeys(tableNodesByName: Map<string, SchemaGraphTableNode>): void;
45
+ declare function buildFileDependencies(params: {
46
+ tableNodesByName: Map<string, SchemaGraphTableNode>;
47
+ ownerFileByTable: Map<string, string>;
48
+ }): SchemaGraphFileDependencyEdge[];
49
+ declare function normalizeTriggerFunctionToken(value: string | undefined): string | null;
50
+ declare function buildFileNodes(params: {
51
+ records: DeclarativeFileRecord[];
52
+ idempotentFiles: SqlFile[];
53
+ idempotentTouchMetadata: Map<string, IdempotentTouchMetadata>;
54
+ definedFunctionMetadataByFile: Map<string, DefinedFunctionMetadata[]>;
55
+ managedBoundaryMetadataByFile: Map<string, ManagedBoundaryMetadata>;
56
+ config: SchemaGuardrailConfig;
57
+ fileDependencies: SchemaGraphFileDependencyEdge[];
58
+ managedSchemas: Set<string>;
59
+ }): SchemaGraphFileNode[];
60
+ export { parseCreateTriggerStatement, appendTriggerRef, extractCreateTriggers, buildDeclarativeFileRecord, collectDeclarativeClaims, createDuplicateTableOwners, buildFunctionValidationArtifacts, buildOwnerFileByTable, buildPolicyOwnershipConflicts, buildTableNodesByName, attachInboundForeignKeys, buildFileDependencies, normalizeTriggerFunctionToken, buildFileNodes, };
61
+ //# sourceMappingURL=schema-guardrail-graph-nodes.d.ts.map
@@ -0,0 +1,31 @@
1
+ /**
2
+ * AI HINT: Schema Guardrail Graph - SQL Helpers
3
+ *
4
+ * Purpose: SQL string sanitization, pattern matching, and metadata extraction
5
+ * for idempotent file analysis
6
+ */
7
+ import { type SqlFile } from '../utils/declarative-dependency-sql-utils.js';
8
+ import type { IdempotentTouchMetadata } from './schema-guardrail-graph-types.js';
9
+ declare function normalizeSqlIdentifier(value: string): string;
10
+ declare function consumeSingleQuotedLiteral(params: {
11
+ content: string;
12
+ startIndex: number;
13
+ prefixLength: number;
14
+ }): {
15
+ blankedText: string;
16
+ nextIndex: number;
17
+ };
18
+ declare function blankSingleQuotedStrings(content: string): string;
19
+ declare function blankDynamicExecuteLiterals(content: string): string;
20
+ declare function sanitizeIdempotentTouchScanContent(content: string): string;
21
+ declare function splitFunctionTargetList(value: string): string[];
22
+ declare function normalizeFunctionTouchTarget(value: string): string | null;
23
+ declare function extractTouchedSchemas(content: string): string[];
24
+ declare function extractTouchedFunctions(content: string): string[];
25
+ declare function normalizeExtensionIdentifier(identifier: string): string;
26
+ declare function extractTouchedExtensions(content: string): string[];
27
+ declare function extractTouchedPolicies(content: string): string[];
28
+ declare function extractIdempotentTouchMetadata(file: SqlFile): IdempotentTouchMetadata;
29
+ export declare function buildIdempotentTouchMetadata(files: SqlFile[]): Map<string, IdempotentTouchMetadata>;
30
+ export { normalizeSqlIdentifier, consumeSingleQuotedLiteral, blankSingleQuotedStrings, blankDynamicExecuteLiterals, sanitizeIdempotentTouchScanContent, splitFunctionTargetList, normalizeFunctionTouchTarget, normalizeExtensionIdentifier, extractTouchedSchemas, extractTouchedFunctions, extractTouchedExtensions, extractTouchedPolicies, extractIdempotentTouchMetadata, };
31
+ //# sourceMappingURL=schema-guardrail-graph-sql-helpers.d.ts.map
@@ -0,0 +1,56 @@
1
+ /**
2
+ * AI HINT: Schema Guardrail Graph - Types & Constants
3
+ *
4
+ * Purpose: Shared types, constants, and tiny utility functions
5
+ * for the schema guardrail graph builder
6
+ */
7
+ import type { SqlFile } from '../utils/declarative-dependency-sql-utils.js';
8
+ import type { SchemaGraphManifest, SchemaGraphOutboundForeignKey, SchemaGraphPolicyClaim, SchemaGraphTriggerRef } from './schema-guardrail-types.js';
9
+ export type PolicyCommand = 'all' | 'select' | 'insert' | 'update' | 'delete';
10
+ export type IdempotentTouchMetadata = {
11
+ touchedSchemas: string[];
12
+ touchedExtensions: string[];
13
+ touchedFunctions: string[];
14
+ touchedPolicies: string[];
15
+ };
16
+ export type DefinedFunctionMetadata = {
17
+ qualifiedName: string;
18
+ qualifiedSignature: string;
19
+ securityDefiner: boolean;
20
+ searchPathLocked: boolean;
21
+ crossSchemaRefs: string[];
22
+ };
23
+ export type ManagedBoundaryMetadata = {
24
+ schemas: string[];
25
+ refs: string[];
26
+ };
27
+ export type DeclarativeFileRecord = {
28
+ file: SqlFile;
29
+ declaredSchemas: string[];
30
+ createSchemaClaims: string[];
31
+ tables: Array<{
32
+ schema: string;
33
+ name: string;
34
+ qualifiedName: string;
35
+ lineNumber?: number;
36
+ columns: string[];
37
+ outboundForeignKeys: SchemaGraphOutboundForeignKey[];
38
+ }>;
39
+ policies: SchemaGraphPolicyClaim[];
40
+ triggersByTable: Map<string, SchemaGraphTriggerRef[]>;
41
+ };
42
+ export declare const GENERATOR_VERSION = "1.0.0";
43
+ export declare const SQL_IDENTIFIER_PATTERN: RegExp;
44
+ export declare const SQL_EXTENSION_IDENTIFIER_PATTERN: RegExp;
45
+ export declare const QUALIFIED_SQL_OBJECT_RE: RegExp;
46
+ export declare const SECURITY_DEFINER_RE: RegExp;
47
+ export declare const SEARCH_PATH_LOCK_RE: RegExp;
48
+ export declare const MANAGED_BOUNDARY_SCHEMAS: readonly ["auth", "storage", "extensions", "net", "supabase_functions"];
49
+ export declare const TRIGGER_GUIDANCE_SUPPRESSED_FUNCTIONS: Set<string>;
50
+ export declare const MAX_SCHEMA_GUIDANCE_TARGETS_PER_FILE = 3;
51
+ export declare function makeGraphVersion(graph: Omit<SchemaGraphManifest, 'graphVersion' | 'generatedAt'>): string;
52
+ export declare function currentIsoTimestamp(): string;
53
+ export declare function stableSorted<T>(values: Iterable<T>, map: (value: T) => string): T[];
54
+ export declare function normalizeFileList(files: Iterable<string>): string[];
55
+ export declare function normalizePolicyCommand(input: string): PolicyCommand;
56
+ //# sourceMappingURL=schema-guardrail-graph-types.d.ts.map
@@ -0,0 +1,20 @@
1
+ /**
2
+ * AI HINT: Schema Guardrail Graph - Orchestration
3
+ *
4
+ * Purpose: Main entry points for schema guardrail graph building
5
+ * Exports: loadSqlSources, buildStaticGraph, StaticGraphBuildResult
6
+ */
7
+ import type { LoadedSqlSources, SchemaGraphManifest, SchemaGuardrailConfig, SchemaGuardrailReport } from './schema-guardrail-types.js';
8
+ export declare function loadSqlSources(targetDir: string, config: SchemaGuardrailConfig): LoadedSqlSources;
9
+ export type StaticGraphBuildResult = {
10
+ graph: SchemaGraphManifest;
11
+ duplicateTableOwners: SchemaGuardrailReport['duplicateTableOwners'];
12
+ duplicateFunctionOwners: SchemaGuardrailReport['duplicateFunctionOwners'];
13
+ policyOwnershipConflicts: SchemaGuardrailReport['policyOwnershipConflicts'];
14
+ semanticDuplicateWarnings: SchemaGuardrailReport['semanticDuplicateWarnings'];
15
+ boundaryGuidanceWarnings: SchemaGuardrailReport['boundaryGuidanceWarnings'];
16
+ localBlindSpotBlockers: SchemaGuardrailReport['localBlindSpotBlockers'];
17
+ multiFileSchemas: SchemaGuardrailReport['multiFileSchemas'];
18
+ };
19
+ export declare function buildStaticGraph(targetDir: string, config: SchemaGuardrailConfig, sources: LoadedSqlSources): Promise<StaticGraphBuildResult>;
20
+ //# sourceMappingURL=schema-guardrail-graph.d.ts.map
@@ -0,0 +1,7 @@
1
+ import type { LoadedSqlSources, LocalBlindSpotBlocker, SchemaGraphManifest } from './schema-guardrail-types.js';
2
+ export declare function buildLocalBlindSpotBlockers(params: {
3
+ graph: SchemaGraphManifest;
4
+ sources: LoadedSqlSources;
5
+ managedSchemas: Set<string>;
6
+ }): LocalBlindSpotBlocker[];
7
+ //# sourceMappingURL=schema-guardrail-local-blockers.d.ts.map
@@ -0,0 +1,26 @@
1
+ import type { SchemaGuardrailReport } from './schema-guardrail-types.js';
2
+ type GuardrailPhaseResult = {
3
+ id: string;
4
+ label: string;
5
+ status: 'passed' | 'warning' | 'failed';
6
+ warningCount?: number;
7
+ warnings?: Array<{
8
+ code: string;
9
+ message: string;
10
+ phase: string;
11
+ details?: Record<string, unknown>;
12
+ }>;
13
+ error?: {
14
+ code: string;
15
+ message: string;
16
+ retryable: boolean;
17
+ phase: string;
18
+ };
19
+ };
20
+ export declare function isStaleBlocking(params: {
21
+ targetDir: string;
22
+ strictOption?: boolean;
23
+ }): boolean;
24
+ export declare function createGuardrailOutcomePhases(report: SchemaGuardrailReport): GuardrailPhaseResult[];
25
+ export {};
26
+ //# sourceMappingURL=schema-guardrail-phases.d.ts.map
@@ -0,0 +1,23 @@
1
+ /**
2
+ * AI HINT: Post-sync Production DDL Order Check
3
+ *
4
+ * Purpose: After local db sync succeeds, generate a pg-schema-diff plan
5
+ * against production (if credentials available) and validate DDL ordering.
6
+ *
7
+ * This catches ALTER POLICY before CREATE FUNCTION issues that only appear
8
+ * in incremental diffs against an existing production database, not during
9
+ * fresh-DB local syncs.
10
+ *
11
+ * Requires: GH_DATABASE_URL_ADMIN or DATABASE_URL_ADMIN (production)
12
+ * If not available: silently skipped (local-only development is fine)
13
+ */
14
+ interface ProductionCheckParams {
15
+ targetDir: string;
16
+ logger: {
17
+ info(message: string): void;
18
+ warn(message: string): void;
19
+ };
20
+ }
21
+ export declare function runProductionDdlOrderCheck(params: ProductionCheckParams): Promise<void>;
22
+ export {};
23
+ //# sourceMappingURL=schema-guardrail-production-check.d.ts.map
@@ -0,0 +1,46 @@
1
+ import type { SchemaGraphManifest, SchemaManagedBlockKind, SchemaGuardrailConfig, SchemaGuardrailReport, SchemaGuardrailStaticResult } from './schema-guardrail-types.js';
2
+ type RenderedManagedBlock = {
3
+ kind: SchemaManagedBlockKind;
4
+ target: string;
5
+ content: string;
6
+ };
7
+ export type HeaderRewritePlan = {
8
+ filePath: string;
9
+ originalSql: string;
10
+ expectedFileBlock?: RenderedManagedBlock;
11
+ expectedTableHeaders: RenderedManagedBlock[];
12
+ staleBlocks: Array<{
13
+ file: string;
14
+ kind: SchemaManagedBlockKind;
15
+ target: string;
16
+ }>;
17
+ existingManagedCount: number;
18
+ };
19
+ export declare function loadHeaderRewritePlans(params: {
20
+ targetDir: string;
21
+ graph: SchemaGraphManifest;
22
+ config: SchemaGuardrailConfig;
23
+ report: SchemaGuardrailReport;
24
+ }): {
25
+ staleBlocks: SchemaGuardrailReport['staleBlocks'];
26
+ rewritePlans: HeaderRewritePlan[];
27
+ failure?: undefined;
28
+ } | {
29
+ staleBlocks?: undefined;
30
+ rewritePlans?: undefined;
31
+ failure: SchemaGuardrailStaticResult;
32
+ };
33
+ export declare function finalizeCheckModeReport(params: {
34
+ report: SchemaGuardrailReport;
35
+ graph: SchemaGraphManifest;
36
+ staleBlocks: SchemaGuardrailReport['staleBlocks'];
37
+ targetDir: string;
38
+ strictOption?: boolean;
39
+ }): SchemaGuardrailStaticResult;
40
+ export declare function rewriteManagedHeaders(params: {
41
+ targetDir: string;
42
+ rewritePlans: HeaderRewritePlan[];
43
+ report: SchemaGuardrailReport;
44
+ }): SchemaGuardrailStaticResult | null;
45
+ export {};
46
+ //# sourceMappingURL=schema-guardrail-rewrite.d.ts.map
@@ -0,0 +1,5 @@
1
+ import type { TablesManifest } from '@runa-ai/runa/manifests';
2
+ import type { SchemaGuardrailReport, SchemaGuardrailRuntimeInput } from './schema-guardrail-types.js';
3
+ export declare function loadRuntimeTablesManifest(targetDir: string): TablesManifest | null;
4
+ export declare function runSchemaGuardrailRuntime(input: SchemaGuardrailRuntimeInput): SchemaGuardrailReport;
5
+ //# sourceMappingURL=schema-guardrail-runtime.d.ts.map
@@ -0,0 +1,9 @@
1
+ import type { TablesManifest } from '@runa-ai/runa/manifests';
2
+ import type { SchemaGraphManifest, SchemaGuardrailConfig, SemanticDuplicateWarning } from './schema-guardrail-types.js';
3
+ export declare function createSemanticWarningDetails(warning: SemanticDuplicateWarning): Record<string, unknown>;
4
+ export declare function buildSemanticDuplicateWarnings(params: {
5
+ graph: SchemaGraphManifest;
6
+ runtimeTables: TablesManifest | null;
7
+ config: SchemaGuardrailConfig;
8
+ }): SemanticDuplicateWarning[];
9
+ //# sourceMappingURL=schema-guardrail-semantic-warnings.d.ts.map
@@ -0,0 +1,243 @@
1
+ import type { SqlFile } from '../utils/declarative-dependency-sql-utils.js';
2
+ export type SchemaManagedBlockKind = 'file-header' | 'table-header';
3
+ export type SchemaGuardrailMode = 'check' | 'sync';
4
+ export type SchemaGraphFileLayer = 'declarative' | 'idempotent';
5
+ export type SchemaGraphFileAuthoringRole = 'declarative-owner' | 'operational';
6
+ export type BoundaryGuidanceWarningKind = 'schema' | 'function' | 'policy' | 'security_definer' | 'trigger_function' | 'managed_boundary';
7
+ export type LocalBlindSpotBlockerKind = 'cross-schema-rls' | 'dynamic-sql' | 'extension-placement';
8
+ export type SchemaGuardrailPhaseId = 'load_sources' | 'build_static_graph' | 'validate_ownership' | 'compare_generated_headers' | 'refresh_generated_headers' | 'handoff_db_sync' | 'runtime_reconcile' | 'publish_report';
9
+ export type SchemaGuardrailFailureCode = 'source_load_failed' | 'duplicate_table_owner' | 'duplicate_function_owner' | 'policy_ownership_conflict' | 'raw_cross_schema_rls_blocked' | 'dynamic_sql_blocked' | 'extension_placement_blocked' | 'stale_generated_header' | 'generated_header_validation_failed' | 'generated_header_rewrite_failed' | 'static_graph_build_failed' | 'critical_runtime_graph_contradiction' | 'sync_apply_failed';
10
+ export interface SchemaGraphFileNode {
11
+ path: string;
12
+ sourceLayer: SchemaGraphFileLayer;
13
+ authoringRole: SchemaGraphFileAuthoringRole;
14
+ domainName?: string;
15
+ declaredSchemas: string[];
16
+ ownedTables: string[];
17
+ forwardDependsOnFiles: string[];
18
+ definedFunctions: string[];
19
+ securityDefinerFunctions: string[];
20
+ securityDefinerContracts: string[];
21
+ triggerFunctions: string[];
22
+ functionCrossSchemaRefs: string[];
23
+ managedBoundarySchemas: string[];
24
+ managedBoundaryRefs: string[];
25
+ touchedSchemas: string[];
26
+ touchedExtensions: string[];
27
+ touchedFunctions: string[];
28
+ touchedPolicies: string[];
29
+ policyCrossSchemaRefs: string[];
30
+ preferredEditSurface?: string;
31
+ idempotentPurpose?: string;
32
+ }
33
+ export interface SchemaGraphSchemaNode {
34
+ name: string;
35
+ claimFiles: string[];
36
+ createSchemaFiles?: string[];
37
+ }
38
+ export interface SchemaGraphOutboundForeignKey {
39
+ column: string;
40
+ referencesTable: string;
41
+ referencesColumn: string;
42
+ onDelete?: 'CASCADE' | 'SET NULL' | 'SET DEFAULT' | 'RESTRICT' | 'NO ACTION';
43
+ onUpdate?: 'CASCADE' | 'SET NULL' | 'SET DEFAULT' | 'RESTRICT' | 'NO ACTION';
44
+ }
45
+ export interface SchemaGraphInboundForeignKey {
46
+ fromTable: string;
47
+ fromColumn: string;
48
+ toColumn: string;
49
+ onDelete?: 'CASCADE' | 'SET NULL' | 'SET DEFAULT' | 'RESTRICT' | 'NO ACTION';
50
+ onUpdate?: 'CASCADE' | 'SET NULL' | 'SET DEFAULT' | 'RESTRICT' | 'NO ACTION';
51
+ }
52
+ export interface SchemaGraphPolicyRef {
53
+ name: string;
54
+ command: 'all' | 'select' | 'insert' | 'update' | 'delete';
55
+ }
56
+ export interface SchemaGraphTriggerRef {
57
+ name: string;
58
+ timing: 'BEFORE' | 'AFTER' | 'INSTEAD OF';
59
+ event: string;
60
+ functionName?: string;
61
+ }
62
+ export interface SchemaGraphTableNode {
63
+ schema: string;
64
+ name: string;
65
+ qualifiedName: string;
66
+ ownerFile: string;
67
+ lineNumber?: number;
68
+ columns: string[];
69
+ outboundForeignKeys: SchemaGraphOutboundForeignKey[];
70
+ inboundForeignKeys: SchemaGraphInboundForeignKey[];
71
+ policies: SchemaGraphPolicyRef[];
72
+ triggers: SchemaGraphTriggerRef[];
73
+ }
74
+ export interface SchemaGraphFunctionClaim {
75
+ qualifiedName: string;
76
+ signature: string;
77
+ sourceLayer: 'declarative' | 'idempotent';
78
+ sourceFile: string;
79
+ lineNumber?: number;
80
+ bodyHash?: string;
81
+ }
82
+ export interface SchemaGraphPolicyClaim {
83
+ name: string;
84
+ targetTable: string;
85
+ command: 'all' | 'select' | 'insert' | 'update' | 'delete';
86
+ sourceFile: string;
87
+ lineNumber?: number;
88
+ }
89
+ export interface SchemaGraphFileDependencyEdge {
90
+ fromFile: string;
91
+ toFile: string;
92
+ viaTables: string[];
93
+ }
94
+ export interface SchemaGraphManifest {
95
+ version: 1;
96
+ source: 'declarative-sql-ast';
97
+ generatedAt: string;
98
+ generatorVersion: string;
99
+ graphVersion: string;
100
+ files: SchemaGraphFileNode[];
101
+ schemas: SchemaGraphSchemaNode[];
102
+ tables: SchemaGraphTableNode[];
103
+ functionClaims: SchemaGraphFunctionClaim[];
104
+ policyClaims: SchemaGraphPolicyClaim[];
105
+ fileDependencies: SchemaGraphFileDependencyEdge[];
106
+ }
107
+ export interface RuntimeWarningIssue {
108
+ code: 'RUNTIME_EXTRA_TABLE';
109
+ target: string;
110
+ details: string;
111
+ }
112
+ export interface RuntimeContradictionIssue {
113
+ code: 'RUNTIME_TABLE_MISSING' | 'RUNTIME_FK_MISMATCH' | 'RUNTIME_POLICY_MISMATCH' | 'RUNTIME_TRIGGER_MISMATCH';
114
+ target: string;
115
+ details: string;
116
+ }
117
+ export interface SemanticDuplicateEvidence {
118
+ nameSimilarity: number;
119
+ sharedColumns: string[];
120
+ sharedFkNeighborhood: string[];
121
+ sameSchemaAffinity: boolean;
122
+ }
123
+ export interface SemanticDuplicateCandidate {
124
+ qualifiedName: string;
125
+ ownerFile: string;
126
+ score: number;
127
+ evidence: SemanticDuplicateEvidence;
128
+ }
129
+ export interface SemanticDuplicateWarning {
130
+ proposedTable: string;
131
+ ownerFile: string;
132
+ candidates: SemanticDuplicateCandidate[];
133
+ score: number;
134
+ evidence: SemanticDuplicateEvidence;
135
+ suggestedNextFile?: string;
136
+ suppressionKey: string;
137
+ }
138
+ export interface BoundaryGuidanceWarning {
139
+ sourceFile: string;
140
+ kind: BoundaryGuidanceWarningKind;
141
+ target: string;
142
+ suggestedDeclarativeFile?: string;
143
+ suggestedIdempotentFile?: string;
144
+ suggestedHelperFunction?: string;
145
+ reason: string;
146
+ }
147
+ export interface LocalBlindSpotBlocker {
148
+ kind: LocalBlindSpotBlockerKind;
149
+ sourceFile: string;
150
+ line?: number;
151
+ target: string;
152
+ details: string;
153
+ suggestedDeclarativeFile?: string;
154
+ suggestedHelper?: string;
155
+ requiredFile?: string;
156
+ }
157
+ export interface SchemaGuardrailReport {
158
+ mode: SchemaGuardrailMode;
159
+ exitMode: 'success' | 'success_with_warnings' | 'failed';
160
+ graphVersion?: string;
161
+ parser: {
162
+ engine: 'ast';
163
+ available: boolean;
164
+ };
165
+ multiFileSchemas: Array<{
166
+ schema: string;
167
+ files: string[];
168
+ }>;
169
+ duplicateTableOwners: Array<{
170
+ qualifiedName: string;
171
+ files: string[];
172
+ }>;
173
+ duplicateFunctionOwners: Array<{
174
+ qualifiedName: string;
175
+ signature: string | null;
176
+ declarativeFiles: string[];
177
+ idempotentFiles: string[];
178
+ }>;
179
+ policyOwnershipConflicts: Array<{
180
+ policyName: string;
181
+ targetTable: string;
182
+ files: string[];
183
+ tableOwnerFile: string;
184
+ }>;
185
+ semanticDuplicateWarnings: SemanticDuplicateWarning[];
186
+ boundaryGuidanceWarnings: BoundaryGuidanceWarning[];
187
+ localBlindSpotBlockers: LocalBlindSpotBlocker[];
188
+ staleBlocks: Array<{
189
+ file: string;
190
+ kind: SchemaManagedBlockKind;
191
+ target: string;
192
+ }>;
193
+ headersRewritten: string[];
194
+ rewritesRetainedOnDisk: boolean;
195
+ applyCommitted: boolean;
196
+ runtimeWarnings: RuntimeWarningIssue[];
197
+ runtimeContradictions: RuntimeContradictionIssue[];
198
+ failure?: {
199
+ phase: SchemaGuardrailPhaseId;
200
+ code: SchemaGuardrailFailureCode;
201
+ message: string;
202
+ };
203
+ }
204
+ export interface SchemaGuardrailStaticInput {
205
+ targetDir: string;
206
+ mode: SchemaGuardrailMode;
207
+ strictOption?: boolean;
208
+ enableLocalBlindSpotBlockers?: boolean;
209
+ }
210
+ export interface SchemaGuardrailStaticResult {
211
+ graph: SchemaGraphManifest | null;
212
+ report: SchemaGuardrailReport;
213
+ }
214
+ export interface SchemaGuardrailRuntimeInput {
215
+ targetDir: string;
216
+ graph: SchemaGraphManifest;
217
+ report: SchemaGuardrailReport;
218
+ }
219
+ export type SchemaGuardrailConfig = {
220
+ declarativeSqlDir: string;
221
+ allowedDuplicateFunctions: Array<{
222
+ qualifiedName: string;
223
+ signature: string;
224
+ reason: string;
225
+ declarativeFile?: string;
226
+ idempotentFile?: string;
227
+ expectedBodyHash?: string;
228
+ }>;
229
+ generatedHeaderRewriteTargets: string[];
230
+ semanticWarnings: {
231
+ threshold: number;
232
+ maxCandidates: number;
233
+ ignorePairs: Set<string>;
234
+ };
235
+ tableHeaderMaxWidth: number;
236
+ excludeFromOrphanDetection: string[];
237
+ idempotentSqlDir: string;
238
+ };
239
+ export type LoadedSqlSources = {
240
+ declarativeFiles: SqlFile[];
241
+ idempotentFiles: SqlFile[];
242
+ };
243
+ //# sourceMappingURL=schema-guardrail-types.d.ts.map
@@ -0,0 +1,10 @@
1
+ import { createGuardrailOutcomePhases } from './schema-guardrail-phases.js';
2
+ import { runSchemaGuardrailRuntime } from './schema-guardrail-runtime.js';
3
+ import type { SchemaGuardrailReport, SchemaGuardrailStaticInput, SchemaGuardrailStaticResult } from './schema-guardrail-types.js';
4
+ export declare function runSchemaGuardrailStatic(input: SchemaGuardrailStaticInput): Promise<SchemaGuardrailStaticResult>;
5
+ export declare function createSyncApplyFailureReport(report: SchemaGuardrailReport, message: string, options?: {
6
+ applyCommitted?: boolean;
7
+ }): SchemaGuardrailReport;
8
+ export { createGuardrailOutcomePhases };
9
+ export { runSchemaGuardrailRuntime };
10
+ //# sourceMappingURL=schema-guardrail.d.ts.map
@@ -36,7 +36,7 @@ export declare const STATIC_EXECUTE_LITERAL_RE: RegExp;
36
36
  export declare const DOLLAR_TAG_RE: RegExp;
37
37
  export declare const PUBLIC_SCHEMA = "public";
38
38
  export declare function countNewlines(text: string): number;
39
- export declare function collectSqlFiles(targetDir: string, layer: SqlLayer): SqlFile[];
39
+ export declare function collectSqlFiles(targetDir: string, layer: SqlLayer, relativeDir?: string): SqlFile[];
40
40
  export declare function blankQuotedStrings(content: string): string;
41
41
  export declare function sanitizeTopLevelSql(statement: string): string;
42
42
  export declare function sanitizeExecutableCode(content: string): string;
@@ -1,3 +1,25 @@
1
+ /**
2
+ * AI HINT: Duplicate Function Ownership Detector
3
+ *
4
+ * Purpose: Detect functions defined in BOTH declarative and idempotent SQL layers.
5
+ * Declarative SQL owns function definitions (pg-schema-diff manages them);
6
+ * idempotent SQL must not redefine declarative-managed functions.
7
+ *
8
+ * Key Functions:
9
+ * - analyzeDuplicateFunctionOwnership(targetDir): Scan declarative/ and idempotent/
10
+ * directories, collect all CREATE FUNCTION definitions, and report duplicates.
11
+ * - formatDuplicateFunctionOwnershipFinding(finding): Format a finding for CLI display.
12
+ *
13
+ * SQL Parsing Approach:
14
+ * - Uses regex-based CREATE [OR REPLACE] FUNCTION detection (from FUNCTION_DEFINITION_RE)
15
+ * - Signature normalization: strips parameter names, canonicalizes type aliases,
16
+ * handles dollar-quoting, nested parens, and DEFAULT expressions
17
+ * - Groups by qualified name (schema.function) and matches by normalized signature
18
+ *
19
+ * Finding Codes:
20
+ * - DUPLICATE_FUNCTION_OWNERSHIP: Exact signature match across layers
21
+ * - DUPLICATE_FUNCTION_OWNERSHIP_AMBIGUOUS: Same name but signature could not be matched
22
+ */
1
23
  import { type SqlLayer } from './declarative-dependency-sql-utils.js';
2
24
  export interface FunctionOwnershipDefinition {
3
25
  qualifiedName: string;
@@ -30,6 +52,10 @@ export interface FormattedDuplicateFunctionOwnershipFinding {
30
52
  suggestion: string;
31
53
  }
32
54
  export declare const DUPLICATE_FUNCTION_OWNERSHIP_NOTE = "Function ownership belongs to declarative SQL; idempotent 2nd pass must not redefine declarative-managed functions.";
33
- export declare function analyzeDuplicateFunctionOwnership(targetDir: string): DuplicateFunctionOwnershipAnalysisResult;
55
+ export declare function extractFunctionOwnershipDefinition(statement: string, file: string, line: number, layer: SqlLayer): FunctionOwnershipDefinition | null;
56
+ export declare function analyzeDuplicateFunctionOwnership(targetDir: string, options?: {
57
+ declarativeSqlDir?: string;
58
+ idempotentSqlDir?: string;
59
+ }): DuplicateFunctionOwnershipAnalysisResult;
34
60
  export declare function formatDuplicateFunctionOwnershipFinding(finding: DuplicateFunctionOwnershipFinding): FormattedDuplicateFunctionOwnershipFinding;
35
61
  //# sourceMappingURL=duplicate-function-ownership.d.ts.map
@@ -0,0 +1,12 @@
1
+ export type PolicyCrossSchemaReference = {
2
+ policySchema: string;
3
+ refSchema: string;
4
+ refTable: string;
5
+ qualifiedRef: string;
6
+ line: number;
7
+ };
8
+ export declare function collectPolicyCrossSchemaReferences(params: {
9
+ content: string;
10
+ managedSchemas: Iterable<string>;
11
+ }): PolicyCrossSchemaReference[];
12
+ //# sourceMappingURL=policy-cross-schema-refs.d.ts.map
@@ -25,6 +25,11 @@ import type { ForeignKeyDefinition, TableEntry } from '@runa-ai/runa/manifests';
25
25
  interface SqlParserUtils {
26
26
  isSqlParserAvailable(): Promise<boolean>;
27
27
  parseSchemaDocument(sqlContent: string): Promise<{
28
+ schemas: Array<{
29
+ name: string;
30
+ ifNotExists: boolean;
31
+ lineNumber?: number;
32
+ }>;
28
33
  tables: Array<{
29
34
  schema: string;
30
35
  name: string;
@@ -58,6 +63,7 @@ interface SqlParserUtils {
58
63
  for: 'select' | 'insert' | 'update' | 'delete' | 'all';
59
64
  using?: string;
60
65
  withCheck?: string;
66
+ lineNumber?: number;
61
67
  }>;
62
68
  }>;
63
69
  parseCreateTables(sqlContent: string): Promise<unknown>;
@@ -0,0 +1,15 @@
1
+ type Layer4ManifestFlagOptions = {
2
+ requireManifest?: boolean;
3
+ allowManifestFallback?: boolean;
4
+ };
5
+ type Layer4ManifestResolutionOptions = Layer4ManifestFlagOptions & {
6
+ exclusiveErrorCode: string;
7
+ };
8
+ type Layer4InjectOptions = {
9
+ verbose?: boolean;
10
+ requireManifest?: boolean;
11
+ };
12
+ export declare function resolveLayer4RequireManifest(options: Layer4ManifestResolutionOptions): boolean | undefined;
13
+ export declare function injectLayer4TestAttrs(options?: Layer4InjectOptions): void;
14
+ export {};
15
+ //# sourceMappingURL=layer4-prereqs.d.ts.map
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'module';
3
- export { getAppConfig, getDatabaseConfig, getDatabasePackagePath, getDeployConfig, getSDKScriptsPath, getSDKTemplatesPath, isMonorepo, loadRunaConfig, validateRunaConfig } from './chunk-5NKWR4FF.js';
4
- import './chunk-JMJP4A47.js';
3
+ export { getAppConfig, getDatabaseConfig, getDatabasePackagePath, getDeployConfig, getSDKScriptsPath, getSDKTemplatesPath, isMonorepo, loadRunaConfig, validateRunaConfig } from './chunk-OERS32LW.js';
4
+ import './chunk-GT5DMS5R.js';
5
5
  import './chunk-VRXHCR5K.js';
6
6
 
7
7
  createRequire(import.meta.url);