5 Durable projection and issuance outbox🔗ℹ
Server processes explicitly require commerce/storage. It is
not re-exported from the default facade. Journal acknowledgement and
projection are separate durability phases. Projection runs outside the
provider request:
Recognizes one opened durable Commerce storage. All journal, projection,
outbox, lineage, and claim operations accept only this type.
Selects the lowest unprocessed journal sequence and atomically writes its
order projection, any newly emitted issuance-outbox row, and its processing
marker. It returns #f when no sequence is pending. A successful
result has disposition 'projected; an order identity conflict has
disposition 'blocked, failure code 'order-conflict, no new
outbox items, and leaves the previous order unchanged.
Exposes the projection disposition, journal sequence, resulting order, new
outbox items, and optional failure code.
One durable issuance work row. New rows are 'pending with zero
attempts and no lease.
Returns the durable order projection.
Returns one outbox row by its stable idempotency key.
Closes the storage during service shutdown.
5.1 SQLite backend🔗ℹ
Opens or creates a Commerce-owned SQLite database. Schema v9 uses WAL mode,
full commit synchronization, foreign keys, and database triggers that reject
updates or deletes of accepted event and entitlement-lineage evidence.
Earlier schema databases migrate in place without rewriting existing rows.
The lineage tables retain stable entitlement roots and contiguous revisions
with exact unsigned Permit payload bytes; no signer or signed-credential
storage is exposed.
The readiness snapshot behind commerce/health; also re-exported
there.
5.2 Issuance lease state machine🔗ℹ
The issuance worker protocol is owner-safe: a row is claimed, signed work
happens outside the claim transaction, and completion or release re-checks
the lease owner against the database.
Claims the lowest due outbox row in one immediate transaction: status
'processing, attempts incremented by one, and an opaque exclusive
lease bound to the owner. A row is due when it is
'pending and
available_at <= now, or when its lease has expired. Returns
#f when nothing is due.
Appends the lineage root together with revision zero, or exactly one
successor revision, and completes the outbox row inside the same short
transaction. The writer enforces the ADR-0008 identity rules as typed
failures before any insert: a second grant over an existing lineage, a
commercial identity bound to a different entitlement, a withdrawal without
a lineage, and a credential id already bound to another revision raise
exn:fail:commerce codes
'entitlement-lineage-conflict or
'entitlement-lineage-required and write nothing. The payload digest
is computed from the given bytes, never trusted from the caller. Completion
without the active lease raises
'lease-not-held. Repeating a
completion that already landed reconciles to the recorded revision; the same
outbox id with different payload bytes is a conflict. When the exact signed
envelope bytes and key id are supplied, the completion transaction also
records the issued credential; a claim token and expiry add its one-time
fulfillment claim. Omitting them records issuance evidence without
delivery.
Returns transient work to 'pending with the typed error code
recorded and a future retry time. Only the lease owner may release; attempts
stay exactly as the claim incremented them.
Returns the durable lineage for one entitlement id.
Resolves the lineage bound to one commercial identity.
Returns one recorded revision. Revision payload bytes are the exact
unsigned snapshot bytes, never signed credential bytes.
Returns the newest recorded revision of one lineage.
Returns the newest recorded revision and the unresolved-refund state as
two facts observed at one instant: one read transaction backs both
values. Hosted proof verification denies on freshness and refund state
together, so reading them separately could straddle the transaction that
records a withdrawal and serve a withdrawn grant.
The stable entitlement root bound to one commercial identity.
One recorded lineage revision. payload-bytes is the exact unsigned
snapshot bytes, never signed credential bytes.
The durable result of one completed issuance work item.
The durable signed-credential audit record. envelope-bytes is the
exact serialized Permit envelope (key id, payload, signature) as delivered.
The result of fulfilling one claim token.
5.3 One-time claim delivery🔗ℹ
The issued credential record retains the exact signed envelope bytes; the
claim stores only the token’s SHA-256 digest. No transport or HTTP listener
is included in this boundary.
Verifies the token, its state, and its fulfillment window, marks the claim
claimed, and returns the claim id, the fulfillment time, and the
issued-credential-record with the exact signed envelope bytes,
which verify as a Permit envelope for the recorded key id. Wrong, reused,
and expired tokens raise typed
exn:fail:commerce values
(
'claim-not-found,
'claim-already-claimed,
'claim-expired) and mutate nothing. Fulfillment never creates or
advances a lineage revision.
Records that a delivery transport handed the token out. The first
notification timestamp wins; later retries are idempotent no-ops.
Marks expired unfulfilled claims retired; returns the number retired.
Exposed to operators through commerce/retention.