SQL read/write classifier fails closed on valid reads (`//`, typed `TIMESTAMPTZ` literals, `NOT GLOB`, CREATE+SELECT) and reports a misleading "user rule" error
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 35/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- sql, typescript
- Bereich
- databases
Rechercherichtung
Start in packages/opencode/src/altimate/tools/sql-classify.ts, at classifyAndCheck, classifyFallback and isScratchSafeWrite, then check how sql-execute.ts maps a write classification to sql_execute_write. Add tests that classify each listed construct (//, NOT GLOB, typed TIMESTAMPTZ literals, CREATE ... AS SELECT followed by SELECT) as a read, and check that a parse failure produces a distinct message. Done means those cases pass and the unparseable-statement denial text is snapshotted.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Problem
When the parser cannot read a statement, classifyAndCheck classifies it as a write. The analyst config denies writes, and the model sees only "The user has specified a rule which prevents you from using this specific tool call". Nothing says the statement was actually a parse failure on a valid read, so models rewrite blindly or switch to slower workarounds.
Mechanism
classifyAndCheckfalls back toclassifyFallback, which returns"write"when the parser throws (packages/opencode/src/altimate/tools/sql-classify.ts:131,:172-193).sql_executethen asks forsql_execute_write(sql-execute.ts:113-121), which the analyst agent denies (packages/opencode/src/agent/agent.ts:254).isScratchSafeWriterequires every statement to be a write (sql-classify.ts:226-271), soCREATE TABLE ... AS SELECT ...; SELECT ...in one call is refused.- Parser gaps on pure reads (probed against the bundled parser): DuckDB integer division
//; SQLiteNOT GLOB;FILTER (...)variants; alias namesatandmatch;PIVOT; typed literals such asTIMESTAMPTZ '2023-05-02 00:00:00+00'. The same queries with/, or with::timestamptzcasts, classify as reads.
Evidence
- 17 of 17 queries containing
//were denied; 4 containingGLOB. - 90 refusals of pure SELECT/WITH statements in one set of sessions: 87 contain a typed
TIMESTAMPTZ '...'literal, 0 of 2,676 allowed queries on the same warehouses do (inferred from this split; not yet reproduced in a unit test). - 31 denied scratch
CREATE ... AS SELECTbatches with a trailingSELECT. - 28 of 32 denials in one set of sessions were avoidable, at about 3.4-3.8 s per lost turn (about 600 s total); 23 generations had every call refused.
- The refusals pushed models onto a scratch-to-scratch
sql_materializepath (45 calls, 728 s, including 4 helper crashes) and blocked a session-setting workaround for expression depth limits (see the many-table issue).
Impact
Time and cost; no direct answer loss (affected sessions recovered), but the risk of abandoning a correct approach is real.
Proposed fix
- Report parser failures as their own message: "could not prove this is read-only: parser error at col N; rewrite or split the statement".
- Teach the dialect lexer/parser
//,GLOB,PIVOT, typed literals (TIMESTAMPTZ,TIMESTAMP,DATE,INTERVAL '...'). - When the parse fails but the statement starts with
SELECT/WITHand masked code has no write keyword, run on a read-only connection. - Accept scratch-safe writes followed by reads and return the last result set.
Acceptance check
Regression tests classifying each of the listed constructs as read, a CREATE ...; SELECT ... scratch batch accepted, and a snapshot of the new denial message for a genuinely unparseable statement.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 813
- Forks
- 124
- Ø Merge
- 1 T. 17 Std.
- Gemergte PRs (30 T.)
- 78
Entwicklungsumgebung
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus AltimateAI/altimate-code
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
AltimateAI/altimate-code#1593 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
AltimateAI/altimate-code#1591 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
AltimateAI/altimate-code#1590 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 69/100
AltimateAI/altimate-code#1588 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
AltimateAI/altimate-code#1573 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in AltimateAI/altimate-code
Ähnliche Issues
-
[Bug]: Pen taps on sidebar rows start a drag and lose their clickEvtl. vergeben @makhnatkin hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
b310-digital/teammapper#1515 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 79/100
puckeditor/puck#1884 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
outline/outline#14378 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
nicobailon/pi-web-access#642 ·
Maintainer antworten meist innerhalb von 1 Tag