/** * Pi-side path-protection policy: the shipped-default mirror (E-60-1), the * tighten-only resolver (E-60-7), the record reader, and the pure Tier 2 tool * call decision (E-60-5). * * The canonical shipped defaults live in the producer crate * (`packages/agentic-workflow/src/path-policy.mjs`); this file embeds a copy * whose parity is pinned by `test/path-protection.test.mjs`. The guard never * weakens the shipped floor: an override may only union globs and raise a * requirement, and a removal or a lowering is ignored and reported. */ export declare const PATH_POLICY_SCHEMA = "path-protection-policy@1"; export declare const RECORDS_SCHEMA = "path-protection-records@1"; /** Mirror of the crate's glob-length bound: a longer `protectedGlobs` entry is refused (F29). */ export declare const PATH_GLOB_MAX_LENGTH = 512; export type PathRequirement = "none" | "justification" | "approval"; export type PathOperation = "create" | "modify" | "delete" | "rename"; export type PathPhaseState = "pre-freeze" | "post-freeze" | "always"; export declare const REQUIREMENTS: readonly PathRequirement[]; export declare const OPERATIONS: readonly PathOperation[]; export declare const PHASE_STATES: readonly PathPhaseState[]; export interface PathPolicyClass { globs: string[]; freeze: boolean; } export type PathPolicyMatrix = Record>; export interface PathPolicy { schema: string; classes: Record; matrix: PathPolicyMatrix; } export interface PathProtectionOverride { protectedGlobs?: string[]; requirements?: Partial>>>; } export type DegradationCode = "missing-config" | "malformed-config" | "ignored-removal" | "ignored-lowering"; export interface PathPolicyDegradation { code: DegradationCode; detail: string; } export interface ResolvedPathPolicy extends PathPolicy { degradations: PathPolicyDegradation[]; } /** The shipped-default mirror, byte-for-byte the crate's projection. */ export declare const SHIPPED_PATH_POLICY: PathPolicy; /** Convert a glob to an anchored regexp. `**` crosses `/`, `*`/`?` do not. */ export declare function globToRegExp(glob: string): RegExp; /** * Linear-time glob match with the same semantics as `globToRegExp` (`**` crosses * `/`; `*` and `?` do not). Memoised so a star-chain glob cannot trigger the * catastrophic backtracking the RegExp form suffers (F20). */ export declare function matchGlob(glob: string, target: string): boolean; export declare function pathMatchesGlob(target: string, glob: string): boolean; export declare function isProtectedPath(policy: PathPolicy, target: string): boolean; /** Merge two owner overrides before intersecting: globs union, requirements max. */ export declare function mergePathProtectionOverrides(base: PathProtectionOverride | undefined, next: PathProtectionOverride | undefined): PathProtectionOverride; /** * Tighten-only resolution (E-60-7). The shipped floor is always kept: globs * union, requirements take the maximum, and a removal or a lowering appends a * degradation record. When the override declares `protectedGlobs`, any shipped * glob it omits is a rejected removal and is reported too. */ export declare function intersectPathPolicy(shipped: PathPolicy, override: PathProtectionOverride | undefined): ResolvedPathPolicy; /** * Collapse `.`/`..` segments and normalise separators so equivalent spellings * (`./tests/x`, `sub/../tests/x`) match the same glob. A leading `..` is kept: * the caller refuses an out-of-root result before matching (E-60-5). */ export declare function normalizeTarget(target: string): string; /** * Read the `path-protection-records@1` fenced blocks and report whether a * `justification` row (authority `execute-phase`) matches `target`. A missing * marker permits nothing; a malformed row voids only its own block. Every * block is consulted, because the guard reads the ledgers of every unit. */ export declare function matchingJustification(target: string, recordsText: string): boolean; export type ToolCallGuardResult = { block: false; } | { block: true; reason: string; }; export interface ToolCallGuardInput { toolName: string; targetPath: string; /** A new-file create is authoring, not modification, so it passes (E-60-5). */ targetExists: boolean; policy: PathPolicy; recordsText: string; } /** * The pure Tier 2 decision: block a `write` / `edit` call to an existing * protected path with no matching justification record; pass reads and * new-file creates. The reason names the escape path. */ export declare function evaluateToolCall(input: ToolCallGuardInput): ToolCallGuardResult;