Repository navigation
perf(artifacts): share sealed inventory and report in inspect_artifact - #2690
Merged
Merged
Conversation
inspect_artifact parsed a fresh inventory and inspection report but left both mutable, so each later Evidence boundary cloned and re-digested the complete payload: createArtifactInspection re-authenticated the nested inventory Evidence, createAnalysisExecution re-parsed the report, and recordEvidence re-authenticated the outer Evidence. Seal both exclusively owned values with freezeJsonSnapshot so those boundaries take the existing immutable-snapshot path. Output is byte-identical. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis 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. |
Contributor
|
…ion-sealed-inventory
This was referenced Oct 13, 2026
…ion-sealed-inventory
…ion-sealed-inventory
…ion-sealed-inventory
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.
Problem
inspect_artifacton a large bundle spent much of its CPU re-validating and re-digesting the same payload. On Keynote.app the payload is a 42 MB inventory. A CPU profile ofrea inspect-artifact /Applications/Keynote.appshowed it being canonically digested into an Evidence ID about four times and zod-parsed about five times:createArtifactInspection→parseEvidencecreateAnalysisExecution→jsonValueSchema.parsecreateEvidencerecordEvidence→immutableEvidence→parseEvidenceRoot cause
inspectArtifactowns two freshly parsed values: the inventory and the inspection report. It left both mutable. The Evidence layer already has a zero-copy path for sealed immutable JSON snapshots (freezeJsonSnapshot/immutableEvidenceSnapshots), but these values never qualified for it.Fix
Seal both exclusively owned values with
freezeJsonSnapshotat the point where they're produced. Each downstream boundary then uses the existing immutable path: nestedcreateEvidenceremembers the record,parseEvidencehits the snapshot cache,jsonValueSchema.parsereturns the sealed report as-is, and the outer Evidence is shared and recorded without re-authentication. No contract or output changes.Measurements
These are warm runs, three each, on an Apple Silicon Mac, measured with
/usr/bin/time -laroundrea inspect-artifact <app> --format json. Main and the branch were built from the same base.On Keynote that is about 15% less wall time, 17% less user CPU and 19% less peak RSS. Token cost is unchanged: stdout is byte-identical before and after on Keynote and Sublime Text (same SHA-256). Cold-cache runs and the MCP adapter were not measured separately; both share this provider path.
Validation
npm run test:focusedon every test file that referencesinspect_artifact/createArtifactInspection(22 files: CLI, MCP, sessions, composition, acceptance, conformance): 138 passed. This shows no downstream consumer mutates the now-sealed report.npm run check:fastpasses.Remaining
createArtifactInspectionstill re-parses the inventory withartifactInventoryResultSchema, and its finalartifactInspectionResultSchema.parsetraverses the nested Evidence once more (about 0.25 s on Keynote). Removing those would mean changing what the domain function'sunknowninput contract validates, so it's left out of this change.🤖 Generated with Claude Code