Related roadmap: #214
Problem
base_cli_declare says it parses every row before mutating the model, but the first pass validates only row structure and required columns. It calls base_cli_model_init before applying commands, options, and positionals. A semantic error in a later row therefore destroys a previously valid model and publishes a partially built replacement.
This makes generated/declarative CLI reloads non-atomic and leaves callers with state that does not match either the old or requested declaration.
Evidence
Reviewed on main at 63753047312cd5c189600ed71597faceae0f5d8e.
Focused reproduction:
- Initialize a model named
demo with name original and an old command.
- Call
base_cli_declare demo with a new model row, a new command, and a late option row using an invalid type.
- The call returns status 2.
Actual state after failure: the model name is the replacement value, the old command is gone, and the new command is present.
The mutation begins at lib/bash/cli/lib_cli.sh:465; late semantic validation occurs while rows are applied at lines 466-504.
Acceptance criteria
Related roadmap: #214
Problem
base_cli_declaresays it parses every row before mutating the model, but the first pass validates only row structure and required columns. It callsbase_cli_model_initbefore applying commands, options, and positionals. A semantic error in a later row therefore destroys a previously valid model and publishes a partially built replacement.This makes generated/declarative CLI reloads non-atomic and leaves callers with state that does not match either the old or requested declaration.
Evidence
Reviewed on
mainat63753047312cd5c189600ed71597faceae0f5d8e.Focused reproduction:
demowith nameoriginaland anoldcommand.base_cli_declare demowith a new model row, a new command, and a late option row using an invalidtype.Actual state after failure: the model name is the replacement value, the old command is gone, and the new command is present.
The mutation begins at
lib/bash/cli/lib_cli.sh:465; late semantic validation occurs while rows are applied at lines 466-504.Acceptance criteria
base_cli_declareleaves every registry entry for an existing model byte-for-byte unchanged.