Repository navigation
feat(tlon): add durable ingress - #110910
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ec7a8f15ae
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return !running || options.abortSignal?.aborted | ||
| ? { kind: "failed-retryable", error: new TlonIngressShutdownError() } | ||
| : result; |
There was a problem hiding this comment.
Finalize successful non-turn dispatches before shutdown
When shutdown races immediately after a handler finishes, this converts its successful result into a retry and leaves the claim for restart recovery. Several recognized-message paths perform user-visible side effects without calling lifecycle.onAdopted()—for example, handleChatFirehose persists/resends approval requests and handles owner admin/approval commands (extensions/tlon/src/monitor/index.ts:1003-1018, extensions/tlon/src/monitor/index.ts:1044-1058). A gateway stop after those effects complete but before this check therefore replays the event on restart, potentially resending an approval notification or re-executing a command; those terminal non-turn paths need to finalize their ingress lifecycle once their durable side effect succeeds.
Useful? React with 👍 / 👎.
What Problem This Solves
Tlon firehose events could be accepted by the SSE client but lost if the process exited before local dispatch. The deleted in-memory processed-message guard also could not preserve dedupe state across restarts.
Why This Change Was Made
This routes Tlon firehose events through the shared SQLite channel-ingress queue. Each recognized message is durably admitted under a stable logical ID before the SSE handler resolves, then dispatched through a serialized conversation lane. Completed logical-ID tombstones replace the deleted processed-messages guard and preserve its count-based capacity of 2,000.
Tlon SSE redelivers unacknowledged events when reconnecting the same HTTP channel: reconnecting with a new channel ID resets the cursor and abandons that channel's pending events. This implementation therefore reopens the same channel first and acknowledges the SSE cursor only after durable admission. A definitive missing-channel response creates and resubscribes a new channel because Eyre may delete inactive channels.
The durable queue provides crash-window durability between SSE acceptance and local dispatch, plus local restart recovery. It does not preserve the old Eyre cursor after the server-side channel is deleted or replaced.
User Impact
Accepted Tlon messages now survive local process crashes and restarts until dispatch. Duplicate logical messages remain bounded by the existing 2,000-message policy. Failed SSE acknowledgements retry on replay, and reconnects retain the server cursor whenever the channel still exists.
Evidence
pnpm test extensions/tlon: 19 files, 173 tests passed, including the loopback HTTP proofspnpm deadcode:unused-files: zero entriespnpm deadcode:exports: zero entriesoxfmt --checkon all six touched TypeScript filesgit diff --checkvoiddispatch.