Skip to content

Inbox list, details and delete; the full inbox JSON (#24) - #28

Merged
thepaul merged 2 commits into
mainfrom
fix-24-inbox-routes
Nov 12, 2026
Merged

thepaul merged 2 commits into
mainfrom
fix-24-inbox-routes

Conversation

@thepaul-bot

Copy link
Copy Markdown
Collaborator

Fixes #24.

The server now has every route and field in PROTOCOL.md's "Inboxes" section.

Routes

  • GET /v1/inboxes lists the account's inboxes, ordered by name.
  • GET /v1/inboxes/{name} returns one inbox. Looking at an inbox doesn't count as reading it, so last_read_at is unchanged.
  • DELETE /v1/inboxes/{name} deletes the inbox along with its events and subscriptions, and answers 204.
    • Each subscription is first removed from its RepoHub. If one can't be reached, the subscriptions that did end leave the inbox, the inbox stays, and the server answers 503 with Retry-After.
    • Open sockets on the inbox close with code 4004.
    • If the inbox is made again, it continues its old numbering, so a reader holding an old position gets inbox.gap.

Inbox JSON

  • PUT and both GETs return the full InboxInfo: ISO dates, oldest and subscriptions. Before this, PUT returned the raw database row.
  • oldest is the oldest event still kept, or head + 1 when there are none.

A deleted inbox stays deleted

  • Deliveries from RepoHub no longer create a missing inbox. Events still queued for a deleted inbox are dropped.
  • A long-poll bridge to a missing inbox gets 404.
  • Deleting an inbox that never had an event leaves no deleted_inboxes row, so that table can't grow without bound.

Docs

  • PROTOCOL.md: no longer claims idle inboxes are deleted after 30 days. An inbox stays until it is deleted or the account needs room, and its subscriptions expire through ttl_seconds.
  • Server README: the "Not yet" list was out of date, and it now says nothing in PROTOCOL.md's routes is missing.
  • DESIGN.md: updated to match.

Tests

  • New tests cover the routes, the inbox fields, closing sockets on delete, a partial delete answering 503, a subscription saved while the delete runs, and a subscribe racing a delete.
  • The debug subscribe route now creates the inbox, so the RepoHub and Control tests are unchanged.

Typecheck is clean. All tests pass: CLI 234, server 175, selfhost 32.

Known leftovers

  • If removing a subscription from the inbox fails during a partial delete, the client gets 500 instead of 503. A retry fixes it either way.
  • One test deliberately makes a RepoHub fail and logs an "Error: unreachable" message during the run.

🤖 Generated with Claude Code

thepaul-bot and others added 2 commits November 11, 2026 14:36
GET /v1/inboxes, GET and DELETE /v1/inboxes/{name}, and PUT now answer
with the inbox as PROTOCOL.md documents it: ISO dates, `oldest` (head + 1
when nothing is kept) and `subscriptions`.

DELETE takes the subscriptions back from their RepoHubs first (503 with
nothing deleted if one fails), then deletes the inbox, its events and
index rows, remembers its numbering in deleted_inboxes, and closes its
sockets with 4004. RepoHub's deliveries no longer make inboxes, so an
event already in its outbox can't bring a deleted inbox back; /debug
injection and debug subscriptions still make them.

PROTOCOL.md now says what the server does with idle inboxes (deleted
only to make room; their subscriptions expire), and the server README's
"Not yet" list is current.

Fixes #24.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- DELETE /v1/inboxes/{name}: when a RepoHub can't give up a
  subscription, the ones that did end leave the index too, so it still
  says what RepoHub has; the 503 keeps the inbox and the rest.
- A long poll's bridge no longer makes the inbox: one opened after a
  delete answers 404.
- An inbox that never had an event leaves no deleted_inboxes row, so
  making and deleting empty ones costs no storage.
- Stale comments; PUT's "touch"; tests for the late save, the subscribe
  race against DELETE, the debug subscribe route, and `oldest` after
  trimming.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thepaul
thepaul merged commit 9ab21a7 into main Nov 12, 2026
2 checks passed
@thepaul
thepaul deleted the fix-24-inbox-routes branch November 12, 2026 00:28
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.

Inbox routes and fields in PROTOCOL.md that the server doesn't have

2 participants