feat(sessions): loadouts, config, and debug commands - #686
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (20)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (18)
📝 WalkthroughWalkthroughAdds minimal config resolution, persisted loadout discovery and activation, ChangesMinimal client config, loadouts, dirs, and daemon logging
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant Config
participant LoadoutFiles
participant Composer
participant Daemon
CLI->>Config: read client config
CLI->>LoadoutFiles: resolve selected loadouts
LoadoutFiles->>Composer: provide parsed loadouts
Composer->>CLI: return WireContribution
CLI->>Daemon: create session with contribution
Possibly related issues
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
crates/minimal/src/dirs.rs (1)
61-61: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider an enum instead of
&'static strformesh_group.
mesh_groupis compared via string equality (== "Config"/== "State") to decide row placement. An enum (e.g.MeshGroup::Config | MeshGroup::State) would make the invariant compiler-checked instead of relying on matching literals.Also applies to: 103-105, 145-150
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/minimal/src/dirs.rs` at line 61, The mesh_group field is using raw &'static str values and string comparisons to decide placement, so replace it with a compiler-checked enum such as MeshGroup with Config and State variants. Update the affected code paths in the dirs.rs logic that currently compare against "Config" and "State" to use the enum instead, including the related uses in the surrounding structs/functions where mesh_group is passed through.crates/minimald/src/main.rs (1)
296-319: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winNo log retention/cleanup for daily-rotated files.
tracing_appender::rolling::dailyis used withoutmax_log_files, so<state>/logs/minimald.log.YYYY-MM-DDaccumulates indefinitely for a long-running daemon. TheRollingFileAppender::builder()API supports.max_log_files(n)to bound retention.♻️ Proposed fix to bound log retention
- let appender = tracing_appender::rolling::daily(&log_dir, "minimald.log"); + let appender = tracing_appender::rolling::Builder::new() + .rotation(tracing_appender::rolling::Rotation::DAILY) + .filename_prefix("minimald.log") + .max_log_files(14) + .build(&log_dir) + .map_err(|e| MainError::Other(format!("initializing log appender: {e}")))?;🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/minimald/src/main.rs` around lines 296 - 319, The daily rolling logger in minimald does not cap retained files, so old logs can accumulate indefinitely. Update the log setup in main() where tracing_appender::rolling::daily is created to use the RollingFileAppender builder API and set a max file count for retention, then keep the existing writer/guard wiring unchanged so the daemon still routes tracing output to the log file.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@crates/minimal/src/dirs.rs`:
- Line 61: The mesh_group field is using raw &'static str values and string
comparisons to decide placement, so replace it with a compiler-checked enum such
as MeshGroup with Config and State variants. Update the affected code paths in
the dirs.rs logic that currently compare against "Config" and "State" to use the
enum instead, including the related uses in the surrounding structs/functions
where mesh_group is passed through.
In `@crates/minimald/src/main.rs`:
- Around line 296-319: The daily rolling logger in minimald does not cap
retained files, so old logs can accumulate indefinitely. Update the log setup in
main() where tracing_appender::rolling::daily is created to use the
RollingFileAppender builder API and set a max file count for retention, then
keep the existing writer/guard wiring unchanged so the daemon still routes
tracing output to the log file.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: fae9a9a7-15e8-42c4-b93f-b9f1d8a4427c
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (20)
Cargo.tomlcrates/minimal/src/config.rscrates/minimal/src/dirs.rscrates/minimal/src/lib.rscrates/minimal/src/loadouts.rscrates/minimal/tests/cli.rscrates/minimal/tests/common/mod.rscrates/minimald/Cargo.tomlcrates/minimald/src/main.rscrates/minimald/src/session_host.rscrates/paths/src/lib.rscrates/remote-proto/build.rscrates/sessions/Cargo.tomlcrates/sessions/src/client/config.rscrates/sessions/src/client/disk.rscrates/sessions/src/client/mod.rscrates/sessions/src/core/compose.rscrates/sessions/src/core/enumerate.rscrates/sessions/src/core/loadout.rsjustfile
a39372a to
80c4d45
Compare
Add loadout support end-to-end, a user client config file, and a `minimal dirs` debug command. Squashed after a rebase onto main that restructured minimal into main.rs + lib.rs. - sessions: client-side `Config` (toml, deny_unknown_fields) with `[loadouts]` block and `default_loadouts` / `follow_symlinks`; on-disk `list_loadouts` / `read_loadout_file` with per-entry `LoadoutEntry` result rows. - sessions: pre-resolve loadout `Inherit` vars from the process env, downgrading `NotPresent` to a warn+drop. - sessions: patch enumeration treats walkdir `NotFound` as a warn+drop so a missing dotfile tree doesn't fail activation. - sessions: `ComposeOptions::with_follow_symlinks` owned builder. - minimal: `--config-dir` global flag routes through the new `paths::minimal_config_dir()` (XDG on Linux, `~/.config` on macOS to match state/cache dirs). - minimal: `loadout list` prints discovered loadouts with default markers; `dirs` prints Config/State/Cache paths with existence markers. - minimal: `activate` applies `--loadout` / `--no-loadouts` / config defaults; composed contribution goes to the daemon. - minimald: file-based rolling daily log when detached; content logging of packages/vars/patches/hooks per session. - paths: `minimal_config_dir` helper; `xdg_config_home` fallback to `$HOME/.config`. - justfile: `just min *args` recipe.
80c4d45 to
fb43cc8
Compare
| /// inspect when debugging. Grouped by role (config / state / cache) | ||
| /// with an "exists?" marker so unused paths don't look identical to | ||
| /// misconfigured ones. | ||
| pub fn cmd_dirs(global: &GlobalArgs) -> Result<(), anyhow::Error> { |
There was a problem hiding this comment.
Do we want minimald/minvmd stuff in here?
There was a problem hiding this comment.
Eg $STATE/minimal/providers/local-0/{ssh.sock,minvmd stuff, data-vol.raw} etc
There was a problem hiding this comment.
I think we do actually because the client is the main way that users will interact with minimal. That said, it only really makes sense if the daemon they are connected to is running locally. When we add support for connecting to remote daemons we should revisit this I think.
| @@ -1,2 +1,4 @@ | |||
| pub mod composer; | |||
There was a problem hiding this comment.
Up to you but this might be a better candidate as a top-level crate, i.e. clientconf or clientstate or something
There was a problem hiding this comment.
I think that's reasonable, but I'll do it in a separate PR.
twitchyliquid64
left a comment
There was a problem hiding this comment.
A few nits but up to you!
Resolves https://github.com/gominimal/inbox/issues/202 and resolves https://github.com/gominimal/inbox/issues/203
Summary
Ships end-to-end loadout support, a user client config file, and two debug
commands (
minimal dirs,minimal loadout list). Adds a rollingfile-based daemon log for detached mode and per-session content logging.
User-facing (
minimal):--config-dirglobal flag (routes through the newpaths::minimal_config_dir(), XDG on Linux,~/.config/minimalonmacOS for consistency with the state/cache dirs)
minimal loadout list— enumerate loadouts from<config>/minimal/loadouts/*.toml, mark defaults from[loadouts].default_loadoutsinconfig.tomlminimal dirs— print all Config/State/Cache paths with existencemarkers (
*= exists,-= missing,?= unresolved)minimal activate --loadout NAME(repeatable) /--no-loadoutstoselect which loadouts to apply; otherwise
[loadouts].default_loadoutsis used
Library side (
sessions):sessions::client::config— TOML withdeny_unknown_fields,[loadouts]block fordefault_loadoutsandfollow_symlinkssessions::client::disk—list_loadouts/read_loadout_filewith per-entry
LoadoutEntryresults so listing tolerates malformedfiles without aborting
Inheritvars pre-resolve from the process env;NotPresent→ warn+drop rather than errorNotFoundas warn+drop, so aloadout that opportunistically patches
~/dotfiles/helix/doesn'tfail activation on a host without that tree
ComposeOptions::with_follow_symlinksowned builderDaemon (
minimald):MINIMALD_DETACHED=1routes tracing to a daily-rotated log fileunder
<state>/logs/minimald.log.YYYY-MM-DDtheir
SourceprovenanceWindowAdjustedSSH flow-control messages downgraded from warn todebug (they were spamming the log)
Structure:
crates/minimal/src/lib.rs(2313 → 1613 lines) with the new logicsplit into
config,dirs,loadoutsmodulespaths::minimal_config_dir()alongside the existingstate/cachehelpers
just min *argsrecipe for quick local invocationsSummary by CodeRabbit
Summary
New Features
loadoutanddirscommands to list loadouts and inspect resolved config/state/cache directories.--config-dirplus loadout activation controls (--loadout,--no-loadouts), andminimaldrotation-backed logging in detached mode.minconvenience command to build and run with the daemon available automatically.Bug Fixes