From 46629915395dd1c3e6752cadb927df733b160d73 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 17 Aug 2026 22:54:48 +0000 Subject: [PATCH] test(metadata-fs): triage snapshot on the #9339 anchor-event failure message watch-write-registration.test.ts's line-166 assertion (`expect(events...).toContain('anchor')`) cannot currently distinguish six independently-measured one-shot delivery gates that all produce the same CI signature (see #9339's investigation). Add getWatched()[viewDir] to the assertion's failure message only: absent means the loss is upstream of `_handleFile`, present means the loss is at or after the emit gate. Assertion semantics and EVENT_WAIT_MS are byte-identical -- this only changes what a failure says when it happens. Part of #9339 Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01NTKPDRoynY8i3HmdSFUxFj --- .../test/watch-write-registration.test.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/metadata-fs/test/watch-write-registration.test.ts b/packages/metadata-fs/test/watch-write-registration.test.ts index 4255a77a2c..6928eaae38 100644 --- a/packages/metadata-fs/test/watch-write-registration.test.ts +++ b/packages/metadata-fs/test/watch-write-registration.test.ts @@ -163,7 +163,20 @@ describe('FileSystemRepository watcher — writes register their own path (#7282 const anchored = nextEvent(); await fs.writeFile(path.join(viewDir, 'anchor.json'), JSON.stringify({ label: 'anchor' }, null, 2)); await Promise.race([anchored, sleep(EVENT_WAIT_MS)]); - expect(events.map((e) => e.ref.name)).toContain('anchor'); + // #9339: on failure, snapshot chokidar's own watched-set for viewDir. That + // one datum splits the failure into two disjoint classes — absent means + // the loss is upstream of `_handleFile` (the directory scan/poll layer); + // present means the loss is at or after the emit gate (`_handleFile` ran + // but no event reached this iterator). This does not change what makes + // the case pass or fail, only what the failure says when it does. + const anchorWatched = watchedIn(repo, viewDir); + expect( + events.map((e) => e.ref.name), + `#9339 triage — getWatched()[${JSON.stringify(viewDir)}] = ${JSON.stringify(anchorWatched)}. ` + + (anchorWatched.includes('anchor.json') + ? `'anchor.json' IS present in the watched set: the loss is at or after the emit gate (_handleFile ran, no event reached the iterator).` + : `'anchor.json' is ABSENT from the watched set: the loss is upstream of _handleFile (the directory scan/poll layer never registered the path).`), + ).toContain('anchor'); // ── The measurement ────────────────────────────────────────────────── await repo.put(ref('fresh'), { label: 'fresh' }, { parentVersion: null, actor: 'tester' });