GeezerVison is showing github.com — fleet-queue: agent.events Turso sink verbs + health terminal counters (#5690) by developing-today[bot] · Pull Request #6762 · developing-today/code
Conversation
developing-today
Bot
commented
Nov 7, 2026
•
edited by blacksmith-sh
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Stacked on #6755 (base queue/6741-turso-backend) — review/merge that one first. Resolves the agent.events blocker for #5690; outage context #6619.
Why
The migration classified agent.events as an append stream → Turso but left it on Postgres "blocked by design" on transactional coupling with the queue core (Gate-1 audit: supabase/turso-migration/consumer-audit-5690.md in hatch-personal). #6755 moved the queue core (whose RPCs are the coupled writers). This PR handles the stream itself.
Coupling verdict (full inventory in the new doc)
- Only the queue RPC family writes events atomically with task state — preserved by construction in the Turso backend (same dispatch, same database); the one honest deviation is pipeline-statement atomicity vs PG's single transaction, recorded in the doc.
- The FK to
agent.tasks does not carry (different id spaces) — historical import targets a separate archive table at cutover, never the live table.
- The only semantic blocker was
revalidate_parked_tasks()'s event_seen EXISTS subquery, which cannot query across databases. Its replacement primitive is built here (/events-seen); the sweeper design is step C3 of the procedure.
repo_queue_health's terminal counters dissolve in Turso — events ⋈ tasks is a local JOIN, restored in /health here.
- The non-queue writers (github-ci webhooks ≈23% of the stream, fleet-fetch) have no coupling at all; both get
AGENT_EVENTS_SINK=pg|dual|turso flips, default pg (Edge Function change in hatch-personal, fleet-fetch in ~/tools — landed alongside, referenced in the doc).
What changed
turso_queue.rs (Turso backend only; PG dispatch untouched): events indexes (kind, created_at), (created_at); verbs POST /events-append, /events-seen, /events-count, /events-prune (prune_events port, self-logging); /health gains terminal_events_24h / terminal_events_7d; unit tests for append parsing + prune cutoff.
doc/fleet/agent-events-turso.md: inventory, verdict, C1–C7 cutover procedure (dual-write → health parity → revalidator sweeper → PG-gated historical import at a max(id) watermark → writer flips → prune/backup re-point → close-out).
queue-turso-cutover.md: cross-reference from the events bullet.
Verification (live, muse-queue)
Side broker instance (own port + socket, QUEUE_BROKER_BACKEND=turso) against the real muse-queue DB:
/events-append → {"id":10,"kind":"sink_proof"}; /events-seen hit {seen:true,count:1} and miss {seen:false,count:0} correct; /events-count per-kind 1, total 10; missing kind → exit 2 kind is required.
/events-prune {keep_days:3650} → deleted:0, self-logged events_pruned (row 11).
/health → terminal_events_24h:2, terminal_events_7d:2 for the proof queue (the JOIN counting fleet-queue: Turso backend for the queue core (muse-queue) (#6741) #6755's two completed proof tasks).
- Independent readback via
turso db shell: rows 10–11 present; indexes events_kind_ts, events_created created by schema ensure.
cargo test -p fleet-queue --features queue-broker --lib: 75 passed.
Known environment caveats: cargo clippy is blocked here by a pre-existing sccache/rustc version clash (E0514 on untouched crates); cargo fmt --check disagrees with the entire branch under this toolchain (24 hunks including untouched files), so new code follows the file's existing style.
Not in this PR / still PG-gated
Historical export at a watermark (needs one green PG window or a verified DIY-backup restore), the revalidator sweeper implementation (C3, designed), cron disables and any drop decision (Drew's call). No defaults flipped, nothing deleted.
![Autofix with [code]smith](/api/image?u=https%3A%2F%2Fcamo.githubusercontent.com%2F33b6f70f3541c4e93f4503d29cbfec051fa1b040d8e0ae9313a51c4ece44a627%2F68747470733a2f2f70722d636f6d6d656e74732d6173736574732e626c61636b736d6974682e73682f636f6465736d6974682f6175746f6669782d776974682d636f6465736d6974682d6461726b2d33782e706e67)
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Nov 7, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Important
Review skipped
Bot user detected.
To trigger a single review, invoke the @coderabbitai review command.
Run configuration
-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: defaults
- Review profile: CHILL
- Plan: Advanced
- Run ID:
7abc2a4d-2ff4-4bdc-9f71-52df544e8308
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Share
-
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…#5690)
Stacked on #6755 (queue/6741-turso-backend). Resolves the agent.events blocker left by the queue-core Turso backend: the stream stays blocked only where Postgres is genuinely required (historical export), everything else now exists behind the same QUEUE_BROKER_BACKEND=turso selection. The Postgres dispatch and the production default are untouched.
turso_queue.rs: events indexes (kind, created_at) and (created_at) in the idempotent schema ensure; POST /events-append (sink for non-queue writers), /events-seen (the event_seen ready-condition primitive replacing the revalidate_parked_tasks EXISTS subquery), /events-count (observability parity), /events-prune (prune_events port, self-logging); /health restores terminal_events_24h/7d per queue via the local events-join-tasks query (the repo_queue_health view fields). Unit tests for append parsing and prune cutoff.
doc/fleet/agent-events-turso.md: full writer/reader inventory (evidence: hatch-personal consumer-audit-5690), the coupling verdict, and the C1-C7 cutover procedure covering the github-ci Edge Function and fleet-fetch AGENT_EVENTS_SINK flips, the broker-side revalidator sweeper design, the PG-gated historical import at a max(id) watermark, prune and backup re-pointing. queue-turso-cutover.md cross-references it.
Verified live against muse-queue with a side broker instance (own port/socket): append returned id 10, events-seen hit/miss correct, counts correct, kind-required validation fires, prune at keep_days=3650 deleted 0 and self-logged, health rows carry terminal_events_24h/7d = 2 from the proof cycle; independent turso CLI readback shows rows 10-11 and both new indexes. cargo test -p fleet-queue --features queue-broker --lib: 75 passed. cargo clippy blocked by a pre-existing sccache/rustc version clash in this environment (E0514 on untouched crates); cargo fmt --check disagrees with the whole branch under this toolchain (24 hunks incl. untouched files), so style follows the file as-is.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Nov 7, 2026
This was referenced Nov 7, 2026
Reviewers
dezren39
Awaiting requested review from dezren39
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|