Skip to main content

Module effective_policy

Module effective_policy 

Source
Expand description

Unified Control: the signed effective policy of one engine (Release B, C0 2.x schemas/policy.schema.json).

GET /v1/policy/bundle with Cloud-Protocol: 2.x keeps every 1.x member and adds effective_policy (EffectivePolicyBundleV1, or null when the server has no lease signing key). Cloud merges the policy hierarchy (org → workspace → vault → engine) itself; the engine never merges, it verifies and applies the result:

  • signature: Ed25519 by a key-set v3 key of purpose policy over EFFECTIVE_POLICY_SIGNATURE_DOMAIN ‖ canonical_json(bundle without signature), 128 lowercase hex characters;
  • digest = "sha256:" + hex(sha256(canonical_json(policy))) (policy_digest), the value the engine acks;
  • every member carries x-enforcement: engine members map onto the gateway policy pack (ENGINE_MEMBERS), server members are enforced by Cloud itself at the point their x-server names (403 policy_denied {member, level}, SERVER_MEMBERS), advisory members are distributed and shown only. The ack’s unenforced reports what is enforced nowhere: every member it received that this engine does not enforce and Cloud does not enforce either (unenforced_members: advisory members and members this engine does not know yet), never pretending to enforce them. Server members are left out: Cloud enforces them whatever the engine does (server_members, shown apart in status).

The bundle, the effective policy and its sections accept unknown members and unknown sections (they are covered by the signature and reported as unenforced); a known member with a value outside the contract refuses the whole bundle, so the engine keeps its last valid one.

ent2 (rules for agents and models) adds the optional agents section and the security members allowed_providers, require_proxy, readable_roots and never_send. This engine enforces readable_roots and never_send (ent2-3: io_boundary and the native hooks), agents.allowed (ent2-2: the MCP server refuses a client whose agent is not listed) and allowed_providers (ent2-4: the proxy refuses a request whose serving provider is not listed) and require_proxy (N1: the MCP server refuses a client whose model traffic is not routed through the LeanCTX proxy).

QN2 adds the optional orchestrator section (OrchestratorPolicyV1). This engine enforces orchestrator.network (off: no Orchestrator kind is posted or relayed for the vault). It validates cross_team_review and max_sessions_per_vault but has no code path that could enforce them (Orchestrator sessions are started by the app, and a review request is not a bus kind). The C0 schema marks both x-enforcement: advisory, so they are ADVISORY_MEMBERS and the ack reports them as unenforced.

Structs§

AgentsPolicyV1
agents of an effective policy (ent2). Absent when no level sets one of its members, so a policy without them keeps its digest.
BundlePolicyV1
policy of a bundle: the default for every vault without an entry, and the per-vault entries ascending by vault_id.
ContextPolicyV1
context of an effective policy.
EffectivePolicyBundleV1
effective_policy of GET /v1/policy/bundle (2.x).
EffectivePolicyV1
The merged policy in normal form (schema $defs/effective).
OrchestratorPolicyV1
orchestrator of an effective policy (QN2, the Orchestrator network; “Queen” in code). Absent when no level sets one of its members, so a policy without them keeps its digest.
PolicyAckRefusalV1
refused of an ack (C0 $defs/ack_refusal): the bundle the engine keeps applying (applied_* both null when it holds none).
PolicyAckRefusedResponseV1
Answer of POST /v1/policy/ack to a refusal (C0 $defs/ack_refused_response).
PolicyAckRequestV1
POST /v1/policy/ack.
PolicyAckResponseV1
Answer of POST /v1/policy/ack.
PolicySourceV1
A document that went into the bundle.
SecurityPolicyV1
security of an effective policy. Absent member = no level sets it.
SharingPolicyV1
sharing of an effective policy (enforced by Cloud, not the engine).
VaultEffectivePolicyV1
The effective policy of one vault with a vault-level document.

Enums§

PolicyAckStateV1
State of an ack: outdated when a newer bundle was issued since.
PolicyActionV1
Filter action, loosest first (x-merge: rank).
PolicyRefusalReasonV1
Why an engine refused a received bundle (C0 $defs/refusal_reason).

Constants§

ADVISORY_MEMBERS
Every member the schema marks x-enforcement: advisory.
EFFECTIVE_POLICY_SCHEMA
EFFECTIVE_POLICY_SIGNATURE_DOMAIN
Domain of the effective-policy signature (key-set v3 purpose policy).
ENGINE_MEMBERS
section.member → the gateway policy pack field that enforces it, for every member the schema marks x-enforcement: engine (its x-engine).
MAX_ORCHESTRATOR_SESSIONS
Largest orchestrator.max_sessions_per_vault (QN2).
MAX_POLICY_SOURCES
Largest number of sources and per-vault entries of one bundle.
MAX_POLICY_VAULTS
MAX_REFUSAL_DETAIL
Longest detail of a refusal.
MAX_UNENFORCED
Largest unenforced list of an ack.
PERSONAL_WORKSPACE_MODES
sharing.personal_workspace, loosest first.
PLANNED_ENGINE_MEMBERS
section.member → its x-instance gateway pack field, for every member the schema marks x-enforcement: instance that this engine validates but does not enforce yet. The ack reports them as unenforced; each one moves into ENGINE_MEMBERS with its enforcement.
POLICY_ACK_SCHEMA
POLICY_DOCUMENT_SCHEMA
POLICY_MISMATCH
Error code of an ack for a version/digest this engine was not issued.
SERVER_MEMBERS
Every member the schema marks x-enforcement: server: Cloud enforces it (its x-server point), this engine does not.

Functions§

is_country
ISO 3166-1 alpha-2: two uppercase ASCII letters ($defs/country).
is_engine_member
Whether the engine enforces member (section.member).
is_server_member
Whether Cloud enforces member itself (x-enforcement: server).
policy_digest
"sha256:" + hex(sha256(canonical_json(value))).
refusal_detail
A diagnostic line as detail takes it: control characters become spaces, every place on the machine (a path, a home folder, a file URL) becomes <path> (K2 M2: the data directory names the user), at most MAX_REFUSAL_DETAIL characters, None when empty.
server_members
The members policy sets that Cloud enforces itself, sorted bytewise.
signing_input_raw
The exact bytes the policy key signs: the raw bundle as received, without its signature.
unenforced_members
The members policy sets that neither this engine nor Cloud enforces (advisory and unknown members), sorted bytewise: what an ack reports.