Signal Composition — Examples
DATA PLATE
Multiple primitives can be queried and evaluated together. SimpleStates emits facts only. Composition, decisions, and enforcement remain application-owned.
EXAMPLE
// Application-owned outcome example.
// SimpleStates does not decide or enforce.
// Read-time fact queries.
const plan = await planSignal.state({ subject });
const deny = await denySignal.state({ subject });
const exp = await expirySignal.state({ subject });
// Application-owned interpretation.
// Do not treat absence as permission without an explicit rule.
const eligible =
plan.plan === "gold" &&
plan.status === "active" &&
deny.signal === "denial_absent" &&
exp.signal === "not_expired";
// Optional evidence capture.
// StateMirror records what the system considered.
// It does not validate the decision.
await stateMirror.capture({
evidence_ref: `eligibility:${subject}:${Date.now()}`,
evidence_type: "eligibility_gate",
captured_at: new Date().toISOString(),
state_payload: {
inputs: { plan, deny, exp },
computed: { eligible },
decision: eligible ? "approved" : "rejected",
},
});
// Enforcement stays outside SimpleStates.
if (eligible) {
return grantFeatureAccess();
}
return rejectFeatureAccess("Not eligible");
// Boundary reminder:
// Facts are queried.
// Decisions are made.
// Actions are executed.
// SimpleStates stops at signal.