Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
docs(health): document lazy_load_in_loop, current marker counts and a split_file id limit (#2815)
Raghav Chamadiyad81a2b9d78e7
diff --git a/README.md b/README.mdindex e634b5265..8b7dd633f 100644--- a/README.md+++ b/README.md@@ -163,7 +163,7 @@ toward the modules you and your agent ask about most, with no switch needed.| **Docs** | A wiki for every module and file, rebuilt incrementally with freshness and confidence scoring plus hybrid search || **Documentation drift** | Your own markdown checked against the tree: the claims each document makes, resolved against the graph, and the ones the code refutes || **Decisions** | Architectural rationale mined from five index-time sources plus human and agent capture, each claim traced to evidence |-| **Code health** | 51 deterministic detectors across defect risk, maintainability, and performance, followed by concrete refactoring plans |+| **Code health** | 53 deterministic detectors across defect risk, maintainability, and performance, followed by concrete refactoring plans |The structural wiki needs no model. Model-written prose is an optional upgrade, onepage or directory at a time. Six of the seven decision sources are deterministic too;@@ -314,7 +314,7 @@ every file, locates where the risk concentrates, and then names the specific fix<img src=".github/assets/health-loop.svg" alt="repowise code-health loop: deterministic markers fan into three signals, the graph and git history locate where risk concentrates, and refactoring intelligence emits concrete plans your agent executes" width="100%" /></div>-Every file is scored 1-10 by **51 deterministic detectors** (McCabe complexity, brain+Every file is scored 1-10 by **53 deterministic detectors** (McCabe complexity, brainmethods, LCOM4 cohesion, god classes, native Rabin-Karp clone detection, untestedhotspots, change entropy, prior-defect history and more), split into three lenses:**defect risk**, **maintainability**, and **performance**: static N+1 and I/O-in-loop@@ -851,7 +851,7 @@ August 2026. Unmarked rows are capability presence, not measurements.</sub>| | repowise | CodeScene ||---|---|---|| Self-hostable, open source | ✅ AGPL-3.0 | ⚠️ on-prem Docker, proprietary |-| Code health score (1-10) | ✅ 51 detectors, 26 scoring | ✅ 25-30 |+| Code health score (1-10) | ✅ 53 detectors, 26 scoring | ✅ 25-30 || Brain Method / LCOM4 / god class | ✅ | ✅ || **Defects found at a 20% review budget** *([measured](docs/BENCHMARKS.md#5-code-health-predicts-defects), 2,770 files)* | ✅ **0.173** | 0.074 || **Effort-aware ranking, Popt** *(measured, p=0.003)* | ✅ **0.607** | 0.462 |diff --git a/docs/BENCHMARKS.md b/docs/BENCHMARKS.mdindex 332df1fd4..bbbcc3e15 100644--- a/docs/BENCHMARKS.md+++ b/docs/BENCHMARKS.md@@ -555,7 +555,7 @@ one that reaches significance and the one to cite.Marker weights are **calibrated against a real defect corpus, not hand-tuned**:every file scored at a commit preceding the bug window so nothing leaks backward,and an L2-logistic fit with file size as an explicit control, so a marker only-earns weight for defect lift *beyond* being big. Only **26** of the 51 detectors+earns weight for defect lift *beyond* being big. Only **26** of the 53 detectorsare permitted to move the defect number, because that is the number carrying theseaccuracy claims.diff --git a/docs/architecture/code-health.md b/docs/architecture/code-health.mdindex 1113fa3e2..9c705b926 100644--- a/docs/architecture/code-health.md+++ b/docs/architecture/code-health.md@@ -298,14 +298,14 @@ returning a list of `BiomarkerResult`s.### The full roster-`biomarkers/registry.py` registers **51 detectors**; counting the three+`biomarkers/registry.py` registers **53 detectors**; counting the threegovernance findings written by the additive pass (`governance.py`) there-are **54 marker ids**. They divide by what each is permitted to affect:+are **56 marker ids**. They divide by what each is permitted to affect:| Group | Count | Scores into ||---|---:|---|-| Defect-scoring | 25 | `defect` (8 of them also `maintainability`) |-| Performance | 20 | `performance` only |+| Defect-scoring | 25 | `defect` (11 of them also `maintainability`) |+| Performance | 22 | `performance` only || SQL | 3 | `maintainability` only || Governance | 3 | nothing — the finding surfaces, the score is untouched || Advisory | 3 | nothing — measured by construction, kept out of impact-ranked lists unless requested |diff --git a/docs/layers/CODE_HEALTH.md b/docs/layers/CODE_HEALTH.mdindex 41f317366..0e24b2d54 100644--- a/docs/layers/CODE_HEALTH.md+++ b/docs/layers/CODE_HEALTH.md@@ -74,7 +74,7 @@ per-line blame index built for every file.## The markers, and what each is allowed to do-Repowise ships **51 registered detectors (54 marker ids)**, but only **25 are+Repowise ships **53 registered detectors (56 marker ids)**, but only **25 arepermitted to move the headline number**. That restriction is deliberate: thedefect score carries published accuracy claims, so only markers that earnedtheir weight against a bug corpus may affect it.@@ -82,7 +82,7 @@ their weight against a bug corpus may affect it.| Tier | Markers | What it may do ||---|---:|---|| **Defect-scoring** | **25** | Calibrated weights; moves the 1-10 score |-| **Performance** | **20** | Own pillar, own cap; never touches the defect score |+| **Performance** | **22** | Own pillar, own cap; never touches the defect score || **Maintainability-only (SQL)** | **3** | Maintainability only || **Governance** | **3** | Surfaces as a finding; never deducts || **Advisory** | **3** | Measured and reported; never deducts, and stays out of impact-ranked lists unless asked for |@@ -95,7 +95,7 @@ Nothing is inert, but "doesn't move the number" means three different things:matter for readability, but proved weak defect predictors under leakage-freecalibration, so they were demoted rather than deleted — and most of them earn**full weight in maintainability**, where they belong.-- **Advisory (19 of the 20 performance markers).** Sub-1.0 weights inside a+- **Advisory (21 of the 22 performance markers).** Sub-1.0 weights inside acategory capped at 2.0. Only `io_in_loop` carries full weight.- **Non-scoring (3 governance markers).** `ungoverned_hotspot`,`stale_governance` and `contradictory_decision` are written by an additive@@ -533,8 +533,9 @@ score.**Soundness limits, by design.** Performance is a static signal, so itunder-reports rather than over-reports. Dynamic dispatch, monkeypatching and-callbacks-as-values produce no call edge and are invisible; ORM lazy-load N+1-fires on attribute access with no visible call and is explicitly out of scope;+callbacks-as-values produce no call edge and are invisible; an ORM lazy load+fires on attribute access with no visible call, so it is seen only where+`lazy_load_in_loop` can type the loop's rows (below) and missed everywhere else;chains beyond three hops are not followed; an unmodelled library has noclassified sinks. We call this performance **risk**, never measured performance,and it never folds into the defect score.@@ -545,6 +546,13 @@ findings are usually batchable; filesystem ones often are not, since deleting Nfiles genuinely needs N unlinks. The finding still tells you where the timegoes.+Each opportunity carries one actionability state: `plan_ready` (a proven+strategy on a reliable call path), `advisory` (a strategy whose prerequisites+are not all proven), `investigate` (no supported strategy yet) or `expected`+(the repetition is real and there is nothing to change: a filesystem or+subprocess boundary, or a loop already walking chunks). The default queue+leaves `expected` out and still counts it.+A few more things keep the plans honest:- **Proven means the transformation, not the runtime.** Parallelizing awaits@@ -566,6 +574,16 @@ code, in the same function or one same-file helper. It is the one shape herethat is not a loop around I/O: the query runs once and returns too much, andthe fix is to select one row per key in the database.+**ORM lazy loads.** `lazy_load_in_loop` (Python, advisory, weight 0.4) flags a+lazy relationship read on each iteration of a loop over model rows, the N+1 an+attribute access hides. The loop's rows must resolve to one SQLAlchemy or+Django model through the cross-file model index, and the attribute must be a+lazy relation the producing query does not already eager-load. Async functions+are skipped, so SQLAlchemy coverage is sync only. Its plan is+`eager_load_relationship`, advisory. Measured at 81% precision on held-out+Django (47 of 58), it ranks in the queue but never leads the performance+directive.+Methodology and raw data:[perf-detection](https://github.com/repowise-dev/repowise-bench/tree/master/perf-detection).diff --git a/docs/layers/REFACTORING.md b/docs/layers/REFACTORING.mdindex 7a744e5f3..a6a750b00 100644--- a/docs/layers/REFACTORING.md+++ b/docs/layers/REFACTORING.md@@ -125,6 +125,14 @@ page cost the whole repository.`performance_fix` plans are excluded by construction: the performance layercomposes, ranks and owns the lifecycle of its own opportunities.+**Known limit: Split File ids across `init` and `update`.** A `split_file` plan+id can differ between a full index and an incremental update of the same+commit. The partition behind it comes from community detection over the file's+symbol graph, and modularity is sensitive to edge density, which the two paths+do not always build identically. The id is stable from one update to the next,+but not guaranteed equal between an `init` and an `update` at one commit, and+the opportunity id over it moves with it.+### Ordering, and `refactoring_view`The ranked head is honestly flat. On the dogfood index eight of the top ten