/** * PRI-480 — Phase 1 Core ABI (rule-context-v2.ts) * * Pure logic: types + canonicalize + validators + behavior-facts computation. * Zero I/O — this module MUST NOT import node:fs / node:path / better-sqlite3 / * any network module. The runtime-v2 architecture-regression test enforces the * file boundary. * * Err-prevention: * - ERR-001 (validate-as-unknown): every public validator takes `unknown` and * validates structurally. No `as` bypass on parsed input. * - ERR-076 (prototype-pollution / host-realm independence): structural checks * use Object.keys + a PROTO_KEYS set. We never touch the host realm's * prototype chain (no `instanceof`, no `in`). * - rc-2: no `as` casts on parsed input. * - rc-5: Object.hasOwn / Object.keys over the `in` operator. * * Spec: docs/superpowers/specs/2026-06-27-rulecode-context-vision-design.md §4. */ export type CanonicalKind = 'read' | 'search' | 'write' | 'execute' | 'agent' | 'other'; export type EvidenceState = 'yes' | 'no' | 'unknown'; export type RuleToolOutcome = 'success' | 'failure' | 'blocked'; export type RuleHistoryStatus = 'available' | 'unavailable'; export interface RuleToolCallRecord { sequenceId: number; toolName: string; canonicalKind: CanonicalKind; normalizedPath: string | null; paramsSummary: Record; outcome: RuleToolOutcome; } export interface RuleHistoryWindow { status: RuleHistoryStatus; unavailableReason?: string; truncated: boolean; calls: readonly RuleToolCallRecord[]; } export interface RuleBehaviorFacts { priorReadOfTarget: EvidenceState; readCount: number | null; writeCount: number | null; uniqueWritePathCount: number | null; sameActionBlockCount: number | null; } export interface RuleContextV2 { version: 2; history: RuleHistoryWindow; facts: RuleBehaviorFacts; } export interface ValidationResult { valid: boolean; errors: string[]; } export declare function canonicalizeToolKind(toolName: unknown): CanonicalKind; export declare function validateRuleToolCallRecord(value: unknown): ValidationResult; export declare function validateRuleHistoryWindow(value: unknown): ValidationResult; export declare function validateRuleBehaviorFacts(value: unknown): ValidationResult; export declare function validateRuleContextV2(value: unknown): ValidationResult; export declare function computeBehaviorFacts(window: RuleHistoryWindow, targetPath: string | null, sameActionBlockCount: number | null): RuleBehaviorFacts; export declare const UNAVAILABLE_RULE_CONTEXT: Readonly; //# sourceMappingURL=rule-context-v2.d.ts.map