Expand description
Deferred-message storage for agents queue {add, list, read id}.
Mirrors the sqlite predecessor’s split: a message_queue row carries
either an agent_instance_hierarchy or an agent_tag (CHECK
enforces); the master message_queue_contents registry has FK-cascade
chains down to per-kind tables (message_queue_texts, message_queue_images,
message_queue_audios, message_queue_videos, message_queue_files) — one DELETE on
message_queue sweeps every per-kind row through the cascades.
Structs§
- Drained
Message - One drained message — carries enough metadata to re-INSERT the original row.
Enums§
- Content
Row - One content row — typed payload of a single
message_queue_contents.id. - Delete
Outcome - Outcome of a
delete_by_idattempt. Distinguishes the three terminal states the handler must surface differently: the row was soft-deleted, no active row matched the id, or the row exists but the caller isn’t authorized to delete it. - Delivery
Target - One addressed delivery target.
- Resolved
Target - List all queued message_queue visible under
parent. Three rules:
Functions§
- check_
any_ pending - EXISTS-check: are any queue rows in scope for
target_hierarchy? - content_
row_ to_ part - Map one
ContentRowto its matching SDKRichContentPartvariant. - delete_
by_ id - Atomically soft-delete the
message_queuerow with the givenid(flipsactive = FALSE) and return its reconstructed shape — but only whencaller_agent_instance_hierarchyis the row’s sender or an ancestor of it. The authorization decision happens inside the transaction, before the flip, so an unauthorized attempt leaves the row untouched. - enqueue_
with_ content - Atomic enqueue: inserts the
message_queuerow, walkscontentand extracts every part into a per-kind table referenced by id, then UPDATEs themessage_queue.contentcolumn with the assembled [ResponseContent] JSON (One(i64)for single-part,Many(Vec<i64>)for multi-part). Returns the newmessage_queue.id. Everything runs inside one transaction — failure rolls every content row back. - list_
delivery_ targets - Enumerate every delivery target with pending queue rows in the
subtree rooted at
parent: - list_
pending_ for_ targets - Stream every
active = TRUEmessage_queuerow for any oftargets, JOINed againstmessage_queue_contentsfor parts. Grouped per-parent sopartsreflects the relational content shape, not a JSON shadow. Pagination is bymessage_queue_contents.id(the--after-id/--limitscope is on parts, not rows — but the row boundary stays stable per parent). - read_
content - Look up a single content row by
message_queue_contents.id. ReturnsNonewhen the id doesn’t exist; a per-kind miss is DB corruption and surfaces asError::InvalidData. - read_
pending_ and_ upgrade_ tag - Non-destructive read of every queue row in scope for an agent, fused with the tag-group upgrade. Two-rule predicate: direct hierarchy match OR BOUND-tag match.
- subscribe_
delivered - Wait until the
message_queuerow identified byidhas been consumed — i.e. itsactivecolumn has flipped from TRUE to FALSE. ResolvesOk(())the moment the flip is observed, regardless of which path performed it.