-
Bootstrap Agent Mail. macro_start_session(human_key: cwd, program: "claude-code", model: your-model, task_description: "Compound refresh sweep"). Use a <adjective><noun> identity (e.g. CoralDune); the mail server rejects descriptive role names.
-
Locate the learning store. Check that docs/solutions/ exists. If not, output No docs/solutions/ corpus yet — run /flywheel-start to seed one via Step 10.55. and stop.
-
Run the scorer. Use the flywheel_memory MCP tool with operation: "refresh_learnings". The tool reads every docs/solutions/**/*.md (skipping _archive/), parses frontmatter via the schema in mcp-server/src/solution-doc-schema.ts, groups by (problem_type, component), and returns a RefreshReport with per-group decisions.
If the MCP tool is unavailable in the current harness, fall back to invoking the algorithm directly via tsx mcp-server/src/refresh-learnings.ts from a small wrapper — but prefer the MCP path so error envelopes flow through the standard hint channel (bead 478 contract).
-
Run rename detection (optional but recommended). Before classifying anything as stale, for each unique frontmatter.component value, run:
git log --follow --name-only --pretty=format: -- "**/<component>*"
Pass the result as the staleProbe callback when re-running the sweep with mutation intent. Without staleProbe, the algorithm refuses to emit Delete or Replace.
-
Render the report. Group output by classification:
Keep: N entries (singletons, no overlap)
Update: N groups (related but low overlap — flag for manual merge)
Consolidate: N groups → archive M entries, keep primary
Replace: N groups → archive M stale entries, keep fresh primary
Delete: N entries (REQUIRES CONFIRMATION below)
Unparseable: N files (frontmatter malformed — review by hand)
For each non-Keep decision, print:
- The primary path (the one being kept).
- Each archive candidate path with the per-dimension overlap score.
- The decision
reason.
-
AskUserQuestion gate (Consolidate / Replace). Ask:
Apply N Consolidate + M Replace decisions? Archives go to docs/solutions/_archive/.
- yes apply all
- review walk through one by one
- no skip mutation, report only
-
AskUserQuestion gate for Delete (mandatory, separate prompt). For EACH Delete candidate, ask explicitly:
Archive `<path>`? Component "<component>" appears stale (score: X.XX).
Files referenced: <files from body>
- archive move to docs/solutions/_archive/
- keep leave it (false positive — make a note)
- skip defer to next sweep
NEVER batch Delete confirmations. NEVER default to "archive".
-
Apply mutations. For each approved archive candidate:
mkdir -p docs/solutions/_archive/<category>
git mv docs/solutions/<category>/<file> docs/solutions/_archive/<category>/<file>
Stage all moves, then surface the diff for review before committing.
-
Report. Output:
Refresh sweep complete.
Archived: N entries → docs/solutions/_archive/
Consolidated: M groups (kept primaries)
Updated (manual review needed): K groups
Unparseable: P (review by hand)
Elapsed: X.X seconds
-
Shutdown agent-mail identity. deregister_agent and exit cleanly.