Skip to content

feat(pacquet): implement find-hash - #12552

Merged
zkochan merged 15 commits into
pnpm:mainfrom
kairosci:feat/pacquet-find-hash
Jun 22, 2026
Merged

zkochan merged 15 commits into
pnpm:mainfrom
kairosci:feat/pacquet-find-hash

Conversation

@kairosci

@kairosci kairosci commented Jun 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Implement pacquet find-hash based on the requirements described in #11633 (comment).
This command allows searching the package index (v11/index.db) for packages that contain a specific file matching the given integrity hash.

Squash Commit Body

feat(pacquet): implement find-hash

- Added `find-hash` subcommand in `pacquet/crates/cli/src/cli_args/find_hash.rs`.
- Scans `StoreIndex` for `PackageFilesIndex` matching the given `digest`.
- Outputs matched package names and versions.

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust pacquet/ port, or the description notes what still needs porting.
  • Added a changeset (pnpm changeset) if this PR changes any published package. Keep it short and written for pnpm users — it becomes a release note.
  • Added or updated tests.
  • Updated the documentation if needed.

Partially written by an agent (Google Antigravity, gemini-3-1-pro).

Summary by CodeRabbit

  • New Features
    • Added a find-hash subcommand to search the local package store index by digest (supports hex and base64-form) and print matching name@version results.
  • Tests
    • Added integration tests covering hex and base64 inputs, plus failure cases for missing hashes and malformed base64.
  • Chores
    • Updated CLI dependency configuration/formatting.
    • Exposed the store index module for wider access.

@kairosci
kairosci requested a review from zkochan as a code owner June 21, 2026 09:29
@coderabbitai

coderabbitai Bot commented Jun 21, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a find-hash CLI subcommand that searches the pacquet store index for packages matching a given file digest. The command normalizes base64-encoded hashes to hex, scans store index entries in both regular files and side-effect additions, and prints matched package names and versions with colored output. The store_index module is made public and a base64 dependency is added.

Changes

find-hash subcommand

Layer / File(s) Summary
Store index visibility and base64 dependency
pacquet/crates/store-dir/src/lib.rs, pacquet/crates/cli/Cargo.toml
store_index module is changed from private to public; base64.workspace = true is added to the CLI crate dependencies.
FindHashArgs struct and run implementation
pacquet/crates/cli/src/cli_args/find_hash.rs
Defines FindHashArgs { hash: String } and implements run with base64-to-hex normalization, read-only store index scanning over data.files and data.side_effects[*].added, manifest-based name/version extraction with "unknown" fallbacks, and colored output. Returns an error when no matches are found or the store index cannot be opened.
CLI enum variant and dispatcher wiring
pacquet/crates/cli/src/cli_args.rs
Adds pub mod find_hash, imports FindHashArgs, adds CliCommand::FindHash(FindHashArgs) variant to the enum, and wires a CliCommand::FindHash match arm in CliArgs::run.
Integration tests
pacquet/crates/cli/tests/find_hash.rs
Adds four tests: find_hash_works installs a package and verifies a real digest lookup; should_fail_on_missing_hash asserts failure with INVALID_FILE_HASH; should_fail_on_invalid_base64 asserts failure with Failed to decode base64 hash; find_hash_works_with_base64 converts a hex digest to base64-encoded sha512 format and verifies the subcommand accepts it.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • zkochan
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

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

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

feat(pacquet): add find-hash command to locate packages by file digest
✨ Enhancement 🧪 Tests 🕐 20-40 Minutes

Grey Divider

Description

• Add pacquet find-hash to list packages containing a file with a given hash.
• Accept both raw hex digests and shaN- integrity strings.
• Add integration tests for success, missing-hash, and invalid-base64 cases.
Diagram

graph TD
  U([User]) --> CLI["pacquet CLI"] --> FH["FindHashArgs"] --> HN["Hash normalize"] --> SI[("StoreIndex (index.db)")] --> SC["Scan entries"] --> OUT["Print matches"]
  subgraph Legend
    direction LR
    _u([CLI/module]) ~~~ _db[(Database)] ~~~ _op["Processing step"]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Add a digest→package reverse index table
  • ➕ Makes lookup fast without scanning all rows
  • ➕ Avoids decoding many PackageFilesIndex blobs on large stores
  • ➖ Requires schema changes and migration/backfill for existing stores
  • ➖ Adds write-path overhead/complexity to maintain the reverse index
2. Stream rows directly from SQLite instead of `keys()` + `get_many()`
  • ➕ Lower peak memory (no full key list)
  • ➕ Avoids chunking/placeholder-limit considerations at call sites
  • ➖ Requires adding new StoreIndex query/iterator API
  • ➖ Still effectively a full scan, so runtime cost remains similar

Recommendation: The PR’s approach (normalize hash, open StoreIndex readonly, scan files plus side_effects.added, then print matches) is a solid first implementation that matches pnpm’s UX/error signaling. If this becomes slow on large stores, the most impactful follow-up is a dedicated reverse index keyed by digest.

Files changed (5) +193 / -2

Enhancement (2) +132 / -0
cli_args.rsWire 'find-hash' into clap command enum and dispatch +7/-0

Wire 'find-hash' into clap command enum and dispatch

• Registers the new 'find_hash' module, adds 'FindHash' to 'CliCommand', and dispatches execution to 'FindHashArgs::run' using the loaded config.

pacquet/crates/cli/src/cli_args.rs

find_hash.rsImplement 'pacquet find-hash' store-index scan and pnpm-like output +125/-0

Implement 'pacquet find-hash' store-index scan and pnpm-like output

• Implements the 'find-hash' subcommand: accepts hex or 'shaN-<base64>' input (decoded to lowercase hex), opens the store index read-only, scans 'files' and 'side_effects.added' for a matching digest, and prints 'name@version' plus the index key with pnpm-like colors. Emits 'INVALID_FILE_HASH' when no match is found and surfaces base64 decode failures with context.

pacquet/crates/cli/src/cli_args/find_hash.rs

Refactor (1) +1 / -1
lib.rsExpose 'store_index' module publicly for CLI consumers +1/-1

Expose 'store_index' module publicly for CLI consumers

• Changes 'store_index' from private to 'pub mod' so the CLI can import 'pacquet_store_dir::store_index::StoreIndex' directly (existing re-exports remain).

pacquet/crates/store-dir/src/lib.rs

Tests (1) +58 / -0
find_hash.rsAdd integration tests for find-hash success and failure cases +58/-0

Add integration tests for find-hash success and failure cases

• Adds a test that installs '[email protected]' to populate the store index, extracts a real digest, and verifies 'find-hash' prints the expected package name/version. Adds negative tests for missing hashes ('INVALID_FILE_HASH') and invalid base64 input (decode error).

pacquet/crates/cli/tests/find_hash.rs

Other (1) +2 / -1
Cargo.tomlAdd base64 dependency for integrity-hash input support +2/-1

Add base64 dependency for integrity-hash input support

• Adds 'base64' as a workspace dependency to decode 'shaN-<base64>' integrity strings. Also switches 'owo-colors' to workspace shorthand syntax.

pacquet/crates/cli/Cargo.toml

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jun 21, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (15) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. FrozenStore open mode wrong 🐞 Bug ☼ Reliability
Description
FindHashArgs::run always opens the store index via StoreIndex::open_readonly_in, which can
create WAL sidecar files and will fail against read-only stores where frozenStore expects an
immutable open. This breaks pacquet find-hash for frozenStore users and can violate the “no
store writes” contract.
Code

pacquet/crates/cli/src/cli_args/find_hash.rs[R44-48]

+        let Ok(store_index) = StoreIndex::open_readonly_in(store_dir) else {
+            return Err(miette::miette!(
+                "INVALID_FILE_HASH\nNo package or index file matching this hash was found."
+            ));
+        };
Evidence
open_readonly may create -shm sidecars and is explicitly not the right API for read-only store
roots; frozen_store promises immutable index opens. The new command always uses
open_readonly_in, so it can fail or write sidecars on read-only stores.

