Repository navigation
A declared table reads what is on disk when each query runs - #1577
Merged
Merged
Conversation
8 tasks done
# Conflicts: # docs/reference/sdk.md # packages/rust/src/lib.rs # packages/ts/napi/src/lib.rs # packages/ts/src/dirsql.ts
thekevinbot
marked this pull request as ready for review
November 4, 2026 17:42
This was referenced Nov 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1572
Restart of #1573, red first. Commit 1 (
d4187d13) holds only tests. The fix is54a009cb, then a merge ofmainto resolve the bind-params conflict (#1576/#1578).What changes
A query on a long-lived
DirSQLreads what is on disk when it starts, in Rust, Python and TypeScript. Before reading, it walks each named table's glob, stats every match, re-reads each file whose stat moved or that changed within the last two seconds, and drops the rows of files that are gone. The row events those re-reads produce reachwatch()streams and the next poll, once each.query()/queryOrdered()run the re-reads on the JS thread (whereonFilecan run) through a newread_changes(), then send the SQL to the threadpool.watch()stream or poll.dirsql query: unchanged; it still reads the index as built.Red run (commit 1, tests only)
--no-fail-fast): all 35 new Rust tests fail on stale rows. Examples:left: [] right: ["c0"],left: ["c0"] right: ["e0"], and an orphaned-child query returningOk([{"name": "alpha"}]).a_query_over_an_orphaned_child_fails_as_the_build_would(the query returned stale rows instead of the FK error).-x, so CI shows only the first failure:it_reads_every_create,assert [] == ['c0']. Locally, all 16 new binding tests failed on main.expected [] to deeply equal ['c0']andexpected ['start'] to deeply equal ['e0']).Local e2e on the unfixed build
tests/e2e/fresh_declared_repros_test.py): 5 failed, 1 passed.it_reads_a_file_written_after_readyandit_reads_a_create_an_edit_and_a_delete;it_is_read_by_the_next_query_and_streamed_once;it_reads_every_write_before_it;it_reads_a_create_with_a_watch_consumed.tests/e2e/fresh-declared-repros.test.ts): the same 5 failed and the path-table test passed.Tests per tier
foreign_keys.rsa_query_before_any_watcher_hands_its_row_events_to_the_first_poll), 1 added (read_changes_reads_the_disk_with_fresh_reads_off)Known limits
onFilere-reads run on the JS thread, so they block the event loop for that time.docs/reference/sdk.md).writereturns, and the 4 open-handle tests were red before the fix.Green run (897b2b5)
All 75 checks pass, including mutation on every language and the CI Gate.
E2E Verification
Run on the fixed build after merging
main(501e509).testing-conventions e2e atteston the e2e files a declared table can reach: declared_table_name, fresh_declared_repros, on_file_query, use_case_{dossier,join,notebook,transcripts}, frontmatter/jsonl parse speed, fanout, plugin_discovery, plugin_extension_discovery, extension_package, server_speed, query_contract, repl_interactive, watch_speed, sigint_interrupt.just test-e2e,-x): 32 passed, then it stopped on the path-table glob speed case./docs/(median 1.18x vs rg, host load 11.3).just e2e-attest-ts(pnpm test:e2e), 25 passed (8 files), including the 6 fresh-declared repros.cargo test -p dirsql --features cli, 2255 passed, 0 failed.