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 / device-management-and-deployment

Device management and deployment

Guard protects a deployed device through a machine-owned package, managed policy, stable device identity, and recurring local evidence. MDM controls installation and policy authority while user context controls that user's Guard integrations. Local protection continues when Cloud or other optional network services are unavailable.

Deployment model

Machine and user boundaries

The deployment separates machine authority from user state. The machine package owns the runtime, machine state, logs, policy source, identity, and health schedule. A user activation owns only that user's ~/.hol-guard state and reversible harness integrations.

This boundary prevents a root or SYSTEM process from guessing a user profile. A device can install before a user signs in. Each eligible user then reaches the managed state at login without a second device install.

AreaMachine contextUser context
Runtime and policyOwns the installed Guard runtime and managed policyCannot replace machine authority
Device evidenceCreates identity, continuity, integrity, and health evidenceDoes not provide machine identity
User protectionRegisters coverage after activationActivates or repairs the user's Guard integrations
RemovalAuthorizes and completes machine-side cleanupConsumes the short-lived authorization

References: src/…/contracts.py• L272-325 src/…/lifecycle.py• L139-159 docs/…/0001-mdm-managed-install-contract.md• L5-12

Platform packages

The platform package installs Guard per machine and gives MDM one vendor-neutral lifecycle contract. macOS uses the org.hol.guard package identity. Windows uses the stable MSI upgrade code B15D39B1-6395-4FEA-98A9-5D734DDC455D. MDM products can adapt detection and assignment without changing Guard behavior.

Production packages bind the runtime to a signed release manifest and a native platform signature. The manifest identifies the platform, architecture, version, installer identity, and complete runtime file set. An unsigned artifact is a test fixture and must not appear healthy in production detection.

The package builders also create the platform login hook and machine health runner. They do not fetch dependencies or contact Guard Cloud during install, repair, replacement, or removal.

References: scripts/…/build-pkg.sh• L10-18 scripts/…/build-pkg.sh• L41-68 scripts/…/build-msi.ps1• L17-46 scripts/…/hol-guard.wxs• L1-5 src/…/manifest.py• L193-206 src/…/native.py• L49-65

Managed policy and identity

Machine policy authority

Managed policy is the machine-level source for settings that an organization controls. macOS reads managed preferences. Windows reads policy from the machine registry. The policy parser rejects unknown or invalid values before they become authority.

Managed values cannot weaken a stronger local security value. Locked settings require the managed value to remain in force. Guard also checks that local policy files and their parent paths remain machine-controlled before it treats them as authority. On Windows, a cached file is never promoted to policy authority when its owner and access control cannot be verified through native security APIs. If configured machine authority becomes unreadable or tampered, Guard uses a fail-closed security floor rather than silently accepting weaker local settings.

The policy also binds update ownership, required harnesses, daemon startup, release trust, network behavior, and optional policy-bundle trust. The policy bundles, integrity, and sync page explains the policy-bundle trust and synchronization path in more detail.

Managed policy can also control extension behavior. The managed extension controls page explains that extension-specific control plane.

The policy loader keeps a small, stat-validated memo for stable file-based sources. It does not reuse a result while the policy or its trusted parent paths may still be changing. Windows machine policy is checked through the registry source on each load because it has no equivalent cheap change signature. Native load or parse failure remains an inaccessible or invalid authority state rather than an absent policy.

References: src/…/policy.py• L1-7 src/…/policy.py• L102-112 src/…/policy.py• L160-215 src/…/policy.py• L218-240 src/…/managed_file_trust.py• L21-74 docs/…/mdm-deployment.md• L15-35

Device identity and continuity

The device identity is a machine key held by a platform-native protected key store. Guard uses bounded native helper calls for live key evidence and for signing health material. The native boundary accepts only well-formed key evidence and canonical lease data. Machine-only operations require a privileged machine context. On Windows, Guard confirms that context from the process token as LocalSystem before device-key work proceeds.

Provisioning is idempotent. Rotation keeps the prior public identity until the related continuity state can move safely. Revocation disables signing first and removes retained key generations.

Installation continuity adds a machine installation ID and an installation generation. Health leases use a monotonic sequence, the previous lease digest, the boot session, and the device key identity. These links help the receiving service distinguish a continuing installation from copied, replayed, or altered state.

The identity and continuity records are machine-owned. Missing, changed, mismatched, or inaccessible records produce an explicit degraded or tampered result instead of a new identity being invented during a health run.

References: src/…/device_key.py• L269-327 src/…/device_key_native.py• L167-291 src/…/device_key_windows_api.py• L28-81 src/…/continuity.py• L318-397

Lifecycle

Installation and activation

