Skip to content

lint: flag optional #USAGE values without explicit defaults #35

Description

@ikma-ricon

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/:

  1. Parse #USAGE directives.
  2. 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
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions