Introducing a new way to review your PRs.

Read the announcement

hashgraph-online / hol-guard

Open-source antivirus and firewall for AI agents: block risky tools, secret access, prompt injection, malicious packages, MCP servers, plugins, and skills at runtime.

View on GitHub

44 documents · Updated Nov 23, 2026

docs / policy-authority-and-cloud-exceptions

Policy authority and cloud exceptions

Guard separates device-owned policy from workspace-owned Cloud policy. It validates each source before use, carries accepted policy through a protected native authority, and gives decision consumers one view of the rules that may affect an action. Cloud exceptions, business policy documents, managed Cloud actions, and action packs use the same authority boundary without turning a request or local setting into a remote override.

Authority model

Policy authority defines which source may change a decision. Local policy belongs to the device, while synced policy belongs to the active Cloud workspace and enters local enforcement only after trust checks.

AuthorityPurposeBoundary
Local policyReuse a decision made for this deviceA local write cannot claim a Cloud source
Synced policySet workspace rules and defaultsNeeds a valid signed bundle for the active workspace
Cloud exceptionRecord a temporary approved risk acceptanceMust be in the accepted bundle and remain active
Strict local configurationProvide local fallback behaviorCannot create a Cloud exception

Local policy authority

Local policy stores remembered decisions for this device. Each local row carries integrity data tied to a device-held key and a generation. Lookup does not trust a row when its proof is missing, changed, signed by an unknown key, or older than the trusted generation.

The native authority also keeps the accepted local view in a protected snapshot. The snapshot binds policy content to the runtime, rule contract, scope, and generation. The policy store admits it only for the expected local authority. A direct hook lane may use this snapshot without the daemon, but only while its acknowledgement and watched inputs still match the accepted generation; otherwise it uses the daemon path.

The local integrity state can be protected or degraded. Protected state has usable key material and control state. Degraded state keeps runtime enforcement active but does not make unverifiable remembered rows trusted. Generation changes use one shared lock so competing writers cannot move the trusted generation backward.

References: rust/…/policy_integrity_resolver.rs• L46-69 rust/…/policy_integrity_resolver.rs• L107-179 rust/…/policy_integrity_generation.rs• L59-76 rust/…/policy_generation_lock.rs• L9-40 rust/…/policy_integrity_rows_op.rs• L97-165 rust/…/policy_store.rs• L152-190 rust/…/policy_store_direct_lane.rs• L171-219 rust/…/policy_store_direct_lane.rs• L295-407

Synced policy authority

Synced policy is the effective policy for the active Cloud workspace. Guard reads it from an authenticated cached bundle. An unsigned or incomplete legacy payload does not become authority when the bundle is absent, malformed, expired, inactive, or rejected.

The resident lookup repeats the bundle authority decision when it reads cached rows. It derives the identities that the current signed bundle allows for this device and excludes rows that the bundle no longer produces. If the resident cannot reproduce the decision, it defers rather than guessing. This keeps materialization and later lookup under one authority contract.

During a version change, Guard can compare a candidate with a legacy or active shadow. An evaluating candidate is used to watch for drift without producing enforcement rows. An enforcing candidate with a real shadow mismatch is rejected; a missing shadow is recorded but does not by itself block rollout.

References: rust/…/policy_bundle_store_identities.rs• L64-96 rust/…/policy_bundle_store_identities.rs• L174-260 rust/…/policy_bundle_store_identities.rs• L285-329 rust/…/policy_decision_lookup_op.rs• L1322-1375 rust/…/policy_shadow_source.rs• L28-55 rust/…/policy_shadow_verdict.rs• L24-45

Policy document authority

Policy documents are portable descriptions of rules and defaults. Guard validates and compares a document before import, then compiles only the parts that local enforcement can represent. A document that needs whole-document authority is rejected rather than silently changed.

Business policy authority

Business policy documents are complete policy sources that may include business selectors and provenance. Guard gives them a separate source authority so a legacy row import cannot replace or remove an installed business policy.

Business imports use replace semantics. The approval is bound to the exact document digest and import mode. A staged request remains pending until an authenticated approval applies that same candidate, so submission alone does not change enforcement.

References: src/…/policy_tools.py• L233-314 src/…/commands_dispatch_policy_document.py• L374-413

Business policy recovery

Recovery treats retained source evidence as part of the authority boundary. If evidence remains but its installation key is unavailable, Guard does not treat the store as a new unprotected store. Recovery must use fresh local approval proof and must confirm that the recovered installation has the candidate digest.

For the full document, inspection, recovery, and approval flow, see Business policy documents and recovery.

References: src/…/mcp-policy-request-panel.js• L289-421 src/…/commands_dispatch_policy_document.py• L195-217

References: src/…/commands_dispatch_policy_document.py• L195-217 src/…/business_policy_document_view.py• L9-36

Signed bundle trust

A policy bundle is a signed statement from Guard Cloud about workspace policy. Its signing key is trusted only when it comes from a pinned or machine-managed trust domain. A key named by sync data can identify a signer, but it cannot create trust.

Bundle validation

