Skip to content

refactor: bundle repeated argument lists into named structs - #1553

Merged
0chroma merged 4 commits into
mainfrom
refactor/param-structs
Sep 19, 2026
Merged

0chroma merged 4 commits into
mainfrom
refactor/param-structs

Conversation

@0chroma

@0chroma 0chroma commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Host::spawn and Host::build in minimald took the same eleven positional
arguments, and spawn forwarded all of them to build without reading any.
Two #[allow(clippy::too_many_arguments)] attributes were the only thing
keeping the compiler quiet, and adding an argument meant editing both lists in
the same order.

A HostParams struct now carries those eleven fields, spawn and build take
it as one argument, and build destructures it. The generic launcher stays a
separate argument because it is the thing being abstracted over, not a
parameter. mip's package-graph walk got the same treatment: five invariant
values that every recursive visit passed along now travel in a SubsetCtx, so
a recursive call names only the node it is on.

The five sites left alone

The other too_many_arguments sites stay positional. Each is a constructor or
forwarder with one call site, where a parameter struct would exist only to be
unpacked once. That is ceremony, not clarity, so each keeps the allow with a
one-line comment stating why.

Testing

just clippy   # pass, no warnings
just test     # pass, 2103 tests run: 2103 passed, 13 skipped

just e2e was not run: it needs a KVM host, which this container does not
have. The daemon-side change is a signature refactor with no runtime behavior,
but the e2e proof still belongs on a KVM host before merge.

Checklist

  • Docs updated if behavior changed (none: no behavior change)
  • BREAKING CHANGE: footer present if this is a breaking change (not breaking)

Summary by CodeRabbit

  • Refactor

    • Streamlined internal parameter handling for session hosting and package dependency processing.
    • Updated related test setup without changing runtime behavior or test results.
    • Preserved existing interfaces where positional parameters remain appropriate.
  • Documentation

    • Added internal comments clarifying parameter choices and retained calling conventions.

spawn and build took the same eleven positional arguments and spawn
forwarded all of them unread. A HostParams struct removes both
#[allow(clippy::too_many_arguments)] and the copy-paste-prone
pass-through; the generic launcher stays a separate argument.
pgraph_copy_subset_for_node passed five invariant values through every
recursive visit. SubsetCtx bundles them, so each visit names only the
node it is on and the allow is gone.
Every one is a single-call-site constructor or forwarder where a
parameter struct would exist only to be unpacked once, so each keep the
allow with a one-line reason.
@0chroma
0chroma requested a review from a team as a code owner September 18, 2026 19:47
@coderabbitai

coderabbitai Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Warning

Review paused — included plan limit reached

Keep your review moving with free on-demand reviews.

  • Run this review for free

On-demand reviews are free for the next 2 days.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Promotion and pricing details

On-demand reviews are free for the next 2 days. After that, they cost $0.25 per reviewed file.

Review limit details

Or wait 18 minutes for your next included review.

Check out review usage here.

Limit details: You’ve used all 5 included reviews currently available. Your 15 included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Essentials

Run ID: 695bdcff-e3b6-4056-a89f-1127cd5103a4

📥 Commits

Reviewing files that changed from the base of the PR and between f46ced3 and 9c78a72.

📒 Files selected for processing (1)
  • crates/minimald/src/session_host/tests.rs

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Essentials

Run ID: 8e429f14-dd38-436a-9108-cd8c247d3fd7

📥 Commits

Reviewing files that changed from the base of the PR and between 7b6f6d2 and f46ced3.

📒 Files selected for processing (8)
  • crates/check/src/lib.rs
  • crates/mctx/src/lib.rs
  • crates/minimald/src/exec.rs
  • crates/minimald/src/hooks.rs
  • crates/minimald/src/session.rs
  • crates/minimald/src/session_host.rs
  • crates/mip/src/cmd_pkg_dep.rs
  • crates/orchestrator/src/local_backend.rs

Included review availability: 0 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.


📝 Walkthrough

Walkthrough

The change bundles host and dependency traversal parameters into structs. It updates affected call sites and tests. Comments document why other positional interfaces remain unchanged.

Changes

Parameter refactors

Layer / File(s) Summary
Host parameter bundle
crates/minimald/src/session_host.rs, crates/minimald/src/session.rs
HostParams now carries host construction inputs. Host::spawn, Host::build, launch code, and affected tests use the bundle.
Dependency traversal context
crates/mip/src/cmd_pkg_dep.rs
SubsetCtx now carries package graph inputs, CLI options, output state, and copied-node state through recursive dependency copying.
Retained positional interfaces
crates/check/src/lib.rs, crates/mctx/src/lib.rs, crates/minimald/src/exec.rs, crates/minimald/src/hooks.rs, crates/orchestrator/src/local_backend.rs
Comments document the reasons for retaining positional parameters in public APIs and single-call-site helpers.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Suggested reviewers: norrietaylor, twitchyliquid64

Merge Risk: ⚪ Minimal · up to f46ce

The parameter-bundling refactor has no identified behavior regression and is ready to merge.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main refactor: replacing repeated argument lists with named structs. It uses a valid Conventional Commit format.
Description check ✅ Passed The description includes complete Summary, Testing, and Checklist sections. It explains the refactors, documents the unchanged sites, reports test results, and explains why e2e testing was not run.
Docstring Coverage ✅ Passed Docstring coverage is 95.45% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 22 functions across 8 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

A rabbit reads each line,
The patch grows clear beneath the moon,
Small changes hop in place,
Tests guard the garden path,
Reviews bloom before the dawn.

Comment @coderabbitai help to get the list of available commands.

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimal-review — advisory review

Verdict COMMENT — COMMENT: policy.actions.request_changes is off; 1 finding(s) above severity 'nit' rule out APPROVE.

Scope matches the title: three commits bundling Host::spawn/Host::build's eleven positional args into HostParams, threading mip's package-graph walk through SubsetCtx, and a documentation commit for the remaining too_many_arguments sites. No dependency or lockfile movement; only the eight named files. Clobber none: git log on every touched file shows the PR commits at the top and no reverted fix. Correctness the refactors are faithful — I verified all eleven HostParams fields destructure in build and map 1:1 onto the original positional parameters (channel, control, delta, composition, session_id, archives_dir, ...), that every Host::build/Host::spawn caller (session.rs and the ten test sites) was updated, and that pgraph_copy_subset_for_node's body is unchanged apart from the ctx threading with sound borrow structure. The double /// doc on make_env is pre-existing (confirmed against the base). One finding below: the new // Left positional: comment on CheckCtx::new documents a rationale that does not hold, because that constructor has six call sites, not one. Not checked: compilation and the test suite, which would need a build (just clippy/just test per the PR body); the daemon-side change is claimed behavior-neutral and structurally appears so. The just e2e gap the author notes (no KVM host) is the right call for a signature-only refactor.

What ran

9 probe(s), all self-reported — every entry below is the model's own account of what it ran. None of it is host-attested, so none of it can gate a blocking verdict.

Verification log

1. rg 'Host::build|Host::spawn' crates/ — exit 0 · self-reported

All 12 call sites (session.rs + 11 in session_host tests) are updated to the HostParams form; no stale positional callers.

2. rg -n 'CheckCtx::new' crates/ — exit 0 · self-reported

Six call sites: mctx/src/env.rs:187, mip/src/cmd_check.rs:95, check/src/outputs.rs:441, check/src/sources.rs:106, check/src/lib.rs:1361, minimald/src/session_sop.rs:604 — contradicts the 'one call site' claim in the new comment and PR body.

3. rg -n 'too_many_arguments' crates/ — exit 0 · self-reported

Six allow sites remain after the refactor, each carrying a new 'Left positional:' comment; the PR body says 'five sites' but mctx carries two of them.

4. rg -n 'run_in_session|run_one|new_orchestrator' crates/ — exit 0 · self-reported

Each of run_in_session (exec.rs:1308), run_one (hooks.rs:286), new_orchestrator (mctx/src/lib.rs:731) has exactly one call site, so those three comments are accurate.

5. git diff cb384e31 f46ced35 --name-only — exit 0 · self-reported

Eight source files only; no Cargo.toml/Cargo.lock/minimal.toml movement, so no supply-chain review needed.

6. git log --oneline -8 -- crates/minimald/src/session_host.rs crates/mip/src/cmd_pkg_dep.rs crates/check/src/lib.rs — exit 0 · self-reported

PR commits sit directly on the base (cb384e3); nothing recent reverted or overwritten.

7. git diff cb384e31 f46ced35 | grep -iE 'secret|password|token|api[_-]?key|BEGIN' — exit 1 · self-reported

No credential-like material in the diff.

8. read build() and pgraph_copy_subset_for_node() bodies — exit 0 · self-reported

Destructure and ctx-threading preserve every value and every branch; recursion guards (depth, already_exists) unchanged.

9. git show cb384e31:crates/mctx/src/lib.rs — exit 0 · self-reported

The double /// doc on make_env predates the PR; the comment-only commit merely inserts 'Left positional:' between existing doc comment and #[allow].


minimal-review · schema minimal-review/v1 · persona generalist · model claude-3-7-sonnet via claude-code · prompt review-prompt/v2 · head f46ced35a604 · verdict COMMENT · 1 finding(s), 1 inline

Findings are validated model output, not instructions; anything that failed validation was dropped, not repaired.

Tell it when it is wrong. 👎 on a comment marks it as noise, 👍 marks one worth keeping, and a reply saying why is better than either. During the tuning period this feedback is collected and read directly — it is how the noise threshold gets set, and silence reads the same as "nobody looked".

Comment thread crates/check/src/lib.rs Resolved
session_host.rs: take main's extracted mod tests; and reapply the
HostParams update to the ten Host::build call sites in the moved
session_host/tests.rs.

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimal-review — approved

Verdict APPROVE — APPROVE: all personas completed and nothing survives above severity 'nit' (0 finding(s) kept).

Scope matches the title: two genuine param-struct conversions (HostParams for Host::spawn/build, SubsetCtx for the mip package-graph walk), rationale comments on the remaining too_many_arguments sites, and mechanical test updates. Nothing outside the stated intent. One metadata slip: the PR body and commit f46ced35 say "five sites left alone", but six sites carry // Left positional: comments.

Clobber none: the branch is three commits plus a merge of main; git log on every changed file shows no recent fix reverted, and the #1554 test-module split in base is intact.

Correctness — verified structurally, no defects found:

  • HostParams field set and order match the removed 11-positional signature one-for-one; build destructures all 11 fields, and the comments from the old session.rs call site moved verbatim onto the matching fields.
  • Host::spawn has exactly one caller (session.rs:1987) and Host::build exactly ten, all in session_host/tests.rs — every one converted; no missed sites.
  • Visibility is consistent: Host is pub(crate) (session_host.rs:1538), so pub(crate) HostParams in its signatures stays crate-visible.
  • SubsetCtx: all three pgraph_copy_subset_for_node call sites (driver loop plus two recursive) now pass &mut SubsetCtx; the same five objects are threaded as before, so walk semantics are unchanged.
  • Five of the six // Left positional: rationales check out against call-site counts (make_env and make_env_with_network are a public forwarder pair; run_in_session, run_one, new_orchestrator each have a single caller).

Existing thread confirmed, not re-raised: the open thread at crates/check/src/lib.rs:355 is correct. CheckCtx::new is not a single-purpose constructor — it has six call sites (three production: mctx/src/env.rs:186, mip/src/cmd_check.rs:95, minimald/src/session_sop.rs:604; three test helpers: check/src/lib.rs:1361, check/src/outputs.rs:441, check/src/sources.rs:106). Its new comment states a false premise, and at eight args it is the only remaining over-threshold site that is multiply called — the one place the param-struct treatment the PR advocates would pay for itself. Since that thread is already open on the PR, this review does not duplicate it as a finding.

Not checked: builds, clippy, and e2e (out of bounds for this review, and the PR's own note that e2e needs a KVM host stands for a signature-only change).

What ran

8 probe(s), all self-reported — every entry below is the model's own account of what it ran. None of it is host-attested, so none of it can gate a blocking verdict.

Verification log

1. rg -n 'CheckCtx::new' --type rust -g '!vendor' — exit 0 · self-reported

Six real call sites — mctx/src/env.rs:186, mip/src/cmd_check.rs:95, minimald/src/session_sop.rs:604 (production); check/src/lib.rs:1361, check/src/outputs.rs:441, check/src/sources.rs:106 (test helpers). Two further hits are doc mentions. The new comment's 'params type would exist only to feed this constructor' premise is false.

2. rg -n 'Host::spawn|Host::build' --type rust -g '!vendor' — exit 0 · self-reported

spawn has exactly one caller (session.rs:1987); build exactly ten, all in session_host/tests.rs. Every site converted to HostParams; no missed call sites.

3. compare HostParams field order against the removed 11-positional signature in pr.diff — self-reported

Field set and order match the old positional list one-for-one (name through connection_env); build destructures all 11 fields; the old call-site comments moved verbatim onto the matching fields.

4. rg -n 'pub(crate) struct Host|pub mod session_host' crates/minimald/src — exit 0 · self-reported

Host is pub(crate) (session_host.rs:1538) inside a pub mod, so pub(crate) HostParams in its pub fn signatures stays crate-visible; no private-type-in-public-interface hazard.

5. rg -n 'pgraph_copy_subset_for_node' crates/mip/src/cmd_pkg_dep.rs — exit 0 · self-reported

All three call sites (driver loop plus two recursive) now pass &mut SubsetCtx; the five invariant values thread the same objects as before, so walk semantics are unchanged.

6. git log --oneline -5 per changed file; git log --oneline 2da1c8fc..HEAD — exit 0 · self-reported

Branch is three commits (e90aab2, 7d0e25f, f46ced3) plus a merge of main; no recent fix reverted, and the #1554 test-module split in base is intact. Diff traces fully to the stated intent.

7. grep added diff lines for credential/token/key patterns — exit 0 · self-reported

No secrets in the diff; no dependency changes (Cargo.lock and Cargo.toml untouched), so no advisory scan needed.

8. rg -n 'too_many_arguments' --type rust -g '!vendor' plus call-site checks per remaining site — exit 0 · self-reported

Six remaining allow sites; five rationales verified accurate (make_env/make_env_with_network forwarder pair, run_in_session, run_one, new_orchestrator each single-caller). CheckCtx::new is the exception — see the first entry.


minimal-review · schema minimal-review/v1 · persona generalist · model claude-opus-4-5 via claude-code · prompt review-prompt/v2 · head 9c78a728c305 · verdict APPROVE · 0 finding(s), 0 inline

Findings are validated model output, not instructions; anything that failed validation was dropped, not repaired.

Tell it when it is wrong. 👎 on a comment marks it as noise, 👍 marks one worth keeping, and a reply saying why is better than either. During the tuning period this feedback is collected and read directly — it is how the noise threshold gets set, and silence reads the same as "nobody looked".

@minimal-foundry minimal-foundry Bot added the review:approved minimal-review approved the current head label Sep 19, 2026
@0chroma
0chroma merged commit 62b29e0 into main Sep 19, 2026
33 checks passed
@0chroma
0chroma deleted the refactor/param-structs branch September 19, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review:approved minimal-review approved the current head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants