/** * Architecture invariant rules (spec-23). * * A small, opt-in, fully declarative rule format for dependency / layer / * module-boundary constraints. Rules are author-declared in * `.openlore/architecture.json` (and optionally sourced from synced ADR files), * NEVER inferred by an LLM. Parsing is total: malformed entries become warnings * and are skipped — loading rules never throws. * * The checker ([check.ts](./check.ts)) compiles these down to deterministic * passes over the file-level dependency graph, reusing the canonical * `classifyLayerEdge` primitive from the call-graph analyzer for the `layers` kind. */ /** Where a rule came from — an author's config file, or a recorded decision (spec-16). */ export type RuleSource = 'config' | 'decision'; /** * Ordered layering: key order is top → bottom, so a lower layer depending on an * upper layer is a violation. Each layer maps to one or more path prefixes. */ export interface LayersRule { kind: 'layers'; layers: Record; source: RuleSource; } /** "Files under `from` must not depend on files under `to`." */ export interface ForbiddenRule { kind: 'forbidden'; from: string; to: string; reason?: string; source: RuleSource; } /** Module boundary: "files under `module` may depend ONLY on `mayDependOn` (plus themselves)." */ export interface AllowedOnlyRule { kind: 'allowedOnly'; module: string; mayDependOn: string[]; reason?: string; source: RuleSource; } export type ArchitectureRule = LayersRule | ForbiddenRule | AllowedOnlyRule; /** The parsed rule set plus any non-fatal warnings collected while loading. */ export interface ArchitectureRules { rules: ArchitectureRule[]; warnings: string[]; } /** * Parse a raw config object into validated rules. Total: every malformed entry is * recorded as a warning and skipped; this never throws. `source` tags provenance. */ export declare function parseArchitectureRules(raw: unknown, source: RuleSource): ArchitectureRules; /** * Parse `Invariant:` markers out of synced ADR files. We read SYNCED files only — * never `pending.json` fields, which are purged on sync (spec-16 edge case). * Supported single-line grammar (deterministic, no LLM): * * Invariant: forbidden -> [(reason)] * Invariant: allowedOnly -> , [(reason)] * * Anything else is ignored. Returns rules tagged `source: 'decision'`. */ export declare function parseInvariantMarkers(adrText: string): ArchitectureRule[]; /** * Load the effective architecture rules for a project: the opt-in config file * merged with any decision-sourced invariants. Absent config is NOT an error — * returns an empty, inert rule set. Never throws. */ export declare function loadArchitectureRules(absDir: string, opts?: { includeDecisions?: boolean; }): Promise; /** True when no rules are declared — the instrument is fully inert. */ export declare function rulesAreInert(rules: ArchitectureRules): boolean; //# sourceMappingURL=rules.d.ts.map