summaryrefslogtreecommitdiff
path: root/plugins/code-modernization
diff options
context:
space:
mode:
authorMorgan Lunt <morganl@anthropic.com>2026-09-23 19:52:43 -0700
committerMorgan Lunt <morganl@anthropic.com>2026-09-24 17:50:21 -0700
commitd13ff0324cf9a8744be6c75251689816485e68cf (patch)
tree58a48e211c22e1078ba9e76d9beacfdf59d4fe7a /plugins/code-modernization
parent6f020b9f66a1340efeab2fd4ca7a17f348e3fea9 (diff)
code-modernization: extract-rules asks before a large run, with an estimate
The command told the model to state the shard count and an estimate before launching, but in live runs on a small system it launched without saying anything: a reply that only mentions the estimate is easy to skip and is not a gate. With more than 12 shards the command now requires an AskUserQuestion that carries the shard count, the line count and the estimate (agents, tokens, minutes) and offers to run all shards, run only a slice, or cancel. With 12 shards or fewer it launches straight away and says what it launched. The estimate is now a working formula (10 to 15 agents per shard, about 16k tokens per agent, about 8 agents finishing per minute) with the two runs it comes from: 4 shards used 58 agents in under 10 minutes, and a 44-program, 30,000-line estate used 466 to 647 agents.
Diffstat (limited to 'plugins/code-modernization')
-rw-r--r--plugins/code-modernization/README.md2
-rw-r--r--plugins/code-modernization/commands/modernize-extract-rules.md23
2 files changed, 17 insertions, 8 deletions
diff --git a/plugins/code-modernization/README.md b/plugins/code-modernization/README.md
index 54b22fda..0ded8668 100644
--- a/plugins/code-modernization/README.md
+++ b/plugins/code-modernization/README.md
@@ -56,7 +56,7 @@ Run in order, but each is standalone — stop, review, resume.
- **`/code-modernization:modernize-map <system-dir> [--no-describe]`** — Dependency and topology map: call graph, data lineage, entry points, and 2–4 business flows each traced for a persona (the claimant, the auditor). Produces `topology.json` and an **interactive zoomable `TOPOLOGY.html`** (circle-pack sized by LOC, edge toggles, search, and a persona-flow walkthrough), plus small `.mmd` diagrams for docs. Each node also gets a short plain-language description in the sidebar, written by one agent per node from just that node's source and links; `--no-describe` skips that step.
-- **`/code-modernization:modernize-extract-rules <system-dir> [module-pattern]`** — Mine the business rules — calculations, validations, eligibility, state transitions — into Given/When/Then "Rule Cards" with `file:line` citations and confidence ratings. With the Workflow tool, anything but a tiny system is extracted in per-module shards (from `map`'s `topology.json` if present, else the directory tree), so each extractor reads one focused slice. Produces `BUSINESS_RULES.md` + `DATA_OBJECTS.md`.
+- **`/code-modernization:modernize-extract-rules <system-dir> [module-pattern]`** — Mine the business rules — calculations, validations, eligibility, state transitions — into Given/When/Then "Rule Cards" with `file:line` citations and confidence ratings. With the Workflow tool, anything but a tiny system is extracted in per-module shards (from `map`'s `topology.json` if present, else the directory tree), so each extractor reads one focused slice. A large run shows an estimate and asks before it starts. Produces `BUSINESS_RULES.md` + `DATA_OBJECTS.md`.
- **`/code-modernization:modernize-brief <system-dir> [target-stack]`** — Synthesize discovery into a phased **Modernization Brief**: target architecture, phase plan, persona walkthroughs, behavior contract, and an approval block. Reads the discovery artifacts and **stops if any are missing**. Stops for your explicit approval as a human-in-the-loop gate, in plan mode if the session supports it. For a same-stack uplift it also requires the **delta catalog**, since an uplift's phase order is decided by its version deltas. The execution commands read the brief and treat each phase's entry criteria as gates, so editing the brief steers execution.
diff --git a/plugins/code-modernization/commands/modernize-extract-rules.md b/plugins/code-modernization/commands/modernize-extract-rules.md
index 6efcdf40..2b355d4f 100644
--- a/plugins/code-modernization/commands/modernize-extract-rules.md
+++ b/plugins/code-modernization/commands/modernize-extract-rules.md
@@ -107,13 +107,22 @@ ask whether to run it first or proceed now. If proceeding:
### 2. Estimate, ask if the run is large, then launch
-Before launching, tell the user the shard count and what it implies: roughly
-**one extractor agent per shard, then one citation referee per candidate
-rule** (usually the dominant term — a few per shard), two judges per P0 rule,
-and one data-object cataloger, queued against the runtime's concurrency cap.
-A 60-shard estate that yields 300 candidate rules with 40 P0s is on the order
-of 450 agents; a tiny system in lens mode is 15–40. Observed on a 44-program,
-30,000-line system: 466 to 647 agents, about 8.8M tokens, 50 to 80 minutes.
+**Estimate** the run before launching: 10 to 15 agents per shard, about 16k
+tokens per agent, about 8 agents finishing per minute. For calibration, 4
+shards (five programs, about 1,600 lines) used 58 agents in under 10
+minutes; a 44-program, 30,000-line estate used 466 to 647 agents, about 8.8M
+tokens and 50 to 80 minutes; a tiny system in lens mode is 15 to 40 agents.
+
+**With more than 12 shards, ask before launching, with the AskUserQuestion
+tool** (a reply that only mentions the estimate is easy to miss and is not a
+gate). Put the shard count, the line count and the estimate (agents, tokens,
+minutes) in the question, and offer "Run all N shards", "Only a slice (say
+which, as a module pattern)" and "Cancel". Launch only after the answer: on
+"Run all N shards", launch; on a slice, rebuild the shard list with that
+pattern (step 1; module mode ignores `modulePattern`) and launch that; on
+"Cancel", stop. With 12 shards or fewer, launch straight away, and say in
+your reply how many shards you launched and the rough estimate.
+
One workflow run is capped at 1000 agents by the runtime; the script stops
scheduling shards before it gets there (they come back in
`stats.skippedModules`), so for a list beyond about 70 shards (10 to 15 agents