Repository navigation
Description
Summary
A training-mode root flag placed before a subcommand is accepted and silently ignored by every subcommand that does not declare that flag. The consequential case is --dry-run: forgelm --dry-run approve RUN_ID really approves the run, promotes the staged model and appends a human_approval.granted event to the append-only audit log.
Found while reviewing #1012 (the fix for #414). It is a separate concern: #414 was about root flags that a subcommand re-declares and then clobbers (purge, quickstart, doctor, deploy, cache-*). This issue is about root flags that no subcommand declares at all.
Observed
Verified on development (b8d2643); #1012 changes only the eight re-declared flags and does not touch these paths. Everything below was run in a scratch directory.
# synthetic pending run: audit_log.jsonl with one human_approval.required event + final_model.staging/
$ forgelm approvals --pending --output-dir D # run-x is listed as pending
$ forgelm --dry-run approve run-x --output-dir D # exit 0
Approved run run-x; final model promoted to D/final_model
# D/final_model now exists and audit_log.jsonl ends with human_approval.granted
$ forgelm --dry-run ingest doc.txt --output out.jsonl # exit 0, out.jsonl is written
$ forgelm ingest doc.txt --output out.jsonl --dry-run # argparse: "unrecognized arguments: --dry-run" (exit 2)
So the same flag is refused loudly after the subcommand and swallowed silently before it.
Which root flags a subcommand actually reads (derived from the parser and the dispatch table):
| Root flag | Subcommands that honour it | Everything else |
|---|---|---|
--dry-run |
purge, quickstart (both declare it) |
ignored: approve, reject, approvals, audit, cache-models, cache-tasks, chat, deploy, doctor, export, ingest, reverse-pii, safety-eval, verify-* |
--fit-check, --merge, --generate-data, --compliance-export, --benchmark-only, --resume, --resume-from, --stage, --force-resume, --input-model, --wizard, --wizard-start-from |
none (no subcommand declares them) | ignored by all |
The CLI reference lists these under "Top-level flags (training mode — used with --config)", so most of them are not promised to work with a subcommand. The problem is that nothing says so at run time, and for --dry-run the silent acceptance turns a rehearsal into the real action.
Already tracked elsewhere (out of scope here)
- Root
--offlineis inert for every subcommand exceptdoctorandquickstart: CR-A05-009 in [Wave 3] Medium — Module sweep: CLI framework: parser, dispatch, exit-code contract, logging #542, and Phase 16 step S7 ([Phase 16] S7 — CLI and wizard boundary: policy declared must be policy enforced #893). - Root
--configignored bychatand other subcommands that do not declare it: CR-A05-054 in [Wave 4] Low/info — Module sweep: CLI framework: parser, dispatch, exit-code contract, logging (part 2/3) #654.
A fix for this issue should reuse the same mechanism as those two so the three do not diverge.
Expected
One of the following; a maintainer decision is needed before implementing:
- Fail closed. Refuse, with a usage error before dispatch, a root flag that the selected subcommand neither declares nor shares. Derive the allowed set from the parser itself (the subparser's own dests plus the shared
--quiet/--log-level/--output-format), not from a hand-kept table. This also makes both flag positions behave the same. - Warn at WARNING level that the flag is ignored for that subcommand.
- Honour
--dry-runin each state-changing subcommand. Much larger, and each subcommand needs its own dry-run semantics.
Option 1 is the safest minimum for --dry-run, because a safety flag should be either honoured or refused, never dropped. The exit code of a usage error must follow docs/standards/error-handling.md; note that argparse's own usage errors currently exit 2, the same code as a training error.
Acceptance criteria
- The chosen behaviour is recorded in this issue before code is written, including how it relates to the
--offlineand--configwork in [Phase 16] S7 — CLI and wizard boundary: policy declared must be policy enforced #893 / [Wave 4] Low/info — Module sweep: CLI framework: parser, dispatch, exit-code contract, logging (part 2/3) #654. - Regression tests patch
sys.argvand callparse_args/mainonly (no GPU, network or model downloads, and never a real approval): at least--dry-runwithapprove,reject,ingestandexport, one training-only flag such as--fit-check, and the flags that must stay accepted (--quiet,--log-level,--output-format, and--dry-runwithpurge/quickstart). -
--helptext is unchanged except where the decision requires it;tools/check_cli_help_consistency.py --strictandtools/check_cli_exit_code_prose.py --strictpass. - A
### Fixedor### Changedentry under## [Unreleased]inCHANGELOG.md. - The CLI reference and its Turkish mirror say that training-mode flags apply only to a
--configrun.
Pointers
forgelm/cli/_dispatch.py(_main_inner,_dispatch_subcommand)forgelm/cli/_parser.py(root flag declarations, per-subcommand_add_*_subcommand)docs/usermanuals/en/reference/cli.mdanddocs/usermanuals/tr/reference/cli.md("Top-level flags")
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTodo
Activity
[-]Training-mode root flags (notably --offline) are silently ignored when a subcommand is given[/-][+]Training-mode root flags are silently ignored by subcommands: `forgelm --dry-run approve` approves for real[/+]cemililik commentedon Oct 18, 2026
Triage notes
Scope. On a closer look the
--offlineand--configparts of the original description are already tracked (CR-A05-009 in #542 and Phase 16 S7 in #893; CR-A05-054 in #654), so they are now listed as out of scope. What was not tracked, and is what this issue is about now, is--dry-runand the other training-mode flags being accepted and ignored by subcommands that do not declare them. The title and description were rewritten accordingly. I found no existing finding forforgelm --dry-run approveor the other state-changing subcommands (searched the CLI, operator-command, GDPR/approval, post-training, ingestion and verify findings).Severity: medium (project 5 Severity = Medium, Wave = W3). Reasoning, so it can be challenged:
purge/quickstartadvertise their own--dry-runin--help, whereas the subcommands affected here do not, the CLI reference files the flag under "training mode", and the after-subcommand position already fails loudly.severity: high/wave: 1; nothing else changes.Not a good first issue. The behaviour needs a maintainer decision first (reject vs warn vs per-subcommand dry-run), and it should be designed together with the central seam planned in #893 so the
--offline,--configand--dry-runhandling stay consistent.Not labelled
security. No privilege boundary is crossed; the operator runs the subcommand themselves.Project 5 fields set: Theme W3 Security contract (silent-failure family, as #651), Kind Code + docs, Area cli, Size S.