feat(cleanup): opt-in auto_drop rules for re-read files and retried errors

Draft
NE
9d ago
+338-29

Approved issue: #952 (awaiting design-approved; draft until then)

Adds two opt-in auto_drop rules that drop tool results the transcript shows are superseded:

  • auto_drop.reread: drop a read once a later read of the same file covers it (whole file, or same offset and limit).
  • auto_drop.retried_errors: drop a failed call once a later call of the same tool succeeds. User rejections are kept.

Both default off. They run in the routine lane of applyHeuristicCleanup, so they never originate a cache bust; protected tags, protected_tools and user-answer results are kept, and drops stay recoverable with ctx_expand. No age-based rule (see removed-config-keys.test.ts).

Harness coverage (required)

  • OpenCode 1: covered (hook.ts → transform.ts → transform-postprocess-phase.ts → heuristic-cleanup.ts)
  • OpenCode 2: covered (v2/hooks/transform-features.ts)
  • Pi: NOT covered — heuristic-cleanup-pi.ts needs its own port; will add after design approval
  • OMP: NOT covered — same Pi path
  • Rust module: NOT covered — will add after design approval

Other surfaces

  • assets/magic-context.schema.json and the docs config reference regenerated (build-schema.ts, build-config-docs.ts).
  • Dashboard: auto_drop listed in OMITTED_BY_DESIGN (raw JSONC only).

Checks (Windows 11, bun 1.3.12)

  • tsc --noEmit (plugin): pass
  • biome lint on changed plugin files: pass
  • bun test src/hooks/magic-context/auto-drop.test.ts src/config/schema scripts/build-schema.test.ts: 46 pass, 0 fail
  • bun test src/components/ConfigEditor/config-parity.test.ts (dashboard): 7 pass, 0 fail
  • bun test src/config and src/v2/hooks: the failures I see are the same set as on an untouched v0.49.67 checkout (Windows path/EBUSY issues); no new failures from this change.

Summary by cubic

Adds opt-in auto_drop rules that drop tool results the transcript shows are superseded. auto_drop.reread drops a read once a later read of the same file covers it (whole file or same offset and limit); auto_drop.retried_errors drops a failed call once a later call of the same tool succeeds, keeping user rejections. Both run in the routine lane, so they never originate a cache bust, and protected tags, protected_tools, and user-answer results are exempted; dropped results stay recoverable with ctx_expand. Both rules default off.

Not covered yet: Pi and OMP harnesses, which need their own port after design approval. The dashboard form lists the key as raw JSONC only; schema and config docs are regenerated.