Skip to content

refactor(resources): own the stable-root digest with classification as an observer - #11445

Merged
morluto merged 5 commits into
mainfrom
refactor/stable-root-digest-resources
Nov 15, 2026
Merged

morluto merged 5 commits into
mainfrom
refactor/stable-root-digest-resources

Conversation

@morluto

@morluto morluto commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

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 records native -> artifacts dropping from 5 to 2 and browser -> artifacts from 6 to 4.

This PR also carries #11484, which was stacked on it and folded in: ArtifactFileSource and artifactFileAdmissionFailure move to src/resources and 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) imported hashStableRootArtifactHandle, withArtifactTargetIdentity and targetDigestChangedFailure from 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

  • New src/resources/StreamDigest.ts. It holds digestReadableToCompletion(stream, signal, integrityAlgorithm, observe), which returns { sha256, bytes, md5? }. Each hashed chunk is passed to the observer (StreamDigestObserver).
    • abortIfNeeded moves here unchanged. Its 22 artifacts importers now take it from resources/index.ts.
  • Moves (git mv): artifacts/inventory/hashStableRootArtifact.ts becomes resources/StableRootArtifact.ts, and artifacts/withArtifactTargetIdentity.ts becomes resources/withArtifactTargetIdentity.ts.
    • The root digest returns a StreamDigest. hashStableRootArtifactHandle takes an optional observer.
    • Inside the unit, imports are direct. Outside it, every import goes through resources/index.ts.
  • artifacts/ArtifactHash.ts. hashReadable and hashReadableToCompletion keep their signatures. They now call the resources digest and pass the classification probe as the observer, so there is one hashing loop.
    • HashResult is ArtifactClassificationEvidence & StreamDigest.
    • New classifyStableRootArtifactHandle is the root digest plus the root's classification evidence. inventory/classify.ts uses it.
    • Every other root-digest caller only compares sha256 and bytes, so it uses the resources function directly. These are extraction, release exposure, scan verification, native and browser.
  • Baseline. crossProvider is lowered: native -> artifacts from 5 to 2, browser -> artifacts from 6 to 4 (the last step from refactor(resources): move the artifact file source into src/resources #11484).
  • Folded in from refactor(resources): move the artifact file source into src/resources #11484: ArtifactFileSource -> resources.
    • src/artifacts/ArtifactFileSource.ts (with its test) and ArtifactFileAdmission.ts move to src/resources/ and are exported from resources/index.ts. PlaywrightTraceDecoder's import of assertArtifactFileSelectedSource no longer reaches artifacts.
    • The bound-descriptor hash uses digestReadableToCompletion and reads only sha256, so it no longer runs a classification probe it discarded.
    • One ordering detail changed, deliberately. hashReadable checked 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.ts now spies on the resources digest, and its abort = true case fails if the post-digest check is restored.

Not included:

Contract and boundary impact

  • Semantic owner and earliest changed stage:
    • The streaming digest and the stable-root/target-identity helpers are now owned by src/resources.
    • Classification evidence remains owned by the artifacts classification probe, which observes the digested chunks.
    • Superseded: the artifacts hashing loop and the artifacts-owned root digest.
  • Contribution scope fit and linked maintainer decision: [Design] Owner for the ZIP reader and the stable-root digest that other providers import from artifacts #11426 (decision posted there). No new capability.
  • CLI and MCP/tool-catalog contract: none.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: unchanged. The same bytes are hashed with the same algorithms. The integrity and cancellation failures, and the partial file-snapshot-hash observation on release, are unchanged.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): the root descriptor admission, release and cleanup-failure paths moved unchanged.
  • Generated metadata (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.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: specifier updates only, in inesArtifact, inesCancellation and artifactProvider.extractionAdmission. Their spies on hashStableRootArtifactHandle now 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-baseline reported native -> artifacts: 2, baseline 5 and browser -> 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.
  • After the latest merge of main: npm run test:focused -- src/artifacts/ZipArtifactReader.test.ts src/artifacts/NodeSeaArtifactReader.test.ts src/resources/ArtifactFileSource.test.ts plus the Bun and .NET bundle reader tests: 94 passed.
  • From refactor(resources): move the artifact file source into src/resources #11484: npm run test:focused -- with src/resources/ArtifactFileSource.test.ts, tests/process-global/selectedArtifactSourceLifecycle.test.ts, src/artifacts/{ArtifactSourceResolution,FitArtifactReader,HexRecordArtifactReader,NtfsMftArtifactReader,ZipArtifactReader,MachOSliceArtifactReader}.test.ts and src/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

  • Breaking changes or migration steps: none. These are internal modules.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: digest and identity checks are unchanged.

Author readiness

Human owner:

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-15T20:12:35.423924Z
We couldn’t complete this review. Comment @codex review to try again.
7753fd2 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@greptile-apps

greptile-apps Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The reviewed changes appear safe to merge; no blocking issues were found.

Summary

Moves stream hashing and stable-file identity helpers into resources. Artifacts keeps classification and observes the same chunks without reading the file again.

  • Resources hash stable root files while artifacts observe the same chunks for classification.
  • Shared file and target identity helpers now live under resources.

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"]
Loading

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
@morluto
morluto merged commit c24f008 into main Nov 15, 2026
7 of 9 checks passed
@morluto
morluto deleted the refactor/stable-root-digest-resources branch November 15, 2026 21:25
@morluto morluto added the area: evidence Evidence, artifacts, and reconstruction label Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: evidence Evidence, artifacts, and reconstruction

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant