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 / native-runtime-authority

Native runtime authority

The Rust native runtime is the trusted boundary for hook decisions. It admits bounded work, checks the active policy and rule state, evaluates commands and tool output, records route evidence, and returns a restrictive result when it cannot prove a safe outcome. It also owns the proof that an approved command is the same command that will run. Python connects harnesses, publishes policy, presents approval prompts, and renders the final response. See resident runtime residency and recovery, native command evaluation and classification, native command-source programs, and native command-pack lifecycle for focused views.

Authority boundary

The boundary separates native decision authority from Python coordination. A native result is a typed, bounded result with a receipt. Python may continue the user flow, but it does not recalculate the native action, reason, signature, or request identity.

Native decision ownership

The native edge owns the facts that decide whether a hook can run. It normalizes the harness and event, checks that duplicate event fields agree, binds the request to its policy generation, and rejects unsupported payload forms before rule evaluation. A hook that needs native authority must use the selected package-bound runtime and its advertised capability contract.

The exact-action boundary also owns the proof of launch identity. It derives the review binding and action proof from the hook payload, verdict, and receipt. A failed proof returns a known reason and no reusable token.

References: rust/…/edge.rs• L112-174 rust/…/edge.rs• L204-266 rust/…/native_exact_action_op.rs• L233-271 rust/…/hook_review.rs• L33-85 rust/…/resident_protocol.rs• L45-184

The runtime also owns small native facts used by Python-facing hook paths. These include payload facts, review bindings, connector launch facts, policy-admission messages, and policy-fence windows. This keeps one meaning for event names, tool inputs, committed authority, and recovery advice across direct hooks and daemon hooks.

References: rust/…/hook_payload_facts_op.rs• L37-180 rust/…/hook_review_binding_op.rs• L23-68 rust/…/hook_connector_facts_op.rs• L58-111 rust/…/hook_policy_admission_op.rs• L40-85

Python coordination

Python remains the control plane for harness wiring, policy publication, approval display, and response rendering. It sends typed requests to Rust and applies typed results. When a path needs facts that only the daemon can provide, the native direct lane defers instead of making a second semantic decision.

References: rust/…/hook_direct.rs• L1-34 rust/…/runner_authority_op.rs• L1-10 rust/…/runtime_cli.rs• L520-535

Hook admission

Hook admission protects the decision boundary before command or output review starts. The daemon bounds the body, payload references, deadline, queue slot, and per-client work. Saturation, invalid input, or a late result produces a fail-safe response rather than an implicit allow.

Admission controls

For each hook, the daemon settles the home, Guard home, workspace, and action working directory. It then assigns the request to a decision or content-security lane and reserves bounded capacity under a workspace and session key. A source-file or out-of-band payload is read only when its reference can be authenticated and kept within the allowed size.

References: rust/…/daemon_edge_hook_admission.rs• L13-20 rust/…/daemon_edge_hook_admission.rs• L76-108 rust/…/daemon_edge_hook_review.rs• L291-427

The resident server applies a second boundary around transport load. It limits active connections and returns an overload response when no slot is available. Its capability report advertises only features the running binary can honor, including bounded admission, panic containment, direct hooks, policy snapshots, and command authority.

References: rust/…/daemon_edge.rs• L34-78 rust/…/daemon_edge.rs• L101-162 rust/…/resident_protocol.rs• L45-169

Hook decision flow

The normal path first tries the resident direct lane when its bound state can reproduce the daemon result. Otherwise the daemon admits the request, prepares policy state, handles native lifecycle work, and asks the resident review path for the terminal harness response.

This diagram shows the relation between the harness, Python bridge, resident runtime, and daemon fallback.

flowchart TD
    A[Harness hook] --> B[Python bridge or direct native client]
    B --> C{Bound native answer available?}
    C -- yes --> D[Resident direct decision]
    C -- no --> E[Daemon admission]
    E --> F{Capacity and policy ready?}
    F -- no --> G[Harness fail-safe response]
    F -- yes --> H[Resident native review]
    H --> I{Review result}
    I -- decision --> J[Receipt and harness response]
    I -- failure --> G
    D --> J
    J --> K[Python rendering and evidence]
    G --> K

The direct lane is not a faster policy engine. It answers only when the workspace, snapshot, evidence path, saved decision, and runtime identity match the daemon contract. It defers for live daemon state, incomplete bindings, unsupported approval flows, or a superseded executable.

References: rust/…/hook_direct.rs• L165-199 rust/…/hook_direct.rs• L201-220 rust/…/daemon_edge_hook_review.rs• L428-485

Harness lifecycle paths

Some events are state transitions rather than new command decisions. Claude permission prompts, permission requests, turn ends, and settled approval questions use native authority state. The state is signed, tied to its session and artifact, and consumed only after the related policy write succeeds.

References: rust/…/daemon_edge_hook_lifecycle.rs• L1-14 rust/…/hook_authority_state_op.rs• L1-18 rust/…/question_settle.rs• L1-22

The same rule applies to approved-call continuity. A native witness ties a later output event to the exact call that passed approval. Without that shared call identity, the later output keeps its policy floor.

References: rust/…/native_admitted_call.rs• L1-15 rust/…/native_admitted_call.rs• L38-80

Policy snapshots

A policy snapshot is the immutable policy view used for one native decision. It binds policy generation to runtime identity, rule identity, mode, scope, command authority, and the effective settings that the decision may use.

Snapshot admission

Python publishes a snapshot or a compact reference. Rust validates the schema, generation, runtime, rule contract, scope, expiry, and derived identity before it becomes active. A hook can match the installed snapshot, but it cannot install, replace, or downgrade policy while a decision is in flight.

References: rust/…/resident_ops.rs• L62-90 rust/…/edge.rs• L467-480 rust/…/policy_enforcement.rs• L77-80

The snapshot is also the comparison point for direct answers and approval reuse. A changed generation, context digest, command-program identity, or runtime state makes the old binding unusable. This prevents Python from treating two similar requests as equivalent when the authority changed.

References: rust/…/edge.rs• L269-294 rust/…/hook_direct.rs• L184-199 rust/…/hook_review_binding_op.rs• L41-67

Policy and rule joins

Native rule evaluation first establishes an intrinsic action from the request. Policy then joins its own floor with that result. The join can raise an action, but it cannot weaken an intrinsic block, sandbox requirement, sensitive-target finding, malformed result, or unknown result.

Observe mode changes only policy-only escalation. It records a warning for a proven safe action while preserving intrinsic review, reapproval, sandbox, block, and malformed outcomes.

References: rust/…/policy_enforcement.rs• L3-14 rust/…/policy_enforcement.rs• L336-395 rust/…/hook_decision_compose.rs• L266-320

Python action hints are inputs to composition, not proof. A native floor wins over a permissive hint. An unauthenticated permissive daemon hint preserves the current action, while strict daemon failure tightens it to block.

References: rust/…/hook_decision_compose.rs• L61-141 rust/…/hook_decision_compose.rs• L322-354

Program and pack authority

Declarative command programs are native rule data for command forms and effects. Their program, catalog, and trust identities are part of runtime capability and policy authority. Publication and pack activation are separate from an ordinary hook request so an admitted decision sees one stable command authority.

Declarative command programs

The runtime evaluates command programs on the native side and exposes their digests through capabilities. A command-control fence prevents a catalog or program change from racing with a hook or approval decision. A catalog change can invalidate related grants and return affected tools to review. See native command-source programs for the program model.

References: rust/…/resident_protocol.rs• L55-69 rust/…/resident_protocol.rs• L172-184 rust/…/resident_ops.rs• L419-428

Pack authority transitions

Command-pack state records which installed or remote source is trusted. Transitions move forward through authority and revocation floors. They reject rollback, version reuse, missing ancestry, and activation whose prepared policy or security observation no longer matches. A retained subset may narrow content, but it cannot expand authority. See native command-pack lifecycle for lifecycle states.

References: rust/…/pack_reserve.rs• L38-157 rust/…/pack_finish.rs• L99-198 rust/…/active_pack_security.rs• L258-449

Route receipts

A route receipt records which authority produced the terminal hook outcome. The native decision receipt binds the request, policy context, action, and result. The route label records whether the terminal answer came from the resident, a direct one-shot path, Python semantics, or a documented degraded path.

Provenance states

RouteMeaning
native_residentA resident Rust process returned the accepted native result.
native_oneshotA direct native one-shot path returned the accepted result.
native_fail_safeNative authority was required but could not produce a trusted result.
native_degradedA documented recovery or recording-only path returned a degraded-safe result.
python_semanticPython owns the terminal semantic result.

The route label and native decision receipt are separate contracts. The worker checks the receipt before storing it or using it as approval evidence. Receipts also feed bounded local and cloud event queues; queued summaries are scrubbed and pending policy decisions may be updated only while the event remains pending.

References: rust/…/edge.rs• L441-465 rust/…/guard_store_receipt_events.rs• L35-82 rust/…/guard_store_receipt_events.rs• L94-135

Output delivery

The native result records what the harness can enforce. For example, a harness that already delivered output cannot claim that a later block removed it, while a harness that replaces blocked output records that withholding. This keeps the receipt and the user-visible effect aligned.

References: rust/…/edge_post_tool_delivery.rs• L1-57 rust/…/edge.rs• L367-411

Approval continuation

Native approval is a continuation of a native floor. Python may show the question and collect the answer, but Rust rebuilds the request binding, checks the policy and runtime context, and controls one-use state. Approval can settle an eligible review; it cannot lower an intrinsic block or sandbox floor.

Review bindings

An approval binding covers the request identity, action class, policy and rule identity, runtime, workspace, device, installation, and selected artifact facts. Raw command text, paths, prompts, and source content do not become reusable approval authority. A retry is accepted only when native proof establishes the same effective action.

The exact-action review derives its binding and action query from one hook review. It checks the receipt's policy binding once, then answers each query as its own native operation would. A valid review has one proof token or one recognized once_only_reason; an invalid or mixed result becomes unproven_launch and cannot mint a retry.

References: rust/…/hook_review_binding_op.rs• L23-67 rust/…/hook_review.rs• L33-175 rust/…/reasons.rs• L16-51 rust/…/native_admitted_call.rs• L98-170

Native store work keeps policy writes, audit events, approval rows, and receipt state in one bounded transaction. Persistent grants can be reused across resident restarts only while their signed authority remains valid. A one-time grant is consumed before a second launch, and a changed helper, expired grant, or tampered record refuses execution without spending the launch.

References: rust/…/guard_store_op.rs• L1-10 rust/…/guard_store_op.rs• L131-170 rust/…/bash_grant_tests.rs• L334-470 rust/…/question_settle.rs• L112-224

Native operation surface

The resident protocol is the common interface for hook decisions, policy snapshots, approvals, command authority, lifecycle state, store transactions, route work, and Python-facing transforms. Its typed operation set gives the native boundary one schema, size limit, and error model.

Resident protocol

The runtime CLI accepts explicit command and argument shapes. Structured requests use bounded input and typed output. The resident protocol rejects unknown request shapes, oversized responses, and error codes outside the published contract. Capabilities describe the protocol version, runtime identity, rule digest, program digests, catalog digest, trust digest, and supported features.

Readiness is a separate contract for whether native authority can safely evaluate. Only ready carries an evaluated and safe verdict. Starting, overloaded, unavailable, incompatible, unauthenticated, and failed states report that evaluation did not occur, with a bounded reason and recovery guidance. Unknown reason text maps to an unavailable result without exposing the original text.

References: rust/…/runtime_cli.rs• L3-18 rust/…/runtime_cli.rs• L104-123 rust/…/resident_protocol.rs• L418-458 rust/…/native_readiness_tests.rs• L15-26 rust/…/native_readiness_tests.rs• L214-255

Python-facing transforms

Runner authority and daemon route operations let Python use the same native decisions for evaluation records, hook rendering, harness routes, adapter state, and managed configuration. These operations return patches, projections, or typed refusals. They do not grant execution to data that Python has not proven against the native contract.

References: rust/…/runner_authority_op.rs• L80-124 rust/…/daemon_route_paths.rs• L261-301 rust/…/daemon_edge_route_calls.rs• L13-47

Fail-safe execution

Fail-safe execution means that uncertainty at the native boundary restricts the outcome. Invalid identity, stale policy, bad framing, overload, timeout, authentication failure, unsafe source access, malformed output, or a contained panic cannot become an allow in a mode that requires Rust.

Failure boundaries

The runtime contains evaluation failures and turns unknown transport, approval, lifecycle, and store errors into finite error results. It retries only transient local transport conditions. Integrity, authentication, protocol, policy, and committed-write failures remain failures. Readiness failures remain explicit non-evaluated states instead of being reported as safe decisions.

References: rust/…/lib.rs• L1-2 rust/…/resident_protocol.rs• L428-458 rust/…/native_error_code.rs• L11-31 rust/…/native_readiness_tests.rs• L204-246 rust/…/guard_store_op.rs• L162-170

Harness outcomes

The final harness response reflects the native floor and route. A native block reaches the harness as a block. A review enters approval coordination. A required native failure uses the fixed fail-safe envelope. A recovery or recording-only response uses separate degraded provenance instead of claiming normal native authority.

References: rust/…/daemon_edge_hook_envelopes.rs• L49-85 rust/…/daemon_edge_hook_review.rs• L462-485 rust/…/hook_decision_compose.rs• L322-354

