grammar+walker: 3j — shared insert/update/delete entry words (ADR-0033 §2 / Amendments 1 & 3)

Wire `insert`/`update`/`delete` as shared DSL/SQL entry words through the
category-grouped dispatcher (ADR-0033 Amendment 1): the Advanced SQL nodes
move off the dev words (`sqlinsert`/`sql_update`/`sql_delete`) to the real
keywords, registered alongside the Simple DSL nodes. Remove the dev-word
scaffold; collapse build_sql_{insert,update,delete} to source.trim();
de-duplicate the two REGISTRY entry-word listing sites.

Dispatch model (ADR-0033 Amendment 3, written this round):
- A command is the mode-rooted grammar-path outcome; identity is intrinsic.
  Advanced mode tries SQL first, falling back to the Simple DSL command when
  no SQL branch matches a token (`delete … --all-rows` falls back;
  `update … --all-rows` does not — the SET expression absorbs it, harmless
  since the engine treats `--all-rows` as a comment).
- Simple mode commits the DSL candidate for a shared word, surfacing the real
  DSL error; bare "this is SQL" is reserved for SQL-only entry words
  (`select`/`with`). A content rejection on the SQL candidate (internal
  table) is committed, never masked by the DSL fallback.

Combined DSL-error + advanced-SQL pointer (ADR-0033 Amendment 3): a Simple-mode
definite DSL error that would run as SQL in advanced mode gains the
`advanced_mode.also_valid_sql` suffix — in the live hint (ambient_hint_in_mode)
and on submit (dispatch_dsl), via the shared advanced_alternative_note — so the
actionable DSL fix and the mode pointer coexist (submit covers constructs that
surface only on submit, e.g. `delete … returning`).

Internal-table rejection symmetrised (/runda finding B, ADR-0030 §6): the DSL
data-command target slots (insert/update/delete/show data/show table) gained
reject_internal_table, so `__rdbms_*` tables are refused in Simple mode too —
previously only the advanced SQL grammar rejected them.

Mode-awareness: classify_input_with_schema_in_mode and
invalid_ident_at_cursor_in_mode stop leaking the advanced SQL view into
simple-mode hints for shared words.

Tests: dev-word inputs migrated to the real words (advanced); DSL grammar /
completion / phase-D / db tests parse in Simple mode (the DSL surface); replay
keeps its advanced-mode model (one stale assertion fixed); dispatcher routing,
combined-pointer, and internal-table tests added. Suite 1626 pass / 0 fail /
1 ignored; clippy --all-targets -D warnings clean.

Defer M4 (execution-time mode side-channel; tracked in requirements.md) to its
own ADR.
This commit is contained in:
claude@clouddev1
2026-05-23 21:13:39 +00:00
parent c16196fc7f
commit d5c7f63513
22 changed files with 956 additions and 314 deletions
+21 -7
View File
@@ -13,13 +13,14 @@
#![allow(dead_code, unreachable_pub)]
use rdbms_playground::completion::{
Completion, SchemaCache, TableColumn, candidates_at_cursor,
Completion, SchemaCache, TableColumn, candidates_at_cursor_in_mode,
};
use rdbms_playground::dsl::parser::parse_command_with_schema;
use rdbms_playground::dsl::parser::parse_command_with_schema_in_mode;
use rdbms_playground::dsl::types::Type;
use rdbms_playground::input_render::{
AmbientHint, InputState, ambient_hint, classify_input_with_schema,
AmbientHint, InputState, ambient_hint_in_mode, classify_input_with_schema_in_mode,
};
use rdbms_playground::mode::Mode;
pub mod insert_form_a;
pub mod insert_form_b;
@@ -174,11 +175,24 @@ pub struct Assessment {
}
/// Assess the typing surface at the given cell.
///
/// The whole typing-surface matrix exercises the **DSL** surface
/// (insert Forms A/B/C, `update`/`delete` with `where` / `--all-rows`,
/// the DSL expression grammar, DDL, app commands) — which is the
/// **Simple-mode** surface (ADR-0003). So every facet here is computed
/// in Simple mode, and consistently so: `ambient_hint` already
/// defaults to Simple, and the others are pinned to Simple via their
/// `*_in_mode` variants. This matters since sub-phase 3j made
/// `insert`/`update`/`delete` shared entry words (ADR-0033
/// Amendment 3): in Advanced mode those route to the SQL grammar
/// (different completion / hints / parse), whereas the DSL forms this
/// matrix documents live in Simple mode. The SQL surface is covered
/// by `tests/sql_*.rs` and the advanced-mode walker diagnostics.
pub fn assess(input: &str, cursor: usize, schema: &SchemaCache) -> Assessment {
let state = classify_input_with_schema(input, schema);
let hint = ambient_hint(input, cursor, None, schema);
let completion = candidates_at_cursor(input, cursor, schema);
let parse_result = match parse_command_with_schema(input, schema) {
let state = classify_input_with_schema_in_mode(input, schema, Mode::Simple);
let hint = ambient_hint_in_mode(input, cursor, None, schema, Mode::Simple);
let completion = candidates_at_cursor_in_mode(input, cursor, schema, Mode::Simple);
let parse_result = match parse_command_with_schema_in_mode(input, schema, Mode::Simple) {
Ok(cmd) => Ok(command_kind_label(&cmd)),
Err(e) => Err(parse_error_label(&e)),
};