Skip to content

A command declared as not mutating passes the declaration check when a task runs it #2696

Closed

Description

@jgregoriorincon

What happens

#2653 added a test-build check (invoke, policy/dispatch.rs, feature declaration-check): a command declared .view() that adds, removes or reorders layers fails the test that ran it. The check asserts inside invoke, and a task runs each step in catch_unwind (cmd/items.rs), which turns that panic into the step's "failed unexpectedly". So a wrongly declared command run as a task step doesn't fail its test: the check misses that path, although AGENTS.md says the tests fail such a command on the paths they run. Raised on #2653 (review thread on dispatch.rs).

Expected

  • A wrongly declared command fails its test whichever way it ran: by itself, as a script line, as a task step or as a plugin's host call, and through any top-level entry (Session::run, a prepared run, a read ahead finishing, a continuation).
  • A test runs one as a task step and fails without the fix.

Proposed fix

invoke notes the violation on the session instead of panicking inside the step, and command_epilogue raises it when the top-level command returns (and drops it on a panic, so it never reaches the next command). Test builds only, as today.

Notes

Activity

  1. jgregoriorincon commented on Nov 22, 2026

    @jgregoriorincon
    ContributorAuthor

    I'm taking this one; the fix is ready and the pull request follows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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