/** * federation/policy.ts — PolicyEngine: enforces per-call envelope * constraints (maxHops, action allowlist, peer blocklist). * * F-038 — ported from ruflo * `v3/@claude-flow/plugin-agent-federation/src/application/policy-engine.ts` * but stripped to the three checks the skeleton needs: * * 1. maxHops — envelope.hopCount must be < budget.maxHops * (default ceiling = 3 hops). * 2. message — envelope.messageType must be in the action * allowlist. * 3. peer — source node must NOT be in the blocklist. * * `enforce(envelope, budget)` returns a discriminated result so * callers can map directly to an MCP error string. */ import { type EnvelopeBudget, type FederationEnvelope, type FederationMessageType } from "./envelope.js"; /** Hard ceiling on hops — matches the spec's "≤ 3" rule. */ export declare const DEFAULT_MAX_HOPS = 3; export type PolicyDecision = { allowed: true; } | { allowed: false; denialReason: "max_hops_exceeded" | "message_type_not_allowed" | "peer_blocked" | "target_mismatch" | "budget_missing" | "budget_invalid"; }; export interface PolicyConfig { /** Set of message kinds accepted by this node. Defaults to all * 16 ruflo kinds — narrow via `allowedMessageTypes`. */ readonly allowedMessageTypes?: readonly FederationMessageType[]; /** Set of sourceNodeIds that are NEVER accepted (blocklist). */ readonly peerBlocklist?: readonly string[]; /** Override the default maxHops ceiling. */ readonly maxHops?: number; } export declare class PolicyEngine { private readonly allowed; private readonly blocked; private readonly maxHops; constructor(cfg?: PolicyConfig); /** Runtime mutator — narrow the allowlist after construction. */ allowMessageType(t: FederationMessageType): void; /** Runtime mutator — narrow the allowlist after construction. */ denyMessageType(t: FederationMessageType): void; /** Runtime mutator — block / unblock a peer at runtime. */ setBlocked(nodeId: string, blocked: boolean): void; /** Admit or reject an envelope given its budget context. */ enforce(envelope: FederationEnvelope, budget: EnvelopeBudget | undefined): PolicyDecision; } //# sourceMappingURL=policy.d.ts.map