T: a dispatch error raises, so a module-mode session survives a typo

This commit is contained in:
ari committed 2026-10-19 22:37:08 -04:00
1 parent e736c12a0e
commit 4d7d7defe6
2 files changed
+32 -17

No files matched your search

+6
View File
@@ -93,3 +93,9 @@ The test builds under `nix build .#tests.x86_64-linux.peers` (or equivalent) and
4. **`TODO.md` T7.** Not edited here (outside WS-T's owned files, and the phase gate rejects changes outside them). Still says `dev/test.nu` and is unticked; the merger updates the name and ticks it.
5. **`AGENTS.md` wording.** "the same command works in an interactive shell" now reads "inside an interactive `devenv shell`". `docs/consolidator.md` says the cache sits at the repo root and that a failing check raises rather than closing the session.
- Handoff 2026-10-19 (WS-T review round 2 -> all): unchanged commands and subcommand names. `nu dev/dev-test.nu self-check` now also fails if any command exits (outside `main`), if a message interpolates a call to `exit`, if a failing step is not catchable in module mode, or if the filter cache is not anchored on the repo root. Merger: items 3 and 4 above.
- 2026-10-19 (WS-T review round 3): Addressed `loop/T/review-n2.md` (one blocking item). No contract change, no file outside the owned list, no new dependency.
1. **Blocking, `main` still exited on a dispatch error.** `export def --wrapped main` wrapped `dispatch-script-args` in `try`/`catch` and called `exit 1`. With `use dev/dev-test.nu *` the bare name `dev-test` is bound to `main`, so every unmatched call reaches it: `dev-test bogus` or a typo like `dev-test unti` ended the caller's Nushell session, and the comment claiming "only script mode reaches this entry point" was wrong. The `try`/`exit 1` is gone; the error propagates, which keeps module mode catchable (`try { dev-test bogus } catch { print caught }; print after` prints both lines) and still makes script mode exit 1 (`nu dev/dev-test.nu bogus` exits 1 with the unknown-subcommand message; Nushell gives an uncaught `error make` in a script status 1). The comment now says both modes land there and why `exit` must not be used. This supersedes the round-2 sentence "`main` is the only place that exits".
- `check-module-mode` no longer allows a window for `main`: any `exit` is a problem, including an inline one such as `catch { …; exit 1 }` (the scan drops comment lines, then matches `exit` at the start of a line or after `;`/`{`). The entry-point slicing (`entry`/`next`) is gone.
- New probes: module mode `try { dev-test bogus } catch { print 'caught' }; print 'after'` must print both lines with exit 0, next to the existing `vm` probe; script mode `nu dev/dev-test.nu bogus` must exit non-zero with the unknown-subcommand reason, so the "script mode still fails" guarantee is tested rather than assumed. `run-steps`' doc comment now says it raises (the process exits non-zero).
- Mutation-checked: restoring `try { … } catch { exit 1 }` in `main` fails the self-check on the `exit` line, and the module-mode `bogus` probe fails on its own.
- Handoff 2026-10-19 (WS-T review round 3 -> all): unchanged commands and subcommand names. `nu dev/dev-test.nu self-check` now fails if any line calls `exit` at all (including in `main`), if a message interpolates a call to `exit`, if a failing step or an unknown subcommand is not catchable in module mode, if `nu dev/dev-test.nu bogus` does not exit non-zero, or if the filter cache is not anchored on the repo root. Merger items from round 2 (stale `dev/test.nu` in other streams' plan files, `TODO.md` T7) stand.