Skip to content

feat(vis): answer the archivedRepo marshall of vis inspect natively - #264

Open
prisis wants to merge 1 commit into
t3/native-inspect-downloadsfrom
t3/native-inspect-archived-repo
Open

prisis wants to merge 1 commit into
t3/native-inspect-downloadsfrom
t3/native-inspect-archived-repo

Conversation

@prisis

@prisis prisis commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

What

vis inspect <package> --json runs the archivedRepo marshall natively. Stacked on #262 (t3/native-inspect-downloads): it shares the service cache reader, the Services addresses in Context and the gate edits. Merge #262 first, then retarget this PR to next (GitHub does it by itself only when merged branches are deleted). Followed by #265 and #266.

With both PRs, the default set minus expiredDomains (MARSHALL_DISABLE_EXPIRED_DOMAINS=1) runs natively. The plain default set still starts Node, until expiredDomains is native.

Behaviour

  • Resolves the inspected version's repository.url (falling back to the last version's entry as Node does) to owner/repo with the four shapes Node reads. The Rust reader is checked against a recorded corpus of 70 inputs run through the TypeScript function (native/cli/tests/fixtures/github-urls.json): trimming, git+, ASCII case folding, .git/.GIT/trailing slash, subpaths, query and fragment, empty owner or name, non-GitHub hosts.
  • Reads ~/.vis/cache/archived-repo/<owner>__<repo>.json (24 hours) or asks https://api.github.com/repos/<owner>/<repo> once with Accept: application/vnd.github+json, User-Agent: visulima-vis-marshall and Authorization: Bearer <GITHUB_TOKEN> when that variable is set and not empty. Archived: a warning (is archived (since …)); 404: a warning (returned 404 from GitHub); 200 and 404 are cached in the bytes JSON.stringify writes (archivedAt kept when GitHub sends a string, also for a repository that is not archived, as Node does); a rate limit, a server error and a null body are no finding and nothing is cached.
  • The launcher gate (bin/route.mjs) accepts archivedRepo; the routing fixture rows and native-routes.snap are updated.

Handed to Node before any output or write

A request that fails before an answer, a redirect (GitHub answers a renamed repository with one, so renamed repositories go through Node), a body that is not JSON the binary reads, a GITHUB_TOKEN that is not visible ASCII (checked only when a request would carry it), an owner or repository outside [A-Za-z0-9._-] (what encodeURIComponent and the URL parser would rewrite), a cache entry that is not what Node writes.

No environment override for the GitHub address; it is a field of Context (loopback stub in the unit tests).

Proof

  • cargo test -p vis-cli: unit tests against a loopback stub (headers with and without a token, every status class, archived with and without a date, cache bytes, fresh and stale entries, last-version fallback, other hosts, hand-overs); cargo fmt --all --check, cargo clippy -p vis-cli --all-targets -- -D warnings, cargo deny check clean; no dependency added.
  • __tests__/native/inspect-parity.test.ts: native vs Node on cached states (archived with and without a date, missing, not archived), on every repository shape of the stub packuments (urls@1.0.0 … 1.7.0, odd-url, dangling, null-repository), and hand-overs of entries Node prints through JavaScript. With Node's fetch replaced, the same file asserts findings, cache bytes and the request headers (with and without GITHUB_TOKEN) for each GitHub answer; the Rust tests assert the same text.
  • Live, scratch workspace, separate temp homes: @visulima/path identical on both sides (stdout and cache bytes); left-pad's repository was renamed, GitHub answered 301, so the binary handed the run to Node, which printed the same report.
  • Unverified locally: Linux.

🤖 Generated with Claude Code

…atively

`vis inspect <package> --json --only archivedRepo` now runs without Node, and
with it the default set minus `expiredDomains`.

The marshall resolves the inspected version's `repository.url` to a GitHub
`owner/repo` (the same four URL shapes, ASCII case folding, the lazy `.git` and
trailing-slash rules; the corpus in `tests/fixtures/github-urls.json` records
what the JavaScript pattern returns for each), reads the cached state
(`~/.vis/cache/archived-repo`, 24 hours) or asks `api.github.com/repos/<owner>/<repo>`
once with the same headers, `GITHUB_TOKEN` included, and reports an archived
repository or a 404. A rate limit, a server error and a `null` body are no
finding and nothing is cached; every other answer is cached in the bytes Node
writes.

