/** * CodexPolicyService * * The initial Governance-owned Single Source of Truth (SSOT) for Codex / policy loading. * This is the V2-P1-S02-REAL first concrete migration slice. * * Role (per 3-subsystem architecture + researcher mapping): * - External Governance (Decision Layer & SSOT) owns "what the policy is". * - All consumers (enforcement CodexLoader, injectors, formatters, MCP surfaces, plugins) * will eventually ask here instead of performing direct fs reads. * * Current scope (minimal safe skeleton): * - Read-only query surface. * - Uses canonical resolveCodexPath + async file load (no duplication of resolution logic). * - Returns ActiveCodexSnapshot compatible with the existing get_active_codex MCP tool. * - Provides getTermCount() with safe 60-term fallback (preserves prior behavior of bypasses). * - Full frameworkLogger discipline on every load/decision/error. * - Reuses one parsed codex while that file still wins and its mtime and size are unchanged. * - No mutation of the cached codex; no enforcement. * * First wired consumer: src/mcps/enforcer-tools.server.ts (getCodexTermCount bypass removed; * now delegates through this service). * * Next recommended slices (documented in researcher mapping append): * - Wire governance.server.ts handleGetActiveCodex to delegate (remove its direct read). * - S02b/S02c follow-ups: update codex-injector, context-loader, codex-formatter, plugin. * - Make CodexLoader delegate its raw data load here, then re-export from governance. * * @module governance/codex-policy.service */ import type { ActiveCodexSnapshot, ICodexPolicyProvider } from './governance-types.js'; /** * Canonical implementation of the Governance Codex/Policy provider. * Single owner of the "first read" of any codex.json for the framework. */ export declare class CodexPolicyService implements ICodexPolicyProvider { private readonly component; /** * Winning parse. Invalid when a higher-priority path appears or mtime/size changes, * so the next check still parses the bytes a fresh load would have read. */ private codexCache; private candidateKey; private fileIdentity; private cachedRaw; /** * Internal loader: resolves candidates, picks first existing, reads + parses. * Repeat calls skip the read and JSON.parse while the winning file is unchanged. * Logs via frameworkLogger on load, error, and fallback (not on a cache hit). */ private loadRaw; private computeTermCount; private getBuiltinFallback; /** * Primary SSOT query: returns the ActiveCodexSnapshot. * Matches (and is the intended backing impl for) the get_active_codex MCP response. */ getCurrentCodex(includeRaw?: boolean): Promise; /** * Convenience: just the term count. * Preserves historical caller behavior (hard 60 fallback when everything fails). */ getTermCount(): Promise; } export declare function getCodexPolicyService(): CodexPolicyService; export { CodexPolicyService as default };