Skip to content

refactor(update): one descriptor per lockfile tool - #221

Merged
sweepies merged 2 commits into
mainfrom
refactor/lockfile-tools
Nov 9, 2026
Merged

sweepies merged 2 commits into
mainfrom
refactor/lockfile-tools

Conversation

@sweepies

@sweepies sweepies commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Thirteenth in the untangle series.

Why

crates/update/src/lockfiles* stated per-ecosystem facts in many places that had to agree:

  • Tool inventory: versions() hardcoded about 15 tools that had to match defaults.toml, tools::defaults(), SEEDABLE, the caches bins and nix::BUILDS. defaults.toml was parsed in four places.
  • Pin-file search: "nearest config at or above a directory" was written four ways, relying on an unstated path-prefix invariant.
  • Stringly values: cache partitions were string prefixes. The GOFLAGS merge was split between two files by a literal key, and the installation-or-CLI-token fallback was duplicated.
  • Jobs: Job encoded "targeted or whole directory" in Option fields, built three ways.
  • A bug: .tool-versions was honoured by mise.lock but ignored for tool versions, so a repository pinning node there got lock runs on the default node.
  • Leftovers: a discarded (Invocation, bool) value, NodeContext built five times, and a test-only Runner::prepare.

What

  • A Tool descriptor per lockfile ecosystem: steers, tools, versions and install, behind one exhaustive descriptor(Ecosystem). tools::defaults() and versions()'s tool list derive from the descriptors.
  • defaults.toml parsed once (OnceLock), with nix's pin moved into it.
  • One nearest-pin search: upward() / nearest_dir() replace the four implementations, with mise's precedence (.mise.toml > mise.toml > .tool-versions in a directory, deeper over shallower).
  • Scope enum for jobs: Directory | Package { package, current, target }. It serializes to the old flat fields in the old order, so job identities, maintenance fingerprints, branches and plan hashes are byte-identical (pinned by lock_jobs_keep_their_serialized_field_layout).
  • Typed Partition: Public | Private(hash) | Installation(id), whose Display reproduces today's directory names. prune parses them.
  • One function each for the token fallback (github_token) and the GOFLAGS merge (caches::goflags).
  • Leftovers removed: the discarded bool, the repeated NodeContext and Runner::prepare.

Behaviour change

.tool-versions pins now apply to lockfile tool versions, as the lockfiles guide already says. A test is added.

Real-tool tests (mise run test:tools): 18 passed.

View guided diff Turn on auto-fix

Each lockfile ecosystem now declares a single Tool descriptor beside its
implementation: the managers that steer its fetches, the tool versions it
resolves, whether it resolves them at all, and how its pins install.
descriptor() maps Ecosystem exhaustively, so a new ecosystem fails to
compile until it has one, and tools::defaults(), versions() and the
driver's dispatch all read the descriptors instead of duplicating the
inventory.

- Job's targeted-vs-directory shape is a Scope enum; custom serde keeps
  the flat package/current/target wire fields so job identities and the
  hashes they feed stay byte-identical.
- "Nearest file at or above a directory" is one upward()/nearest_dir()
  helper over snapshot paths, used by job(), versions(), .python-version,
  global.json and the pin readers.
- versions() takes its tool list from the descriptors and now honours
  .tool-versions under mise's precedence (.mise.toml > mise.toml >
  .tool-versions, deeper over shallower); docs already described it.
- defaults.toml is parsed once behind a cache and now also pins nix;
  mise.rs no longer re-parses the embedded file.
- Cache partitions are a typed Partition whose Display reproduces the
  public/private-<hash>/installation-<id> directory names exactly, and
  prune() matches on parsed partitions. The GOFLAGS merge lives in
  caches.rs and the installation-or-CLI token fallback in one
  github_token().
- NodeContext is built once per (ecosystem, directory) group; the cargo,
  go and terraform bodies moved into their own modules; the discarded
  python bool is gone and Runner::prepare is deleted (tests use
  prepare_all).

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 22 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread crates/update/src/lockfiles/nix.rs Resolved
Comment thread crates/update/src/lockfiles/tests.rs Resolved
@sweepies
sweepies merged commit 6f1b7f2 into main Nov 9, 2026
12 checks passed
@sweepies
sweepies deleted the refactor/lockfile-tools branch November 9, 2026 14:14
@sweepies-ops sweepies-ops Bot mentioned this pull request Nov 9, 2026
sweepies added a commit that referenced this pull request Nov 10, 2026
…g every path (#234)

* perf(update): find the nearest lockfile by walking up, not by scanning every path

#221 replaced the directory walk #201 introduced with a filter over every
path in the repository, once per dependency. On grafana, mastodon and
sentry that put the warm policy phase at 1.3 s instead of 0.3 s.
upward now walks from the directory to the root and looks each candidate
up; it takes a lookup-only Paths trait, so it cannot scan again.

* test(update): pin upward's root-first, name-ordered results
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.

1 participant