Skip to content

Report which hosted patch pins changed - #2307

Open
Martin Torp (mtorp) wants to merge 4 commits into
mainfrom
codex/report-hosted-pin-changes
Open

Martin Torp (mtorp) wants to merge 4 commits into
mainfrom
codex/report-hosted-pin-changes

Conversation

@mtorp

@mtorp Martin Torp (mtorp) commented Nov 27, 2026 •

Copy link
Copy Markdown

Hosted scans report an applied event for every confirmed patch, including a patch that was already in place. When two packages share a lockfile, the file list alone cannot tell a caller which pin changed.

Hosted scan and get now include details.pinChanged on each confirmed patch's JSON event. The CLI compares local dependency records for the package and patch UUID. It reports true for a new or updated pin, false for an unchanged pin, and null when the records cannot establish the result. A dry run reports the planned change. This adds no network requests.

The scan integration suite covers adding a second patch to a shared npm lockfile, previewing that change, rerunning with both pins already in place, and repairing one pin's integrity without changing its UUID.


Generated by Claude Code

Compare local pin records before and after the hosted rewrite so JSON
consumers can tell which patch changed in a shared lockfile. Report an
unknown result when the available records cannot establish the change.

Assisted-by: Codex:GPT-6
Keep the two variants of FinalDiscovery so existing Rust callers can
still match on both. Give the CLI a separate way to read pins found on
servers named by a grant. Keep the public discovery field empty when
the grant adds a server.

Assisted-by: Codex:GPT-6
Reuse the existing check for whether the pin check's discovery matches
the written disk, which also skips the report after a vlt store heal.
Set pinChanged where the confirmed events are built, check that scan's
discovery is still current once per run, and skip collecting created
paths when no report will read them.

Assisted-by: Claude Code:claude-opus-5-5
@cursor

cursor Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes hosted rewrite discovery attribution and JSON event shape; behavior is additive but consumers and dry-run/JSON paths depend on the new comparison logic.

Overview
Hosted JSON envelopes now expose details.pinChanged on each confirmed hosted pin (applied or dry-run verified), so callers can tell whether this run actually added or updated a pin versus leaving it unchanged. Values are true / false when before/after lockfile discovery can attribute the pin, and null when attribution fails (e.g. unreadable lockfiles); if nothing was rewritten, all confirmed pins report false.

The CLI adds a pin_changes pass that snapshots discovery before rewrite (reusing scan’s prior discovery when safe, or widening origins for foreign grant hosts), then compares hosted refs after write—even on --dry-run when JSON is enabled—via discovery_after_writes. The core hosted engine now keeps grant_origin_discovery separate from final_discovery and exposes pin_discovery(), so post-rewrite comparison still works when grants come from non-configured patch servers.

CLI_CONTRACT and integration tests (including shared npm lockfiles: second pin, idempotent re-run, integrity repair) document and assert the new field.

Reviewed by Cursor Bugbot for commit 19870c4. Configure here.

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

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

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

Reviewed by Cursor Bugbot for commit 19870c4. Configure here.

The three JSON envelope tests that compare events exactly now expect
`details.pinChanged: true` on the pin they write.

A confirmed pin withheld from `refs` because an unpatched copy sits
beside it is in `Discovery::shadowed`; count it so its change is
reported instead of `null`. When a wet run's writes landed but the
gate's overlay cannot stand for the project, discover it again with
the same origins as the before snapshot. A dry run still reports
`null` in that case, as CLI_CONTRACT.md describes.

Assisted-by: Claude Code:claude-opus-5-5
@mikolalysenko

Mikola Lysenko (mikolalysenko) commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

[agent] PR shepherd: review brief for the approver

What it does
Each confirmed hosted pin in scan/get --mode hosted --json now carries details.pinChanged. The value is true for a new or updated pin, false for an unchanged one, and null when the CLI can't tell. It works by comparing the local dependency discovery before the rewrite with the discovery after it. The field is additive JSON, it adds no network requests, and human output is unchanged.

Risk: medium. The change is additive for JSON consumers. But it changes how the hosted engine hands back the pin-check discovery: a run whose grants name another server now keeps that discovery in a new grant_origin_discovery field, and final_discovery stays None for those runs as before. JSON runs also do one extra local discovery pass when scan's prior discovery can't be reused.

Look here

  • hosted.rs:1736: snapshot taken before the rewrite (JSON runs only)
  • hosted.rs:2704: picks the "after" discovery; does a fresh read on a wet run when the gate's overlay can't stand in for the project
  • [pin_changes.rs:67](https://github.com/SocketDev/socket-patch/blob/4aac79f50857e18387290b4b86bfe1a243386550/crates/socket-patch-cli/src/commands/scan/hosted/pin_changes.rs#L67): compare; an unreadable or unparseable lockfile, or a uuid known under another purl, gives null
  • engine.rs:2969: grant-origin discovery is now kept apart from final_discovery
  • hosted_render.rs:778: dry run, rerun with no change, re-pin, and integrity repair cases

Verified

Changes I made: none.

Open questions: none. Note that ci-ok can't go green until #2280 lands, so this PR queues behind it.


Generated by Claude Code

@mikolalysenko Mikola Lysenko (mikolalysenko) added the Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review label Nov 27, 2026
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.

3 participants