Enterprise Mirror · docs

Architecture decisions

9 ADRs for the lab slice.

Draft for review · built from the evidence in mirror/examples · Lab evidence from a synthetic world with deterministic reference agents (no model inference). Not a production result, not a certification of any real system, not a statement about any model.

ADR-0001 Synthetic services in stdlib Python, not containers and Postgres

Status: accepted for v0.1 (lab). Date: 2026-11-30.

Context. The brief suggests a realistic stack (FastAPI, Postgres, Playwright, containers). The slice must run offline, deterministically, with no paid services and no installs beyond common Python packages, inside a cloud session without Docker.

Decision. Build the world and services as plain Python objects over one state document, with a hash-chained journal and a virtual clock. Expose them through REST, MCP and a DOM reader on one gateway, plus an optional loopback HTTP server so an agent can be driven over a real socket.

Consequences. Clean-checkout boot in seconds, exact determinism, easy reset and parallel runs. Lower fidelity: no database transaction semantics, no network latency, no real browser. Moving a service to a container later keeps the same action contract and journal events. Tracked as MG-01 and MG-12 limits.

ADR-0002 One enforcement path for every surface and every actor

Status: accepted. Date: 2026-11-30.

Context. The plan's principle is one path for effects (diagram 04). If REST, MCP and the browser each enforced policy, they would drift, and a test passing on one surface would say nothing about another.

Decision. All surfaces translate to Gateway.invoke. Scripted human workers use the same path with their own tokens. Policy errors and guard errors fail closed.

Consequences. One place to test and one journal. Human calls count toward the step counter, which is documented as a limit.

ADR-0003 Python policy decision point that mirrors the Cedar file

Status: accepted for v0.1, to be revisited. Date: 2026-11-30.

Context. Plan section 10B specifies Cedar grants. Running the Cedar engine needs the Cedar CLI or a binding, a new install that needs Felix's agreement.

Decision. Keep packs/kyc/policies/agent.cedar as the reviewed policy and implement a small Python decision point that mirrors its permits and forbids, returning the same policy ids.

Consequences. Works offline with no install. Parity with Cedar is asserted by review, not tested. Gap MG-17 proposes a parity test that runs the same request set through both.

ADR-0004 Deterministic reference agents, no model inference

Status: accepted. Date: 2026-11-30.

Context. The default must work without paid APIs, and AT12 must not claim model-based execution.

Decision. Ship three scripted agents: governed 1.0.0, governed 1.1.0 (adds a vendor contract check) and a naive baseline. All implement the same adapter contract a model-based agent would.

Consequences. Results are exact and reproducible, and they show the harness can tell safe from unsafe behaviour. They are not evidence about any model. Comparative model runs are Phase D (MG-11).

ADR-0005 Private oracles stored beside the pack, separated by convention

Status: accepted as a known limitation. Date: 2026-11-30.

Context. Oracles and holdout answers must never reach the agent. A separate store with access control is the right answer but needs infrastructure.

Decision. Keep oracles under packs/kyc/private/oracles/, never pass them to the agent, hash them into the fingerprint, and publish only holdout counts and digests on the site.

Consequences. Anyone with repository access can read them, so contamination of a model trained on the repo is possible. MG-06 tracks moving them to an assurance-only store.

ADR-0006 Browser surface as a DOM reader, not a real browser

Status: accepted for v0.1. Date: 2026-11-30.

Context. The brief asks for one browser surface. Playwright and a browser binary are not installed, and installing them is a project-level change.

Decision. Serve the case portal as a structured DOM (elements, roles, accessibility labels) that the agent reads and acts on through the gateway. Injection through hidden accessibility labels is tested (scenario 014).

Consequences. Tests the trust handling of page content, not rendering, scripts or click targeting. A real browser surface is Phase D.

ADR-0007 In-process transport by default, loopback HTTP as the isolation check

Status: accepted. Date: 2026-11-30.

Context. In-process calls are fast and deterministic but share memory with the harness. A real boundary needs a socket.

