Skip to content

Backfill workbench messages into participants' mailboxes (CL-7454) - #650

Closed
TheGreatAxios wants to merge 4 commits into
mainfrom
cl-7454-mailbox-backfill
Closed

TheGreatAxios wants to merge 4 commits into
mainfrom
cl-7454-mailbox-backfill

Conversation

@TheGreatAxios

Copy link
Copy Markdown
Contributor

Fixes CL-7454
Part of CL-7445

Unit tests over in-memory fakes for the cursor/paging logic and the
author-aware fan-out (human outbound/inbound, agent inbound-only), plus
a DB-gated integration test replaying a three-message thread (person,
agent, person) in a two-human workbench against a real @corbits/mailbox
schema, proving the parent links and that a second pass writes nothing.
CL-7450 wired the live send path to fan a new message into every human
participant's @corbits/mailbox inbox as it is posted; nothing wrote a
mailbox copy of a message posted before that landed, and nothing
retroactively fills the gap for a workbench that has been quiet since.

runMailboxBackfillPass (packages/chat/src/mailbox-backfill.ts) is that
fill: a per-workbench replay that walks workbench_messages oldest-first,
mints and stamps mail_message_id for any row that predates CL-7104, and
writes the same author-aware mailbox rows a live send would have — an
outbound copy for a human author, an inbound copy for every other human,
and inbound-only copies for an agent-authored row (an agent has no
mailbox of its own). A workbench with no human participant is skipped
and reported. Idempotent by @corbits/mailbox's own default transport key,
with a per-workbench progress cursor (new chat.mailbox_backfill_cursor
table, migration 0030) as a courtesy on top so a rerun resumes rather
than re-walking history. Every written row carries an extra
{ kind: "import", id: "chat-backfill" } ref, since @corbits/mailbox's
priority/classification/status columns are the mount boundary's own
vocabulary rather than something this package can stamp a value into.

Wired into apps/hub/src/index.ts as a one-shot, fire-and-forget boot
step beside the other mailbox sweeps, reusing the exact mailbox dep the
live send path fans out through so a backfilled row and a live-sent row
are addressed and idempotency-keyed identically.
Documents runMailboxBackfillPass — what it replays, its idempotency and
cursor story, the import-ref marker choice, and its boot wiring — plus
that the whole module is meant to be deleted once workbench_messages
itself is retired.
@linear-code

linear-code Bot commented Sep 5, 2026

Copy link
Copy Markdown

CL-7454

CL-7445

@TheGreatAxios

Copy link
Copy Markdown
Contributor Author

Closed: owner ruled a hard cutover, no backfill of existing workbench messages into mailboxes (CL-7454 canceled). The thread-backed timeline lands with the old tables dropped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant