# Repository Health — Tech Debt & Organisational Changes

## How to use this doc

Work through items one at a time, test that the core workflow still runs after each change,
then commit. The order below is designed so early changes don't break later ones.

---

## Pending Items

### ORG-2 · Separate Pine Script files from Python files in `strategies/`

**Why:** `strategies/` currently contains a mix of active Python files (`.py`), active Pine Script
strategy file (`.pine`), historical Pine baselines, and parameter JSON files. Makes it hard to
find the active strategy at a glance.

**Proposed structure:**

```
strategies/
  *.py                  (Python — unchanged)
  params/               (Parameter files — already done)
  pine/
    strategy_activation_scores.pine    (ACTIVE — single source of truth)
    archive/
      baseline_v36.pine
      baseline_2025-09-12_pre_m2-refactor.pine
      MainStrategy.pine
      strategy_activation_scores_debug.pine
      RSI-Gaussian Channel Strategy v3.0.pine
```

**Test:** No Python imports reference `.pine` files — safe to restructure.

---

### ORG-3 · Move `indicators/` and `libraries/` under a single `pine/` top-level directory

**Why:** Both contain Pine Script files exclusively. A single `pine/indicators/` and
`pine/libraries/` structure is cleaner than two separate top-level dirs.

**Test:** No Python code imports from these directories. Safe to restructure.

---

### TD-4 · `pine-def.txt` in repo root

**What:** `pine-def.txt` is a Pine Script reference/scratch file sitting in the root.

**Action:** Move to `docs/` or delete if no longer needed.

---

### ORG-6 · Add README.md directory structure section

**Why:** New contributors need a map of the repo. Add a directory tree to the root README.md
after restructuring stabilises.

---

## Completed (for reference)

| Item | Done | Notes |
|------|------|-------|
| TD-0: sweep_database.db exceeded GitHub 100MB limit | 2026-03-18 | Deleted pre-2026-03-17 rows (118MB → 41MB); DB now gitignored |
| TD-1: Duplicate tools/optimize_strategy.py | 2026-03-18 | Deleted stale tools/ copy |
| TD-1.5: optimization_log_*.txt written to root | 2026-03-18 | Now written to output/ |
| TD-2: No __init__.py in strategies/ and tools/ | 2026-03-18 | Added empty __init__.py to both |
| TD-3: TRAIN_END / SCORE_START hardcoded in multiple files | 2026-03-18 | config.py created; all scripts import from it |
| TD-5: optimization_log.txt in root | 2026-03-18 | Logger now writes to output/ |
| ORG-1: auto_optimize_loop.py in root | 2026-03-18 | Moved to tools/; all callers updated |
| ORG-4: Stale docs/ | 2026-03-18 | docs/strategyMain/ and docs/strategyActivation/legacy/ moved to docs/archive/ |
| ORG-5: results/ and output/ not gitignored | 2026-03-18 | results/sweeps/, results/reports/, results/sweep_database.db, output/ all gitignored |
