Repository navigation
feat(artifacts)!: inspect and compare directories by a content-addressed root digest - #14270
Merged
Merged
Conversation
…sed root digest
inspect_artifact takes an optional path and inspects it without the open
session target; a directory is inventoried in place. compare_artifacts
accepts {kind:"path",path} on either side. open_binary is unchanged and
still refuses ordinary directories with directory_requires_file.
The inventory owner computes a versioned tree digest (rea-directory-tree
v1) from the walk it already performs: SHA-256 over length-prefixed
records of each member's NFC path, kind and content digest, sorted by
path bytes. Symlink targets are recorded and not followed; FIFOs,
sockets and devices are recorded by kind. A walk that a limit or an
unreadable member stops reports root_digest partial with no digest.
BREAKING CHANGE: subject.identity gains a directory kind
{kind:"directory",algorithm:"rea-directory-tree",version:1,sha256}. A
directory inventory's subject and root sha256 are its tree digest, and a
partial walk's subject is {kind:"unknown",reason:"not-observed"}.
inspect_artifact no longer requires an open target. Directory symlink
occurrences record link_target and compare by it.
morluto
marked this pull request as ready for review
November 24, 2026 03:29
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. |
Contributor
[Medium impact] The reviewed changes appear safe to merge. SummaryAdds path-based artifact inspection and comparison, with complete directories identified by a versioned tree digest.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["Selected artifact path"] --> B{"Directory?"}
B -->|Yes| C["Inventory existing directory"]
B -->|No| D["Inspect in artifact-only session"]
C --> E{"Walk complete?"}
E -->|Yes| F["Directory subject with tree digest"]
E -->|No| G["Unknown subject; no tree digest"]
D --> H["File subject"]
F --> I["Compare inventories"]
G --> I
H --> I
Reviews (8) · Last reviewed commit: "fix(artifacts): compare stored directory..." · Reviewed by Greptile |
… cleanup retryable - The tree digest encodes each member's exact stored name bytes instead of an NFC path, so names that differ only in normalization stay two members and swapping their contents changes the identity. - A directory inspection whose readers cannot be released retains its scope in the caller's lifetime (the MCP session, the CLI session or the comparison's resource scope), so a later close retries it. The one-shot session of a path-selected file is retained the same way. - compare_artifacts keeps a completed left inventory as an argument observation when the right side fails. - A summary of a partial directory inventory, whose subject is unknown, resolves to its exact parent and compares with unknown coverage. - The directory identity reference is in the site navigation, and the CLI boundary test passes the comparison command its environment.
…ts in claims and digest filters verify_reconstruction required a file subject for every structural source, so a structural-artifact claim over two complete directory inventories stayed unknown even when compare_artifacts confirmed a difference. Artifact claims now accept a file or directory identity; function claims remain file-only. get_evidence_bundle's target_sha256 filter compared only file subjects, so a directory's returned tree digest matched no records. It now matches the digest of a file or directory subject.
…ct-identity # Conflicts: # src/artifacts/inventory/ArtifactGraphConstruction.ts
A relative directory selection such as "." reached the directory route unresolved, so the subject's local_path was the relative spelling. The directory route now uses the caller path owner, as target admission does for files, and records the absolute path. The CLI acceptance test that pinned "inspect-artifact ." to directory_requires_file now expects the inventoried empty directory, and the macOS bundle verifier asserts the .app directory's tree-digest identity instead of a file format.
# Conflicts: # src/artifacts/ArtifactProvider.ts
…LI evidence delivery, cleanup retry, and tool effects
morluto
enabled auto-merge (squash)
November 24, 2026 15:31
morluto
added a commit
that referenced
this pull request
Nov 25, 2026
…essions #14270 made inspect_artifact take an optional path and stop requiring an open target, so a resource-only session reports it available. The macOS-only acceptance test still expected target_unsupported. It now expects inspect_artifact available, inventories the bundle by path in the resource session, and still expects the target-less call refused.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #14159 (owner decision: path-based inspection with a content-addressed directory identity).
Draft until #14247 (the first
TargetFailurePR from #14239) lands; see "Sequencing" below.Behavior
inspect_artifacttakes an optional absolutepathand inspects it without the open session target and withoutopen_binary. A directory is inventoried in place; any other path is admitted as a target in its own artifact-only session that closes before the call returns. Omittingpathkeeps inspecting the open target.inspect_artifactno longer requires an open target in the capability inventory.rea inspect-artifact <dir>inventories the directory directly.compare_artifacts/rea compare-artifactsaccept{"kind":"path","path":"/abs","integrity_policy"?}on either side, besides Evidence, retained references and Evidence files. CLI path sources resolve relative to the working directory.open_binaryis unchanged; fix(javascript): route directories by JavaScript input presence and name directory-capable operations #14186'sdirectory_requires_filestill refuses ordinary directories for native analysis.{"kind":"directory","algorithm":"rea-directory-tree","version":1,"sha256":<root digest>}with the usualnameandlocal_pathdisplay facts. The inventory carries the same fact asroot_digest(withmember_count), and the root node'ssha256is the root digest.root_digestis{"status":"partial","limitations":[...]}with no digest, and the Evidence subject is{"kind":"unknown","reason":"not-observed"}. A partial digest is never presented as the identity.link_target({text, hex}) on their occurrence;compare_artifactscompares two recorded targets instead of reporting the link as unavailable. Their limitation reads "Symlink target was recorded, not followed."Design notes
Owner.
src/domain/directoryTreeDigest.tsowns the encoding;scanReaderfeeds it from the rootDirectoryArtifactReaderwalk it already performs (no second walker), only for the root directory's own members (members of an expanded ASAR inside the directory are not tree members; the ASAR file is).artifactInventorySubjectinartifactInventoryEvidence.tsis the one projection of an inventory root to its subject, andvalidateArtifactInventorySubjectchecks against the same rule.EvidenceSubjectTargetgains an optionaltree(algorithm, version);evidenceSubjectTargetIdentityis the single place that turns it into adirectoryidentity.Encoding (version 1). SHA-256 over:
Paths are root-relative and join each name's exact stored bytes with
/(strict UTF-8 names only; never Unicode-normalized); records sort by path bytes (= code point order). Every directory has a record, so empty subdirectories count; the empty root is the header with count 0 (b28a57a5…91b3b6, independently checked withprintf | shasum -a 256).Rationale and sources.
mode name NUL digestentries. Git keeps the executable bit and drops empty directories. REA drops mode, owner and times, because some hosts (Windows) cannot observe POSIX execute bits and the identity must be the same across hosts; the executable marking stays on occurrences and in comparisons. REA keeps empty directories so an added empty directory changes the identity.dirhash.Hash1: sortedsha256hex name\nlines, which forces it to disallow names containing newlines. Length-prefixed fields need no such refusal.éon Linux) one path, so trees differing only by swapping their contents would share an identity (review thread). Occurrences keep NFC logical paths for display; the identity uses stored bytes.Flat rather than per-subdirectory Merkle: the inventory is already a flat occurrence list and no workflow reuses subtree digests; a future subtree encoding gets a new
version. Reference doc:docs/reference/directory-identity.md.Sequencing with #14239
#14247 (
TargetFailure) is still open, so this PR adds no new failure types or sites. The failure paths reuse existing owners: a path that is not a directory goes through target admission (FIFO roots, missing paths and so on keep their current refusals); a change during the walk keeps the directory reader's existing integrity failures; a limit stop is not a failure but a partialroot_digest. The comparison's "this adapter cannot inventory a path source" refusal is an input refusal. When #14247 lands I will rebase and raise the directory-route admission refusals throughTargetFailureif the owner wants them distinct from the target-admission ones.Validation
src/domain/directoryTreeDigest.test.ts): documented byte encoding reproduced independently; empty-directory golden; walk-order independence; UTF-8/code-point ordering (U+FF61 vs U+1F600); sensitivity to a content byte, a name, a kind, a symlink target, an added and a removed member; injective fields; non-normalized paths refused; partial builder has nosha256.src/artifacts/inventory/DirectoryRootDigest.test.ts) on real temp trees: same digest at different locations, creation orders, mtimes and modes; one-byte change; empty directory; symlink target recorded and not followed (outside content change keeps the digest, retarget changes it); FIFO recorded by kind; entry-limit stop is partial with no digest and unknown coverage.tests/boundary/cli/directoryArtifactComparison.test.ts), the issue's scenario as two generated build folders (two PE-shaped executables, four SPIR-V modules and a synthetic DXBC; B drops one exe, adds one, flips one SPIR-V byte, adds a data file): CLIinspect-artifact <dir>subject; CLIcompare-artifactswith path sources gives.,shaders,shaders/b.spvchanged,editor.exe,data.pakadded,tool.exeremoved, the same classifications as the zipped workaround; MCPinspect_artifact {path}withoutopen_binarygives the same identity as the CLI, and path-source and retained-evidence comparisons agree.incompletecall fails the partial-walk test; dropping the symlink target from the encoding fails the golden, the symlink-sensitivity and the not-followed tests.tests/boundary/filesystem/directoryArtifactReaderOpen.test.ts > rejects entries that are not files, which fails identically onmain(expectsformat, the reader throwspathsince fix(errors)!: split reader path refusals from malformed target bytes #14225).verify:advertised-schemas -- --update-summary(inspect_artifact input changed), architecture guards, oxfmt, oxlint on changed files; compile (tsc -p tsconfig.build.jsonviabuild:cached) passes.rea inspect-artifact <dir> --detail summary --evidence_output …: complete digest,member_count6045; 2.30 s / 2.34 s wall (two warm runs; 2.4 s user, 0.9 s sys), peak RSS ~0.52 GB, which includes reading and hashing every byte for the inventory and writing a 12.9 MB bundle. The tree encoding itself was not measured separately. No token measurement.Remaining cleanup (not in this PR)
audit_release_exposureandinspect_desktop_applicationstill name directories with file-kind subjects offormat: "directory"(release exposure usesmanifest.root_sha256, which for a partial walk is a listing commitment, not an identity; desktop uses its examined-range snapshot). Moving them to the directory kind changes those tools' report contracts and the desktop owner's work ([Feature] inspect-desktop-application: recognise native (Qt/SDL/Win32) desktop releases instead of returning only file metadata #14173/[Bug] inspect-desktop-application: Godot candidates get no probe, and self-contained .NET games bury the app among 180+ BCL probes #14179), so it is left for a follow-up.extract_artifacton an Apple bundle still records a file-kinddirectorysubject because its result carries noroot_digest.