Skip to content

Commit f4fbaf9

Browse files
committed
refactor: #2355 and #2356 filed; Docker ran
A Docker daemon starts in the sandbox, so the two leads that waited for it ran. #1970 is confirmed: the Go and NuGet Docker suites pass on a binary whose default apply patches nothing. L14 is confirmed with real scala-cli and filed as #2356. NuGet agent mode under a real .NET SDK gave one defect: apply deletes the file the stale-copy check of hosted and vendored mode reads, so a hosted scan attests an unpatched package (#2355). Assisted-by: Claude Code
1 parent c1b1463 commit f4fbaf9

2 files changed

Lines changed: 90 additions & 9 deletions

File tree

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
[agent] 2026-11-29: architecture refactor
2+
3+
**`main`:** cfc870f. The run started at 02:55Z.
4+
5+
### Chosen
6+
No PR this run. Three routine PRs are open (#2261, #2265, #2267), so step 3 applies: open none and verify leads instead. All three are `ready` and unchanged since 2026-11-26: none merged or closed, none has a review from a person, and no maintainer has commented on the discussion.
7+
8+
For three days the register said the leads still marked `to verify` could not run here: #1970 needs Docker, L14 needs scala-cli. **That was wrong. `dockerd` starts a Docker daemon in this sandbox**, and with it the Docker suites, a real .NET SDK and a real scala-cli all run. So this run settled both leads, and then gave NuGet's agent mode the check no run could give it before: the real `dotnet` after a patch. That found one new defect, #2355.
9+
10+
### PR
11+
None opened. #2261, #2265 and #2267 still await review. `main` has not moved from cfc870f.
12+
13+
### Leads and issues
14+
15+
**#1970, confirmed by running it.** Eight of the nine Docker agent suites serve a 64-zero `beforeHash` and apply with `--force`. I built local images for two of them (Go 1.21.13, .NET SDK 8.0.428), ran the committed suites unchanged against the binary from `main`, and then against a mutant in which a pristine file never passes the hash gate (core `patch/apply.rs`, `verify_file_patch`: the `beforeHash` comparison made always true), so a default `apply` can patch nothing:
16+
17+
```
18+
docker_e2e_golang main: 1 passed mutant: 1 passed
19+
docker_e2e_nuget main: 2 passed mutant: 2 passed
20+
```
21+
22+
A throwaway copy of the Go suite that serves the real `beforeHash`, gates `scan --sync`'s own apply and then applies without `--force` passes on `main` and fails on the mutant ("scan --sync exited 1"). The same gated chain by hand on a real .NET install also passes on `main`. So the default path works on these two real installs today, and these suites would not notice if it stopped. The mutant is not a survivor of the whole test set: I did not run the other suites against it, and the gate has unit tests. What it shows is the issue's claim, that a suite named for the install-to-apply chain proves the forced path alone. The issue's plan (gem's probe for the real hash, in every suite) stands. Test code only, so it joins the end of the Next PR line.
23+
24+
**L14, confirmed with real scala-cli 1.19.0 and filed as #2356.** scala-cli never removes anything from `.scala-build/.bloop`: a directory build with tests leaves 4 entries, each script run on its own 2, each new set of command-line options 4 more (`scala-cli test .` counts as one). The reader stops at 256 entries, which is 128 project files and not the 256 its comment says, because every project has a directory beside its file. After 120 scripts compiled once each the directory held 262 entries and `discover` returned `None`. The gate's remedy, `scala-cli compile --test .`, left 262 entries and `None`. `scala-cli clean .` and a compile left 4 and the evidence came back. The CLI's text in that state, from a throwaway test over the suite's fixture: "no scala-cli resolution under .scala-build/.bloop; run `scala-cli compile --test .` […] and re-run". The lead's open question is answered too: no command I ran writes a `.json` that is not a Bloop project into that directory (`setup-ide` writes its files one level up). Low harm: a skip.
25+
26+
**New: L86, filed as #2355.** Agent mode deletes `.nupkg.metadata` from a NuGet package it patches, and `rollback` does not put it back. That file is the only thing the stale-copy check of #352 reads (core `vendor/nuget_feed.rs`, `extracted_content_hash`; three call sites). Real .NET SDK 8.0.428, Newtonsoft.Json 13.0.3, a lock file, a stand-in patch API:
27+
28+
```
29+
control (a folder NuGet filled):
30+
$ socket-patch scan --mode hosted --yes --vex vex.json …
31+
Warning: omitting pkg:nuget/Newtonsoft.Json@13.0.3 from VEX: the installed copy is not patched (stale_install)
32+
Warning: … NuGet's global packages folder already holds the UNPATCHED copy … Delete that directory …
33+
Error: VEX generation failed: No applied patches with vulnerability metadata to attest. # exit 1, no document
34+
35+
after agent `scan --sync --global` and `rollback` (the dll is upstream again, .nupkg.metadata is gone):
36+
$ socket-patch scan --mode hosted --yes --vex vex.json …
37+
Wrote OpenVEX document with 1 statement to vex.json … # exit 0, not_affected
38+
$ dotnet restore
39+
error NU1403: Package content hash validation failed for Newtonsoft.Json.13.0.3.
40+
```
41+
42+
Vendored mode without a lock loses the same warning and the build then loads the upstream dll; SDK 10.0.404 gives the same. NuGet writes the file back on its first full restore, so a second scan warns. The reason the code gives for the delete ("`dotnet restore` flags the package as tampered") did not hold: with the dll replaced by hand and the file kept, `restore`, `restore --force`, `--locked-mode` and a rebuild all pass on SDK 6.0.428, 8.0.428 and 10.0.404. The planned fix is one function: fall back to the `.nupkg.sha512` file. Whether agent mode should stop deleting the file is left to a maintainer in the issue.
43+
44+
**Seen and not filed:**
45+
- **After an agent-mode apply, an already built project keeps loading the old dll from `bin/`** until it is rebuilt. #2198 (another routine's) has it.
46+
- **The general `vendored_tree_out_of_sync` remedy, "re-run your package manager's install", does not resync a NuGet global folder.** It is in #2355's text; #2353 has the same remedy for pnpm.
47+
- **The Go Docker suite pre-chmods the file it patches and runs as root**, so it cannot test the read-only module cache either. Read, not run; it belongs to #1970's rewrite.
48+
- **L08, L13:** still to verify. They need Windows.
49+
50+
### Areas examined
51+
All with the binary built from `main`.
52+
53+
- **The Go and NuGet Docker agent suites**, committed and gated, on `main` and on one mutant (above).
54+
- **NuGet agent mode under the real .NET SDK 8.0.428** (the global packages folder): a gated `scan --sync --global` applies; the next `dotnet build` copies the patched dll to `bin/` and the app loads it; `dotnet restore --force`, a second project restoring the same package, `dotnet build --no-incremental`, and `restore --use-lock-file` then `--locked-mode` all keep the patched file; NuGet writes `.nupkg.metadata` back with the same hash; `vex` attests. Clean but for #2355.
55+
- **Mode moves on NuGet**: agent to vendored (the record migrates, the build loads the patched copy), and agent, rollback, then hosted or vendored (#2355), with and without a lock file.
56+
- **scala-cli 1.19.0**: what `compile`, `run`, `test`, `package`, `setup-ide`, changed directives and changed options leave in the Bloop directory.
57+
- Not run: the other six Docker agent suites and the five vendored ones, sbt, .NET 9, hosted NuGet on .NET 10, and Windows.
58+
59+
### Lessons
60+
- **"Needs X" in the register was wrong a second time** (Go on 11-27, Docker now). Run `command -v dockerd` and start it before writing that a lead cannot run.
61+
- **Docker here, step by step.**
62+
1. `dockerd > log 2>&1 &`. Pulls from Docker Hub and `mcr.microsoft.com` work.
63+
2. A container cannot reach the sandbox's HTTPS proxy, which listens on loopback. Forward the bridge address to it (20 lines of Python `asyncio` on `172.17.0.1:<the port in $HTTPS_PROXY>`), and bake into each image `HTTPS_PROXY` with that address, `NO_PROXY=host.docker.internal,localhost,127.0.0.1`, and the sandbox's CA bundle (`$CURL_CA_BUNDLE`) as `/etc/ssl/certs/ca-certificates.crt`.
64+
3. The repository's Dockerfiles do not build here: the network policy refuses `deb.debian.org` and `go.dev`, and the host-built binary needs glibc 2.39, which Debian 12 lacks. Build a stand-in on Ubuntu 24.04 with the same tool version and the suite's tag (`socket-patch-test-<ecosystem>:latest`): Go by `COPY --from=golang:1.21.13 /usr/local/go`, .NET from `mcr.microsoft.com/dotnet/sdk:8.0-noble`.
65+
4. Run a suite with `--features docker-e2e`, `SOCKET_PATCH_DOCKER_E2E_REQUIRED=1` and `SOCKET_PATCH_DOCKER_BIN=<a copy of the built binary>`. For a mutant, run the test executable under `target/debug/deps/` again from the crate directory with another binary: no rebuild of the test.
66+
- **scala-cli from its image** (`virtuslab/scala-cli:1.19.0`): it cannot fetch its JVM index, so mount the host's JDK 21 and `/etc/java-21-openjdk` and pass `--jvm system`. Give the launcher (as `-D` arguments) and `JAVA_TOOL_OPTIONS` the proxy host and port and the host's Java trust store. Mount the project at the same path as on the host: Bloop records absolute paths. A loop of compiles inside one container keeps the Bloop server up (120 scripts in about 4 minutes).
67+
- **A stand-in patch API for NuGet in all three modes is 70 lines of Python**: `patches/batch`, `by-package`, `view` (also at `/patch/view/<uuid>`), `patches/package` (the grant: artifact URL, `integrity.sha512`, `registryOverride` of kind `nuget-v3`), the flat-container feed (`index.json`, the versions list, the nupkg) and `/patch/blob/<hash>` for `rollback`, which needs `SOCKET_PROXY_URL` pointed at it. Bind `0.0.0.0`; containers reach it at `host.docker.internal` with `--add-host=host.docker.internal:host-gateway`. Pass `--api-url`, `--api-token`, `--org` and `--patch-server-url` as flags.
68+
- **To see which assembly a .NET app loads**, have it print the SHA-256 of `typeof(X).Assembly.Location`, and use another target framework's dll of the same package as the patched bytes: it loads and it hashes differently.
69+
- **Check a fix-up's stated reason against the real tool, on more than one version.** The reason in the NuGet sidecar code reads as fact. Three SDKs said otherwise in two minutes.
70+
- **A file one mode deletes can be the input of another mode's check.** Grep the name of every file a fix-up removes across the other modes.
71+
- **Read the contract row before calling a missing warning a defect.** The row for the stale-copy warning says a directory without `.nupkg.metadata` is never judged, and means a `packages.config` folder. The issue says so and proposes the row's change.
72+
- The hunt took about 40 minutes of wall time: the CLI build 4, Docker and the proxy 6, the Go suites and the mutant 5, scala-cli 9, NuGet 14, the two write-ups the rest.
73+
- The register was at 11,990 characters and is at 11,917. L14 and #1970 left their own rows for the `filed` and `confirmed` rows, L86 joined the `filed` row, and the tools note now says what Docker brings.
74+
- The owner was notified at 03:37Z of #2355 and #2356.
75+
76+
### Needs a person
77+
- **#2355:** after an agent-mode NuGet apply and rollback, a hosted `scan --vex` attests a package NuGet still restores unpatched. It also asks whether agent mode should keep `.nupkg.metadata`.
78+
- **#2353 is new on `main` since v5.1.0 and not released.** Whether it holds the 5.2.0 release PR (#2248) is a maintainer's call.
79+
- **Review #2261, #2265 and #2267.** This is the thirty-sixth run in a row that could only verify leads.
80+
- **#2270** still blocks `ci-ok` on every PR; #2280 is open for it.
81+
- **#2347, #2340, #2309, #2277 and #2297 need an answer.** **#2299** and **#2315** each ask which of two fixes a maintainer prefers.
82+
- Forty-nine confirmed problems wait for a slot, in the order the register's "Next PR" line gives.

0 commit comments

Comments
 (0)