pacquet/crates/cli/src/cli_args/find_hash.rs[41-48]
pacquet/crates/store-dir/src/store_index.rs[442-490]
pacquet/crates/config/src/lib.rs[859-876]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`pacquet find-hash` opens the SQLite store index with `StoreIndex::open_readonly_in(...)` unconditionally. For `frozenStore` (read-only stores), this is the wrong open mode: WAL databases may require creating `-shm` sidecars even on read-only opens, which can fail or violate the "no writes" expectation.
## Issue Context
- `StoreIndex::open_readonly` explicitly notes it may create `-shm` sidecars and recommends `open_immutable` for read-only stores.
- `Config::frozen_store` documents that pacquet should open `index.db` via `immutable=1` and suppress store writes.
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/find_hash.rs[41-48]
### Suggested implementation direction
- Branch on `config.frozen_store`:
- if `true`, open with `StoreIndex::open_immutable(store_dir.root())`
- else open with `StoreIndex::open_readonly_in(store_dir)`
- Keep the existing "INVALID_FILE_HASH" behavior for the "no index.db exists" case, but avoid mapping *all* open errors to INVALID_FILE_HASH (surface unexpected DB open errors with context).

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


2. Flaky hash selection test ✓ Resolved 🐞 Bug ☼ Reliability
Description
find_hash_works picks a digest from the first entry of a HashMap returned by
StoreIndex::get_many, so the chosen hash is nondeterministic. The test then asserts the output
contains [email protected], which can intermittently fail when the selected hash belongs to a different
installed package.
Code

pacquet/crates/cli/tests/find_hash.rs[R18-40]

+    // Find a valid hash
+    let mut valid_hash = String::new();
+    let entries = store_index.get_many(&keys).unwrap();
+    for (_key, data) in entries {
+        if let Some(file) = data.files.values().next() {
+            valid_hash = file.digest.clone();
+        }
+        if !valid_hash.is_empty() {
+            break;
+        }
+    }
+    assert!(!valid_hash.is_empty(), "Should find a valid hash in the store index");
+
+    // 2. Run find-hash with the valid hash
+    let mut pacquet2 = std::process::Command::cargo_bin("pacquet").unwrap();
+    pacquet2.current_dir(&workspace);
+    let output = pacquet2.arg("find-hash").arg(&valid_hash).assert().success();
+    let stdout = String::from_utf8_lossy(&output.get_output().stdout);
+
+    // Output should contain is-odd
+    assert!(stdout.contains("is-odd"));
+    assert!(stdout.contains("3.0.1"));
+}
Evidence
The test’s valid_hash selection is driven by iterating a HashMap from get_many, so the chosen
digest can vary; the assertion is hardcoded to [email protected], making the test unreliable.

pacquet/crates/cli/tests/find_hash.rs[10-40]
pacquet/crates/store-dir/src/store_index.rs[585-605]
pacquet/crates/store-dir/src/store_index.rs[813-817]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The `find_hash_works` test currently derives `valid_hash` by iterating a `HashMap` (`StoreIndex::get_many` result) and taking the first file digest it encounters. `HashMap` iteration order is nondeterministic, so the test may select a digest from any package in the store index, but it always asserts the output contains `[email protected]`.
## Issue Context
`pacquet add [email protected]` installs multiple packages (the target package plus dependencies), so the store index contains multiple entries. `StoreIndex::get_many` returns a `HashMap`, making iteration order non-stable.
## Fix Focus Areas
- pacquet/crates/cli/tests/find_hash.rs[10-40]
### Suggested implementation direction
- Pick the digest from the *specific* row for `[email protected]`.
- Option A: find the store index key that contains `"\[email protected]"` (keys are `"{integrity}\t{pkg_id}"`), then `StoreIndex::get(&key)` and read a file digest from that row.
- Option B: scan entries and select the one whose manifest name/version match `is-odd`/`3.0.1`.
- Then assert output contains the matching package/version.

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



Remediation recommended

3. Corrupt row aborts scan 🐞 Bug ☼ Reliability
Description
FindHashArgs::run aborts the entire find-hash scan when any single package_index row fails to
decode, so one corrupt cache entry makes the command unusable even if other rows contain matches.
This is inconsistent with StoreIndex::get_many, which intentionally treats undecodable rows as
cache misses and continues.
Code

pacquet/crates/cli/src/cli_args/find_hash.rs[R75-88]

+        store_index.for_each_raw(|index_key, bytes| -> Result<(), FindHashError> {
+            let data = decode_find_hash_index(&bytes).map_err(|source| {
+                FindHashError::CorruptStoreIndexRow { key: index_key.clone(), source }
+            })?;
+            if !contains_hash(&data, &hash) {
+                return Ok(());
+            }
+
+            let (name, version) = package_identity(&bytes).map_err(|source| {
+                FindHashError::CorruptStoreIndexRow { key: index_key.clone(), source }
+            })?;
+            results.push((name, version, index_key));
+            Ok(())
+        })?;
Evidence
The new find-hash visitor uses ? on decode errors, which returns early and fails the whole
command. In contrast, StoreIndex::get_many explicitly logs and skips undecodable rows instead of
failing the caller.

pacquet/crates/cli/src/cli_args/find_hash.rs[75-88]
pacquet/crates/store-dir/src/store_index.rs[569-605]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`pacquet find-hash` currently fails fast on the first undecodable `package_index` row. This makes the command brittle in the presence of partial/corrupt store-index entries.
### Issue Context
The store index read path (`StoreIndex::get_many`) already documents a best-effort stance: decode failures are logged and dropped as cache misses.
### Fix Focus Areas
- pacquet/crates/cli/src/cli_args/find_hash.rs[75-88]
### Suggested fix
- Change the `for_each_raw` visitor to **continue scanning** on `decode_find_hash_index` / `package_identity` decode errors.
- Emit a `tracing::debug!` or `tracing::warn!` including the `index_key` and error (similar to `StoreIndex::get_many`) so corruption is still diagnosable.
- Only return `ERR_PNPM_INVALID_FILE_HASH` when the scan completes with no matches (regardless of skipped corrupt rows).

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


4. Output newline injection 🐞 Bug ⛨ Security
Description
sanitize() explicitly preserves \n and \t, so store-derived fields printed by `pacquet
find-hash/why` can inject additional lines/columns into terminal/CI logs, spoofing or corrupting
human/parsing interpretation of results. This undermines the stated goal of preventing stored
metadata from emitting unsafe terminal sequences/controls.
Code

pacquet/crates/cli/src/cli_args/sanitize.rs[R3-13]

+/// Strip control characters from store-derived text before it reaches the
+/// terminal, keeping `\n` and `\t`. Prevents stored metadata from emitting
+/// raw escape sequences to the user's terminal.
+pub fn sanitize(text: &str) -> Cow<'_, str> {
+    if text.bytes().any(|byte| byte < 0x20 && byte != b'\n' && byte != b'\t') {
+        Cow::Owned(
+            text.chars()
+                .filter(|character| {
+                    !character.is_control() || *character == '\n' || *character == '\t'
+                })
+                .collect(),
Evidence
The sanitizer explicitly allows \n/\t, and the new command prints store-index-derived manifest
fields after passing them through sanitize(). The repo’s review guide treats manifests/metadata as
attacker-controlled, making output-injection a plausible threat model for this path.

pacquet/crates/cli/src/cli_args/sanitize.rs[3-13]
pacquet/crates/cli/src/cli_args/find_hash.rs[125-162]
pacquet/crates/store-dir/src/store_index.rs[850-886]
REVIEW_GUIDE.md[30-46]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`sanitize()` currently keeps `\n` and `\t`, which allows store-derived strings (e.g. package name/version/index keys) to break the line-oriented CLI output of `find-hash` and `why`.
## Issue Context
This helper is used immediately before printing store-index-derived fields to stdout.
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/sanitize.rs[3-13]
- pacquet/crates/cli/src/cli_args/find_hash.rs[125-162]
- pacquet/crates/cli/src/cli_args/why.rs[481-489]
## Suggested fix
- Make terminal-facing sanitization *line-safe*: either strip all ASCII control characters including `\n`/`\t`, or escape them to visible sequences (e.g. replace with `\\n`/`\\t`), so one logical result cannot emit multiple lines.
- If keeping `\n`/`\t` is needed elsewhere, split into two helpers (e.g. `sanitize_terminal()` vs `sanitize_multiline()`) and use the stricter one for `find-hash`/`why` output.

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


5. Unstable output ordering 🐞 Bug ⚙ Maintainability
Description
find-hash output order is nondeterministic because it reads keys via StoreIndex::keys() (no
ORDER BY) and iterates results from StoreIndex::get_many() (a HashMap). This makes the command’s
stdout unstable across runs/stores, which is brittle for scripting and snapshot-style tests.
Code

pacquet/crates/cli/src/cli_args/find_hash.rs[R93-99]

+        let keys =
+            store_index.keys().into_diagnostic().wrap_err("Failed to get store index keys")?;
+        let mut results = Vec::new();
+
+        for chunk in keys.chunks(999) {
+            let entries = store_index.get_many(chunk).into_diagnostic()?;
+            for (index_key, data) in entries {
Evidence
The CLI iterates over a HashMap produced by get_many(), and the underlying key collection query
has no ordering clause, so printing order is inherently unstable.

pacquet/crates/cli/src/cli_args/find_hash.rs[93-99]
pacquet/crates/store-dir/src/store_index.rs[772-787]
pacquet/crates/store-dir/src/store_index.rs[585-605]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`pacquet find-hash` prints matches in an unstable iteration order (unordered SQL + `HashMap` iteration).
## Issue Context
`StoreIndex::keys()` currently does `SELECT key FROM package_index` with no ordering, and `get_many()` returns a `HashMap`, both of which can vary ordering across runs.
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/find_hash.rs[93-162]
- pacquet/crates/store-dir/src/store_index.rs[772-787]
## Suggested fix
Choose one:
1) Sort in the CLI: after collecting `results`, `results.sort_unstable_by(|a,b| ...)` (e.g., by `(name, version, index_key)` or just `index_key`) before printing.
2) Make key enumeration stable: change `StoreIndex::keys()` query to `SELECT key FROM package_index ORDER BY key` and (optionally) iterate `get_many_raw()` results (Vec) rather than a `HashMap` when order matters.

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


View more (11)
6. Sanitize misses C1 controls 🐞 Bug ⛨ Security
Description
sanitize() only decides to filter when it sees bytes < 0x20, so it returns the original string
unchanged when it contains DEL (0x7F) or Unicode C1 control characters (e.g. U+009B), leaving a
terminal-control injection path via store-derived metadata printed by find-hash/why. This
defeats the stated purpose of preventing stored metadata from emitting raw escape sequences.
Code

pacquet/crates/cli/src/cli_args/sanitize.rs[R6-16]

+pub fn sanitize(text: &str) -> Cow<'_, str> {
+    if text.bytes().any(|byte| byte < 0x20 && byte != b'\n' && byte != b'\t') {
+        Cow::Owned(
+            text.chars()
+                .filter(|character| {
+                    !character.is_control() || *character == '\n' || *character == '\t'
+                })
+                .collect(),
+        )
+    } else {
+        Cow::Borrowed(text)
Evidence
The sanitizer’s comment claims it prevents stored metadata from emitting raw escape sequences, but
the implementation only checks for ASCII C0 controls (<0x20), skipping filtering for DEL and Unicode
control characters; both find-hash and why rely on this helper when emitting store-derived
strings to stdout.

pacquet/crates/cli/src/cli_args/sanitize.rs[3-17]
pacquet/crates/cli/src/cli_args/find_hash.rs[155-182]
pacquet/crates/cli/src/cli_args/why.rs[481-489]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`sanitize()` uses a byte-level pre-scan (`byte < 0x20`) to decide whether to run the control-character filter. This misses DEL (0x7F) and any Unicode control chars encoded as multi-byte UTF-8 (notably C1 controls like U+009B), causing the function to return `Cow::Borrowed(text)` and emit the control characters to the terminal.
### Issue Context
This helper is now used by `find-hash` and `why` to sanitize store-index-derived strings before coloring/printing.
### Fix Focus Areas
- pacquet/crates/cli/src/cli_args/sanitize.rs[6-17]
### Fix approach
Replace the byte-level pre-scan with a `char`-based pre-scan (or otherwise include DEL + Unicode control ranges) so *all* `char::is_control()` codepoints (except `\n`/`\t`) trigger filtering.
For example:
- Use `text.chars().any(|c| c.is_control() && c != '\n' && c != '\t')` as the trigger.
- Keep the existing filter (or equivalent) to remove all control chars except `\n` and `\t`.

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


7. Blocking scan on Tokio thread 🐞 Bug ➹ Performance
Description
find-hash runs a potentially long SQLite scan synchronously while dispatched inside the Tokio
runtime, so the scan blocks a runtime worker thread for the duration. On large stores this can make
the process less responsive and can starve/serialize any other async work that might be active
in-process while the scan runs.
Code

pacquet/crates/cli/src/cli_args/find_hash.rs[R92-98]

+        let keys =
+            store_index.keys().into_diagnostic().wrap_err("Failed to get store index keys")?;
+        let mut results = Vec::new();
+
+        for chunk in keys.chunks(999) {
+            let entries = store_index.get_many(chunk).into_diagnostic()?;
+            for (index_key, data) in entries {
Evidence
The CLI’s top-level main runs CliArgs::run inside a Tokio runtime, and the new find-hash
implementation performs synchronous StoreIndex::keys() + StoreIndex::get_many() loops (rusqlite
queries + row decoding), so the scan executes on a Tokio worker thread and blocks it until
completion.

pacquet/crates/cli/src/lib.rs[37-45]
pacquet/crates/cli/src/cli_args.rs[466-468]
pacquet/crates/cli/src/cli_args/find_hash.rs[92-98]
pacquet/crates/store-dir/src/store_index.rs[569-605]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`FindHashArgs::run` performs synchronous rusqlite I/O + decoding loops, but it is invoked from within `CliArgs::run` which executes under a Tokio runtime. This blocks a Tokio worker thread for the scan duration.
## Issue Context
`pacquet` always builds a Tokio runtime and `block_on`s `CliArgs::run` for non-fast-path commands. `find-hash` is a purely blocking workload (SQLite + decoding), so it should be offloaded to the blocking pool.
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args.rs[466-468]
- pacquet/crates/cli/src/cli_args/find_hash.rs[24-167]
### Suggested approach
- In the `CliCommand::FindHash` match arm, load the config once (producing an `&'static Config`), then call `tokio::task::spawn_blocking(move || args.run(|| Ok(cfg_ref)))` and `.await` it.
- Alternatively, refactor `FindHashArgs::run` into a pure blocking function `run_with_config(&Config)` to avoid the lifetime-generic closure, and invoke that from `spawn_blocking`.

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


8. Unknown labels for matches 🐞 Bug ≡ Correctness
Description
FindHashArgs::run derives name/version solely from PackageFilesIndex.manifest and prints
"unknown" when it is missing. Several store-index write paths persist manifest: None (notably
git-hosted fetchers), so real matches can be displayed as unknown@unknown even though the
store-index key encodes a package identifier.
Code

pacquet/crates/cli/src/cli_args/find_hash.rs[R124-146]

+                if found {
+                    let name = data
+                        .manifest
+                        .as_ref()
+                        .and_then(|manifest| {
+                            manifest
+                                .get("name")
+                                .and_then(|n| n.as_str())
+                                .map(std::string::ToString::to_string)
+                        })
+                        .unwrap_or_else(|| "unknown".to_string());
+                    let version = data
+                        .manifest
+                        .as_ref()
+                        .and_then(|manifest| {
+                            manifest
+                                .get("version")
+                                .and_then(|n| n.as_str())
+                                .map(std::string::ToString::to_string)
+                        })
+                        .unwrap_or_else(|| "unknown".to_string());
+                    results.push((name, version, index_key.clone()));
+                }
Evidence
The CLI code unconditionally falls back to "unknown" when data.manifest is absent, while other
parts of the codebase explicitly write store-index rows with manifest: None. Store-index keys are
defined to embed a pkg_id separated by a tab, so find-hash can derive a better label from
index_key when manifest is missing.

pacquet/crates/cli/src/cli_args/find_hash.rs[124-146]
pacquet/crates/store-dir/src/store_index.rs[813-846]
pacquet/crates/git-fetcher/src/fetcher.rs[194-210]
pacquet/crates/git-fetcher/src/tarball_fetcher.rs[166-222]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`pacquet find-hash` currently labels matched rows using `data.manifest.name`/`data.manifest.version` and falls back to `"unknown"` when `manifest` is `None`. But some store-index producers intentionally write rows with `manifest: None`, which makes the command output `unknown@unknown` for valid matches.
### Issue Context
Store-index keys are structured as `"{integrity}\t{pkg_id}"` (and for git-hosted keys, `"{pkg_id}\t{built|not-built}"`). That means the package identifier is still available via `index_key` even when `manifest` is missing.
### Fix Focus Areas
- pacquet/crates/cli/src/cli_args/find_hash.rs[124-146]
- pacquet/crates/store-dir/src/store_index.rs[813-846]
### Suggested fix
1. Keep using `manifest` when present.
2. If `manifest` is `None` or lacks `name`/`version`, derive a better fallback from `index_key`:
- `let (first, second) = index_key.split_once('\t').unwrap_or((&index_key, ""));`
- If `second` is `"built"` or `"not-built"`, treat `first` as the identifier; else treat `second` as the identifier (tarball case).
- If the identifier looks like `name@version`, split with `rsplit_once('@')` to support scoped names.
3. Use the derived values instead of hard-coded `"unknown"` so output remains meaningful for manifest-less rows.

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


9. No hex hash validation 🐞 Bug ➹ Performance
Description
FindHashArgs::run treats any non-shaN-... input as a candidate digest and immediately opens the
store index, loads all keys, and scans the DB. For malformed/garbage inputs (non-hex or wrong
length), this delays the error and can waste significant time on large stores instead of failing
fast.
Code

pacquet/crates/cli/src/cli_args/find_hash.rs[R27-63]

+        let mut hash = self.hash;
+
+        if hash.contains('-') {
+            let Some((_, base64_part)) = hash.split_once('-') else {
+                return Err(miette::miette!(
+                    "Invalid hash format. Expected something like sha512-..., got {}",
+                    hash
+                ));
+            };
+            use base64::{Engine as _, engine::general_purpose::STANDARD as BASE64};
+            let decoded = BASE64
+                .decode(base64_part)
+                .into_diagnostic()
+                .wrap_err("Failed to decode base64 hash")?;
+            use std::fmt::Write as _;
+            let mut hex = String::with_capacity(decoded.len() * 2);
+            for b in decoded {
+                write!(&mut hex, "{b:02x}").into_diagnostic()?;
+            }
+            hash = hex;
+        }
+        hash = hash.to_lowercase();
+
+        let config = config()?;
+        let store_dir = &config.store_dir;
+
+        let Ok(store_index) = StoreIndex::open_readonly_in(store_dir) else {
+            return Err(FindHashError::InvalidFileHash.into());
+        };
+
+        let keys =
+            store_index.keys().into_diagnostic().wrap_err("Failed to get store index keys")?;
+        let mut results = Vec::new();
+
+        for chunk in keys.chunks(999) {
+            let entries = store_index.get_many(chunk).into_diagnostic()?;
+            for (index_key, data) in entries {
Evidence
The new command lowercases the input and begins a full store-index scan without validating the
plain-hex case, so malformed inputs will only be rejected after loading keys and iterating rows. The
store index explicitly documents that digest is stored as raw hex and that pacquet writes sha512
digests, which makes early format/length validation feasible and appropriate.

pacquet/crates/cli/src/cli_args/find_hash.rs[27-63]
pacquet/crates/store-dir/src/store_index.rs[856-896]
pacquet/crates/store-dir/src/upload.rs[30-36]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`pacquet find-hash` currently lowercases the input and proceeds to scan the entire `index.db` when the argument does not contain `-`, even if the input is clearly not a valid digest (wrong length or non-hex characters). This causes avoidable work and delayed feedback on large stores.
### Issue Context
Store-index file digests are stored as raw-hex strings (`CafsFileInfo.digest`) under a known algorithm (`sha512` in pacquet today), so the CLI can validate that a plain-hex argument is well-formed before opening/scanning the index.
### Fix Focus Areas
- pacquet/crates/cli/src/cli_args/find_hash.rs[27-59]
- Before opening the DB / loading keys, validate the **non-`shaN-...`** input is a valid hex digest for the expected algorithm (at minimum: `[0-9a-fA-F]+` and expected length, e.g. 128 hex chars for sha512).
- If invalid, return a clear “invalid hash format” error immediately (do not scan).

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


10. Algorithm prefix ignored 🐞 Bug ≡ Correctness
Description
find-hash accepts any - input but discards the prefix and never checks it against the store
index’s algo field, even though pacquet currently only supports sha512 digests. This makes
unsupported integrity strings (e.g. sha1-...) look like valid queries and then fail with a
misleading “no package found” error rather than a clear “unsupported algorithm/format” error.
Code

pacquet/crates/cli/src/cli_args/find_hash.rs[R20-61]

+        if hash.contains('-') {
+            let Some((_, base64_part)) = hash.split_once('-') else {
+                return Err(miette::miette!(
+                    "Invalid hash format. Expected something like sha512-..., got {}",
+                    hash
+                ));
+            };
+            use base64::{Engine as _, engine::general_purpose::STANDARD as BASE64};
+            let decoded = BASE64
+                .decode(base64_part)
+                .into_diagnostic()
+                .wrap_err("Failed to decode base64 hash")?;
+            use std::fmt::Write as _;
+            let mut hex = String::with_capacity(decoded.len() * 2);
+            for b in decoded {
+                write!(&mut hex, "{b:02x}").into_diagnostic()?;
+            }
+            hash = hex;
+        }
+        hash = hash.to_lowercase();
+
+        let config = config()?;
+        let store_dir = &config.store_dir;
+
+        let Ok(store_index) = StoreIndex::open_readonly_in(store_dir) else {
+            return Err(miette::miette!(
+                "INVALID_FILE_HASH\nNo package or index file matching this hash was found."
+            ));
+        };
+
+        let keys =
+            store_index.keys().into_diagnostic().wrap_err("Failed to get store index keys")?;
+        let mut results = Vec::new();
+
+        for chunk in keys.chunks(999) {
+            let entries = store_index.get_many(chunk).into_diagnostic()?;
+            for (index_key, data) in entries {
+                let mut found = false;
+
+                for file in data.files.values() {
+                    if file.digest == hash {
+                        found = true;
Evidence
The new parsing logic intentionally throws away the shaN prefix and later compares only the hex
digest against file.digest, while the store index schema and integrity checker both treat the
digest algorithm as explicit and (currently) sha512-only.

pacquet/crates/cli/src/cli_args/find_hash.rs[20-38]
pacquet/crates/cli/src/cli_args/find_hash.rs[59-61]
pacquet/crates/store-dir/src/store_index.rs[856-869]
pacquet/crates/store-dir/src/check_pkg_files_integrity.rs[420-429]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`pacquet find-hash` treats any string containing `-` as an integrity hash, decodes the base64 payload, and compares the resulting hex digest without validating the algorithm prefix (or cross-checking `PackageFilesIndex.algo`).
### Issue Context
- `PackageFilesIndex` carries an explicit `algo` field.
- Other code paths treat `sha512` as the only supported digest algorithm.
- Without validating the prefix, inputs like `sha1-...` are accepted and then produce a misleading “no match” error.
### Fix Focus Areas
- pacquet/crates/cli/src/cli_args/find_hash.rs[18-40]
- pacquet/crates/cli/src/cli_args/find_hash.rs[59-61]
### Suggested approach
- When parsing `shaN-...` inputs, require a supported prefix (likely `sha512`, case-insensitive).
- Optionally validate decoded length (e.g., sha512 => 64 bytes) before allocating/formatting.
- When scanning rows, either:
- only compare against rows where `data.algo == "sha512"`, or
- generalize to support multiple algos by mapping the prefix to the expected `data.algo`.

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


11. Strict base64 decode 🐞 Bug ≡ Correctness
Description
find-hash decodes shaN-... inputs with the strict base64::STANDARD engine, which errors on
some non-canonical base64 forms that pnpm decodes via Buffer.from(..., 'base64'). This can make
pacquet find-hash fail with “Failed to decode base64 hash” for hashes that pnpm would accept,
breaking behavioral parity for this new command.
Code

pacquet/crates/cli/src/cli_args/find_hash.rs[R27-31]

+            use base64::{Engine as _, engine::general_purpose::STANDARD as BASE64};
+            let decoded = BASE64
+                .decode(base64_part)
+                .into_diagnostic()
+                .wrap_err("Failed to decode base64 hash")?;
Evidence
The Rust implementation explicitly uses the strict STANDARD engine for base64 decoding, while the
pnpm reference implementation uses Node’s Buffer.from(..., 'base64') conversion path for the same
input, so pacquet can reject inputs that pnpm would decode and proceed with.

pacquet/crates/cli/src/cli_args/find_hash.rs[20-32]
pnpm11/store/commands/src/inspecting/findHash.ts[47-52]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`pacquet find-hash` uses `base64::engine::general_purpose::STANDARD` to decode the integrity base64 segment. This decoder is strict and may reject base64 strings that pnpm’s Node implementation decodes via `Buffer.from(..., 'base64')`, causing parity-breaking errors.
## Issue Context
pnpm’s handler converts `shaN-...` to hex using Node’s base64 decoding (`Buffer.from(base64Part, 'base64')`). pacquet should be at least as permissive for this CLI input to avoid surprising failures.
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/find_hash.rs[20-39]
## Suggested fix approach
- Decode using a more permissive strategy:
- try `general_purpose::STANDARD` first, and if it fails, fall back to `general_purpose::STANDARD_NO_PAD`, **or**
- normalize padding (add `=` until length % 4 == 0) before decoding, then decode with `STANDARD`.
- Keep the existing diagnostic context (`wrap_err("Failed to decode base64 hash")`) so invalid inputs still produce a clear error.

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


12. Non-hermetic missing-hash test 🐞 Bug ☼ Reliability
Description
should_fail_on_missing_hash does not create/populate the store index before running find-hash,
so it can pass even when the command fails because index.db is missing rather than because the
hash is absent. This reduces test signal and can mask regressions in the actual “scan existing index
but no match” behavior.
Code

pacquet/crates/cli/tests/find_hash.rs[R60-67]

+#[test]
+fn should_fail_on_missing_hash() {
+    let CommandTempCwd { mut pacquet, root: _root, .. } =
+        CommandTempCwd::init().add_mocked_registry();
+    let output = pacquet.arg("find-hash").arg("sha512-MJ7MSJwS1utMxA9QyQLytNDtd+5RGnx6m808qG1M2G+YndNbxf9JlnDaNCVbRbDP2DDoH2Bdz33FVC6TrpzXbw==").assert().failure();
+    let stderr = String::from_utf8_lossy(&output.get_output().stderr);
+    assert!(stderr.contains("INVALID_FILE_HASH"));
+}
Evidence
The test never runs an install to populate the store index, but find-hash returns
INVALID_FILE_HASH both when opening the index fails and when a scan finds no matches, so the
assertion does not prove the scan behavior is correct.

pacquet/crates/cli/tests/find_hash.rs[60-67]
pacquet/crates/cli/src/cli_args/find_hash.rs[41-48]
pacquet/crates/store-dir/src/store_index.rs[456-463]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`should_fail_on_missing_hash` invokes `pacquet find-hash` without first creating/populating the store’s `v11/index.db`. Because the command currently maps an index-open failure to the same `INVALID_FILE_HASH` output, the test can succeed without exercising the intended path (scan an existing index and find no matches).
### Issue Context
The test should validate behavior when the index exists and the hash is truly not present.
### Fix Focus Areas
- pacquet/crates/cli/tests/find_hash.rs[60-67]
- pacquet/crates/cli/src/cli_args/find_hash.rs[41-110]
### Suggested change
In `should_fail_on_missing_hash`, run a small install first (e.g. `pacquet add [email protected]`) to ensure `index.db` exists, then pass a digest that is guaranteed not to match any file digest (e.g. take a real digest from the index and flip one hex character, or use a 128-hex string that differs from all stored digests). Assert the failure output as today.

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


13. Corrupt rows hidden 🐞 Bug ≡ Correctness
Description
find-hash scans via StoreIndex::get_many, which intentionally drops undecodable package_index
rows (debug-log only). If the sought digest exists only in a row that fails to decode, the command
can incorrectly report INVALID_FILE_HASH (false negative).
Code

pacquet/crates/cli/src/cli_args/find_hash.rs[R54-56]

+        for chunk in keys.chunks(999) {
+            let entries = store_index.get_many(chunk).into_diagnostic()?;
+            for (index_key, data) in entries {
Evidence
The find-hash implementation relies on StoreIndex::get_many to provide all entries to scan, but
get_many explicitly documents and implements dropping undecodable rows, meaning those rows are
never scanned and can hide matches.

pacquet/crates/cli/src/cli_args/find_hash.rs[54-56]
pacquet/crates/store-dir/src/store_index.rs[569-605]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`pacquet find-hash` uses `StoreIndex::get_many`, which silently drops rows that fail to decode. This can produce false negatives if the matching digest exists in an undecodable row.
## Issue Context
`StoreIndex::get_many` is designed for install-time cache behavior (treat malformed rows as cache misses), but `find-hash` is a diagnostic/search command where accuracy is preferred.
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/find_hash.rs[54-56]
## Suggested fix
- Replace `get_many(...)` with `get_many_raw(...)` and explicitly decode each row.
- If decoding fails for any row, return an error that includes the index key and indicates the store index is corrupted (instead of silently skipping).
- Optionally, add a `--strict/--ignore-corrupt` flag if you want to preserve the current “best-effort” behavior, but default should avoid false negatives for a debugging tool.

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


14. Vacuous test assertions 🐞 Bug ⚙ Maintainability
Description
find_hash_works (and the base64 variant) may leave expected_name/expected_version empty when
the chosen store-index row has manifest == None, making stdout.contains("") always pass and
potentially masking regressions in printed name@version output.
Code

pacquet/crates/cli/tests/find_hash.rs[R18-57]

+    // Find a valid hash and remember which package it belongs to
+    let mut valid_hash = String::new();
+    let mut expected_name = String::new();
+    let mut expected_version = String::new();
+
+    let entries = store_index.get_many(&keys).unwrap();
+    for (_key, data) in entries {
+        if let Some(file) = data.files.values().next() {
+            valid_hash = file.digest.clone();
+
+            if let Some(manifest) = &data.manifest {
+                expected_name =
+                    manifest.get("name").and_then(|v| v.as_str()).unwrap_or("unknown").to_string();
+                expected_version = manifest
+                    .get("version")
+                    .and_then(|v| v.as_str())
+                    .unwrap_or("unknown")
+                    .to_string();
+            }
+        }
+        if !valid_hash.is_empty() {
+            break;
+        }
+    }
+    assert!(!valid_hash.is_empty(), "Should find a valid hash in the store index");
+
+    // 2. Run find-hash with the valid hash
+    let mut pacquet2 = std::process::Command::cargo_bin("pacquet").unwrap();
+    pacquet2.current_dir(&workspace);
+    let output = pacquet2.arg("find-hash").arg(&valid_hash).assert().success();
+    let stdout = String::from_utf8_lossy(&output.get_output().stdout);
+
+    println!("STDOUT: {stdout}");
+
+    // Output should contain the package name and version we extracted the hash from
+    assert!(stdout.contains(&expected_name), "Expected stdout to contain name {expected_name}");
+    assert!(
+        stdout.contains(&expected_version),
+        "Expected stdout to contain version {expected_version}"
+    );
Evidence
The test initializes expected_name/expected_version to empty strings and only populates them
when data.manifest is Some(_); since the store-index schema allows manifest to be absent,
those strings can remain empty, and contains("") will always succeed.

pacquet/crates/cli/tests/find_hash.rs[18-57]
pacquet/crates/store-dir/src/store_index.rs[853-886]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The integration test can pass without validating output because `expected_name`/`expected_version` may remain empty when `data.manifest` is `None`, and `stdout.contains("")` always returns true.
### Issue Context
`PackageFilesIndex.manifest` is optional, so entries without a manifest are valid. The test currently does not enforce selecting an entry with a manifest (or asserting `unknown` output explicitly).
### Fix Focus Areas
- pacquet/crates/cli/tests/find_hash.rs[18-57]
### Suggested change
Update the test loop to *only* select a `valid_hash` from an entry where `manifest.name` and `manifest.version` are present (or explicitly set `expected_name/expected_version` to "unknown" and assert that exact output). Add an assertion like `assert!(!expected_name.is_empty() && !expected_version.is_empty())` before checking stdout, so the test cannot succeed vacuously.

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


15. Unsafe colored stdout 🐞 Bug ⛨ Security
Description
find-hash prints name, version, and index_key with unconditional owo_colors styling, so
captured/piped output includes ANSI escape codes (unlike other CLI commands that explicitly avoid
this). It also prints these store-index-derived strings without control-character sanitization, so
any control bytes present in stored metadata/keys will be emitted to the terminal/logs verbatim.
Code

pacquet/crates/cli/src/cli_args/find_hash.rs[R114-120]

+        for (name, version, index_key) in results {
+            println!(
+                "{}@{}  {}",
+                name.bright_green(),
+                version.bright_green(),
+                index_key.color(Rgb(7, 132, 135))
+            );
Evidence
The new command prints colored output unconditionally and does not sanitize printed strings; other
CLI code explicitly TTY-gates color and sanitizes control characters before styling/printing.

pacquet/crates/cli/src/cli_args/find_hash.rs[82-121]
pacquet/crates/cli/src/cli_args/outdated.rs[578-583]
pacquet/crates/cli/src/cli_args/why.rs[481-503]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`pacquet find-hash` uses `owo_colors` directly (`bright_green()`, `color(Rgb(...))`) when printing results. This causes ANSI escape codes to appear even when stdout is not a terminal (piped/captured output), and it prints store-index-derived strings without filtering control characters.
### Issue Context
Other pacquet CLI commands already implement two relevant conventions:
1) disable color when stdout is not a TTY so piped output stays plain (chalk parity), and
2) sanitize strings to remove unexpected control characters before emitting to the terminal.
### Fix Focus Areas
- pacquet/crates/cli/src/cli_args/find_hash.rs[82-121]
### What to change
- Add a small `sanitize()` helper (can be copied from `cli_args/why.rs`) to strip control characters (except `\n`/`\t` if you want to preserve them).
- Apply `sanitize()` to `name`, `version`, and `index_key` before printing.
- Replace direct `.bright_green()` / `.color(Rgb(...))` usage with `if_supports_color(Stream::Stdout, ...)` (as in `outdated.rs`) so ANSI is only emitted when stdout supports color.
### Acceptance criteria
- When stdout is redirected/captured, `find-hash` output contains no ANSI escape codes.
- Control characters in stored `manifest.name` / `manifest.version` / `index_key` are not emitted verbatim.

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


16. Eager manifest decode scan 🐞 Bug ➹ Performance
Description
find-hash scans the index via StoreIndex::get_many, which fully deserializes each
PackageFilesIndex (including the potentially large manifest) for every row before checking
digests, making the command significantly more CPU/memory heavy than necessary on large stores. The
store-index implementation itself documents that manifest-bearing row decoding is the dominant CPU
cost, so this scan approach is expected to be slower than an implementation that avoids decoding
manifest except for matched rows.
Code

pacquet/crates/cli/src/cli_args/find_hash.rs[R50-56]

+        let keys =
+            store_index.keys().into_diagnostic().wrap_err("Failed to get store index keys")?;
+        let mut results = Vec::new();
+
+        for chunk in keys.chunks(999) {
+            let entries = store_index.get_many(chunk).into_diagnostic()?;
+            for (index_key, data) in entries {
Evidence
The find-hash implementation calls StoreIndex::get_many(...) during the full scan, which implies
full row deserialization per entry; separately, StoreIndex documents that decoding
manifest-bearing rows is the dominant CPU cost, making this a concrete performance concern for large
stores.

pacquet/crates/cli/src/cli_args/find_hash.rs[50-56]
pacquet/crates/store-dir/src/store_index.rs[607-619]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`pacquet find-hash` currently uses `StoreIndex::get_many(...)` while scanning the whole index. `get_many` decodes full `PackageFilesIndex` values, including `manifest`, for every row, even though `manifest` is only needed to print matched packages.
### Issue Context
`StoreIndex` already exposes `get_many_raw`, and its docs call out that decoding rows with a `manifest` field is the dominant CPU cost. `find-hash` can be made materially faster by scanning with a decode shape that omits `manifest`, and only decoding name/version when a digest match is found.
### Fix Focus Areas
- pacquet/crates/cli/src/cli_args/find_hash.rs[50-104]
- pacquet/crates/store-dir/src/store_index.rs[607-650]
### Implementation sketch
1. Replace `get_many(...)` calls with `get_many_raw(...)` (or a new `StoreIndex` helper) to fetch undecoded blobs.
2. Deserialize each blob into a lightweight struct that *excludes* `manifest` (so serde skips it), containing only `files` and `side_effects`.
3. If a digest match is found, then decode (or otherwise obtain) the package identity to print (either by doing a second full decode for just the matched rows, or by storing only the minimal needed `manifest` fields).

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


Grey Divider

Qodo Logo

Comment thread pacquet/crates/cli/tests/find_hash.rs Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
pacquet/crates/cli/tests/find_hash.rs (2)

35-39: ⚡ Quick win

Add logging before multi-line output assertions.

As per CODE_STYLE_GUIDE.md, "log before non-trivial assertions (especially for multi-line outputs/errors)". This helps debug test failures by showing what the command actually produced.

📋 Suggested enhancement
 let output = pacquet2.arg("find-hash").arg(&valid_hash).assert().success();
 let stdout = String::from_utf8_lossy(&output.get_output().stdout);
+eprintln!("find-hash stdout:\n{}", stdout);

 // Output should contain is-odd
 assert!(stdout.contains("is-odd"));
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pacquet/crates/cli/tests/find_hash.rs` around lines 35 - 39, Before the
assertions that check stdout.contains("is-odd") and stdout.contains("3.0.1"),
add a logging statement that prints the actual stdout content. This follows the
CODE_STYLE_GUIDE.md requirement to log before non-trivial assertions on
multi-line outputs, making it easier to debug test failures by showing what the
command actually produced.

Source: Coding guidelines


42-58: ⚡ Quick win

Consider adding a success test with sha512-base64 format.

Current coverage:

  • Test 1: Success with hex digest ✓
  • Test 2: Failure with sha512-base64 (hash not found) ✓
  • Test 3: Failure with invalid base64 ✓

Missing: Success test with sha512-base64 format to verify the base64-to-hex conversion produces the correct hex and finds the right package. Test 2 exercises base64 decoding but only on the failure path, so it doesn't verify the conversion is correct.

💡 Suggested test case

You could convert the valid_hash from test 1 to base64 format and verify that both formats find the same package:

#[test]
fn find_hash_works_with_base64() {
    let CommandTempCwd { mut pacquet, workspace, root: _root, npmrc_info, .. } =
        CommandTempCwd::init().add_mocked_registry();

    pacquet.arg("add").arg("[email protected]").assert().success();

    let store_dir = pacquet_store_dir::StoreDir::from(npmrc_info.store_dir);
    let store_index = StoreIndex::open_readonly_in(&store_dir).unwrap();
    let keys = store_index.keys().unwrap();
    let entries = store_index.get_many(&keys).unwrap();
    
    // Find a valid hex hash
    let mut hex_hash = String::new();
    for (_key, data) in entries {
        if let Some(file) = data.files.values().next() {
            hex_hash = file.digest.clone();
            break;
        }
    }
    
    // Convert hex to base64 and test with sha512-base64 format
    use base64::{Engine as _, engine::general_purpose::STANDARD as BASE64};
    let bytes = hex::decode(&hex_hash).unwrap();
    let base64_hash = format!("sha512-{}", BASE64.encode(&bytes));
    
    let mut pacquet2 = std::process::Command::cargo_bin("pacquet").unwrap();
    pacquet2.current_dir(&workspace);
    let output = pacquet2.arg("find-hash").arg(&base64_hash).assert().success();
    let stdout = String::from_utf8_lossy(&output.get_output().stdout);
    
    assert!(stdout.contains("is-odd"));
    assert!(stdout.contains("3.0.1"));
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pacquet/crates/cli/tests/find_hash.rs` around lines 42 - 58, Add a new test
function to verify that the find-hash command succeeds with sha512-base64
format. The test should initialize CommandTempCwd, add a package to the
registry, extract a valid hex hash from the store index, convert that hex hash
to base64 format (prefixed with "sha512-"), run the find-hash command with the
base64 hash argument, and assert that the command succeeds and the output
contains the expected package name and version. This ensures the base64-to-hex
conversion logic works correctly on the success path, not just on failure cases
like the existing test for invalid base64.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@pacquet/crates/cli/tests/find_hash.rs`:
- Around line 35-39: Before the assertions that check stdout.contains("is-odd")
and stdout.contains("3.0.1"), add a logging statement that prints the actual
stdout content. This follows the CODE_STYLE_GUIDE.md requirement to log before
non-trivial assertions on multi-line outputs, making it easier to debug test
failures by showing what the command actually produced.
- Around line 42-58: Add a new test function to verify that the find-hash
command succeeds with sha512-base64 format. The test should initialize
CommandTempCwd, add a package to the registry, extract a valid hex hash from the
store index, convert that hex hash to base64 format (prefixed with "sha512-"),
run the find-hash command with the base64 hash argument, and assert that the
command succeeds and the output contains the expected package name and version.
This ensures the base64-to-hex conversion logic works correctly on the success
path, not just on failure cases like the existing test for invalid base64.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2519d390-b26f-4698-aed6-209a5bf0b67f

📥 Commits

Reviewing files that changed from the base of the PR and between bdc1b07 and d8b96ac.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock, !Cargo.lock
📒 Files selected for processing (5)
  • pacquet/crates/cli/Cargo.toml
  • pacquet/crates/cli/src/cli_args.rs
  • pacquet/crates/cli/src/cli_args/find_hash.rs
  • pacquet/crates/cli/tests/find_hash.rs
  • pacquet/crates/store-dir/src/lib.rs

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jun 21, 2026
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit d8b96ac

@kairosci kairosci left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

All review comments are addressed: the println has been removed and a test using base64 engine directly without the hex crate has been added.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pacquet/crates/cli/tests/find_hash.rs`:
- Around line 73-80: The digest extraction logic takes the first available
digest from any entry in the store_index without checking which package it
belongs to, but the subsequent assertions expect the digest specifically from
the [email protected] package. This causes test flakiness and order-dependency.
Modify the loop in the hex_hash extraction to filter for and bind the digest
specifically from the [email protected] package entry rather than accepting the first
digest found from any package in the entries.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a7e415e8-1011-40c1-898c-4cb1afb29ff9

📥 Commits

Reviewing files that changed from the base of the PR and between d8b96ac and a8bd195.

📒 Files selected for processing (1)
  • pacquet/crates/cli/tests/find_hash.rs

Comment thread pacquet/crates/cli/tests/find_hash.rs Resolved
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit a8bd195

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit a8bd195

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit d76bc16

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit d76bc16

@codecov-commenter

codecov-commenter commented Jun 21, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.73964% with 41 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.04%. Comparing base (b4fdfe9) to head (7a50945).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
pacquet/crates/cli/src/cli_args/find_hash.rs 74.10% 36 Missing ⚠️
pacquet/crates/cli/src/cli_args/sanitize.rs 44.44% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12552      +/-   ##
==========================================
+ Coverage   88.02%   88.04%   +0.01%     
==========================================
  Files         321      323       +2     
  Lines       44941    45238     +297     
==========================================
+ Hits        39559    39828     +269     
- Misses       5382     5410      +28     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 4a30d87

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 4a30d87

@github-actions

github-actions Bot commented Jun 21, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD.

Scenario: Isolated linker: fresh restore, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.855 ± 0.217 3.646 4.279 1.86 ± 0.14
pacquet@main 3.815 ± 0.151 3.643 4.040 1.84 ± 0.12
pnpr@HEAD 2.159 ± 0.109 1.986 2.326 1.04 ± 0.08
pnpr@main 2.068 ± 0.110 1.973 2.276 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.8552240544200003,
      "stddev": 0.21685544977588658,
      "median": 3.76457619182,
      "user": 3.60595336,
      "system": 3.4267210399999994,
      "min": 3.64556283282,
      "max": 4.27946609482,
      "times": [
        3.93967960782,
        4.27946609482,
        3.73684694682,
        3.79230543682,
        4.14653754782,
        3.70772430382,
        3.69828148882,
        3.66604175282,
        3.93979453182,
        3.64556283282
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 3.81542334242,
      "stddev": 0.1507697189825743,
      "median": 3.82234479782,
      "user": 3.6071215600000004,
      "system": 3.40414834,
      "min": 3.6426947528199998,
      "max": 4.03976455282,
      "times": [
        3.94182267982,
        3.93058181482,
        3.94797746582,
        3.6426947528199998,
        3.90296931082,
        3.74172028482,
        4.03976455282,
        3.66549626682,
        3.67731970982,
        3.6638865858200003
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.15884573662,
      "stddev": 0.109482321556663,
      "median": 2.14297934932,
      "user": 2.65936696,
      "system": 3.00795654,
      "min": 1.98583823382,
      "max": 2.32578733182,
      "times": [
        2.21064838282,
        2.08559174982,
        1.98583823382,
        2.20646829382,
        2.32578733182,
        2.15066509182,
        2.08084741682,
        2.32415135382,
        2.08316590482,
        2.13529360682
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.0683396954199997,
      "stddev": 0.11035737806362572,
      "median": 2.02141426082,
      "user": 2.67184126,
      "system": 3.0181270400000004,
      "min": 1.97270299082,
      "max": 2.27565523582,
      "times": [
        2.06427397682,
        2.27565523582,
        2.01249433582,
        2.06180274582,
        2.02614892182,
        2.01553650682,
        2.26383449982,
        1.97270299082,
        1.97426814082,
        2.01667959982
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 652.9 ± 12.1 638.0 675.8 1.00
pacquet@main 653.2 ± 12.8 631.6 671.9 1.00 ± 0.03
pnpr@HEAD 742.9 ± 87.5 685.7 987.4 1.14 ± 0.14
pnpr@main 748.8 ± 104.5 686.7 1039.2 1.15 ± 0.16
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.65287501522,
      "stddev": 0.01212328169619435,
      "median": 0.6522806574200001,
      "user": 0.4143603799999999,
      "system": 1.3179518,
      "min": 0.6379835354200001,
      "max": 0.6757759014200001,
      "times": [
        0.6528753874200001,
        0.6757759014200001,
        0.6608577164200001,
        0.6434463554200001,
        0.65548748842,
        0.64472100342,
        0.6516859274200001,
        0.6397448844200001,
        0.6379835354200001,
        0.66617195242
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.6532277383200003,
      "stddev": 0.012777521420715133,
      "median": 0.6518998719200001,
      "user": 0.41742548,
      "system": 1.3226456999999998,
      "min": 0.6316294214200001,
      "max": 0.67193665942,
      "times": [
        0.6605552404200001,
        0.6316294214200001,
        0.64849747442,
        0.6369546814200001,
        0.6501381584200001,
        0.6594724674200001,
        0.6509470014200001,
        0.6528527424200001,
        0.67193665942,
        0.6692935364200001
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.7429441614200001,
      "stddev": 0.08754595079067466,
      "median": 0.72120128492,
      "user": 0.41939788,
      "system": 1.3738781999999998,
      "min": 0.6856831794200001,
      "max": 0.98740355042,
      "times": [
        0.7323165494200001,
        0.6916061814200001,
        0.6856831794200001,
        0.7248632074200001,
        0.70831009442,
        0.7375349734200001,
        0.7298442854200001,
        0.71434023042,
        0.71753936242,
        0.98740355042
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.7488145690200001,
      "stddev": 0.10453179488269736,
      "median": 0.72195431342,
      "user": 0.43632177999999994,
      "system": 1.3821451,
      "min": 0.6866665014200001,
      "max": 1.03923249642,
      "times": [
        0.6948151534200001,
        0.6992426104200001,
        0.6866665014200001,
        0.6961397004200001,
        0.7432595014200001,
        0.71524568742,
        0.72866293942,
        0.7293241544200001,
        1.03923249642,
        0.7555569454200001
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.275 ± 0.052 4.210 4.365 1.99 ± 0.11
pacquet@main 4.267 ± 0.056 4.151 4.358 1.98 ± 0.11
pnpr@HEAD 2.251 ± 0.115 2.076 2.430 1.05 ± 0.08
pnpr@main 2.153 ± 0.119 2.011 2.345 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.27473241796,
      "stddev": 0.05222495861756963,
      "median": 4.2732190153600005,
      "user": 3.7885957600000006,
      "system": 3.3514289600000007,
      "min": 4.20962438036,
      "max": 4.36536172236,
      "times": [
        4.3300185113600005,
        4.2982956983600005,
        4.210096286360001,
        4.36536172236,
        4.309696922360001,
        4.223132345360001,
        4.254660282360001,
        4.270756895360001,
        4.20962438036,
        4.27568113536
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.266781207460001,
      "stddev": 0.056310078416206236,
      "median": 4.271456435360001,
      "user": 3.80955436,
      "system": 3.34800936,
      "min": 4.150719657360001,
      "max": 4.357594968360001,
      "times": [
        4.277931786360001,
        4.267945405360001,
        4.150719657360001,
        4.328068479360001,
        4.26237289536,
        4.2749674653600005,
        4.21626090136,
        4.27818453436,
        4.357594968360001,
        4.253765981360001
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.25069745376,
      "stddev": 0.11529693490776532,
      "median": 2.28367677486,
      "user": 2.47026136,
      "system": 2.95171136,
      "min": 2.07572108736,
      "max": 2.43048254936,
      "times": [
        2.37249150736,
        2.31437334536,
        2.29816113636,
        2.43048254936,
        2.07572108736,
        2.27120158236,
        2.29615196736,
        2.11043594236,
        2.16429952636,
        2.17365589336
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.15267347776,
      "stddev": 0.11909806107177291,
      "median": 2.11718969086,
      "user": 2.50126996,
      "system": 2.9013176599999997,
      "min": 2.01069213936,
      "max": 2.34547761836,
      "times": [
        2.34547761836,
        2.10417380036,
        2.33541560336,
        2.12143269436,
        2.02375472036,
        2.01069213936,
        2.18960442336,
        2.22467733436,
        2.11294668736,
        2.0585597563599998
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, hot cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.380 ± 0.023 1.342 1.413 1.97 ± 0.18
pacquet@main 1.430 ± 0.033 1.395 1.495 2.04 ± 0.19
pnpr@HEAD 0.701 ± 0.065 0.659 0.879 1.00
pnpr@main 0.715 ± 0.099 0.667 0.994 1.02 ± 0.17
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.38042781218,
      "stddev": 0.02264522456374274,
      "median": 1.3823753081799999,
      "user": 1.42222112,
      "system": 1.72268564,
      "min": 1.34202795968,
      "max": 1.41258706268,
      "times": [
        1.41258706268,
        1.35193439668,
        1.34202795968,
        1.36205851468,
        1.38285416568,
        1.40052996168,
        1.3985434636799998,
        1.39476814968,
        1.37707799668,
        1.38189645068
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.4299864884799998,
      "stddev": 0.03318998475922451,
      "median": 1.42302102068,
      "user": 1.4531998199999996,
      "system": 1.7595611399999995,
      "min": 1.39465543868,
      "max": 1.49499391368,
      "times": [
        1.4602826276799998,
        1.39777100068,
        1.40051784468,
        1.49499391368,
        1.42472532768,
        1.43202701668,
        1.42131671368,
        1.39465543868,
        1.46339874468,
        1.41017625668
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.70084424568,
      "stddev": 0.06455114882096213,
      "median": 0.6801432771800001,
      "user": 0.3766194199999999,
      "system": 1.3202182399999998,
      "min": 0.6593443536800001,
      "max": 0.8792877986800001,
      "times": [
        0.6771600526800001,
        0.6898830746800001,
        0.8792877986800001,
        0.7161901926800001,
        0.6831265016800001,
        0.67068300568,
        0.6873959256800001,
        0.66878364168,
        0.6593443536800001,
        0.67658790968
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.7145621305800001,
      "stddev": 0.09853423665158946,
      "median": 0.68323838668,
      "user": 0.38237592,
      "system": 1.3210048399999998,
      "min": 0.6672934316800001,
      "max": 0.9939979226800001,
      "times": [
        0.67747744468,
        0.69620088168,
        0.68063962968,
        0.6810549476800001,
        0.68193826168,
        0.6845385116800001,
        0.6878616536800001,
        0.6672934316800001,
        0.69461862068,
        0.9939979226800001
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.128 ± 0.061 3.047 3.263 4.60 ± 0.10
pacquet@main 3.091 ± 0.065 3.038 3.267 4.54 ± 0.10
pnpr@HEAD 0.684 ± 0.007 0.677 0.694 1.01 ± 0.01
pnpr@main 0.680 ± 0.006 0.669 0.687 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.1275537250200007,
      "stddev": 0.060850683375315365,
      "median": 3.1252240993200004,
      "user": 1.88511006,
      "system": 2.01017396,
      "min": 3.0466115298200003,
      "max": 3.2632022548200004,
      "times": [
        3.1509486038200003,
        3.14578820082,
        3.1046599978200002,
        3.15978013582,
        3.14905734382,
        3.0798835538200002,
        3.0920151228200004,
        3.0835905068200002,
        3.2632022548200004,
        3.0466115298200003
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 3.09136383862,
      "stddev": 0.06512790503496099,
      "median": 3.07965359832,
      "user": 1.88078076,
      "system": 1.9814308600000001,
      "min": 3.0382286238200003,
      "max": 3.26705196182,
      "times": [
        3.0382286238200003,
        3.04456350382,
        3.06093775182,
        3.06248337982,
        3.08307656182,
        3.10575988682,
        3.0762306348200004,
        3.0887822858200003,
        3.26705196182,
        3.0865237958200002
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.6844900933200001,
      "stddev": 0.006595719489534141,
      "median": 0.6825362393200001,
      "user": 0.37572195999999997,
      "system": 1.3209142600000001,
      "min": 0.6769306378200001,
      "max": 0.6942377838200001,
      "times": [
        0.6803197648200001,
        0.6769306378200001,
        0.6920156888200001,
        0.67965557082,
        0.6777115628200001,
        0.6928787348200001,
        0.6847527138200001,
        0.6798637768200001,
        0.6865346988200001,
        0.6942377838200001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.6804835499200002,
      "stddev": 0.0055833849152947075,
      "median": 0.68153075232,
      "user": 0.38050806000000004,
      "system": 1.31355986,
      "min": 0.6689521908200001,
      "max": 0.6871372438200001,
      "times": [
        0.6852931518200001,
        0.6689521908200001,
        0.68262378582,
        0.6804377188200001,
        0.6756894868200001,
        0.6792374768200001,
        0.67643678782,
        0.6871372438200001,
        0.6855651388200001,
        0.6834625178200001
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Jun 21, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12552
Testbedpacquet
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
4,274.73 ms
(+1.20%)Baseline: 4,224.23 ms
5,069.08 ms
(84.33%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
3,127.55 ms
(+3.94%)Baseline: 3,008.96 ms
3,610.75 ms
(86.62%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
1,380.43 ms
(+3.78%)Baseline: 1,330.16 ms
1,596.20 ms
(86.48%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
3,855.22 ms
(-3.35%)Baseline: 3,988.96 ms
4,786.75 ms
(80.54%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
652.88 ms
(+4.76%)Baseline: 623.21 ms
747.86 ms
(87.30%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Jun 21, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12552
Testbedpnpr

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymilliseconds (ms)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,250.70 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
684.49 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
700.84 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,158.85 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
742.94 ms
🐰 View full continuous benchmarking report in Bencher

kairosci added 11 commits June 22, 2026 01:42
- Rename single-letter closure params |m| to |manifest|
- Wrap bare color hex references in backticks in comments
- Add trailing comma in multi-line macro invocation
- Use fmt::Write as _ to follow repo convention
- Fix taplo formatting in Cargo.toml
- Fix  by moving trailing comma from
  inside  to the  macro arg list.
- Fix  wrapping of  and
   chained calls.
Before opening the store index DB, validate that non-shaN-... inputs are
valid hex digests of the expected length (128 chars for sha512).
Return a clear 'invalid hash format' error immediately instead of
scanning the entire index with a malformed argument.
- Branch on config.frozen_store: use open_immutable for frozen stores,
  open_readonly_in otherwise; surface DB open errors with context.
- Validate shaN- input algorithm prefix: only sha512 is supported.
- Accept non-standard base64 padding via fallback to STANDARD_NO_PAD
  after STANDARD fails (matching Node.js leniency).
- Validate decoded base64 payload is 64 bytes for sha512.
- Fix should_fail_on_missing_hash test: install package first so
  index.db exists, then search for a non-matching hash.
- Surface store-index open errors instead of mapping everything to
  INVALID_FILE_HASH.
@zkochan
zkochan force-pushed the feat/pacquet-find-hash branch from 336ceb9 to 25db237 Compare June 21, 2026 23:48
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 25db237

1 similar comment
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 25db237

zkochan added 2 commits June 22, 2026 02:00
find-hash printed name@version and the index key with unconditional
owo_colors styling, leaking ANSI escapes into piped/captured output.
pnpm's chalk disables color when stdout is not a TTY, so emit color only
via if_supports_color(Stream::Stdout, ...) and route the store-derived
strings through sanitize() to strip control characters.

Extract the sanitize helper out of `why` into a shared cli_args::sanitize
module so both commands reuse it.

Also guard the find-hash success tests against vacuous assertions: the
sampled row's manifest is optional, so assert the resolved name/version
are non-empty before checking stdout.
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 5ef1d68

1 similar comment
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 5ef1d68

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 7a50945

@zkochan
zkochan enabled auto-merge (squash) June 22, 2026 01:10
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 7a50945

@zkochan
zkochan merged commit e72b482 into pnpm:main Jun 22, 2026
31 checks passed
KSXGitHub pushed a commit that referenced this pull request Jun 22, 2026
Reconcile the pack command port with main's new find-hash command
(#12552), which touched the same CLI wiring.

- cli_args.rs: git auto-merged the non-adjacent additions, so both the
  Pack and FindHash commands (modules, imports, enum variants, dispatch
  arms) are present.
- cli/Cargo.toml: union the external dependencies — main's rmp-serde and
  the owo-colors.workspace dotted form, plus this branch's tracing.

The other incoming commits (pnpr namespace/toggles, audit, tooling) do
not interact with pack. The merged workspace builds, clippy is clean,
and the pack / fs-packlist / exportable-manifest tests pass.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01G4k3hPXaosUkKBPbnChg4q
@kairosci
kairosci deleted the feat/pacquet-find-hash branch June 22, 2026 06:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pacquet reviewed: coderabbit CodeRabbit submitted an approving review state: automerge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants