8000 fix(mfile): bind repo-wide params into task command interpolation by norrietaylor · Pull Request #1980 · gominimal/minimal · GitHub
[go: up one dir, main page]

Skip to content

fix(mfile): bind repo-wide params into task command interpolation - #1980

Merged
norrietaylor merged 1 commit into
mainfrom
fix/task-command-repo-params
Oct 5, 2026
Merged

norrietaylor merged 1 commit into
mainfrom
fix/task-command-repo-params

Conversation

@norrietaylor
@norrietaylor norrietaylor commented Oct 5, 2026 •
Copy link
Copy Markdown
Member

Problem

docs/reference/minimal-dot-toml.md says repo-wide [params] are available to tasks across the repository, but task commands never saw them. With

[params]
greeting = { type = "string", default = "hi" }

[tasks.useparam]
packages = ["base"]
bash = "echo greeting=%{greeting}"

min task run useparam failed with nickel eval failed for string: echo greeting=%{greeting}, and the attached note wrongly suggested escaping the %{. There was also no way to override a param on the command line.

Task interpolation (mctx::interpolate_task_strings) binds only task_packages and the task's parsed args, and File::hydrate_task_defaults applied the repo's default profile, state key and stack packages to a task but not its params.

Fix

  • File::hydrate_task_defaults (crates/mfile) merges each [params] entry into task.args unless the task already declares an arg of that name, so a task arg shadows a repo param. Every param must carry a default, so the merged entries are optional args: every path that parses a task's args now binds them, applying the default or a --<name> override.
  • The [params] section of docs/reference/minimal-dot-toml.md now states that params act as defaulted args on every task and that a task arg of the same name wins.

Tests

  • crates/mfile: task_inherits_repo_params_as_args: File::task returns the param as an arg with its default, and a task arg of the same name is kept.
  • crates/mctx: interpolate_resolves_hydrated_repo_param: echo %{greeting} resolves to echo hi with an empty argv and to echo bye with --greeting bye.

Commands run (macOS arm64 host, pinned toolchain 1.97.0):

  • cargo fmt --check: clean.
  • just test-one task_inherits_repo_params_as_args -p mfile: 1 passed.
  • cargo clippy -p mfile --all-targets --locked -- -D warnings: clean.
  • mctx does not build natively on macOS, so it ran through cross (musl in Docker):
    • CROSS_CONTAINER_OPTS="--env HOME=/tmp" cross test -p mctx -p mfile --target aarch64-unknown-linux-musl --locked: mctx 44 passed, 3 ignored; mfile 66 passed; 0 failed.
    • CROSS_CONTAINER_OPTS="--env HOME=/tmp" cross test -p mctx --target aarch64-unknown-linux-musl --locked -- interpolate_: 3 passed, including the new test.
    • CROSS_CONTAINER_OPTS="--env HOME=/tmp" cross clippy -p mctx -p mfile --all-targets --target aarch64-unknown-linux-musl --locked -- -D warnings: clean.
  • just lint-prose docs/reference/minimal-dot-toml.md: no alerts on the changed lines.

Refs gominimal/inbox#871

Summary by CodeRabbit

  • New Features
    • Repository-wide parameters now provide default task arguments. Tasks can reference them in commands, and callers can override them from the command line. Task-specific arguments take precedence over repository defaults.
  • Documentation
    • Added an example showing how to define and use a repository-wide parameter.

File::hydrate_task_defaults now merges each [params] entry into the
task's args unless the task declares an arg of the same name, so a
command can read a repo param as %{name} and override it with --name.
@norrietaylor
norrietaylor requested a review from a team as a code owner October 5, 2026 06:20
@coderabbitai
coderabbitai Bot commented Oct 5, 2026 •
Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

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: 6c38da14-3fed-4b86-b341-02d7dd7dd72f
📥 Commits

Reviewing files that changed from the base of the PR and between 908b5a8 and 5af66c8.

📒 Files selected for processing (3)
  • crates/mctx/src/env.rs
  • crates/mfile/src/lib.rs
  • docs/reference/minimal-dot-toml.md

Included review availability: This review used your included allowance. Your plan provides up to 5 included reviews per hour; 1 remain after this review.


📝 Walkthrough

Walkthrough

Repository-wide parameters are added to task arguments as defaults when a task does not define an argument with the same name. Tests cover interpolation and command-line overrides. Documentation describes how to define and use these parameters.

Changes

Repository Parameter Defaults

Layer / File(s) Summary
Hydrate and verify task parameter defaults
crates/mfile/src/lib.rs, crates/mctx/src/env.rs, docs/reference/minimal-dot-toml.md
Task hydration adds repository-wide parameter specifications unless a task defines an argument with the same name. Tests check inherited defaults, task-local precedence, interpolation, and command-line overrides. Documentation describes parameter references and overrides.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: evanspearman

Merge Risk: ⚪ Minimal · up to 5af66

No actionable merge-blocking issue is identified; the change is ready for normal merge checks.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: binding repository-wide parameters into task command interpolation. It is concise and uses a Conventional Commit-style subject.
Description check ✅ Passed The description explains the problem and fix, documents parameter precedence, and lists tests and validation commands. It covers the template’s required information, though it does not include a separ…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 files. (1 skipped: 1 …
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
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit reads the params file,
Then nibbles defaults with a smile.
A task can keep its own,
Or pass a value of its own.
“Hi” turns to “bye” at run-time,
And hops along in perfect rhyme.

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

@minimal-foundry
minimal-foundry Bot commented Oct 5, 2026 •
Copy link
Copy Markdown
Contributor

Approved: no findings at 5af66c8b1de4.

Nothing to do.

Clobber: none: git log on the touched files shows no recent work reverted.

@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 — No findings.

@minimal-foundry minimal-foundry Bot added the review:approved minimal-review approved the current head label Oct 5, 2026
@norrietaylor
norrietaylor added this pull request to the merge queue Oct 5, 2026
Merged via the queue into main with commit 234d9bf Oct 5, 2026
35 checks passed
@norrietaylor
norrietaylor deleted the fix/task-command-repo-params branch October 5, 2026 21:56
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

0