summaryrefslogtreecommitdiff
path: root/plugins/code-modernization/commands/modernize-extract-rules.md
diff options
context:
space:
mode:
authorMorgan Lunt <morganl@anthropic.com>2026-09-24 20:14:51 -0700
committerMorgan Lunt <morganl@anthropic.com>2026-09-24 20:14:51 -0700
commitcafefb304bde4070c6c0877528ee49c1252eff85 (patch)
tree7e3a0db85edf586817474e04253a4d9d02416676 /plugins/code-modernization/commands/modernize-extract-rules.md
parentb10dab2f5ad83f642a03b5f800dea71651830beb (diff)
code-modernization: simpler commands, a source option, a report page and an equivalence check
Commands hardcoded legacy/<system>, so code too big to copy, or living at an absolute path, needed a hand-made symlink. Preflight now takes --source <path> and makes the legacy/<system> link for you (a junction on Windows); nothing is copied, and every command says where the link points before it starts. The harden patch is applied with patch -p1 -d. Each command ends by naming the next command to run, and the commands are about a third shorter with no step removed: - map accepts an existing dependency graph (--graph) or the stack's own tooling, maps very large estates in resumable chunks, records reflection targets as unresolved instead of dead, asks before describing more than 40 nodes, and never gives two nodes the same location. - transform can take its module and target from the brief, counts the equivalence cases that executed (zero is a failure and a comparison never skips), shows the tests can fail with a deliberate one-line break, and hands "same or different" to a script when both systems can run. - brief writes each phase in one fixed shape: one command, module ids as in the map, and criteria written as conditions a build command may tick but not reword. - reimagine reuses the discovery artifacts instead of extracting them again. - status names the exact command to paste next. scripts/build_report.py turns whatever the commands wrote into one self-contained, offline REPORT.html (Mermaid is vendored, all text from the analysis is escaped, the quarantined secrets file is never read), and scripts/compare.py decides byte-for-byte whether two outputs match, records why, and checks it can fail. The shard builder ignores symbolic links and paths that leave the source, matches a plain name against what lies beneath it, and falls back to the directory tree when the map's modules share a location. The README drops from 275 to about 100 lines; the pane's reference moves to hooks/README.md.
Diffstat (limited to 'plugins/code-modernization/commands/modernize-extract-rules.md')
-rw-r--r--plugins/code-modernization/commands/modernize-extract-rules.md16
1 files changed, 6 insertions, 10 deletions
diff --git a/plugins/code-modernization/commands/modernize-extract-rules.md b/plugins/code-modernization/commands/modernize-extract-rules.md
index 421dd210..89e27188 100644
--- a/plugins/code-modernization/commands/modernize-extract-rules.md
+++ b/plugins/code-modernization/commands/modernize-extract-rules.md
@@ -10,9 +10,7 @@ engineers about to retire. If a module pattern was given (`$module_pattern`), fo
there; otherwise cover the whole system. Prioritize calculation, validation, eligibility
and state-transition logic over plumbing.
-`$source` is the code: the first line of `analysis/$system/SOURCE` if that file exists,
-else `legacy/$system`. When the file exists, pass `sourceDir: "<that line>"` to the
-workflow below; when it does not, omit it.
+The code is `legacy/$system`, often a symlink to where it really lives: say where it points (`readlink legacy/$system`) in one line before you start.
## Method A — Workflow (preferred when the Workflow tool is available)
@@ -57,7 +55,6 @@ Workflow({
scriptPath: "${CLAUDE_PLUGIN_ROOT}/workflows/extract-rules.js",
args: {
system: "$system",
- sourceDir: "<first line of SOURCE, only if that file exists>",
modules: <contents of analysis/$system/extract-rules.modules.json>, // omit in lens mode
modulePattern: "$module_pattern" // lens mode only
}
@@ -107,12 +104,12 @@ Then go to **Finish**. Without the Workflow tool, use Method B.
Spawn **three business-rules-extractor subagents in parallel**, one lens each (add "focusing
on files matching $module_pattern" if a pattern was given):
-1. **Calculations** — "Find every formula, rate, threshold and computed value in $source: what
+1. **Calculations** — "Find every formula, rate, threshold and computed value in legacy/$system: what
it computes, the inputs, the exact formula, where (file:line), the edge cases handled."
2. **Validations and eligibility** — "Find every validation, eligibility check and guard in
- $source: what is checked, what happens on pass and fail, where (file:line)."
+ legacy/$system: what is checked, what happens on pass and fail, where (file:line)."
3. **State and lifecycle** — "Find every status field, state machine and lifecycle transition
- in $source: the states, what triggers transitions, what side effects fire."
+ in legacy/$system: the states, what triggers transitions, what side effects fire."
Merge and de-duplicate, then **verify before you write**: read each cited line and confirm the
code implements the rule; drop (and note) any rule supported only by a comment or string.
@@ -124,7 +121,7 @@ them, location) in this format:
### RULE-NNN: <plain-English name>
**Category:** Calculation | Validation | Lifecycle | Policy
**Priority:** P0 | P1 | P2
-**Source:** `path/to/file.ext:line-line` (path relative to $source)
+**Source:** `path/to/file.ext:line-line` (path relative to legacy/$system)
**Plain English:** One sentence a business analyst would recognize.
**Specification:**
Given <precondition>
@@ -147,5 +144,4 @@ confirmation** section listing each Medium and Low rule with its question.
Report: total rules, breakdown by category, how many need SME review, and (Method A) how many
candidates the referees rejected: that number is the quality the verification bought. Refresh the
-report: `python3 "${CLAUDE_PLUGIN_ROOT}/scripts/build_report.py" $system` (skip quietly if `python3`
-is missing). The next step is `/code-modernization:modernize-brief $system <target-stack>`.
+report: `python3 "${CLAUDE_PLUGIN_ROOT}/scripts/build_report.py" $system` (a convenience: if it fails or `python3` is missing, say so in one line and carry on). The next step is `/code-modernization:modernize-brief $system <target-stack>`.