1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
use PgPool;
/// Whether the row whose `message_id` is `id` is currently held by a claim (`locked_by IS NOT
/// NULL`) — the "has it been claimed" half of what a single `locked_until` read used to answer
/// before ADR 0050 dropped that column; `available_at` is `NOT NULL`, so there is no longer an
/// `Option` to test for that question.
///
/// Filters on `message_id`, not `id` (ADR 0044 §1): every call site holds the envelope's
/// `MessageId` (from `common::seed`'s returned envelopes or a captured publish), never the row's
/// own database-assigned surrogate id.
pub async
/// Reads the current `available_at` of the row whose `message_id` is `id` — since ADR 0050 this
/// **is** the lease end for a leased row, the lease clock and the only one. The read half of the
/// lease-renewal probes (ADR 0043 §5): a real-time *eventually*/*never* assertion reads this twice
/// around a renewal tick rather than inferring renewal from whether the row is claimable, since
/// claimability also changes the instant a row completes (§43 review round 1, B2/B3).
///
/// Filters on `message_id`, see [`claimed`].
pub async
/// Moves the row whose `message_id` is `id`'s lease into the past — SQL time-travel for
/// lease-expiry tests, never a wall-clock sleep (§8.2). Since ADR 0050 there is no second lease
/// column: `available_at` **is** the lease clock, so this is now the identical statement as
/// [`make_available_now`] — kept as its own name because the two describe different intents at
/// the call site ("this lease has lapsed" vs. "this backoff is due"), even though both now move
/// the one clock they share.
pub async
/// Moves the `available_at` of the row whose `message_id` is `id` into the past — makes a
/// retry-delayed row due without waiting. Filters on `message_id`, see [`claimed`].
pub async
/// Ages an already-committed inbox row's `updated_at` by `age` (a Postgres interval literal, e.g.
/// `"30 days"`) — SQL time-travel for retention-ageing and in-flight-row scenarios (ADR 0043 §5),
/// promoted from the identical inline `UPDATE` three inbox scenario files each wrote by hand.
/// Never used to move `completed_at`/`dead_at` themselves — those are set at seed time by the
/// caller's own `INSERT` when the seeded state (not the ageing) is what a test is proving.
pub async
/// ADR 0046 Correction B.3's shared post-condition: no row may carry a `claim_token` once its
/// `locked_by` has been cleared. Every statement that ends a claim (B.1's closed list — the four
/// outcome writes, the poison sweep, the expiry sweep, `retry_dead`) clears both columns in the
/// same statement, so a row failing this check means one of those writers forgot to clear the
/// token, not that the token is merely stale (a stale-but-still-owned token is exactly what the
/// fence is for and is not what this asserts). Call at the end of any trial that exercises
/// `purge`, `retry_dead` or an outcome write.
pub async