Skip to content

feat(migration): close plan-only data safety (#686) - #753

Merged
kunaldhongade merged 1 commit into
mainfrom
feature/686-migration-safety-close
Aug 6, 2026
Merged

feat(migration): close plan-only data safety (#686)#753
kunaldhongade merged 1 commit into
mainfrom
feature/686-migration-safety-close

Conversation

@kunaldhongade

Copy link
Copy Markdown
Member

Summary

Test plan

  • vitest migration-safety + CLI migration + MCP migration_safety
  • tsc -p tsconfig.base.json --noEmit
  • CI green on this PR

Closes #686

Made with Cursor

…686

Add rename classification, connection-target blocking, rollback-failed verdicts, cleanup obligations, MCP migration_safety, and UAT-DATA-1..6 without contacting databases.
@github-actions github-actions Bot added documentation Improvements or additions to documentation type: test Test coverage, fixtures, or verification improvements area: cli CLI package or command behavior area: docs README, community files, or documentation area: mcp Model Context Protocol integration labels Aug 6, 2026
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

CodeDecay PR Check

Lead catch: Database area changed — packages/cli/src/commands/migration.ts:15

packages/cli/src/commands/migration.ts touches a database area and should be reviewed for regression impact.

Risk: High · Merge 100/100 · Decay 54/100 · Security 0/100

Full CodeDecay report

CodeDecay Report

Overall risk: High

Score Value
Merge risk 100/100
Decay risk 54/100
Security risk 0/100
Findings Count
High 13
Medium 10
Low 12

Changed Files

  • docs/migration.md added (+34/-0)
  • packages/cli/src/commands/migration.ts modified (+11/-1)
  • packages/cli/src/docs/command-docs/analysis.ts modified (+13/-2)
  • packages/cli/src/parsers/migration.ts modified (+12/-1)
  • packages/cli/src/types/migration.ts modified (+5/-0)
  • packages/knowledge/src/index.ts modified (+6/-1)
  • packages/knowledge/src/migration/analyze.ts modified (+235/-24)
  • packages/knowledge/src/migration/render.ts modified (+16/-4)
  • packages/knowledge/src/migration/target-safety.ts added (+89/-0)
  • packages/knowledge/src/migration/types.ts modified (+26/-1)
  • packages/knowledge/test/migration-safety.test.ts modified (+161/-15)
  • packages/mcp/src/handlers/migration-safety.ts added (+41/-0)
  • packages/mcp/src/index.ts modified (+3/-0)
  • packages/mcp/src/tools/register-analysis.ts modified (+11/-2)
  • packages/mcp/src/tools/registry.ts modified (+3/-1)
  • packages/mcp/src/tools/schemas.ts modified (+16/-0)
  • packages/mcp/src/tools/types.ts modified (+13/-0)
  • packages/mcp/test/mcp-migration-safety.test.ts added (+44/-0)

Likely Impacted Areas

  • High Database and schema (database): packages/cli/src/commands/migration.ts, packages/cli/src/parsers/migration.ts, packages/cli/src/types/migration.ts, packages/knowledge/src/migration/analyze.ts, packages/knowledge/src/migration/render.ts, packages/knowledge/src/migration/target-safety.ts, packages/knowledge/src/migration/types.ts, packages/mcp/src/handlers/migration-safety.ts
  • Low Documentation (docs): docs/migration.md, packages/cli/src/docs/command-docs/analysis.ts
  • Low Source code (source): packages/knowledge/src/index.ts, packages/mcp/src/index.ts, packages/mcp/src/tools/register-analysis.ts, packages/mcp/src/tools/registry.ts, packages/mcp/src/tools/schemas.ts, packages/mcp/src/tools/types.ts
  • Low Tests (test): packages/knowledge/test/migration-safety.test.ts, packages/mcp/test/mcp-migration-safety.test.ts

Normalized Impact Graph

Graph artifact: .codedecay/local/impact-graph.json (4615 node(s), 9386 edge(s))

  • Confidence: Direct: 9386, inferred: 0, heuristic: 0
  • codedecay-js-babel-symbols via @babel/parser (available, adapter 1.0.0)
    • Limitation: Call expressions are not connected to target symbols in this adapter version.
    • Limitation: Only JavaScript and TypeScript files parsed by @babel/parser are represented.
    • Limitation: Static import resolution does not resolve runtime dependency injection or dynamic imports.
  • codedecay-python-lezer via @lezer/python (available, adapter 1.0.0)
    • Limitation: Dynamic imports, dependency injection, decorators without literal routes, and framework route registries are not resolved.
    • Limitation: Python impact evidence uses the @lezer/python grammar and conservative module-to-file resolution.
    • Limitation: Static test imports do not prove execution or assertion quality.
  • Graph limitation: A static test import does not prove the symbol executed or that assertions cover its behavior.

Symbol Impact Evidence

Graph artifact: .codedecay/local/symbol-impact-graph.json (961 file(s), 5812 edge(s))

  • packages/cli/src/commands/migration.ts#runMigrationCommand -> packages/cli/src/commands/registry.ts
  • packages/cli/src/docs/command-docs/analysis.ts#ANALYSIS_COMMAND_DOCS -> packages/cli/src/docs/commands.ts
  • packages/cli/src/parsers/migration.ts#parseMigrationArgs -> packages/cli/src/commands/migration.ts, packages/cli/src/parsers/args.ts
  • packages/cli/src/types/migration.ts#MigrationOptions -> packages/cli/src/commands/migration.ts, packages/cli/src/parsers/migration.ts, packages/cli/src/types.ts, packages/cli/src/types/index.ts
  • packages/knowledge/src/index.ts#classifyMigrationConnectionTarget -> packages/knowledge/test/migration-safety.test.ts
    • Likely tests: packages/knowledge/test/migration-safety.test.ts
  • packages/knowledge/src/index.ts#MigrationTargetKind -> packages/cli/src/types/migration.ts, packages/tool-adapters/src/migration/types.ts
  • packages/knowledge/src/migration/analyze.ts#analyzeMigrationSafety -> packages/cli/src/commands/migration.ts, packages/knowledge/src/index.ts, packages/knowledge/test/migration-safety.test.ts, packages/mcp/src/handlers/migration-safety.ts
    • Likely tests: packages/knowledge/test/migration-safety.test.ts
  • packages/knowledge/src/migration/analyze.ts#AnalyzeMigrationSafetyOptions -> packages/knowledge/src/index.ts
  • packages/knowledge/src/migration/render.ts#renderMigrationSafetyMarkdown -> packages/cli/src/commands/migration.ts, packages/knowledge/src/index.ts, packages/mcp/src/handlers/migration-safety.ts
  • packages/knowledge/src/migration/target-safety.ts#classifyMigrationConnectionTarget -> packages/knowledge/src/index.ts, packages/knowledge/src/migration/analyze.ts, packages/knowledge/test/migration-safety.test.ts
    • Likely tests: packages/knowledge/test/migration-safety.test.ts
  • packages/knowledge/src/migration/types.ts#MigrationCleanupEvidence -> packages/knowledge/src/index.ts, packages/knowledge/src/migration/analyze.ts
  • packages/knowledge/src/migration/types.ts#MigrationConnectionTarget -> packages/knowledge/src/index.ts, packages/knowledge/src/migration/target-safety.ts
  • ...and 13 more symbol impact(s)

Language And Parser Coverage

  • Source files classified: 17
  • Fully supported parser files: 17
  • Limited files: 0
  • Unsupported files: 0

Merge Risk Breakdown

  • Score: 100/100
  • Raw score before dampeners: 100/100
  • Adjusted score before severity cap: 100/100
  • Highest contributing severity: High

Top contributors:

  • +30 Database area changed (direct): packages/cli/src/commands/migration.ts touches a database area and should be reviewed for regression impact.
  • +30 Database area changed (direct): packages/cli/src/parsers/migration.ts touches a database area and should be reviewed for regression impact.
  • +30 Database area changed (direct): packages/cli/src/types/migration.ts touches a database area and should be reviewed for regression impact.
  • +30 Database area changed (direct): packages/knowledge/src/migration/analyze.ts touches a database area and should be reviewed for regression impact.
  • +30 Database area changed (direct): packages/knowledge/src/migration/render.ts touches a database area and should be reviewed for regression impact.

Notes:

  • Untrusted memory context is visible but contributes 0 score until trusted evidence corroborates it.

Decay Risk Breakdown

  • Score: 54/100
  • Raw score before dampeners: 100/100
  • Adjusted score before severity cap: 84/100
  • Highest contributing severity: High
  • Evidence mode: heuristic-only

Top contributors:

  • +18 Duplicated added logic (heuristic): A similar block of added logic appears 4 times across 4 file(s).
  • +18 Duplicated added logic (heuristic): A similar block of added logic appears 3 times across 3 file(s).
  • +10 Broad unrelated change set (heuristic): This PR changes 16 files across 1 top-level areas and 3 risk categories.
  • +10 Duplicated added logic (heuristic): A similar block of added logic appears 2 times across 2 file(s).
  • +10 Duplicated added logic (heuristic): A similar block of added logic appears 2 times across 2 file(s).

Dampeners:

  • -16 Heuristic-only dampener: Decay stays conservative until direct evidence exists.

Notes:

  • Heuristic-only decay is capped at 54/100 until direct evidence exists.

Security Risk Breakdown

  • Score: 0/100
  • Raw score before dampeners: 0/100
  • Adjusted score before severity cap: 0/100

Security Matcher Coverage

  • Changed source files scanned: 15
  • Security candidates found: 0
  • Skipped files: 0

Test Evidence

  • Mode: heuristic-only
  • Sources: none
  • Changed source coverage:
  • packages/cli/src/commands/migration.ts: not measured (no measurable changed lines)
  • packages/cli/src/docs/command-docs/analysis.ts: not measured (no measurable changed lines)
  • packages/cli/src/parsers/migration.ts: not measured (no measurable changed lines)
  • packages/cli/src/types/migration.ts: not measured (no measurable changed lines)
  • packages/knowledge/src/index.ts: not measured (no measurable changed lines)
  • packages/knowledge/src/migration/analyze.ts: not measured (no measurable changed lines)
  • packages/knowledge/src/migration/render.ts: not measured (no measurable changed lines)
  • packages/knowledge/src/migration/target-safety.ts: not measured (no measurable changed lines)
  • Notes:
  • No runtime coverage artifact was found. Test audit remains heuristic-only.

Changed Path Test Proof

Status Count
Runtime-proven 0
Static-only 10
Weakened by mocks 0
Unproven 15
  • Static-only packages/cli/src/commands/migration.ts#runMigrationCommand (static-reference, deterministic)
    • Evidence: Referenced by packages/knowledge/test/migration-safety.test.ts, packages/mcp/test/mcp-migration-safety.test.ts, but no runtime coverage artifact proves changed lines executed.
    • Static references: packages/knowledge/test/migration-safety.test.ts, packages/mcp/test/mcp-migration-safety.test.ts
    • Repair task: Strengthen packages/knowledge/test/migration-safety.test.ts so it executes packages/cli/src/commands/migration.ts#runMigrationCommand with assertions; static import alone is not proof.
  • Static-only packages/cli/src/docs/command-docs/analysis.ts#ANALYSIS_COMMAND_DOCS (static-reference, deterministic)
    • Evidence: Referenced by packages/knowledge/test/migration-safety.test.ts, but no runtime coverage artifact proves changed lines executed.
    • Static references: packages/knowledge/test/migration-safety.test.ts
    • Repair task: Strengthen packages/knowledge/test/migration-safety.test.ts so it executes packages/cli/src/docs/command-docs/analysis.ts#ANALYSIS_COMMAND_DOCS with assertions; static import alone is not proof.
  • Static-only packages/cli/src/parsers/migration.ts#parseMigrationArgs (static-reference, deterministic)
    • Evidence: Referenced by packages/knowledge/test/migration-safety.test.ts, packages/mcp/test/mcp-migration-safety.test.ts, but no runtime coverage artifact proves changed lines executed.
    • Static references: packages/knowledge/test/migration-safety.test.ts, packages/mcp/test/mcp-migration-safety.test.ts
    • Repair task: Strengthen packages/knowledge/test/migration-safety.test.ts so it executes packages/cli/src/parsers/migration.ts#parseMigrationArgs with assertions; static import alone is not proof.
  • Static-only packages/cli/src/types/migration.ts#MigrationOptions (static-reference, deterministic)
    • Evidence: Referenced by packages/knowledge/test/migration-safety.test.ts, packages/mcp/test/mcp-migration-safety.test.ts, but no runtime coverage artifact proves changed lines executed.
    • Static references: packages/knowledge/test/migration-safety.test.ts, packages/mcp/test/mcp-migration-safety.test.ts
    • Repair task: Strengthen packages/knowledge/test/migration-safety.test.ts so it executes packages/cli/src/types/migration.ts#MigrationOptions with assertions; static import alone is not proof.
  • Static-only packages/knowledge/src/index.ts#classifyMigrationConnectionTarget (static-reference, deterministic)
    • Evidence: Referenced by packages/knowledge/test/migration-safety.test.ts, but no runtime coverage artifact proves changed lines executed.
    • Static references: packages/knowledge/test/migration-safety.test.ts
    • Repair task: Strengthen packages/knowledge/test/migration-safety.test.ts so it executes packages/knowledge/src/index.ts#classifyMigrationConnectionTarget with assertions; static import alone is not proof.
  • Unproven packages/knowledge/src/index.ts#MigrationTargetKind (missing-proof, heuristic)
    • Evidence: No runtime coverage or static test reference was found for this changed path.
    • Repair task: Add an integration test that reaches packages/knowledge/src/index.ts#MigrationTargetKind without mocking the changed boundary.
  • Static-only packages/knowledge/src/migration/analyze.ts#analyzeMigrationSafety (static-reference, deterministic)
    • Evidence: Referenced by packages/knowledge/test/migration-safety.test.ts, but no runtime coverage artifact proves changed lines executed.
    • Static references: packages/knowledge/test/migration-safety.test.ts
    • Repair task: Strengthen packages/knowledge/test/migration-safety.test.ts so it executes packages/knowledge/src/migration/analyze.ts#analyzeMigrationSafety with assertions; static import alone is not proof.
  • Unproven packages/knowledge/src/migration/analyze.ts#AnalyzeMigrationSafetyOptions (missing-proof, heuristic)
    • Evidence: No runtime coverage or static test reference was found for this changed path.
    • Repair task: Add an integration test that reaches packages/knowledge/src/migration/analyze.ts#AnalyzeMigrationSafetyOptions without mocking the changed boundary.
  • ...and 17 more changed path proof entries

Untrusted Memory Context

  • Project invariant may be impacted (packages/knowledge/src/index.ts:73): Untrusted memory context: invariant "No hidden cloud or model call" applies to this change. The OSS CLI must remain useful without telemetry, API keys, hosted services, required LLM calls, or CodeDecayCloud.
  • Project invariant may be impacted (packages/knowledge/src/index.ts:73): Untrusted memory context: invariant "Commands are explicit" applies to this change. CodeDecay must not run project commands unless they are configured and safety.allowCommands is true.
  • Project invariant may be impacted (docs/migration.md:1): Untrusted memory context: invariant "Tool evidence is separate from AI suggestions" applies to this change. Reports must not present agent/model suggestions as verified evidence unless backed by deterministic checks or command output.
  • Project invariant may be impacted (docs/migration.md:1): Untrusted memory context: invariant "Output must be actionable" applies to this change. Redteam reports and agent bundles should say what behavior to verify, which test proof is weak or missing, and what task a coding agent should perform.
  • Architecture note applies (packages/cli/src/commands/migration.ts:15): Untrusted architecture context: CLI is the published surface: The public npm package is @submuxhq/codedecay and the binary is codedecay. Internal workspace packages are implementation details.
  • Architecture note applies (packages/mcp/src/handlers/migration-safety.ts:1): Untrusted architecture context: Agent-owned workflow: CodeDecay should produce evidence and task bundles that a user's own Codex, Claude Code, Cursor, OpenCode, Pi, desktop app, or MCP client can use.

High Risk Findings

  • Duplicated added logic (packages/cli/src/types/migration.ts:11): A similar block of added logic appears 4 times across 4 file(s).
  • Duplicated added logic (packages/cli/src/types/migration.ts:12): A similar block of added logic appears 3 times across 3 file(s).
  • Database area changed (packages/cli/src/commands/migration.ts:15): packages/cli/src/commands/migration.ts touches a database area and should be reviewed for regression impact.
  • Database area changed (packages/cli/src/parsers/migration.ts:11): packages/cli/src/parsers/migration.ts touches a database area and should be reviewed for regression impact.
  • Database area changed (packages/cli/src/types/migration.ts:11): packages/cli/src/types/migration.ts touches a database area and should be reviewed for regression impact.
  • Database area changed (packages/knowledge/src/migration/analyze.ts:5): packages/knowledge/src/migration/analyze.ts touches a database area and should be reviewed for regression impact.
  • Database area changed (packages/knowledge/src/migration/render.ts:5): packages/knowledge/src/migration/render.ts touches a database area and should be reviewed for regression impact.
  • Database area changed (packages/knowledge/src/migration/target-safety.ts:1): packages/knowledge/src/migration/target-safety.ts touches a database area and should be reviewed for regression impact.
  • Database area changed (packages/knowledge/src/migration/types.ts:5): packages/knowledge/src/migration/types.ts touches a database area and should be reviewed for regression impact.
  • Database area changed (packages/mcp/src/handlers/migration-safety.ts:1): packages/mcp/src/handlers/migration-safety.ts touches a database area and should be reviewed for regression impact.

Medium Risk Findings

  • Broad unrelated change set: This PR changes 16 files across 1 top-level areas and 3 risk categories.
  • Duplicated added logic (packages/mcp/src/handlers/migration-safety.ts:8): A similar block of added logic appears 2 times across 2 file(s).
  • Duplicated added logic (packages/mcp/src/handlers/migration-safety.ts:9): A similar block of added logic appears 2 times across 2 file(s).
  • Duplicated added logic (packages/mcp/src/handlers/migration-safety.ts:10): A similar block of added logic appears 2 times across 2 file(s).
  • Changed test looks happy-path only (packages/mcp/test/mcp-migration-safety.test.ts:27): packages/mcp/test/mcp-migration-safety.test.ts has assertions but no obvious negative, malformed, or boundary case coverage for risky source changes.
  • High complexity in changed function (packages/cli/src/parsers/migration.ts:5): parseMigrationArgs has estimated cyclomatic complexity 17.
  • High complexity in changed function (packages/knowledge/src/migration/analyze.ts:36): analyzeMigrationSafety has estimated cyclomatic complexity 15.
  • High complexity in changed function (packages/knowledge/src/migration/target-safety.ts:11): classifyMigrationConnectionTarget has estimated cyclomatic complexity 17.
  • Large changed function (packages/mcp/src/tools/register-analysis.ts:39): registerAnalysisMcpTools spans 148 lines, which increases review and regression risk.

Low Risk Findings

  • Docs area changed (docs/migration.md:1): docs/migration.md touches a docs area and should be reviewed for regression impact.
  • Docs area changed (packages/cli/src/docs/command-docs/analysis.ts:13): packages/cli/src/docs/command-docs/analysis.ts touches a docs area and should be reviewed for regression impact.
  • Source area changed (packages/knowledge/src/index.ts:73): packages/knowledge/src/index.ts touches a source area and should be reviewed for regression impact.
  • Source area changed (packages/mcp/src/index.ts:33): packages/mcp/src/index.ts touches a source area and should be reviewed for regression impact.
  • Source area changed (packages/mcp/src/tools/register-analysis.ts:17): packages/mcp/src/tools/register-analysis.ts touches a source area and should be reviewed for regression impact.
  • Source area changed (packages/mcp/src/tools/registry.ts:24): packages/mcp/src/tools/registry.ts touches a source area and should be reviewed for regression impact.
  • Source area changed (packages/mcp/src/tools/schemas.ts:144): packages/mcp/src/tools/schemas.ts touches a source area and should be reviewed for regression impact.
  • Source area changed (packages/mcp/src/tools/types.ts:74): packages/mcp/src/tools/types.ts touches a source area and should be reviewed for regression impact.
  • Test area changed (packages/knowledge/test/migration-safety.test.ts:1): packages/knowledge/test/migration-safety.test.ts touches a test area and should be reviewed for regression impact.
  • Test area changed (packages/mcp/test/mcp-migration-safety.test.ts:1): packages/mcp/test/mcp-migration-safety.test.ts touches a test area and should be reviewed for regression impact.

Recommended Checks

  • Add an integration test that reaches packages/knowledge/src/index.ts#MigrationTargetKind without mocking the changed boundary.
  • Add an integration test that reaches packages/knowledge/src/migration/analyze.ts#AnalyzeMigrationSafetyOptions without mocking the changed boundary.
  • Add an integration test that reaches packages/knowledge/src/migration/render.ts#renderMigrationSafetyMarkdown without mocking the changed boundary.
  • Add an integration test that reaches packages/knowledge/src/migration/types.ts#MigrationCleanupEvidence without mocking the changed boundary.
  • Add an integration test that reaches packages/knowledge/src/migration/types.ts#MigrationConnectionTarget without mocking the changed boundary.
  • Add an integration test that reaches packages/knowledge/src/migration/types.ts#MigrationMatrixState without mocking the changed boundary.
  • Add an integration test that reaches packages/knowledge/src/migration/types.ts#MigrationOperationKind without mocking the changed boundary.
  • Add an integration test that reaches packages/knowledge/src/migration/types.ts#MigrationRollbackStatus without mocking the changed boundary.
  • Add an integration test that reaches packages/knowledge/src/migration/types.ts#MigrationSafetyReport without mocking the changed boundary.
  • Add an integration test that reaches packages/knowledge/src/migration/types.ts#MigrationVerdict without mocking the changed boundary.
  • Add an integration test that reaches packages/mcp/src/tools/register-analysis.ts#registerAnalysisMcpTools without mocking the changed boundary.
  • Add an integration test that reaches packages/mcp/src/tools/registry.ts#CodeDecayMcpToolHandlers without mocking the changed boundary.

Notes

CodeDecay is deterministic and local-first. This report was generated without telemetry, API keys, LLMs, or model calls.


Found by CodeDecay - deterministic, local-first, no telemetry.

@kunaldhongade
kunaldhongade merged commit 7d22b3b into main Aug 6, 2026
10 of 11 checks passed
@kunaldhongade
kunaldhongade deleted the feature/686-migration-safety-close branch August 6, 2026 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli CLI package or command behavior area: docs README, community files, or documentation area: mcp Model Context Protocol integration documentation Improvements or additions to documentation type: test Test coverage, fixtures, or verification improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(data-safety): verify schema migrations and mixed-version compatibility

1 participant