Description
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
- No effect on the app's builds: the check compiles only under
cfg(test)or the feature. - I have this ready on a branch from the work on fix(engine): measure layers in shared steps, and say plugin commands are never steps (#2645) #2653 and can open the pull request.
Activity
jgregoriorincon commentedon Nov 22, 2026
I'm taking this one; the fix is ready and the pull request follows.
fix(engine): a scoped script raises its lines' declaration check (ope…
fix(engine): the declaration check reports past a task's catch (openg…