Change checklist

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

  • Keep capability features, protocol versions, runtime identity, rule digest, program digests, and Python route gates aligned. An advertised feature that the binary cannot honor can change a required hook result.
  • Keep event canonicalization, payload facts, request identity, policy generation, review bindings, route labels, and receipts aligned. A new hook path must not reuse a receipt or report the wrong terminal authority.
  • Keep admission budgets, scheduler lanes, payload-reference rules, direct-lane bindings, and daemon fallback behavior aligned. A direct answer must cover only a result the daemon would return with the same authority.
  • Keep intrinsic action floors, policy joins, observe mode, approval eligibility, post-tool delivery, and harness envelopes aligned. A user-facing response must not claim an effect the harness cannot enforce.
  • Keep exact-action proof inputs, recognized once-only reasons, approval tokens, helper identity, and one-time consumption aligned. A review must not turn an unproven or changed launch into reusable authority.
  • Keep snapshot generation, command-control fences, catalog and program digests, pack epochs, revocation floors, and grant invalidation aligned. A retained or pending pack must not expand authority.
  • Keep native store commits, approval consumption, authority-state cleanup, receipts, and cloud event queue state aligned. A failed or partial write must not leave reusable approval or misleading evidence.
  • Keep readiness states, emitted reason codes, safe-verdict fields, retry flags, and recovery commands aligned. A new runtime failure must not become an unrecognized or apparently safe readiness result.
  • Keep explicit CLI shapes, resident operation variants, response size limits, and published error codes aligned. Unknown or oversized input must stop before semantic evaluation.

Important failure modes

TriggerConsequenceGuard
Runtime capabilities or policy identity do not match the selected packageNative authority is unavailableCapability and snapshot binding checks run before hook evaluation.
Event fields disagree or a request uses a stale generationThe native edge rejects the hookCanonical event checks and generation validation run before rule evaluation.
Admission capacity, deadline, or payload bounds are exceededThe harness receives a fail-safe responseScheduler reservations, connection limits, and fixed fail-safe envelopes bound the work.
A direct hook lacks daemon-parity state or runs a superseded executableThe resident defers to the daemonDirect answers require current runtime identity and complete bindings.
The hook receipt or verdict has an incomplete policy bindingReview evidence cannot mint a reusable tokenNative review checks the receipt and returns a known refusal reason.
A command proof is absent, mixed, or no longer matches the launchApproval reuse is refusedExact-action proof returns one token or one recognized once-only reason.
A one-time grant is expired, tampered, or already claimedNo second launch occursNative authority verifies signed grant state and consumes it once.
Policy or command authority changes during a decisionThe snapshot or grant cannot be usedNative fences and immutable admitted snapshots keep one authority view.
Approval context or call identity does not match the retry or output eventApproval reuse is refused and the policy floor remainsNative bindings and admitted-call witnesses require the same request or call identity.
Store, receipt, or event write is incompleteNo reusable approval or trusted route evidence is returnedBounded transactions report committed state and scrub or reject invalid events.
Runtime readiness reports an unknown reason or a non-ready stateThe result is unavailable or not evaluated, never safely evaluatedThe readiness contract maps known reasons to states and redacts unknown reason text.
Native response is malformed, unknown, late, or panics during evaluationThe supported hook fails safeTyped response checks, finite error codes, deadlines, and panic containment prevent an allow.

Key files

FileWhy to read it
rust/…/edge.rsDefines how a validated hook envelope becomes a native decision and receipt.
rust/…/daemon_edge_hook_review.rsShows hook admission, daemon fallback, lifecycle handling, and fail-safe delivery.
rust/…/hook_direct.rsShows when the resident can answer directly and when it must defer.
rust/…/policy_enforcement.rsShows how intrinsic findings and installed policy floors join.
rust/…/hook_decision_compose.rsShows how native floors interact with Python-facing action hints.
rust/…/native_exact_action_op.rsDefines the native proof boundary for action identity, review evidence, and approval tokens.
rust/…/hook_review.rsShows how one hook review becomes its binding and action queries.
rust/…/reasons.rsDefines stable reasons for launches that cannot receive reusable approval.
rust/…/bash_grant_tests.rsShows the guarantees for persistent grants, one-time grants, mutation checks, and tamper refusal.
rust/…/resident_protocol.rsDefines capabilities, typed resident operations, bounds, and safe errors.
rust/…/resident_ops.rsRoutes resident operations to the native authority owning each decision.
rust/…/runtime_cli.rsDefines explicit native CLI, hook, one-shot, and resident-client entry paths.
rust/…/native_readiness_tests.rsShows the readiness contract for evaluated, non-evaluated, retryable, and unsafe states.
rust/…/hook_payload_facts_op.rsShows the native normalization shared by Python-facing hook paths.
rust/…/hook_review_binding_op.rsShows the committed authority inputs used to bind a review.
rust/…/guard_store_op.rsShows transaction and committed-write behavior for native state.
rust/…/guard_store_receipt_events.rsShows how route evidence enters the bounded event queue.
rust/…/native_admitted_call.rsShows continuity between an approved pre-hook and its post-hook.
rust/…/hook_authority_state_op.rsShows signed lifecycle state for Claude and Cursor hook paths.
rust/…/runner_authority_op.rsShows the shared native transform surface used by Python.
rust/…/daemon_route_paths.rsShows route classes and authentication boundaries for daemon paths.
rust/…/edge_post_tool_delivery.rsShows how native output decisions map to harness effects.
rust/…/edge_session_cascade.rsShows native stops for repeated calls and subagent fan-out.