/** * Permission policy engine. Merges user config (/permissions.json) * and project config (/.phi/permissions.json). * * Security model: * - The project file is read only for TRUSTED projects (a cloned repo must not * be able to relax the user's policy). * - Even when trusted, the project can only TIGHTEN the policy: tier decisions * take the strictest of user and project, and project "allow" rules are ignored. * * Default behavior when NO config exists: everything allowed. This preserves * the pre-permissions behavior of Phi Code (non-regression requirement). */ import { type PermissionTier } from "./tiers.ts"; export type PermissionDecision = "allow" | "deny" | "prompt"; export interface PermissionRule { tool: string; pattern?: string; decision: PermissionDecision; } export interface PermissionsConfig { read?: PermissionDecision; write?: PermissionDecision; exec?: PermissionDecision; rules?: PermissionRule[]; } export interface ResolvedPolicy { /** True when no config file existed at all (legacy allow-everything mode) */ legacyAllowAll: boolean; config: PermissionsConfig; } export interface LoadPolicyOptions { /** Whether /.phi/permissions.json may be read. Defaults to false (untrusted). */ projectTrusted?: boolean; } export declare function loadPolicy(cwd: string, options?: LoadPolicyOptions): ResolvedPolicy; /** Test helper / runtime invalidation. */ export declare function resetPolicyCache(): void; export declare function decide(policy: ResolvedPolicy, toolName: string, params: unknown, declaredTier?: PermissionTier): { decision: PermissionDecision; tier: PermissionTier; matchedRule?: PermissionRule; }; //# sourceMappingURL=policy.d.ts.map