Skip to content

[Draft] Quality layer for agents: dead code, complexity, impact scoring #58

Description

@lexasub

Status: stream of thoughts, might be nonsense. Draft for discussion, not a commitment.

Goal: let an agent understand project "quality" — not as an HTML report (that's for humans; an agent won't wait for it), but as structured verdicts through MCP tools: {dead_code: [...], complexity_hotspots: [...], impact: [{node, score, confidence, reason}]}.

Algorithms already studied (from competitors, all small — we write them in-house)

Dead code (CGC, ~40 lines):

  • Function with zero incoming CALLS from non-dependency callers
  • The real value is in exclusion heuristics: main/setup/run, dunders, test_*, names containing main/entry/application, decorator filter, is_synthetic for module-level frames

Cyclomatic complexity (CGC, ~20 lines, index-time):

  • 1 + count(node.type ∈ {if, for, while, except, with, boolean_operator, list_comprehension, generator_expression, case_clause})
  • Stored as a property on Function at indexing time

Impact scoring (CodeSlicer — the best algorithm of the bunch):

  • chain_confidence = geometric mean of edge confidences along the path (doesn't let a long path collapse the way naive multiplication does)
  • impact_score = criticality(kind) × chain_confidence × decay^distance
  • Status thresholds: ≥0.90 Confirmed / ≥0.75 High probability / ≥0.55 Needs verification / Ambiguous

Coupling/Cohesion: Ca/Ce, Instability, LCOM/CAM — computed from our own edge graph

Principle

Everything essential — in-house, in one package. Do not shell out to competitor binaries (archscope etc.): the market is winner-take-all; a user will install one tool — if raged depends on someone else's binary, the user will drop raged and install that binary directly.

The foundation already exists: #56 (global symbol table) + confidence on edges.


Relates to: #35 (cross-repo support), #24 (multi-index for third-party libs), #20 (advanced semantic search), #31 (multi-project configs)

Metadata

Metadata

Assignees

No one assigned

    Labels

    draftDraft / stream of thoughts — not a commitmentresearch

    Projects

    Status
    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions