GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Read Cargo.toml [package] identity through formats::cargo::manifest (#693) by mikolalysenko · Pull Request #1110 · SocketDev/socket-patch

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Oct 8, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

LLM Description written by Claude Code:claude-opus-5-5

Fixes #693 (slice 1 of 2)

Summary

Three parsers read a Cargo.toml's [package] name and version: the cargo crawler's hand-rolled line scanner, VEX product detection's scan_toml_section, and cargo_tag's own toml_edit lookup. This PR adds one toml_edit reader, formats::cargo::manifest, moves all three onto it, and deletes the crawler's scanner.

Why

  • Issue #693, register row E15 (living document §5.4, Cargo).
  • The three readers had drifted. On a BOM, the legacy [project] table, dotted keys or invalid TOML, the crawler, VEX and cargo_tag gave different answers (see the table in Read Cargo.toml package name and version through one shared toml_edit reader #693).
  • In a cargo vendor directory, where the dir name carries no version, the crawler couldn't find a crate with such a manifest at all.
  • Leverage: B 0; U 1 (Vendored cargo warns cargo_multi_version_old_cargo ("declares no rust-version") when the root package inherits rust-version from [workspace.package] #651 and the vendor/cargo.rs slice build on this reader); D 3 parsers into 1, about −110 production lines; R L.

What changed

  • New formats/cargo/manifest.rs:
    • package_table(&Table) returns [package], else legacy [project];
    • package_name_version(&str) returns the literal name and version, or None for invalid TOML, a missing or empty field, or a non-literal field such as version.workspace = true. It is pure, so it passes the formats architecture guard.
  • crawlers/cargo_crawler.rs (and its test oracle) calls package_name_version. Deleted: parse_cargo_toml_name_version, parse_table_header, extract_string_value and the scanner-specific unit tests. The tests that pin crawler behavior (comments, quotes, subtables, workspace inheritance) stay and now run through the shared reader.
  • vex/product.rs parse_cargo_toml calls package_name_version. scan_toml_section stays for pyproject.toml (E38's).
  • vendor/cargo_tag.rs version_literal finds its table through package_table and keeps only the span and quote logic.
  • tests/crawler_cargo_e2e.rs imports the reader from formats::cargo::manifest.

Left for slice 2: vendor/cargo.rs (path_crate_version, declared_cargo_minor, and #651's rust-version inheritance). Open PRs #1026, #1039, #1041, #1043 and #1050 change that file.

Diff

7 files, +250 / −247: production about +45 / −115, the rest tests.

Behavior

Lockfiles, JSON output, exit codes and the CLI contract don't change. Cargo-style parsing changes the reader in these cases:

  • Crawler: now reads a manifest with a BOM, [project], dotted keys or an inline package = { … }. It no longer reads invalid TOML ([package] junk, a stray [oops line); those fall back to the directory name, as version.workspace = true already did.
  • VEX product: now reads [project], dotted keys and the inline table.
  • cargo_tag: unchanged.

Normalized crates.io manifests (plain [package]) take none of these paths. On all 208 real registry manifests in ~/.cargo/registry/src, the old scanner and the new reader agree on every file.

Cost on the crawl path

A full toml_edit parse is slower than the line scanner, which stopped early. Release build, 208 real registry manifests × 20 iterations:

  • old scanner: 0.5 µs per manifest;
  • new reader: 81 µs per manifest.

crawl_all reads each crate's Cargo.toml on the walk pool, so 1,000 cached crates cost about 80 ms of extra CPU spread across the pool's threads. This is the price of agreeing with cargo, and #693 asks for toml_edit explicitly. S = 0 (no speed-up claimed).

Tests

  • New: vex::product::tests::cargo_manifest_readers_agree. It runs the issue's drift rows (plain, BOM, [project], dotted, inline, workspace, invalid, no package) through the crawler's reader, VEX parse_cargo_toml and cargo_tag::tag_manifest_text, and asserts they agree.
  • New: formats::cargo::manifest::tests, covering every spelling, [package] over [project], and the inputs it can't read.
  • New: find_by_purls_vendor_layout_reads_every_manifest_spelling (crawler e2e): vendored crates with a BOM, [project] or dotted-key manifest are found. It fails on main, where the scanner returns None and the version-less dir name can't stand in.
  • cargo clippy --workspace --all-features -- -D warnings: clean.
  • cargo test -p socket-patch-core --lib: 5711 passed, 4 failed. The 4 are the known root-only sandbox failures that also fail on main (copy_tree::relax_loop_must_not_traverse_symlinked_root, vlt_heal::an_unremovable_hidden_lock_keeps_every_store_entry, pypi_poetry::wire_write_failure_maps_error_and_leaves_lock_untouched, pypi_requirements::wire_failure_rolls_back_already_written_files).
  • cargo test -p socket-patch-core --test crawler_cargo_e2e: 34 passed.
  • cargo test -p socket-patch-cli --all-features with --test in_process_cargo_apply, mode_migration_cargo, e2e_cargo, covgap_commands_vex, e2e_vex_redirect and e2e_vex_vendor: all green.

Risk

Low. The changes are the documented reader cases above, and the extra parse CPU on the cargo crawl path.

🤖 Generated with Claude Code


Note

Medium Risk
Changes crate discovery and VEX product PURLs for non-standard but cargo-valid manifests; crawl path is slower per manifest though normal registry layouts are unchanged.

Overview
Unifies Cargo.toml package identity behind a single toml_edit reader in formats::cargo::manifest (package_name_version / package_table), replacing three divergent parsers (cargo crawler line scanner, VEX scan_toml_section, and duplicated table lookup in cargo_tag).

The cargo crawler and its test oracle now call package_name_version; the hand-rolled parser and most of its unit tests are deleted. VEX parse_cargo_toml and cargo_tag::version_literal route through the same module. Behavior shifts for edge manifests cargo accepts: UTF-8 BOM, legacy [project], dotted keys, and inline package = { … } are read consistently (fixing vendored crates whose dir name has no version). Invalid TOML is no longer partially parsed by the crawler scanner—it returns None and may fall back to directory-name parsing. Crawl path pays a full toml_edit parse per manifest.

Tests add manifest unit coverage, cargo_manifest_readers_agree, and vendor-layout e2e for alternate spellings.

Reviewed by Cursor Bugbot for commit 3f4b741. Configure here.


Generated by Claude Code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@claude
Start refactor for #693
4cf9908
Assisted-by: Claude Code:claude-opus-5-5
@mikolalysenko Mikola Lysenko (mikolalysenko) added refactor Structural change: duplicated code or logic, missing abstraction, layering, dead code arch-refactor PR opened by the scheduled architecture refactor routine labels Oct 8, 2026
@mikolalysenko Mikola Lysenko (mikolalysenko) mentioned this pull request Oct 8, 2026
Read Cargo.toml package name and version through one shared toml_edit reader #693
Closed
4 tasks
Claude (claude) added 2 commits October 8, 2026 06:02
@claude
Read Cargo.toml identity through one reader
bfb282e
The cargo crawler, VEX product detection and cargo_tag each read a
Cargo.toml [package] table their own way, and they disagreed: the
crawler's line scanner missed a manifest with a BOM, the legacy
[project] table or dotted keys, so such a vendored crate could not be
found at all, while it accepted text cargo rejects as invalid TOML.

formats::cargo::manifest now parses with toml_edit for all three, and
the crawler's hand-rolled scanner is deleted.

Assisted-by: Claude Code:claude-opus-5-5
@claude
Drop the deleted scanner's header test; format
3f4b741
Assisted-by: Claude Code:claude-opus-5-5
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review October 8, 2026 06:21
@mikolalysenko

Mikola Lysenko (mikolalysenko) commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator Author

BugBot review


Generated by Claude Code

cursor[bot] reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Mikola Lysenko (mikolalysenko) pushed a commit that referenced this pull request Oct 8, 2026
@claude
refactor: #1110 for #693 slice 1; re-rank at ea09714
eaa0ad9
Assisted-by: Claude Code:claude-opus-5-5
cursor[bot]
cursor Bot reviewed Oct 8, 2026
View reviewed changes

@cursor cursor Bot left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 3f4b741. Configure here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mikolalysenko Mikola Lysenko (mikolalysenko) mentioned this pull request Oct 8, 2026
Vendored cargo warns cargo_multi_version_old_cargo ("declares no rust-version") when the root package inherits rust-version from [workspace.package] #651
Closed
@mikolalysenko Mikola Lysenko (mikolalysenko) added the Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review label Oct 8, 2026
@mikolalysenko

Mikola Lysenko (mikolalysenko) commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator Author

Ready for review (burn-down agent).

  • Head: 3f4b7417ccabb9577718e53ecaa97893cffc4a7e
  • CI: 503/503 check runs green (success/skipped/neutral) on this head, mergeable, no conflicts.
  • Bugbot: reviewed this head (Cursor Bugbot check: success), no unresolved review threads.
  • Changelog: untouched.

Nothing specific flagged for the reviewer beyond the PR description.


Generated by Claude Code

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Tanmay182003
Tanmay Singla (Tanmay182003) approved these changes Oct 8, 2026
View reviewed changes
@mikolalysenko
Mikola Lysenko (mikolalysenko) added this pull request to the merge queue Oct 8, 2026
Merged via the queue into main with commit d52a67b Oct 8, 2026
504 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@mikolalysenko
Mikola Lysenko (mikolalysenko) deleted the arch-refactor/693-cargo-manifest-reader branch October 8, 2026 17:29
Mikola Lysenko (mikolalysenko) pushed a commit that referenced this pull request Oct 8, 2026
@claude
refactor: record #1106/#1110/#1117, open #1153
e40e6b1
Assisted-by: Claude Code:claude-opus-5-5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@cursor cursor[bot] cursor[bot] left review comments
@Tanmay182003 Tanmay Singla (Tanmay182003) Tanmay182003 approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

arch-refactor PR opened by the scheduled architecture refactor routine Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review refactor Structural change: duplicated code or logic, missing abstraction, layering, dead code

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Read Cargo.toml package name and version through one shared toml_edit reader

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@mikolalysenko @Tanmay182003 @claude
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.