summaryrefslogtreecommitdiff
path: root/plugins/code-modernization/commands
diff options
context:
space:
mode:
authorMorgan Lunt <morganl@anthropic.com>2026-09-24 21:10:47 -0700
committerMorgan Lunt <morganl@anthropic.com>2026-09-24 21:10:47 -0700
commit6436c5a81d2b163fe5a1c971b96f211d910bd75a (patch)
treeca25b3b10c30d4ca04f871f8e53bf4c9b1047c0f /plugins/code-modernization/commands
parent29c1c6a0d16453427b488e3eca1ad6e8beac0c10 (diff)
code-modernization: safer, more general version uplifts
Found by reading the commands as an engineer with a large Java 8 system: - The baseline suite was run "on legacy/<system>", which writes build output into the source. It now runs on a scratch copy, its result files or log are kept under analysis/<system>/baseline/ and named in BASELINE.md, and a typed table alone no longer counts as a measured baseline. - The working copy no longer carries the source repository's history, keeps files that look like credentials or production settings out of its first commit and lists them for a person, and moves that history to its own new local repository. - Migration tools (OpenRewrite and the like) run on a scratch copy, never in the source, since a dry run still builds and downloads. - A move spanning several versions or two things at once (a JDK and a framework) is split into hops that each build and test green. - Tests are not run against a database or service the configuration names until the person says it is a local or throwaway instance. - The silent-behavior hunt now names the usual traps for Java, Python, Node and PHP as well as .NET (locale data, default charset, ORM mappings, property binding, str/bytes). - The brief no longer requires business rules for a same-technology uplift: the recorded baseline is its behavior contract, so extract-rules can wait.
Diffstat (limited to 'plugins/code-modernization/commands')
-rw-r--r--plugins/code-modernization/commands/modernize-brief.md12
-rw-r--r--plugins/code-modernization/commands/modernize-uplift.md26
2 files changed, 27 insertions, 11 deletions
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.