Installation prepares the machine runtime and machine protection. It provisions device identity and installation continuity, then installs the protected machine health schedule. It does not activate a guessed user.

At user login, the platform hook runs a repair-style activation for the current user. Activation applies the managed install, records the activation marker, and requests machine-side harness coverage registration. The operation is idempotent, so repeated login or repair converges on the same protected state.

The lifecycle moves through machine preparation and user convergence as shown below.

flowchart LR
    A[MDM installs package] --> B[Provision device identity]
    B --> C[Provision installation continuity]
    C --> D[Install machine health supervisor]
    D --> E[User signs in]
    E --> F[Activate or repair user state]
    F --> G[Register required harness coverage]
    G --> H[Guard protects user activity]

References: scripts/…/hol-guard.wxs• L38-65 scripts/…/org.hol.guard.user-activation.plist• L5-12 scripts/…/activate-current-user.sh• L4-8 src/…/lifecycle.py• L411-447

Deactivation and removal

Managed deactivation uses two contexts because a machine authority must authorize removal while the target user must remove that user's state. The machine creates a short-lived authorization bound to the target user and installation. The user-context operation consumes it and restores Guard-owned integrations. Machine context then unregisters coverage and removes the authorization.

Package removal is not the same as authorized device retirement. Upgrades and rollback preserve the machine identity and continuity where possible. Irreversible key retirement belongs to an authorized removal flow, so an interrupted package action does not create a new device identity or erase evidence by accident.

References: src/…/lifecycle.py• L496-539 scripts/…/deactivate-user.sh• L9-21 scripts/…/deactivate-user.ps1• L1-10 scripts/…/hol-guard.wxs• L56-65 docs/…/mdm-deployment.md• L50-60

Integrity and protection

Local integrity evidence

The local integrity snapshot is a bounded machine report that combines the checks needed to decide whether a deployment is trustworthy and how it can be repaired. It reports one overall result plus separate component states for the release manifest, native package, policy, ownership and access control, supervisor, device key, harness coverage, installation identity, lease continuity, daemon, command shadowing, and update eligibility.

The native package check confirms the platform package identity, release version, and publisher signature. macOS verifies the org.hol.guard receipt and expected signing team. Windows verifies the HOLGuardMachine executable with configured machine-package signer thumbprints. These pins belong to the MDM machine package and must not be confused with rotating Desktop Artifact Signing certificates.

The report includes only the identifiers and product facts needed for fleet review. Its assurance level distinguishes user-managed installation from MDM-managed installation that has not yet been fully verified. Its remediation class points to user reinstall, MDM repair, or administrator action. A healthy report requires every required component to be healthy and carries no reason codes.

References: src/…/integrity.py• L225-361 src/…/native.py• L17-65 src/…/native.py• L67-165 src/…/contracts.py• L239-269 docs/…/local-integrity-snapshot-v1.schema.json• L7-23 docs/…/local-integrity-snapshot-v1.schema.json• L57-119

Harness coverage

Harness coverage connects a machine-managed deployment to the user-facing entry points that must be protected. MDM declares required harnesses. User activation prepares the user's managed installs. Machine context then registers the observed coverage against the installed runtime.

Coverage is reported separately from package integrity because a valid machine package does not prove that every required user integration is active. Missing or degraded coverage can therefore lead to repair without treating the package itself as altered.

References: src/…/lifecycle.py• L184-273 src/…/lifecycle.py• L450-493 src/…/integrity.py• L265-268

Health reporting

Machine health cadence

The machine health cadence runs independently of user sessions and harness activity. It checks the managed binding, creates or recovers a signed protection lease, and sends it through the machine-owned Cloud connection when one is configured. A lease binds the workspace, device, machine installation, installation generation, sequence, snapshot digest, and signing key.

The cadence registers the current health key, delivers the lease, stores the authenticated acknowledgement, and then checks for a single pending attestation challenge. A challenge can produce only a new lease bound to its exact nonce and installation context. Invalid or command-shaped responses are rejected.

Cloud delivery failure does not remove the local outbox or change local enforcement. The health result reports delivery state, lease age, delivery delay, queue depth, key storage health, and a bounded reason. A missing machine Cloud profile reports that the lease is ready rather than borrowing a logged-in user's credentials.

References: src/…/health_reporter.py• L63-172 src/…/health_lease.py• L332-471 src/…/health_transport.py• L29-43

Network boundary

Managed network policy

All external Guard HTTP uses one managed network policy. The authoritative transport applies that policy to both URL and requests-based clients. It selects direct access, the platform system proxy, or an administrator-defined HTTPS proxy while keeping TLS validation enabled in every mode.

