import type { OrgAuth } from "../auth/sf-auth.ts"; import { type ValidationRuleRecord } from "../describe/tooling-client.ts"; export type TouchedValidationRulesFile = { sessionId: string; targetOrg: string; snapshotAt: string; rules: ValidationRuleRecord[]; }; export type PendingRecovery = { sessionId: string; targetOrg: string; count: number; snapshotAt: string; }; export type Logger = (line: string) => Promise | void; /** * Query target org for active VRs on the seeded objects, persist the * snapshot to disk, then deactivate each one. Returns the number flipped. * * If `objects` is empty, this is a no-op (no file written, zero touched). */ export declare function snapshotAndDeactivate(opts: { auth: OrgAuth; sessionId: string; sessionDir: string; targetOrg: string; objects: string[]; log?: Logger; fetchFn?: typeof fetch; }): Promise<{ touchedCount: number; rules: ValidationRuleRecord[]; }>; /** * Read the snapshot file and PATCH every rule back to `Active = true`. * * Failure semantics: * - Each rule is attempted independently. Failures are collected, not * thrown, so one bad rule doesn't leave the rest disabled. * - If ALL rules succeed, the snapshot is moved to * `touched-validation-rules.reactivated.json` (audit trail; the * pending-recovery scan ignores this suffix). * - If ANY rule fails, the snapshot stays in place with `rules` * narrowed to the failed subset, and the next tool call will be * forced into recovery again. * * If the snapshot file doesn't exist, this is a no-op. */ export declare function reactivateFromSnapshot(opts: { auth: OrgAuth; sessionDir: string; log?: Logger; fetchFn?: typeof fetch; }): Promise<{ reactivatedCount: number; failed: Array<{ fullName: string; error: string; }>; totalInSnapshot: number; }>; /** * Scan every session directory under `sessionsRoot` for a * `touched-validation-rules.json` file. Used at the top of every MCP * tool call to block new work while any recovery is pending. * * Robust to missing dir / unreadable files — returns what it can, never * throws. (A failing guard must not brick the tool.) */ export declare function findPendingRecoveries(sessionsRoot: string): Promise; /** Public accessor to the canonical filename (used by tests/UI text). */ export declare const TOUCHED_VALIDATION_RULES_FILENAME = "touched-validation-rules.json"; export declare const REACTIVATED_VALIDATION_RULES_FILENAME = "touched-validation-rules.reactivated.json";