GeezerVison is showing github.com — mcpx(artifacts): a content-addressed blob can change after registration — PutFile and Export hardlink it to files outside the store, and adopt() then cements the mutated bytes under the original hash · Issue #1660 · developing-today/code
mcpx(artifacts): a content-addressed blob can change after registration — PutFile and Export hardlink it to files outside the store, and adopt() then cements the mutated bytes under the original hash #1660Labels app/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobtask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests DescriptionProblem
mcpx's artifact store is content-addressed — "The body lives under its sha256" (pkgs/mcpx/internal/artifacts/artifacts.go:16-19) — but two of its three ingestion/delivery paths make the blob share an inode with a file outside the store, so the bytes under a hash can change after registration:
PutFile (artifacts.go:226) hardlinks the caller's file into the blob path: os.Link(path, dest) (artifacts.go:255). The same-filesystem case is pinned by TestPutFileHardlinksRatherThanCopies (artifacts_test.go:139-156, asserts sameInode).
Export (artifacts.go:551) hardlinks the blob out to the caller's directory first: os.Link(src, dest) (artifacts.go:560). This is the delivery path used by execsvc (internal/execsvc/execsvc.go:746).
An in-place rewrite through either outside name — the normal shape for a screenshot tool overwriting the same path, or a caller annotating/cropping a delivered file in place — rewrites the blob. From then on:
Bytes/OpenBody serve bytes whose sha256 no longer equals the registered Meta.SHA256 (and whose length may no longer equal Meta.Size): the hash a caller compares to skip a transfer (package doc, artifacts.go:16-19) now vouches for different content.
- Worse,
adopt (artifacts.go:288-295) trusts an existing blob path as "Identical content by definition": a later Put of the genuine original content finds the mutated blob in place, keeps it, and registers the original hash against the mutated bytes — permanently.
- The daemon ingests script-produced files through this path (internal/daemon/routes_exec.go:380,
store.PutFile), so a script/tool pair that reuses an output path can corrupt an earlier run's artifact after that run already reported its hash.
Evidence
Verified on main 7eb930a by (1) deterministic trace of the code above, and (2) the hardlink premise, exercised this run:
$ printf 'ORIGINAL' > src.png && ln src.png blob && printf 'REPLACED!' > src.png
$ cat blob -> REPLACED!
$ stat -c '%i' src.png blob -> identical inode
(log: goal hidden_files/probe-2026-10-28-laneA-artifactlink/premise.log)
Disclosure: the Go probe that drives the real Store (hidden_files/probe-2026-10-28-laneA-artifactlink/probe_lanea_test.go in the goal workspace: PutFile → in-place overwrite → Bytes returns the replacement under the original hash; re-Put of the original content still serves the replacement; Export → in-place edit → stored body changes) was not executed — the laptop (the only sanctioned probe host) was unreachable for the whole creator run (SSH tunnel closes immediately, same outage the queue lanes hit earlier today), and probes are never compiled on the sandbox. Triage: run the probe first and correct this evidence if any verdict differs.
Why it matters
The store's whole contract is that a hash names immutable bytes: dedup, transfer-skipping, and quota accounting (Used, distinct hash) all assume it. A silent mutation breaks that contract with no error anywhere, and adopt makes the corruption sticky for the genuine content too. The hardlink itself is a deliberate, tested optimisation — the defect is that nothing protects the blob from writes through the outside name (no copy-on-ingest for mutable sources, no read-only blob mode, no hash re-verification on serve/adopt).
Acceptance criteria
- Triage runs the prepared probe and confirms/corrects the three verdicts (PutFile mutation, adopt stickiness, Export mutation).
- After the fix, bytes served for a registration always hash to
Meta.SHA256 and match Meta.Size, even when the PutFile source or an exported copy is rewritten in place afterwards.
- Regression tests cover: PutFile source overwritten in place; Export target edited in place; re-Put of original content after a mutation attempt.
- The chosen remedy (e.g. copy instead of link on ingest, link + read-only blob, copy-on-export, or verify-on-adopt) is pinned in the package doc, including what happens to the existing
TestPutFileHardlinksRatherThanCopies expectation if the link optimisation is dropped or narrowed.
Activityadded kind/bugSomething isn't working (prefixed form of the classic bug label) task/triageQueue packet kind: verify, reproduce, and route this item app/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo) effort/sSmall: expected under 2 hours of work on Oct 28, 2026dezren39 commented on Oct 28, 2026 🤖 Agent note · state: filed
- Agent: new-issue-creator (new-issue-creator-code-a)
- Session / ID: cron new-issue-creator-code-a run 2026-10-28 06:35 CDT
- Found via: filed this run
- Task: Triage the artifacts hardlink-mutation defect: run the prepared probe (goal hidden_files/probe-2026-10-28-laneA-artifactlink/probe_lanea_test.go) first, then pin the remedy for blob immutability.
- Expectation: effort/s — done looks like the probe verdicts confirmed/corrected and a remedy pinned for the queue fix lane.
- Links: queue packet packet-1660.json (repo-health-code-pilot, triage)
dezren39 commented on Oct 31, 2026 dezren39 commented on Oct 31, 2026 🤖 Agent note · done
- Agent: queue worker (repo-worker-code), lane C shift
- Session / ID: queue task 4177
- Found via: queue claim (resumed from awaiting_ci park)
- Task: PR 3046 merged — squash merge commit 9959756, head b3b1a45. CI fully green on the head (lint, plugin tests, stress PR-changed-tests, docs build, CI time budget all SUCCESS). Codex review on the head: no findings. PutFile + Export now copy instead of hardlinking in pkgs/mcpx/internal/artifacts; closing this issue as completed.
- Expectation: done.
- Links: PR fix(mcpx/artifacts): copy instead of hardlink in PutFile and Export (#1660) #3046
MetadataMetadataapp/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobtask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests DevelopmentNo branches or pull requestsIssue actions
|