Skip to content

armgit / rea

Public Imported from GitHub
0

Reverse engineer anything with agents, from app behavior down to native binaries.

fix(snapshot): report query workflow and Evidence counts separately

N0zoM1z00e779533a910
diff --git a/docs/cli.md b/docs/cli.md
index ae7da8660..e1cc345df 100644
--- a/docs/cli.md
+++ b/docs/cli.md
@@ -109,6 +109,14 @@ cached result. `close_binary` accepts `snapshot_path` and optional
`overwrite: true` to save before releasing provider resources. A failed save
leaves the session open so the caller can resolve the output failure.
+The MCP save receipt reports `primitive_entries`, `workflow_entries`, and
+`evidence_records` separately; the existing `entries` field remains the
+primitive count. Zero primitive bindings can still accompany retained workflow
+results and Evidence. These are cached observations, not a saved provider
+database: only eligible exact queries can reuse a result, and new or live
+queries can still require provider startup. The CLI uses the same snapshot
+format and preserves these records when loading and updating it.
+
## Import, export and compare Evidence
Evidence records retain artifact identity, source locations, observations,
diff --git a/src/application/binary/BinarySession.ts b/src/application/binary/BinarySession.ts
index ddbc24554..b65754075 100644
--- a/src/application/binary/BinarySession.ts
+++ b/src/application/binary/BinarySession.ts
@@ -368,7 +368,13 @@ export class BinarySession
if (!written.ok) return written;
const closed = await this.#closeActive(options);
return closed.ok
- ? ok({ ...written.value, entries: snapshot.value.entries.length })
+ ? ok({
+ ...written.value,
+ entries: snapshot.value.entries.length,
+ primitive_entries: snapshot.value.entries.length,
+ workflow_entries: snapshot.value.workflow_entries?.length ?? 0,
+ evidence_records: snapshot.value.evidence_bundle.records.length,
+ })
: closed;
});
}
diff --git a/src/application/binary/BinarySessionPort.ts b/src/application/binary/BinarySessionPort.ts
index cfee02501..b2f9a24a7 100644
--- a/src/application/binary/BinarySessionPort.ts
+++ b/src/application/binary/BinarySessionPort.ts
@@ -22,6 +22,12 @@ export interface SavedAnalysisSnapshot {
readonly path: string;
readonly bytes: number;
readonly entries: number;
+ /** Eligible primitive query bindings; also reported by the legacy entries field. */
+ readonly primitive_entries: number;
+ /** Eligible composed workflow bindings, separate from primitive queries. */
+ readonly workflow_entries: number;
+ /** All retained Evidence records, including observations without a replay binding. */
+ readonly evidence_records: number;
}
/** Target lifecycle used by CLI and MCP without exposing a concrete provider. */
diff --git a/src/contracts/toolOutputSchemaGroups.ts b/src/contracts/toolOutputSchemaGroups.ts
index a928101ec..adb4af43e 100644
--- a/src/contracts/toolOutputSchemaGroups.ts
+++ b/src/contracts/toolOutputSchemaGroups.ts
@@ -402,7 +402,28 @@ export const sessionOutputSchemas = {
z.object({
path: z.string(),
bytes: z.number().int().min(0),
- entries: z.number().int().min(0),
+ entries: z
+ .number()
+ .int()
+ .min(0)
+ .describe("Legacy primitive query count."),
+ primitive_entries: z
+ .number()
+ .int()
+ .min(0)
+ .describe("Retained eligible primitive query bindings."),
+ workflow_entries: z
+ .number()
+ .int()
+ .min(0)
+ .describe("Retained eligible composed workflow bindings."),
+ evidence_records: z
+ .number()
+ .int()
+ .min(0)
+ .describe(
+ "All retained Evidence records, including observations without replay bindings.",
+ ),
}),
]),
),
diff --git a/tests/boundary/mcp/sessionMcp.test.ts b/tests/boundary/mcp/sessionMcp.test.ts
index 90fadfcf6..dbd5d14b5 100644
--- a/tests/boundary/mcp/sessionMcp.test.ts
+++ b/tests/boundary/mcp/sessionMcp.test.ts
@@ -347,7 +347,13 @@ describe("target-free MCP workflow", () => {
arguments: { snapshot_path: snapshotPath },
}),
).result,
- ).toMatchObject({ path: snapshotPath, entries: 0 });
+ ).toMatchObject({
+ path: snapshotPath,
+ entries: 0,
+ primitive_entries: 0,
+ workflow_entries: 0,
+ evidence_records: 0,
+ });
expect(JSON.parse(await readFile(snapshotPath, "utf8"))).toMatchObject({
evidence_bundle: { records: [], unknowns: [] },
});
diff --git a/tests/boundary/mcp/workflowSnapshotReplayMcp.test.ts b/tests/boundary/mcp/workflowSnapshotReplayMcp.test.ts
index 2a985d61e..f4de2a5aa 100644
--- a/tests/boundary/mcp/workflowSnapshotReplayMcp.test.ts
+++ b/tests/boundary/mcp/workflowSnapshotReplayMcp.test.ts
@@ -89,6 +89,16 @@ describe("MCP composed workflow snapshot replay", () => {
expect(closed.isError, JSON.stringify(closed.content)).not.toBe(true);
const snapshot = await readAnalysisSnapshot(snapshotPath);
if (!snapshot.ok) throw snapshot.error;
+ const receipt = toolContract("close_binary").outputSchema.parse(
+ closed.structuredContent,
+ ).result;
+ expect(receipt).toMatchObject({
+ path: snapshotPath,
+ entries: snapshot.value.entries.length,
+ primitive_entries: snapshot.value.entries.length,
+ workflow_entries: snapshot.value.workflow_entries?.length ?? 0,
+ evidence_records: snapshot.value.evidence_bundle.records.length,
+ });
expect(snapshot.value.workflow_entries).toHaveLength(1);
expect(snapshot.value.evidence_bundle.records).toContainEqual(
expect.objectContaining({