From 3efcec344060de0a8080e78bada3fca5ef0d7bc2 Mon Sep 17 00:00:00 2001 From: dafuga Date: Mon, 30 Nov 2026 15:53:23 +0000 Subject: [PATCH 1/3] fix: reproduce ambiguous app Home canary answers --- test/needs-you-canary-answer-paths.test.ts | 51 +++++++++++++++++++--- test/needs-you-canary.test.ts | 17 ++++++++ test/support/needsYouCanaryClients.ts | 32 ++++++++++++++ 3 files changed, 94 insertions(+), 6 deletions(-) diff --git a/test/needs-you-canary-answer-paths.test.ts b/test/needs-you-canary-answer-paths.test.ts index 51b0fb87914..cde22c3a88d 100644 --- a/test/needs-you-canary-answer-paths.test.ts +++ b/test/needs-you-canary-answer-paths.test.ts @@ -3,14 +3,20 @@ import { judgeAnswer } from '../scripts/needs-you-canary/awaitAnswer'; import type { CanarySurface } from '../scripts/needs-you-canary/canary.types'; import { canaryAsk } from '../scripts/needs-you-canary/canaryAsk'; import { canarySurfaces } from '../scripts/needs-you-canary/runCanary'; -import { raise, realTracker, tapThrough, type RealTracker } from './support/needsYouCanaryClients'; +import { + raise, + realTracker, + tapAppHome, + tapThrough, + type RealTracker +} from './support/needsYouCanaryClients'; let tracker: RealTracker; beforeEach(() => void (tracker = realTracker())); afterEach(() => tracker.close()); /** What the canary decides after `app` answers the ask it raised for `surface`. */ -async function judged(surface: CanarySurface, app: CanarySurface) { +async function judged(surface: CanarySurface, app: CanarySurface, tap = tapThrough[app]) { const ask = canaryAsk({ surface, release: 'release-item', @@ -19,7 +25,7 @@ async function judged(surface: CanarySurface, app: CanarySurface) { byHand: true }); const id = await raise(tracker, ask); - await tapThrough[app](tracker, id, ask, ask.expected); + await tap(tracker, id, ask, ask.expected); const item = await tracker.read(`/items/${id}`); expect(item).toMatchObject({ answer: 'Canary B', answer_option: 2 }); return { item, outcome: judgeAnswer(item, ask) }; @@ -35,8 +41,41 @@ describe('needs-you canary reads what each app really writes', () => { canarySurfaces.filter((app) => app !== surface).map((app) => [surface, app] as const) ); - test.each(crossed)('fails a %s ask answered through the %s app', async (surface, app) => { - const { outcome } = await judged(surface, app); - expect(outcome).toMatchObject({ state: 'failed' }); + // The Hub web path is the shared Home writer, which the app surfaces also use. + const shared = ([surface, app]: readonly [CanarySurface, CanarySurface]) => + app === 'web' && surface !== 'web'; + + test.each(crossed.filter((pair) => !shared(pair)))( + 'fails a %s ask answered through the %s app', + async (surface, app) => { + const { outcome } = await judged(surface, app); + expect(outcome).toMatchObject({ state: 'failed' }); + } + ); +}); + +describe('needs-you canary and the shared Home writer', () => { + test.each(['mac', 'iphone'] as const)( + 'cannot confirm the device of a %s ask answered on an app Home screen', + async (surface) => { + const { item, outcome } = await judged(surface, surface, tapAppHome); + expect(item.answered_by).toBe('Daniel via Hub'); + expect(outcome.state).toBe('unconfirmed'); + expect(outcome.detail).toContain('cannot name the device'); + } + ); + + test.each(['mac', 'iphone'] as const)('fails a wrong %s option there', async (surface) => { + const ask = canaryAsk({ + surface, + release: 'release-item', + nonce: 'n1x', + expected: 2, + byHand: true + }); + const id = await raise(tracker, ask); + await tapAppHome(tracker, id, ask, 3); + const item = await tracker.read(`/items/${id}`); + expect(judgeAnswer(item, ask).state).toBe('failed'); }); }); diff --git a/test/needs-you-canary.test.ts b/test/needs-you-canary.test.ts index 1c7c6de2dcd..6ff1e1175e6 100644 --- a/test/needs-you-canary.test.ts +++ b/test/needs-you-canary.test.ts @@ -1,6 +1,7 @@ import { describe, expect, test } from 'vitest'; import { runCanary } from '../scripts/needs-you-canary/runCanary'; import { isTrackerCosMessage } from '../src/utils/projects-sessions/isTrackerPing'; +import { trackerAskOptions } from '../src/utils/projects-sessions/trackerAskOptions'; import { canaryHub, canaryOptions, canaryTracker } from './support/needsYouCanaryWorld'; import type { CanaryWorld } from './support/needsYouCanaryWorld.types'; @@ -100,6 +101,22 @@ describe('needs-you release canary failures', () => { expect(states(report)).toEqual({ web: 'passed', mac: 'failed', iphone: 'failed' }); expect(report.passed).toBe(false); }); + + test('holds the release on right answers that name no device', async () => { + const { world, release, item } = setup(); + const report = await runCanary( + canaryOptions(world, { release, taps: everyHand }, (question) => { + const marker = /\[canary-[a-z0-9-]+\]/.exec(question)![0]; + world.tap(marker, 'Canary B', 'Daniel via Hub'); + }) + ); + expect(states(report)).toEqual({ web: 'passed', mac: 'unconfirmed', iphone: 'unconfirmed' }); + expect(report.passed).toBe(false); + expect(item().status).toBe('blocked'); + expect(item().blocked_reason).toBe('needs-you canary: mac unconfirmed, iphone unconfirmed'); + const choices = trackerAskOptions(item().options as string); + expect(choices.find((choice) => choice.recommended)?.label).toBe('Keep the release blocked'); + }); }); describe('needs-you release canary holds and cleanup', () => { diff --git a/test/support/needsYouCanaryClients.ts b/test/support/needsYouCanaryClients.ts index d9563e51b99..cf0cdedd3d8 100644 --- a/test/support/needsYouCanaryClients.ts +++ b/test/support/needsYouCanaryClients.ts @@ -1,11 +1,17 @@ import { DatabaseSync } from 'node:sqlite'; import { vi } from 'vitest'; import { MacTrackerInboxService } from '../../packages/desktop/src/lib/development-tooling/desktop-initialization/MacTrackerInboxService'; +import { createHomeChatWriter } from '../../packages/desktop/src/lib/development-tooling/desktop-initialization/tracker-overview-publisher/createHomeChatWriter'; import { deliverHomeChat } from '../../packages/desktop/src/lib/development-tooling/desktop-initialization/tracker-overview-publisher/homeTrackerChat'; import { optionWrite } from '../../packages/desktop/src/lib/development-tooling/tracker-inbox/trackerInbox'; import type { InboxDetail } from '../../packages/desktop/src/models/development-tooling/TrackerInbox.types'; import { agentOpenAsks } from '../../packages/reports/src/lib/projects-sessions/hub-home/homeOpenAsks'; import type { HomeAgent } from '../../packages/reports/src/lib/projects-sessions/hub-home/hubHome.types'; +import { + buildHomeSnapshot, + noProviders +} from '../../packages/reports/src/lib/projects-sessions/hub-home/homeTrackerProjection'; +import { readTrackerSources } from '../../packages/reports/src/lib/projects-sessions/project-overview/projectOverviewTracker'; import type { CanaryAsk, CanaryItem, @@ -122,6 +128,32 @@ async function tapIphone(tracker: RealTracker, id: string, ask: CanaryAsk, optio accepted('iPhone', receipt.status === 'accepted', receipt.status); } +/** + * The Home screen of the installed Mac app (local bridge) and iPhone app (relayed to that Mac): + * both hand the tap to the one writer `initializeDesktop` builds with `createHomeChatWriter`. + */ +export async function tapAppHome(tracker: RealTracker, id: string, ask: CanaryAsk, option: number) { + // The daemon serves runs and machines elsewhere; items and the write stay on the real store. + const send = (async (url: string, init?: RequestInit) => + ['/runs', '/machines'].includes(new URL(url).pathname) + ? Response.json([]) + : tracker.send(url, init)) as typeof fetch; + const sources = await readTrackerSources(send, true); + const listed = buildHomeSnapshot(sources, noProviders, Date.now()).openAsks?.find( + (entry) => entry.itemId === id + ); + const receipt = await createHomeChatWriter(send)({ + id: '00000000-0000-4000-8000-000000000002', + agentId: listed?.agentId, + itemId: id, + question: ask.question, + kind: 'answer', + text: ask.labels[option - 1], + option + }); + accepted('App Home', receipt.status === 'sent', receipt.status); +} + export const tapThrough: Record< CanarySurface, (tracker: RealTracker, id: string, ask: CanaryAsk, option: number) => Promise From c464d7804f977951d5882dca5b5233de7ff3faa5 Mon Sep 17 00:00:00 2001 From: dafuga Date: Mon, 30 Nov 2026 15:54:15 +0000 Subject: [PATCH 2/3] fix: score ambiguous app Home canary answers as unconfirmed --- scripts/needs-you-canary/awaitAnswer.ts | 15 +++++++++------ scripts/needs-you-canary/canary.types.ts | 3 ++- scripts/needs-you-canary/canaryAsk.ts | 10 ++++++++-- scripts/needs-you-canary/releaseAsk.ts | 3 ++- .../features/planned/needs-you-release-canary.md | 13 +++++++++---- 5 files changed, 30 insertions(+), 14 deletions(-) diff --git a/scripts/needs-you-canary/awaitAnswer.ts b/scripts/needs-you-canary/awaitAnswer.ts index d722bc05da7..e4a7e6b894d 100644 --- a/scripts/needs-you-canary/awaitAnswer.ts +++ b/scripts/needs-you-canary/awaitAnswer.ts @@ -6,7 +6,7 @@ import type { CanaryOutcome as Outcome, CanaryWeb } from './canary.types'; -import { surfaceAnswerers } from './canaryAsk'; +import { homeAnswerer, surfaceAnswerers } from './canaryAsk'; const pollMs = 3000; const appearMs = 120_000; @@ -20,11 +20,14 @@ export function judgeAnswer(item: CanaryItem, ask: CanaryAsk): Outcome { const label = ask.labels[ask.expected - 1]; const actor = surfaceAnswerers[ask.surface]; const read = `answered_by=${item.answered_by}, answer_option=${item.answer_option}`; - const right = - item.answered_by === actor && - Number(item.answer_option) === ask.expected && - item.answer === label; - if (right) return { state: 'passed', detail: `${read}, answered_at=${item.answered_at}` }; + const right = Number(item.answer_option) === ask.expected && item.answer === label; + const timed = `${read}, answered_at=${item.answered_at}`; + if (right && item.answered_by === actor) return { state: 'passed', detail: timed }; + if (right && item.answered_by === homeAnswerer) { + const why = + 'Hub web and both app Home screens record this, so the record cannot name the device'; + return { state: 'unconfirmed', detail: `right option, ${timed}; ${why}` }; + } return failed(`expected ${actor} and option ${ask.expected}, read ${read}`); } diff --git a/scripts/needs-you-canary/canary.types.ts b/scripts/needs-you-canary/canary.types.ts index 3e92dad4d92..bed6fa414a0 100644 --- a/scripts/needs-you-canary/canary.types.ts +++ b/scripts/needs-you-canary/canary.types.ts @@ -47,7 +47,8 @@ export interface CanaryOptions { tapTimeoutMs?: number; } -export type CanaryState = 'passed' | 'failed' | 'not-seen'; +/** `unconfirmed`: the right answer arrived, but nothing shows which surface sent it. */ +export type CanaryState = 'passed' | 'failed' | 'unconfirmed' | 'not-seen'; export interface CanaryResult { surface: CanarySurface; diff --git a/scripts/needs-you-canary/canaryAsk.ts b/scripts/needs-you-canary/canaryAsk.ts index 262ce9b0b88..2fe64d79afb 100644 --- a/scripts/needs-you-canary/canaryAsk.ts +++ b/scripts/needs-you-canary/canaryAsk.ts @@ -8,8 +8,8 @@ export const surfaceNames: Record = { }; /** - * What each app's own answer write records as `answered_by`: Hub web through the linked Mac, the Mac - * app's Needs you page (which names no one, as the CLI does too) and the iPhone's intent. + * What proves each surface as `answered_by`: Hub web through the linked Mac, the Mac app's Needs you + * page (which names no one, as the CLI does too) and the iPhone's intent. */ export const surfaceAnswerers: Record = { web: 'Daniel via Hub', @@ -17,6 +17,12 @@ export const surfaceAnswerers: Record = { iphone: 'Daniel' }; +/** + * The Home screens of the Mac and iPhone apps record the same as Hub web, because all three answer + * through the linked Mac. A right answer read this way is real but names no device. + */ +export const homeAnswerer = surfaceAnswerers.web; + const labels = ['Canary A', 'Canary B', 'Canary C']; const effect = 'Test answer only. Nothing deploys or changes.'; diff --git a/scripts/needs-you-canary/releaseAsk.ts b/scripts/needs-you-canary/releaseAsk.ts index 05a452710b0..aa8a63ec7a3 100644 --- a/scripts/needs-you-canary/releaseAsk.ts +++ b/scripts/needs-you-canary/releaseAsk.ts @@ -22,7 +22,8 @@ export function surfaceSummary(results: CanaryResult[]): string { /** The flag words for a release that did not pass: what is unproven, and the ways forward. */ export function releaseAskArgs(release: string, results: CanaryResult[]): string[] { const open = results.filter((result) => result.state !== 'passed'); - const broken = open.some((result) => result.state === 'failed'); + // Another tap cannot settle an unconfirmed surface, so only unseen ones recommend tapping. + const broken = open.some((result) => result.state !== 'not-seen'); const options = [tapAll, keepBlocked]; if (open.some((result) => result.detail === signedOut)) options.splice(1, 0, signInOnce); const recommend = broken ? options.indexOf(keepBlocked) + 1 : 1; diff --git a/specification/features/planned/needs-you-release-canary.md b/specification/features/planned/needs-you-release-canary.md index 790df2a8ebd..8f40fd8d963 100644 --- a/specification/features/planned/needs-you-release-canary.md +++ b/specification/features/planned/needs-you-release-canary.md @@ -20,11 +20,16 @@ scripted check to run after it is deployed: pressing that option on the "Blocked - needs you" row. A row without option buttons fails. - A surface named in `--tap` is answered by Daniel by hand. This is the only way for the Mac app and the iPhone. -- A surface passes only when the Tracker then reads back its own app's `answered_by`, with +- A surface passes only when the Tracker then reads back the `answered_by` that proves it, with `answer_option` and `answer` equal to the named option, on an ask that was unanswered when the - surface was reached. `answered_by` is `Daniel via Hub` for Hub web, `daniel` for the Mac app and - `Daniel` for the iPhone. `test/needs-you-canary-answer-paths.test.ts` reads each from that app's - write code, so a change there fails the test. + surface was reached. That is `Daniel via Hub` for Hub web, `daniel` for the Mac app's Needs you + page and `Daniel` for the iPhone's replica intent. `test/needs-you-canary-answer-paths.test.ts` + reads each from that app's write code, so a change there fails the test. +- The Home screens of the Mac and iPhone apps answer through the linked Mac and also record + `Daniel via Hub`. A right option read that way on a Mac or iPhone ask is `unconfirmed`: it is not + a failed answer, and it does not pass, because a tap in Hub web or on the other device reads the + same. The release stays held. A wrong option or any other actor fails. Until answers record the + answering device (q84bd0), a person has to confirm which app sent an unconfirmed answer. - `answered_by` names the write path, not the device or the person's hands. A Hub tap in a phone browser reads as Hub web, and `daniel` is also what `tracker answer` writes without `--by`, so the Mac result also rests on the instruction. From 19ebf79a80a2b665fb518220ea06b91aab0dc89c Mon Sep 17 00:00:00 2001 From: dafuga Date: Mon, 30 Nov 2026 15:57:26 +0000 Subject: [PATCH 3/3] chore: record canary scoring regression evidence --- .../loops/q84bd0-canary-scoring/loop.json | 67 +++++++++++++++++++ .../loops/q84bd0-canary-scoring/trace.ndjson | 6 ++ 2 files changed, 73 insertions(+) create mode 100644 specification/loops/q84bd0-canary-scoring/loop.json create mode 100644 specification/loops/q84bd0-canary-scoring/trace.ndjson diff --git a/specification/loops/q84bd0-canary-scoring/loop.json b/specification/loops/q84bd0-canary-scoring/loop.json new file mode 100644 index 00000000000..786c4d33bf0 --- /dev/null +++ b/specification/loops/q84bd0-canary-scoring/loop.json @@ -0,0 +1,67 @@ +{ + "name": "q84bd0-canary-scoring", + "goal": "Prove correct legacy app Home answers hold the release as unconfirmed", + "createdAt": "2026-11-30T15:52:59.740Z", + "updatedAt": "2026-11-30T15:56:36.358Z", + "template": "bug-fix", + "templateLineage": [ + "bug-fix" + ], + "enforceOrder": true, + "regressionCommits": 1, + "steps": [ + { + "id": "spec", + "title": "Identify the failing behavior, expected behavior, and reproduction.", + "status": "complete", + "completedAt": "2026-11-30T15:53:19.646Z", + "evidence": "6kmyg7 run 1549 recorded the correct iPhone Home option under the shared Daniel via Hub actor; this must hold as unconfirmed" + }, + { + "id": "coverage", + "title": "Explain why existing standardized tests missed the bug; name the scenario, fixture, lifecycle or assertion gap and reusable test change.", + "status": "complete", + "completedAt": "2026-11-30T15:53:22.405Z", + "evidence": "The existing canary answered from the replica intent and Mac inbox. It now exercises the app Home writer and checks wrong option, actor, and release disposition." + }, + { + "id": "red", + "title": "Strengthen the existing standardized test; commit it before repair, run it failing with loop record --phase red, and preserve the assertion.", + "status": "complete", + "completedAt": "2026-11-30T15:54:44.185Z", + "evidence": "3efcec3440 failed three assertions; correct app Home answers scored failed instead of unconfirmed." + }, + { + "id": "implement", + "title": "Implement the smallest repair without weakening the regression test.", + "status": "complete", + "completedAt": "2026-11-30T15:54:48.313Z", + "evidence": "c464d7804f preserves the release hold and wrong-option and wrong-actor failures." + }, + { + "id": "green", + "title": "Rerun the same unchanged regression test at a separate fix commit with loop record --phase green; preserve passing proof.", + "status": "complete", + "completedAt": "2026-11-30T15:56:36.358Z", + "evidence": "Same two suites and unchanged regression passed in the clean snapshot at c464d7804f." + }, + { + "id": "siblings", + "title": "Run harness loop siblings to record the root cause and evaluate the same pattern across committed source.", + "status": "pending" + }, + { + "id": "verify", + "title": "Run relevant project checks and affected UI browser flows with fresh inspected screenshots and no unexpected browser errors; preserve diagnostics and keep pending until proof passes.", + "status": "pending" + } + ], + "evaluators": [ + { + "id": "check", + "title": "Run the project check script.", + "command": "bun run check", + "step": "verify" + } + ] +} diff --git a/specification/loops/q84bd0-canary-scoring/trace.ndjson b/specification/loops/q84bd0-canary-scoring/trace.ndjson new file mode 100644 index 00000000000..7460f990cfe --- /dev/null +++ b/specification/loops/q84bd0-canary-scoring/trace.ndjson @@ -0,0 +1,6 @@ +{"event":"loop.created","timestamp":"2026-11-30T15:52:59.740Z","name":"q84bd0-canary-scoring","goal":"Prove correct legacy app Home answers hold the release as unconfirmed","template":"bug-fix","templateLineage":["bug-fix"]} +{"event":"step.completed","timestamp":"2026-11-30T15:53:19.646Z","loop":"q84bd0-canary-scoring","step":"spec","evidence":"6kmyg7 run 1549 recorded the correct iPhone Home option under the shared Daniel via Hub actor; this must hold as unconfirmed"} +{"event":"step.completed","timestamp":"2026-11-30T15:53:22.405Z","loop":"q84bd0-canary-scoring","step":"coverage","evidence":"The existing canary answered from the replica intent and Mac inbox. It now exercises the app Home writer and checks wrong option, actor, and release disposition."} +{"event":"step.completed","timestamp":"2026-11-30T15:54:44.185Z","loop":"q84bd0-canary-scoring","step":"red","evidence":"3efcec3440 failed three assertions; correct app Home answers scored failed instead of unconfirmed."} +{"event":"step.completed","timestamp":"2026-11-30T15:54:48.313Z","loop":"q84bd0-canary-scoring","step":"implement","evidence":"c464d7804f preserves the release hold and wrong-option and wrong-actor failures."} +{"event":"step.completed","timestamp":"2026-11-30T15:56:36.358Z","loop":"q84bd0-canary-scoring","step":"green","evidence":"Same two suites and unchanged regression passed in the clean snapshot at c464d7804f."}