@neat.is/types 0.3.8 → 0.4.2

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/dist/index.cjs CHANGED
@@ -31,6 +31,7 @@ __export(index_exports, {
31
31
  CompatibleDriverSchema: () => CompatibleDriverSchema,
32
32
  ConfigNodeSchema: () => ConfigNodeSchema,
33
33
  DEFAULT_EXTRACTED_PRECISION_FLOOR: () => DEFAULT_EXTRACTED_PRECISION_FLOOR,
34
+ DaemonHealthResponseSchema: () => DaemonHealthResponseSchema,
34
35
  DatabaseNodeSchema: () => DatabaseNodeSchema,
35
36
  DiscoveredViaSchema: () => DiscoveredViaSchema,
36
37
  DivergenceResultSchema: () => DivergenceResultSchema,
@@ -152,6 +153,18 @@ var ServiceNodeSchema = import_zod2.z.object({
152
153
  type: import_zod2.z.literal(NodeType.ServiceNode),
153
154
  name: import_zod2.z.string(),
154
155
  language: import_zod2.z.string(),
156
+ // Deployment environment from the OTel `deployment.environment.name` attr
157
+ // (with `deployment.environment` and resource-attr fallbacks). The literal
158
+ // `'unknown'` is the honest sentinel when no env signal is present; static
159
+ // extraction never sees env at extract time, so its ServiceNodes carry
160
+ // `undefined` here and the id stays in the env-less wire format
161
+ // `service:<name>`. See ADR-074 §2 and docs/contracts/env-dimension.md.
162
+ env: import_zod2.z.string().optional(),
163
+ // Framework recorded by the static extractor when the install plan
164
+ // dispatches a framework-specific path (Next.js, Remix, SvelteKit, Nuxt,
165
+ // Astro). Optional enrichment — `undefined` for lib-only packages and
166
+ // ambiguous repos. See ADR-074 §3 / docs/contracts/framework-installers.md.
167
+ framework: import_zod2.z.string().optional(),
155
168
  discoveredVia: DiscoveredViaSchema.optional(),
156
169
  version: import_zod2.z.string().optional(),
157
170
  dbConnectionTarget: import_zod2.z.string().optional(),
@@ -382,11 +395,18 @@ var DATABASE_PREFIX = "database:";
382
395
  var CONFIG_PREFIX = "config:";
383
396
  var INFRA_PREFIX = "infra:";
384
397
  var FRONTIER_PREFIX = "frontier:";
385
- function serviceId(name) {
386
- return `${SERVICE_PREFIX}${name}`;
398
+ var ENV_UNKNOWN = "unknown";
399
+ function serviceId(name, env) {
400
+ if (env === void 0 || env === ENV_UNKNOWN) return `${SERVICE_PREFIX}${name}`;
401
+ return `${SERVICE_PREFIX}${name}:${env}`;
387
402
  }
388
403
  function parseServiceId(id) {
389
- return id.startsWith(SERVICE_PREFIX) ? id.slice(SERVICE_PREFIX.length) : null;
404
+ if (!id.startsWith(SERVICE_PREFIX)) return null;
405
+ const rest = id.slice(SERVICE_PREFIX.length);
406
+ if (rest.length === 0) return null;
407
+ const colon = rest.indexOf(":");
408
+ if (colon === -1) return { name: rest, env: ENV_UNKNOWN };
409
+ return { name: rest.slice(0, colon), env: rest.slice(colon + 1) };
390
410
  }
391
411
  function databaseId(host) {
392
412
  return `${DATABASE_PREFIX}${host}`;
@@ -702,6 +722,17 @@ var HealthResponseSchema = import_zod9.z.object({
702
722
  project: import_zod9.z.string(),
703
723
  uptimeMs: import_zod9.z.number().int().nonnegative()
704
724
  }).passthrough();
725
+ var DaemonHealthResponseSchema = import_zod9.z.object({
726
+ ok: import_zod9.z.boolean(),
727
+ uptimeMs: import_zod9.z.number().int().nonnegative(),
728
+ projects: import_zod9.z.array(
729
+ import_zod9.z.object({
730
+ name: import_zod9.z.string(),
731
+ nodeCount: import_zod9.z.number().int().nonnegative(),
732
+ edgeCount: import_zod9.z.number().int().nonnegative()
733
+ }).passthrough()
734
+ )
735
+ }).passthrough();
705
736
  var SingleProjectResponseSchema = import_zod9.z.object({
706
737
  project: RegistryEntrySchema
707
738
  });
@@ -811,6 +842,7 @@ function passesExtractedFloor(confidence) {
811
842
  CompatibleDriverSchema,
812
843
  ConfigNodeSchema,
813
844
  DEFAULT_EXTRACTED_PRECISION_FLOOR,
845
+ DaemonHealthResponseSchema,
814
846
  DatabaseNodeSchema,
815
847
  DiscoveredViaSchema,
816
848
  DivergenceResultSchema,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/constants.ts","../src/nodes.ts","../src/edges.ts","../src/events.ts","../src/results.ts","../src/identity.ts","../src/policy.ts","../src/registry.ts","../src/divergence.ts","../src/responses.ts","../src/confidence.ts"],"sourcesContent":["export * from './constants.js'\nexport * from './nodes.js'\nexport * from './edges.js'\nexport * from './events.js'\nexport * from './results.js'\nexport * from './identity.js'\nexport * from './policy.js'\nexport * from './registry.js'\nexport * from './divergence.js'\nexport * from './responses.js'\nexport * from './confidence.js'\n","export const Provenance = {\n EXTRACTED: 'EXTRACTED',\n INFERRED: 'INFERRED',\n OBSERVED: 'OBSERVED',\n STALE: 'STALE',\n} as const\n\nexport type ProvenanceValue = (typeof Provenance)[keyof typeof Provenance]\n\nexport const EdgeType = {\n CALLS: 'CALLS',\n DEPENDS_ON: 'DEPENDS_ON',\n CONNECTS_TO: 'CONNECTS_TO',\n CONFIGURED_BY: 'CONFIGURED_BY',\n PUBLISHES_TO: 'PUBLISHES_TO',\n CONSUMES_FROM: 'CONSUMES_FROM',\n RUNS_ON: 'RUNS_ON',\n} as const\n\nexport type EdgeTypeValue = (typeof EdgeType)[keyof typeof EdgeType]\n\nexport const NodeType = {\n ServiceNode: 'ServiceNode',\n DatabaseNode: 'DatabaseNode',\n ConfigNode: 'ConfigNode',\n InfraNode: 'InfraNode',\n FrontierNode: 'FrontierNode',\n} as const\n\nexport type NodeTypeValue = (typeof NodeType)[keyof typeof NodeType]\n\nimport { z } from 'zod'\n\n// Zod-side mirror of NodeType, exported for schemas that need to discriminate\n// or filter by node type at parse time (policy rules, traversal results, etc.).\n// Adding a new node type means adding it to NodeType above and to this enum.\nexport const NodeTypeSchema = z.enum([\n NodeType.ServiceNode,\n NodeType.DatabaseNode,\n NodeType.ConfigNode,\n NodeType.InfraNode,\n NodeType.FrontierNode,\n])\n","import { z } from 'zod'\nimport { NodeType } from './constants.js'\n\nexport const CompatibleDriverSchema = z.object({\n name: z.string(),\n minVersion: z.string(),\n})\nexport type CompatibleDriver = z.infer<typeof CompatibleDriverSchema>\n\n// How NEAT first learned of a node. Static-extraction fills in the rich\n// fields (language, version, dependencies); OTel ingest can also create a\n// minimal node when it sees a span for an unknown peer. When both layers\n// recorded the same node, the value is 'merged'. ADR-031 schema growth.\nexport const DiscoveredViaSchema = z.enum(['static', 'otel', 'merged'])\nexport type DiscoveredVia = z.infer<typeof DiscoveredViaSchema>\n\nexport const ServiceNodeSchema = z.object({\n id: z.string(),\n type: z.literal(NodeType.ServiceNode),\n name: z.string(),\n language: z.string(),\n discoveredVia: DiscoveredViaSchema.optional(),\n version: z.string().optional(),\n dbConnectionTarget: z.string().optional(),\n repoPath: z.string().optional(),\n owner: z.string().optional(),\n dependencies: z.record(z.string(), z.string()).optional(),\n // Hostnames OTel spans might mention for this service: compose service\n // names, k8s metadata.name (and the cluster-DNS variants), Dockerfile\n // labels, etc. resolveServiceId in ingest.ts checks these before falling\n // back to a FRONTIER placeholder.\n aliases: z.array(z.string()).optional(),\n // Optional. If set, services declare their `engines.node` here so γ #74's\n // node-engine compat check has something to test against.\n nodeEngine: z.string().optional(),\n incompatibilities: z\n .array(\n // Discriminated by `kind`. `driver-engine` is the original shape and\n // stays default for backward compatibility — older snapshots without a\n // `kind` field still parse via the union's `.optional()` discriminator\n // fallback. New kinds came in with γ #74.\n z.union([\n z.object({\n kind: z.literal('driver-engine').optional(),\n driver: z.string(),\n driverVersion: z.string(),\n engine: z.string(),\n engineVersion: z.string(),\n reason: z.string(),\n }),\n z.object({\n kind: z.literal('node-engine'),\n package: z.string(),\n packageVersion: z.string().optional(),\n requiredNodeVersion: z.string(),\n declaredNodeEngine: z.string().optional(),\n reason: z.string(),\n }),\n z.object({\n kind: z.literal('package-conflict'),\n package: z.string(),\n packageVersion: z.string().optional(),\n requires: z.object({\n name: z.string(),\n minVersion: z.string(),\n }),\n foundVersion: z.string().optional(),\n reason: z.string(),\n }),\n z.object({\n kind: z.literal('deprecated-api'),\n package: z.string(),\n packageVersion: z.string().optional(),\n reason: z.string(),\n }),\n ]),\n )\n .optional(),\n})\nexport type ServiceNode = z.infer<typeof ServiceNodeSchema>\n\nexport const DatabaseNodeSchema = z.object({\n id: z.string(),\n type: z.literal(NodeType.DatabaseNode),\n name: z.string(),\n engine: z.string(),\n engineVersion: z.string(),\n compatibleDrivers: z.array(CompatibleDriverSchema),\n host: z.string().optional(),\n port: z.number().optional(),\n discoveredVia: DiscoveredViaSchema.optional(),\n})\nexport type DatabaseNode = z.infer<typeof DatabaseNodeSchema>\n\nexport const ConfigNodeSchema = z.object({\n id: z.string(),\n type: z.literal(NodeType.ConfigNode),\n name: z.string(),\n path: z.string(),\n fileType: z.string(),\n})\nexport type ConfigNode = z.infer<typeof ConfigNodeSchema>\n\nexport const InfraNodeSchema = z.object({\n id: z.string(),\n type: z.literal(NodeType.InfraNode),\n name: z.string(),\n provider: z.string(),\n region: z.string().optional(),\n kind: z.string().optional(),\n})\nexport type InfraNode = z.infer<typeof InfraNodeSchema>\n\n// Placeholder for a span peer the ingest layer couldn't resolve to a known\n// ServiceNode. Lives at id `frontier:<host>` and gets replaced by the real\n// service once a later extraction round records that host as an alias.\nexport const FrontierNodeSchema = z.object({\n id: z.string(),\n type: z.literal(NodeType.FrontierNode),\n name: z.string(),\n host: z.string(),\n firstObserved: z.string().datetime().optional(),\n lastObserved: z.string().datetime().optional(),\n})\nexport type FrontierNode = z.infer<typeof FrontierNodeSchema>\n\nexport const GraphNodeSchema = z.discriminatedUnion('type', [\n ServiceNodeSchema,\n DatabaseNodeSchema,\n ConfigNodeSchema,\n InfraNodeSchema,\n FrontierNodeSchema,\n])\nexport type GraphNode = z.infer<typeof GraphNodeSchema>\n","import { z } from 'zod'\nimport { EdgeType, Provenance } from './constants.js'\n\nexport const ProvenanceSchema = z.enum([\n Provenance.EXTRACTED,\n Provenance.INFERRED,\n Provenance.OBSERVED,\n Provenance.STALE,\n])\n\nexport const EdgeTypeSchema = z.enum([\n EdgeType.CALLS,\n EdgeType.DEPENDS_ON,\n EdgeType.CONNECTS_TO,\n EdgeType.CONFIGURED_BY,\n EdgeType.PUBLISHES_TO,\n EdgeType.CONSUMES_FROM,\n EdgeType.RUNS_ON,\n])\n\n// Static-extraction evidence for an EXTRACTED edge (ADR-029, contract #5).\n// `file` is required — retire.ts keys ghost-edge cleanup off it. `line` and\n// `snippet` are optional because the existing extractors (configs.ts,\n// docker-compose.ts) record file-level evidence only; loosening lets those\n// edges through ADR-061's response-shape validation without forcing the\n// extractors to fabricate line numbers.\nexport const EdgeEvidenceSchema = z.object({\n file: z.string(),\n line: z.number().int().nonnegative().optional(),\n snippet: z.string().optional(),\n})\nexport type EdgeEvidence = z.infer<typeof EdgeEvidenceSchema>\n\n// Runtime signal for per-edge confidence (γ #76). Populated by ingest. Three\n// continuous numbers stand in for the previous coarse 0.3/0.5/0.7/1.0 ladder:\n// how much traffic, how clean, and how recent.\nexport const EdgeSignalSchema = z.object({\n spanCount: z.number().int().nonnegative(),\n errorCount: z.number().int().nonnegative(),\n lastObservedAgeMs: z.number().nonnegative().optional(),\n})\nexport type EdgeSignal = z.infer<typeof EdgeSignalSchema>\n\n// `confidence` is in [0, 1] and graded per provenance tier (ADR-066). Producers\n// write it on every EXTRACTED and OBSERVED edge via the helpers in\n// confidence.ts; flat coarse values (the old `0.5` / `1.0` shape) are a\n// contract violation. The field stays `.optional()` for snapshot back-compat —\n// older snapshots may carry edges without confidence and persist.ts loads them\n// on the documented growth path (ADR-031).\nexport const GraphEdgeSchema = z.object({\n id: z.string(),\n source: z.string(),\n target: z.string(),\n type: EdgeTypeSchema,\n provenance: ProvenanceSchema,\n confidence: z.number().min(0).max(1).optional(),\n lastObserved: z.string().datetime().optional(),\n callCount: z.number().int().nonnegative().optional(),\n evidence: EdgeEvidenceSchema.optional(),\n signal: EdgeSignalSchema.optional(),\n})\nexport type GraphEdge = z.infer<typeof GraphEdgeSchema>\n","import { z } from 'zod'\n\n// Passthrough of OTel span attributes. Records source-attribution\n// (`code.filepath`, `code.lineno`, `code.function`), HTTP context\n// (`http.method`, `http.target`, `http.status_code`), DB context\n// (`db.system`, `db.statement`), and any other span attribute the SDK\n// emitted. Consumers (incident UI, MCP getRootCause) filter what they\n// surface. Schema growth per ADR-031 — optional, additive only.\nexport const SpanAttributesSchema = z.record(\n z.string(),\n z.union([z.string(), z.number(), z.boolean(), z.null(), z.array(z.string()), z.array(z.number()), z.array(z.boolean())]),\n)\nexport type SpanAttributes = z.infer<typeof SpanAttributesSchema>\n\nexport const ErrorEventSchema = z.object({\n id: z.string(),\n timestamp: z.string().datetime(),\n service: z.string(),\n traceId: z.string(),\n spanId: z.string(),\n errorType: z.string().optional(),\n errorMessage: z.string(),\n // OTLP span events with name=\"exception\" carry richer error data than\n // status.message. When present, these fields capture the exception type\n // and stacktrace from the SDK that recorded the error. ADR-031 schema\n // growth — added without a shape change because both fields are optional.\n exceptionType: z.string().optional(),\n exceptionStacktrace: z.string().optional(),\n // Span attributes passthrough (ADR-068 follow-up). Surfaces `code.*`\n // semconv attributes for source attribution, plus the rest of the\n // attribute set for downstream filtering.\n attributes: SpanAttributesSchema.optional(),\n affectedNode: z.string(),\n})\nexport type ErrorEvent = z.infer<typeof ErrorEventSchema>\n\n// Appended one-per-line to stale-events.ndjson whenever ingest.ts demotes\n// an OBSERVED edge to STALE (per-edge-type thresholds, ADR-024). Surfaces\n// on GET /stale-events for incident triage.\nexport const StaleEventSchema = z.object({\n edgeId: z.string(),\n source: z.string(),\n target: z.string(),\n edgeType: z.string(),\n thresholdMs: z.number().nonnegative(),\n ageMs: z.number().nonnegative(),\n lastObserved: z.string(),\n transitionedAt: z.string(),\n})\nexport type StaleEvent = z.infer<typeof StaleEventSchema>\n","import { z } from 'zod'\nimport { ProvenanceSchema, EdgeTypeSchema } from './edges.js'\n\nexport const RootCauseResultSchema = z.object({\n rootCauseNode: z.string(),\n rootCauseReason: z.string(),\n traversalPath: z.array(z.string()),\n edgeProvenances: z.array(ProvenanceSchema),\n confidence: z.number().min(0).max(1),\n fixRecommendation: z.string().optional(),\n})\nexport type RootCauseResult = z.infer<typeof RootCauseResultSchema>\n\nexport const BlastRadiusAffectedNodeSchema = z.object({\n nodeId: z.string(),\n // Distance from the origin in BFS hops. The origin itself is never in\n // affectedNodes, so distance 0 has no meaning — the BFS at traverse.ts\n // already skips frame 0. Tightening to positive() locks that invariant\n // mechanically (ADR-038, issue #138).\n distance: z.number().int().positive(),\n edgeProvenance: ProvenanceSchema,\n // path: origin → ... → nodeId. Length === distance + 1. Surfaced from the\n // BFS predecessor chain so consumers don't have to reconstruct it from\n // distance + the graph (ADR-038, issue #137).\n path: z.array(z.string()).min(2),\n // confidence: confidenceFromMix(...edgesAlongPath). Multiplicative cascade —\n // each hop is independent evidence and uncertainty compounds. ADR-036.\n confidence: z.number().min(0).max(1),\n})\nexport type BlastRadiusAffectedNode = z.infer<typeof BlastRadiusAffectedNodeSchema>\n\nexport const BlastRadiusResultSchema = z.object({\n origin: z.string(),\n affectedNodes: z.array(BlastRadiusAffectedNodeSchema),\n totalAffected: z.number().int().nonnegative(),\n})\nexport type BlastRadiusResult = z.infer<typeof BlastRadiusResultSchema>\n\n// Transitive get_dependencies (issue #144). Flat list with distance, edge\n// type, and provenance per dependency. Sibling shape to BlastRadius but\n// thinner — no path tracking, no confidence cascade. Use cases live in the\n// MCP get_dependencies tool (\"what does X depend on, transitively?\").\nexport const TransitiveDependencySchema = z.object({\n nodeId: z.string(),\n // Distance from the origin in BFS hops. The origin itself is never in\n // dependencies, so distance is positive (>= 1).\n distance: z.number().int().positive(),\n // Type of the edge that brought traversal to this node (CALLS,\n // CONNECTS_TO, DEPENDS_ON, etc.).\n edgeType: EdgeTypeSchema,\n // Provenance of that edge.\n provenance: ProvenanceSchema,\n})\nexport type TransitiveDependency = z.infer<typeof TransitiveDependencySchema>\n\nexport const TransitiveDependenciesResultSchema = z.object({\n origin: z.string(),\n depth: z.number().int().positive(),\n dependencies: z.array(TransitiveDependencySchema),\n total: z.number().int().nonnegative(),\n})\nexport type TransitiveDependenciesResult = z.infer<typeof TransitiveDependenciesResultSchema>\n","// Identity helpers — the single source of truth for node and edge id wire\n// format. See ADR-028 (nodes), ADR-029 (edges), and docs/contracts/identity.md\n// + docs/contracts/provenance.md.\n//\n// Producers construct ids via these helpers; consumers parse via the inverses.\n// Hand-rolled template literals like `service:${name}` or\n// `${type}:OBSERVED:${source}->${target}` are contract violations\n// (caught by packages/core/test/audits/contracts.test.ts).\n\nconst SERVICE_PREFIX = 'service:'\nconst DATABASE_PREFIX = 'database:'\nconst CONFIG_PREFIX = 'config:'\nconst INFRA_PREFIX = 'infra:'\nconst FRONTIER_PREFIX = 'frontier:'\n\n// ServiceNode id: `service:<name>` where <name> is the manifest name verbatim\n// (package.json#name for JS/TS, pyproject [project].name for Python). Names\n// with slashes (e.g. scoped npm packages `@org/foo`) are kept as-is — no\n// transformation. See ADR-028 §5 for workspace-collision deferral.\nexport function serviceId(name: string): string {\n return `${SERVICE_PREFIX}${name}`\n}\n\nexport function parseServiceId(id: string): string | null {\n return id.startsWith(SERVICE_PREFIX) ? id.slice(SERVICE_PREFIX.length) : null\n}\n\n// DatabaseNode id: `database:<host>`. Port is intentionally excluded; two DBs\n// on the same host different ports collide. See ADR-028 §6 for deferral.\nexport function databaseId(host: string): string {\n return `${DATABASE_PREFIX}${host}`\n}\n\nexport function parseDatabaseId(id: string): string | null {\n return id.startsWith(DATABASE_PREFIX) ? id.slice(DATABASE_PREFIX.length) : null\n}\n\n// ConfigNode id: `config:<relPath>` where <relPath> is the path relative to\n// the scan root, with forward slashes regardless of platform. ConfigNodes\n// record file existence only (ADR-016).\nexport function configId(relPath: string): string {\n return `${CONFIG_PREFIX}${relPath}`\n}\n\nexport function parseConfigId(id: string): string | null {\n return id.startsWith(CONFIG_PREFIX) ? id.slice(CONFIG_PREFIX.length) : null\n}\n\n// InfraNode id: `infra:<kind>:<name>`. <kind> is a free string sub-type\n// (kafka-topic, redis, grpc-service, lambda, queue, etc.) per ADR-022.\nexport function infraId(kind: string, name: string): string {\n return `${INFRA_PREFIX}${kind}:${name}`\n}\n\nexport function parseInfraId(id: string): { kind: string; name: string } | null {\n if (!id.startsWith(INFRA_PREFIX)) return null\n const rest = id.slice(INFRA_PREFIX.length)\n const colon = rest.indexOf(':')\n if (colon === -1) return null\n return { kind: rest.slice(0, colon), name: rest.slice(colon + 1) }\n}\n\n// FrontierNode id: `frontier:<host>` where <host> is host:port from the OTel\n// peer attribute. Promoted to a typed node id (typically serviceId(...)) once\n// an alias resolves; the FrontierNode is removed and edges are rewritten.\nexport function frontierId(host: string): string {\n return `${FRONTIER_PREFIX}${host}`\n}\n\nexport function parseFrontierId(id: string): string | null {\n return id.startsWith(FRONTIER_PREFIX) ? id.slice(FRONTIER_PREFIX.length) : null\n}\n\n// ──────────────────────────────────────────────────────────────────────────\n// Edge ids (ADR-029, ADR-068)\n// ──────────────────────────────────────────────────────────────────────────\n//\n// Edge id wire format per provenance:\n// EXTRACTED: `${type}:${source}->${target}`\n// OBSERVED: `${type}:OBSERVED:${source}->${target}`\n// INFERRED: `${type}:INFERRED:${source}->${target}`\n// STALE never appears in an edge id; STALE is a transition of an existing\n// OBSERVED edge (ADR-024), not a creation pattern.\n//\n// Per ADR-068, edges to FrontierNodes carry whatever provenance describes\n// how the edge was learned — span-derived edges use observedEdgeId with the\n// FrontierNode id as the target string. Node-type is orthogonal to\n// provenance; the wire format reflects provenance only.\n//\n// Multiple edges between the same node pair coexist under distinct provenance\n// ids — that's what makes the EXTRACTED+OBSERVED coexistence rule\n// (contracts.md Rule 2) mechanically possible.\n\nconst EDGE_ARROW = '->'\n\nexport function extractedEdgeId(source: string, target: string, type: string): string {\n return `${type}:${source}${EDGE_ARROW}${target}`\n}\n\nexport function observedEdgeId(source: string, target: string, type: string): string {\n return `${type}:OBSERVED:${source}${EDGE_ARROW}${target}`\n}\n\nexport function inferredEdgeId(source: string, target: string, type: string): string {\n return `${type}:INFERRED:${source}${EDGE_ARROW}${target}`\n}\n\n// Parse an edge id into its parts. Returns null if the input is not a\n// well-formed edge id — covers all three creation variants (STALE rides on\n// the OBSERVED id format). Useful for consumers (traversal, MCP, persist)\n// that need to walk back from an id.\n//\n// Note: EXTRACTED ids have no provenance segment, so we detect them by\n// checking whether the second segment matches a known provenance marker.\nexport function parseEdgeId(id: string): {\n type: string\n provenance: 'EXTRACTED' | 'OBSERVED' | 'INFERRED'\n source: string\n target: string\n} | null {\n const arrowIdx = id.lastIndexOf(EDGE_ARROW)\n if (arrowIdx === -1) return null\n const left = id.slice(0, arrowIdx)\n const target = id.slice(arrowIdx + EDGE_ARROW.length)\n if (!left || !target) return null\n\n // left is one of:\n // `${type}:${source}` → EXTRACTED\n // `${type}:OBSERVED:${source}` → OBSERVED\n // `${type}:INFERRED:${source}` → INFERRED\n const firstColon = left.indexOf(':')\n if (firstColon === -1) return null\n const type = left.slice(0, firstColon)\n const rest = left.slice(firstColon + 1)\n\n for (const prov of ['OBSERVED', 'INFERRED'] as const) {\n if (rest.startsWith(`${prov}:`)) {\n return { type, provenance: prov, source: rest.slice(prov.length + 1), target }\n }\n }\n return { type, provenance: 'EXTRACTED', source: rest, target }\n}\n\n// ──────────────────────────────────────────────────────────────────────────\n// Provenance ranking (ADR-029, ADR-068)\n// ──────────────────────────────────────────────────────────────────────────\n//\n// Canonical priority used by traversal and any consumer that needs to pick\n// a single edge between two nodes when multiple provenance variants exist.\n// Higher number = higher trust = preferred.\n//\n// Four entries match the four-value Provenance enum (ADR-068). Node-type\n// gating (e.g. \"stop at FrontierNodes\" per contracts.md Rule 3) is enforced\n// at the node level by traversal, independent of edge rank.\nexport const PROV_RANK: Readonly<Record<'OBSERVED' | 'INFERRED' | 'EXTRACTED' | 'STALE', number>> = Object.freeze({\n OBSERVED: 3,\n INFERRED: 2,\n EXTRACTED: 1,\n STALE: 0,\n})\n","import { z } from 'zod'\nimport { ProvenanceSchema, EdgeTypeSchema } from './edges.js'\nimport { NodeTypeSchema } from './constants.js'\n\n// Policy schema (ADR-042). Lives at <projectRoot>/policy.json. Loaded at\n// startup and reloaded on file change. Five rule types, discriminated by\n// `rule.type`. Adding a new rule type requires an ADR amendment plus a\n// corresponding evaluator in the engine (ADR-043).\n\nexport const PolicySeveritySchema = z.enum(['info', 'warning', 'error', 'critical'])\nexport type PolicySeverity = z.infer<typeof PolicySeveritySchema>\n\nexport const PolicyActionSchema = z.enum(['log', 'alert', 'block'])\nexport type PolicyAction = z.infer<typeof PolicyActionSchema>\n\n// rule.type === 'structural' — asserts the existence of an edge between\n// node-type pairs. e.g. \"every ServiceNode must have a CONNECTS_TO edge to a\n// DatabaseNode.\"\nexport const StructuralRuleSchema = z.object({\n type: z.literal('structural'),\n // Node type the rule applies to. Every node of this type must satisfy the\n // edge requirement below.\n fromNodeType: NodeTypeSchema,\n // Required outbound edge type from each fromNodeType node.\n edgeType: EdgeTypeSchema,\n // Required target node type at the other end of the edge.\n toNodeType: NodeTypeSchema,\n})\nexport type StructuralRule = z.infer<typeof StructuralRuleSchema>\n\n// rule.type === 'compatibility' — re-runs `compat.ts` against current graph\n// state. Catches OBSERVED-vs-EXTRACTED divergence: a service whose compat\n// shape failed at extract time stays flagged on every evaluation.\nexport const CompatibilityRuleSchema = z.object({\n type: z.literal('compatibility'),\n // Optional kind narrowing. When omitted, all four compat shapes\n // (driver-engine, node-engine, package-conflict, deprecated-api) run.\n kind: z\n .enum(['driver-engine', 'node-engine', 'package-conflict', 'deprecated-api'])\n .optional(),\n})\nexport type CompatibilityRule = z.infer<typeof CompatibilityRuleSchema>\n\n// rule.type === 'provenance' — asserts that edges of a given type to a given\n// target carry a specific provenance (or one of a set). e.g. \"every CALLS\n// edge to service:payments must have OBSERVED provenance.\"\nexport const ProvenanceRuleSchema = z.object({\n type: z.literal('provenance'),\n // Edge type the rule applies to.\n edgeType: EdgeTypeSchema,\n // Target node id (e.g. 'service:payments') that incoming edges of edgeType\n // must satisfy. Optional — when omitted, the rule runs against every edge\n // of edgeType regardless of target.\n targetNodeId: z.string().optional(),\n // Required provenance (single value or one-of). The audit fails if the\n // observed edge's provenance is not in this set.\n required: z.union([ProvenanceSchema, z.array(ProvenanceSchema).min(1)]),\n})\nexport type ProvenanceRule = z.infer<typeof ProvenanceRuleSchema>\n\n// rule.type === 'ownership' — every node of nodeType must declare an `owner`\n// field. The field name lives on the node attributes; the rule fires when a\n// node of the type doesn't carry it (or carries an empty string).\nexport const OwnershipRuleSchema = z.object({\n type: z.literal('ownership'),\n // Node type the rule applies to. ServiceNode is the common case; the\n // discriminator stays generic so future node types can opt in.\n nodeType: NodeTypeSchema,\n // Field name on the node attributes that must be non-empty. Defaults to\n // 'owner' if omitted.\n field: z.string().default('owner'),\n})\nexport type OwnershipRule = z.infer<typeof OwnershipRuleSchema>\n\n// rule.type === 'blast-radius' — no node of the given type may have more\n// than `maxAffected` transitively-affected downstream nodes. Computed via\n// getBlastRadius at evaluation time.\nexport const BlastRadiusRuleSchema = z.object({\n type: z.literal('blast-radius'),\n // Node type the rule applies to (ServiceNode is the common case).\n nodeType: NodeTypeSchema,\n // Cap on `totalAffected` from getBlastRadius. Inclusive — a node hitting\n // exactly this number passes; > maxAffected fails.\n maxAffected: z.number().int().positive(),\n // Depth to evaluate against. Defaults to the contract's blast-radius\n // default (10) when omitted.\n depth: z.number().int().positive().optional(),\n})\nexport type BlastRadiusRule = z.infer<typeof BlastRadiusRuleSchema>\n\nexport const PolicyRuleSchema = z.discriminatedUnion('type', [\n StructuralRuleSchema,\n CompatibilityRuleSchema,\n ProvenanceRuleSchema,\n OwnershipRuleSchema,\n BlastRadiusRuleSchema,\n])\nexport type PolicyRule = z.infer<typeof PolicyRuleSchema>\n\nexport const PolicySchema = z.object({\n // Unique within the file. Duplicates fail PolicyFileSchema.parse.\n id: z.string().min(1),\n name: z.string().min(1),\n description: z.string().optional(),\n severity: PolicySeveritySchema,\n // When omitted, the engine derives a default from severity per ADR-044\n // (info→log, warning→alert, error→alert, critical→block).\n onViolation: PolicyActionSchema.optional(),\n rule: PolicyRuleSchema,\n})\nexport type Policy = z.infer<typeof PolicySchema>\n\n// Top-level shape of policy.json. version: z.literal(1) — bumping requires\n// an ADR amendment per the schema-growth contract (ADR-031).\nexport const PolicyFileSchema = z\n .object({\n version: z.literal(1),\n policies: z.array(PolicySchema),\n })\n .superRefine((file, ctx) => {\n // id uniqueness is enforced at parse time, not at registry-add time.\n // Duplicates collapse silently otherwise — we'd evaluate the second one\n // and lose the first.\n const seen = new Set<string>()\n for (const [i, p] of file.policies.entries()) {\n if (seen.has(p.id)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['policies', i, 'id'],\n message: `duplicate policy id \"${p.id}\"`,\n })\n }\n seen.add(p.id)\n }\n })\nexport type PolicyFile = z.infer<typeof PolicyFileSchema>\n\n// Emitted by the evaluator. Appended to policy-violations.ndjson.\n// Deterministic id (per ADR-043) means re-evaluating the same graph + same\n// policies produces the same violation ids; the writer skips duplicates.\n// Hypothetical action for POST /policies/check (ADR-045). Each action shape\n// names a candidate change to the graph; the engine simulates it and returns\n// any violations that *would* result. MVP scope is the two action shapes\n// below; new shapes need an ADR amendment.\nexport const HypotheticalActionSchema = z.discriminatedUnion('kind', [\n z.object({\n kind: z.literal('promote-frontier'),\n // The FrontierNode id that would be promoted.\n frontierId: z.string().min(1),\n }),\n z.object({\n kind: z.literal('add-edge'),\n source: z.string().min(1),\n target: z.string().min(1),\n edgeType: EdgeTypeSchema,\n provenance: ProvenanceSchema,\n }),\n])\nexport type HypotheticalAction = z.infer<typeof HypotheticalActionSchema>\n\n// Body of POST /policies/check.\nexport const PoliciesCheckBodySchema = z.object({\n hypotheticalAction: HypotheticalActionSchema.optional(),\n})\nexport type PoliciesCheckBody = z.infer<typeof PoliciesCheckBodySchema>\n\n// Scope filter for the check_policies MCP tool. 'all' (default) returns\n// every current violation; 'unresolved' is reserved for future resolution\n// tracking and behaves like 'all' for the MVP; { policyId } narrows to one\n// named policy.\nexport const CheckPoliciesScopeSchema = z.union([\n z.enum(['all', 'unresolved']),\n z.object({ policyId: z.string().min(1) }),\n])\nexport type CheckPoliciesScope = z.infer<typeof CheckPoliciesScopeSchema>\n\nexport const PolicyViolationSchema = z.object({\n // ${policy.id}:${violation-context}. The violation-context is shape-\n // specific (e.g. nodeId for structural; edgeId for provenance).\n id: z.string().min(1),\n policyId: z.string().min(1),\n policyName: z.string().min(1),\n severity: PolicySeveritySchema,\n // Resolved at evaluation time — either the explicit policy.onViolation or\n // the severity-derived default per ADR-044.\n onViolation: PolicyActionSchema,\n ruleType: z.enum(['structural', 'compatibility', 'provenance', 'ownership', 'blast-radius']),\n subject: z\n .object({\n nodeId: z.string().optional(),\n edgeId: z.string().optional(),\n path: z.array(z.string()).optional(),\n })\n .refine(\n (s) => s.nodeId !== undefined || s.edgeId !== undefined || s.path !== undefined,\n { message: 'subject must carry at least one of nodeId, edgeId, path' },\n ),\n message: z.string().min(1),\n observedAt: z.string().datetime(),\n})\nexport type PolicyViolation = z.infer<typeof PolicyViolationSchema>\n","import { z } from 'zod'\n\n// Machine-level project registry (ADR-048). Single file at\n// `~/.neat/projects.json`, per-user, machine-local. The wire shape lives here\n// so the registry module and the daemon agree on it without a circular\n// dependency through @neat.is/core.\n\nexport const RegistryStatusSchema = z.enum(['active', 'paused', 'broken'])\nexport type RegistryStatus = z.infer<typeof RegistryStatusSchema>\n\nexport const RegistryEntrySchema = z.object({\n // Unique within the registry. Project-scoped operations (`neat watch\n // --project <name>`, `neatd reload <name>`) key on this. Collisions are a\n // hard error at registration time.\n name: z.string().min(1),\n // Resolved absolute path on disk. Path normalisation is what keeps two\n // `neat init` calls from different relative paths from creating two entries\n // for the same directory.\n path: z.string().min(1),\n // ISO8601, set at first registration.\n registeredAt: z.string(),\n // ISO8601, updated whenever the daemon successfully sees the project.\n // Optional because a freshly-registered project hasn't been seen yet.\n lastSeenAt: z.string().optional(),\n // Languages detected at `init` time. Free-form strings keyed off the\n // installer modules — `'javascript'`, `'python'`, …\n languages: z.array(z.string()),\n status: RegistryStatusSchema,\n})\nexport type RegistryEntry = z.infer<typeof RegistryEntrySchema>\n\nexport const RegistryFileSchema = z.object({\n version: z.literal(1),\n projects: z.array(RegistryEntrySchema),\n})\nexport type RegistryFile = z.infer<typeof RegistryFileSchema>\n\nexport const EMPTY_REGISTRY: RegistryFile = { version: 1, projects: [] }\n","// Divergence — the thesis surface (ADR-060). A typed result describing\n// places where what the code declares (EXTRACTED) doesn't match what\n// production observed (OBSERVED). Five locked variants discriminated by\n// `type`; new shapes require a successor ADR.\n//\n// The schema lives here because consumers across the stack (REST, MCP,\n// CLI, future frontend) need to validate the wire shape against the same\n// definition. Computation lives in packages/core/src/divergences.ts —\n// pure functions over a NeatGraph; no I/O, no mutation.\n\nimport { z } from 'zod'\nimport { EdgeTypeSchema, GraphEdgeSchema } from './edges.js'\n\nconst commonFields = {\n source: z.string(),\n target: z.string(),\n confidence: z.number().min(0).max(1),\n reason: z.string(),\n recommendation: z.string(),\n}\n\nexport const MissingObservedDivergenceSchema = z.object({\n type: z.literal('missing-observed'),\n ...commonFields,\n edgeType: EdgeTypeSchema,\n extracted: GraphEdgeSchema,\n})\nexport type MissingObservedDivergence = z.infer<typeof MissingObservedDivergenceSchema>\n\nexport const MissingExtractedDivergenceSchema = z.object({\n type: z.literal('missing-extracted'),\n ...commonFields,\n edgeType: EdgeTypeSchema,\n observed: GraphEdgeSchema,\n})\nexport type MissingExtractedDivergence = z.infer<typeof MissingExtractedDivergenceSchema>\n\n// 'incompatible' = compat.json rule fires definitively.\n// 'deprecated' = compat.json deprecated-api rule fires.\n// 'unknown' = engine version present but no compat rule covers it.\nexport const CompatibilityVerdictSchema = z.enum(['incompatible', 'deprecated', 'unknown'])\nexport type CompatibilityVerdict = z.infer<typeof CompatibilityVerdictSchema>\n\nexport const VersionMismatchDivergenceSchema = z.object({\n type: z.literal('version-mismatch'),\n ...commonFields,\n extractedVersion: z.string(),\n observedVersion: z.string(),\n compatibility: CompatibilityVerdictSchema,\n})\nexport type VersionMismatchDivergence = z.infer<typeof VersionMismatchDivergenceSchema>\n\nexport const HostMismatchDivergenceSchema = z.object({\n type: z.literal('host-mismatch'),\n ...commonFields,\n extractedHost: z.string(),\n observedHost: z.string(),\n})\nexport type HostMismatchDivergence = z.infer<typeof HostMismatchDivergenceSchema>\n\n// Free-shape reference to the compat.json rule that fired — kept as a plain\n// record so the schema stays insulated from compat.ts's internal types. The\n// `rule` field carries enough metadata to identify which rule + why.\nexport const CompatRuleRefSchema = z.object({\n kind: z.string(),\n reason: z.string(),\n package: z.string().optional(),\n driver: z.string().optional(),\n engine: z.string().optional(),\n})\nexport type CompatRuleRef = z.infer<typeof CompatRuleRefSchema>\n\nexport const CompatViolationDivergenceSchema = z.object({\n type: z.literal('compat-violation'),\n ...commonFields,\n rule: CompatRuleRefSchema,\n observed: GraphEdgeSchema,\n})\nexport type CompatViolationDivergence = z.infer<typeof CompatViolationDivergenceSchema>\n\nexport const DivergenceSchema = z.discriminatedUnion('type', [\n MissingObservedDivergenceSchema,\n MissingExtractedDivergenceSchema,\n VersionMismatchDivergenceSchema,\n HostMismatchDivergenceSchema,\n CompatViolationDivergenceSchema,\n])\nexport type Divergence = z.infer<typeof DivergenceSchema>\n\nexport const DivergenceResultSchema = z.object({\n divergences: z.array(DivergenceSchema),\n totalAffected: z.number().int().nonnegative(),\n // ISO8601 timestamp the result was computed at. Each call re-derives from\n // the live graph — there is no persisted divergence history.\n computedAt: z.string().datetime(),\n})\nexport type DivergenceResult = z.infer<typeof DivergenceResultSchema>\n\n// Locked set of divergence types. Consumers (REST query parser, CLI flag\n// parser) validate the user-supplied filter against this enum.\nexport const DivergenceTypeSchema = z.enum([\n 'missing-observed',\n 'missing-extracted',\n 'version-mismatch',\n 'host-mismatch',\n 'compat-violation',\n])\nexport type DivergenceType = z.infer<typeof DivergenceTypeSchema>\n","import { z } from 'zod'\nimport { GraphEdgeSchema } from './edges.js'\nimport { GraphNodeSchema } from './nodes.js'\nimport { ErrorEventSchema, StaleEventSchema } from './events.js'\nimport { PolicyViolationSchema } from './policy.js'\nimport { RegistryEntrySchema } from './registry.js'\n\n// ADR-061 envelope rule: every GET response is a JSON object. List endpoints\n// wrap in plural-noun fields plus a count; single-item endpoints wrap the\n// item in a singular field. Bare arrays are a contract violation.\n\n// `count` is the length of the returned array; `total` is the size of the\n// underlying collection before filtering / limiting.\nconst listEnvelope = <T extends z.ZodTypeAny>(itemSchema: T) =>\n z.object({\n count: z.number().int().nonnegative(),\n total: z.number().int().nonnegative(),\n events: z.array(itemSchema),\n })\n\nexport const IncidentsResponseSchema = listEnvelope(ErrorEventSchema)\nexport type IncidentsResponse = z.infer<typeof IncidentsResponseSchema>\n\nexport const StaleEventsResponseSchema = listEnvelope(StaleEventSchema)\nexport type StaleEventsResponse = z.infer<typeof StaleEventsResponseSchema>\n\nexport const PoliciesViolationsResponseSchema = z.object({\n violations: z.array(PolicyViolationSchema),\n})\nexport type PoliciesViolationsResponse = z.infer<typeof PoliciesViolationsResponseSchema>\n\nexport const GraphNodeResponseSchema = z.object({\n node: GraphNodeSchema,\n})\nexport type GraphNodeResponse = z.infer<typeof GraphNodeResponseSchema>\n\nexport const GraphEdgesResponseSchema = z.object({\n inbound: z.array(GraphEdgeSchema),\n outbound: z.array(GraphEdgeSchema),\n})\nexport type GraphEdgesResponse = z.infer<typeof GraphEdgesResponseSchema>\n\n// `.passthrough()` because the handler keeps legacy fields (uptime,\n// nodeCount, edgeCount, lastUpdated) for the web shell's StatusBar. The\n// canonical triple is what's required; the extras ride along.\nexport const HealthResponseSchema = z\n .object({\n ok: z.boolean(),\n project: z.string(),\n uptimeMs: z.number().int().nonnegative(),\n })\n .passthrough()\nexport type HealthResponse = z.infer<typeof HealthResponseSchema>\n\nexport const SingleProjectResponseSchema = z.object({\n project: RegistryEntrySchema,\n})\nexport type SingleProjectResponse = z.infer<typeof SingleProjectResponseSchema>\n\n// /search matches are graph nodes with an added per-match score. The\n// schema keeps `score` mandatory and lets the underlying node shape pass\n// through — GraphNodeSchema is a discriminated union and tightening here\n// would force every match into one variant.\nexport const SearchMatchSchema = z\n .object({ score: z.number() })\n .passthrough()\nexport type SearchMatch = z.infer<typeof SearchMatchSchema>\n\nexport const SearchResponseSchema = z.object({\n query: z.string(),\n provider: z.string(),\n matches: z.array(SearchMatchSchema),\n})\nexport type SearchResponse = z.infer<typeof SearchResponseSchema>\n\n// Live snapshot returned by GET /graph. Mirrors the in-memory graphology\n// instance; nothing reads graph.json at request time (Rule 6).\nexport const SerializedGraphSchema = z.object({\n nodes: z.array(GraphNodeSchema),\n edges: z.array(GraphEdgeSchema),\n})\nexport type SerializedGraph = z.infer<typeof SerializedGraphSchema>\n\n// GET /graph/diff response. The diff module owns the implementation;\n// the schema mirrors its current GraphDiff interface.\nexport const GraphDiffResultSchema = z.object({\n base: z.object({ exportedAt: z.string().optional() }),\n current: z.object({ exportedAt: z.string() }),\n added: z.object({\n nodes: z.array(GraphNodeSchema),\n edges: z.array(GraphEdgeSchema),\n }),\n removed: z.object({\n nodes: z.array(GraphNodeSchema),\n edges: z.array(GraphEdgeSchema),\n }),\n changed: z.object({\n nodes: z.array(\n z.object({\n id: z.string(),\n before: GraphNodeSchema,\n after: GraphNodeSchema,\n }),\n ),\n edges: z.array(\n z.object({\n id: z.string(),\n before: GraphEdgeSchema,\n after: GraphEdgeSchema,\n }),\n ),\n }),\n})\nexport type GraphDiffResult = z.infer<typeof GraphDiffResultSchema>\n","// Confidence grading helpers — single source of truth for ADR-066.\n//\n// EXTRACTED is graded at emit time per producer; OBSERVED is graded by the\n// signal block on the edge. PROV_RANK still locks tier ordering. The grading\n// sits within each tier so the divergence query can reweight against honest\n// values, not flat coarse ones.\n//\n// Producers in packages/core/src/extract/ import `confidenceForExtracted`\n// and pass the producer kind; ingest.ts imports `confidenceForObservedSignal`\n// and calls it at the same point it writes the signal block.\n\nimport type { EdgeSignal } from './edges.js'\n\n// Discriminator that producers pass when emitting an EXTRACTED edge. Each\n// kind maps to a numeric grade; the divergence query treats sub-floor\n// candidates as if they never existed (precision floor, NEAT_EXTRACTED_PRECISION_FLOOR).\nexport type ExtractedConfidenceKind =\n // 0.85 — direct AST / file facts. ConfigNode existence (ADR-016), package.json\n // deps, AST imports, Dockerfile RUNS_ON, docker-compose depends_on, parsed\n // database config files. Structural — what the code says it does.\n | 'structural'\n // 0.85 — framework-aware call-site recognizer matched the SDK shape. Today's\n // covers kafkajs producer.send / consumer.subscribe, AWS SDK Bucket/TableName\n // near a *Client, grpc-js Client construction with the import context, and\n // import-aware *Client classification (#238).\n | 'verified-call-site'\n // 0.5 — URL-shaped literal with structural support. Today's `redis://host` /\n // `rediss://host` URL captures fit here: the scheme proves it's a redis URL,\n // but there's no call expression verifying it's actually wired into the\n // service's runtime path.\n | 'url-with-structural-support'\n // 0.2 — bare URL/hostname match against a registered service. urlMatchesHost\n // requires scheme + exact hostname so this is structurally tight, but no\n // framework-aware recognizer confirms the call. Drops below the default\n // precision floor (0.7) and never enters the graph unless the floor is\n // lowered for diagnostics.\n | 'hostname-shape-match'\n\nexport const EXTRACTED_CONFIDENCE: Record<ExtractedConfidenceKind, number> = {\n structural: 0.85,\n 'verified-call-site': 0.85,\n 'url-with-structural-support': 0.5,\n 'hostname-shape-match': 0.2,\n}\n\nexport function confidenceForExtracted(kind: ExtractedConfidenceKind): number {\n return EXTRACTED_CONFIDENCE[kind]\n}\n\n// OBSERVED grading from the signal block (ADR-066 §2). The piecewise function\n// reflects the three buckets the ADR locks plus the error-ratio adjustment.\n// `lastObservedAgeMs` defaults to 0 (just-observed) when the caller doesn't\n// pass a signal — upsertObservedEdge writes 0 on creation and on every span\n// update; the staleness loop is the only thing that lets the age drift.\n\nconst STRONG_SPAN_THRESHOLD = 100\nconst GOOD_SPAN_THRESHOLD = 10\nconst RECENT_AGE_MS = 60 * 60 * 1000\n\nexport function confidenceForObservedSignal(signal: EdgeSignal | undefined): number {\n // No signal block — fall back to the strong-tier ceiling. This case is\n // legacy edges loaded from a pre-v0.3.4 snapshot or hand-written test\n // fixtures; new producers always write the signal block.\n if (!signal) return 1.0\n const { spanCount, errorCount } = signal\n const ageMs = signal.lastObservedAgeMs ?? 0\n const recent = ageMs < RECENT_AGE_MS\n\n let base: number\n if (spanCount >= STRONG_SPAN_THRESHOLD && recent) {\n // Strong tier. Scale linearly from 0.95 at the threshold up to 1.0 at\n // 10× the threshold. Saturates at 1.0 above that.\n const over = Math.min(1, (spanCount - STRONG_SPAN_THRESHOLD) / (9 * STRONG_SPAN_THRESHOLD))\n base = 0.95 + 0.05 * over\n } else if (spanCount >= GOOD_SPAN_THRESHOLD && recent) {\n // Good tier. 0.7 at the threshold up to 0.9 just below the strong tier.\n const range = STRONG_SPAN_THRESHOLD - GOOD_SPAN_THRESHOLD\n const over = (spanCount - GOOD_SPAN_THRESHOLD) / range\n base = 0.7 + 0.2 * over\n } else if (spanCount > 0 && recent) {\n // Weak tier. 0.4 at one span up to 0.6 just below the good tier.\n const range = GOOD_SPAN_THRESHOLD - 1\n const over = range > 0 ? (spanCount - 1) / range : 0\n base = 0.4 + 0.2 * over\n } else if (spanCount > 0) {\n // Not recent — clamp the weak tier; staleness loop will demote this edge\n // to STALE on the next tick.\n base = 0.4\n } else {\n // Defensive: no spans on an OBSERVED edge means the upsert path was\n // skipped somewhere. Treat as no-evidence rather than max-trust.\n base = 0.4\n }\n\n // Error-ratio penalty. errorCount / spanCount on a healthy edge is 0; on a\n // failing edge it climbs. Subtract up to 0.2.\n if (spanCount > 0 && errorCount > 0) {\n const ratio = Math.min(1, errorCount / spanCount)\n base -= 0.2 * ratio\n }\n\n if (base < 0) return 0\n if (base > 1) return 1\n return Math.round(base * 1000) / 1000\n}\n\n// Precision-floor helpers (ADR-066 §3). The floor reads the\n// NEAT_EXTRACTED_PRECISION_FLOOR env var on each call so tests can flip it\n// in-process. Default 0.7. NEAT_EXTRACTED_PRECISION_FLOOR=0.0 keeps every\n// candidate (diagnostic mode).\n\nexport const DEFAULT_EXTRACTED_PRECISION_FLOOR = 0.7\n\nexport function extractedPrecisionFloor(): number {\n const raw = process.env.NEAT_EXTRACTED_PRECISION_FLOOR\n if (raw === undefined) return DEFAULT_EXTRACTED_PRECISION_FLOOR\n const n = Number(raw)\n if (!Number.isFinite(n) || n < 0 || n > 1) return DEFAULT_EXTRACTED_PRECISION_FLOOR\n return n\n}\n\nexport function passesExtractedFloor(confidence: number): boolean {\n return confidence >= extractedPrecisionFloor()\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC+BA,iBAAkB;AA/BX,IAAM,aAAa;AAAA,EACxB,WAAW;AAAA,EACX,UAAU;AAAA,EACV,UAAU;AAAA,EACV,OAAO;AACT;AAIO,IAAM,WAAW;AAAA,EACtB,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,eAAe;AAAA,EACf,cAAc;AAAA,EACd,eAAe;AAAA,EACf,SAAS;AACX;AAIO,IAAM,WAAW;AAAA,EACtB,aAAa;AAAA,EACb,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,cAAc;AAChB;AASO,IAAM,iBAAiB,aAAE,KAAK;AAAA,EACnC,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AAAA,E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Y,uBAAuB;AACjD,WAAO,MAAM,MAAM;AAAA,EACrB,WAAW,YAAY,KAAK,QAAQ;AAElC,UAAM,QAAQ,sBAAsB;AACpC,UAAM,OAAO,QAAQ,KAAK,YAAY,KAAK,QAAQ;AACnD,WAAO,MAAM,MAAM;AAAA,EACrB,WAAW,YAAY,GAAG;AAGxB,WAAO;AAAA,EACT,OAAO;AAGL,WAAO;AAAA,EACT;AAIA,MAAI,YAAY,KAAK,aAAa,GAAG;AACnC,UAAM,QAAQ,KAAK,IAAI,GAAG,aAAa,SAAS;AAChD,YAAQ,MAAM;AAAA,EAChB;AAEA,MAAI,OAAO,EAAG,QAAO;AACrB,MAAI,OAAO,EAAG,QAAO;AACrB,SAAO,KAAK,MAAM,OAAO,GAAI,IAAI;AACnC;AAOO,IAAM,oCAAoC;AAE1C,SAAS,0BAAkC;AAChD,QAAM,MAAM,QAAQ,IAAI;AACxB,MAAI,QAAQ,OAAW,QAAO;AAC9B,QAAM,IAAI,OAAO,GAAG;AACpB,MAAI,CAAC,OAAO,SAAS,CAAC,KAAK,IAAI,KAAK,IAAI,EAAG,QAAO;AAClD,SAAO;AACT;AAEO,SAAS,qBAAqB,YAA6B;AAChE,SAAO,cAAc,wBAAwB;AAC/C;","names":["import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod","import_zod"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/constants.ts","../src/nodes.ts","../src/edges.ts","../src/events.ts","../src/results.ts","../src/identity.ts","../src/policy.ts","../src/registry.ts","../src/divergence.ts","../src/responses.ts","../src/confidence.ts"],"sourcesContent":["export * from './constants.js'\nexport * from './nodes.js'\nexport * from './edges.js'\nexport * from './events.js'\nexport * from './results.js'\nexport * from './identity.js'\nexport * from './policy.js'\nexport * from './registry.js'\nexport * from './divergence.js'\nexport * from './responses.js'\nexport * from './confidence.js'\n","export const Provenance = {\n EXTRACTED: 'EXTRACTED',\n INFERRED: 'INFERRED',\n OBSERVED: 'OBSERVED',\n STALE: 'STALE',\n} as const\n\nexport type ProvenanceValue = (typeof Provenance)[keyof typeof Provenance]\n\nexport const EdgeType = {\n CALLS: 'CALLS',\n DEPENDS_ON: 'DEPENDS_ON',\n CONNECTS_TO: 'CONNECTS_TO',\n CONFIGURED_BY: 'CONFIGURED_BY',\n PUBLISHES_TO: 'PUBLISHES_TO',\n CONSUMES_FROM: 'CONSUMES_FROM',\n RUNS_ON: 'RUNS_ON',\n} as const\n\nexport type EdgeTypeValue = (typeof EdgeType)[keyof typeof EdgeType]\n\nexport const NodeType = {\n ServiceNode: 'ServiceNode',\n DatabaseNode: 'DatabaseNode',\n ConfigNode: 'ConfigNode',\n InfraNode: 'InfraNode',\n FrontierNode: 'FrontierNode',\n} as const\n\nexport type NodeTypeValue = (typeof NodeType)[keyof typeof NodeType]\n\nimport { z } from 'zod'\n\n// Zod-side mirror of NodeType, exported for schemas that need to discriminate\n// or filter by node type at parse time (policy rules, traversal results, etc.).\n// Adding a new node type means adding it to NodeType above and to this enum.\nexport const NodeTypeSchema = z.enum([\n NodeType.ServiceNode,\n NodeType.DatabaseNode,\n NodeType.ConfigNode,\n NodeType.InfraNode,\n NodeType.FrontierNode,\n])\n","import { z } from 'zod'\nimport { NodeType } from './constants.js'\n\nexport const CompatibleDriverSchema = z.object({\n name: z.string(),\n minVersion: z.string(),\n})\nexport type CompatibleDriver = z.infer<typeof CompatibleDriverSchema>\n\n// How NEAT first learned of a node. Static-extraction fills in the rich\n// fields (language, version, dependencies); OTel ingest can also create a\n// minimal node when it sees a span for an unknown peer. When both layers\n// recorded the same node, the value is 'merged'. ADR-031 schema growth.\nexport const DiscoveredViaSchema = z.enum(['static', 'otel', 'merged'])\nexport type DiscoveredVia = z.infer<typeof DiscoveredViaSchema>\n\nexport const ServiceNodeSchema = z.object({\n id: z.string(),\n type: z.literal(NodeType.ServiceNode),\n name: z.string(),\n language: z.string(),\n // Deployment environment from the OTel `deployment.environment.name` attr\n // (with `deployment.environment` and resource-attr fallbacks). The literal\n // `'unknown'` is the honest sentinel when no env signal is present; static\n // extraction never sees env at extract time, so its ServiceNodes carry\n // `undefined` here and the id stays in the env-less wire format\n // `service:<name>`. See ADR-074 §2 and docs/contracts/env-dimension.md.\n env: z.string().optional(),\n // Framework recorded by the static extractor when the install plan\n // dispatches a framework-specific path (Next.js, Remix, SvelteKit, Nuxt,\n // Astro). Optional enrichment — `undefined` for lib-only packages and\n // ambiguous repos. See ADR-074 §3 / docs/contracts/framework-installers.md.\n framework: z.string().optional(),\n discoveredVia: DiscoveredViaSchema.optional(),\n version: z.string().optional(),\n dbConnectionTarget: z.string().optional(),\n repoPath: z.string().optional(),\n owner: z.string().optional(),\n dependencies: z.record(z.string(), z.string()).optional(),\n // Hostnames OTel spans might mention for this service: compose service\n // names, k8s metadata.name (and the cluster-DNS variants), Dockerfile\n // labels, etc. resolveServiceId in ingest.ts checks these before falling\n // back to a FRONTIER placeholder.\n aliases: z.array(z.string()).optional(),\n // Optional. If set, services declare their `engines.node` here so γ #74's\n // node-engine compat check has something to test against.\n nodeEngine: z.string().optional(),\n incompatibilities: z\n .array(\n // Discriminated by `kind`. `driver-engine` is the original shape and\n // stays default for backward compatibility — older snapshots without a\n // `kind` field still parse via the union's `.optional()` discriminator\n // fallback. New kinds came in with γ #74.\n z.union([\n z.object({\n kind: z.literal('driver-engine').optional(),\n driver: z.string(),\n driverVersion: z.string(),\n engine: z.string(),\n engineVersion: z.string(),\n reason: z.string(),\n }),\n z.object({\n kind: z.literal('node-engine'),\n package: z.string(),\n packageVersion: z.string().optional(),\n requiredNodeVersion: z.string(),\n declaredNodeEngine: z.string().optional(),\n reason: z.string(),\n }),\n z.object({\n kind: z.literal('package-conflict'),\n package: z.string(),\n packageVersion: z.string().optional(),\n requires: z.object({\n name: z.string(),\n minVersion: z.string(),\n }),\n foundVersion: z.string().optional(),\n reason: z.string(),\n }),\n z.object({\n kind: z.literal('deprecated-api'),\n package: z.string(),\n packageVersion: z.string().optional(),\n reason: z.string(),\n }),\n ]),\n )\n .optional(),\n})\nexport type ServiceNode = z.infer<typeof ServiceNodeSchema>\n\nexport const DatabaseNodeSchema = z.object({\n id: z.string(),\n type: z.literal(NodeType.DatabaseNode),\n name: z.string(),\n engine: z.string(),\n engineVersion: z.string(),\n compatibleDrivers: z.array(CompatibleDriverSchema),\n host: z.string().optional(),\n port: z.number().optional(),\n discoveredVia: DiscoveredViaSchema.optional(),\n})\nexport type DatabaseNode = z.infer<typeof DatabaseNodeSchema>\n\nexport const ConfigNodeSchema = z.object({\n id: z.string(),\n type: z.literal(NodeType.ConfigNode),\n name: z.string(),\n path: z.string(),\n fileType: z.string(),\n})\nexport type ConfigNode = z.infer<typeof ConfigNodeSchema>\n\nexport const InfraNodeSchema = z.object({\n id: z.string(),\n type: z.literal(NodeType.InfraNode),\n name: z.string(),\n provider: z.string(),\n region: z.string().optional(),\n kind: z.string().optional(),\n})\nexport type InfraNode = z.infer<typeof InfraNodeSchema>\n\n// Placeholder for a span peer the ingest layer couldn't resolve to a known\n// ServiceNode. Lives at id `frontier:<host>` and gets replaced by the real\n// service once a later extraction round records that host as an alias.\nexport const FrontierNodeSchema = z.object({\n id: z.string(),\n type: z.literal(NodeType.FrontierNode),\n name: z.string(),\n host: z.string(),\n firstObserved: z.string().datetime().optional(),\n lastObserved: z.string().datetime().optional(),\n})\nexport type FrontierNode = z.infer<typeof FrontierNodeSchema>\n\nexport const GraphNodeSchema = z.discriminatedUnion('type', [\n ServiceNodeSchema,\n DatabaseNodeSchema,\n ConfigNodeSchema,\n InfraNodeSchema,\n FrontierNodeSchema,\n])\nexport type GraphNode = z.infer<typeof GraphNodeSchema>\n","import { z } from 'zod'\nimport { EdgeType, Provenance } from './constants.js'\n\nexport const ProvenanceSchema = z.enum([\n Provenance.EXTRACTED,\n Provenance.INFERRED,\n Provenance.OBSERVED,\n Provenance.STALE,\n])\n\nexport const EdgeTypeSchema = z.enum([\n EdgeType.CALLS,\n EdgeType.DEPENDS_ON,\n EdgeType.CONNECTS_TO,\n EdgeType.CONFIGURED_BY,\n EdgeType.PUBLISHES_TO,\n EdgeType.CONSUMES_FROM,\n EdgeType.RUNS_ON,\n])\n\n// Static-extraction evidence for an EXTRACTED edge (ADR-029, contract #5).\n// `file` is required — retire.ts keys ghost-edge cleanup off it. `line` and\n// `snippet` are optional because the existing extractors (configs.ts,\n// docker-compose.ts) record file-level evidence only; loosening lets those\n// edges through ADR-061's response-shape validation without forcing the\n// extractors to fabricate line numbers.\nexport const EdgeEvidenceSchema = z.object({\n file: z.string(),\n line: z.number().int().nonnegative().optional(),\n snippet: z.string().optional(),\n})\nexport type EdgeEvidence = z.infer<typeof EdgeEvidenceSchema>\n\n// Runtime signal for per-edge confidence (γ #76). Populated by ingest. Three\n// continuous numbers stand in for the previous coarse 0.3/0.5/0.7/1.0 ladder:\n// how much traffic, how clean, and how recent.\nexport const EdgeSignalSchema = z.object({\n spanCount: z.number().int().nonnegative(),\n errorCount: z.number().int().nonnegative(),\n lastObservedAgeMs: z.number().nonnegative().optional(),\n})\nexport type EdgeSignal = z.infer<typeof EdgeSignalSchema>\n\n// `confidence` is in [0, 1] and graded per provenance tier (ADR-066). Producers\n// write it on every EXTRACTED and OBSERVED edge via the helpers in\n// confidence.ts; flat coarse values (the old `0.5` / `1.0` shape) are a\n// contract violation. The field stays `.optional()` for snapshot back-compat —\n// older snapshots may carry edges without confidence and persist.ts loads them\n// on the documented growth path (ADR-031).\nexport const GraphEdgeSchema = z.object({\n id: z.string(),\n source: z.string(),\n target: z.string(),\n type: EdgeTypeSchema,\n provenance: ProvenanceSchema,\n confidence: z.number().min(0).max(1).optional(),\n lastObserved: z.string().datetime().optional(),\n callCount: z.number().int().nonnegative().optional(),\n evidence: EdgeEvidenceSchema.optional(),\n signal: EdgeSignalSchema.optional(),\n})\nexport type GraphEdge = z.infer<typeof GraphEdgeSchema>\n","import { z } from 'zod'\n\n// Passthrough of OTel span attributes. Records source-attribution\n// (`code.filepath`, `code.lineno`, `code.function`), HTTP context\n// (`http.method`, `http.target`, `http.status_code`), DB context\n// (`db.system`, `db.statement`), and any other span attribute the SDK\n// emitted. Consumers (incident UI, MCP getRootCause) filter what they\n// surface. Schema growth per ADR-031 — optional, additive only.\nexport const SpanAttributesSchema = z.record(\n z.string(),\n z.union([z.string(), z.number(), z.boolean(), z.null(), z.array(z.string()), z.array(z.number()), z.array(z.boolean())]),\n)\nexport type SpanAttributes = z.infer<typeof SpanAttributesSchema>\n\nexport const ErrorEventSchema = z.object({\n id: z.string(),\n timestamp: z.string().datetime(),\n service: z.string(),\n traceId: z.string(),\n spanId: z.string(),\n errorType: z.string().optional(),\n errorMessage: z.string(),\n // OTLP span events with name=\"exception\" carry richer error data than\n // status.message. When present, these fields capture the exception type\n // and stacktrace from the SDK that recorded the error. ADR-031 schema\n // growth — added without a shape change because both fields are optional.\n exceptionType: z.string().optional(),\n exceptionStacktrace: z.string().optional(),\n // Span attributes passthrough (ADR-068 follow-up). Surfaces `code.*`\n // semconv attributes for source attribution, plus the rest of the\n // attribute set for downstream filtering.\n attributes: SpanAttributesSchema.optional(),\n affectedNode: z.string(),\n})\nexport type ErrorEvent = z.infer<typeof ErrorEventSchema>\n\n// Appended one-per-line to stale-events.ndjson whenever ingest.ts demotes\n// an OBSERVED edge to STALE (per-edge-type thresholds, ADR-024). Surfaces\n// on GET /stale-events for incident triage.\nexport const StaleEventSchema = z.object({\n edgeId: z.string(),\n source: z.string(),\n target: z.string(),\n edgeType: z.string(),\n thresholdMs: z.number().nonnegative(),\n ageMs: z.number().nonnegative(),\n lastObserved: z.string(),\n transitionedAt: z.string(),\n})\nexport type StaleEvent = z.infer<typeof StaleEventSchema>\n","import { z } from 'zod'\nimport { ProvenanceSchema, EdgeTypeSchema } from './edges.js'\n\nexport const RootCauseResultSchema = z.object({\n rootCauseNode: z.string(),\n rootCauseReason: z.string(),\n traversalPath: z.array(z.string()),\n edgeProvenances: z.array(ProvenanceSchema),\n confidence: z.number().min(0).max(1),\n fixRecommendation: z.string().optional(),\n})\nexport type RootCauseResult = z.infer<typeof RootCauseResultSchema>\n\nexport const BlastRadiusAffectedNodeSchema = z.object({\n nodeId: z.string(),\n // Distance from the origin in BFS hops. The origin itself is never in\n // affectedNodes, so distance 0 has no meaning — the BFS at traverse.ts\n // already skips frame 0. Tightening to positive() locks that invariant\n // mechanically (ADR-038, issue #138).\n distance: z.number().int().positive(),\n edgeProvenance: ProvenanceSchema,\n // path: origin → ... → nodeId. Length === distance + 1. Surfaced from the\n // BFS predecessor chain so consumers don't have to reconstruct it from\n // distance + the graph (ADR-038, issue #137).\n path: z.array(z.string()).min(2),\n // confidence: confidenceFromMix(...edgesAlongPath). Multiplicative cascade —\n // each hop is independent evidence and uncertainty compounds. ADR-036.\n confidence: z.number().min(0).max(1),\n})\nexport type BlastRadiusAffectedNode = z.infer<typeof BlastRadiusAffectedNodeSchema>\n\nexport const BlastRadiusResultSchema = z.object({\n origin: z.string(),\n affectedNodes: z.array(BlastRadiusAffectedNodeSchema),\n totalAffected: z.number().int().nonnegative(),\n})\nexport type BlastRadiusResult = z.infer<typeof BlastRadiusResultSchema>\n\n// Transitive get_dependencies (issue #144). Flat list with distance, edge\n// type, and provenance per dependency. Sibling shape to BlastRadius but\n// thinner — no path tracking, no confidence cascade. Use cases live in the\n// MCP get_dependencies tool (\"what does X depend on, transitively?\").\nexport const TransitiveDependencySchema = z.object({\n nodeId: z.string(),\n // Distance from the origin in BFS hops. The origin itself is never in\n // dependencies, so distance is positive (>= 1).\n distance: z.number().int().positive(),\n // Type of the edge that brought traversal to this node (CALLS,\n // CONNECTS_TO, DEPENDS_ON, etc.).\n edgeType: EdgeTypeSchema,\n // Provenance of that edge.\n provenance: ProvenanceSchema,\n})\nexport type TransitiveDependency = z.infer<typeof TransitiveDependencySchema>\n\nexport const TransitiveDependenciesResultSchema = z.object({\n origin: z.string(),\n depth: z.number().int().positive(),\n dependencies: z.array(TransitiveDependencySchema),\n total: z.number().int().nonnegative(),\n})\nexport type TransitiveDependenciesResult = z.infer<typeof TransitiveDependenciesResultSchema>\n","// Identity helpers — the single source of truth for node and edge id wire\n// format. See ADR-028 (nodes), ADR-029 (edges), and docs/contracts/identity.md\n// + docs/contracts/provenance.md.\n//\n// Producers construct ids via these helpers; consumers parse via the inverses.\n// Hand-rolled template literals like `service:${name}` or\n// `${type}:OBSERVED:${source}->${target}` are contract violations\n// (caught by packages/core/test/audits/contracts.test.ts).\n\nconst SERVICE_PREFIX = 'service:'\nconst DATABASE_PREFIX = 'database:'\nconst CONFIG_PREFIX = 'config:'\nconst INFRA_PREFIX = 'infra:'\nconst FRONTIER_PREFIX = 'frontier:'\n\n// ServiceNode id: `service:<name>` for env-unknown nodes (the default,\n// produced by static extraction or by ingest when the span carries no env\n// signal) and `service:<name>:<env>` for env-tagged nodes (produced by\n// ingest when the span carries `deployment.environment(.name)`).\n//\n// <name> is the manifest name verbatim (package.json#name for JS/TS,\n// pyproject [project].name for Python). Names with slashes (e.g. scoped\n// npm packages `@org/foo`) are kept as-is — no transformation. See\n// ADR-028 §5 for workspace-collision deferral.\n//\n// The env discriminator is ADR-074 §2. `env === 'unknown'` is the honest\n// \"no signal\" sentinel; emitting it as the env-less wire format keeps\n// pre-v0.3.9 snapshots byte-stable on disk.\nconst ENV_UNKNOWN = 'unknown'\n\nexport function serviceId(name: string, env?: string): string {\n if (env === undefined || env === ENV_UNKNOWN) return `${SERVICE_PREFIX}${name}`\n return `${SERVICE_PREFIX}${name}:${env}`\n}\n\n// Parse a service id into its (name, env) tuple. Returns null when the\n// input is not a service id. env is `'unknown'` when the id carries no\n// env segment (the env-less wire format).\nexport function parseServiceId(id: string): { name: string; env: string } | null {\n if (!id.startsWith(SERVICE_PREFIX)) return null\n const rest = id.slice(SERVICE_PREFIX.length)\n if (rest.length === 0) return null\n const colon = rest.indexOf(':')\n if (colon === -1) return { name: rest, env: ENV_UNKNOWN }\n return { name: rest.slice(0, colon), env: rest.slice(colon + 1) }\n}\n\n// DatabaseNode id: `database:<host>`. Port is intentionally excluded; two DBs\n// on the same host different ports collide. See ADR-028 §6 for deferral.\nexport function databaseId(host: string): string {\n return `${DATABASE_PREFIX}${host}`\n}\n\nexport function parseDatabaseId(id: string): string | null {\n return id.startsWith(DATABASE_PREFIX) ? id.slice(DATABASE_PREFIX.length) : null\n}\n\n// ConfigNode id: `config:<relPath>` where <relPath> is the path relative to\n// the scan root, with forward slashes regardless of platform. ConfigNodes\n// record file existence only (ADR-016).\nexport function configId(relPath: string): string {\n return `${CONFIG_PREFIX}${relPath}`\n}\n\nexport function parseConfigId(id: string): string | null {\n return id.startsWith(CONFIG_PREFIX) ? id.slice(CONFIG_PREFIX.length) : null\n}\n\n// InfraNode id: `infra:<kind>:<name>`. <kind> is a free string sub-type\n// (kafka-topic, redis, grpc-service, lambda, queue, etc.) per ADR-022.\nexport function infraId(kind: string, name: string): string {\n return `${INFRA_PREFIX}${kind}:${name}`\n}\n\nexport function parseInfraId(id: string): { kind: string; name: string } | null {\n if (!id.startsWith(INFRA_PREFIX)) return null\n const rest = id.slice(INFRA_PREFIX.length)\n const colon = rest.indexOf(':')\n if (colon === -1) return null\n return { kind: rest.slice(0, colon), name: rest.slice(colon + 1) }\n}\n\n// FrontierNode id: `frontier:<host>` where <host> is host:port from the OTel\n// peer attribute. Promoted to a typed node id (typically serviceId(...)) once\n// an alias resolves; the FrontierNode is removed and edges are rewritten.\nexport function frontierId(host: string): string {\n return `${FRONTIER_PREFIX}${host}`\n}\n\nexport function parseFrontierId(id: string): string | null {\n return id.startsWith(FRONTIER_PREFIX) ? id.slice(FRONTIER_PREFIX.length) : null\n}\n\n// ──────────────────────────────────────────────────────────────────────────\n// Edge ids (ADR-029, ADR-068)\n// ──────────────────────────────────────────────────────────────────────────\n//\n// Edge id wire format per provenance:\n// EXTRACTED: `${type}:${source}->${target}`\n// OBSERVED: `${type}:OBSERVED:${source}->${target}`\n// INFERRED: `${type}:INFERRED:${source}->${target}`\n// STALE never appears in an edge id; STALE is a transition of an existing\n// OBSERVED edge (ADR-024), not a creation pattern.\n//\n// Per ADR-068, edges to FrontierNodes carry whatever provenance describes\n// how the edge was learned — span-derived edges use observedEdgeId with the\n// FrontierNode id as the target string. Node-type is orthogonal to\n// provenance; the wire format reflects provenance only.\n//\n// Multiple edges between the same node pair coexist under distinct provenance\n// ids — that's what makes the EXTRACTED+OBSERVED coexistence rule\n// (contracts.md Rule 2) mechanically possible.\n\nconst EDGE_ARROW = '->'\n\nexport function extractedEdgeId(source: string, target: string, type: string): string {\n return `${type}:${source}${EDGE_ARROW}${target}`\n}\n\nexport function observedEdgeId(source: string, target: string, type: string): string {\n return `${type}:OBSERVED:${source}${EDGE_ARROW}${target}`\n}\n\nexport function inferredEdgeId(source: string, target: string, type: string): string {\n return `${type}:INFERRED:${source}${EDGE_ARROW}${target}`\n}\n\n// Parse an edge id into its parts. Returns null if the input is not a\n// well-formed edge id — covers all three creation variants (STALE rides on\n// the OBSERVED id format). Useful for consumers (traversal, MCP, persist)\n// that need to walk back from an id.\n//\n// Note: EXTRACTED ids have no provenance segment, so we detect them by\n// checking whether the second segment matches a known provenance marker.\nexport function parseEdgeId(id: string): {\n type: string\n provenance: 'EXTRACTED' | 'OBSERVED' | 'INFERRED'\n source: string\n target: string\n} | null {\n const arrowIdx = id.lastIndexOf(EDGE_ARROW)\n if (arrowIdx === -1) return null\n const left = id.slice(0, arrowIdx)\n const target = id.slice(arrowIdx + EDGE_ARROW.length)\n if (!left || !target) return null\n\n // left is one of:\n // `${type}:${source}` → EXTRACTED\n // `${type}:OBSERVED:${source}` → OBSERVED\n // `${type}:INFERRED:${source}` → INFERRED\n const firstColon = left.indexOf(':')\n if (firstColon === -1) return null\n const type = left.slice(0, firstColon)\n const rest = left.slice(firstColon + 1)\n\n for (const prov of ['OBSERVED', 'INFERRED'] as const) {\n if (rest.startsWith(`${prov}:`)) {\n return { type, provenance: prov, source: rest.slice(prov.length + 1), target }\n }\n }\n return { type, provenance: 'EXTRACTED', source: rest, target }\n}\n\n// ──────────────────────────────────────────────────────────────────────────\n// Provenance ranking (ADR-029, ADR-068)\n// ──────────────────────────────────────────────────────────────────────────\n//\n// Canonical priority used by traversal and any consumer that needs to pick\n// a single edge between two nodes when multiple provenance variants exist.\n// Higher number = higher trust = preferred.\n//\n// Four entries match the four-value Provenance enum (ADR-068). Node-type\n// gating (e.g. \"stop at FrontierNodes\" per contracts.md Rule 3) is enforced\n// at the node level by traversal, independent of edge rank.\nexport const PROV_RANK: Readonly<Record<'OBSERVED' | 'INFERRED' | 'EXTRACTED' | 'STALE', number>> = Object.freeze({\n OBSERVED: 3,\n INFERRED: 2,\n EXTRACTED: 1,\n STALE: 0,\n})\n","import { z } from 'zod'\nimport { ProvenanceSchema, EdgeTypeSchema } from './edges.js'\nimport { NodeTypeSchema } from './constants.js'\n\n// Policy schema (ADR-042). Lives at <projectRoot>/policy.json. Loaded at\n// startup and reloaded on file change. Five rule types, discriminated by\n// `rule.type`. Adding a new rule type requires an ADR amendment plus a\n// corresponding evaluator in the engine (ADR-043).\n\nexport const PolicySeveritySchema = z.enum(['info', 'warning', 'error', 'critical'])\nexport type PolicySeverity = z.infer<typeof PolicySeveritySchema>\n\nexport const PolicyActionSchema = z.enum(['log', 'alert', 'block'])\nexport type PolicyAction = z.infer<typeof PolicyActionSchema>\n\n// rule.type === 'structural' — asserts the existence of an edge between\n// node-type pairs. e.g. \"every ServiceNode must have a CONNECTS_TO edge to a\n// DatabaseNode.\"\nexport const StructuralRuleSchema = z.object({\n type: z.literal('structural'),\n // Node type the rule applies to. Every node of this type must satisfy the\n // edge requirement below.\n fromNodeType: NodeTypeSchema,\n // Required outbound edge type from each fromNodeType node.\n edgeType: EdgeTypeSchema,\n // Required target node type at the other end of the edge.\n toNodeType: NodeTypeSchema,\n})\nexport type StructuralRule = z.infer<typeof StructuralRuleSchema>\n\n// rule.type === 'compatibility' — re-runs `compat.ts` against current graph\n// state. Catches OBSERVED-vs-EXTRACTED divergence: a service whose compat\n// shape failed at extract time stays flagged on every evaluation.\nexport const CompatibilityRuleSchema = z.object({\n type: z.literal('compatibility'),\n // Optional kind narrowing. When omitted, all four compat shapes\n // (driver-engine, node-engine, package-conflict, deprecated-api) run.\n kind: z\n .enum(['driver-engine', 'node-engine', 'package-conflict', 'deprecated-api'])\n .optional(),\n})\nexport type CompatibilityRule = z.infer<typeof CompatibilityRuleSchema>\n\n// rule.type === 'provenance' — asserts that edges of a given type to a given\n// target carry a specific provenance (or one of a set). e.g. \"every CALLS\n// edge to service:payments must have OBSERVED provenance.\"\nexport const ProvenanceRuleSchema = z.object({\n type: z.literal('provenance'),\n // Edge type the rule applies to.\n edgeType: EdgeTypeSchema,\n // Target node id (e.g. 'service:payments') that incoming edges of edgeType\n // must satisfy. Optional — when omitted, the rule runs against every edge\n // of edgeType regardless of target.\n targetNodeId: z.string().optional(),\n // Required provenance (single value or one-of). The audit fails if the\n // observed edge's provenance is not in this set.\n required: z.union([ProvenanceSchema, z.array(ProvenanceSchema).min(1)]),\n})\nexport type ProvenanceRule = z.infer<typeof ProvenanceRuleSchema>\n\n// rule.type === 'ownership' — every node of nodeType must declare an `owner`\n// field. The field name lives on the node attributes; the rule fires when a\n// node of the type doesn't carry it (or carries an empty string).\nexport const OwnershipRuleSchema = z.object({\n type: z.literal('ownership'),\n // Node type the rule applies to. ServiceNode is the common case; the\n // discriminator stays generic so future node types can opt in.\n nodeType: NodeTypeSchema,\n // Field name on the node attributes that must be non-empty. Defaults to\n // 'owner' if omitted.\n field: z.string().default('owner'),\n})\nexport type OwnershipRule = z.infer<typeof OwnershipRuleSchema>\n\n// rule.type === 'blast-radius' — no node of the given type may have more\n// than `maxAffected` transitively-affected downstream nodes. Computed via\n// getBlastRadius at evaluation time.\nexport const BlastRadiusRuleSchema = z.object({\n type: z.literal('blast-radius'),\n // Node type the rule applies to (ServiceNode is the common case).\n nodeType: NodeTypeSchema,\n // Cap on `totalAffected` from getBlastRadius. Inclusive — a node hitting\n // exactly this number passes; > maxAffected fails.\n maxAffected: z.number().int().positive(),\n // Depth to evaluate against. Defaults to the contract's blast-radius\n // default (10) when omitted.\n depth: z.number().int().positive().optional(),\n})\nexport type BlastRadiusRule = z.infer<typeof BlastRadiusRuleSchema>\n\nexport const PolicyRuleSchema = z.discriminatedUnion('type', [\n StructuralRuleSchema,\n CompatibilityRuleSchema,\n ProvenanceRuleSchema,\n OwnershipRuleSchema,\n BlastRadiusRuleSchema,\n])\nexport type PolicyRule = z.infer<typeof PolicyRuleSchema>\n\nexport const PolicySchema = z.object({\n // Unique within the file. Duplicates fail PolicyFileSchema.parse.\n id: z.string().min(1),\n name: z.string().min(1),\n description: z.string().optional(),\n severity: PolicySeveritySchema,\n // When omitted, the engine derives a default from severity per ADR-044\n // (info→log, warning→alert, error→alert, critical→block).\n onViolation: PolicyActionSchema.optional(),\n rule: PolicyRuleSchema,\n})\nexport type Policy = z.infer<typeof PolicySchema>\n\n// Top-level shape of policy.json. version: z.literal(1) — bumping requires\n// an ADR amendment per the schema-growth contract (ADR-031).\nexport const PolicyFileSchema = z\n .object({\n version: z.literal(1),\n policies: z.array(PolicySchema),\n })\n .superRefine((file, ctx) => {\n // id uniqueness is enforced at parse time, not at registry-add time.\n // Duplicates collapse silently otherwise — we'd evaluate the second one\n // and lose the first.\n const seen = new Set<string>()\n for (const [i, p] of file.policies.entries()) {\n if (seen.has(p.id)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['policies', i, 'id'],\n message: `duplicate policy id \"${p.id}\"`,\n })\n }\n seen.add(p.id)\n }\n })\nexport type PolicyFile = z.infer<typeof PolicyFileSchema>\n\n// Emitted by the evaluator. Appended to policy-violations.ndjson.\n// Deterministic id (per ADR-043) means re-evaluating the same graph + same\n// policies produces the same violation ids; the writer skips duplicates.\n// Hypothetical action for POST /policies/check (ADR-045). Each action shape\n// names a candidate change to the graph; the engine simulates it and returns\n// any violations that *would* result. MVP scope is the two action shapes\n// below; new shapes need an ADR amendment.\nexport const HypotheticalActionSchema = z.discriminatedUnion('kind', [\n z.object({\n kind: z.literal('promote-frontier'),\n // The FrontierNode id that would be promoted.\n frontierId: z.string().min(1),\n }),\n z.object({\n kind: z.literal('add-edge'),\n source: z.string().min(1),\n target: z.string().min(1),\n edgeType: EdgeTypeSchema,\n provenance: ProvenanceSchema,\n }),\n])\nexport type HypotheticalAction = z.infer<typeof HypotheticalActionSchema>\n\n// Body of POST /policies/check.\nexport const PoliciesCheckBodySchema = z.object({\n hypotheticalAction: HypotheticalActionSchema.optional(),\n})\nexport type PoliciesCheckBody = z.infer<typeof PoliciesCheckBodySchema>\n\n// Scope filter for the check_policies MCP tool. 'all' (default) returns\n// every current violation; 'unresolved' is reserved for future resolution\n// tracking and behaves like 'all' for the MVP; { policyId } narrows to one\n// named policy.\nexport const CheckPoliciesScopeSchema = z.union([\n z.enum(['all', 'unresolved']),\n z.object({ policyId: z.string().min(1) }),\n])\nexport type CheckPoliciesScope = z.infer<typeof CheckPoliciesScopeSchema>\n\nexport const PolicyViolationSchema = z.object({\n // ${policy.id}:${violation-context}. The violation-context is shape-\n // specific (e.g. nodeId for structural; edgeId for provenance).\n id: z.string().min(1),\n policyId: z.string().min(1),\n policyName: z.string().min(1),\n severity: PolicySeveritySchema,\n // Resolved at evaluation time — either the explicit policy.onViolation or\n // the severity-derived default per ADR-044.\n onViolation: PolicyActionSchema,\n ruleType: z.enum(['structural', 'compatibility', 'provenance', 'ownership', 'blast-radius']),\n subject: z\n .object({\n nodeId: z.string().optional(),\n edgeId: z.string().optional(),\n path: z.array(z.string()).optional(),\n })\n .refine(\n (s) => s.nodeId !== undefined || s.edgeId !== undefined || s.path !== undefined,\n { message: 'subject must carry at least one of nodeId, edgeId, path' },\n ),\n message: z.string().min(1),\n observedAt: z.string().datetime(),\n})\nexport type PolicyViolation = z.infer<typeof PolicyViolationSchema>\n","import { z } from 'zod'\n\n// Machine-level project registry (ADR-048). Single file at\n// `~/.neat/projects.json`, per-user, machine-local. The wire shape lives here\n// so the registry module and the daemon agree on it without a circular\n// dependency through @neat.is/core.\n\nexport const RegistryStatusSchema = z.enum(['active', 'paused', 'broken'])\nexport type RegistryStatus = z.infer<typeof RegistryStatusSchema>\n\nexport const RegistryEntrySchema = z.object({\n // Unique within the registry. Project-scoped operations (`neat watch\n // --project <name>`, `neatd reload <name>`) key on this. Collisions are a\n // hard error at registration time.\n name: z.string().min(1),\n // Resolved absolute path on disk. Path normalisation is what keeps two\n // `neat init` calls from different relative paths from creating two entries\n // for the same directory.\n path: z.string().min(1),\n // ISO8601, set at first registration.\n registeredAt: z.string(),\n // ISO8601, updated whenever the daemon successfully sees the project.\n // Optional because a freshly-registered project hasn't been seen yet.\n lastSeenAt: z.string().optional(),\n // Languages detected at `init` time. Free-form strings keyed off the\n // installer modules — `'javascript'`, `'python'`, …\n languages: z.array(z.string()),\n status: RegistryStatusSchema,\n})\nexport type RegistryEntry = z.infer<typeof RegistryEntrySchema>\n\nexport const RegistryFileSchema = z.object({\n version: z.literal(1),\n projects: z.array(RegistryEntrySchema),\n})\nexport type RegistryFile = z.infer<typeof RegistryFileSchema>\n\nexport const EMPTY_REGISTRY: RegistryFile = { version: 1, projects: [] }\n","// Divergence — the thesis surface (ADR-060). A typed result describing\n// places where what the code declares (EXTRACTED) doesn't match what\n// production observed (OBSERVED). Five locked variants discriminated by\n// `type`; new shapes require a successor ADR.\n//\n// The schema lives here because consumers across the stack (REST, MCP,\n// CLI, future frontend) need to validate the wire shape against the same\n// definition. Computation lives in packages/core/src/divergences.ts —\n// pure functions over a NeatGraph; no I/O, no mutation.\n\nimport { z } from 'zod'\nimport { EdgeTypeSchema, GraphEdgeSchema } from './edges.js'\n\nconst commonFields = {\n source: z.string(),\n target: z.string(),\n confidence: z.number().min(0).max(1),\n reason: z.string(),\n recommendation: z.string(),\n}\n\nexport const MissingObservedDivergenceSchema = z.object({\n type: z.literal('missing-observed'),\n ...commonFields,\n edgeType: EdgeTypeSchema,\n extracted: GraphEdgeSchema,\n})\nexport type MissingObservedDivergence = z.infer<typeof MissingObservedDivergenceSchema>\n\nexport const MissingExtractedDivergenceSchema = z.object({\n type: z.literal('missing-extracted'),\n ...commonFields,\n edgeType: EdgeTypeSchema,\n observed: GraphEdgeSchema,\n})\nexport type MissingExtractedDivergence = z.infer<typeof MissingExtractedDivergenceSchema>\n\n// 'incompatible' = compat.json rule fires definitively.\n// 'deprecated' = compat.json deprecated-api rule fires.\n// 'unknown' = engine version present but no compat rule covers it.\nexport const CompatibilityVerdictSchema = z.enum(['incompatible', 'deprecated', 'unknown'])\nexport type CompatibilityVerdict = z.infer<typeof CompatibilityVerdictSchema>\n\nexport const VersionMismatchDivergenceSchema = z.object({\n type: z.literal('version-mismatch'),\n ...commonFields,\n extractedVersion: z.string(),\n observedVersion: z.string(),\n compatibility: CompatibilityVerdictSchema,\n})\nexport type VersionMismatchDivergence = z.infer<typeof VersionMismatchDivergenceSchema>\n\nexport const HostMismatchDivergenceSchema = z.object({\n type: z.literal('host-mismatch'),\n ...commonFields,\n extractedHost: z.string(),\n observedHost: z.string(),\n})\nexport type HostMismatchDivergence = z.infer<typeof HostMismatchDivergenceSchema>\n\n// Free-shape reference to the compat.json rule that fired — kept as a plain\n// record so the schema stays insulated from compat.ts's internal types. The\n// `rule` field carries enough metadata to identify which rule + why.\nexport const CompatRuleRefSchema = z.object({\n kind: z.string(),\n reason: z.string(),\n package: z.string().optional(),\n driver: z.string().optional(),\n engine: z.string().optional(),\n})\nexport type CompatRuleRef = z.infer<typeof CompatRuleRefSchema>\n\nexport const CompatViolationDivergenceSchema = z.object({\n type: z.literal('compat-violation'),\n ...commonFields,\n rule: CompatRuleRefSchema,\n observed: GraphEdgeSchema,\n})\nexport type CompatViolationDivergence = z.infer<typeof CompatViolationDivergenceSchema>\n\nexport const DivergenceSchema = z.discriminatedUnion('type', [\n MissingObservedDivergenceSchema,\n MissingExtractedDivergenceSchema,\n VersionMismatchDivergenceSchema,\n HostMismatchDivergenceSchema,\n CompatViolationDivergenceSchema,\n])\nexport type Divergence = z.infer<typeof DivergenceSchema>\n\nexport const DivergenceResultSchema = z.object({\n divergences: z.array(DivergenceSchema),\n totalAffected: z.number().int().nonnegative(),\n // ISO8601 timestamp the result was computed at. Each call re-derives from\n // the live graph — there is no persisted divergence history.\n computedAt: z.string().datetime(),\n})\nexport type DivergenceResult = z.infer<typeof DivergenceResultSchema>\n\n// Locked set of divergence types. Consumers (REST query parser, CLI flag\n// parser) validate the user-supplied filter against this enum.\nexport const DivergenceTypeSchema = z.enum([\n 'missing-observed',\n 'missing-extracted',\n 'version-mismatch',\n 'host-mismatch',\n 'compat-violation',\n])\nexport type DivergenceType = z.infer<typeof DivergenceTypeSchema>\n","import { z } from 'zod'\nimport { GraphEdgeSchema } from './edges.js'\nimport { GraphNodeSchema } from './nodes.js'\nimport { ErrorEventSchema, StaleEventSchema } from './events.js'\nimport { PolicyViolationSchema } from './policy.js'\nimport { RegistryEntrySchema } from './registry.js'\n\n// ADR-061 envelope rule: every GET response is a JSON object. List endpoints\n// wrap in plural-noun fields plus a count; single-item endpoints wrap the\n// item in a singular field. Bare arrays are a contract violation.\n\n// `count` is the length of the returned array; `total` is the size of the\n// underlying collection before filtering / limiting.\nconst listEnvelope = <T extends z.ZodTypeAny>(itemSchema: T) =>\n z.object({\n count: z.number().int().nonnegative(),\n total: z.number().int().nonnegative(),\n events: z.array(itemSchema),\n })\n\nexport const IncidentsResponseSchema = listEnvelope(ErrorEventSchema)\nexport type IncidentsResponse = z.infer<typeof IncidentsResponseSchema>\n\nexport const StaleEventsResponseSchema = listEnvelope(StaleEventSchema)\nexport type StaleEventsResponse = z.infer<typeof StaleEventsResponseSchema>\n\nexport const PoliciesViolationsResponseSchema = z.object({\n violations: z.array(PolicyViolationSchema),\n})\nexport type PoliciesViolationsResponse = z.infer<typeof PoliciesViolationsResponseSchema>\n\nexport const GraphNodeResponseSchema = z.object({\n node: GraphNodeSchema,\n})\nexport type GraphNodeResponse = z.infer<typeof GraphNodeResponseSchema>\n\nexport const GraphEdgesResponseSchema = z.object({\n inbound: z.array(GraphEdgeSchema),\n outbound: z.array(GraphEdgeSchema),\n})\nexport type GraphEdgesResponse = z.infer<typeof GraphEdgesResponseSchema>\n\n// `.passthrough()` because the handler keeps legacy fields (uptime,\n// nodeCount, edgeCount, lastUpdated) for the web shell's StatusBar. The\n// canonical triple is what's required; the extras ride along.\nexport const HealthResponseSchema = z\n .object({\n ok: z.boolean(),\n project: z.string(),\n uptimeMs: z.number().int().nonnegative(),\n })\n .passthrough()\nexport type HealthResponse = z.infer<typeof HealthResponseSchema>\n\n// Daemon-wide /health (issue #343). Distinct from `HealthResponseSchema`\n// because the unscoped probe doesn't have a single project to report on —\n// readiness lives at the daemon level. `projects` is a flat array of every\n// slot currently loaded so a probe consumer can decide which subset to\n// poll per-project /health on.\nexport const DaemonHealthResponseSchema = z\n .object({\n ok: z.boolean(),\n uptimeMs: z.number().int().nonnegative(),\n projects: z.array(\n z.object({\n name: z.string(),\n nodeCount: z.number().int().nonnegative(),\n edgeCount: z.number().int().nonnegative(),\n }).passthrough(),\n ),\n })\n .passthrough()\nexport type DaemonHealthResponse = z.infer<typeof DaemonHealthResponseSchema>\n\nexport const SingleProjectResponseSchema = z.object({\n project: RegistryEntrySchema,\n})\nexport type SingleProjectResponse = z.infer<typeof SingleProjectResponseSchema>\n\n// /search matches are graph nodes with an added per-match score. The\n// schema keeps `score` mandatory and lets the underlying node shape pass\n// through — GraphNodeSchema is a discriminated union and tightening here\n// would force every match into one variant.\nexport const SearchMatchSchema = z\n .object({ score: z.number() })\n .passthrough()\nexport type SearchMatch = z.infer<typeof SearchMatchSchema>\n\nexport const SearchResponseSchema = z.object({\n query: z.string(),\n provider: z.string(),\n matches: z.array(SearchMatchSchema),\n})\nexport type SearchResponse = z.infer<typeof SearchResponseSchema>\n\n// Live snapshot returned by GET /graph. Mirrors the in-memory graphology\n// instance; nothing reads graph.json at request time (Rule 6).\nexport const SerializedGraphSchema = z.object({\n nodes: z.array(GraphNodeSchema),\n edges: z.array(GraphEdgeSchema),\n})\nexport type SerializedGraph = z.infer<typeof SerializedGraphSchema>\n\n// GET /graph/diff response. The diff module owns the implementation;\n// the schema mirrors its current GraphDiff interface.\nexport const GraphDiffResultSchema = z.object({\n base: z.object({ exportedAt: z.string().optional() }),\n current: z.object({ exportedAt: z.string() }),\n added: z.object({\n nodes: z.array(GraphNodeSchema),\n edges: z.array(GraphEdgeSchema),\n }),\n removed: z.object({\n nodes: z.array(GraphNodeSchema),\n edges: z.array(GraphEdgeSchema),\n }),\n changed: z.object({\n nodes: z.array(\n z.object({\n id: z.string(),\n before: GraphNodeSchema,\n after: GraphNodeSchema,\n }),\n ),\n edges: z.array(\n z.object({\n id: z.string(),\n before: GraphEdgeSchema,\n after: GraphEdgeSchema,\n }),\n ),\n }),\n})\nexport type GraphDiffResult = z.infer<typeof GraphDiffResultSchema>\n","// Confidence grading helpers — single source of truth for ADR-066.\n//\n// EXTRACTED is graded at emit time per producer; OBSERVED is graded by the\n// signal block on the edge. PROV_RANK still locks tier ordering. The grading\n// sits within each tier so the divergence query can reweight against honest\n// values, not flat coarse ones.\n//\n// Producers in packages/core/src/extract/ import `confidenceForExtracted`\n// and pass the producer kind; ingest.ts imports `confidenceForObservedSignal`\n// and calls it at the same point it writes the signal block.\n\nimport type { EdgeSignal } from './edges.js'\n\n// Discriminator that producers pass when emitting an EXTRACTED edge. Each\n// kind maps to a numeric grade; the divergence query treats sub-floor\n// candidates as if they never existed (precision floor, NEAT_EXTRACTED_PRECISION_FLOOR).\nexport type ExtractedConfidenceKind =\n // 0.85 — direct AST / file facts. ConfigNode existence (ADR-016), package.json\n // deps, AST imports, Dockerfile RUNS_ON, docker-compose depends_on, parsed\n // database config files. Structural — what the code says it does.\n | 'structural'\n // 0.85 — framework-aware call-site recognizer matched the SDK shape. Today's\n // covers kafkajs producer.send / consumer.subscribe, AWS SDK Bucket/TableName\n // near a *Client, grpc-js Client construction with the import context, and\n // import-aware *Client classification (#238).\n | 'verified-call-site'\n // 0.5 — URL-shaped literal with structural support. Today's `redis://host` /\n // `rediss://host` URL captures fit here: the scheme proves it's a redis URL,\n // but there's no call expression verifying it's actually wired into the\n // service's runtime path.\n | 'url-with-structural-support'\n // 0.2 — bare URL/hostname match against a registered service. urlMatchesHost\n // requires scheme + exact hostname so this is structurally tight, but no\n // framework-aware recognizer confirms the call. Drops below the default\n // precision floor (0.7) and never enters the graph unless the floor is\n // lowered for diagnostics.\n | 'hostname-shape-match'\n\nexport const EXTRACTED_CONFIDENCE: Record<ExtractedConfidenceKind, number> = {\n structural: 0.85,\n 'verified-call-site': 0.85,\n 'url-with-structural-support': 0.5,\n 'hostname-shape-match': 0.2,\n}\n\nexport function confidenceForExtracted(kind: ExtractedConfidenceKind): number {\n return EXTRACTED_CONFIDENCE[kind]\n}\n\n// OBSERVED grading from the signal block (ADR-066 §2). The piecewise function\n// reflects the three buckets the ADR locks plus the error-ratio adjustment.\n// `lastObservedAgeMs` defaults to 0 (just-observed) when the caller doesn't\n// pass a signal — upsertObservedEdge writes 0 on creation and on every span\n// update; the staleness loop is the only thing that lets the age drift.\n\nconst STRONG_SPAN_THRESHOLD = 100\nconst GOOD_SPAN_THRESHOLD = 10\nconst RECENT_AGE_MS = 60 * 60 * 1000\n\nexport function confidenceForObservedSignal(signal: EdgeSignal | undefined): number {\n // No signal block — fall back to the strong-tier ceiling. This case is\n // legacy edges loaded from a pre-v0.3.4 snapshot or hand-written test\n // fixtures; new producers always write the signal block.\n if (!signal) return 1.0\n const { spanCount, errorCount } = signal\n const ageMs = signal.lastObservedAgeMs ?? 0\n const recent = ageMs < RECENT_AGE_MS\n\n let base: number\n if (spanCount >= STRONG_SPAN_THRESHOLD && recent) {\n // Strong tier. Scale linearly from 0.95 at the threshold up to 1.0 at\n // 10× the threshold. Saturates at 1.0 above that.\n const over = Math.min(1, (spanCount - STRONG_SPAN_THRESHOLD) / (9 * STRONG_SPAN_THRESHOLD))\n base = 0.95 + 0.05 * over\n } else if (spanCount >= GOOD_SPAN_THRESHOLD && recent) {\n // Good tier. 0.7 at the threshold up to 0.9 just below the strong tier.\n const range = STRONG_SPAN_THRESHOLD - GOOD_SPAN_THRESHOLD\n const over = (spanCount - GOOD_SPAN_THRESHOLD) / range\n base = 0.7 + 0.2 * over\n } else if (spanCount > 0 && recent) {\n // Weak tier. 0.4 at one span up to 0.6 just below the good tier.\n const range = GOOD_SPAN_THRESHOLD - 1\n const over = range > 0 ? (spanCount - 1) / range : 0\n base = 0.4 + 0.2 * over\n } else if (spanCount > 0) {\n // Not recent — clamp the weak tier; staleness loop will demote this edge\n // to STALE on the next tick.\n base = 0.4\n } else {\n // Defensive: no spans on an OBSERVED edge means the upsert path was\n // skipped somewhere. Treat as no-evidence rather than max-trust.\n base = 0.4\n }\n\n // Error-ratio penalty. errorCount / spanCount on a healthy edge is 0; on a\n // failing edge it climbs. Subtract up to 0.2.\n if (spanCount > 0 && errorCount > 0) {\n const ratio = Math.min(1, errorCount / spanCount)\n base -= 0.2 * ratio\n }\n\n if (base < 0) return 0\n if (base > 1) return 1\n return Math.round(base * 1000) / 1000\n}\n\n// Precision-floor helpers (ADR-066 §3). The floor reads the\n// NEAT_EXTRACTED_PRECISION_FLOOR env var on each call so tests can flip it\n// in-process. Default 0.7. NEAT_EXTRACTED_PRECISION_FLOOR=0.0 keeps every\n// candidate (diagnostic mode).\n\nexport const DEFAULT_EXTRACTED_PRECISION_FLOOR = 0.7\n\nexport function extractedPrecisionFloor(): number {\n const raw = process.env.NEAT_EXTRACTED_PRECISION_FLOOR\n if (raw === undefined) return DEFAULT_EXTRACTED_PRECISION_FLOOR\n const n = Number(raw)\n if (!Number.isFinite(n) || n < 0 || n > 1) return DEFAULT_EXTRACTED_PRECISION_FLOOR\n return n\n}\n\nexport function passesExtractedFloor(confidence: number): boolean {\n return confidence >= extractedPrecisionFloor()\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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