mirror of
https://github.com/morluto/rea.git
synced 2026-10-26 17:35:11 +00:00
refactor(workflows): share source caveat grouping identity
This commit is contained in:
1 parent
7439d0d5d8
commit
5e581fd3b1
2 files changed
+10
-12
No files matched your search
@@ -25,6 +25,13 @@ export const sourceLimitationKey = ({
|
||||
limitation,
|
||||
]);
|
||||
|
||||
/** Provider/text identity shared by rendering and composed-workflow budgets. */
|
||||
export const sourceLimitationGroupKey = ({
|
||||
provider,
|
||||
limitation,
|
||||
}: Pick<SourceLimitation, "provider" | "limitation">): string =>
|
||||
JSON.stringify([provider.id, provider.name, provider.version, limitation]);
|
||||
|
||||
/** Render unique source caveats without losing their provider or operation. */
|
||||
export const renderSourceLimitations = (
|
||||
limitations: readonly SourceLimitation[],
|
||||
@@ -38,12 +45,7 @@ export const renderSourceLimitations = (
|
||||
}
|
||||
>();
|
||||
for (const { provider, operation, limitation } of limitations) {
|
||||
const key = JSON.stringify([
|
||||
provider.id,
|
||||
provider.name,
|
||||
provider.version,
|
||||
limitation,
|
||||
]);
|
||||
const key = sourceLimitationGroupKey({ provider, limitation });
|
||||
const group = groups.get(key) ?? {
|
||||
provider,
|
||||
limitation,
|
||||
|
||||
@@ -26,6 +26,7 @@ import { UnknownRegistryError } from "../domain/unknownRegistryError.js";
|
||||
import { workflowUnknownInput } from "./investigation/WorkflowUnknown.js";
|
||||
import {
|
||||
renderSourceLimitations,
|
||||
sourceLimitationGroupKey,
|
||||
sourceLimitationKey,
|
||||
type SourceLimitation,
|
||||
} from "./SourceLimitations.js";
|
||||
@@ -110,12 +111,7 @@ export const executeComposedWorkflow = async (
|
||||
omittedObservations += 1;
|
||||
continue;
|
||||
}
|
||||
const group = JSON.stringify([
|
||||
fact.provider.id,
|
||||
fact.provider.name,
|
||||
fact.provider.version,
|
||||
limitation,
|
||||
]);
|
||||
const group = sourceLimitationGroupKey(fact);
|
||||
if (!perItemGroups.has(group)) {
|
||||
if (
|
||||
perItemGroups.size >= budget.maxDistinct ||
|
||||
|
||||
Reference in new issue
Block a user