Skip to content

corbits-mailbox: createMailboxPersist accepts refs at insert time - #13

Merged
TheGreatAxios merged 6 commits into
mainfrom
cl-7451-persist-resolve-refs
Sep 5, 2026
Merged

corbits-mailbox: createMailboxPersist accepts refs at insert time#13
TheGreatAxios merged 6 commits into
mainfrom
cl-7451-persist-resolve-refs

Conversation

@TheGreatAxios

Copy link
Copy Markdown
Contributor

Fixes CL-7451
Part of CL-7445

Summary

  • CreateMailboxPersistOpts.resolveRefs?(args) — persist args plus the
    resolved senderAuthorization and the decoded frame (or null) —
    is called once per frame, before the transaction opens.
  • The result is validated with MailboxRefArraySchema and capped at
    MAX_MAILBOX_REFS (boundRefs, now exported from write.ts), then
    stored on every recipient row inside the existing single
    transaction, so the post-commit bus create event already carries
    refs.
  • A throwing resolveRefs follows the wrapper's existing dual-write
    contract: logged, upstream unaffected, no mailbox row for that
    frame.
  • onRow is unchanged.

Test plan

  • bun run typecheck
  • bun test src (362 pass, including 4 new resolveRefs cases in
    persist.test.ts: refs visible to a bus subscriber on create,
    resolver called once for three recipients, throwing resolver ->
    zero rows with upstream completing, over-cap refs truncated to
    MAX_MAILBOX_REFS)
  • bun run build
  • bun test --cwd examples/reference-host (reference-host
    acceptance, 20 pass)

Covers refs landing inside the same transaction (visible to a bus
subscriber on the create event), a resolver called once per frame
regardless of recipient count, a throwing resolver leaving zero rows
while upstream still completes, and over-cap refs truncated to
MAX_MAILBOX_REFS.
resolveRefs(args) is called once per frame, before the transaction
opens, receiving the persist args plus the resolved
senderAuthorization and the decoded frame (or null). Its result is
validated with MailboxRefArraySchema and capped at MAX_MAILBOX_REFS
(boundRefs, now exported from write.ts), then stored on every
recipient row inside the existing single transaction, so the
post-commit bus event already carries refs. A throwing resolver
follows the wrapper's existing dual-write contract: logged, upstream
unaffected, no mailbox row for that frame.
Document the seam in ARCHITECTURE.md's persist section, add a
README snippet, and a CHANGELOG entry.
@TheGreatAxios
TheGreatAxios merged commit 0d696b0 into main Sep 5, 2026
1 check passed
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