Skip to content

Commit 76879b2

Browse files
committed
audit-core: ledgers, manifest, first patch files; A76-A79; carried rows reconciled
Assisted-by: Claude Code:claude-opus-5-5
1 parent fa2001b commit 76879b2

8 files changed

Lines changed: 132 additions & 38 deletions

File tree

‎coverage/files.tsv‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -658,21 +658,21 @@ crates/socket-patch-core/src/hosted/render.rs 81 audit-core cbbbdb9 2026-11-02 -
658658
crates/socket-patch-core/src/hosted/sbt_reads.rs 242 audit-core cbbbdb9 2026-11-02 - hosted_repo_dirs is a vex consumed-copy helper: move to vex; Disk|Snapshot dispatch (A75)
659659
crates/socket-patch-core/src/hosted/takeover.rs 113 audit-core cbbbdb9 2026-11-02 - inline any_takeover_ecosystem (1-line wrapper); gradle file-suffix test x4 with engine is_gradle_*; clean otherwise
660660
crates/socket-patch-core/src/hosted/vlt.rs 219 audit-core cbbbdb9 2026-11-02 - WITHHELD_REASON alias of ARTIFACT_UNVERIFIABLE: drop; install_state_present/bun_lockb_present hand view dispatch (A75); plan clones deps into Vec<DepOverride>; no unit tests in file
661-
crates/socket-patch-core/src/ledgers.rs 732 audit-core - -
662-
crates/socket-patch-core/src/manifest/cleanup_blobs.rs 924 audit-core - -
663-
crates/socket-patch-core/src/manifest/mod.rs 4 audit-core - -
664-
crates/socket-patch-core/src/manifest/operations.rs 633 audit-core - -
665-
crates/socket-patch-core/src/manifest/records.rs 87 audit-core - -
666-
crates/socket-patch-core/src/manifest/schema.rs 697 audit-core - -
667-
crates/socket-patch-core/src/patch/apply.rs 4428 audit-core - -
668-
crates/socket-patch-core/src/patch/apply_lock.rs 1612 audit-core - -
669-
crates/socket-patch-core/src/patch/copy_tree.rs 707 audit-core - -
670-
crates/socket-patch-core/src/patch/file_hash.rs 214 audit-core - -
671-
crates/socket-patch-core/src/patch/jvm_jar.rs 1323 audit-core - -
672-
crates/socket-patch-core/src/patch/mod.rs 15 audit-core - -
673-
crates/socket-patch-core/src/patch/npm_bin.rs 739 audit-core - -
674-
crates/socket-patch-core/src/patch/package.rs 839 audit-core - -
675-
crates/socket-patch-core/src/patch/path_safety.rs 210 audit-core - -
661+
crates/socket-patch-core/src/ledgers.rs 732 audit-core cbbbdb9 2026-11-02 - drop test-only pub Ledgers::vendor_claimed; uuid_only_record private; inline primary/claims (1 caller each) and test wrapper record(); owned() re-runs claimant per vendored key after claims(); hosted pins are (String,String) in merge_ledger_records_for_updates but HostedPin in hosted_pins_matching
662+
crates/socket-patch-core/src/manifest/cleanup_blobs.rs 924 audit-core cbbbdb9 2026-11-02 - move format_cleanup_result_for/format_all_in_use/format_bytes (CLI-only callers) to cli ui; after_removal re-writes retain's non-empty beforeHash filter; CleanupResult blobs_* fields also count diff/package archives; test sweep_blobs re-implements sweep's closure; test_cleanup_keeps_after_hash_removes_orphan duplicated by L454 and the table test
663+
crates/socket-patch-core/src/manifest/mod.rs 4 audit-core cbbbdb9 2026-11-02 - clean
664+
crates/socket-patch-core/src/manifest/operations.rs 633 audit-core cbbbdb9 2026-11-02 - manifest_exists is a 1-line try_exists wrapper with a 9-line doc; test_write_manifest_failure_preserves_existing writes a different path, passes with a non-atomic writer (see entry); dup tests: write_and_read (L555), blob_extractors_cross (L449), parse_missing_fields, read_invalid_schema; mkfifo copy (A51); ~6 history comment lines
665+
crates/socket-patch-core/src/manifest/records.rs 87 audit-core cbbbdb9 2026-11-02 - build_patch_record's files param: every caller passes files_for_manifest(patch), stale 'caller owns' doc; fold into record_from_patch_response; vulnerabilities_for_manifest pub, 1 internal caller: inline; files_for_manifest tests live in cli get.rs L3728, move here
666+
crates/socket-patch-core/src/manifest/schema.rs 697 audit-core cbbbdb9 2026-11-02 - PatchManifest::new = Default; PatchRecord literal x4 in tests (use a fixture); test_empty_manifest_roundtrip asserts len 0 only; camel_case tests (L181,L194) covered by snake_case rejection + roundtrip; ~25 banner/narration comment lines
667+
crates/socket-patch-core/src/patch/apply.rs 4428 audit-core cbbbdb9 2026-11-02 - inline chown_blocking; select_installed_variants = _any([p]) twice; drop one-variant AppliedVia+as_tag (+CLI mirror); is_socket_content any-length hex vs is_valid_blob_hash; verify_file_patch builds VerifyResult x7; npm source_hash computed twice; 336-line apply_package_patch_at; pycache cleanup+DirWriteGuard out; fix hash_mismatch_blocks test (fails on bad blob hash); ~70 comment lines; A76
668+
crates/socket-patch-core/src/patch/apply_lock.rs 1612 audit-core cbbbdb9 2026-11-02 - delete-pending explained 3x, identity check 4x (~60 comment lines); SOCKET_DIR_NAME dup of constants; EINVAL=22 -> libc; .socket gate x2 (L263,L351); eprintln! in core (L203,L600); LockError::Io says 'lock file' for socket dir/journal; group-commit recovery belongs in group_commit; tautological contended_sentinel test; 3 subsumed tests
669+
crates/socket-patch-core/src/patch/copy_tree.rs 707 audit-core cbbbdb9 2026-11-02 - fresh_copy skip_file_name is None at every prod caller: drop param, skipped_dir_depth (L53-81), cfg(test) oracle copy_tree_blocking_reference and 4-5 skip tests; stale registry_fetch docs about 'the skip a vendor stage asks for'; inline copy_tree_blocking/make_owner_writable; test Rng (A29); ~20 comment lines
670+
crates/socket-patch-core/src/patch/file_hash.rs 214 audit-core cbbbdb9 2026-11-02 - merge into hash::git_sha256; sync twin has 1 caller (vex/verify) and no test; test_compute_file_git_sha256_rejects_directory compares error text to a hash (can't fail); assert ErrorKind::InvalidInput; ~12 doc lines repeat open_regular_file
671+
crates/socket-patch-core/src/patch/jvm_jar.rs 1323 audit-core cbbbdb9 2026-11-02 - restore loop L536 `let _ = write_jar` records 'rolled back' even if restore fails; dead derived_copies, DerivedVerdict::clean; 6 pub fns file-local; sha256_hex/sha1_hex wrappers (A06); String errors+&str codes; .ok() at L656 hides network errors as 'no upstream matches'; daemon SidecarRecord x2; 2 expect in prod; 12 single-caller fns
672+
crates/socket-patch-core/src/patch/mod.rs 15 audit-core cbbbdb9 2026-11-02 - clean
673+
crates/socket-patch-core/src/patch/npm_bin.rs 739 audit-core cbbbdb9 2026-11-02 - fix_bin/unfix_bin/is_linked_bin/has_lf_shebang/fixed_for_write pub(crate) but file-local; form_for_write doc ends mid-sentence; bare #1756/#1791/#1804 refs; clean_path = relpath::fold_str (A19); 'Hash verification failed before patch' string x2 with apply.rs L513; sentence .contains test L476; no test of form_for_write matrix
674+
crates/socket-patch-core/src/patch/package.rs 839 audit-core cbbbdb9 2026-11-02 - tar reader misnamed/misplaced (A77); bool strict+strip_package_prefix drive 3 forwarders -> Layout enum; FIFO-safe open L96-111 copies utils::fs::open_regular_file_sync; canonical_member_key serves the zip decoder; 9 unit tests duplicate tests/package_e2e.rs; bomb test accepts any Err; ambiguous-root drop untested
675+
crates/socket-patch-core/src/patch/path_safety.rs 210 audit-core cbbbdb9 2026-11-02 - is_safe_name_version 1-line && wrapper; uuid check (A15); purl_builders test belongs to utils::purl; ~6 history comment lines
676676
crates/socket-patch-core/src/patch/redirect/bun_binary.rs 322 audit-core - -
677677
crates/socket-patch-core/src/patch/redirect/cargo_lock_equivalence_tests.rs 222 audit-core - -
678678
crates/socket-patch-core/src/patch/redirect/composer_equivalence_tests.rs 284 audit-core - -

‎doc/03-duplication.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,4 @@ _Last checked against main @ cbbbdb9 on 2026-11-02 by audit-core._
9090
- **Gradle wrapper version:** `gradle-wrapper.properties` is read by 3 parsers; the hosted and vendored "6.8 or newer" gates disagree on `distributionUrl = …` and a BOM, and only one honours a later duplicate key (executed). {{A72}}
9191
- **Gradle init-script list:** `GradleHome::init_scripts_for` (pure, its `distribution_url` narrowing test-only) vs `gradle_cache::init_scripts_for_build` + `dist_init_dirs`. {{A35}}
9292
- **Git blob hash loop:** async and blocking readers in `hash/git_sha256.rs` are byte-identical twins; `vendor/common` open-codes `zip_member_git_sha256`. Local notes.
93+
- **File mode/owner across an atomic write:** `apply::restore_file_permissions` (after rename, warns) and `utils::fs::keep_owner` (before rename, silent chgrp fallback) {{A78}}. **Creates-file sentinel:** the empty-`beforeHash` test is hand-written at ~18 production sites {{A79}}. Apply/rollback copies (blob read gate ×3, daemon-lock record ×4) handed to C24.

‎doc/04-structure.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,4 @@ _Last checked against main @ cbbbdb9 on 2026-11-02 by audit-core._
9595
- **Rewriter context through the file map:** 8 synthetic `<socket-patch:…>` keys in `files: BTreeMap<String, String>` carry JSON or tab-separated side data (go workspace, NuGet locks and sources, uv ancestor config, sbt resolution, gemspecs) that the rewriters parse back with `.ok()`. Target: a typed rewrite context. {{A73}}
9696
- **`golden.rs`, `gradle/*`, `hash/*` tally (audit-core, 2026-11-02, 9 files, 6.2K lines):** ~10 single-caller fns, ~9 wrappers or forwarders (`redirect::gradle::lockfile_paths` → `ScriptGraph::lockfile_paths` → `locks::lockfile_paths_in`), ~15 deletable comment lines; production-dead: `locks::lockfile_paths` (an inventory walk its doc says discovery uses), `dsl::literal_strings_in_call`, `GradleHome::init_dirs`, `ScriptGraph::{build_scripts, settings_includes}`. `hosted/engine.rs` (read to L960): `read_candidate_files` is ~360 lines of per-ecosystem phases.
9797
- **`hosted/` tally (audit-core, 2026-11-02, 17 files, 16.3K lines; `engine.rs` finished):** ~30 single-caller fns (a dozen `pnpm_trust_*_detail`/`npm_allow_remote_*_detail` text fns, `refuse_git_branch_locks`, `reusable_prior`), ~10 wrappers or shims (`guidance`'s `pub use … as pnpm_*` renames, `any_takeover_ecosystem`, `WITHHELD_REASON`), ~40 deletable comment lines. Giant functions: `memory::engine` (735 lines, 12 phases over a 14-field `RootState` accumulator), `engine::pnpm_trust` (280 lines, 4-tuple out), `engine::unattributed_pins` (240). The npm-family workspace model lives in `hosted/governing_root` though vendor, vex, the crawler and CLI scan import it {{A74}}. `memory/` re-implements core helpers: `join_bounded` (= `utils::concurrent::ordered_concurrent`), the vendor-ledger legacy parse, the cargo wiring probe. Dead: `EngineError::Internal`, the always-empty `deleted_files`.
98+
- **`ledgers.rs`, `manifest/*`, first `patch/*` tally (audit-core, 2026-11-02, 15 files, 14.4K lines):** ~35 single-caller fns (12 in `jvm_jar`), ~20 wrappers (`select_installed_variants` = `_any([p])`, `manifest_exists`, one-variant `AppliedVia` + CLI mirror), ~260 deletable comment lines (~70 `apply.rs`, ~60 `apply_lock.rs`); dead: `Ledgers::vendor_claimed`, `jvm_jar::derived_copies`, `DerivedVerdict::clean`, `copy_tree::fresh_copy`'s `skip_file_name` (always `None`). Advisories decoded from error strings {{A76}}; `patch/` mixes npm, JVM, tar and pycache code {{A77}}; `apply_package_patch_at` is 336 lines; human cleanup text (`format_bytes` …) sits in core `manifest/cleanup_blobs.rs`.

‎doc/05-tests.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Part 5
22

3-
_Last checked against main @ cbbbdb9 on 2026-11-02 by audit-cli-tests._
3+
_Last checked against main @ cbbbdb9 on 2026-11-02 by audit-core._
44

55
Tests:Fake tests (asserting on their own mocks, recomputing expected values with the code under test, unable to fail, claiming more than they check), mock overuse where a tempdir or a real install is cheap, sentence-matching assertions, duplicate tests, and real coverage gaps. Per-directory tallies and the fixes that landed.
66

@@ -20,6 +20,7 @@ _Last checked against main @ cbbbdb9 on 2026-11-02 by audit-cli-tests._
2020
- Sentence matching where a typed error exists: `http` cap tests.
2121
- Only `is_err()` asserted: `pdm_lock` unsafe-sources test.
2222
- **Root-skip tests** pass silently under root (`group_commit` ×2, `fs` ×3).
23+
- **`ledgers.rs`, `manifest/*`, first `patch/*` (audit-core, 2026-11-02, 15 files): about 25 fake, duplicate or weak tests.** All 23 `manifest::operations` tests pass with `write_manifest` replaced by a torn non-atomic write (executed), so `test_write_manifest_failure_preserves_existing` (writes a different path) and `leaves_no_stage_litter` cannot catch a lost atomic write; `apply` `test_apply_package_patch_hash_mismatch_blocks` fails on an invalid blob hash, not the mismatch; `file_hash` compares an error message to a hash; `apply_lock` `contended_sentinel_is_classified_as_contention` restates its one-line predicate; `package.rs` repeats 9 `tests/package_e2e.rs` cases; ~10 subsumed duplicates.
2324
- **Coverage gaps:**
2425
- `http` mid-stream cap and `Truncated`;
2526
- `cargo_build_cache` warning text;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[agent] 2026-11-02: handover from audit-core to audit-cli-tests
2+
3+
While reading core `patch/apply.rs` and `patch/jvm_jar.rs` at `cbbbdb9`, I found more copies of the apply/rollback mirror. That mirror is your carried row **C24**, so I'm handing them over to be added to C24 rather than opening a new A row:
4+
- **The Maven daemon-lock `SidecarRecord` literal is built 4×:** [apply.rs L1334-L1348](https://github.com/SocketDev/socket-patch/blob/cbbbdb90b336f8eb69886ea23a687a3a09fb108d/crates/socket-patch-core/src/patch/apply.rs#L1334-L1348), [rollback.rs L841-L855](https://github.com/SocketDev/socket-patch/blob/cbbbdb90b336f8eb69886ea23a687a3a09fb108d/crates/socket-patch-core/src/patch/rollback.rs#L841-L855), and [jvm_jar.rs L543](https://github.com/SocketDev/socket-patch/blob/cbbbdb90b336f8eb69886ea23a687a3a09fb108d/crates/socket-patch-core/src/patch/jvm_jar.rs#L543) and [L795](https://github.com/SocketDev/socket-patch/blob/cbbbdb90b336f8eb69886ea23a687a3a09fb108d/crates/socket-patch-core/src/patch/jvm_jar.rs#L795). The apply and rollback copies differ only in a comment and in how the target path is spelled.
5+
- **The blob read gate is written 3×.** [`apply::read_blob` L1426](https://github.com/SocketDev/socket-patch/blob/cbbbdb90b336f8eb69886ea23a687a3a09fb108d/crates/socket-patch-core/src/patch/apply.rs#L1426-L1440) is one; rollback re-implements the hash gate and the error text "Refusing to read blob with invalid hash" twice ([L269-L281](https://github.com/SocketDev/socket-patch/blob/cbbbdb90b336f8eb69886ea23a687a3a09fb108d/crates/socket-patch-core/src/patch/rollback.rs#L269-L281), [L769-L776](https://github.com/SocketDev/socket-patch/blob/cbbbdb90b336f8eb69886ea23a687a3a09fb108d/crates/socket-patch-core/src/patch/rollback.rs#L769-L776)).
6+
- **The regular-file probe on a blob entry is written twice:** [apply.rs L1411-L1413](https://github.com/SocketDev/socket-patch/blob/cbbbdb90b336f8eb69886ea23a687a3a09fb108d/crates/socket-patch-core/src/patch/apply.rs#L1411-L1413) and [rollback.rs L588-L590](https://github.com/SocketDev/socket-patch/blob/cbbbdb90b336f8eb69886ea23a687a3a09fb108d/crates/socket-patch-core/src/patch/rollback.rs#L588-L590).
7+
- **The verify-loop-then-write-loop skeleton is written twice:** [`apply_package_patch_at` L1100-L1174](https://github.com/SocketDev/socket-patch/blob/cbbbdb90b336f8eb69886ea23a687a3a09fb108d/crates/socket-patch-core/src/patch/apply.rs#L1100-L1174) and `rollback_package_patch_at` ([rollback.rs L611-L650](https://github.com/SocketDev/socket-patch/blob/cbbbdb90b336f8eb69886ea23a687a3a09fb108d/crates/socket-patch-core/src/patch/rollback.rs#L611-L650)). There are also two private `mark_crlf_bin_rewrite` functions with different signatures.
8+
9+
The stringly advisory channel the two engines share is filed separately as A76 ([#1987](https://github.com/SocketDev/socket-patch/issues/1987)).
10+
11+
---
12+
_Generated by [Claude Code](https://claude.ai/code)_

0 commit comments

Comments
 (0)