Repository navigation
feat(webhook): turn_finished event types, builder and queue (#962) - #999
Merged
Merged
Conversation
Part 1 of 2 of the turn_finished outbound event: the closed TurnStatus/TurnCode enums and TurnEnd with its exhaustive outcome mapping, the signed event builder and per-settle event id, the volatile queue with the same-session overflow replacement (a retry never evicts a newer event), and the sender changes that deliver it. Nothing in the session host or serve calls it yet; part 2 wires it and adds the real-binary e2e.
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
ajianaz
added a commit
that referenced
this pull request
Nov 19, 2026
…962) (#988) Part 2 of 2 of the turn_finished outbound webhook event (owner decisions D1-D10 confirmed 2026-11-19). Wires the part-1 types and queue (#999) into the turn path: run_session_turn_with_end and resume_session_turn_with_end return a typed TurnEnd with a per-session settle counter, and serve announces after the turn returns, outside every lock; the approval id comes from the queue entry, never from the outcome. Adds the real-binary e2e (8 tests) with a run-time-built leak-check marker proven to reach the log, plus the threat-model rows, design and delivery notes, faces.md row, CHANGELOG and README. Independent read-only review done; Cora verdict clean and CI green on the merged head.
ajianaz
added a commit
that referenced
this pull request
Nov 19, 2026
…hing else (#980) (#1002) The approval and turn_finished sender sent every due event inline on one thread, so a destination that hung (timeout up to 30 s, up to 256 events due at once) stalled every other destination and the approval-expiry timer. The sender now runs one worker thread per destination that lists approval_requested, approval_resolved or turn_finished, plus one timer thread started first; each worker has at most one request in flight and skips its destination for the rest of the pass after a transient failure. A retry refused by a full queue is reported once as queue_full instead of being dropped silently or counted twice. The #999 queue rules are unchanged (same-session replacement on push, a retry never evicts a newer event, same retry schedule and 15 min horizon). Independent read-only review done and re-checked; Cora verdict clean and CI green on the merged head.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Part 1 of 2 of the
turn_finishedoutbound webhook event (#962, designdocs/turn-finished-event.md, owner decisions D1-D10 confirmed 2026-11-19). The contract and the queue only: nothing in the session host ortole servecalls it yet. Part 2 (#988) wires it into the turn path and adds the real-binary e2e, docs and CHANGELOG.Why
The chat gateway (epic #910, tole-gateway#16 and #969) polls status and log after an Allow to learn that a turn ended. One signed event per turn end removes that polling, with ids and a status word only.
Size: this was one 18-file, about 2,300-line PR; the Cora job timed out on it, so it is split by layer per the PR size standard. This part is 8 files and 1,314 changed lines (above the 1,000 ideal, under the 1,500 ceiling; 591 of them are unit tests), because the types, the builder, the queue rule and the sender retry schedule must land together to be tested and green on their own.
Changes
webhook_out/turn.rs(new): closedTurnStatus/TurnCodeenums,TurnEnd,TurnSignal, andTurnEnd::from_outcome, one exhaustive match onTurnOutcomewith no wildcard arm that drops every payload string. All knobs are named constants (D1-D10).webhook_out/event.rs:turn_finishedbuilder (body at most 1 KiB, refused not cut; an id outside its charset or one the redactor would change is not sent) andturn_event_id(turn:<readable>:<hash16>:<last_seq>:<settle>, at most 128 characters, shared with the cron helper).Event::TurnFinished(ALLis now 4). Defaulteventsis unchanged, so an existing destination does not receive it.volatile.rs: on a full queue a new turn event replaces the oldest queued one of the same session (D8). A retry (requeue) never takes that replacement: when full the retry is dropped and counted, so an older settle can never evict a newer one.approval_sender.rs: the sender starts for a turn event too, with its own retry schedule (2 s, 10 s, 30 s, 2 min, then every 5 min, 15 min horizon); a lost event is one stderr line with the destination name and a closed code.Testing
cargo fmt --all -- --check: clean.cargo clippy -p tole-cli --all-targets -- -D warnings: clean for default features and for--no-default-features.cargo test -p tole-cli --lib webhook_out: 163 passed.