mirror of
https://github.com/kevwillow/scaffold.git
synced 2026-10-20 08:37:34 +02:00
Adds a per-field type rule table and a `_check_preset_value_type` helper
that runs in the schema-aware branch of `validate_preset`. Hand-crafted
or LLM-generated presets that previously slipped past structural checks
and produced silently-wrong form state via Python's bool/int conflation
or string-into-multi_enum coercion are now rejected at validation time
with a specific message.
D2b: `{"--verbose": "false"}` for a boolean flag now errors instead of
silently checking the box (`bool("false")` is True).
D2c: `{"--ports": "80,443"}` for a multi_enum flag now errors instead
of silently producing an empty selection.
Backward compatibility: when `tool_data` is not passed, behaviour is
unchanged — all existing structural checks still fire identically.
Repeatable booleans (e.g. rsync `--verbose`, ssh `-v`) serialize as int
(the QSpinBox repeat count), so the helper takes the full arg dict and
allows `(bool, int)` for `repeatable=true` boolean fields.
The `default_presets/rsync/rsync_selective_copy_excludes.json` shipped
preset stored a list value for a non-multi_enum string field, which the
GUI's `_set_field_value` could never cleanly apply (`str(value)` on a
list produced garbage). Moved the extra patterns to `_extra_flags` so
the preset round-trips correctly under the new rule.
§202 in test_functional.py covers booleans, integers, floats, multi_enum,
all string-shaped types, backward compatibility (with and without
tool_data), unknown-key handling, subcommand-scoped keys, the
repeatable-boolean exception, helper-level smoke, and a shipped-preset
round-trip guard against breaking the bundled examples.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>