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 / cloud-device-control-integration

Cloud device-control integration

Cloud device-control integration connects an MDM-managed Guard installation to a workspace control plane. It gives an administrator a bounded way to enroll a device, deliver signed policy, receive proof of application and health, and send typed repair work while the device keeps enforcing its last trusted state during Cloud or process failure. See Device management and deployment for the machine installation boundary and Policy authority and Cloud exceptions for policy trust inside Guard.

System boundary

The integration has three trust boundaries: the MDM-managed machine, the Cloud control plane, and the transport between them. The machine owns its device identity and local enforcement. Cloud owns desired policy, delivery records, health records, and remediation jobs. The transport carries only identity-bound and purpose-bound data.

The Cloud channel does not become a general remote shell. Its contracts reject secrets and command-like authority fields. This keeps device control separate from local Guard enforcement and from the daemon's local service interface. See Daemon and local service lifecycle for the local process boundary.

Control-plane responsibilities

The integration assigns each side a clear role:

SideResponsibility
MDM-managed Guard clientHolds the device key, installation identity, active policy, health snapshot, and retry state.
Cloud control planeRegisters devices, signs desired policy, records acknowledgements and health, and creates typed remediation jobs.
Request transportAuthenticates device requests and carries bounded configuration, evidence, and job data.

References: src/…/contracts.py• L12-24 src/…/health_transport.py• L29-43 scripts/…/README.md• L24-33

Device enrollment

Enrollment creates the binding that all later Cloud actions use. A device presents its workspace, device, installation generation, and public machine key with a one-time enrollment token. Cloud accepts the token once and returns the public key used to verify later signed configuration.

Enrollment identity

The installation generation distinguishes one machine installation from another. The public P-256 key proves that the enrolling device controls the identity it presents. Cloud rejects token reuse and rejects a second device that tries to reuse an existing public key. This prevents a copied enrollment record from becoming a second managed client. device_base.py• L145-169 lab_store_base.py• L240-286

Enrollment is not the same as policy activation. Enrollment establishes who may speak for the device. A later signed configuration establishes what the device should enforce.

Request proof

After enrollment, each runtime request carries a proof bound to the HTTP method, path, body, device identity, request time, and increasing request sequence. Cloud checks the proof and the stored sequence before it accepts configuration requests, acknowledgements, health, or remediation results.

This binding makes a valid request unusable at another endpoint or in another workspace. A replay, a changed body, a changed path, or a clock outside the accepted window is a request failure rather than a new device action. device_base.py• L171-207 lab_store_base.py• L288-342

Policy delivery

Policy delivery moves signed desired state from Cloud to the local MDM policy surface. Cloud assigns revisions to enrolled devices. The device asks for its current assignment and applies it only after it verifies the assignment's identity, signature, policy hash, revision chain, validity window, and rollback meaning.

Signed desired state

Each configuration envelope binds these concepts:

  • Workspace, device, and installation generation.
  • A monotonic revision and the predecessor policy hash.
  • The managed policy and its policy hash.
  • Validity times and explicit rollback metadata.
  • The Cloud signing identity and signature.

The predecessor hash makes the assignment stream a chain. A stale or out-of-order envelope cannot replace a newer accepted revision. An authorized rollback is still a new signed revision, so the device never treats an old response as a free downgrade. cloud_control.py• L223-306 lab_store_policy.py• L56-140

The device uses an ETag to avoid reapplying unchanged state. The ETag is only a transport hint. The revision and policy hash remain the authority, so a newer revision with the same policy bytes is still visible and applied.

Policy acknowledgement

An acknowledgement reports the result for one exact revision and policy hash. It is delivery evidence, not permission to weaken local policy. Cloud retains historical acknowledgements so a delayed report for an earlier assignment remains meaningful after a newer assignment exists. lab_store_policy.py• L161-205

The device queues an acknowledgement before it depends on successful transport. It removes the queued item only after Cloud accepts it or proves that the exact request already exists. Transient errors and uncertain responses leave the item for retry. device_outbox.py• L18-84

When Cloud, transport, signature, JSON, ETag, or policy validation fails, the client reports the failure while retaining the last known good policy. This separates delivery health from local enforcement health. device_policy.py• L73-127

The following flow shows how an assignment becomes local state and then becomes Cloud evidence.

sequenceDiagram
    participant C as Cloud control plane
    participant D as Managed Guard client
    participant L as Local policy surface

    C->>D: Signed configuration assignment
    D->>D: Verify identity, chain, time, hash, and signature
    D->>L: Atomically write managed policy
    D->>D: Queue exact acknowledgement and health evidence
    D-->>C: Acknowledgement and health report
    C-->>D: Typed remediation job when repair is needed
    D-->>C: Remediation result
    D-->>C: Fresh healthy evidence

Health leases

Health leases give Cloud fresh, signed evidence that a managed machine still has the expected protection state. The machine health cadence runs from machine context rather than from a logged-in user or an active Guard harness. It reports both local integrity and the identity of the lease.

Machine health cadence

The cadence requires an active MDM policy with locked workspace and device identifiers. It registers the machine health signing key, creates or recovers one pending lease, delivers it, and then polls for a purpose-bound attestation challenge. A challenge creates a new lease that proves the device answered that specific Cloud request.

The lease carries the machine installation identity, installation generation, sequence, snapshot digest, expiry, and prior lease digest. Cloud can therefore distinguish a current report from a replay or a report from a different installation. health_reporter.py• L40-137 health_lease_contract.py• L176-258

Health evidence

The signed snapshot describes machine protection as one bounded view. It includes installation identity, product identity, policy identity, key state, supervisor state, daemon state, harness coverage, and lease continuity. The snapshot must match the lease claims and the prior sequence before Cloud can use it.

Health reports are monotonic per device and installation generation. A duplicate exact report is safe to replay. A conflicting sequence or a report for another assignment is rejected. health_snapshot_validation.py• L130-229 lab_store_policy.py• L207-292

Lease acknowledgement

The client keeps one exact lease and its snapshot in a protected outbox. It records the lease sequence before it treats the lease as complete. A Cloud acknowledgement must match the workspace, device, installation identity, sequence, and lease digest. This makes a lost response recoverable without issuing a different lease for the same pending operation. health_lease.py• L268-377

The health transport is purpose-bound. It can register a key, poll an attestation challenge, and deliver a lease. It does not borrow a logged-in user's Cloud credentials for machine health. health_transport.py• L29-52 health_transport.py• L142-151

Installation continuity

Installation continuity links the machine identity to a protected installation record across boots and process restarts. It records the installation ID, generation, last lease sequence, last lease digest, signing key, boot session, and monotonic uptime. The record lets Guard detect identity changes and time movement without trusting user-writable state.

Continuity record

The continuity record is provisioned only after the machine device key is ready. Verification checks the record against the device key and the current boot observation. A missing record is an absent state. A key mismatch, invalid protected file, or monotonic regression is a tamper or degraded state rather than a fresh starting point. continuity.py• L39-84 continuity.py• L318-367

Crash recovery

Lease issuance uses a durable outbox and a continuity record as one recovery sequence. If the process stops after writing either part, the next cadence validates the exact pending lease and completes the missing step. An expired, unacknowledged lease remains evidence and cannot be replaced by a synthetic historical lease. health_lease.py• L380-471

This behavior is the main continuity promise for MDM-managed clients: a process restart or short Cloud outage can delay evidence, but it does not create a new identity or silently erase an unresolved delivery.

Remediation transport

Remediation transport lets Cloud request a small set of known repair operations. Cloud binds each job to the enrolled device and its current installation generation. The device validates the job before it runs it and returns a result through the same durable evidence path used for acknowledgements and health.

Typed remediation jobs

The allowed actions are fixed:

  • Install a target version.
  • Converge to a target version.
  • Refresh policy.
  • Repair machine or user scope.
  • Register the machine-health or supervisor service.
  • Run an integrity scan.

Each action has an exact parameter shape and a short validity period. Shells, scripts, URLs, credentials, open parameter bags, and unknown actions are not part of the contract. cloud_control.py• L49-56 cloud_control.py• L381-431

Remediation evidence

Cloud uses an idempotency key to return the same job on a retry and to reject a retry with different meaning. The device stores completed results by job ID, so a repeated poll does not run the same repair as a new job. lab_store_remediation.py• L24-114 device_remediation.py• L41-76

Successful local execution is not final Cloud success. Cloud marks the job as awaiting evidence until a later healthy report proves that the protection state recovered. This prevents a repair result from being mistaken for a verified repair. lab_store_remediation.py• L127-177 lab_store_policy.py• L259-286

Cloud-lab contracts

The Cloud lab is a provider-neutral reference control plane for this integration. It uses real HTTP between a persistent Cloud service, a fault proxy, and four independently keyed device runtimes in two workspaces. Its purpose is to prove the Guard-owned contracts without claiming that a commercial MDM provider or native platform has been certified.

Reference control plane

The lab models the full control loop:

  1. Enroll devices with one-time seeds.
  2. Publish baseline and canary policy by workspace.
  3. Apply revisions and record acknowledgements.
  4. Deliver health and remediation evidence.
  5. Inject faults and check recovery.
  6. Restart Cloud and devices against the same state.

The Cloud store keeps device identities, assignments and assignment history, acknowledgements, health, remediation jobs, and a hash-linked audit record. The device runtime keeps policy state, request sequences, outboxes, and completed job results. lab_store_base.py• L65-158 device_base.py• L25-73

