Skip to content

Only warn berry migration risk when the classic lock holds a pin - #1077

Merged
Mikola Lysenko (mikolalysenko) merged 3 commits into
mainfrom
agent/followup-917-berry-risk-mirror
Oct 8, 2026
Merged

Mikola Lysenko (mikolalysenko) merged 3 commits into
mainfrom
agent/followup-917-berry-risk-mirror

Conversation

@mikolalysenko

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

Copy link
Copy Markdown
Collaborator

Follow-up to #917 (merged), fixing a Cursor Bugbot finding that landed after the merge.

Bugbot finding (Low severity, on #917)

Berry warning fires without a pin. any_pinned is set from matched_any after a classic entry matches, including when an offline-mirror refusal then skips the rewrite. The advisory still claims the lock carries hosted pins, so a first run that writes nothing reports redirect_yarn_classic_berry_migration_risk alongside redirect_yarn_classic_offline_mirror.

Fix

rewrite_yarn_classic (crates/socket-patch-core/src/patch/redirect/mod.rs) now tracks a separate pinned_any per dependency:

  • An entry that is rewritten counts as pinned.
  • An entry skipped by the offline-mirror refusal counts as pinned only if its block already contains the hosted artifact URL (an earlier run wrote the pin, so the berry-migration risk is real).
  • any_pinned (which gates redirect_yarn_classic_berry_migration_risk) is now fed from pinned_any instead of matched_any.

Tests

New unit test yarn_classic_berry_risk_follows_pins_under_offline_mirror_refusal:

  • first hosted run under an offline mirror: only redirect_yarn_classic_offline_mirror is emitted (no berry-risk warning);
  • re-run under the mirror on a lock that already holds the hosted pin: nothing written, berry-risk warning still emitted once.

Locally: cargo test -p socket-patch-core --lib redirect 656 passed. Branch has current main merged in.

🤖 Generated with Claude Code


Note

Low Risk
Narrows when a redirect advisory is emitted in yarn.lock rewriting; behavior change is limited to warning accuracy under offline-mirror refusal.

Overview
Fixes redirect_yarn_classic_berry_migration_risk firing when Yarn classic entries match but no hosted pin is actually present—e.g. first run under offline-mirror refusal, which skips rewriting resolved URLs.

rewrite_yarn_classic now tracks pinned_any separately from matched_any: a dependency counts toward berry-migration risk only when a pin is written this run, or when a refused block already contains a patch-server hosted URL from an earlier run (berry_hosted_pin_is_ours). any_pinned is updated from pinned_any instead of matched_any.

Adds yarn_classic_berry_risk_follows_pins_under_offline_mirror_refusal to assert mirror-only warnings on first refusal, berry-risk when re-running on an already-pinned lock, and correct behavior for old grant URLs vs unrelated mirrors.

Reviewed by Cursor Bugbot for commit f0062e5. Configure here.

An offline-mirror refusal leaves the matched classic entries untouched,
but the matched entry still set any_pinned, so a first hosted run that
wrote nothing reported redirect_yarn_classic_berry_migration_risk next to
redirect_yarn_classic_offline_mirror. Count a refused entry as pinned only
when an earlier run already wrote its hosted URL into the block.

Reported by Cursor Bugbot on #917.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

bugbot run

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

Stale Bugbot comment from a previous run.

Comment thread crates/socket-patch-core/src/patch/redirect/mod.rs Outdated
Under an offline-mirror refusal the prior-pin check matched only this
run's exact artifact URL, so a lock still holding a hosted pin from an
earlier grant token or patch uuid on the same patch server stayed silent
about the berry migration risk. Reuse berry_hosted_pin_is_ours on the
entry's resolved URL (fragment stripped) so any same-origin hosted pin
naming the package version counts, while a user's own mirror does not.

Reported by Cursor Bugbot on #1077.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

bugbot run

@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 f0062e5. Configure here.

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

Copy link
Copy Markdown
Collaborator Author

[agent] Ready for review at f0062e5.

  • CI on f0062e5: 554 success, 6 skipped, 0 failing/pending; ci-ok green. Mergeable: clean.
  • Changes: opened this PR from the never-opened Fix hosted yarn classic pins missing berry warning (#907) #917 Bugbot follow-up branch; merged current main (5ffe66b); fixed a second Bugbot finding (f0062e5): the offline-mirror prior-pin check now accepts any same-origin hosted pin naming the package version (earlier grant token / uuid) via berry_hosted_pin_is_ours, not only this run's exact URL. Unit test covers rotated same-server pin (warned) and a user mirror on another origin (not warned).
  • Bugbot: re-run on f0062e5 found no new issues; the earlier thread is resolved.

Generated by Claude Code

@mikolalysenko
Mikola Lysenko (mikolalysenko) added this pull request to the merge queue Oct 7, 2026
Merged via the queue into main with commit 72ef1e2 Oct 8, 2026
561 checks passed
@mikolalysenko
Mikola Lysenko (mikolalysenko) deleted the agent/followup-917-berry-risk-mirror branch October 8, 2026 01:18
Mikola Lysenko (mikolalysenko) added a commit that referenced this pull request Oct 8, 2026
Resolve the redirect import and berry_reposition_blocks conflicts in
favor of this branch's formats/yarn grammar, and read the classic
resolved URL through classic_field in main's #1077 refused-pin check.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Mikola Lysenko (mikolalysenko) added a commit that referenced this pull request Oct 8, 2026
Resolve conflicts with main's #946 (PyPI takeover pre-gate), #1042
(containment helper) and #1077 (classic berry-migration warning):

- hosted.rs: keep this PR's staged takeover; main's new
  `preflight_pypi_takeover` pre-gate inside the deleted
  `vendored_takeover` is dropped. The staged takeover's `explain` now
  calls `preflight_pypi_takeover` (instead of only the requirements
  check), so a retracted uv pin-down (#723) or Poetry 0.x (#945)
  takeover is still skipped with `redirect_uv_takeover_version_unreachable`
  / `redirect_poetry_lock_unsupported`, as main's tests expect.
- socket_dir.rs: use main's `containment::ensure_unlinked` guard, then
  this PR's deferred removal.
- redirect/mod.rs: take main's `pinned_any` (a mirror-refused entry
  counts only when it already carries our hosted pin), which subsumes
  this PR's mirror fix.
- CLI_CONTRACT.md: describe the uv/Poetry cases as retractions.
- mode_migration_pypi.rs: keep both sides' tests.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants