mirror of
https://github.com/morluto/rea.git
synced 2026-12-04 05:51:06 +00:00
refactor(evidence): tally changed-behavior findings once (#16491)
This commit is contained in:
1 parent
66a670a6c4
commit
53051663d3
1 file changed
+8
-11
@@ -12,6 +12,7 @@ import {
|
||||
} from "./comparisonEvidenceResult.js";
|
||||
import type { ComparisonEvidenceOperation } from "./comparisonEvidenceIdentity.js";
|
||||
import type { Evidence } from "./evidence.js";
|
||||
import { incrementCount } from "./valueCounts.js";
|
||||
import { evidenceInputSchema } from "./evidenceReference.js";
|
||||
import { err, ok, type Result } from "./result.js";
|
||||
import type { AnalysisInputError } from "./analysisErrorCore.js";
|
||||
@@ -170,13 +171,16 @@ export const findChangedBehavior = (input: unknown): FoundChangedBehavior => {
|
||||
...item.evidence_links,
|
||||
]),
|
||||
);
|
||||
const counts = new Map<Finding["classification"], number>();
|
||||
for (const finding of findings)
|
||||
incrementCount(counts, finding.classification);
|
||||
const result = changedBehaviorResultSchema.parse({
|
||||
behavior_status: behaviorStatus(runtimeStatuses),
|
||||
summary: {
|
||||
observed_changes: count(findings, "observed_change"),
|
||||
static_candidates: count(findings, "derived_relationship"),
|
||||
contradictions: count(findings, "contradiction"),
|
||||
unresolved: count(findings, "unresolved_branch"),
|
||||
observed_changes: counts.get("observed_change") ?? 0,
|
||||
static_candidates: counts.get("derived_relationship") ?? 0,
|
||||
contradictions: counts.get("contradiction") ?? 0,
|
||||
unresolved: counts.get("unresolved_branch") ?? 0,
|
||||
},
|
||||
findings: {
|
||||
items: findings,
|
||||
@@ -419,13 +423,6 @@ const behaviorStatus = (
|
||||
const isChange = (status: RuntimeStatus): boolean =>
|
||||
status === "added" || status === "removed" || status === "changed";
|
||||
|
||||
const count = (
|
||||
findings: readonly Finding[],
|
||||
classification: Finding["classification"],
|
||||
): number =>
|
||||
findings.filter((finding) => finding.classification === classification)
|
||||
.length;
|
||||
|
||||
const compareFindings = (left: Finding, right: Finding): number =>
|
||||
compareUnicodeCodePoints(
|
||||
compositeKey([left.scope, left.dimension, left.source_comparison_id]),
|
||||
|
||||
Reference in new issue
Block a user