Decision. Default to in-process. Offer --transport http, where the agent's client holds only a 127.0.0.1 URL and a token, with proxies disabled. A test checks the HTTP client has no harness reference and both transports give the same state hash.

Consequences. The isolation claim is limited to "the agent object cannot reach harness objects"; it is not an OS sandbox.

ADR-0008 Outcome-guard hook for the ROE engine

Status: accepted. Date: 2026-11-30.

Context. A separate ROE workstream owns the Regulatory Outcome Envelope (plan section 12) and its rule engine. The Mirror must enforce ROE decisions without owning ROE logic, so the prototype is not built twice.

Decision. Gateway.outcome_guards is a list of callables run in enforced mode after the policy decision allows a side-effecting call and before any effect. Each returns nothing or a decision of allow, deny, hold or require approval with rule ids. Decisions are journalled; any non-allow denies the call; an exception fails closed. run_scenario(..., outcome_guards=[...]) installs them.

Consequences. The ROE engine can plug in without changing the gateway. A ROE change changes the fingerprint and triggers full recertification. Tested by test_outcome_guard_blocks_effect_and_is_journalled.

ADR 0009: Close the ROE assurance loop inside Enterprise Mirror (v0.2)

Status: accepted for the lab (1 December 2026); owner decisions listed at the end. Supersedes the "not wired yet" limits in ADR 0008 and docs/roe-integration.md. ROE-D16 (module home) and the Mirror decision log stay as settled.

Context

ADR 0008 put roekit's preventive checks in the gateway as an outcome guard. Duties, post-commit reconciliation and exact approval binding stayed in the standalone ROE lab, and unmapped side effects passed as "outside scope". Brief v0.2 asks for the full preventive, detective and temporal loop in the default enforced run, with evidence in the packet.

Decision

Ownership

ConcernOwnerNotes
Rule language, semantics, duty monitor, reconciler, report verdictsROE (roe/roekit)Mirror never re-implements them
World adapter, action-to-outcome mapping, fact derivation, coverage matrixMirror (enterprise_mirror/roe_guard.py)Adapter is read-only
Business commitsMirror gateway (control.Gateway.invoke)One path for effects. roekit's commit() is never called
Independent outcome gradingMirror oracleKept separate; disagreements are recorded, not merged

Event contract: mirror-roe-event-0.1.0

A canonical ROE event is written to the adapter ledger only after the gateway journals effect.committed. One Mirror action can yield several outcome events. Fields: event_id (MEV-<journal seq>-<n>), schema, event, target, tenant, run_id, call_id, causation (journal seq of the commit), actor, principal, delegation_chain, action, interface, params, effect_digest, decision_id (journal seq of the outcome_guard.decision, or null when no guard decision preceded the commit), bundle_digest, mapping_version, fact_version, facts (pre-commit projection), state_version (post-commit case version), at (virtual business clock). Events enter the ledger once per committed call; a replayed idempotent call commits nothing and adds nothing.

Approval binding contract: mirror-approval-binding-0.1.0

