From dbf84bbcb6418e568c58b5def4258bdbe4124b1b Mon Sep 17 00:00:00 2001 From: Lily Shen <115414357+lilyshen0722@users.noreply.github.com> Date: Tue, 25 Aug 2026 03:21:02 -0700 Subject: [PATCH] test(threading): positive control on the backfillPending absence probe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @sprint-review noted that rule 18's rider two asks for a positive control and the exemplar the rule is built on hasn't got one. It is safe anyway, because `read()` is an unguarded `readFileSync` — a bad path throws rather than yielding ''. That closes one of the two ways to match nothing. The other is not closed by anything the loader does. A wrong needle — a typo'd identifier, an over-anchored regex, or a haystack that is simply the wrong file — matches nothing against source where the code is in plain sight, and the absence assertion passes vacuously. Control matches THREADING_BACKFILL_MIGRATION, chosen because it shares the substring: if a backfill-named identifier can be found in this file, the probe's silence about backfillPending is informative. Negative control run, isolated and restored: repointing CONTROLLER_SRC at models/User.ts reddens the new line and leaves `not.toMatch(/backfillPending/)` green — the exact vacuous pass this closes. 21/21 on Node 22. Co-Authored-By: Claude Opus 5 --- backend/__tests__/unit/models/threadUserState.test.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/backend/__tests__/unit/models/threadUserState.test.js b/backend/__tests__/unit/models/threadUserState.test.js index 6579c4ef3..bcda11652 100644 --- a/backend/__tests__/unit/models/threadUserState.test.js +++ b/backend/__tests__/unit/models/threadUserState.test.js @@ -223,6 +223,16 @@ describe('the pre-cutoff expanded default reaches the client', () => { // rule. It asserts the ABSENCE of code, which no execution can demonstrate: // a dead branch that never runs is invisible to a behavioural test and // still there for the next reader to revive. + // + // CONTROL: "matches nothing" has two causes, and only one of them is + // already closed here. An empty haystack cannot happen — `read()` is an + // unguarded `readFileSync`, so a bad path throws rather than yielding ''. + // A wrong needle is not covered by that: a typo'd identifier matches + // nothing against a file where the code is sitting in plain sight. So + // match a backfill-related identifier that IS present, chosen because it + // shares the substring — if this line goes red the probe below is reading + // something other than the controller, and its silence means nothing. + expect(CONTROLLER_SRC).toMatch(/THREADING_BACKFILL_MIGRATION/); expect(CONTROLLER_SRC).not.toMatch(/backfillPending/); }); });