---
phase: "05"
plan: "01"
name: "Remove Stale Scripts"
type: "cleanup"
autonomous: true
wave: 1
depends_on: []
requirements: [CLEAN-01, CLEAN-02, CLEAN-03]
---

# Phase 5 Plan 1: Remove Stale Scripts

## Objective

Remove all stale scripts from `scripts/` directory identified via cross-reference audit. These are research pattern analysis scripts (all patterns invalidated per adversarial audit), one-off benchmarks, and superseded maintenance utilities. Total: ~79 files, ~35K LOC.

## Context

- @docs/research/adversarial-audit-methodology.md (100% of patterns invalidated)
- @docs/research/pattern-research-summary.md (research conclusions preserved)
- @scripts/CLAUDE.md (production script inventory)

## Tasks

### Task 1: Remove invalidated research pattern scripts

type="auto"

Remove 70 research/pattern analysis scripts whose conclusions are fully documented in `docs/research/`. All pattern research was invalidated by the adversarial audit framework. These scripts have zero production references (not in mise tasks, systemd units, or Python imports).

**Files to remove (70):**

- Pattern analysis: `*_polars.py` research scripts, `regime_analysis*.py`, `pattern_*.py`
- TDA research: `tda_*.py` (14 scripts)
- Duration/correlation: `duration_*.py`, `cross_*.py`, `combined_*.py`
- Hurst research: `hurst_*.py` (4 scripts)
- Multi-factor: `multifactor_*.py`, `multithreshold_*.py`, `multi_threshold_*.py`
- Position sizing: `position_sizing_*.py`, `psr_mintrl_*.py`
- Direction/momentum: `direction_*.py`, `run_length_momentum_analysis.py`
- Other research: `coarse_to_fine_cascade.py`, `trend_filter_analysis.py`, `oos_validation_polars.py`

**Keep (in mise tasks):** `run_length_momentum_multi_symbol.py`, `run_length_momentum_wfo.py`

Done criteria:

- [ ] All 70 research scripts removed from `scripts/`
- [ ] git status shows only deletions
- [ ] No broken imports in remaining scripts

### Task 2: Remove stale benchmark and one-off scripts

type="auto"

Remove 9 additional stale scripts:

- 6 benchmarks: `benchmark_apen_vs_pent.py`, `benchmark_arrow_export.py`, `benchmark_cache_pipeline.py`, `benchmark_comprehensive.py`, `benchmark_reset_index_optimization.py`, `benchmark_smallvec_optimization.py`
- 3 superseded: `cleanup_extra_symbols.py`, `microstructure_simple.py`, `analyze_flash_crash.py`

Done criteria:

- [ ] All 9 scripts removed
- [ ] Cross-referenced to confirm no mise/systemd/import dependencies

### Task 3: Update scripts/CLAUDE.md and verify no broken references

type="auto"

Update `scripts/CLAUDE.md` to remove references to deleted scripts. Verify no broken doc references across CLAUDE.md network. Update `mise/tasks/research.toml` if needed.

Done criteria:

- [ ] scripts/CLAUDE.md updated
- [ ] No broken script references in any CLAUDE.md file
- [ ] `git grep` for deleted filenames returns zero hits in non-planning dirs

## Verification

1. No deleted filename appears in any `.py`, `.toml`, `.md` file (outside `.planning/` and `CHANGELOG.md`)
2. All remaining scripts in `scripts/` are referenced by at least one of: mise task, systemd unit, CLAUDE.md, or production Python import

## Success Criteria

- 79 stale scripts removed (~35K LOC)
- Zero broken references
- Production scripts unaffected
