teleo-codex/ops/diagnostics/CONSOLIDATION-DIFF-LOG.md
2026-04-13 10:57:43 +02:00

141 lines
7.1 KiB
Markdown

# Diagnostics Consolidation Diff Log
# Branch: epimetheus/consolidate-infra
# Date: 2026-04-13
## Files with multiple copies — resolution
### alerting.py
- ROOT diagnostics/alerting.py (22320 bytes) — KEPT (newer: has _ALLOWED_DIM_EXPRS SQL injection protection, stricter dim_expr validation)
- ops/diagnostics/alerting.py (22039 bytes) — OVERWRITTEN (missing SQL injection guards)
- VPS /opt/teleo-eval/diagnostics/alerting.py (22039 bytes) — matches ops/ version, needs deploy
### alerting_routes.py
- ROOT diagnostics/alerting_routes.py (4216 bytes) — KEPT (newer: proper try/finally/conn.close, ValueError catch on hours param)
- ops/diagnostics/alerting_routes.py (4043 bytes) — OVERWRITTEN (missing error handling, missing conn.close)
- VPS /opt/teleo-eval/diagnostics/alerting_routes.py (4043 bytes) — matches ops/ version, needs deploy
### vitality.py
- ROOT diagnostics/vitality.py (25548 bytes) — KEPT (only copy in repo, larger than VPS)
- VPS /opt/teleo-eval/diagnostics/vitality.py (18539 bytes) — older version, needs deploy
- MOVED TO: ops/diagnostics/vitality.py
### vitality_routes.py
- ROOT diagnostics/vitality_routes.py (10824 bytes) — KEPT (only copy in repo, larger than VPS)
- VPS /opt/teleo-eval/diagnostics/vitality_routes.py (9729 bytes) — older version, needs deploy
- MOVED TO: ops/diagnostics/vitality_routes.py
## Files moved
| From | To | Reason |
|------|-----|--------|
| diagnostics/vitality.py | ops/diagnostics/vitality.py | Consolidate to canonical location |
| diagnostics/vitality_routes.py | ops/diagnostics/vitality_routes.py | Consolidate to canonical location |
| diagnostics/alerting.py | ops/diagnostics/alerting.py | Newer version overwrites older |
| diagnostics/alerting_routes.py | ops/diagnostics/alerting_routes.py | Newer version overwrites older |
## Root diagnostics/ after consolidation
- PATCH_INSTRUCTIONS.md — kept (documentation, not code)
- evolution.md — kept (documentation)
- weekly/2026-03-25-week3.md — kept (report)
- ops/sessions/*.json — kept (session data)
- alerting.py, alerting_routes.py REMOVED by this consolidation
- vitality.py, vitality_routes.py were already absent (moved in prior commit)
- No .py files remain in root diagnostics/
## VPS .bak files inventory (30+ files)
All in /opt/teleo-eval/diagnostics/. Git is the backup now. Safe to delete after consolidation verified.
## VPS deploy needed after merge
alerting.py, alerting_routes.py, vitality.py, vitality_routes.py — all local versions are newer than VPS.
---
## Root Patch Script Audit (Epimetheus's 7 patches)
### patch-prompt-version.py — APPLIED
- **Target:** db.py, merge.py, extract.py, extraction_prompt.py
- **What:** Schema v17 migration for prompt_version/pipeline_version columns, version stamping on PR discovery, feedback param for re-extraction
- **Status:** All 4 targets have changes. Schema is at v19 (includes this migration). merge.py stamps versions. extract.py has feedback param. extraction_prompt.py has previous_feedback.
- **Action:** SAFE TO DELETE
### tmp-patch-research-state.py — APPLIED
- **Target:** research-session.sh
- **What:** Integrates agent-state hooks (state_start_session, state_update_report, state_journal_append)
- **Status:** All hooks present in research-session.sh (STATE_LIB sourcing, HAS_STATE init, session lifecycle calls)
- **Action:** SAFE TO DELETE
### patch-dashboard-cost.py — STALE (superseded)
- **Target:** dashboard_routes.py
- **What:** Adds per-PR cost queries via audit_log (cost_map, triage_cost_map)
- **Status:** Cost tracking implemented differently in current codebase — uses `costs` table and p.cost_usd column, not audit_log aggregation. Patch logic abandoned in favor of newer approach.
- **Action:** SAFE TO DELETE (superseded by different implementation)
### patch-dashboard-prs-cost.py — STALE (superseded)
- **Target:** dashboard_prs.py
- **What:** Adds Cost column header, fmtCost() function, cost cell in row template
- **Status:** Cost KPI card exists (line 101) but implemented as card-based KPI, not table column. fmtCost() not present. Different UI approach than patch intended.
- **Action:** SAFE TO DELETE (superseded by card-based cost display)
### patch-cost-per-pr.py — NOT APPLIED
- **Target:** evaluate.py
- **What:** Adds _estimate_cost() helper function, cost instrumentation to audit events (haiku_triage, domain_rejected, approved, changes_requested)
- **Status:** _estimate_cost not found in evaluate.py. No cost fields in audit events. eval_checks.py has its own estimate_cost but for bot responses, not pipeline eval.
- **Action:** SAFE TO DELETE — eval_checks.py already has cost estimation for its own use case. The pipeline eval cost tracking was a different approach that was never completed.
### patch-dashboard-prs-version.py — NOT APPLIED
- **Target:** dashboard_prs.py
- **What:** Adds version badges (prompt_version, pipeline_version) to eval chain section and agent cell
- **Status:** No version badges in dashboard_prs.py. prompt_version/pipeline_version not displayed anywhere.
- **Action:** SAFE TO DELETE — version columns exist in schema (v17 migration) but UI display was never built. Low priority feature, can be re-implemented from schema when needed.
### patch-dashboard-version.py — NOT APPLIED
- **Target:** dashboard_routes.py, shared_ui.py
- **What:** Adds prompt_version/pipeline_version to SELECT query, version badges to shared_ui
- **Status:** Version fields not in SELECT. shared_ui.py exists but without version display.
- **Action:** SAFE TO DELETE — same reasoning as patch-dashboard-prs-version.py.
### Summary
| Script | Status | Action |
|--------|--------|--------|
| patch-prompt-version.py | APPLIED | Delete |
| tmp-patch-research-state.py | APPLIED | Delete |
| patch-dashboard-cost.py | STALE (superseded) | Delete |
| patch-dashboard-prs-cost.py | STALE (superseded) | Delete |
| patch-cost-per-pr.py | NOT APPLIED (abandoned) | Delete |
| patch-dashboard-prs-version.py | NOT APPLIED (low priority) | Delete |
| patch-dashboard-version.py | NOT APPLIED (low priority) | Delete |
All 7 safe to delete. 2 were applied, 2 were superseded by different implementations, 3 were never applied but the features either exist differently or are low priority.
---
## Root Orphan Files
### extract.py (693 lines)
- **Location:** Pentagon workspace root
- **Canonical:** teleo-codex/ops/pipeline-v2/openrouter-extract-v2.py (Apr 7+)
- **Status:** Older draft (Apr 1). Confirmed by Cory as safe to delete.
- **Action:** DELETE
### cascade.py (274 lines)
- **Location:** Pentagon workspace root
- **Canonical:** teleo-codex/ops/pipeline-v2/lib/cascade.py (10372 bytes, Apr 13)
- **Status:** Older draft. Confirmed by Cory as safe to delete.
- **Action:** DELETE
---
## Argus's Patch Scripts (in root diagnostics/)
8 patch scripts owned by Argus — audit responsibility is Argus's:
- diagnostics/compute_profile_patch.py
- diagnostics/dashboard_compute_patch.py
- diagnostics/patch_4page.py
- diagnostics/patch_dashboard_tokens.py
- diagnostics/patch_evaluate_costs.py
- diagnostics/patch_llm_cli.py
- diagnostics/patch_prs_page.py
- diagnostics/patch_vps_app.py
These remain in root diagnostics/ until Argus completes his audit.