Skip to content

feat(coord): list messages by sender - #242

Merged
amirkhakshour merged 2 commits into
mainfrom
feat/coord-outbox
Oct 23, 2026
Merged

amirkhakshour merged 2 commits into
mainfrom
feat/coord-outbox

Conversation

@amirkhakshour

Copy link
Copy Markdown
Contributor

Summary

mini-ork's IDE run page lists a run's concord mailbox (run:<id>), but the only message route lists by recipient, so the messages a run sent — concord's run-to-run side — could not be read. This adds an outbox route keyed on the sender.

Contract

  • GET /api/v1/coord/messages?from=<principal_or_actor>[&limit=N] → 200 {"messages": [Message]}, the existing Message shape; each message's principal_id is its recipient.
  • Oldest first (same as the inbox route). limit defaults to 200, clamped to 1..=1000, and keeps the newest limit messages by id.
  • from missing or empty → 400 {"error": "missing required query parameter 'from'"}.
  • A sender with no messages, or one that is not a registered principal (e.g. human:amir), → 200 {"messages": []}, never 404.
  • Store: CoordStore::list_messages_from(from, limit) next to list_messages; new idx_messages_from ON messages(from_actor, id) (CREATE INDEX IF NOT EXISTS, so existing coord.db files open unchanged).

Tests

  • cargo +1.98.1 test --lib coord_store → 23 passed (new: list_messages_from_is_the_outbox_newest_kept_oldest_first — inbox vs outbox separation, limit keeps newest, oldest-first order, unknown sender → empty).
  • cargo +1.98.1 test --test coord_principals_test → 9 passed (new: messages_from_lists_the_senders_outbox_across_recipients — 200 list across recipients, limit, unregistered sender → [], 400 on missing/empty from).
  • cargo fmt --check → clean; cargo build → ok.
  • cargo clippy --lib --no-deps -- -D warnings → 616 errors with and without this diff (pre-existing baseline), none in the touched files.

mini-ork's run page shows a run's concord mailbox, but the only message
route lists by recipient (`/principals/:id/messages`), so the messages a
run *sent* — the run-to-run side of concord — could not be read at all.

GET /api/v1/coord/messages?from=<actor>[&limit=N] returns every message
`from` sent, across recipients (each message's principal_id is its
recipient), newest `limit` kept (default 200, clamped 1..=1000) and
emitted oldest first like the inbox route. `from_actor` is free text, so
an unknown sender is 200 with an empty list, never 404; a missing or
empty `from` is 400. A new idx_messages_from(from_actor, id) index keeps
the scan bounded; CREATE INDEX IF NOT EXISTS opens existing coord.db
files unchanged.
@amirkhakshour
amirkhakshour merged commit bd3bf3e into main Oct 23, 2026
7 checks passed
@amirkhakshour
amirkhakshour deleted the feat/coord-outbox branch October 23, 2026 06:55
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