Skip to content

Move BOM handling in 4 more files onto formats::text (#905) - #1191

Merged
Mikola Lysenko (mikolalysenko) merged 2 commits into
mainfrom
arch-refactor/905-bom-sites-3
Oct 9, 2026
Merged

Mikola Lysenko (mikolalysenko) merged 2 commits into
mainfrom
arch-refactor/905-bom-sites-3

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

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

Refs #905 (step 3, slice 3). This PR doesn't close the issue: 11 files stay on PENDING_INLINE_BOMS, and open PRs change every one of them.

Summary

Four production files still handled a leading UTF-8 BOM with their own inline code. They now call formats::text::{split_bom, strip_bom}, and the guard's pending list drops them.

File Site Now
patch/redirect/vlt.rs vlt.json modifiers probe strip_bom
vendor/go_mod_edit.rs normalize_for_read (go.mod / go.work read-only parsers) strip_bom
vendor/jvm/gradle.rs append_line (BOM-only file check), first_statement_offset (never insert before a BOM) strip_bom, split_bom(..).0.len()
vendor/lock_inventory/pypi.rs parse_pipfile_lock, the shared reader for the inventory, the hosted Pipenv rewriter, upstream restore and discovery strip_bom (was trim_start_matches)

Why

  • Issue: #905. Register row E64 (register). Living document: doc/04-js-lockfiles.md, the E64 bullet.
  • Leverage: B 0, U 0, D ≈4 (four inline copies of the one-BOM rule), R L. Score ≈8. It was the top-ranked candidate whose files no open arch-refactor/* or agent/fix-* PR changes.

Behavior

Deleted

  • Production: 4 inline BOM rules. Diff: +11/−13 production lines, +74 test lines (git diff --stat over the 5 files).

Tests

Each former caller gets a 0/1/2-BOM test:

  • vlt::tests::modifiers_probe_reads_past_one_vlt_json_bom_only
  • go_mod_edit::tests::normalize_for_read_drops_one_leading_bom_only
  • jvm::gradle::tests::appended_and_inserted_lines_skip_one_leading_bom
  • lock_inventory::pypi::tests::pipfile_lock_reads_past_one_bom_only. Its two-BOM assertion fails on main, because trim_start_matches parses the lock; it pins the behavior change above.

Results:

  • cargo clippy --workspace --all-features -- -D warnings: clean.
  • cargo test -p socket-patch-core --lib: 5839 passed and 4 failed. All 4 failures need root, also fail on main in this sandbox, and pass in CI: 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.
  • CLI suites:
    • e2e_vex_lockfile: 343 passed.
    • e2e_vlt: 27 passed.
    • gradle_agent_cli: 52 passed.
    • in_process_redirect_pipenv: 11 passed.

Risk

Low. The change is mechanical, and only the double-BOM Pipfile.lock case behaves differently.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NRDjSfGgExpXELjwUSeZwi


Note

Low Risk
Mechanical refactor with one edge-case behavior change: double-BOM Pipfile.lock files now fail to parse instead of being accepted.

Overview
Continues #905 by routing four call sites through formats::text::{strip_bom, split_bom} instead of ad hoc UTF-8 BOM handling, and removes those paths from PENDING_INLINE_BOMS.

vlt (modifiers probe on vlt.json), go.mod read normalization, Gradle (append_line / first_statement_offset), and Pipfile.lock parsing now share the one leading BOM = encoding rule. vlt, Go, and Gradle behavior is unchanged in practice; Pipfile.lock parsing no longer strips every leading BOM via trim_start_matches—a second leading BOM is treated as content and parse fails, matching other readers.

Each migrated area gets a small test pinning 0/1/2-BOM behavior.

Reviewed by Cursor Bugbot for commit 2f5cd77. Configure here.


Generated by Claude Code

Assisted-by: Claude Code:claude-opus-5-5
@mikolalysenko Mikola Lysenko (mikolalysenko) added arch-refactor PR opened by the scheduled architecture refactor routine refactor Structural change: duplicated code or logic, missing abstraction, layering, dead code labels Oct 9, 2026
The vlt.json modifiers probe, the read-only go.mod normalizer, the
vendored Gradle settings editor (appended lines and the
pluginManagement insertion point) and the shared Pipfile.lock parser
spelled out "skip a leading UTF-8 BOM" inline. They now call
strip_bom or split_bom, so one leading BOM is encoding everywhere
(#905).

Zero or one leading BOM behaves as before. A Pipfile.lock that starts
with two BOMs is now unparseable (the second is content), the same
rule every other reader follows since #1160; it parsed before.

PENDING_INLINE_BOMS drops these four files (11 remain, all in files
open PRs change). Each former caller gets a 0/1/2-BOM test.

Assisted-by: Claude Code:claude-opus-5-5
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review October 9, 2026 00:12
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

BugBot review


Generated by Claude Code

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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 2f5cd77. Configure here.

@mikolalysenko Mikola Lysenko (mikolalysenko) added the Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review label Oct 9, 2026
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

Ready for review at head 2f5cd77e80297c8f8729feaa095ab916da3784ef.

  • CI: all check suites on this head are green (no failures; skipped jobs are path-filtered).
  • Bugbot: reviewed 2f5cd77e, no findings. No unresolved review threads.
  • Mergeable: yes, no conflicts. No CHANGELOG.md change.

Slack announcement: not sent this run (Slack send tool unavailable); the next run will retry.


Generated by Claude Code

@mikolalysenko
Mikola Lysenko (mikolalysenko) added this pull request to the merge queue Oct 9, 2026
Merged via the queue into main with commit eb3fcc4 Oct 9, 2026
535 checks passed
@mikolalysenko
Mikola Lysenko (mikolalysenko) deleted the arch-refactor/905-bom-sites-3 branch October 9, 2026 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

Development

Successfully merging this pull request may close these issues.

3 participants