Skip to content

feat(vis): answer the expiredDomains marshall natively; default vis inspect --json runs without Node - #266

Open
prisis wants to merge 2 commits into
t3/native-inspect-signaturesfrom
t3/native-inspect-expired-domains
Open

prisis wants to merge 2 commits into
t3/native-inspect-signaturesfrom
t3/native-inspect-expired-domains

Conversation

@prisis

@prisis prisis commented Nov 26, 2026

Copy link
Copy Markdown
Member

What

expiredDomains runs natively, and with it the default vis inspect <package> --json (no --only) runs without Node in a plain CI context. Stacked on #265 (signatures) → #264 (archivedRepo) → #262 (downloads); the default set does not need signatures, but the branch builds on it because they edit the same gate and test setup. Merge in order; retarget each PR to next as its base lands (GitHub does this only when merged branches are deleted).

How the marshall works, and why it departs from the brief's route

The brief suggested ToSocketAddrs or an existing resolver crate. Neither fits: Node does not use the system resolver for this marshall. new Resolver() with setServers(["1.1.1.1", "8.8.8.8"]) (c-ares) sends the NS query of the domain, as written, to 1.1.1.1 over UDP; /etc/hosts, search domains and the system's servers play no part, and getaddrinfo cannot ask for NS records at all. So the port sends the same query itself (a small hand-written DNS message reader/writer, std::net::UdpSocket, no new dependency).

Behaviour (checked against Node's own resolver, not assumed):

answer of 1.1.1.1 Node native
NOERROR with NS records in the answer section registered registered
NXDOMAIN lapsed (error finding per address) lapsed
NOERROR, no answer record (also: NS only in the authority section) lapsed lapsed
SERVFAIL, REFUSED, FORMERR, NOTIMP failed lookup ("could not verify" warning) hand-over to Node
CNAME or A record only (Node: no data) lapsed hand-over (not read strictly)
truncated Node retries over TCP hand-over
no answer in 2 s Node asks the second server hand-over

Node asks the first server only; the second only when the first gives no answer in time (two-stub test in inspect-dns.test.ts: lapsed/registered/SERVFAIL/silent combinations, 5 rounds each, the second server asked 0 times). Search domains do not apply: with LOCALDOMAIN=search.test RES_OPTIONS=ndots:5, Node still asks only example.test (recorded in the test). RES_OPTIONS=rotate does make Node ask either server first, so native hands over when RES_OPTIONS is set or /etc/resolv.conf has a rotate option.

Extraction as Node does: the part after the last @, JS trim, lower-cased; _npmUser then maintainers; one finding per (domain, address); one lookup per domain; cache expired-domains/<sha256(domain)[..12]>.json {createdAt,outcome,ttlMs} (anything that is not outcome: "ok" reads as lapsed, as Node reads it). Hand-over: a non-ASCII domain, a domain that is not a plain host name of two or more labels (when a query would be needed), a null maintainer, a maintainers that is not an array.

Gate

With every marshall native, bin/route.mjs no longer inspects which marshalls a run executes (INSPECT_NATIVE_MARSHALLS, inspectMarshallIsOff and isTruthyEnv are gone): the default set, --only lists and MARSHALL_DISABLE_* pass when the context is plain (CI, off a terminal, no proxy/CA/Node option, network_environment_is_plain), and the binary hands over what it cannot reproduce. route.rs still needs no change; the routing fixture rows are flipped to launcher: native and the route snapshot gets the two new --only rows.

Cost to know about

On a machine where UDP 53 or 1.1.1.1 is blocked, a run with an uncached domain now spends up to 2 seconds in the native wait before Node repeats everything (Node then waits its own 4 s per domain). Domains are cached for 24 hours when answered.

Proof

  • cargo test -p vis-cli, cargo fmt --all --check, cargo clippy -p vis-cli --all-targets -- -D warnings, cargo deny check: clean. Rust tests run every scenario of tests/fixtures/dns-scenarios.json against a UDP stub on 127.0.0.1 (including a stray answer with another id) and assert the wire bytes of the query.
  • __tests__/native/inspect-dns.test.ts serves the same fixture to Node's Resolver and asserts the classification the fixture names (21 tests, including the two-server and search-domain cases).
  • __tests__/native/inspect-parity.test.ts: native vs Node on the default set, --strict, expiredDomains alone and the eight-marshall list, answered from the seeded caches of all services (no network), plus a version with seven maintainer shapes (same address twice, other address of the same domain, domain in capitals, name without address, string and number in place of an address, gus@), cached outcomes expired/ok/missing/non-string, and the non-ASCII hand-over; identical stdout, exit status and cache files.
  • Live, scratch workspace, separate temp homes, default set with no --only: @visulima/path, lodash@4.17.21 (its maintainer's domain dev.ofcr.se is lapsed: same error finding, exit 1) and tiny-invariant: identical stdout and exit status on both sides; native answered without a Node fallback. --only expiredDomains on left-pad, lodash, @types/node: identical stdout and identical domain cache files.
  • Unverified locally: Linux (the DNS client is plain std UDP; a Linux runner whose resolver settings differ is covered by the RES_OPTIONS/rotate hand-over only).
  • Test-infra note: ~/.t3/shared-target is one path for every worktree; an integration test (tests/routing.rs) failed once when another build replaced debug/vis mid-run and passed on every rerun. The vitest suites use a private copy.

🤖 Generated with Claude Code

…fault `vis inspect --json` without Node

The marshall takes the maintainer addresses of the inspected version (`_npmUser`,
then `maintainers`), lower-cases the domain of each, and asks a resolver for its
NS records. Records mean the domain is registered; "no such domain" and "no
data" mean it lapsed, which is an error finding per address. The answer per
domain is cached for 24 hours in the bytes Node writes.

The query is the one Node's resolver sends to the first of its two servers
(1.1.1.1): one NS question, recursion desired, no EDNS, over UDP. Node asks the
second server only when the first does not answer in time; a clean answer of the
first is final, and so is a SERVFAIL (a failed lookup). The answers read are the
three Node's resolver classifies as registered or lapsed (NS records in the
answer section, NXDOMAIN, NOERROR without an answer record);
`__tests__/native/inspect-dns.test.ts` and `tests/fixtures/dns-scenarios.json`
run every case against Node's own resolver (one and two stub servers) and
against this reader. Anything else goes to Node before any output or write: no
answer within two seconds, a truncated answer, SERVFAIL, REFUSED or another
code, a CNAME or other record in the answer, a domain that is not a plain ASCII
host name of two or more labels, a maintainer that is null, and a machine whose
resolver settings rotate the servers (`RES_OPTIONS` set, or `rotate` in
`/etc/resolv.conf`), where Node does not ask the first server first.

With every marshall native, the launcher gate no longer looks at which ones a
run executes: the default `vis inspect <package> --json`, `--only` lists and
`MARSHALL_DISABLE_*` all pass it when the context is plain (CI, off a terminal,
no proxy, CA or Node option), and the binary hands over what it cannot
reproduce.

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: 205e756c-06d4-481c-8596-a0f20ff3d513

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

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for following the naming conventions! 🙏

@github-actions github-actions Bot added the vouch:trusted PR author is a collaborator, a bot or on the VOUCHED list. label Nov 26, 2026
@github-actions github-actions Bot added the size:XL Size of the change, tests and generated files excluded. label Nov 26, 2026
@qodo-code-review

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

Copy link
Copy Markdown

PR Summary by Qodo

Run default vis inspect JSON reports with native expiredDomains checks

✨ Enhancement 🧪 Tests 🕐 40+ Minutes

Grey Divider

AI Description

• Add native expiredDomains checks so default vis inspect --json can run without Node in plain CI.
• Match Node’s DNS classifications and cache format; hand unsupported responses to Node before
 output or writes.
• Verify resolver behavior and report parity with shared DNS fixtures and local stubs.
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 router, native inspect planner, DNS resolver, and expired-domain cache jointly implement one bounded inspect outcome: detecting maintainer domains that appear unregistered.
  • They are implementation hops of the same user-visible inspection behavior, not independent capabilities.
Behavioral complexity 🟡 Medium 🧩 Multiple interactions

  • Before, expiredDomains was delegated to Node whenever the run needed DNS.
  • After, the native CLI parses DNS wire responses, classifies selected outcomes, caches results, and selectively delegates unsupported cases.
  • New correctness conditions include matching Node's maintainer extraction and outcome semantics, validating DNS identifiers, questions, and records, preserving first-server and timeout behavior, handling fresh versus stale cache state, and ensuring fallback occurs before native output or writes for cases the native path cannot reproduce.
  • The parser is a new transformation rather than routine reuse of an existing mapping helper.
Potential damage 🟡 Medium 🩹 Incorrect results

  • If the native DNS classification, maintainer extraction, fallback decision, or cache interpretation regresses, inspect can report a false expired-domain finding or omit a real one.
  • The effect is limited to inspection output and status; it does not alter package or domain state.
  • Reverting stops new native processing, but already-written cache entries may need removal or expiry before rerunning inspection.
  • Revert restores the implementation, but cached outcomes written by the changed path can persist until expiry or manual deletion.
Assessed commit 0b6ae51
Diagram

graph TD
  Gate{"Native gate"} --> Plan["Inspect plan"] --> Cache["Domain cache"] --> DNS["UDP NS query"] --> Classify{"Supported answer"} --> Report["JSON report"]
  Cache -->|fresh entry| Report
  Classify -->|unsupported| Node["Node handover"]
  DNS -->|timeout or failure| Node
  Gate -->|ineligible| Node
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Use a DNS wire-format crate with explicit UDP transport
  • ➕ Could reduce maintenance and parsing risk for untrusted DNS responses.
  • ➕ Could provide broader protocol validation if native DNS support expands.
  • ➖ Adds a dependency without replacing the required Node-specific routing and classification rules.
  • ➖ May require additional work to preserve the exact query and conservative handover behavior.

Recommendation: Keep the constrained native query and reader for this scope: a system resolver cannot make the equivalent NS lookup, and unsupported responses already hand over to Node. Consider a DNS wire-format crate if the native path grows beyond these narrowly classified answers.

Files changed (8) +1253 / -74

Enhancement (3) +543 / -57
route.mjsAllow default JSON inspections through the native gate +11/-25

Allow default JSON inspections through the native gate

• Removes the launcher’s marshall-availability restriction now that expiredDomains is native. Keeps invocation-shape and environment checks while leaving marshall selection to the binary.

packages/tooling/vis/bin/route.mjs

expired_domains.rsImplement native expired-domain lookups and caching +506/-0

Implement native expired-domain lookups and caching

• Extracts maintainer domains, reads and stages Node-compatible cache entries, and produces error findings for lapsed domains. Sends NS queries over UDP and declines names, settings, or responses it cannot safely classify like Node.

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

mod.rsIntegrate expiredDomains into native inspection +26/-32

Integrate expiredDomains into native inspection

• Adds DNS resolver configuration to inspect services and runs the new marshall in the existing plan. Removes the blanket rejection of expiredDomains, preserving staged cache changes and pre-output handover.

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

Tests (5) +710 / -17
inspect-dns.test.tsCompare DNS scenarios against Node’s resolver +255/-0

Compare DNS scenarios against Node’s resolver

• Adds local UDP stubs to check Node’s classification of shared DNS scenarios, query bytes, and first-server behavior. Confirms when Node consults the second server.

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

inspect-parity.test.tsExercise native default reports and domain findings +71/-12

Exercise native default reports and domain findings

• Adds parity cases for default and expiredDomains-only reports, maintainer-address deduplication, cached outcomes, and non-ASCII handover. Changes the prior default-report expectation from Node routing to native execution.

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

tests.rsTest native DNS decisions, cache behavior, and findings +363/-0

Test native DNS decisions, cache behavior, and findings

• Uses local DNS stubs and shared scenarios to test query format, classification, findings, deduplicated lookups, and cache reads and writes. Covers timeouts, resolver rotation, malformed maintainer data, and other handover cases.

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

dns-scenarios.jsonShare DNS response scenarios across Node and Rust tests +16/-0

Share DNS response scenarios across Node and Rust tests

• Defines registered, lapsed, and unresolved responses, including authority-only NS records, other answer types, response errors, truncation, and silence. Marks cases the native reader must decline.

packages/tooling/vis/native/cli/tests/fixtures/dns-scenarios.json

routing.jsonExpect native routing for expiredDomains selections +5/-5

Expect native routing for expiredDomains selections

• Updates launcher expectations for default JSON inspections and selections containing expiredDomains. The fixture’s unreachable registry still causes the binary to hand execution to Node after passing the native gate.

packages/tooling/vis/native/cli/tests/fixtures/routing.json

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2)

Grey Divider


Remediation recommended

1. Blocked DNS slows every default inspect run 🐞 Bug
Description
plan runs expired_domains::run after the packument fetch and the downloads API request, and
Resolver::lookup can wait the full 2 s WAIT before handing over. Any Err throws away the
native work, including cache writes, and Node then repeats the packument and download requests and
waits its own 4 s per domain. Node never caches a failed lookup, so on a CI runner where UDP 53 to
1.1.1.1 is blocked (common with egress-restricted runners), or where a maintainer domain keeps
returning SERVFAIL, every default vis inspect --json pays this cost on every run. Before this PR
the gate sent such runs straight to Node.
Code

packages/tooling/vis/native/cli/src/inspect/mod.rs[R325-328]

+            Marshall::ExpiredDomains => {
+                let (found, changes) =
+                    expired_domains::run(&context.services.dns, &context.cache_dir, &view, &target, context.now_ms)?;
+
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
When the DNS lookup of `expiredDomains` cannot be answered (UDP 53 blocked, SERVFAIL, timeout), the native run hands over only after it has fetched the packument, called the downloads API and waited up to 2 s. Node then repeats all of that. Node never caches transient failures, so this happens on every run.

## Fix Focus Areas
- packages/tooling/vis/native/cli/src/inspect/mod.rs[300-335]
- packages/tooling/vis/native/cli/src/inspect/expired_domains.rs[363-430]

## Recommended Fix
Resolve the domains that need a query before any other network-backed marshall (`downloads`, `archivedRepo`, `signatures`) runs. Keep the report order unchanged, for example by splitting the outcome collection out of finding generation. A hand-over then costs at most the packument fetch. Optionally, remember for the rest of the process (or in a short-lived marker) that 1.1.1.1 was unreachable, and skip the native attempt. At minimum, document in the gate comment that blocked DNS adds 2 s per run.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗



View low (1)
Informational
2. A malformed final NS record still counts as registered 🐞 Bug
Description
In read_answer, the NS target is checked against the record’s declared rdlength, but the
complete record is not checked against the received message, and the authority and additional
sections are not read. When a record declares bytes beyond the packet, or a later section is
corrupt, the reply is classified Registered and run caches it as ok for 24 hours instead of
handing it to Node, where c-ares would reject it as EBADRESP.
Code

packages/tooling/vis/native/cli/src/inspect/expired_domains.rs[R206-209]

+            read_name(message, data)
+                .filter(|(_, end)| *end <= data + usize::from(length))
+                .ok_or("an NS record whose target is not readable")?;
+            at = data + usize::from(length);
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`wire::read_answer` accepts an NS record whose declared RDATA extends beyond the received packet and does not inspect authority or additional records. A malformed reply can consequently be cached as a registered domain instead of being handed to Node.

## Fix Focus Areas
- packages/tooling/vis/native/cli/src/inspect/expired_domains.rs[194-212]
- packages/tooling/vis/native/cli/src/inspect/tests.rs[1669-1685]

## Recommended Fix
Before accepting each record, verify that `data + usize::from(length)` is within `message.len()` and that the decoded NS target fits within the declared RDATA. Return a hand-over error for incomplete records and add a UDP-stub test with an oversized RDLENGTH. Also walk the NSCOUNT and ARCOUNT records with the same bounds checks, handing over if any cannot be read.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


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:52 — with GitHub Actions Active
@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-expired-domains (2e9fab0) with t3/native-inspect-signatures (b2f2dd2)

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

This branch was successfully deployed

1 active deployment
benchmarks — 2e9fab08 Deployed Nov 26, 2026 by prisis via Bench native (vis) #449
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