From 7cccf4eabb853bf8a7bf5a4347c43dc1d82641ec Mon Sep 17 00:00:00 2001 From: "claude@clouddev1" Date: Fri, 29 May 2026 10:38:43 +0000 Subject: [PATCH] refactor: make completion-drop gate schema-aware for consistency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The candidates_at_cursor "input parses complete" gate — which suppresses re-suggesting a keyword the user just finished typing — used the schemaless parse while the rest of the completion path is schema-aware. A schemaless parse can call a type-/arity-wrong tuple complete. The divergence is benign today (the drop only removes a re-offered keyword equal to the partial, and schema divergence is confined to value type/arity, which never coincides), but parse with the schema so the gate matches the rest of the surface and stays correct if the grammar evolves. Strictly safe: can only ever retain a candidate the schemaless gate would have dropped, never the reverse. --- src/completion.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/completion.rs b/src/completion.rs index 5bb1580..28447f7 100644 --- a/src/completion.rs +++ b/src/completion.rs @@ -18,7 +18,7 @@ use crate::dsl::grammar::IdentSource; use crate::dsl::types::Type; use crate::dsl::walker::outcome::Expectation; use crate::dsl::{ParseError, parse_command}; -use crate::dsl::parser::parse_command_in_mode; +use crate::dsl::parser::parse_command_with_schema_in_mode; use crate::mode::Mode; /// Composite literal candidates whose lexed shape is more than @@ -333,7 +333,18 @@ pub fn candidates_at_cursor_with_in_mode( // `pk` at the end of `create table T with pk`. The // optional-suffix case (`save ` → `as`) is preserved // because there `partial_prefix` is empty. - let input_parses_complete = parse_command_in_mode(input, mode).is_ok(); + // + // Parse *with the schema* (not the schemaless `parse_command_in_mode`) + // so "complete" means the schema-aware grammar accepts it — the same + // consistency fix as issue #2's ambient-hint fallback. A schemaless + // parse can report a type-/arity-wrong tuple as complete and wrongly + // gate the drop on. Today the two agree at every position this drop + // can fire (the drop only removes a re-offered keyword == partial, + // and schema divergence is confined to value type/arity, which never + // coincides — see issue #18); schema-aware is the principled, latent- + // bug-proof choice and can only ever *retain* a candidate the + // schemaless gate would have dropped, never the reverse. + let input_parses_complete = parse_command_with_schema_in_mode(input, cache, mode).is_ok(); // Schema-aware probe: one walk yields both the expected set // and the table-context snapshot (ADR-0024 §Phase D