Resilience matrix

The lab checks the properties that are easy to lose when a network or process fails:

ConditionExpected system behavior
Network partition or throttlingKeep the last trusted policy and retry queued evidence.
Lost success responseRetry the same operation without duplicate Cloud records.
Corrupt, stale, or incomplete configurationReject it and keep the accepted revision.
Process restartRecover persistent identities, revisions, outboxes, and audit state.
Cross-workspace targetReject the request without exposing another workspace.
Local repair successWait for fresh healthy evidence before closing the job.

The lab runner validates a bounded report with at least the full integration matrix and records native certification as not-evaluated. The container and workflow gates add isolation and evidence checks. README.md• L24-33 orchestrator.py• L32-110 run-cloud-integration-lab.py• L70-84

Managed-client continuity

Continuity means that MDM-managed Guard clients fail safe without losing the identity or trusted local state needed to recover. Machine policy is read from a trusted MDM source and can be cached only as controlled failure evidence. A live managed policy also supplies the workspace and device binding required for machine health.

Local enforcement during outage

Cloud availability affects delivery and health freshness. It does not grant permission to replace the active local policy with missing, stale, or unsigned data. The client reports a delivery failure while local enforcement remains healthy when the last accepted state is still intact. health_reporter.py• L131-172 policy.py• L365-407

Machine supervision

The machine health cadence is placed under a native machine supervisor rather than a user session. The supervisor runs with the machine identity and is checked for the expected executable, arguments, schedule, and security boundary. This lets health continue when no user is logged in and lets the health snapshot report a missing or stopped runner. supervisor.py• L19-33 supervisor.py• L315-329

Assurance levels

Machine health is available only to an MDM-managed installation with locked identity fields. User-managed Guard can opt into a lower-assurance health lease, but that path does not replace the machine-owned key and continuity guarantees. user_health.py• L287-335

Change checklist

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

  • Keep the enrollment identity fields aligned across the enrollment payload, stored device row, request proof, configuration envelope, health lease, and remediation job.
  • When changing revision or policy-hash rules, update ETag handling, assignment history, acknowledgement matching, and last-known-good recovery together.
  • When changing lease claims, update snapshot binding, sequence and digest continuity, outbox recovery, Cloud acknowledgement matching, and challenge handling as one contract.
  • Keep every remediation action's allowed parameter set aligned between Cloud job creation, device validation, execution, and evidence closure.
  • Preserve the distinction between machine health credentials and user Cloud credentials when changing transport setup.
  • Keep the lab report schema, restart phase, native certification boundary, and fault matrix aligned with the provider-neutral contracts.

Important failure modes

TriggerConsequenceGuard
Reused enrollment token or public keyCloud refuses the new enrollment.Consume each seed once and require a unique device key.
Request proof replay or workspace substitutionCloud rejects the request before it reaches control data.Bind proof to method, path, body, sequence, time, and enrolled identity.
Stale, corrupt, or unsigned configurationThe client keeps the last accepted policy and reports delivery failure.Verify signature, identity, revision chain, hash, ETag, and policy shape before activation.
Lost acknowledgement or health responseThe exact evidence stays queued and may be retried.Use durable outboxes and accept only exact duplicates as complete.
Lease sequence, digest, or installation mismatchCloud cannot use the report as current device evidence.Match the lease to the protected continuity record and snapshot.
Remediation result reports success without healthy follow-upThe job remains awaiting_evidence.Close successful jobs only after a fresh healthy report.
Cloud lab reports native certification as completeProvider or platform support is overstated.Keep native gates explicitly not-evaluated until real platform tests run.

Key files

FileWhy to read it
src/…/cloud_control.pyDefines the shared Cloud configuration, acknowledgement, health, remediation, and request-proof contracts.
src/…/health_reporter.pyShows the machine health cadence and its delivery and challenge sequence.
src/…/health_lease.pyShows durable lease issuance, acknowledgement, and crash recovery.
src/…/continuity.pyShows the protected installation identity and boot continuity model.
src/…/health_transport.pyShows the purpose-bound machine Cloud channel.
src/…/policy.pyShows how MDM policy authority is loaded and how unreadable authority fails closed.
scripts/…/lab_store_policy.pyShows Cloud publication, assignment history, acknowledgements, and health acceptance.
scripts/…/lab_store_remediation.pyShows idempotent remediation jobs and evidence-gated completion.
scripts/…/device_policy.pyShows device-side policy validation, recovery, health queueing, and sync.
scripts/…/device_outbox.pyShows FIFO evidence delivery and retry versus dead-letter behavior.
scripts/…/orchestrator.pyShows the initial and restart integration phases and bounded evidence report.
scripts/…/run-cloud-integration-lab.pyShows lab execution, report validation, checksums, diagnostics, and teardown.