Diagram explorer

Ten tests of the export admission contract

The supplied SQLite teaching lab records requests, jobs, outbox rows and remaining credits after each failure. Explore the four pre-commit cuts, post-commit recovery and identity cases.

Relationship map
01 Ten-credit fixture02 After request insert03 After quota debit04 After job insert05 Immediately before commit06 After commit, before reply07 Eight equal callers08 Same key, new snapshot09 Same key, different tenant10 Same input, new key11 Exhausted balance12 Perform one admission13 Compare durable state14 Move the test to the real adapter
01 / 14Process termination

Ten-credit fixture

Each crash case starts in a temporary database with ten credits. Reconnect after the child process terminates and count committed rows before retrying.

02 / 14Process termination

After request insert

The request identity was tentatively inserted. On reconnect no claimed request, job or outbox survives and the balance remains ten.

03 / 14Process termination

After quota debit

The transaction had reduced the balance. The uncommitted debit rolls back with the identity, restoring all ten credits.

04 / 14Process termination

After job insert

The job row may have existed within the transaction. Reopening the database must reveal no durable job awaiting a missing dispatch.

05 / 14Process termination

Immediately before commit

All four writes were staged, including outbox intent. The four observed values after restart are zero requests, zero jobs, zero outbox rows and ten credits.

06 / 14Process termination

After commit, before reply

Restart now finds one request, one job, one outbox row and nine credits. Replaying the same key must yield the saved receipt without changing any count.

07 / 14Identity and quota

Eight equal callers

Eight callers submit one key and payload. SQLite serializes writers in this fixture. All eight must converge on one receipt, one job and one debit.

08 / 14Identity and quota

Same key, new snapshot

After a prior acceptance, changing the normalized input with the original key must produce a mismatch and leave that acceptance untouched.

09 / 14Identity and quota

Same key, different tenant

Each namespace gets an independent job and balance. This teaching case exercises key scoping. Production authorization requires its own checks.

10 / 14Identity and quota

Same input, new key

A fresh key represents deliberate new work. An identical payload can produce another accepted job and another debit when there is credit.

11 / 14Identity and quota

Exhausted balance

The zero-credit fixture rejects admission. No partial request, job or outbox may survive. Retrying alone cannot fund an export.

12 / 14Evaluate the guarantee

Perform one admission

Retry after a pre-commit crash. The expected durable tuple is now one request, one job, one outbox and nine credits, all representing the same intent.

13 / 14Evaluate the guarantee

Compare durable state

Compare the receipt and the four state values with the prediction for this case. A successful HTTP status alone cannot establish the debit and dispatch invariant.

14 / 14Evaluate the guarantee

Move the test to the real adapter

Single-writer SQLite results apply to this fixture. Lock timeouts, lost commit acknowledgements and failover must be examined against the production engine and its isolation rules.