Skip to content

Training-mode root flags are silently ignored by subcommands: forgelm --dry-run approve approves for real #1016

Open

Description

@cemililik

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)

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:

  1. 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.
  2. Warn at WARNING level that the flag is ignored for that subcommand.
  3. Honour --dry-run in 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 --offline and --config work 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.argv and call parse_args / main only (no GPU, network or model downloads, and never a real approval): at least --dry-run with approve, reject, ingest and export, one training-only flag such as --fit-check, and the flags that must stay accepted (--quiet, --log-level, --output-format, and --dry-run with purge / quickstart).
  • --help text is unchanged except where the decision requires it; tools/check_cli_help_consistency.py --strict and tools/check_cli_exit_code_prose.py --strict pass.
  • A ### Fixed or ### Changed entry under ## [Unreleased] in CHANGELOG.md.
  • The CLI reference and its Turkish mirror say that training-mode flags apply only to a --config run.

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.md and docs/usermanuals/tr/reference/cli.md ("Top-level flags")

Activity

  1. added
    bug
    area: cli
    needs-triage
    on Oct 18, 2026
  2. removed
    needs-triage
    on Oct 18, 2026
  3. changed the title [-]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[/+] on Oct 18, 2026
  4. added
    severity: medium
    wave: 3
    on Oct 18, 2026
  5. cemililik commented on Oct 18, 2026

    @cemililik
    CollaboratorAuthor

    Triage notes

    Scope. On a closer look the --offline and --config parts 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-run and 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 for forgelm --dry-run approve or 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:

    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, --config and --dry-run handling 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: clibugseverity: mediumwave: 3

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions