|
1 | 1 | import fs from 'node:fs'; |
2 | 2 | import path from 'node:path'; |
3 | 3 | import { sleep } from '../../utils/timeouts.ts'; |
4 | | -import { normalizeError } from '../../kernel/errors.ts'; |
5 | | -import type { AndroidHelperContentRecoveryDecision } from '../../platforms/android/snapshot-content-recovery.ts'; |
6 | 4 | import { markSessionPartialRefsIssued, setSessionSnapshot } from '../session-snapshot.ts'; |
7 | | -import { isSparseSnapshotQualityVerdict } from '../../snapshot/snapshot-quality.ts'; |
| 5 | +import { |
| 6 | + isSparseSnapshotQualityVerdict, |
| 7 | + isUnreadableCaptureContentError, |
| 8 | +} from '../../snapshot/snapshot-quality.ts'; |
8 | 9 | import { displayLabel, formatRole } from '../../snapshot/snapshot-lines.ts'; |
9 | 10 | import { redactDiagnosticData } from '../../kernel/redaction.ts'; |
10 | 11 | import type { CommandFlags } from '../../core/dispatch.ts'; |
@@ -288,41 +289,6 @@ export async function captureDivergenceObservation(params: { |
288 | 289 | return attempt.observation; |
289 | 290 | } |
290 | 291 |
|
291 | | -// The ONLY three reason codes `rejectAndroidHelperContentUnavailable` |
292 | | -// (`platforms/android/snapshot.ts`) attaches as |
293 | | -// `androidSnapshotHelperFailureReason` — mirrors |
294 | | -// `AndroidHelperContentRecoveryDecision['reason']` |
295 | | -// (`platforms/android/snapshot-content-recovery.ts`), the SOLE site that |
296 | | -// classifies a structurally-succeeded helper capture as too thin/foreign to |
297 | | -// trust: the helper produced accessibility XML, but its content doesn't meet |
298 | | -// the bar. This is deliberately narrower than the error's own `retriable` |
299 | | -// flag: Android's adb layer (`adb-executor.ts`) ALSO marks transport-level |
300 | | -// mechanism failures retriable (`connection_dropped`, `device_offline`, |
301 | | -// `server_version_mismatch`) because an unchanged retry of the SAME adb |
302 | | -// command can succeed there — a true statement about adb, but not evidence |
303 | | -// this specific capture failure is a content-quality verdict rather than a |
304 | | -// genuine mechanism failure (a crashed/timed-out helper invocation, a |
305 | | -// dropped adb connection, a missing helper artifact) a launch-race retry |
306 | | -// cannot fix. `androidSnapshotHelperCaptureError`'s generic capture-failure |
307 | | -// wrap (`rejectAndroidHelperCaptureFailure`) ALSO sets |
308 | | -// `androidSnapshotHelperFailureReason` — but to an arbitrary formatted |
309 | | -// failure message, never one of these three literals, so this exact-value |
310 | | -// membership check does not also catch that unrelated, non-content-quality |
311 | | -// case. |
312 | | -const ANDROID_CAPTURE_CONTENT_QUALITY_REASONS: ReadonlySet< |
313 | | - AndroidHelperContentRecoveryDecision['reason'] |
314 | | -> = new Set(['empty-helper-output', 'system-window-only', 'content-poor-app-window']); |
315 | | - |
316 | | -function isCaptureContentQualityFailure(error: unknown): boolean { |
317 | | - const reason = normalizeError(error).details?.androidSnapshotHelperFailureReason; |
318 | | - return ( |
319 | | - typeof reason === 'string' && |
320 | | - ANDROID_CAPTURE_CONTENT_QUALITY_REASONS.has( |
321 | | - reason as AndroidHelperContentRecoveryDecision['reason'], |
322 | | - ) |
323 | | - ); |
324 | | -} |
325 | | - |
326 | 292 | type DivergenceCaptureAttempt = { |
327 | 293 | observation: DivergenceObservation; |
328 | 294 | /** |
@@ -394,7 +360,7 @@ async function captureDivergenceObservationAttempt(params: { |
394 | 360 | reason: 'capture-failed', |
395 | 361 | hint: `Post-failure snapshot capture failed (${error instanceof Error ? error.message : String(error)}); the original replay failure is unaffected.`, |
396 | 362 | }, |
397 | | - retryable: isCaptureContentQualityFailure(error), |
| 363 | + retryable: isUnreadableCaptureContentError(error), |
398 | 364 | }; |
399 | 365 | } |
400 | 366 | } |
|
0 commit comments