Repository navigation
Read the go.mod module directive through go_mod_edit (#781) - #870
Conversation
Assisted-by: Claude Code:claude-opus-5-5
VEX --product auto-detection read the go.mod module directive with its own line scanner, which misread Go's block form `module ( example.com/blk )` as `pkg:golang/(`. The crawler kept a third reader, parse_go_mod_module, that nothing in production called. go_mod_edit::module_path now reads the directive through the same directive walker as require and replace (single-line and block forms, quoted tokens, BOM, trailing comments). product.rs keeps only the purl formatting, and parse_go_mod_module and its tests are deleted; its cases move to module_path's unit tests. Assisted-by: Claude Code:claude-opus-5-5
|
BugBot review Generated by Claude Code |
|
BugBot review Generated by Claude Code |
There was a problem hiding this comment.
✅ 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 b486532. Configure here.
|
[agent] One check is red: I don't think this PR causes it:
No fix exists to port. I'm re-running the failed job once. If it fails again, I'll treat it as a real failure and investigate the cell's Generated by Claude Code |
LLM Description written by Claude Code:claude-opus-5-5
Fixes #781
Summary
The go.mod
moduledirective had three readers: a deadcrawlers::go_crawler::parse_go_mod_module, VEX--product's own line scanner invex/product.rs, and thego_mod_editdirective walker thatrequireandreplacealready go through. This PR addsgo_mod_edit::module_path, built on that walker, and deletes the other two readers.Why
What changed
vendor/go_mod_edit.rs: newpub fn module_path(text) -> Option<String>. It runsnormalize_for_read(BOM, quoted tokens) andfor_each_directive_body(…, "module", …)(single-line andmodule ( … )block forms, trailing//comments, any whitespace). It takes the first body and returns its single token. It returnsNonefor a multi-token body, a token that is still quoted (module ""), or a path that failsis_safe_multi_segment.vex/product.rs:parse_go_modnow callsmodule_pathand only formatspkg:golang/<module>.What was deleted
crawlers::go_crawler::parse_go_mod_module, which had no production caller, plus its 8 unit tests and the 5 tests intests/crawler_go_e2e.rs. The cases worth keeping now run againstmodule_path.product.rsparse_go_mod.git diff --stat: 4 files, +87 / −181. That's about +22 / −64 production lines and +65 / −117 test lines.Behavior
vexproduct auto-detection on a go.mod that uses the block formmodule (⏎\texample.com/blk⏎). It now yieldspkg:golang/example.com/blkinstead ofpkg:golang/(.module "foo) is no longer read asfoo. A whitespace separator other than space or tab aftermoduleis now accepted, matching Go's lexer.Test evidence
go_mod_edittests:module_path_reads_every_directive_formandmodule_path_rejects_malformed_directives(the cases carried over from the deleted tests, plus the block form, backticks, BOM, CRLF and unsafe paths).vex::producttest:detect_go_mod_block_form_module. Red→green: withmain'sparse_go_modrestored it fails withleft: Some("pkg:golang/("),right: Some("pkg:golang/example.com/blk"). On this branch it passes.cargo clippy --workspace --all-features -- -D warnings: clean.cargo test -p socket-patch-core --lib: 5046 passed, 4 failed. Those 4 are the sandbox's known root-only failures, which also fail onmain: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_untouchedandpypi_requirements::wire_failure_rolls_back_already_written_files.cargo test -p socket-patch-core --test crawler_go_e2e: 19 passed.cargo test -p socket-patch-cli --all-features --test vex_terminal_output: 12 passed.--test covgap_commands_vex: 12 passed.b486532: 455 checks passed, 6 skipped. The one failure, the Bunnative (macos-latest, 1.3.10)cellpreexisting-manifest vendored, passed on its one re-run.Risk
Low. One read-only parser in VEX product detection. The writers and lockfile discovery already used the shared walker.
🤖 Generated with Claude Code
Note
Low Risk
Read-only parsing change in VEX product detection with expanded tests; no CLI contract or crawler runtime behavior changes beyond removing dead code.
Overview
Consolidates go.mod
moduledirective parsing into a single shared reader,go_mod_edit::module_path, built on the same directive walker already used forrequire/replace.VEX product auto-detection (
parse_go_mod) now calls that helper instead of a hand-rolled line scanner. Block-form directives (module (\n\tpath\n)) correctly yieldpkg:golang/<path>instead of the boguspkg:golang/(.Removes the unused
crawlers::go_crawler::parse_go_mod_moduleand its duplicate tests; coverage moves togo_mod_editand a newdetect_go_mod_block_form_moduletest. Net reduction in duplicated parsing logic (~40 production lines).Reviewed by Cursor Bugbot for commit b486532. Configure here.
Generated by Claude Code