SQL read/write classifier fails closed on valid reads (`//`, typed `TIMESTAMPTZ` literals, `NOT GLOB`, CREATE+SELECT) and reports a misleading "user rule" error
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- sql, typescript
- 领域
- databases
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- TypeScript
- 星标
- 810
- 派生
- 121
- 平均合并
- 1 天 12 小时
- 30 天内合并 PR
- 94
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
AltimateAI/altimate-code 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
AltimateAI/altimate-code#1454 ·
维护者通常 1 天内回复
-
test: MCP tests fail when the developer's ~/.claude.json has MCP servers (HOME is not sandboxed)未关闭
难度 2/5 1-3 小时 新手友好度 78/100
AltimateAI/altimate-code#1386 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
AltimateAI/altimate-code#1384 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
AltimateAI/altimate-code#1323 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 86/100
AltimateAI/altimate-code#1288 ·
维护者通常 1 天内回复
查看 AltimateAI/altimate-code 的全部 Issue
相似的 Issue
-
check:failed streams:edit
难度 2/5 1-3 小时 新手友好度 64/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 2 天内回复
-
package:ios ships XCFrameworks with absolute symlinks, which SwiftPM refuses to extract可能已有人在做 @cusnirvladislav 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
callstackincubator/rock#740 ·
-
S: triage
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 2 天内回复
-
area:workflow bug ready-for-human
难度 1/5 1 小时以内 新手友好度 78/100
fil-donadoni/tolaria#6108 ·
维护者通常 1 天内回复