Repository navigation
Commit e6d3817
* fix(drivers): recover #1204 review debt — driver-e2e false-skip, file: URI checks, Windows paths, telemetry, docs
#1204 (fix/warehouse-store-path-resolution, merged 1caa234) shipped the core
path-resolution fix but merged with only 2 of 47 review threads addressed. This
recovers the real bugs and finishes the incomplete P1 left behind.
Recovered from an orphaned agent worktree, re-applied and re-verified here:
- drivers-e2e.test.ts: three bare connect({ type: "duckdb" }) calls threw
under #1204's new requireStorePath() guard, so probeDuckDB() always
self-caught and 39 of 50 tests in the file silently skipped even with the
duckdb binding installed. Fixed by passing path: ":memory:". Verified
independently: 11 pass/39 skip -> 36 pass/14 skip.
- file-store.ts isLocalFilePath: the scheme-exclusion regex matched any
"2+ letter prefix + colon", misreading a local filename shaped like
data:warehouse.duckdb as a remote scheme. Narrowed to real scheme://
URIs plus DuckDB's specific non-slash extension schemes (md:,
motherduck:, ducklake:). Added a regression unit test.
Completed the incomplete P1 (absoluteFileUriPath() was written but never
wired into assertStoreExists, so behavior was unchanged on main):
- Wired absoluteFileUriPath() into assertStoreExists so a missing
*absolute* file: URI now fails loudly instead of opening silently empty
— the exact bug class #1204 exists to fix. Relative file: URIs are
deliberately left alone (tracked separately as #1209). Added tests for
both.
Remaining live review threads, fixed with tests where testable:
- registry.ts resolveStorePaths: POSIX path.isAbsolute() doesn't
recognize C:\..., so a shared/migrated Windows config path got mangled
by path.resolve. Fixed with path.isAbsolute() || path.win32.isAbsolute().
By-inspection only — no Windows CI.
- warehouse-add.ts: tool description said a relative path resolves
"against the directory of the config that declares it"; Registry.add()
actually resolves against projectRoot() at add-time regardless of where
it's persisted (the global config). Description corrected to match.
- sql-execute.ts: SQL fingerprint telemetry was emitted only on the
success path, so failed executions (including the new error-surfacing
branch) never got fingerprinted — biasing telemetry away from failures.
Extracted a shared emitSqlFingerprint() helper and call it from all
three outcomes (success, result-shaped error, thrown exception).
- docs/configure/warehouses.md: still said path was optional/omittable
for DuckDB and SQLite in-memory; requireStorePath() now rejects that.
Corrected in both the DuckDB and SQLite sections.
- file-store.ts assertStoreExists: fs.existsSync is also true for a
directory at that path, which would have let a misconfigured directory
path through to a confusing driver-level error instead of this guard's
clear one. Added an existsAsFile check.
Out of scope: the registry cross-tenant-scoping P1 (registry.ts:80/:175,
the process-global loaded state) is tracked separately as #1237 and needs
its own design PR — not attempted here.
Gates: bun test packages/drivers/ packages/opencode/test/altimate/ green
(5007+317 pass, 0 fail), bun turbo typecheck 13/13, marker check
--base origin/main --strict clean (no upstream-shared files touched),
prettier clean on all newly-written content.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VqnuBDGkh1ZT65Ti7e6DHZ
* fix(drivers): address #1238 review — directory/create ordering, file: URI slashes, Windows paths, telemetry mislabel, post-probe failure
Follow-up to #1238's own review round (8 threads, all on the new code that PR
added). Verified each against current code before acting; fixed the real bugs
with tests, replied with reasoning on the one genuine design call.
- file-store.ts: `create: true` bypassed the new directory check entirely,
since `if (allowCreate) return` ran before it — a directory path with
`create: true` reached the driver instead of getting this guard's clear
error. Extracted `rejectIfDirectory()` and moved it before the `allowCreate`
bypass in both the plain-path and `file:` URI branches, since neither engine
can create a database at a path that's already a directory.
- file-store.ts `absoluteFileUriPath`: the leading-slash check was bounded to
1-3 slashes, so `file:////mnt/share/warehouse.duckdb` (UNC-style, 4+
slashes) was treated as relative and bypassed the existence guard. Verified
`fileURLToPath` handles any number of leading slashes without throwing;
widened the check to `/^\/+/`.
- file-store.ts `isLocalFilePath`: the `scheme://` regex accepted a
single-character scheme, so a doubled-slash Windows path like
`C://data/warehouse.duckdb` matched it exactly like `s3://...` and was
misclassified as remote. No real scheme is a single letter; require 2+
characters before `://`.
- sql-execute.ts: the previous round's "fingerprint on every outcome" fix
mislabeled the catch block. `sql.execute` never throws for a
connection/query failure — it returns a result carrying `error`, already
fingerprinted on the result-error branch. The catch block only fires when
the query never reached a warehouse at all (e.g. dispatcher down), so
fingerprinting it there folded "never executed" into a signal meant to
measure "executed SQL", re-biasing the telemetry in the opposite direction.
Removed the catch-block emission; kept it on success + result-error only.
- drivers-e2e.test.ts: if DuckDB setup failed after the availability probe
already passed, every test's `if (!duckdbReady) return` guard reported a
pass instead of a failure — the same vacuous-green class as the false-skip
bug, one layer down. Extracted `connectWithRetry()`, which now throws (with
the underlying error) once retries are exhausted instead of swallowing it;
`beforeAll` no longer catches that throw, so a genuine post-probe failure
now fails the whole describe block. Added a standalone unit test for the
helper that runs independent of real DuckDB availability.
Not fixed — genuine design call, replied with reasoning, left open: a custom
DuckDB extension using an unlisted bare `scheme:` form (e.g. `acme:catalog`)
is no longer forwarded, because narrowing the bare-scheme exclusion to a
closed list (to fix the `data:warehouse.duckdb` false-positive from the prior
round) is in direct, unavoidable tension with forwarding arbitrary unknown
bare schemes — nothing in the syntax alone can tell them apart.
Gates: `bun test packages/drivers/` 323/323 pass, `bun test
packages/opencode/test/altimate/` 5009/5009 pass (653 skip, unrelated),
`bun turbo typecheck` 13/13, marker check `--base origin/main --strict`
clean, prettier clean on every newly-written/substantially-edited file.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VqnuBDGkh1ZT65Ti7e6DHZ
* docs(drivers): record the bare-scheme-vs-local-filename decision (#1238 last thread)
Documents the maintainer decision on #1238's remaining open thread
(file-store.ts:61 — narrowing the bare-scheme exclusion to a closed list
broke forwarding for an unlisted custom DuckDB extension's bare-scheme
target). Decision: accept the closed-list default.
- file-store.ts: expanded the comment at NON_SLASH_REMOTE_SCHEMES to state
the fundamental ambiguity (a bare word:target cannot be told apart
syntactically from a local filename with a colon), why the closed list was
chosen over the broad heuristic (local filenames with colons are the common
case; known extensions are enumerable), and the escape hatch (use the
extension's scheme:// form, or extend the list when a new extension is
adopted).
- docs/configure/warehouses.md: new note in the DuckDB section explaining
bare word:target values are treated as local files unless the prefix is one
of the recognized bare schemes (md:, motherduck:, ducklake:).
- docs/drivers.md: one-sentence pointer to the same rule alongside the
existing file-backed-driver path notes.
Gates: packages/drivers file-store-guard tests 27/27 pass, bun turbo
typecheck 13/13 (forced, 0 cached), marker check --base origin/main --strict
clean, prettier clean on file-store.ts (the two docs files were already
unformatted on origin/main before this change, left as-is).
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VqnuBDGkh1ZT65Ti7e6DHZ
* fix(drivers): resolve #1238's round-3 threads — connector leak, error identity, fingerprint-on-format-throw, de-scope telemetry
Fixes the 3 real bugs the round-3 review caught, and de-scopes the SQL
fingerprint telemetry change per plan (approved by Anand).
Bug fixes, with tests:
- drivers-e2e.test.ts: the DuckDB beforeAll's connectWithRetry attempt built
a connector (mod.connect()) and then opened it (c.connect()) as two
separate steps. If the open step failed after the connector object already
existed, the connector was dropped without close(), leaking the underlying
native handle on every failed retry. Extracted connectOrClose(), which
closes a half-open connector before rethrowing, and wired it into the
beforeAll attempt.
- drivers-e2e.test.ts: connectWithRetry's final throw was a plain
new Error(message), discarding the last attempt's original error object —
its stack, type, and any extra properties. Now thrown with
{ cause: lastError }, preserving the original through unmodified.
- sql-execute.ts: the fingerprint emission ran after formatResult(result),
so a genuinely-executed query went uncounted if formatting itself threw.
Moved the fingerprint emission before formatResult().
De-scope (the key decision): reverted sql-execute.ts's fingerprint telemetry
to fingerprint-on-success-only — the behavior that predates PR #1204. Three
review rounds converged on the same root problem: sql.execute's result-shaped
error (returned instead of throwing) is indistinguishable between "a
warehouse ran the query and it failed" and "the query never reached a
warehouse at all" (no warehouse configured, connector setup failed — see
connections/register.ts). Fingerprinting the result-error branch therefore
risked mislabeling never-executed queries as executed SQL — the opposite of
what the original #1204 comment asked for. Rather than build a
failed-execution-vs-never-executed taxonomy inside this cleanup PR, picked
the smaller, clearly-correct change: fingerprint only what's provably
executed (the success path). Removed the now-single-use emitSqlFingerprint
helper, inlining the fingerprint block back into the success path.
Follow-up issue #1242 captures the real fix: an
explicit executed-phase signal from the sql.execute handler itself, which
sql-execute.ts can branch on once it exists. Referenced from the code comment
at the de-scoped result-error branch and from the updated structural test.
Gates: packages/drivers + packages/opencode/test/altimate green (5013 + 323
pass, 0 fail), bun turbo typecheck --force 13/13 (0 cached), marker check
--base origin/main --strict clean, prettier clean on sql-execute.ts (the two
test files were already unformatted on origin/main before this PR touched
them, per established practice).
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VqnuBDGkh1ZT65Ti7e6DHZ
* docs(warehouses): fix self-contradicting sentence in bare-scheme note (#1238 round-4 thread)
The note added to explain the bare-word:target-vs-local-filename tradeoff
read as self-contradicting: it said a bare word:target is "treated as an
ordinary local filename... including the exact word prefix a DuckDB storage
extension uses," which the very next sentence then said IS treated as
remote for md:/motherduck:/ducklake:. Reworded in the intended, unambiguous
order: local-by-default, named exceptions (md:/motherduck:/ducklake:) are
remote, scheme:// forces remote for anything else.
docs/drivers.md's one-line pointer already used this order and doesn't have
the same confusion — left unchanged.
Gates: marker check --base origin/main --strict clean. This file is part of
the same pre-existing-formatting-drift set established earlier in this PR
(not reformatted, per established practice).
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VqnuBDGkh1ZT65Ti7e6DHZ
---------
Co-authored-by: Claude Opus 4.8 <[email protected]>
1 parent 1caa234 commit e6d3817
9 files changed
Lines changed: 556 additions & 46 deletions
File tree
- docs/docs
- configure
- packages
- drivers
- src
- test
- opencode
- src/altimate
- native/connections
- tools
- test/altimate
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
264 | | - | |
| 264 | + | |
265 | 265 | | |
266 | 266 | | |
267 | 267 | | |
| |||
283 | 283 | | |
284 | 284 | | |
285 | 285 | | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
286 | 295 | | |
287 | 296 | | |
288 | 297 | | |
| |||
461 | 470 | | |
462 | 471 | | |
463 | 472 | | |
464 | | - | |
| 473 | + | |
465 | 474 | | |
466 | 475 | | |
467 | 476 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
197 | | - | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
198 | 201 | | |
199 | 202 | | |
200 | 203 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
18 | 47 | | |
19 | 48 | | |
20 | 49 | | |
| |||
29 | 58 | | |
30 | 59 | | |
31 | 60 | | |
32 | | - | |
33 | | - | |
34 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
35 | 75 | | |
36 | 76 | | |
37 | 77 | | |
38 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
39 | 89 | | |
40 | 90 | | |
41 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
42 | 132 | | |
43 | 133 | | |
44 | 134 | | |
| |||
69 | 159 | | |
70 | 160 | | |
71 | 161 | | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
72 | 192 | | |
73 | | - | |
74 | | - | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
75 | 196 | | |
76 | 197 | | |
77 | 198 | | |
| |||
84 | 205 | | |
85 | 206 | | |
86 | 207 | | |
87 | | - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
88 | 228 | | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
89 | 232 | | |
90 | 233 | | |
91 | 234 | | |
| |||
0 commit comments