Skip to content

[Story] Simplify and de-duplicate the Python analysis backend #36

Done

Description

@aMonteSl

As a researcher who will add ML-based analyses on top of the backend,
I want the Python analyzers to be small, table-driven and free of duplicated windows,
so that adding a language or a metric is a data change, not a copy of a 500-line function.

Scope (ROADMAP W4-P P01–P20 and W5-44..49)

  • Reuse _empty_metrics, _add_graph_metrics, _iter_raw_targets; single get_file_size; single read in build_line_metrics; narrow exception types; CAPABILITIES read from the contract; relation count in one pass; dead locals.
  • Split analyze_file envelopes, scan bodies, main() dispatcher (within the source-text pins).
  • One shared directory-coordinator helper; rename sumaryFiles/ → summaryFiles/ (with its TS caller).
  • analyze_classes (536 lines, CCN 90) becomes table-driven behind a 21-arm golden test; analyze_dependencies and analyze_file_dependencies into helpers; _infer_class_owner characterized and refactored.

Do not touch

The XR field-schema contract (xr_field_schema.py ↔ xrFieldSchemaService.ts): XR_SCHEMA_VERSION, field order/labels, _text_field/_numeric_field syntax, complexity-band thresholds. Known behaviour quirks recorded in V1.2.1_STATUS.md (non-deterministic dependency resolution, class-owner inference) are pinned as they are and left for 1.3.0.

Acceptance criteria

  • Goldens identical before and after every refactor; npm run test:python and test:analysis green.
  • Python worst CCN 90 → ≤ 15; functions over CCN 15 ≤ 4; analyze_classes ≤ 160 lines; duplicated windows 14.7 % → ≤ 6 %.
  • ruff clean.

Activity

  1. self-assigned this
    on Nov 25, 2026
  2. added
    tfm
    user-story
    on Nov 25, 2026
  3. 9 remaining items

  4. aMonteSl commented on Nov 25, 2026

    @aMonteSl
    CollaboratorAuthor

    Done in #50, merged into v1.2.1 with CI green on Linux, macOS and Windows. Worst backend CCN 90 → 18, functions over CCN 15 10 → 1. F5 notes for #43 are in .claude/docs/v1.2.1/sessions/36-python-backend.md.


    Generated by Claude Code

  5. added
    area: python-backend
    stream: cleanup-refactor
    on Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: python-backendstream: cleanup-refactortfmuser-story

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions