import type { NativeMethodBinding, NativeMethodology, NativeRulePolicy, ScopeMode } from './native-project.js'; import type { CompiledConstraint } from '../validator/constraint-eval.js'; /** Severity as the ontology and policies spell it. */ export type RuleSeverity = 'error' | 'warning' | 'info'; /** How far a rule may be tailored, from the rule's own `tailoring` attribute. */ export type RuleTailoring = 'invariant' | 'assurance' | 'methodology'; /** One step in the chain that produced a rule's effective disposition. */ export interface PolicyChainEntry { /** Methodology usage name, or the binding's usage name for a project policy. */ source: string; /** 'methodology' or 'project' — which authority applied it. */ level: 'methodology' | 'project'; policy: NativeRulePolicy; } /** A rule and everything that happened to it. */ export interface EffectiveRule { /** The rule as originally defined. */ sourceRuleId: string; sourceRuleType: string; /** The rule that actually evaluates; differs from the source when replaced. */ activeRuleId: string; activeRuleType: string; disposition: 'enabled' | 'disabled' | 'replaced'; /** Severity after any override. */ effectiveSeverity: RuleSeverity; /** Severity as the ontology authored it. */ declaredSeverity: RuleSeverity; tailoring: RuleTailoring; /** Every policy that touched this rule, base-first. */ policyChain: PolicyChainEntry[]; /** Rationale and authority from the last policy that changed the rule. */ rationaleText?: string; authority?: string; approvalReference?: string; /** Where the rule is declared. */ sourceFile?: string; } export interface RuleResolutionDiagnostic { code: 'missing-target' | 'missing-replacement' | 'duplicate-rule-id' | 'invariant-protected' | 'replacement-without-target' | 'missing-rationale' | 'ambiguous-target' /** Resolution itself threw. Reported so the UI shows why the set is empty. */ | 'resolution-failed'; message: string; ruleId?: string; policy?: string; file?: string; } export interface MethodologyDiagnostic { code: 'missing-base' | 'inheritance-cycle' | 'unavailable-module' | 'scope-mode-conflict'; message: string; methodology?: string; } /** The methodology chain plus its merged selection. */ export interface EffectiveMethodology { /** Base first, selected methodology last. */ chain: NativeMethodology[]; scopeMode: ScopeMode; includedLayers: string[]; includedModules: string[]; includedStandards: string[]; includedArtifactKinds: string[]; includedViewpoints: string[]; /** Policies in application order: base methodology first, project binding last. */ policyChain: PolicyChainEntry[]; diagnostics: MethodologyDiagnostic[]; } /** * Walk the methodology inheritance chain and merge its selection. * * Exactly one base per methodology, so the chain is a list. The resolver walks * base-first and then applies the child, which is also the order policies are * applied in: a child methodology may tailor what its base decided, and the * project binding gets the last word. */ export declare function resolveEffectiveMethodology(binding: NativeMethodBinding | undefined, methodologies: Map, availablePackages: ReadonlySet): EffectiveMethodology; /** A rule as the constraint loader found it, plus the metadata policies need. */ export interface RuleCandidate { /** Stable rule ID, e.g. "CR-MED-040". Durable identity for audit records. */ id: string; /** The `constraint def` name, which is what a policy references. */ typeName: string; severity: RuleSeverity; tailoring: RuleTailoring; file?: string; constraint?: CompiledConstraint; } /** * Map compiled native constraints onto rule candidates. * * One place, because both `memo rules` and the dev server need it and they got * the field names wrong independently — `collectNativeConstraints` returns * `id`/`typeName`/`sourceFile`, not `ruleId`/`ruleType`/`file`. A rule whose * identity does not survive this mapping resolves as `undefined` and is * unauditable, which is the opposite of what section 10.4 asks for. * * A constraint with no `typeName` is skipped: a policy references a rule by its * `constraint def` name, so a rule without one cannot be tailored and does not * belong in a set whose purpose is recording tailoring decisions. */ export declare function ruleCandidatesFromConstraints(constraints: readonly CompiledConstraint[]): RuleCandidate[]; export interface EffectiveRuleSet { rules: EffectiveRule[]; diagnostics: RuleResolutionDiagnostic[]; /** The constraints that should actually be evaluated, in rule-ID order. */ activeConstraints: CompiledConstraint[]; } /** * Produce the effective rule set. * * Steps 1-3 of section 10.3 (collecting rules from ontology, extension, and * methodology packages) happen upstream: `collectNativeConstraints` walks the * resolved closure, which is exactly the set of packages those steps describe. * This function is steps 4-9 — apply policies base-first, validate, and emit. */ export declare function resolveEffectiveRules(candidates: RuleCandidate[], policyChain: PolicyChainEntry[]): EffectiveRuleSet; //# sourceMappingURL=methodology-resolver.d.ts.map