diff options
Diffstat (limited to 'plugins/code-modernization')
4 files changed, 33 insertions, 13 deletions
diff --git a/plugins/code-modernization/agents/version-delta-analyst.md b/plugins/code-modernization/agents/version-delta-analyst.md index f029249e..e8624e18 100644 --- a/plugins/code-modernization/agents/version-delta-analyst.md +++ b/plugins/code-modernization/agents/version-delta-analyst.md @@ -37,6 +37,10 @@ has none of that, so "installed" ≠ "produced findings". **Never fold a tool's findings into the catalog unless it actually ran** — instead record "coverage lost: <tool> needs restore+network, unavailable here". +**Run a migration tool only on a scratch copy** of the code (rsync it into a +temporary folder), never inside `legacy/`: builds and dry runs write output and +download plugins, and the source is never touched. + - **.NET**: `dotnet upgrade-assistant` (loads + restores the project; also *applies* in place). `try-convert` (project-system → SDK-style). The **Portability Analyzer** (`apiport`) analyzes *compiled assemblies*, not diff --git a/plugins/code-modernization/commands/modernize-brief.md b/plugins/code-modernization/commands/modernize-brief.md index 86dff44a..fb9a8f76 100644 --- a/plugins/code-modernization/commands/modernize-brief.md +++ b/plugins/code-modernization/commands/modernize-brief.md @@ -9,9 +9,11 @@ document a steering committee approves and engineering executes. Target stack: `$target_stack` (if blank, the one in `analysis/$system/INTENT.md`, else recommend one from the assessment). Read `ASSESSMENT.md`, `topology.json` (and the `.mmd` files beside it; never read -`TOPOLOGY.html`, it is a viewer with the data minified inside) and `BUSINESS_RULES.md` -in `analysis/$system/` first. If any is missing, say so and stop: they come from `assess`, -`map` and `extract-rules`, which run first. Four more inputs are conditional: +`TOPOLOGY.html`, it is a viewer with the data minified inside) in `analysis/$system/` first, +and `BUSINESS_RULES.md` too unless this is a same-technology **uplift** (the intent or the assessment +says so): an uplift keeps the code, so its Behavior Contract is the recorded baseline and `extract-rules` +can wait. If a required file is missing, say so and stop: they come from `assess`, `map` and +`extract-rules`, which run first. Four more inputs are conditional: - **`RULE_REVIEWS.json` / `RULE_REVIEWS.md`**, if they exist (written by `/code-modernization:modernize-review`): a person's verdicts on individual rules. Never put a rule marked `wrong` or `discuss` in the Behavior @@ -105,7 +107,9 @@ entry points and mark them as needing SME confirmation. **5. Behavior Contract.** The **P0 rules** from `BUSINESS_RULES.md` (the ones the system's core purpose depends on, or that are costly if wrong) that MUST be proven equivalent before any phase ships: they become the regression suite. -Flag any P0 rule below High confidence as a blocker needing SME confirmation before its phase starts. +Flag any P0 rule below High confidence as a blocker needing SME confirmation before its phase starts. For an uplift +with no rules file, the contract is the baseline: `analysis/$system/BASELINE.md` and the result files it points to, +which the new version must reproduce. **6. Validation Strategy.** Which combination applies, per phase: characterization tests, contract tests, dual-execution diff, property-based tests, manual UAT. diff --git a/plugins/code-modernization/commands/modernize-uplift.md b/plugins/code-modernization/commands/modernize-uplift.md index 8ee655b5..5e0eda2e 100644 --- a/plugins/code-modernization/commands/modernize-uplift.md +++ b/plugins/code-modernization/commands/modernize-uplift.md @@ -23,7 +23,10 @@ recorded outputs on the target only. That is fine, but label it honestly (Step 0 ## Step 0 — Toolchain and version pinning (fail fast) 1. **Pin the version pair exactly.** If the versions were not given, take them from `analysis/$system/INTENT.md` or the - brief. If either version is missing or vague (".NET" with no number), stop and ask. + brief. If either version is missing or vague (".NET" with no number), stop and ask. When the move spans several + major versions or two things at once (a JDK and a framework: Java 8 with Spring 4 to Java 21 with Spring Boot 3), + split it into hops that each build and pass their tests before the next starts (for example Java 8, 11, 17, 21), + name the order in the plan, and treat each hop as its own pilot. 2. **Target runtime, required.** Verify it builds and tests (`dotnet --version` and a `dotnet test` smoke; `mvn` or `gradle`; `python3 -V` and `pytest`). 3. **Source runtime, the baseline oracle.** Verify the *old* version also runs here. If it does not @@ -44,6 +47,9 @@ recorded outputs on the target only. That is fine, but label it honestly (Step 0 emits a patch: the most reliable). Python: `pyupgrade` (`2to3` is removed in 3.13, `python-modernize` is abandoned). JS and Angular: `ng update` (edits in place, needs a clean git tree and `node_modules`). +6. **Where the tests point.** Before running any suite, read its configuration for the databases, queues and services it + connects to. If any is not a local or throwaway instance, stop and ask which environment to use: the baseline and + the proof both run the old code against it. `/code-modernization:modernize-preflight $system $target_version` gives the full readiness report. @@ -57,9 +63,11 @@ approved") is the next step: meet it, never re-plan around it. If no phase match **Working copy first.** An uplift edits a whole solution *in place* (target frameworks, API fixes, the `.sln` and relative project references intact, a reviewable `git diff`). So copy it once, whole: -`rsync -a legacy/$system/ modernized/$system-uplifted/` (the recommended deny rule refuses a `cp` out of the -source directory), and do all editing there, git-tracked (`git init` and a first commit if the copy is not -already a repository). `legacy/$system` stays the untouched baseline. +`rsync -a --exclude .git legacy/$system/ modernized/$system-uplifted/` (the recommended deny rule refuses a `cp` out of the +source directory), and do all editing there, git-tracked in its own new local history (`git init` and a first +commit in the copy only, never in the source repository). `legacy/$system` stays the untouched baseline. Do not +commit files that look like credentials or production configuration (keystores, `*.pem`, `.env*`, `*prod*` +settings): leave them out of the first commit, list them in `UPLIFT_NOTES.md` and let a person decide. Copying the whole solution keeps the relative references intact and makes the result a real diff against the seeded copy. For a very large git-tracked source, the plan may propose `git worktree add --detach modernized/$system-uplifted` in the source repository instead of a copy @@ -131,10 +139,14 @@ Either way rank by blast radius and mark each delta **Mechanical** (a codemod ca trivial real type and assert on it under both targets; if that will not go green on both, fix the harness now, not mid-migration. If the source leg cannot run here (Step 0.3), prove the target leg and mark it target-only. -2. **Baseline is the oracle, and it goes in a file.** Run the existing suite on **`legacy/$system`** (the $source_version code) and +2. **Baseline is the oracle, and it goes in a file.** Run the existing suite on **a scratch copy of `legacy/$system`** (the $source_version code; a build writes output, and nothing is ever built inside the source) and write the per-test table to **`analysis/$system/BASELINE.md`**, including the tests legacy fails: you - are proving *no behavior changed*, not *all tests pass*. If the source runtime cannot run here, write - the single line `target-only: <why>` instead. Step 5 does not start until the file exists. + are proving *no behavior changed*, not *all tests pass*. **Measure it, do not type it:** keep the runner's + own result files or raw log of that run (Maven `target/surefire-reports`, `pytest --junitxml`, a `dotnet test` + log) under `analysis/$system/baseline/` and name them in a `Recorded:` line of `BASELINE.md`; the proof step + counts a baseline it can read from those files, and a typed table alone caps the verdict at PARTLY PROVEN. + If the source runtime cannot run here, write the single line `target-only: <why>` instead. Step 5 does not + start until the file exists. 3. **Gap-fill at delta sites.** With the catalog, spawn `test-engineer` to add characterization tests where **behavioral-silent** deltas touch under-tested code (culture, encoding, serialization, dates), not blanket coverage. No credential becomes a fixture. Target-only: pin them to recorded outputs. diff --git a/plugins/code-modernization/workflows/uplift-deltas.js b/plugins/code-modernization/workflows/uplift-deltas.js index 45475eaf..1c31bc4a 100644 --- a/plugins/code-modernization/workflows/uplift-deltas.js +++ b/plugins/code-modernization/workflows/uplift-deltas.js @@ -99,7 +99,7 @@ const CATEGORIES = [ { key: 'behavioral', label: 'Behavioral-silent', - brief: `Changes that COMPILE AND RUN but produce a DIFFERENT RESULT on ${target} vs ${source} — the dangerous, silent class. PROBE GLOBALIZATION/LOCALE FIRST: .NET 5+ switched to ICU (vs NLS), silently changing string.Compare/casing/sort-order/DateTime parsing — the canonical Framework→.NET trap. Then: default encoding, TLS defaults, serialization formats, DateTime/timezone, floating-point, async context, collection ordering. For each, name the exact characterization test to write before touching the site.`, + brief: `Changes that COMPILE AND RUN but produce a DIFFERENT RESULT on ${target} vs ${source} — the dangerous, silent class. PROBE GLOBALIZATION/LOCALE AND TEXT FIRST, for this stack: .NET 5+ switched to ICU (vs NLS), silently changing string.Compare/casing/sort-order/DateTime parsing; Java 9+ uses CLDR locale data (number, date and currency formats change), JDK 18+ defaults to UTF-8 (file and stream reads without a charset), Hibernate 5→6 changes id generation and column type mapping (Oracle DATE, booleans, UUIDs), Spring 5→6 and Boot 2→3 change property binding, path matching and Jackson defaults; Python 2→3 makes str/bytes a hard boundary and division, dict ordering, hash randomization and the default encoding behave differently; Node and PHP major versions change coercion, JSON and date handling. Then: default encoding, TLS defaults, serialization formats, DateTime/timezone, floating-point, async context, collection ordering. For each, name the exact characterization test to write before touching the site.`, }, { key: 'project-system', @@ -120,7 +120,7 @@ const found = await parallel( Your category this pass: ${c.brief} -A delta belongs in the catalog ONLY if it is in the intersection of (a) a known ${source}→${target} change and (b) something THIS code actually uses — cite the file:line where it hits, and set siteCount to how many sites hit it (the migration cost is dominated by high-siteCount deltas, so be accurate). If a standard migration tool for this stack is installed (dotnet upgrade-assistant / OpenRewrite 'mvn rewrite:dryRun' / pyupgrade), check whether it can ACTUALLY RUN here (most need a working restore+build and often network — a read-only/offline sandbox usually can't). Only fold in findings from a tool that actually ran; if it's installed but couldn't run, say so in toolReport ("coverage lost: <tool> needs restore+network") rather than implying coverage. Don't rely on apiport (compiled-assembly + archived) or 2to3 (removed in Python 3.13). +A delta belongs in the catalog ONLY if it is in the intersection of (a) a known ${source}→${target} change and (b) something THIS code actually uses — cite the file:line where it hits, and set siteCount to how many sites hit it (the migration cost is dominated by high-siteCount deltas, so be accurate). Run a migration tool only on a scratch copy of the code (make one with rsync into a temporary folder), never inside ${legacyDir}: builds and dry runs write output and download plugins. If a standard migration tool for this stack is installed (dotnet upgrade-assistant / OpenRewrite 'mvn rewrite:dryRun' / pyupgrade), check whether it can ACTUALLY RUN here (most need a working restore+build and often network — a read-only/offline sandbox usually can't). Only fold in findings from a tool that actually ran; if it's installed but couldn't run, say so in toolReport ("coverage lost: <tool> needs restore+network") rather than implying coverage. Don't rely on apiport (compiled-assembly + archived) or 2to3 (removed in Python 3.13). Mark each delta Mechanical (a codemod/tool can apply it) or Judgment (needs a human). For Behavioral-silent deltas, give the exact test to write before touching the code. ${UNTRUSTED}`, |
