From 3e2560349674b3753769b4d11d5d96e6fcac4e95 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Wed, 2 Dec 2026 12:00:36 +0800 Subject: [PATCH] refactor(errors): share top-level projection options (#15768) --- src/domain/analysisErrorProjection.ts | 46 +++++++++++---------------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/src/domain/analysisErrorProjection.ts b/src/domain/analysisErrorProjection.ts index 7bbc8477c54..a03c72f9f92 100644 --- a/src/domain/analysisErrorProjection.ts +++ b/src/domain/analysisErrorProjection.ts @@ -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";