SYSNOMINAL|BUILDv2026.01.01|REGIONSELF_HOST

StateMirror — Examples

DATA PLATE
DOC
StateMirror — Examples
ID
SS-EX-SM-2025.12
REV
A
SURFACE
PUBLIC
MODEL
Application computes. StateMirror preserves.
PURPOSE
Illustrative reference patterns only. No enforcement.
REF
Examples
PURPOSE

StateMirror stores immutable snapshots of computed evidence payload at the moment a decision is made. It does not decide outcomes. It does not interpret payloads.

EXAMPLE 1 — CAPTURE AT DECISION TIME
// Pseudocode. Your application computes evidence payload.
// StateMirror preserves the snapshot. Your application enforces outcomes.

const deny = await denySignal.state({ subject, scope: "global" });
const exp  = await expirySignal.state({ subject, scope: "plan" });
const plan = await planSignal.state({ subject, scope: "account" });

// Application-owned evidence payload (facts you chose to capture):
const decisionState = {
  subject,
  evidence_type: "api_access_gate",
  inputs: {
    deny,
    exp,
    plan,
  },
  computed: {
    eligible: deny.signal !== "denial_present" && exp.signal !== "expired",
    plan: plan.plan ?? null,
  },
  policy_version: "2025-12-REV-A",
  correlation_id: req.headers["x-correlation-id"] ?? null,
};

// Snapshot BEFORE you execute the outcome.
const snapshot = await stateMirror.capture({
  evidence_ref: `access:${subject}:${Date.now()}`,
  evidence_type: "api_access_gate",
  captured_at: new Date().toISOString(),
  state_payload: decisionState,
});

// Application-owned outcome:
if (decisionState.computed.eligible) {
  permit(); // your system chooses this outcome
} else {
  denyRequest("Not eligible"); // your system chooses this outcome
}

// Store snapshot_id in your audit record / support ticket / dispute record:
log.info({ snapshot_id: snapshot.snapshot_id, evidence_ref: snapshot.evidence_ref });
EXAMPLE 2 — DISPUTE LOOKUP
// Support / Tier-3 workflow: point lookup.
// No dashboards required. Reference-driven retrieval.

GET /v1/snapshots/{snapshot_id}
→ returns the exact payload stored at decision time.

GET /v1/snapshots?evidence_ref=access:user_123:1734460000000
→ returns all snapshots for that evidence_ref (usually 1).

// The goal is "what did the system believe was true?"
// Not "reconstruct the past" and not "search logs".
EXAMPLE 3 — SAFE RETRIES (IDEMPOTENCY)
// Network failures happen. Retries must not create duplicates.
// Use an Idempotency-Key per capture attempt.

POST /v1/snapshots
Idempotency-Key: 3b5c2b2a-3d31-4f2b-9f1b-8b1dd4b0f1ad
{ ...same envelope... }

If the same key is replayed:
- same payload → returns the original snapshot response
- different payload → 409 conflict (explicit)
CONSTRAINTS
  • StateMirror does not enforce ordering semantics in your application.
  • StateMirror does not validate business meaning of your payload.
  • StateMirror does not provide search/analytics over payload contents.
  • Snapshot volume should be decision-level, not event-level.

← Examples·Products