Repository navigation
test(artifacts): make same-size carrier rewrites observable on coarse timestamps - #10155
SahinurDEV wants to merge 3 commits into
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b058a9418c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // The replacement keeps the carrier size, and filesystems with coarse | ||
| // timestamps can leave mtime unchanged within one tick. Move mtime so | ||
| // the mutation is observable independently of timestamp granularity. | ||
| utimesSync(args[0], before.atime, new Date(before.mtimeMs + 1000)); |
There was a problem hiding this comment.
Advance mtime past the filesystem timestamp quantum
If these tests run with tmpdir() on a filesystem with 2-second timestamp ticks, such as FAT, mtimeMs + 1000 can round back to the original mtime; if ctime is also unchanged within its tick, sameRegularFileState still sees identical metadata and the integrity assertion can resolve instead of reject. The same delta is used in the UF2, Deno, and PyInstaller tests; use a delta beyond that quantum or verify the post-utimes stat changed.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good point. In 4abf945 I moved mtime forward by 10 s instead of 1 s in all four tests (UF2, Node SEA, Deno, PyInstaller), so the bump stays visible even with 2 s FAT timestamp ticks.
Resolve the Uf2ArtifactReader.test.ts conflict by following morluto#13372, which removed the UF2 reader identity test during numbering consolidation. Keep the 10 s mtime bump in the Node SEA, Deno, and PyInstaller tests. Signed-off-by: Sahinur <[email protected]>
[Low impact] The reviewed changes appear safe to merge. SummaryThe PR makes same-size rewrites visible in three artifact-reader test files by moving
Reviews (2) · Last reviewed commit: "Merge upstream/main into fix/same-size-c..." · Reviewed by Greptile |
|
@SahinurDEV thanks for the PR — there is 1 open review thread here:
Could you address or reply to this? Once it's resolved and CI is green we can take another look. |
Summary
Four artifact-reader tests rewrite the carrier in place with bytes of the same size and then expect
reason: "integrity". Carrier identity is checked withsameRegularFileState(dev, ino, size, mode, mtime/ctime). On filesystems whose timestamps advance in coarse ticks (for example ext4 on Linux 6.12, where two writes a few milliseconds apart get identicalmtimeNs/ctimeNs), the rewrite is invisible to that check, so the tests fail or flake depending on how fast the reader runs. No issue is linked; this is a test-reliability fix found while running targeted suites.Problem and expected behavior
Smallest trigger: on Linux 6.12.113 / ext4, Node 24.22.1:
Affected tests on
main(a016743):Uf2ArtifactReader.test.ts› rejects a forged region entry and a changed carrier (fails every run here:promise resolved "Readable{…}" instead of rejecting)NodeSeaArtifactReader.test.ts› rejects post-classification carrier mutation before publishing Node SEA facts: valid replacement / malformed blob (1–2 of 2 fail per run)deno/DenoStandaloneArtifactReader.boundaries.test.ts› rejects carrier mutation between physical member reads (intermittent)pyinstaller/PyInstallerBoundaries.test.ts› binds materialization to the inventoried digest and checks cached carrier freshness (intermittent;"first"and"other"have the same length)Expected: these tests verify that a changed carrier is rejected, independent of host timestamp granularity.
Change and scope
Test-only. Each test now records the carrier's stats before the same-size rewrite and afterwards moves
mtimeforward by one second withutimes(orFileHandle.utimesinside the Deno read hook). This follows the existing pattern intests/boundary/filesystem/directoryArtifactReaderOpen.test.ts. The tests still exercise the real identity check; they just make the mutation observable to it on every filesystem.Intentionally not included: no production change to
sameRegularFileStateorArtifactFileSource. Detecting same-size, same-tick rewrites would need content rehashing on every open, which is a design decision for maintainers, not a test fix.Follow the contribution scope.
Contract and boundary impact
src/artifacts/**.test.ts); no producer or consumer changes.docs/public/product-catalog.json), package, or installation impact: none.Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.
Evidence and regression coverage
npx vitest run src/artifactsreported2 failed | 1745 passed | 1 skipped, with the Uf2 and Node SEA tests failing; a second base run failed the Deno and PyInstaller tests instead.Uf2ArtifactReader.test.tsalone failed 2/2 runs.For evidence-bearing changes:
Validation performed
npx vitest run src/artifacts/Uf2ArtifactReader.test.ts src/artifacts/NodeSeaArtifactReader.test.ts(3 runs) — 55 passed each runnpx vitest run src/artifacts(3 runs) — 1747 passed, 1 skipped each runnpm run typecheck— passednpx oxlint <changed files>— no new findings (only existingno-this-aliaswarnings elsewhere inPyInstallerBoundaries.test.ts)npx oxfmt --check src/artifacts— all files formattedCompatibility, safety, and release
Author readiness
Human owner: @SahinurDEV
Before merge
type(scope): outcome.