Skip to content

armgit / rea

Public Imported from GitHub
0

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

perf(evidence): group repeated caveats with their source operations

morluto1e377e696572
diff --git a/src/application/SourceLimitations.ts b/src/application/SourceLimitations.ts
index f30490af4..5c62cf388 100644
--- a/src/application/SourceLimitations.ts
+++ b/src/application/SourceLimitations.ts
@@ -29,18 +29,34 @@ export const sourceLimitationKey = ({
export const renderSourceLimitations = (
limitations: readonly SourceLimitation[],
): string[] => {
- const rendered = new Map<string, string>();
+ const groups = new Map<
+ string,
+ {
+ readonly provider: ProviderIdentity;
+ readonly limitation: string;
+ readonly operations: Set<AnalysisOperation>;
+ }
+ >();
for (const { provider, operation, limitation } of limitations) {
- const provenance = sourceLimitationKey({
+ const key = JSON.stringify([
+ provider.id,
+ provider.name,
+ provider.version,
+ limitation,
+ ]);
+ const group = groups.get(key) ?? {
provider,
- operation,
limitation,
- });
- const version = provider.version === null ? "" : ` ${provider.version}`;
- rendered.set(
- provenance,
- `${provider.name} (${provider.id}${version}) ${operation}: ${limitation}`,
- );
+ operations: new Set<AnalysisOperation>(),
+ };
+ group.operations.add(operation);
+ groups.set(key, group);
}
- return [...rendered.values()].sort(compareUnicodeCodePoints);
+ return [...groups.values()]
+ .map(({ provider, limitation, operations }) => {
+ const version = provider.version === null ? "" : ` ${provider.version}`;
+ const operationList = [...operations].sort(compareUnicodeCodePoints);
+ return `${provider.name} (${provider.id}${version}) ${operationList.join(", ")}: ${limitation}`;
+ })
+ .sort(compareUnicodeCodePoints);
};
diff --git a/src/application/WorkflowEvidence.test.ts b/src/application/WorkflowEvidence.test.ts
index 7b1859915..d62522fcc 100644
--- a/src/application/WorkflowEvidence.test.ts
+++ b/src/application/WorkflowEvidence.test.ts
@@ -122,10 +122,9 @@ it("retains unique upstream limits in canonical order across concurrent observat
ok({
result: { count: 0 },
limitations: [
+ "Fixture (fixture 1) list_procedures, list_strings: shared",
"Fixture (fixture 1) list_procedures: second",
- "Fixture (fixture 1) list_procedures: shared",
"Fixture (fixture 1) list_strings: first",
- "Fixture (fixture 1) list_strings: shared",
],
}),
);
@@ -158,8 +157,7 @@ it("deduplicates exact source caveats without merging providers or operations",
ok({
result: { count: 0 },
limitations: [
- "First (first 1) list_procedures: same source caveat",
- "First (first 1) list_strings: same source caveat",
+ "First (first 1) list_procedures, list_strings: same source caveat",
"Second (second 1) list_strings: same source caveat",
],
}),
diff --git a/tests/boundary/mcp/enhancedTools.limitations.test.ts b/tests/boundary/mcp/enhancedTools.limitations.test.ts
index 4188f78c6..cc9a21c80 100644
--- a/tests/boundary/mcp/enhancedTools.limitations.test.ts
+++ b/tests/boundary/mcp/enhancedTools.limitations.test.ts
@@ -31,10 +31,7 @@ it("retains provider coverage caveats in a composed MCP overview without repeate
expect(evidence.limitations).toEqual([
"Artifact identity is unavailable for this observation.",
"Derived by an REA composed workflow.",
- `Fixture (fixture 1) current_document: ${limitation}`,
- `Fixture (fixture 1) list_procedures: ${limitation}`,
- `Fixture (fixture 1) list_segments: ${limitation}`,
- `Fixture (fixture 1) list_strings: ${limitation}`,
+ `Fixture (fixture 1) current_document, list_procedures, list_segments, list_strings: ${limitation}`,
]);
expect(evidence.normalized_result).toMatchObject({
document: "fixture",