This commit is contained in:
2026-10-08 19:09:30 +08:00
parent 2c0f55d9b7
commit ed99ecba1c
17 changed files with 157 additions and 106 deletions
+18 -2
View File
@@ -16,6 +16,21 @@ const AVAILABLE_MODULES = new Set([...CONFIGURED_MODULES, ...OPTIONAL_MODULES])
const A0_LOCATION_PAGE_SIZE = 200
const A0_MAX_LOCATION_MUTATIONS = 8
export function transportFailureDetails(error) {
const causes = []
const visited = new Set()
const symbol = value => typeof value === 'string' && /^[A-Za-z][A-Za-z0-9_]{0,79}$/.test(value) ? value : null
function visit(value) {
if (!value || typeof value !== 'object' || visited.has(value) || causes.length >= 6) return
visited.add(value)
causes.push({ name: symbol(value.name), code: symbol(value.code), syscall: symbol(value.syscall) })
visit(value.cause)
if (Array.isArray(value.errors)) for (const nested of value.errors) visit(nested)
}
visit(error)
return { causes }
}
export function planA0LocationIsolation(locations, requiredSlots = 1,
maxMutations = A0_MAX_LOCATION_MUTATIONS) {
const slots = Math.max(1, Number.isInteger(Number(requiredSlots)) ? Number(requiredSlots) : 1)
@@ -643,7 +658,7 @@ export class AcceptanceRun {
await new Promise((resolve) => setTimeout(resolve, attempt * 250))
continue
}
return { method, path, http: 0, body: null, raw: error instanceof Error ? error.message : String(error), requestId: null, traceId: null }
return { method, path, http: 0, body: null, raw: error instanceof Error ? error.message : String(error), requestId: null, traceId: null, transportError: transportFailureDetails(error) }
}
}
throw new Error('unreachable request attempt state')
@@ -675,7 +690,7 @@ export class AcceptanceRun {
requestId: payload?.requestId || response.headers.get('x-request-id'),
traceId: payload?.traceId || response.headers.get('x-trace-id') }
} catch (error) {
return { method, path, http: 0, body: null, raw: error instanceof Error ? error.message : String(error), requestId: null, traceId: null }
return { method, path, http: 0, body: null, raw: error instanceof Error ? error.message : String(error), requestId: null, traceId: null, transportError: transportFailureDetails(error) }
}
}
@@ -718,6 +733,7 @@ export class AcceptanceRun {
code: response?.body?.code === undefined ? null : String(response.body.code),
message: response?.body?.message || response?.raw || null,
requestId: response?.requestId || null, traceId: response?.traceId || null,
...(response?.transportError ? { transportError: response.transportError } : {}),
evidence, checkedAt: new Date().toISOString(),
}
this.steps.push(step)