Skip to content

Commit e8eafe4

Browse files
anandgupta42claude
andcommitted
refactor(sql-check): remove the predicate_effect mode, keep the generic fixes
The mode validated caller-supplied SQL by its text, and each review round found another server-side definition that the text cannot reveal. It was opt-in, off by default and unused, so it is removed with its config key, prompt sentence and tests. Kept, with regression tests: permission requests evaluate every pattern before prompting, PostgreSQL forwards bind parameters on both query paths, SQLite and DuckDB honour `readOnly`, tokenizer fixes for shared read validation, and readable `sql_check` validation errors. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 866aa63 commit e8eafe4

9 files changed

Lines changed: 193 additions & 3870 deletions

File tree

‎packages/core/src/v1/config/config.ts‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,16 +169,6 @@ export const Info = Schema.Struct({
169169
description:
170170
"Thresholds for truncating tool output. When output exceeds either limit, the full text is written to the truncation directory and a preview is returned.",
171171
}),
172-
// altimate_change start — require an explicit opt-in for the predicate-effect SQL probe
173-
sql_check: Schema.optional(
174-
Schema.Struct({
175-
predicate_effect: Schema.optional(Schema.Boolean).annotate({
176-
description:
177-
"Enable predicate_effect for trusted databases (default: false). Executes caller-supplied SQL whose server-side definitions cannot be fully validated.",
178-
}),
179-
}),
180-
).annotate({ description: "SQL check tool options" }),
181-
// altimate_change end
182172
compaction: Schema.optional(
183173
Schema.Struct({
184174
auto: Schema.optional(Schema.Boolean).annotate({

‎packages/drivers/src/local-engine-child-source.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ async function withReadOnly(p, execute) {
241241
const first = await control("SELECT txid_current() AS id");
242242
const second = await control("SELECT txid_current() AS id");
243243
if (first[0].id === second[0].id) {
244-
throw new Error("DuckDB read-only execution cannot run inside an active transaction; finish it before running the probe.");
244+
throw new Error("DuckDB read-only execution cannot run inside an active transaction; finish it before running the query.");
245245
}
246246
await control("BEGIN TRANSACTION READ ONLY");
247247
try {

‎packages/opencode/src/altimate/prompts/analyst.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
You are altimate-code: a read-only analyst. Do not modify source data or files. When available, `sql_materialize` may write session-local `scratch` tables.
22

3-
Inspect connections, schemas and actual rows before joining or parsing; key formats may differ across databases. Establish population, grain, denominator and assumptions. Every clause of the question must bite: a filter that removes nothing usually means the wrong column. (`sql_check` `predicate_effect` reports what each filter removes; a filter that removes nothing at the right population is a reason to profile an alternative column, not to invent an exclusion). When a phrase admits two readings (which population, denominator, transform or owner column), compute both, then choose by the question's own definitions and the data's shape; keep that reasoning out of the final message. Use `sql_check` for keys, fan-out, grain, nulls or extraction coverage when they affect the answer; trivial queries need no ritual. `sql_analyze` is optional.
3+
Inspect connections, schemas and actual rows before joining or parsing; key formats may differ across databases. Establish population, grain, denominator and assumptions. Every clause of the question must bite: a filter that removes nothing usually means the wrong column. When a phrase admits two readings (which population, denominator, transform or owner column), compute both, then choose by the question's own definitions and the data's shape; keep that reasoning out of the final message. Use `sql_check` for keys, fan-out, grain, nulls or extraction coverage when they affect the answer; trivial queries need no ritual. `sql_analyze` is optional.
44

55
Derive large intermediate sets in-engine. For a cross-engine join, move the smaller side: a few hundred keys go into an IN list or VALUES against the big table; materialize into `scratch` only the side that is small after filtering, never a multi-million-row table when a filter or aggregate could shrink it first. Preserve requested weighting: group means weighted by contributing counts can be exact; unweighted averages change the weighting. For many similar tables, prefer catalog-driven SQL (information_schema, DuckDB query_table/UNION ALL BY NAME) after confirming dialect support.
66

0 commit comments

Comments
 (0)