diff --git a/README.md b/README.md
index 5f33eafd..cfd01e65 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,7 @@ writes prose on top of those facts, and the app marks every AI sentence as AI.
| Stage 3, `model`: the map of modules per snapshot | Works on all three repositories |
| Stage 5, `analyze`: decisions, finding types, before and after | Works on all three repositories |
| Stage 7, `report`: ranking, `findings.json`, the web bundle | Works on all three repositories |
-| Web app: Overview, Decisions, Findings and finding detail, Map, Change, Trust, Size | Works on the three bundles and the two synthetic fixtures in `web/public/bundles/`; see [Web app](#web-app) |
+| Web app: the tabs Report, Findings (with finding detail), Map, Before and after, Approach, and the Decisions and Size screens | Works on the three bundles and the two synthetic fixtures in `web/public/bundles/`; see [Web app](#web-app) |
| Stage 6, `judge`: AI text for the shown findings | Works with `LLM_API_KEY` set; answers are cached in the run folder, so a re-run makes no call |
| `decisions propose`: rules proposed from written decision documents | Works with `LLM_API_KEY` set; writes `proposals.yaml` for review, and the reviewed rules are in `rules/` |
| `check
This finding holds no evidence record.
)} {shown.map((g) => ( -- {listed.length} more {listed.length === 1 ? "file" : "files"} · open one to read its - lines + Open a file to read its lines.
+ {"{"} + {stop.payload.fields.map((f) => { + const added = prev !== null && !before.has(f.key); + return ( + + {" "} + {f.key} + : + {f.value} + + ); + })} + {"}"} ++
+ {prev ? "Highlighted fields are new at this stop. " : ""}Values are an example request. +
++ Stop {idx + 1} of {journey.stops.length} + / + {lanes[s.lane]} +
+{s.caption}
+{s.file}
+
+ {s.method}
+
+ + {s.via ? ( + <> + Arrived by {s.via.label} + {prev && ( + <> + {" "} + from {prev.module} + > + )} + > + ) : ( + "Start of the journey" + )} +
+ {finding && ( + + #{finding.rank} + + {finding.title} + + Open the finding, its graph and its code + + + + )} +{journey.name}
++ {journey.stops.length} stops through {modules} modules + {findingSteps > 0 && + `, ${findingSteps} ${findingSteps === 1 ? "step is a ranked finding" : "steps are ranked findings"}`} + . +
+- Hover or focus a cell. Rows use columns. Click to open it on the Map. + Rows use columns. Click a cell to open it on the Map.
+ Did the structure get better or worse once the team started using AI coding tools? +
++ This page shows what changed between the two dates. It does not blame any change on AI: + only commits with an explicit AI marker are counted as AI, so that share is a lower bound, + and everything else is no AI signal. +
+- Markers are a lower bound: a commit without one has no AI signal, nothing more. -
)}- Rule: z = (recent − prior) ÷ √(prior + 1) of at least 3, with at least 2 changes per month - recently; new files and restructuring commits are left out. -
-- recent: changes in the last 3 months.{" "} - prior: expected changes in 3 months, - from the months before. The bar is z. -
-
+ Files that changed far more often in the last 3 months than their own history predicts. New
+ files and restructuring commits are left out.
No file met the rule in this run.
) : ( @@ -174,10 +157,10 @@ function Hotspots({ repo }: { repo: RepoBundle }) { )} - prior {h.prior.toFixed(2)}{" "} -{fmt(added.length)} new {added.length === 1 ? "link" : "links"} between modules:{" "} - {fmt(c.planned)} planned, {fmt(c.none)} with no stated intent. Each one's evidence is - listed under structural events. + {fmt(c.planned)} planned, {fmt(c.none)} unexplained. Each one's evidence is listed under + "Show every change" above.
{plan && (
@@ -306,6 +286,7 @@ function NewLinks({ repo }: { repo: RepoBundle }) {
function AiRisk({ repo }: { repo: RepoBundle }) {
const sponsor = repo.sponsorDate ?? repo.beforeDate;
+ const missing = missingAiData(repo);
return (
- Each evidence line is credited to the last change that touched it, which is not always the
- change that first wrote it. The marked share counts explicit AI markers only, so it is a
- lower bound.
+ For each top finding: how much of the code behind it changed after {sponsor}, and how much
+ of that carries an explicit AI marker. Each line counts toward the last change that
+ touched it. Only explicit markers count as AI, so the AI share is a lower bound.
+ {missing && ` ${missing}`}
No finding was ranked in this run.
- Rules come from what the project enforces in its build, what its docs say, and habits the
- code measurably keeps. Conformance is the share of links where the rule could apply and is
- kept.
+ Decisions come from what the project enforces in its build and tests, what its documents
+ say, and habits the code measurably keeps; conformance is the share of links where a
+ decision could apply and is kept.
No decision could be checked in this run. No finding was ranked in this run.
- Legend
-
- Statuses are checked in this order and the first match wins. Each trend line runs over the
- stored snapshots; the dashed line marks{" "}
- {compareDate}.
- one check, at {dates[0]}
{d.statement}
-
-
- {d.id} · source{" "}
-
+
- {values.length === 1 ? `one check only, at ${dates[0]}` : "no stored checks"}
-
+
“{w.statement}”
{w.proposedBy === "ai" &&
+ #{f.rank}
+ of {fmt(all.length)}
+ /
+ {TYPE[f.type].label}
+ {!inTop &&
-
- Why it matters
+ )}
+ {seenIn.length > 0 && (
+
+ Seen in{" "}
+ {seenIn.map((x, i) => (
+
+ {i > 0 && ", "}
+
+ the journey "{x.journey.name}", stop {x.stop + 1}
+
- {TYPE[f.type].why}
- The order is arithmetic on stored numbers, explained below the list. No AI model changes
- the order. Each finding carries its own evidence and caveats.
-
+ {rankedCount === 1 ? "1 finding is ranked" : `${fmt(rankedCount)} findings are ranked`},
+ in an order computed from stored numbers with no AI model.
+
+
+ How the rank is computed, under Approach
+
- The same ranking continues here. The top 10 is limited to a few findings per type and
- per module, so some of these have a higher score than a finding above them.
-
+ The top 10 holds at most a few findings per type and per module, so some of these
+ score higher than a finding above them.
+
- How the rank is computed
- impact = A × ({w(weightOf(repo, "S"))}·S + {w(weightOf(repo, "R"))}·R +{" "}
- {w(weightOf(repo, "P"))}·P)
- priority = impact × ease, rounded to 2 places order: priority, then finding id
- The weights are stored with the run; they are a judgement, not a standard. The top 10 then
- holds at most 3 findings of one type and 2 from one module.
-
- Every cheap-loop fix whose own simulation succeeded with no new exception, applied
- together on a copy of the map. Nothing is applied to the code.
- {batch.newExceptions.length > 0 &&
- ` The batch creates ${fmt(batch.newExceptions.length)} new ${batch.newExceptions.length === 1 ? "exception" : "exceptions"}.`}{" "}
- {BATCH_LOOPS_NOTE}
+ Every cheap-loop fix that simulated cleanly, applied together on a copy of the map, not
+ to the code.
+ Each journey starts with something a person does in the browser and follows it through the
+ modules that handle it. The height of the line is the layer: a dip goes down into core
+ code, a rise brings the result back up. Press Play or pick any stop.
+
+ These journeys are a hand-traced sample for {repo.name}, not yet produced by the pipeline.
+ File paths are shortened to the module folder.
+
- CodeXray measures how well a codebase keeps its own architecture decisions over
- time, before and after the team adopted AI coding tools, and tells you which
- exceptions to fix first.
-
+ CodeXray checks a repository against its architecture decisions and ranks the
+ exceptions it finds. Each finding links to its place on the module map and to the
+ lines of code.
+ snapshot {dates[0]}
+ Loading the list of reports…
+
+ The list of reports could not be loaded.{" "}
+ {summaries.why}
+
+ No report of a real repository is in bundles/index.json.
+
- Finding, counting and ranking are computed, with no AI model. An AI model writes
- prose in three places only: reading written decisions, judging the code behind an
- exception, and describing a module. Each of its sentences is checked against the
- stored facts and marked AI.
-
- {real.length} {real.length === 1 ? "repository" : "repositories"}
- {dates.length === 1 && ` · snapshot ${dates[0]}`}
-
- Loading the list of reports…
-
- The list of reports could not be loaded.{" "}
- {summaries.why}
-
- No report of a real repository is in bundles/index.json.
-
- Synthetic fixtures, for testing the screens:{" "}
- {fixtures.map((r, i) => (
-
- {i > 0 && " · "}
-
- {r.label}
-
-
- ))}
- {title}
+ {checked === 0
+ ? "No decision checked."
+ : `${checked} ${checked === 1 ? "decision" : "decisions"} checked: ${present
+ .map((s) => `${counts[s]} ${STATUS[s].label.toLowerCase()}`)
+ .join(", ")}`}
+
+ The rest of this card could not be loaded.
+
- Each row uses the columns it has links into. Switch between the code at the before date,
- now, and now with the simulated fix batch; the layout stays the same and only the colours
- change.
+ Every square is one of the {fmt(present)} modules using another. Above the diagonal, blue
+ squares point the normal way, from features down to the shared code they build on. Below
+ it, orange squares point backwards. Click a square to see the code behind it.
+ {listsBeforeOnly &&
+ beforeOnly > 0 &&
+ ` ${fmt(beforeOnly)} more ${beforeOnly === 1 ? "module" : "modules"} existed only at the before date.`}
No finding was ranked in this run. {hint}
- {repo.adoptionDate ? (
- <>
- The team adopted AI coding tools around{" "}
- {repo.adoptionDate.slice(0, 7)}
- .{" "}
- >
- ) : (
- <>No adoption date of AI coding tools was detected in this run. >
- )}
- Everything below compares the code before and after{" "}
- {compareDate.slice(0, 7)}.
- No decision could be checked in this run.
- {d.statement}
-
+
- Simulated fix batch
-
- Every cheap-loop fix whose own simulation succeeded with no new exception is applied
- together, on a copy of the module map. Nothing is applied to the code.
- {batch.fixesSkipped > 0 &&
- ` ${fmt(batch.fixesSkipped)} ${batch.fixesSkipped === 1 ? "fix was" : "fixes were"} left out.`}
- {batch.newExceptions.length > 0 &&
- ` The batch creates ${fmt(batch.newExceptions.length)} new ${batch.newExceptions.length === 1 ? "exception" : "exceptions"}.`}{" "}
- {BATCH_LOOPS_NOTE}
- {d?.statement ?? h.decisionId}
- {h.evidence}
- {f.origin.note} Lines without an explicit marker carry no AI signal.{" "}
-
+ The AI share counts explicit markers only, so it is a lower bound, and lines without a
+ marker carry no AI signal. Facts This finding stores no fact.
+
-
- Every sentence here is computed from the stored facts. The model reads only the
- highest-ranked decision exceptions and overloaded classes, and a reading that fails a
- check is not shown.
+
+ No AI reading is shown for this finding, so this text is built from the stored facts
+ by fixed rules.
+
+ Why it matters
+ {TYPE[f.type].why} {NO_FIX_TEXT}
+
Simulation
{fix ? SIMULATION[kind].long : NO_FIX_TEXT}
- The numbers match the grid’s axes. Pick a module to highlight its row and column
- and read what it does. Click a cell to list the code links behind it.
+ The numbers match the grid. Pick a module to highlight its row and column.
No description of this module in this run.
- “Used by” and “uses” count link lines at {repo.snapshotDate}.{" "}
-
+ “Used by” and “uses” count link lines at {repo.snapshotDate}.{" "}
+
+ {repo.adoptionDate ? (
+ <>
+ The team adopted AI coding tools around{" "}
+ {repo.adoptionDate.slice(0, 7)}. Here
+ is how the structure moved from {monthYear(compareDate)} to now.
+ >
+ ) : (
+ <>How the structure moved from {monthYear(compareDate)} to now.>
+ )}
+
+ {f.title}
+
+ {TYPE[f.type].label}. {TYPE[f.type].why}
+ {f.judgement && (
+
+
+ {VERDICT[f.judgement.verdict]}
+
+ No finding was ranked in this run.
-
+ {m.description.source === "ai" &&
+ {title} {lead}
- What this report rests on
+ How many of the top 10 findings stay in the top 10 under each change.{" "}
+
+ Three jobs, each one where reading prose is needed. Text a model wrote carries the{" "}
+
+ Given: {j.given}
+
+ Returns: {j.returns}
+
+ A failed check gets one retry, except a wrong number, which is rejected. An answer that
+ still fails is replaced by the computed sentence. Answers are cached, so a re-run with the
+ same inputs returns the same text.
+ No AI call is logged in this run.
+ A job without a row has no call logged in this run's ledger.
+
+ impact = A × ({w(weightOf(repo, "S"))}·S + {w(weightOf(repo, "R"))}·R +{" "}
+ {w(weightOf(repo, "P"))}·P)
+ priority = impact × ease, rounded to 2 places order: priority, then finding id
+ The weights are stored with the run; they are a judgement, not a standard. The top 10
+ then holds at most 3 findings of one type and 2 from one module.
+
+ {s.does}
+
- Each rule is one of four shapes, checked against every link in the code.
-
+
+ Decisions checked
- {list.map((d) => (
-
- )}
-
-
- {repo.findings.slice(0, FINDINGS_SHOWN).map((f) => (
-
- )}
-
+ {list.map((d) => (
+
- {STATUS_ORDER.map((s) => (
-
-
+ {STATUS_ORDER.map((s) => (
+
);
}
-function Provenance({ d }: { d: Pick
+
- {d.argList.map(({ key, values: v }) => (
-
- )}
-
- {(
- [
- ["exceptions", fmt(d.exceptions)],
- ["opportunities", fmt(d.opportunities)],
- ["per 1,000 lines", d.perKloc.toFixed(2)],
- ["modules covered", fmt(d.modulesCovered)],
- ["allowed exceptions", fmt(d.allowed)],
- ] as const
- ).map(([k, v]) => (
-
{findings.length > 0 && (
-
+
{findings.map((f) => (
-
)}
+
+
+
+ {rows.map(([k, v]) => (
+
+
- {shown.map((w) => (
-
-
+
+
+ {shown.map((w) => (
+
+
- {f.title}
-
+
+ {f.title}
+
+ {f.judgement && (
- One list, ranked by what pays back first.
-
-
- {groups.map((g) => (
-
- )}
+ Findings
+
- {rest.map((f) => (
-
- {restAll.length > SUPPORTING_SHOWN && (
-
+ {rest.map((f) => (
+
+
- {LETTERS.map(([k, label]) => (
-
-
{(
[
- ["loops", `${fmt(batch.loopsBefore)} → ${fmt(batch.loopsAfter)}`],
- ["links cut", fmt(batch.linksRemoved)],
- ["links added", fmt(batch.linksAdded)],
- ["applied", fmt(batch.fixesApplied)],
- ["skipped", fmt(batch.fixesSkipped)],
+ ["loops", `${fmt(batch.loopsBefore)} → ${fmt(batch.loopsAfter)}`, BATCH_LOOPS_NOTE],
+ ["links cut", fmt(batch.linksRemoved), undefined],
+ ["links added", fmt(batch.linksAdded), undefined],
+ ["applied", fmt(batch.fixesApplied), undefined],
+ ["skipped", fmt(batch.fixesSkipped), undefined],
+ ...(batch.newExceptions.length > 0
+ ? ([["new exceptions", fmt(batch.newExceptions.length), undefined]] as const)
+ : []),
] as const
- ).map(([k, v]) => (
-
+ Follow one request through the code
+
+
- Your team wrote down how the code should fit together.{" "}
- Is it still true?
-
-
+ Which architecture problems to fix first, with the code behind each
+
+
+ Reports
+
+ {dates.length === 1 && (
+
- {STEPS.map(([t, d], i) => (
-
-
+ {real.map((r) => (
+
- Reports
+
+ How it works
- {summaries.state === "ready" && (
-
- {real.map((r, i) => (
-
- )}
- {fixtures.length > 0 && (
- 2 ? "lg:grid-cols-5" : "lg:grid-cols-2",
+ )}
+ >
+ {stages.map(([name, text], i) => (
+
- {present.flatMap((s) =>
- Array.from({ length: counts[s] }, (_, k) => (
-
-
-
- Modules ordered foundation-last. Anything below the diagonal points against the grain.
+ Which module uses which
- {repo.findings.slice(0, 5).map((f) => (
-
- )}
-
+ {STATUS_ORDER.map((s) => (
+
-
- {total > 0 && (
-
- {STATUS_ORDER.map((s) => (
-
-
-
-
- {shown.map((d) => {
- const values = d.series.map((s) => s.conformance);
- const lo = Math.min(0.75, ...values);
- return (
-
- )}
+
- Apply the {fmt(batch.fixesApplied)} simulated{" "}
- {batch.fixesApplied === 1 ? "fix" : "fixes"} and module loops{" "}
- {batch.loopsAfter === batch.loopsBefore
- ? `stay at ${fmt(batch.loopsBefore)}`
- : `go from ${fmt(batch.loopsBefore)} to ${fmt(batch.loopsAfter)}`}
- .
-
-
- Not simulated in this run.
-
- )}
-
- {(
- [
- ["loops", `${fmt(batch.loopsBefore)}→${fmt(batch.loopsAfter)}`],
- ["links cut", fmt(batch.linksRemoved)],
- ["links added", fmt(batch.linksAdded)],
- ["applied", fmt(batch.fixesApplied)],
- ["skipped", fmt(batch.fixesSkipped)],
- ] as const
- ).map(([k, v]) => (
-
- )}
-
- {shown.map((h) => {
- const d = repo.decisions.find((x) => x.id === h.decisionId);
- return (
-
+ How they work together: {first.name.toLowerCase()}
+
+ Play the {journeys.journeys.length} journeys{" "}
+
+ Facts
+
- {f.facts.map((x) => (
-
-
+ )}
+
+ {facts.map((x) => (
+
- ) : (
-
+ Judgement
+
+
diff --git a/web/src/routes/map/CellPanel.tsx b/web/src/routes/map/CellPanel.tsx
index 6383dfd5..0c08b47d 100644
--- a/web/src/routes/map/CellPanel.tsx
+++ b/web/src/routes/map/CellPanel.tsx
@@ -72,7 +72,7 @@ export function CellPanel({
<>
{" · "}
- {against ? "against the grain" : "with the grain"}
+ {against ? "backward link" : "forward link"}
>
)}
diff --git a/web/src/routes/map/ModulePanel.tsx b/web/src/routes/map/ModulePanel.tsx
index 9e7cb43b..725265e9 100644
--- a/web/src/routes/map/ModulePanel.tsx
+++ b/web/src/routes/map/ModulePanel.tsx
@@ -1,5 +1,5 @@
import { X } from "lucide-react";
-import { AiBadge, ComputedMark, NotMeasured } from "../../components/cx/badges";
+import { AiBadge, ComputedMark } from "../../components/cx/badges";
import { FOCUS, cn } from "../../components/cx/cn";
import { Prose } from "../../components/cx/primitives";
import { fmt } from "../../cx/meta";
@@ -11,18 +11,26 @@ function Source({ source }: { source: "ai" | "computed" }) {
return source === "ai" ?
Modules
- {repo.modules.map((mm, i) => (
+ {listed.map(({ mm, i }) => (
- {(
- [
- ["lines", num(m.loc)],
- ["files", num(m.files)],
- ["instability", num(m.instability, 2)],
- ["used by", num(m.linksIn)],
- ["uses", num(m.linksOut)],
- ["changes 12m", num(m.changes12m)],
- ] as const
- ).map(([k, v]) => (
-
-
+ {stats.map(([k, v, digits]) => (
+
+
+ {repo.findings.slice(0, SHOWN).map((f) => (
+
+ )}
+
+ {shown.map((m) => (
+
+ );
+}
diff --git a/web/src/routes/overview/TrustStrip.tsx b/web/src/routes/overview/TrustStrip.tsx
index 123c7c7c..1a57debe 100644
--- a/web/src/routes/overview/TrustStrip.tsx
+++ b/web/src/routes/overview/TrustStrip.tsx
@@ -1,91 +1,140 @@
import { ArrowRight } from "lucide-react";
import type { ReactNode } from "react";
import { Link } from "react-router";
-import { ComputedMark, NotMeasured } from "../../components/cx/badges";
+import { ComputedMark } from "../../components/cx/badges";
import { FOCUS, cn } from "../../components/cx/cn";
+import { SectionHead } from "../../components/cx/primitives";
import { repoPath } from "../../cx/address";
import { fmt } from "../../cx/meta";
import type { RepoBundle } from "../../cx/types";
-/** Cost in US dollars, written as the Trust screen writes it. */
-const usd = (n: number) => `$${n.toFixed(3)}`;
+/** The stored re-run tests, in the order a reader can follow them. */
+const TESTS: { test: string; label: string }[] = [
+ { test: "identical_rerun", label: "Run again, same input" },
+ { test: "fresh_ai_run", label: "Run again with fresh AI text" },
+ { test: "commits_removed_5pct", label: "5% of commits left out" },
+ { test: "weights_changed_20pct", label: "Ranking weights moved by 20%" },
+ { test: "end_date_minus_1_month", label: "Snapshot one month earlier" },
+];
-function Fact({ label, children }: { label: string; children: ReactNode }) {
+function Block({
+ title,
+ lead,
+ children,
+}: {
+ title: string;
+ lead: ReactNode;
+ children?: ReactNode;
+}) {
return (
-
-
+ {tests.map((t) => (
+
)}
-
-
+
+
+ {JOB_DETAIL.map((j) => (
+
+
+ Before a judgement is shown, it must pass every check
+
+
+ {CHECKS.map((c) => (
+
+
+ {cells.map((c, i) => (
+
+ );
+ return (
+
+ {c}
+
+ ))}
+
+ Every call, logged and priced
+ {rows.length > 0 && (
+
+ {fmt(sum("calls"))} calls · {usd(sum("cost"))} total
+ {rows.length === 0 ? (
+
+
+
+
+ {head.map((h, i) => (
+
+
+
+ {sorted.map((u) =>
+ row(`${u.job}-${u.model}`, [
+
+ {u.job} · {JOBS[u.job]}
+ ,
+ {u.model},
+ fmt(u.calls),
+ fmt(u.cached),
+ fmt(u.tokensIn),
+ fmt(u.tokensOut),
+ fmt(u.cachedInputTokens),
+ usd(u.cost),
+ ]),
+ )}
+ {row(
+ "total",
+ [
+ Total,
+ "",
+ fmt(sum("calls")),
+ fmt(sum("cached")),
+ fmt(sum("tokensIn")),
+ fmt(sum("tokensOut")),
+ fmt(sum("cachedInputTokens")),
+ usd(sum("cost")),
+ ],
+ true,
+ )}
+
+
+ {h}
+
+ ))}
+
+ {LETTERS.map(([k, label]) => (
+
+
+ {numbers.map(([v, noun]) => (
+
+ )}
+ {title}
+ {note}
+
+ {stages.map((s) => (
+
+