Skip to content

U130 Phase 2 — Static Code Reviewer check on editor buffer #39

Description

@LosAICode

Parent: #211
Plan: U130-CMS-Editor-Diagnostics-Plan.md § Phase 2
Depends on: Phase 1 (#211 subtask)
Effort: ~3h

Scope

Run `CODE_REVIEWER_SYSTEM_PROMPT` against the current editor buffer and return findings.

  • New module: `modules/services/magnus_diagnostics.py`
  • Function: `run_code_reviewer_on_buffer(html: str, script: str, project_id: str) -> list[Finding]`
    • Composes buffer with `<script>` wrapper mirroring U129 render-time injection
    • Calls `_call_llm` with `CODE_REVIEWER_SYSTEM_PROMPT` at `code_reviewer` model role
    • Parses returned JSON checklist into `Finding` dataclass: `id`, `severity`, `title`, `detail`, `fix_hint`
  • Cache: in-memory LRU keyed on SHA256(html+script), 5-min TTL (env: `MAGNUS_DIAGNOSTICS_CACHE_TTL`)
  • Credits: deduct via `_calculate_magnus_credits(module='magnus_code_reviewer')`
  • Failure: return a single warning Finding (`"Code reviewer unavailable"`) — never 500

Acceptance

POSTing the pre-U129 TaskMaster `/tasks` HTML returns findings including:

Re-posting identical buffer within 5 min = zero LLM cost (cache hit).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions