/** * Structured logging module for the FormSpec constraint-validation pipeline. * * Provides namespace scaffolding (§8.3a) and the per-tag-application log-entry * schema (§8.3b) for the constraint-validator consumers. * * Namespaces: * formspec:analysis:constraint-validator — root * formspec:analysis:constraint-validator:build — build-path (tsdoc-parser.ts) * formspec:analysis:constraint-validator:snapshot — snapshot-path (file-snapshots.ts) * formspec:analysis:constraint-validator:typed-parser — typed-argument parser * formspec:analysis:constraint-validator:registry — extension-registry construction * formspec:analysis:constraint-validator:broadening — broadening bypass decisions * * Log level convention: * debug — one entry per tag application (§8.3b) * trace — argument-lowering detail * * @packageDocumentation */ import * as ts from "typescript"; import type { LoggerLike } from "@stripe/formspec-core"; /** * Which pipeline consumer emitted this log entry. * * @public */ export type ConstraintValidatorConsumer = "build" | "snapshot"; /** * The outcome of a single role in the constraint-validation pipeline. * * Roles A–D mirror the architectural roles described in the refactor plan: * A — placement check (is the tag allowed on this declaration kind?) * B — path/target validation (is the `:path` target syntactically valid and resolvable?) * C — argument type check (is the argument value type-compatible?) * D1 — direct-field custom-constraint dispatch * D2 — path-target built-in broadening dispatch * bypass — broadening registry short-circuit (tag accepted without role-C check) * * @public */ export type ConstraintValidatorRoleOutcome = "A-pass" | "A-reject" | "B-pass" | "B-reject" | "C-pass" | "C-reject" | "D1" | "D2" | "bypass"; /** * Structured log entry emitted once per constraint-tag application. * * Enabling `DEBUG=formspec:analysis:constraint-validator:*` at `debug` level * produces one of these for every tag evaluation. Enabling `trace` level adds * argument-lowering detail records with the same shape but `elapsedMicros` * reflecting only the lowering step. * * @public */ export interface ConstraintTagApplicationLogEntry { /** Which pipeline consumer produced this entry. */ readonly consumer: ConstraintValidatorConsumer; /** Normalized tag name, e.g. "minimum". */ readonly tag: string; /** Declaration placement, e.g. "class-field". */ readonly placement: string; /** * A human-readable description of the subject type kind, e.g. * "primitive/string", "primitive/number", "custom/Decimal", "unknown". */ readonly subjectTypeKind: string; /** The final role outcome for this tag application. */ readonly roleOutcome: ConstraintValidatorRoleOutcome; /** * Elapsed time in microseconds for this tag's full validation path. * Measured with `performance.now()` when available, otherwise `Date.now()`. */ readonly elapsedMicros: number; } /** * Structured log entry emitted when setup diagnostics are generated during * extension-registry construction. * * @public */ export interface SetupDiagnosticLogEntry { /** Number of setup diagnostics emitted in this construction/setup call. */ readonly diagnosticCount: number; /** Diagnostic codes present in this batch, e.g. ["UNSUPPORTED_CUSTOM_TYPE_OVERRIDE"]. */ readonly codes: readonly string[]; } /** * Returns a human-readable type-kind string for §8.3b log entries. * * Examples: "primitive/string", "primitive/number", "object/Decimal", * "array", "union", "unknown". * * @public */ export declare function describeTypeKind(type: ts.Type, checker: ts.TypeChecker): string; /** * Root namespace for constraint-validator structured logging. * * Activate with `DEBUG=formspec:analysis:constraint-validator:*`. * * @public */ export declare const CONSTRAINT_VALIDATOR_NS = "formspec:analysis:constraint-validator"; /** Sub-namespace for the build consumer (tsdoc-parser.ts). */ export declare const CONSTRAINT_VALIDATOR_BUILD_NS = "formspec:analysis:constraint-validator:build"; /** Sub-namespace for the snapshot consumer (file-snapshots.ts). */ export declare const CONSTRAINT_VALIDATOR_SNAPSHOT_NS = "formspec:analysis:constraint-validator:snapshot"; /** Sub-namespace for the typed-argument parser (active from Phase 2). */ export declare const CONSTRAINT_VALIDATOR_TYPED_PARSER_NS = "formspec:analysis:constraint-validator:typed-parser"; /** Sub-namespace for extension-registry construction events. */ export declare const CONSTRAINT_VALIDATOR_REGISTRY_NS = "formspec:analysis:constraint-validator:registry"; /** Sub-namespace for broadening bypass decisions. */ export declare const CONSTRAINT_VALIDATOR_BROADENING_NS = "formspec:analysis:constraint-validator:broadening"; /** Returns the module-level logger for the build consumer namespace. */ export declare function getBuildLogger(): LoggerLike; /** Returns the module-level logger for the snapshot consumer namespace. */ export declare function getSnapshotLogger(): LoggerLike; /** Returns the module-level logger for the extension-registry namespace. */ export declare function getRegistryLogger(): LoggerLike; /** Returns the module-level logger for the typed-argument-parser namespace. */ export declare function getTypedParserLogger(): LoggerLike; /** Returns the module-level logger for the broadening-bypass namespace. */ export declare function getBroadeningLogger(): LoggerLike; /** * Returns a microsecond timestamp using `performance.now()` when available, * falling back to `Date.now() * 1000`. */ export declare function nowMicros(): number; /** * Computes elapsed microseconds since `startMicros`. */ export declare function elapsedMicros(startMicros: number): number; /** * Emits a single per-tag-application structured log entry (§8.3b). * * The logger argument is the module-level logger for the appropriate consumer * namespace (build or snapshot). Call at the end of each tag's validation path * regardless of outcome. */ export declare function logTagApplication(logger: LoggerLike, entry: ConstraintTagApplicationLogEntry): void; /** * Emits a setup-diagnostic count record (§8.3c). * * Call whenever setup diagnostics are generated during extension-registry * construction. */ export declare function logSetupDiagnostics(logger: LoggerLike, entry: SetupDiagnosticLogEntry): void; //# sourceMappingURL=constraint-validator-logger.d.ts.map