Skip to content

Add socket-patch report to tell Socket that a patch broke something - #2193

Merged
Mikola Lysenko (mikolalysenko) merged 4 commits into
mainfrom
feat/report-command
Nov 23, 2026
Merged

Mikola Lysenko (mikolalysenko) merged 4 commits into
mainfrom
feat/report-command

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Builds on #2178 (merged): it uses that PR's per-patch telemetry entries.

What this adds

There was no way to tell Socket that a patch broke a project. Rollbacks are counted, but nothing says why, and a patch that broke a build without being rolled back was never heard of.

socket-patch report lodash --reason tests --message "jest: TypeError in merge()"
socket-patch report 8be53d06-7bd4-40cc-ab8f-36dc6248985a      # a patch already rolled back
  • Which patches. A PURL or a package name selects the patches the project holds for that package (the target grammar rollback <target> uses). Where it holds patches for one package in several modes, the report names the one the build consumes: the vendored artifact, else the hosted pin, else the agent manifest's record. A UUID names any patch, so one that was already rolled back can still be reported. A name the project holds no patch for (patch_not_found), one that reaches several packages (ambiguous_target), or more than 50 patches (too_many_patches) is an error and sends nothing.
  • What is sent. One patch_reported event on the route the run's telemetry takes: each patch's UUID, ecosystem and patch mode, the reason (build, tests, runtime or other, the default), the message, and the CLI's version and platform. No package name, path or file content. The message goes out on one line, with URL credentials and the home directory redacted, cut to 1000 characters.
  • Delivery. The run waits for the answer. A report the endpoint did not take is a failed run (report_not_sent, exit 1, with the cause). A saved login the org endpoint refuses (401 / 403) does not cost the report: it is sent again without the token on the public route. --dry-run shows the whole report as it would be sent, message redaction included, and sends nothing. The project is never changed.
  • After a rollback. A rollback that named its targets, took off one to three patches and runs at a terminal with a person at it ends with one line giving the command to report them: Did this patch break something? Tell Socket: socket-patch report <uuid> --message "what happened". Never on a dry run, under --json or --silent, in a pipe, in an AI coding agent's terminal, or after a bare rollback.

This is deliberately the small version: one command and one event on the existing route. No new endpoint, no wizard, no local record of reports, no rollback --report flag.

Decisions a reviewer should check

  1. A report ignores the telemetry opt-outs. --no-telemetry, SOCKET_TELEMETRY_DISABLED and DO_NOT_TRACK do not stop a report, because the user ran the command to send it. --offline / SOCKET_OFFLINE does (offline_unsupported). If a report should honour the opt-outs instead, it is one condition in send_patch_report.
  2. The rollback hint is new human output. It prints only for a targeted rollback at an attended terminal, so no pipe, log, agent or --json consumer sees it.
  3. No -m short for --message. -m is reserved (it was --manifest-path), and a test pins that.
  4. Events need Socket's backend to know patch_reported. Until it does, a report is stored but not categorised with the other patch events. The backend change is in review separately; this should not be released before it.

Testing

  • crates/socket-patch-core telemetry:: unit tests: the event's body, the opt-outs, offline, an endpoint that refuses, one that is unreachable, the message's redaction and cap.
  • tests/report_e2e.rs: the built binary against a mock endpoint: a UUID from an empty directory, a package name resolved against a manifest, --dry-run, --silent, --json, a name that matches nothing, a refusing endpoint, --offline, a refused login, an unreadable manifest, and the 50-patch cap.
  • tests/cli_parse_report.rs: the argument surface.
  • tests/rollback/rollback_render.rs: the hint on a pseudo-terminal, and its absence on a dry run, in a pipe and after a bare rollback.
  • Local runs: the CLI's unit tests (1049), the rollback suite (141), cli_global_args, cli_parse_main, help_text_hygiene, command_module_layering, json_error_shape, all passing. The full suite and the other platforms are left to CI.

Review

/code-review high ran on this diff and returned ten findings. Eight are fixed in the last commit (its message lists them). Two are not code changes:

  • A report made from the rollback hint carries mode: "unknown" and no ecosystem. By then the project no longer holds the patch, and passing both through the hinted command would need two more flags. The patch's UUID is the signal; the contract now says so.
  • The backend has to know patch_reported before a release. That cannot be checked from this repo. It is decision 4 above.

🤖 Generated with Claude Code


Generated by Claude Code

