Class: FencedOutbox
Defined in: packages/agentos/src/io/channels/meetings/stores/fenced-outbox.ts:80
Wraps an IOutbox so that a purge of a run reaches its deliveries in flight, not only its stored rows.
purgeContentaborts the run's sends under way before it writes the fence, waits for them to end, then empties the run's content deliveries in the wrapped outbox, delivered ones included.sendClaimedclaims one delivery under the run's guard: behind the fence it scrubs the run's content first, then reads the delivery again, so a purge that landed while the dispatcher resolved its destination sends the content-freebot:purgedbody in its place. The send itself goes out once the guard is released.- Once the run is fenced, every delivery enqueued for it is stored as
bot:purgedwith an empty payload, whatever its type (bot:doneincluded): its destination learns only the delivery's ids and the run's.
Wrap each outbox once per process and give that one wrapper to the manager and to the OutboxDispatcher: a second
wrapper of the same outbox does not see the first one's sends, so a purge through one cannot cancel a send through the
other. A run's enqueues, claims, scrubs and forget run one at a time, and a send runs outside that guard: an enqueue
for a run, and with it the manager's handling of the run's events (a participant's stop among them), never waits for a
destination; only a purge waits for the run's sends, once it has cancelled them. A delivery is sent once at a time
here: a pass that takes a delivery another pass is still sending skips it. Over an outbox that evicts whole runs (an
in-memory one) the wrapper has forget too, which forgets the run's fence with its deliveries, so the manager's
eviction after the retention grace goes on as it does without the wrapper.
Implements
Constructors
Constructor
new FencedOutbox(
inner,fences):FencedOutbox
Defined in: packages/agentos/src/io/channels/meetings/stores/fenced-outbox.ts:98
Parameters
inner
The outbox the deliveries are kept in; wrap it once (see the class).
fences
Where the fence is kept; a durable one carries it across a restart.
Returns
FencedOutbox
Properties
forget()?
readonlyoptionalforget: (runId) =>Promise<void>
Defined in: packages/agentos/src/io/channels/meetings/stores/fenced-outbox.ts:92
Present when the wrapped outbox has forget: forgets the run's deliveries there, and its fence here and in the
DeliveryFence when that forgets too. Call it only after the run's producers have stopped.
Parameters
runId
string
Returns
Promise<void>
Implementation of
Methods
cancel()
cancel(
runId,destinationRef):Promise<boolean>
Defined in: packages/agentos/src/io/channels/meetings/stores/fenced-outbox.ts:257
Ends the run's pending deliveries to a destination in the wrapped outbox, under the run's guard; false when the wrapped outbox has no such method.
Parameters
runId
string
destinationRef
string
Returns
Promise<boolean>
Implementation of
due()
due(
now,limit?):Promise<OutboxDelivery[]>
Defined in: packages/agentos/src/io/channels/meetings/stores/fenced-outbox.ts:227
The wrapped outbox's pending deliveries due at now.
Parameters
now
number
limit?
number
Returns
Promise<OutboxDelivery[]>
Implementation of
endExpired()
endExpired(
now):Promise<number>
Defined in: packages/agentos/src/io/channels/meetings/stores/fenced-outbox.ts:262
Ends the expired mail deliveries in the wrapped outbox; none when the wrapped outbox has no such method.
Parameters
now
number
Returns
Promise<number>
Implementation of
enqueue()
enqueue(
delivery,now):Promise<void>
Defined in: packages/agentos/src/io/channels/meetings/stores/fenced-outbox.ts:138
Adds a pending delivery as the wrapped outbox does. Behind the fence it is stored content-free instead, as
bot:purged with an empty payload, and the run's content is scrubbed again, so a fence another process wrote reaches
this outbox's rows too.
Parameters
delivery
now
number
Returns
Promise<void>
Implementation of
holdUntil()
holdUntil(
id,notBefore):Promise<boolean>
Defined in: packages/agentos/src/io/channels/meetings/stores/fenced-outbox.ts:252
Holds a pending delivery in the wrapped outbox until notBefore; false when the wrapped outbox has no such method.
Parameters
id
string
notBefore
number
Returns
Promise<boolean>
Implementation of
listByRun()
listByRun(
runId):Promise<OutboxDelivery[]>
Defined in: packages/agentos/src/io/channels/meetings/stores/fenced-outbox.ts:267
Every delivery of the run in the wrapped outbox.
Parameters
runId
string
Returns
Promise<OutboxDelivery[]>
Implementation of
markDead()
markDead(
id):Promise<boolean>
Defined in: packages/agentos/src/io/channels/meetings/stores/fenced-outbox.ts:247
Ends a pending delivery at once in the wrapped outbox; false when the wrapped outbox has no such method.
Parameters
id
string
Returns
Promise<boolean>
Implementation of
markDelivered()
markDelivered(
id):Promise<void>
Defined in: packages/agentos/src/io/channels/meetings/stores/fenced-outbox.ts:232
Records in the wrapped outbox that the destination took the delivery.
Parameters
id
string
Returns
Promise<void>
Implementation of
markFailed()
markFailed(
id,now):Promise<void>
Defined in: packages/agentos/src/io/channels/meetings/stores/fenced-outbox.ts:237
Records a failed attempt in the wrapped outbox.
Parameters
id
string
now
number
Returns
Promise<void>
Implementation of
purgeContent()
purgeContent(
runId):Promise<void>
Defined in: packages/agentos/src/io/channels/meetings/stores/fenced-outbox.ts:200
Fences the run's deliveries and empties its content deliveries in the wrapped outbox, delivered ones included. The run's sends under way here are aborted at once, before the fence's write, and again once the fence is written; the purge then waits for them to end before it scrubs, so when it resolves no send of the run's content is still in progress in this process. A send must therefore never wait for a purge of its own run.
Parameters
runId
string
Returns
Promise<void>
Implementation of
replay()
replay(
id,now):Promise<void>
Defined in: packages/agentos/src/io/channels/meetings/stores/fenced-outbox.ts:242
Makes the delivery pending again in the wrapped outbox; one a purge emptied goes out content-free.
Parameters
id
string
now
number
Returns
Promise<void>
Implementation of
sendClaimed()
sendClaimed(
candidate,send):Promise<boolean>
Defined in: packages/agentos/src/io/channels/meetings/stores/fenced-outbox.ts:159
Claims one delivery under the run's guard and sends it once the guard is released, so no enqueue or claim for the
run waits for its destination. Under the guard, behind the fence, the run's content is scrubbed first; then the
delivery is read again (a purge may have emptied it since due returned it) and, while it is still pending and no
other send of it is under way here, send gets the fresh row and a signal that a purge of the run aborts. True when
send resolved; false when the delivery is gone, no longer pending or being sent already, or a purge cancelled the
send; rejects with send's own error otherwise.
Parameters
candidate
A delivery due returned.
send
(fresh, signal) => Promise<void>
Sends the fresh copy; it stops at the signal before it writes the body.
Returns
Promise<boolean>