Skip to content

Commit 188cd5c

Browse files
committed
audit-core: C79 (#1257), Part 7 route passage after #1041
Assisted-by: Claude Code:claude-opus-5-5
1 parent ebcba82 commit 188cd5c

4 files changed

Lines changed: 62 additions & 11 deletions

File tree

‎doc/02-cli.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
## Part 2: CLI command layer and user experience
44

5-
_Last checked against main @ f3c6313 on 2026-10-09 by audit-core. Owner: audit-core._ Re-checked on `f3c6313` (03:40Z run): `scan`'s human-arm `fetched == 0` exit (C70, unchanged), the removed v4 spellings after #1031 (docs and wrappers clean) and the hand-written `--json` status strings of `get`. Re-checked on `830749f` (21:40Z run): the command-module graph after #1043 (14 allowlisted edges in `tests/command_module_layering.rs`), the interactive-prompt gates (`confirm_waits`, `select_one`; one production `select_one` caller) and the hidden `self-update`/`hosted-bundle` subcommands. Re-checked on `823810a` (15:40Z run): `validate_paths` (C76, unchanged) and the socket.yml policy callers (only `scan`); C44, C45 and C58 were closed by the 2026-10-08 backlog review, and their passages still describe main. Re-checked on `b96a785` (09:40Z run): the path-flag validation #1029 added (`validate_paths`, C76), the `--manifest-path` ledger roots (C43, unchanged) and `remove`'s identifier matching after #1035. Re-checked on `05ecc6e` (21:40Z run): the 2.9 mode-folding premises (`scan`/`get` defaults, socket.yml `mode` refusal, takeover scope), the no-state exit codes of every command, and lock contention under `--json` (consistent `lock_held`). Earlier: `431b818` by the October 7 reconciliation (command cycles, takeover scope, envelope shapes and client sites re-checked; function sizes from `1c6c509`); `c5be5d1` by audit-core. Re-checked on `c5be5d1` (15:50Z run): the exit codes of a corrupt and a missing manifest across commands, and the command-model premises of 2.9 (unchanged). Re-checked on `9c43dfc` (09:56Z run): manifest-presence probes per command and `remove`'s per-store identifier matching. Re-checked on `9c43dfc`: the paid-tier `--json` output of `get` and `scan` against the contract (2.8), the manifest-load error codes of every command and the exit-2 usage-error output under `--json` (2.8), the legacy mode spellings and embedded `--vex` (2.7), the god-function sizes for `vendor_records_reusing`, `run_redirect_selected` and `rollback::run`, the get ↔ scan cycle, `ecosystem_dispatch`'s size and the takeover bypass; the rest is as of `045d7ec` or earlier.
5+
_Last checked against main @ a80b89e on 2026-10-09 by audit-core. Owner: audit-core._ Re-checked on `a80b89e` (09:40Z run): `--json` and `--dry-run` across every command on an empty and an agent-mode project (dry runs write nothing; no-state exits as in C74), the envelope's `Summary`/`PatchEvent` fields against the contract (C79), and the four GC report shapes. Re-checked on `f3c6313` (03:40Z run): `scan`'s human-arm `fetched == 0` exit (C70, unchanged), the removed v4 spellings after #1031 (docs and wrappers clean) and the hand-written `--json` status strings of `get`. Re-checked on `830749f` (21:40Z run): the command-module graph after #1043 (14 allowlisted edges in `tests/command_module_layering.rs`), the interactive-prompt gates (`confirm_waits`, `select_one`; one production `select_one` caller) and the hidden `self-update`/`hosted-bundle` subcommands. Re-checked on `823810a` (15:40Z run): `validate_paths` (C76, unchanged) and the socket.yml policy callers (only `scan`); C44, C45 and C58 were closed by the 2026-10-08 backlog review, and their passages still describe main. Re-checked on `b96a785` (09:40Z run): the path-flag validation #1029 added (`validate_paths`, C76), the `--manifest-path` ledger roots (C43, unchanged) and `remove`'s identifier matching after #1035. Re-checked on `05ecc6e` (21:40Z run): the 2.9 mode-folding premises (`scan`/`get` defaults, socket.yml `mode` refusal, takeover scope), the no-state exit codes of every command, and lock contention under `--json` (consistent `lock_held`). Earlier: `431b818` by the October 7 reconciliation (command cycles, takeover scope, envelope shapes and client sites re-checked; function sizes from `1c6c509`); `c5be5d1` by audit-core. Re-checked on `c5be5d1` (15:50Z run): the exit codes of a corrupt and a missing manifest across commands, and the command-model premises of 2.9 (unchanged). Re-checked on `9c43dfc` (09:56Z run): manifest-presence probes per command and `remove`'s per-store identifier matching. Re-checked on `9c43dfc`: the paid-tier `--json` output of `get` and `scan` against the contract (2.8), the manifest-load error codes of every command and the exit-2 usage-error output under `--json` (2.8), the legacy mode spellings and embedded `--vex` (2.7), the god-function sizes for `vendor_records_reusing`, `run_redirect_selected` and `rollback::run`, the get ↔ scan cycle, `ecosystem_dispatch`'s size and the takeover bypass; the rest is as of `045d7ec` or earlier.
66

77
> Scope: `crates/socket-patch-cli/src/` — `args.rs`, `lib.rs`/`main.rs`, `ecosystem_dispatch.rs`, `json_envelope.rs`, `ui/*`, `update_notifier.rs`, and every `commands/*` module.
88
@@ -199,6 +199,8 @@ That is **7 verbs instead of 9 visible + 2 hidden + 2 aliases + 3 hidden flag sp
199199

200200
- {{C54}} The contract's paid-tier codes match no command: `get` emits `status: "paid_required"` (snake_case, no events or `errorCode`) and `scan` emits nothing paid-specific, while `CLI_CONTRACT.md` documents `status=paidRequired` for both. The fix is documentation plus one shared `get` emitter.
201201

202+
- {{C79}} Artifact GC is reported in four JSON shapes: `repair` `details{count, checked}`, `remove` `details{blobsRemoved, rolledBack, archivesRemoved}`, and `rollback`/`scan --prune` `gc{removedBlobs, …, bytesFreed}`. The contract's `summary.bytesDownloaded`, `summary.bytesFreed` and `events[].bytes` are emitted by no command, so its `repair --json | jq .summary.bytesFreed` recipe prints `null` and `removed: 1` for any number of blobs. The `PatchAction` "Emitted by" column lists scan, get and rollback, which print legacy shapes with no events.
203+
202204
- {{C74}} "Nothing to undo" has no single verdict: on a project with no patch state, `rollback` (legacy `Manifest not found`) and `repair` (`manifest_not_found`) exit 1 while `apply`, `vendor`, `vendor --revert` and `list` exit 0. v5 hosted and vendored modes leave exactly that state after a full `rollback`, so a second `rollback` exits 1; `vlt_pinned_matrix_hosted_idempotence` pins it (run twice on `05ecc6e`). Folded into the command-model decision as Q2.
203205

204206
- {{C58}} `vex` is the one command whose exit `2` is not a usage error: every runtime failure but "nothing attested" exits `2` (`manifest_unreadable`, `manifest_not_found`, `write_failed`, …), while the same corrupt or missing manifest exits `1` on `apply --check`, `vendor --check`, `remove`, `repair` and embedded `--vex` (run twice on `c5be5d1`).

‎doc/07-infra-agent.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
## Part 7: Core infrastructure and agent (in-place) mode
44

5-
_Last checked against main @ f3c6313 on 2026-10-09 by audit-core. Owner: audit-core._ Re-checked on `f3c6313` (03:40Z run): public-registry fan-out against `utils::concurrent` (C78), and dead `pub fn`s in `utils/`, `api/` and `update/`. Re-checked on `830749f` (21:40Z run): `apply.lock` after #1030 (interrupt cleanup), the HTTP client builders and timeouts, the FIFO-safe readers of every `.socket` store, and lock acquisition per command (all through `lock_cli`). Re-checked on `823810a` (15:40Z run): production file writes outside `utils::fs` (only the VEX document, C77, plus self-update, `apply.lock` and blob-fetch staging), PATH resolution of spawned tools (all through `resolve_tool`), the GC retention split (C50, unchanged), and the C60/C63 passages after #887's close and #1045. Re-checked on `b96a785` (09:40Z run): env truthiness and home-directory resolvers after #1038, and the test-telemetry boundary after #1046. Re-checked on `b762f41` (03:40Z run): 7.3 atomic writes and the 7.7 containment and credentials rows after #1042 and #1070, hash-case verify sites, and the TLS trust roots of every HTTP client (C75). Earlier: `431b818` by the October 7 reconciliation (7.3 spawn deadlines, the 7.4 safety model and the new 7.7 security boundaries); `c5be5d1` by audit-core. Re-checked on `c5be5d1` (15:50Z run): 7.2 retry table and registry timeouts after #889 and #876. Re-checked on `9c43dfc` (09:56Z run): the 7.4 agent-mode footprint, the sidecar list (Maven rewriter from #646) and which ecosystems need agent mode. Re-checked on `9c43dfc`: the self-update footprint and its overlap with `install.sh` (7.5), the credentials block of `client.rs`, agent-mode jar member verification, the apply/rollback store-copy fold and the artifact-retention (GC) policies. Re-checked on `0d302dc`: the `api/*` size row, the `client.rs` breakdown, the retry table, the registry-client timeout, process spawning and hash case. The timeout, blob/diff body, zip-read, process-spawning, API-pacing, URL-builder, retry, batching, hashing, UUID, env/home-dir, atomic-write, purl, dead-code, telemetry, apply/rollback-engine, diff-download, `apply.lock`, Maven-sidecar, group-commit-reader, socket.yml and spawn-deadline passages were re-checked on `045d7ec`; the rest is as of `2463257`. 2026-10-07 14:00Z: 7.2, 7.4, 7.5 and 7.6 record the maintainer's decisions on #648, #792, #808, #983 and #1000 (no code re-check).
5+
_Last checked against main @ a80b89e on 2026-10-09 by audit-core. Owner: audit-core._ Re-checked on `a80b89e` (09:40Z run): the URL-builder passage after #1041 (one `ApiRoute` per run, client construction per command), HTTP body reads (only the self-update, vendor, Maven and vlt downloads are capped; uncapped blob/JSON bodies are the maintainer's #571 call), production process spawns (all bounded) and the failpoint/switch-off hooks (debug or `failpoints`-feature builds only). Re-checked on `f3c6313` (03:40Z run): public-registry fan-out against `utils::concurrent` (C78), and dead `pub fn`s in `utils/`, `api/` and `update/`. Re-checked on `830749f` (21:40Z run): `apply.lock` after #1030 (interrupt cleanup), the HTTP client builders and timeouts, the FIFO-safe readers of every `.socket` store, and lock acquisition per command (all through `lock_cli`). Re-checked on `823810a` (15:40Z run): production file writes outside `utils::fs` (only the VEX document, C77, plus self-update, `apply.lock` and blob-fetch staging), PATH resolution of spawned tools (all through `resolve_tool`), the GC retention split (C50, unchanged), and the C60/C63 passages after #887's close and #1045. Re-checked on `b96a785` (09:40Z run): env truthiness and home-directory resolvers after #1038, and the test-telemetry boundary after #1046. Re-checked on `b762f41` (03:40Z run): 7.3 atomic writes and the 7.7 containment and credentials rows after #1042 and #1070, hash-case verify sites, and the TLS trust roots of every HTTP client (C75). Earlier: `431b818` by the October 7 reconciliation (7.3 spawn deadlines, the 7.4 safety model and the new 7.7 security boundaries); `c5be5d1` by audit-core. Re-checked on `c5be5d1` (15:50Z run): 7.2 retry table and registry timeouts after #889 and #876. Re-checked on `9c43dfc` (09:56Z run): the 7.4 agent-mode footprint, the sidecar list (Maven rewriter from #646) and which ecosystems need agent mode. Re-checked on `9c43dfc`: the self-update footprint and its overlap with `install.sh` (7.5), the credentials block of `client.rs`, agent-mode jar member verification, the apply/rollback store-copy fold and the artifact-retention (GC) policies. Re-checked on `0d302dc`: the `api/*` size row, the `client.rs` breakdown, the retry table, the registry-client timeout, process spawning and hash case. The timeout, blob/diff body, zip-read, process-spawning, API-pacing, URL-builder, retry, batching, hashing, UUID, env/home-dir, atomic-write, purl, dead-code, telemetry, apply/rollback-engine, diff-download, `apply.lock`, Maven-sidecar, group-commit-reader, socket.yml and spawn-deadline passages were re-checked on `045d7ec`; the rest is as of `2463257`. 2026-10-07 14:00Z: 7.2, 7.4, 7.5 and 7.6 record the maintainer's decisions on #648, #792, #808, #983 and #1000 (no code re-check).
66

77
> Scope: `api/*`, `manifest/*`, `ledgers.rs`, `constants.rs`, `patch/` (excluding `redirect/`), `policy/*`, `rollout*`, `update/*`, the CLI `update_notifier.rs`/`update.rs`, `telemetry.rs`, and the generic `utils/*` and `hash/*`.
88
@@ -39,7 +39,7 @@ That is about **19.6K production lines.** Comments are a large share of them: 25
3939

4040
The vendor policy also has three separate hand-written retry loops, plus a first-attempt/resume split that exists only to keep the request sequence identical under prefetch. Two near-identical downloaders (`download_vendor_archive_once` and `download_artifact_capped_once`) differ only in return type and message strings.
4141

42-
**Three URL builders with two different policies.** `patches_path` sends an authenticated client without an org slug to `/v0/orgs/default/...`, but `binary_url` and `vendor_package_url` send the same client to the public proxy. Telemetry has a fourth copy of the decision. So when org auto-resolve fails, JSON calls go to the "default" org while blob downloads silently go to the proxy. Re-verified by execution on `045d7ec`: view and batch go to `/v0/orgs/default/patches/…` with the bearer, while blob, diff, vendor references and telemetry go anonymously to `patches-api.socket.dev/patch/…`. Decided in #648: the org is resolved once, when the client is built, into one route (`Org{slug}` or `Proxy`) that all builders and telemetry read; a failed auto-resolve sends the whole run to the public proxy anonymously with one warning, never `/v0/orgs/default`; embedded `--vex` reuses the run's client instead of resolving again. Landed in #1041 (`ApiRoute` in `api/client.rs`). {{C07}}
42+
**One API route per run (#1041).** `get_api_client_with_overrides` resolves the org once, when the run's client is built, into one `ApiRoute` (`Org{slug}` or `Proxy`). `patches_path`, the batch 404 message, `binary_url`, `vendor_package_url` and telemetry (`TelemetryAuth::for_client`) all read it. A token whose org auto-resolve fails sends the whole run to the public proxy anonymously (a proxy client never keeps the token), with one stderr warning and an `api_auth_fallback` entry in `warnings[]`, never `/v0/orgs/default`. Embedded `--vex` reuses the host's client. On `a80b89e` every command builds at most one client per run (`repair`, vendored repair and `rollback` build theirs lazily or pass it down). Commands with no client (`list`, standalone `vex` before a fetch) route telemetry through `GlobalArgs::telemetry_auth`, which still depends on `apply_env_toggles` mirroring `--api-url`/`--proxy-url` (C10). The mid-run 401/403 proxy swap is separate (C09). {{C07}}
4343

4444
**Timeouts on the main paths (#581).**
4545
- `ApiClient::new` and `plain_client()` build both reqwest clients through one policy, `api::retry::ApiTimeouts`: `API_CONNECT_TIMEOUT` (10 s) and `API_READ_TIMEOUT` (60 s of silence, reset per chunk), with no total deadline. Tests override it with `ApiClient::with_api_timeouts`. {{C02}}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
[agent] 2026-10-09: architecture audit (CLI and core)
2+
3+
**main @ `a80b89e`.** Since my last run (`f3c6313`), main merged #1041, #1036, #1007, #1193, #1209, #1217, #1218, #1221, #1223, #1227, #1228 and #1230, plus CI-only changes. The one in my area is #1041. There are no new maintainer comments and no handovers addressed to `audit-core`.
4+
5+
**Reconciled:**
6+
- **C07, #1041:** the refactor routine had already recorded this as fixed. I rewrote the Part 7 URL-builder passage so that it describes main: one `ApiRoute` per run, read by every builder and by telemetry. I checked every `get_api_client_with_overrides` call site, and each command builds at most one client per run.
7+
- **C41:** `blob_hash_matches` is still in `blob_fetcher.rs`, waiting on #1049. The row is unchanged.
8+
- **In-PR rows:** #1026, #1034, #1049, #1126 and #1253 are still open.
9+
- **Re-checks:**
10+
- [#1066](https://github.com/SocketDev/socket-patch/issues/1066#issuecomment-6078581383) still holds. Its counters moved to `rollback.rs#L1581-L1589`, so I posted fresh permalinks.
11+
- #1123 still holds. `validate_paths` only gates the directory check on a non-default `--manifest-path` spelling (`args.rs#L435`). The code moved by one line, so I didn't comment.
12+
13+
**Backlog:** C31 is the only `to verify` row, and it is still blocked on #794, which is open.
14+
15+
**New finding: C79 → [#1257](https://github.com/SocketDev/socket-patch/issues/1257)** (bug, P3).
16+
- The contract's envelope documents `summary.bytesDownloaded`, `summary.bytesFreed` and `events[].bytes`. `json_envelope::Summary` and `PatchEvent` have none of these fields, so no command emits them.
17+
- Artifact GC is reported in four shapes:
18+
- `repair`: `details{count, checked}`, with bytes freed going only to telemetry;
19+
- `remove`: `details{blobsRemoved, rolledBack, archivesRemoved}`;
20+
- `rollback` and `scan --prune`: `gc{removedBlobs, …, bytesFreed}`.
21+
- The "Emitted by" column of the `PatchAction` table lists scan, get and rollback, which print legacy shapes with no events.
22+
- **Proof:** I ran a debug build twice on an agent-mode fixture with unreferenced blobs. Each time, the contract's `repair --json | jq '{removed: .summary.removed, bytesFreed: .summary.bytesFreed}'` printed `{removed: 1, bytesFreed: null}` after deleting 5 blobs.
23+
24+
**Searched without filing:**
25+
- **API client construction after #1041:** one client per run in every command.
26+
- **Telemetry routing without a client:** the `list`/`vex` route depends on `apply_env_toggles` mirroring `--api-url`, which is C10.
27+
- **HTTP body reads:** blob/diff and JSON bodies have no size cap. The maintainer declined a cap on #571 (trusted upstream), so I ruled it out.
28+
- **Production process spawns:** all go through `output_within` or `resolve_tool`, including self-update's `sanity_exec`.
29+
- **Non-atomic writes:** only the VEX document, which is C77.
30+
- **Failpoint and switch-off env hooks:** they compile only into debug builds or the dev-only `failpoints` feature, and resolver 2 keeps that feature out of `cargo build --release`.
31+
- **Date code:** `api/date.rs` and `vex/time.rs` are inverse halves of one algorithm, pinned by a round-trip test, so they are not duplicates.
32+
- **`utils/` layering:** `utils/` has about 32 production imports of `vendor`, `crawlers`, `formats` and `patch` (for example `utils::purl` → `vendor::is_safe_npm_name` and `utils::concurrent` → `crawlers::walk_pool`). I didn't file it, because pure moves of this kind were closed as not planned (#883).
33+
- **Flags in docs:** every flag mentioned in README, `docs/` and the wrappers exists, apart from cargo and npm flags.
34+
- **`--dry-run`:** I ran each of apply, rollback, remove, repair, vendor and `vendor --revert` on an applied and an unapplied agent-mode project. None wrote anything.
35+
- **`--json` on an empty project:** the exit codes match the known rows C74 and C58.
36+
37+
**False positives ruled out:** the blob/JSON size cap (maintainer decision on #571), and the failpoint hooks in release builds (feature-gated).
38+
39+
**Living document:**
40+
- Part 2: check line, plus a C79 bullet.
41+
- Part 7: check line, and the URL-builder passage rewritten for #1041.
42+
- Register: C79 added, and a few closed rows shortened to stay under 20K.
43+
- The §0 numbers were refreshed today at 03:52Z.
44+
45+
**Next backlog rows:** C31 (after #794); re-check the `in PR` rows as #1026, #1034, #1049, #1126 and #1253 merge; re-check #1062 and #1063; C69 perf rows.
46+
47+
---
48+
_Generated by [Claude Code](https://claude.ai/code)_

0 commit comments

Comments
 (0)