s-m-r-t
Open the s-m-r-t source on GitHub Switch to dark color scheme
← All packages
Foundation v0.57.40 New

@happyvertical/smrt-approvals

A decision gate: revision-bound, single-use approvals with quorum, expiry, tenant policy, and an append-only event ledger.

Source ↗

What it gives you

A decision gate: revision-bound, single-use approvals with quorum, expiry, tenant policy, and an append-only event ledger.

  1. 01A package defines an approval kind; a requester opens a request bound to one revision of one subject
  2. 02Only human principals of the same tenant holding the kind’s permission decide, once each; agents and services may request and consume
  3. 03Not a workflow engine: no stages, no executor, no compensation

Request, decide, consume

ApprovalRequest is one gate on one subject revision. ApprovalEvent is the append-only ledger and the source of truth. ApprovalPolicy lets a tenant tighten a kind with a higher quorum, a shorter expiry, or one more permission; it can never loosen the defaults. An approved request is consumed exactly once against the revision the consumer is about to act on.

Concurrency has one winner

Every transition is one guarded conditional UPDATE plus one event insert in the same transaction. Concurrent double approval or double consumption has exactly one winner; the loser is refused and writes nothing. Each transition returns transitioned, already_applied for an idempotent requestKey replay, or refused with a typed reason.

Only the service writes

A request or event built directly is refused at the model layer. Events cannot be updated or deleted. Optional self-approval needs an explicit selfApprovalPermission on the kind and is recorded on the event.