Skip to content

Route every CLI command explicitly and import handlers lazily - #164

Merged
ProfSynapse merged 2 commits into
feat/submodule-cloud-api-v1from
claude/cli-routing-fixes
Oct 2, 2026
Merged

ProfSynapse merged 2 commits into
feat/submodule-cloud-api-v1from
claude/cli-routing-fixes

Conversation

@ProfSynapse

Copy link
Copy Markdown
Owner

Summary

PR 3 of 5. Stacked on #163.

  • The parser advertised commands the router never handled. compute-losses, judge-sample, cloud-compare and download-experiment were accepted but unrouted, so they fell through to the interactive menu and hung non-interactive or agent callers. None had a working implementation, so all four are removed. Tools/judge_sample.py, an unfinished draft that never imported, is deleted.
  • The router is now a COMMAND_ROUTES table.
    • A command the parser accepts but that has no route exits 2 with COMMAND_NOT_ROUTED.
    • Only running with no command at all opens the interactive menu.
    • In --json mode, running with no command is an error.
  • Handlers are imported only when their command runs. Before this, one handler's module-level torch import broke list, eval, cloud-jobs and others in torch-less environments. Now a missing dependency affects only the command that needs it.
  • doctor: reports a torch that is installed but fails to import as a finding, instead of crashing.
  • compare-runs: finds its script from the engine root instead of the working directory.
  • New test: tests/cli/test_router_coverage.py (86 cases) checks every parser command against the route table, in both directions, and checks each handler target from source. It also runs doctor --json with torch blocked.

Test plan

🤖 Generated with Claude Code

https://claude.ai/code/session_013etFNjLuo22CCoQmUGYqCT


Generated by Claude Code

claude added 2 commits October 2, 2026 11:33
- Remove compute-losses, judge-sample, cloud-compare and download-experiment
  from the parser choices. They had no handler and fell through to the
  interactive menu, hanging non-interactive callers. judge_sample.py is an
  unfinished draft that does not import; the other three were never built.
- Replace the if-chain and bulk handler import in the router with a
  COMMAND_ROUTES table of lazily imported handlers. A command with no route
  now fails with COMMAND_NOT_ROUTED and exit code 2; only an invocation with
  no command opens the interactive menu.
- Import handlers per command so light commands (doctor, status, list, ...)
  no longer depend on torch via experiment_handler. A missing dependency is
  reported as HANDLER_IMPORT_ERROR for that command only.
- Doctor reports a broken torch install as a finding instead of crashing.
- compare-runs resolves Tools/compare_runs.py from the engine root rather
  than the current directory.
- Add tests/cli/test_router_coverage.py: every parser command must have a
  route, every route must name an existing handler, unrouted commands are
  refused, and doctor runs without torch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013etFNjLuo22CCoQmUGYqCT
The draft never imported (missing setup_logging), called process_sample
with the wrong keyword and wrote to an undefined path. Its CLI command was
already removed; generation-time judging lives in SynthChat.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013etFNjLuo22CCoQmUGYqCT
@ProfSynapse
ProfSynapse changed the base branch from claude/data-leakage-guards to feat/submodule-cloud-api-v1 October 2, 2026 23:28
@ProfSynapse
ProfSynapse merged commit 052eab2 into feat/submodule-cloud-api-v1 Oct 2, 2026
@ProfSynapse
ProfSynapse deleted the claude/cli-routing-fixes branch October 6, 2026 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants