fix(llm): honor a carried failure snapshot on any Error
markLlmAdapterFailure gated the own-`failure` data property on instanceof HarnessError, which drops the validated facts exactly when class identity is lost — two copies of this package in one process (e.g. a source-plane replay harness throwing into a lib-plane boot) make the replay-thrown LlmError's SERVER/AUTH code arrive as UNKNOWN and defeat llm-retry's retryable-code match. The snapshot is already validated field-by-field and cross-checked against the error's own code, so honor it on any Error.
This commit is contained in:
@@ -47,7 +47,12 @@ export function markLlmAdapterFailure(
|
|||||||
const error = value instanceof Error
|
const error = value instanceof Error
|
||||||
? value as Error & { code?: string }
|
? value as Error & { code?: string }
|
||||||
: new HarnessError(String(value), 'UNKNOWN', { cause: value })
|
: new HarnessError(String(value), 'UNKNOWN', { cause: value })
|
||||||
const carried = error instanceof HarnessError ? ownFailureSnapshot(error) : undefined
|
// The own `failure` data property is the serializable boundary contract:
|
||||||
|
// validated field-by-field and cross-checked against the error's own code,
|
||||||
|
// then honored on ANY Error — an instanceof gate here would drop the facts
|
||||||
|
// exactly when class identity is lost (a second copy of this package in
|
||||||
|
// the process, e.g. a source-plane test harness over a lib-plane boot).
|
||||||
|
const carried = ownFailureSnapshot(error)
|
||||||
const failure = carried !== undefined && carried.code === error.code ? carried : Object.freeze({
|
const failure = carried !== undefined && carried.code === error.code ? carried : Object.freeze({
|
||||||
message: errorMessage(error),
|
message: errorMessage(error),
|
||||||
code: harnessErrorCode(error),
|
code: harnessErrorCode(error),
|
||||||
|
|||||||
Reference in New Issue
Block a user