02 · System Architecture · code map · verified against the 2026-07 source

The code map: the directory is the layering

The architecture page is the dataflow view; this page is the code view. The directory structure embodies the layer contract directly, and every layer keeps an explicit extension slot: add a language without touching the rules, add a rule without touching the languages, add a tool without touching the ranking.

                     source files (Python / C / C++ · .ts/.tsx already detected)
                              │
src/cupid/
├─ language.py           suffix → language; the one suffix→language table in the system
│
├─ frontends/          ── LANGUAGE TIER ──  the only home of language syntax
│   ├─ python.py             stdlib ast
│   ├─ c.py · cpp.py · _cfamily.py   tree-sitter, one shared C-family walker
│   ├─ clang_index.py        libclang precision tier (sees through macros; degrades without a DB)
│   └─ «typescript.py»      ◄ new-language slot (grammar already a dependency, enum registered)
│                              │ produces ▼
├─ ir/                 ── THE CONTRACT ──  the language-neutral fact model
│   └─ module.py · sites.py · capabilities.py (frontends declare / signals require)
│                              │ consumed by ▼
├─ signals/            ── CHECK TIER ──  capability-gated rules · 6 families
│   ├─ base.py               Signal protocol + registry()  ◄ new rules register here
│   ├─ complexity · performance · correctness · memory · null_safety · quality
│   └─ _evidence.py · config.py   shared percentile evidence · threshold config
│
├─ graph/              ── ARCHITECTURE TIER ──  cross-file
│   ├─ import_graph.py       Martin Ca/Ce · instability · graded cycles (soft only if the soft edges close it) · intentional-shape dispositions (facade / composition root / core value type)
│   ├─ call_graph.py         hub functions · duplicate-function · dead statics · C3 method resolution
│   └─ test_graph.py ★      static test linkage (graded confidence; never runs customer tests)
│
├─ code_context.py ★       the context classifier: the layer behind sanitizer-do-not-split / variant downgrades
├─ path_context.py ★       path role weights (production 1.0 · test .45 · fixture .1)
├─ vcs_risk.py ★            bus-factor governance lens (one rename-following git pass, commit metadata only)
│
├─ tools/              ── EXTERNAL ──  semgrep · clang-tidy · CSA · infer → second opinions
│   └─ findings.py           the one Finding schema + three-axis RankAxes  ◄ new tool adapters converge here
│
├─ norms/               baseline.py (15 reference repos · 42,021 functions) · profile.py
├─ report/              analyze · overview · architecture ★ · examples · render_html (single-file output)
├─ serve.py · serve_settings.py ★   stdlib web front door + threshold settings panel
├─ corpus/ · vcs.py · compile_db.py    repo access · blobless git history · compile DB
│
└─ dataset/            ── EVIDENCE ENGINE (offline · zero LLM) ──
    ├─ scan.py · snapshot.py               per-version snapshots (git archive × tag · ≤60 tags, resumable)
    ├─ trajectory.py · labels.py · release_transitions.py   cross-version tracking · fix-commit mining
    ├─ confirm_refactors.py · removability.py ★   deterministic refactor confirmation → stuck / confirmed / rising
    └─ multivariate ★ · evidence · derisk · opportunity_derisk ★ · charts · methodology   AUC validation · vetoing bad directions

loop/ (repo root)        rubric.md · evals/cases.jsonl (60 frozen cases) · overrides.jsonl · BACKLOG.md   the self-continuing adversarial verification loop
◄ slot: the three extension points the product grows through by addition ★ new: modules landed since the previous architecture map ✦ click any module line: it is circled and the source-verified engineering details open layer dependencies are one-way: frontend → IR → signals / graph → report, enforced by lint and tests
← Back to the architecture Scan a repository