StateMirror — Examples
DATA PLATE
PURPOSE
StateMirror stores immutable snapshots of computed evidence payloads at decision time. It does not decide outcomes, interpret payloads, or prove that the submitted state was correct.
EXAMPLE 1 — CAPTURE AT DECISION TIME
// Application-owned evidence example.
// StateMirror preserves the submitted snapshot.
// Your application computes facts and 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" });
const eligible =
deny.signal !== "denial_present" &&
exp.signal !== "expired" &&
plan.status === "active";
// Application-owned evidence payload.
const decisionState = {
subject,
evidence_type: "api_access_gate",
inputs: {
deny,
exp,
plan,
},
computed: {
eligible,
plan: plan.plan ?? null,
},
policy_version: "2025-12-REV-A",
correlation_id: req.headers["x-correlation-id"] ?? null,
};
// Snapshot the evidence around the decision moment.
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 (eligible) {
return grantApiAccess();
}
return rejectApiAccess("Not eligible");
// Store snapshot_id in an audit record, support ticket, or dispute record.
log.info({
snapshot_id: snapshot.snapshot_id,
evidence_ref: snapshot.evidence_ref,
});EXAMPLE 2 — DISPUTE LOOKUP
// Support or Tier-3 workflow.
// Retrieval is reference-driven. No dashboard required.
GET /v1/snapshots/{snapshot_id}
→ returns the exact payload stored at decision time.
GET /v1/snapshots?evidence_ref=access:user_123:1734460000000
→ returns snapshots for that evidence_ref.
// The question is:
// "What did the system believe was true when it decided?"
// The question is not:
// "Can StateMirror reconstruct the past?"
// "Can StateMirror prove the outcome was correct?"
// "Can StateMirror search every event?"EXAMPLE 3 — SAFE RETRIES
// Network failures happen.
// Retries should not create duplicate evidence snapshots.
POST /v1/snapshots
Idempotency-Key: 3b5c2b2a-3d31-4f2b-9f1b-8b1dd4b0f1ad
{
"evidence_ref": "access:user_123:1734460000000",
"evidence_type": "api_access_gate",
"captured_at": "2025-12-01T18:44:22.000Z",
"state_payload": {
"subject": "user_123",
"eligible": true
}
}
// Replay behavior:
//
// same idempotency key + same payload
// → returns original snapshot response
//
// same idempotency key + different payload
// → explicit conflict responseCONSTRAINTS
- StateMirror does not validate the business meaning of your payload.
- StateMirror does not decide whether your application outcome was correct.
- StateMirror does not provide analytics, dashboards, or payload-wide search.
- Retrieval is reference-driven, not exploratory event reconstruction.
- Snapshot volume should normally be decision-level, not event-level.
BOUNDARY
Facts are computed. Evidence is captured. Decisions are made. Actions are executed. StateMirror preserves submitted evidence. SimpleStates stops at state.