Skip to content

refactor(vis): split run.rs - #244

Merged
prisis merged 8 commits into
nextfrom
refactor/vis-split-run
Nov 25, 2026
Merged

prisis merged 8 commits into
nextfrom
refactor/vis-split-run

Conversation

@prisis

@prisis prisis commented Nov 25, 2026

Copy link
Copy Markdown
Member

Stacked on #242 (which is stacked on #241): this branch contains their commits, so merge those first. The diff of this PR alone is the last four commits.

What

native/cli/src/run.rs (1142 lines) is split into a run/ directory, and the remaining small items of the same review are done.

Old location New home
run.rs environment, working-directory, lockfile, pin checks, nothing_to_sweep run/preflight.rs
run.rs first half of attempt run/preflight.rs::gates
run.rs workspace read of attempt run/mod.rs::projects
run.rs version questions and re-check of attempt run/mod.rs::probe_and_recheck
run.rs Look, Grouping, Answer::stdout, describe, layout_fits, gitlab_section_key, seconds_text run/render.rs
run.rs Answer::summary, iso, and the private Json writer run/summary_json.rs, on sort_package_json::json::{Json, stringify}
run.rs parse, Hit, Answer, look_up_all, sort_times, write_summary, run run/mod.rs
run::plain run::is_target_word, on text::is_ascii_graphic
launcher_version: Option and node_command: Option with an unreachable (None, None) arm enum NodeVersion { Launcher(String), Probe(PathBuf) }
!all(!exists) any(exists)
cache_why::table (128 lines) render_header, render_trace_reasons, render_diff
run::SWEEP_WINDOW, cache_prune::DEFAULT_MAX_CACHE_AGE, cache_prune::V2_ROOT, and the dot-file and v2 check in both cache::entries::{DEFAULT_MAX_CACHE_AGE, is_sweep_candidate}
toolchain::matches_all matching the operator text twice toolchain::Operator

Differences found between former copies

None that changes behaviour. The two sweep windows were both seven days (cache prune held it as 7.0 * 24.0 * 60.0 * 60.0 * 1000.0 milliseconds, which DEFAULT_MAX_CACHE_AGE.as_secs_f64() * 1000.0 equals exactly). The private JSON writer and stringify agree on indentation, empty containers and escapes; run writes the same text, with no trailing newline.

Tests: the Json unit test is dropped with the writer (stringify has its own); the_summary_is_written_like_json_stringify_with_the_hits_in_project_order checks the written summary's shape, the project order of taskGraph and the tasks entries; the run tests moved with the code they cover.

Not done from the review, left for a later change: the hand-built JSON in cache list and cache size and summary::json_text (the run writer is the only one unified here), and the printable-ASCII predicates of modules outside the cache commands (keys_refresh, self_update, deps). The sweep predicate is named is_sweep_candidate rather than sweep_candidates, because it tests one name.

What ran locally

  • cargo fmt, cargo clippy -p vis-core -p vis-cli --all-targets -- -D warnings: clean.
  • cargo test --workspace in packages/tooling/vis/native: all pass (vis-cli: 492 unit tests).
  • With the addon rebuilt, a fresh debug vis copied over vis-native-cli and FORCE_COLOR=3: vitest run-all-hit, cache-prune, cache-clean, cache-inspect, cache-hash, summary-commands, route and routing-fixture parity files: 2474 tests passed in one run; cache-inspect (one 10-minute test) timed out in that run while the machine was loaded and passed alone in 83 s.

🤖 Generated with Claude Code

prisis and others added 7 commits November 25, 2026 00:54
`clean`, `cache clean`, `cache hash`, `cache why` and `replay` each defined
their own stdout, stderr and status struct and wrote it through a private
writer. `output::Output` holds them once, with `say` for a pail block on
the stream its level uses and `emit` built on `write_streams`. No behaviour
change.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
cache_hash.rs doubled as the run-summary schema, the collation library
and a second loader, and `cache why` and `replay` copied its failure
outputs. The schema (`Details`, `Fingerprint`, `Task`, `Summary`, the
probes) moves to `run_summary`, the root collation to `collation`.
`cache hash` now reads through `summary::{context, load_summary,
find_task}` like the other two, with `Ordered<V>` replacing its own
`Bucket` and `Lists`. The "no summary" and "task not in run" blocks, the
failure JSON, `json_text` and the run id check each live once in
`summary`.

