mirror of
https://github.com/morluto/rea.git
synced 2026-11-16 11:43:20 +00:00
feat(snapshots)!: persist the target identity as the snapshot target (#11551)
* feat(snapshots)!: persist the target identity as the snapshot target
The snapshot target is now `{ kind, identity }`, where `identity` is the
FileTargetIdentity that `binaryTargetIdentity` produces and `kind` is the
binary kind query IDs commit to. The per-format target projection and
`snapshotTargetIdentity` are deleted; the schema checks the format's
selection, architecture and kind instead of keeping one union arm per format.
Entry execution subjects use the Evidence subject shape (file or explicit
unknown), so a snapshot entry commits to the same identity, including the
selection, as its Evidence record. Workflow entries take the subject of the
workflow's own Evidence. Replay no longer re-derives the selection from the
open target.
`FileTargetSelection` gains `universal-slice` (`offset`, `size`, and the FAT
`cpu_type`/`cpu_subtype` when target admission supplied the FAT table, else
null). `binaryTargetIdentity` produces it for `mach-o-universal` targets, so
Evidence and snapshots for different slices of one container no longer share
an identity.
Refs #11417
BREAKING CHANGE: analysis snapshot files change shape: `target` is
`{ kind, identity: { kind: "file", sha256, format, architecture, selection } }`
and entry `execution.subject` is the Evidence subject
(`{ identity, name, local_path }`, never null). Snapshot binding mismatch
details report `target.snapshot`/`target.selected` in the same shape. Evidence
IDs of universal Mach-O targets change because their subject identity now
carries the selected slice. Recreate saved snapshots and Evidence bundles of
universal Mach-O targets.
* docs(evidence): name the universal Mach-O slice selection in the subject contract
* fix(snapshots): read the snapshot target identity in the Ghidra verification scripts
The real Ghidra snapshot checks (lifecycle, RISC-V, MIPS, PowerPC) read
snapshot.target.sha256 and .architecture, which moved under
snapshot.target.identity, so they would fail after saving a valid snapshot.
* feat(evidence)!: name live browser page Evidence by its page URL (#11559)
Browser page observations (inspect_web_page, analyze_web_bundle,
observe_web_session, discover_webmcp_tools, capture_web_screenshot,
observe_web_execution, inspect_web_event_listeners) named an unknown
(`not-observed`) subject although the provider reports the page URL.
`TargetIdentity` gains a `url` kind: the reported URL with userinfo removed
and its origin (`null` for an opaque origin). The schema refuses a URL that
carries userinfo or an origin the URL does not have.
`browserUrlTargetIdentity` in the browser URL owner builds it from the
provider's reported URL; a withheld or unparseable URL stays unknown
(`not-observed`). Target lists and comparisons still name no single
document. Analysis views keep their parent's URL subject, as they already
keep a file subject.
BREAKING CHANGE: Evidence IDs of live browser page observations and their
analysis views change, and their subject is
`{ "kind": "url", "url", "origin" }` with `name` and `local_path` null.
Recreate stored Evidence for these tools. This lands inside Evidence format
revision 2 under the release hold (#11417); no `evidence_format` bump.
This commit is contained in:
1 parent
f6df353002
commit
ff0176256a
30 files changed
+678
-396
No files matched your search
@@ -8,8 +8,13 @@ import {
|
||||
ANALYSIS_SNAPSHOT_PROFILE,
|
||||
ANALYSIS_SNAPSHOT_PROVIDER,
|
||||
ANALYSIS_SNAPSHOT_TARGET,
|
||||
snapshotExecution,
|
||||
} from "../../domain/analysisSnapshot.fixture.js";
|
||||
import { createEvidence, immutableEvidence } from "../../domain/evidence.js";
|
||||
import {
|
||||
createEvidence,
|
||||
evidenceSubject,
|
||||
immutableEvidence,
|
||||
} from "../../domain/evidence.js";
|
||||
import { createAnalysisExecutionEvidence } from "../../domain/analysisObservation.js";
|
||||
import {
|
||||
createEvidenceBundle,
|
||||
@@ -37,6 +42,7 @@ import {
|
||||
isSourceEvidenceRetainable,
|
||||
} from "./AnalysisSnapshotCache.js";
|
||||
import { EvidenceLedger } from "../investigation/EvidenceLedger.js";
|
||||
|
||||
import { nativeCallGraphSchema } from "../../domain/native/nativeCallGraph.js";
|
||||
|
||||
it.each(["provider", "workflow"] as const)(
|
||||
@@ -73,7 +79,11 @@ it.each(["provider", "workflow"] as const)(
|
||||
execution: { ...execution, analysisProfile },
|
||||
};
|
||||
if (kind === "provider") cache.record(input);
|
||||
else cache.recordWorkflow(input);
|
||||
else
|
||||
cache.recordWorkflow({
|
||||
...input,
|
||||
execution: snapshotExecution(input.execution),
|
||||
});
|
||||
const entries = () =>
|
||||
kind === "provider" ? cache.entries() : cache.workflowEntries();
|
||||
const expected = entries();
|
||||
@@ -123,10 +133,12 @@ it("exports independent nested query, workflow and Evidence payloads", () => {
|
||||
operation: "analyze_function",
|
||||
parameters,
|
||||
execution: {
|
||||
...createAnalysisExecution(result, REA_WORKFLOW_PROVIDER, {
|
||||
subject: target,
|
||||
rawResult: result,
|
||||
}),
|
||||
...snapshotExecution(
|
||||
createAnalysisExecution(result, REA_WORKFLOW_PROVIDER, {
|
||||
subject: target,
|
||||
rawResult: result,
|
||||
}),
|
||||
),
|
||||
analysisProfile: workflowProfile,
|
||||
},
|
||||
});
|
||||
@@ -226,7 +238,10 @@ it.each(["provider", "workflow"] as const)(
|
||||
profile,
|
||||
operation,
|
||||
parameters,
|
||||
execution: { ...execution, analysisProfile: evidenceProfile },
|
||||
execution: snapshotExecution({
|
||||
...execution,
|
||||
analysisProfile: evidenceProfile,
|
||||
}),
|
||||
});
|
||||
expect(ledger.record(evidence).ok).toBe(true);
|
||||
const before = cache.export(target, profile, ledger.export());
|
||||
@@ -285,14 +300,14 @@ it.each(["provider", "workflow"] as const)(
|
||||
if (!after.ok) throw after.error;
|
||||
const entries =
|
||||
kind === "provider" ? after.value.entries : after.value.workflow_entries;
|
||||
expect(entries[0]?.execution.subject?.path).toBe("/relocated/fixture");
|
||||
expect(entries[0]?.execution.subject.local_path).toBe("/relocated/fixture");
|
||||
expect(entries[0]?.execution.result).toBe("original");
|
||||
expect(after.value.evidence_bundle.records).toContainEqual(relocated);
|
||||
const originalEntries =
|
||||
kind === "provider"
|
||||
? before.value.entries
|
||||
: before.value.workflow_entries;
|
||||
expect(originalEntries[0]?.execution.subject?.path).toBe(target.path);
|
||||
expect(originalEntries[0]?.execution.subject.local_path).toBe(target.path);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -327,7 +342,11 @@ it.each(["provider", "workflow"] as const)(
|
||||
};
|
||||
if (kind === "provider")
|
||||
cache.record({ ...input, operation: "procedure_info" });
|
||||
else cache.recordWorkflow(input);
|
||||
else
|
||||
cache.recordWorkflow({
|
||||
...input,
|
||||
execution: snapshotExecution(input.execution),
|
||||
});
|
||||
expect(
|
||||
ledger.record(
|
||||
createEvidence(subject ?? unknownTarget("not-observed"), provider, {
|
||||
@@ -356,7 +375,9 @@ it.each(["provider", "workflow"] as const)(
|
||||
const saved =
|
||||
kind === "provider" ? snapshot.entries : snapshot.workflow_entries;
|
||||
expect(saved).toHaveLength(1);
|
||||
expect(saved[0]?.execution.subject?.sha256).toBe(target.sha256);
|
||||
expect(saved[0]?.execution.subject.identity).toMatchObject({
|
||||
sha256: target.sha256,
|
||||
});
|
||||
expect(snapshot.evidence_bundle.records).toHaveLength(1);
|
||||
expect(
|
||||
kind === "provider" ? cache.entries() : cache.workflowEntries(),
|
||||
@@ -402,9 +423,11 @@ it("counts newly retained direct and workflow bindings when staging", () => {
|
||||
operation: "trace_feature",
|
||||
parameters: { query: "feature" },
|
||||
execution: {
|
||||
...createAnalysisExecution("workflow", REA_WORKFLOW_PROVIDER, {
|
||||
subject: target,
|
||||
}),
|
||||
...snapshotExecution(
|
||||
createAnalysisExecution("workflow", REA_WORKFLOW_PROVIDER, {
|
||||
subject: target,
|
||||
}),
|
||||
),
|
||||
analysisProfile: workflowProfile,
|
||||
},
|
||||
});
|
||||
@@ -532,11 +555,13 @@ it("binds an omitted subject to the selected target in snapshot replay", () => {
|
||||
]),
|
||||
);
|
||||
if (!snapshot.ok) throw snapshot.error;
|
||||
expect(snapshot.value.entries[0]?.execution.subject?.path).toBe(target.path);
|
||||
expect(snapshot.value.entries[0]?.execution.subject.local_path).toBe(
|
||||
target.path,
|
||||
);
|
||||
const reparsed = parseAnalysisSnapshot(
|
||||
JSON.parse(serializeAnalysisSnapshot(snapshot.value)),
|
||||
);
|
||||
expect(reparsed.entries[0]?.execution.subject?.path).toBe(target.path);
|
||||
expect(reparsed.entries[0]?.execution.subject.local_path).toBe(target.path);
|
||||
cache.clear();
|
||||
const imported = cache.import(
|
||||
reparsed,
|
||||
@@ -583,9 +608,11 @@ describe("analysis snapshot cache capacity", () => {
|
||||
const target = ANALYSIS_SNAPSHOT_TARGET;
|
||||
const profile = ANALYSIS_SNAPSHOT_PROFILE;
|
||||
const execution = {
|
||||
...createAnalysisExecution("workflow", REA_WORKFLOW_PROVIDER, {
|
||||
subject: target,
|
||||
}),
|
||||
...snapshotExecution(
|
||||
createAnalysisExecution("workflow", REA_WORKFLOW_PROVIDER, {
|
||||
subject: target,
|
||||
}),
|
||||
),
|
||||
analysisProfile: workflowAnalysisProfile(profile),
|
||||
};
|
||||
const workflowInput = {
|
||||
@@ -673,7 +700,7 @@ describe("analysis snapshot cache capacity", () => {
|
||||
cache.recordWorkflow({
|
||||
...workflowInput,
|
||||
target: otherTarget,
|
||||
execution: { ...execution, subject: otherTarget },
|
||||
execution: { ...execution, subject: evidenceSubject(otherTarget) },
|
||||
});
|
||||
expect(cache.entries()).toEqual([]);
|
||||
expect(cache.workflowEntries()).toHaveLength(1);
|
||||
@@ -1233,10 +1260,12 @@ it.each([
|
||||
operation,
|
||||
parameters,
|
||||
execution: {
|
||||
...createAnalysisExecution(oldResult, REA_WORKFLOW_PROVIDER, {
|
||||
subject: target,
|
||||
rawResult: oldResult,
|
||||
}),
|
||||
...snapshotExecution(
|
||||
createAnalysisExecution(oldResult, REA_WORKFLOW_PROVIDER, {
|
||||
subject: target,
|
||||
rawResult: oldResult,
|
||||
}),
|
||||
),
|
||||
analysisProfile: oldProfile,
|
||||
},
|
||||
});
|
||||
@@ -1316,9 +1345,11 @@ it.each([1, 2])(
|
||||
limitations: [],
|
||||
};
|
||||
const execution = {
|
||||
...createAnalysisExecution(oldResult, REA_WORKFLOW_PROVIDER, {
|
||||
subject: target,
|
||||
}),
|
||||
...snapshotExecution(
|
||||
createAnalysisExecution(oldResult, REA_WORKFLOW_PROVIDER, {
|
||||
subject: target,
|
||||
}),
|
||||
),
|
||||
analysisProfile: oldProfile,
|
||||
};
|
||||
cache.recordWorkflow({ target, profile, operation, parameters, execution });
|
||||
|
||||
Reference in new issue
Block a user