Signal Composition - Examples
DATA PLATE
Multiple primitives can be queried and evaluated together. SimpleStates emits facts only. Composition, decisions, and actions 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 preserves submitted evidence about the decision moment.
// It does not validate the decision or evaluate policy.
await stateMirror.capture({
evidence_ref: `eligibility:${subject}:${Date.now()}`,
evidence_type: "eligibility_gate",
captured_at: new Date().toISOString(),
state_payload: {
evidence_lanes: {
PlanEvidence: plan,
DenialEvidence: deny,
ExpiryEvidence: exp,
},
computed: {
eligible,
application_result: eligible ? "approved" : "rejected",
},
},
});
// Actions stay outside SimpleStates.
if (eligible) {
return grantFeatureAccess();
}
return rejectFeatureAccess("Not eligible");
// Boundary reminder:
// State is queried.
// Decisions are made.
// Actions remain application-owned.
// SimpleStates stops at signal.