mirror of
https://github.com/morluto/rea.git
synced 2026-11-22 22:45:47 +00:00
fix(evidence): keep unobserved correlation paths unknown without complete coverage
A path neither source inventory observed proves a malformed selector only when the comparison covered every member. With incomplete coverage the selector may name a member the comparison never reached, so report it as an unresolved branch instead of refusing the whole correlation. Refs #13211 Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
This commit is contained in:
1 parent
a486423e0e
commit
94232d0d5f
2 files changed
+74
-3
No files matched your search
@@ -287,7 +287,8 @@ export type UnreportedArtifactPathClassifier = (
|
||||
* number of paths it omitted from `changes`. Only a path observed once on each
|
||||
* side of a fully covered comparison is unchanged; this matches the paths
|
||||
* counted in `summary.unchanged`. A path neither inventory observed is not
|
||||
* evidence of equality.
|
||||
* evidence of equality: it is unobserved under complete coverage and unknown
|
||||
* otherwise.
|
||||
*/
|
||||
export const prepareUnreportedArtifactPaths = (
|
||||
result: ArtifactComparisonResult,
|
||||
@@ -306,11 +307,19 @@ export const prepareUnreportedArtifactPaths = (
|
||||
const leftByPath = occurrencesByPath(left.occurrences);
|
||||
const rightByPath = occurrencesByPath(right.occurrences);
|
||||
return (logicalPath) => {
|
||||
// The index holds only observed paths; absence on both sides is unobserved.
|
||||
// The index holds only observed paths. Absence on both sides proves the
|
||||
// selector names no compared member only when coverage is complete;
|
||||
// otherwise the path may lie where the comparison never reached.
|
||||
const leftMatches = leftByPath.get(logicalPath);
|
||||
const rightMatches = rightByPath.get(logicalPath);
|
||||
if (leftMatches === undefined && rightMatches === undefined)
|
||||
return { status: "unobserved" };
|
||||
return fullyCovered
|
||||
? { status: "unobserved" }
|
||||
: {
|
||||
status: "unknown",
|
||||
limitation:
|
||||
"The selected artifact path was not observed in either inventory, and the comparison does not have complete coverage; it may name a member the comparison never reached.",
|
||||
};
|
||||
if (fullyCovered && leftMatches?.length === 1 && rightMatches?.length === 1)
|
||||
return { status: "unchanged" };
|
||||
return {
|
||||
|
||||
@@ -817,3 +817,65 @@ describe("prepared unreported artifact paths", () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("unobserved artifact paths", () => {
|
||||
it("keeps a path neither inventory observed unknown without complete coverage", () => {
|
||||
const partial = createEvidence(
|
||||
evidenceSubjectInput(artifactLeft.subject),
|
||||
artifactLeft.provider,
|
||||
{
|
||||
operation: artifactLeft.operation,
|
||||
parameters: artifactLeft.parameters,
|
||||
result: {
|
||||
...artifactInventoryResultSchema.parse(
|
||||
artifactLeft.normalized_result,
|
||||
),
|
||||
coverage: { scope: "root", status: "unknown" },
|
||||
},
|
||||
confidence: artifactLeft.confidence,
|
||||
authority: artifactLeft.authority,
|
||||
},
|
||||
);
|
||||
const comparison = createEvidence(
|
||||
unknownTarget("derived-from-linked-evidence"),
|
||||
ARTIFACT_COMPARISON_PROVIDER,
|
||||
{
|
||||
predicateType: "rea.artifact-comparison",
|
||||
operation: "compare_artifacts",
|
||||
parameters: {
|
||||
left_evidence_ids: [partial.evidence_id],
|
||||
right_evidence_ids: [partial.evidence_id],
|
||||
},
|
||||
result: compareArtifacts(partial, partial),
|
||||
confidence: "derived",
|
||||
authority: "analyst-inference",
|
||||
evidenceLinks: [partial.evidence_id],
|
||||
},
|
||||
);
|
||||
const input = select("never/reached.js");
|
||||
const result = correlateStaticAndRuntime(
|
||||
{
|
||||
...input,
|
||||
static_comparisons: [comparison],
|
||||
mappings: input.mappings.map((item) => ({
|
||||
...item,
|
||||
static: {
|
||||
...item.static,
|
||||
comparison_evidence_id: comparison.evidence_id,
|
||||
},
|
||||
})),
|
||||
},
|
||||
{
|
||||
sourceEvidence: (id) =>
|
||||
id === partial.evidence_id ? partial : undefined,
|
||||
},
|
||||
);
|
||||
expect(result.correlations.items[0]).toMatchObject({
|
||||
static: { status: "unknown", conclusion_kind: "unresolved_branch" },
|
||||
classification: "unresolved_branch",
|
||||
});
|
||||
expect(result.correlations.items[0]?.limitations.join(" ")).toMatch(
|
||||
/not observed in either inventory/u,
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user