Handed to Node before any output or write: a request that fails before an
answer, a redirect (a renamed repository), a body that is not JSON, a token that
is not visible ASCII, an owner or name outside `[A-Za-z0-9._-]`, and a cache
entry that is not what Node writes.

The launcher gate accepts `archivedRepo`; a run that executes `expiredDomains`
or `signatures` still stays in Node.

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

coderabbitai Bot commented Nov 26, 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: 6bbd8763-7a27-4a07-bd38-4cc201cff581

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 26, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Run archivedRepo checks natively in vis inspect JSON reports

✨ Enhancement 🧪 Tests 🕐 40+ Minutes

Grey Divider

AI Description

• Adds native archivedRepo checks so eligible JSON inspections no longer require Node.
• Matches Node’s GitHub warnings, authentication, and 24-hour cache behavior; delegates uncertain
 cases safely.
• Expands routing and parity tests while keeping expiredDomains-dependent runs in Node.
Merge Risk 🟡 Medium

Blast radius 🟢 Low 💥 1 capability

  • 1 affected end-to-end capability after fault-specific containment; implementation boundaries do not widen its functional scope.
  • The route, native GitHub lookup, report finding, and repository cache all implement one end-to-end inspect behavior: warning users when a package's source repository is archived or missing.
  • They are technical hops within one bounded inspection integration, not independent capabilities.
Sources

packages/tooling/vis/bin/route.mjs[1122-1126]

// be among the seven the binary has (`INSPECT_NATIVE_MARSHALLS`: the five that read the packument alone, `downloads`, which asks the
// registry's download API, and `archivedRepo`, which asks GitHub): `expiredDomains` and `signatures` ask other services, so a plain
// `vis inspect <package> --json` stays in Node. The binary re-checks everything, including the registry and the packument.
const INSPECT_MARSHALLS = ["author", "provenance", "s1ngularity", "newBin", "metadata", "downloads", "expiredDomains", "signatures", "archivedRepo"];
const INSPECT_NATIVE_MARSHALLS = new Set(["archivedRepo", "author", "downloads", "metadata", "newBin", "provenance", "s1ngularity"]);
Behavioral complexity 🟡 Medium 🧩 Interacting branches, Compatibility cases

  • Before, archivedRepo ran through the Node implementation.
  • After, eligible invocations may use Rust and must preserve Node behavior across routing gates, repository URL forms, fresh versus stale cache entries, GitHub status/body classes, token handling, and Node handoff cases.
  • The new correctness conditions are agreement across native and Node implementations and consistent cache/report behavior across those states; these are materially interacting compatibility branches rather than routine use of an existing helper.
Sources

packages/tooling/vis/bin/route.mjs[1122-1126]

// be among the seven the binary has (`INSPECT_NATIVE_MARSHALLS`: the five that read the packument alone, `downloads`, which asks the
// registry's download API, and `archivedRepo`, which asks GitHub): `expiredDomains` and `signatures` ask other services, so a plain
// `vis inspect <package> --json` stays in Node. The binary re-checks everything, including the registry and the packument.
const INSPECT_MARSHALLS = ["author", "provenance", "s1ngularity", "newBin", "metadata", "downloads", "expiredDomains", "signatures", "archivedRepo"];
const INSPECT_NATIVE_MARSHALLS = new Set(["archivedRepo", "author", "downloads", "metadata", "newBin", "provenance", "s1ngularity"]);
Potential damage 🟡 Medium 🩹 Incorrect results

  • If the native implementation diverges from Node in URL parsing, GitHub response handling, routing, or cache interpretation, inspection may emit a missed or spurious advisory warning.
  • The consequence is limited to inspection correctness; no package or runtime state is changed.
  • The same cache format is shared with Node, so a bad cached result could persist until expiry or cache clearing.
  • Reverting the native route stops new native results, but an already-written incorrect repository cache entry may still be read by Node or later native runs; expiry or explicit cache clearing may be needed.
Sources

packages/tooling/vis/bin/route.mjs[1122-1126]

// be among the seven the binary has (`INSPECT_NATIVE_MARSHALLS`: the five that read the packument alone, `downloads`, which asks the
// registry's download API, and `archivedRepo`, which asks GitHub): `expiredDomains` and `signatures` ask other services, so a plain
// `vis inspect <package> --json` stays in Node. The binary re-checks everything, including the registry and the packument.
const INSPECT_MARSHALLS = ["author", "provenance", "s1ngularity", "newBin", "metadata", "downloads", "expiredDomains", "signatures", "archivedRepo"];
const INSPECT_NATIVE_MARSHALLS = new Set(["archivedRepo", "author", "downloads", "metadata", "newBin", "provenance", "s1ngularity"]);
Assessed commit f3de88c
Diagram

graph TD
  G["Launcher gate"] --> D{"Eligible run?"} -->|yes| N["Native inspect"] --> P["Repository parser"] --> C["Service cache"] -->|miss| H["GitHub API"] --> R["JSON report"]
  C -->|fresh| R
  D -->|no| J["Node inspect"] --> R
  N -->|unsafe case| J
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Delegate GitHub cache misses to Node
  • ➕ Avoids duplicating GitHub request and response behavior in Rust.
  • ➖ Requires Node for uncached repositories, defeating the primary native-inspection goal.

Recommendation: Keep the native implementation: it reuses the service-cache pattern, covers cache misses without Node, and delegates cases where parity is uncertain. Merge its prerequisite #262 first.

Files changed (8) +891 / -22

Enhancement (3) +359 / -10
route.mjsAllow archivedRepo through the native inspect gate +4/-4

Allow archivedRepo through the native inspect gate

• Adds archivedRepo to the launcher’s supported marshall set. Runs requiring expiredDomains or signatures still route to Node.

packages/tooling/vis/bin/route.mjs

archived_repo.rsImplement the native archivedRepo marshall +323/-0

Implement the native archivedRepo marshall

• Resolves GitHub repository URLs, reads or fetches repository status, and emits archived or missing-repository warnings. Mirrors Node’s cache format and delegates requests, responses, tokens, URLs, or cache entries it cannot safely reproduce.

packages/tooling/vis/native/cli/src/inspect/archived_repo.rs

mod.rsWire archivedRepo into native inspection +32/-6

Wire archivedRepo into native inspection

• Adds the GitHub service address and token to inspection context and permits archivedRepo in native marshall selection. Incorporates its findings and deferred cache actions into the existing inspection plan.

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

Tests (5) +532 / -12
inspect-parity.test.tsVerify archivedRepo behavior against Node +127/-8

Verify archivedRepo behavior against Node

• Adds native-versus-Node checks for cached warnings, repository metadata, and handoffs. Records Node’s stubbed service requests to verify GitHub headers, responses, and cache bytes.

packages/tooling/vis/tests/native/inspect-parity.test.ts

tests.rsExercise GitHub status, caching, and fallback paths +330/-1

Exercise GitHub status, caching, and fallback paths

• Adds loopback tests for findings, headers, cache freshness and bytes, unsupported inputs, and finding order. Tests both successful native answers and cases delegated before output.

packages/tooling/vis/native/cli/src/inspect/tests.rs

github-urls.jsonRecord Node’s GitHub URL parsing results +70/-0

Record Node’s GitHub URL parsing results

• Adds a 70-input corpus covering supported URL forms, case and suffix handling, malformed URLs, and names requiring delegation. The Rust parser test checks its results against this corpus.

packages/tooling/vis/native/cli/tests/fixtures/github-urls.json

native-routes.snapUpdate the inspect routing snapshot +1/-0

Update the inspect routing snapshot

• Records the archivedRepo-plus-expiredDomains inspect invocation in the routing snapshot.

packages/tooling/vis/native/cli/tests/fixtures/native-routes.snap

routing.jsonUpdate native eligibility routing cases +4/-3

Update native eligibility routing cases

• Marks archivedRepo selections and the default set without expiredDomains as launcher-native. Keeps combinations requiring expiredDomains on Node and documents fixture-driven binary handoffs.

packages/tooling/vis/native/cli/tests/fixtures/routing.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 tweak Display settings with a live preview to see your comment before it ships

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@prisis
prisis deployed to benchmarks November 26, 2026 00:15 — with GitHub Actions Active
@github-actions github-actions Bot added vouch:trusted PR author is a collaborator, a bot or on the VOUCHED list. size:XL Size of the change, tests and generated files excluded. labels Nov 26, 2026
@codspeed

codspeed Bot commented Nov 26, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 3 untouched benchmarks
⏩ 113 skipped benchmarks1


Comparing t3/native-inspect-archived-repo (f3de88c) with t3/native-inspect-downloads (60bdb3e)

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. ↩

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for following the naming conventions! 🙏

This branch was successfully deployed

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

Labels

package: vis size:XL 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