Business policy documents and recovery
Business policy documents define rules for managed business actions such as mail, drive, and calendar operations. Guard keeps the complete document as the authority source, binds every installation and approval step to its exact digest, and uses native identity and transport evidence before those rules can affect a managed application.
Business policy document authority
The business policy document is the full source of business protection. It carries the policy identity and revision, defaults, rules, lifetimes, and provenance. A rule can describe a business service and operation together with account, audience, recipient, sensitivity, or volume limits. The document is not active merely because it parses or compiles.
Business policy authority has three separate parts:
- Source authority identifies the exact document that an operator approved.
- Native policy authority validates and installs the business binding used by enforcement.
- Action authority proves the identity, content, target, and transport facts for one managed operation.
This separation prevents a document compiler, a browser payload, or an app command from granting permission by itself. The parent page, Policy authority and cloud exceptions, describes how this local authority relates to signed Cloud policy.
Source identity
Guard represents the full policy as a typed document and derives its source identity from canonical document bytes. The approval binding includes the import purpose, replacement mode, and that digest. Therefore, approval for one document cannot authorize a changed document or a different import mode.
The source digest also travels through native compilation, authenticated source records, retained anchors, database witnesses, and recovery responses. A source revision gives operators an ordering label, but the digest remains the identity of the content. A policy removal or replacement must use the same business-source authority rather than falling back to legacy local rows.
References: src/…/policy_document.py• L152-182 src/…/policy_document_authority.py• L10-26 src/…/business_policy_document_import.py• L33-63
Source compilation
Compilation is an offline validation step for the complete document. Guard first requires a trusted, bounded, single YAML document. It then checks the document shape, bounds, rule IDs, defaults, business selectors, lifetimes, and supported scope before native compilation creates a business-policy binding.
Validation reports problems as safe, location-based diagnostics without exposing policy values. It separates three outcomes: a schema-invalid document, a schema-valid document that this Guard runtime cannot enforce, and a file that Guard cannot trust or read. A command expression can be valid with a warning when an older runtime cannot enforce it. The result still states that it is unverified source and is not installed policy.
This whole-document rule matters because a partial projection could drop a selector or lifetime and silently widen protection. Legacy local rules can compile only when they fit the older local policy model. A document with business rules goes through the native business compiler instead.
References: src/…/policy_document_yaml.py• L67-79 src/…/policy_document_yaml.py• L466-498 src/…/policy_document_diagnostics.py• L33-38 src/…/policy_document_diagnostics.py• L294-327 src/…/native_business_document_compile.py• L19-103 rust/…/business_policy_document.rs• L133-248 rust/…/business_document_compile.rs• L9-40 src/…/business_policy_document_import.py• L37-43
Business policy installation
Installation turns an approved complete document into the current business source and the local policy state that refers to it. The owner prepares a signed source record, writes a closed installation marker, updates the local policy transaction, and writes a committed marker only after the database witness and retained source agree.
The installation path accepts replacement mode for business documents. It does not merge business rules into legacy rows. A failed or interrupted installation remains closed and requires an explicit recovery action; ordinary import does not guess which older state is safe to restore.
This diagram shows the relationship between the source document, native validation, durable source identity, and active enforcement.
flowchart LR
A[Complete business policy document] --> B[Canonical source digest]
B --> C[Native whole-document compilation]
C --> D{Supported and bounded?}
D -- no --> E[Reject without installation]
D -- yes --> F[Fresh exact approval]
F --> G[Authenticated prepared source]
G --> H[Closed source marker and retained anchor]
H --> I[Policy database transaction]
I --> J{Source, anchor, and witness agree?}
J -- no --> K[Keep closed; require recovery]
J -- yes --> L[Committed source authority]
L --> M[Native policy enforcement]
Installation authority
The import owner checks approval before and during the mutation. It binds approval to the exact source digest and verifies the native consumer capability before it prepares or installs the source. The native codec authenticates source records and anchors, but it does not check approval or currentness; the installation owner supplies those decisions.
The committed state is valid only when the source record, anchor, independently retained anchor, and database witness describe the same source identity. This gives runtime consumers one current source floor and prevents an old database row or marker from becoming a newer policy by itself.
References: src/…/native_business_source_store.py• L1-6 src/…/native_business_source_store.py• L199-310 src/…/native_business_source_bridge.py• L54-63 rust/…/business_source_codec.rs• L88-169
Enforcement boundary
Native enforcement applies the installed business policy as a floor over the action result. It requires complete authenticated business facts before a selector can match. If a business-looking action has no trusted facts, Guard blocks it instead of treating unknown identity, audience, content, or target data as a non-match.
Budgets remain a protected boundary. A policy that declares budgets is not treated as executable until a budget owner can reserve and enforce them. This keeps a reviewed budget declaration from being mistaken for a durable reservation.
References: rust/…/policy_enforcement_business.rs• L27-132 rust/…/policy_enforcement_business.rs• L199-221 rust/…/policy_enforcement.rs• L35-56 rust/…/business_match.rs• L156-205
Bounded business policy recovery
Recovery completes one exact interrupted installation. It does not reconstruct lost policy, restore an older document, replay an app task, or resolve the original review request. The candidate must be the authenticated prepared source for the request and must match its digest.
When recovery runs, Guard follows a bounded sequence:
- Confirm that the request is a business-policy replacement with the expected candidate digest.
- Re-read the exact saved document and recompute its digest.
- Require fresh high-risk approval for that document.
- Verify the prepared source, every readable retained anchor, and the database witness.
- Reject missing, conflicting, or newer identity evidence rather than selecting a majority or repairing silently.
- Complete the source and database transaction when the identities agree.
- Confirm the committed witness and markers before returning success.
The recovery result records that policy installation was recovered. The original app action remains untouched, so the application must make a new action request if it still needs to act.
References: src/…/native_business_source_recovery.py• L22-129 src/…/business_policy_recovery.py• L18-85 src/…/business_policy_document_import.py• L101-164
Recovery evidence
Recovery uses only native-authenticated saved state for its policy preview. The dashboard does not trust the request text or browser copy as the recovery candidate. It receives a redacted policy view and a digest, so author metadata and private source details do not become part of the operator preview.
The inspection state distinguishes three outcomes:
- Unavailable: no exact authenticated candidate is available.
- Interrupted: the candidate exists but the installed source state is not coherent.
- Installed: the exact candidate is already current.
References: src/…/business_policy_recovery_inspection.py• L17-60 src/…/business_policy_document_view.py• L1-120 dashboard/…/business-policy-recovery-api.ts• L10-65
Dashboard recovery controls
The dashboard presents recovery as a policy installation action, not as approval of the original application request. It shows the saved policy rules without author metadata, the candidate digest, and the current installation state. The recovery button is available only when the exact candidate is present and is not already installed.
Recovery requires fresh local approval proof. The dashboard clears proof fields after submission, disables duplicate submissions while the request is busy, and accepts success only when the returned source digest equals the displayed candidate digest. A recovered request cannot be approved again as if it were a new app action.
The dashboard's recovery panel therefore gives the operator a narrow choice:
- Review the saved policy and recover its interrupted installation with fresh proof.
- Refresh or restore state when the candidate is unavailable, changed, or inconsistent.
- Decline the unchanged original request when the policy is already installed.
References: dashboard/…/business-policy-recovery-panel.tsx• L6-73 dashboard/…/business-policy-recovery-api.ts• L3-87 dashboard/…/business-policy-recovery.test.tsx• L11-67
Managed application integrations
Managed business applications use the policy document through a separate action-facts and transport path. The integration must prove the provider account and tenant, resolve the audience, inspect the complete content, bind the target revision, and use the approved native transport. Syntax parsing or an identity hint is not enough.
The business action contract carries bounded facts for the provider, operation, audience, content, target, and volume. Its fields are integrity commitments that a trusted producer must create and bind to the native review origin. An incomplete or caller-supplied fact set cannot authorize an action.
Identity evidence
The Google identity integration turns a worker-owned server-flow login into short-lived account and tenant bindings. It checks the configured client, hosted domain, nonce, token audience, issuer, signature, access-token hash, and time window. The result proves identity evidence for the worker; it does not enroll an account, grant a send operation, or prove that a browser or model owns the credential.
Directory resolution then binds literal recipients to customer-directory principals. It checks the same tenant, rejects suspended or ambiguous users, and records a resolution binding that changes when provider data changes. The prepared business facts use these bindings rather than raw caller identity claims.
References: rust/…/lib.rs• L36-63 rust/…/lib.rs• L65-205 rust/…/directory.rs• L128-232 rust/…/directory_prepared.rs• L43-145
Outbound transport
The outbound transport is a fixed operation for a registered native worker. Before it sends, the worker must consume the single-use decision, enforce the current policy and any budgets, and journal the attempt. The transport receives frozen input whose binding must match the prepared request, so it cannot reread changed command or message data.
For the Gmail send path, an API acceptance returns a namespace- and account-bound message fingerprint. A connection error, unexpected response, or malformed acknowledgement produces an unconfirmed attempt. The transport does not retry because the provider may already have accepted the request. An API acknowledgement means acceptance by the endpoint, not proof of final delivery.
References: rust/…/directory_dispatch.rs• L5-51 rust/…/dispatch.rs• L1-28 docs/…/owned-send-transport.md• L3-29 rust/…/business_input.rs• L63-129
Application action flow
The identity and transport integrations meet at a prepared business request. This sequence keeps document authority, action evidence, review origin, and provider effects separate.
sequenceDiagram
participant App as Managed application
participant Worker as Credential-owning worker
participant Guard as Native Guard
participant Provider as Business provider
App->>Worker: Request a managed business action
Worker->>Worker: Resolve identity, audience, content, and target
Worker->>Guard: Bind complete action facts to the reviewed request
Guard->>Guard: Apply installed business policy floor
Guard-->>Worker: Allow a matching prepared action or require review
Worker->>Guard: Consume the exact single-use decision
Worker->>Provider: Send frozen input through the fixed route
Provider-->>Worker: Accepted or unconfirmed result
Worker-->>App: Report the bounded outcome without automatic retry
References: rust/…/directory_prepared.rs• L43-145 rust/…/workspace_review_business_producer.rs• L11-67 rust/…/policy_enforcement.rs• L35-56 rust/…/directory_dispatch.rs• L10-51
Related pages
- Policy authority and cloud exceptions — parent page for local and Cloud policy authority.
- Policy bundles, integrity, and sync — signed Cloud policy validation and local activation.
- Cloud exception request workflow — Cloud-owned exception requests and later policy delivery.
- Cloud review delivery and recovery — review event delivery and exact remote decisions.
- Dashboard review and approval workflow — the wider dashboard review and proof model.
- Daemon and local service lifecycle — local authority service access and recovery.
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to the policy document schema must update strict YAML validation, canonical hashing, exact approval binding, native whole-document compilation, and source recovery identity together.
- Changes to validation diagnostics must preserve the distinction between schema-invalid, not-enforceable, and untrusted-file results. Diagnostics must remain bounded and must not expose policy values.
- Changes to business selector fields must preserve the whole-document rule and must not allow unsupported co-selectors or lifetimes to become a narrower-looking active rule.
- Changes to source markers, retained anchors, or database witnesses must keep the same source digest, mutation revision, and business-policy binding across every copy.
- Changes to recovery responses must keep the candidate digest, redacted preview, installation state, and request-recovery state mutually consistent.
- Changes to dashboard proof must preserve fresh approval, duplicate-submit prevention, and success confirmation against the displayed digest.
- Changes to business action facts must keep provider identity, audience expansion, content inspection, target revision, and volume tied to the frozen input.
- Changes to provider identity must keep account and tenant bindings aligned with directory resolution, policy selectors, review origin, and transport results.
- Changes to outbound transport must preserve the fixed route, frozen input binding, single-use decision consumption, and no-retry rule for unconfirmed effects.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A policy file is untrusted or exceeds the document bounds | Guard cannot treat its contents as a policy candidate | Return a file-trust diagnostic and refuse validation or import |
| A business document is compiled without whole-document validation | A dropped selector or lifetime could widen active protection | Compile the complete document and reject unsupported projections |
| Approval digest differs from the prepared source digest | A changed document could use approval for another document | Bind approval to the exact canonical document digest |
| A schema-valid rule is not enforceable on the current runtime | The rule could appear valid while having no active effect | Report not-enforceable status and block installation of that rule |
| Source marker, retained anchor, or database witness is missing or conflicts | Installation is not trusted as current | Require every readable identity floor to agree; recover explicitly |
| Recovery has no exact prepared candidate | Guard cannot know which source is safe to install | Return unavailable and require review of the current policy |
| Recovery candidate differs from the request digest | The dashboard could recover a different policy | Compare candidate and request digests before approval and installation |
| Business action facts are incomplete or unauthenticated | A business operation could fall through to a normal non-match | Block business-looking actions until native facts are complete and trusted |
| Provider identity or directory revision changes after review | The approved action may target another account or audience | Refresh identity and resolution; reject a changed preparation binding |
| Outbound response is missing or ambiguous | The provider effect may have occurred without confirmation | Return an unconfirmed attempt and never retry automatically |
| A policy declares budgets without an enforcing budget owner | A reviewed budget could be treated as a reservation | Block the business action until budget execution is integrated |
Key files
| File | Why to read it |
|---|---|
| src/…/policy_document.py | Defines the typed business policy document and its canonical source digest. |
| src/…/policy_document_authority.py | Shows how import approval binds to the exact document. |
| src/…/policy_document_yaml.py | Defines strict, bounded document parsing before policy validation. |
| src/…/policy_document_diagnostics.py | Defines the safe validation results for schema, enforcement, and file trust. |
| src/…/business_policy_document_import.py | Connects business documents to native compilation, planning, and installation. |
| rust/…/business_policy_document.rs | Defines whole-document business compilation and supported policy meaning. |
| src/…/native_business_source_store.py | Shows source installation, durable identity, and commit boundaries. |
| src/…/native_business_source_recovery.py | Defines exact-source recovery and conflict refusal. |
| src/…/business_policy_recovery.py | Connects the protected recovery request to the source owner. |
| src/…/business_policy_recovery_inspection.py | Provides authenticated recovery inspection and redacted preview. |
| dashboard/…/business-policy-recovery-panel.tsx | Shows the operator recovery control and fresh-proof boundary. |
| dashboard/…/business-policy-recovery-api.ts | Defines inspection, recovery, digest checks, and user-facing failure states. |
| rust/…/policy_enforcement_business.rs | Shows how complete business facts meet the installed policy floor. |
| rust/…/business_action.rs | Defines the bounded action facts needed for managed business operations. |
| rust/…/lib.rs | Defines worker-owned Google identity and tenant evidence. |
| rust/…/directory.rs | Shows tenant-bound directory resolution for recipients. |
| rust/…/directory_prepared.rs | Builds complete prepared business facts from verified input. |
| rust/…/directory_dispatch.rs | Defines frozen-input dispatch and bounded transport outcomes. |
| docs/…/owned-send-transport.md | States the managed outbound transport boundary and no-retry behavior. |