/** * The `vg-graph/1.1` on-disk schema. * * This is vg's own open schema (VG-PACKAGE-AND-SCHEMA.md §4) — informed by good * ideas (content-hashed ids, epistemic typing of facts) but standalone and * self-contained. Every collection is deterministically serialized * (sorted keys, stable element order). These TypeScript shapes are normative. * * ## Version history * * - `vg-graph/1.0` — code-only vocabulary. * - `vg-graph/1.1` — **additive**: toolchain node kinds (`resource`, `workload`, * `job`, `step`, `image`, `chart`) and toolchain edge kinds (`depends_on`, * `provisions`, `deploys`, `triggers`, `exposes`, `mounts`, `builds_from`), * produced by `engine/toolchain/`. Nothing was removed or renamed, so a 1.0 * reader that tolerates unknown kinds reads a 1.1 graph correctly; readers * that hard-match the version string need widening (see * `SUPPORTED_SCHEMA_VERSIONS`). */ declare const SCHEMA_VERSION: "vg-graph/1.1"; /** * Schema versions a reader should accept. The toolchain vocabulary added in 1.1 * is purely additive, so a 1.0 artifact still loads — only the newer kinds are * absent from it. Readers must prefer this over an equality check on * {@link SCHEMA_VERSION}, which rejects perfectly readable older graphs. */ declare const SUPPORTED_SCHEMA_VERSIONS: readonly ["vg-graph/1.0", "vg-graph/1.1"]; type SupportedSchemaVersion = (typeof SUPPORTED_SCHEMA_VERSIONS)[number]; type ResolverKind = 'scip' | 'stackgraph' | 'tsc' | 'heuristic'; /** Coarse, honest resolution tier for an edge (see engine/epistemic.ts). */ type EpistemicTier = 'observed' | 'name-matched' | 'declared'; /** * The toolchain that produced this graph — the reproducibility fingerprint. * Everything here deterministically affects graph *content* (parse trees change * between grammar releases; resolvers change which edges resolve), so a CI run * and a laptop run that disagree can be caught by comparing `fingerprint`. * Deliberately excludes the Node/OS version so the graph stays byte-stable * across host runtimes; `fingerprint` pins the parse/resolve toolchain only. */ interface Toolchain { schema: string; tool: string; grammars: string; resolvers: ResolverKind[]; fingerprint: string; } interface Provenance { tool: 'vg'; version: string; grammars: Record; resolver: ResolverKind[]; deep: boolean; semanticModel?: string; corpusHash: string; toolchain?: Toolchain; } /** Analysis cost tier — auto-selected by node count (or forced). Reported honestly. */ type AnalysisTier = 'full' | 'large' | 'xl'; interface GraphMeta { root: string; languages: string[]; counts: { nodes: number; edges: number; areas: number; tests: number; untested: number; }; cluster: 'leiden' | 'louvain' | 'none'; /** Auto-selected (or forced) analysis tier for large maps. */ analysisTier?: AnalysisTier; edgeKinds: EdgeKind[]; } type NodeKind = 'file' | 'module' | 'package' | 'class' | 'interface' | 'function' | 'method' | 'property' | 'test' | 'route' | 'component' /** Documentation / config text ingested for semantic ask (markdown, txt, env examples). */ | 'document' | 'external' /** A declared infrastructure object: Terraform resource/data, K8s object, Compose service. */ | 'resource' /** A deployable unit that runs containers (Deployment, StatefulSet, DaemonSet, Job, CronJob). */ | 'workload' /** A CI job (GitHub Actions job, GitLab CI job). */ | 'job' /** A single step within a CI job. */ | 'step' /** A container image reference (`ghcr.io/acme/web:1.2.3`) or a Dockerfile build stage. */ | 'image' /** A Helm chart (from `Chart.yaml`). */ | 'chart'; interface Span { start: number; end: number; } interface Centrality { degree: number; pagerank: number; betweenness: number; eigenvector: number; } interface GraphNode { id: string; kind: NodeKind; name: string; qualifiedName: string; file: string; span: Span; lang: string; visibility?: 'public' | 'private' | 'protected' | 'internal'; signature?: string; doc?: string; importance: number; centrality: Centrality; area: number; isHub: boolean; tested: boolean | null; coverage?: number; changeCoupling?: string[]; } type EdgeKind = 'call' | 'import' | 'contains' | 'extends' | 'implements' | 'references' | 'test' | 'coverage' /** Declared ordering/reference dependency (Terraform `depends_on` + interpolation, Compose `depends_on`, CI `needs`). */ | 'depends_on' /** An IaC declaration creates infrastructure (Terraform module → resource, chart → workload). */ | 'provisions' /** A CI job or IaC declaration puts a workload/image into an environment. */ | 'deploys' /** An event or upstream job causes a workflow/job to run. */ | 'triggers' /** A workload/service publishes a port or endpoint. */ | 'exposes' /** A workload/service consumes a volume, config map, or secret *by reference*. */ | 'mounts' /** A build stage or workload is derived from a container image. */ | 'builds_from'; interface GraphEdge { id: string; kind: EdgeKind; src: string; dst: string; resolution: ResolverKind; confidence: number; epistemic?: EpistemicTier; surprise?: number; count?: number; } interface Area { id: number; label: string; size: number; members: string[]; cohesion: number; externalEdges: number; } type FactKind = 'contract' | 'invariant' | 'characterization'; type DerivedBy = 'declared' | 'static'; type FactConfidence = 'Observed' | 'Derived'; interface Fact { id: string; kind: FactKind; subjectIds: string[]; predicate: unknown; derivedBy: DerivedBy; confidence: FactConfidence; evidence: { file: string; span: Span; }[]; } /** * A reference the graph could not resolve — surfaced by `vg unknowns`. Reporting * what it *cannot* connect (ranked by blast radius) is the honest inverse of a * scanner that hides its unknowns. Only unknowns the precise rungs (tsc/scip) * did not supersede are recorded, so a compiler-resolved file never shows here. */ interface Unknown { from: string; name: string; kind: 'call' | 'extends' | 'implements'; count: number; } type GroundingKind = 'should_follow' | 'smells_like' | 'relevant_to'; interface GroundingEdge { src: string; packEntryId: string; kind: GroundingKind; confidence: number; rationale: 'recommended' | 'conjectured'; citation: { title: string; url: string; }; } /** Precomputed hub blast-radius counts for fast agent answers (optional). */ interface HubBlastSummary { id: string; name: string; kind: string; file: string; importance: number; direct: number; depth2: number; files: number; tested: boolean | null; } interface GraphSummaries { hubs: HubBlastSummary[]; } interface VgGraph { /** * The schema this artifact was written against. A freshly built graph always * carries {@link SCHEMA_VERSION}; a graph *loaded* from disk may carry any * member of {@link SUPPORTED_SCHEMA_VERSIONS}, since older artifacts stay * readable (the 1.1 additions are additive). */ schemaVersion: SupportedSchemaVersion; generatedAt: string; provenance: Provenance; meta: GraphMeta; nodes: GraphNode[]; edges: GraphEdge[]; areas: Area[]; facts?: Fact[]; grounding?: GroundingEdge[]; unknowns?: Unknown[]; /** Build-time hub blast-radius summaries (always on; tiny). */ summaries?: GraphSummaries; } /** A definition extracted from one file (pre-resolution, pre-id). */ interface RawDef { kind: NodeKind; name: string; qualifiedName: string; startLine: number; endLine: number; startByte: number; endByte: number; signature?: string; doc?: string; visibility?: 'public' | 'private' | 'protected' | 'internal'; } interface RawCall { callee: string; byte: number; line: number; /** True when the call site had a receiver/qualifier (`obj.foo()`, `pkg::foo()`); the receiver itself is not captured. */ qualified?: boolean; } interface RawImport { source: string; } interface RawHeritage { superName: string; byte: number; kind: 'extends' | 'implements'; } /** A type used as a constructor parameter or field's declared type — a * structural dependency (e.g. Spring constructor/field injection) rather than * an invocation. Resolved to a `references` edge, not a `call` edge. */ interface RawTypeRef { name: string; byte: number; } interface RawGuard { expr: string; line: number; } /** The full result of parsing a single file. */ interface FileParse { rel: string; lang: string; hash: string; bytes: number; defs: RawDef[]; calls: RawCall[]; imports: RawImport[]; heritage: RawHeritage[]; typeRefs: RawTypeRef[]; guards: RawGuard[]; /** * Namespaces this file declares (C#/package-scoped langs). Used to resolve a * cross-directory reference when the caller `using`-imports the namespace the * target is declared in — the correct scoping rule for C#, where a namespace * is decoupled from the directory (unlike Java/Go, where package == dir). * Empty/absent for languages with no namespace query. */ namespaces?: string[]; /** * Architecture role hits extracted from the same tree as defs/calls. * Omit when none (absent ≠ []). */ roles?: Array<{ role: 'controller' | 'service' | 'repository' | 'entity' | 'handler' | 'router'; layer: 'routing' | 'middleware' | 'services' | 'domain' | 'data-access' | 'infrastructure' | 'presentation' | 'config' | 'testing' | 'shared'; confidence: number; signal: string; packId: string; }>; /** Non-fatal issues (e.g. a query that failed to compile for this grammar). */ warnings?: string[]; } export { type Area as A, type Centrality as C, type DerivedBy as D, type EdgeKind as E, type FileParse as F, type GraphNode as G, type HubBlastSummary as H, type NodeKind as N, type Provenance as P, type ResolverKind as R, SCHEMA_VERSION as S, type Toolchain as T, type Unknown as U, type VgGraph as V, type GraphEdge as a, type Fact as b, type GroundingKind as c, type GroundingEdge as d, type AnalysisTier as e, type EpistemicTier as f, type FactConfidence as g, type FactKind as h, type GraphMeta as i, type GraphSummaries as j, SUPPORTED_SCHEMA_VERSIONS as k, type Span as l, type SupportedSchemaVersion as m };