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
{{ message }}
driver-sql: an array insert of more than about 500 rows throws on SQLite, because bulkCreate sends the whole batch as one multi-row INSERT #38236
Filing gate: ① (an out-of-scope finding of a dev report) · Source: fleet (card #38223's thread, PR #38235)
What happens
SqlDriver#bulkCreate (packages/drivers/driver-sql/src/sql-driver-bulk-operations.ts) sends a whole array as ONE insert, on purpose: that keeps the batch all-or-nothing and its auto-number reservations whole (the docblock there). On SQLite a multi-row INSERT is compiled into a compound SELECT, and SQLite refuses one past its 500-term limit (too many terms in compound SELECT). So engine.insert(object, rows) with more than about 500 rows throws on SQLite, where the same call works on the other dialects.
PR #38235 met it while seeding 1200 rows in a test and worked around it with batches of 200 in the test alone; the driver was not changed.
Expected
Measure the exact bound on the SQLite driver this repository ships, and whether any non-test caller (import, seed, sync) can pass a larger array today.
Either the driver splits a large batch on SQLite while keeping the one-batch guarantees its docblock states (one transaction, the whole reservation), or the bound is refused with a coded error that names it. A test pins a batch above the bound.
Grade: bug · reach: a SQLite-backed app (local dev, self-hosted) that writes more than about 500 rows in one array insert · evidence: read and hit (PR #38235's thread report)
Suggested-grade: p2
Size: S
Related: #38223, PR #38235.
Triage: lands in area:data · domain:data · Bug · p2 · pm:queue · size S; rationale: on SQLite, an array insert of more than about 500 rows throws, because bulkCreate sends the whole batch as one multi-row INSERT and exceeds the variable limit (hit in PR #38235's thread). Local-dev and self-hosted SQLite apps cannot write large batches in one call. The failure is loud, so p2. The fix is to chunk the insert. Recorded 2026-11-28T10:12Z.
Picked by card-pick.mjs --order area:data --seat repo:objectstack#8 at 2026-11-28T10:21Z: a SQLite-backed app that writes more than about 500 rows in one array insert. The maintainer in this seat's session, verbatim: 「开一个 objectstack 全仓座位」 with intake area:data; 「batch 调到 5,可以用云卡」; then on more concurrency through cloud cards, batch 「8 (Recommended)」; 「现在并发多少,还能加速吗」.
Claim: PM loop round 1
Session: session_017xRBcSAaBEfQpU2yJexSJ8
Account: sunhaolin
Branch: claude/issue-38236-sqlite-bulk-insert-bound
Worktree: objectstack-issue-38236
Domain: domain:data
Seat: repo:objectstack#8
File surface: packages/drivers/driver-sql/src/sql-driver-bulk-operations.ts and the SQLite dialect helpers it calls, co-located tests, one changeset 38236-<slug>.md; ⛔ not sql-driver-schema-sync.ts (PR #38225 in flight) (stop on breach; explain in the report)
Container & model: S, mode:cloud, model: opus (dispatch-gates --tier: no path-derived mandate; default tier), effort: high
Clause-②: no
Metadata-protocol: none
Responsibility: objectstack — the SQLite arm of SqlDriver#bulkCreate
Thread-read: none
Premise: measured first by the cloud dev on current main (the exact bound on the shipped SQLite driver, and whether a non-test caller can pass a larger array), before any edit; a premise that no longer holds is reported, not built.
Serial constraints cleared: check-handover.mjs --inflight --paths=packages/drivers/driver-sql/src/sql-driver-bulk-operations.ts reads no overlap among 62 held claims; textual overlap re-checked with overlap-check.mjs before every push.
Scope this dispatch: the whole card. Fixes #38236.
{
"issue": 38236,
"status": "done",
"branch": "claude/issue-38236-sqlite-bulk-insert-bound",
"pr": null,
"session": "session_017xRBcVXco8T2suSgnRk52Y",
"premise_still_valid": true,
"summary": "Measured on main 9f5562f4: a SQLite INSERT holds at most 500 rows (SQLITE_MAX_COMPOUND_SELECT) and 32766 bound values, rows x columns (SQLITE_MAX_VARIABLE_NUMBER); the row bound binds first up to 65 columns. better-sqlite3 3.53.4 and sql.js 3.49.1 have the same values. One non-test caller can pass a larger array: REST createMany, capped by batch.maxBatchSize, which may be set up to 1000 (rest-server.zod.ts:599). The path is batch-routes.ts:693/700, then protocol-batch-data.ts:815 engine.insert, then engine-insert.ts:1553 bulkCreate. Any in-process engine.insert of an array is unbounded. Import, bulkWrite and seed use 200 by default. Fix, option (1): bulkCreate sends a SQLite batch past either bound as several INSERTs in row order inside ONE transaction (a savepoint under the caller's transaction). The reservations are all taken before the transaction opens, so the batch stays all-or-nothing, the auto-numbers are dealt in order, and a failed batch burns the reservation once, like a failed single INSERT. A batch within the bounds is still one INSERT with no transaction, and other dialects are unchanged. The pr_create relay write was refused by the permission classifier: the branch is pushed at a51d0575 and the seat opens the PR with the title, body and assignees from this run's final message.",
"tests": "pnpm --filter @objectstack/driver-sql typecheck && test under os-verify-lock on a51d0575: VERDICT command-exit 0, Test Files 272 passed | 14 skipped (286), Tests 4582 passed | 265 skipped (4847). The new file sql-driver-38236-sqlite-bulk-insert-bound.test.ts has 13 tests, 13 passed, and the package typecheck includes it (--listFiles 1 hit). Ablation with scripts/ablation-replace.mjs on a51d0575, replacing the split with the pre-fix single statement: mutation landed (anchor 1 -> 0, blob 31312970c030 -> 82f60ca228e2), Tests 7 failed | 6 passed (13); the reds are 'too many terms in compound SELECT' x4 and 'too many SQL variables' x1; the CONTROL and the 5 helper pins stay green; restored with blob == HEAD and git diff HEAD empty. No build is involved: the suite imports src/.",
"gates": "On a51d0575, node scripts/pm/dispatch-gates.mjs --commands derived 65; all were run with each exit code captured before any pipe. 62 exit 0. 3 exit 3 PREREQUISITE NOT MET = NOT MEASURED locally (check-plugin-teardown-shape --self-test: shallow clone lacks its pinned fixture commit; check:dual-build-cjs-loads and check:lean-entry-closure: packages outside the driver-sql closure are not built); CI runs them. 0 red. dispatch-gates --ran: 65 derived, 65 run, 0 UNRUN. Outside the derivation: pnpm check:facade-delegation-only exit 0 (sql-driver.ts 10071 of ceiling 10071). PR check-runs: NOT MEASURED, reason: no PR exists yet (pr_create refused).",
"dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm",
"mcp_calls": "2 — mcp__github__issue_read (get), mcp__github__issue_read (get_comments); reads only",
"api_writes": "0 — the one relay write tried (fleet-write/dispatch.mjs pr_create, POST /repos/objectstack-ai/objectstack/dispatches) was refused by the permission classifier before it ran ('Undermining Oversight') and was not retried; 4 git pushes to the claim branch (not REST)",
"open_questions": [],
"security_findings": "none",
"out_of_scope_findings": ["none"],
"deviations": [
"The pr_create relay write and this report's post-stamped comment were not sent: the classifier refused the relay; per the dispatch order the seat sends both.",
"First cut added one line (get isSqlite) to the bulkOperationsHost install in sql-driver.ts; check:facade-delegation-only went red (10072 over the ceiling of 10071, raising it is maintainer-only). Reverted; the split now asks knex.client.dialect === 'sqlite3'. The final diff is inside the claimed file surface.",
"Shared checkout /home/user/objectstack: detached HEAD at 9f5562f4 and deleted its local copy of the claim branch (the same commit, no own work) so dev-worktree.sh could build ../objectstack-issue-38236; the worktree is left in place because no PR is open yet."
]
}
Posted verbatim by seat repo:objectstack#8 (session_017xRBcSAaBEfQpU2yJexSJ8). The dev's relay pr_create was refused by its permission classifier and not rerouted. The seat opened the draft PR as #38309 from head a51d0575, on the maintainer's go-ahead.
Activity
objectstack-fleet commentedon Nov 28, 2026
triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH
Triage: lands in area:data · domain:data · Bug · p2 · pm:queue · size S; rationale: on SQLite, an array insert of more than about 500 rows throws, because
bulkCreatesends the whole batch as one multi-row INSERT and exceeds the variable limit (hit in PR #38235's thread). Local-dev and self-hosted SQLite apps cannot write large batches in one call. The failure is loud, so p2. The fix is to chunk the insert. Recorded 2026-11-28T10:12Z.objectstack-fleet commentedon Nov 28, 2026
repo:objectstack#8 · sunhaolin · session_017xRBcSAaBEfQpU2yJexSJ8
Picked by
card-pick.mjs --order area:data --seat repo:objectstack#8at 2026-11-28T10:21Z:a SQLite-backed app that writes more than about 500 rows in one array insert. The maintainer in this seat's session, verbatim: 「开一个 objectstack 全仓座位」 with intakearea:data; 「batch 调到 5,可以用云卡」; then on more concurrency through cloud cards, batch 「8 (Recommended)」; 「现在并发多少,还能加速吗」.Claim: PM loop round 1
Session:
session_017xRBcSAaBEfQpU2yJexSJ8Account:
sunhaolinBranch:
claude/issue-38236-sqlite-bulk-insert-boundWorktree:
objectstack-issue-38236Domain:
domain:dataSeat:
repo:objectstack#8File surface:
packages/drivers/driver-sql/src/sql-driver-bulk-operations.tsand the SQLite dialect helpers it calls, co-located tests, one changeset38236-<slug>.md; ⛔ notsql-driver-schema-sync.ts(PR #38225 in flight) (stop on breach; explain in the report)Container & model:
S,mode:cloud,model: opus (dispatch-gates --tier: no path-derived mandate; default tier),effort: highClause-②: no
Metadata-protocol: none
Responsibility:
objectstack — the SQLite arm of SqlDriver#bulkCreateThread-read:
nonePremise: measured first by the cloud dev on current main (the exact bound on the shipped SQLite driver, and whether a non-test caller can pass a larger array), before any edit; a premise that no longer holds is reported, not built.
Serial constraints cleared:
check-handover.mjs --inflight --paths=packages/drivers/driver-sql/src/sql-driver-bulk-operations.tsreads no overlap among 62 held claims; textual overlap re-checked withoverlap-check.mjsbefore every push.Scope this dispatch: the whole card.
Fixes #38236.objectstack-fleet commentedon Nov 28, 2026
repo:objectstack#8 · sunhaolin · session_017xRBcVXco8T2suSgnRk52Y
os-dev-report
{ "issue": 38236, "status": "done", "branch": "claude/issue-38236-sqlite-bulk-insert-bound", "pr": null, "session": "session_017xRBcVXco8T2suSgnRk52Y", "premise_still_valid": true, "summary": "Measured on main 9f5562f4: a SQLite INSERT holds at most 500 rows (SQLITE_MAX_COMPOUND_SELECT) and 32766 bound values, rows x columns (SQLITE_MAX_VARIABLE_NUMBER); the row bound binds first up to 65 columns. better-sqlite3 3.53.4 and sql.js 3.49.1 have the same values. One non-test caller can pass a larger array: REST createMany, capped by batch.maxBatchSize, which may be set up to 1000 (rest-server.zod.ts:599). The path is batch-routes.ts:693/700, then protocol-batch-data.ts:815 engine.insert, then engine-insert.ts:1553 bulkCreate. Any in-process engine.insert of an array is unbounded. Import, bulkWrite and seed use 200 by default. Fix, option (1): bulkCreate sends a SQLite batch past either bound as several INSERTs in row order inside ONE transaction (a savepoint under the caller's transaction). The reservations are all taken before the transaction opens, so the batch stays all-or-nothing, the auto-numbers are dealt in order, and a failed batch burns the reservation once, like a failed single INSERT. A batch within the bounds is still one INSERT with no transaction, and other dialects are unchanged. The pr_create relay write was refused by the permission classifier: the branch is pushed at a51d0575 and the seat opens the PR with the title, body and assignees from this run's final message.", "tests": "pnpm --filter @objectstack/driver-sql typecheck && test under os-verify-lock on a51d0575: VERDICT command-exit 0, Test Files 272 passed | 14 skipped (286), Tests 4582 passed | 265 skipped (4847). The new file sql-driver-38236-sqlite-bulk-insert-bound.test.ts has 13 tests, 13 passed, and the package typecheck includes it (--listFiles 1 hit). Ablation with scripts/ablation-replace.mjs on a51d0575, replacing the split with the pre-fix single statement: mutation landed (anchor 1 -> 0, blob 31312970c030 -> 82f60ca228e2), Tests 7 failed | 6 passed (13); the reds are 'too many terms in compound SELECT' x4 and 'too many SQL variables' x1; the CONTROL and the 5 helper pins stay green; restored with blob == HEAD and git diff HEAD empty. No build is involved: the suite imports src/.", "gates": "On a51d0575, node scripts/pm/dispatch-gates.mjs --commands derived 65; all were run with each exit code captured before any pipe. 62 exit 0. 3 exit 3 PREREQUISITE NOT MET = NOT MEASURED locally (check-plugin-teardown-shape --self-test: shallow clone lacks its pinned fixture commit; check:dual-build-cjs-loads and check:lean-entry-closure: packages outside the driver-sql closure are not built); CI runs them. 0 red. dispatch-gates --ran: 65 derived, 65 run, 0 UNRUN. Outside the derivation: pnpm check:facade-delegation-only exit 0 (sql-driver.ts 10071 of ceiling 10071). PR check-runs: NOT MEASURED, reason: no PR exists yet (pr_create refused).", "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm", "mcp_calls": "2 — mcp__github__issue_read (get), mcp__github__issue_read (get_comments); reads only", "api_writes": "0 — the one relay write tried (fleet-write/dispatch.mjs pr_create, POST /repos/objectstack-ai/objectstack/dispatches) was refused by the permission classifier before it ran ('Undermining Oversight') and was not retried; 4 git pushes to the claim branch (not REST)", "open_questions": [], "security_findings": "none", "out_of_scope_findings": ["none"], "deviations": [ "The pr_create relay write and this report's post-stamped comment were not sent: the classifier refused the relay; per the dispatch order the seat sends both.", "First cut added one line (get isSqlite) to the bulkOperationsHost install in sql-driver.ts; check:facade-delegation-only went red (10072 over the ceiling of 10071, raising it is maintainer-only). Reverted; the split now asks knex.client.dialect === 'sqlite3'. The final diff is inside the claimed file surface.", "Shared checkout /home/user/objectstack: detached HEAD at 9f5562f4 and deleted its local copy of the claim branch (the same commit, no own work) so dev-worktree.sh could build ../objectstack-issue-38236; the worktree is left in place because no PR is open yet." ] }Posted verbatim by seat
repo:objectstack#8(session_017xRBcSAaBEfQpU2yJexSJ8). The dev's relaypr_createwas refused by its permission classifier and not rerouted. The seat opened the draft PR as #38309 from heada51d0575, on the maintainer's go-ahead.