Problem
mise file tasks expose #USAGE parse results as usage_* environment variables. If an optional arg/flag has no default=... and is omitted, usage does not export a replacement value, so a stale inherited parent usage_<name> can remain visible to the child task.
This caused a real review finding in KnickKnackLabs/sessions#89: nested sessions run / sessions wake could inherit usage_message and usage_headless from the parent agent dispatch and take the wrong no-message/headless path.
We documented the pattern in fold: notes/usage-defaults-clear-inherited-env.md.
Upstream discussion: jdx/mise#9460 (comment)
Proposed lint
Add a codebase lint for .mise/tasks/* that flags optional #USAGE args/flags read via usage_* when the directive lacks an explicit default.
Default desired shape:
#USAGE flag "--headless" default=#false
#USAGE flag "--model <model>" default=""
#USAGE arg "[message]" default=""
#USAGE flag "--meta <meta>" var=#true default=""
Rule sketch
For each executable task under .mise/tasks/:
- Parse
#USAGE directives.
- Identify optional args/flags:
- optional positional args like
[message]
- flags without
required=#true
- booleans without an explicit default
- repeatable
var=#true flags/args without an explicit default
- If the task body references the corresponding
usage_<snake_name> and the directive lacks default=..., report it.
Prefer checking read sites so docs-only/unused directives do not create noise.
Config / escape hatch
Support repo config for cases where ambient inheritance is intentional, e.g.:
[_.codebase.lint.usage-defaults]
allow = [".mise/tasks/foo:usage_model"]
or a directive-level suppression comment if that is more consistent with existing codebase lints.
Related
- codebase#13 — USAGE flag/placeholder mismatches
- codebase#21 — variadic
#USAGE parsing hazards
Problem
misefile tasks expose#USAGEparse results asusage_*environment variables. If an optional arg/flag has nodefault=...and is omitted,usagedoes not export a replacement value, so a stale inherited parentusage_<name>can remain visible to the child task.This caused a real review finding in
KnickKnackLabs/sessions#89: nestedsessions run/sessions wakecould inheritusage_messageandusage_headlessfrom the parent agent dispatch and take the wrong no-message/headless path.We documented the pattern in fold:
notes/usage-defaults-clear-inherited-env.md.Upstream discussion: jdx/mise#9460 (comment)
Proposed lint
Add a
codebaselint for.mise/tasks/*that flags optional#USAGEargs/flags read viausage_*when the directive lacks an explicit default.Default desired shape:
Rule sketch
For each executable task under
.mise/tasks/:#USAGEdirectives.[message]required=#truevar=#trueflags/args without an explicit defaultusage_<snake_name>and the directive lacksdefault=..., report it.Prefer checking read sites so docs-only/unused directives do not create noise.
Config / escape hatch
Support repo config for cases where ambient inheritance is intentional, e.g.:
or a directive-level suppression comment if that is more consistent with existing codebase lints.
Related
#USAGEparsing hazards