feat: bring simple-mode insert arity diagnostics to parity with advanced

A wrong-count simple-mode insert now shows the friendly per-column arity
message at typing time (instead of a bare "expected `,`/`)`") and is
blocked from dispatch at submit — unifying simple and advanced mode onto
the one ADR-0027 model (structural parse + ERROR diagnostic), where they
had diverged.

Grammar: a simple-mode-only arity gate (dsl_insert_value_list) routes a
wrong-count DSL insert tuple to the type-blind fallback so it matches
structurally and the per-tuple arity diagnostic fires. The gate is gated
to simple mode, so advanced behaviour is unchanged. count_tuple_values
and the target-column selection (insert_target_columns) are now shared
by both grammars.

Diagnostic: dml_insert_arity_diagnostics is mode-aware — advanced Form B
expects all columns; simple Form B/C expects the user-fillable columns
(serial/shortid auto-fill). It counts the DSL Form A role and scans the
keyword-less Form C tuple. New catalog keys name the fillable/auto split
and the all-auto-table case.

Submit: a wrong-count DSL insert now parses Ok + carries the ERROR
diagnostic, so a unified Ok-arm pre-flight (dsl_insert_count_mismatch_notes)
blocks dispatch and teaches; the previous Err-arm note retires.
advanced_alternative_note's gate now reads the validity verdict so it
still fires for the parse-Ok-with-error shape.

Docs: ADR-0036 Amendment 2 (+ README index) and requirements.md H1a.
This commit is contained in:
claude@clouddev1
2026-05-29 20:45:21 +00:00
parent 7cccf4eabb
commit 10e5197c19
16 changed files with 812 additions and 240 deletions
@@ -422,6 +422,67 @@ So the live highlight catches *numeric-shape* mismatches (`int`/`decimal`/
`bool`), not malformed dates. The column-type **hint** still shows for
every type.
## Amendment 2 — Simple-mode arity-diagnostic parity (issue #17, 2026-05-29)
Phase 3b (Amendment 1) introduced, for the **advanced** grammar, an
*arity-gating tuple lookahead* (`tuple_value_list`, `sql_insert.rs`):
a wrong-count `VALUES` tuple is routed to the type-blind fallback so it
**structurally matches** and the §8.1 arity diagnostic
(`dml_insert_arity_diagnostics`) fires its friendly *"N column(s) … M
value(s)"* message instead of the engine's raw error.
The **simple-mode DSL** insert (`data.rs` → `column_value_list`) never
had that gate: its value list is a fixed-length typed `Seq`, so a
wrong-count tuple **Mismatched** (parse error) and the arity diagnostic
never ran. Simple-mode learners — the primary audience — got a bare
`expected `,`/`)`` while advanced mode got the friendly message. Issue
#1 had papered over this with a *submit-time* teaching note bolted onto
the parse-error path; that workaround existed only because the
diagnostic couldn't fire in simple mode.
**This amendment brings the two modes onto one model.**
1. **Grammar (simple-mode only).** A `tuple_value_list`-style gate
(`dsl_insert_value_list`, `data.rs`) routes a wrong-count DSL insert
tuple to the shared type-blind `FALLBACK_VALUE_LIST`, so it matches
and the diagnostic fires. The gate is **gated to `Mode::Simple`**: in
advanced mode the DSL insert node stays strict (a non-SQL shape like
Form C must not spuriously match — advanced inserts are owned by
`sql_insert.rs`), so **advanced behaviour is byte-for-byte
unchanged**. `count_tuple_values` + the target-column selection
(`insert_target_columns`) are now shared by both grammars so the gate
and the typed slots never disagree.
2. **Diagnostic is mode-aware.** `dml_insert_arity_diagnostics` gains a
`mode` parameter. The expected count differs by mode **because the
modes' auto-fill differs** (the very distinction this ADR preserves):
- **advanced Form B** auto-fills nothing → expects **all** columns
(unchanged);
- **simple Form B/C** auto-fills `serial`/`shortid` (ADR-0018 §3) →
expects the **user-fillable** columns.
It also now counts the DSL Form A column role (`insert_first_item`)
alongside the SQL `insert_column`, and scans the simple-mode Form C
tuple (no `values` keyword). New catalog keys
`diagnostic.insert_arity_mismatch_form_b_simple` (names the fillable
*and* the auto-generated columns) and
`diagnostic.insert_arity_mismatch_all_auto` (every column
auto-generated).
3. **Unified submit pre-flight.** A wrong-count DSL insert now parses
`Ok` (so the typing-time diagnostic can fire), so dispatch is gated
by an Ok-arm pre-flight (`dsl_insert_count_mismatch_notes`) that
**blocks `ExecuteDsl`** and shows the teaching note — mirroring the
advanced Ok-arm pre-flight (`form_b_positional_count_mismatch_note`).
The issue #1 Err-arm note retires. The user-facing invalidity is the
ADR-0027 validity verdict (the `[ERR]` indicator), which reads the
diagnostic; the structural `InputState` is now `Valid` (it parses).
**Scope guard.** This is *arity-diagnostic UX parity only*. It does
**not** consolidate value-handling, execution, or auto-fill across modes
— the deliberate mode-distinctness this ADR was narrowed to preserve
stands. The count difference per mode is a *consequence* of that
distinctness, not a violation of it.
## See also
- ADR-0030 §4 / ADR-0033 §10 — the execute-path this ADR **augments**
+1 -1
View File
File diff suppressed because one or more lines are too long
+9 -4
View File
@@ -540,10 +540,15 @@ handoff-14 cleanup; 449 after B2/C2.)
names the schema-correct next token (`,` between values, `)`
after the last) instead of the type-blind close-paren, and so a
wrong-arity closed tuple surfaces the real parse error rather
than a misleading "submit with Enter"). A systematic pass is
still pending; simple-mode wrong-count tuples still get a generic
expected-token message rather than the friendly arity diagnostic
advanced mode shows (issue #17).
than a misleading "submit with Enter"; **issue #17 / ADR-0036
Amendment 2, 2026-05-29** then brought the §8.1 arity diagnostic
to **simple mode** at parity with advanced — a wrong-count DSL
insert (Form A/B/C) now fires the friendly *"N value(s) for
`col`…"* message at typing time, counted against the user-fillable
columns, with `serial`/`shortid` auto-fill named; new keys
`diagnostic.insert_arity_mismatch_form_b_simple` /
`diagnostic.insert_arity_mismatch_all_auto`). A systematic pass is
still pending.
- [ ] **H2** `hint` provides contextual help for the current
input or the most recent error.
- [ ] **H3** `help` provides general reference and per-command