Control channel: a per-request param_check level, applied and confirmed by the app (#9184) (#9185)

* claim: #9184

* Control channel: a request's own param_check level, applied and confirmed by the app (#9184)

`engine.execute`, `engine.batch` and `engine.script` take an optional
`param_check: "off"|"warn"|"strict"` in their params. The app runs the
request at that level through the same `run_checked` path and batch
preflight a headless session uses, puts its own level back, and every
reply says the level it ran at as `param_check` beside `ok`. A command
that switches designs keeps the app's level; any other word is refused.
Readings and exports answered on a copy off the window thread keep the
level too.

`control.capabilities`, answered at once on the control-server thread,
lists what the channel does beyond the methods every version has:
`{"param_check": ["off", "warn", "strict"]}`. An older app answers
"unknown method".

The MCP bridge asks it once per connection. When the app lists the
level, every call and batch goes with it and the app checks against its
own commands; otherwise the bridge checks before sending, as #9073 does.
At strict, a reply that doesn't say the app checked the call is an error,
and the next calls are checked by the bridge. Also: `add_param_warnings`
takes the reply by `&mut`, and `with_param_check` sits beside
`Remote::new`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Control channel: a design-switching command is checked at the request's level

Review fixes for #9184. `component.edit_in_place`, `component.finish_edit`,
`view.next_tab` and `view.previous_tab` ran at the app's own level and
echoed `off`, so a misspelt call went through at strict. They now have
their parameters checked at the request's level before they run (and
still run at the app's own level, as each design keeps its own), and the
reply echoes the requested level. The MCP bridge at strict now requires
the echo to match its level, not just to be there. `param_check` is read
only by `engine.execute`, `engine.batch` and `engine.script`; other
methods ignore it. The off-thread test now shows the design change
computing off the window thread before it is refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Rick MorgansandClaude Opus 5.5 authored and GitHub committed 2026-10-30 07:24:41 +00:00
1 parent 5d6c5bab39
commit 92af4a21c8
10 files changed
+415 -34

No files matched your search

+12
View File
@@ -28,6 +28,9 @@ pub enum ParamCheck {
}
impl ParamCheck {
/// Every level, least checking first.
pub const ALL: [ParamCheck; 3] = [ParamCheck::Off, ParamCheck::Warn, ParamCheck::Strict];
pub fn parse(s: &str) -> Option<ParamCheck> {
match s.trim().to_ascii_lowercase().as_str() {
"off" => Some(ParamCheck::Off),
@@ -36,6 +39,15 @@ impl ParamCheck {
_ => None,
}
}
/// The level's word, as [`ParamCheck::parse`] reads it (the control channel's `param_check`).
pub fn name(self) -> &'static str {
match self {
ParamCheck::Off => "off",
ParamCheck::Warn => "warn",
ParamCheck::Strict => "strict",
}
}
}
/// The JSON Schema (2020-12) of what deserializes into `T`: a command's parameters.
+7
View File
@@ -361,6 +361,13 @@ fn the_level_survives_a_new_design() {
assert_eq!(s.scratch().param_check, ParamCheck::Strict);
}
#[test]
fn a_level_is_read_back_from_its_name() {
for level in ParamCheck::ALL {
assert_eq!(ParamCheck::parse(level.name()), Some(level));
}
}
/// Whether `v` conforms to `node` of the schema `root`, for the keywords these schemas use
/// apart from `pattern`: `type`, `properties`, `required`, `additionalProperties: false`,
/// `items`, `minItems`, `maxItems`, `uniqueItems`, `enum`, `minLength`, `maxLength`, `minimum`,