summaryrefslogtreecommitdiff
path: root/plugins/code-modernization/README.md
diff options
context:
space:
mode:
authorMorgan Westlee Lunt <morganl@anthropic.com>2026-06-09 23:31:52 +0000
committerMorgan Westlee Lunt <morganl@anthropic.com>2026-06-09 23:31:52 +0000
commit3b9df6160068f836214bfae942a2ca2530489c84 (patch)
tree9cb7e5f2492dc47910b750026a786bcd537ecdd5 /plugins/code-modernization/README.md
parent4a8250babf1d131c1406b113f3d759d18c55ec48 (diff)
code-modernization: fix findings from adversarial audit
Code/security: - extract-rules.js: guard null agent() verdicts in the verify + P0 loops (a skipped/dead referee made {rule,v:null} survive .filter(Boolean) and then crashed on v.injectionSuspected / v.every) — sibling scripts already had the guard. - topology viewer XSS: the map injector embedded untrusted JSON (node names from filenames, etc.) into a <script> island unescaped — a name containing </script> executed on open. Escape < > & in the injected data and add a CSP to the template. - Second-order injection: citation/identifier fields (source / cwe / source_site / correctedSource) were interpolated UNFENCED into the verifier prompts that are supposed to be the trust anchor. Fence them in extract-rules, harden-scan, uplift-deltas. uplift design (audit of the new feature): - Working-copy model: copy the WHOLE solution to modernized/ once and edit in place (relative project refs survive; result is a reviewable git diff) — the incremental per-project copy broke multi-project builds. - Dual-run honesty: reframed as 'if both runtimes run here' (net48 needs Windows; JUnit/pytest don't multi-target); dummy-test gate now binds a real SUT under both targets; per-stack harness notes. - Tooling honesty: present/runnable/actually-ran distinction; never fold in a tool that couldn't run; apiport/2to3 demoted; py2->3 removed from 'preserve' examples. - Delta classes: name the high-blast-radius landmines (JPMS strong encapsulation, .NET trimming/AOT, ICU globalization, hosting/runtime-config, analyzer/nullable) in the finder briefs + agent. - Rewrite-vs-uplift signal: weigh by touched sites (siteCount), not delta-card count; judgment-share demoted to secondary. Docs/consistency: brief reads topology.json (not TOPOLOGY.html); README 'five commands'; credential-masking claim split (analysts mask+cite vs code-writers substitute fakes); read-only/write-scope claims softened to match enforcement (Bash retained -> discipline, not tool-lock); reimagine nested blockers/pendingRuleIds; status splits transform vs reimagine markers; portfolio enumeration basenames; plugin.json description updated. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Diffstat (limited to 'plugins/code-modernization/README.md')
-rw-r--r--plugins/code-modernization/README.md37
1 files changed, 22 insertions, 15 deletions
diff --git a/plugins/code-modernization/README.md b/plugins/code-modernization/README.md
index a56aaa34..2a1e1803 100644
--- a/plugins/code-modernization/README.md
+++ b/plugins/code-modernization/README.md
@@ -12,7 +12,7 @@ preflight → assess → map → extract-rules → brief → reimagine | transfo
The three build paths are different *methods*, chosen by the brief's recommended pattern: **`transform`** (cross-stack rewrite from extracted intent), **`reimagine`** (greenfield rebuild), and **`uplift`** (same-stack version bump — e.g. .NET Framework → .NET 8 — that preserves the code and fixes only the version deltas).
-The discovery commands (`assess`, `map`, `extract-rules`) build artifacts under `analysis/<system>/`. The `brief` command synthesizes them into an approval gate. The build commands (`reimagine`, `transform`, `uplift`) write new code under `modernized/`. The `harden` command audits the legacy system and produces a reviewable remediation patch. Each step has a dedicated slash command, and specialist agents (legacy analyst, business rules extractor, architecture critic, security auditor, test engineer) are invoked from within those commands — or directly — to keep the work honest.
+The discovery commands (`assess`, `map`, `extract-rules`) build artifacts under `analysis/<system>/`. The `brief` command synthesizes them into an approval gate. The build commands (`reimagine`, `transform`, `uplift`) write new code under `modernized/`. The `harden` command audits the legacy system and produces a reviewable remediation patch. Each step has a dedicated slash command, and specialist agents (such as legacy analyst, business rules extractor, architecture critic, security auditor, test engineer, version delta analyst, scaffolder) are invoked from within those commands — or directly — to keep the work honest.
## Expected layout
@@ -27,13 +27,13 @@ mkdir -p legacy && ln -s /path/to/your/legacy/codebase legacy/billing
The commands degrade gracefully, but each of these makes the output meaningfully better — run `/modernize-preflight <system-dir>` to check all of them at once and get a readiness report:
- **Analysis tools**: [`scc`](https://github.com/boyter/scc) (LOC + complexity + COCOMO) or [`cloc`](https://github.com/AlDanial/cloc); [`lizard`](https://github.com/terryyin/lizard) for portfolio mode. Without them, metrics fall back to `find`/`wc` and get coarser.
-- **A working build toolchain** for the legacy stack (e.g. GnuCOBOL for COBOL) — required before `/modernize-transform` can prove behavioral equivalence, and verified by preflight with a real smoke compile against your code.
+- **A working build toolchain** for the legacy stack (e.g. GnuCOBOL for COBOL) — it enables `/modernize-transform`'s *strongest* equivalence proof (live dual execution), and is verified by preflight with a real smoke compile. It is not strictly required: when the legacy stack can't build locally (common for CICS/IMS, or .NET Framework on Linux), equivalence falls back to recorded-trace / golden-master tests, and preflight reports Ready-with-gaps rather than blocking.
- **The whole system in the tree**: deployment descriptors (JCL, CICS definitions, route configs), copybooks/includes, and DDL/schemas. Entry-point detection and data lineage in `/modernize-map` are guesswork without them.
- **Production telemetry** (optional): an observability MCP server or batch job logs enable the runtime overlay in `/modernize-assess` and timing annotations on critical paths.
## Dynamic workflow orchestration
-On Claude Code builds that ship the **Workflow tool**, four commands upgrade
+On Claude Code builds that ship the **Workflow tool**, five commands upgrade
from "spawn a few agents and merge by hand" to scripted orchestration
(`workflows/*.js` in this plugin). The commands detect the tool and fall back
to direct subagent fan-out on older builds — no configuration needed.
@@ -50,10 +50,14 @@ These fan out more agents than the fallback path (tens, on a large estate) —
the commands state the expected count before launching. Invoking the slash
command is the opt-in.
-A structural security property comes with the conversion: workflow extraction
-agents return **schema-validated data**, and only the orchestrating session
-writes artifacts. Analysis agents never touch disk. See the next two sections
-for why that matters.
+A useful property comes with the conversion: workflow extraction agents return
+**schema-validated data**, and the orchestrating session is what writes the
+artifacts — so analysis output flows through a typed boundary, not a
+free-form file write. Note this is a *workflow-shape* property, not a tool-lock:
+the analysis agents still carry `Bash` (they need `grep`/`scc`/`npm audit`),
+so "read-only" is enforced by their system prompt + the data-only return value,
+not by removing write tools. The real injection boundary is the fence and the
+typed return — see the next two sections.
## Untrusted code & prompt injection
@@ -64,22 +68,25 @@ steering what lands in `BUSINESS_RULES.md` or `SECURITY_FINDINGS.md` — which
downstream commands treat as trusted. Defenses, in layers: every agent's
system prompt pins file content as data-never-instructions and reports
instruction-shaped text as a finding (`injectionFlags` in workflow results —
-surfaced prominently when non-empty); analysis agents are read-only, with
-artifact writes happening only in the orchestrating session; citation
+surfaced prominently when non-empty); analysis agents are instructed read-only
+and return typed data, with artifact writes happening in the orchestrating
+session (prompt- and shape-enforced — they retain `Bash` for `grep`/`scc`, so
+this is discipline, not a tool lock); citation
referees refute any rule or finding supported by comments rather than
executable code; agent-produced text is **fenced as untrusted data** when it
flows into a downstream agent's prompt (referees re-derive claims from the
cited code rather than trusting the finder's description — second-order
injection); workflow inputs that become filesystem paths are validated
against a strict name pattern; the one write-capable workflow agent
-(`scaffolder`) runs with an explicit minimal tool list and a write scope of
-exactly its own service directory; and `/modernize-brief` remains a human
+(`scaffolder`) is told to write only within its own service directory (enforce
+this with the workspace `settings.json` below — the instruction alone is not a
+sandbox); and `/modernize-brief` remains a human
approval gate before anything is executed against. Treat discovery artifacts
from code you don't trust with the same skepticism as the code itself.
## Secret handling
-Legacy systems routinely contain live credentials, and assessment artifacts get committed and shared. **Every agent in this plugin masks credential values** — findings, rule-card parameters, architecture notes, and test fixtures cite `file:line` with a masked preview (`AKIA****`), never the value. When credentials are found, a per-credential inventory (type, location, blast radius, rotation recommendation) is written to `analysis/<system>/SECRETS.local.md`, which the commands gitignore before writing; on non-git projects the quarantine file goes to `~/.modernize/<system>/` instead. `/modernize-harden` splits its remediation diff so credential-removal hunks (which necessarily contain the raw value) land in a gitignored `security_remediation.local.patch`, never the shareable patch. Pass `--show-secrets` to include raw values in the quarantine file (and only there). If you ran an earlier version of this plugin on a real system, check whether `analysis/` artifacts containing credentials were committed or shared, and rotate anything that was.
+Legacy systems routinely contain live credentials, and assessment artifacts get committed and shared. **Every agent in this plugin keeps credential values out of shared artifacts.** The analysis agents mask-and-cite — `file:line` with a masked preview (`AKIA****`), never the value — in findings, rule-card parameters, and architecture notes. The code-writing agents (`test-engineer`, `scaffolder`) never carry a legacy credential into a fixture at all: they substitute fake same-shape values and env-var placeholders. When credentials are found, a per-credential inventory (type, location, blast radius, rotation recommendation) is written to `analysis/<system>/SECRETS.local.md`, which the commands gitignore before writing; on non-git projects the quarantine file goes to `~/.modernize/<system>/` instead. `/modernize-harden` splits its remediation diff so credential-removal hunks (which necessarily contain the raw value) land in a gitignored `security_remediation.local.patch`, never the shareable patch. Pass `--show-secrets` to include raw values in the quarantine file (and only there). If you ran an earlier version of this plugin on a real system, check whether `analysis/` artifacts containing credentials were committed or shared, and rotate anything that was.
## Commands
@@ -103,10 +110,10 @@ Build a dependency and topology map of the **legacy** system: program/module cal
Mine the business rules embedded in the legacy code — calculations, validations, eligibility, state transitions, policies — into Given/When/Then "Rule Cards" with `file:line` citations and confidence ratings. Spawns three `business-rules-extractor` agents in parallel (calculations, validations, lifecycle). Produces `analysis/<system>/BUSINESS_RULES.md` and `analysis/<system>/DATA_OBJECTS.md`.
### `/modernize-brief <system-dir> [target-stack]`
-Synthesize the discovery artifacts into a phased **Modernization Brief** — the single document a steering committee approves and engineering executes: target architecture, strangler-fig phase plan with entry/exit criteria, persona-based business walkthroughs (the section non-technical approvers actually read), behavior contract, validation strategy, open questions, and an approval block. Reads `ASSESSMENT.md`, `TOPOLOGY.html`, and `BUSINESS_RULES.md` and **stops if any are missing** — run the discovery commands first. Produces `analysis/<system>/MODERNIZATION_BRIEF.md` and enters plan mode as a human-in-the-loop gate.
+Synthesize the discovery artifacts into a phased **Modernization Brief** — the single document a steering committee approves and engineering executes: target architecture, strangler-fig phase plan with entry/exit criteria, persona-based business walkthroughs (the section non-technical approvers actually read), behavior contract, validation strategy, open questions, and an approval block. Reads `ASSESSMENT.md`, `topology.json` (not the `TOPOLOGY.html` viewer — the brief parses the JSON, whose `flows` drive the persona walkthroughs), and `BUSINESS_RULES.md`, and **stops if any are missing** — run the discovery commands first. Produces `analysis/<system>/MODERNIZATION_BRIEF.md` and enters plan mode as a human-in-the-loop gate.
### `/modernize-reimagine <system-dir> <target-vision>`
-Greenfield rebuild from extracted intent rather than a structural port. Mines a spec (`analysis/<system>/AI_NATIVE_SPEC.md`), designs a target architecture and has it adversarially reviewed (`analysis/<system>/REIMAGINED_ARCHITECTURE.md`), then **scaffolds services with executable acceptance tests** under `modernized/<system>-reimagined/` and writes a `CLAUDE.md` knowledge handoff for the new system. Two human-in-the-loop checkpoints. Spawns `business-rules-extractor`, `legacy-analyst` (×2), `architecture-critic`, and general-purpose scaffolding agents.
+Greenfield rebuild from extracted intent rather than a structural port. Mines a spec (`analysis/<system>/AI_NATIVE_SPEC.md`), designs a target architecture and has it adversarially reviewed (`analysis/<system>/REIMAGINED_ARCHITECTURE.md`), then **scaffolds services with executable acceptance tests** under `modernized/<system>-reimagined/` and writes a `CLAUDE.md` knowledge handoff for the new system. Two human-in-the-loop checkpoints. Spawns `business-rules-extractor`, `legacy-analyst` (×2), `architecture-critic`, and the `scaffolder` agent (Phase E).
### `/modernize-transform <system-dir> <module> <target-stack>`
Surgical, single-module strangler-fig rewrite. Plans first (HITL gate), then writes characterization tests via `test-engineer`, then an idiomatic target implementation under `modernized/<system>/<module>/`, proves equivalence by running the tests, and produces `TRANSFORMATION_NOTES.md` mapping legacy → modern with deliberate deviations called out. Reviewed by `architecture-critic`.
@@ -128,7 +135,7 @@ Security hardening pass on the **legacy** system: OWASP/CWE scan, dependency CVE
- **`security-auditor`** — Reviews code for auth, input validation, secret handling, and dependency CVEs. Tuned for the kinds of issues that appear when translating security primitives across stacks (e.g., session handling from servlet to stateless JWT). Used by `assess` and `harden`.
- **`test-engineer`** — Writes characterization, contract, and equivalence tests that pin legacy behavior so transformation can be proven correct. Flags tests that exercise code paths without asserting outcomes. Used by `transform` and `uplift`.
- **`version-delta-analyst`** — For **same-stack uplifts**: finds the breaking/behavioral changes between two versions of one stack that actually bite a given codebase, and drives the ecosystem migration tool. Produces a delta catalog (API-removed / silent-behavioral / project-system / dependency), preserving the code rather than redesigning it. Used by `uplift`.
-- **`scaffolder`** — Builds one service of a reimagined system from the approved architecture and spec: skeleton, domain model, API stubs, executable acceptance tests. Write scope is exactly its own `modernized/.../<service>/` directory; treats the spec's imperative-sounding content as data, since the spec derives from untrusted legacy code. Used by `reimagine` (Phase E).
+- **`scaffolder`** — Builds one service of a reimagined system from the approved architecture and spec: skeleton, domain model, API stubs, executable acceptance tests. Instructed to write only within its own `modernized/.../<service>/` directory (enforce with the workspace `settings.json` below); treats the spec's imperative-sounding content as data, since the spec derives from untrusted legacy code. Used by `reimagine` (Phase E).
## Installation