Repository navigation
refactor(domain): compare snapshot targets through one target identity key - #11341
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. |
[Medium impact] The PR appears safe to merge, with no outstanding actionable findings. SummarySnapshot comparisons now share
Reviews (4) · Last reviewed commit: "fix(domain): refuse snapshot targets who..." · Reviewed by Greptile |
|
@greptileai please review the latest commit (8e90b81), which addresses the kind/format finding. |
Summary
Slice 1 of the accepted target-identity ADR (
docs/adr/evidence/target-identity.md): addssrc/domain/targetIdentity.tswith a taggedTargetIdentity(thefilekind for now) andtargetIdentityKey, an RFC 8785 canonical digest. Snapshot target comparison now goes through that key only. No Evidence ID, snapshot format or query ID changes. Refs #10510.Problem and expected behavior
Target comparison for analysis snapshots had two implementations: a field-by-field
snapshotMatchesTargetand aJSON.stringifycompare inAnalysisSnapshotCache.stage, which depends on member order. Both compare the same facts. They should use one comparison owned by the domain.Change and scope
src/domain/targetIdentity.ts:FileTargetIdentity(sha256,format,architecture,selection),FileTargetSelection(entry-pointfor raw and DOL targets,esp-flashfor ESP flash offsets),targetIdentityKeyandsameTargetIdentity.src/domain/analysisSnapshot.ts:snapshotTargetIdentityprojects the persisted snapshot target into the identity.snapshotMatchesTargetcompares keys instead of fields.AnalysisSnapshotCache.stagecompares keys instead ofJSON.stringifyoutput.BINARY_TARGET_FORMAT_KINDS(src/domain/binaryTargetTypes.ts) owns each format's single kind, type-checked against everyBinaryTargetvariant. The snapshot target schema refuses a kind its format cannot have: query IDs commit to the kind, so such a header would stage entries no lookup or export can reach (Greptile finding).BinaryTargetResolver's archive check reads the map instead of its own format list.url,process,sessionandunknownkinds;sameEvidenceSubjectTargetIdentityinevidence.ts, which compares Evidence subjects and is replaced in slice 2;BinaryTargetResolveralready hashes through the shared stable file hasher (hashStableRegularFileDescriptor) on main, so that part of the slice needs no change.Contract and boundary impact
src/domain/targetIdentity.ts(new);snapshotTargetIdentityinsrc/domain/analysisSnapshot.ts.kindis no longer compared on its own. Every format has exactly one kind, and the snapshot schema now enforces it. A snapshot whose target kind disagrees with its format is refused at parse; no REA producer writes one.Expected effects:
Evidence and regression coverage
analysisSnapshot.test.ts"refuses a snapshot target whose kind its format cannot have";src/domain/targetIdentity.test.ts. The key ignores member order (two spellings whoseJSON.stringifyoutput differs get the same key). The same bytes with a different raw entry point or ESP flash offset are different targets. The path is display only, not identity.analysisSnapshot.test.ts(raw entry partitioning, foreign target),AnalysisSnapshotCache.test.ts.JSON.stringifycompare has no reproducible failure today, because zod's parsed member order matchessnapshotTarget's construction order. This change removes the order dependence; it does not fix an observed bug.For evidence-bearing changes:
Validation performed
npm run check:fast: passed (typecheck, lint, architecture guards)npm run test:focused -- src/domain/targetIdentity.test.ts src/domain/analysisSnapshot.test.ts src/application/binary/AnalysisSnapshotCache.test.ts src/application/binary/TargetFormatVocabularies.test.ts: 4 files, 107 passed (after the kind fix)npm run test:focused --the 8 test files importingBinaryTargetResolver(IdaWorkspaceThinning, GhidraDolLoadImage, GhidraDolProfile, BinarySessionBundleResources, LazyAnalysisProvider, auxiliaryDeclarations, managedMemberComparison, managedNativeOsMachine): 99 passedCompatibility, safety, and release
Author readiness
Human owner:
Before merge
type(scope): outcome.