Skip to content

fix(mip): dump --stacks; remove the dead HostPath build dep variant - #842

Merged
norrietaylor merged 2 commits into
mainfrom
inbox-patch/dump-stacks-hostpath-17ee74b735356ff1
Jul 20, 2026
Merged

norrietaylor merged 2 commits into
mainfrom
inbox-patch/dump-stacks-hostpath-17ee74b735356ff1

Conversation

@gominimal-aw-bot

@gominimal-aw-bot gominimal-aw-bot Bot commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #838
Routing-Key: inbox-route/I_kwDOSUhdos8AAAABJPmOPg

Problem

crates/mip/src/cmd_dump.rs had two reachable todo!() macros that panicked at runtime on advertised flag combinations:

  1. The output dispatch in cmd_dump() only handled DumpKind { packages: true, stacks: false }; mip dump --stacks (the required-group alternative to -p/--packages) fell through to todo!("output not implemented: {:?}", args.kind).
  2. pkg_ref_from_input() matched only Build, Local, Subset, and Source, so a BuildDep::HostPath — the one remaining BuildDep variant — hit _ => todo!("bsi variant {:?}", i). Any package with a host-path build dep panicked the dump.

Fix

This PR is two commits:

1. fix(mip): dump --stacks and HostPath deps instead of panicking
Adds a --stacks output branch that collects stacks via graph.iter_stacks(), applies the same --name/--exact filter the packages path uses, and sorts by name (stacks live in a HashMap, so deterministic ordering matters). The filtering/sorting is factored into a small pure select_stacks helper — mirroring how #146 extracted resolve_target so cmd_dump internals stay unit-testable without a Context.

2. refactor(decode,graph,mip)!: remove the unused HostPath build dep variant
Rather than handle the HostPath panic, this removes the variant entirely. BuildDep::HostPath was #[allow(dead_code)] throughout, was never materialized into a build sandbox, and only ever reached a todo!() when dumped — aspirational, never-functional surface. Removing it:

  • Drops the HostPath type and its BuildDep contract arm from the Nickel stdlib (and 'Path from Tys).
  • Removes ObjTy::Path and from_term_hostpath from decode.
  • Removes the BuildDep::HostPath variant and every match arm across graph (loader, spec_hasher, transitives, planner, graph, wire). The matches over BuildDep are now exhaustive without a wildcard, so a future variant fails to compile instead of reintroducing a runtime panic.
  • Removes NodeData::HostPath and the --hostpath-deps flag from mip dep, and reverts the PkgRef::HostPath mapping added in commit 1.

The two golden-hash tests in graph::spec_hasher that used a HostPath build dep as filler now construct their spec in Rust instead of via Nickel, so the hash is deterministic across architectures and no longer needs the arch_hash! macro.

BREAKING CHANGE: the HostPath build-dep type is removed from the Nickel stdlib; a .ncl using | HostPath no longer parses. It was non-functional (never built; dumping it panicked), so no working configuration is affected.

Verification

All commands run from the workspace root:

  • cargo fmt --all — clean, no drift.
  • cargo clippy --workspace --all-targets -- -D warnings — exit 0, no warnings.
  • cargo test --workspace — exit 0; every test binary passed. The rewritten attrs_hash / subset_hash golden-hash tests pass with single architecture-independent hashes.

Generated by inbox-patch · ◷

`mip dump --stacks` and any package with a `HostPath` build dep both
reached `todo!()` macros in `cmd_dump` and panicked at runtime, even
though the flag parses and the dependency is valid.

Implement the `--stacks` output branch: collect stacks from the graph,
filter them by the shared `--name`/`--exact` query, and sort by name so
the JSON dump is stable across runs (stacks live in a `HashMap`). The
`DumpKind` clap group is `required = true, multiple = false`, so the
remaining match arm is genuinely unreachable.

Map `BuildDep::HostPath` to a new `PkgRef::HostPath` variant in
`pkg_ref_from_input`, making the match exhaustive over every `BuildDep`
variant so a future addition fails to compile rather than panic.
@coderabbitai

coderabbitai Bot commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a5a68829-bd8b-4a6c-8cf0-7ba3f38eefa3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

…iant

The `HostPath` build-dep was `#[allow(dead_code)]` throughout, was never
materialized into a build sandbox, and only ever reached a `todo!()` when
a package carrying one was dumped. Rather than handle that panic (as the
previous commit did for `mip dump`), remove the variant outright:

- Drop the `HostPath` type and its `BuildDep` contract arm from the
  Nickel stdlib (and `'Path` from `Tys`).
- Remove `ObjTy::Path` and `from_term_hostpath` from decode.
- Remove the `BuildDep::HostPath` variant and every match arm across
  graph (loader, spec_hasher, transitives, planner, graph, wire).
- Remove `NodeData::HostPath` and the `--hostpath-deps` flag from
  `mip dep`, and revert the `PkgRef::HostPath` mapping in `mip dump`
  (the match over `BuildDep` is now exhaustive without it).

The two golden-hash tests in `graph::spec_hasher` that used a HostPath
dep as filler now build their spec in Rust, so the hash is deterministic
across architectures and no longer needs the `arch_hash!` macro.

BREAKING CHANGE: the `HostPath` build-dep type is removed from the Nickel
stdlib; a config using `| HostPath` no longer parses. It was
non-functional (never built; dumping it panicked), so no working
configuration is affected.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@norrietaylor norrietaylor changed the title fix: dump --stacks and HostPath build deps instead of panicking fix(mip): dump --stacks; remove the dead HostPath build dep variant Jul 20, 2026
@norrietaylor
norrietaylor marked this pull request as ready for review July 20, 2026 21:39
@norrietaylor
norrietaylor merged commit 6b329be into main Jul 20, 2026
28 checks passed
@norrietaylor
norrietaylor deleted the inbox-patch/dump-stacks-hostpath-17ee74b735356ff1 branch July 20, 2026 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mip dump panics with todo!() for --stacks and unhandled BuildDep variants

2 participants