Skip to content

arch: D-series — 5 more route groups, codec_dashboard 3618→2921#162

Merged
AVADSA25 merged 2 commits into
mainfrom
dashboard-route-extraction-2
May 30, 2026
Merged

arch: D-series — 5 more route groups, codec_dashboard 3618→2921#162
AVADSA25 merged 2 commits into
mainfrom
dashboard-route-extraction-2

Conversation

@AVADSA25
Copy link
Copy Markdown
Owner

Summary

Continuation of route extraction (PR #161 deferrals). Pytest: 2148 → 2172 (+24 regression tests, 0 regressions).

What landed

Phase Group Endpoints Target
D1 /api/qchat/* 5 (sessions, save, search, delete) routes/qchat.py + qchat_db helper
D2 /api/vibe/* 4 (sessions, save, delete) routes/vibe.py + vibe_db helper
D3 /api/schedules/* 6 incl /run with background _execute_task routes/schedules.py
D4 /api/prompts/* 3 + 3 helper functions routes/prompts.py
D5 media 6 (webcam x3, screenshot, clipboard x2) routes/media.py

Not included: /api/upload + /api/upload_image (250 LOC with B1 fence markers + size cap + path safety) — kept in codec_dashboard.py to keep the security-hardening review surface tight. Future PR.

LOC trajectory

Test plan

  • pytest tests/test_route_extractions_d.py24/24 new tests pass
  • pytest tests/test_a12_invariant.py — passes (media.py allowlisted for vision POST)
  • pytest tests/test_dashboard_llm.py — passes (count assertion 5 → 4 after media move)
  • pytest tests/test_chat_helpers.py — 5/5 pass (chat_completion lazy-imports _load_prompt_overrides from routes.prompts)
  • pytest tests/ -k "qchat or vibe or schedule or prompt or webcam or clipboard or screenshot" — 50+ pass
  • pytest tests/ (full) — 2172 passed, 83 skipped, 0 failed in 1m24s

After merge

cd ~/codec-repo && git pull
pm2 restart codec-dashboard codec-mcp-http

🤖 Generated with Claude Code

Mikarina13 and others added 2 commits May 30, 2026 13:51
…2921

Continuation of route extraction (PR #161 deferrals).
Pytest: 2148 → 2172 (+24 regression tests, 0 regressions).

ROUTES EXTRACTED

D1 / SR-42: /api/qchat/*       → routes/qchat.py
  5 endpoints (sessions/{sid}/save/{sid}/search) + QCHAT_DB + qchat_db()
  helper. SQLite WAL + busy_timeout + auto-migration of user_id column.

D2 / SR-43: /api/vibe/*        → routes/vibe.py
  4 endpoints (sessions/session/save/delete) + VIBE_DB + vibe_db() helper.
  Same lifecycle pattern as qchat.

D3 / SR-44: /api/schedules/*   → routes/schedules.py
  6 endpoints including the /run endpoint with its background-thread
  _execute_task() (LLM report → Google Doc → notification flow).
  PUT endpoint uses codec_jsonstore.atomic_write_json (re-audit medium
  fix preserved).

D4 / SR-45: /api/prompts/*     → routes/prompts.py
  3 endpoints + the 3 helper functions (_load_prompt_overrides,
  _save_prompt_overrides, _get_all_prompts). codec_dashboard's
  chat_completion handler now lazy-imports _load_prompt_overrides
  from routes.prompts to avoid a module-load-time cycle.

D5 / SR-46: media endpoints    → routes/media.py
  6 endpoints (webcam x3, screenshot, clipboard x2). Vision-proxy POST
  in webcam_capture added to test_a12_invariant._ALLOWLIST (legitimate
  vision site pending A-11 cleanup).

NOT INCLUDED IN D5
- /api/upload and /api/upload_image (250 LOC with B1 fence markers +
  size cap + path safety) — kept in codec_dashboard.py to keep the
  security-hardening review surface tight. Future PR.

LOC SHIFT

  codec_dashboard.py: 3,618 → 2,921 LOC (-697, -19.3%)
                     (started at 3,912 before PR #160)

NEW TESTS

  tests/test_route_extractions_d.py — 24 tests across 5 phases.
  Each phase parametrizes endpoint-registered checks + source-side
  invariants (db helpers in module, atomic-write in schedules, lazy
  prompt import in dashboard). Global LOC floor tightened to < 3,000.

UPDATED SOURCE-SCAN TESTS

- tests/test_a12_invariant.py: routes/media.py added to allowlist
  (vision POST in webcam_capture, A-11 pending)
- tests/test_dashboard_llm.py: /chat/completions count assertion
  bumped 5 → 4 (vision POST moved out with media)

Full pytest: 2172 passed, 83 skipped (env-dependent), 0 failed (1m24s).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…b/vibe_db

PR #162 CI smoke ruff gate failed:
- F401: sqlite3, uuid, pathlib.Path, _notif_lock, _load_notifications,
  _write_notifications, _append_schedule_run_log — all callers moved to
  routes/qchat, routes/vibe, routes/schedules
- F821: 4 call sites in codec_dashboard.py still referenced qchat_db()
  and vibe_db() — added lazy `from routes.qchat import qchat_db` (etc.)
  inside each function body that uses them

No behavior change. Full pytest still 2172 passed.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@AVADSA25 AVADSA25 merged commit fd1b316 into main May 30, 2026
1 check passed
AVADSA25 added a commit that referenced this pull request May 30, 2026
* arch: E-series — 3 more route groups, codec_dashboard 2921→2530

Continuation of dashboard route extraction (PR #162 follow-up).
Pytest: 2172 → 2185 (+13 regression tests, 0 regressions).

EXTRACTIONS

E1 / SR-47: Sparkle update endpoints → routes/update.py
  2 endpoints (/api/update/check, /api/update/download). Both proxy
  through codec_update which handles Ed25519 signature verification.

E2 / SR-48: public health + manifest + metrics + status → routes/health.py
  5 endpoints (/api/health, /health, /api/status, /manifest.json, /metrics).
  HealthResponse Pydantic model moved with them. /api/services/status
  stays in codec_dashboard.py because it reads _bg_status / _bg_tasks
  globals owned by the startup hooks.

E4 / SR-49: upload + upload_image + save_file → routes/upload.py
  3 security-hardened endpoints bundled because they share defensive
  scaffolding:
    - _UPLOAD_MAX_BYTES + 3-layer size cap (B1 / SR-15)
    - _fence_user_document marker helper (B1 / SR-16)
    - _SAVE_FILE_BLOCKED_* + _save_file_is_safe (A1 / SR-8 mirror of
      PR-1C file_write blocklist)

DEFERRED (next round)
  - E3 routes/config.py — /api/config GET/PUT with 22-rule validation
    matrix + sensitive field masking. Medium-risk; standalone PR.
  - E5 routes/vibe_exec.py — /api/preview, /preview_frame, /api/run_code
    (Vibe IDE exec surface; touches subprocess + is_dangerous check)
  - E6 routes/misc.py — /api/tts, /api/response, /api/web_search,
    /api/command, /api/cdp/status

LOC SHIFT

  codec_dashboard.py: 2,921 → 2,530 LOC (-391, -13.4%)
                     (3,912 → 2,530 cumulative = -1,382, -35.3%)

UPDATED TESTS

- tests/test_top10_action_list.py: `_save_file_is_safe` import points
  to routes.upload (was codec_dashboard).
- tests/test_a12_invariant.py: routes/upload.py allowlisted for vision
  POST (A-11 pending, same as routes/media.py).
- tests/test_dashboard_llm.py: /chat/completions count assertion
  bumped from 4 → 3 (upload_image vision POST moved out).
- tests/test_dead_code_3g.py: HealthResponse now lives at
  routes.health.HealthResponse (E2 extraction).
- tests/test_route_extractions_e.py NEW: 13 tests parametrized across
  3 phases — endpoint-registered + source-side invariants
  (HealthResponse exported, B1 helpers in routes/upload).

NEW INVARIANT FLOOR

  test_dashboard_loc_below_2700 — codec_dashboard.py < 2700 LOC.
  Tightens as future extractions land.

Full pytest: 2185 passed, 83 skipped (env-dependent), 0 failed (1m20s).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix(lint): drop unused pydantic imports (BaseModel/Field) — moved with HealthResponse

---------

Co-authored-by: Mickael Farina <farina.mickael@gmail.com>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants