@ddt-tools/cli 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/import.ts"],"sourcesContent":["import { promises as fs } from 'node:fs';\nimport path from 'node:path';\nimport { Command } from 'commander';\nimport { importScript, loadProject, parseScript, type ParsedStatement } from '@ddt-tools/core';\n\n/**\n * `ddt import` — parse a SQL script and apply each DDL statement to a\n * `.ddtproj` tree, writing each into the canonical folder for its object\n * type (`catalogs/<cat>/schemas/<sch>/<type-folder>/<name>.sql`).\n *\n * Default mode is safe:\n * - Parses the whole script first; refuses to write anything if any\n * statement has hard errors. The user reviews the report, fixes the\n * script, and re-runs.\n * - Refuses to overwrite existing files. Pass `--force` to clobber.\n * - `--dry-run` shows the plan without writing.\n */\nexport function importCommand(): Command {\n const cmd = new Command('import');\n cmd\n .description(\n 'Parse a SQL script and write each DDL statement into the .ddtproj tree under its canonical folder.',\n )\n .requiredOption('--script <path>', 'Path to the SQL script to import.')\n .requiredOption('-p, --project <path>', 'Path to the .ddtproj file.')\n .option('--dry-run', 'Report what would be written without touching disk.', false)\n .option('--force', 'Overwrite existing files (default refuses on conflict).', false)\n .option(\n '--ignore-errors',\n 'Import classifiable statements even when others have errors. Default refuses on any error.',\n false,\n )\n .action(async (opts) => {\n const scriptPath = path.resolve(String(opts.script));\n const projectPath = path.resolve(String(opts.project));\n const sql = await fs.readFile(scriptPath, 'utf8');\n const parsed = parseScript(sql);\n\n // Up-front parse report — surfaces every error/warning verbatim.\n printParseReport(scriptPath, parsed);\n\n if (parsed.totalErrors > 0 && !opts.ignoreErrors) {\n console.error(\n `\\nRefusing to import: ${parsed.totalErrors} parse error(s) above. ` +\n `Fix the script and re-run, or pass --ignore-errors to import the clean statements.`,\n );\n process.exitCode = 2;\n return;\n }\n\n const loaded = await loadProject(projectPath);\n const result = await importScript(parsed, loaded, {\n dryRun: !!opts.dryRun,\n force: !!opts.force,\n });\n\n console.log('');\n const verb = opts.dryRun ? 'would write' : 'wrote';\n for (const item of result.imported) {\n const rel = path.relative(loaded.rootDir, item.targetPath);\n console.log(\n ` ${verb} ${item.statement.objectType} ${qualified(item.statement)} → ${rel}`,\n );\n }\n for (const item of result.skipped) {\n const head =\n item.statement.objectType && item.statement.fqn\n ? `${item.statement.objectType} ${qualified(item.statement)}`\n : `<unclassified statement at line ${item.statement.startLine}>`;\n console.log(` skip ${head} — ${item.reason}`);\n }\n console.log('');\n console.log(\n `Summary: ${result.imported.length} ${verb}, ${result.skipped.length} skipped, ` +\n `${parsed.totalErrors} errors, ${parsed.totalWarnings} warnings.`,\n );\n\n if (result.imported.length === 0 && result.skipped.length > 0) {\n process.exitCode = 1;\n }\n });\n return cmd;\n}\n\nfunction qualified(stmt: ParsedStatement): string {\n if (!stmt.fqn) return '<no fqn>';\n return [stmt.fqn.database, stmt.fqn.schema, stmt.fqn.name].filter(Boolean).join('.');\n}\n\nfunction printParseReport(scriptPath: string, parsed: ReturnType<typeof parseScript>): void {\n console.log(`Parsed ${parsed.statements.length} statement(s) from ${scriptPath}.`);\n if (parsed.totalErrors === 0 && parsed.totalWarnings === 0) {\n console.log('All statements classified cleanly.');\n return;\n }\n for (const stmt of parsed.statements) {\n if (stmt.errors.length === 0 && stmt.warnings.length === 0) continue;\n const head =\n stmt.objectType && stmt.fqn ? `${stmt.objectType} ${qualified(stmt)}` : '<unclassified>';\n console.log(`\\n[line ${stmt.startLine}–${stmt.endLine}] ${head}`);\n for (const e of stmt.errors) console.log(` ERROR: ${e}`);\n for (const w of stmt.warnings) console.log(` warning: ${w}`);\n }\n}\n"],"mappings":";;;AAAA,SAAS,YAAY,UAAU;AAC/B,OAAO,UAAU;AACjB,SAAS,eAAe;AACxB,SAAS,cAAc,aAAa,mBAAyC;AActE,SAAS,gBAAyB;AACvC,QAAM,MAAM,IAAI,QAAQ,QAAQ;AAChC,MACG;AAAA,IACC;AAAA,EACF,EACC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,IACjD;AACA,YAAQ,IAAI,EAAE;AACd,YAAQ;AAAA,MACN,YAAY,OAAO,SAAS,MAAM,IAAI,IAAI,KAAK,OAAO,QAAQ,MAAM,aAC/D,OAAO,WAAW,YAAY,OAAO,aAAa;AAAA,IACzD;AAEA,QAAI,OAAO,SAAS,WAAW,KAAK,OAAO,QAAQ,SAAS,GAAG;AAC7D,cAAQ,WAAW;AAAA,IACrB;AAAA,EACF,CAAC;AACH,SAAO;AACT;AAEA,SAAS,UAAU,MAA+B;AAChD,MAAI,CAAC,KAAK,IAAK,QAAO;AACtB,SAAO,CAAC,KAAK,IAAI,UAAU,KAAK,IAAI,QAAQ,KAAK,IAAI,IAAI,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AACrF;AAEA,SAAS,iBAAiB,YAAoB,QAA8C;AAC1F,UAAQ,IAAI,UAAU,OAAO,WAAW,MAAM,sBAAsB,UAAU,GAAG;AACjF,MAAI,OAAO,gBAAgB,KAAK,OAAO,kBAAkB,GAAG;AAC1D,YAAQ,IAAI,oCAAoC;AAChD;AAAA,EACF;AACA,aAAW,QAAQ,OAAO,YAAY;AACpC,QAAI,KAAK,OAAO,WAAW,KAAK,KAAK,SAAS,WAAW,EAAG;AAC5D,UAAM,OACJ,KAAK,cAAc,KAAK,MAAM,GAAG,KAAK,UAAU,IAAI,UAAU,IAAI,CAAC,KAAK;AAC1E,YAAQ,IAAI;AAAA,QAAW,KAAK,SAAS,SAAI,KAAK,OAAO,KAAK,IAAI,EAAE;AAChE,eAAW,KAAK,KAAK,OAAQ,SAAQ,IAAI,cAAc,CAAC,EAAE;AAC1D,eAAW,KAAK,KAAK,SAAU,SAAQ,IAAI,cAAc,CAAC,EAAE;AAAA,EAC9D;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/publish.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { promises as fs } from 'node:fs';\nimport path from 'node:path';\nimport {\n CompareEngine,\n DatabricksExecutor,\n PacSource,\n ProjectSource,\n ScriptGenerator,\n ai,\n aiPreflight,\n approval,\n buildDeployManifest,\n buildExecutionPlan,\n colorizeMigrationScript,\n compileSlice,\n createConnection,\n defaultSafePlan,\n executePlan,\n getProfile,\n lintSql,\n loadProject,\n mergeDeployOptions,\n pac as pacNs,\n pacFreshness,\n protectedObjects,\n queryExecution,\n recordDeployChangelog,\n renderHtmlReport,\n resolveProfile,\n safety,\n testFramework,\n validatePlan,\n type CompareSource,\n type StepResult,\n} from '@ddt-tools/core';\nimport { addMappingFlags, buildMappingFromOptions, describeMapping } from '../util/mapping.js';\nimport { attachRelatedOptions } from '../util/help-catalog.js';\n\n/**\n * `ddt publish` — produce a migration script that drives a target toward a\n * source's desired state. `--dry-run` (default) generates the script and\n * prints the safety assessment + default-safe plan summary.\n * `--apply` executes the plan against the named connection profile via\n * `DatabricksExecutor` + `executePlan`, with automatic rollback on\n * partial failure.\n */\nexport function publishCommand(): Command {\n const cmd = new Command('publish');\n cmd\n .description('Generate (and optionally apply) a migration script from source → target.')\n .option(\n '--source <path>',\n 'Source: .ddtproj or .ddtpac (the desired state). Required for a normal publish; omit only with --restore-from-snapshot.',\n )\n .option(\n '--target <path>',\n 'Target: .ddtproj or .ddtpac (the current state). Required for a normal publish; omit only with --restore-from-snapshot.',\n )\n .option(\n '--restore-from-snapshot <batchId>',\n 'Recovery mode: skip the compare step and emit DROP/CREATE … SHALLOW CLONE against the snapshot batch <batchId> from the registry. ' +\n 'Dry-run by default; pass --apply --yes to execute. ' +\n \"This is the command printed by TRUST.4's post-deploy-smoke + TRUST.8's restore-hint when a deploy fails — they tell the operator to run `ddt publish --restore-from-snapshot <id>`.\",\n )\n .option(\n '--snapshot-dir <path>',\n 'Snapshot registry directory used with --restore-from-snapshot.',\n '.ddt/snapshots',\n )\n .option(\n '--out <path>',\n 'Write the generated SQL to this path (currently honored on the --restore-from-snapshot recovery path).',\n )\n .option('--dry-run', 'Print the migration script and safety assessment without applying.', true)\n .option(\n '--apply',\n 'Apply the migration against --connection. Requires --connection. Default false.',\n false,\n )\n .option('--connection <name>', 'Connection profile to apply against. Required with --apply.')\n .option(\n '--yes',\n 'Skip interactive confirmation when applying. Required with --apply (no TTY today).',\n false,\n )\n .option('--variables <kv>', 'Comma-separated KEY=VALUE pairs for $(VAR) substitution.')\n .option('--ignore-case', 'Compare object FQNs case-insensitively.', false)\n .option(\n '--no-rollback',\n 'Skip rollback on partial failure (leaves DIRTY state). Default rollback ON.',\n )\n .option(\n '--require-reversible',\n 'Refuse before any DDL runs if any step lacks reverse SQL.',\n false,\n )\n .option(\n '--manifest <path>',\n 'Write a JSON deploy manifest (every step + status + duration + reverse SQL) to <path>. Audit-friendly.',\n )\n .option('--report-html <path>', 'Write a self-contained HTML compare-report to <path>.')\n .option(\n '--no-lint',\n 'Skip the lint gate. Default: lint the generated script and refuse --apply on ERROR-severity findings.',\n )\n .option(\n '--webhook <url>',\n 'POST a deploy-summary JSON to this URL after --apply completes. Or set $DDT_NOTIFY_WEBHOOK.',\n )\n .option(\n '--profile <name>',\n 'Use the deploymentProfiles[<name>] overlay from --source (.ddtproj). ' +\n 'Pulls profile.connection, profile.variables, profile.deployOptions on top of project defaults.',\n )\n .option(\n '--changelog [catalog]',\n 'After --apply, append a row to <catalog>.__ddt.deploy_log on the workspace. ' +\n \"Defaults catalog to the connection profile's default catalog. Liquibase-style audit table.\",\n )\n .option(\n '--no-slice',\n \"Disable the source's Project Slice (if it has one). Default: a sliced source partitions the diff automatically and target objects outside the slice are left untouched.\",\n )\n .option(\n '--query-tag <tag>',\n 'Tag attached to every executed statement so system.query.history can attribute the deploy. ' +\n 'Prepended as `-- DDT-TAG: <tag>` comment. ' +\n \"Defaults to 'ddt:<projectName>@<projectVersion>:<unix-ms>' when omitted.\",\n )\n .option(\n '--color <mode>',\n 'Color stdout: auto | always | never. Honors NO_COLOR / DDT_NO_COLOR env vars in auto mode.',\n 'auto',\n )\n .option(\n '--ai-preflight',\n \"Before --apply, ask AI to grade the operator's plain-language deploy description against the actual diff + safety findings. Blocks on 'mismatch' unless --confirm-after-preflight-mismatch is also passed.\",\n false,\n )\n .option(\n '--ai-preflight-text <narrative>',\n 'Non-interactive form of --ai-preflight. Supplies the narrative directly instead of reading from stdin.',\n )\n .option(\n '--strict-ai-preflight',\n \"Also block on 'partial' (not just 'mismatch'). Useful for production deploys.\",\n false,\n )\n .option(\n '--confirm-after-preflight-mismatch',\n 'Proceed even when --ai-preflight returns a mismatch verdict. Acknowledges that the AI grader flagged a discrepancy.',\n false,\n )\n .option(\n '--require-approvals <n>',\n 'Multi-approver gate: refuse --apply until <n> distinct approvers have signed off via `ddt approval add <deploy-id> --as <user>`. Team-tier.',\n )\n .option(\n '--approver <ids>',\n 'Comma-separated allow-list of approver IDs honoured by --require-approvals. Empty = any approver counts.',\n )\n .option(\n '--deploy-id <id>',\n 'Stable deploy identifier paired with --require-approvals (default: <connection>:<catalog>.<schema>).',\n )\n .option(\n '--approvals-root <path>',\n 'Approvals directory (default: .ddt/approvals).',\n path.join('.ddt', 'approvals'),\n )\n .option(\n '--allow-protected <fqns>',\n 'Comma-separated FQNs to exempt from the .ddt-protection.json gate. Repeatable.',\n (val: string, prev: string[]) => [...prev, val],\n [] as string[],\n )\n .option(\n '--allow-all-protected',\n 'Bypass all protection gates defined in .ddt-protection.json. Use with care.',\n false,\n )\n .option(\n '--freshness <mode>',\n 'Pac age check: warn (log if stale, continue), strict (block if stale), skip (no check). Default warn.',\n 'warn',\n )\n .option(\n '--post-deploy-tests <project>',\n 'After a successful --apply, discover YAML tests under <project>/tests/ and run them against the same connection. Exits 2 on any blocking (error-severity) DQ failure. Emits POST_DEPLOY_DQ_FAILED hint with --manifest recipe when tests fail.',\n );\n addMappingFlags(cmd);\n cmd.action(async (opts) => {\n // Recovery mode — branch out of the normal compare/apply flow and emit\n // DROP/CREATE … SHALLOW CLONE from a recorded snapshot batch.\n if (opts.restoreFromSnapshot) {\n await runRestoreFromSnapshot(opts);\n return;\n }\n if (!opts.source || !opts.target) {\n throw new Error(\n '--source <path> and --target <path> are required (unless --restore-from-snapshot is given).',\n );\n }\n const nameMapping = await buildMappingFromOptions(opts);\n const sourcePath = String(opts.source);\n const targetPath = String(opts.target);\n const engine = new CompareEngine();\n const src: CompareSource = sourcePath.endsWith('.ddtpac')\n ? new PacSource(sourcePath, 'source')\n : new ProjectSource(sourcePath, 'source');\n const tgt: CompareSource = targetPath.endsWith('.ddtpac')\n ? new PacSource(targetPath, 'target')\n : new ProjectSource(targetPath, 'target');\n\n // Freshness gate — only fires when source is a .ddtpac, before any network call.\n let loadedSrcPac: Awaited<ReturnType<typeof pacNs.readPac>> | undefined;\n if (sourcePath.endsWith('.ddtpac')) {\n loadedSrcPac = await pacNs.readPac(sourcePath);\n const freshnessMode = (opts.freshness as pacFreshness.FreshnessMode | undefined) ?? 'warn';\n if (freshnessMode !== 'skip') {\n const fr = pacFreshness.checkPacFreshness(loadedSrcPac.manifest.builtAt);\n if (fr.status !== 'fresh') {\n const msg = pacFreshness.formatFreshnessWarning(fr, sourcePath);\n if (freshnessMode === 'strict') {\n console.error(msg);\n process.exitCode = 1;\n return;\n } else {\n console.warn(msg);\n }\n }\n }\n }\n\n // Auto-load slice from the source. .ddtpac carries it in manifest;\n // .ddtproj has it as a top-level field. --no-slice bypasses.\n let slice: ReturnType<typeof compileSlice> | undefined;\n if (opts.slice !== false) {\n if (sourcePath.endsWith('.ddtpac')) {\n const srcPac = loadedSrcPac ?? (await pacNs.readPac(sourcePath));\n if (srcPac.manifest.slice) slice = compileSlice(srcPac.manifest.slice);\n } else {\n const loaded = await loadProject(sourcePath);\n if (loaded.project.slice) slice = compileSlice(loaded.project.slice);\n }\n }\n\n const result = await engine.compare(src, tgt, {\n ignoreCase: !!opts.ignoreCase,\n ...(nameMapping ? { nameMapping } : {}),\n ...(slice ? { sliceFilter: slice } : {}),\n });\n const mappingSummary = describeMapping(nameMapping);\n if (mappingSummary) console.log(`Mapping: ${mappingSummary}`);\n if (slice) {\n const outside = result.outsideScope?.length ?? 0;\n const refs = result.referenced?.length ?? 0;\n console.log(\n `Slice active: ${result.objects.length} owned · ${outside} outside scope (untouched) · ${refs} referenced`,\n );\n }\n\n if (opts.reportHtml) {\n const html = renderHtmlReport(result, {\n title: `Publish ${result.source.label} → ${result.target.label}`,\n safety: safety.assess(result),\n });\n const htmlPath = path.resolve(String(opts.reportHtml));\n await fs.mkdir(path.dirname(htmlPath), { recursive: true });\n await fs.writeFile(htmlPath, html, 'utf8');\n console.log(`Wrote HTML report → ${htmlPath}`);\n }\n\n // --profile overlay (project-level deployOptions + variables + connection).\n // VARSYNTAX.2 — also reads from `.ddtpac` manifest's deploymentProfiles\n // snapshot when --source is a built pac (writable since the pac builder\n // snapshots loaded.project.deploymentProfiles into the manifest).\n let profileDeployment: ReturnType<typeof mergeDeployOptions>['deployment'] | undefined;\n let profileVariables: Record<string, string> = {};\n let profileConnection: string | undefined;\n if (opts.profile) {\n const profileName = String(opts.profile);\n if (sourcePath.endsWith('.ddtpac')) {\n const srcPac = loadedSrcPac ?? (await pacNs.readPac(sourcePath));\n const block = srcPac.manifest.deploymentProfiles?.[profileName];\n if (!block) {\n const available = Object.keys(srcPac.manifest.deploymentProfiles ?? {});\n throw new Error(\n `--profile ${profileName}: no deploymentProfile by that name in the pac manifest. ` +\n (available.length === 0\n ? 'The pac carries no deploymentProfiles (was it built before VARSYNTAX.2, or does the .ddtproj declare any?).'\n : `Available: ${available.join(', ')}.`),\n );\n }\n if (block.variables) profileVariables = { ...block.variables };\n if (block.connection) profileConnection = block.connection;\n // pac-snapshot path does NOT overlay profile-level deployOptions —\n // those are already merged into manifest.deployOptions at build\n // time. Leave profileDeployment undefined; the caller falls back\n // to `mergeDeployOptions().deployment`.\n console.log(\n `Profile: ${profileName}${profileConnection ? ` (connection=${profileConnection})` : ''}`,\n );\n } else {\n const loaded = await loadProject(sourcePath);\n const resolved = resolveProfile(loaded, profileName);\n profileDeployment = resolved.deployment;\n profileVariables = resolved.variables;\n profileConnection = resolved.connection;\n console.log(`Profile: ${resolved.name} (connection=${resolved.connection})`);\n }\n }\n\n const assessment = safety.assess(result);\n const deployment = profileDeployment ?? mergeDeployOptions().deployment;\n const variables = { ...profileVariables, ...(parseVariables(opts.variables) ?? {}) };\n\n // VARSYNTAX.3 — assemble the deploy context so `$(DDT_PROFILE)`,\n // `$(DDT_PROJECT_NAME)`, `$(DDT_PROJECT_VERSION)`, `$(DDT_PLATFORM)`,\n // `$(DDT_TIMESTAMP)`, `$(DDT_USER)` substitute without the operator\n // having to pass them via --variables. projectName / projectVersion\n // come from whichever source was loaded (.ddtpac manifest or\n // .ddtproj); profile defaults to undefined unless --profile was used.\n let ctxProjectName: string | undefined;\n let ctxProjectVersion: string | undefined;\n if (sourcePath.endsWith('.ddtpac')) {\n const srcPac = loadedSrcPac ?? (await pacNs.readPac(sourcePath));\n ctxProjectName = srcPac.manifest.projectName;\n ctxProjectVersion = srcPac.manifest.projectVersion;\n } else {\n try {\n const loaded = await loadProject(sourcePath);\n ctxProjectName = loaded.project.name;\n ctxProjectVersion = loaded.project.version;\n } catch {\n // best-effort; built-in vars stay defaulted\n }\n }\n const generateContext: {\n profile?: string;\n projectName?: string;\n projectVersion?: string;\n user?: string;\n } = {\n ...(opts.profile ? { profile: String(opts.profile) } : {}),\n ...(ctxProjectName ? { projectName: ctxProjectName } : {}),\n ...(ctxProjectVersion ? { projectVersion: ctxProjectVersion } : {}),\n };\n\n const generator = new ScriptGenerator();\n const script = generator.generate(result, {\n variables,\n deployment,\n context: generateContext,\n });\n\n const plan = defaultSafePlan(result);\n const validated = validatePlan(result, plan);\n const steps = buildExecutionPlan(result, validated, { deployment });\n\n // Protection gate — block operations on objects declared in .ddt-protection.json.\n const protConfig = await protectedObjects.loadProtectionConfig(path.dirname(sourcePath));\n if (protConfig) {\n const ops = result.objects\n .filter((o) => o.kind !== 'unchanged' && o.kind !== 'added')\n .map((o) => ({\n fqn: o.identity.fqn,\n objectType: String(o.identity.objectType),\n kind: o.kind,\n }));\n const allowedFqns = ((opts.allowProtected as string[]) ?? []).flatMap((s: string) =>\n s.split(',').map((f: string) => f.trim()),\n );\n const violations = protectedObjects.checkProtectedObjects(ops, protConfig, {\n allowedFqns,\n allowAll: Boolean(opts.allowAllProtected),\n });\n if (violations.length > 0) {\n console.error(protectedObjects.formatProtectionViolations(violations));\n process.exitCode = 1;\n return;\n }\n }\n\n printPlanReport(result.summary, script.summary, assessment, steps);\n\n // ── apply path ──────────────────────────────────────────────────────\n if (opts.apply) {\n const connectionName = opts.connection ?? profileConnection;\n if (!connectionName) {\n throw new Error(\n '--apply requires --connection <profile-name> or --profile <env> (supplies connection).',\n );\n }\n if (!opts.yes) {\n throw new Error(\n '--apply requires --yes. The CLI does not currently prompt interactively. Pass --yes to confirm.',\n );\n }\n if (assessment.blocked) {\n console.error(\n `Refusing to apply: safety classifier blocked the deploy (${assessment.blockReason}).`,\n );\n process.exitCode = 2;\n return;\n }\n\n // Approval gate (Team-tier): refuse to apply until N distinct\n // approvers have recorded approval tokens for this deploy id.\n if (opts.requireApprovals !== undefined && opts.requireApprovals !== false) {\n const required = Number(opts.requireApprovals) || 0;\n const allowed = opts.approver\n ? String(opts.approver)\n .split(',')\n .map((s: string) => s.trim())\n .filter(Boolean)\n : [];\n const deployId = String(opts.deployId ?? `${connectionName}:default`);\n const approvalsRoot = String(opts.approvalsRoot);\n const file = await approval.readApprovalFile(approvalsRoot, deployId);\n const outcome = approval.evaluateApprovalGate(\n { deployId, required, allowedApprovers: allowed },\n file.approvals,\n );\n if (!outcome.satisfied) {\n console.error(\n 'Approval gate blocked deploy: ' +\n (outcome.blockReason ?? 'gate not satisfied') +\n `. Record approvals with \\`ddt approval add ${deployId} --as <user>\\`.`,\n );\n process.exitCode = 2;\n return;\n }\n console.error(\n ` approvals: ${outcome.satisfiedBy.length}/${required} ` +\n `(${outcome.satisfiedBy.join(', ')})`,\n );\n }\n\n // AI preflight grader: ask the operator to type what they expect\n // this deploy to do, then let an AI compare that narrative to the\n // actual SQL + safety findings. Blocks deploy on `mismatch`.\n if (opts.aiPreflight) {\n const narrative = await readPreflightNarrative(opts.aiPreflightText);\n if (!narrative) {\n console.error(\n '--ai-preflight needs a narrative. Provide it inline via --ai-preflight-text or via stdin.',\n );\n process.exitCode = 2;\n return;\n }\n console.log('Grading deploy narrative with AI...');\n try {\n const findings = [\n ...assessment.unrecoverable.map((f) => ({\n code: String(f.code),\n fqn: f.fqn,\n reason: f.reason,\n })),\n ...assessment.destructive.map((f) => ({\n code: String(f.code),\n fqn: f.fqn,\n reason: f.reason,\n })),\n ...assessment.expensive.map((f) => ({\n code: String(f.code),\n fqn: f.fqn,\n reason: f.reason,\n })),\n ];\n const compareSummary = `added ${result.summary.added}, modified ${result.summary.modified}, removed ${result.summary.removed}, unchanged ${result.summary.unchanged}`;\n const verdict = await aiPreflight.gradePreflight(\n {\n narrative,\n compareSummary,\n safetyFindings: findings,\n diffSampleDdl: script.sql,\n target: `${result.target.label}@${connectionName ?? 'unknown'}`,\n },\n {\n completeFn: async (prompt) => {\n const r = await ai.complete([{ role: 'user', content: prompt }], {\n feature: 'ai-preflight',\n });\n return r.text;\n },\n },\n );\n console.log(` preflight verdict: ${verdict.verdict}`);\n if (verdict.reasoning) console.log(` preflight reasoning: ${verdict.reasoning}`);\n for (const d of verdict.discrepancies) console.log(` • ${d}`);\n\n const isBlocking =\n verdict.verdict === 'mismatch' ||\n (opts.strictAiPreflight && verdict.verdict === 'partial');\n if (isBlocking && !opts.confirmAfterPreflightMismatch) {\n console.error(\n `Refusing to apply: AI preflight returned \"${verdict.verdict}\". Re-run with --confirm-after-preflight-mismatch to override, or revise the narrative.`,\n );\n process.exitCode = 2;\n return;\n }\n if (verdict.parseFailed) {\n console.warn(\n ' preflight verdict could not be parsed — continuing without a clean alignment signal.',\n );\n }\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n console.error(\n `--ai-preflight failed: ${msg}. Configure an AI provider via \\`ddt ai status\\` or omit --ai-preflight.`,\n );\n process.exitCode = 2;\n return;\n }\n }\n\n // Lint gate — refuse --apply when the generated script trips an\n // ERROR-severity lint rule (L003 ADD NOT NULL no DEFAULT, L007\n // REFUSED placeholder). Opt out with --no-lint when you've\n // reviewed the script and want to proceed.\n if (opts.lint !== false) {\n const lint = lintSql(script.sql);\n if (lint.errorCount > 0) {\n console.error('');\n console.error(\n `Refusing to apply: lint gate caught ${lint.errorCount} ERROR-severity finding(s).`,\n );\n for (const f of lint.findings) {\n if (f.severity !== 'ERROR') continue;\n console.error(` ${f.rule} line ${f.line}: ${f.message}`);\n if (f.suggestion) console.error(` → ${f.suggestion}`);\n }\n console.error('');\n console.error('Resolve the findings or re-run with --no-lint to override.');\n process.exitCode = 2;\n return;\n }\n if (lint.warningCount > 0) {\n console.log(`Lint: ${lint.warningCount} warning(s) — proceeding.`);\n }\n }\n\n const profile = await getProfile(String(connectionName));\n const conn = createConnection(profile);\n const queryTag = resolveQueryTag(\n opts.queryTag,\n sourcePath,\n result.source.label,\n ctxProjectName,\n ctxProjectVersion,\n );\n if (queryTag) console.log(`Query tag: ${queryTag}`);\n try {\n await conn.connect();\n const executor = new DatabricksExecutor(conn, {\n ...(queryTag ? { queryTag } : {}),\n onStatement: (sql) => {\n const head = sql.split('\\n')[0]?.slice(0, 100) ?? '';\n console.log(` → ${head}${sql.length > 100 ? ' …' : ''}`);\n },\n });\n console.log('');\n console.log('--- APPLYING ---');\n const report = await executePlan(steps, executor, {\n rollbackOnFailure: opts.rollback !== false,\n requireReversible: !!opts.requireReversible,\n onStepStart: (step) => {\n console.log(`▶ ${step.objectType} ${step.fqn} — ${step.description}`);\n },\n onStepEnd: (r: StepResult) => {\n const tag =\n r.status === 'SUCCESS'\n ? '✓'\n : r.status === 'ROLLED_BACK'\n ? '↩'\n : r.status === 'FAILED'\n ? '✗'\n : r.status === 'SKIPPED'\n ? '-'\n : '?';\n console.log(\n ` ${tag} ${r.status}${r.durationMs ? ` (${r.durationMs}ms)` : ''}${r.error ? `: ${r.error}` : ''}`,\n );\n },\n });\n console.log('');\n console.log('--- DEPLOYMENT REPORT ---');\n console.log(`finalState: ${report.finalState}`);\n if (report.failedStepId) console.log(`failedStepId: ${report.failedStepId}`);\n if (report.preflightErrors?.length) {\n console.log('preflightErrors:');\n for (const e of report.preflightErrors) console.log(` ${e}`);\n }\n const manifestJson = JSON.stringify(\n buildDeployManifest(report, profile.auth.host),\n null,\n 2,\n );\n if (opts.manifest) {\n const mPath = path.resolve(String(opts.manifest));\n await fs.mkdir(path.dirname(mPath), { recursive: true });\n await fs.writeFile(mPath, manifestJson + '\\n', 'utf8');\n console.log(`Wrote deploy manifest → ${mPath}`);\n }\n\n // Target-side changelog table — best-effort. Failures are reported\n // (the deploy already succeeded) but never thrown.\n if (opts.changelog) {\n const catalog = opts.changelog === true ? undefined : String(opts.changelog);\n const r = await recordDeployChangelog(\n conn,\n report,\n result.source,\n result.target,\n manifestJson,\n '0.3.0',\n catalog ? { catalog } : {},\n );\n if (r.ok) {\n console.log(`Changelog: deploy_id=${r.entry.deployId} appended.`);\n } else {\n console.error(`Changelog write failed (deploy still completed): ${r.error}`);\n }\n }\n\n // Webhook notification — fire-and-forget POST with a small JSON\n // summary. Slack / Teams / generic JSON receivers all work.\n const webhookUrl = opts.webhook ?? process.env['DDT_NOTIFY_WEBHOOK'];\n if (webhookUrl) {\n try {\n await postWebhook(String(webhookUrl), {\n workspaceHost: profile.auth.host,\n source: result.source.label,\n target: result.target.label,\n finalState: report.finalState,\n failedStepId: report.failedStepId,\n stepsTotal: report.steps.length,\n stepsSucceeded: report.steps.filter((s) => s.status === 'SUCCESS').length,\n stepsFailed: report.steps.filter((s) => s.status === 'FAILED').length,\n });\n console.log(`Webhook notified → ${webhookUrl}`);\n } catch (err) {\n console.error(\n `Webhook POST failed (deploy still completed): ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n\n if (report.finalState === 'DIRTY') {\n console.error(\n 'DIRTY: rollback could not complete. Manual intervention required — see report above.',\n );\n process.exitCode = 1;\n } else if (report.finalState !== 'CLEAN_SUCCESS') {\n process.exitCode = 1;\n }\n\n if (opts.postDeployTests && report.finalState === 'CLEAN_SUCCESS') {\n const projectRoot = path.resolve(String(opts.postDeployTests));\n console.log('Running post-deploy DQ tests from ' + projectRoot + '...');\n const testFiles = await testFramework.discoverTests(projectRoot);\n if (testFiles.length === 0) {\n console.warn(\n ' POST_DEPLOY_DQ: no tests found under ' + projectRoot + '/tests/ — skipping.',\n );\n } else {\n const dqReport = await testFramework.runTestFiles(testFiles, conn);\n process.stdout.write(testFramework.renderTextReport(dqReport));\n if (dqReport.summary.blocking) {\n console.error(\n 'POST_DEPLOY_DQ_FAILED: ' +\n dqReport.summary.fail +\n ' fail / ' +\n dqReport.summary.error +\n ' error.' +\n (opts.manifest\n ? ' Recover: `ddt revert --manifest ' + String(opts.manifest) + '`'\n : ' Inspect tests/ and re-run after fixing data issues.'),\n );\n process.exitCode = 2;\n } else {\n console.log(\n ' POST_DEPLOY_DQ: ' +\n dqReport.summary.pass +\n '/' +\n dqReport.summary.total +\n ' pass.',\n );\n }\n }\n }\n } finally {\n await conn.disconnect();\n }\n return;\n }\n\n // ── dry-run path (default) ──────────────────────────────────────────\n // Colorize the script for terminal output so destructive lines and safety\n // banners are unmissable; ANSI is stripped in auto mode when stdout is\n // not a TTY (e.g. piped to a file or CI log).\n const colorMode = (opts.color as 'auto' | 'always' | 'never' | undefined) ?? 'auto';\n console.log('');\n console.log('--- MIGRATION SCRIPT ---');\n console.log(colorizeMigrationScript(script.sql, { mode: colorMode }));\n });\n attachRelatedOptions(cmd, [\n 'deployment.allowDropTable',\n 'deployment.allowDropColumn',\n 'deployment.allowUnrecoverableDrop',\n 'deployment.allowNarrowingTypes',\n 'deployment.allowTableRebuild',\n 'deployment.blockOnPossibleDataLoss',\n 'deployment.preserveTargetOnlyObjects',\n ]);\n return cmd;\n}\n\nfunction printPlanReport(\n diffSummary: { added: number; removed: number; modified: number; unchanged: number },\n scriptSummary: { destructive: number; refused: number },\n assessment: ReturnType<typeof safety.assess>,\n steps: ReturnType<typeof buildExecutionPlan>,\n): void {\n console.log('--- COMPARE SUMMARY ---');\n console.log(\n `+${diffSummary.added} -${diffSummary.removed} ~${diffSummary.modified} =${diffSummary.unchanged}` +\n (scriptSummary.destructive ? ` (destructive=${scriptSummary.destructive})` : '') +\n (scriptSummary.refused ? ` (refused=${scriptSummary.refused})` : ''),\n );\n console.log('');\n console.log('--- SAFETY ASSESSMENT ---');\n console.log(`unrecoverable=${assessment.unrecoverable.length}`);\n console.log(`destructive=${assessment.destructive.length}`);\n console.log(`expensive=${assessment.expensive.length}`);\n console.log(`warnings=${assessment.warnings.length}`);\n if (assessment.blocked) console.log(`BLOCKED: ${assessment.blockReason}`);\n console.log('');\n console.log('--- DEFAULT-SAFE PLAN ---');\n const reversible = steps.filter((st) => st.reverseSql).length;\n console.log(`${steps.length} step(s) planned (default-safe selection)`);\n console.log(`${reversible} step(s) reversible · ${steps.length - reversible} irreversible`);\n}\n\nasync function postWebhook(url: string, payload: unknown): Promise<void> {\n const isSlackOrTeams = /hooks\\.slack\\.com|webhook\\.office\\.com/.test(url);\n let body: string;\n if (isSlackOrTeams) {\n // Both Slack and Teams accept a simple { text: \"...\" } shape.\n const summary = payload as {\n finalState: string;\n target: string;\n stepsTotal: number;\n stepsSucceeded: number;\n stepsFailed: number;\n };\n body = JSON.stringify({\n text: `DDT publish → ${summary.target} · ${summary.finalState} · ${summary.stepsSucceeded}/${summary.stepsTotal} steps ok${summary.stepsFailed ? ` · ${summary.stepsFailed} failed` : ''}`,\n });\n } else {\n body = JSON.stringify(payload);\n }\n const res = await fetch(url, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body,\n });\n if (!res.ok) {\n throw new Error(`HTTP ${res.status} ${res.statusText}`);\n }\n}\n\n// PD7.2 — parse `--variables KEY=VALUE,KEY=VALUE,...` using indexOf split\n// so a `=` inside the value (base64, JWT, connection-string fragments) is\n// preserved instead of being treated as a second delimiter. Mirrors the SDT\n// parsePublishVariables contract.\nexport function parseVariables(raw: unknown): Record<string, string> | undefined {\n if (!raw) return undefined;\n const out: Record<string, string> = {};\n for (const pair of String(raw).split(',')) {\n const eq = pair.indexOf('=');\n if (eq <= 0) continue;\n const k = pair.slice(0, eq).trim();\n const v = pair.slice(eq + 1).trim();\n if (k.length > 0) out[k] = v;\n }\n return Object.keys(out).length > 0 ? out : undefined;\n}\n\n/**\n * Resolve the effective query tag. Honors an explicit `--query-tag`\n * flag value verbatim; otherwise auto-generates\n * `ddt:<projectName>@<projectVersion>:<unix-ms>` using the supplied\n * project context (pac manifest or .ddtproj). When projectName is\n * unknown, falls back to the source-path basename / sourceLabel; when\n * projectVersion is unknown the `@<projectVersion>` segment is omitted\n * so the tag remains valid. Returns undefined only when the user\n * explicitly passed `--query-tag ''`.\n */\nexport function resolveQueryTag(\n raw: unknown,\n sourcePath: string,\n sourceLabel: string,\n projectName: string | undefined,\n projectVersion: string | undefined,\n): string | undefined {\n if (raw !== undefined) {\n const s = String(raw).trim();\n return s.length === 0 ? undefined : s;\n }\n const fallback = sourcePath.endsWith('.ddtpac')\n ? path.basename(sourcePath, '.ddtpac')\n : sourceLabel;\n const base = projectName ?? fallback;\n const version = projectVersion ? `@${projectVersion}` : '';\n return `ddt:${base}${version}:${Date.now()}`;\n}\n\n/**\n * `ddt publish --restore-from-snapshot <batchId>` recovery path.\n *\n * Loads the batch from the registry, emits the restore SQL (DROP target +\n * CREATE … SHALLOW CLONE from snapshot, or a MANUAL hint row for\n * materialised / streaming objects), and either prints it (dry-run / no\n * --apply) or executes it against the live target (--apply --yes).\n *\n * Skips: pac freshness, compare, safety classifier, AI preflight, approval\n * gate, lint gate, manifest writing. Recovery is an emergency lever — the\n * gates that protect the forward path don't apply when we're restoring a\n * known-good snapshot the safety classifier itself authored.\n */\nasync function runRestoreFromSnapshot(opts: Record<string, unknown>): Promise<void> {\n const batchId = String(opts.restoreFromSnapshot);\n const registryDir = path.resolve(String(opts.snapshotDir ?? '.ddt/snapshots'));\n\n let batch: safety.SnapshotBatch;\n try {\n batch = await safety.readSnapshotBatch(registryDir, batchId);\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n console.error(`Snapshot batch \"${batchId}\" not found in ${registryDir}: ${msg}`);\n process.exitCode = 1;\n return;\n }\n\n const sqlLines = safety.emitRestoreFromSnapshotSql(batch);\n const sql = sqlLines.join('\\n');\n\n console.log(`Restoring from batch ${batch.batchId} (createdAt=${batch.createdAt})`);\n console.log(\n ` ${batch.entries.length} object(s) recorded; ${sqlLines.filter((l) => !l.startsWith('--')).length} statement(s) will run.`,\n );\n\n if (opts.out) {\n const out = path.resolve(String(opts.out));\n await fs.mkdir(path.dirname(out), { recursive: true });\n await fs.writeFile(out, sql + '\\n', 'utf8');\n console.log(`Wrote restore SQL → ${out}`);\n }\n\n // The DDT publish defaults --dry-run to true; recovery follows the same\n // convention: only --apply executes anything.\n if (!opts.apply) {\n const colorMode = (opts.color as 'auto' | 'always' | 'never' | undefined) ?? 'auto';\n process.stdout.write(colorizeMigrationScript(sql, { mode: colorMode }) + '\\n');\n return;\n }\n\n if (!opts.yes) {\n console.error(\n '--apply requires --yes (restore replaces target tables via DROP + SHALLOW CLONE).',\n );\n process.exitCode = 1;\n return;\n }\n if (!opts.connection) {\n console.error('--apply --restore-from-snapshot requires --connection <profile>.');\n process.exitCode = 1;\n return;\n }\n\n const profile = await getProfile(String(opts.connection));\n const conn = createConnection(profile);\n let executed = 0;\n let failed = 0;\n try {\n await conn.connect();\n for (const stmt of queryExecution.splitStatements(sql).map((s) => s.sql)) {\n try {\n await conn.executeRows(stmt);\n executed += 1;\n const head = stmt.split('\\n')[0]?.slice(0, 100) ?? '';\n console.log(' → ' + head + (stmt.length > 100 ? ' …' : ''));\n } catch (err) {\n failed += 1;\n const msg = err instanceof Error ? err.message : String(err);\n console.error(` [restore ${batch.batchId}] ${msg}\\n ${stmt}`);\n }\n }\n } finally {\n await conn.disconnect();\n }\n\n if (failed === 0) {\n console.log(`Restore complete. ${executed} statement(s) executed.`);\n } else {\n console.error(\n `Restore finished with failures: ${executed} ok, ${failed} failed. ` +\n `Inspect the snapshot tables under ${registryDir} and recover by hand.`,\n );\n process.exitCode = 1;\n }\n}\n\n/**\n * Read the AI-preflight narrative from --ai-preflight-text (preferred for CI)\n * or from stdin (interactive). Returns trimmed text, or undefined when no\n * narrative was supplied.\n */\nasync function readPreflightNarrative(inlineText: unknown): Promise<string | undefined> {\n if (typeof inlineText === 'string' && inlineText.trim().length > 0) {\n return inlineText.trim();\n }\n if (process.stdin.isTTY) {\n process.stdout.write(\n '\\n--ai-preflight is active. In one paragraph, describe what you expect this deploy to do.\\nEnd with an empty line (or Ctrl-D):\\n> ',\n );\n }\n process.stdin.setEncoding('utf8');\n let buffer = '';\n await new Promise<void>((resolve) => {\n const onData = (chunk: string): void => {\n buffer += chunk;\n if (/\\n\\s*\\n/.test(buffer)) {\n process.stdin.removeListener('data', onData);\n process.stdin.removeListener('end', onEnd);\n resolve();\n }\n };\n const onEnd = (): void => {\n process.stdin.removeListener('data', onData);\n resolve();\n };\n process.stdin.on('data', onData);\n process.stdin.on('end', onEnd);\n });\n const trimmed = buffer.trim();\n return trimmed.length > 0 ? trimmed : undefined;\n}\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,eAAe;AACxB,SAAS,YAAY,UAAU;AAC/B,OAAO,UAAU;AACjB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAYA,SAAS,iBAA0B;AACxC,QAAM,MAAM,IAAI,QAAQ,SAAS;AACjC,MACG,YAAY,+EAA0E,EACtF;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA;AAAA,EAGF,EACC;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,OAAO,aAAa,sEAAsE,IAAI,EAC9F;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,EACF,EACC,OAAO,uBAAuB,6DAA6D,EAC3F;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,EACF,EACC,OAAO,oBAAoB,0DAA0D,EACrF,OAAO,iBAAiB,2CAA2C,KAAK,EACxE;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,OAAO,wBAAwB,uDAAuD,EACtF;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA;AAAA,EAEF,EACC;AAAA,IACC;AAAA,IACA;AAAA,EAEF,EACC;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA;AAAA,EAGF,EACC;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA;AAAA,IACA,KAAK,KAAK,QA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