@titan-design/code-read 0.1.9 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +111 -3
- package/dist/chunk-7FNTXO7C.js +2344 -0
- package/dist/chunk-7FNTXO7C.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +133 -3
- package/dist/index.js.map +1 -1
- package/dist/query/index.d.ts +1283 -5
- package/dist/query/index.js +77 -1
- package/package.json +5 -5
- package/dist/chunk-VXQFCVGB.js +0 -1326
- package/dist/chunk-VXQFCVGB.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/query/contract.ts","../src/query/schemas.ts","../src/query/contract-findings.ts","../src/query/contract-nodes.ts","../src/query/model.ts","../src/query/source.ts","../src/query/snapshot-ref.ts","../src/query/rollup.ts","../src/query/tree.ts","../src/query/baseline.ts","../src/query/excerpt.ts","../src/query/finding-rows.ts","../src/query/neighbors.ts","../src/query/stats.ts","../src/query/finding-get.ts","../src/query/findings-list.ts","../src/query/hierarchy.ts","../src/query/node-get.ts","../src/query/resolve.ts","../src/query/commands.ts","../src/query/resolver.ts"],"sourcesContent":["import { toJSONSchema, z, type ZodType } from \"zod\";\nimport { Capabilities, MetricDescriptor, RuleSummary, SnapshotInfo } from \"./schemas.js\";\nimport { FINDING_GET, FINDINGS_LIST, NODE_NEIGHBORS } from \"./contract-findings.js\";\nimport { HIERARCHY_GET, NODE_GET, NODE_RESOLVE } from \"./contract-nodes.js\";\n\n/** The read API's semver. Bump it whenever `CONTRACT` changes; `contract.lock.json` records the last one. */\nexport const CODE_READ_API_VERSION = \"0.1.2\";\n\nexport interface CommandContract<Args extends ZodType = ZodType, Result extends ZodType = ZodType> {\n description: string;\n args: Args;\n result: Result;\n}\n\nconst describeArgs = z.object({});\nconst describeResult = z.object({\n api: z.string(),\n dataset: z.enum([\"live\", \"static\"]),\n commands: z.array(z.string()),\n newest: SnapshotInfo.nullable(),\n indexVersions: z.array(z.string()),\n capabilities: Capabilities,\n metrics: z.array(MetricDescriptor),\n rules: z.array(RuleSummary),\n});\n\nconst snapshotListArgs = z.object({\n ref: z.string().min(1).optional(),\n limit: z.number().int().min(1).max(500).default(50),\n});\nconst snapshotListResult = z.object({ snapshots: z.array(SnapshotInfo) });\n\n// The lock sees JSON Schema only: a .refine(), .superRefine(), or .transform() here changes behaviour without a lock diff.\n/** The single source of command names, argument schemas, and result schemas for every surface. */\nexport const CONTRACT = {\n \"api.describe\": {\n description:\n \"Contract version, commands served, capabilities, the newest snapshot, and the metric and rule catalogues. Call first to pin compatibility.\",\n args: describeArgs,\n result: describeResult,\n },\n \"snapshot.list\": {\n description: \"Indexed snapshots, newest first, with ref, commit, time, and index version. Optionally one ref only.\",\n args: snapshotListArgs,\n result: snapshotListResult,\n },\n \"hierarchy.get\": HIERARCHY_GET,\n \"node.get\": NODE_GET,\n \"node.resolve\": NODE_RESOLVE,\n \"findings.list\": FINDINGS_LIST,\n \"finding.get\": FINDING_GET,\n \"node.neighbors\": NODE_NEIGHBORS,\n} as const satisfies Record<string, CommandContract>;\n\nexport type CommandName = keyof typeof CONTRACT;\nexport type CommandArgs<N extends CommandName> = z.output<(typeof CONTRACT)[N][\"args\"]>;\nexport type CommandInput<N extends CommandName> = z.input<(typeof CONTRACT)[N][\"args\"]>;\nexport type CommandResult<N extends CommandName> = z.output<(typeof CONTRACT)[N][\"result\"]>;\n\n/** Name to input args and result: the shape a typed client (`rpc-protocol`'s `CommandMap`) needs. */\nexport type CodeReadCommandMap = { [N in CommandName]: { args: CommandInput<N>; result: CommandResult<N> } };\n\nexport const COMMAND_NAMES = Object.keys(CONTRACT).sort() as CommandName[];\n\n/** The agent-shaped commands the design puts on MCP; `hierarchy.get` is UI-shaped. A product filters with this until the registry can (P3). */\nexport const AGENT_COMMANDS: readonly CommandName[] = [\n \"api.describe\",\n \"finding.get\",\n \"findings.list\",\n \"node.get\",\n \"node.neighbors\",\n \"node.resolve\",\n];\n\nexport interface SerializedContract {\n api: string;\n commands: Record<string, { args: unknown; result: unknown }>;\n}\n\n/** Args and results as JSON Schema in a stable key order; descriptions are docs, not contract, so they are left out. */\nexport function serializeContract(): SerializedContract {\n const commands: SerializedContract[\"commands\"] = {};\n for (const name of COMMAND_NAMES) {\n const { args, result } = CONTRACT[name];\n commands[name] = { args: toJSONSchema(args, { io: \"input\" }), result: toJSONSchema(result) };\n }\n return { api: CODE_READ_API_VERSION, commands };\n}\n","import { z } from \"zod\";\n\n/** Open string: \"repo\" | \"package\" | \"directory\" | \"file\" | \"symbol\" today; consumers tolerate unknown kinds. */\nexport const NodeKind = z.string();\n\n/** Open string: \"error\" | \"warning\" | \"info\" today. */\nexport const Severity = z.string();\n\nexport const ProvenanceKind = z.enum([\"measured\", \"derived\", \"model\"]);\n\nexport const Provenance = z.object({\n kind: ProvenanceKind,\n source: z.string(),\n at: z.string().optional(),\n});\n\nexport const SnapshotInfo = z.object({\n id: z.number().int(),\n ref: z.string(),\n commit: z.string().nullable(),\n takenAt: z.string(),\n indexVersion: z.string(),\n});\n\nexport const MetricDescriptor = z.object({\n name: z.string(),\n unit: z.string().nullable(),\n appliesTo: z.array(NodeKind),\n rollup: z.enum([\"sum\", \"max\", \"mean\", \"none\"]),\n direction: z.enum([\"higher-worse\", \"lower-worse\", \"neutral\"]),\n absent: z.enum([\"zero\", \"exclude\"]),\n window: z.string().optional(),\n description: z.string(),\n provenance: Provenance,\n});\n\nexport const RuleSummary = z.object({ id: z.string(), type: z.string(), severity: Severity });\n\n/** A snapshot id, a digit string, or a ref name meaning that ref's newest snapshot. Omitted means the newest overall. */\nexport const SnapshotRef = z.union([z.number().int().positive(), z.string().min(1)]);\n\nexport const Span = z.object({ startLine: z.number().int(), endLine: z.number().int() });\n\n/** How a node is addressed everywhere in the API; consumers treat `id` as opaque and read the other fields. */\nexport const NodeRef = z.object({\n id: z.string(),\n kind: NodeKind,\n name: z.string(),\n /** The declaring file for a symbol, the directory path for a directory, \"\" for the repo. */\n path: z.string(),\n span: Span.optional(),\n});\n\n/** Open string: \"no-rollup\" | \"not-measured\" | \"not-in-snapshot\" today; why a value is null. */\nexport const MissingReason = z.string();\n\nexport const Capabilities = z.object({\n findings: z.enum([\"none\", \"check-rules\", \"store\"]),\n verdicts: z.boolean(),\n themes: z.boolean(),\n feedback: z.boolean(),\n embeddings: z.object({ model: z.string(), embedded: z.number(), symbols: z.number() }).nullable(),\n cochange: z.boolean(),\n sourceAtCommit: z.boolean(),\n excerpts: z.enum([\"any\", \"flagged\", \"none\"]),\n});\n\nexport type ProvenanceKind = z.infer<typeof ProvenanceKind>;\nexport type Provenance = z.infer<typeof Provenance>;\nexport type SnapshotInfo = z.infer<typeof SnapshotInfo>;\nexport type MetricDescriptor = z.infer<typeof MetricDescriptor>;\nexport type RuleSummary = z.infer<typeof RuleSummary>;\nexport type Capabilities = z.infer<typeof Capabilities>;\nexport type SnapshotRef = z.infer<typeof SnapshotRef>;\nexport type Span = z.infer<typeof Span>;\nexport type NodeRef = z.infer<typeof NodeRef>;\n","import { z } from \"zod\";\nimport { NodeRef, Provenance, ProvenanceKind, Severity, SnapshotRef, Span } from \"./schemas.js\";\n\n/** Most rows one `findings.list` page returns; a table pages with `offset`. */\nexport const FINDINGS_PAGE_MAX = 500;\n\n/** Most lines one excerpt carries, whatever the flagged range and context ask for. */\nexport const EXCERPT_LINE_CAP = 80;\n\nexport const FindingStatus = z.enum([\"new\", \"carryover\", \"resolved\", \"worsened\", \"improved\"]);\n\nconst BaselineFields = {\n baselineSnapshotId: z.number().int().optional(),\n comparable: z.boolean().optional(),\n};\n\nexport const Finding = z.object({\n /** Opaque and stable across snapshots while the rule, node, and destination are unchanged. */\n id: z.string(),\n snapshotId: z.number().int(),\n rule: z.string(),\n /** Open string: \"check\" for check-rule findings today. */\n tool: z.string(),\n severity: Severity,\n node: NodeRef,\n destination: NodeRef.optional(),\n /** The first flagged line range; absent when the finding is about the whole node. */\n range: Span.optional(),\n metric: z.string().optional(),\n value: z.number().optional(),\n threshold: z.number().optional(),\n /** How far past the threshold, as a ratio where larger is worse; null when the rule has no threshold. */\n excess: z.number().nullable(),\n /** Present only when a baseline was given. */\n status: FindingStatus.optional(),\n message: z.string(),\n provenance: Provenance,\n});\n\nconst findingsListArgs = z.object({\n snapshot: SnapshotRef.optional(),\n baseline: SnapshotRef.optional(),\n scope: z.string().optional(),\n rule: z.array(z.string()).default([]),\n severity: z.array(Severity).default([]),\n tool: z.array(z.string()).default([]),\n provenance: z.array(ProvenanceKind).default([]),\n kind: z.array(z.string()).default([]),\n status: z.array(FindingStatus).default([]),\n sort: z.enum([\"severity\", \"excess\", \"value\", \"path\", \"rule\"]).default(\"severity\"),\n order: z.enum([\"asc\", \"desc\"]).default(\"desc\"),\n offset: z.number().int().min(0).default(0),\n limit: z.number().int().min(0).max(FINDINGS_PAGE_MAX).default(20),\n facets: z.boolean().default(false),\n});\n\nconst findingsListResult = z.object({\n snapshotId: z.number().int(),\n ...BaselineFields,\n rows: z.array(Finding),\n total: z.number().int(),\n /** Facet name to value to count, over every row that passed the filters; each facet's counts sum to `total`. */\n facets: z.record(z.string(), z.record(z.string(), z.number().int())).optional(),\n});\n\nexport const FINDINGS_LIST = {\n description:\n \"Findings in a snapshot, filtered, sorted, and offset-paginated, with optional facet counts. Check-rule findings are \" +\n \"derived on read (provenance 'derived'), so one disappears when its rule or threshold changes. `scope` limits to a node \" +\n \"and everything under it. With `baseline`, each row gets a status and resolved findings come back from the baseline.\",\n args: findingsListArgs,\n result: findingsListResult,\n} as const;\n\nexport const SourceExcerpt = z.object({\n path: z.string(),\n startLine: z.number().int(),\n endLine: z.number().int(),\n text: z.string(),\n /** Of the whole file at the snapshot. */\n contentHash: z.string(),\n origin: z.enum([\"commit\", \"worktree\", \"export\"]),\n highlights: z.array(Span),\n /** True when the cap cut the requested window short. */\n truncated: z.boolean(),\n});\n\nconst findingGetArgs = z.object({\n snapshot: SnapshotRef.optional(),\n id: z.string(),\n baseline: SnapshotRef.optional(),\n context_lines: z.number().int().min(0).max(20).default(5),\n});\n\nconst findingGetResult = z.object({\n snapshotId: z.number().int(),\n ...BaselineFields,\n finding: Finding,\n rule: z.object({ id: z.string(), type: z.string(), severity: Severity, text: z.string() }),\n measured: z.object({\n value: z.number().nullable(),\n threshold: z.number().nullable(),\n percentile: z.number().nullable(),\n siblingMedian: z.number().nullable(),\n baselineValue: z.number().nullable().optional(),\n }),\n why: z.string(),\n excerpt: SourceExcerpt.nullable(),\n /** Open string: why `excerpt` is null, such as \"no-source\" or \"changed-since-snapshot\". */\n excerptMissing: z.string().optional(),\n related: z.array(Finding),\n});\n\nexport const FINDING_GET = {\n description:\n \"One finding by id with its rule, the measured value in context, a source excerpt of the flagged lines plus \" +\n \"`context_lines` either side, and up to 10 related findings on the same node or on graph neighbours.\",\n args: findingGetArgs,\n result: findingGetResult,\n} as const;\n\nconst nodeNeighborsArgs = z.object({\n snapshot: SnapshotRef.optional(),\n id: z.string(),\n direction: z.enum([\"in\", \"out\", \"both\"]).default(\"both\"),\n edge_kinds: z.array(z.string()).default([]),\n metrics: z.array(z.string().min(1)).max(10).default([\"loc\", \"utilization\"]),\n offset: z.number().int().min(0).default(0),\n limit: z.number().int().min(1).max(100).default(20),\n});\n\nconst Neighbor = z.object({\n node: NodeRef,\n kind: z.string(),\n weight: z.number().nullable(),\n specifier: z.string().optional(),\n values: z.record(z.string(), z.number().nullable()),\n});\n\nconst nodeNeighborsResult = z.object({\n snapshotId: z.number().int(),\n node: NodeRef,\n inbound: z.array(Neighbor),\n outbound: z.array(Neighbor),\n /** Edges in each direction before `offset` and `limit`; zero for a direction not asked for. */\n total: z.object({ inbound: z.number().int(), outbound: z.number().int() }),\n});\n\nexport const NODE_NEIGHBORS = {\n description:\n \"Edges into and out of one stored node (file, symbol, module, or external), heaviest first, each with the neighbour's \" +\n \"metric values. Empty `edge_kinds` means every kind except 'references' unless the node is a symbol.\",\n args: nodeNeighborsArgs,\n result: nodeNeighborsResult,\n} as const;\n\nexport type Finding = z.infer<typeof Finding>;\nexport type FindingStatus = z.infer<typeof FindingStatus>;\nexport type SourceExcerpt = z.infer<typeof SourceExcerpt>;\n","import { z } from \"zod\";\nimport { MetricDescriptor, MissingReason, NodeRef, SnapshotRef } from \"./schemas.js\";\n\n/** The row cap on `hierarchy.get`; past it the result says `truncated` and the shallowest rows are kept. */\nexport const HIERARCHY_ROW_CAP = 5_000;\n\nconst MetricNames = z.array(z.string().min(1)).max(40);\n\n/** Present only with a baseline: the baseline's id, and false when its index version differs, so deltas may compare unlike measures. */\nconst BaselineFields = {\n baselineSnapshotId: z.number().int().optional(),\n comparable: z.boolean().optional(),\n};\n\nconst hierarchyArgs = z.object({\n snapshot: SnapshotRef.optional(),\n root: z.string().optional(),\n depth: z.number().int().min(1).max(8).default(2),\n metrics: MetricNames.default([\"loc\"]),\n baseline: SnapshotRef.optional(),\n include_symbols: z.boolean().default(false),\n exclude_roles: z.array(z.string()).default([]),\n});\n\nconst HierarchyRow = NodeRef.extend({\n parentId: z.string().nullable(),\n /** Relative to the requested root, which is 0. */\n depth: z.number().int(),\n /** Children in the full tree, symbols included, whatever `depth` and `include_symbols` returned. */\n childCount: z.number().int(),\n role: z.string().optional(),\n values: z.record(z.string(), z.number().nullable()),\n missing: z.record(z.string(), MissingReason).optional(),\n deltas: z.record(z.string(), z.number().nullable()).optional(),\n});\n\nconst hierarchyResult = z.object({\n snapshotId: z.number().int(),\n ...BaselineFields,\n nodes: z.array(HierarchyRow),\n truncated: z.boolean(),\n});\n\nexport const HIERARCHY_GET = {\n description:\n \"A subtree of the synthesized repo, directory, file, and symbol hierarchy as a flat list with parent ids, \" +\n \"shallowest first. Directory values roll up per the metric catalogue; a null value says why in `missing`.\",\n args: hierarchyArgs,\n result: hierarchyResult,\n} as const;\n\nconst nodeGetArgs = z.object({\n snapshot: SnapshotRef.optional(),\n id: z.string(),\n baseline: SnapshotRef.optional(),\n metrics: MetricNames.default([]),\n});\n\nconst NodeMetric = z.object({\n name: z.string(),\n unit: z.string().nullable(),\n direction: MetricDescriptor.shape.direction,\n rollup: MetricDescriptor.shape.rollup,\n value: z.number().nullable(),\n missing: MissingReason.optional(),\n percentile: z.number().nullable(),\n siblingMedian: z.number().nullable(),\n siblingRank: z.number().int().nullable(),\n siblingCount: z.number().int(),\n baseline: z.number().nullable().optional(),\n delta: z.number().nullable().optional(),\n});\n\nconst nodeGetResult = z.object({\n snapshotId: z.number().int(),\n ...BaselineFields,\n node: NodeRef.extend({\n language: z.string().optional(),\n role: z.string().optional(),\n exported: z.boolean().optional(),\n signature: z.string().optional(),\n purpose: z.string().optional(),\n }),\n ancestors: z.array(NodeRef),\n childCounts: z.record(z.string(), z.number().int()),\n metrics: z.array(NodeMetric),\n});\n\nexport const NODE_GET = {\n description:\n \"One node by id (a directory id ends in '/', the repo is ''): its containing chain, child counts, and each metric \" +\n \"with direction, percentile among same-kind nodes, sibling median and rank, and a delta against an optional baseline.\",\n args: nodeGetArgs,\n result: nodeGetResult,\n} as const;\n\nconst nodeResolveArgs = z.object({\n snapshot: SnapshotRef.optional(),\n query: z.string().min(1).optional(),\n path: z.string().min(1).optional(),\n line: z.number().int().min(1).optional(),\n limit: z.number().int().min(1).max(50).default(10),\n});\n\nconst nodeResolveResult = z.object({\n candidates: z.array(\n z.object({\n node: NodeRef,\n score: z.number(),\n /** Open string: \"exact\" | \"span\" | \"suffix\" | \"prefix\" | \"substring\" today. */\n match: z.string(),\n }),\n ),\n});\n\nexport const NODE_RESOLVE = {\n description:\n \"Turn a loose reference into ranked candidate node ids. Pass exactly one of `query` (a path, path:line, symbol name, \" +\n \"or file#Scope.name) or `path` with an optional `line`; a line resolves to the innermost symbol whose span contains it.\",\n args: nodeResolveArgs,\n result: nodeResolveResult,\n} as const;\n","import type { MetricDescriptor, SnapshotInfo, Span } from \"./schemas.js\";\n\n/** A graph node as the read API holds it; mirrors code-graph's `GraphNode` without importing it. */\nexport interface ModelNode {\n id: string;\n kind: string;\n name: string;\n parentId: string | null;\n language?: string;\n role?: string;\n attrs: Record<string, unknown>;\n}\n\nexport interface ModelEdge {\n srcId: string;\n dstId: string;\n kind: string;\n attrs: Record<string, unknown>;\n}\n\nexport interface ModelAlias {\n oldId: string;\n newId: string;\n reason: string;\n}\n\nexport interface ModelMetric {\n nodeId: string;\n name: string;\n value: number | null;\n unit?: string;\n}\n\n/** A rule as findings cite it: `text` is a plain-language statement of what the rule demands. */\nexport interface ModelRule {\n id: string;\n type: string;\n severity: string;\n text: string;\n}\n\n/** One check-rule violation, keyed by the ratchet's `violationKey`; `ranges` are the flagged lines, absent for a whole-node finding. */\nexport interface ModelFinding {\n id: string;\n rule: string;\n severity: string;\n nodeId: string;\n destinationId?: string;\n metric?: string;\n value?: number;\n threshold?: number;\n message: string;\n ranges?: readonly Span[];\n}\n\n/** A catalogue entry as code-graph's `describeMetric` returns it; provenance is added here. */\nexport interface CatalogueEntry {\n name: string;\n unit: string;\n appliesTo: readonly string[];\n rollup: MetricDescriptor[\"rollup\"];\n direction: MetricDescriptor[\"direction\"];\n absent: MetricDescriptor[\"absent\"];\n source: string;\n description: string;\n window?: string;\n}\n\n/** Everything one snapshot holds, indexed for reads. Snapshots are immutable, so a model never goes stale. */\nexport interface ReadModel {\n snapshot: SnapshotInfo;\n nodes: readonly ModelNode[];\n nodeById: ReadonlyMap<string, ModelNode>;\n edges: readonly ModelEdge[];\n aliases: readonly ModelAlias[];\n /** Metric name to node id to value. */\n metrics: ReadonlyMap<string, ReadonlyMap<string, number | null>>;\n /** One descriptor per metric name present in the snapshot, sorted by name. */\n metricCatalogue: readonly MetricDescriptor[];\n /** Derived on load from the product's rules; a changed rule set means a different model. */\n findings: readonly ModelFinding[];\n rules: readonly ModelRule[];\n}\n\nexport interface ReadModelParts {\n snapshot: SnapshotInfo;\n nodes: readonly ModelNode[];\n edges: readonly ModelEdge[];\n aliases: readonly ModelAlias[];\n metrics: readonly ModelMetric[];\n /** The catalogue lookup, injected so this module never imports code-graph's Node-only root. */\n describe: (name: string) => CatalogueEntry | null;\n findings?: readonly ModelFinding[];\n rules?: readonly ModelRule[];\n}\n\nexport function buildReadModel(parts: ReadModelParts): ReadModel {\n const nodeById = new Map(parts.nodes.map((n) => [n.id, n]));\n return {\n snapshot: parts.snapshot,\n nodes: parts.nodes,\n nodeById,\n edges: parts.edges,\n aliases: parts.aliases,\n metrics: indexMetrics(parts.metrics),\n metricCatalogue: buildCatalogue(parts, nodeById),\n findings: parts.findings ?? [],\n rules: parts.rules ?? [],\n };\n}\n\nfunction indexMetrics(metrics: readonly ModelMetric[]): Map<string, Map<string, number | null>> {\n const byName = new Map<string, Map<string, number | null>>();\n for (const m of metrics) {\n let values = byName.get(m.name);\n if (!values) byName.set(m.name, (values = new Map()));\n values.set(m.nodeId, m.value);\n }\n return byName;\n}\n\ninterface ObservedMetric {\n unit: string | null;\n kinds: Set<string>;\n}\n\nfunction observeMetrics(metrics: readonly ModelMetric[], nodeById: ReadonlyMap<string, ModelNode>): Map<string, ObservedMetric> {\n const observed = new Map<string, ObservedMetric>();\n for (const m of metrics) {\n let entry = observed.get(m.name);\n if (!entry) observed.set(m.name, (entry = { unit: m.unit ?? null, kinds: new Set() }));\n const kind = nodeById.get(m.nodeId)?.kind;\n if (kind) entry.kinds.add(kind);\n }\n return observed;\n}\n\nfunction buildCatalogue(parts: ReadModelParts, nodeById: ReadonlyMap<string, ModelNode>): MetricDescriptor[] {\n const observed = observeMetrics(parts.metrics, nodeById);\n const engine = `code-graph@${parts.snapshot.indexVersion}`;\n return [...observed.keys()].sort().map((name) => {\n const entry = parts.describe(name);\n return entry ? fromCatalogue(entry, engine) : uncatalogued(name, observed.get(name)!, engine);\n });\n}\n\nfunction fromCatalogue(entry: CatalogueEntry, engine: string): MetricDescriptor {\n const descriptor: MetricDescriptor = {\n name: entry.name,\n unit: entry.unit,\n appliesTo: [...entry.appliesTo],\n rollup: entry.rollup,\n direction: entry.direction,\n absent: entry.absent,\n description: entry.description,\n provenance: { kind: \"measured\", source: `${engine}/${entry.source}` },\n };\n if (entry.window !== undefined) descriptor.window = entry.window;\n return descriptor;\n}\n\n// A stored name the catalogue does not know: served with no judgement rather than dropped.\nfunction uncatalogued(name: string, seen: ObservedMetric, engine: string): MetricDescriptor {\n return {\n name,\n unit: seen.unit,\n appliesTo: [...seen.kinds].sort(),\n rollup: \"none\",\n direction: \"neutral\",\n absent: \"exclude\",\n description: \"Not in code-graph's metric catalogue.\",\n provenance: { kind: \"measured\", source: `${engine}/uncatalogued` },\n };\n}\n","import { EXIT } from \"@titan-design/rpc-protocol\";\nimport type { CommandName } from \"./contract.js\";\nimport type { ReadModel } from \"./model.js\";\nimport type { Capabilities, RuleSummary, SnapshotInfo } from \"./schemas.js\";\n\n/** What a source can serve, independent of any one snapshot. */\nexport interface SourceFacts {\n dataset: \"live\" | \"static\";\n commands: readonly CommandName[];\n capabilities: Capabilities;\n rules: readonly RuleSummary[];\n}\n\n/** Where excerpt text came from: the snapshot's commit, a working tree proven to match it, or a static export. */\nexport type SourceOrigin = \"commit\" | \"worktree\" | \"export\";\n\n/** Some or all of one file's lines as they were at the snapshot; `startLine` is the first line held. */\nexport interface SourceWindow {\n path: string;\n contentHash: string;\n origin: SourceOrigin;\n startLine: number;\n lines: readonly string[];\n /** Lines in the whole file, so a window can be clipped at the file's end. */\n lineCount: number;\n}\n\n/** Open string: \"no-source\" | \"changed-since-snapshot\" | \"not-in-export\" | \"unreadable\" today. */\nexport type SourceRead = SourceWindow | { unavailable: string };\n\n/**\n * The seam every query function reads through. The daemon implements it over SQLite with an\n * LRU of models; a static export implements it over a decoded dataset. Same queries, same answers.\n */\nexport interface ReadSource {\n facts(): SourceFacts;\n /** Every snapshot, newest first. */\n snapshots(): readonly SnapshotInfo[];\n /** Throws a `ReadError` with `EXIT.NOINPUT` when the snapshot does not exist. */\n model(snapshotId: number): ReadModel;\n /** A file's text at the snapshot; absent when the source holds no source text at all. */\n readSource?(snapshotId: number, path: string): SourceRead;\n}\n\n/** A failure carrying the sysexits code every surface reports, so the registry's `describeError` maps it as is. */\nexport class ReadError extends Error {\n constructor(\n message: string,\n readonly code: number,\n ) {\n super(message);\n this.name = \"ReadError\";\n }\n}\n\nexport function snapshotNotFound(snapshotId: number): ReadError {\n return new ReadError(`No snapshot with id ${snapshotId}`, EXIT.NOINPUT);\n}\n\nexport function nodeNotFound(id: string, snapshotId: number): ReadError {\n return new ReadError(`No node \"${id}\" in snapshot ${snapshotId}`, EXIT.NOINPUT);\n}\n\nexport function findingNotFound(id: string, snapshotId: number): ReadError {\n return new ReadError(`No finding \"${id}\" in snapshot ${snapshotId}`, EXIT.NOINPUT);\n}\n\n/** Bad arguments the schema cannot express, such as \"exactly one of\"; same code as a schema failure. */\nexport function invalidArgs(message: string): ReadError {\n return new ReadError(`Invalid arguments: ${message}`, EXIT.DATAERR);\n}\n","import { EXIT } from \"@titan-design/rpc-protocol\";\nimport type { ReadModel } from \"./model.js\";\nimport type { SnapshotInfo, SnapshotRef } from \"./schemas.js\";\nimport { ReadError, snapshotNotFound, type ReadSource } from \"./source.js\";\n\nconst DIGITS = /^\\d+$/;\n\n/** An id, a digit string, or a ref name (its newest snapshot); omitted means the newest overall. */\nexport function resolveSnapshot(source: ReadSource, ref: SnapshotRef | undefined): SnapshotInfo {\n const snapshots = source.snapshots();\n if (ref === undefined) {\n const newest = snapshots[0];\n if (!newest) throw new ReadError(\"No snapshots have been indexed\", EXIT.NOINPUT);\n return newest;\n }\n if (typeof ref === \"number\" || DIGITS.test(ref)) {\n const id = Number(ref);\n const found = snapshots.find((s) => s.id === id);\n if (!found) throw snapshotNotFound(id);\n return found;\n }\n const newestOfRef = snapshots.find((s) => s.ref === ref);\n if (!newestOfRef) throw new ReadError(`No snapshot of ref \"${ref}\"`, EXIT.NOINPUT);\n return newestOfRef;\n}\n\nexport function modelFor(source: ReadSource, ref: SnapshotRef | undefined): ReadModel {\n return source.model(resolveSnapshot(source, ref).id);\n}\n","import type { ReadModel } from \"./model.js\";\nimport type { MetricDescriptor } from \"./schemas.js\";\nimport type { Tree, TreeNode } from \"./tree.js\";\n\n/** Why a value is null: the rollup rule forbids one, the node has no measurement, the metric does not describe the node, or the snapshot lacks the metric. */\nexport type Missing = \"no-rollup\" | \"not-measured\" | \"not-applicable\" | \"not-in-snapshot\";\n\nexport interface MetricValue {\n value: number | null;\n missing?: Missing;\n}\n\ninterface Aggregate {\n sum: number;\n count: number;\n max: number;\n}\n\nconst KIND_RANK: Record<string, number> = { repo: 0, directory: 1, file: 2, symbol: 3 };\nconst EMPTY: Aggregate = { sum: 0, count: 0, max: -Infinity };\n\n/** One metric over one tree: stored values where the catalogue says the metric applies, rollups above them. */\nexport interface Column {\n descriptor: MetricDescriptor | undefined;\n valueOf(node: TreeNode): MetricValue;\n}\n\n// Files before symbols: a metric stored on both rolls up from files only, so no value counts twice.\nfunction leafKind(descriptor: MetricDescriptor): string | null {\n if (descriptor.appliesTo.includes(\"file\")) return \"file\";\n return descriptor.appliesTo.includes(\"symbol\") ? \"symbol\" : null;\n}\n\nfunction rank(kind: string): number {\n return KIND_RANK[kind] ?? Infinity;\n}\n\nfunction storedValue(descriptor: MetricDescriptor, values: ReadonlyMap<string, number | null> | undefined, id: string): MetricValue {\n const value = values?.get(id);\n if (value !== undefined && value !== null) return { value };\n if (value === undefined && descriptor.absent === \"zero\") return { value: 0 };\n return { value: null, missing: \"not-measured\" };\n}\n\nfunction merge(a: Aggregate, b: Aggregate): Aggregate {\n return { sum: a.sum + b.sum, count: a.count + b.count, max: Math.max(a.max, b.max) };\n}\n\nfunction finalValue(rule: MetricDescriptor[\"rollup\"], agg: Aggregate): MetricValue {\n if (agg.count === 0) return { value: null, missing: \"not-measured\" };\n if (rule === \"max\") return { value: agg.max };\n if (rule === \"mean\") return { value: agg.sum / agg.count };\n return { value: agg.sum };\n}\n\nfunction buildColumn(model: ReadModel, name: string): Column {\n const descriptor = model.metricCatalogue.find((m) => m.name === name);\n if (!descriptor) return { descriptor, valueOf: () => ({ value: null, missing: \"not-in-snapshot\" }) };\n const values = model.metrics.get(name);\n const leaf = leafKind(descriptor);\n const aggregates = new Map<TreeNode, Aggregate>();\n const own = (node: TreeNode): MetricValue => storedValue(descriptor, values, node.ref.id);\n const aggregate = (node: TreeNode): Aggregate => {\n const cached = aggregates.get(node);\n if (cached) return cached;\n let agg = EMPTY;\n if (node.ref.kind === leaf) {\n const v = own(node).value;\n if (v !== null) agg = { sum: v, count: 1, max: v };\n }\n for (const child of node.children) if (rank(child.ref.kind) <= rank(leaf ?? \"\")) agg = merge(agg, aggregate(child));\n aggregates.set(node, agg);\n return agg;\n };\n const valueOf = (node: TreeNode): MetricValue => {\n if (node.stored && descriptor.appliesTo.includes(node.ref.kind)) return own(node);\n if (leaf === null || rank(node.ref.kind) >= rank(leaf)) return { value: null, missing: \"not-applicable\" };\n if (descriptor.rollup === \"none\") return { value: null, missing: \"no-rollup\" };\n return finalValue(descriptor.rollup, aggregate(node));\n };\n return { descriptor, valueOf };\n}\n\nconst columns = new WeakMap<Tree, Map<string, Column>>();\n\n/** The column for a metric over a tree, built once per tree and metric name. */\nexport function columnFor(model: ReadModel, tree: Tree, name: string): Column {\n let byName = columns.get(tree);\n if (!byName) columns.set(tree, (byName = new Map()));\n let column = byName.get(name);\n if (!column) byName.set(name, (column = buildColumn(model, name)));\n return column;\n}\n\n/** Whether a metric says anything about a node of this kind: stored on it, or rolled up into it. */\nexport function describesKind(descriptor: MetricDescriptor, kind: string): boolean {\n if (descriptor.appliesTo.includes(kind)) return true;\n const leaf = leafKind(descriptor);\n return leaf !== null && rank(kind) < rank(leaf);\n}\n","import type { ModelNode, ReadModel } from \"./model.js\";\nimport type { NodeRef, Span } from \"./schemas.js\";\n\n/** One row of the synthesized hierarchy: repo, directory, file, or symbol. */\nexport interface TreeNode {\n ref: NodeRef;\n parentId: string | null;\n /** Absolute depth: the repo is 0. */\n depth: number;\n /** The stored node; absent for the synthesized repo and directories. */\n stored?: ModelNode;\n children: TreeNode[];\n}\n\n/** code-graph stores no repo, directory, or class level, so this tree is derived from file paths and symbol scopes. */\nexport interface Tree {\n root: TreeNode;\n byId: ReadonlyMap<string, TreeNode>;\n}\n\nexport const REPO_ID = \"\";\nconst SYMBOL_SEP = \"#\";\n\n/** A directory's id carries a trailing slash, which no file id has, so the two id spaces never collide. */\nexport function directoryId(path: string): string {\n return path === \"\" ? REPO_ID : `${path}/`;\n}\n\nexport function spanOf(node: ModelNode): Span | undefined {\n const { startLine, endLine } = node.attrs;\n return typeof startLine === \"number\" && typeof endLine === \"number\" ? { startLine, endLine } : undefined;\n}\n\nexport function toRef(node: ModelNode): NodeRef {\n const sep = node.kind === \"symbol\" ? node.id.indexOf(SYMBOL_SEP) : -1;\n const ref: NodeRef = { id: node.id, kind: node.kind, name: node.name, path: sep < 0 ? node.id : node.id.slice(0, sep) };\n const span = spanOf(node);\n if (span) ref.span = span;\n return ref;\n}\n\nfunction treeNode(ref: NodeRef, parentId: string | null, stored?: ModelNode): TreeNode {\n return stored ? { ref, parentId, depth: 0, stored, children: [] } : { ref, parentId, depth: 0, children: [] };\n}\n\nfunction dirPath(fileId: string): string {\n const slash = fileId.lastIndexOf(\"/\");\n return slash < 0 ? \"\" : fileId.slice(0, slash);\n}\n\nfunction ensureDirectory(byId: Map<string, TreeNode>, path: string): TreeNode {\n const id = directoryId(path);\n const existing = byId.get(id);\n if (existing) return existing;\n const parent = ensureDirectory(byId, dirPath(path));\n const name = path.slice(path.lastIndexOf(\"/\") + 1);\n const dir = treeNode({ id, kind: \"directory\", name, path }, parent.ref.id);\n parent.children.push(dir);\n byId.set(id, dir);\n return dir;\n}\n\nfunction attach(byId: Map<string, TreeNode>, parent: TreeNode, stored: ModelNode): void {\n const node = treeNode(toRef(stored), parent.ref.id, stored);\n parent.children.push(node);\n byId.set(stored.id, node);\n}\n\nfunction containsStrictly(outer: Span, inner: Span): boolean {\n const wider = outer.endLine - outer.startLine > inner.endLine - inner.startLine;\n return wider && outer.startLine <= inner.startLine && inner.endLine <= outer.endLine;\n}\n\n/** The smallest sibling symbol whose span strictly contains this one: the class level for pre-0.14 bare-name ids. */\nfunction innermostEnclosing(symbol: ModelNode, siblings: readonly ModelNode[]): ModelNode | undefined {\n const span = spanOf(symbol);\n if (!span) return undefined;\n let best: ModelNode | undefined;\n let bestSpan: Span | undefined;\n for (const other of siblings) {\n const outer = spanOf(other);\n if (other === symbol || !outer || !containsStrictly(outer, span)) continue;\n if (!bestSpan || outer.endLine - outer.startLine < bestSpan.endLine - bestSpan.startLine) [best, bestSpan] = [other, outer];\n }\n return best;\n}\n\n/** A qualified name `A.b.c` hangs under `A.b`, else `A`, else the symbol whose span encloses it, else its file. */\nfunction symbolParentId(symbol: ModelNode, fileId: string, bySymbolId: ReadonlyMap<string, ModelNode>, siblings: readonly ModelNode[]): string {\n const segments = symbol.name.split(\".\");\n for (let n = segments.length - 1; n > 0; n--) {\n const scopeId = `${fileId}${SYMBOL_SEP}${segments.slice(0, n).join(\".\")}`;\n if (bySymbolId.has(scopeId)) return scopeId;\n }\n return innermostEnclosing(symbol, siblings)?.id ?? fileId;\n}\n\nfunction symbolsByFile(model: ReadModel, byId: ReadonlyMap<string, TreeNode>): Map<string, ModelNode[]> {\n const out = new Map<string, ModelNode[]>();\n for (const node of model.nodes) {\n if (node.kind !== \"symbol\" || node.parentId === null || !byId.has(node.parentId)) continue;\n const list = out.get(node.parentId);\n if (list) list.push(node);\n else out.set(node.parentId, [node]);\n }\n return out;\n}\n\nfunction attachSymbols(model: ReadModel, byId: Map<string, TreeNode>): void {\n for (const [fileId, symbols] of symbolsByFile(model, byId)) {\n const bySymbolId = new Map(symbols.map((s) => [s.id, s]));\n const parentOf = new Map(symbols.map((s) => [s.id, symbolParentId(s, fileId, bySymbolId, symbols)]));\n const pending = [...symbols];\n // Parents attach before children, so repeat passes until every symbol has found its parent in the tree.\n while (pending.length > 0) {\n const ready = pending.filter((s) => byId.has(parentOf.get(s.id)!));\n // Only malformed spans can make a parent cycle; those symbols hang under the file rather than vanish.\n if (ready.length === 0) for (const s of pending) parentOf.set(s.id, fileId);\n for (const s of ready) attach(byId, byId.get(parentOf.get(s.id)!)!, s);\n for (const s of ready) pending.splice(pending.indexOf(s), 1);\n }\n }\n}\n\nconst KIND_ORDER: Record<string, number> = { directory: 0, file: 1, symbol: 2 };\n\nfunction compareSiblings(a: TreeNode, b: TreeNode): number {\n const byKind = (KIND_ORDER[a.ref.kind] ?? 3) - (KIND_ORDER[b.ref.kind] ?? 3);\n if (byKind !== 0) return byKind;\n const byLine = (a.ref.span?.startLine ?? Infinity) - (b.ref.span?.startLine ?? Infinity);\n if (byLine !== 0 && !Number.isNaN(byLine)) return byLine;\n return a.ref.id < b.ref.id ? -1 : a.ref.id > b.ref.id ? 1 : 0;\n}\n\nfunction finish(node: TreeNode, depth: number): void {\n node.depth = depth;\n node.children.sort(compareSiblings);\n for (const child of node.children) finish(child, depth + 1);\n}\n\nfunction buildTree(model: ReadModel, excludeRoles: ReadonlySet<string>): Tree {\n const root = treeNode({ id: REPO_ID, kind: \"repo\", name: \".\", path: \"\" }, null);\n const byId = new Map<string, TreeNode>([[REPO_ID, root]]);\n for (const node of model.nodes) {\n if (node.kind !== \"file\" || (node.role !== undefined && excludeRoles.has(node.role))) continue;\n attach(byId, ensureDirectory(byId, dirPath(node.id)), node);\n }\n attachSymbols(model, byId);\n finish(root, 0);\n return { root, byId };\n}\n\nconst trees = new WeakMap<ReadModel, Map<string, Tree>>();\n\n/** The hierarchy for a snapshot without files of the given roles; built once per model and role set. */\nexport function treeFor(model: ReadModel, excludeRoles: readonly string[] = []): Tree {\n const roles = [...new Set(excludeRoles)].sort();\n const key = roles.join(\"\\n\");\n let byKey = trees.get(model);\n if (!byKey) trees.set(model, (byKey = new Map()));\n let tree = byKey.get(key);\n if (!tree) byKey.set(key, (tree = buildTree(model, new Set(roles))));\n return tree;\n}\n","import type { ReadModel } from \"./model.js\";\nimport { columnFor } from \"./rollup.js\";\nimport type { SnapshotRef } from \"./schemas.js\";\nimport { modelFor } from \"./snapshot-ref.js\";\nimport type { ReadSource } from \"./source.js\";\nimport { treeFor, type Tree } from \"./tree.js\";\n\n/** A prior snapshot to measure deltas against, with the same role exclusions as the current one. */\nexport interface Baseline {\n model: ReadModel;\n tree: Tree;\n}\n\nexport function openBaseline(source: ReadSource, ref: SnapshotRef | undefined, excludeRoles: readonly string[] = []): Baseline | undefined {\n if (ref === undefined) return undefined;\n const model = modelFor(source, ref);\n return { model, tree: treeFor(model, excludeRoles) };\n}\n\n// Matched by id only: following renames through the alias chain is TP-187's identity work.\nexport function baselineValue(baseline: Baseline, id: string, name: string): number | null {\n const node = baseline.tree.byId.get(id);\n return node ? columnFor(baseline.model, baseline.tree, name).valueOf(node).value : null;\n}\n\n/** The result fields every baseline-aware command reports; `comparable` is false across index versions. */\nexport function baselineFields(current: ReadModel, baseline: Baseline | undefined): { baselineSnapshotId?: number; comparable?: boolean } {\n if (!baseline) return {};\n return {\n baselineSnapshotId: baseline.model.snapshot.id,\n comparable: baseline.model.snapshot.indexVersion === current.snapshot.indexVersion,\n };\n}\n\nexport function delta(value: number | null, before: number | null): number | null {\n return value !== null && before !== null ? value - before : null;\n}\n","import { EXCERPT_LINE_CAP, type SourceExcerpt } from \"./contract-findings.js\";\nimport type { Span } from \"./schemas.js\";\nimport type { SourceRead, SourceWindow } from \"./source.js\";\n\nexport interface ExcerptResult {\n excerpt: SourceExcerpt | null;\n missing?: string;\n}\n\ninterface Window {\n from: number;\n to: number;\n truncated: boolean;\n}\n\n/** The flagged lines plus `context` either side, clipped to the file; a whole-node finding starts at line 1. */\nexport function excerptWindow(ranges: readonly Span[], context: number, lineCount: number): Window {\n const from = ranges.length === 0 ? 1 : Math.max(1, Math.min(...ranges.map((r) => r.startLine)) - context);\n const wanted = ranges.length === 0 ? lineCount : Math.min(lineCount, Math.max(...ranges.map((r) => r.endLine)) + context);\n const to = Math.min(wanted, from + EXCERPT_LINE_CAP - 1);\n return { from, to, truncated: to < wanted };\n}\n\nfunction clipped(ranges: readonly Span[], from: number, to: number): Span[] {\n return ranges\n .filter((r) => r.endLine >= from && r.startLine <= to)\n .map((r) => ({ startLine: Math.max(r.startLine, from), endLine: Math.min(r.endLine, to) }));\n}\n\nfunction holds(window: SourceWindow, from: number, to: number): boolean {\n return from >= window.startLine && to <= window.startLine + window.lines.length - 1;\n}\n\n/** Cut an excerpt from what the source returned; a static window that misses the range says \"not-in-export\". */\nexport function buildExcerpt(read: SourceRead, ranges: readonly Span[], context: number): ExcerptResult {\n if (\"unavailable\" in read) return { excerpt: null, missing: read.unavailable };\n const { from, to, truncated } = excerptWindow(ranges, context, read.lineCount);\n if (to >= from && !holds(read, from, to)) return { excerpt: null, missing: \"not-in-export\" };\n const text = read.lines.slice(from - read.startLine, to - read.startLine + 1).join(\"\\n\");\n const excerpt: SourceExcerpt = {\n path: read.path,\n startLine: from,\n endLine: to,\n text,\n contentHash: read.contentHash,\n origin: read.origin,\n highlights: clipped(ranges, from, to),\n truncated,\n };\n return { excerpt };\n}\n","import type { Finding } from \"./contract-findings.js\";\nimport type { ModelFinding, ModelRule, ReadModel } from \"./model.js\";\nimport type { NodeRef } from \"./schemas.js\";\nimport { toRef } from \"./tree.js\";\n\nexport type FindingSort = \"severity\" | \"excess\" | \"value\" | \"path\" | \"rule\";\nexport type SortOrder = \"asc\" | \"desc\";\n\nconst SEVERITY_RANK: Record<string, number> = { error: 2, warning: 1, info: 0 };\nconst CHECK_TOOL = \"check\";\n\n/** A stored node's reference, or a bare one for an id the snapshot does not hold, so a finding never drops its node. */\nexport function refFor(model: ReadModel, id: string): NodeRef {\n const node = model.nodeById.get(id);\n return node ? toRef(node) : { id, kind: \"unknown\", name: id, path: id };\n}\n\n/** Larger is worse for every rule: value over threshold for a maximum, threshold over value for a minimum. */\nexport function excessOf(ruleType: string | undefined, value?: number, threshold?: number): number | null {\n if (value === undefined || threshold === undefined) return null;\n if (ruleType === \"metric-min\") return value > 0 ? threshold / value : null;\n return threshold > 0 ? value / threshold : null;\n}\n\nfunction toFinding(model: ReadModel, f: ModelFinding, rules: ReadonlyMap<string, ModelRule>): Finding {\n const out: Finding = {\n id: f.id,\n snapshotId: model.snapshot.id,\n rule: f.rule,\n tool: CHECK_TOOL,\n severity: f.severity,\n node: refFor(model, f.nodeId),\n excess: excessOf(rules.get(f.rule)?.type, f.value, f.threshold),\n message: f.message,\n provenance: { kind: \"derived\", source: `${CHECK_TOOL}/${f.rule}` },\n };\n if (f.destinationId !== undefined) out.destination = refFor(model, f.destinationId);\n if (f.ranges?.[0]) out.range = f.ranges[0];\n if (f.metric !== undefined) out.metric = f.metric;\n if (f.value !== undefined) out.value = f.value;\n if (f.threshold !== undefined) out.threshold = f.threshold;\n return out;\n}\n\nconst rowsByModel = new WeakMap<ReadModel, readonly Finding[]>();\n\n/** Every finding of a snapshot as a contract row, built once per model. */\nexport function findingsFor(model: ReadModel): readonly Finding[] {\n let rows = rowsByModel.get(model);\n if (!rows) {\n const rules = new Map(model.rules.map((r) => [r.id, r]));\n rowsByModel.set(model, (rows = model.findings.map((f) => toFinding(model, f, rules))));\n }\n return rows;\n}\n\nfunction statusAgainst(current: Finding, before: Finding | undefined): Finding[\"status\"] {\n if (!before) return \"new\";\n if (current.excess === null || before.excess === null || current.excess === before.excess) return \"carryover\";\n return current.excess > before.excess ? \"worsened\" : \"improved\";\n}\n\n// Matched by id only: following renames through the alias chain is TP-187's identity work.\n/** The current rows with a status against the baseline, then the baseline's rows that no longer occur, as \"resolved\". */\nexport function withStatus(current: readonly Finding[], baseline: readonly Finding[]): Finding[] {\n const before = new Map(baseline.map((f) => [f.id, f]));\n const now = new Set(current.map((f) => f.id));\n const rows = current.map((f) => ({ ...f, status: statusAgainst(f, before.get(f.id)) }));\n for (const f of baseline) if (!now.has(f.id)) rows.push({ ...f, status: \"resolved\" });\n return rows;\n}\n\nconst severityRank = (f: Finding): number => SEVERITY_RANK[f.severity] ?? -1;\nconst byText = (a: string, b: string): number => (a < b ? -1 : a > b ? 1 : 0);\n\n/** Nulls sort last whatever the direction, so an unmeasured row never heads a page. */\nfunction byNullable(a: number | null | undefined, b: number | null | undefined, sign: number): number {\n const [x, y] = [a ?? null, b ?? null];\n if (x === null || y === null) return x === y ? 0 : x === null ? 1 : -1;\n return sign * (x - y);\n}\n\ntype Compare = (a: Finding, b: Finding) => number;\n\nconst PRIMARY: Record<FindingSort, (sign: number) => Compare> = {\n severity: (sign) => (a, b) => sign * (severityRank(a) - severityRank(b)),\n excess: (sign) => (a, b) => byNullable(a.excess, b.excess, sign),\n value: (sign) => (a, b) => byNullable(a.value, b.value, sign),\n path: (sign) => (a, b) => sign * byText(a.node.path, b.node.path),\n rule: (sign) => (a, b) => sign * byText(a.rule, b.rule),\n};\n\n// Fixed whatever the sort: worst first, then by place, ending on the unique id so every page boundary is stable.\nconst TIES: readonly Compare[] = [\n PRIMARY.severity(-1),\n PRIMARY.excess(-1),\n PRIMARY.path(1),\n PRIMARY.rule(1),\n (a, b) => byText(a.id, b.id),\n];\n\n/** A total order: `order` flips the primary key only; ties always break the same way. */\nexport function compareFindings(sort: FindingSort, order: SortOrder): Compare {\n const chain = [PRIMARY[sort](order === \"asc\" ? 1 : -1), ...TIES];\n return (a, b) => {\n for (const compare of chain) {\n const c = compare(a, b);\n if (c !== 0) return c;\n }\n return 0;\n };\n}\n","import type { CommandArgs, CommandResult } from \"./contract.js\";\nimport { refFor } from \"./finding-rows.js\";\nimport type { ModelEdge, ReadModel } from \"./model.js\";\nimport { columnFor } from \"./rollup.js\";\nimport { modelFor } from \"./snapshot-ref.js\";\nimport { invalidArgs, nodeNotFound, type ReadSource } from \"./source.js\";\nimport { treeFor, type Tree } from \"./tree.js\";\n\ntype NeighborsResult = CommandResult<\"node.neighbors\">;\ntype Neighbor = NeighborsResult[\"inbound\"][number];\n\ninterface Adjacency {\n inbound: ReadonlyMap<string, readonly ModelEdge[]>;\n outbound: ReadonlyMap<string, readonly ModelEdge[]>;\n}\n\nconst adjacencies = new WeakMap<ReadModel, Adjacency>();\n\nfunction push(map: Map<string, ModelEdge[]>, key: string, edge: ModelEdge): void {\n const list = map.get(key);\n if (list) list.push(edge);\n else map.set(key, [edge]);\n}\n\n/** Edges by destination and by source, built once per model. */\nexport function adjacencyOf(model: ReadModel): Adjacency {\n let adjacency = adjacencies.get(model);\n if (!adjacency) {\n const inbound = new Map<string, ModelEdge[]>();\n const outbound = new Map<string, ModelEdge[]>();\n for (const edge of model.edges) {\n push(inbound, edge.dstId, edge);\n push(outbound, edge.srcId, edge);\n }\n adjacencies.set(model, (adjacency = { inbound, outbound }));\n }\n return adjacency;\n}\n\nexport const weightOf = (edge: ModelEdge): number | null => (typeof edge.attrs.weight === \"number\" ? edge.attrs.weight : null);\n\nfunction valueOf(model: ReadModel, tree: Tree, id: string, name: string): number | null {\n const node = tree.byId.get(id);\n if (node) return columnFor(model, tree, name).valueOf(node).value;\n return model.metrics.get(name)?.get(id) ?? null;\n}\n\nfunction toNeighbor(model: ReadModel, tree: Tree, edge: ModelEdge, otherId: string, metrics: readonly string[]): Neighbor {\n const neighbor: Neighbor = { node: refFor(model, otherId), kind: edge.kind, weight: weightOf(edge), values: {} };\n if (typeof edge.attrs.specifier === \"string\") neighbor.specifier = edge.attrs.specifier;\n for (const name of metrics) neighbor.values[name] = valueOf(model, tree, otherId, name);\n return neighbor;\n}\n\n// Heaviest first, unweighted last, then by neighbour id and kind, so equal weights page the same way every time.\nfunction compareNeighbors(a: Neighbor, b: Neighbor): number {\n const [x, y] = [a.weight ?? -Infinity, b.weight ?? -Infinity];\n if (x !== y) return y - x;\n if (a.node.id !== b.node.id) return a.node.id < b.node.id ? -1 : 1;\n return a.kind < b.kind ? -1 : a.kind > b.kind ? 1 : 0;\n}\n\ntype EdgeFilter = (edge: ModelEdge) => boolean;\n\n// The design's default: `references` is the symbol layer, noise on a file's list but a symbol's only edges.\nfunction edgeFilter(kinds: readonly string[], nodeKind: string): EdgeFilter {\n if (kinds.length > 0) return (edge) => kinds.includes(edge.kind);\n return nodeKind === \"symbol\" ? () => true : (edge) => edge.kind !== \"references\";\n}\n\ninterface Side {\n rows: Neighbor[];\n total: number;\n}\n\ninterface Paging {\n keep: EdgeFilter;\n build: (edge: ModelEdge, otherId: string) => Neighbor;\n offset: number;\n limit: number;\n}\n\nfunction side(edges: readonly ModelEdge[] | undefined, other: (edge: ModelEdge) => string, p: Paging): Side {\n const all = (edges ?? []).filter(p.keep).map((e) => p.build(e, other(e))).sort(compareNeighbors);\n return { rows: all.slice(p.offset, p.offset + p.limit), total: all.length };\n}\n\n/** `node.neighbors`: a stored node's inbound and outbound edges, each side paged on its own. */\nexport function getNeighbors(source: ReadSource, args: CommandArgs<\"node.neighbors\">): NeighborsResult {\n const model = modelFor(source, args.snapshot);\n const tree = treeFor(model);\n const node = model.nodeById.get(args.id);\n if (!node && tree.byId.has(args.id)) throw invalidArgs(`${args.id} is synthesized; node.neighbors needs a stored node`);\n if (!node) throw nodeNotFound(args.id, model.snapshot.id);\n const { inbound, outbound } = adjacencyOf(model);\n const metrics = [...new Set(args.metrics)];\n const paging: Paging = {\n keep: edgeFilter(args.edge_kinds, node.kind),\n build: (e, id) => toNeighbor(model, tree, e, id, metrics),\n offset: args.offset,\n limit: args.limit,\n };\n const none: Side = { rows: [], total: 0 };\n const ins = args.direction === \"out\" ? none : side(inbound.get(node.id), (e) => e.srcId, paging);\n const outs = args.direction === \"in\" ? none : side(outbound.get(node.id), (e) => e.dstId, paging);\n return {\n snapshotId: model.snapshot.id,\n node: refFor(model, node.id),\n inbound: ins.rows,\n outbound: outs.rows,\n total: { inbound: ins.total, outbound: outs.total },\n };\n}\n","import type { Column } from \"./rollup.js\";\nimport type { Tree, TreeNode } from \"./tree.js\";\n\nexport interface PeerStats {\n /** Share of same-kind nodes in the snapshot whose value is at most this one, 0 to 100. */\n percentile: number | null;\n siblingMedian: number | null;\n /** 1 is the largest value among the siblings; ties share a rank. */\n siblingRank: number | null;\n /** Same-kind siblings with a value, the node included. */\n siblingCount: number;\n}\n\nconst sortedByKind = new WeakMap<Column, Map<string, number[]>>();\n\nfunction valuesOf(column: Column, nodes: Iterable<TreeNode>, kind: string): number[] {\n const out: number[] = [];\n for (const node of nodes) {\n if (node.ref.kind !== kind) continue;\n const { value } = column.valueOf(node);\n if (value !== null) out.push(value);\n }\n return out;\n}\n\nfunction sortedPeers(column: Column, tree: Tree, kind: string): number[] {\n let byKind = sortedByKind.get(column);\n if (!byKind) sortedByKind.set(column, (byKind = new Map()));\n let sorted = byKind.get(kind);\n if (!sorted) byKind.set(kind, (sorted = valuesOf(column, tree.byId.values(), kind).sort((a, b) => a - b)));\n return sorted;\n}\n\n/** Count of sorted values at most `value`, by binary search. */\nfunction countAtMost(sorted: readonly number[], value: number): number {\n let lo = 0;\n let hi = sorted.length;\n while (lo < hi) {\n const mid = (lo + hi) >>> 1;\n if (sorted[mid]! <= value) lo = mid + 1;\n else hi = mid;\n }\n return lo;\n}\n\nfunction median(values: readonly number[]): number | null {\n if (values.length === 0) return null;\n const sorted = [...values].sort((a, b) => a - b);\n const mid = sorted.length >>> 1;\n return sorted.length % 2 === 1 ? sorted[mid]! : (sorted[mid - 1]! + sorted[mid]!) / 2;\n}\n\nconst round1 = (n: number): number => Math.round(n * 10) / 10;\n\n/** Where a node's value sits among every same-kind node and among its same-kind siblings. */\nexport function peerStats(column: Column, tree: Tree, node: TreeNode, value: number | null): PeerStats {\n const parent = node.parentId === null ? undefined : tree.byId.get(node.parentId);\n const siblings = valuesOf(column, parent ? parent.children : [node], node.ref.kind);\n if (value === null) return { percentile: null, siblingMedian: median(siblings), siblingRank: null, siblingCount: siblings.length };\n const peers = sortedPeers(column, tree, node.ref.kind);\n return {\n percentile: peers.length === 0 ? null : round1((100 * countAtMost(peers, value)) / peers.length),\n siblingMedian: median(siblings),\n siblingRank: 1 + siblings.filter((v) => v > value).length,\n siblingCount: siblings.length,\n };\n}\n","import { baselineFields, baselineValue, openBaseline, type Baseline } from \"./baseline.js\";\nimport type { Finding } from \"./contract-findings.js\";\nimport type { CommandArgs, CommandResult } from \"./contract.js\";\nimport { buildExcerpt, type ExcerptResult } from \"./excerpt.js\";\nimport { compareFindings, findingsFor, withStatus } from \"./finding-rows.js\";\nimport type { ModelRule, ReadModel } from \"./model.js\";\nimport { adjacencyOf } from \"./neighbors.js\";\nimport { columnFor } from \"./rollup.js\";\nimport { modelFor } from \"./snapshot-ref.js\";\nimport { findingNotFound, type ReadSource } from \"./source.js\";\nimport { peerStats } from \"./stats.js\";\nimport { treeFor } from \"./tree.js\";\n\ntype GetResult = CommandResult<\"finding.get\">;\n\n/** Findings shown beside the one asked for: the same node's, then the same rule's on graph neighbours. */\nexport const RELATED_CAP = 10;\n\nfunction measure(model: ReadModel, finding: Finding, baseline?: Baseline): GetResult[\"measured\"] {\n const measured: GetResult[\"measured\"] = {\n value: finding.value ?? null,\n threshold: finding.threshold ?? null,\n percentile: null,\n siblingMedian: null,\n };\n const tree = treeFor(model);\n const node = tree.byId.get(finding.node.id);\n const metric = finding.metric;\n if (node && metric !== undefined && model.metrics.has(metric)) {\n const column = columnFor(model, tree, metric);\n const stats = peerStats(column, tree, node, column.valueOf(node).value);\n measured.percentile = stats.percentile;\n measured.siblingMedian = stats.siblingMedian;\n }\n if (baseline && metric !== undefined) measured.baselineValue = baselineValue(baseline, finding.node.id, metric);\n return measured;\n}\n\nfunction neighbourIds(model: ReadModel, id: string): Set<string> {\n const { inbound, outbound } = adjacencyOf(model);\n const ids = new Set<string>();\n for (const e of inbound.get(id) ?? []) if (e.kind !== \"references\") ids.add(e.srcId);\n for (const e of outbound.get(id) ?? []) if (e.kind !== \"references\") ids.add(e.dstId);\n return ids;\n}\n\nfunction relatedTo(model: ReadModel, rows: readonly Finding[], finding: Finding): Finding[] {\n const near = neighbourIds(model, finding.node.id);\n const order = compareFindings(\"severity\", \"desc\");\n const sameNode = rows.filter((f) => f.id !== finding.id && f.node.id === finding.node.id).sort(order);\n const sameRule = rows.filter((f) => f.rule === finding.rule && f.node.id !== finding.node.id && near.has(f.node.id)).sort(order);\n return [...sameNode, ...sameRule].slice(0, RELATED_CAP);\n}\n\nfunction ruleOf(model: ReadModel, finding: Finding): ModelRule {\n return model.rules.find((r) => r.id === finding.rule) ?? { id: finding.rule, type: \"unknown\", severity: finding.severity, text: \"\" };\n}\n\nfunction excerptOf(source: ReadSource, model: ReadModel, finding: Finding, context: number): ExcerptResult {\n if (!source.readSource) return { excerpt: null, missing: \"no-source\" };\n const stored = model.findings.find((f) => f.id === finding.id);\n return buildExcerpt(source.readSource(model.snapshot.id, finding.node.path), stored?.ranges ?? [], context);\n}\n\n/** `finding.get`: one finding with its rule, numbers in context, the flagged source, and related findings. */\nexport function getFinding(source: ReadSource, args: CommandArgs<\"finding.get\">): GetResult {\n const model = modelFor(source, args.snapshot);\n const baseline = openBaseline(source, args.baseline);\n const current = findingsFor(model);\n const rows = baseline ? withStatus(current, findingsFor(baseline.model)).filter((f) => f.status !== \"resolved\") : current;\n const finding = rows.find((f) => f.id === args.id);\n if (!finding) throw findingNotFound(args.id, model.snapshot.id);\n const rule = ruleOf(model, finding);\n const { excerpt, missing } = excerptOf(source, model, finding, args.context_lines);\n const result: GetResult = {\n snapshotId: model.snapshot.id,\n ...baselineFields(model, baseline),\n finding,\n rule,\n measured: measure(model, finding, baseline),\n why: rule.text ? `${rule.text} Here: ${finding.message}.` : finding.message,\n excerpt,\n related: relatedTo(model, rows, finding),\n };\n if (missing !== undefined) result.excerptMissing = missing;\n return result;\n}\n","import { baselineFields, openBaseline } from \"./baseline.js\";\nimport type { Finding } from \"./contract-findings.js\";\nimport type { CommandArgs, CommandResult } from \"./contract.js\";\nimport { compareFindings, findingsFor, withStatus } from \"./finding-rows.js\";\nimport type { NodeRef } from \"./schemas.js\";\nimport { modelFor } from \"./snapshot-ref.js\";\nimport { invalidArgs, nodeNotFound, type ReadSource } from \"./source.js\";\nimport { REPO_ID, directoryId, treeFor, type TreeNode } from \"./tree.js\";\n\ntype ListArgs = CommandArgs<\"findings.list\">;\ntype ListResult = CommandResult<\"findings.list\">;\n\n/** What a scope holds and how its findings split among its children. */\ninterface Scope {\n contains(ref: NodeRef): boolean;\n childOf(ref: NodeRef): string;\n}\n\nfunction childUnder(prefix: string, ref: NodeRef): string {\n if (ref.kind === \"external\" || !ref.path.startsWith(prefix)) return ref.id;\n const rest = ref.path.slice(prefix.length);\n const slash = rest.indexOf(\"/\");\n return slash < 0 ? ref.path : directoryId(prefix + rest.slice(0, slash));\n}\n\n// A symbol's path is its declaring file, so a file scope holds its symbols' findings too.\nfunction scopeOf(node: TreeNode): Scope {\n const { kind, id, path } = node.ref;\n if (kind === \"repo\") return { contains: () => true, childOf: (ref) => childUnder(\"\", ref) };\n if (kind === \"directory\") {\n const prefix = `${path}/`;\n return { contains: (ref) => ref.path.startsWith(prefix), childOf: (ref) => childUnder(prefix, ref) };\n }\n if (kind === \"file\") return { contains: (ref) => ref.path === id, childOf: (ref) => ref.id };\n return { contains: (ref) => ref.id === id || ref.id.startsWith(`${id}.`), childOf: (ref) => ref.id };\n}\n\ntype Filter = (f: Finding) => boolean;\n\nfunction oneOf<T>(allowed: readonly T[], pick: (f: Finding) => T | undefined): Filter {\n if (allowed.length === 0) return () => true;\n const set = new Set(allowed);\n return (f) => {\n const value = pick(f);\n return value !== undefined && set.has(value);\n };\n}\n\nfunction filtersFor(args: ListArgs, scope: Scope): Filter[] {\n return [\n (f) => scope.contains(f.node),\n oneOf(args.rule, (f) => f.rule),\n oneOf(args.severity, (f) => f.severity),\n oneOf(args.tool, (f) => f.tool),\n oneOf(args.provenance, (f) => f.provenance.kind),\n oneOf(args.kind, (f) => f.node.kind),\n oneOf(args.status, (f) => f.status),\n ];\n}\n\nconst FACETS: Record<string, (f: Finding, scope: Scope) => string | undefined> = {\n rule: (f) => f.rule,\n severity: (f) => f.severity,\n tool: (f) => f.tool,\n provenance: (f) => f.provenance.kind,\n kind: (f) => f.node.kind,\n child: (f, scope) => scope.childOf(f.node),\n status: (f) => f.status,\n};\n\nfunction sortedCounts(counts: Map<string, number>): Record<string, number> {\n return Object.fromEntries([...counts].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)));\n}\n\n/** Counts per facet over every kept row, so each facet's counts sum to `total`; `status` only with a baseline. */\nfunction facetCounts(rows: readonly Finding[], scope: Scope, withBaseline: boolean): Record<string, Record<string, number>> {\n const out: Record<string, Record<string, number>> = {};\n for (const [name, pick] of Object.entries(FACETS)) {\n if (name === \"status\" && !withBaseline) continue;\n const counts = new Map<string, number>();\n for (const f of rows) {\n const value = pick(f, scope) ?? \"\";\n counts.set(value, (counts.get(value) ?? 0) + 1);\n }\n out[name] = sortedCounts(counts);\n }\n return out;\n}\n\n/** `findings.list`: a snapshot's findings, filtered, ordered by a total order, and cut to one page. */\nexport function listFindings(source: ReadSource, args: ListArgs): ListResult {\n const model = modelFor(source, args.snapshot);\n const baseline = openBaseline(source, args.baseline);\n if (args.status.length > 0 && !baseline) throw invalidArgs(\"status needs a baseline\");\n const root = treeFor(model).byId.get(args.scope ?? REPO_ID);\n if (!root) throw nodeNotFound(args.scope ?? REPO_ID, model.snapshot.id);\n const scope = scopeOf(root);\n const all = baseline ? withStatus(findingsFor(model), findingsFor(baseline.model)) : findingsFor(model);\n const filters = filtersFor(args, scope);\n const kept = all.filter((f) => filters.every((keep) => keep(f))).sort(compareFindings(args.sort, args.order));\n const result: ListResult = {\n snapshotId: model.snapshot.id,\n ...baselineFields(model, baseline),\n rows: kept.slice(args.offset, args.offset + args.limit),\n total: kept.length,\n };\n if (args.facets) result.facets = facetCounts(kept, scope, baseline !== undefined);\n return result;\n}\n","import { HIERARCHY_ROW_CAP } from \"./contract-nodes.js\";\nimport type { CommandArgs, CommandResult } from \"./contract.js\";\nimport { baselineFields, baselineValue, delta, openBaseline, type Baseline } from \"./baseline.js\";\nimport { columnFor, type Column } from \"./rollup.js\";\nimport { modelFor } from \"./snapshot-ref.js\";\nimport { nodeNotFound, type ReadSource } from \"./source.js\";\nimport { REPO_ID, treeFor, type TreeNode } from \"./tree.js\";\n\ntype HierarchyResult = CommandResult<\"hierarchy.get\">;\ntype HierarchyRow = HierarchyResult[\"nodes\"][number];\n\n/** Breadth-first to `depth`, so a truncated answer keeps the levels a treemap draws first. */\nfunction collectRows(root: TreeNode, depth: number, includeSymbols: boolean): { rows: TreeNode[]; truncated: boolean } {\n const rows: TreeNode[] = [];\n const queue: TreeNode[] = [root];\n for (let i = 0; i < queue.length; i++) {\n const node = queue[i]!;\n if (rows.length === HIERARCHY_ROW_CAP) return { rows, truncated: true };\n rows.push(node);\n if (node.depth - root.depth >= depth) continue;\n for (const child of node.children) if (includeSymbols || child.ref.kind !== \"symbol\") queue.push(child);\n }\n return { rows, truncated: false };\n}\n\nfunction toRow(node: TreeNode, rootDepth: number, columns: readonly Column[], names: readonly string[], baseline?: Baseline): HierarchyRow {\n const row: HierarchyRow = { ...node.ref, parentId: node.parentId, depth: node.depth - rootDepth, childCount: node.children.length, values: {} };\n if (node.stored?.role !== undefined) row.role = node.stored.role;\n const missing: Record<string, string> = {};\n const deltas: Record<string, number | null> = {};\n names.forEach((name, i) => {\n const { value, missing: reason } = columns[i]!.valueOf(node);\n row.values[name] = value;\n if (reason) missing[name] = reason;\n if (!baseline) return;\n deltas[name] = delta(value, baselineValue(baseline, node.ref.id, name));\n });\n if (Object.keys(missing).length > 0) row.missing = missing;\n if (baseline) row.deltas = deltas;\n return row;\n}\n\n/** `hierarchy.get`: a flat, shallowest-first slice of the synthesized tree with per-row metric values. */\nexport function getHierarchy(source: ReadSource, args: CommandArgs<\"hierarchy.get\">): HierarchyResult {\n const model = modelFor(source, args.snapshot);\n const tree = treeFor(model, args.exclude_roles);\n const root = tree.byId.get(args.root ?? REPO_ID);\n if (!root) throw nodeNotFound(args.root ?? REPO_ID, model.snapshot.id);\n const baseline = openBaseline(source, args.baseline, args.exclude_roles);\n const names = [...new Set(args.metrics)];\n const columns = names.map((name) => columnFor(model, tree, name));\n const { rows, truncated } = collectRows(root, args.depth, args.include_symbols);\n const nodes = rows.map((node) => toRow(node, root.depth, columns, names, baseline));\n return { snapshotId: model.snapshot.id, ...baselineFields(model, baseline), nodes, truncated };\n}\n","import type { CommandArgs, CommandResult } from \"./contract.js\";\nimport { baselineFields, baselineValue, delta, openBaseline, type Baseline } from \"./baseline.js\";\nimport type { ReadModel } from \"./model.js\";\nimport { columnFor, describesKind } from \"./rollup.js\";\nimport type { NodeRef } from \"./schemas.js\";\nimport { modelFor } from \"./snapshot-ref.js\";\nimport { nodeNotFound, type ReadSource } from \"./source.js\";\nimport { peerStats } from \"./stats.js\";\nimport { treeFor, type Tree, type TreeNode } from \"./tree.js\";\n\ntype NodeGetResult = CommandResult<\"node.get\">;\ntype NodeMetric = NodeGetResult[\"metrics\"][number];\n\nfunction ancestorsOf(tree: Tree, node: TreeNode): NodeRef[] {\n const chain: NodeRef[] = [];\n for (let id = node.parentId; id !== null; ) {\n const parent = tree.byId.get(id)!;\n chain.push(parent.ref);\n id = parent.parentId;\n }\n return chain.reverse();\n}\n\nfunction childCounts(node: TreeNode): Record<string, number> {\n const counts: Record<string, number> = {};\n for (const child of node.children) counts[child.ref.kind] = (counts[child.ref.kind] ?? 0) + 1;\n return counts;\n}\n\nfunction describeNode(node: TreeNode): NodeGetResult[\"node\"] {\n const out: NodeGetResult[\"node\"] = { ...node.ref };\n const stored = node.stored;\n if (!stored) return out;\n if (stored.language !== undefined) out.language = stored.language;\n if (stored.role !== undefined) out.role = stored.role;\n const { exported, signature, purpose } = stored.attrs;\n if (typeof exported === \"boolean\") out.exported = exported;\n if (typeof signature === \"string\") out.signature = signature;\n if (typeof purpose === \"string\") out.purpose = purpose;\n return out;\n}\n\nfunction metricNames(model: ReadModel, kind: string, requested: readonly string[]): string[] {\n if (requested.length > 0) return [...new Set(requested)];\n return model.metricCatalogue.filter((d) => describesKind(d, kind)).map((d) => d.name);\n}\n\nfunction measure(model: ReadModel, tree: Tree, node: TreeNode, name: string, baseline?: Baseline): NodeMetric {\n const column = columnFor(model, tree, name);\n const { value, missing } = column.valueOf(node);\n const d = column.descriptor;\n const metric: NodeMetric = {\n name,\n unit: d?.unit ?? null,\n direction: d?.direction ?? \"neutral\",\n rollup: d?.rollup ?? \"none\",\n value,\n ...(missing ? { missing } : {}),\n ...peerStats(column, tree, node, value),\n };\n if (!baseline) return metric;\n metric.baseline = baselineValue(baseline, node.ref.id, name);\n metric.delta = delta(value, metric.baseline);\n return metric;\n}\n\n/** `node.get`: one node of the synthesized hierarchy with its numbers in context. */\nexport function getNode(source: ReadSource, args: CommandArgs<\"node.get\">): NodeGetResult {\n const model = modelFor(source, args.snapshot);\n const tree = treeFor(model);\n const node = tree.byId.get(args.id);\n if (!node) throw nodeNotFound(args.id, model.snapshot.id);\n const baseline = openBaseline(source, args.baseline);\n return {\n snapshotId: model.snapshot.id,\n ...baselineFields(model, baseline),\n node: describeNode(node),\n ancestors: ancestorsOf(tree, node),\n childCounts: childCounts(node),\n metrics: metricNames(model, node.ref.kind, args.metrics).map((name) => measure(model, tree, node, name, baseline)),\n };\n}\n","import type { CommandArgs, CommandResult } from \"./contract.js\";\nimport { modelFor } from \"./snapshot-ref.js\";\nimport { invalidArgs, type ReadSource } from \"./source.js\";\nimport { treeFor, type Tree, type TreeNode } from \"./tree.js\";\n\ntype Candidate = CommandResult<\"node.resolve\">[\"candidates\"][number];\ntype Scored = { score: number; match: string };\n\nconst SEARCHED_KINDS = new Set([\"directory\", \"file\", \"symbol\"]);\nconst PATH_LINE = /^([^#]+):(\\d+)$/;\n\n// Ported from codewatch packages/cli/src/read-api/search.ts (rankSearch): exact, suffix, prefix, then substring.\nfunction scoreNode(node: TreeNode, q: string): Scored | null {\n const id = (node.ref.kind === \"directory\" ? node.ref.path : node.ref.id).toLowerCase();\n const name = node.ref.name.toLowerCase();\n if (id === q || name === q) return { score: 100, match: \"exact\" };\n if (id.endsWith(`/${q}`) || id.endsWith(`#${q}`)) return { score: 80, match: \"suffix\" };\n // Since TP-182 a method's name is `Class.method`, so its bare name is a suffix of the qualified one.\n if (node.ref.kind === \"symbol\" && name.endsWith(`.${q}`)) return { score: 80, match: \"suffix\" };\n if (name.startsWith(q)) return { score: 60, match: \"prefix\" };\n if (id.includes(q)) return { score: 40, match: \"substring\" };\n if (name.includes(q)) return { score: 30, match: \"substring\" };\n return null;\n}\n\nfunction normalize(query: string): string {\n const q = query.toLowerCase();\n return q.length > 1 && q.endsWith(\"/\") ? q.slice(0, -1) : q;\n}\n\nfunction rank(tree: Tree, query: string, kinds: ReadonlySet<string>): Candidate[] {\n const q = normalize(query);\n const hits: Candidate[] = [];\n for (const node of tree.byId.values()) {\n if (!kinds.has(node.ref.kind)) continue;\n const scored = scoreNode(node, q);\n if (scored) hits.push({ node: node.ref, ...scored });\n }\n return hits.sort((a, b) => b.score - a.score || (a.node.id < b.node.id ? -1 : a.node.id > b.node.id ? 1 : 0));\n}\n\n// Ported from codewatch packages/graph/src/coverage.ts (innermostContaining): the smallest span holding the line.\nfunction innermostContaining(file: TreeNode, line: number): TreeNode | null {\n let best: TreeNode | null = null;\n const visit = (node: TreeNode): void => {\n for (const child of node.children) {\n const span = child.ref.span;\n if (span && span.startLine <= line && line <= span.endLine) {\n const bestSpan = best?.ref.span;\n if (!bestSpan || span.endLine - span.startLine < bestSpan.endLine - bestSpan.startLine) best = child;\n }\n visit(child);\n }\n };\n visit(file);\n return best;\n}\n\nfunction resolvePath(tree: Tree, path: string, line: number | undefined): Candidate[] {\n const files = rank(tree, path, new Set([\"file\"]));\n if (line === undefined) return files;\n return files.map((hit) => {\n const symbol = innermostContaining(tree.byId.get(hit.node.id)!, line);\n return symbol ? { node: symbol.ref, score: hit.score, match: \"span\" } : hit;\n });\n}\n\nfunction pathAndLine(args: CommandArgs<\"node.resolve\">): { path: string; line: number | undefined } | null {\n if (args.path !== undefined) return { path: args.path, line: args.line };\n const m = PATH_LINE.exec(args.query!);\n return m ? { path: m[1]!, line: Number(m[2]) } : null;\n}\n\n/** `node.resolve`: a path, path:line, symbol name, or qualified id to ranked candidate nodes. */\nexport function resolveNode(source: ReadSource, args: CommandArgs<\"node.resolve\">): CommandResult<\"node.resolve\"> {\n if ((args.query === undefined) === (args.path === undefined)) throw invalidArgs(\"pass exactly one of query or path\");\n if (args.line !== undefined && args.path === undefined) throw invalidArgs(\"line needs path\");\n const tree = treeFor(modelFor(source, args.snapshot));\n const located = pathAndLine(args);\n const candidates = located ? resolvePath(tree, located.path, located.line) : rank(tree, args.query!, SEARCHED_KINDS);\n return { candidates: candidates.slice(0, args.limit) };\n}\n","import { CODE_READ_API_VERSION, type CommandArgs, type CommandName, type CommandResult } from \"./contract.js\";\nimport { getFinding } from \"./finding-get.js\";\nimport { listFindings } from \"./findings-list.js\";\nimport { getHierarchy } from \"./hierarchy.js\";\nimport { getNeighbors } from \"./neighbors.js\";\nimport { getNode } from \"./node-get.js\";\nimport { resolveNode } from \"./resolve.js\";\nimport type { ReadSource } from \"./source.js\";\n\nexport type QueryFn<N extends CommandName> = (source: ReadSource, args: CommandArgs<N>) => CommandResult<N>;\n\nexport function describeApi(source: ReadSource): CommandResult<\"api.describe\"> {\n const facts = source.facts();\n const snapshots = source.snapshots();\n const newest = snapshots[0] ?? null;\n return {\n api: CODE_READ_API_VERSION,\n dataset: facts.dataset,\n commands: [...facts.commands],\n newest,\n indexVersions: [...new Set(snapshots.map((s) => s.indexVersion))],\n capabilities: facts.capabilities,\n metrics: newest ? [...source.model(newest.id).metricCatalogue] : [],\n rules: [...facts.rules],\n };\n}\n\nexport function listSnapshots(source: ReadSource, args: CommandArgs<\"snapshot.list\">): CommandResult<\"snapshot.list\"> {\n const matching = source.snapshots().filter((s) => args.ref === undefined || s.ref === args.ref);\n return { snapshots: matching.slice(0, args.limit) };\n}\n\n/** One pure function per command; the registry commands and the static resolver both dispatch here. */\nexport const QUERIES: { [N in CommandName]: QueryFn<N> } = {\n \"api.describe\": describeApi,\n \"snapshot.list\": listSnapshots,\n \"hierarchy.get\": getHierarchy,\n \"node.get\": getNode,\n \"node.resolve\": resolveNode,\n \"findings.list\": listFindings,\n \"finding.get\": getFinding,\n \"node.neighbors\": getNeighbors,\n};\n","import { EXIT, errorEnvelope, successEnvelope, type JsonEnvelope } from \"@titan-design/rpc-protocol\";\nimport type { z } from \"zod\";\nimport { QUERIES, type QueryFn } from \"./commands.js\";\nimport { CONTRACT, type CommandName } from \"./contract.js\";\nimport type { ReadSource } from \"./source.js\";\n\n/** rpc-client's static `resolve` option: raw args in, an envelope out, never a throw. */\nexport type QueryResolver = (name: string, args: unknown) => JsonEnvelope<unknown>;\n\nfunction isCommandName(name: string): name is CommandName {\n return Object.hasOwn(CONTRACT, name);\n}\n\n// Same wording as the registry's invokeCommand, so a static answer reads like a live one.\nfunction formatIssues(error: z.ZodError): string {\n return error.issues.map((issue) => `${issue.path.join(\".\") || \"(root)\"}: ${issue.message}`).join(\"; \");\n}\n\nfunction describeFailure(err: unknown): { message: string; code: number } {\n const code = (err as { code?: unknown } | null)?.code;\n const message = err instanceof Error ? err.message : String(err);\n return { message, code: typeof code === \"number\" ? code : EXIT.GENERIC };\n}\n\n/** Validate, run, and envelope one command against a source, exactly as the daemon's registry does. */\nexport function createQueryResolver(source: ReadSource): QueryResolver {\n return (name, rawArgs) => {\n if (!isCommandName(name)) return errorEnvelope(`Unknown command: ${name}`, EXIT.USAGE);\n if (!source.facts().commands.includes(name)) {\n return errorEnvelope(`${name} is not available from a ${source.facts().dataset} dataset`, EXIT.UNAVAILABLE);\n }\n const parsed = CONTRACT[name].args.safeParse(rawArgs ?? {});\n if (!parsed.success) return errorEnvelope(`Invalid arguments: ${formatIssues(parsed.error)}`, EXIT.DATAERR);\n try {\n const query = QUERIES[name] as QueryFn<CommandName>;\n return successEnvelope(query(source, parsed.data as never));\n } catch (err) {\n const { message, code } = describeFailure(err);\n return errorEnvelope(message, code);\n }\n };\n}\n"],"mappings":";AAAA,SAAS,cAAc,KAAAA,UAAuB;;;ACA9C,SAAS,SAAS;AAGX,IAAM,WAAW,EAAE,OAAO;AAG1B,IAAM,WAAW,EAAE,OAAO;AAE1B,IAAM,iBAAiB,EAAE,KAA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