Repository navigation
refactor(resources): own the stable-root digest with classification as an observer - #11445
Conversation
Codex Review Summary: ❌ FailedThis 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. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
[Low impact] The reviewed changes appear safe to merge; no blocking issues were found. SummaryMoves stream hashing and stable-file identity helpers into
The previous and current commits have different merge bases with the target commit, so this review covered the full PR diff. No previous review threads were supplied. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
Inventory["Artifact inventory"] --> Classification["classifyStableRootArtifactHandle"]
Classification --> Root["Resources: stable-root checks"]
Consumers["Native, browser, extraction and verification"] --> Root
Root --> Digest["digestReadableToCompletion"]
Digest --> Hashes["SHA-256, optional MD5 and byte count"]
Digest --> Observer["Artifacts classification probe"]
Observer --> Evidence["Classification evidence"]
Reviews (6) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile |
…digest-resources # Conflicts: # scripts/lib/module-layers.baseline.json # src/artifacts/deno/DenoStandaloneLocation.ts
# Conflicts: # scripts/lib/module-layers.baseline.json
# Conflicts: # scripts/lib/module-layers.baseline.json # src/artifacts/BunStandaloneArtifactReader.ts # src/artifacts/ZipArtifactReader.ts # src/artifacts/bun/BunModuleGraphLayout.ts # src/artifacts/dotnet/DotnetBundle.ts # src/artifacts/nodeSea/NodeSeaLocation.ts
Summary
Implements the digest half of the decision on #11426. The stable-root digest and the target-identity helpers move from the artifacts provider into
src/resources. Classification stays in artifacts, behind a chunk-observer port.native and browser now take these helpers from
resources/index.ts. After merging main (which has #11415), the baseline recordsnative -> artifactsdropping from 5 to 2 andbrowser -> artifactsfrom 6 to 4.This PR also carries #11484, which was stacked on it and folded in:
ArtifactFileSourceandartifactFileAdmissionFailuremove tosrc/resourcesand hash through the resources digest (see the section below).Refs #11426 #11359. Part of plan W9.
Problem and expected behavior
native (
NativeMachoSource,NativeMacOSProvider) and browser (PlaywrightTraceDecoder) importedhashStableRootArtifactHandle,withArtifactTargetIdentityandtargetDigestChangedFailurefrom the artifacts provider. They only check that a target's SHA-256 still matches its admitted identity. The digest could not move on its own, because it also ran the artifacts classification probe over the hashed bytes.Expected: one SHA-256/MD5 hashing loop, owned below providers. Artifacts derives its classification evidence from the same bytes through an observer, without a second read.
Change and scope
src/resources/StreamDigest.ts. It holdsdigestReadableToCompletion(stream, signal, integrityAlgorithm, observe), which returns{ sha256, bytes, md5? }. Each hashed chunk is passed to the observer (StreamDigestObserver).abortIfNeededmoves here unchanged. Its 22 artifacts importers now take it fromresources/index.ts.git mv):artifacts/inventory/hashStableRootArtifact.tsbecomesresources/StableRootArtifact.ts, andartifacts/withArtifactTargetIdentity.tsbecomesresources/withArtifactTargetIdentity.ts.StreamDigest.hashStableRootArtifactHandletakes an optional observer.resources/index.ts.artifacts/ArtifactHash.ts.hashReadableandhashReadableToCompletionkeep their signatures. They now call the resources digest and pass the classification probe as the observer, so there is one hashing loop.HashResultisArtifactClassificationEvidence & StreamDigest.classifyStableRootArtifactHandleis the root digest plus the root's classification evidence.inventory/classify.tsuses it.sha256andbytes, so it uses the resources function directly. These are extraction, release exposure, scan verification, native and browser.crossProvideris lowered:native -> artifactsfrom 5 to 2,browser -> artifactsfrom 6 to 4 (the last step from refactor(resources): move the artifact file source into src/resources #11484).ArtifactFileSource-> resources.src/artifacts/ArtifactFileSource.ts(with its test) andArtifactFileAdmission.tsmove tosrc/resources/and are exported fromresources/index.ts.PlaywrightTraceDecoder's import ofassertArtifactFileSelectedSourceno longer reaches artifacts.digestReadableToCompletionand reads onlysha256, so it no longer runs a classification probe it discarded.hashReadablechecked the signal right after the last chunk, which let a cancellation in that window preempt source revalidation. Now the completed digest is revalidated first, and cancellation is checked afterwards, as the code comment there already required. A matching digest still ends cancelled; a changed source is reported as the integrity failure.tests/process-global/selectedArtifactSourceLifecycle.test.tsnow spies on the resources digest, and itsabort = truecase fails if the post-digest check is restored.Not included:
ZipArtifactReaderitself out of artifacts ([Design] Owner for the ZIP reader and the stable-root digest that other providers import from artifacts #11426). Its other dependencies moved in refactor(resources): move the artifact reader limit failure into src/resources #11474 and refactor(domain): move ZIP member-region accounting and CP437 name decoding into src/domain/zip #11475; it follows once this PR lands.native -> artifactsimports, which are the PE resources and other readers.Contract and boundary impact
src/resources.file-snapshot-hashobservation on release, are unchanged.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
Tests added or updated: specifier updates only, in
inesArtifact,inesCancellationandartifactProvider.extractionAdmission. Their spies onhashStableRootArtifactHandlenow target the resources module, and still observe the root hashes during classification and extraction.Base reproduction or other evidence: after merging main,
node scripts/verify-module-boundaries.mjs --shrink-layer-baselinereportednative -> artifacts: 2, baseline 5andbrowser -> artifacts: 5, baseline 6.User-visible CLI/MCP output (if applicable): none.
Remaining proof gaps: none known. The root-digest cancellation, integrity and cleanup coverage in the tests above ran unchanged.
Observed, derived, and inferred claims remain distinguishable.
Artifact identity, source provenance, and failed attempts remain preserved.
Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.
Validation performed
npm run check:fast: passed, before and after each merge of main. The pre-push hook passed.npm run test:focused -- src/artifacts/ZipArtifactReader.test.ts src/artifacts/NodeSeaArtifactReader.test.ts src/resources/ArtifactFileSource.test.tsplus the Bun and .NET bundle reader tests: 94 passed.npm run test:focused --withsrc/resources/ArtifactFileSource.test.ts,tests/process-global/selectedArtifactSourceLifecycle.test.ts,src/artifacts/{ArtifactSourceResolution,FitArtifactReader,HexRecordArtifactReader,NtfsMftArtifactReader,ZipArtifactReader,MachOSliceArtifactReader}.test.tsandsrc/artifacts/{UnityFsArtifactReader,WxapkgArtifactReader}.boundaries.test.ts: 10 files, 186 passed. With the post-digest signal check restored, the late-abort(true)case failed (1 failed, 7 passed).node scripts/verify-module-boundaries.mjs --shrink-layer-baseline: lowered the two entries above.npm run test:focused -- tests/boundary/filesystem/inesArtifact.test.ts tests/boundary/filesystem/inesCancellation.test.ts tests/boundary/providers/native/artifactProvider.extractionAdmission.test.ts src/artifacts/ArtifactHash.test.ts src/artifacts/inventory/ArtifactInventoryFinalization.test.ts src/artifacts/inventory/scanReader.test.ts src/artifacts/ZipArtifactReader.test.ts src/browser/history/playwrightTrace/PlaywrightTraceLifecycle.test.ts: 151 passed.Compatibility, safety, and release
Author readiness
Human owner:
Before merge
type(scope): outcome.