/** * Local gate + ledger — SQLite parity for --local mode (G3d). * * Same state machine as lib/governance/gate-service.ts; same hashing as the * cloud (enforced by the shared golden vectors). SQLite gives us real * transactions, so the append is simpler than the cloud's optimistic loop. * Append-only is enforced by SQLite TRIGGERs, mirroring the Postgres ones. */ import type { Database } from 'better-sqlite3'; import { type LedgerRow, type LedgerEventType, type VerifyResult } from './ledger'; import { type Pillar } from './schemas'; export type GatePolicy = 'auto_commit' | 'review' | 'reject'; export type Risk = 'low' | 'medium' | 'high'; export declare const DEFAULT_POLICY: Record; export declare class LocalGateError extends Error { constructor(message: string); } export declare function initGovernanceSchema(db: Database): void; export interface LocalLedgerEventInput { projectId: string; eventType: LedgerEventType; payload: Record; pillar?: string | null; refTable?: string | null; refId?: string | null; authorUser?: string | null; authorAgent?: string | null; } export declare function appendLocalLedgerEvent(db: Database, input: LocalLedgerEventInput): LedgerRow; export declare function verifyLocalChain(db: Database, projectId: string): VerifyResult; interface ConflictCandidate { entryId: string; title: string; match: 'exact_key' | 'similar'; } export declare function classifyRisk(params: { pillar: Pillar; supersedes?: string | null; conflicts: { candidates: ConflictCandidate[]; degraded: boolean; }; }): Risk; export declare function resolvePolicy(params: { pillar: Pillar; risk: Risk; projectPolicy?: Record | null; source?: string; }): { route: GatePolicy; policyApplied: string; }; export interface LocalGateOutcome { proposalId: string; status: 'auto_committed' | 'pending' | 'rejected'; risk: Risk; policyApplied: string; committedRef?: { table: string; id: string; }; message: string; } export declare function localPropose(db: Database, input: { projectId: string; pillar: Pillar; payload: Record; reasoning?: string; supersedes?: string; agent?: string; source?: 'propose_entry' | 'legacy_capture' | 'git_hook'; }): LocalGateOutcome; export declare function localDecide(db: Database, params: { proposalId: string; decision: 'approve' | 'reject'; note?: string; }): LocalGateOutcome; export declare function listLocalPending(db: Database, projectId: string): Array<{ id: string; pillar: string; payload: string; risk: string; policy_applied: string; proposed_by_agent: string; supersedes: string | null; conflicts: string | null; created_at: string; }>; export {}; //# sourceMappingURL=local-gate.d.ts.map