import type { ImpactTrust } from './impact-trust.js'; import type { BaselineIdentity, FingerprintStrategy, Signal, ToolShortId, VerdictPolicy } from '@opensip-cli/core'; /** Default baseline identity for envelopes using the host default fingerprint strategy. */ export declare const DEFAULT_BASELINE_IDENTITY: BaselineIdentity; /** Public JSON schema version for {@link SignalEnvelope}. */ export declare const SIGNAL_ENVELOPE_SCHEMA_VERSION: 2; /** Return true when a value has the structural shape of a SignalEnvelope. */ export declare function isSignalEnvelope(value: unknown): value is SignalEnvelope; /** * Run-level verdict header. `passed` ⇔ "no `critical`/`high` signals"; * `score` is the canonical {@link passRate} over `summary`. */ export interface RunVerdict { readonly score: number; readonly passed: boolean; /** * True when the run was a RUNTIME FAULT (a unit threw/timed-out — `runFaulted` * or any `units[].error`) rather than a findings failure. A fault means the * result is UNKNOWN, not that the code failed the gate, so it is a distinct * outcome (see {@link deriveOutcome}). When `faulted` is true, `passed` is * always false. Optional for forward-compat: legacy envelopes (pre-tri-state) * omit it and degrade to the binary passed/failed. */ readonly faulted?: boolean; readonly summary: { readonly total: number; readonly passed: number; readonly failed: number; readonly errors: number; readonly warnings: number; }; } /** * Per-unit fact sidecar. A "unit" is the neutral umbrella over a fit check, a * graph rule, and a sim scenario (ADR-0011). Carries ONLY what a flat * `Signal[]` cannot express: that a unit ran, whether it errored, and timing. * `passed` ⇔ "that unit emitted no `critical`/`high` signals". */ export interface UnitResult { readonly slug: string; readonly passed: boolean; readonly violationCount?: number; readonly durationMs: number; readonly error?: string; /** * Files the unit validated/scanned this run (fitness's "Validated" column). * A per-unit fact a flat `Signal[]` cannot express — a check that scanned * 450 files and emitted 0 signals still has `filesValidated: 450`. Optional: * graph rules / sim scenarios do not scan files and omit it (the terminal * table renders the column blank for those tools). `itemType` names the * scanned noun (`files` / `packages` / …) for the column label. */ readonly filesValidated?: number; readonly itemType?: string; /** * Findings suppressed by an inline `@fitness-ignore` directive this run * (fitness's "Ignores" column). Like {@link filesValidated}, a per-unit fact * not recoverable from the (post-suppression) signal list; optional and * omitted by tools without a suppression mechanism. */ readonly ignoredCount?: number; } /** Host-stamped provenance describing the declared inputs that produced a run. */ export interface DeclaredInputs { readonly cliVersion: string; readonly nodeVersion: string; readonly packageManager?: string; readonly platform: string; readonly tool: ToolShortId; readonly engineVersion?: string; readonly baselineIdentity?: BaselineIdentity; } /** The one tool-run output envelope. The `CommandResult` payload every tool returns. */ export interface SignalEnvelope { readonly schemaVersion: typeof SIGNAL_ENVELOPE_SCHEMA_VERSION; readonly tool: ToolShortId; readonly recipe?: string; readonly runId: string; readonly createdAt: string; readonly verdict: RunVerdict; readonly units: readonly UnitResult[]; readonly signals: readonly Signal[]; /** * Fingerprint strategy identity used to stamp this envelope's signals * (ADR-0075). Persisted in baseline meta on `--gate-save` and compared on * `--gate-compare`. */ readonly baselineIdentity: BaselineIdentity; /** * Host-stamped provenance for verdict diagnostics. Optional for additive * output compatibility: absence means an older/no-manifest producer. */ readonly declaredInputs?: DeclaredInputs; /** Graph-only edge-fidelity marker, carried over from CliOutput.resolutionMode. */ readonly resolutionMode?: 'exact' | 'fast'; /** * Optional verification trust metadata for scoped runs. Fitness uses this for * `--changed` / `--include-impacted` so downstream agent loops can distinguish * targeted verification from conservative fallback without scraping logs. */ readonly verification?: ImpactTrust; } /** * Input to {@link buildSignalEnvelope}. `signals` are already the wire * currency; `units` carry the per-unit ran/errored/timing facts. `runId` and * `createdAt` are supplied by the caller (formatter-purity contract: no * `Date.now()`/`randomUUID` in this layer, so tests stay deterministic). */ export interface BuildEnvelopeInput { readonly tool: ToolShortId; readonly recipe?: string; readonly runId: string; readonly createdAt: string; readonly units: readonly UnitResult[]; readonly signals: readonly Signal[]; readonly resolutionMode?: 'exact' | 'fast'; readonly verification?: ImpactTrust; /** * The tool's resolved findings policy (ADR-0035). `verdict.passed` is computed * from `(errors, warnings)` against this — replacing the old `errors === 0`. */ readonly policy: VerdictPolicy; /** * `true` when the run faulted OUTSIDE its units — e.g. fit's plugin-load * errors, which occur before any unit exists. Unit-level faults are derived * from `UnitResult.error` and need not be passed here. A faulted run always * FAILs, independent of the findings policy (a crash ≠ "0 errors found"). */ readonly runFaulted: boolean; /** * The tool's baseline-identity strategy (ADR-0036). {@link buildSignalEnvelope} * stamps `Signal.fingerprint` with it at construction, so every envelope * reaches the host seams (gate save/compare, cloud, SARIF) already stamped — * the "tool forgot to stamp" failure class cannot occur for an envelope built * here. Omitted ⇒ {@link defaultFingerprintStrategy} (`ruleId|filePath|line|col`), * which is exactly the documented inheritance for a tool that declares no * `Tool.fingerprintStrategy`. Stamping is idempotent: a signal that already * carries a non-empty `fingerprint` is preserved byte-for-byte, so a tool may * still stamp earlier (e.g. at `createSignal`) without double-hashing. */ readonly fingerprintStrategy?: FingerprintStrategy; } /** * Assemble a {@link SignalEnvelope} from a run's units + signals. * * Centralises the verdict/summary computation so all three tools agree on * "`passed` ⇔ no critical/high" and the score definition. Pure: no IO, no * clock, no id generation — `runId`/`createdAt` arrive on the input. * * - `summary.total/passed/failed` come from `units` (units are what "ran"). * - `summary.errors/warnings` come from `signals` (critical|high → error, * else warning). * - `score = passRate(summary)`. * - `verdict.passed` (ADR-0035) ⇔ the run did not fault, no unit errored, AND * the error/warning counts pass the tool's findings `policy`. This is the * single verdict that drives both the exit code and the headline. * - Every signal is fingerprint-stamped (ADR-0036) with * `input.fingerprintStrategy` (host default when omitted; idempotent for * pre-stamped signals), so the built envelope is gate-ready by construction. */ export declare function buildSignalEnvelope(input: BuildEnvelopeInput): SignalEnvelope; export type { BaselineIdentity } from '@opensip-cli/core'; //# sourceMappingURL=signal-envelope.d.ts.map