You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix: turso_client pipeline chunks lose the session (rde_incoming vanishes mid-load)
Found by Codex review on PR #8544 (migration of the runtime-db-export machinery to pkgs/agent-backup/, #5976), comment 4534316362. The defect is pre-existing in the hatch original (tools/runtime-db-export/turso_client.py) — the migrated copy is verbatim, so both copies carry it.
Problem
When a history-enabled spec such as spec_m3.json loads a 100-row page, load_rows.py creates and populates the temporary rde_incoming table using more than 100 statements. The chunking loop in turso_client.py splits those statements into separate _pipeline calls, each appending close without preserving a session baton. Subsequent staging inserts and the history archive then run on a connection where rde_incoming does not exist, so normal paged exports can fail.
Fix direction (per the finding)
Preserve the same session across chunks, or keep the staging, archive, and merge operations together in one pipeline/session.
Scope notes
Fix in the canonical code copy (pkgs/agent-backup/turso_client.py) and mirror to the hatch original (or supersede it), so the copies do not diverge silently.
Needs a test that exercises a history-enabled load whose statement count crosses the chunk boundary, with the oracle: staging table persists across all chunks and the archive/merge steps see the staged rows.
Triage verdict for issue #8545: TRIAGED — real, well-scoped bug with fix direction and test oracle in the issue; defect verified present at origin/main this shift (2026-11-17).
Fresh verification: pkgs/agent-backup/turso_client.py at origin/main carries the described chunking (line 375: "chunk into pipeline calls of at most 100 statements"; separate _pipeline calls at lines 383/390) — the session-baton loss Codex flagged on PR docs: migrate backup scripts & backup documentation from hatch (#5976) #8544 (comment 4534316362) is in the shipped code, not just the migrated copy.
First concrete step for the follow-on: reproduce with a history-enabled spec whose statement count crosses 100, then preserve the session across chunks (or hold staging+archive+merge in one session), and mirror the fix to the hatch original per the issue's scope notes.
Follow-on: fix packet enqueued as task 20172 (dedupe repo-health:v1:fix:developing-today/code:issue:8545). Completing task 18687 as triaged naming task 20172.
Fix (pkgs/agent-backup/turso_client.py): the client now carries the libsql session baton across the pipeline chunks of one batch — _pipeline(statements, close=…) sends the stored baton, records the returned one, and only the final chunk of execute closes; a mid-batch failure drops the session best-effort so its temp tables can't leak into the next batch. Before this, each ≤100-statement chunk ran on a fresh session, so the CREATE TEMP + 100 INSERTs + archive INSERT..SELECT shape in load_rows lost rde_incoming at the first chunk boundary.
Mirror: the identical fix was applied to the hatch original ~/tools/runtime-db-export/turso_client.py in the same pass (outside this repo), with the same test file copied there and passing, so the copies do not diverge on this defect.
Tests: new pkgs/agent-backup/test_turso_client.py — a fake Hrana server whose sessions are separate in-memory SQLite DBs (faithful temp-table visibility). The cross-boundary staging test and the failed-batch session-drop test both fail on the pre-fix client and pass with the fix (verified by stashing, in both copies).
Reviews: Codex review quota-failed (no findings, zero inline comments); merged under standing authority on the local verification above.
Activity
developing-today commentedon Nov 11, 2026
CODE-2550
dezren39 commentedon Nov 17, 2026
agent-note:v1
state: triaged
task: 18687 (queue repo-health-code-pilot, worker repo-worker-code, lane code-d)
Triage verdict for issue #8545: TRIAGED — real, well-scoped bug with fix direction and test oracle in the issue; defect verified present at origin/main this shift (2026-11-17).
pkgs/agent-backup/turso_client.pyat origin/main carries the described chunking (line 375: "chunk into pipeline calls of at most 100 statements"; separate_pipelinecalls at lines 383/390) — the session-baton loss Codex flagged on PR docs: migrate backup scripts & backup documentation from hatch (#5976) #8544 (comment 4534316362) is in the shipped code, not just the migrated copy.dezren39 commentedon Nov 17, 2026
🤖 Agent note · picked up (task 20172)
Revalidated fresh: issue #8545 OPEN, labels kind/bug, task/small-fix, priority/normal, app/id, effort/m — no hard-stop labels. Next: read
pkgs/agent-backup/turso_client.pychunking, reproduce a cross-chunk history-enabled load losingrde_incoming, preserve the session across chunks, mirror to the hatch original, add the boundary test.Merge pull request #11258 from developing-today/queue/20172-8545-turs…
dezren39 commentedon Nov 17, 2026
🤖 Agent note · done (task 20172, fixed_merged)
Outcome: PR #11258 merged (84c07af), issue #8545 auto-closed.
pkgs/agent-backup/turso_client.py): the client now carries the libsql session baton across the pipeline chunks of one batch —_pipeline(statements, close=…)sends the stored baton, records the returned one, and only the final chunk ofexecutecloses; a mid-batch failure drops the session best-effort so its temp tables can't leak into the next batch. Before this, each ≤100-statement chunk ran on a fresh session, so the CREATE TEMP + 100 INSERTs + archive INSERT..SELECT shape inload_rowslostrde_incomingat the first chunk boundary.~/tools/runtime-db-export/turso_client.pyin the same pass (outside this repo), with the same test file copied there and passing, so the copies do not diverge on this defect.pkgs/agent-backup/test_turso_client.py— a fake Hrana server whose sessions are separate in-memory SQLite DBs (faithful temp-table visibility). The cross-boundary staging test and the failed-batch session-drop test both fail on the pre-fix client and pass with the fix (verified by stashing, in both copies).