Skip to content

design: move agent append streams (agent.events, agent.quota_records) from Supabase to Turso staging #5690

Todo

Description

@dezren39

Design scope only — no data moves in this issue's first pass.

What moves

  • From: Supabase (muse-dev2) agent.events (158,802 live rows, 65.5 MB) and agent.quota_records (8,163 live rows, 3.9 MB)
  • To: Turso, staging tier (per §4 of the design doc), partitioned by day/work unit

Why

Both are append-only ledgers: in the stats window since 2026-10-29, agent.events shows 159,546 inserts / 0 updates / 3 deletes and quota_records is insert-only periodic plan/quota snapshots with a jsonb payload. The Scaler-era revision (§7 Phase A, §9.2) names exactly this shape — high-write append ledgers — as Turso staging-tier natives. Neither needs cross-row transactions or FK integrity.

Design doc: §9 of doc/2026-11-04T21-27-34Z_design_atlas_scaler_revision/ (PR #5667, addendum PR #5689).

Risks

  • agent.events is the heaviest-read table in the project (54M cumulative index scans since 2026-10-29) — its consumers are NOT yet audited; a blind move breaks whatever reads it (queue observability is the suspected reader).
  • Writers are live fleet systems (queue-broker path); dual-write cutover must not lose or reorder events.
  • quota_records.payload is jsonb — Turso side needs a JSON-column convention consistent with the staging schema versioning rule (§4.1).

Sketch of steps

  1. Consumer audit: enumerate every reader/writer of both tables (code search + pg_stat_statements).
  2. Define the staging-tier tables under the versioned staging schema; decide retention (events are a ledger — propose a rolling window with cold export).
  3. Dual-write from the producers, backfill, compare counts/checksums per day partition.
  4. Flip readers, observe one full fleet cycle, then stop the Postgres writes; keep the Postgres tables read-only for one retention window before any drop decision (separate approval).

Links: design doc PR #5667 · addendum PR #5689 · tracking dezren39/hatch-personal#21

Acceptance criteria

  • A design record (on this issue or a linked doc/PR) specifies the Turso staging-tier shape for agent.events and agent.quota_records: partitioning by day/work unit, writer path, and reader migration.
  • All consumers of agent.events (the heaviest-read table in the project) are inventoried in the design, with a migration or compatibility plan for each — queue observability explicitly included.
  • Cutover, dual-write/verification, and rollback steps are specified; no data moves under this design issue itself.
  • Follow-on implementation issues are filed and linked.

Activity

  1. added
    queue/queued
    task/triage
    on Nov 5, 2026
  2. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

  3. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    Task 10126 (lane code-s) claimed and assigned to the opencode execution lane. Handed off to the opencode claimant — the bound session drives this task to its terminal state. Parked by this lane per the handoff protocol.

  4. added
    queue/parked
    status/parked
    work/assigned
    and removed
    queue/queued
    on Nov 5, 2026
  5. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

  6. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

  7. added
    queue/claimed
    and removed
    status/parked
    queue/parked
    on Nov 5, 2026
  8. 205 remaining items

  9. dezren39 commented on Nov 17, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · triage — already satisfied; remainder is Drew-gated

  10. dezren39 commented on Nov 17, 2026

    @dezren39
    MemberAuthor

    Agent note — state: triaged · task 19876, lane any-g

  11. removed their assignment
    on Nov 20, 2026
  12. dezren39 commented on Nov 24, 2026

    @dezren39
    MemberAuthor

    Design deliverable for queue task 21669: nine-point agent append-stream Turso design. It records the event/quota boundaries, alternatives, migration slices, rollback and evidence gates; it authorizes no production cutover. Proposed in PR #14109, commit 472da08ec4ad6db17ae3456c1c385148e44171d3.

  13. dezren39 commented on Nov 24, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done (second pass, remainder routed)

  14. developing-today-fleet commented on Nov 27, 2026

    @developing-today-fleet
    Contributor

    🤖 Agent note (lane code-j, 2026-11-26, triage task 25342): design and sinks landed; production decommission remains gated — no packet.

  15. developing-today-fleet commented on Nov 27, 2026

    @developing-today-fleet
    Contributor

    Triage recheck — code-f, 2026-11-27 (queue task 25740)

    Sinks landed; sole remainder is PG decommission, gated — no packet. Fresh reads concur with tasks 21835 / 25342:

    Remaining wave work stays under the merged-wave tracker #6581.

  16. added
    priority/normal
    status/blocked
    on Nov 29, 2026
  17. dezren39 commented on Nov 29, 2026

    @dezren39
    MemberAuthor

    🤖 Census note — 2026-11-29 (lane CEN-C04, full-census pass)

    Verdict: blocked — design done, remainder is a Drew-gated decommission. Rechecked firsthand. Landed: agent.events sink (PR #6762), quota_records sink (PR #6655), nine-point design (PR #14109 merged 2026-11-24); doc/fleet/agent-events-turso.md on main. Sole remainder: step 4, Postgres decommission — gated per the design on a green PG window / C4 verification and then Drew's decommission decision. Not queue-actionable until that gate is taken. Blocker: Drew's step-4 decision.

    Census actions: added labels priority/normal, status/blocked.

  18. developing-today-fleet commented on Nov 29, 2026

    @developing-today-fleet
    Contributor

    Census 2026-11-29 (Felix):

  19. added
    effort/m
    area/infra
    on Nov 29, 2026
  20. developing-today-fleet commented on Nov 29, 2026

    @developing-today-fleet
    Contributor

    Issue census — 2026-11-29

    Gaps found: no effort/* and no app//area/ label; no acceptance criteria section (the body has What moves / Why / Risks / Sketch of steps).
    Strengths: the move is quantified (agent.events 158,802 rows / 65.5 MB, quota_records 8,163 rows), the append-only evidence is cited from the stats window, and the key risk is named honestly — agent.events is the heaviest-read table in the project and its consumers are not yet audited. Design source linked (§9, PR #5667 / #5689).
    Actions: added labels effort/m and area/infra; appended a ## Acceptance criteria section derived from the body's own scope (original text untouched). Priority unchanged (normal). The blocked label stands: consumer inventory is the gating work before any move.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/infradesign/supabase-turso-migrationeffort/mepic/turso-cloudflarekind/designpriority/normalstatus/blockedtask/triage

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions