/** * Live observation without persistence — call each plugin's `describeResources()` * for an environment and collect the results as `LiveObservation[]`, ready to * project into the graph IR (`buildLiveGraphIr`, ../graph-ir.ts) for * `chant graph --live`. * * This is the read half of what `takeSnapshot` (./snapshot.ts) does before it * validates + writes to git: same per-plugin build-output/entities assembly, no * side effects. Snapshotting keeps its own copy for now; a future refactor can * fold both onto this primitive. */ import type { ObservationLexicon } from "../lexicon.js"; import type { BuildResult } from "../build.js"; import type { LiveObservation, IREdge } from "../graph-ir.js"; import type { ResourceMetadata } from "../lexicon.js"; export interface ObserveResult { observations: LiveObservation[]; warnings: string[]; errors: string[]; /** * Run-level notices from the lexicons (#1265), each said once however many * stacks or lexicons reported it — "ownership filter unavailable on this * read path" is the canonical one. Kept apart from `warnings`, which are * per-entity, so a caller can print them where a note belongs: after the * answer, not ahead of it. */ notes: string[]; } /** * Query every plugin that implements `describeResources` for its resources in * `environment`. `owned` (default true for the managed-only diagram, epic #776) * restricts to resources carrying chant's ownership marker; a lexicon with no * marker channel logs and returns everything (its own contract). Plugins that * throw are collected into `errors` — one failing lexicon never sinks the whole * graph — and every entity they were asked about is recorded as NOT-OBSERVED * (`read-failed`, #1089) rather than dropped, so a failed read is visibly a * hole instead of a silent absence. * * `stacks` (#57) is for a multi-stack, per-component project (e.g. loomster) * where there is no single stack named after the environment — AWS's * single-stack convention (`lexicons/aws/src/plugin.ts`'s `describeResources`, * absent an explicit `stack`) queries a stack that simply doesn't exist there, * so the single-call path always observes zero nodes. When `stacks` is * present and non-empty, each observing plugin's `describeResources` is * called once per stack and the returned observations are merged. A stack entry * may be a bare name or `{ name, region?, src? }` (#1162): `src` is built * SCOPED so the deployed BARE LogicalResourceIds match (the whole-project build * disambiguates colliding names to `UsWest1Src…`, which the live ids never * carry), and a scoped stack's observed ids are qualified `${stack}::${id}` so * the same bare id in two stacks stays distinct. A bare-string stack keeps its * bare ids and the tri-state merge (#57). When `stacks` is absent or empty, behavior is * exactly the single call of before (no `stack` key at all), so a single-stack * project is unaffected. */ export declare function observeResources(environment: string, plugins: ObservationLexicon[], buildResult: BuildResult, opts?: { owned?: boolean; stacks?: Array; /** Also report resources of a managed kind that nothing declares or * references (#1278). Opt-in: it asks the provider what exists rather than * resolving out from what is declared. */ ambient?: boolean; /** Where to read an entity that declares no namespace of its own (#1629). * Passed through to every lexicon's `describeResources`; one that has no * namespace-like scope ignores it. */ namespace?: string; }): Promise; /** * Ask a lexicon what exists of the kinds it manages, beyond what is declared * (#1278). Once per stack for the region, merged by physical id — the same * ambient resource seen from two stacks is one resource. * * "The same" is per region (#1416). Two stacks in one region reporting the * account's default security group is one group; two regions' default security * groups are two, whatever their ids look like, so the merge key carries the * region a resource records itself in. */ export declare function collectAmbient(plugin: ObservationLexicon, opts: { environment: string; kinds: string[]; observed: Record; stacks: Array<{ name: string; region?: string; src?: string; }>; warnings: string[]; }): Promise>; /** Dependencies collected across a lexicon's stacks, plus anything to report. */ export interface CollectedDependencies { resources: Record; edges: IREdge[]; warnings: string[]; } /** * Ask a lexicon what its declared estate references but does not manage (#1273). * * Called once per stack, because the closure roots and the region differ per * stack, and merged by key. Dependencies are keyed by physical id and are * deliberately NOT stack-qualified: the account's default VPC route table is the * same resource whichever stack routes through it, and qualifying it would * produce one node per referrer and an edge to each. * * Best-effort. A lexicon that does not implement the hook, or one whose read * fails, contributes nothing — the managed observation is already complete and * useful on its own, and failing it because an ambient dependency could not be * read would trade a whole answer for a partial one. */ export declare function collectDependencies(plugin: ObservationLexicon, opts: { environment: string; entities: Map; }>; observed: Record; stacks: Array<{ name: string; region?: string; src?: string; }>; }): Promise; //# sourceMappingURL=observe.d.ts.map