Differences between the former copies, each now the stricter one so Node
answers where the two disagreed: a summary file or task entry that is a
JSON array (serde reads a sequence into a struct, JavaScript does not),
and a workspace root containing a backslash, which `cache hash` did not
check. `Ordered` rejected an empty key where `cache hash` kept it; Node
prints both the same, so `Ordered` keeps it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
`replay`, `cache why` and `cache hash` answer natively for a summary whose
environment, stats or hash inputs hold a `""` key. The parity suites now
prove those answers equal Node's.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
`matches_all` matched the operator text twice, once to strip it and once to
pick the comparison. An `Operator` enum now splits the clause and decides
whether it holds. No behaviour change.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
`table` was 128 lines of header, trace-mode reasons and diff. It now
orchestrates `render_header`, `render_trace_reasons` and `render_diff`.
No behaviour change.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
`vis run` and `cache prune` each held the seven-day window and the rule
that dot files and the `v2` store are not swept. They now read
`DEFAULT_MAX_CACHE_AGE` and `is_sweep_candidate` from `cache::entries`. No
behaviour change.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
run.rs (1142 lines) becomes a `run/` directory: `preflight` (the process,
working-directory, lockfile and pin checks that run before a workspace file
is read, and the sweep check), `render` (the static renderer's lines and
the layout checks), `summary_json` (`.vis/last-summary.json`) and `mod`
(parse, the lookups, `attempt`, `run`).

`attempt` was 128 lines of seven phases; it is now `gates`, `projects` and
`probe_and_recheck` around the lookups. The Node version of the summary was
two options with an arm for "neither" that could not be reached; it is an
`enum NodeVersion { Launcher, Probe }`. `!all(!exists)` reads as
`any(exists)`. The summary is built with the shared ordered JSON writer
instead of a private one, and the target-name predicate is built on
`text::is_ascii_graphic`. No behaviour change: the summary bytes are the same.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

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

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c5a0e798-1a56-4cf0-81eb-eaeb6048c947

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
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@qodo-code-review

qodo-code-review Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Split native run and cache modules into focused components

✨ Enhancement 🧪 Tests 🕐 40+ Minutes

Grey Divider

AI Description

• Split native run and cache implementations into focused modules while preserving Node delegation
 behavior.
• Centralize summary parsing, output, cache paths, sweep rules, and text predicates to remove
 duplication.
• Add parity coverage for empty JSON keys and verify generated run-summary ordering.
Merge Risk 🟡 Medium

Blast radius 🔴 High 💥 4 capabilities

  • 4 affected capabilities span independent functional scopes: native_cache_operations, native_cli_command_integration, native_recorded_summary_tools, native_run_execution.
  • Listing, sizing, cleaning and pruning all operate on the bounded cache-management integration and share the cache directory, settings and entry model.
  • The cache directory, entry and formatter modules are implementation hops in that same end-to-end behavior, not independent capabilities.
  • Task keying, cache lookup, cached terminal-output replay, run rendering and summary persistence jointly implement one user-visible cached run.
  • The summary writer and render/preflight modules are propagation hops of that behavior, not separate capabilities.
  • Replay, cache hash and cache why are distinct user operations over the same bounded recorded-run integration and shared summary schema.
  • They share storage and parsing infrastructure but produce distinct diagnostic and replay outcomes within one functional scope.
  • The changed dispatch and shared output, text and toolchain helpers support several native command entry points, but they remain one bounded CLI integration surface.
  • The individual command modules are consumers of those shared runtime paths; no evidence requires treating each technical module as an independent functional scope.
Behavioral complexity 🔴 High 🧩 Multiple interactions

  • Before, the Node path governed these run transitions.
  • After, the native path combines parallel task keying and lookups, deterministic task ordering, cache-entry eligibility, preflight/toolchain and lockfile rechecks, output layout, summary persistence and Node handback.
  • New correctness conditions are that every task corresponds to the same key and cache entry, no output or summary is emitted before all gates pass, and rendered task order and metadata agree with the persisted summary.
  • Compatibility also applies to the Node-generated cache and summary formats.
Potential damage 🟡 Medium 🩹 Temporary loss

  • If the native cache-management behavior regresses, users can lose cache inspection or maintenance capability, or may need to rebuild cache entries after an erroneous removal.
  • Cache contents are derived artifacts; restoring code does not restore deleted entries, while normal task execution can rebuild them.
  • No external business effect is supported by the inspected path.
  • Revert or delegate the command to Node to restore future operation.
  • Deleted cache entries require subsequent task execution or manual cache restoration; automatic repair is not established.
Assessed commit 5cf612e
Diagram

graph TD
  CLI["Native CLI"] --> Run["Run orchestration"] --> Gates["Preflight gates"] --> Cache["Cache modules"]
  Run --> Writer["Summary writer"]
  CLI --> Commands["Summary commands"] --> Reader["Summary reader"]
  Commands --> Cache
Loading
High-Level Assessment

The focused module split and shared helpers are appropriate for a behavior-preserving review. Unifying the other hand-built cache JSON outputs would expand the parity surface, so leaving that for a separate change is sensible.

Files changed (34) +3595 / -1115

Refactor (30) +3480 / -1115
dirs.rsExtract cache directory and scope resolution +446/-0

Extract cache directory and scope resolution

• Moves path resolution, worktree and branch scoping, eviction directory selection, store paths, and scope/target values into one module. Adds a shared default task-cache path.

packages/tooling/vis/native/cli/src/cache/dirs.rs

entries.rsExtract cache entries, statistics, and sweep rules +267/-0

Extract cache entries, statistics, and sweep rules

• Owns entry collection, size accounting, store statistics, and the shared seven-day sweep window and candidate predicate.

packages/tooling/vis/native/cli/src/cache/entries.rs

flags.rsShare valued-flag parsing across cache commands +79/-0

Share valued-flag parsing across cache commands

• Provides the common inline-or-next-token parser and rejects missing, repeated, empty, or dash-led values.

packages/tooling/vis/native/cli/src/cache/flags.rs

format.rsExtract cache size, date, and age formatting +120/-0

Extract cache size, date, and age formatting

• Moves Node-compatible human-readable byte sizes, ISO timestamps, and entry ages out of the cache command module.

packages/tooling/vis/native/cli/src/cache/format.rs

mod.rsKeep cache list and size orchestration in the module root +379/-0

Keep cache list and size orchestration in the module root

• Retains argument parsing, list and size rendering, workspace gating, and command dispatch while calling the extracted cache modules.

packages/tooling/vis/native/cli/src/cache/mod.rs

settings.rsExtract cache configuration reading +60/-0

Extract cache configuration reading

• Reads supported literal workspace configuration for cache directory, branch scoping, and worktree sharing; dynamic or unsupported cases remain delegated to Node.

packages/tooling/vis/native/cli/src/cache/settings.rs

cache_clean.rsReuse shared cache parsing, paths, and output +27/-81

Reuse shared cache parsing, paths, and output

• Replaces local flag, target, path-suffix, printable-text, and output helpers with the extracted cache, text, and output modules.

packages/tooling/vis/native/cli/src/cache_clean.rs

cache_hash.rsMove summary parsing and collation out of cache hash +31/-686

Move summary parsing and collation out of cache hash

• Uses shared summary loading, failure output, collation, and text predicates. Resolves tracked fingerprints through the shared default task-cache path.

packages/tooling/vis/native/cli/src/cache_hash.rs

cache_prune.rsShare cache-prune flags and sweep eligibility +17/-35

Share cache-prune flags and sweep eligibility

• Uses extracted flag and scope parsing, the common seven-day age and sweep predicate, and the shared single-line layout check.

packages/tooling/vis/native/cli/src/cache_prune.rs

cache_why.rsSeparate cache-why table rendering and share failures +114/-124

Separate cache-why table rendering and share failures

• Splits the table renderer into header, trace-reason, and diff sections. Reuses summary loading, missing-task outputs, text predicates, and layout checks.

packages/tooling/vis/native/cli/src/cache_why.rs

clean.rsUse shared command output and path validation +12/-37

Use shared command output and path validation

• Replaces its local output type, pail writer, and printable-path check with shared helpers while retaining removal results and exit status.

packages/tooling/vis/native/cli/src/clean.rs

collation.rsExtract Node-compatible ASCII collation +103/-0

Extract Node-compatible ASCII collation

• Moves root-locale detection and printable-ASCII comparison out of cache hash for use by cache and SBOM commands.

packages/tooling/vis/native/cli/src/collation.rs

implode.rsUse extracted cache path helpers +3/-2

Use extracted cache path helpers

• Switches cache workspace and POSIX-path checks to their new cache-module locations.

packages/tooling/vis/native/cli/src/implode.rs

keys_refresh.rsImport the cache directory helper from its new module +1/-1

Import the cache directory helper from its new module

• Points the per-user cache directory import at cache::dirs.

packages/tooling/vis/native/cli/src/keys_refresh.rs

main.rsRegister extracted shared CLI modules +3/-0

Register extracted shared CLI modules

• Declares the new collation, run_summary, and text modules.

packages/tooling/vis/native/cli/src/main.rs

output.rsCentralize native command output and exit handling +26/-0

Centralize native command output and exit handling

• Adds an output container that routes pail levels to the correct stream and writes both streams before exiting with its status.

packages/tooling/vis/native/cli/src/output.rs

pail.rsShare the one-line layout check +16/-0

Share the one-line layout check

• Adds Layout::fits_one_line for the byte-conscious width check used by cache prune and cache why, with a boundary test.

packages/tooling/vis/native/cli/src/pail.rs

replay.rsReuse summary failures and printable-text predicates +27/-69

Reuse summary failures and printable-text predicates

• Uses shared summary paths, run-id validation, missing-summary and missing-task outputs, and ASCII checks instead of local copies.

packages/tooling/vis/native/cli/src/replay.rs

mod.rsRetain native run orchestration and cache-hit tests +530/-0

Retain native run orchestration and cache-hit tests

• Coordinates project discovery, parallel keys and lookups, version probing, summary writing, rendering, and Node handback. Represents launcher versus probed Node versions with an enum and tests the written summary shape and task order.

packages/tooling/vis/native/cli/src/run/mod.rs

preflight.rsIsolate native-run eligibility checks +229/-0

Isolate native-run eligibility checks

• Holds environment, platform, lockfile, pin, cache-directory, and background-sweep checks. Reuses the shared cache sweep predicate and age.

packages/tooling/vis/native/cli/src/run/preflight.rs

render.rsIsolate cache-hit terminal rendering +307/-0

Isolate cache-hit terminal rendering

• Moves CI log grouping, color, task output, duration formatting, and layout checks from the former run module alongside their tests.

packages/tooling/vis/native/cli/src/run/render.rs

summary_json.rsBuild run summaries with the existing JSON serializer +130/-0

Build run summaries with the existing JSON serializer

• Constructs cache-hit summary fields using sort_package_json::json and stringify rather than the former private JSON writer.

packages/tooling/vis/native/cli/src/run/summary_json.rs

run_summary.rsExtract strict recorded-run summary types +339/-0

Extract strict recorded-run summary types

• Centralizes ordered hash-detail and fingerprint schemas, task parsing, raw-task probes, and summary paths. Keeps unsupported or ambiguous JSON shapes eligible for Node delegation.

packages/tooling/vis/native/cli/src/run_summary.rs

bom.rsUse the shared ASCII collation module +1/-1

Use the shared ASCII collation module

• Imports the existing comparison logic from its extracted home instead of cache hash.

packages/tooling/vis/native/cli/src/sbom/bom.rs

mod.rsUse shared collation and path predicates +3/-7

Use shared collation and path predicates

• Switches locale detection to collation and replaces a local printable-path check with the text module helper.

packages/tooling/vis/native/cli/src/sbom/mod.rs

mod.rsReuse the printable ASCII path predicate +2/-6

Reuse the printable ASCII path predicate

• Replaces a local path check with text::is_ascii_graphic_path.

packages/tooling/vis/native/cli/src/sort_package_json/mod.rs

summary.rsCentralize summary loading and failure responses +121/-29

Centralize summary loading and failure responses

• Shares run-id validation, JSON formatting, and missing-summary and missing-task outputs among summary commands. Accepts empty ordered-map keys and tests strict loading of unusual summaries.

packages/tooling/vis/native/cli/src/summary.rs

task_why.rsReuse the target's ASCII graphic check +2/-1

Reuse the target's ASCII graphic check

• Replaces the inline task-id byte predicate with the named text helper.

packages/tooling/vis/native/cli/src/task_why.rs

text.rsName the shared printable-ASCII predicates +34/-0

Name the shared printable-ASCII predicates

• Defines separate checks for graphic ASCII, printable ASCII including spaces, and graphic-ASCII paths, with tests distinguishing their accepted text.

packages/tooling/vis/native/cli/src/text.rs

toolchain.rsRepresent version-range operators explicitly +51/-36

Represent version-range operators explicitly

• Replaces repeated operator-text matching with an Operator enum and uses the shared printable-ASCII check for package-manager pins.

packages/tooling/vis/native/cli/src/toolchain.rs

Tests (4) +115 / -0
cache-hash-parity.test.tsCover empty hash-input keys in cache-hash parity +3/-0

Cover empty hash-input keys in cache-hash parity

• Adds table and JSON parity cases for a recorded run whose hash-input maps contain an empty key.

packages/tooling/vis/tests/native/cache-hash-parity.test.ts

summary-commands-parity.test.tsCover empty keys in replay and cache-why parity +5/-0

Cover empty keys in replay and cache-why parity

• Adds table and JSON cases for summaries containing empty keys in environment, statistics, and hash inputs.

packages/tooling/vis/tests/native/summary-commands-parity.test.ts

empty-key.jsonFixture for empty hash-input keys +54/-0

Fixture for empty hash-input keys

• Adds a recorded task with empty keys in its nodes and runtime hash records for cache-hash parity tests.

packages/tooling/vis/native/cli/tests/fixtures/cache-hash/recorded/.vis/runs/empty-key.json

empty-key.jsonFixture for empty summary-object keys +53/-0

Fixture for empty summary-object keys

• Adds empty keys to environment, statistics, and task hash inputs for replay and cache-why parity tests.

packages/tooling/vis/native/cli/tests/fixtures/run-summaries/odd/.vis/runs/empty-key.json

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can copy the agent prompt from any finding and feed it to your IDE agent

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@github-actions github-actions Bot added vouch:trusted PR author is a collaborator, a bot or on the VOUCHED list. package: vis labels Nov 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for following the naming conventions! 🙏

@github-actions github-actions Bot added the size:XXL Size of the change, tests and generated files excluded. label Nov 25, 2026
@codspeed

codspeed Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

🆕 3 new benchmarks
⏩ 113 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
🆕 transform/transform_ts[470] N/A 355.4 µs N/A
🆕 transform/transform_ts[47000] N/A 16 ms N/A
🆕 transform/transform_ts[9400] N/A 3.3 ms N/A

Comparing refactor/vis-split-run (110dbf2) with next (1078fa9)2

Open in CodSpeed

Footnotes

  1. 113 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on next (a65ddee) during the generation of this report, so 65c051d was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo did not review this PR because this workspace reached its daily trial limit of 100 reviews. Reviews start again at 00:00 UTC. Choose a plan to continue now.

@prisis
prisis deployed to benchmarks November 25, 2026 09:37 — with GitHub Actions Active
@prisis
prisis merged commit a635290 into next Nov 25, 2026
38 of 42 checks passed

This branch was successfully deployed

1 active deployment
benchmarks — 110dbf2b Deployed Nov 25, 2026 by prisis via Bench native (vis) #415
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: vis size:XXL Size of the change, tests and generated files excluded. vouch:trusted PR author is a collaborator, a bot or on the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant