mirror of
https://github.com/morluto/rea.git
synced 2026-12-04 22:11:12 +00:00
refactor(ledger): reuse evaluation maps for orphan manifest IDs (#15898)
This commit is contained in:
1 parent
8fa5cfd0db
commit
34fa343534
2 files changed
+27
-22
No files matched your search
@@ -37,6 +37,28 @@ describe("reconstruction obligation ledger", () => {
|
||||
expect(first.status).toBe("open");
|
||||
});
|
||||
|
||||
it("reports unknown manifest IDs once in order", () => {
|
||||
const input = readyReviewedLedgerRequest();
|
||||
const [binding] = input.manifest.bindings;
|
||||
if (binding === undefined) throw new Error("Expected a manifest binding");
|
||||
const evidence_ids = input.evidence_bundle.records.map(
|
||||
({ evidence_id }) => evidence_id,
|
||||
);
|
||||
const ledger = build({
|
||||
...input,
|
||||
manifest: {
|
||||
bindings: [binding, { ...binding, obligation_id: "review.z" }],
|
||||
contradictions: [
|
||||
{ obligation_id: "review.z", evidence_ids },
|
||||
{ obligation_id: "review.a", evidence_ids },
|
||||
],
|
||||
},
|
||||
});
|
||||
expect(ledger.limitations).toContain(
|
||||
"Manifest entries reference unknown obligations: review.a, review.z.",
|
||||
);
|
||||
});
|
||||
|
||||
it("merges repeated captures of one process scenario into one definition", () => {
|
||||
const first = processEvidence();
|
||||
const second = processEvidence({
|
||||
|
||||
@@ -79,8 +79,12 @@ export const evaluateReconstructionObligationLedger = ({
|
||||
const candidates = [...candidatesInput].sort((left, right) =>
|
||||
compareUnicodeCodePoints(left.obligation_id, right.obligation_id),
|
||||
);
|
||||
const orphanManifestIds = findOrphanManifestIds(candidates, manifest);
|
||||
const context = createEvaluationContext(candidates, records, manifest);
|
||||
const orphanManifestIds = [
|
||||
...new Set([...context.bindings.keys(), ...context.contradictions.keys()]),
|
||||
]
|
||||
.filter((id) => !context.candidates.has(id))
|
||||
.sort();
|
||||
const obligations = applyDependencyDiagnostics(
|
||||
candidates.map((candidate) => evaluateObligation(candidate, context)),
|
||||
context,
|
||||
@@ -146,27 +150,6 @@ const createEvaluationContext = (
|
||||
contradictions: groupByObligation(manifest.contradictions),
|
||||
});
|
||||
|
||||
const findOrphanManifestIds = (
|
||||
candidates: readonly ReconstructionObligationCandidate[],
|
||||
manifest: ReconstructionObligationManifest,
|
||||
): string[] => {
|
||||
const candidateIds = new Set(
|
||||
candidates.map(({ obligation_id: obligationId }) => obligationId),
|
||||
);
|
||||
return [
|
||||
...new Set(
|
||||
[
|
||||
...manifest.bindings.map(
|
||||
({ obligation_id: obligationId }) => obligationId,
|
||||
),
|
||||
...manifest.contradictions.map(
|
||||
({ obligation_id: obligationId }) => obligationId,
|
||||
),
|
||||
].filter((obligationId) => !candidateIds.has(obligationId)),
|
||||
),
|
||||
].sort();
|
||||
};
|
||||
|
||||
const ledgerLimitations = (
|
||||
generationLimitations: readonly string[],
|
||||
candidateCount: number,
|
||||
|
||||
Reference in new issue
Block a user