Guard accepts a bundle as one trust decision. Its shape, workspace, time window, runtime support, ordering, hashes, and signature must agree.

The bundle hash identifies the policy core. The payload hash also covers the signed payload, including Cloud exceptions and device acknowledgements. A change to an exception or acknowledgement therefore needs a new signed identity.

References: src/…/policy_bundle_parser.py• L158-182 src/…/policy_bundle_parser.py• L265-298

Bundle activation

An accepted bundle and the data derived from it become one activation unit. This includes materialized policy rows, Cloud exceptions, the trust checkpoint, and the device acknowledgement. A failed refresh keeps the last valid authority only while it still passes validation. Otherwise Guard clears remote authority and leaves local policy and fallback controls to decide the next action.

References: rust/…/policy_bundle_store_identities.rs• L189-260 rust/…/policy_bundle_store_identities.rs• L482-503 src/…/policy_bundle_parser.py• L158-182 src/…/policy_bundle_parser.py• L265-298 src/…/store_policy.py• L896-1148

Cloud exception authority

A Cloud exception is a Cloud-owned acceptance of a risk that would otherwise need review or a stronger action. It has a source, owner, reason, scope, and expiry. It changes local enforcement only after it returns inside a later accepted signed bundle.

Exception scope

Scope controls the reach of the acceptance. The request surface seeks the narrowest useful scope, while broad team or workspace policy remains a Cloud responsibility.

ScopeReach
ArtifactOne artifact or exact action identity
PublisherMatching items from one publisher
HarnessMatching actions for one harness
WorkspaceMatching actions in one project
GlobalBroad Cloud risk acceptance

Only an active, valid exception appears in the active view. Expired entries do not lift policy. Device acknowledgement binds the applied exception state to the exact bundle, device, version, and apply time.

References: src/…/cloud_exceptions.py• L63-108 src/…/cloud_exceptions.py• L111-228

Exception requests

Guard submits an exception request only after it has validated the request and prepared an authenticated Cloud connection. The request carries evidence, target scope, requester and owner identity, reason, and a future expiry. Submission creates a pending Cloud request and does not change local enforcement.

Command-policy requests use correlation IDs instead of raw command or policy data. Cloud resolves the pending command from those IDs. This keeps sensitive action content on the device-to-review path while still binding the request to its machine, workspace, and local request.

References: src/…/cloud_exception_requests.py• L11-102 src/…/cloud_exception_requests.py• L184-322

Entitlement and connection state

Entitlement is an access check for Cloud-backed capabilities. It is not authority to create an exception. Guard separates connected access, reconnect-required access, and paid access that cannot be proven. When access cannot be proven, new Cloud-dependent actions are blocked, while existing local protection can still be repaired or removed when the local artifact is present.

For the request and reconciliation sequence, see Cloud exception request workflow.

References: src/…/package_firewall_entitlement.py• L265-358

Managed Cloud actions

Managed Cloud actions are Cloud-backed operations that use the authenticated action connection and its access state. They do not bypass local policy authority. Their result must still enter the accepted policy path before it can affect a decision.

Cloud action connectivity

Cloud action connectivity supplies the identity and connection context for sync, review, exception requests, and other managed actions. A missing or expired connection blocks the operation rather than producing a local substitute. The Cloud actions connectivity and operations page describes the connection states and operational flow.

References: src/…/cloud_exception_requests.py• L184-322 src/…/cloud_review_sync.py• L75-130

Cloud action packs

Cloud action packs are managed groups of actions evaluated under the active policy and native safety floors. The policy store admits the pack view only with the current native authority, and the action result cannot weaken a native block, containment floor, or required review.

An action-pack change therefore follows the same broad path as other policy changes: Cloud supplies signed authority, the local store checks the authority and current generation, and the decision consumer uses the admitted result. See Cloud action packs and evaluation for the pack evaluation flow.

References: rust/…/policy_store.rs• L240-362 rust/…/policy_store_command_authority.rs• L43-178

Policy change propagation

Policy changes move from Cloud or local policy sources to runtime consumers through trust-gated activation. The accepted bundle supplies remote rules, defaults, exceptions, and acknowledgement data. The native snapshot and its generation then protect the handoff to hooks and other consumers.

This diagram shows the path from a policy or exception change to runtime use and the points that stop an untrusted change.

flowchart LR
    A[Local change or Cloud policy change] --> B[Candidate policy or signed bundle]
    B --> C{Validate authority, integrity, time, scope, and generation}
    C -- reject --> D[Keep valid authority or clear remote authority]
    C -- accept --> E[Materialize policy, exceptions, and acknowledgement]
    E --> F[Build and admit native snapshot]
    F --> G{Freshness and input checks}
    G -- fail --> H[Use daemon path or fail safe]
    G -- pass --> I[Runtime decision consumers]
    E --> J[Cloud acknowledgement or review status]

Sync and materialization

Sync selects a usable bundle and validates it again at activation. It replaces remote rows as a set, so a removed Cloud rule or exception cannot remain as stale remote authority. Runtime lookup then checks that each cached row still matches an identity derived from the current validated bundle.

The local snapshot adds a separate protection layer. It binds the accepted content to the runtime, rule contract, scope, generation, and time window. A direct hook may use it only while the publisher's acknowledgement names the same generation and digest and all watched inputs remain unchanged. If a daemon republishes during a hook, a routed consumer can wait for a valid same-generation or newer acknowledgement only when the old lane had already admitted a hook.

References: rust/…/policy_store.rs• L240-362 rust/…/policy_store_direct_lane.rs• L295-407 rust/…/policy_store_direct_lane_reopen.rs• L35-69

Decision consumers

Runtime configuration reads defaults from the validated cached bundle. Policy lookup combines eligible local and remote decisions, reports local integrity context, and keeps remote rows distinct from local rows. Native hooks apply the accepted snapshot before and after a managed action. The daemon and dashboard expose the same accepted policy and exception view.

Cloud review delivery reports local events to Cloud through a durable identity-bound path. Delivery does not itself authorize a decision; a later signed and validated Cloud result must reach the next accepted bundle. For delivery and recovery detail, see Cloud review delivery and recovery.

References: rust/…/policy_decision_lookup_op.rs• L863-949 src/…/cloud_review_sync.py• L75-130 src/…/cloud_review_sync.py• L224-469

Change checklist

When these files or sections are changed, remember to consider these:

  • Changes to local integrity generations must stay aligned across key resolution, row signing, startup reconciliation, the shared generation lock, and decision lookup.
  • Changes to bundle decision identity derivation must stay aligned with materialization, resident lookup, scoped artifact keys, and the current bundle validation result.
  • Changes to shadow rollout rules must preserve the difference between an evaluating candidate, a missing shadow, and an enforcing mismatch.
  • Changes to snapshot generation or digest admission must stay aligned with the publisher acknowledgement and direct-lane freshness checks.
  • Changes to direct-lane workspace or input rules must preserve daemon fallback when the acknowledgement, workspace proof, or watched input is not current.
  • Changes to Cloud exception fields must update the signed payload identity, active view, acknowledgement binding, and request contract.
  • Changes to business policy authority must preserve replace semantics, exact digest approval, retained source evidence, and recovery-key checks.
  • Changes to Cloud access or entitlement states must keep new Cloud actions separate from local repair and removal actions.
  • Changes to action-pack authority must preserve native safety floors and the current command-control authority lease.

Important failure modes

TriggerConsequenceGuard
Resident lookup cannot reproduce the current signed bundle authorityCached remote rows are not used or the lookup defersDerive bundle identities with the same validation and materialization contract
Local row generation is older, missing, or not authenticatedThe row cannot supply a trusted remembered decisionVerify the row against the trusted generation and local key
A direct-lane acknowledgement is missing, stale, expired, or mismatchedThe hook uses the daemon path or defersRequire the current generation, digest, lease, and unchanged inputs
A v2 candidate disagrees with its enforcing shadowThe candidate is rejectedCompare canonical and legacy shadow decisions before enforcement rollout
Cloud access or paid entitlement cannot be provenNew Cloud-dependent actions are blockedResolve connection and entitlement state before submission
A Cloud exception is expired or exists only in an unsigned legacy payloadThe exception does not lift policyUse active entries from the accepted signed bundle only
Retained business source evidence has no installation keyRecovery does not create a fresh unprotected authorityRequire the source owner's recovery proof
A staged policy candidate or current digest changes before approvalThe request cannot apply the stale candidateRecheck the candidate digest and current authority at application
An action-pack authority marker is not currentThe managed action is not admittedMatch the signed marker to the current binding and hold the mutation lease

Key files

FileWhy to read it
rust/…/policy_decision_lookup_op.rsShows how local integrity and current signed-bundle identity control decision lookup.
rust/…/policy_bundle_store_identities.rsShows how resident lookups reproduce bundle authority and materialized identities.
rust/…/policy_integrity_rows_op.rsShows the native boundary for signing, verifying, and reconciling local rows.
rust/…/policy_integrity_generation.rsShows how trusted generations are adopted, reconciled, and cut over.
rust/…/policy_store.rsShows native snapshot admission and the shared local policy state.
rust/…/policy_store_authority.rsShows snapshot authority checks and change detection.
rust/…/policy_shadow_source.rsShows how a candidate selects its legacy or active shadow.
rust/…/policy_shadow_verdict.rsShows when shadow drift blocks an enforcing candidate.
rust/…/policy_store_direct_lane.rsShows freshness checks for direct hook use of the accepted snapshot.
rust/…/policy_store_direct_lane_reopen.rsShows safe recovery when a direct lane closes during republish.
src/…/policy_bundle_parser.pyDefines the signed bundle trust checks and payload identity.
src/…/cloud_exceptions.pyDefines Cloud exception scope, status, provenance, and active use.
src/…/cloud_exception_requests.pyDefines the request boundary and correlation-only command-policy contract.
src/…/policy_tools.pyShows digest-bound policy staging and approval.
src/…/cloud_review_sync.pyShows identity-bound Cloud review delivery and recovery status.
src/…/package_firewall_entitlement.pyShows how connection and entitlement state gates Cloud-backed actions.