fix: insert VALUES between-values hint points at comma not close-paren

The ambient-hint fallback in ambient_hint_core_in_mode parsed
schemalessly, so the type-blind grammar closed an `insert … values
(…)` tuple after the first value and the "Next:" hint pointed at `)`.
With a schema available the walk knows the remaining columns and the
correct next token is `,`. Parse the fallback with the schema cache so
the expected-token prose matches the rest of the (already
schema-aware) hint ladder.

Also corrects wrong-arity closed tuples where the schemaless parse
accepted the input and the hint said "submit with Enter" for a command
the schema-aware parse rejects — the hint now surfaces the accurate
error. Three typing-surface snapshots updated to match.

Docs: ADR-0022 Amendment 3 (+ README index) records the schema-aware
fallback; requirements.md H1a cites the hint-accuracy improvement.
This commit is contained in:
claude@clouddev1
2026-05-29 10:22:57 +00:00
parent abc9bb6d0f
commit fa5d0dc6da
7 changed files with 161 additions and 7 deletions
@@ -549,6 +549,44 @@ ordering; `order_by_after_sort_item_offers_direction`,
`create_table_after_column_spec_offers_constraints` lock the
trailing-optional fix. ~20 typing-surface snapshots re-baselined.
## Amendment 3 — Ambient-hint fallback parses with the schema (2026-05-29)
Amendment 1's "What changed" listed *the fallback
`parse_command_in_mode`* among the sub-calls threaded through the
active `mode`. That fallback (the bottom rung of `ambient_hint`'s
candidate-or-prose ladder, which produces the `ambient_complete` /
`ambient_expected` / `ambient_error_with_usage` prose) was
**schemaless** — it took the input and mode but not the `SchemaCache`,
even though every earlier rung (`input_diagnostics_in_mode`,
`hint_resolution_at_input_in_mode`, `candidates_at_cursor_in_mode`)
already ran schema-aware. That was an oversight, not a decision: the
ADR's whole intent is a schema- and mode-consistent hint surface.
The gap surfaced as a user-reported bug (issue #2). Between two values
of an `insert … values (…)` tuple, the type-blind (schemaless) grammar
closes the tuple after one value, so the expected-token prose pointed
at `)` when the schema-aware grammar — knowing the remaining columns —
expects `,`. The same schemaless parse also accepted wrong-arity closed
tuples as complete, so the prose read *"submit with Enter"* for an
input the schema-aware parse (and the on-submit path) rejects.
**Change:** the fallback rung now calls
`parse_command_with_schema_in_mode(input, cache, mode)`. The whole
ladder is now schema-consistent. No new walk — the call site already
held the `cache`; this swaps which parse function consumes it.
**What still holds:** the friendly arity diagnostic (ADR-0033 §8.1) is
checked at a higher rung, so where it fires (advanced-mode wrong-arity
tuples) it still wins over this fallback — locked by
`advanced_mode_wrong_arity_insert_keeps_friendly_diagnostic_over_fallback`.
The §13 one-walk-per-render posture is unchanged.
**Coverage:** `ambient_hint_between_values_points_to_comma_not_close_paren`,
`ambient_hint_after_last_value_points_to_close_paren`, the no-masking
guard above, and three re-baselined `typing_surface` snapshots
(`form_a_in_progress_one_value`, `form_b_too_few_values`,
`form_c_wrong_count`).
## Out of scope
Deliberately deferred to keep this ADR shippable as a single
+1 -1
View File
@@ -27,7 +27,7 @@ This directory contains the project's ADRs, recorded per
- [ADR-0019 — Friendly error layer (H1) and i18n message catalog](0019-friendly-error-layer-and-i18n.md)
- [ADR-0020 — Tokenization layer for the DSL parser](0020-tokenization-layer-for-the-dsl-parser.md)
- [ADR-0021 — Parser-as-source-of-truth for H1a (per-command usage in parse errors)](0021-parser-as-source-of-truth-for-h1a.md)
- [ADR-0022 — Ambient typing assistance: colour, hint panel, completion (I3 + I4)](0022-ambient-typing-assistance.md) — **Amendment 1 supersedes §12's simple-mode-only carve-out**: the unified mode-aware walker (ADR-0030/0031/0032) now speaks SQL, so advanced-mode ambient assistance is re-enabled. `ambient_hint_in_mode` + `hint_resolution_at_input_in_mode` + `expected_for_hint_snapshot` thread `Mode`; `render_hint_panel` calls ambient for all modes (no more advanced-mode `None`); the one-shot `:` sigil is stripped before the ambient walk. Fixes a live bug where advanced-mode SQL hinting/completion-preview were dead despite Phase 2 marking them green (validated at the engine layer, not the UI). Simple-mode gating, highlighting, and the §13 performance posture are unchanged; covered by an app-level render test plus ambient-layer regression locks; **Amendment 2 reverses the handoff-14 keywords-first candidate ordering** — schema identifiers (table/column/relationship names) now sort *before* keywords so a name the user would have to look up stays visible in the single-row, window-scrolled candidate line (keywords are learned over time; the `tok_identifier`/`tok_keyword` colour split marks the boundary); shipped with a `walk_repeated` fix that surfaces a list item's trailing optionals at a clean boundary (`order by Name ``asc`/`desc`, `select Name ``as`, `create table … Code(text) ``not`/`unique`/`default`/`check`; the `,` separator deliberately not surfaced); records a deferred two-line hint box for growing lists
- [ADR-0022 — Ambient typing assistance: colour, hint panel, completion (I3 + I4)](0022-ambient-typing-assistance.md) — **Amendment 1 supersedes §12's simple-mode-only carve-out**: the unified mode-aware walker (ADR-0030/0031/0032) now speaks SQL, so advanced-mode ambient assistance is re-enabled. `ambient_hint_in_mode` + `hint_resolution_at_input_in_mode` + `expected_for_hint_snapshot` thread `Mode`; `render_hint_panel` calls ambient for all modes (no more advanced-mode `None`); the one-shot `:` sigil is stripped before the ambient walk. Fixes a live bug where advanced-mode SQL hinting/completion-preview were dead despite Phase 2 marking them green (validated at the engine layer, not the UI). Simple-mode gating, highlighting, and the §13 performance posture are unchanged; covered by an app-level render test plus ambient-layer regression locks; **Amendment 2 reverses the handoff-14 keywords-first candidate ordering** — schema identifiers (table/column/relationship names) now sort *before* keywords so a name the user would have to look up stays visible in the single-row, window-scrolled candidate line (keywords are learned over time; the `tok_identifier`/`tok_keyword` colour split marks the boundary); shipped with a `walk_repeated` fix that surfaces a list item's trailing optionals at a clean boundary (`order by Name ``asc`/`desc`, `select Name ``as`, `create table … Code(text) ``not`/`unique`/`default`/`check`; the `,` separator deliberately not surfaced); records a deferred two-line hint box for growing lists; **Amendment 3 makes the ambient-hint fallback rung schema-aware** — Amendment 1's bottom-rung `parse_command_in_mode` was schemaless while every earlier rung was not, so between-values insert hints pointed at `)` (type-blind close) instead of `,` and wrong-arity closed tuples read "submit with Enter" for an input the schema-aware parse rejects (issue #2); now uses `parse_command_with_schema_in_mode`, no extra walk, with the friendly arity diagnostic still winning at its higher rung
- [ADR-0023 — Unified declarative grammar tree](0023-unified-grammar-tree.md) — direction (superseded for execution detail by ADR-0024)
- [ADR-0024 — Unified grammar tree: execution plan](0024-unified-grammar-tree-execution-plan.md) — **Accepted**, the executable spec — implemented (Phases AF; Phase F shipped "minimal", `parser.rs` retained as the router — see the ADR's Phase F implementation note)
- [ADR-0025 — Indexes](0025-indexes.md) — **Accepted** (**Amendment 1, 2026-05-25**: UNIQUE indexes admitted on the **advanced-mode** surface via `CREATE UNIQUE INDEX` — ADR-0035 §4d; the `IndexSchema.unique` flag round-trips through `project.yaml` with no new metadata table since the engine reports uniqueness natively; simple-mode `add unique index` stays deferred), `add index` / `drop index`, persistence, rebuild-table preservation, and items-list display (`C3` index portion + `S2`)