Managed transport does not treat user shell proxy or CA settings as machine authority. In managed mode, the requests client does not trust the process environment and both HTTP client paths use the selected proxy and managed TLS context. Proxy credentials stay in the native operating-system credential store rather than in policy. A managed CA bundle adds to public and system trust; it does not replace them. Optional public package registries can be blocked without blocking Guard Cloud or local enforcement.

The policy accepts only absolute HTTPS proxy and update endpoints. It rejects embedded proxy credentials, unsafe proxy origins, invalid certificate paths, and other malformed values before a request proceeds. Proxy authentication records are read through the native store for the current platform and must have a bounded, valid shape. The transport validates destinations and prevents authenticated requests from following redirects to an uncontrolled destination. It also refuses encoded response bodies before a client decoder can process them. Direct authenticated calls can reuse a short-lived connection, which reduces repeated TLS setup without changing redirect or request-safety rules. A stale reused connection is retried only when the request was not sent or the method is safe to repeat. Network diagnosis reports DNS, proxy selection, TLS, clock, and endpoint reachability as separate bounded results. When remote services fail, Guard keeps using validated local policy and signed cached intelligence where available. The cloud device-control integration page covers the Cloud-side device contract that uses this boundary.

References: src/…/policy.py• L31-43 src/…/policy.py• L66-96 src/…/policy.py• L171-215 src/…/network.py• L1-25 src/…/network_credentials.py• L40-137 src/…/network_keepalive.py• L24-37 src/…/network_keepalive.py• L39-91 src/…/network_keepalive.py• L110-191 src/…/network_transport.py• L56-67 src/…/network_transport.py• L70-242 src/…/network_transport.py• L245-352 src/…/network_transport.py• L355-439 src/…/network_trust.py• L43-96 docs/…/mdm-networking.md• L1-14 docs/…/mdm-endpoints.v1.json• L1-20

Supervisor and service cadence

Native health supervisor

The native supervisor gives machine health a protected execution schedule. macOS uses a system LaunchDaemon. Windows uses a hidden SYSTEM scheduled task. Both invoke the machine runtime on a fixed cadence and use a controlled environment rather than user shell state.

Health checks verify more than process presence. They verify the registration, target executable, run identity, schedule, and protected paths. A stopped, disabled, mismatched, or invalid supervisor is reported as a distinct health state so MDM can choose repair instead of assuming that a running binary is enough.

This supervisor is separate from the on-demand Guard daemon. For daemon startup, worker isolation, and local service recovery, see Daemon and local service lifecycle.

References: src/…/supervisor.py• L19-34 src/…/supervisor.py• L121-140 src/…/supervisor.py• L237-300 scripts/…/org.hol.guard.machine-health.plist• L5-25 scripts/…/hol-guard.wxs• L38-52

Cloud device-control integration

Cloud device-control integration supplies enrollment, policy delivery, acknowledgement, health lease handling, and remote remediation around the local deployment contract. Keep those server and client exchange rules in Cloud device-control integration; this page covers the local device boundary that receives and proves those controls.

Change checklist

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

  • Keep package identity, release-manifest installer identity, native signature checks, and MDM detection aligned for both platforms.
  • Keep machine and user context boundaries aligned across login activation, harness coverage registration, deactivation authorization, and removal cleanup.
  • Keep device-key generations, installation continuity, lease claims, acknowledgements, challenge bindings, and privileged machine-context checks compatible when identity or health contracts change.
  • Keep the Windows token API bindings aligned with the machine-context check so non-SYSTEM work cannot create or use machine identity.
  • Keep native helper output, canonical lease claims, signature formats, and return states aligned with the device-key contract.
  • Keep machine-policy path ownership checks aligned with the platform source so a local cache cannot become authority without proof of control.
  • Keep Windows registry policy authority distinct from the unverified ProgramData cache. Do not promote a cache file to signing authority without native owner and DACL verification.
  • Keep policy-load states, native request schemas, source labels, cache freshness rules, and the fail-closed floor aligned when managed policy loading changes.
  • Keep every integrity component and reason code aligned between the snapshot producer and local-integrity-snapshot.v1.
  • Keep the network facade and every external caller on the authoritative managed transport. Apply the same policy to URL clients, requests sessions, health delivery, and diagnostics.
  • Keep native proxy credential records, proxy endpoint hashes, authentication headers, TLS trust, destination checks, redirect handling, environment trust, and response-encoding refusal aligned across both HTTP client paths.
  • Keep public and system trust, administrator CA trust, proxy selection, credential loading, destination blocking, and authenticated-request redirect rules aligned across both supported HTTP client paths.
  • Keep direct authenticated connection reuse bounded by idle age and host count. Reuse only fully consumed responses, and retry a stale connection only when the request was not sent or the method is safe to repeat.
  • Keep supervisor registration, health command arguments, executable paths, and platform package actions aligned.

