Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion crates/socket-patch-cli/CLI_CONTRACT.md
Original file line number Diff line number Diff line change
Expand Up @@ -2349,6 +2349,7 @@ outcome for a selected record, rather than inferring a write from exit 0.
| `patch_fetch_failed` | get | The patch search or view request failed, or was answered by something other than the patch service (a `404` that is not its own, an unknown organization; see "No patches" needs an answer). |
| `patch_no_applicable_files` | get | The fetched patch has no file it could record; nothing written. |
| `blob_write_failed` | get | A patch blob could not be decoded or written; the patch's `failed` event carries the same `errorCode` (search path: a per-patch `failed` event only). |
| `replaced_patch_not_restored` | get, scan | Agent mode: the recorded patch could not be rolled back before another patch replaced its record (#2096). The recorded patch is kept and the new one is not applied; the patch's `failed` event carries the same `errorCode` (search path and `scan`: a per-patch `failed` event only). |
| `selection_required` | get | Several patches match and `--json` cannot prompt; `status` is `selectionRequired` (exit 1), the top-level `purl` names the package and `options[]` lists the candidates. |
| `offline_unsupported` | scan, get | `--offline` / `SOCKET_OFFLINE`: the command needs the patch API. |
| `patch_details_failed` | scan | Every patch-detail query failed. |
Expand Down Expand Up @@ -2467,7 +2468,7 @@ One command is **intentionally not** plain-envelope and will stay that way (not

The keys describe the selection, on every `scan --json` run that fetches the by-package records (every mode, a dry run and a report-only run included). Whether a selected patch landed is its event (`applied`, `verified`, `skipped`, `failed`). `unfixedIds` counts a patch the account cannot download (`tier: "paid"`) like any other. When a package's release variants selected different patches, `fixedIds` holds only the ids every one of them names. The batch records do not pair an advisory id with its CVE, so an alias the selected patch does not list is reported unfixed, never the reverse.

**Events per mode.** Agent mode (`get`, `scan --mode agent` / `--sync`): a fetched patch is `downloaded` (new manifest record) or `updated` (+`oldUuid`: it replaced another uuid), one already recorded at the same uuid is `skipped` / `already_in_manifest` (it is still re-applied), a patch that could not be fetched or recorded is `failed` (`download_failed`, `patch_no_applicable_files`, `blob_write_failed`); then the nested apply adds `applied` only for each recorded patch it actually patched, `skipped` with `errorCode` / `reason` for each recorded patch it left untouched (including `already_patched`, `vendored`, `package_not_installed`, and `user_patch_conflict`) plus a `skipped` / `user_patch_conflict` event for any other manifest package it left untouched for a user patch, and `failed` (apply's `apply_failed` / `package_not_installed` with its `error`, #424) for each it failed — a failing manifest patch the run did not select (the nested apply covers the whole `--ecosystems`-scoped manifest) gets its own `failed` event, and a failure no single patch explains (an unreadable manifest, the yarn PnP refusal, unavailable patch sources) is a purl-less `failed` event, so a failed apply is always `partialFailure` (exit 1). The apply's mismatch overwrites (#1004) are `content_mismatch_overwritten` warnings; a record whose purl the vendor ledger wires at another uuid adds a `vendored_uuid_drift` warning. A run that leaves patches recorded in a manifest git would not commit (inside a git work tree, `git check-ignore` matches the manifest's project-relative path, e.g. a `manifest.json`, `*.json` or `.socket/` rule; a tracked manifest never warns) adds a `manifest_gitignored` warning naming the rule: a fresh checkout's `apply` would find no manifest and apply nothing (#1638). It stays a warning (exit unchanged) because a pipeline that scans and applies in one job never commits `.socket/`. Vendor-owned and lockfile-only selections are `skipped` / `vendored` and `skipped` / `package_not_installed` before any download. Hosted and vendored events are described under "Scan modes" above; every one carries `details.mode`. `get`'s narrowing adds `skipped` events (`package_not_installed`, `yarn_pnp_unsupported`, `pnpm_pnp_unsupported`) and `paidRequired` runs one `skipped` / `paid_required` event per patch found.
**Events per mode.** Agent mode (`get`, `scan --mode agent` / `--sync`): a fetched patch is `downloaded` (new manifest record) or `updated` (+`oldUuid`: it replaced another uuid), one already recorded at the same uuid is `skipped` / `already_in_manifest` (it is still re-applied), a patch that could not be fetched or recorded is `failed` (`download_failed`, `patch_no_applicable_files`, `blob_write_failed`, `replaced_patch_not_restored`); then the nested apply adds `applied` only for each recorded patch it actually patched, `skipped` with `errorCode` / `reason` for each recorded patch it left untouched (including `already_patched`, `vendored`, `package_not_installed`, and `user_patch_conflict`) plus a `skipped` / `user_patch_conflict` event for any other manifest package it left untouched for a user patch, and `failed` (apply's `apply_failed` / `package_not_installed` with its `error`, #424) for each it failed — a failing manifest patch the run did not select (the nested apply covers the whole `--ecosystems`-scoped manifest) gets its own `failed` event, and a failure no single patch explains (an unreadable manifest, the yarn PnP refusal, unavailable patch sources) is a purl-less `failed` event, so a failed apply is always `partialFailure` (exit 1). The apply's mismatch overwrites (#1004) are `content_mismatch_overwritten` warnings; a record whose purl the vendor ledger wires at another uuid adds a `vendored_uuid_drift` warning. A run that leaves patches recorded in a manifest git would not commit (inside a git work tree, `git check-ignore` matches the manifest's project-relative path, e.g. a `manifest.json`, `*.json` or `.socket/` rule; a tracked manifest never warns) adds a `manifest_gitignored` warning naming the rule: a fresh checkout's `apply` would find no manifest and apply nothing (#1638). It stays a warning (exit unchanged) because a pipeline that scans and applies in one job never commits `.socket/`. Before a record is replaced (`updated`) by a patch that does not list every file the recorded patch changed, the recorded patch is rolled back in every installed copy, as `rollback` would, so that replacement is "roll back the old patch, record the new one, apply it" (#2096): a file the new patch does not list would otherwise stay patched with no record listing it. A new patch that lists every file of the recorded one needs no rollback; the apply moves each file to it. This runs with `--save-only` too, which then leaves the package original and recorded, like a `--save-only` of a new patch. A human run prints a `[restore]` line for the package. Every copy is verified before any is written, and a copy that holds none of the recorded patch's bytes has nothing to roll back: the patch was never applied to it, it is another release variant's distribution, or its patched files were edited since. Such a copy is left as it is with a `replaced_patch_not_on_copy` warning naming it. When a copy the recorded patch is on cannot be rolled back (one of its files holds bytes that are neither side of the patch, or an original blob is missing and cannot be downloaded), the replacement is refused: the patch is `failed` / `replaced_patch_not_restored`, the recorded patch stays recorded and applied, the new patch is not applied, and the run exits 1. Vendor-owned and lockfile-only selections are `skipped` / `vendored` and `skipped` / `package_not_installed` before any download. Hosted and vendored events are described under "Scan modes" above; every one carries `details.mode`. `get`'s narrowing adds `skipped` events (`package_not_installed`, `yarn_pnp_unsupported`, `pnpm_pnp_unsupported`) and `paidRequired` runs one `skipped` / `paid_required` event per patch found.

**Patch metadata.** `downloaded` / `updated` events (agent and vendored) carry the patch metadata in `details`, the same keys for every command:

Expand Down
Loading
Loading