arch: 5 route groups + crews/ split — codec_dashboard 3912→3618, codec_agents 1808→1128#161
Merged
Merged
Conversation
…c_agents 1808→1128 Continuation of B6 architecture refactor (PR #160 deferrals). Pytest: 2128 → 2148 (+20 regression tests, 0 regressions). DASHBOARD ROUTE GROUPS (C1..C5) Followed the routes/notifications.py pattern from PR #160 P3. Each group is a self-contained APIRouter included in codec_dashboard. C1 / SR-36: /api/approvals/* → routes/approvals.py 4 endpoints (list, count, allow, deny). All state already lived in routes/_shared (_pending_approvals, _approval_lock, _evict_expired_approvals). test_bounded_dicts source-scan updated to look at routes/approvals.py. C2 / SR-37: /api/heartbeat/* → routes/heartbeat.py 4 endpoints (config GET/PUT, alerts GET/PUT). Pure CONFIG_PATH JSON reads, no shared mutex needed. C3 / SR-38: /api/cortex/* → routes/cortex.py 4 endpoints (health, skills, logs/{svc}, restart/{svc}). The skills endpoint reads from codec_dispatch.registry (A-4 invariant preserved). test_skill_loader_unification source-scan updated. C4 / SR-39: /api/audit, /api/audit/stream, /api/audit/stats → routes/audit.py 3 read-only endpoints. AUDIT_LOG read from routes/_shared. C5 / SR-40: /api/observer/buffer → routes/observer.py 1 debug-only privileged endpoint. Emits OBSERVER_BUFFER_INSPECTED on every read (audit trail preserved). CREWS SPLIT (C6) C6 / SR-41: 12 crew builders → codec_crews.py ~700 LOC of declarative wiring moved out of codec_agents.py. codec_agents now imports and re-exports the 12 builders so CREW_REGISTRY (which references them by name) and any external `from codec_agents import deep_research_crew` import keep working. Single-file extraction this time; future per-crew files at crews/{name}.py is a separate refactor. LOC SHIFT codec_dashboard.py: 3,912 → 3,618 LOC (-294, -7.5%) codec_agents.py: 1,808 → 1,128 LOC (-680, -37.6%) NEW TESTS tests/test_route_extractions.py — 20 tests across 6 phases. Each phase pins (a) endpoint registered on the FastAPI app via the router include, (b) source-side invariants (e.g. cortex_skills uses codec_dispatch.registry; observer emits OBSERVER_BUFFER_INSPECTED). Plus a global LOC floor (codec_dashboard.py < 3,700) that tightens as future route extractions land. UPDATED SOURCE-SCAN TESTS - tests/test_bounded_dicts.py: scans routes/approvals.py for `_evict_expired_approvals(` (was: codec_dashboard.py) - tests/test_skill_loader_unification.py: scans routes/cortex.py for `from codec_dispatch import registry` (was: codec_dashboard.py) - tests/test_security.py: scans codec_crews.py for the 12 crew builders + their allowed_tools= invariant (was: codec_agents.py) Full pytest: 2148 passed, 83 skipped (env-dependent), 0 failed (1m34s). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ogger PR #161 CI smoke ruff gate failed on 7 unused imports: - codec_crews.py: typing.List/Optional unused (carried over from copy); added missing `log = logging.getLogger("codec_crews")` for the function-local log.warning at meeting_summarizer_crew - codec_dashboard.py: subprocess imported at top-level was shadowed by function-local re-imports throughout (screenshot/pbpaste/pbcopy/ pdftotext/cmd_runner); dropped the unused top-level import - codec_dashboard.py: AUDIT_LOG no longer needed at module level (audit endpoints moved to routes/audit.py in C4) - codec_dashboard.py: _pending_approvals / _approval_lock / _evict_expired_approvals no longer needed at module level (approval endpoints moved to routes/approvals.py in C1) No behavior change. Full pytest still 2148 passed, 0 failed. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
6 tasks
AVADSA25
added a commit
that referenced
this pull request
May 30, 2026
* arch: D-series — 5 more route groups extracted, codec_dashboard 3618→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> * fix(lint): ruff F401/F821 — drop unused imports + lazy-import qchat_db/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> --------- Co-authored-by: Mickael Farina <farina.mickael@gmail.com> Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Continuation of B6 architecture refactor (PR #160 deferrals). Pytest: 2128 → 2148 (+20 regression tests, 0 regressions).
What landed
5 dashboard route groups extracted (C1..C5)
Followed the proven
routes/notifications.pypattern from PR #160 Phase 3./api/approvals/*routes/approvals.py/api/heartbeat/*routes/heartbeat.py/api/cortex/*routes/cortex.py/api/audit/*routes/audit.py/api/observer/bufferroutes/observer.py12 crew builders →
codec_crews.py(C6)~700 LOC of declarative wiring moved out of
codec_agents.py.codec_agentsnow imports and re-exports the 12 builders soCREW_REGISTRY(which references them by name) and any externalfrom codec_agents import deep_research_crewimport keep working. Single-file extraction this time; future per-crew files atcrews/{name}.pyis a separate refactor.LOC shift
codec_dashboard.py: 3,912 → 3,618 LOC (-294, -7.5%)codec_agents.py: 1,808 → 1,128 LOC (-680, -37.6%)Test plan
pytest tests/test_route_extractions.py— 20/20 new tests pass, parametrized across 6 phasespytest tests/ -k "approval or heartbeat or cortex or audit or observer or notification"— 237/237 passpytest tests/ -k "crew or agent"— 236/236 passpytest tests/test_bounded_dicts.py— updated source-scan, 9/9 passpytest tests/test_skill_loader_unification.py— updated source-scan, all passpytest tests/test_security.py— crew floor test updated to scancodec_crews.py, all passpytest tests/(full) — 2148 passed, 83 skipped, 0 failed in 1m34sAfter merge
🤖 Generated with Claude Code