Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions docs/PROJECT_PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,19 @@ cross-request CAS token — a DOMAIN token carried in fields, deliberately
not a storage version, because it must survive across requests and
processes.

**Effective watermark and lifecycle rank** — an event applies only if
strictly newer than `max(eventAt, snapshotAt)`. A distinct event sharing
that exact second is resolved by lifecycle RANK, never delivery order:
terminal non-granting states outrank granting ones, so a stale `active`
cannot restore a same-second `canceled`, while a transient `incomplete`
still loses to a same-second `active`. Equal rank at the equal second
drops the later arrival — conservative staleness until a strictly newer
event arrives.
**Effective watermark and lifecycle rank** — an event replaces lifecycle
fields when strictly newer than `max(eventAt, snapshotAt)`. A distinct event
sharing that exact second replaces them only when its lifecycle RANK outranks
the stored status, never because it arrived later: terminal non-granting
states outrank granting ones, so a stale `active` cannot restore a same-second
`canceled`, while a transient `incomplete` still loses to a same-second
`active`. Equal rank at the equal second keeps the stored lifecycle fields —
conservative staleness until a strictly newer event arrives. A distinct event
rejected by these ordering rules can still record monotonic
`offerRedeemed: true` evidence from a granting status or an explicit flag.
That evidence-only write preserves the lifecycle watermark and all other
fields while advancing `snapshotGeneration`; exact redelivery remains an
idempotent no-op.

**Snapshot reconciliation** — a periodic sweep fetches provider truth
AFTER observing the watermark, then applies it through a decider that
Expand Down
10 changes: 10 additions & 0 deletions packages/billing-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ line items, or amounts.
Arrival order proves nothing. Every apply goes through the effective-watermark
guard and lifecycle rank. Exact redelivery is an idempotent no-op.

Offer redemption is monotonic across delivery order. When lifecycle ordering
rejects a distinct event, a granting status or explicit redemption evidence
still records `offerRedeemed: true` on any row where it is false. The
evidence-only write changes only `offerRedeemed` and `snapshotGeneration`,
preserving the lifecycle watermark, `snapshotAt`, and every lifecycle,
provider, reservation, and host field. The generation change makes an
overlapping reconciliation observe the write. In that case `applied` is
`true` because the event caused a durable ledger write, even though its
`eventAt` and `eventId` did not become the lifecycle watermark.

`sticky` and `firstWins` are declared on the host's ledger definition and
enforced inside the update decider, so they re-evaluate against fresh state
on every conflict. A reservation id is minted inside the decider and read
Expand Down
Loading
Loading