diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index 8d86a994b0..8e4bbf497b 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -291,6 +291,7 @@ jobs: path: | ${{ env.NATIVE_SCHEDULE_PRODUCT_FIXTURE }}/**/receipt.json ${{ env.NATIVE_SCHEDULE_PRODUCT_FIXTURE }}/**/failure-diagnostic.json + ${{ env.NATIVE_SCHEDULE_PRODUCT_FIXTURE }}/**/failure-sql.json if-no-files-found: ignore retention-days: 7 - name: Upload isolated schedule foundation failure diagnostics diff --git a/packages/ui/tests/browser/integration-attachment-actions.test.ts b/packages/ui/tests/browser/integration-attachment-actions.test.ts index ab26f81164..6cdfa1e3d9 100644 --- a/packages/ui/tests/browser/integration-attachment-actions.test.ts +++ b/packages/ui/tests/browser/integration-attachment-actions.test.ts @@ -67,7 +67,6 @@ test(`AC-C5 ${dismissal} cancels and restores the exact Status opener at ${width test("AC-C5 attachment rejects activation below 500ms and admits one double-click after 600ms", async () => { await withAttachment(async ({ page, model, calls }) => { const time = new Date("2026-11-03T12:00:00Z") - await page.clock.install({ time }) await page.clock.pauseAt(time) await launch(page) const confirm = picker(page).getByRole("button", { name: "Attach", exact: true }) diff --git a/packages/ui/tests/browser/integration-attachment-install.test.ts b/packages/ui/tests/browser/integration-attachment-install.test.ts index 48ddf668d5..c5780fa648 100644 --- a/packages/ui/tests/browser/integration-attachment-install.test.ts +++ b/packages/ui/tests/browser/integration-attachment-install.test.ts @@ -34,6 +34,7 @@ test("AC-C15 sessionless install/update needs fresh active native status and a p const dialog = await launchInstallation(page, name) assert.match(await dialog.innerText(), /Blender.*OpenCode for Blender 1\.2\.3/s) assert.match(await dialog.innerText(), /machine where OpenCode runs/) + await page.waitForFunction(element => element === document.activeElement, await dialog.getByRole("button", { name: "Cancel", exact: true }).elementHandle()) assert.equal(await dialog.getByRole("button", { name: "Cancel", exact: true }).evaluate(el => el === document.activeElement), true) await dialog.getByRole("button", { name: "Cancel", exact: true }).click() } @@ -77,7 +78,6 @@ test("AC-C5/C15 installer rejects sub-500ms activation and admits exactly one do await withAttachment(async ({ page, model, calls }) => { await installationReady(page, model) const time = new Date("2026-11-03T12:00:00Z") - await page.clock.install({ time }) await page.clock.pauseAt(time) const dialog = await launchInstallation(page) const confirm = dialog.locator("button.button-primary") @@ -255,7 +255,6 @@ async function launchRemoval(page: Page, surface: "plugins" | "section", guarded const item = page.getByRole("menuitem", { name: "Remove from Global", exact: true }) if (guardedClock) { const time = new Date("2026-11-03T12:00:00Z") - await page.clock.install({ time }) await page.clock.pauseAt(time) // Kobalte selects on pointer-up/Enter, then closes its menu on a zero-delay timer. await item.press("Enter") diff --git a/packages/ui/tests/browser/opencode-setup.test.ts b/packages/ui/tests/browser/opencode-setup.test.ts index e5236e3239..1a262056ce 100644 --- a/packages/ui/tests/browser/opencode-setup.test.ts +++ b/packages/ui/tests/browser/opencode-setup.test.ts @@ -791,6 +791,9 @@ test("changing executable fences an old read and its queued follow-up", async () const page = await browser.newPage() let hold = false, changed = false, release!: () => void, reads = 0 await page.route("**/api/**", async route => { + if (route.request().method() !== "GET" || new URL(route.request().url()).pathname !== "/api/opencode/update") { + return route.fulfill({ json: healthyStatus }) + } const status = { ...healthyStatus, binaryPath: changed ? "new-opencode" : "old-opencode", serviceState: changed ? "stopped" : "ready" } if (hold) { reads++; await new Promise(resolve => { release = resolve }) } else if (reads) reads++ @@ -811,6 +814,8 @@ test("changing executable fences an old read and its queued follow-up", async () release() await oldRead await page.evaluate(() => new Promise(resolve => setTimeout(resolve, 30))) + // Authentication reads must not count as status checks or overwrite the held read. + await page.evaluate(() => fetch("/api/auth/status")) assert.equal(await page.getByText("old-opencode", { exact: true }).count(), 0) assert.equal(await page.getByText("OpenCode is connected.", { exact: true }).count(), 0) assert.equal(reads, 2) diff --git a/scripts/test-native-mission-schedule-product.mjs b/scripts/test-native-mission-schedule-product.mjs index 728b6083f9..d55142549b 100644 --- a/scripts/test-native-mission-schedule-product.mjs +++ b/scripts/test-native-mission-schedule-product.mjs @@ -164,12 +164,29 @@ async function journey(kind) { assert(Buffer.byteLength(rows[0].value) <= 256 * 1024) return JSON.parse(rows[0].value) } - const snapshot = id => readSQL(db => { + const snapshot = (id, failureDetails = false) => readSQL(db => { const doc = document(db, id), passage = doc.pending ?? doc.history?.at(-1) const start = passage ? db.prepare("SELECT id,type FROM session_message WHERE session_id=? AND type IN ('user','synthetic') ORDER BY seq LIMIT 16").all(passage.coordinatorSessionID) : [] const sessions = db.prepare("SELECT id,parent_id,metadata,time_suspended FROM session_v2 WHERE json_extract(metadata,'$.\"codenomad.mission\".document.missionID')=? LIMIT 16").all(id) - const schedules = (doc.calendarOwner?.slots ?? []).filter(slot => slot.scheduleID).map(slot => ({ role: slot.role, - ...db.prepare('SELECT id,session_id,status,next_due_at,run_count,time_created,"when" AS native_when FROM schedule WHERE id=?').get(slot.scheduleID) })) + const schedules = (doc.calendarOwner?.slots ?? []).filter(slot => slot.scheduleID).map(slot => { + const schedule = { role: slot.role, + ...db.prepare('SELECT id,session_id,status,next_due_at,run_count,time_created,"when" AS native_when FROM schedule WHERE id=?').get(slot.scheduleID) } + if (failureDetails) { + Object.assign(schedule, db.prepare("SELECT last_outcome,retry_at,time_updated,last_message_id FROM schedule WHERE id=?").get(slot.scheduleID)) + const proof = row => { + if (!row) return null + const { body, ...status } = row, data = body === null ? null : JSON.parse(body), text = data?.text + return { ...status, bodyOmitted: body === null, schedule: data?.metadata?.schedule ?? null, + textBytes: typeof text === "string" ? Buffer.byteLength(text) : null, textSHA256: typeof text === "string" ? hash(text) : null } + } + schedule.carrier = { sessionID: slot.sessionID, + session: db.prepare("SELECT id,time_suspended,time_busy,time_idle,idle_outcome FROM session_v2 WHERE id=?").get(slot.sessionID) ?? null, + messages: Array.from(new Set([schedule.last_message_id, ...(schedule.id ? [`msg_${schedule.id}_${schedule.run_count + 1}`] : [])].filter(Boolean)), messageID => ({ messageID, + message: proof(db.prepare("SELECT type,seq,time_created,time_updated,length(CAST(data AS BLOB)) AS bytes,CASE WHEN length(CAST(data AS BLOB))<=262144 THEN data END AS body FROM session_message WHERE id=? AND session_id=?").get(messageID, slot.sessionID)), + inbox: proof(db.prepare("SELECT type,delivery,enqueued_seq,time_created,length(CAST(payload AS BLOB)) AS bytes,CASE WHEN length(CAST(payload AS BLOB))<=262144 THEN payload END AS body FROM session_inbox WHERE id=? AND session_id=?").get(messageID, slot.sessionID)) })) } + } + return schedule + }) const startDetails = passage ? db.prepare("SELECT id,type,data FROM session_message WHERE session_id=? AND type IN ('user','synthetic') ORDER BY seq LIMIT 64").all(passage.coordinatorSessionID) .map(row => { const data = JSON.parse(row.data); return { id: row.id, type: row.type, textSHA256: hash(data.text ?? ""), metadataKeys: Object.keys(data.metadata ?? {}), missionDocument: data.metadata?.["codenomad.mission"]?.document, @@ -640,7 +657,14 @@ export default Plugin.define({id:"codenomad.product-provider-observer",effect:ct const detail = item => item && { name: redact(item.name), type: redact(item.type ?? item._tag), message: redact(item.message), stack: redact(item.stack) } result.status = "failed"; result.error = redact(error?.message ?? "qualification-failed") await save("failure-diagnostic", { stage: result.stage, error: detail(error), reason: detail(error?.reason), cause: detail(error?.cause), nativeErrorTail: redact(nativeErrorTail) }) - if (result.documentID) try { await save("failure-sql", snapshot(result.documentID)) } catch { /* Preserve the original failure. */ } + if (result.documentID) try { + const state = snapshot(result.documentID, true) + state.maintenance = await maintenanceEvents().then(events => ({ count: events.length, + tail: events.filter(event => !event.sessionID || state.document.calendarOwner?.slots.some(slot => slot.sessionID === event.sessionID)).slice(-32) }), + () => ({ error: "maintenance-events-unavailable" })) + const json = JSON.stringify(state, (_key, value) => typeof value === "string" ? redact(value) : value) + await writeFile(path.join(root, "failure-sql.json"), Buffer.byteLength(json) <= 512 * 1024 ? json : '{"error":"failure-sql-bound"}') + } catch { /* Preserve the original failure. */ } throw Error(`Native product qualification failed at ${result.stage ?? "setup"}: ${result.error}; private redacted diagnostic saved`) } finally {