Important failure modes

TriggerConsequenceGuard
The package, native signature, or release manifest does not match the expected platform identityMachine status is unhealthy and production detection must not accept the installSigned manifest and native package verification must agree on version and identity
Managed policy is invalid, inaccessible, or tamperedGuard uses a fail-closed security floor or reports degraded managed stateValidate machine-owned policy sources and do not promote an untrusted cache
Windows policy is present only as an unverifiable cached fileThe cache cannot become machine policy authorityRead authority from HKLM. Keep the Windows cache fail-closed until native owner and DACL checks exist
Device-key work runs outside the privileged machine contextThe operation fails before it can create, inspect, revoke, or use machine identityRequire root on macOS and LocalSystem on Windows. Verify the Windows process token through the platform token API
A native helper returns malformed evidence or a non-canonical lease payloadKey state or health signing fails closed instead of producing proof that another component can trustBound helper output and time. Validate the exact response shape, canonical claims, and signature encoding
The device key or continuity record is missing, changed, or bound to another keyIdentity proof and lease issuance fail closedVerify live key evidence and continuity bindings before issuing a lease
A managed policy file or one of its parent paths is user-controlledLocal content can be mistaken for machine authorityRequire a machine-owned regular file and trusted ancestor path checks for the active policy source
A required user harness is absent or degradedThe machine package may be valid but user protection is incompleteRegister coverage after activation and report coverage as its own component
The supervisor is disabled or points to another executablePeriodic machine health evidence stops or runs outside the protected runtimeVerify the native registration, identity, schedule, and target executable
Cloud, proxy, DNS, or TLS delivery failsHealth delivery is delayed, but local policy enforcement continuesRetain the protected outbox and use bounded delivery diagnostics
A managed proxy, proxy credential record, destination, or administrator CA bundle is invalidThe request is blocked before it can use an untrusted network pathValidate the managed policy, native credential record, destination, and machine-controlled CA bundle
An authenticated request receives a redirectCredentials could be sent to a destination outside the intended endpointReject redirects for requests that carry authentication headers
A response has content encoding that the transport did not permitThe body is refused before a client decoder processes itRequest identity encoding and reject encoded responses in the shared transport
A pooled direct connection is stale or a response body is not fully consumedThe next request can fail or the connection can carry unread data into another requestExpire idle connections, check for peer closure, and return only complete responses to the pool
A stale connection fails after a non-repeatable request may have reached the serviceRetrying can duplicate a lease, acknowledgement, or result actionRetry only before a request is sent or for methods safe to repeat
Deactivation lacks a valid short-lived authorizationUser state is not removed and coverage cleanup cannot completeRequire machine-created authorization bound to the target user and installation

Key files

FileWhy to read it
docs/…/0001-mdm-managed-install-contract.mdStates the machine/user ownership and platform deployment decisions
docs/…/mdm-deployment.mdDescribes the vendor-neutral deployment, trust, health enrollment, and upgrade contract
src/…/contracts.pyDefines the shared policy, identity, integrity, status, and machine-path concepts
src/…/lifecycle.pyShows the user activation, repair, coverage, and authorized removal flow
src/…/policy.pyDefines strict managed-policy validation, platform authority sources, cache handling, memo freshness, and non-weaker policy composition
src/…/device_key.pyShows the device identity lifecycle and proof states
src/…/device_key_native.pyShows the bounded native device-key and lease-signing boundary
src/…/managed_file_trust.pyShows the cross-platform trust checks for machine-managed files and their parent paths
src/…/device_key_windows_api.pyShows the typed Windows token boundary used to verify machine context
src/…/continuity.pyShows installation continuity and lease sequence evidence
src/…/integrity.pyShows how local machine evidence becomes one bounded integrity result
src/…/native.pyShows platform package identity and publisher-signature verification
src/…/health_reporter.pyShows the machine-only health cadence and its delivery states
src/…/network.pyExposes the single managed network boundary used by Guard HTTP clients
src/…/network_keepalive.pyReuses short-lived direct HTTPS connections without repeating unsafe requests
src/…/network_transport.pyApplies managed policy, proxy, destination, credential, TLS, environment, redirect, and response handling rules to both external request clients
src/…/network_credentials.pyReads bounded proxy-auth records from native operating-system credential stores
src/…/network_trust.pyBuilds verified public, system, and additive administrator CA trust
src/…/supervisor.pyDefines native machine health scheduling and verification
src/…/manifest.pyDefines release-manifest identity and runtime coverage checks
scripts/mdm/windows/hol-guard.wxsShows Windows per-machine installation and machine actions
scripts/…/build-pkg.shShows macOS package assembly, signing, and health components