Repository navigation
perf(ai): run_sql seeks trace-id lookups through trace_index and stops at the row cap - #1960
Merged
Makisuo merged 16 commits intoOct 30, 2026
Merged
Maple Review Bot / Maple / review
succeeded
Oct 30, 2026 in 1m 35s
Confidence 10/10 · No issues found
🟢 Confidence 10/10 · safe to merge
The sql-identifiers edits come from the base branch, and F5 cannot fire: only a statement-terminal LIMIT matches the end-anchored OWN_LIMIT.
no findings · tests covered · risk medium
run_sql now seeks literal trace-id reads through trace_index and truncates at the 1,000-row cap with an atRowCap notice instead of failing. The seek is added only where it cannot change rows, and the cap notice stays truthful. Safe to merge.
withTraceIndexSeekANDs thetrace_indexseek onto an unbounded literal trace-id conjunctrun_sqlfalls back to the SQL as written when the seeked form is refused as invalid SQLtruncateAtCapmakes the row-cap wrapper fetch 1,000 rows instead of 1,001atRowCapis reported unless the statement's own terminalLIMITasked for a full page
Fixed since the last review
- ✅
F5 ·limitedWithinCapreads a subqueryLIMITas the statement's own cap
What was checked
- Ran
OWN_LIMITin node: a nestedLIMITis always followed by), so only a statement-terminal one matches - The seek text matches
inTraces(packages/query-engine/src/ch/tables.ts:142) over the sametrace_indexsort-key prefix - The added
$__orgFilterinside the seek subquery passesorgFilterIssue(itsWHEREis its own scope), so the seeked form validates
c25d423 · Updated on every push. Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.
Loading