refactor(errors): share top-level projection options (#15768)

This commit is contained in:
Vincent Koc authored and GitHub committed 2026-12-02 04:00:36 +00:00
1 parent 8f8a8539fc
commit 3e25603496
1 file changed
+18 -28
+18 -28
View File
@@ -83,6 +83,21 @@ const relatedInputDetails = (
: { related_providers: [...related.providers] }),
});
const projectTopLevelError = (
error: AnalysisError,
callerLifetime: AnalysisCallerLifetime,
omit?: "captured-output" | "partial-observation",
): AnalysisErrorProjection =>
projectError(
error,
{
capturedOutput: omit !== "captured-output",
partialObservation: omit !== "partial-observation",
secondary: true,
},
callerLifetime,
);
/**
* Project expected failures into exhaustive, secret-safe caller fields. The
* default describes a continuing caller, such as an MCP connection, and is
@@ -93,46 +108,21 @@ const relatedInputDetails = (
export const projectAnalysisError = (
error: AnalysisError,
callerLifetime: AnalysisCallerLifetime = "continuing",
): AnalysisErrorProjection =>
projectError(
error,
{
capturedOutput: true,
partialObservation: true,
secondary: true,
},
callerLifetime,
);
): AnalysisErrorProjection => projectTopLevelError(error, callerLifetime);
/** Cleanup history references output retained by its enclosing error owner. */
export const projectAnalysisErrorWithoutCapturedOutput = (
error: AnalysisError,
callerLifetime: AnalysisCallerLifetime = "continuing",
): AnalysisErrorProjection =>
projectError(
error,
{
capturedOutput: false,
partialObservation: true,
secondary: true,
},
callerLifetime,
);
projectTopLevelError(error, callerLifetime, "captured-output");
/** Bounded fallback when the completed observation itself cannot be delivered. */
export const projectAnalysisErrorWithoutPartialObservation = (
error: AnalysisError,
callerLifetime: AnalysisCallerLifetime = "continuing",
): AnalysisErrorProjection =>
projectError(
error,
{
capturedOutput: true,
partialObservation: false,
secondary: true,
},
callerLifetime,
);
projectTopLevelError(error, callerLifetime, "partial-observation");
export interface UnretainedEvidenceCandidate {
readonly field: "partial_observation" | "completed_observation";