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

This commit is contained in:
N0zoM1z0
2026-10-09 18:13:50 +08:00
parent c5c75c38c3
commit 0e779533a9
6 changed files with 60 additions and 3 deletions
+8
View File
@@ -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,
+7 -1
View File
@@ -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;
});
}
@@ -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. */
+22 -1
View File
@@ -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.",
),
}),
]),
),
+7 -1
View File
@@ -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: [] },
});
@@ -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({