Open-source AI Security Operations Center: alert fusion, LLM-agent triage, MITRE ATT&CK investigation, and a replayable decision ledger for every agent step. Self-hostable, runs with no API keys, MIT licensed. Ships an MCP server for Claude, Cursor and Continue.
Python agentic-aiai-securityalert-triageblue-teamcybersecuritydetection-engineeringincident-responselanggraphllm-agentsmcpmitre-attackmodel-context-protocolpurple-teamsecurity-operationsself-hostedsiemsoarsocthreat-detectionthreat-intelligence
Two advisories a workspace override could not reach, and a graph the console showed whole (#832)
Beenu Arora6f9e0dec7fd5
diff --git a/.github/dependabot.yml b/.github/dependabot.ymlindex ce8716454..8d7bcf727 100644--- a/.github/dependabot.yml+++ b/.github/dependabot.yml@@ -63,8 +63,29 @@ updates:# tree that would add several hundred megabytes to every other TypeScript# CI job. That also means the `/` entry above does not cover it — and# Dependabot *alerts* scan every manifest regardless of this file, so- # alerts appeared here that no update job could ever act on. A security- # update against an uncovered directory is what failed the Dependabot run.+ # alerts appeared here that no update job could ever act on.+ #+ # Adding this entry made the directory visible to update jobs. It did not,+ # and cannot, make every advisory here actionable, and the difference is+ # worth writing down because the next person will read a red+ # `Dependabot Updates` run and look for a mistake in this file.+ #+ # A security update for a *transitive* npm dependency can only propose a+ # version the parent's own range permits. Two `image-size` advisories+ # (GHSA-5p2g-fcmc-qvqq, GHSA-w3rx-r6r6-pgpr) are fixed in 2.0.3, and every+ # `metro` release that depends on `image-size` declares `^1.0.2` — so the+ # highest version Dependabot could install was 1.2.1 and it recorded+ # `security_update_not_possible`, which surfaces as a *failed job* rather+ # than as a pull request. Raising the parent was not a route either: the+ # only `@expo/metro` that drops `image-size` ships with Expo SDK 55, and+ # `expo` is pinned to 54 here.+ #+ # The fix for that class is a pnpm override in `apps/mobile/package.json`,+ # which is a resolution decision this file has no way to express.+ # `scripts/check_toolchain_pins.py` now compares the override sets and the+ # resolved versions of every install root against each other, so an+ # override applied in the workspace and not here fails CI instead of+ # sitting as an open alert nobody can action.- package-ecosystem: npmdirectory: /apps/mobileschedule:@@ -87,6 +108,15 @@ updates:- dependency-name: "react-native"- dependency-name: "react"- dependency-name: "react-dom"+ # Hold `typescript` on v6, for the same measured reason as the `/` and+ # `/services/realtime` entries above. This directory's CI gate is+ # `tsc --noEmit`, so a TypeScript 7 pull request reds it exactly the way+ # it reds `apps/web` — and it was the only Node install root running+ # `tsc` without the hold, which is the same shape as the `image-size`+ # finding: a decision taken for the workspace that never reached the+ # root installing separately.+ - dependency-name: "typescript"+ update-types: ["version-update:semver-major"]# ── services/realtime ────────────────────────────────────────#diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 92fcb5032..166c623ed 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,6 +7,81 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0## [Unreleased]+### Security++- **`apps/mobile` resolved a vulnerable `image-size` that the workspace had+ already fixed.** Two high-severity advisories — GHSA-5p2g-fcmc-qvqq+ (CVE-2025-71329, JXL/HEIF parsers) and GHSA-w3rx-r6r6-pgpr+ (CVE-2025-71330, ICNS parser), both infinite-loop denial of service, both+ fixed in 2.0.3 — stayed open against `apps/mobile/pnpm-lock.yaml` for a+ structural reason rather than an unfixed one. The repository root pinned+ `image-size` to `>=2.0.4 <3` through a pnpm override, and `apps/mobile` is+ a deliberately independent install root with its own+ `pnpm-workspace.yaml` and lockfile, created that way so its install would+ stop rewriting the root lock. The override could not reach it and nothing+ compared the two. Resolved by declaring the same override in+ `apps/mobile/package.json`; the lockfile now resolves `[email protected]`+ and drops its `queue` dependency with it.++ Metro is the only consumer, and no version of Metro that depends on+ `image-size` permits 2.x — every one declares `^1.0.2`, which is why+ Dependabot recorded `security_update_not_possible` and failed its job+ instead of opening a pull request. Metro 0.83.3's two call sites go+ through `_interopRequireDefault(require("image-size")).default`, and+ `[email protected]`'s CommonJS build still exports a callable `default`, so+ `metro.getAssetSize` returns correct dimensions against it.++### Added++- **The Attack Graph says when it is showing a truncated graph.**+ `GET /api/v1/graph` bounds itself to 400 nodes and 900 edges and reports+ `truncated`; the console rendered the flag nowhere, so a graph cut at the+ ceiling and a graph that is genuinely that size looked identical. On an+ attack graph that difference changes a conclusion — a missing edge reads+ as a lateral path that does not exist. The view now shows a+ `role="status"` notice naming the counts, the depth and the ceiling that+ produced them, with a depth control that issues a new query rather than+ re-rendering the cached one. The three existing states are unchanged: an+ empty tenant still reads as empty, an unreachable backend still names the+ endpoint and the status, and neither is reported as a truncation.++- `GraphOverviewResponse` gains `nodeLimit` and `edgeLimit`, read from+ `graph_service` rather than restated, so the ceiling a client reports is+ the ceiling the service applied. Additive and defaulted; no existing+ consumer changes.++### Fixed++- **`scripts/check_toolchain_pins.py` compares every Node install root+ against every other.** There are four — the workspace root, `apps/mobile`,+ `services/realtime` and `services/mcp/cursor-extension` — and the gate read+ dependency resolution out of the first one only, so the `image-size` split+ above was invisible to it. It now discovers install roots structurally,+ reads both pnpm and npm override spellings and both lockfile formats, and+ checks in both directions: an override declared in one root against what+ every other root resolved, and each root's own lockfile against its own+ manifest. Exemptions are keyed on the exact versions they were verified+ against, so a bump re-opens the question rather than inheriting the+ clearance. Running it against the pre-fix tree names the defect and the+ file; running it over a lockfile it cannot parse, or a tree with no+ install root, fails rather than reporting a clean comparison it never+ performed. The gate found a third instance of the same class on first run+ (`ws` 6.2.6/7.5.13 in `apps/mobile`, verified clean against OSV and+ recorded).++- The workspace-wide `esbuild` override ban now applies to every install+ root instead of the repository root alone. `apps/mobile` was the one place+ the mistake that broke Turbopack's font import map could have been+ reintroduced without anything noticing, because its bundler is Metro and+ the damage would surface in a different workspace.++- `.github/dependabot.yml`'s `apps/mobile` entry gains the `typescript`+ semver-major hold that the `/` and `/services/realtime` entries already+ carry. Its CI gate is `tsc --noEmit`, so it was the only Node install root+ running `tsc` without the hold — the same shape as the `image-size`+ finding, a decision taken for the workspace that never reached the root+ installing separately.+### BREAKING- **Three MSSP response schemas describing fabricated data are removed:diff --git a/apps/mobile/package.json b/apps/mobile/package.jsonindex a7e07d36f..8b5ce448d 100644--- a/apps/mobile/package.json+++ b/apps/mobile/package.json@@ -36,7 +36,8 @@"overrides": {"postcss": "^8.5.23","decode-uri-component": "^0.5.0",- "uuid": "^11.1.1"+ "uuid": "^11.1.1",+ "image-size": ">=2.0.4 <3"}}}diff --git a/apps/mobile/pnpm-lock.yaml b/apps/mobile/pnpm-lock.yamlindex d7118c4e3..13a0310ed 100644--- a/apps/mobile/pnpm-lock.yaml+++ b/apps/mobile/pnpm-lock.yaml@@ -8,6 +8,7 @@ overrides:postcss: ^8.5.23decode-uri-component: ^0.5.0uuid: ^11.1.1+ image-size: '>=2.0.4 <3'importers:@@ -4195,12 +4196,10 @@ packages:engines: {node: '>= 4'}dev: false- resolution: {integrity: sha512-rH+46sQJ2dlwfjfhCyNx5thzrv+dtmBIhPHk0zgRUukHzZ/kRueTJXoYYsclBaKcSMBWuGbOFXtioLpzTb5euw==}- engines: {node: '>=16.x'}+ resolution: {integrity: sha512-QRUkFFsRV/6fuESxb9Vkq+a0LkSrgKXuc2NEqfikiXxxN/G3tjWt5EVUlMaImRBZRZK/jRBEbYvpPYZL8t08Zw==}+ engines: {node: '>=18'}hasBin: true- dependencies:- queue: 6.0.2dev: false@@ -5037,7 +5036,7 @@ packages:flow-enums-runtime: 0.0.6graceful-fs: 4.2.11hermes-parser: 0.32.0- image-size: 1.2.1+ image-size: 2.0.4invariant: 2.2.4jest-worker: 29.7.0jsc-safe-url: 0.2.4@@ -5567,12 +5566,6 @@ packages:strict-uri-encode: 2.0.0dev: false- resolution: {integrity: sha512-iHZWu+q3IdFZFX36ro/lKBkSvfkztY5Y7HMiPlOUjhupPcG2JMfst2KKEpu5XndviX/3UhFbRngUPNKtgvtZiA==}- dependencies:- inherits: 2.0.4- dev: false-resolution: {integrity: sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==}engines: {node: '>= 0.6'}diff --git a/apps/web/src/components/graph/AttackGraphView.test.tsx b/apps/web/src/components/graph/AttackGraphView.test.tsxindex 38d6fa4f6..408cf4c2a 100644--- a/apps/web/src/components/graph/AttackGraphView.test.tsx+++ b/apps/web/src/components/graph/AttackGraphView.test.tsx@@ -21,7 +21,7 @@*/import { describe, expect, it, vi, beforeEach, afterEach } from 'vitest';-import { cleanup, render, screen, waitFor } from '@testing-library/react';+import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';import { SWRConfig } from 'swr';const getOverview = vi.hoisted(() => vi.fn());@@ -142,6 +142,161 @@ describe('AttackGraphView, demo mode off', () => {});});+/**+ * `GET /api/v1/graph` bounds itself and reports `truncated`. For a while+ * nothing rendered it, which put both halves of one defect on either side of+ * a single request: the API stopped presenting a partial graph as complete,+ * and the canvas carried on doing it.+ *+ * Asserted at first paint for the same reason as the block above — a view+ * handed `fallbackData` never fetches, so a truncation flag it reads out of a+ * mock proves nothing about a real response.+ */+describe('AttackGraphView, truncated response', () => {+ /**+ * The notice is named, because `EmptyState` is a `role="status"` too.+ * `getByRole('status')` would match whichever of the two happened to be+ * mounted — so "no truncation notice" and "the empty state is showing"+ * would assert the same thing, and a test for one would pass on the other.+ */+ const NOTICE = { name: 'Truncated graph' } as const;+ const findNotice = () => screen.findByRole('status', NOTICE);+ const queryNotice = () => screen.queryByRole('status', NOTICE);++ const TRUNCATED = {+ nodes: [{ id: 'host:WIN-DB01', label: 'WIN-DB01', kind: 'host', riskScore: 92 }],+ edges: [{ id: 'e1', source: 'host:WIN-DB01', target: 'host:WIN-DB01', label: 'self' }],+ generatedAt: '2026-09-24T12:00:00Z',+ truncated: true,+ nodeLimit: 400,+ edgeLimit: 900,+ };++ it('holds no truncation claim at first paint — nothing has been fetched', () => {+ getOverview.mockImplementation(() => new Promise(() => {}));+ renderView();+ // Were `fallbackData` ever supplied, `graphState.data` would be populated+ // on the first render and this notice would already be on screen — for+ // good, because supplying it also disables revalidation.+ expect(screen.queryByText(/This graph is incomplete/)).toBeNull();+ expect(queryNotice()).toBeNull();+ });++ it('says the graph is incomplete, and reports the counts and the depth', async () => {+ getOverview.mockResolvedValue(TRUNCATED);+ renderView();++ const notice = await findNotice();+ expect(notice).toHaveTextContent('This graph is incomplete.');+ expect(notice).toHaveTextContent('1 nodes and 1 edges at depth 3');+ // The limits come from the response, so the number shown is the number+ // the service applied rather than a copy the console keeps.+ expect(notice).toHaveTextContent("this view's ceiling of 400 nodes and 900 edges");+ // And it must not read as a load failure or an empty tenant.+ expect(screen.queryByText("Couldn't load graph")).toBeNull();+ expect(screen.queryByText('No graph yet')).toBeNull();+ });++ it('names the node ceiling when the returned counts reach it', async () => {+ getOverview.mockResolvedValue({ ...TRUNCATED, nodeLimit: 1, edgeLimit: 900 });+ renderView();+ expect(await findNotice()).toHaveTextContent('cut at the 1-node ceiling');+ });++ it('names the edge ceiling when that is the one that bit', async () => {+ getOverview.mockResolvedValue({ ...TRUNCATED, nodeLimit: 400, edgeLimit: 1 });+ renderView();+ expect(await findNotice()).toHaveTextContent('cut at the 1-edge ceiling');+ });++ it('names both when both were reached', async () => {+ getOverview.mockResolvedValue({ ...TRUNCATED, nodeLimit: 1, edgeLimit: 1 });+ renderView();+ expect(await findNotice()).toHaveTextContent('cut at the 1-node and 1-edge ceiling');+ });++ it('claims no ceiling the response did not report', async () => {+ getOverview.mockResolvedValue({ ...TRUNCATED, nodeLimit: undefined, edgeLimit: undefined });+ renderView();+ const notice = await findNotice();+ expect(notice).toHaveTextContent('a ceiling this response did not report');+ expect(notice).not.toHaveTextContent('400');+ });++ it('narrowing the depth issues a new query rather than re-showing the cache', async () => {+ getOverview.mockResolvedValue(TRUNCATED);+ renderView();++ await findNotice();+ expect(getOverview).toHaveBeenCalledWith({ depth: 3 });++ // A control that moved a number and refetched nothing would be worse than+ // no control: it would report a narrower, still-truncated graph as the+ // result of narrowing.+ fireEvent.change(screen.getByRole('combobox'), { target: { value: '1' } });+ await waitFor(() => {+ expect(getOverview).toHaveBeenCalledWith({ depth: 1 });+ });+ });++ it('says nothing when the backend reports a complete graph', async () => {+ getOverview.mockResolvedValue({ ...TRUNCATED, truncated: false });+ renderView();++ await waitFor(() => {+ expect(screen.queryByText('No graph yet')).toBeNull();+ });+ expect(queryNotice()).toBeNull();+ });++ it('says nothing when the endpoint omits the flag entirely', async () => {+ // `undefined` means "this endpoint does not report bounding", which is+ // not the same as "complete" — but it is not grounds for a claim either.+ getOverview.mockResolvedValue({ ...TRUNCATED, truncated: undefined });+ renderView();++ await waitFor(() => {+ expect(screen.queryByText('No graph yet')).toBeNull();+ });+ expect(queryNotice()).toBeNull();+ });++ it('does not claim truncation for a graph that failed to load', async () => {+ // A graph that could not be retrieved has no size to report, and saying+ // "incomplete" about it would soften an error state that is correct.+ getOverview.mockRejectedValue(new ApiError('API 503 — /api/v1/graph', 503));+ renderView();++ await waitFor(() => {+ expect(screen.getByText("Couldn't load graph")).toBeInTheDocument();+ });+ expect(queryNotice()).toBeNull();+ });++ it('does not claim truncation for a tenant with no graph', async () => {+ getOverview.mockResolvedValue({ nodes: [], edges: [], generatedAt: '2026-09-24T12:00:00Z' });+ renderView();++ await waitFor(() => {+ expect(screen.getByText('No graph yet')).toBeInTheDocument();+ });+ expect(queryNotice()).toBeNull();+ });++ it('introduces no heading, so the page heading order is unchanged', async () => {+ getOverview.mockResolvedValue(TRUNCATED);+ renderView();+ const notice = await findNotice();++ // The page already runs h1 -> h2 -> the h3 inside EmptyState/ErrorState.+ // A heading in the notice would land between the h2 panels and those,+ // which the axe-core WCAG AA gate reads as a broken order. Asserted on+ // the notice itself rather than on the page's heading set, because the+ // set changes with whichever panel states happen to be showing.+ expect(notice.querySelector('h1, h2, h3, h4, h5, h6')).toBeNull();+ });+});+describe('AttackGraphView, hosted demo', () => {it('substitutes sample topology only when demo mode allows it', async () => {// The same failure as the second test above, with the gate open. If thisdiff --git a/apps/web/src/components/graph/AttackGraphView.tsx b/apps/web/src/components/graph/AttackGraphView.tsxindex b3e514869..f69806007 100644--- a/apps/web/src/components/graph/AttackGraphView.tsx+++ b/apps/web/src/components/graph/AttackGraphView.tsx@@ -104,6 +104,119 @@ const KIND_SHAPES: Record<GraphNodeKind, string> = {asset: 'round-rectangle',};+// ─── Traversal depth ──────────────────────────────────────────────────────────++/** Matches the `depth` default on `GET /api/v1/graph`. */+const DEFAULT_DEPTH = 3;++/** `GET /api/v1/graph` declares `Query(ge=1, le=6)`; offering 7 would 422. */+const DEPTH_CHOICES = [1, 2, 3, 4, 5, 6] as const;++// ─── Truncation notice ────────────────────────────────────────────────────────++interface TruncationNoticeProps {+ nodeCount: number;+ edgeCount: number;+ nodeLimit?: number;+ edgeLimit?: number;+ depth: number;+ onNarrow: (depth: number) => void;+}++/**+ * Say that the graph is partial, say what bounded it, and offer a way out.+ *+ * `GET /api/v1/graph` bounds itself and flags `truncated`, and for a while+ * nothing rendered the flag. That left the two halves of the same defect on+ * either side of one request: the API stopped presenting a partial graph as+ * complete, and the canvas carried on doing exactly that. On an attack graph+ * the cost is specific rather than cosmetic — a missing edge is a lateral+ * path the analyst concludes does not exist, and nothing on screen+ * distinguishes "these are your attack paths" from "these are four hundred+ * of your attack paths".+ *+ * Three things, because two of them are not enough:+ *+ * 1. that it is truncated, in words rather than an icon;+ * 2. the ceiling that produced it, taken from the response so the number+ * shown is the number applied;+ * 3. a control that actually narrows the query. Telling someone their answer+ * is incomplete and leaving them no move makes the notice something to+ * learn to ignore.+ *+ * Deliberately not a heading. The page is `h1` "Attack Graph", the panels+ * below it are `h2`, and `EmptyState`/`ErrorState` already contribute the+ * `h3`s inside them. A heading here would sit between an `h2` and those, and+ * the axe-core WCAG AA gate checks heading order. `role="status"` with an+ * `aria-label` puts it in the accessibility tree without inventing one —+ * `EmptyState` is also a `status`, so the label is what tells the two apart+ * for a screen reader arriving at either.+ */+function TruncationNotice({+ nodeCount,+ edgeCount,+ nodeLimit,+ edgeLimit,+ depth,+ onNarrow,+}: TruncationNoticeProps) {+ // Which ceiling the returned counts actually reach.+ //+ // Not always answerable, and it would be easy to assume otherwise. The+ // service flags `truncated` on the counts its traversal bounded, then the+ // endpoint drops nodes it could not identify and edges whose endpoints went+ // with them — so a truncated response can arrive holding fewer than either+ // limit. Naming a ceiling the counts do not reach would point the analyst+ // at the wrong knob; refusing to name one at all when the response says+ // what bounded it would throw away the number they need.+ const reached = [+ nodeCount >= (nodeLimit ?? Infinity) ? `${nodeLimit}-node` : null,+ edgeCount >= (edgeLimit ?? Infinity) ? `${edgeLimit}-edge` : null,+ ].filter((entry): entry is string => entry !== null);++ const declared = [+ nodeLimit !== undefined ? `${nodeLimit} nodes` : null,+ edgeLimit !== undefined ? `${edgeLimit} edges` : null,+ ].filter((entry): entry is string => entry !== null);++ const ceiling =+ reached.length > 0+ ? `the ${reached.join(' and ')} ceiling`+ : declared.length > 0+ ? `this view's ceiling of ${declared.join(' and ')}`+ : 'a ceiling this response did not report';++ return (+ <div+ role="status"+ aria-label="Truncated graph"+ className="flex flex-col gap-3 border-b border-amber-500/30 bg-amber-500/10 px-4 py-3 sm:flex-row sm:items-center sm:justify-between"+ >+ <p className="text-xs leading-relaxed text-amber-200">+ <span className="font-semibold">This graph is incomplete.</span>{' '}+ Showing {nodeCount.toLocaleString()} nodes and{' '}+ {edgeCount.toLocaleString()} edges at depth {depth}, cut at {ceiling}.+ Paths beyond it were dropped, so an absent connection here is not+ evidence that none exists.+ </p>+ <label className="flex shrink-0 items-center gap-2 text-xs text-amber-200/90">+ <span>Narrow to depth</span>+ <select+ value={depth}+ onChange={(event) => onNarrow(Number(event.target.value))}+ className="rounded border border-amber-500/40 bg-slate-900/80 px-2 py-1 text-xs text-amber-100 focus:outline-none focus:ring-1 focus:ring-amber-400"+ >+ {DEPTH_CHOICES.map((choice) => (+ <option key={choice} value={choice}>+ {choice}+ </option>+ ))}+ </select>+ </label>+ </div>+ );+}+// ─── Cytoscape canvas ─────────────────────────────────────────────────────────interface GraphCanvasProps {@@ -379,11 +492,24 @@ export function AttackGraphView() {*/const [override, setOverride] = useState<{ node: GraphNode | null } | null>(null);+ /**+ * Traversal depth, and the one thing an analyst can do about a truncated+ * graph from here.+ *+ * It is part of the SWR key rather than an argument closed over by the+ * fetcher, because a key that does not change is a fetch that does not+ * happen: the control would move the number, re-render, and show the same+ * cached graph. Narrowing that silently does nothing is worse than no+ * control at all — it tells the analyst they have seen a smaller, complete+ * picture when they are still looking at the truncated one.+ */+ const [depth, setDepth] = useState(DEFAULT_DEPTH);+const graphState = useSWR<AttackGraph>(- 'attack-graph',+ ['attack-graph', depth],async () => {try {- return await graphApi.getOverview({ depth: 3 });+ return await graphApi.getOverview({ depth });} catch (err) {// "So the UI is always alive" meant a fabricated attack graph — named// hosts, users and edges — rendered as the tenant's real estate@@ -442,6 +568,23 @@ export function AttackGraphView() {{/* Graph panel */}<section className="rounded-xl bg-slate-900/60 border border-white/5 overflow-hidden">+ {/*+ Above the canvas, and only when the response says so. The three+ existing states are deliberately untouched: an empty tenant still+ reads as empty, an unreachable backend still names the endpoint and+ the status, and neither of those is a truncation — a graph that+ could not be loaded has no size to report.+ */}+ {graph?.truncated ? (+ <TruncationNotice+ nodeCount={graph.nodes.length}+ edgeCount={graph.edges.length}+ nodeLimit={graph.nodeLimit}+ edgeLimit={graph.edgeLimit}+ depth={depth}+ onNarrow={setDepth}+ />+ ) : null}<div className="grid lg:grid-cols-[1fr_320px]"><div className="relative h-[560px] bg-[#0a1120]">{graphState.isLoading ? (diff --git a/apps/web/src/lib/api.ts b/apps/web/src/lib/api.tsindex ba7132f5a..d500c6f65 100644--- a/apps/web/src/lib/api.ts+++ b/apps/web/src/lib/api.ts@@ -3632,6 +3632,19 @@ export interface AttackGraph {nodes: GraphNode[];edges: GraphEdge[];generatedAt: string;+ /**+ * The response was cut at the server's ceiling, so paths are missing.+ *+ * Optional because `/graph/blast-radius` and the case attack-path route+ * reuse this shape and bound differently. A consumer must treat `undefined`+ * as "this endpoint does not say" and not as "complete" — the two are only+ * the same for a response that was never bounded.+ */+ truncated?: boolean;+ /** The node ceiling the service applied, when it reports one. */+ nodeLimit?: number;+ /** The edge ceiling the service applied, when it reports one. */+ edgeLimit?: number;}export interface AttackPath {diff --git a/docs/openapi.yaml b/docs/openapi.yamlindex c0ce21211..c8362f32e 100644--- a/docs/openapi.yaml+++ b/docs/openapi.yaml@@ -20578,6 +20578,14 @@ components:type: booleantitle: Truncateddefault: false+ nodeLimit:+ type: integer+ title: Nodelimit+ default: 400+ edgeLimit:+ type: integer+ title: Edgelimit+ default: 900type: objectrequired:- nodes@@ -20593,7 +20601,22 @@ components:identically, and a viewer who cannot tell them apart reads a partial- picture as the whole estate.'+ picture as the whole estate.+++ ``nodeLimit`` and ``edgeLimit`` travel with it so the ceiling a caller++ reports is the ceiling this service applied. They are the same two++ constants the traversal is bounded by, read from++ ``graph_service`` rather than restated: a console that hardcoded 400 and++ 900 would keep printing those numbers after someone moved them here, and++ a client telling an analyst the wrong limit is a smaller version of the++ bug ``truncated`` exists to fix.'HTTPValidationError:properties:detail:diff --git a/scripts/check_toolchain_pins.py b/scripts/check_toolchain_pins.pyindex c021fd75d..9b799a4de 100644--- a/scripts/check_toolchain_pins.py+++ b/scripts/check_toolchain_pins.py@@ -179,6 +179,55 @@ EXPECTED_ESBUILD: dict[str, str] = {"0.28.1": "the version the scoped tsup/vite/bundle-require overrides ask for",}+# `apps/mobile` and `services/realtime` resolve esbuild too, and neither is+# checked against EXPECTED_ESBUILD above. That is deliberate and is not the+# one-directional hole it resembles: the pinned *resolved set* exists because+# Next bundles its own esbuild and a replacement breaks Turbopack's font+# import map, and Next lives only in the root workspace. What does apply+# everywhere is the *scoping* rule — no install root may override esbuild+# workspace-wide — and `check_esbuild_overrides` now enforces that against+# every root rather than against the repository root alone.++# Install roots allowed to resolve a package another root pins, with the+# reason and the exact versions the exemption was verified against.+#+# Version-bearing on purpose. `("body-parser", "services/realtime")` alone+# would be a permanent hole: realtime could drift to any other 1.x and this+# gate would keep crediting it. Recording the versions makes each entry a+# ratchet — a bump re-fires the check and someone has to re-verify — and+# `check_override_propagation` fails in the reverse direction too, so an entry+# naming a root that no longer resolves the package, or a version the lockfile+# no longer contains, fails the build rather than sitting here.+#+# What an entry may say, and what it may not. These record *a package on two+# supported major lines*, verified clean on both. They do not record "we+# accept a vulnerable version": an override floor exists because something+# below it is exploitable, and a root resolving an affected release has to be+# fixed, not exempted. The evidence for each is a version query against the+# OSV API — the resolved version, not the range a manifest declares — because+# ten justifications in this repository's history were found to be untrue when+# checked that way.+CROSS_ROOT_OVERRIDE_EXEMPT: dict[tuple[str, str], tuple[tuple[str, ...], str]] = {+ ("body-parser", "services/realtime"): (+ ("1.20.8",),+ "the root override `>=2.3.0 <3` is a major-line floor for the "+ "workspace's Express 5 tree; realtime is on Express 4, whose 1.x line "+ "is separately patched. OSV version query for body-parser 1.20.8 on "+ "2026-09-24 returns no advisories",+ ),+ ("ws", "apps/mobile"): (+ ("6.2.6", "7.5.13"),+ "React Native's development server pins its own websocket majors: 6.2.6 "+ "through @react-native/dev-middleware and react-native itself, 7.5.13 "+ "through metro and react-devtools-core. Both are the terminal patched "+ "releases of those lines and OSV version queries for ws 6.2.6 and "+ "7.5.13 on 2026-09-24 return no advisories. Forcing 8.x here would "+ "override the transport the Metro dev server speaks, which is a bundler "+ "change made to satisfy a range written for the web workspace — and "+ "none of these three reach the shipped app bundle",+ ),+}+# Prose, vendored history and generated artefacts.SKIP_PREFIXES = ("plans/",@@ -308,11 +357,39 @@ class Install:raw: str+@dataclass+class NodeRoot:+ """One directory that resolves its own node_modules.++ An *install root*, not a workspace member: a directory holding both a+ manifest and a lockfile, so `pnpm install` or `npm install` run there+ produces a version set of its own. There are four in this tree and they+ were treated as one for as long as only the repository root was read.+ """++ directory: str # "" for the repository root+ manifest: str+ lockfile: str+ tool: str # pnpm | npm+ # Override key exactly as written -> spec. Keys may be a bare name, a+ # scoped name, a name with a version selector (`js-yaml@3`) or a+ # parent-scoped path (`vite>esbuild`).+ overrides: dict[str, str] = field(default_factory=dict)+ # The key the overrides were read from, so `check_override_parser_coverage`+ # can tell "no overrides" apart from "overrides this parser cannot see".+ overrides_key: str = ""+ # package -> every version the lockfile resolved for it. A list, not one+ # version: pnpm keeps several majors of the same package side by side and+ # collapsing them would hide exactly the one that is vulnerable.+ resolved: dict[str, list[str]] = field(default_factory=dict)++@dataclassclass Scan:pins: list[Pin] = field(default_factory=list)installs: list[Install] = field(default_factory=list)files: list[str] = field(default_factory=list)+ node_roots: list[NodeRoot] = field(default_factory=list)go_modules: dict[str, dict] = field(default_factory=dict)go_cache_paths: list[tuple[str, str]] = field(default_factory=list)pnpm_actions: list[tuple[str, str]] = field(default_factory=list)@@ -913,6 +990,117 @@ def parse_package_json(path: Path, rel: str, scan_result: Scan) -> None:scan_result.pins.append(Pin("node", re.sub(r"^[^\d]*", "", engine), rel, "floor", f"engines.node: {engine}"))+# A pnpm lockfile package header: ` /[email protected]:` or+# ` /@babel/[email protected]([email protected]):`. The peer suffix is dropped — it+# identifies a variant of the same release, not a different version.+_PNPM_PKG = re.compile(r"^ {2}/(?P<name>@[^/@\s]+/[^@\s]+|[^@/\s][^@\s]*)@(?P<version>\d[^(:\s]*)", re.MULTILINE)++#: An override key, split into the package it governs and the selector on it.+#:+#: Four shapes appear in this tree and they do not mean the same thing:+#: `image-size` every resolution of the package+#: `js-yaml@3` only resolutions in that version line+#: `@babel/plugin-…` a scoped package, where the `@` is part of the name+#: `vite>esbuild` only where `vite` is the parent — a *scoped*+#: override, which is the whole point of the esbuild+#: arrangement and must not be read as a global one+_OVERRIDE_KEY = re.compile(r"^(?:(?P<parent>[^>]+)>)?(?P<name>@[^/@]+/[^@]+|[^@>]+)(?:@(?P<selector>.+))?$")+++def parse_override_key(key: str) -> tuple[str | None, str, str | None]:+ """`(parent, package, selector)` for one override key."""+ match = _OVERRIDE_KEY.match(key.strip())+ if not match:+ return None, key.strip(), None+ return match.group("parent"), match.group("name"), match.group("selector")+++def parse_pnpm_lock(text: str) -> dict[str, list[str]]:+ resolved: dict[str, list[str]] = {}+ for match in _PNPM_PKG.finditer(text):+ resolved.setdefault(match.group("name"), []).append(match.group("version"))+ return resolved+++def parse_npm_lock(text: str) -> dict[str, list[str]]:+ resolved: dict[str, list[str]] = {}+ for key, meta in (json.loads(text).get("packages") or {}).items():+ if "node_modules/" not in key or not isinstance(meta, dict):+ continue+ version = meta.get("version")+ if isinstance(version, str) and version:+ # Nested paths carry the package last: `node_modules/a/node_modules/b`.+ resolved.setdefault(key.rsplit("node_modules/", 1)[1], []).append(version)+ return resolved+++def _flatten_npm_overrides(block: dict, prefix: str = "") -> dict[str, str]:+ """npm's nested `overrides` object, flattened to the same shape as pnpm's.++ npm permits `{"a": {"b": "1.0.0"}}`, which pnpm writes `a>b`. Reading only+ the flat form would credit a nested override as absent, so the two+ spellings are normalised to one before anything compares them.+ """+ flat: dict[str, str] = {}+ for key, value in block.items():+ name = f"{prefix}{key}"+ if isinstance(value, str):+ flat[name] = value+ elif isinstance(value, dict):+ if isinstance(value.get("."), str):+ flat[name] = value["."]+ flat.update(_flatten_npm_overrides({k: v for k, v in value.items() if k != "."}, f"{name}>"))+ return flat+++def parse_node_root(manifest: Path, lockfile: Path, rel_dir: str) -> NodeRoot:+ data = json.loads(manifest.read_text(encoding="utf-8"))+ pnpm_overrides = (data.get("pnpm") or {}).get("overrides") or {}+ npm_overrides = data.get("overrides") or {}+ if pnpm_overrides:+ overrides, key = dict(pnpm_overrides), "pnpm.overrides"+ elif npm_overrides:+ overrides, key = _flatten_npm_overrides(npm_overrides), "overrides"+ else:+ overrides, key = {}, ""++ text = lockfile.read_text(encoding="utf-8")+ if lockfile.name == "pnpm-lock.yaml":+ tool, resolved = "pnpm", parse_pnpm_lock(text)+ else:+ tool, resolved = "npm", parse_npm_lock(text)++ return NodeRoot(+ directory=rel_dir,+ manifest=manifest.name if not rel_dir else f"{rel_dir}/{manifest.name}",+ lockfile=lockfile.name if not rel_dir else f"{rel_dir}/{lockfile.name}",+ tool=tool,+ overrides=overrides,+ overrides_key=key,+ resolved=resolved,+ )+++def scan_node_roots(root: Path) -> list[NodeRoot]:+ """Every directory in the tree that resolves its own node_modules.++ Discovered structurally rather than listed. A list would have had one+ entry — the repository root — for the same reason every other check here+ did: `apps/mobile` was created as an independent install root precisely so+ its install would stop rewriting the root lockfile, and nothing that reads+ dependency resolution was told it now existed.+ """+ found: list[NodeRoot] = []+ for name in ("pnpm-lock.yaml", "package-lock.json"):+ for lockfile in walk(root, name):+ manifest = lockfile.parent / "package.json"+ if not manifest.is_file():+ continue # reported by `check_dead_lockfiles`+ rel_dir = lockfile.parent.relative_to(root).as_posix()+ found.append(parse_node_root(manifest, lockfile, "" if rel_dir == "." else rel_dir))+ return sorted(found, key=lambda r: r.directory)++def scan(root: Path) -> Scan:result = Scan()@@ -953,6 +1141,10 @@ def scan(root: Path) -> Scan:result.files.append(rel)parse_package_json(manifest, rel, result)+ result.node_roots = scan_node_roots(root)+ for node_root in result.node_roots:+ result.files.append(node_root.lockfile)+# `packages/*` as well as `services/*`: the packages are the *published*# artefacts, so their floor is a promise to a downstream consumer rather# than an internal note. Reading only `services/` meant the floor that@@ -1368,7 +1560,258 @@ def check_go_modules(root: Path, data: Scan) -> list[str]:return problems-def check_esbuild_overrides(root: Path) -> list[str]:+_RELEASE = re.compile(r"^(\d+(?:\.\d+)*)")+_CLAUSE = re.compile(r"^(?P<op>>=|<=|>|<|=|\^|~)?(?P<version>\d[\w.*-]*)$")+++def satisfies_npm_range(version: str, spec: str) -> bool | None:+ """Whether a concrete version is inside an npm range.++ Returns ``None`` — not ``False`` — for a range this function cannot+ reason about. A boolean for an unparsed spec is the shape that makes a+ gate credit something it never evaluated: `False` reds the build for no+ reason and `True` passes silently, and the second is how the caller ends+ up printing OK about a comparison that did not happen. The caller reports+ ``None`` as a finding against this gate rather than against the tree.++ Only the operators actually written in this repository's overrides are+ supported (`>=`, `<=`, `>`, `<`, `=`, `^`, `~`, bare, and space- or+ comma-joined conjunctions of them). `||` unions and hyphen ranges are+ deliberately absent rather than approximated.+ """+ release = _RELEASE.match(version)+ if not release:+ return None+ actual = tuple(int(p) for p in release.group(1).split("."))++ normalised = spec.strip().replace(",", " ")+ if not normalised or "||" in normalised or " - " in normalised or normalised in {"*", "x", "latest"}:+ return None++ for clause in normalised.split():+ match = _CLAUSE.match(clause)+ if not match or "*" in match.group("version") or "-" in match.group("version"):+ return None+ bound_release = _RELEASE.match(match.group("version"))+ if not bound_release:+ return None+ bound = tuple(int(p) for p in bound_release.group(1).split("."))+ operator = match.group("op") or "="+ left, right = _pad(actual, bound)++ if operator in {"^", "~"}:+ # `^1.2.3` is `>=1.2.3 <2.0.0`; `^0.2.3` is `>=0.2.3 <0.3.0`+ # (npm treats a leading zero major as unstable). `~1.2.3` is+ # `>=1.2.3 <1.3.0`.+ if left < right:+ return False+ if operator == "~" or (operator == "^" and bound and bound[0] == 0):+ ceiling = bound[:2] if len(bound) >= 2 else bound+ if actual[: len(ceiling)] != ceiling:+ return False+ elif actual[:1] != bound[:1]:+ return False+ continue++ ok = {">=": left >= right, ">": left > right, "<=": left <= right, "<": left < right, "=": left == right}[operator]+ if not ok:+ return False+ return True+++def _governed(versions: list[str], selector: str | None) -> list[str]:+ """The resolutions an override key actually governs.++ A bare key governs every resolution; `js-yaml@3` governs only the 3.x+ line. Without this, the root's `brace-expansion@1` pin would be compared+ against the 5.0.12 the workspace also resolves and fail for a version the+ key was never written about.+ """+ if not selector:+ return versions+ return [v for v in versions if satisfies_npm_range(v, selector) is True]+++def check_override_propagation(root: Path, data: Scan) -> list[str]:+ """A dependency resolution decision made in one install root and not another.++ This is the Node half of the defect ``check_dependency_pins`` was built+ for on the Python side, where CI installed a ``cryptography`` range+ disjoint from the one a service required. Here the two sides are two+ *install roots*: the repository workspace pinned ``image-size`` to+ ``>=2.0.4 <3`` after establishing that ``<= 2.0.2`` is vulnerable, and+ ``apps/mobile`` — an independent root with its own lockfile, created that+ way so its install would stop rewriting the root lock — kept resolving+ 1.2.1 through Metro. The fix could not reach it and nothing compared them,+ so two high-severity advisories stayed open against a package the+ repository had already decided the answer for.++ Both directions:++ declaration -> resolution+ a root resolving a package another root pins, at a version outside+ that pin, with no pin of its own. The direction the tree drifted.+ resolution -> declaration+ a root whose own lockfile resolves a version its own override+ forbids — a lockfile that was not regenerated after the manifest+ moved, which is the same disagreement inside one root.+ exemption -> tree / tree -> exemption+ an exemption naming a root that no longer resolves the package, or+ one whose recorded version no longer matches what the lockfile says.++ Not checked, and said plainly rather than left to be discovered: an+ override declared in one root and resolved by no root at all is *not*+ reported. Several here are deliberately defensive — nothing in this tree+ resolves js-yaml 3.x, and the `js-yaml@3` pin exists so that if something+ later does, it lands patched. Calling that dead would push people to+ delete the pin that is doing the work.+ """+ problems: list[str] = []+ by_dir = {r.directory: r for r in data.node_roots}++ # ── declaration -> resolution, across roots ──────────────────────────+ for declaring in data.node_roots:+ for key, spec in sorted(declaring.overrides.items()):+ parent, package, selector = parse_override_key(key)+ if parent:+ continue # `vite>esbuild` constrains one parent, not the package+ for other in data.node_roots:+ if other.directory == declaring.directory:+ continue+ governed = _governed(other.resolved.get(package, []), selector)+ if not governed:+ continue+ exempt = CROSS_ROOT_OVERRIDE_EXEMPT.get((package, other.directory))+ offending = []+ for version in sorted(set(governed)):+ verdict = satisfies_npm_range(version, spec)+ if verdict is None:+ problems.append(+ f"{declaring.manifest} pins `{key}` to `{spec}`, which this gate cannot "+ f"evaluate against the {version} that {other.lockfile} resolved — a range "+ f"the comparison skips is a comparison that did not happen; teach "+ f"`satisfies_npm_range` the operator or rewrite the pin (override propagation)"+ )+ elif verdict is False:+ offending.append(version)+ if not offending:+ continue+ if exempt and set(offending) <= set(exempt[0]):+ continue+ if exempt:+ offending = sorted(set(offending) - set(exempt[0]))+ own = other.overrides.get(key) or other.overrides.get(package)+ held = f" — it declares `{own}` of its own" if own else " and declares no override of its own"+ problems.append(+ f"{declaring.manifest} pins `{key}` to `{spec}` but {other.lockfile} resolves "+ f"{package}@{', '.join(offending)}{held}. `{other.directory or '.'}` is a separate "+ f"install root, so a resolution applied in one lockfile does not reach the other; "+ f"add the override there too, or record a measured reason in "+ f"CROSS_ROOT_OVERRIDE_EXEMPT (override propagation)"+ )++ # ── resolution -> declaration, inside one root ───────────────────────+ for node_root in data.node_roots:+ for key, spec in sorted(node_root.overrides.items()):+ parent, package, selector = parse_override_key(key)+ if parent:+ continue+ for version in sorted(set(_governed(node_root.resolved.get(package, []), selector))):+ if satisfies_npm_range(version, spec) is False:+ problems.append(+ f"{node_root.manifest} overrides `{key}` to `{spec}` but {node_root.lockfile} "+ f"resolves {package}@{version}, which does not satisfy it — the lockfile was "+ f"not regenerated after the manifest moved, so `{node_root.tool} install "+ f"--frozen-lockfile` installs a version the manifest forbids "+ f"(override propagation)"+ )++ # ── exemption <-> tree ───────────────────────────────────────────────+ for (package, directory), (versions, _) in sorted(CROSS_ROOT_OVERRIDE_EXEMPT.items()):+ # Named apart from the `node_root` the loops above bind: this one is+ # a lookup that can miss, and reusing the name would narrow an+ # optional into a type the earlier loops guaranteed.+ exempt_root = by_dir.get(directory)+ if exempt_root is None:+ # Only reported when the directory is *there* and has stopped+ # resolving its own node_modules. An exemption for a directory+ # that does not exist in this tree at all is a fixture or a fork,+ # not drift — the same distinction `check_pnpm_actions` draws by+ # testing its exemptions against the files the scan actually saw.+ if (root / directory).is_dir():+ problems.append(+ f"CROSS_ROOT_OVERRIDE_EXEMPT names `{directory}`, which is no longer an install "+ f"root — it has no lockfile of its own, so the exemption asserts a constraint "+ f"nothing is under (override propagation)"+ )+ continue+ got = set(exempt_root.resolved.get(package, []))+ if not got:+ problems.append(+ f"CROSS_ROOT_OVERRIDE_EXEMPT exempts `{package}` in `{directory}`, which no longer "+ f"resolves it — the exemption asserts a constraint nothing is under (override propagation)"+ )+ elif stale := sorted(set(versions) - got):+ problems.append(+ f"CROSS_ROOT_OVERRIDE_EXEMPT was verified against `{package}@{', '.join(stale)}` in "+ f"`{directory}`, which now resolves {', '.join(sorted(got))}. The exemption records "+ f"exact versions on purpose so a bump re-opens the question — re-verify the resolved "+ f"version against OSV and update it (override propagation)"+ )+ return problems+++def check_node_root_corpus(data: Scan) -> list[str]:+ """Refuse to render a verdict over install roots that were never read.++ Every check above answers "do these roots agree", and a root whose+ lockfile yielded nothing agrees with everyone. That is the shape this+ repository keeps finding: *found nothing* and *scanned nothing* print the+ same word. So a discovered root that parsed to zero resolutions, or a+ tree with no install root at all, is a failure of the gate rather than a+ pass for the tree — which is also what keeps this check from reporting OK+ on an empty corpus.+ """+ if not data.node_roots:+ return [+ "no Node install root was discovered (a directory holding both package.json and a "+ "lockfile). Either the tree has none, or the discovery walk is looking in the wrong "+ "place — both mean the cross-root comparison below ran over nothing (node root corpus)"+ ]+ return [+ f"{node_root.lockfile} parsed to zero resolved packages, so every comparison against it "+ f"passes by default. A {node_root.tool} lockfile this gate cannot read is not a clean "+ f"root, it is an unread one (node root corpus)"+ for node_root in data.node_roots+ if not node_root.resolved+ ]+++def check_override_parser_coverage(root: Path, data: Scan) -> list[str]:+ """A manifest whose override block this parser could not see.++ The other direction of discovery. `check_node_root_corpus` asks whether+ the lockfiles were read; this asks whether the *manifests* were, because+ a root counted and compared while contributing no override is+ indistinguishable from one that genuinely pins nothing.+ """+ problems: list[str] = []+ declares = re.compile(r'"(?:pnpm|overrides)"\s*:')+ for node_root in data.node_roots:+ path = root / node_root.manifest+ if not path.is_file():+ continue+ text = path.read_text(encoding="utf-8")+ if declares.search(text) and not node_root.overrides:+ problems.append(+ f"{node_root.manifest} declares an override block but the parser extracted nothing "+ f"from it — the root is counted as compared while contributing no pin "+ f"(override parser coverage)"+ )+ return problems+++def check_esbuild_overrides(root: Path, data: Scan) -> list[str]:"""esbuild must stay overridden per parent, and the resolved set must be pinned.Forcing esbuild across the workspace broke Turbopack's font import map,@@ -1376,19 +1819,23 @@ def check_esbuild_overrides(root: Path) -> list[str]:overrides are therefore scoped (`vite>esbuild`) — but that scoping means a`vite` bump can pull a different esbuild with no esbuild line in the diff,so the resolved versions are compared too.++ The scoping half is checked against *every* install root. It used to read+ the repository root's manifest alone, which left the one place a+ workspace-wide esbuild override could be added without anything noticing:+ `apps/mobile` installs separately and is the root whose bundler is not+ Turbopack, so the mistake would look locally harmless there and reach the+ web build through nothing but a future reviewer's memory."""problems: list[str] = []- manifest = root / "package.json"- if not manifest.exists():- return []- overrides = (json.loads(manifest.read_text(encoding="utf-8")).get("pnpm") or {}).get("overrides") or {}- for key in sorted(overrides):- if key == "esbuild" or key.startswith("esbuild@"):- problems.append(- f"package.json overrides `{key}` workspace-wide. Next bundles its own esbuild "- f"and a workspace-wide override replaces it, which breaks Turbopack's font "- f"import map — scope it to its parent as `<parent>>esbuild` (override scope)"- )+ for node_root in data.node_roots:+ for key in sorted(node_root.overrides):+ if key == "esbuild" or key.startswith("esbuild@"):+ problems.append(+ f"{node_root.manifest} overrides `{key}` workspace-wide. Next bundles its own "+ f"esbuild and a workspace-wide override replaces it, which breaks Turbopack's "+ f"font import map — scope it to its parent as `<parent>>esbuild` (override scope)"+ )lockfile = root / "pnpm-lock.yaml"if not lockfile.exists():@@ -1528,6 +1975,16 @@ def report(data: Scan) -> None:locked = sum(1 for i in data.installs if i.locked)print(f" node installs: {len(data.installs)} ({locked} locked, {len(data.installs) - locked} unlocked)")+ # Named, not counted. "4 install roots compared" is true whether the+ # fourth was read or silently parsed to nothing, and a root that resolved+ # zero packages agrees with every other root about everything.+ print(f" node install roots: {len(data.node_roots)} — each with what was actually read from it")+ for node_root in data.node_roots:+ print(+ f" {(node_root.directory or '.'):<30} {node_root.tool:<5} "+ f"{len(node_root.resolved):>5} packages resolved, "+ f"{len(node_root.overrides)} override(s) from {node_root.overrides_key or 'none declared'}"+ )modules = sorted(d for d, e in data.go_modules.items() if e.get("mod"))print(f" go modules: {len(modules)} — {', '.join(modules)}")scopes = ", ".join(f"{w.split('/')[-1]}{f' [{s}]' if s else ' [repo-wide]'}" for w, s, _, _ in data.gofmt_steps) or "none"@@ -1563,8 +2020,11 @@ def run(root: Path, verbose: bool = False) -> tuple[int, list[str]]:+ check_go_modules(root, data)+ check_go_formatting(data)+ check_published_service_ci(root, data)- + check_esbuild_overrides(root)+ + check_esbuild_overrides(root, data)+ check_pnpm_actions(data)+ + check_node_root_corpus(data)+ + check_override_propagation(root, data)+ + check_override_parser_coverage(root, data)+ check_parser_coverage(root, data)+ check_scan_coverage(root, data))@@ -1608,12 +2068,28 @@ def _fixture(root: Path) -> None:"private": True,"packageManager": "[email protected]","engines": {"node": ">=22.0.0"},- "pnpm": {"overrides": {"vite>esbuild": "^0.28.1"}},+ "pnpm": {"overrides": {"vite>esbuild": "^0.28.1", "image-size": ">=2.0.4 <3"}},}),encoding="utf-8",)- (root / "pnpm-lock.yaml").write_text("lockfileVersion: '6.0'\n /[email protected]:\n /[email protected]:\n", encoding="utf-8")+ (root / "pnpm-lock.yaml").write_text(+ "lockfileVersion: '6.0'\n /[email protected]:\n /[email protected]:\n /[email protected]:\n", encoding="utf-8"+ )++ # A second install root, shaped like `apps/mobile`: its own manifest and+ # its own lockfile, outside the workspace the root one describes. The+ # cross-root checks have nothing to compare without it, and a fixture with+ # one root is how a gate for two roots passes its own self-test while+ # exercising neither direction.+ satellite = root / "apps" / "satellite"+ satellite.mkdir(parents=True)+ (satellite / "package.json").write_text(+ json.dumps({"name": "satellite", "private": True, "pnpm": {"overrides": {"image-size": ">=2.0.4 <3"}}}),+ encoding="utf-8",+ )+ (satellite / "pnpm-lock.yaml").write_text("lockfileVersion: '6.0'\n /[email protected]:\n", encoding="utf-8")+ (root / "pnpm-workspace.yaml").write_text('packages:\n - "apps/*"\n - "!apps/satellite"\n', encoding="utf-8")(root / "services" / "web-svc" / "Dockerfile").write_text("FROM node:22-alpine AS base\nRUN npm install -g [email protected]\n"@@ -1686,12 +2162,19 @@ def self_test() -> int:def build(mutate=None) -> tuple[int, list[str]]:temp = Path(tempfile.mkdtemp(prefix="toolchain_selftest_"))+ # Two injections below add an entry to the module-level exemption+ # list, which is how an exemption is drifted. Restoring it per case+ # keeps one case from deciding the verdict of the next — a self-test+ # whose cases leak into each other proves the wrong thing.+ saved = dict(CROSS_ROOT_OVERRIDE_EXEMPT)try:_fixture(temp)if mutate:mutate(temp)return run(temp)finally:+ CROSS_ROOT_OVERRIDE_EXEMPT.clear()+ CROSS_ROOT_OVERRIDE_EXEMPT.update(saved)shutil.rmtree(temp, ignore_errors=True)def drift_node_image_behind_ci(root: Path) -> None:@@ -1919,6 +2402,81 @@ def self_test() -> int:encoding="utf-8",)+ # ── The cross-root install-root directions ───────────────────────────+ #+ # Written by enumerating what the check *credits* rather than what it+ # flags. It credits a root as agreeing when the root declares the same+ # override, when the version it resolved satisfies the other root's pin,+ # or when the package is absent from it — and each of those three is also+ # what a root looks like when the parser could not read its lockfile, its+ # manifest, or the range being compared. Those are the last four cases+ # here, and they are the ones that would have let this check pass while+ # comparing nothing.++ def drift_override_reaching_one_root(root: Path) -> None:+ """The measured bug: the workspace pins image-size, apps/mobile does not."""+ path = root / "apps" / "satellite" / "package.json"+ path.write_text(json.dumps({"name": "satellite", "private": True}), encoding="utf-8")+ (root / "apps" / "satellite" / "pnpm-lock.yaml").write_text("lockfileVersion: '6.0'\n /[email protected]:\n", encoding="utf-8")++ def drift_lockfile_behind_its_own_manifest(root: Path) -> None:+ """The same disagreement inside one root: the manifest moved, the lock did not."""+ (root / "apps" / "satellite" / "pnpm-lock.yaml").write_text("lockfileVersion: '6.0'\n /[email protected]:\n", encoding="utf-8")++ def drift_workspace_wide_esbuild_in_a_satellite_root(root: Path) -> None:+ """The esbuild trap in the one root the old check could not see."""+ path = root / "apps" / "satellite" / "package.json"+ data = json.loads(path.read_text())+ data["pnpm"]["overrides"]["esbuild"] = "^0.28.1"+ path.write_text(json.dumps(data), encoding="utf-8")++ def drift_exemption_for_a_root_that_stopped_being_one(root: Path) -> None:+ """A directory still in the tree that no longer resolves its own node_modules.++ Deliberately not a directory that is simply absent: an exemption for+ a path this tree never had is a fixture or a fork, and failing on+ that would make the gate unusable anywhere but here.+ """+ (root / "apps" / "folded-in").mkdir(parents=True)+ (root / "apps" / "folded-in" / "package.json").write_text(json.dumps({"name": "folded-in"}), encoding="utf-8")+ CROSS_ROOT_OVERRIDE_EXEMPT[("image-size", "apps/folded-in")] = (("1.2.1",), "a root folded back into the workspace")++ def drift_exemption_whose_version_moved(root: Path) -> None:+ CROSS_ROOT_OVERRIDE_EXEMPT[("image-size", "apps/satellite")] = (("1.2.1",), "verified against a version since bumped")++ def drift_unreadable_lockfile(root: Path) -> None:+ """A lockfile in a format the parser does not understand.++ It yields no resolutions, so every cross-root comparison against it+ passes — the exact shape of a gate reporting OK about a root it never+ read. `check_node_root_corpus` must call this a failure of the gate.+ """+ (root / "apps" / "satellite" / "pnpm-lock.yaml").write_text("lockfileVersion: '9.0'\nsnapshots: {}\n", encoding="utf-8")++ def drift_override_block_the_parser_cannot_read(root: Path) -> None:+ """A manifest that declares overrides under a key this parser misses."""+ path = root / "apps" / "satellite" / "package.json"+ path.write_text(+ json.dumps({"name": "satellite", "private": True, "pnpm": {"override": {"image-size": ">=2.0.4 <3"}}}),+ encoding="utf-8",+ )++ def drift_range_the_comparison_cannot_evaluate(root: Path) -> None:+ """A spec `satisfies_npm_range` has no answer for.++ A boolean here would be invented. Passing is the dangerous half: the+ gate would print OK having compared nothing.+ """+ path = root / "package.json"+ data = json.loads(path.read_text())+ data["pnpm"]["overrides"]["image-size"] = "1.x || >=2.0.4"+ path.write_text(json.dumps(data), encoding="utf-8")+ (root / "apps" / "satellite" / "pnpm-lock.yaml").write_text("lockfileVersion: '6.0'\n /[email protected]:\n", encoding="utf-8")++ def drift_no_install_root_at_all(root: Path) -> None:+ (root / "pnpm-lock.yaml").unlink()+ (root / "apps" / "satellite" / "pnpm-lock.yaml").unlink()+cases = [("clean fixture passes", None, None),("ship -> test (image behind CI)", drift_node_image_behind_ci, "ship -> test"),@@ -1954,6 +2512,15 @@ def self_test() -> int:("coverage claimed by a quoted path in a list", drift_coverage_claimed_by_a_quoted_path, "image -> CI"),("coverage through a matrix working-directory", drift_matrix_working_directory, None),("publish entry for a directory that moved", drift_publish_context_that_moved, "CI -> image"),+ ("override reaching one install root and not the other", drift_override_reaching_one_root, "override propagation"),+ ("lockfile behind its own manifest", drift_lockfile_behind_its_own_manifest, "override propagation"),+ ("workspace-wide esbuild in a satellite root", drift_workspace_wide_esbuild_in_a_satellite_root, "override scope"),+ ("exemption for a root that stopped being one", drift_exemption_for_a_root_that_stopped_being_one, "no longer an install root"),+ ("exemption whose verified version moved", drift_exemption_whose_version_moved, "re-opens the question"),+ ("lockfile the parser cannot read", drift_unreadable_lockfile, "node root corpus"),+ ("override block the parser cannot read", drift_override_block_the_parser_cannot_read, "override parser coverage"),+ ("range the comparison cannot evaluate", drift_range_the_comparison_cannot_evaluate, "cannot evaluate"),+ ("no install root at all", drift_no_install_root_at_all, "no Node install root"),]failures: list[str] = []diff --git a/services/api/app/api/v1/endpoints/graph.py b/services/api/app/api/v1/endpoints/graph.pyindex e6bfe0496..66e712ed0 100644--- a/services/api/app/api/v1/endpoints/graph.py+++ b/services/api/app/api/v1/endpoints/graph.py@@ -155,12 +155,22 @@ class GraphOverviewResponse(BaseModel):cut at the node ceiling and a graph that is genuinely this size renderidentically, and a viewer who cannot tell them apart reads a partialpicture as the whole estate.++ ``nodeLimit`` and ``edgeLimit`` travel with it so the ceiling a caller+ reports is the ceiling this service applied. They are the same two+ constants the traversal is bounded by, read from+ ``graph_service`` rather than restated: a console that hardcoded 400 and+ 900 would keep printing those numbers after someone moved them here, and+ a client telling an analyst the wrong limit is a smaller version of the+ bug ``truncated`` exists to fix."""nodes: list[OverviewNode]edges: list[OverviewEdge]generatedAt: strtruncated: bool = False+ nodeLimit: int = graph_service.OVERVIEW_NODE_LIMIT+ edgeLimit: int = graph_service.OVERVIEW_EDGE_LIMIT#: Neo4j label → the node kind the console has a colour and a glyph for.diff --git a/tests/test_toolchain_pin_gate.py b/tests/test_toolchain_pin_gate.pyindex b985c4ec5..e99ae2579 100644--- a/tests/test_toolchain_pin_gate.py+++ b/tests/test_toolchain_pin_gate.py@@ -15,6 +15,7 @@ from __future__ import annotationsimport importlib.utilimport json+import reimport sysfrom pathlib import Path@@ -342,31 +343,208 @@ def test_every_runtime_records_why_it_matters():# ── esbuild overrides ────────────────────────────────────────────────────────-def _write_workspace(root: Path, overrides: dict, resolved: list[str]) -> None:- (root / "package.json").write_text(json.dumps({"pnpm": {"overrides": overrides}}), encoding="utf-8")- (root / "pnpm-lock.yaml").write_text("\n".join(f" /esbuild@{v}:" for v in resolved), encoding="utf-8")+def _write_workspace(root: Path, overrides: dict, resolved: list[str], subdir: str = ""):+ """One install root, returned as the Scan the checks take.++ `subdir` puts the manifest somewhere other than the repository root,+ because the scoping half of the esbuild check now applies to every+ install root and the interesting case is the one that is *not* the root —+ `apps/mobile` is where a workspace-wide override could previously be+ added with nothing looking at it.+ """+ directory = root / subdir if subdir else root+ directory.mkdir(parents=True, exist_ok=True)+ (directory / "package.json").write_text(json.dumps({"pnpm": {"overrides": overrides}}), encoding="utf-8")+ (directory / "pnpm-lock.yaml").write_text("\n".join(f" /esbuild@{v}:" for v in resolved), encoding="utf-8")+ scan = gate.Scan()+ scan.node_roots = gate.scan_node_roots(root)+ return scandef test_a_scoped_esbuild_override_is_allowed(tmp_path):- _write_workspace(tmp_path, {"vite>esbuild": "^0.28.1"}, list(gate.EXPECTED_ESBUILD))- assert gate.check_esbuild_overrides(tmp_path) == []+ scan = _write_workspace(tmp_path, {"vite>esbuild": "^0.28.1"}, list(gate.EXPECTED_ESBUILD))+ assert gate.check_esbuild_overrides(tmp_path, scan) == []def test_a_workspace_wide_esbuild_override_fails(tmp_path):"""Next bundles its own esbuild; replacing it broke Turbopack's font map."""- _write_workspace(tmp_path, {"esbuild": "^0.28.1"}, list(gate.EXPECTED_ESBUILD))- assert any("override scope" in p for p in gate.check_esbuild_overrides(tmp_path))+ scan = _write_workspace(tmp_path, {"esbuild": "^0.28.1"}, list(gate.EXPECTED_ESBUILD))+ assert any("override scope" in p for p in gate.check_esbuild_overrides(tmp_path, scan))+++def test_a_workspace_wide_esbuild_override_fails_in_a_satellite_root(tmp_path):+ """The one root the check could not see until it stopped reading only `/`."""+ _write_workspace(tmp_path, {"vite>esbuild": "^0.28.1"}, list(gate.EXPECTED_ESBUILD))+ scan = _write_workspace(tmp_path, {"esbuild": "^0.28.1"}, ["0.28.1"], subdir="apps/mobile")+ problems = gate.check_esbuild_overrides(tmp_path, scan)+ assert any("override scope" in p and "apps/mobile/package.json" in p for p in problems)def test_a_moved_esbuild_resolution_fails(tmp_path):"""A vite bump pulls esbuild through the scoped override with no esbuild in the diff."""- _write_workspace(tmp_path, {"vite>esbuild": "^0.28.1"}, [*gate.EXPECTED_ESBUILD, "0.30.0"])- assert any("0.30.0" in p for p in gate.check_esbuild_overrides(tmp_path))+ scan = _write_workspace(tmp_path, {"vite>esbuild": "^0.28.1"}, [*gate.EXPECTED_ESBUILD, "0.30.0"])+ assert any("0.30.0" in p for p in gate.check_esbuild_overrides(tmp_path, scan))def test_a_stale_expectation_fails(tmp_path):- _write_workspace(tmp_path, {"vite>esbuild": "^0.28.1"}, [sorted(gate.EXPECTED_ESBUILD)[0]])- assert any("stale" in p for p in gate.check_esbuild_overrides(tmp_path))+ scan = _write_workspace(tmp_path, {"vite>esbuild": "^0.28.1"}, [sorted(gate.EXPECTED_ESBUILD)[0]])+ assert any("stale" in p for p in gate.check_esbuild_overrides(tmp_path, scan))+++# ── Cross-root override propagation ──────────────────────────────────────────+++def no_exemptions(monkeypatch):+ """Test the propagation logic against an empty exemption list.++ These fixtures build a tree containing `apps/mobile`, which the real+ exemption list has an entry for. Leaving it in place would mean every+ assertion below also asserted something about this repository's current+ exemptions, and a future entry would fail tests that have nothing to do+ with it. The live entries are checked separately — by+ `test_every_cross_root_exemption_records_versions_and_a_reason` for shape+ and by the whole-repository run at the bottom of this file for liveness.+ """+ monkeypatch.setattr(gate, "CROSS_ROOT_OVERRIDE_EXEMPT", {})+++def _two_roots(root: Path, root_overrides: dict, root_lock: dict, sat_overrides: dict, sat_lock: dict):+ """A workspace plus one independent install root, as `apps/mobile` is."""+ for directory, overrides, lock in (+ (root, root_overrides, root_lock),+ (root / "apps" / "mobile", sat_overrides, sat_lock),+ ):+ directory.mkdir(parents=True, exist_ok=True)+ (directory / "package.json").write_text(json.dumps({"pnpm": {"overrides": overrides}}), encoding="utf-8")+ (directory / "pnpm-lock.yaml").write_text(+ "lockfileVersion: '6.0'\n" + "".join(f" /{n}@{v}:\n" for n, vs in lock.items() for v in vs),+ encoding="utf-8",+ )+ scan = gate.Scan()+ scan.node_roots = gate.scan_node_roots(root)+ return scan+++def test_an_override_that_reached_one_install_root_fails(tmp_path, no_exemptions):+ """The measured bug: the workspace pinned image-size, apps/mobile kept 1.2.1."""+ scan = _two_roots(tmp_path, {"image-size": ">=2.0.4 <3"}, {"image-size": ["2.0.4"]}, {}, {"image-size": ["1.2.1"]})+ problems = gate.check_override_propagation(tmp_path, scan)+ assert any("override propagation" in p and "apps/mobile/pnpm-lock.yaml" in p for p in problems)+++def test_an_override_present_in_both_roots_passes(tmp_path, no_exemptions):+ scan = _two_roots(+ tmp_path,+ {"image-size": ">=2.0.4 <3"},+ {"image-size": ["2.0.4"]},+ {"image-size": ">=2.0.4 <3"},+ {"image-size": ["2.0.4"]},+ )+ assert gate.check_override_propagation(tmp_path, scan) == []+++def test_a_package_absent_from_the_other_root_passes(tmp_path, no_exemptions):+ """Not every override has to appear everywhere — only where it is resolved."""+ scan = _two_roots(tmp_path, {"sharp": ">=0.35.4"}, {"sharp": ["0.35.4"]}, {}, {"left-pad": ["1.3.0"]})+ assert gate.check_override_propagation(tmp_path, scan) == []+++def test_a_version_selector_only_governs_its_own_line(tmp_path, no_exemptions):+ """`brace-expansion@1` says nothing about the 5.x the workspace also resolves."""+ scan = _two_roots(+ tmp_path,+ {"brace-expansion@1": ">=1.1.18 <2"},+ {"brace-expansion": ["1.1.21", "5.0.12"]},+ {},+ {"brace-expansion": ["5.0.12"]},+ )+ assert gate.check_override_propagation(tmp_path, scan) == []+++def test_a_parent_scoped_override_is_not_read_as_a_global_one(tmp_path, no_exemptions):+ """`vite>esbuild` constrains esbuild under vite, not esbuild everywhere."""+ scan = _two_roots(tmp_path, {"vite>esbuild": "^0.28.1"}, {"esbuild": ["0.28.1"]}, {}, {"esbuild": ["0.25.12"]})+ assert gate.check_override_propagation(tmp_path, scan) == []+++def test_a_lockfile_behind_its_own_manifest_fails(tmp_path, no_exemptions):+ scan = _two_roots(+ tmp_path,+ {"image-size": ">=2.0.4 <3"},+ {"image-size": ["2.0.4"]},+ {"image-size": ">=2.0.4 <3"},+ {"image-size": ["1.2.1"]},+ )+ assert any("was not regenerated" in p for p in gate.check_override_propagation(tmp_path, scan))+++def test_an_unreadable_lockfile_is_not_a_clean_root(tmp_path):+ """What the check *credits*: a root it could not read agrees with everyone."""+ scan = _two_roots(tmp_path, {"image-size": ">=2.0.4 <3"}, {"image-size": ["2.0.4"]}, {}, {})+ assert any("node root corpus" in p for p in gate.check_node_root_corpus(scan))+++def test_no_install_root_at_all_is_a_failure(tmp_path):+ assert any("no Node install root" in p for p in gate.check_node_root_corpus(gate.Scan()))+++def test_a_range_the_comparison_cannot_evaluate_is_reported(tmp_path, no_exemptions):+ """A union range must not silently pass for want of an opinion."""+ scan = _two_roots(tmp_path, {"image-size": "1.x || >=2.0.4"}, {"image-size": ["2.0.4"]}, {}, {"image-size": ["1.2.1"]})+ assert any("cannot evaluate" in p for p in gate.check_override_propagation(tmp_path, scan))+++def test_an_override_block_the_parser_cannot_read_is_reported(tmp_path):+ (tmp_path / "package.json").write_text(json.dumps({"pnpm": {"override": {"image-size": ">=2"}}}), encoding="utf-8")+ (tmp_path / "pnpm-lock.yaml").write_text("lockfileVersion: '6.0'\n /[email protected]:\n", encoding="utf-8")+ scan = gate.Scan()+ scan.node_roots = gate.scan_node_roots(tmp_path)+ assert any("override parser coverage" in p for p in gate.check_override_parser_coverage(tmp_path, scan))+++def test_npm_nested_overrides_are_read(tmp_path):+ """npm writes `{"a": {"b": "1"}}` where pnpm writes `a>b`; both must be seen."""+ (tmp_path / "package.json").write_text(+ json.dumps({"overrides": {"qs": "^6.16.0", "express": {"body-parser": "^2.3.0"}}}), encoding="utf-8"+ )+ (tmp_path / "package-lock.json").write_text(+ json.dumps({"lockfileVersion": 3, "packages": {"node_modules/qs": {"version": "6.16.0"}}}), encoding="utf-8"+ )+ root = gate.scan_node_roots(tmp_path)[0]+ assert root.overrides == {"qs": "^6.16.0", "express>body-parser": "^2.3.0"}+ assert root.resolved == {"qs": ["6.16.0"]}+++def test_an_exemption_holds_only_for_the_versions_it_records(tmp_path, monkeypatch):+ """The ratchet. A bump past the verified version re-opens the question."""+ monkeypatch.setattr(gate, "CROSS_ROOT_OVERRIDE_EXEMPT", {("image-size", "apps/mobile"): (("1.2.1",), "verified")})+ scan = _two_roots(tmp_path, {"image-size": ">=2.0.4 <3"}, {"image-size": ["2.0.4"]}, {}, {"image-size": ["1.2.1"]})+ assert gate.check_override_propagation(tmp_path, scan) == []++ moved = _two_roots(tmp_path, {"image-size": ">=2.0.4 <3"}, {"image-size": ["2.0.4"]}, {}, {"image-size": ["1.2.0"]})+ problems = gate.check_override_propagation(tmp_path, moved)+ assert any("re-opens the question" in p for p in problems)+ assert any("1.2.0" in p for p in problems)+++def test_an_exemption_for_a_directory_outside_this_tree_is_not_drift(tmp_path, monkeypatch):+ """A fixture or a fork simply lacks the directory; that must not fail the gate."""+ monkeypatch.setattr(gate, "CROSS_ROOT_OVERRIDE_EXEMPT", {("image-size", "apps/never-existed"): (("1.2.1",), "x")})+ scan = _two_roots(tmp_path, {"image-size": ">=2.0.4 <3"}, {"image-size": ["2.0.4"]}, {}, {})+ assert gate.check_override_propagation(tmp_path, scan) == []++ # But a directory that is *there* and has stopped resolving its own+ # node_modules is drift, and must be reported.+ (tmp_path / "apps" / "never-existed").mkdir(parents=True)+ assert any("no longer an install root" in p for p in gate.check_override_propagation(tmp_path, scan))+++def test_every_cross_root_exemption_records_versions_and_a_reason(tmp_path):+ """A bare package/root pair would be a permanent hole; the versions make it a ratchet."""+ for key, (versions, reason) in gate.CROSS_ROOT_OVERRIDE_EXEMPT.items():+ assert versions and all(re.match(r"^\d+\.\d+", v) for v in versions), key+ assert "OSV" in reason and len(reason) > 80, key# ── The gate against this repository ─────────────────────────────────────────