feat(minimal): finish client interface — lib/main split, CLI subcommands, test harness, stop - #612
Conversation
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe minimal CLI now lives in a library entrypoint with typed command dispatch, richer RPC error context, exposed daemon test harness APIs, and real integration tests that exercise the CLI against a running ChangesMinimal CLI library extraction and testing
Estimated code review effort: 4 (Complex) | ~60 minutes Poem
Note 🎁 Summarized by CodeRabbit FreeYour organization has reached its limit of developer seats under the Pro Plan. For new users, CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please add seats to your subscription by visiting https://app.coderabbit.ai/login.If you believe this is a mistake and have available seats, please assign one to the pull request author through the subscription management page using the link above. Comment |
|
WRT to the rebase conflict, minimal/minimal2 crates were moved, but you can get a clanker to fix it if you tell em that the minimal crate is now the mip crate and the minimal2 crate is now the minimal crate |
1920bd2 to
d29ec86
Compare
Rebase the minimal2 CLI work onto main, adapting to the crate rename (minimal2 → minimal, minimal → mip). Combines the following features: - version, rename, init, add, and update subcommands - --json and --raw output flags for the ls command - anyhow-based error handling replacing ad-hoc eprintln!+Err(()) - resolve_session helper for UUID/name session lookups - integration test harness with 14 CLI tests exercising real daemon - lib/main split so integration tests can call cmd_* functions directly - minimald test-support feature exposing TestServer/TestClient externally - merged main's session-creation flow (SessionConfig, Pending/Ready, AbortOnUnapproved, drive_pending_to_active, send_abort) into the anyhow-based error handling - client.rs socket path now uses paths::minimal_state_dir()
Adds a `minimal stop` command that sends the Shutdown RPC (PR #613) to the running minimald daemon. With no flags it requests a graceful shutdown — the daemon refuses if any session is live. Pass --force to tear down live sessions and shut down regardless. Includes three integration tests covering the no-sessions, refused, and forced paths. Also adds a bring_session_up helper to the test harness so tests can make sessions "live" for shutdown scenarios.
Reduce duplication and improve test coverage after the lib/main split: extract SessionLookup/ensure_daemon helpers, make parse_ingress return anyhow::Error, privatize shell_quote, and capture stdout in ls integration tests via a new format_ls function.
d29ec86 to
a24d00a
Compare
…lity The init/add/update subcommands depend on mctx → hakoniwa → libcgroups → procfs, which only compiles on Linux. Gating mctx/op behind target_os = "linux" keeps the minimal binary buildable on macOS, fixing the autospawn-e2e CI lane that builds and runs minimal on the self-hosted Apple Silicon runner.
78aa8e0 to
8628f87
Compare
Summary
Completes the minimal CLI by splitting the monolithic
main.rsinto a testable library, adding the remaining subcommands, and wiring up a full integration test suite against a real in-process daemon.Lib/main split
lib.rs(new, ~1535 lines): all CLI argument structs, therun()dispatcher, and everycmd_*function are nowpub, enabling integration tests to call commands directlymain.rs: reduced to 26 lines — tracing init,Cli::parse(), andminimal::run(cli)client.rs: error type changed fromStringtoanyhow::Errorfor proper error chaining throughoutNew subcommands
stop [--force]— sends aShutdownRPC to minimald; refuses if active sessions exist unless--forceis passedversion— prints CLI version and, if the daemon is reachable, daemon + stdlib versions (does not autospawn)rename <session> <new-name>— resolves by UUID or name, issuesRenameSessionRPCinit,add,update— ports the build-system commands from the legacy binary; operates locally againstmctx/op/graph(no daemon RPC)--jsonflag onls— three output modes: default table,--raw(IDs only),--json(pretty-printedListSessionsResponse)Test infrastructure
minimaldtest-supportfeature: compilestest_harnessaspub modso external crates can spin up a real minimald server over UDS without a separate binaryversion,ls(all three modes, empty and with sessions),activate,destroy(by UUID/name, unknown),stop(no-sessions/live/force),rename(by UUID/name), andsession policy— all against a realTestServeron a UDSformat_lsextracted fromcmd_lsso tests capture and assert on actual JSON/raw/table outputCode review refactors
SessionLookupenum withFromimpls for bothGetSessionRecordRequestandGetSessionPolicyRequest, eliminating duplicated UUID-or-name parsingensure_daemon()helper, replacing 9 copies of the autospawn boilerplateparse_ingress_mapping/parse_ingress_protofromResult<_, String>toResult<_, anyhow::Error>shell_quoteprivate (internal only)create_sessionhelper reusesunwrap_readyfrom the harness instead of duplicating the matchChanged files
crates/minimal/src/lib.rscmd_*functionscrates/minimal/src/main.rscrates/minimal/src/client.rsString→anyhow::Errorerror typescrates/minimal/tests/cli.rscrates/minimal/tests/common/mod.rsTestDaemonharnesscrates/minimal/Cargo.tomlanyhow,mctx,op,pathsdeps +test-supportdev-depcrates/minimald/Cargo.tomltest-supportfeaturecrates/minimald/src/lib.rstest_harnessgated ontestortest-supportcrates/minimald/src/test_harness.rspub(crate)→pub+bring_session_uphelperTest plan
cargo test -p minimal— 12 unit + 17 integration tests passcargo test -p minimald— 106 tests pass (unaffected)cargo clippy -p minimal -p minimald --all-targets -- -D warnings— cleancargo fmt -- --check— clean./target/debug/minimal --help— all subcommands visible./target/debug/minimal version— prints client + daemon versionSummary by CodeRabbit