-
Notifications
You must be signed in to change notification settings - Fork 134
feat(workspace): route warehouse tools through the bound workspace's engine #1168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
ralphstodomingo
wants to merge
4
commits into
feat/workspace-engine-overlay
Choose a base branch
from
feat/workspace-precedence-v2
base: feat/workspace-engine-overlay
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ec3489c
feat(workspace): route warehouse tools through the bound workspace's …
211c5bb
chore: wrap the native-tool description hooks in start/end markers; f…
33285f5
fix: undetermined outcomes always carry a stated reason in the result
347db29
test(workspace): prove the stale-connection guard and the attribution…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MAJOR — time-of-check/time-of-use between the routing decision and the executed target
This pin, and the check at
:497-501, close the window across the dbt await. But the routing decision was made earlier and elsewhere:Precedence.check()→resolveDefaultTarget(register.ts:139-160) does its ownRegistry.list().warehouses[0]read from inside the tool body, and the handler then resolves the target again, independently. Theawait Dispatcher.call(...)boundary and the handler's own awaits are enough for a queued concurrent mutation to land in between, so the comment's claim that this makes the decided and executed connection "the same by construction" is stronger than what the pin actually does.Concretely:
warehouse.removedrops it;sql.explainorschema.inspectthen picks the newly-first Snowflake connection and executes it locally, despite Snowflake being shadowed — unaudited execution on a served connection, the exact outcome this design exists to prevent;warehouse.addcan replace that name with a served type aftercheck()read it. The handler pins the already-replaced type and sees no subsequent change, so this check cannot detect that window.Note also that this pin exists only in
register("sql.execute")—sql.explain(:552-570) andschema.inspect(:678-691) have no equivalent guard at all.Fix: make the decision and the target acquisition atomic — move the precedence check into the handler after it pins the target (passing
sessionIDthrough), or return a lease{name, canonicalType, generation}that handlers must revalidate. Apply it to all three ops, explicit names included.Related, same seam:
Precedence.check()'sawait import("../native/connections/register")(precedence.ts:586-588) has no try/catch, andcheck()is called outside the surroundingtryin all three tool bodies — so a throw there takes outsql_execute,sql_explainandschema_inspecttogether instead of failing open.default-target.test.ts:123-151does not prove its stated invariant: it calls the dispatcher directly, omitting the preceding precedence decision, which is where the race actually is.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partially addressed in
81d5e402f: the overclaiming comment is softened to what the pin guarantees, andcheck()now fails open with a stated reason on any internal throw (covers the uncaught lazy import ahead of all three tool try blocks). The pin extension to explain/inspect and the atomic-lease design are recorded residuals.