There was no way to say that a patch broke a project: rollbacks were
counted, but nothing said why, and a patch that broke a build without
being rolled back was never heard of.

`socket-patch report <patch>... [--reason build|tests|runtime|other]
[--message <text>]` sends one `patch_reported` event on the route the
run's telemetry takes. It names each patch by UUID with its ecosystem
and patch mode, the reason, and the message the user typed (on one
line, URL credentials and the home directory redacted, cut to 1000
characters). No package name, path or file content is sent.

A PURL or a package name selects the patches the project holds for
that package; a UUID names any patch, so one that was already rolled
back can still be reported. A name the project holds no patch for, or
one that reaches several packages, is an error and sends nothing.

A report is something the user asked to send, so the telemetry
opt-outs do not stop it; `--offline` does. Unlike a telemetry event the
run waits for the answer, and a report the endpoint did not take is a
failed run (`report_not_sent`, exit 1). `--dry-run` shows what would be
sent. The project is never changed.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A patch is usually rolled back because it broke something, and once it
is off the project no longer holds it: only its UUID still names it.

A `rollback` that named its targets, took off one to three patches and
runs at a terminal with a person at it now ends with one line giving
the command that reports them:

  Did this patch break something? Tell Socket: socket-patch report
  <uuid> --message "what happened"

Never on a dry run, under `--json` or `--silent`, in a pipe, in an AI
coding agent's terminal, or after a bare `rollback`.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Findings from the review of the `report` command, fixed:

- A report of more than 50 patches said all were reported while the
  event carried 50. One report now names at most 50 and never leaves one
  out: more is `too_many_patches`, and a long message beside a full
  list is cut further instead of the list.
- A patch that is both in the manifest and vendored was reported as an
  agent patch, a manifest record the vendored artifact had replaced was
  reported in its place, and a vendor ledger entry with no embedded
  record could not be named at all. The report now reads the vendor
  ledger's own entries and names the patch the build consumes: the
  vendored artifact, else the hosted pin, else the manifest's record.
- The hint after a rollback printed the recorded patch id inside a
  command to run. A manifest's `uuid` is a string a project file
  supplies, so only an id that is a UUID is printed; a run that took
  off a patch with any other id prints no hint.
- A saved login the org endpoint refuses (401 / 403) failed the report.
  It is sent again without the token, on the public route.
- A report that got no answer now says why (the cause chain of the
  request error), not only that the request failed.
- A manifest or vendor ledger that cannot be read is named as the
  problem when a PURL or a name then matches nothing, instead of
  `patch_not_found`. A report by UUID still goes out.
- A human run prints the whole report: each patch with its mode, and
  the message as it was sent, so `--dry-run` shows the redaction.
- Comments no longer describe a `rollback --report` flag.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review November 20, 2026 19:57
@mikolalysenko Mikola Lysenko (mikolalysenko) added the Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review label Nov 20, 2026
@cursor

cursor Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Introduces a user-initiated network path and deliberately ignores telemetry opt-outs, though it only sends patch UUIDs and redacted metadata and does not modify project patch state.

Overview
Adds socket-patch report, a read-only command that sends a single patch_reported event to Socket when patches break build, tests, runtime, or something else. Users target patches by package name, PURL (resolved from local manifest, vendor ledger, and hosted pins), or UUID (including after rollback); the command picks the consumed patch when multiple modes exist and caps reports at 50 patches with sanitized, length-limited messages.

Reporting bypasses telemetry opt-outs (only --offline blocks it), awaits delivery with org-token fallback to the public route on 401/403, and supports --dry-run, --json, and --reason / --message. Targeted rollback at an attended terminal now suggests a report command with UUIDs for up to three rolled-back patches.

Docs and CLI contract are updated; parse, e2e, telemetry unit, and rollback render tests cover the new surface.

Reviewed by Cursor Bugbot for commit e1c2bf2. 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 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, 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 e1c2bf2. Configure here.

A name or purl was resolved against the stores that could still be read,
so with an unreadable vendor ledger a report went out under the
manifest's or a hosted pin's UUID and mode, not the vendored copy the
build consumes. Refuse any non-UUID target with the store's error and
the UUID hint instead; a UUID report still goes out.

Assisted-by: Claude Code:claude-opus-5-5
Merged via the queue into main with commit d852819 Nov 23, 2026
50 checks passed
@mikolalysenko
Mikola Lysenko (mikolalysenko) deleted the feat/report-command branch November 23, 2026 18:36
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