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: make the layer pages scannable and move method detail to architecture docs (#3777)
Raghav Chamadiyaf94702531942
diff --git a/docs/architecture/README.md b/docs/architecture/README.mdindex a82e90bbe..12bcadc65 100644--- a/docs/architecture/README.md+++ b/docs/architecture/README.md@@ -12,6 +12,7 @@ curious; you don't need them to *use* repowise (start with| [change-risk.md](change-risk.md) | The change-risk model: features, offline calibration and why the score is reported as a size statistic, PR structural impact, and the public risk-scale inventory || [bug-history.md](bug-history.md) | Bug-fix history internals: fix-shape classification, the `fix_events` table, the bug-magnet rollup, and the inducing-commit (SZZ) work that was measured and not shipped || [decisions.md](decisions.md) | Decision capture internals: the source registry, evidence verification, confidence, currency, session mining and hook delivery |+| [security.md](security.md) | Security signals internals: per-kind matching rules, placeholder skipping, baseline keys, and the JS/TS precision checks || [test-intelligence.md](test-intelligence.md) | The inferred test tier: call and import walks, their measured precision and recall, the resolution-origin filter, and why nothing is stored || [language-support.md](language-support.md) | The language pipeline internals and the step-by-step recipe for adding a new language || [forges.md](forges.md) | Git host support: the forges package, its invariants, and the recipes for adding a host or a CI system |diff --git a/docs/architecture/bug-history.md b/docs/architecture/bug-history.mdindex f7a7f382b..98bdf900d 100644--- a/docs/architecture/bug-history.md+++ b/docs/architecture/bug-history.md@@ -55,6 +55,19 @@ Change-risk `fix_history` uses its own 365-day half-lifepushes a fresh fix into the future west of UTC and makes its age vanish. Thefix lives once, upstream of every consumer.+## Measurements++- **Fix-shape classifier.** 98.3% agreement with hand labels on 240 fix+ commits: 60/60 on repowise, flask and django each, 56/60 on zod. The four+ misses are all "a code-extension file changed but no product code did".+- **Per-symbol attribution.** Inside the indexed symbol range for 97.4% of+ django's 2,179 events, 96.3% of flask's 125, 96.8% of repowise's 1,145 and+ 81.8% of zod's 337. Old fixes drift because symbol spans are current; zod's+ misses are test files with few named symbols.+- **Filtering and the health score.** Re-running the defect calibration with+ filtered counts moves pooled AUC by +0.0002, so the health score does not+ change with filtering.+## Inducing-commit attribution (SZZ): measured, not shippedA refactor-aware SZZ pass was built: blame each fix's replaced lines backdiff --git a/docs/architecture/change-risk.md b/docs/architecture/change-risk.mdindex b749d3a34..6ee32a21c 100644--- a/docs/architecture/change-risk.md+++ b/docs/architecture/change-risk.md@@ -22,6 +22,9 @@ commit) the model reads as risk-raising. `nf`, `nd` and `ns` have smallnegative coefficients from collinearity with `la`; they stay in the logit asfit and are hidden as drivers because the explanation would contradict itself.+Drivers are stated relative to the model's baseline commit (10.5 lines added,+1.7 files), not to the repository being scored.+Constants are hard-coded in `_CONSTANTS` in `model.py`. Only constants ship.## Calibration@@ -121,6 +124,29 @@ authority) on every payload. The reference tier (corpus, formula, components,the full `risk_scales` dictionary) never varies, so MCP returns it only for`include=["scales"]`; the CLI `--format json` output carries it always.+## Baseline sample++`repowise risk` samples recent commits live; the web UI reads the indexed+commit history. One walk is reused for every change scored against the same+anchor and filters in a process, so a long-running MCP server pays for it once.++## Independent changes grouping++A changed file is grouped only when it has a file node in the index, is not a+test file, and is in a language whose resolver can emit an import edge. Docs,+config, data and test files are never grouped and never bridge two groups.++## Branch overlap scan++`repowise overlap` scans local and remote branches, newest committer date+first, up to `--limit`. It drops the base, the change's own ref, refs pointing+at either tip, and branches stacked on or under this one. For each remaining+branch it takes `git diff --name-only base...branch` (what that branch did+since it forked) and intersects it with this change's files. Noise paths+(workflows, lockfiles, generated, vendored and localization files) and+dependency manifests (`package.json`, `pyproject.toml`, `go.mod`, `Cargo.toml`+and similar) are removed from both sides first.+## RecalibratingThe calibration script lives in the separate benchmark repositorydiff --git a/docs/architecture/code-health.md b/docs/architecture/code-health.mdindex 2f49c6851..265a642d7 100644--- a/docs/architecture/code-health.md+++ b/docs/architecture/code-health.md@@ -711,6 +711,16 @@ The findings list uses the same rule: worth-doing findings lead and the rest carpriority there; a performance opportunity is unless production code runs it overgrowing data.+#### Fix first steps++A finding's first step can borrow a stored refactoring plan. A refactoring item is+`later` when the plan of any of its steps still leaves a function above the+break-up bar; a finding whose first step borrows such a plan keeps its tier, and+the step says the plan alone leaves the function above the bar. An Extract Method+step finds its lines by the text they start and end with, as the plan does, since+line numbers move with the first edit; when that text also appears elsewhere in+the file, the step says to keep the edit inside its function.+### 6.4 Performance opportunities (`perf/`)User guide: [PERFORMANCE.md](../layers/PERFORMANCE.md).diff --git a/docs/architecture/decisions.md b/docs/architecture/decisions.mdindex bbe5e8dec..ec7520a5e 100644--- a/docs/architecture/decisions.md+++ b/docs/architecture/decisions.md@@ -101,14 +101,15 @@ and always read `active`. Only `active` and `needs_review` govern.## Supersession and conflict detection-`evolution.detect_supersessions_and_conflicts` used embedding similarity to-scope candidate pairs, then opposing verbs or reversal phrases, with a model-tiebreaker. It is disabled (`SEMANTIC_SUPERSESSION_ENABLED = False`): among-records from one repository, high cosine similarity was the baseline, not-evidence of a shared topic. It was the only writer of `supersedes` and-`conflicts_with` edges. The diff-driven pass on `update` (`reverts.py`) still-marks a decision a commit reversed, and `deprecate --superseded-by` records the-successor on the record.+`evolution.detect_supersessions_and_conflicts` scopes candidate pairs by+embedding similarity, then looks for opposing verbs or reversal phrases, with a+model tiebreaker. It is disabled (`SEMANTIC_SUPERSESSION_ENABLED = False`):+among records from one repository, high cosine similarity is the baseline, not+evidence of a shared topic. It is the only writer of `supersedes` and+`conflicts_with` edges, so those edges are not inferred. Lineage comes from the+diff-driven pass on `update` (`reverts.py`), which marks a decision a commit+reversed, and from `deprecate --superseded-by`, which records the successor on+the record.## Session mining@@ -132,6 +133,9 @@ Three stages:record is written as a `proposed` candidate with `source: session`. Repeatobservations add evidence rows.+The `session` source ships off. In a measured run on the Repowise repository it produced 139+records, none with a context and 115 with neither context nor rationale.+Staging lives in `.repowise/sessions/sessions.db`. Transcripts never leave themachine; only distilled decision text is stored. The same switch gatesinjected-decision feedback and update-time hook-efficacy replay.@@ -148,6 +152,40 @@ and name only paths the cited turns' tools touched. Bundled claims are flaggedfor splitting. Unsent prose stays queued oldest-first; a provider failurerequeues and retries on the next two updates.+## Tracked manifest++`repowise decision export` writes accepted decisions to+`.repowise/decisions.yaml`; `repowise decision import` reads them back:++```yaml+# Accepted architectural decisions for this repository.+version: 1+decisions:+- id: 228ddce7b28c4f93a8f1e8976dd1ba4c+ title: Avoid feature gating+ decision: Do not add feature gating.+ reason: Feature flags outlived their purpose here+ scope:+ - packages/core+ currency: active+ source: session+ accepted_at: '2026-09-01T13:04:22+00:00'+ accepted_by: Jane Doe+```++- The file is ordered by id with a fixed field order, so a one-line change is+ a one-line diff.+- `export` un-ignores this one file if a `.repowise/` rule in `.gitignore`+ hides it.+- On `import` the file wins: new entries are created and accepted with the+ file as accepter (signer kind `import`), changed entries are re-accepted, and+ entries missing a reason or scope are skipped.+- Records the file does not hold are left alone on `import`, since a missing+ line may be a bad merge.+- An empty store never overwrites a non-empty committed file, and a file+ written by a newer Repowise is refused.+- Candidates and episodes stay out of the file.+## Review state and lanesCandidates carry a review row (`open`, `accepted`, `merged`, `needs_split`,@@ -165,7 +203,9 @@ all-time and a queue a store predates is reported absent.## Hook delivery`augment_cmd/decision_inject.py`: session start scores records against the-working set expanded one hop, multiplies relevance by confidence and freshness,+session's likely working set (dirty and staged files, branch changes, the+previous session's edits, branch-name tokens) expanded one hop through imports+and co-change partners, multiplies relevance by confidence and freshness,and injects under `_TOKEN_CAP = 400`, with candidates in a separate sectionunder `_CANDIDATE_TOKEN_CAP = 120`. Edit-time notices go through`decision_node_links`, once per session per decision. Injected ids are recordeddiff --git a/docs/architecture/graph-algorithms.md b/docs/architecture/graph-algorithms.mdindex fe7520a53..af3e31b21 100644--- a/docs/architecture/graph-algorithms.md+++ b/docs/architecture/graph-algorithms.md@@ -41,6 +41,98 @@ This is the raw material. Every algorithm below operates on the file subgraph un---+## Call edges: capture, resolution and measurement++The algorithms below trust the symbol-level edges they walk, so this section+covers how a call edge is made and how its accuracy is measured. The resolver+internals (strategy seam, origin table, receiver typing) are in+[language-support.md](language-support.md#call-resolution).++### Why every edge carries an origin++For `user.save()` a tool has three options: emit nothing (a dead-code pass then+offers to delete `save`), guess by picking one of the repo's methods named+`save` (with `User.save`, `Draft.save` and `Session.save` that is a two in three+chance of the wrong file), or work out what `user` is and resolve `save` on that+type. A graph that presents a guess the same way as a certainty produces wrong+arrows that look like answers, and a wrong arrow is worse than a missing one.+repowise resolves by type where it can, falls back to a name match where it+must, and labels which one happened on every edge.++### Two stages that fail differently++**Capture** notices that a call was written at all. It is a tree-sitter query+per language listing the source shapes that count as a call site:++```scheme+; Go method call: obj.Method(args)+(call_expression+ function: (selector_expression+ operand: (identifier) @call.receiver+ field: (field_identifier) @call.target+ )+ arguments: (argument_list) @call.arguments+) @call.site+```++A shape that no query matches is absent from the graph, not low confidence or+unresolved, and nothing downstream can recover it. Go lists a plain call, a+method call, a package-qualified call, a chained call, and a function passed as+an argument; the last is captured as a reference, since passing a handler is+not invoking it.++**Resolution** turns a captured name and receiver (`save` on `repo` in+`repo.save(draft)`) into one declaration in one file. This is where the 39+resolution origins live.++A missed capture is silent, since nothing internal knows the call existed, so+capture is measured against an outside answer key (a compiler). A bad+resolution is visible, because the origin names the strategy that produced it,+so a wrong class of edge is found and fixed once for every call site that+strategy touched. At the bottom of the ladder the resolver declines to guess,+trading recall for precision.++### Why `references` and `framework_binds` are separate edge types++A handler in a dispatch table is never called anywhere a parser can see.+Counting that as "no use" would report whole registration layers as safe to+delete, so a handle to a function is a `references` edge. `framework_binds`+separates the opposite case: a fixture nobody calls and a collaborator nobody+constructs are both used, by the container, but an inferred wiring hop is not+source, and rendering it as a call would put it into an execution flow as+though someone had written it.++### How accuracy is measured++- **Against a compiler, Go and TypeScript.** Seven cells over five+ repositories, 37,853 compiler edges from the Go team's RTA call graph and+ `tsc`'s own resolution, compared across five tools. Precision is 0.976 to+ 0.995. No tool that finds as much of the call graph gets more of it right in+ any cell; two tools post higher precision in some cells by drawing much+ smaller graphs. Recall leads in three of the seven cells. Most misses are+ dynamic dispatch, which no tool in the comparison resolves without emitting+ several wrong edges for each right one.+- **Against compiler indexes for more languages.** Java reads 0.725 to 0.781+ precision against javac across three repositories (0.781 on jsoup). C on git,+ a repository held out from all tuning, reads 0.979 precision at 0.83 recall.+ C#, C++, Rust and Python (against jedi, a static analyser) are in the same+ table.+- **Hand-graded across nine languages.** 280 call edges per tool, 560 in all,+ each read with its imports and enclosing scope open: 240 of 280 correct for+ repowise (85.7%) against 164 of 280 for CodeGraph 1.5.0 (58.6%), with+ disjoint intervals. Errors concentrate in Rust, C++ and Java.++Unused methods are not reported for any language because method-level precision+does not hold up under this measurement, and reporting them would mean+recommending wrong deletions. `global_unique` stays at 0.50 because a labelled+guess serves reachability better than a missing edge.++Tables, intervals and pre-registrations are in+[BENCHMARKS.md](../BENCHMARKS.md#accuracy-by-language) and+[repowise-bench/graph](https://github.com/repowise-dev/repowise-bench/tree/master/graph).++---+## 1. PageRank### What question does it answer?diff --git a/docs/architecture/language-support.md b/docs/architecture/language-support.mdindex 83918900c..35d02f605 100644--- a/docs/architecture/language-support.md+++ b/docs/architecture/language-support.md@@ -32,7 +32,9 @@ new language needs one only when it hits the same kind of wall.- [Call resolution](#call-resolution) · [the strategy seam](#the-per-language-strategy-seam) · [resolution origins](#resolution-origins) · [receiver typing](#receiver-typing) · [inherited dispatch](#inherited-dispatch)- [The edge vocabulary](#the-edge-vocabulary)- [Multi-language files (the SFC pattern)](#multi-language-files-the-sfc-pattern)+- [Extensions and import resolution](#extensions-and-import-resolution)- [Per-language mechanics](#per-language-mechanics) · [Elixir](#elixir) · [F#](#f) · [Objective-C](#objective-c) · [GDScript / Godot](#gdscript--godot) · [VB.NET](#vbnet) · [QML](#qml) · [Flutter widget trees](#flutter-widget-trees)+- [Known gaps per language](#known-gaps-per-language)- [Optional language-specific passes](#optional-language-specific-passes)- [The three code-health dialect registries](#the-three-code-health-dialect-registries) · [test-quality markers per language](#test-quality-markers-per-language)- [Workspace contract extraction](#workspace-contract-extraction)@@ -693,6 +695,41 @@ The same steps would fit Astro components; only the locator changes.---+## Extensions and import resolution++The file extensions each Full and Good language claims, and the build files and+conventions its import resolver reads. Good-tier languages resolve the+dependency surface their syntax supports.++| Tier | Language | Extensions | Import resolution |+|------|----------|-----------|-------------------|+| Full | **Python** | `.py` `.pyi` | Source-root-aware module index (`src/`, monorepo `packages/*/src`, PEP 420), `__init__.py` re-export barrels |+| Full | **TypeScript** | `.ts` `.tsx` `.mts` `.cts` | ESM and `require()`, tsconfig path aliases, npm/yarn/pnpm workspaces, `export * from` barrels |+| Full | **JavaScript** | `.js` `.jsx` `.mjs` `.cjs` | `import` and `require()`, including CommonJS re-export shapes |+| Full | **Svelte** | `.svelte` | The TS/JS resolver plus SvelteKit's `$lib` and `#` subpath imports |+| Full | **Vue** | `.vue` | The TS/JS resolver plus config aliases, directory-index components, router `import()` specifiers |+| Full | **Java** | `.java` | Maven and Gradle reactor discovery, JPMS, `import static`, package fan-out |+| Full | **Kotlin** | `.kt` `.kts` | Shares the JVM index with Java, so resolution is cross-language |+| Full | **Go** | `.go` | Multi-module `go.mod` discovery; a package import fans out to every file in the package |+| Full | **Rust** | `.rs` | `use crate::` / `super::` / `self::` with `Cargo.toml` |+| Full | **C++** | `.cpp` `.cc` `.cxx` `.h` `.hh` `.hpp` `.hxx` `.inl` `.ipp` `.tpp` `.inc` | `#include` via `compile_commands.json` plus CMake and Bazel header maps, header/implementation pairing |+| Full | **C#** | `.cs` | `using`, `global using` and aliases via `.csproj` / `.sln`, MSBuild project graph, `partial` class linking |+| Full | **Scala** | `.scala` | The shared JVM index, with SBT and Mill build parsing as fallback |+| Full | **Ruby** | `.rb` | `require` / `require_relative` with `$LOAD_PATH` probing, Gemfile externals, Rails / Zeitwerk autoloading |+| Good | **C** | `.c` | `#include` via `compile_commands.json` (shares the C++ grammar) |+| Good | **Swift** | `.swift` | SPM `Package.swift` targets, intra-module type references, `@main` entry points |+| Good | **PHP** | `.php` | `use` declarations through PSR-4 from every `composer.json`, same-namespace and fully qualified class references |+| Good | **Dart** | `.dart` | `import` / `export` / `part`, `package:` via every `pubspec.yaml` |+| Good | **Object Pascal** | `.pas` `.pp` `.dpr` `.dpk` `.lpr` | `uses` clauses via unit-name to file-stem match; project files as entry points |+| Good | **COBOL** | `.cbl` `.cob` `.cobol` `.cpy` | Literal `CALL` and `PERFORM` targets; dynamic calls and `COPY` stay silent |+| Good | **GDScript** | `.gd` | `preload` / `load` / `extends "res://..."` from the nearest `project.godot` |+| Good | **VB.NET** | `.vb` | `Imports` through the same MSBuild project index C# uses |+| Good | **Elixir** | `.ex` `.exs` | `alias` / `import` / `require` / `use` against a `defmodule` index, Mix path convention as fallback |+| Good | **F#** | `.fs` `.fsx` `.fsi` | `open` against a declared-name index plus the fsproj compile order; `.fsi` files contribute imports only |+| Good | **Objective-C** | `.m` `.mm` `.h` | `#import` / `#include` through the header-stem index |++---+## Per-language mechanicsThe resolution shapes that are specific to one language and are not derivable@@ -922,6 +959,28 @@ both settles a name two files declare and refuses a class that merely shadows aframework widget. A class reached through an `export` barrel is missed, whichcosts an edge rather than inventing one.+### Known gaps per language++- **Template dialects are invisible.** Django/Jinja, Go templates, ERB,+ Handlebars, Blade and Thymeleaf parse as HTML and yield nothing.+- **Svelte and Vue binding forms are skipped.** `{#each x as y}` and+ `v-for="x in xs"` are not resolved, and the unused-export pass is off for+ both, since props are set by the parent as markup attributes.+- **Object Pascal type kinds collapse** to `kind="class"`, and its `extends`+ vs `implements` split follows the `I`-prefix naming convention.+- **COBOL is COBOL-85 shaped.** `COPY` does not create an edge; dynamic program+ names and dialect extensions stay silent.+- **Razor has no import edges**, because every directive is blanked by the+ projection.+- **GDScript string dispatch is unresolved**, and a script without `class_name`+ gets no class symbol.+- **VB.NET leaves a few constructs unparsed**, XML and tuple literals among them.+- **C has no performance risk support.** Extract Method reuses the C+++ def/use dialect; C carries none of the C++-only nodes, so the same plan+ fires for both.+- **Scala import resolution is partial**, and ScalaTest's infix DSL+ (`x shouldBe y`) is not counted as an assertion.+---## Optional language-specific passesdiff --git a/docs/architecture/refactoring.md b/docs/architecture/refactoring.mdindex 106fc020e..c96cc5153 100644--- a/docs/architecture/refactoring.md+++ b/docs/architecture/refactoring.md@@ -24,6 +24,105 @@ pass (`HealthAnalyzer` in `analysis/health/engine.py`) on data already computed.The methods follow published work: Fokaefs-Tsantalis class splitting, Bavotafeature-envy distance, MFAS for cycles, Newman modularity for decomposition.+## Extract Method gates++`extract_method.py` offers a span only when it can show the extraction keeps+behavior. Spans it cannot prove are dropped, so it under-reports by design.++- Behavior preservation: every returned value is written on every path, no+ state is carried across loop iterations, no local a closure shares crosses+ the span's edge, and there is no write to a `global` name without its+ declaration. A staged plan also leaves out a stage whose inputs or outputs+ depend on a `switch` or `match` arm's write.+- Error handling: a span or stage never changes which handler catches an error+ or what it sees. It is not offered when it would split a `try` from its+ handlers, write a value a handler or `finally` reads, or move a Go `defer`.+- Returns: a value the span writes is returned whenever any path can carry it+ to a later read, including past a later write in an `else` arm or a `try`+ body that may raise first.+- Refusals: spans too small to matter and spans that would carry the original+ finding into the helper are skipped. A component whose branching is mostly+ in its markup gets no extraction, and neither does a function that only+ fills one value field by field behind independent guards (summary rows,+ query parameters, optional settings), since splitting it simplifies neither+ half. The finding records why in `details.extract_method_refused`.+- Size: a span must remove at least two decision points, hold at least 8 code+ lines, cover at most 60% of the function's lines, and not start on the+ docstring. When the best span misses one of these, only a span that does not+ overlap it is offered, never a slightly smaller copy of it. Estimated gain+ never exceeds the share of decision points removed.+- Async: a span that awaits (Python `await`, `async with`, `async for`;+ TypeScript and JavaScript `await`, `for await`; Rust `.await`; C+++ `co_await`) carries `needs_async: true`: the helper is async and its call is+ awaited. An await inside a nested function, closure or Rust `async` block+ does not count. When the function holding the span is not declared async (a+ C++ coroutine), the step is a judgment call with reason+ `async_helper_unexpressible`.+- Receivers: the plan says under `new_symbol` whether the helper must be a+ method on the same object (the span uses `self`, `this` or a Go receiver)+ and which of the object's fields the span assigns directly. A span that uses+ `this` outside a class, or writes fields of a Go value receiver, is a+ judgment call (`receiver_unbound`, `receiver_copy_written`).+- Signatures: the plan writes out the new helper's header and the line that+ replaces the span, in the file's language, with parameter types where the+ code declares them. In TypeScript, an optional parameter is written+ `T | undefined`, and a type an earlier guard narrows (`if (!x) return;`) is+ written narrowed, or a note asks for the narrowed type. Plan detail shows+ both with a copy button. Where the code names no type, the text reads+ `<type>`.+- Staged plans: a Python, TypeScript or JavaScript function too complex for one+ helper can get several helpers the function calls in order, each small+ enough to leave the finding behind. Plan detail lists them as steps, with a+ shared parameter object when many values pass between them, and the plan's+ estimated gain is the whole drop in the function's complexity. The plan's+ own span, header and call are its first stage. When the work sits inside one+ loop or `if`, the stages are cut from its body and the function keeps the+ loop and calls them each time round. A stage running across several+ labelled sections is named after them. When a function moves between a+ single helper and a staged plan, or its stages change, the plan gets a new+ id.+- Anchors: every step, and every stage of a staged plan, shows the exact first+ and last lines of its span, so an agent finds it by its text after earlier+ stages have moved its lines; the line numbers are only a hint. The plan asks+ for each stage as a direct edit to the file, one at a time, never a script+ that rewrites it. A staged plan whose stages cannot all be pinned down that+ way falls back to a single helper, and a function with neither gets no plan.+- Batches: a staged plan with more than five stages comes in batches of at+ most five. Each batch names the tests to run before the next one, and a+ batch whose tests fail stops the plan there. The code runs after every+ batch, so a failure points at the stages just applied.+- Unfinished work: a plan that would still leave the function, or one of its+ new helpers, above the break-up bar says so, for example "leaves+ build_from_json at CCN 83, still above the break-up bar; more stages+ needed". The plan and its file's opportunity rank after the work that+ finishes the job. The mark is set when the repository is indexed, so a plan+ ranked live is not marked.++## Break Cycle imports++Cycles are found over runtime imports only. An import under+`if TYPE_CHECKING:` or a TypeScript `import type` / `typeof import()` is+type-only, and an import inside a function body is deferred (it runs on first+call, the usual way to break a cycle on purpose). Neither closes a cycle. Only+a plain `TYPE_CHECKING` or `module.TYPE_CHECKING` condition counts; a negated+or aliased flag is read as a runtime import.++## Test commands++A plan's test command runs from the owner of the tests it names:++| Language | Command |+|----------|---------|+| JavaScript, TypeScript | From the package whose `package.json` declares its `test` script (`npm --prefix ui-tui test -- src/a.test.ts`). A test no package can run gets no command. |+| Go | `go test ./internal/cart` |+| Rust | `cargo test -p parser` |+| Java, Kotlin | `./mvnw -pl core -am test` or `./gradlew :app:test` |+| Ruby | `bundle exec rspec` or `bundle exec rake test` |+| C# | `dotnet test` on the test project that holds it (`dotnet test tests/Shop.Tests/Shop.Tests.csproj`), narrowed with `--filter` to the named tests, or on the repository's solution when no single test project does. With neither, no command. |++A test whose build file or runner the repository does not have gets no+command.+## Plan shape`RefactoringSuggestion` in `models.py` is the source of truth for every field@@ -69,6 +168,13 @@ through `services/refactoring_health.py`, which MCP `get_health` and the REST roshare, so the two surfaces cannot disagree. Scope `fix_first` takes its eligibilityfrom the Fix-first builder itself.+## Counting++Every plan is counted once: the rollup's `plans_total` is the steps, plus+`evidence_total`, plus `unattached_plans_total` (plans in no opportunity, such+as a file whose only plan is a cycle). The plan list's `structural_total`+leaves Break Cycle out, matching the opportunities; `by_type` still counts it.+## REST routes (local server)```textdiff --git a/docs/architecture/security.md b/docs/architecture/security.mdnew file mode 100644index 000000000..0ea5ab67c--- /dev/null+++ b/docs/architecture/security.md@@ -0,0 +1,45 @@+# Security signals internals++Contributor reference for the security layer. For what users see and how to read+findings, start with [layers/SECURITY.md](../layers/SECURITY.md). The scanner+lives in `packages/core/src/repowise/core/analysis/security_scan.py` and the CI+gate in `packages/core/src/repowise/core/analysis/security_gate.py`.++## Matching rules++Each kind matches over one view of the source. The view decides whether a+comment or a quoted string can fire it.++| Rule | Detail |+|---|---|+| Python `eval` and `exec` | Found by walking the AST, so a match is a real call. Other languages use source with comments and strings masked out |+| Text describing code | `pickle_loads`, `os_system`, `subprocess_shell_true` and `new_function_call` match over masked source, so a comment naming the call does not fire. The keyword secret kinds need the name to be code, so `password = "..."` in a doctest does not fire |+| Vendor key shapes | Match anywhere, comments included: a real key in a comment is still a leak |+| Prose, generated and vendored files | `.md`, `.mdx`, `.rst`, `.txt` and `.adoc` files are scanned for the secret kinds only. So are generated and vendored files (a minified or webpack bundle included) and `.d.ts` declarations, since nobody in the repository wrote their calls |+| JavaScript kinds | `unsafe_inner_html`, `template_literal_sql`, `new_function_call`, `reject_unauthorized_false` and `public_env_secret` do not fire in Python files, where such a line can only be quoted text |+| Raw source kinds | `concat_sql`, `template_literal_sql` and `unsafe_inner_html` run on raw source, comments included |+| Code-start kinds | `fstring_sql` and `weak_hash` need their match to start in code, so a comment or a fixture string quoting one does not fire |++### Placeholders++A keyword secret value is skipped when it is elided or templated (`...`,+`<your key>`, `xxx`, `example`, `placeholder`, `dummy`, `fake`, `redacted`,+`changeme`, `{{ }}`, `${}`), shorter than eight characters, a short single-case+word, or a snake_case key name. A value a vendor kind already reports is not+reported twice.++## Baseline keys++A baseline entry is keyed on file, kind and masked line, so it survives line+shifts. Vendor shapes also key on a one-way hash of the matched text, so a new key+on an identical line is a new finding. Keyword kinds carry no hash, because a+short password could be guessed back from its hash.++## Precision checks++The five JS/TS kinds are hand-checked on a 17-repository, 1,109-file corpus, with+their rules at their current strictness: `unsafe_inner_html` fires 4 times,+`template_literal_sql` hits are 2 of 2 real, `public_env_secret` hits are 3 of 3+real, and `new_function_call` and `reject_unauthorized_false` do not fire.+`unsafe_inner_html` ships at `med` because it cannot tell a name pointing at a+pinned constant from a dynamic value.diff --git a/docs/architecture/test-intelligence.md b/docs/architecture/test-intelligence.mdindex 8f9ffbd8f..da61c21b1 100644--- a/docs/architecture/test-intelligence.md+++ b/docs/architecture/test-intelligence.md@@ -12,9 +12,9 @@ walks), `analysis/test_selection.py` (runner arguments for `impacted-tests`),## Why a graph signalThe measured map (`test_coverage`) is filled only by a coverage report. Most-repositories never ingest one, so without a second signal `tests_to_run` was-empty, `impacted_tests` said "run the full suite", and `untested_hotspot` fell-back to matching filenames.+repositories never ingest one, so without a second signal `tests_to_run` would+be empty, `impacted_tests` would say "run the full suite", and `untested_hotspot`+would fall back to matching filenames.Filename matching fails both ways. On this repository, five of the six worstbug-magnet files have no test named for them, while the graph names the tests@@ -140,5 +140,97 @@ per run, and caches it. The per-change walk reads the same edge tablemisses, the commit measured) are kept as history,`COVERAGE_HISTORY_RETENTION = 50`. A local index created before the historytable changed keeps one record per repository until rebuilt.-- Path matching needs more than the basename when the report names a- directory: `other/pkg/utils.py` never maps to `src/utils.py`.++## Report formats and discovery++The parser is chosen by sniffing the file unless `--format` or `coverage.format`+names one:++| Format | Detected by |+|--------|-------------|+| LCOV | `TN:` / `SF:` / `DA:` style lines |+| Cobertura XML | `<coverage` plus `<packages` or `line-rate` |+| Clover XML | `<coverage` plus `<project` |+| JaCoCo XML | The JaCoCo doctype, or a `<report` root |+| Go coverprofile | Leading `mode:` line |+| coverage.py `.coverage` | SQLite file |+| Normalized JSON (`repowise-coverage-v1`) | Leading `{` plus `repowise-coverage` or `line_coverage_pct` |++With no path, `coverage add` looks for `coverage/lcov.info`, `lcov.info`,+`coverage.lcov`, `coverage.xml`, `**/cobertura.xml`, `**/clover.xml`,+`target/llvm-cov/**/*.lcov`, `coverage.out`, `cover.out`,+`**/target/site/jacoco*/jacoco.xml`, `build/reports/jacoco/**/*.xml`, a+repo-root `.coverage`, and a few more. `coverage.artifacts` overrides the+globs. Multiple reports merge: covered and coverable lines are each unioned.++## Report path matching++Report paths are matched to indexed files by exact path, then by the longest+matching tail. A tie is reported as ambiguous, never guessed. A relative path+is tried under the report's own directory first, so+`packages/web/coverage/lcov.info` naming `src/index.ts` maps to+`packages/web/src/index.ts`. Cobertura paths are joined to each `<source>`+root. Matching needs more than the basename when the report names a directory:+`other/pkg/utils.py` never maps to `src/utils.py`. When a whole report comes+back unmatched, `coverage.strip_prefix` trims the absolute prefix the runner+wrote.++## Test wiring edges++The graph carries test wiring no import states, which test selection reads:++- Runner setup files (`setupFiles`, `globalSetup` and the like) link to the+ tests their config runs.+- A helper a test starts by a path relative to itself links to that test.+- A `conftest.py` links to the files pytest collects.+- Each fixture request links the test to the fixture, so a change a conftest+ reaches only through its imports selects the tests whose fixtures use it,+ plus one import check.++## Nearest tests per function++Each index keeps, for every function, the few test functions nearest it in the+call graph. Refactoring plans quote them as runnable selectors in place of+whole test files; they are inferred like the rest of the graph map. A function+with no resolved caller, or in a language whose tests cannot be told apart by+name (such as Java's `@Test` or Rust's `#[test]`), is left unknown instead of+called untested.++## The `impacted_tests` payload++`get_change_risk(revspec=...)` returns:++```json+{+ "status": "selected",+ "run_all": false,+ "reasons": [],+ "basis": "measured",+ "map_present": true,+ "tests_to_run": ["tests/test_auth.py::test_login", "..."],+ "why": {"tests/test_auth.py": "src/auth.py changed (coverage)"},+ "total": 23,+ "truncated": true,+ "line_coverage": {+ "untested_changes": [{"source_file": "...", "uncovered_lines": [...]}],+ "stale_test_candidates": [...],+ "covered": [...],+ "no_coverage_data": [...]+ },+ "summary": "23 test(s) to run for this change (9 of 412 test files); showing first 10; the rest can be skipped."+}+```++## Coverage re-ingest hook++With `hooks.coverage_reingest: true`, the hook fires after the agent runs a+whole test suite: `pytest`, `go test ./...`, `npm test`, `cargo test`,+`mvn test`, `./gradlew test` and similar. It re-ingests any watched report+newer than the last ingest, in the background, and says so in one transcript+line. It does not act:++- in a repository that has never ingested coverage;+- on a run that targets some tests (a path, `::`, `-k`, `-run`, `--filter`,+ `-p` and the like);+- on a `.coverage` database alone;+- on a report only a `**` glob finds.diff --git a/docs/layers/BUG_HISTORY.md b/docs/layers/BUG_HISTORY.mdindex 262b0b05b..e7da8ed7a 100644--- a/docs/layers/BUG_HISTORY.md+++ b/docs/layers/BUG_HISTORY.md@@ -125,33 +125,30 @@ never more. To turn hooks off, see [HOOKS.md](../agent/HOOKS.md).## Accuracy and limits-- **Fix-shape classifier**: agrees with hand labels on 98.3% of 240 fix commits- across repowise, flask, django and zod (60/60 on the first three, 56/60 on- zod). The four misses are all "a code-extension file changed but no product- code did".-- **Noise removed varies by repo**: 58.7% of keyword-matched fix commits on- flask are not code fixes; 7.0% on repowise.-- **Per-symbol attribution** lands inside the indexed symbol range for 97.4% of- django's 2,179 events, 96.3% of flask's 125, 96.8% of repowise's 1,145 and- 81.8% of zod's 337. Old fixes drift (symbol spans are current); zod's misses- are test files with few named symbols.-- **No inducing commit is named.** File-level SZZ reached 74.5% top-candidate- precision on 53 hand-judged rows, below the 80% bar for putting a commit and- an author on screen. Counts and recency ship; blame does not.+| Check | Result |+|---|---|+| Fix-shape classifier against hand labels | 98.3% of 240 fix commits across repowise, flask, django and zod |+| Keyword-matched fix commits that are not code fixes | 58.7% on flask, 7.0% on repowise |+| Per-symbol attribution inside the indexed symbol range | 96.3% to 97.4% of events on django, flask and repowise; 81.8% on zod |++- **No inducing commit is named.** Counts and recency ship; blame for the+ commit that caused a bug does not, because its precision is below the bar+ for naming a commit and an author on screen.- **Recall is keyword bound.** A fix whose subject does not say so isinvisible. The shape filter improves precision only.- **The window is fixed.** A file fixed heavily two years ago and quiet sincereads as clean.-- **The health score does not change with filtering**: re-running the defect- calibration with filtered counts moved pooled AUC by +0.0002.+- **Per-symbol counts drift on old fixes**, because symbol spans come from the+ current tree.- **In a workspace**, the hook's lookup does not filter by repository; wheremember repos lack their own `.repowise`, it falls silent.-- **Whether the hook notice changes agent behaviour has not been measured.**+- **The hook notice's effect on agent behaviour is unmeasured.**Benchmark method for the health model that reads these counts:[docs/BENCHMARKS.md](../BENCHMARKS.md#code-health-predicts-defects). The-measured SZZ attempt is written up in-[architecture/bug-history.md](../architecture/bug-history.md).+classifier misses, the inducing-commit measurement and the effect of filtering+on the health score are in+[architecture/bug-history.md](../architecture/bug-history.md#measurements).## Where it shows updiff --git a/docs/layers/CHANGE_RISK.md b/docs/layers/CHANGE_RISK.mdindex 29299b13c..73274cfb4 100644--- a/docs/layers/CHANGE_RISK.md+++ b/docs/layers/CHANGE_RISK.md@@ -1,20 +1,18 @@# Change risk (`repowise risk`)-`repowise risk` reports on a **change**: a commit, a `base..head` range, or-your uncommitted work. It tells you two things. Where the change sits in the-repository's own distribution of recent commits, by size and spread. And-whether the files it touches have broken before. It scores changes; for scores-on files, use `repowise health`.--It needs no LLM key, no network and no index: it runs on `git` plus constants-learned offline. A typical run is one `git log` walk and a sample of recent-commits. Branch overlap and the independent-changes report use the index when-there is one.--Lead with `risk_percentile`: the change's rank among recent commits by diff-size and spread, not a bug predictor. `fix_history` is separate evidence about-where the change lands. The 0-10 score is a supporting measure of diff size and-spread, not a probability (see [Accuracy and limits](#accuracy-and-limits)).+`repowise risk` reports on a **change**: a commit, a `base..head` range, or your+uncommitted work. It tells you where the change sits in the repository's own+distribution of recent commits, by size and spread, and whether the files it touches+have broken before. For scores on files, use `repowise health`.++It needs no LLM key, no network and no index: it runs on `git` plus constants learned+offline. A typical run is one `git log` walk and a sample of recent commits. Branch+overlap and the independent-changes report use the index when there is one.++Lead with `risk_percentile`: the change's rank among recent commits by diff size and+spread, not a bug predictor. `fix_history` is separate evidence about where the change+lands. The 0-10 score is a supporting measure of diff size and spread, not a probability+(see [Accuracy and limits](#accuracy-and-limits)).## Quick start@@ -24,35 +22,27 @@ repowise risk HEAD # the last commitrepowise risk main..HEAD # a branch or PR range, as one changerepowise risk main..HEAD --ext .py # count only .py filesrepowise risk main..HEAD -x 'tests/' -x '*.spec.ts'-repowise risk --format jsonrepowise overlap # other branches editing the same files```-From an agent:--```python-get_change_risk() # the working tree or HEAD-get_change_risk(revspec="main..HEAD")-get_risk(changed_files=["src/api/routes.ts", "src/middleware/cors.ts"]) # PR mode-```--`get_change_risk` leads with what the change newly made worse: it compares the-health of both revisions and keeps diff shape as supporting context. In the-dashboard, the Commits page leads its table with review priority.+From an agent: `get_change_risk()` scores the working tree or HEAD,+`get_change_risk(revspec="main..HEAD")` a range, and+`get_risk(changed_files=["src/api/routes.ts", "src/middleware/cors.ts"])` runs PR mode.+`get_change_risk` leads with what the change newly made worse: it compares the health of+both revisions and keeps diff shape as supporting context. In the dashboard, the Commits+page leads its table with review priority.### What gets scored-With no revspec the subject is your uncommitted work (staged, unstaged and-untracked) when the tree is dirty, otherwise `HEAD`. The payload sets-`working_tree: true` when it took that path. Naming a revspec, `HEAD`-included, always means committed refs. A merge commit is scored for the diff it-brought onto its first parent, so a merged PR reads as its own content.+With no revspec the subject is your uncommitted work (staged, unstaged and untracked)+when the tree is dirty, otherwise `HEAD`. The payload sets `working_tree: true` when it+took that path. Naming a revspec, `HEAD` included, always means committed refs. A merge+commit is scored for the diff it brought onto its first parent, so a merged PR reads as+its own content.## Reading the results-Read the result in this order:--| Field | What it is | Act on it |+| Field, in reading order | What it is | Act on it ||---|---|---|| `risk_percentile` | Where this change's diff size and spread ranks among the repo's recent commits (0-100) | Yes: size, not danger || `fix_history` | Prior bug fixes on the touched files | Yes: where to look |@@ -63,8 +53,7 @@ Read the result in this order:### Fix history: where the change lands-`fix_history` answers a question diff shape cannot: have these files broken-before?+`fix_history` answers a question diff shape cannot: have these files broken before?```Bug-fix record for HEAD: touches files with prior bug fixes@@ -73,56 +62,47 @@ core/pipeline/persist.py 40 21.6cli/commands/update_cmd/command.py 6 19.3```-- **Prior fixes** counts bug-fix commits that touched the file before the- change, weighted by age against the change's own date: a fix one year earlier- counts a half, two years a quarter. The same commit scores the same on every- re-run.-- **`density`** is the churn-weighted mean of those per-file numbers. It is a- ratio, so it does not grow with diff size: one line in a file fixed twenty- times outranks a thousand lines in files never fixed.-- **`percentile`** ranks that density against the same measure over the repo's- recent commits. It is `null` when the change touches no fix history, or when- fewer than eight sampled commits are available. It ships in `--format json`- and MCP `include=["diagnostics"]` only, so one percentile leads each surface.-- **Manifests and lockfiles** (`package.json`, `package-lock.json`,- `pyproject.toml`, `go.sum` and the like) are left out of the listed files: a- dependency bump edits them, which does not make them files that broke.- `density` and its `percentile` still count them.--History is read from before the change: a commit is never ranked against fixes-it caused. For a range, the record is read at the fork point. Up to 20,000-commits are walked, once per repository state.--A bug fix is a commit whose subject matches `fix`, `bug`, `patch`, `resolves`,-`closes #N` or `fixes #N`, and does not contain `docs`, `typo`, `bump`, `deps`,-`chore`, `lint`, `format` or `style`. The same rule feeds the health layer and-[bug-fix history](BUG_HISTORY.md).+- Prior fixes counts bug-fix commits that touched the file before the change, weighted+ by age against the change's own date: a fix one year earlier counts a half, two years+ a quarter. The same commit scores the same on every re-run.+- `density` is the churn-weighted mean of those per-file numbers. It is a ratio, so it+ does not grow with diff size: one line in a file fixed twenty times outranks a+ thousand lines in files never fixed.+- `percentile` ranks that density against the same measure over the repo's recent+ commits. It is `null` when the change touches no fix history, or when fewer than eight+ sampled commits are available. It ships in `--format json` and MCP+ `include=["diagnostics"]` only, so one percentile leads each surface.+- Manifests and lockfiles (`package.json`, `package-lock.json`, `pyproject.toml`,+ `go.sum` and the like) are left out of the listed files: a dependency bump edits them,+ which does not make them files that broke. `density` and its `percentile` still count+ them.++History is read from before the change: a commit is never ranked against fixes it+caused. For a range, the record is read at the fork point. Up to 20,000 commits are+walked, once per repository state. A bug fix is a commit whose subject matches `fix`,+`bug`, `patch`, `resolves`, `closes #N` or `fixes #N`, and does not contain `docs`,+`typo`, `bump`, `deps`, `chore`, `lint`, `format` or `style`. The same rule feeds the+health layer and [bug-fix history](BUG_HISTORY.md).### The diff-shape score-The score uses Kamei-style change metrics: lines added and deleted (`la`,-`ld`), files touched (`nf`), directories and top-level subsystems touched-(`nd`, `ns`), the entropy of churn across files, and the author's prior commit-count (`exp`). `exp` is `null` when the author cannot be resolved and then-contributes nothing. The model is a plain logistic over standardized features,-so each driver's push is exact.--Drivers are stated relative to the model's baseline commit (10.5 lines added,-1.7 files), not to this repo. A small change can read "more lines added than-baseline" and still rank below typical in a repo of large commits. `nf`, `nd`-and `ns` enter the model but are not reported as drivers: their small negative-weights are collinearity with size, not evidence that touching more files is-safer.--The absolute score is calibrated on single commits. A squash-merged PR or a-`base..head` range is several commits' worth of diff and skews high on it; the-percentile does not have that problem. `score_unit` states this in every-payload.+The score is a plain logistic over Kamei-style change metrics: lines added and deleted+(`la`, `ld`), files touched (`nf`), directories and top-level subsystems touched (`nd`,+`ns`), the entropy of churn across files, and the author's prior commit count (`exp`,+`null` and contributing nothing when the author cannot be resolved). Each driver's push+is exact. Drivers are stated relative to the model's baseline commit, not to this repo,+so a small change can read "more lines added than baseline" and still rank below typical+in a repo of large commits. `nf`, `nd` and `ns` are not reported as drivers+([why](../architecture/change-risk.md#the-model)).++The absolute score is calibrated on single commits, so a squash-merged PR or a+`base..head` range skews high on it; the percentile does not. `score_unit` states this+in every payload.### What the sample is anchored to-`repowise risk` samples recent commits live (`--baseline`, default 200). The-web UI uses the indexed commit history.+`repowise risk` samples recent commits live (`--baseline`, default 200). The web UI uses+the indexed commit history.| Subject | Sample runs back from ||---|---|@@ -131,16 +111,13 @@ web UI uses the indexed commit history.| A `base..head` range | the merge-base of the two sides || Uncommitted work | `HEAD` |-A change never ranks against itself. One walk is reused for every change scored-against the same anchor and filters in a process, so a long-running MCP server-pays for it once.+A change never ranks against itself.### PR mode (`get_risk` with `changed_files`)-`get_risk(changed_files=[...])`, or `repowise risk --target FILE---changed-file FILE`, answers a different question: what does this set of-files reach, and what is missing from it. The response opens with a-`directive` block:+`get_risk(changed_files=[...])`, or `repowise risk --target FILE --changed-file FILE`,+answers a different question: what does this set of files reach, and what is missing+from it. The response opens with a `directive` block:| Field | Meaning ||---|---|@@ -154,163 +131,138 @@ files reach, and what is missing from it. The response opens with a| `next_calls` | What to call next || `summary` | One sentence over all of the above |-In a workspace the directive also carries cross-repo fields, dropped when no workspace is loaded:-`will_break_consumers` (repos that structurally depend on this one; structural-reach, not a runtime claim), `missing_cross_repo_cochanges`,-`breaking_changes` (incompatible provider contract changes since the last-index), `conformance_violations` and `dependency_cycles`. See+In a workspace the directive also carries cross-repo fields, dropped when no workspace+is loaded: `will_break_consumers` (repos that structurally depend on this one;+structural reach, not a runtime claim), `missing_cross_repo_cochanges`,+`breaking_changes` (incompatible provider contract changes since the last index),+`conformance_violations` and `dependency_cycles`. See[Cross-Repo Blast Radius](../scale/WORKSPACES.md#cross-repo-blast-radius) and[Breaking-Change Guard](../scale/WORKSPACES.md#breaking-change-guard).The directive also names `recommended_reviewers`, and `include=["blast"]` adds-`pr_blast_radius`. The structural impact score is a deterministic, uncalibrated-0-10 heuristic over PageRank, churn and transitive dependents, banded-`localized` (below 4), `moderate` (4 to below 7) and `broad` (7 and up). It is-not a probability and does not decide review. The MCP reply carries only its-band, as `directive.reach`; `include=["blast", "scales"]` adds the score and-its scale. The REST blast-radius response and the CLI keep the score with its-exact deprecated alias `overall_risk_score`.+`pr_blast_radius`. The structural impact score is a deterministic, uncalibrated 0-10+heuristic over PageRank, churn and transitive dependents+([formula](../architecture/change-risk.md#pr-structural-impact-get_risk)), banded+`localized` (below 4), `moderate` (4 to below 7) and `broad` (7 and up). It is not a+probability and does not decide review. MCP carries only the band, as `directive.reach`;+`include=["blast", "scales"]` adds the score and its scale. The REST blast-radius+response and the CLI keep the score with its exact deprecated alias+`overall_risk_score`.## Independent changes-This answers whether the files in front of you are one change or several. It-is a structural property of the diff, with no score.+This answers whether the files in front of you are one change or several. It is a+structural property of the diff, with no score. Only indexed source files in a language+whose resolver emits import edges are grouped+([eligibility](../architecture/change-risk.md#independent-changes-grouping)). Three+kinds of link join them:-A changed file is grouped only when it has a file node in the index, is not a-test file, and is in a language whose resolver can emit an import edge. Docs,-config, data and test files are never grouped and never bridge two groups.-Three kinds of link join eligible files:--- **Index edges** between two different changed files: imports, calls, type- references, framework and dynamic edges, reads.+- **Index edges** between two different changed files: imports, calls, type references,+ framework and dynamic edges, reads.- **Stored co-change pairs**: files history moves together.-- **Shared commits**, for a `base..head` range only: files one commit touched- belong together.--Files left out are listed as `ungrouped_files` and never counted as an-independent change. `bridging_files` names the files that alone hold a group of-three or more together. The `basis` field states in words exactly what was-checked; a missing edge is a claim about this index, not about the code.+- **Shared commits**, for a `base..head` range only: files one commit touched belong+ together.-The report is silent unless there are at least two groups. `repowise risk`-prints the groups under the driver table; `--format json` and-`get_change_risk` carry them as `independent_changes` (absent without an-index).+Files left out are listed as `ungrouped_files` and never counted as an independent+change. `bridging_files` names the files that alone hold a group of three or more+together. The `basis` field states in words exactly what was checked; a missing edge is+a claim about this index, not about the code. The report is silent unless there are at+least two groups. `repowise risk` prints the groups under the driver table;+`--format json` and `get_change_risk` carry them as `independent_changes` (absent+without an index).## Branch overlap-Branch overlap answers one question: which other open branches edit the files-this change edits. It is git first, so it works in a fresh clone with no index.+Branch overlap answers one question: which other open branches edit the files this+change edits. It is git first, so it works in a fresh clone with no index.```bashrepowise overlap # HEAD against the trunkrepowise overlap --base main --branch feature/x --limit 100```-It scans local and remote branches, newest committer date first, up to-`--limit` (default 50). It drops the base, the change's own ref, refs pointing-at either tip, and branches stacked on or under this one. For each branch it-takes `git diff --name-only base...branch` (what that branch did since it-forked) and intersects it with this change's files. Noise paths (workflows,-lockfiles, generated, vendored and localization files) and dependency-manifests (`package.json`, `pyproject.toml`, `go.mod`, `Cargo.toml` and-similar) are removed from both sides first. A branch with no shared file after-filtering produces no entry.+It scans local and remote branches, newest committer date first, up to `--limit`+(default 50), and intersects what each did since it forked with this change's files,+ignoring noise paths and dependency manifests on both sides+([scan rules](../architecture/change-risk.md#branch-overlap-scan)). A branch with no+shared file after filtering produces no entry.Every row states its basis, one of two:- **`same file`**: both branches change that path.-- **`co-change pair, N of M commits`**: shown only under a branch that already- has a direct hit. A file the other branch edits that history pairs with one- of yours at least half the time. At most three per branch. Needs an index.+- **`co-change pair, N of M commits`**: shown only under a branch that already has a+ direct hit. A file the other branch edits that history pairs with one of yours at+ least half the time. At most three per branch. Needs an index.-Each entry carries `ahead`, `behind` and the date of its last commit. Branches-sort by shared files, then recency, then name. There is no score.--It compares paths, not hunks: a shared file is a reason to talk to the other-author, not a predicted merge conflict. `repowise overlap` prints one line when-nothing overlaps, naming how many branches were scanned of how many exist.-`get_change_risk` omits the `branch_overlap` block when nothing overlaps or the-branch scan times out.+Each entry carries `ahead`, `behind` and the date of its last commit. Branches sort by+shared files, then recency, then name. There is no score. It compares paths, not hunks:+a shared file is a reason to talk to the other author, not a predicted merge conflict.+`repowise overlap` prints one line when nothing overlaps, naming how many branches were+scanned of how many exist. `get_change_risk` omits the `branch_overlap` block when+nothing overlaps or the branch scan times out.## Tuning and suppressing-- **`--exclude` / `-x PATTERN`** (repeatable, gitignore-style) omits files. The- same filter applies to the sampled commits, so the comparison stays like for- like.-- **`.riskignore`** at the repository root holds project-wide, risk-only- patterns. They apply automatically and combine with `-x`.-- **`--ext`** counts only the listed suffixes.-- **`--baseline N`** sets the sample size; `0` turns ranking off and leaves only+- `--exclude` / `-x PATTERN` (repeatable, gitignore-style) omits files. The same filter+ applies to the sampled commits, so the comparison stays like for like.+- `.riskignore` at the repository root holds project-wide, risk-only patterns. They+ apply automatically and combine with `-x`.+- `--ext` counts only the listed suffixes.+- `--baseline N` sets the sample size; `0` turns ranking off and leaves only`fallback_band`.## In CI-`--fail-above-percentile P` turns the command into a size gate on-`risk_percentile`. It flags changes larger than most, not likelier to break.-The absolute 0-10 value never decides.+`--fail-above-percentile P` turns the command into a size gate on `risk_percentile`: it+flags changes larger than most, not likelier to break, and the 0-10 value never decides.```bashrepowise risk --fail-above-percentile 95 --format githubrepowise risk origin/main...HEAD --fail-above-percentile 95 --format markdown```-With the flag, or with `--format markdown` or `github`, and no revspec, the-subject is the CI change: the pull request's target branch (from CI variables,-else the remote's default branch) `...HEAD`. A CI checkout of a PR is a merge-commit, so `HEAD` alone would be the wrong change.--Exit codes are the shared CI ones: `0` at or below the percentile, `1` above,-`2` when the gate cannot evaluate. A change with no percentile cannot be gated:-`--baseline 0` turns ranking off, and a shallow clone with fewer than 8 recent-commits has nothing to rank against, so fetch full history. A revspec git-cannot read also exits `2`. At percentile P roughly (100 - P)% of changes fail-by construction; a failure asks for a split or a second reviewer, not a code-fix.--`json` adds a `gate` object with the unrounded percentile it compared.-`markdown` leads with the verdict, then the range, sample, size and fix-history-rank. `github` writes an `::error::` (or `::notice::`) and puts the markdown in-the job summary.--The GitHub Action runs it as the `risk` gate (input-`risk-fail-above-percentile`; empty reports the rank without gating), and the-GitLab template as the `repowise-risk` job when+With the flag, or with `--format markdown` or `github`, and no revspec, the subject is+the CI change: the pull request's target branch (from CI variables, else the remote's+default branch) `...HEAD`. A CI checkout of a PR is a merge commit, so `HEAD` alone+would be the wrong change.++Exit codes are the shared CI ones: `0` at or below the percentile, `1` above, `2` when+the gate cannot evaluate. A change with no percentile cannot be gated: `--baseline 0`+turns ranking off, and a shallow clone with fewer than 8 recent commits has nothing to+rank against, so fetch full history. A revspec git cannot read also exits `2`. At+percentile P roughly (100 - P)% of changes fail by construction; a failure asks for a+split or a second reviewer, not a code fix.++`json` adds a `gate` object with the unrounded percentile it compared. `markdown` leads+with the verdict, then the range, sample, size and fix-history rank. `github` writes an+`::error::` (or `::notice::`) and puts the markdown in the job summary. The GitHub+Action runs it as the `risk` gate (input `risk-fail-above-percentile`; empty reports the+rank without gating), and the GitLab template as the `repowise-risk` job when`REPOWISE_RISK_FAIL_ABOVE_PERCENTILE` is set. See [CI](../start/CI.md).## Accuracy and limits-- **The score is a diff-size statistic.** Lines added carries a weight 7.6x the- next feature, and `la` alone reproduces the full score within 0.12-0.16- points on every repo tried.-- **Against churn-only it barely moves.** Leave-one-repo-out AUC on 4,102- commits across 7 repositories (AG-SZZ labels): 0.772 for the model, 0.766 for- churn alone (95% CI of the gap includes zero).-- **The score cannot rank danger.** On 47 hand-picked within-repo pairs of a- small dangerous change and a large boring one, the score picks the dangerous- one in 0 of 47. Fix density picks it in 46 of 47. The set is a falsification- test, built so size alone scores 0; it is not an accuracy estimate.-- **`fix_history` has no AUC of its own.** It scores near chance against SZZ- labels, which are size-biased; quoting that number would mislead.-- **The fix classifier is keyword based.** It misses conventions outside its- list (Django's `Fixed #N` is the notable one) and drops genuine fixes whose- subject says `docs` or `style`. Where a project's convention falls outside- it, `fix_history` reads low.-- **Absolute scores skew high on ranges and squash merges**: the scale is one- commit. Use the percentile.-- **Overlap compares paths, not hunks.**--Method, the refit that was measured and rejected, and every public scale are in+- The score is a diff-size statistic. Lines added carries a weight 7.6x the next+ feature, and `la` alone reproduces the full score within 0.12-0.16 points on every+ repo tried.+- Against churn alone the score adds little: leave-one-repo-out AUC on 4,102 commits+ across 7 repositories (AG-SZZ labels) is 0.772 for the model and 0.766 for churn+ alone, and the 95% CI of the gap includes zero.+- The score does not rank danger. On 47 within-repo pairs of a small dangerous change+ and a large boring one, built so size alone scores 0, the score picks the dangerous+ one in 0 of 47 and fix density in 46 of 47. This is a falsification test, not an+ accuracy estimate.+- `fix_history` has no AUC of its own: SZZ labels are size-biased, so it scores near+ chance against them.+- The fix classifier is keyword based. It misses conventions outside its list (Django's+ `Fixed #N` is the notable one) and drops genuine fixes whose subject says `docs` or+ `style`; where a project's convention falls outside it, `fix_history` reads low.+- Absolute scores skew high on ranges and squash merges: the scale is one commit. Use+ the percentile.++Method, calibration and every public scale:[architecture/change-risk.md](../architecture/change-risk.md).-## Where it shows up--- **CLI**: `repowise risk`, `repowise overlap`.-- **MCP**: `get_change_risk` for a diff, `get_risk` for files and PR mode.-- **Dashboard**: the Commits page, led by review priority.-- **REST**: `GET /api/repos/{repo_id}/risk/range`.-- **CI**: the GitHub Action `risk` gate and the GitLab `repowise-risk` job.-## Reference### `repowise risk [REVSPEC]`@@ -337,15 +289,12 @@ Method, the refit that was measured and rejected, and every public scale are in| `--limit N` | 50 | Branches to diff, newest first || `--format` | `table` | `table` or `json` |-Full CLI entries: [`repowise risk`](../reference/CLI_REFERENCE.md#repowise-risk-revspec),-[`repowise overlap`](../reference/CLI_REFERENCE.md#repowise-overlap). MCP-schemas: [`get_change_risk`](../agent/MCP_TOOLS.md#get_change_risk),-[`get_risk`](../agent/MCP_TOOLS.md#get_risk).--## See also--- [architecture/change-risk.md](../architecture/change-risk.md): calibration,- the scale inventory, and PR structural-impact internals.-- [BUG_HISTORY.md](BUG_HISTORY.md): per-file and per-symbol fix counts.-- [CODE_HEALTH.md](CODE_HEALTH.md): file-level scores.-- [Workspaces](../scale/WORKSPACES.md): cross-repo blast radius and contracts.+Full CLI entries:+[`repowise risk`](../reference/CLI_REFERENCE.md#repowise-risk-revspec),+[`repowise overlap`](../reference/CLI_REFERENCE.md#repowise-overlap). MCP schemas:+[`get_change_risk`](../agent/MCP_TOOLS.md#get_change_risk),+[`get_risk`](../agent/MCP_TOOLS.md#get_risk). REST:+`GET /api/repos/{repo_id}/risk/range`. Related: [BUG_HISTORY.md](BUG_HISTORY.md)+(per-file and per-symbol fix counts), [CODE_HEALTH.md](CODE_HEALTH.md) (file-level+scores) and [Workspaces](../scale/WORKSPACES.md) (cross-repo blast radius and+contracts).diff --git a/docs/layers/CODE_HEALTH.md b/docs/layers/CODE_HEALTH.mdindex e181fc045..71416b9d7 100644--- a/docs/layers/CODE_HEALTH.md+++ b/docs/layers/CODE_HEALTH.md@@ -1,8 +1,8 @@# Code HealthRepowise scores every source file from 1 to 10 and lists which files to fix-first. It reads the parse tree, the dependency graph and git history, needs no LLM-key or network, and runs inside `repowise init` and `repowise update`. The+first. It reads the parse tree, the dependency graph and git history, needs no+LLM key or network, and runs inside `repowise init` and `repowise update`. Theanalysis is budgeted at under 30 seconds for 3,000 files, and a test enforces it.It finds code shapes and change patterns that go with bugs, slow code and code@@ -43,34 +43,34 @@ are never blended into one number.| Signal | What it answers | Weights ||---|---|---|-| **Code health** (defect risk) | Which files are most likely to carry the next bug | Fitted against a defect corpus; the headline number, band and badge |-| **Maintainability** | How hard the code is to read and change | Set by hand; never fitted to bugs |-| **Performance risk** | Where the structure wastes work | Per-marker precision weights; see [PERFORMANCE.md](PERFORMANCE.md) |+| Code health (defect risk) | Which files are most likely to carry the next bug | Fitted against a defect corpus; the headline number, band and badge |+| Maintainability | How hard the code is to read and change | Set by hand; never fitted to bugs |+| Performance risk | Where the structure wastes work | Per-marker precision weights; see [PERFORMANCE.md](PERFORMANCE.md) |Smells that fire often but predict bugs weakly (low cohesion, brain methods,-duplicated code, broad error handling) are down-weighted in code health and counted-in full in maintainability.+duplicated code, broad error handling) are down-weighted in code health and+counted in full in maintainability.## Reading the score-Each file starts at 10. Every finding deducts its severity times its marker weight,-deductions are capped per category, and the result is clamped to 1-10.+Each file starts at 10. Every finding deducts its severity times its marker+weight, deductions are capped per category, and the result is clamped to 1-10.| Band | Score | Meaning ||---|---|---|-| **Excellent** | 8.5 and above | Low risk, easy to change |-| **Good** | 7.0 to 8.5 | Sound; nothing demands attention |-| **Fair** | 5.5 to 7.0 | Rising complexity or process risk |-| **Needs work** | 4.0 to 5.5 | Worth scheduling |-| **At risk** | under 4.0 | Where defects concentrate |+| Excellent | 8.5 and above | Low risk, easy to change |+| Good | 7.0 to 8.5 | Sound; nothing demands attention |+| Fair | 5.5 to 7.0 | Rising complexity or process risk |+| Needs work | 4.0 to 5.5 | Worth scheduling |+| At risk | under 4.0 | Where defects concentrate |-Bands are absolute, so a 6.2 means the same in every repository. On the 2,770-file-benchmark corpus, files under 4.0 carried 16.9 times the per-file defect rate of-files at 8.0 and above.+Bands are absolute, so a 6.2 means the same in every repository. On the+2,770-file benchmark corpus, files under 4.0 carry 16.9 times the per-file defect+rate of files at 8.0 and above.-Repository KPIs are **average health**, **hotspot health** (hotspot files only; both-weighted by code lines) and the **worst performer**. A file in an unsupported-language is counted as not analysed, never scored as a 10.+Repository KPIs are average health, hotspot health (hotspot files only; both+weighted by code lines) and the worst performer. A file in an unsupported language+is counted as not analysed, never scored as a 10.Two controls decide what a figure describes. Every response echoes them.@@ -79,26 +79,26 @@ Two controls decide what a figure describes. Every response echoes them.| `scope` | `all` (default), `production` | `production` drops test files, which lowers the headline because tests usually score higher || `counts` | `everything` (default), `code_shape` | `code_shape` removes the git-history half of each deduction, to see whether your code improved after a refactor raised churn |-`everything` is the calibrated number every accuracy claim refers to, and the badge-always reports it.+`everything` is the calibrated number every accuracy claim refers to, and the+badge always reports it.## Fix first-**Fix first** is one ranked list of what to fix. `repowise health` prints the top 3;+Fix first is one ranked list of what to fix. `repowise health` prints the top 3;`get_health()` and the dashboard Overview tab show more. Each item is one unit of-work: a refactoring plan, one performance intervention, or the strongest code-shape-finding in a file with no plan. It gives what to change and where, why, the first-edit, the expected gain, the effort and the tests to run.+work: a refactoring plan, one performance intervention, or the strongest+code-shape finding in a file with no plan. It gives what to change and where, why,+the first edit, the expected gain, the effort and the tests to run.Among items of the same value, a function that many commits have changed comesbefore an equally complex one that rarely changes, and its reason says how many-commits changed it. A "Break up X" item's reason names the function's shape and what-splitting it buys: smaller parts that are easier to read and change, and less+commits changed it. A "Break up X" item's reason names the function's shape and+what splitting it buys: smaller parts that are easier to read and change, and lessduplicated code when part of it is a copy.Left out, and counted with a reason:-- test files, tooling (including Dart's `tool/` scripts), generated and vendored code,- docs and examples+- test files, tooling (including Dart's `tool/` scripts), generated and vendored+ code, docs and examples- files whose only findings come from git history- changes that would recover under half a point, and items with no concrete firstedit@@ -110,26 +110,28 @@ Left out, and counted with a reason:- functions under CCN 80 and 200 lines whose file rarely changes and has no bugfixes; they stay in the refactoring list-Test helpers named for a module's tests (`bot.test-harness.ts`, `card-test-helpers.ts`,-`test-support.mjs`) count as test support, and bundler output (`*.bundle.js`) as-generated code, so neither leads Fix first, the refactoring list or the dashboard's-worst-file lists, which say how many files they left out and why.+Test helpers named for a module's tests (`bot.test-harness.ts`,+`card-test-helpers.ts`, `test-support.mjs`) count as test support, and bundler+output (`*.bundle.js`) as generated code, so neither leads Fix first, the+refactoring list or the dashboard's worst-file lists, which say how many files+they left out and why.-A function is dormant when its body opens with `if not FLAG: return ...` (or is one-`if FLAG:` block) and `FLAG` is a module-level `False`, `0` or `None` (`const FLAG =-false` in TypeScript or JavaScript) that nothing in the same file assigns again.-Dormant functions are counted next to the excluded totals, not dropped silently.-Only the file itself is read: a flag imported from another module, or flipped from-outside with `setattr` or a test's monkeypatch, still reads as off.+A function is dormant when its body opens with `if not FLAG: return ...` (or is+one `if FLAG:` block) and `FLAG` is a module-level `False`, `0` or `None`+(`const FLAG = false` in TypeScript or JavaScript) that nothing in the same file+assigns again. Dormant functions are counted next to the excluded totals, not+dropped silently. Only the file itself is read: a flag imported from another+module, or flipped from outside with `setattr` or a test's monkeypatch, still+reads as off.Items rank by value first (how far the code sits past size and complexity bars,one step more in a widely imported file), then by tier. Within a value, thecomplexity a fix removes times how widely the file is imported decides, so a-4,000-line loop outranks a long print routine. A function under a twentieth of a-very large file counts only its share of that file's importers. A performance fix ranks by what runs-it: a request or message handler, then a scheduled job, then code with no role-evidence. No kind takes more than 3 of the first 5 places while another has work-worth doing.+4,000-line loop outranks a long print routine. A performance fix ranks by what+runs it: a request or message handler, then a scheduled job, then code with no+role evidence. No kind takes more than 3 of the first 5 places while another has+work worth doing. Exact ordering rules:+[architecture/code-health.md](../architecture/code-health.md#63-fix-first-ranking-fix_first-worthpy).| Tier | Meaning ||---|---|@@ -137,49 +139,56 @@ worth doing.| `next` | Worth doing, needs judgment || `later` | Real but can wait; the reason is shown |-A refactoring item is `later` when the plan of any of its steps would still leave a function above the break-up bar: it needs more stages before it is worth starting. When a finding's first step borrows such a plan, the finding keeps its tier and the step says the plan alone leaves the function above the bar.--A finding whose first step comes from a stored Extract Method plan that makes its function smaller leads with that plan: its title names the first lift, and its next call opens the plan. A finding with no such plan still reads "Break up".--A `now` or `next` item shows its first step and the command that checks it without opening it, on the card, and over MCP for the lead and for each item of an `only=["fix_first"]` page. When no test reaches the code, Verify says to add a characterization test first. An Extract Method step shows the helper's header and the call that replaces the lines, ready to copy. It finds the lines by the text they start and end with, as the plan does, since line numbers move with the first edit; when that text also appears elsewhere in the file, the step says to keep the edit inside its function.--Findings, performance causes, refactoring plans and Fix first items are counted the-same way everywhere: open in the inventory, in scope, eligible, due (tier `now` or-`next`) and shown, with every exclusion named by its reason. The numbers on the-dashboard, in `get_health` and in `repowise health --format json` (`queue_counts`) agree.+A refactoring item is `later` when the plan of any of its steps would still leave+a function above the break-up bar: it needs more stages before it is worth+starting. A finding whose first step comes from a stored Extract Method plan that+makes its function smaller leads with that plan: its title names the first lift,+and its next call opens the plan. A finding with no such plan reads "Break up".++A `now` or `next` item shows its first step and the command that checks it+without opening it, on the card, and over MCP for the lead and for each item of an+`only=["fix_first"]` page. When no test reaches the code, Verify says to add a+characterization test first. An Extract Method step shows the helper's header and+the call that replaces the lines, ready to copy. How a step borrows a plan and+finds its lines: [Fix first steps](../architecture/code-health.md#fix-first-steps).++Findings, performance causes, refactoring plans and Fix first items are counted+the same way everywhere: open in the inventory, in scope, eligible, due (tier+`now` or `next`) and shown, with every exclusion named by its reason. The numbers+on the dashboard, in `get_health` and in `repowise health --format json`+(`queue_counts`) agree.### Do next-`repowise next` prints the cross-layer list the dashboard calls **Do next** and-`get_overview` returns as `next_actions`. It reads stored actions, so it is instant.-Fix first items sit beside a live secret, fresh regressions, fragile files, files-with knowledge loss, broken doc references, a dead-code batch, missing or stale-coverage, and decisions waiting for review. Rows are grouped as **Now**, **Worth-planning** and **Improve what Repowise can see**. Within a group, rows rank by value-times confidence over effort, and the top due Fix first item leads its group, so Do-next and Fix first lead with the same work. Dismissing or-snoozing a row takes effect at once.-+`repowise next` prints the cross-layer list the dashboard calls Do next and+`get_overview` returns as `next_actions`. It reads stored actions, so it is+instant. Fix first items sit beside a live secret, fresh regressions, fragile+files, files with knowledge loss, broken doc references, a dead-code batch,+missing or stale coverage, and decisions waiting for review. Rows are grouped as+Now, Worth planning and Improve what Repowise can see. Within a group, rows rank+by value times confidence over effort, and the top due Fix first item leads its+group, so Do next and Fix first lead with the same work. Dismissing or snoozing a+row takes effect at once.A fragile file asks for tests only when no measured coverage and no test in the-code graph reaches it; otherwise the row asks you to simplify its lead function.-A folder where bug fixes concentrate names its first step, the most fixed file's,-or is left out.-An index with fewer than five commits leaves out the rows ranked by history.+code graph reaches it; otherwise the row asks you to simplify its lead function. A+folder where bug fixes concentrate names its first step, the most fixed file's, or+is left out. An index with fewer than five commits leaves out the rows ranked by+history.```bash-repowise next # top 5 for this week (or the quarter when the week is empty)+repowise next # top 5 this week (the quarter if the week is empty)repowise next --horizon quarter --allrepowise next --json # the whole stored view```## Findings-Findings are the observations behind the score. The dashboard **Findings** tab lists+Findings are the observations behind the score. The dashboard Findings tab liststhem by dimension and severity, and `get_health(targets=[...])` returns them perfile. Each has a stable id that survives edits above it. Mark one `acknowledged`,`false_positive` or `resolved` in the dashboard, over REST, or with the opt-in-`set_finding_status` MCP tool. Triage survives re-indexing, and a `resolved` finding-that is detected again reopens.+`set_finding_status` MCP tool. Triage survives re-indexing, and a `resolved`+finding that is detected again reopens.The 53 detectors fall into families. Category caps keep any one family fromdominating a file.@@ -196,16 +205,17 @@ dominating a file.| SQL | 4 | none | Complex SQL, `SELECT *`, `UPDATE`/`DELETE` with no `WHERE`, cartesian joins; maintainability or performance only || Performance | 21 | none | See [PERFORMANCE.md](PERFORMANCE.md); performance only |-Twenty-five detectors move code health. Three markers are **advisory**: they are-listed, carry zero impact, and stay out of impact-ranked lists unless you ask for the-advisory dimension. Three **governance** findings (an ungoverned hotspot, stale-governance, a contradictory decision) come from the [decisions layer](DECISIONS.md)-and never deduct. Every detector id: [architecture/code-health.md](../architecture/code-health.md#the-full-roster).+Twenty-five detectors move code health. Three markers are advisory: they are+listed, carry zero impact, and stay out of impact-ranked lists unless you ask for+the advisory dimension. Three governance findings (an ungoverned hotspot, stale+governance, a contradictory decision) come from the+[decisions layer](DECISIONS.md) and never deduct. Every detector id:+[architecture/code-health.md](../architecture/code-health.md#the-full-roster).-**History amplifies code risk; it does not stand alone.** Git history costs a file at-most 1.0 point, plus one point for each point its code-shape findings deduct, up to-3.5. A simple file that changes often reads as busy, not broken, and never drops-below 9.0 from history alone.+History amplifies code risk and does not stand alone. Git history costs a file at+most 1.0 point, plus one point for each point its code-shape findings deduct, up+to 3.5. A simple file that changes often reads as busy, not broken, and never+drops below 9.0 from history alone.| Detector | Fires when ||---|---|@@ -219,20 +229,24 @@ On a small team, `knowledge_loss` and `ownership_risk` are capped at low severitunless the file is a hotspot, and the `small-team` profile lowers them further.`ownership_risk` is also low on a file under 40 code lines.`large_assertion_block` and `duplicated_assertion_block` fire only in test files.-House assertion helpers go in the [`assertions:` block](../reference/CONFIG.md#the-assertions-block).+House assertion helpers go in the+[`assertions:` block](../reference/CONFIG.md#the-assertions-block).Per-language coverage: [LANGUAGE_SUPPORT.md](LANGUAGE_SUPPORT.md#code-health-coverage).## Trends, coverage and badges-Every `init`, `update` and `health --recompute` stores a snapshot (the last 50 per repository). Alerts: **declining** (fell-0.5 or more against five snapshots back), **predicted decline** (three falls in a-row) and **history drag** (either, where only the git-history half moved, so there-is nothing in the code to act on). `repowise health --trend` prints the last 10.+Every `init`, `update` and `health --recompute` stores a snapshot (the last 50+per repository). Alerts: declining (fell 0.5 or more against five snapshots back),+predicted decline (three falls in a row) and history drag (either, where only the+git-history half moved, so there is nothing in the code to act on).+`repowise health --trend` prints the last 10.Coverage reports (LCOV, Cobertura, Clover, JaCoCo, Go coverprofile, Repowise JSON)feed the coverage detectors: `repowise coverage add coverage.lcov`. With no report,-only `untested_hotspot` runs, and no file is treated as uncovered.-`repowise health --badge` prints README badge Markdown. After adding a report, run `repowise health --recompute`, which analyzes the working tree instead of reading the stored analysis and, on a whole-repo table run, writes the result to the index.+only `untested_hotspot` runs, and no file is treated as uncovered. After adding a+report, run `repowise health --recompute`, which analyzes the working tree+instead of reading the stored analysis and, on a whole-repo table run, writes the+result to the index. `repowise health --badge` prints README badge Markdown.## Configuration@@ -252,7 +266,8 @@ Per-file rules live in `.repowise/health-rules.json`:`path` uses gitignore semantics, and every matching rule applies. `small-team`lowers the people signals a 1-3 person repository cannot support, and an explicit`severity_overrides` entry wins over it. Only severity labels are tunable; weights-and caps are the calibrated constants the published accuracy rests on. Full schema:+and caps are the calibrated constants the published accuracy rests on. Full+schema:[CONFIG.md](../reference/CONFIG.md#the-health-rulesjson-file).## Accuracy and limits@@ -266,9 +281,9 @@ next six months of bug fixes.0.173 vs 0.074 (p = 0.003), 2.3 times the defects. AUC and precision are ties.- Lines of code alone scores AUC 0.742, a tie. The gain is in ordering a fixedreview budget and saying why. Within size quartiles AUC is 0.525 to 0.718.-- The score did not track GitHub merge time on open data.-- `get_health(include=["accuracy"])` reports how many of your 20 lowest-scoring files- had a bug fix in the last 180 days against the base rate. It is an association,+- On open data, the score does not track GitHub merge time.+- `get_health(include=["accuracy"])` reports how many of your 20 lowest-scoring+ files had a bug fix in the last 180 days against the base rate. It is an association,not a forward test, and stays silent below 25 scored files or 5 fixed ones.Every test: [BENCHMARKS.md](../BENCHMARKS.md#code-health-predicts-defects).diff --git a/docs/layers/DEAD_CODE.md b/docs/layers/DEAD_CODE.mdindex 08749abd4..02ef603bf 100644--- a/docs/layers/DEAD_CODE.md+++ b/docs/layers/DEAD_CODE.md@@ -42,9 +42,8 @@ In the dashboard, open the **Dead code** view of a repository.Methods, fields, properties and enum members are never reported as unusedexports: they are reached through their container. `unused_internal` is-withheld from the dashboard and default MCP responses because its measured-precision was very low ([Accuracy and limits](#accuracy-and-limits)); ask for-it with `--include-internals` or `include_internals=True`.+withheld from the dashboard and default MCP responses because its precision is+very low ([Accuracy and limits](#accuracy-and-limits)); ask for it with `--include-internals` or `include_internals=True`.## Reading the results@@ -65,7 +64,7 @@ deadness is. It starts from a base value per kind and can only be lowered:Several caps then pull a finding down to `0.40`, the review tier: a runtimeloader in the same directory, a path that looks like config or bootstrap code,an unused export's name written somewhere else in the repository, or a name that-appears in a file repowise could not index. Each cap adds a line to the+appears in a file Repowise could not index. Each cap adds a line to thefinding's evidence saying why.### Tiers@@ -135,7 +134,7 @@ There is no allowlist file for dead-code findings; use the dashboard status.## False positives and dynamic code-When a file contains a runtime loader, repowise assumes its neighbours in the+When a file contains a runtime loader, Repowise assumes its neighbours in thesame directory may be reached through it and caps their confidence at `0.40`.Markers are recognised in Python, JavaScript and TypeScript, Java, Kotlin,Ruby, PHP, Go, Swift, Scala, Rust, C# and C/C++. Examples: `importlib.import_module`,@@ -185,11 +184,10 @@ See [WORKSPACES.md](../scale/WORKSPACES.md) for how cross-repo data is built.## Accuracy and limits-- `unused_internal` was measured at under 1% precision on 1,511 hand-labelled- findings from one TypeScript/Python monorepo, which is why it is withheld by- default. Private symbols used within their own file are often invisible to- the graph.-- Whole unreachable files were measured well below the deletion-ready bar+- `unused_internal` precision is under 1% on 1,511 hand-labelled findings from+ one TypeScript/Python monorepo, so it is withheld by default. Private symbols+ used within their own file are often invisible to the graph.+- Precision on whole unreachable files is well below the deletion-ready bar(build scripts, manifests and runtime loaders read files by path), so theyare never marked `safe_to_delete`.- Unused-export confidence is only as good as the graph's call and importdiff --git a/docs/layers/DECISIONS.md b/docs/layers/DECISIONS.mdindex aa80fc1b6..33c259b94 100644--- a/docs/layers/DECISIONS.md+++ b/docs/layers/DECISIONS.md@@ -10,10 +10,10 @@ It does not decide anything for you. A machine can propose a candidate; only aperson (or a committed ADR) makes it a decision that governs.Cost: capture runs inside `repowise init` and `repowise update`. ADR files,-inline markers, manual entry and the conventions source work with no LLM key.-Commit, pull request and comment mining need a model, and are skipped with a-stated reason when no provider is configured. Delivery to agents is a local-SQLite lookup with no network.+inline markers, manual entry and conventions need no LLM key. Commit, pull+request and comment mining need a model and are skipped with a stated reason+when no provider is configured. Delivery to agents is a local SQLite lookup+with no network.## Quick start@@ -26,44 +26,10 @@ repowise decision health # stale, unscoped, ungoverned hotspotsrepowise decision export # write accepted ones to .repowise/decisions.yaml```-Record one yourself, from a script or an agent:--```bash-repowise decision add --title "JWT over sessions" \- --decision "Authenticate API calls with signed JWTs" \- --rationale "Stateless horizontal scaling" \- --affects src/auth-```--From an agent over MCP:--```python-get_why(query="why JWT over sessions?") # search decisions-get_why(query="src/payments/processor.ts") # what governs this file-get_why() # governance health-```--In the dashboard, the **Decisions** page of a repository lists records by+To record one yourself, see [How to add one](#how-to-add-one); agents ask with+`get_why`. The dashboard's **Decisions** page of a repository lists records byreview lane and lets you accept or dismiss candidates.-```-repowise decision health-- Decision Health-- Active decisions 14- Proposed (needs review) 3- Stale decisions 2- Deprecated 1-- Stale decisions (2):- 9f3c1a44 JWT over sessions (staleness: 0.72)- 2b70de91 EventBus stays in-process (staleness: 0.58)-- Ungoverned hotspots (1):- payments/processor.ts-```-## What a decision record isRepowise keeps three things apart:@@ -83,9 +49,9 @@ alternatives, consequences, tags, the files or modules it governs (its scope),its source, a confidence, a staleness score, and one or more evidence rows(file and line, or commit, plus the quote).-**Acceptance** is a recorded event, not a status flag. It carries a reason, a-scope, an evidence reference and who signed it. Repowise refuses to store an-acceptance that is missing any of those:+Acceptance is a recorded event, not a status flag. It carries a reason, a+scope, an evidence reference and who signed it, and Repowise refuses to store+an acceptance that is missing any of those:```$ repowise decision confirm 4b6ddc58@@ -123,14 +89,11 @@ The same decision found by two sources becomes one record with two evidencerows. Headline fields come from the more authoritative source; the other iskept as corroboration and raises confidence.-Internals of each source, the evidence check, the confidence formula and the-session miner: [architecture/decisions.md](../architecture/decisions.md).-## LifecycleStored status is one of `proposed` (a candidate), `active` (accepted),`deprecated`, `superseded` or `dismissed`. An accepted decision also has a-**currency**, which says whether it still describes the code:+currency, which says whether it still describes the code:| Currency | Meaning | Still governs? ||----------|---------|----------------|@@ -144,39 +107,32 @@ Stored status is one of `proposed` (a candidate), `active` (accepted),`active`, `needs_review`, `uncheckable` and `stale` are derived from the codeon every read. `superseded` and `dismissed` are set by a person.-**Staleness score.** Each record carries `staleness_score` between 0 and 1: the-fraction of its governed files that have been committed to since the decision-was recorded. A file the repository does not track counts as changed. At 0.5 or-above a record is stale for `decision list --stale-only`, the health summary,-and the `needs_review` currency. A record that names no file scores 0.0 and is-counted separately as unscoped. `repowise decision show` and `get_why` on a-path also ask git directly for one record and print what changed.--**Sticky review.** A dismissed candidate is kept as a tombstone, so re-indexing-never proposes it again. An accepted decision is never walked back to-`proposed` by a later extraction.--**Supersession.** `repowise decision deprecate ID --superseded-by ID2` records-the successor. `repowise update` also marks a decision that a new commit-reversed. Automatic detection of `supersedes` and `conflicts_with` edges by-text similarity is switched off, because similarity between records from one-repository did not reliably mean a shared topic.+- Staleness score: each record carries `staleness_score` between 0 and 1, the+ fraction of its governed files committed to since the decision was recorded.+ A file the repository does not track counts as changed. At 0.5 or above a+ record is stale for `decision list --stale-only`, the health summary and the+ `needs_review` currency. A record that names no file scores 0.0 and is+ counted separately as unscoped. `repowise decision show` and `get_why` on a+ path also ask git directly for one record and print what changed.+- Sticky review: a dismissed candidate is kept as a tombstone, so re-indexing+ never proposes it again. A later extraction never walks an accepted decision+ back to `proposed`.+- Supersession: `repowise decision deprecate ID --superseded-by ID2` records+ the successor, and `repowise update` marks a decision that a new commit+ reversed. These are the only sources of lineage; Repowise does not infer+ `supersedes` or `conflicts_with` edges from text similarity+ ([why](../architecture/decisions.md#supersession-and-conflict-detection)).## Reviewing candidates-| Command | What it records |-|---------|-----------------|-| `decision confirm ID...` | Accept one or more candidates. `--reason`, `--scope`, `--evidence` fill gaps. `--preview` writes nothing. |-| `decision dismiss ID...` | Tombstone. On an accepted decision this also withdraws its authority. |-| `decision deprecate ID --superseded-by ID2` | Retire with an explicit successor. |-| `decision merge ID INTO_ID` | Fold a candidate into an accepted decision. The old id keeps resolving. |-| `decision dedupe` | Fold duplicate candidates in one sweep. Dry run until `--apply`. |-| `decision split ID` | Flag a candidate as bundling two choices. Never splits it for you. |+`decision confirm` accepts, `dismiss` tombstones, `deprecate` retires, and+`merge`, `dedupe` and `split` tidy candidates ([Reference](#reference)). In a+batch, each id goes through the same acceptance check and is applied on its+own, so one refusal does not stop the rest.-In a batch, each id goes through the same acceptance check and is applied on-its own, so one refusal does not stop the rest.--The Decisions page splits records into five lanes that do not overlap:+The Decisions page splits records into five lanes that do not overlap. Its+Accept goes through the same check as `decision confirm`, so a candidate+missing a reason, scope or evidence has Accept disabled with the gap named.| Lane | What is in it ||------|---------------|@@ -186,10 +142,6 @@ The Decisions page splits records into five lanes that do not overlap:| Uncheckable | Accepted, but names no file or module. || History | Accepted, then withdrawn, superseded or dismissed. |-Accept from the UI goes through the same check as `decision confirm`: a-candidate missing a reason, scope or evidence has Accept disabled with the gap-named.-## How to add one```bash@@ -201,86 +153,55 @@ repowise decision add --title T --decision D [--affects PATH ...] # no prompts|------|---------|| `--title`, `--decision` | Both together switch to non-interactive mode and print the new id || `--context`, `--rationale` | Why it was needed, why this choice |-| `--alternative` | A rejected alternative. Repeatable |-| `--consequence` | A tradeoff accepted. Repeatable |-| `--affects` | A file or module it governs. Repeatable |-| `--tag` | A tag. Repeatable |+| `--alternative`, `--consequence` | A rejected alternative; a tradeoff accepted. Repeatable |+| `--affects`, `--tag` | A file or module it governs; a tag. Repeatable || `--evidence-commit` | A commit the decision was made in. Repeatable || `--kind` | `architectural` (default) or `agreement` || `--format json` | Machine-readable output with the full id |What gets stored depends on how you add it:-- **Guided prompts** record an acceptance, signed by you. If an architectural- decision names no files it is kept as a candidate, because it cannot be+- Guided prompts record an acceptance, signed by you. An architectural+ decision that names no files is kept as a candidate, because it cannot bechecked against the code.-- **Flags** (`--title` and `--decision`) store a candidate (`proposed`). A- person answering the prompts has reviewed the decision; a script or agent- inferring one has not. Promote it with `repowise decision confirm ID`.+- Flags (`--title` and `--decision`) store a candidate (`proposed`). A person+ answering the prompts has reviewed the decision; a script or agent inferring+ one has not. Promote it with `repowise decision confirm ID`.- `--kind agreement` records a rule about how the work is done ("never pushwithout review"). It governs the whole repository, needs no files, andreaches an agent at session start.## Governance-**Who may accept.** Each acceptance records who signed it and what kind of-signer: `person`, `agent`, or `import` (the committed manifest or an ADR). The-person defaults to `git config user.name`; `--as` records a different identity.--An agent may withdraw authority (`dismiss`, `deprecate`) by signing as itself-with `--agent SLUG`. Granting authority is refused for an agent unless the-repository allows it:+### Who may accept-```bash-repowise decision config agent-acceptance --on # off by default-repowise decision confirm ID --agent claude_code --session "$SESSION_ID"-```--The dashboard badges any authority record a person did not sign, and+Each acceptance records who signed it and what kind of signer: `person`,+`agent`, or `import` (the committed manifest or an ADR). The person defaults to+`git config user.name`; `--as` records a different identity. An agent may+withdraw authority (`dismiss`, `deprecate`) by signing as itself with+`--agent SLUG`. Granting authority is refused for an agent unless the+repository allows it with `repowise decision config agent-acceptance --on` (off+by default); the agent then signs with, for example,+`decision confirm ID --agent claude_code --session "$SESSION_ID"`. The dashboard badges any authority record a person did not sign, and`decision show --format json` returns the signature.-**The tracked manifest.** Accepted decisions belong to the repository, so they-live in a file you commit:+### The tracked manifest-```bash-repowise decision export # store -> .repowise/decisions.yaml-repowise decision import # .repowise/decisions.yaml -> store-```+Accepted decisions belong to the repository, so they live in a file you+commit. `repowise decision export` writes the store to+`.repowise/decisions.yaml` and `repowise decision import` reads it back. Each+entry holds the id, title, decision, reason, scope, currency, source, and when+and by whom it was accepted. On `import` the file wins, and candidates and+episodes stay out of it. Format, merge and ordering rules:+[architecture/decisions.md](../architecture/decisions.md#tracked-manifest).-```yaml-# Accepted architectural decisions for this repository.-version: 1-decisions:-- id: 228ddce7b28c4f93a8f1e8976dd1ba4c- title: Avoid feature gating- decision: Do not add feature gating.- reason: Feature flags outlived their purpose here- scope:- - packages/core- currency: active- source: session- accepted_at: '2026-09-01T13:04:22+00:00'- accepted_by: Jane Doe-```+### Capture policy-The file is ordered by id with a fixed field order, so a one-line change is a-one-line diff. `export` un-ignores this one file if a `.repowise/` rule in-`.gitignore` was hiding it. On `import` the file wins: new entries are created-and accepted with the file as accepter, changed entries are re-accepted, entries-missing a reason or scope are skipped, and entries the file no longer holds are-left alone (a missing line may be a bad merge). An empty store never overwrites-a non-empty committed file, and a file written by a newer repowise is refused.-Candidates and episodes stay out of the file.--**Capture policy.** Every source can be switched, and so can the model:--```bash-repowise decision config show # resolved policy, with reasons-repowise decision config preset local_only # default | off | local_only | balanced | full-repowise decision source set comment --off-repowise decision source set adr --no-llm # keep the parse, skip the model-repowise decision llm --off # no decision extraction calls a model-```+Every source can be switched, and so can the model: `decision config preset`+picks a preset, `decision source set SRC --off` (or `--no-llm` to keep a+source's parse and skip its model stage) switches one source, and+`decision llm --off` stops every decision extraction model call.+`decision config show` prints the resolved policy, with reasons.| Preset | What it runs ||--------|--------------|@@ -303,14 +224,13 @@ model spend on decision extraction.Through hooks, without asking (details in [HOOKS.md](../agent/HOOKS.md)):-- **Session start.** Repowise scores decisions against the session's likely- working set (dirty and staged files, branch changes, the previous session's- edits, branch-name tokens), expands one hop through imports and co-change- partners, and injects the most relevant under a hard ~400-token cap.- Candidates come in a separate, labelled section with its own small budget.- If nothing is relevant enough, nothing is injected.-- **Edit time.** When the agent edits a file an accepted decision governs, it- gets a one-line notice with the rationale, once per session per decision.+- Session start: Repowise injects the decisions most relevant to the+ session's likely working set under a hard ~400-token cap. Candidates come in+ a separate, labelled section with its own small budget. If nothing is+ relevant enough, nothing is injected. How the working set is scored:+ [architecture/decisions.md](../architecture/decisions.md#hook-delivery).+- Edit time: when the agent edits a file an accepted decision governs, it gets+ a one-line notice with the rationale, once per session per decision.Through MCP, `get_why` picks its mode from the call shape:@@ -328,6 +248,8 @@ source. Full parameters: [MCP_TOOLS.md](../agent/MCP_TOOLS.md#get_why).Accepted decisions also appear in the generated `CLAUDE.md`, `get_overview`,`get_context`, and as the `governance_risk` flag in `get_risk`. A candidatenever raises `governance_risk`, and reaches `get_answer` labelled `candidate`.+Code health reports `ungoverned_hotspot`, `stale_governance` and+`contradictory_decision` findings ([CODE_HEALTH.md](CODE_HEALTH.md)).## Accuracy and limits@@ -335,28 +257,14 @@ never raises `governance_risk`, and reaches `get_answer` labelled `candidate`.is not grounded is cleared; a candidate with no grounded field is rejected.- Confidence is capped at 0.99 and rises with source authority and independentcorroboration. It is a ranking aid, not a probability.-- The `session` source ships off: on this repository it produced 139 records,- none with a context and 115 with neither context nor rationale.-- Automatic supersession and conflict edges are off, so lineage comes only from- explicit `--superseded-by` and commit reversals.+- The `session` source ships off: of 139 records here, none has a context and 115+ have no rationale either ([measurement](../architecture/decisions.md#session-mining)).+- Lineage comes only from explicit `--superseded-by` and commit reversals.- Staleness measures whether governed files changed, not whether the decisionis still true.- Commit, PR and comment mining need a model; without one, only ADRs, markers,conventions, sessions (gates only) and manual entry produce records.-Method for repowise's measured numbers: [BENCHMARKS.md](../BENCHMARKS.md).--## Where it shows up--| Surface | What you get |-|---------|--------------|-| CLI | `repowise decision ...` |-| MCP | `get_why`; decisions inside `get_overview`, `get_context`, `get_risk`, `get_answer` |-| Hooks | Session-start and edit-time injection |-| Dashboard | Decisions page with review lanes |-| Generated files | Accepted decisions in `CLAUDE.md` |-| Code health | `ungoverned_hotspot`, `stale_governance`, `contradictory_decision` findings |-## ReferenceEvery subcommand takes an optional trailing `PATH`, `--format json`, and@@ -369,8 +277,12 @@ unknown id.| `decision list` | Table of records. `--status`, `--source`, `--proposed`, `--stale-only` || `decision show ID` | Full record with evidence and signature || `decision candidates` | What awaits review, and why each was raised |-| `decision confirm` / `dismiss` / `deprecate` | Accept, tombstone, retire |-| `decision merge` / `dedupe` / `split` | Fold or flag candidates |+| `decision confirm ID...` | Accept. `--reason`, `--scope`, `--evidence` fill gaps; `--preview` writes nothing |+| `decision dismiss ID...` | Tombstone. On an accepted decision this also withdraws its authority |+| `decision deprecate ID --superseded-by ID2` | Retire with an explicit successor |+| `decision merge ID INTO_ID` | Fold a candidate into an accepted decision. The old id keeps resolving |+| `decision dedupe` | Fold duplicate candidates in one sweep. Dry run until `--apply` |+| `decision split ID` | Flag a candidate as bundling two choices. Never splits it for you || `decision export` / `import` | Round-trip `.repowise/decisions.yaml` || `decision migrate` | Classify records from older stores. Dry run unless `--apply` || `decision health` | Counts, stale records, ungoverned hotspots |@@ -380,12 +292,9 @@ unknown id.| `decision llm --on/--off` | Master switch for model calls |Full flags: [CLI_REFERENCE.md](../reference/CLI_REFERENCE.md#repowise-decision).-MCP: [`get_why`](../agent/MCP_TOOLS.md#get_why).## See also-- [architecture/decisions.md](../architecture/decisions.md): source internals, evidence check, confidence, session mining.+- [architecture/decisions.md](../architecture/decisions.md): source internals, evidence check, confidence, session mining, manifest rules, hook scoring.- [INTELLIGENCE_LAYERS.md](INTELLIGENCE_LAYERS.md): where decisions sit among the layers.-- [CODE_HEALTH.md](CODE_HEALTH.md): the governance findings.-- [HOOKS.md](../agent/HOOKS.md): the injection hooks.-- [CONFIG.md](../reference/CONFIG.md): the `decisions:` block.+- [CODE_HEALTH.md](CODE_HEALTH.md), [HOOKS.md](../agent/HOOKS.md), [CONFIG.md](../reference/CONFIG.md): governance findings, injection hooks, the `decisions:` block.diff --git a/docs/layers/DOC_DRIFT.md b/docs/layers/DOC_DRIFT.mdindex 16dc143b0..4c0e9360a 100644--- a/docs/layers/DOC_DRIFT.md+++ b/docs/layers/DOC_DRIFT.md@@ -6,10 +6,10 @@ so it checks them and reports the ones the tree refutes.This is part of the code-health layer, not a separate analysis you run. Ithappens on every `init` and every `update` and needs no model. The four-file-level kinds take well under a second; the `symbol` kind reads git history-and, measured on a repository of about 4,800 files and 190 documents, adds-about 7 seconds to `init` and 1 to 4 seconds to an `update`, which re-resolves-only the references the update could have changed.+file-level kinds take well under a second. The `symbol` kind reads git history:+on a repository of about 4,800 files and 190 documents it adds about 7 seconds+to `init` and 1 to 4 seconds to an `update`, which re-resolves only the+references the update could have changed.## What it checks@@ -20,7 +20,7 @@ Five classes of reference, all of them things the repository itself can settle:| `path` | a document names a file or directory | nothing at that path || `link` | a document links to another document | the target is not there || `anchor` | a link points at a heading | the heading was renamed or removed |-| `command` | a document tells you to run something | the manifest no longer declares it |+| `command` | a document tells you to run something | the manifest does not declare it || `symbol` | a document names a function, class or method | it was defined when the line was written and is defined nowhere now |The anchor case is the one people are most surprised by, because it is the one@@ -137,25 +137,18 @@ record it again when you add the kind.repowise doc-drift --check --format github```-`--format github` annotates each finding on the document line and writes a-summary to the job page. `--format sarif` produces a file for GitHub code-scanning, `--format gitlab` a GitLab Code Quality report for the merge request-widget (baselined findings left out), and `--format markdown` is for posting a-comment yourself. In the Code Quality report a finding at or above-`--fail-on-confidence` is `major` and one below it `minor`.--A finding with a likely replacement carries it into every format. The JSON has-`suggestion`, plus `suggested_line` (the whole document line with every copy of-the reference replaced) and `suggestion_columns` (each replaced span: 1-based,-end exclusive, in UTF-16 code units). SARIF carries a `fixes` entry that-replaces exactly those spans, the markdown summary adds a `suggestion` block-with the replaced line under each finding, ready to paste into a pull-request-review, and the Code Quality description ends with "Likely now:" and the-replacement. Findings read back from an index keep the suggestion but not the-placed line. Full history-(`fetch-depth: 0`) is optional and only improves the rename suggestions. The-GitHub Action and GitLab template that run it beside the other gates are in-[Repowise in CI](../start/CI.md).+| Format | Output | Likely replacement carried as |+|---|---|---|+| `github` | an annotation on each document line, plus a job summary | in the annotation |+| `sarif` | a file for GitHub code scanning | a `fixes` entry that replaces exactly the reference spans |+| `gitlab` | a Code Quality report for the merge request widget, baselined findings left out; `major` at or above `--fail-on-confidence`, `minor` below | a description ending in "Likely now:" and the replacement |+| `markdown` | a summary to post as a comment yourself | a `suggestion` block with the replaced line, ready to paste into a pull-request review |+| `json` | one object per finding | `suggestion`, `suggested_line` (the whole line with every copy of the reference replaced) and `suggestion_columns` (each replaced span: 1-based, end exclusive, in UTF-16 code units) |++Findings read back from an index keep the suggestion but not the placed line.+For the file-level kinds, full history (`fetch-depth: 0`) is optional and only+improves the rename suggestions. The GitHub Action and GitLab template that run+the check beside the other gates are in [Repowise in CI](../start/CI.md).To adopt the gate on a repository that already has drift, record what is thereand fail only on new findings:@@ -211,6 +204,6 @@ or rename something and want to know what will go stale.## See also-- [CODE_HEALTH.md](CODE_HEALTH.md) — the layer this belongs to-- [`repowise doc-drift`](../reference/CLI_REFERENCE.md#repowise-doc-drift-path) — every flag-- [MCP_TOOLS.md](../agent/MCP_TOOLS.md) — the agent-facing surface+- [CODE_HEALTH.md](CODE_HEALTH.md): the layer this belongs to+- [`repowise doc-drift`](../reference/CLI_REFERENCE.md#repowise-doc-drift-path): every flag+- [MCP_TOOLS.md](../agent/MCP_TOOLS.md): the agent-facing surfacediff --git a/docs/layers/GRAPH.md b/docs/layers/GRAPH.mdindex 9e8526d69..fa69a10de 100644--- a/docs/layers/GRAPH.md+++ b/docs/layers/GRAPH.md@@ -1,14 +1,11 @@# Graph Intelligence-Most tools that draw a code graph will tell you `A calls B`. Very few will tell-you how sure they are, and the interesting questions cannot be answered-without that.-repowise builds a two-tier graph of your codebase, files and symbols, with no-model calls and no network. It needs no LLM key and is built during-`repowise init` and kept current by `repowise update`. What makes it worth-trusting is not its size. Every edge carries its own evidence: the strategy-that produced it and the confidence that strategy earns.+model calls and no network. It needs no LLM key, is built during+`repowise init` and is kept current by `repowise update`. Every edge carries its+own evidence: the strategy that produced it and the confidence that strategy+earns, so an agent or a reviewer can tell a fact from a guess. An LLM is only+an optional upgrade for wiki prose, so the graph is reproducible.<p><img src="https://img.shields.io/badge/17-edge_types-3178C6?style=flat-square&labelColor=0A0A0A" alt="17 edge types" />@@ -17,20 +14,13 @@ that produced it and the confidence that strategy earns.<img src="https://img.shields.io/badge/0-LLM_calls-1E293B?style=flat-square&labelColor=0A0A0A" alt="zero LLM calls" /></p>-**Contents:** [Quick start](#quick-start) ·-[The problem with a plain arrow](#the-problem-with-a-plain-arrow) ·-[Two stages, and they fail differently](#two-stages-and-they-fail-differently) ·-[How good is it, and how we know](#how-good-is-it-and-how-we-know) ·-[What is in the graph](#what-is-in-the-graph) ·-[Every edge says how it got there](#every-edge-says-how-it-got-there) ·-[Typing the receiver](#typing-the-receiver) ·-[Seventeen edge types](#seventeen-edge-types-because-calls-was-doing-too-many-jobs) ·-[Flows that say why they stopped](#flows-that-say-why-they-stopped) ·-[What the graph powers](#what-the-graph-powers) ·-[Seeing it yourself](#seeing-it-yourself) ·-[Honest ceilings](#honest-ceilings)-----+**Contents:** [Quick start](#quick-start), [How an edge is made](#how-an-edge-is-made),+[How far to trust it](#how-far-to-trust-it), [What is in the graph](#what-is-in-the-graph),+[Every edge says how it got there](#every-edge-says-how-it-got-there),+[Typing the receiver](#typing-the-receiver), [Edge types](#edge-types),+[Flows that say why they stopped](#flows-that-say-why-they-stopped),+[What the graph powers](#what-the-graph-powers), [Seeing it yourself](#seeing-it-yourself),+[Limits](#limits)## Quick start@@ -49,119 +39,50 @@ get_symbol(id="src/app.py::App.run", depth=2)`get_context` lists callers and callees with their confidence; `get_symbol` atdepth 2 also returns the bodies the symbol calls. Both expansions drop call-edges below 0.7, which keeps-the repo-wide name guesses out of them (see+edges below 0.7, which keeps the repo-wide name guesses out of them (see[how an agent should read confidence](#how-an-agent-should-read-confidence)).------## The problem with a plain arrow--Consider one line of Python:--```python-user.save()-```--To draw an edge, a tool has to answer "what is `user`?". There are three ways to-do it, and they are not equally good:--1. Give up. Emit nothing. The edge is missing, so a dead-code pass now thinks- `save` is unused and offers to delete it.-2. Guess. Find every method named `save` in the repo and pick one. If your- codebase has `User.save`, `Draft.save` and `Session.save`, you have a two in- three chance of drawing an arrow to the wrong file.-3. Work out what `user` is, then resolve `save` on that type.+## How an edge is made-Most graphs do (2) and present the result identically to an edge they were-certain about. That is the actual problem. A wrong arrow is worse than a missing-one, because a missing arrow looks like missing information and a wrong arrow-looks like an answer.+To draw an edge for `user.save()`, a tool has to know what `user` is.+repowise reads the receiver's declared type and resolves `save` on that type.+Where it cannot, it falls back to matching the name across the repo, and the+edge says which of the two happened. A wrong arrow that looks like an answer is+worse than a labelled guess, so nothing turns a guess into a fact.-repowise does (3) where it can, falls back to (2) where it must, and labels-which one happened on every edge.+An edge is two claims, made in two stages that fail in different ways:------## Two stages, and they fail differently--An edge is two claims made by two different pieces of machinery. They are kept-apart because they break in opposite directions.--**Capture** is noticing that a call was written at all. It is a tree-sitter-query per language, listing the source shapes that count as a call site:--```scheme-; Go method call: obj.Method(args)-(call_expression- function: (selector_expression- operand: (identifier) @call.receiver- field: (field_identifier) @call.target- )- arguments: (argument_list) @call.arguments-) @call.site-```+| Stage | What it does | Fails when | Costs you |+|---|---|---|---|+| Capture | A per-language tree-sitter query notices that a call was written | no query covers that call shape | recall: the edge does not exist |+| Resolution | Turns the captured name and receiver into one declaration in one file; the 39 resolution origins live here | the receiver cannot be typed, or the name is ambiguous | precision if it guesses, recall if it declines |-A shape that no query matches is a call the graph will never contain. Not low-confidence, not unresolved: absent. Nothing downstream can recover it, because-nothing downstream knows the call was there. Go alone lists a plain call, a-method call, a package-qualified call, a chained call, and a function passed as-an argument. That last one is captured as a reference, not a call, because-passing a handler is not invoking it.+A missed capture is silent, so it is measured against a compiler. A bad+resolution is visible, because the origin on the edge names the strategy, so a+wrong class of edge is found and fixed once. At the bottom of the ladder+repowise declines to guess, trading recall for precision. The design and the+capture queries are in+[architecture/graph-algorithms.md](../architecture/graph-algorithms.md#call-edges-capture-resolution-and-measurement).-**Resolution** is working out what a captured name points at.-`repo.save(draft)` hands you the name `save` and a receiver spelled `repo`, and-the job is to turn that into one declaration in one file. This is where the 39-resolution origins live.+## How far to trust it-| Stage | Fails when | Costs you | How you find out |-|---|---|---|---|-| Capture | no query covers that call shape | recall: the edge does not exist | nothing internal can tell you; it takes an outside answer key |-| Resolution | the receiver cannot be typed, or the name is ambiguous | precision if it guesses, recall if it declines | the origin on the edge names the strategy, so a wrong class of edge is found and fixed once |--That asymmetry sets the design. A missed capture is silent, so it is measured-against a compiler. A bad resolution is loud, so every edge is stamped with the-strategy that produced it, and nothing is allowed to launder a guess into a-fact.--At the bottom of the ladder repowise declines to guess. That costs recall, and-it is the right way round.-------## How good is it, and how we know--Measured on main, freshly indexed from source, on 2026-10-03.--- **Against a compiler, Go and TypeScript.** Seven cells over five- repositories, 37,853 compiler edges (the Go team's RTA call graph and `tsc`'s- own resolution). Precision runs 0.976 to 0.995, and recall is higher than our- August figure in all seven cells. In all seven, no tool in the five-tool- comparison that finds as much of the call graph gets more of it right. Two- tools post higher precision in some cells by drawing much smaller graphs.-- **Against compiler indexes for more languages.** Java on jsoup reads 0.781- precision against javac (0.725 to 0.781 across three repositories). C on git, a- repository held out from all tuning, reads 0.979 precision at 0.83 recall.- C#, C++, Rust and Python (against jedi, a static analyser) are in the same- table.-- **Hand-graded across nine languages.** 280 call edges per tool, 560 in all,- each read with its imports and enclosing scope open: 240 of 280 correct for- repowise (85.7%) against 164 of 280 for CodeGraph 1.5.0 (58.6%), intervals- disjoint. Read the other way round, about one call edge in seven (roughly- fourteen percent) is wrong, concentrated in Rust, C++ and Java.--Recall is the column we do not lead everywhere. Against the compiler we lead-recall in three of the seven cells and trail in four. Where our misses go is-mostly dynamic dispatch, which no tool in the comparison has cleared without-emitting several wrong edges for each right one.--The per-language table, the five-tool table and the method are in-[BENCHMARKS.md: accuracy by language](../BENCHMARKS.md#accuracy-by-language) and-[BENCHMARKS.md: call graph against a compiler](../BENCHMARKS.md#8-the-same-question-against-an-answer-key-we-do-not-control).-The hand-graded rows are in-[BENCHMARKS.md: hand-graded](../BENCHMARKS.md#7-edge-precision).-----+| Answer key | Scope | Result |+|---|---|---|+| Compiler (Go RTA call graph, `tsc`) | Go and TypeScript, 7 cells over 5 repositories, 37,853 compiler edges | Precision 0.976 to 0.995 |+| javac | Java, 3 repositories | Precision 0.725 to 0.781 (0.781 on jsoup) |+| Compiler index | C on git, held out from all tuning | Precision 0.979 at 0.83 recall |+| Hand-graded | 280 call edges across nine languages | 240 of 280 correct (85.7%); errors cluster in Rust, C++ and Java |++In all seven Go and TypeScript cells, no tool in the five-tool comparison that+finds as much of the call graph gets more of it right; two tools post higher+precision in some cells by drawing much smaller graphs. Recall leads in three of+the seven cells, and most misses are dynamic dispatch. C#, C++, Rust and Python+(against jedi, a static analyser) are measured in the same table.++Per-language figures, the five-tool table and sample sizes:+[BENCHMARKS.md: accuracy by language](../BENCHMARKS.md#accuracy-by-language),+[call graph against a compiler](../BENCHMARKS.md#call-graph-against-a-compiler-five-tools)+and [hand-graded](../BENCHMARKS.md#call-edges-hand-graded-across-nine-languages).## What is in the graph@@ -171,9 +92,8 @@ external nodes, so a dependency is visible without being documented.**Two families of edge.** Structure the parser can see (imports, calls,inheritance) and structure only history can see (files that keep changing-together without importing each other). They are kept apart on purpose. A-co-change edge is real signal, but treating it as a dependency would put "these-two files were edited in the same commit" into your import graph.+together without importing each other). They are kept apart, so a shared commit+never appears in your import graph as a dependency.Every consumer reads the graph through one of three shared views, so no twofeatures disagree about what counts as a dependency:@@ -184,15 +104,13 @@ features disagree about what counts as a dependency:| Symbol use | "what reaches this symbol?" Containment is excluded, since a class holding a method is not a use of it || Reachability | "does anything use this at all?" The dead-code view |-----## Every edge says how it got thereEach `calls` and `references` edge is stamped with a **resolution origin**: thenamed strategy that produced it. There are 39, from a closed vocabulary, and-each one carries exactly one confidence. The table lists the 18 base origins;-the other 21 are receiver-typing variants, covered in-[Typing the receiver](#typing-the-receiver).+each one carries exactly one confidence, so the origin distribution and the+confidence histogram are two views of the same data. The table lists the 18+base origins; the other 21 are [receiver-typing variants](#typing-the-receiver).| Confidence | Origin | What was established ||:---:|---|---|@@ -215,10 +133,6 @@ the other 21 are receiver-typing variants, covered in| 0.75 | `receiver_global` | The `(class, method)` pair exists somewhere in the repo || 0.50 | `global_unique` | The name is unique repo-wide. A guess, and stored as one |-Because every origin has exactly one confidence, the origin distribution and the-confidence histogram are two views of the same data. That is what makes the-stamping checkable.-### How an agent should read confidence| Confidence | Read it as |@@ -230,17 +144,12 @@ stamping checkable.An agent tracing a flow can decline anything below a threshold and know what itdeclined. A reviewer reading a blast radius can tell "this definitely breaks"-from "this shares a method name with something that breaks". When the graph is-wrong, the origin names which strategy was wrong, so it is fixed once for every-call site that strategy touched.-----+from "this shares a method name with something that breaks".## Typing the receiver-21 of the 39 origins exist to answer the `user.save()` question properly. They-read the receiver's declaration and resolve the method on that type, instead of-matching a bare method name.+21 of the 39 origins read the receiver's declaration and resolve the method on+that type, instead of matching a bare method name.```javavoid handle(UserRepo repo) { // parameter declares the type@@ -250,9 +159,6 @@ void handle(UserRepo repo) { // parameter declares the type}```-Each receiver shape is its own origin family, so each can be measured on its-own:-| Family | Example | Origins ||---|---|:---:|| Locals and parameters, including Go's method receiver | `var repo = new UserRepo()`, `func (s *Server) handle()` | 4 |@@ -264,22 +170,15 @@ own:The families map onto the same scopes as the base origins (same file, samepackage, import, global), and a typed origin shares its untyped twin's-confidence. The inferred type had to declare the method before any edge was-emitted, so the evidence is no weaker. What differs is how the receiver was-named, and naming that difference is the point of an origin.--Declaration scanning covers Java, C#, Python, Go, Kotlin, Swift, TypeScript,-Rust and C++. A language outside that list falls back to the base origins and-says so on every edge.-----+confidence: the inferred type had to declare the method before any edge was+emitted. Declaration scanning covers Java, C#, Python, Go, Kotlin, Swift,+TypeScript, Rust and C++. Other languages use the base origins and say so on+every edge.-## Seventeen edge types, because `calls` was doing too many jobs+## Edge types-An edge type is a claim. If one type carries several different claims, every-consumer downstream has to guess which one it is looking at. The graph has 17-edge types. These six carry the distinctions that matter most when you read an-answer:+The graph has 17 edge types, each one a distinct claim. These six matter most+when you read an answer:| Edge | Claims | Does not claim ||---|---|---|@@ -292,26 +191,14 @@ answer:The other eleven are `imports`, `defines`, `has_method`, `extends`,`implements`, `method_implements`, `framework`, `reads`, `dynamic_uses`,-`dynamic_imports` and `dynamic_url_route`.--The `references` distinction is not academic. A handler sitting in a dispatch-table is never called anywhere a parser can see. Counting that as "no use"-would report entire registration layers as safe to delete.--`framework_binds` is separated from `calls` for the opposite reason. A fixture-nobody calls and a collaborator nobody constructs are both used, by the-container. But an inferred wiring hop is not source, and letting it render as a-call would put it into an execution flow as though someone had written it.-----+`dynamic_imports` and `dynamic_url_route`. A `references` edge keeps+registration layers out of dead-code reports, and a `framework_binds` hop counts+as a use without appearing in an execution flow as a call.## Flows that say why they stopped-An execution flow walks the call graph from an entry point. Every walk ends, and-a trace that just stops reads the same whether execution really ends there or-the walker ran out of things it could follow.--So every flow ends with one of six reasons:+An execution flow walks the call graph from an entry point, and every flow ends+with one of six reasons:| Termination | Meaning ||---|---|@@ -322,40 +209,24 @@ So every flow ends with one of six reasons:| `excluded_target` | Every successor was a test, demo or fixture node || `callees_truncated` | Rows were cut before the walk saw them |-Two details carry most of the value. `no_callees` is deliberately not called a-leaf: a symbol whose calls we failed to resolve looks exactly like a function-that calls nothing, and asserting the second is a claim the graph cannot-support. When a confidence floor stopped the walk, the flow reports which-origins it declined, which is the part you can act on.-----+`no_callees` is not called a leaf: a symbol whose calls were not resolved looks+the same as a function that calls nothing. When a confidence floor stopped the+walk, the flow reports which origins it declined.## What the graph powers-The graph is not the product. These are:--- **Blast radius.** Change a file, walk the dependency edges, get the set of- things that can break. Confidence travels with it, so a speculative hop is- visible as one.-- **Dead code.** Reachability over the union view, not over `calls` alone. A- symbol reached only by a framework, a dispatch table or a type reference is- not dead, and each of those is a different edge type for this reason.-- **Communities.** Leiden clustering (Louvain as fallback) finds the modules- your codebase actually has, which is often not the directory layout.-- **Centrality.** PageRank over the file tier ranks what everything depends on.- Betweenness finds the bridges whose removal splits the graph. Neither is fed- co-change edges, because "changes alongside many things" is not "many things- depend on it".-- **Cycles.** Strongly connected components, which need their own documentation- order because nothing in them can be explained before the others.-- **Execution flows.** Entry point to leaf, ranked, with the termination reason- attached.-- **Framework wiring.** Framework handlers connect routes to handlers, DI- registrations to implementations and ORM entities to their relationships,- across Django, FastAPI, Flask, Spring, ASP.NET, Rails, Laravel, Next.js,- Express, Axum, Gin and more.-----+| Feature | What the graph contributes |+|---|---|+| Blast radius | The set of things a change can break, with confidence on every hop |+| Dead code | Reachability over the union view, so a symbol reached only by a framework, a dispatch table or a type reference is not dead |+| Communities | Leiden clustering (Louvain as fallback) finds the modules your codebase actually has, often not the directory layout |+| Centrality | PageRank over the file tier ranks what everything depends on; betweenness finds the bridges. Neither is fed co-change edges |+| Cycles | Strongly connected components, documented together because nothing in them can be explained before the others |+| Execution flows | Entry point to leaf, ranked, with the termination reason attached |+| Framework wiring | Routes to handlers, DI registrations to implementations, ORM entities to relationships, across Django, FastAPI, Flask, Spring, ASP.NET, Rails, Laravel, Next.js, Express, Axum, Gin and more |++The algorithms behind these are in+[architecture/graph-algorithms.md](../architecture/graph-algorithms.md).## Seeing it yourself@@ -376,61 +247,41 @@ Opt-in tools are enabled through the tool surface settings; see**In the dashboard**, `repowise serve` gives you the Graph, Architecture,Coupling, Blast radius, Knowledge graph and Dead code views.-**Across a multi-repo workspace**, a service-level system graph built from-contracts and package dependencies adds declared dependency rules, cycle-detection, a dependency-structure matrix and a 1-10 architecture score. Those-rules work between services, not between layers inside one repository. See+**Across a multi-repo workspace**, a service-level system graph adds declared+dependency rules between services, cycle detection, a dependency-structure matrix+and a 1-10 architecture score; see[Architecture Conformance](../scale/WORKSPACES.md#architecture-conformance) and[Architecture Metrics](../scale/WORKSPACES.md#architecture-metrics).-**Everything above is computed without a model call.** An LLM is an optional-upgrade for prose quality in the wiki. It is never part of building the graph,-which is why the graph is reproducible and why indexing needs no API key.-------## Honest ceilings--- **Resolution quality varies by language.** The- [language support page](LANGUAGE_SUPPORT.md) says what each rung covers.- Statically typed languages with explicit declarations resolve best.- Dynamically typed and reflective code resolves worst, and falls back to the- low-confidence origins.-- **Receiver typing reads declarations with per-language patterns**, not a full- type checker. A declaration the patterns cannot see is a receiver that does- not get typed, and the call falls back to a weaker origin.-- **`dispatches_to` compares no signature.** It matches by method name, so it- names a possible dispatch target, not a proven override.-- **A repo-wide unique name is still a guess**, and `global_unique` at 0.50 is- where that lives. It is kept because a labelled guess beats a missing edge for- reachability, and it is labelled so nothing downstream mistakes it for a fact.-- **Unused methods are not reported**, for any language. Method-level precision- did not hold up when measured, and shipping it would mean confidently- recommending wrong deletions.-- **About fourteen percent of our call edges are wrong** on the hand-graded- sample (85.7% correct over 280 rows), and we trail on recall in four of seven+## Limits++- Statically typed languages with explicit declarations resolve best;+ dynamically typed and reflective code falls back to the low-confidence origins.+- Receiver typing reads declarations with per-language patterns, not a full+ type checker, so a declaration the patterns cannot see leaves a weaker origin.+- `dispatches_to` compares no signature: a possible target, not a proven override.+- `global_unique` at 0.50 is a labelled guess, kept for reachability.+- Unused methods are not reported for any language, because method-level+ precision is too low to recommend deletions.+- About one call edge in seven is wrong on the hand-graded sample (85.7%+ correct over 280 rows). Recall is lower than the leading tool in four of sevencompiler-graded cells.-- **Overloads cost precision on Java and C#.** The graph keeps one node per- overload set, so a call to the right method can land on the wrong overload.- On C#, plan against the compiler figure (0.73 to 0.92), not the hand-graded- 30 of 30.-- **Precision is published for ten languages, not all 26.** Go, TypeScript,- Java, C#, C, C++, Rust and Python have a compiler or analyser answer key.- Kotlin and Swift have the hand-graded sample only, at 30 rows each. The other- full-AST languages have no published precision figure.-- **A precision figure without the recall beside it is a misuse of this data**,- including by us. Two tools beat us on precision in some compiler cells, each by- drawing a much smaller graph.-----+- The graph keeps one node per overload set, so on Java and C# a call can land+ on the wrong overload. On C#, plan against the compiler figure (0.73 to 0.92),+ not the hand-graded 30 of 30.+- Precision is published for ten of the 26 full-AST languages. Go, TypeScript,+ Java, C#, C, C++, Rust and Python have a compiler or analyser answer key;+ Kotlin and Swift have the hand-graded sample only, at 30 rows each.+- Read a precision figure together with its recall. Two tools post higher+ precision in some compiler cells, each by drawing a much smaller graph.## See also-- [LANGUAGE_SUPPORT.md](LANGUAGE_SUPPORT.md) · what works per language, and the tier each one sits in-- [architecture/language-support.md](../architecture/language-support.md) · call resolution internals and the contributor recipe-- [architecture/graph-algorithms.md](../architecture/graph-algorithms.md) · PageRank, Leiden, betweenness and SCC in detail-- [DEAD_CODE.md](DEAD_CODE.md) · how reachability becomes a confidence-tiered report-- [CHANGE_RISK.md](CHANGE_RISK.md) · how live diff-shape review and structural PR impact stay distinct-- [reference/COMPUTED_GLOSSARY.md](../reference/COMPUTED_GLOSSARY.md) · every derived metric, defined-- [BENCHMARKS.md](../BENCHMARKS.md#accuracy-by-language) · the accuracy numbers on this page, with sample sizes, intervals and method-- [repowise-bench/graph](https://github.com/repowise-dev/repowise-bench/tree/master/graph) · the harnesses, the graded rows and the pre-registrations+- [LANGUAGE_SUPPORT.md](LANGUAGE_SUPPORT.md): what works per language, and the tier each one sits in+- [architecture/language-support.md](../architecture/language-support.md): call resolution internals and the contributor recipe+- [architecture/graph-algorithms.md](../architecture/graph-algorithms.md): PageRank, Leiden, betweenness and SCC, plus how call edges are captured and measured+- [DEAD_CODE.md](DEAD_CODE.md): how reachability becomes a confidence-tiered report+- [CHANGE_RISK.md](CHANGE_RISK.md): how live diff-shape review and structural PR impact stay distinct+- [reference/COMPUTED_GLOSSARY.md](../reference/COMPUTED_GLOSSARY.md): every derived metric, defined+- [BENCHMARKS.md](../BENCHMARKS.md#accuracy-by-language): the accuracy numbers on this page, with sample sizes, intervals and method+- [repowise-bench/graph](https://github.com/repowise-dev/repowise-bench/tree/master/graph): the harnesses, the graded rows and the pre-registrationsdiff --git a/docs/layers/INTELLIGENCE_LAYERS.md b/docs/layers/INTELLIGENCE_LAYERS.mdindex 7a629e849..41d918c4a 100644--- a/docs/layers/INTELLIGENCE_LAYERS.md+++ b/docs/layers/INTELLIGENCE_LAYERS.md@@ -6,11 +6,11 @@ combination of them. This page is the map: what each layer holds, what is builtit, and which page has the detail.```- What you use answers · change risk · Fix first · dead code · impacted tests- refactoring plans · doc drift · contracts across repositories- ▲- Five layers 1 Graph · 2 Git history · 3 Docs · 4 Decisions · 5 Health- ▲+ What you use answers, change risk, Fix first, dead code, impacted tests,+ refactoring plans, doc drift, contracts across repositories+ ^+ Five layers 1 Graph, 2 Git history, 3 Docs, 4 Decisions, 5 Health+ ^One index your source, its git history, your markdown, your coverage```@@ -134,8 +134,8 @@ impact and architecture rules you can gate in CI. See| What is this file or symbol, who calls it? | `repowise context`, `repowise symbol` | `get_context`, `get_symbol` || What breaks if I change it? | `repowise risk` | `get_risk`, `get_change_risk` || Why is it built this way? | `repowise why` | `get_why` |-| What should we fix first? | `repowise next`, `repowise health` | `get_health` |-| What can we delete? | `repowise dead-code` | `get_dead_code` |+| What should be fixed first? | `repowise next`, `repowise health` | `get_health` |+| What can be deleted? | `repowise dead-code` | `get_dead_code` || Which tests matter? | `repowise impacted-tests` | `get_risk(changed_files=[...])` |18 MCP tools are registered; a single-repo server exposes 10 by default and the restdiff --git a/docs/layers/LANGUAGE_SUPPORT.md b/docs/layers/LANGUAGE_SUPPORT.mdindex b49e5ffff..a385ab75f 100644--- a/docs/layers/LANGUAGE_SUPPORT.md+++ b/docs/layers/LANGUAGE_SUPPORT.md@@ -9,68 +9,47 @@ resolution and health markers are all static.<p><strong>Full tier </strong>- <img src="https://img.shields.io/badge/Python-3776AB?style=flat-square&logo=python&logoColor=white" alt="Python" />- <img src="https://img.shields.io/badge/TypeScript-3178C6?style=flat-square&logo=typescript&logoColor=white" alt="TypeScript" />- <img src="https://img.shields.io/badge/JavaScript-F7DF1E?style=flat-square&logo=javascript&logoColor=black" alt="JavaScript" />- <img src="https://img.shields.io/badge/Svelte-FF3E00?style=flat-square&logo=svelte&logoColor=white" alt="Svelte" />- <img src="https://img.shields.io/badge/Vue-42B883?style=flat-square&logo=vuedotjs&logoColor=white" alt="Vue" />- <img src="https://img.shields.io/badge/Java-ED8B00?style=flat-square&logo=openjdk&logoColor=white" alt="Java" />- <img src="https://img.shields.io/badge/Kotlin-7F52FF?style=flat-square&logo=kotlin&logoColor=white" alt="Kotlin" />- <img src="https://img.shields.io/badge/Go-00ADD8?style=flat-square&logo=go&logoColor=white" alt="Go" />- <img src="https://img.shields.io/badge/Rust-000000?style=flat-square&logo=rust&logoColor=white" alt="Rust" />- <img src="https://img.shields.io/badge/C++-00599C?style=flat-square&logo=cplusplus&logoColor=white" alt="C++" />- <img src="https://img.shields.io/badge/C%23-512BD4?style=flat-square&logo=csharp&logoColor=white" alt="C#" />- <img src="https://img.shields.io/badge/Scala-DC322F?style=flat-square&logo=scala&logoColor=white" alt="Scala" />+ <img src="https://img.shields.io/badge/Python-3776AB?style=flat-square&logo=python&logoColor=white" alt="Python" /> <img src="https://img.shields.io/badge/TypeScript-3178C6?style=flat-square&logo=typescript&logoColor=white" alt="TypeScript" /> <img src="https://img.shields.io/badge/JavaScript-F7DF1E?style=flat-square&logo=javascript&logoColor=black" alt="JavaScript" /> <img src="https://img.shields.io/badge/Svelte-FF3E00?style=flat-square&logo=svelte&logoColor=white" alt="Svelte" />+ <img src="https://img.shields.io/badge/Vue-42B883?style=flat-square&logo=vuedotjs&logoColor=white" alt="Vue" /> <img src="https://img.shields.io/badge/Java-ED8B00?style=flat-square&logo=openjdk&logoColor=white" alt="Java" /> <img src="https://img.shields.io/badge/Kotlin-7F52FF?style=flat-square&logo=kotlin&logoColor=white" alt="Kotlin" /> <img src="https://img.shields.io/badge/Go-00ADD8?style=flat-square&logo=go&logoColor=white" alt="Go" />+ <img src="https://img.shields.io/badge/Rust-000000?style=flat-square&logo=rust&logoColor=white" alt="Rust" /> <img src="https://img.shields.io/badge/C++-00599C?style=flat-square&logo=cplusplus&logoColor=white" alt="C++" /> <img src="https://img.shields.io/badge/C%23-512BD4?style=flat-square&logo=csharp&logoColor=white" alt="C#" /> <img src="https://img.shields.io/badge/Scala-DC322F?style=flat-square&logo=scala&logoColor=white" alt="Scala" /><img src="https://img.shields.io/badge/Ruby-CC342D?style=flat-square&logo=ruby&logoColor=white" alt="Ruby" /></p><p><strong>Good tier </strong>- <img src="https://img.shields.io/badge/C-A8B9CC?style=flat-square&logo=c&logoColor=black" alt="C" />- <img src="https://img.shields.io/badge/Swift-F05138?style=flat-square&logo=swift&logoColor=white" alt="Swift" />- <img src="https://img.shields.io/badge/PHP-777BB4?style=flat-square&logo=php&logoColor=white" alt="PHP" />- <img src="https://img.shields.io/badge/Dart-0175C2?style=flat-square&logo=dart&logoColor=white" alt="Dart" />- <img src="https://img.shields.io/badge/Delphi-EE1F35?style=flat-square&logo=delphi&logoColor=white" alt="Object Pascal / Delphi" />- <img src="https://img.shields.io/badge/COBOL-005CA5?style=flat-square" alt="COBOL" />- <img src="https://img.shields.io/badge/GDScript-478CBF?style=flat-square&logo=godotengine&logoColor=white" alt="GDScript / Godot" />- <img src="https://img.shields.io/badge/VB.NET-945DB7?style=flat-square&logo=dotnet&logoColor=white" alt="VB.NET" />- <img src="https://img.shields.io/badge/Elixir-6E4A7E?style=flat-square&logo=elixir&logoColor=white" alt="Elixir" />- <img src="https://img.shields.io/badge/F%23-378BBA?style=flat-square&logo=fsharp&logoColor=white" alt="F#" />- <img src="https://img.shields.io/badge/Objective--C-438EFF?style=flat-square&logo=apple&logoColor=white" alt="Objective-C" />- <strong>· Partial </strong>- <img src="https://img.shields.io/badge/Luau-00A2FF?style=flat-square&logo=lua&logoColor=white" alt="Luau" />- <img src="https://img.shields.io/badge/Razor-512BD4?style=flat-square&logo=blazor&logoColor=white" alt="Razor / Blazor" />+ <img src="https://img.shields.io/badge/C-A8B9CC?style=flat-square&logo=c&logoColor=black" alt="C" /> <img src="https://img.shields.io/badge/Swift-F05138?style=flat-square&logo=swift&logoColor=white" alt="Swift" /> <img src="https://img.shields.io/badge/PHP-777BB4?style=flat-square&logo=php&logoColor=white" alt="PHP" /> <img src="https://img.shields.io/badge/Dart-0175C2?style=flat-square&logo=dart&logoColor=white" alt="Dart" />+ <img src="https://img.shields.io/badge/Delphi-EE1F35?style=flat-square&logo=delphi&logoColor=white" alt="Object Pascal / Delphi" /> <img src="https://img.shields.io/badge/COBOL-005CA5?style=flat-square" alt="COBOL" /> <img src="https://img.shields.io/badge/GDScript-478CBF?style=flat-square&logo=godotengine&logoColor=white" alt="GDScript / Godot" /> <img src="https://img.shields.io/badge/VB.NET-945DB7?style=flat-square&logo=dotnet&logoColor=white" alt="VB.NET" />+ <img src="https://img.shields.io/badge/Elixir-6E4A7E?style=flat-square&logo=elixir&logoColor=white" alt="Elixir" /> <img src="https://img.shields.io/badge/F%23-378BBA?style=flat-square&logo=fsharp&logoColor=white" alt="F#" /> <img src="https://img.shields.io/badge/Objective--C-438EFF?style=flat-square&logo=apple&logoColor=white" alt="Objective-C" />+</p>+<p>+ <strong>Partial tier </strong>+ <img src="https://img.shields.io/badge/Luau-00A2FF?style=flat-square&logo=lua&logoColor=white" alt="Luau" /> <img src="https://img.shields.io/badge/Razor-512BD4?style=flat-square&logo=blazor&logoColor=white" alt="Razor / Blazor" /></p>-**Contents:** [Tiers](#tiers) ·-[What the pipeline gives each tier](#what-the-pipeline-gives-each-tier) ·-[How accurate is the graph per language](#how-accurate-is-the-graph-per-language) ·-[Full tier](#full-tier) · [Good tier](#good-tier) ·-[Beyond code files](#beyond-code-files) ·-[Code-health coverage](#code-health-coverage) ·-[Known ceilings](#known-ceilings) · [Roadmap](#roadmap) ·-[Requesting or adding a language](#requesting-or-adding-a-language)-----+**Contents:** [Tiers](#tiers), [What the pipeline gives each tier](#what-the-pipeline-gives-each-tier),+[How accurate is the graph per language](#how-accurate-is-the-graph-per-language),+[Extensions and imports](#extensions-and-imports), [Framework-aware edges](#framework-aware-edges),+[Beyond code files](#beyond-code-files), [Code-health coverage](#code-health-coverage),+[Limits](#limits), [Roadmap](#roadmap), [Requesting or adding a language](#requesting-or-adding-a-language)## Tiers| Tier | Languages | What you get ||------|-----------|--------------|-| **Full** (13) | Python · TypeScript · JavaScript · Svelte · Vue · Java · Kotlin · Go · Rust · C++ · C# · Scala · Ruby | The whole pipeline: AST symbols, import resolution, a resolved call graph, heritage, docstrings, framework edges and code-health markers |-| **Good** (11) | C · Swift · PHP · Dart · Object Pascal · COBOL · GDScript · VB.NET · Elixir · F# · Objective-C | Everything above except the full health suite. Dart, Object Pascal and PHP get health markers; C, Swift, F# and Objective-C get the complexity-derived ones; the rest get none yet |-| **Partial** (2) | Luau / Roblox · Razor / Blazor | Luau: AST symbols and `require()` resolution (Rojo and `.luaurc` aware), no health markers. Razor: a component symbol per file, call edges from `@code` blocks and component tags, C# health markers, no import edges yet |-| **Lightweight** (6) | Clojure · Haskell · Lean 4 · Erlang · HTML · QML | A real file-to-file import graph, no symbol-level claims |-| **Structural** (8) | R · Zig · Julia · Elm · OCaml · Crystal · Nim · D | Git history only: blame, hotspots, co-change. No AST parsing |+| **Full** (13) | Python, TypeScript, JavaScript, Svelte, Vue, Java, Kotlin, Go, Rust, C++, C#, Scala, Ruby | The whole pipeline: AST symbols, import resolution, a resolved call graph, heritage, docstrings, framework edges and code-health markers |+| **Good** (11) | C, Swift, PHP, Dart, Object Pascal, COBOL, GDScript, VB.NET, Elixir, F#, Objective-C | Everything above except the full health suite. Dart, Object Pascal and PHP get health markers; C, Swift, F# and Objective-C get the complexity-derived ones; the rest get none yet |+| **Partial** (2) | Luau / Roblox, Razor / Blazor | Luau: AST symbols and `require()` resolution (Rojo and `.luaurc` aware), no health markers. Razor: a component symbol per file, call edges from `@code` blocks and component tags, C# health markers, no import edges yet |+| **Lightweight** (6) | Clojure, Haskell, Lean 4, Erlang, HTML, QML | A real file-to-file import graph, no symbol-level claims |+| **Structural** (8) | R, Zig, Julia, Elm, OCaml, Crystal, Nim, D | Git history only: blame, hotspots, co-change. No AST parsing |Tree-sitter parsing covers the first three rungs: those are the **26 languagesparsed to a full AST**. The bottom two rungs come from git history and importextraction, and all five together make the **40** on the ladder.-[SQL / dbt](#sql--dbt) and [shell](#shell) sit outside the ladder on purpose,-because neither fits a rung: SQL gets symbols and health markers but no call-graph, and shell gets symbols, `source` edges and complexity but no dead-code-claims. Cross-repo contracts (HTTP routes, gRPC, queues, sockets, database-tables) are listed per language and framework in+[SQL / dbt](#sql--dbt) and [shell](#shell) sit outside the ladder, because+neither fits a rung: SQL gets symbols and health markers but no call graph, and+shell gets symbols, `source` edges and complexity but no dead-code claims.+Cross-repo contracts (HTTP routes, gRPC, queues, sockets, database tables) are+listed per language and framework in[WORKSPACES.md](../scale/WORKSPACES.md#api-contract-extraction).## What the pipeline gives each tier@@ -87,26 +66,20 @@ tables) are listed per language and framework in| Dead code detection | ✅ | ✅* | ✅ | ✅ | ✅ || Semantic search and wiki pages | ✅ | ✅ | ✅ | ✅ | ✅ |-Scala, Elixir and F# have dedicated import resolvers with known gaps. Object-Pascal and Objective-C resolve through a generic unit-name or header-stem match,-and COBOL resolves literal program calls, not imports. Every other Full and Good-language has a dedicated import resolver.+Every Full and Good language has a dedicated import resolver except Object+Pascal and Objective-C, which resolve through a generic unit-name or header-stem+match, and COBOL, which resolves literal program calls instead of imports.+Scala, Elixir and F# have dedicated import resolvers with known gaps; see+[Limits](#limits).\* COBOL is excluded from dead-code claims: JCL, schedulers and dynamic programcalls are entry paths the repository graph cannot observe.-Every `calls` edge records how it was resolved and carries a confidence from-that, and a call on a typed variable resolves through the variable's declared-type. [GRAPH.md](GRAPH.md) covers resolution origins, receiver typing and-execution flows.-## How accurate is the graph per language-Call-graph precision and recall differ by language, because resolution depends-on what the grammar and the type system expose. Measured figures per language,-with the corpus and method behind them, are in-[BENCHMARKS.md](../BENCHMARKS.md#accuracy-by-language). This page states only-what each rung covers, not how well.+Precision and recall differ by language, because resolution depends on what the+grammar and the type system expose. Measured figures per language, with corpus+and method, are in [BENCHMARKS.md](../BENCHMARKS.md#accuracy-by-language).### Every call edge says how it was resolved, and how much to trust it@@ -155,40 +128,32 @@ vocabulary, and every origin has exactly one confidence:| `return_type_global` | 0.75 | The returned type and method pair exists somewhere in the repo || `global_unique` | 0.50 | The name is unique repo-wide. **A guess, and labelled as one** |-That is the complete vocabulary of 39. You can filter a graph by confidence, and both-the MCP tools and the web UI surface which origin produced an edge, so an agent-reading an execution flow can tell a fact from an inference instead of treating-both as source.+That is the complete vocabulary of 39. You can filter a graph by confidence, and+both the MCP tools and the web UI surface which origin produced an edge, so an+agent reading an execution flow can tell a fact from an inference. Receiver+typing, execution-flow terminations and the edge types are in+[GRAPH.md](GRAPH.md).-Receiver typing, execution-flow terminations and the edge types are in [GRAPH.md](GRAPH.md).+## Extensions and imports----+Each Full and Good language claims its usual file extensions (C++ also claims+headers such as `.hpp`, `.inl` and `.tpp`) and resolves imports through its own+build files: tsconfig path aliases and workspaces, Maven and Gradle reactors,+`go.mod`, `Cargo.toml`, `compile_commands.json`, `.csproj` / `.sln`, PSR-4,+`pubspec.yaml`, `project.godot` and so on. The table per language is in+[architecture/language-support.md](../architecture/language-support.md#extensions-and-import-resolution).-## Full tier+`.svelte`, `.vue` and Razor files are projected into TypeScript or C# at the+same byte offsets, so they get that language's queries and health markers and+every line number points at the real source. How the projection works:+[architecture/language-support.md](../architecture/language-support.md#multi-language-files-the-sfc-pattern).-AST parsing, import resolution, call resolution, named bindings, heritage,-docstrings, framework-aware edges and code-health markers.--| Language | Extensions | Import resolution |-|----------|-----------|--------------|-| **Python** | `.py` `.pyi` | Source-root-aware module index (`src/`, monorepo `packages/*/src`, PEP 420), `__init__.py` re-export barrels |-| **TypeScript** | `.ts` `.tsx` `.mts` `.cts` | ESM and `require()`, tsconfig path aliases, npm/yarn/pnpm workspaces, `export * from` barrels |-| **JavaScript** | `.js` `.jsx` `.mjs` `.cjs` | `import` and `require()`, including CommonJS re-export shapes |-| **Svelte** | `.svelte` | The TS/JS resolver plus SvelteKit's `$lib` and `#` subpath imports |-| **Vue** | `.vue` | The TS/JS resolver plus config aliases, directory-index components, router `import()` specifiers |-| **Java** | `.java` | Maven and Gradle reactor discovery, JPMS, `import static`, package fan-out |-| **Kotlin** | `.kt` `.kts` | Shares the JVM index with Java, so resolution is cross-language |-| **Go** | `.go` | Multi-module `go.mod` discovery; a package import fans out to every file in the package |-| **Rust** | `.rs` | `use crate::` / `super::` / `self::` with `Cargo.toml` |-| **C++** | `.cpp` `.cc` `.cxx` `.h` `.hh` `.hpp` `.hxx` `.inl` `.ipp` `.tpp` `.inc` | `#include` via `compile_commands.json` plus CMake and Bazel header maps, header/implementation pairing |-| **C#** | `.cs` | `using`, `global using` and aliases via `.csproj` / `.sln`, MSBuild project graph, `partial` class linking |-| **Scala** | `.scala` | The shared JVM index, with SBT and Mill build parsing as fallback |-| **Ruby** | `.rb` | `require` / `require_relative` with `$LOAD_PATH` probing, Gemfile externals, Rails / Zeitwerk autoloading |--### Framework-aware edges+## Framework-aware edgesRoutes connect to handlers, DI registrations to implementations, and test-fixtures to the tests that use them.+fixtures to the tests that use them. The dead-code analyzer also knows each+ecosystem's entry points and generated files, so framework-invoked code is not+reported as unreachable.| Language | Frameworks ||----------|-----------|@@ -204,50 +169,15 @@ fixtures to the tests that use them.| Dart | Flutter route tables, `runApp()` and widget trees || GDScript | Godot scenes, autoloads, signal connections, `class_name` |-The dead-code analyzer also knows each ecosystem's entry points and generated-files, so framework-invoked code is not reported as unreachable.--### Single-file components and Razor--A `.svelte` or `.vue` file is projected into TypeScript at the same byte-offsets, so components get the TypeScript queries and health markers, and every-line number points at the real source. Razor (`.razor`, `.cshtml`) does the same-with its `@code` blocks projected into C#; it sits on the Partial rung because-it has no import edges yet.-------## Good tier--AST parsing, symbol extraction and static call resolution, plus the-dependency surface each language's syntax supports.--| Language | Extensions | Dependency resolution |-|----------|-----------|--------------|-| **C** | `.c` | `#include` via `compile_commands.json` (shares the C++ grammar) |-| **Swift** | `.swift` | SPM `Package.swift` targets, intra-module type references, `@main` entry points |-| **PHP** | `.php` | `use` declarations through PSR-4 from every `composer.json`, same-namespace and fully qualified class references |-| **Dart** | `.dart` | `import` / `export` / `part`, `package:` via every `pubspec.yaml` |-| **Object Pascal** | `.pas` `.pp` `.dpr` `.dpk` `.lpr` | `uses` clauses via unit-name to file-stem match; project files as entry points |-| **COBOL** | `.cbl` `.cob` `.cobol` `.cpy` | Literal `CALL` and `PERFORM` targets; dynamic calls and `COPY` stay silent |-| **GDScript** | `.gd` | `preload` / `load` / `extends "res://..."` from the nearest `project.godot` |-| **VB.NET** | `.vb` | `Imports` through the same MSBuild project index C# uses |-| **Elixir** | `.ex` `.exs` | `alias` / `import` / `require` / `use` against a `defmodule` index, Mix path convention as fallback |-| **F#** | `.fs` `.fsx` `.fsi` | `open` against a declared-name index plus the fsproj compile order; `.fsi` files contribute imports only |-| **Objective-C** | `.m` `.mm` `.h` | `#import` / `#include` through the header-stem index |------## Beyond code files### SQL / dbt-SQL is parsed by sqlglot (multi-dialect, error-tolerant), not tree-sitter.-+- Parsed by sqlglot (multi-dialect, error-tolerant), not tree-sitter. Set+ `sql_dialect` in config for dialect-specific syntax. A file that fails to+ parse is kept as plain text.- `CREATE TABLE` / `VIEW` become class-kind symbols with columns in the- signature; `CREATE FUNCTION` / `PROCEDURE` become functions. Set `sql_dialect`- in config for dialect-specific syntax. A file that fails to parse is kept as- plain text.+ signature; `CREATE FUNCTION` / `PROCEDURE` become functions.- dbt `{{ ref('model') }}` and `{{ source(...) }}` become import edges, so modellineage, hotspots, co-change and ownership work on dbt projects. Outside dbt,`.sql` files get symbols and pages but no import edges.@@ -260,29 +190,24 @@ SQL is parsed by sqlglot (multi-dialect, error-tolerant), not tree-sitter.### Shell`.sh` / `.bash` / `.zsh`: functions become symbols, `source` / `.` statements-become import edges (including `$SCRIPT_DIR/x.sh` and `$(dirname "$0")/x.sh`+become import edges (including the `$SCRIPT_DIR/x.sh` and `$(dirname "$0")/x.sh`idioms), and calls to functions in the same or a sourced file resolve. Shell-gets function-level complexity. No dead-code flagging: scripts are invoked by-name, so static reachability says nothing.--### Lightweight tier--Clojure, Haskell, Lean 4, Erlang, HTML and QML get a file-level import graph-resolved against a declared module-name index, with no symbol-level claims.-HTML contributes `<script src>` and `<link href>` edges (so `index.html` reaches-`src/main.ts` in a Vite or webpack app). HTML and QML files are never flagged-as dead code, since whether a page or a Qt component is reachable is decided at-runtime.--### Config and data--OpenAPI, Protobuf, GraphQL, Dockerfile, Makefile, YAML, JSON, TOML, Terraform-and Markdown appear in the file tree and the wiki. OpenAPI and Protobuf also feed-workspace contracts, and Terraform feeds AWS Lambda handler edges. Godot resource-files (`.tscn`, `.tres`, `.escn`, `project.godot`, `plugin.cfg`) carry no symbols-but are read for the script paths they name.-----+gets function-level complexity and no dead-code flagging, because scripts are+invoked by name.++### Lightweight and config files++- Lightweight languages resolve imports against a declared module-name index.+- OpenAPI, Protobuf, GraphQL, Dockerfile, Makefile, YAML, JSON, TOML, Terraform+ and Markdown appear in the file tree and the wiki.+- HTML contributes `<script src>` and `<link href>` edges, so `index.html`+ reaches `src/main.ts` in a Vite or webpack app.+- HTML and QML files are never flagged as dead code, since whether a page or a+ Qt component is reachable is decided at runtime.+- OpenAPI and Protobuf also feed workspace contracts, and Terraform feeds AWS+ Lambda handler edges.+- Godot resource files (`.tscn`, `.tres`, `.escn`, `project.godot`,+ `plugin.cfg`) carry no symbols but are read for the script paths they name.## Code-health coverage@@ -294,74 +219,64 @@ This table is why a language is Full and not Good.|----------|:---:|:---:|:---:|:---:|:---:|:---:|:---:|| Python | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ || TypeScript / JavaScript | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |-| Svelte · Vue | ✅ | ✅ | ✅ | no | no | ✅ | ✅ |+| Svelte, Vue | ✅ | ✅ | ✅ | no | no | ✅ | ✅ || Java | ✅ | ✅ | ✅ | no | no | ✅ | ✅ || Go | ✅ | n/a | ✅ | no | no | ✅ | ✅ |-| Rust · C++ · C# | ✅ | ✅ | ✅ | no | no | ✅ | ✅ |-| Scala · Ruby | ✅ | ✅ | ✅ | no | no | no | ✅ |+| Rust, C++, C# | ✅ | ✅ | ✅ | no | no | ✅ | ✅ |+| Scala, Ruby | ✅ | ✅ | ✅ | no | no | no | ✅ || Kotlin | ✅ | ✅ | ✅ | no | no | no | ✅ || Dart | ✅ | ✅ | ✅ | no | no | no | ✅ || Object Pascal | ✅ | n/a | ✅ | n/a | n/a | no | ✅ || Razor | ✅ | n/a | n/a | n/a | n/a | no | ✅ || PHP | ✅ | ✅ | ✅ | no | no | no | no || C | ✅ | no | no | no | no | ✅ | no |-| F# · Objective-C | ✅ | ✅ | no | no | no | no | no |+| F#, Objective-C | ✅ | ✅ | no | no | no | no | no || Shell | ✅ | n/a | n/a | n/a | n/a | n/a | n/a |✅ supported, "no" not available yet, n/a the language cannot carry that metric.-Dart, F#, and Objective-C report class size, method count, and CCN (supporting detectors like God Class), but do not compute cohesion metrics (LCOM4).-An unmapped language produces no findings, never guessed ones. The two-test-quality markers (mock saturation, assertion-free test) are advisory and-never deduct from a score. Why Go and Java are held back from them, and why-Kotlin's Extract Method waits on its grammar, is in++- Dart, F# and Objective-C report class size, method count and CCN (supporting+ detectors like God Class), but do not compute cohesion metrics (LCOM4).+- An unmapped language produces no findings, never guessed ones.+- The two test-quality markers (mock saturation, assertion-free test) are+ advisory and never deduct from a score.++Why Go and Java are held back from the test-quality markers, and why Kotlin's+Extract Method waits on its grammar:[architecture/language-support.md](../architecture/language-support.md#test-quality-markers-per-language).-Per-marker detail is in [CODE_HEALTH.md](CODE_HEALTH.md).-------## Known ceilings--- **Template dialects are invisible.** Django/Jinja, Go templates, ERB,- Handlebars, Blade and Thymeleaf parse as HTML and yield nothing.-- **Svelte and Vue binding forms are skipped.** `{#each x as y}` and- `v-for="x in xs"` are not resolved, and the unused-export pass is off for- both, since props are set by the parent as markup attributes.-- **Object Pascal type kinds collapse** to `kind="class"`, and its `extends`- vs `implements` split follows the `I`-prefix naming convention.-- **COBOL is COBOL-85 shaped.** `COPY` does not create an edge; dynamic program- names and dialect extensions stay silent.-- **Razor has no import edges.**-- **GDScript string dispatch is unresolved**, and a script without `class_name`- gets no class symbol.-- **VB.NET leaves a few constructs unparsed**, XML and tuple literals among them.-- **C has no performance risk support.** Extract Method reuses the C++- def/use dialect; C carries none of the C++-only nodes, so the same plan- fires for both.-- **Scala import resolution is partial**, and ScalaTest's infix DSL- (`x shouldBe y`) is not counted as an assertion.--Mechanics behind these:-[architecture/language-support.md](../architecture/language-support.md#per-language-mechanics).-----+Per-marker detail: [CODE_HEALTH.md](CODE_HEALTH.md).++## Limits++- Template dialects (Django/Jinja, Go templates, ERB, Handlebars, Blade,+ Thymeleaf) parse as HTML and yield nothing.+- Svelte and Vue binding forms (`{#each}`, `v-for`) are not resolved, and the+ unused-export pass is off for both.+- Razor has no import edges.+- Scala import resolution is partial, and the Elixir and F# import resolvers+ have known gaps.+- COBOL support is COBOL-85 shaped: `COPY`, dynamic program names and dialect+ extensions produce no edges.+- C has no performance risk support.++The full list per language, with the mechanics behind each gap, is in+[architecture/language-support.md](../architecture/language-support.md#known-gaps-per-language).## Roadmap| Language | Next ||----------|------|-| Vue · Svelte | Template binding forms (`v-for`, `{#each}`) |+| Vue, Svelte | Template binding forms (`v-for`, `{#each}`) || Kotlin | Extract Method, which needs a grammar that labels control flow |-| Scala · Ruby | Extract Method (dataflow dialect) |+| Scala, Ruby | Extract Method (dataflow dialect) || GDScript | Health markers (complexity, performance, dataflow) || Object Pascal | A dedicated `uses` resolver || COBOL | Copybook resolution, dialect coverage, health markers |-| VB.NET · Elixir | Health markers |-| F# · Objective-C | Health markers beyond complexity |+| VB.NET, Elixir | Health markers |+| F#, Objective-C | Health markers beyond complexity || SQL / dbt | Column-level blast radius || Shell | Shebang detection for extensionless executables |-----## Requesting or adding a languageTo ask for a language, open an issue on@@ -374,12 +289,10 @@ and the general contribution flow is inGood or Partial rung; health markers come from separate registries described inthe same architecture page.-----## See also-- [GRAPH.md](GRAPH.md) · edge vocabulary, resolution origins, execution flows-- [architecture/language-support.md](../architecture/language-support.md) · pipeline internals and per-language mechanics-- [CODE_HEALTH.md](CODE_HEALTH.md) · health markers-- [BENCHMARKS.md](../BENCHMARKS.md#accuracy-by-language) · measured accuracy per language-- [WORKSPACES.md](../scale/WORKSPACES.md) · cross-repo contracts+- [GRAPH.md](GRAPH.md): edge vocabulary, resolution origins, execution flows+- [architecture/language-support.md](../architecture/language-support.md): pipeline internals and per-language mechanics+- [CODE_HEALTH.md](CODE_HEALTH.md): health markers+- [BENCHMARKS.md](../BENCHMARKS.md#accuracy-by-language): measured accuracy per language+- [WORKSPACES.md](../scale/WORKSPACES.md): cross-repo contractsdiff --git a/docs/layers/OWNERSHIP.md b/docs/layers/OWNERSHIP.mdindex adbe4f5b5..67c080100 100644--- a/docs/layers/OWNERSHIP.md+++ b/docs/layers/OWNERSHIP.md@@ -85,7 +85,7 @@ rest of [code health](CODE_HEALTH.md) and appear in its findings list.| Detector | Fires when | Severity ||---|---|---|-| `knowledge_loss` | The file is still changing (a commit in 90 days, or a hotspot; never a file marked stable), its bus factor is 1, and the primary owner is no longer the recent owner or the recent owner makes under 20% of recent commits | High on a hotspot; medium when both conditions hold; otherwise low |+| `knowledge_loss` | The file is still changing (a commit in 90 days, or a hotspot; never a file marked stable), its bus factor is 1, and the primary owner is not the recent owner or the recent owner makes under 20% of recent commits | High on a hotspot; medium when both conditions hold; otherwise low || `ownership_risk` | The file has 5 or more commits and either 3 or more minor contributors (each under 5% of commits) or no author above 40% | Critical at 6+ minor contributors on a hotspot; high at 5+, or 3+ on a hotspot; medium at 3+; otherwise low. Low on a file under 40 code lines || `developer_congestion` | 5 or more contributors, the file is in the top quarter of churn for this repository, and nobody holds half the commits | High at 10+ contributors and 20+ commits in 90 days; medium at 7+ contributors or 12+ commits; otherwise low |@@ -165,12 +165,12 @@ Full schema: [CONFIG.md](../reference/CONFIG.md#the-health-rulesjson-file).- Identity merging is conservative: beyond `.mailmap` and GitHub `noreply`folding, two addresses are only merged on guarded evidence, so some people maystill appear twice. A false merge is treated as worse than a split.-- In the health score's defect calibration, `ownership_risk` showed positive- lift and carries a higher weight than the default. `developer_congestion` and- `knowledge_loss` showed weak signal and deduct less than the default; they are- kept as findings a team can act on. All three share the change-history+- In the health score's defect calibration, `ownership_risk` has positive lift+ and carries a higher weight than the default. `developer_congestion` and+ `knowledge_loss` carry weak signal and deduct less than the default; they+ stay as findings a team can act on. All three share the change-historycategory cap. Method: [BENCHMARKS.md](../BENCHMARKS.md).-- A contributor profile's 90-day commit count is measured back from the newest+- A contributor profile's 90-day commit count counts back from the newestcommit, and stays empty when the stored commits do not reach back that far.- Truncated history (shallow clone, low `--commit-limit`) can make an earlyauthor vanish, which can both hide and invent a `knowledge_loss` finding.diff --git a/docs/layers/PERFORMANCE.md b/docs/layers/PERFORMANCE.mdindex e0eab2e1f..2e11e339a 100644--- a/docs/layers/PERFORMANCE.md+++ b/docs/layers/PERFORMANCE.md@@ -6,7 +6,7 @@ iteration. It reads the parse tree and the call graph. It does not run your codeor measure time, so a finding means "this shape is slow when the data grows", not"this was slow in production".-It is high precision and low recall. It misses cases rather than guessing.+It is high precision and low recall: it skips a case instead of guessing.Performance risk is one of the three signals in [Code Health](CODE_HEALTH.md).## What it finds@@ -22,29 +22,34 @@ Performance risk is one of the three signals in [Code Health](CODE_HEALTH.md).That is 21 performance detectors plus `sql_cartesian_join`. They move only theperformance signal, never the defect score.-A loop that appends to one string several times is one `string_concat_in_loop`-finding that lists every append line. TypeScript and JavaScript never get this-finding, because JavaScript engines make repeated `+=` linear.+A few shapes are deliberately quiet:-A TypeScript or JavaScript `includes` check against a short `const` table of-literals that the file never changes is not flagged, because a table of fixed-size costs the same at any scale.+- A loop that appends to one string several times is one `string_concat_in_loop`+ finding that lists every append line. TypeScript and JavaScript never get this+ finding, because JavaScript engines make repeated `+=` linear.+- A TypeScript or JavaScript `includes` check against a short `const` table of+ literals that the file never changes is not flagged, because a table of fixed+ size costs the same at any scale.+- An awaited call on a line that an ESLint `no-await-in-loop` suppression covers+ is not reported: the comment states that the sequential await is intended.-An awaited call on a line that an ESLint `no-await-in-loop` suppression covers is-not reported at all: the comment states that the sequential await is intended.+### Across functionsThe loop and the I/O call do not have to be in the same function. Repowisefollows the resolved call graph up to three hops and attaches thecaller-to-sink path. Per-function linters cannot see that case.+An I/O call is recognised by the library its receiver was imported from. InTypeScript and JavaScript only the module name counts, so a local variable namedlike a package (`ws`) or a module path that contains a library name(`plugin-sdk/provider-http`) is not read as that library.+In Java, any call on a Spring Data repository or a MyBatis mapper inside a `for`loop counts as a database call, whatever the method is named. The receiver'sdeclared type decides: an interface that extends a Spring Data repository, carries-`@Mapper`, or sits in a `@MapperScan` package. JPA lazy associations read in a loop-are not reported yet.+`@Mapper`, or sits in a `@MapperScan` package.++### LanguagesPerformance analysis covers Python, TypeScript/JavaScript (including Vue andSvelte scripts), Java, Go, C# (including Razor), Rust, Kotlin, Scala, Ruby, C++,@@ -69,25 +74,37 @@ Each opportunity gets one state:A plan lists its edits, one step per call site and loop, each naming the call itrepeats and the kind of I/O that call does (database, network, file system orsubprocess). When every site reaches one sink, the step that adds a bulk form of-that sink comes first. The plan also lists tests to run, found from coverage, the call-graph and the import graph. An opportunity with a supported shared fix links to a-`performance_fix` plan in [REFACTORING.md](REFACTORING.md).+that sink comes first. The plan also lists tests to run, found from coverage, the+call graph and the import graph. An opportunity with a supported shared fix links+to a `performance_fix` plan in [REFACTORING.md](REFACTORING.md).Each loop also says what it walks: rows a query returns, a collection its callerpasses in, the rows of one key, a registry or configuration table, a fixed set, a-directory listing or a stream, and plan steps name it. Python, TypeScript/JavaScript,-Go, Java, C#, Ruby, Rust, Kotlin, C++ and Pascal loops say whether they grow with the data or are bounded; a-loop whose size the code does not show stays unknown and is never treated as-bounded. A loop that stops at the first call that answers, or feeds each call's-result into the next, gets no batch advice (reason `loop_not_batchable`).+directory listing or a stream, and plan steps name it. Python,+TypeScript/JavaScript, Go, Java, C#, Ruby, Rust, Kotlin, C++ and Pascal loops say whether+they grow with the data or are bounded; a loop whose size the code does not show+stays unknown and is never treated as bounded. A loop that stops at the first call+that answers, or feeds each call's result into the next, gets no batch advice+(reason `loop_not_batchable`).## The default queueThe default queue holds production opportunities in the `plan_ready` and-`advisory` states. They are ranked by cost first; state only breaks ties.-Only opportunities whose cost is measured are in it. A loop whose size nothing measured is `cost_proof = unproven`, never leads, and shows only with the `proof=unproven` filter.-Each opportunity also says what runs its loop (`execution_role`: request, event consumer, scheduled job, startup, CLI, UI, tooling, test or unknown), and loops run per request rank above the rest. Roles are read for Python and TypeScript/JavaScript; other languages show `unknown`. The `role` filter lists any one role, or `all`.-Work a request hands to `asyncio.create_task` and never waits for is a background job, not part of the request, even when the task is kept in a map on shared app state. An opportunity takes its role and loop size from the same live call sites, so a call site switched off by a constant flag or already chunked never leads it.+`advisory` states. They are ranked by cost first; state only breaks ties. Only+opportunities whose cost is measured are in it. A loop whose size nothing measured+is `cost_proof = unproven`, never leads, and shows only with the `proof=unproven`+filter.++Each opportunity also says what runs its loop (`execution_role`: request, event+consumer, scheduled job, startup, CLI, UI, tooling, test or unknown), and loops run+per request rank above the rest. Roles are read for Python and+TypeScript/JavaScript; other languages show `unknown`. The `role` filter lists any+one role, or `all`.++Work a request hands to `asyncio.create_task` and never waits for is a background+job, not part of the request, even when the task is kept in a map on shared app+state. An opportunity takes its role and loop size from the same live call sites,+so a call site switched off by a constant flag or already chunked never leads it.Everything else is counted by reason, not hidden:@@ -103,11 +120,13 @@ Everything else is counted by reason, not hidden:| `cold_role` | Only startup, a CLI command, tooling, tests or client UI code run the loop, so no server pays it per request || `background_unproven` | A scheduled job runs the loop and nothing shows it grows with the data; listed under `proof=background_unproven` |-To see them, widen the filter (below). Each performance finding also stores the reason its cause is in or out of the queue.-Code in a package path that only looks like an example tree (`com/example/...`) is judged as production when the index read it as production.+To see them, widen the filter (below). Each performance finding also stores the+reason its cause is in or out of the queue. Code in a package path that only looks+like an example tree (`com/example/...`) is judged as production when the index+read it as production.-Performance work also appears in-[Fix first](CODE_HEALTH.md#fix-first), where it competes with other kinds of work.+Performance work also appears in [Fix first](CODE_HEALTH.md#fix-first), where it+competes with other kinds of work.## Reading it@@ -115,7 +134,7 @@ Performance work also appears in|---|---|| CLI | `repowise health` and `repowise next` list performance work inside Fix first || MCP | `get_health(include=["performance"])`; open one cause with `opportunity_id` |-| Dashboard | Code Health, **Performance** tab: each cause with its steps and the raw observations as evidence |+| Dashboard | Code Health, Performance tab: each cause with its steps and the raw observations as evidence |MCP filters: `performance_view` (`detail` or `summary`), `performance_context`(`production` by default; `tooling`, `test`, `unknown` or `all`),@@ -134,8 +153,10 @@ get_health(opportunity_id="perf...")edge, so those cases are missed.- Chains longer than three hops are not followed.- ORM lazy loads are reported only where the loop's rows resolve to one model.+- JPA lazy associations read in a loop are not reported.- A library Repowise does not model has no classified I/O calls.-Internals (sinks, gates, dialects, weights): [architecture/code-health.md](../architecture/code-health.md#64-performance-opportunities-perf).+Internals (sinks, gates, dialects, weights):+[architecture/code-health.md](../architecture/code-health.md#64-performance-opportunities-perf).Linter comparison and ranking quality:[repowise-bench/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 281a780bf..3ef4ec740 100644--- a/docs/layers/REFACTORING.md+++ b/docs/layers/REFACTORING.md@@ -62,31 +62,29 @@ filters for type, confidence and effort. A plan's drawer explains its rank, showthe tests that reach the code and the command to run them, and can export thestructured plan for an agent. The page never edits code or runs tests on its own.+### Tests and commands+A plan lists the tests closest to the change first: measured coverage, thentests named for the file, then the call graph. Tests that reach the file onlythrough a widely imported hub module are left out. When the plan changes knownfunctions, it quotes the few test functions nearest each one as runnableselectors (`tests/test_orders.py::test_total`), and its command runs only the-files they live in. When no test reaches the change, the plan has no command and-asks for a characterization test first; it also asks when tests reach the file-but none reaches the changed function.-A JavaScript or TypeScript test runs from the package whose `package.json`-declares its `test` script (`npm --prefix ui-tui test -- src/a.test.ts`), and a-test that no package can run gets no command.-Go, Rust, Java, Kotlin and Ruby tests get a command too, for the package that owns-them: `go test ./internal/cart`, `cargo test -p parser`, `./mvnw -pl core -am test`-or `./gradlew :app:test`, and `bundle exec rspec` or `bundle exec rake test`. A test-whose build file or runner the repository does not have gets no command.-A C# test runs `dotnet test` on the test project that holds it-(`dotnet test tests/Shop.Tests/Shop.Tests.csproj`), narrowed with `--filter` to-the named tests, or on the repository's solution when no single test project-does. With neither, the plan has no command.+files they live in.++When no test reaches the change, the plan has no command and asks for a+characterization test first; it also asks when tests reach the file but none+reaches the changed function. JavaScript, TypeScript, Go, Rust, Java, Kotlin,+Ruby and C# tests get a command for the package or project that owns them; a+test whose build file or runner the repository does not have gets no command. Per-language rules:+[architecture/refactoring.md](../architecture/refactoring.md#test-commands).In a plan with several steps, such as a performance fix at several call sites,plan detail adds a `verify` to each step whose tests differ from the plan's: thetests that reach that step's lines and the command to run them. A step withoutone is checked by the plan's own command.+### Recipes+Any plan can be read as a recipe: what must hold before the edit (tests thatpass, a characterization test to add, a decision to read), the edits in order,the checks and expected improvement after, and what the edit must not do. The@@ -94,7 +92,7 @@ dashboard's copy-prompt, `repowise health --plan`, plan detail with`include=recipe` and code generation all read that same recipe, so an agent seesone set of steps wherever it starts. The recipe and the prompt name the plan bythe public id `get_health(plan_id=...)` takes; REST plan detail's own `id` field-stays the storage id it has always served.+is the storage id.## Reading the results@@ -124,20 +122,20 @@ rows of their own.Plan detail also lists `risks`, one sentence each, to read before applying theplan: an accepted decision that governs the file, callers or importers of what-the plan moves, a target nothing reaches (delete it instead), and recent commits+the plan moves, a target nothing reaches (delete it instead), recent commitson the same lines, and a test the plan runs that asserts on the function's ownsource text. When the plan changes a symbol a package exports to its consumers,-the risk names the file exporting it. A governed plan's steps are `judgment`, and its-`blast_radius.co_change_partners` names the files that usually change with it.-A newly accepted decision shows here after the next index or update.+the risk names the file exporting it. A governed plan's steps are `judgment`, and+its `blast_radius.co_change_partners` names the files that usually change with+it. A newly accepted decision shows here after the next index or update.A plan the index stops detecting is resolved, and its detail then carries a`payoff` with the target's size before and after and the commit that resolvedit. `applied` means the measures are consistent with the plan being applied: thetarget lost at least half the predicted complexity and a function the size of-the extracted span appeared beside it (Extract Method only, so far). The other-outcomes are `file_deleted`, `superseded` (the same plan found again under a new-id), `target_changed` (renamed or rewritten another way) and `unknown`.+the extracted span appeared beside it (computed for Extract Method only). The+other outcomes are `file_deleted`, `superseded` (the same plan found again under+a new id), `target_changed` (renamed or rewritten another way) and `unknown`.Plans and opportunities on Java, C#, C and C++ files are composed and stored asusual but held back pending verification: the plan lists, the queue, its facets@@ -145,33 +143,25 @@ and the rollup's lead leave them out unless the caller passes`include_unverified`, and responses count them in `gated`.Break Cycle is advisory. Its plan names edges to cut, not which symbols cross-them or how to move them, so an opportunity carries it as `evidence` rather than+them or how to move them, so an opportunity carries it as `evidence` instead ofas a numbered step: it never leads, and never reaches Fix first. The plan itself-stays in the plan list. Cycles are found over runtime imports only: an import-under `if TYPE_CHECKING:` or a TypeScript `import type` / `typeof import()` is-type-only, and an import inside a function body is deferred (it runs on first-call, the usual way to break a cycle on purpose). Neither closes a cycle. Only a-plain `TYPE_CHECKING` or `module.TYPE_CHECKING` condition counts; a negated or-aliased flag is read as a runtime import.--Every plan is counted once: the rollup's `plans_total` is the steps, plus-`evidence_total`, plus `unattached_plans_total` (plans in no opportunity, such as-a file whose only plan is a cycle). The plan list's `structural_total` leaves-Break Cycle out, matching the opportunities; `by_type` still counts it.+stays in the plan list. Cycles are found over runtime imports only; type-only and+deferred imports do not close a cycle+([rules](../architecture/refactoring.md#break-cycle-imports)). How the rollup+counts plans: [architecture/refactoring.md](../architecture/refactoring.md#counting).Names are never invented. A suggested helper or file name is `null` when nothingin the code anchors one. A Split File or Extract Class plan with an unnamed groupis held as `needs_design`, like a cycle: it is not a step and never reaches Fixfirst. A plan led by Move Method or Extract Class stays in the full list but iskept out of Fix first and the default scope, counted as not yet audited, until-that kind passes a per-language review. When such a step follows another lead, the-Fix first item leaves it out and says how many steps it held back; the full plan-keeps them. Code only moves within a language family,-so Java, Kotlin and Scala are separate. A callback is named after the call it is-passed to. An Extract Method helper follows the same rule: the code rarely says-what a block is for, so the plan gives the helper a placeholder name,-`extracted_helper`. The plan and its prompt ask you to rename it for what it-returns or does when you apply it.+that kind passes a per-language review. When such a step follows another lead,+the Fix first item leaves it out and says how many steps it held back; the full+plan keeps them. Code only moves within a language family, so Java, Kotlin and+Scala are separate. A callback is named after the call it is passed to. An+Extract Method helper gets the placeholder name `extracted_helper`, since the+code rarely says what a block is for; the plan and its prompt ask you to rename+it for what it returns or does when you apply it.An empty list means no detector found work that clears its gates. It does not meanthe code needs no attention: check the findings in@@ -194,7 +184,7 @@ after production files.## Code generation-Code generation is **off by default**, only runs when you ask for it, and never+Code generation is off by default, only runs when you ask for it, and neverruns during indexing. Turn it on with the code-generation switch on the repoSettings page or in an open plan, or with `refactoring.llm.enabled: true`. Theswitch names the provider and model it will use, so there is nothing else to@@ -248,73 +238,33 @@ Most plans answer a health finding, so per-path marker rules in- Plans are suggestions for review. Nothing is applied automatically, andgenerated code comes back as a diff.-- Extract Method offers a span only when it can show the extraction keeps behavior- (every returned value written on every path, no state carried across loop- iterations, no local a closure shares across the span's edge, no write to a- `global` name without its declaration). A staged plan also leaves out a stage- whose inputs or outputs depend on a `switch` or `match` arm's write. A span or- stage never changes which handler catches an error or what it sees: it is not- offered when it would split a `try` from its handlers, write a value a handler- or `finally` reads, or move a Go `defer`. Spans it- cannot prove are dropped, so it under-reports by design. A value the span writes- is returned whenever any path can carry it to a later read, including past a- later write in an `else` arm or a `try` body that may raise first.-- Extract Method skips spans too small to matter and spans that would carry the- original finding into the helper. A component whose branching is mostly in its- markup gets no extraction, and neither does a function that only fills one- value field by field behind independent guards (summary rows, query- parameters, optional settings), since splitting it simplifies neither half.- Its finding records why in `details.extract_method_refused`.-- An Extract Method span must remove at least two decision points, hold at least- 8 code lines, cover at most 60% of the function's lines, and not start on the- docstring. When the best span misses one of these, only a span that does not- overlap it is offered, never a slightly smaller copy of it. Estimated gain- never exceeds the share of decision points removed.-- An Extract Method span that awaits (Python `await`, `async with`, `async for`;- TypeScript and JavaScript `await`, `for await`; Rust `.await`; C++ `co_await`)- carries `needs_async: true`: the helper is async and its call is awaited. An- await inside a nested function, closure or Rust `async` block does not count.- When the function holding the span is not declared async (a C++ coroutine), the- step is a judgment call with reason `async_helper_unexpressible`.-- An Extract Method plan says whether the helper must be a method on the same- object (the span uses `self`, `this` or a Go receiver) and which of the- object's fields the span assigns directly, under `new_symbol`. A span that uses `this`- outside a class, or writes fields of a Go value receiver, is a judgment call- (`receiver_unbound`, `receiver_copy_written`).+- Extract Method offers a span only when it can show the extraction keeps+ behavior, so it under-reports by design. Spans that would split a `try` from+ its handlers, move a Go `defer`, or carry the original finding into the+ helper are not offered. Full gates:+ [architecture/refactoring.md](../architecture/refactoring.md#extract-method-gates).+- A span must remove at least two decision points, hold at least 8 code lines+ and cover at most 60% of the function's lines. Estimated gain never exceeds+ the share of decision points removed.+- When Extract Method declines a function, its finding records why in+ `details.extract_method_refused`.- An Extract Method plan writes out the new helper's header and the line that- replaces the span, in the file's language, with parameter types where the code- declares them. In TypeScript, an optional parameter is written `T | undefined`,- and a type an earlier guard narrows (`if (!x) return;`) is written narrowed, or- a note asks for the narrowed type. Plan detail shows both with a copy button.- Where the code names no type, the text reads `<type>` for you to fill in.+ replaces the span, in the file's language, with parameter types where the+ code declares them; `<type>` marks a type for you to fill in. It flags an+ awaiting span with `needs_async: true` and a receiver-bound helper under+ `new_symbol`.+- A step Repowise cannot express mechanically is a judgment call with a reason+ code: `async_helper_unexpressible`, `receiver_unbound` or+ `receiver_copy_written`.- A Python, TypeScript or JavaScript function too complex for one helper can- get a staged plan instead: several helpers the function calls in order, each- small enough to leave the finding behind. Plan detail lists them as steps,- with a shared parameter object when many values pass between them, and the- plan's estimated gain is the whole drop in the function's complexity. The- plan's own span, header and call are its first stage. When the work sits- inside one loop or `if`, the stages are cut from its body and the function- keeps the loop and calls them each time round. A stage running across several- labelled sections is named after them. When a function moves- between a single helper and a staged plan, or its stages change, the plan- gets a new id.-- Every Extract Method step, and every stage of a staged plan, shows the exact- first and last lines of its span, so an agent finds it by its text after- earlier stages have moved its lines; the line numbers are only a hint. The- plan asks for each stage as a direct edit to the file, one at a time, never a- script that rewrites it. A staged plan whose stages cannot all be pinned down- that way falls back to a single helper, and a function with neither gets no plan.-- A staged plan with more than five stages comes in batches of at most five.- Each batch names the tests to run before the next one, and a batch whose- tests fail stops the plan there. The code runs after every batch, so a- failure points at the stages just applied.-- An Extract Method plan that would still leave the function, or one of its new- helpers, above the break-up bar says so, for example "leaves build_from_json- at CCN 83, still above the break-up bar; more stages needed". The plan and- its file's opportunity rank after the work that finishes the job. The mark is- set when the repository is indexed, so a plan ranked live is not marked.-- Move Method never targets a class the method only instantiates, or an ancestor of- its own class.+ get a staged plan: several helpers called in order, applied as direct edits+ one stage at a time, in batches of at most five with tests between batches.+- A plan that would leave the function or a new helper above the break-up bar+ says so ("still above the break-up bar; more stages needed") and ranks after+ work that finishes the job. The mark is set at index time, so a plan ranked+ live is not marked.+- Move Method never targets a class the method only instantiates, or an+ ancestor of its own class.- Split File works on any language with call resolution and suggests a split onlywhen the groups are clearly separable. Python and TypeScript splits usually needa re-export shim, flagged as `shim_required`.@@ -342,5 +292,5 @@ Most plans answer a health finding, so per-path marker rules in- [CODE_HEALTH.md](CODE_HEALTH.md): the findings and health signals plans are built on, and Fix first.- [INTELLIGENCE_LAYERS.md](INTELLIGENCE_LAYERS.md): how code health fits the rest of the index.-- [architecture/refactoring.md](../architecture/refactoring.md): detector algorithms, ranking, plan ids and REST routes.+- [architecture/refactoring.md](../architecture/refactoring.md): detector algorithms, Extract Method gates, test commands, ranking, plan ids and REST routes.- [architecture/code-health.md](../architecture/code-health.md): health pipeline internals.diff --git a/docs/layers/SECURITY.md b/docs/layers/SECURITY.mdindex 9619c9cdd..bd8b507ff 100644--- a/docs/layers/SECURITY.md+++ b/docs/layers/SECURITY.md@@ -5,11 +5,11 @@ Repowise records security signals while it indexes: matches from a registry ofIt also scans git history for leaked credentials, and gates pull requests onwhat a change adds.-It is a pattern registry, not a security scanner. There is no taint analysis,-no framework model and no dependency lookup. Run a real SAST tool and a secret+It works as a pattern registry: it marks places to read, without taint analysis,+framework models or dependency lookup. Run a SAST tool and a dedicated secretscanner alongside it.-No LLM key, no network. Working-tree signals cost a regex pass during+It needs no LLM key and no network. Working-tree signals cost a regex pass duringindexing; the CI check needs only git.## Quick start@@ -33,8 +33,9 @@ repowise security check origin/main...HEAD # CI gate on what a change adds```From an agent, `get_risk(targets=["src/api/"])` includes a `security_signals`-block, without the informational `security_sensitive_symbol` rows. In the dashboard, findings are on the Security tab of the Code Health-page, and over REST at `GET /api/repos/{repo_id}/security`.+block, without the informational `security_sensitive_symbol` rows. In the+dashboard, findings are on the Security tab of the Code Health page, and over REST+at `GET /api/repos/{repo_id}/security`.## Reading the results@@ -46,7 +47,8 @@ material, or under a directory named `test`, `tests`, `__tests__`, `__test__`,`fixtures`, `__fixtures__`, `spec`, `specs`, `mock`, `mocks`, `__mocks__`,`example` or `examples`, is recorded at `low`. A non-secret finding in ascript, tool, benchmark, migration or docs example is `low` too; a secret there-keeps its severity. Nothing is scored or ranked.+keeps its severity. Nothing is scored or ranked. `security_sensitive_symbol` is+informational: it marks where security code lives, not a problem.| Kind | Severity | Matches ||------|----------|---------|@@ -77,48 +79,29 @@ keeps its severity. Nothing is scored or ranked.| `weak_hash` | low | MD5 or SHA-1 in use in code: a call (`hashlib.md5(`), a type (`MD5.Create()`) or the algorithm named to a hashing call (`createHash("sha1")`). A call passing `usedforsecurity=False` does not fire || `security_sensitive_symbol` | low | a symbol named `auth`, `password`, `jwt` or `crypto`. A bare `session` or `token` is usually a database session or a lexer token and does not fire |-`security_sensitive_symbol` is informational: it marks where security code-lives, not a problem.--The eleven **secret kinds** are `hardcoded_password`, `hardcoded_secret`,+The eleven secret kinds are `hardcoded_password`, `hardcoded_secret`,`git_url_credentials` and the eight vendor shapes (AWS, GitHub, GitLab, Azure-DevOps, Slack, Google, Stripe, PEM). History mode-and the in-change commit scan report only these by default.+DevOps, Slack, Google, Stripe, PEM). History mode and the in-change commit scan+report only these by default.### What fires and what does not-- **`eval` and `exec` in Python** are found by walking the AST, so a match is- a real call. Other languages use source with comments and strings masked out.-- **Text describing code is not code.** `pickle_loads`, `os_system`,- `subprocess_shell_true` and `new_function_call` match over masked source, so a- comment naming the call does not fire. The keyword secret kinds need the name- to be code, so `password = "..."` in a doctest does not fire.-- **Vendor key shapes match anywhere**, comments included: a real key in a- comment is still a leak.-- **Prose files** (`.md`, `.mdx`, `.rst`, `.txt`, `.adoc`) are scanned for the- secret kinds only. So are generated and vendored files (a minified or webpack- bundle included) and `.d.ts` declarations: nobody here wrote their calls.-- **JavaScript kinds stay in JavaScript.** `unsafe_inner_html`,- `template_literal_sql`, `new_function_call`, `reject_unauthorized_false` and- `public_env_secret` do not fire in Python files, where such a line can only be- quoted text.-- **Placeholders are skipped**: a keyword value that is elided or templated- (`...`, `<your key>`, `xxx`, `example`, `placeholder`, `dummy`, `fake`, `redacted`,- `changeme`, `{{ }}`, `${}`), shorter than eight characters, a short- single-case word, or a snake_case key name. A value a vendor kind already- reports is not reported twice.-- **`concat_sql`, `template_literal_sql` and `unsafe_inner_html`** run on raw- source, comments included. `fstring_sql` and `weak_hash` need their match to- start in code, so a comment or a fixture string quoting one does not fire.+Python `eval` and `exec` are found from the AST. Most other kinds match over+source with comments and strings masked out, so text describing a call does not+fire. Vendor key shapes match anywhere, comments included: a real key in a comment+is still a leak. Prose, generated and vendored files are scanned for the secret+kinds only, and placeholder values (`<your key>`, `changeme`, `${}`) are skipped.+The full rules per kind are in+[architecture/security.md](../architecture/security.md#matching-rules).### Working tree versus history-**Working tree** runs during `repowise init` and `repowise update`. Rows have-an empty `commit_sha`. `repowise security scan` without `--history` only+The working-tree scan runs during `repowise init` and `repowise update`. Rows+have an empty `commit_sha`. `repowise security scan` without `--history` onlyprints a hint, since indexing already did this.-**History** runs on `repowise security scan --history` and walks every tracked-revision. Rows carry the SHA and author date of the commit that introduced the+The history scan runs on `repowise security scan --history` and walks every+tracked revision. Rows carry the SHA and author date of the commit that introduced thematch. This finds a credential committed in March and removed in April: absentfrom HEAD, present in every clone. By default it reports only the secret kinds.A committed secret stays valid until rotated; an `eval` that was later removed@@ -169,10 +152,10 @@ repowise security check --format sarif > security.sarifIt judges what the change adds:-- **At the head**, every touched file is scanned, and a finding counts only+- At the head, every touched file is scanned, and a finding counts onlywhen a line it spans was added or edited. In documentation files only thesecret kinds count.-- **Inside the change**, every non-merge commit in the range is scanned for the+- Inside the change, every non-merge commit in the range is scanned for thesecret kinds. A key added in one commit and deleted in the next is reportedwith the commit that added it.@@ -200,18 +183,16 @@ syntax; `repowise-security-ignore: aws_access_key` silences only the kinds itlists. There is no next-line or whole-file form. A silenced finding never failsthe gate and is still reported there as suppressed. The scan that indexingstores leaves it out, so it does not reach the dashboard, `get_risk` or REST.-Exact rules are in the-[CLI reference](../reference/CLI_REFERENCE.md#repowise-security-check-revspec).+Exact rules are in the [CLI reference](../reference/CLI_REFERENCE.md#repowise-security-check-revspec).The scanner also honours other scanners' comments: `# pragma: allowlist secret`on the finding's line, or `# pragma: allowlist nextline secret` on the lineabove it (detect-secrets), and `gitleaks:allow`, `trufflehog:ignore`, `nosec`(Bandit, gosec) and `noqa: S105`/`S106`/`S107` (Ruff) on the finding's line-(`//` and `/*` comments work too). Unlike the Repowise gate-only-marker, allowlisted secret findings are excluded from the stored scan and-the gate; they do not appear in the gate's suppressed count. Non-secret-findings on the same line still report. A marker inside a string does not-silence a finding.+(`//` and `/*` comments work too). Unlike the Repowise gate-only marker,+allowlisted secret findings are excluded from the stored scan and the gate; they+do not appear in the gate's suppressed count. Non-secret findings on the same line+still report. A marker inside a string does not silence a finding.### A repository's `.gitleaks.toml`@@ -226,13 +207,12 @@ gitleaks does, so a change's own allowlist entries apply to it.### Baselines`--write-baseline FILE` records the change's findings in a committed JSON file-and exits 0; `--baseline FILE` accepts what it lists, so only new findings-fail. An entry is keyed on file, kind and masked line, so it survives line-shifts. Vendor shapes also key on a one-way hash of the matched text, so a new-key on an identical line is a new finding. Keyword kinds do not, since a short-password could be guessed back from its hash. Writing to an existing baseline-adds entries; remove one by deleting it. `sarif` marks accepted findings-suppressed; `gitlab` leaves them out.+and exits 0; `--baseline FILE` accepts what it lists, so only new findings fail.+An entry is keyed on file, kind and masked line, so it survives line shifts; a+new vendor-shaped key on an identical line is still a new finding+([how entries are keyed](../architecture/security.md#baseline-keys)). Writing to+an existing baseline adds entries; remove one by deleting it. `sarif` marks+accepted findings suppressed; `gitlab` leaves them out.### Custom patterns: `security.patterns`@@ -252,41 +232,38 @@ blocks a commit on a finding at or above `high`. Skip it once with## Accuracy and limits-This is a registry of regular expressions with a little parsing. Read every-result with that in mind.+Each result is a regular-expression match with a little parsing. Read every+result as a place to look.-- **No taint analysis or dataflow.** Whether attacker input reaches a call is- not computed. `eval_call` fires the same on a constant and on a request- parameter.-- **No framework semantics.** Missing authorization, permissive CORS,- unvalidated redirects and missing ownership checks are out of reach.-- **Mostly Python and JS/TS.** `pickle_loads`, `os_system`,+- No taint analysis or dataflow. Whether attacker input reaches a call is not+ computed: `eval_call` fires the same on a constant and on a request parameter.+- No framework semantics. Missing authorization, permissive CORS, unvalidated+ redirects and missing ownership checks are out of reach.+- The registry is shaped around Python and JS/TS. `pickle_loads`, `os_system`,`subprocess_shell_true`, `tls_verify_false` and `fstring_sql` are Pythonidioms. On Go, Rust or Java, `eval`/`exec` and the secret kinds are most ofwhat can fire, and a quiet report reflects the registry's shape.-- **Secret detection is shallow.** No entropy scoring; providers outside the- eight vendor shapes are invisible unless you add custom patterns. Use gitleaks- or trufflehog for secret scanning proper.-- **No dependency or CVE scanning.**-- **False positives happen.** `weak_hash` fires on an MD5 checksum unless the- call passes `usedforsecurity=False`.- `unsafe_inner_html` ships at `med` because it cannot tell a name pointing at- a pinned constant from a dynamic value.-- **The five JS/TS kinds were checked by hand** on a 17-repository, 1,109-file- corpus. After tightening: `unsafe_inner_html` 4 hits, `template_literal_sql`- 2 of 2 real, `public_env_secret` 3 of 3 real, `new_function_call` and- `reject_unauthorized_false` 0.-- **A CI pass means no pattern matched a changed line**, nothing more.+- Secret detection matches shapes, with no entropy scoring. Providers outside+ the eight vendor shapes are caught only through custom patterns. Use gitleaks+ or trufflehog for full secret scanning.+- No dependency or CVE scanning.+- `weak_hash` fires on an MD5 checksum unless the call passes+ `usedforsecurity=False`. `unsafe_inner_html` ships at `med` because it cannot+ tell a name pointing at a pinned constant from a dynamic value.+- The five JS/TS kinds are hand-checked on a 17-repository, 1,109-file corpus;+ per-kind results are in+ [architecture/security.md](../architecture/security.md#precision-checks).+- A CI pass means no pattern matched a changed line, nothing more.## Where it shows up-- **CLI**: `repowise security scan --history`, `repowise security check`,- `repowise hook install --security`.-- **MCP**: the `security_signals` block on `get_risk`.-- **Dashboard**: the Security tab of the Code Health page.-- **REST**: `GET /api/repos/{repo_id}/security`.-- **CI**: the GitHub Action's `security` gate (annotations, SARIF) and the- GitLab template (Code Quality).+| Surface | Where |+|---|---|+| CLI | `repowise security scan --history`, `repowise security check`, `repowise hook install --security` |+| MCP | The `security_signals` block on `get_risk` |+| Dashboard | The Security tab of the Code Health page |+| REST | `GET /api/repos/{repo_id}/security` |+| CI | The GitHub Action's `security` gate (annotations, SARIF) and the GitLab template (Code Quality) |## Referencediff --git a/docs/layers/TEST_INTELLIGENCE.md b/docs/layers/TEST_INTELLIGENCE.mdindex aa08bdbb3..c1c1ab79e 100644--- a/docs/layers/TEST_INTELLIGENCE.md+++ b/docs/layers/TEST_INTELLIGENCE.md@@ -1,18 +1,16 @@# Test Intelligence-Test intelligence answers two questions your CI cannot: which files are risky-*and* untested, and which tests a given change exercises. The second turns a-4,000-test suite into the few dozen tests that guard the change you just made.+Test intelligence answers two questions your CI cannot: which files are risky *and*+untested, and which tests a given change exercises. The second turns a 4,000-test suite+into the few dozen tests that guard the change you just made.It works at two levels of evidence. Ingest a coverage report and the answers are-**measured**: this test ran these lines. Without one, repowise still answers-from the dependency graph, which records which tests reach which files; those-answers are **inferred**, always labelled as such, and never turned into a-percentage.--No LLM key, no network. Ingesting a report is a parse and a database write;-every question after that is an index lookup. The patch-coverage gate for pull-requests needs only git and a report (see [Patch coverage in CI](#patch-coverage-in-ci)).+**measured**: this test ran these lines. Without one, Repowise still answers from the+dependency graph, which records which tests reach which files; those answers are+**inferred**, always labelled as such, and never turned into a percentage. No LLM key,+no network. Ingesting a report is a parse and a database write; every question after+that is an index lookup. The patch-coverage gate for pull requests needs only git and a+report (see [Patch coverage in CI](#patch-coverage-in-ci)).## Quick start@@ -20,38 +18,19 @@ requests needs only git and a report (see [Patch coverage in CI](#patch-coverage# 1. Produce a report. Any supported format works.pytest --cov --cov-report=lcov:coverage.lcovcoverage run --contexts=test -m pytest # also records which test ran each line-# 2. Ingest it.repowise coverage add coverage.lcovrepowise coverage add .coverage # per-file coverage + per-test map-repowise coverage status-+repowise coverage status # files, line and branch %, map counts# 3. Use it.repowise health # untested hotspots now light uprepowise impacted-tests main...HEAD # the tests guarding this branchrepowise impacted-tests main...HEAD --format list | xargs pytest```-From an agent: `get_change_risk(revspec="main...HEAD")` returns `impacted_tests`-and `patch_coverage`; `get_risk(changed_files=[...])` returns test-recommendations. In the dashboard, coverage is the **Tests** tab of a-repository's health page.--```-repowise coverage status-- Coverage (lcov)- Files: 412- Lines: 71.4%- Branch: 63.9%-- Test-to-code map (coverage.py)- Tests: 1,204- Files: 388- Records: 19,551-```--Longer walkthrough: [examples/health-coverage/](../../examples/health-coverage/).+Agents read the same answers through MCP ([From an agent](#from-an-agent)); the+dashboard shows coverage on the **Tests** tab of a repository's health page. Longer+walkthrough: [examples/health-coverage/](../../examples/health-coverage/).## Measured and inferred@@ -65,103 +44,68 @@ Longer walkthrough: [examples/health-coverage/](../../examples/health-coverage/)| Labelled | `measured` | `measured` | `inferred` || Powers | Code-health coverage findings, the Tests tab | `impacted-tests`, `impacted_tests`, `tests_to_run` | The fallback under every row, when nothing measured answers |-The two kinds are shown side by side and never averaged. Inference errs in one-known direction: a call edge says control *can* reach a file, not that a run-did. So it is safe as a floor ("something reaches this, do not call it-untested") and unsafe as a quantity.--Each index also keeps, for every function, the few test functions nearest it in-the call graph. Refactoring plans quote them as runnable selectors in place of-whole test files, and they are inferred like the rest of the graph map. A-function with no resolved caller, or in a language whose tests cannot be told-apart by name (such as Java's `@Test` or Rust's `#[test]`), is left unknown-rather than called untested.--Each ingest replaces the previous per-file and per-test rows. Ingest at the-commit you intend to query so line numbers match. The repo-wide totals of the-newest 50 ingests are kept as history and drawn as a trend on the Tests tab-once there are three; partial ingests are left out of the trend.+The two kinds are shown side by side and never averaged. A call edge says control *can*+reach a file, not that a run did, so inference is safe as a floor ("something reaches+this, do not call it untested") and unsafe as a quantity. Refactoring plans name the+test functions nearest each function in the call graph as runnable selectors+([how](../architecture/test-intelligence.md#nearest-tests-per-function)).## Supported formats-| Format | Detected by | Per-test map |-|--------|-------------|--------------|-| **LCOV** | `TN:` / `SF:` / `DA:` style lines | Yes, when each record carries a non-blank `TN:` test name |-| **Cobertura** XML | `<coverage` plus `<packages` or `line-rate` | No |-| **Clover** XML | `<coverage` plus `<project` | No |-| **JaCoCo** XML | The JaCoCo doctype, or a `<report` root | No |-| **Go coverprofile** (`go test -coverprofile`) | Leading `mode:` line | No |-| **coverage.py `.coverage`** | SQLite file | Yes, when written with `--contexts` |-| **Normalized JSON** (`repowise-coverage-v1`) | Leading `{` plus `repowise-coverage` or `line_coverage_pct` | No |+| Format | Per-test map |+|--------|--------------|+| **LCOV** | Yes, when each record carries a non-blank `TN:` test name |+| **Cobertura**, **Clover** and **JaCoCo** XML | No |+| **Go coverprofile** (`go test -coverprofile`) | No |+| **coverage.py `.coverage`** | Yes, when written with `--contexts` |+| **Normalized JSON** (`repowise-coverage-v1`) | No |-Force a parser with `--format lcov|cobertura|clover|repowise-json|go-coverprofile|jacoco`.-Go percentages are line-based, not the statement percentage `go tool cover`-prints. Any other runner can be fed through the normalized JSON:+The format is sniffed from the file+([detection rules](../architecture/test-intelligence.md#report-formats-and-discovery));+force one with `--format lcov|cobertura|clover|repowise-json|go-coverprofile|jacoco`. Go+percentages are line-based, not the statement percentage `go tool cover` prints. Any+other runner can be fed through the normalized JSON:```json{ "format": "repowise-coverage-v1",- "files": { "src/foo.py": { "line_coverage_pct": 87.5,- "total_coverable_lines": 40,- "covered_lines": [1, 2, 5],- "coverable_lines": [1, 2, 3, 5] } } }+ "files": { "src/foo.py": { "line_coverage_pct": 87.5, "total_coverable_lines": 40,+ "covered_lines": [1, 2, 5], "coverable_lines": [1, 2, 3, 5] } } }````covered_lines` and `coverable_lines` are optional. Patch coverage needs`coverable_lines`; without it a file reads as having no line data, never as 0%.-**Discovery.** With no path, `coverage add` looks for the usual locations:-`coverage/lcov.info`, `lcov.info`, `coverage.lcov`, `coverage.xml`,-`**/cobertura.xml`, `**/clover.xml`, `target/llvm-cov/**/*.lcov`,-`coverage.out`, `cover.out`, `**/target/site/jacoco*/jacoco.xml`,-`build/reports/jacoco/**/*.xml`, a repo-root `.coverage`, and a few more.-Multiple reports merge: covered and coverable lines are each unioned.--**Path matching.** Report paths are matched to indexed files by exact path,-then by the longest matching tail. A tie is reported as ambiguous, never-guessed. A relative path is tried under the report's own directory first, so-`packages/web/coverage/lcov.info` naming `src/index.ts` maps to-`packages/web/src/index.ts`. Cobertura paths are joined to each `<source>`-root. If a whole report comes back unmatched, set `coverage.strip_prefix`.-`coverage add --strict` fails when any report file did not map. The coverage-summary (`get_health`, the REST coverage route) reports how each report mapped-and whether it was measured at the indexed commit.--### Building a per-test map--The per-test map needs a report that records which test covered each line.--**coverage.py dynamic contexts** (the main path):--```bash-coverage run --contexts=test -m pytest-repowise coverage add .coverage-```--Repowise reads the `.coverage` SQLite file directly and has no runtime-dependency on coverage.py. Contexts like-`tests/test_auth.py::TestLogin::test_ok|run` become test ids.--**Per-test LCOV**: each record carries a distinct `TN:` name. Blank `TN:`-records are skipped.--If the report has no contexts, `coverage add` says so; the per-file aggregate-is still stored. The map is capped at 250,000 rows and the CLI reports how many-were dropped.+With no path, `coverage add` finds reports in the+[usual locations](../architecture/test-intelligence.md#report-formats-and-discovery);+multiple reports merge. Report paths map to indexed files by path suffix, and a tie is+reported, never guessed+([rules](../architecture/test-intelligence.md#report-path-matching)). If a whole report+comes back unmatched, set `coverage.strip_prefix`; `--strict` fails when any report file+did not map. The coverage summary (`get_health`, the REST coverage route) reports how+each report mapped and whether it was measured at the indexed commit.++**Building a per-test map.** The main path is coverage.py dynamic contexts:+`coverage run --contexts=test -m pytest`, then `repowise coverage add .coverage`.+Contexts like `tests/test_auth.py::TestLogin::test_ok|run` become test ids, with no+runtime dependency on coverage.py. Per-test LCOV works too: each record carries a+distinct `TN:` name, and blank `TN:` records are skipped. If the report has no contexts,+`coverage add` says so and still stores the per-file aggregate. The map is capped at+250,000 rows and the CLI reports how many were dropped.## Impacted tests-`repowise impacted-tests` diffs a change, looks up the changed lines in the-per-test map, and returns the tests whose recorded coverage touches them.+`repowise impacted-tests` diffs a change, looks up the changed lines in the per-test+map, and returns the tests whose recorded coverage touches them.```bashrepowise impacted-tests # staged changes (the default outside CI)repowise impacted-tests main...HEAD # a branch or PR, from the merge-base-repowise impacted-tests main..HEAD # a plain range-repowise impacted-tests abc123 # a single commitrepowise impacted-tests main...HEAD --format args --runner pytest # for CI```-Each result says how it was found, and a guess never passes for evidence:+`base...head` diffs from the merge-base, so it is what a pull request changed;+`base..head` is the plain range, and a single SHA is one commit. Change risk follows the+same rule. Each result says how it was found, and a guess never passes for evidence:| Situation | Reported as ||-----------|-------------|@@ -172,34 +116,28 @@ Each result says how it was found, and a guess never passes for evidence:| None of the above | "unknown, run the full suite to be safe" || No map ingested at all | A prompt to run `coverage add` on a report with contexts |-The graph also carries test wiring no import states: runner setup files-(`setupFiles`, `globalSetup` and the like) link to the tests their config runs,-a helper a test starts by a path relative to itself links to that test, and a-`conftest.py` links to the files pytest collects. Each fixture request links-the test to the fixture, so a change a conftest reaches only through its-imports selects the tests whose fixtures use it, plus one import check.--With `--format list` the caveats go to stderr so the pipe stays clean. The-command exits `0` in every case: it reports, it does not gate. `--format args`-prints runner arguments, or `:all` whenever any part of the answer is unknown.-Rules, `tests.*` config keys and CI recipes:-[Selecting the tests a change needs](../start/CI.md#selecting-the-tests-a-change-needs).+The graph also links tests to wiring no import states: runner setup files, helpers a+test starts by path, `conftest.py` files and the fixtures a test requests+([details](../architecture/test-intelligence.md#test-wiring-edges)).-`base...head` diffs from the merge-base, so it is what a pull request changed.-`base..head` is the plain range. Change risk follows the same rule.+With `--format list` the caveats go to stderr so the pipe stays clean. The command exits+`0` in every case: it reports, it does not gate. `--format args` prints runner+arguments, or `:all` whenever any part of the answer is unknown. Rules, `tests.*` config+keys and CI recipes:+[Selecting the tests a change needs](../start/CI.md#selecting-the-tests-a-change-needs).## Patch coverage in CI-`repowise coverage check [REVSPEC]` gates a change on patch coverage: of the-changed lines the report marks executable, what share did the tests run?+`repowise coverage check [REVSPEC]` gates a change on patch coverage: of the changed+lines the report marks executable, what share did the tests run?```bashrepowise coverage check origin/main...HEAD --report coverage/lcov.info --fail-under 80```-It needs git and a report, nothing else: no index, no ingest, no LLM key. The-same figure appears in `get_change_risk`'s `patch_coverage` block and in the-REST patch-coverage route the editor reads.+It needs git and a report, nothing else: no index, no ingest, no LLM key. The same+figure appears in `get_change_risk`'s `patch_coverage` block and in the REST+patch-coverage route the editor reads.| File status | Meaning | Counts in the % ||-------------|---------|-----------------|@@ -209,135 +147,94 @@ REST patch-coverage route the editor reads.| `no_line_data` | The report names the file but gives no executable-line set | No || `stale_file` | Stored coverage only: the file changed since the commit the coverage was measured at | No; listed, no figures |-Exit `0` passes or had nothing to judge, `1` is below a gate, `2` means the-check could not run (no usable report, unknown revision, shallow clone without-a merge-base, bad config). With an index, each uncovered range also names the-test file to extend.--Everything else lives in [Repowise in CI](../start/CI.md): the GitHub Action-and GitLab template, the per-language report commands,-[path-scoped gates](../start/CI.md#path-scoped-gates),-[risk-weighted gates](../start/CI.md#risk-weighted-patch-coverage),-[branches on changed lines](../start/CI.md#branches-on-changed-lines),-[project coverage and coverage outside the change](../start/CI.md#project-coverage-and-coverage-outside-the-change),-and [monorepos and matrix jobs](../start/CI.md#monorepos-and-matrix-jobs). All-flags and JSON fields: the [`coverage check` reference](../reference/CLI_REFERENCE.md#repowise-coverage-check-revspec).+Exit `0` passes or had nothing to judge, `1` is below a gate, `2` means the check could+not run (no usable report, unknown revision, shallow clone without a merge-base, bad+config). With an index, each uncovered range also names the test file to extend. The+GitHub Action, GitLab template, per-language reports, path-scoped and risk-weighted+gates, branches, project coverage and monorepos: [Repowise in CI](../start/CI.md). All+flags and JSON fields: the+[`coverage check` reference](../reference/CLI_REFERENCE.md#repowise-coverage-check-revspec).## Untested hotspotsCoverage feeds the [code health](CODE_HEALTH.md) layer. The sharpest finding is-`untested_hotspot`, the "write tests before you refactor" case. It fires only-when a file is all three of:--1. **A hotspot**: flagged by the git layer, 8+ commits in 90 days, or a- temporal hotspot score of 0.8 or more.-2. **Depended on**: at least 4 dependents.-3. **Under-tested**: line coverage below 40%. With no coverage ingested, it- fires only when *nothing* says a test touches the file: no paired test file- by name and no test reaching it in the graph.+`untested_hotspot`, the "write tests before you refactor" case. It fires only when a+file is all three of:-Severity is `CRITICAL` at 15% coverage or less with 10+ dependents, `HIGH` at-one of those two, `MEDIUM` otherwise. `coverage_gap` covers thin-but-present-coverage, and `coverage_gradient` deducts in proportion to the uncovered share.+| Condition | Threshold |+|---|---|+| A hotspot | Flagged by the git layer, 8+ commits in 90 days, or a temporal hotspot score of 0.8 or more |+| Depended on | At least 4 dependents |+| Under-tested | Line coverage below 40%. With no coverage ingested, only when *nothing* says a test touches the file: no paired test file by name and no test reaching it in the graph |-Why the graph matters here: a filename convention fails both ways. On this-repository, five of the six worst bug-magnet files have no test named for them-yet are reached by 3 to 23 test files in the graph, and the sixth was paired-with a different subsystem's `test_engine.py` by basename alone.+Severity is `CRITICAL` at 15% coverage or less with 10+ dependents, `HIGH` at one of+those two, `MEDIUM` otherwise. `coverage_gap` covers thin-but-present coverage, and+`coverage_gradient` deducts in proportion to the uncovered share. The graph check+matters because a filename convention misses tests in both directions+([examples](../architecture/test-intelligence.md#why-a-graph-signal)).## From an agent-**`get_risk(changed_files=[...], include=["tests"])`** leads with a `directive`-whose `test_recommendations` names up to ten tests for the changed files. Each-row keeps its `basis`:+`get_risk(changed_files=[...], include=["tests"])` leads with a `directive` whose+`test_recommendations` names up to ten tests for the changed files. Each row keeps its+`basis`:| `basis` | Holds | Means ||---|---|---|| `measured` | A test node id | The per-test map shows the test covering a changed file || `inferred` | A test file path | The graph shows the test reaching the change; a candidate, not proof |-`tests_to_run`, sent without the include, is the run list from the same-selection `repowise impacted-tests` makes, with `tests_to_run_basis`,-`tests_to_run_why` and `tests_run_all` (plus `tests_run_all_reasons` when every-test must run). Without a coverage map the directive carries-`coverage: {status, reason}`; with one, `coverage_analysis` says whether-coverage is available, partial, degraded or stale.--**`get_change_risk(revspec=...)`** returns `impacted_tests`, the same selection-over the change's diff, so a measured map at either end of it matches by line:--```json-{- "status": "selected",- "run_all": false,- "reasons": [],- "basis": "measured",- "map_present": true,- "tests_to_run": ["tests/test_auth.py::test_login", "..."],- "why": {"tests/test_auth.py": "src/auth.py changed (coverage)"},- "total": 23,- "truncated": true,- "line_coverage": {- "untested_changes": [{"source_file": "...", "uncovered_lines": [...]}],- "stale_test_candidates": [...],- "covered": [...],- "no_coverage_data": [...]- },- "summary": "23 test(s) to run for this change (9 of 412 test files); showing first 10; the rest can be skipped."-}-```--`untested_changes` is the strong signal: the file is in the map but nothing-covers the lines you touched. `stale_test_candidates` flags covered lines whose-guarding test is absent from the diff. `no_coverage_data` means the file is not-in the map.--**Self-checking before a push.** `get_change_risk` without a `revspec` measures-`patch_coverage` over everything a push would bring: the working tree-(untracked files included) or `HEAD`, diffed from the merge-base with the-branch CI compares against. Uncommitted code is `current` when the last ingest-came after the newest edit of the changed files, else `stale`. When changed-lines are uncovered, the directive adds one `next_actions` line naming the-tests to extend, or saying to re-run tests with coverage first.--**Re-ingest after a test run** (opt-in). Set `hooks.coverage_reingest: true`-in `.repowise/config.yaml` (or `REPOWISE_HOOK_COVERAGE_REINGEST=1` for one-session). After the agent runs a whole test suite (`pytest`, `go test ./...`,-`npm test`, `cargo test`, `mvn test`, `./gradlew test` and similar), the hook-re-ingests any watched report that is newer than the last ingest, in the-background, and says so in one transcript line. It acts only in a repository-that has ingested coverage before, never on a run that targets some tests (a-path, `::`, `-k`, `-run`, `--filter`, `-p` and the like), never on a-`.coverage` database alone, and never on a report only a `**` glob finds. It-costs a process start after each shell command in that repository. Claude Code-runs it from repo-local hook entries ([what gets written where](../agent/HOOKS.md#what-gets-written-where));-Codex only after a successful command.+`tests_to_run`, sent without the include, is the run list `repowise impacted-tests`+makes, with `tests_to_run_basis`, `tests_to_run_why`, `tests_run_all` and+`tests_run_all_reasons` ([PR mode](CHANGE_RISK.md#pr-mode-get_risk-with-changed_files)).+`coverage_analysis` says whether coverage is available, partial, degraded or stale;+without a coverage map the directive carries `coverage: {status, reason}`.++`get_change_risk(revspec=...)` returns `impacted_tests`, the same selection over the+change's diff, so a measured map at either end of it matches by line+([payload](../architecture/test-intelligence.md#the-impacted_tests-payload)). In its+`line_coverage` block, `untested_changes` is the strong signal: the file is in the map+but nothing covers the lines you touched. `stale_test_candidates` flags covered lines+whose guarding test is absent from the diff. `no_coverage_data`: the file is not in the+map.++**Self-check before a push.** `get_change_risk` without a `revspec` measures+`patch_coverage` over everything a push would bring: the working tree (untracked files+included) or `HEAD`, diffed from the merge-base with the branch CI compares against.+Uncommitted code is `current` when the last ingest came after the newest edit of the+changed files, else `stale`. When changed lines are uncovered, the directive adds one+`next_actions` line naming the tests to extend, or saying to rerun tests with coverage.++**Re-ingest after a test run** (opt-in). With `hooks.coverage_reingest: true` in+`.repowise/config.yaml` (or `REPOWISE_HOOK_COVERAGE_REINGEST=1` for one session), a+whole-suite test run by the agent re-ingests any watched report newer than the last+ingest, in the background, with one transcript line+([trigger rules](../architecture/test-intelligence.md#coverage-re-ingest-hook)). It+costs a process start after each shell command in that repository. Claude Code runs it+from [repo-local hook entries](../agent/HOOKS.md#what-gets-written-where); Codex only+after a successful command.## Empty means unknown-**An empty test list never means the change is untested.** Every surface-carries a discriminator beside the list:--- `get_change_risk` `impacted_tests.status`:-- | `status` | Meaning |- |---|---|- | `selected` | The selection vouches for `tests_to_run`. Empty here means the change needs no test (documentation, a deleted test) |- | `run_all` | Every test must run; `reasons` says why, and `tests_to_run` is what to run first |- | `no_index` | Nothing indexed yet |- | `unknown` | The git or index read failed |- | `config_invalid` | `tests.*` in `.repowise/config.yaml` does not parse |- | `timeout` | The selection took over 30 seconds; `repowise impacted-tests` gives the same answer |- | `busy` | A selection for this repository is still running |-- Every status but `selected` carries `run_all: true`: nothing vouches for a subset.- | `no_source_line_changes` | No changed source lines to map |--- `get_risk` keeps coverage availability, freshness and map presence explicit- in `test_impact.coverage`. An empty list under unavailable analysis is- unknown, never "no tests needed".-- The CLI prints "unknown, run the full suite", and the per-file lookups report- a file with no data as `no_coverage_data`, not as uncovered.+**An empty test list never means the change is untested.** Every surface carries a+discriminator beside the list. For `get_change_risk`, `impacted_tests.status` is one of:++| `status` | Meaning |+|---|---|+| `selected` | The selection vouches for `tests_to_run`. Empty here means the change needs no test (documentation, a deleted test) |+| `run_all` | Every test must run; `reasons` says why, and `tests_to_run` is what to run first |+| `no_index` | Nothing indexed yet |+| `unknown` | The git or index read failed |+| `config_invalid` | `tests.*` in `.repowise/config.yaml` does not parse |+| `timeout` | The selection took over 30 seconds; `repowise impacted-tests` gives the same answer |+| `busy` | A selection for this repository is still running |+| `no_source_line_changes` | No changed source lines to map |++Every status but `selected` carries `run_all: true`: nothing vouches for a subset.+`get_risk` keeps coverage availability, freshness and map presence explicit in+`test_impact.coverage`; an empty list under unavailable analysis is unknown, never "no+tests needed". The CLI prints "unknown, run the full suite", and the per-file lookups+report a file with no data as `no_coverage_data`, not as uncovered.## Configuration@@ -346,8 +243,7 @@ The `coverage:` block in `.repowise/config.yaml`:```yamlcoverage:auto_discover: true- artifacts: # override the discovery globs- - "coverage/lcov.info"+ artifacts: ["coverage/lcov.info"] # override the discovery globspaths: # explicit reports or globs (skip discovery)- "coverage/lcov.info"- {path: "web/coverage/*.info", path_prefix: web} # per-report prefix@@ -362,63 +258,43 @@ coverage:- {name: api, paths: ["/services/api/"], fail_under: 85}```-Coverage is also auto-discovered and ingested during `init` and `update`, and+`init` and `update` also discover and ingest coverage;`repowise init --coverage-report <path>` takes explicit reports (repeatable).-`--coverage-report` is test coverage; `--coverage` controls documentation-breadth. Full block: [CONFIG.md](../reference/CONFIG.md).+`--coverage-report` is test coverage; `--coverage` controls documentation breadth. Full+block: [CONFIG.md](../reference/CONFIG.md).## Accuracy and limits-Inferred tier, dogfooded on this repository against a real-`coverage run --contexts=test` over a slice with complete per-test attribution-(37 test files, 159 production files provably executed):--- **"What reaches this file"** (suppresses `untested_hotspot`): **95.7%- precision**, 27.7% recall (46 claims, 44 correct).-- **"Which tests do I run"** (`tests_to_run`, `impacted_tests`): **97.5%- precision**, 100% of targets answered (47 targets).-- Recall reads low because coverage counts a file as run when it was merely- imported. Among files where over three quarters of what ran was inside- function bodies, recall is 77%.-- Framework-invoked code with no static caller (migrations run by naming- convention, for example) is not reached by the graph.-- Inferred answers are file-level; only measured data is line-level.-- Measured data is only as current as the last ingest; rows are tied to their- commit and read `stale` once the index moves past it.+The inferred tier is measured on the Repowise repository against a real+`coverage run --contexts=test`, over a slice with complete per-test attribution (37 test+files, 159 production files provably executed):-How these were measured and why the walk is shaped this way:-[architecture/test-intelligence.md](../architecture/test-intelligence.md).-Benchmark method across layers: [BENCHMARKS.md](../BENCHMARKS.md).+| Question | Precision | Reach |+|---|---:|---:|+| "What reaches this file" (suppresses `untested_hotspot`) | 95.7% (44 of 46 claims) | 27.7% recall |+| "Which tests do I run" (`tests_to_run`, `impacted_tests`) | 97.5% | 100% of 47 targets answered |-## Where it shows up+- Recall reads low because coverage counts a file as run when it was merely imported.+ Among files where over three quarters of what ran was inside function bodies, recall+ is 77%.+- Framework-invoked code with no static caller (migrations run by naming convention, for+ example) is not reached by the graph.+- Inferred answers are file-level; only measured data is line-level.+- Measured data is only as current as the last ingest: each ingest replaces the previous+ rows, so ingest at the commit you intend to query. Rows read `stale` once the index+ moves past their commit. The Tests tab trends the repo-wide totals of the newest 50+ ingests once there are three, leaving partial ingests out.-| Surface | What you get |-|---------|--------------|-| CLI | `repowise coverage add/status/check/suggest-gates`, `repowise impacted-tests` |-| MCP | `get_change_risk` (`impacted_tests`, `patch_coverage`), `get_risk` (`test_recommendations`, `tests_to_run`), `get_health` (coverage summary) |-| Dashboard | The Tests tab on the health page; coverage findings in code health |-| CI | The GitHub Action and GitLab template run `coverage check`; `impacted-tests --format args` selects tests |-| Editor | The branch-risk view reads patch coverage |-| Hooks | Optional re-ingest after an agent's full test run |+Method: [architecture/test-intelligence.md](../architecture/test-intelligence.md) and,+across layers, [BENCHMARKS.md](../BENCHMARKS.md).## Reference-| Command | What it does | Flags |-|---------|--------------|-------|-| `repowise coverage add [PATHS...]` | Ingest reports; auto-discovers with no path; builds the per-test map when contexts are present | `--path`, `--format`, `--strict`, `--verbose` |-| `repowise coverage status` | Coverage summary plus per-test map counts | `--path` |-| `repowise coverage check [REVSPEC]` | Patch-coverage gate, no index needed | `--report`, `--report-format`, `--fail-under`, `--min-coverable-lines`, `--fail-under-risky`, `--fail-under-branches`, `--base-report`, `--max-drop`, `--path`, `--format` |-| `repowise coverage suggest-gates` | Propose `coverage.gates` YAML; writes nothing | `--path`, `--format` |-| `repowise impacted-tests [REVSPEC]` | The tests a change exercises, or runner arguments | `--path`, `--staged`, `--format table\|json\|list\|args`, `--runner auto\|pytest\|go\|jest\|files` |--Full reference: [CLI_REFERENCE.md](../reference/CLI_REFERENCE.md#repowise-coverage).-MCP: [`get_change_risk`](../agent/MCP_TOOLS.md#get_change_risk),+Commands: `repowise coverage add [PATHS...]` (ingest; auto-discovers with no path),+`coverage status` (summary plus per-test map counts), `coverage check [REVSPEC]`+(patch-coverage gate, no index needed), `coverage suggest-gates` (proposes+`coverage.gates` YAML, writes nothing) and `repowise impacted-tests [REVSPEC]` (the+tests a change exercises, or runner arguments). Every flag:+[CLI_REFERENCE.md](../reference/CLI_REFERENCE.md#repowise-coverage). MCP:+[`get_change_risk`](../agent/MCP_TOOLS.md#get_change_risk),[`get_risk`](../agent/MCP_TOOLS.md#get_risk).--## See also--- [architecture/test-intelligence.md](../architecture/test-intelligence.md): the inferred tier's walks, measurements and storage choice.-- [Repowise in CI](../start/CI.md): gates, the GitHub Action, per-language reports.-- [CODE_HEALTH.md](CODE_HEALTH.md): coverage findings and how they deduct.-- [CHANGE_RISK.md](CHANGE_RISK.md): the review signal `impacted_tests` rides alongside.-- [CONFIG.md](../reference/CONFIG.md): the `coverage:` block.diff --git a/docs/layers/WIKI.md b/docs/layers/WIKI.mdindex 26586fab6..7286094f8 100644--- a/docs/layers/WIKI.md+++ b/docs/layers/WIKI.md@@ -52,11 +52,10 @@ configured model only names them.## Which pages exist-There is no page budget to spend by default. Every page type below the concept-tree is rendered from structure and costs no tokens, and the concept partition-is a total cover of the production files that would stop being a map of the-repository if it were rationed. So each bucket takes every candidate that clears-its eligibility floor.+By default there is no page budget. Every page type below the concept tree is+rendered from structure and costs no tokens, and the concept partition covers+every production file, so rationing it would stop it being a map of the+repository. Each bucket takes every candidate that clears its eligibility floor.The one exception is opt-in and owner-chosen. `max_file_pages` bounds the filebucket, highest importance first, for repositories large enough that the tail@@ -65,24 +64,22 @@ policy decide, `0` means one page per eligible file however many that is, and apositive value is a hard cap. It does not reduce model spend, because file pagesare rendered from structure either way.-Selection does not fork on whether a key is present, and that is the point: a-keyed and a keyless index of the same commit agree about which files have pages-at all.+Selection does not depend on whether a key is present: a keyed and a keyless+index of the same commit agree about which files have pages.## What a model writesThree page types are model-written when a provider is configured: `module_page`,-`repo_overview` and `onboarding`. That is the layer-where prose earns its keep, the one that explains how the codebase fits together-above the file level. Everything else is rendered from the parse, the import-graph and git history, and no model ever sees it.+`repo_overview` and `onboarding`. These pages explain how the codebase fits+together above the file level. Everything else is rendered from the parse, the+import graph and git history, and no model ever sees it.A model-written page is not prompted with raw source. It is prompted withassembled material: parsed structure and signatures, what the subject importsand what imports it, ownership and churn signals, the significant commits fromits history with merges, dependency bumps and lint-only commits filtered out,-and cross-references to the pages it should link to. That is the recipe for a-page that explains *why* rather than restating *what*.+and cross-references to the pages it should link to. The result explains *why*+instead of restating *what*.### Keyless runs@@ -97,22 +94,21 @@ decision archaeology are identical.### Two facts on every page-Worth keeping apart, because collapsing them is the mistake this layer has-already made once:+Each page records two separate facts:- **`provider_name`** answers *has a model written this page yet*. It is whatthe docs tree's "not written yet" marker and the reader's upgrade affordanceread.- **`confidence`** answers *how far should a reader trust the statements*. A- structure-rendered page is `1.0`, because everything on it was extracted- rather than summarised. A model-written page is `0.8`: grounded in the- assembled material and checked against it, but a summary of the code rather- than an extraction from it. Nothing gates on the difference, it is reported.+ structure-rendered page is `1.0`, because everything on it is extracted from+ the code. A model-written page is `0.8`: grounded in the assembled material+ and checked against it, but a summary of the code instead of an extraction.+ Nothing gates on the difference; it is reported.The axis is trust, not completeness. A page can be thin and still be entirely-true. The only `0.3` left is a page that was meant to carry prose and lost it to-a provider outage, which is the one state a reader cannot infer from the page-itself. A keyless run produces `1.0` pages throughout, because an index built+true. A `0.3` marks a page that was meant to carry prose and lost it to a+provider outage, the one state a reader cannot infer from the page itself. A+keyless run produces `1.0` pages throughout, because an index builtwithout a key is that shape by design.## Adding prose later@@ -130,7 +126,7 @@ repowise update --full # the whole wiki at once````generate` writes the model-written pages and only those. Naming a structural-page with `--page` is an actionable error rather than a silent LLM re-render,+page with `--page` is an actionable error instead of a silent LLM re-render,because those pages refresh on `repowise update` for free. Run it bare on aterminal and it prints the wiki's state, defaults to the unwritten pages, andends at the normal cost confirmation.@@ -148,13 +144,11 @@ Two mechanisms decide what is stale:verbatim, with no tokens spent.- **Structure-rendered pages** fold the subject's own hash together with afingerprint of the renderer: the template source, the resolved style and the- output language. Nothing else refreshes these pages, and no model will ever- come along and fix them, so comparing the stored key against a freshly- computed one is what turns a released template change into exactly one- regeneration.+ output language. Comparing the stored key against a freshly computed one+ turns a released template change into exactly one regeneration.-That second mechanism is why shipping a template edit shows up as a one-time-re-render of every page of that type. It is the intended behaviour, not drift.+So a new Repowise release that edits a template re-renders every page of that+type once. That is intended, not drift.`--cascade-budget N` caps how many pages a single update may regenerate fromcascading changes. It is adaptive when unset, which is what you want except on a@@ -200,7 +194,7 @@ reuses the existing index and git data, so nothing is re-resolved or re-blamed.repowise restyle reference```-In the web app, **Settings → Documentation style** does the same, and an+In the web app, **Settings > Documentation style** does the same, and anindividual page can be regenerated in a one-off style from its **Regenerate**control.