Disposition approvals carry a binding written by the case service when the recommendation is filed: rule_id, tenant, case_id, action, events, canonical params, effect_digest (roekit's digest of event, target and params), case_version (a real monotonic counter, see below), preparer, purpose, bundle_digest, nonce, expires_at, single_use: true, consumed_by. roekit gains two optional checks that leave standalone behaviour unchanged: an approval already consumed, or bound to another bundle digest, is invalid. The approval of the business disposition (senior approver) and the authorization of the recorder (a second permitted person, four-eyes) stay separate.

Case version

case.version is a monotonic counter in the case record, raised by every action that changes a decision-relevant fact (recommendation, disposition, closure, rating, confirmed discrepancy). Notes, drafts, holds, escalations and approval workflow steps do not raise it, so they do not invalidate an approval. It replaces len(history) + 1.

Commit-time revalidation

The gateway records the state hash when the guards decide. If anything changes the state before the effect runs (the competing_write fault simulates another actor), the gateway re-validates the token and re-runs every guard on fresh state, and refuses on anything but allow. This is a single-process, single-threaded boundary. Distributed atomicity is not claimed (IA-07).

Coverage contract: mirror-effect-coverage-0.1.0

Every action in apps.ACTIONS has one entry in roe_guard.COVERAGE: outcome (maps to typed ROE events), governed-technical (a reviewed exclusion with rationale, owner, compensating controls and test), or read-only (with whether disclosure matters). An action with no entry, or an outcome action whose mapping yields no event without a named exclusion, is denied in enforced mode. A test fails when a new action is unclassified. The matrix is generated to docs/effect-coverage.md and .json.

Duties

The adapter feeds every canonical event to roekit's DutyMonitor through Runtime.after_event. Duty IDs stay <rule>::<correlation> (roekit's existing scheme) and keep the bundle digest and trigger event. Duties persist to roe/duties.json in the run's working directory. After the agent stops, the runner opens an observation window: scripted people act, the business clock advances to the latest duty deadline plus one minute, and the monitor ticks, so a missed duty is found without the agent running. Clock convention: the lab business clock is the world's virtual UTC clock; no calendar, no time zones; a duty is overdue when now > due_at (roekit's boundary).

Reconciliation and evidence

At the end of the window the adapter runs roekit reconcile() over the ledger with claims derived from the agent's structured report, then a completeness check: every committed call of an outcome action must have ledger events, every ledger event must have a guard decision (otherwise it is labelled detective, not prevented), and any observer error makes the run indeterminate. The packet gains roe/evidence.jsonl (roekit hash chain), roe/duties.json, roe/ledger.json, roe/reconciliation.json and roe/report.json. The manifest becomes mirror-evidence-0.2.0; 0.1.0 packets still verify.

Gate namespaces

Mirror hard gates are emitted as MIRROR:G1 to MIRROR:G10; AI-SDLC gates are SDLC:G0 to SDLC:G6. Bare IDs in 0.1.0 packets resolve through gates.resolve(). Old evidence is never rewritten.

Failure modes

FailureBehaviour
Guard raisesDeny (unchanged)
Observer raises after commitJournal roe.observer_error; run ROE verdict indeterminate
Fact source missingroekit on_unknown (hold or deny)
Unclassified side effectDeny in enforced mode
Permissive modeNo guard decisions; ledger still built; packet marked not certifiable
Duty monitor state unknown for a blocking ruleroekit holds the dependent effect

Consequences

journal hashes differ from the 0.1.0 baseline. The comparison is regenerated and the change explained.

exist (owner decision 2 and 3).

Certification (added 1 December 2026)

Certificate schema mirror-certificate-0.2.0 requires the ROE bundle digest, roekit runtime version and every Mirror ROE contract version in the fingerprint. ROE semantics changes (bundle, runtime, mapping, event, facts, reconciler) are full recertifications; coverage is targeted at affected actions; binding and the certificate gate are targeted at authority; claims and the evidence contract are regrades. Critical findings (hard gate failure, no ROE or permissive, nonconformant, not certifiable, missing packet) block activation and cannot be waived. CertificateGate holds agent effects while the certificate is suspended or bound to another bundle, except a safe subset (review hand-offs, notes, governed-technical actions).

Status registry

status/capabilities.yaml is the single source for capability status. The ROE README table and the Mirror status page are generated from it, and implemented rows must name the tests that show them.

Owner decisions

All eight were answered "All as suggested" by Felix on 1 December 2026:

  1. Gate namespaces MIRROR: and SDLC: with legacy aliases.
  2. Discrepancy trigger: case.confirm_discrepancy, discharged only by a human review.acknowledge.
  3. Default governed agent 1.2.0; 1.0.0 and 1.1.0 kept for comparison.
  4. Unclassified side effects are denied by default.
  5. Per-run ROE verdict scoped to the rules the run exercised.
  6. Baseline the conceptual ROE as v1.0 (the definition, not the synthetic bundles).
  7. Install markdown on the workstream's cloud machine.
  8. A sanctions match is resolved only by a recorded resolution.