mirror of
https://github.com/morluto/rea
synced 2026-10-27 06:33:32 -04:00
76b56957e9
Reuse validated class pages for inline pagination audits while retaining complete provider replies. Move retention into the shared Android workflow and remove the MCP-only service wrapper and application text reparser. Preserve unknown JSON metadata, late cancellation and retention failures.
48 lines
1.8 KiB
TypeScript
48 lines
1.8 KiB
TypeScript
import type { EvidenceWriter } from "../investigation/InvestigationRecordPort.js";
|
|
import { createEvidence, type Evidence } from "../../domain/evidence.js";
|
|
import type { AnalysisError } from "../../domain/analysisErrorBase.js";
|
|
import type { JsonValue } from "../../domain/jsonValue.js";
|
|
import { ok, type Result } from "../../domain/result.js";
|
|
|
|
/**
|
|
* Retain the complete search Evidence — full raw provider calls included —
|
|
* in the session record, then deliver a bounded summary Evidence inline.
|
|
* Callers without a retaining session receive complete source Evidence inline.
|
|
* Both copies preserve examined inventory ranges separately from matching rows.
|
|
*/
|
|
export const summarizeRetainedAndroidSearch = (
|
|
evidence: Evidence,
|
|
summary: Readonly<Record<string, JsonValue>>,
|
|
recordEvidence: EvidenceWriter["recordEvidence"] | undefined,
|
|
): Result<Evidence, AnalysisError> => {
|
|
if (recordEvidence === undefined) return ok(evidence);
|
|
const recorded = recordEvidence(evidence);
|
|
if (!recorded.ok) return recorded;
|
|
const subject = evidence.subject;
|
|
return ok(
|
|
createEvidence(
|
|
subject === null
|
|
? undefined
|
|
: {
|
|
path: subject.local_path,
|
|
sha256: subject.digest.sha256,
|
|
format: subject.format,
|
|
...(subject.architecture === null
|
|
? {}
|
|
: { architecture: subject.architecture }),
|
|
},
|
|
evidence.provider,
|
|
{
|
|
operation: evidence.operation,
|
|
parameters: evidence.parameters,
|
|
result: evidence.normalized_result,
|
|
rawResult: { ...summary, complete_evidence_id: evidence.evidence_id },
|
|
confidence: evidence.confidence,
|
|
limitations: evidence.limitations,
|
|
locations: evidence.locations,
|
|
evidenceLinks: [evidence.evidence_id],
|
|
},
|
|
),
|
|
);
|
|
};
|