Skip to content

test(threading): one identity per seat in the scoping fixture, and a guard - #1152

Merged
lilyshen0722 merged 1 commit into
mainfrom
fix/thread-scoping-fixture-one-identity
Aug 23, 2026
Merged

lilyshen0722 merged 1 commit into
mainfrom
fix/thread-scoping-fixture-one-identity

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

@sprint-review (57037) found seat-a carrying two user ids in one fixture: bot-1 through User.findById, where it authors the thread root, and bot-user-a through User.find, where it's a wake target. Same agent, two identities, depending which lookup you went through.

Nothing asserted the difference, so nothing failed. But this suite's entire subject is which id a seat is keyed by, and a fixture that disagrees with itself cannot tell a correct key from a wrong one — which is the same shape as the defect it was written for. installedBy looked right for as long as it did precisely because the fixture gave it the same value as the bot's row.

The rename alone wasn't enough

Unified to bot-user-a, then probed it — because a rename that changes no outcome might mean the fixture never exercised identity at all. It didn't: reintroducing the split passed 18/18. Hygiene that cannot fail is a comment.

So the consistency is now executable: one test asserts the root author's id equals the id User.find maps seat-a to, reached through the mocked lookups rather than by reading the constants back.

Probe Result
Split findById's id kills exactly the new guard
Split BOT_USER_ROWS kills the guard plus three behaviour tests

That asymmetry is right: the second is a genuine mis-keying and should take more with it.

A test about a fixture is unusual, and deliberate. 19 pass.

Not established

A full __tests__/unit/{services,models} run on my machine reports 14 failed suites / 18 failed tests. I have not shown whether any are mine.

They're almost certainly the Node 26 class in AX entry 43 — this diff is one test file, and the failing suites don't import it — but "almost certainly" is exactly the reasoning that entry warns about, and my background runs to confirm it were killed. CI at Node 22 gets to answer rather than me. If it's green, that's the answer; if not, I'll chase whatever it names.

🤖 Generated with Claude Code

…guard

@sprint-review (57037): seat-a carried two user ids in one fixture — `bot-1`
through User.findById, where it authors the thread root, and `bot-user-a`
through User.find, where it is a wake target. Same agent, two identities,
depending which lookup you went through.

Nothing asserted the difference, so nothing failed. But this suite's entire
subject is WHICH ID A SEAT IS KEYED BY, and a fixture that disagrees with
itself cannot tell a correct key from a wrong one. That is the same shape as
the defect it was written for: `installedBy` looked right for as long as it
did because the fixture gave it the same value as the bot's row.

Unified to `bot-user-a` everywhere. Then probed the rename, because a rename
that changes no outcome might mean the fixture never exercised identity at
all — and it didn't: reintroducing the split passed 18/18. Hygiene that
cannot fail is a comment.

So the consistency is now executable. One test asserts the root author's id
equals the id User.find maps seat-a to, reached through the mocked lookups
rather than by reading the constants. Probed from both sides: splitting
findById's id kills exactly it; splitting BOT_USER_ROWS kills it plus three
behaviour tests, which is the right asymmetry — the second break is a real
mis-keying and should take more with it.

A test about a fixture is unusual and deliberate here. 19 pass.

NOT ESTABLISHED: a full `__tests__/unit/{services,models}` run on this
machine reports 14 failed suites / 18 failed tests. I have not yet shown
whether any are mine. They are almost certainly the Node 26 class in AX entry
43 — this diff is one test file and the other suites do not import it — but
"almost certainly" is the reasoning that entry warns about, so CI at Node 22
gets to answer rather than me.

Co-Authored-By: Claude Opus 5 <[email protected]>
@lilyshen0722
lilyshen0722 merged commit 5b00752 into main Aug 23, 2026
11 checks passed
@lilyshen0722
lilyshen0722 deleted the fix/thread-scoping-fixture-one-identity branch August 23, 2026 00:21
lilyshen0722 added a commit that referenced this pull request Aug 23, 2026
…aked it (#1158)

@sprint-review (57122) named the gap and it is still open on main eleven
hours later. Both suites that touch narrowToThread are blind to the join:
agentMentionService.threadScoping.test.js mocks threadWakeScopeService
outright, so it never runs the real narrowing; threadWakeScope.test.js runs
the real narrowing but supplies its own `identify`.

Worse than they said. That local stand-in was `(t) => t.installedBy`, which
is the keying production STOPPED using — `installedBy` is the human installer
on half the write paths, the bug #1120 fixed. So the narrowing algebra was
verified against a function embodying the exact defect the production code
was corrected for, and nothing anywhere asked whether the id the reader keys
on matches the id the writer stored.

Writer tested. Narrowing tested. Join untested, with one side's double still
encoding the bug. Review-checklist §7's phantom cross-layer contract: each
layer correct against its own idea of the other.

threadScopingSeam.test.js runs BOTH real halves against one pg-mem database —
ThreadUserState.follow / unfollow / followByParticipation on the write side,
effectiveFollowerIds + narrowToThread on the read side — with the two identity
spaces held deliberately DISTINCT, because a fixture where they coincide
cannot discriminate a correct key from a wrong one. That is the same fixture
discipline #1152 added one layer down.

Five cases. The discriminating one writes the row under `installedBy` and
asserts the seat is NOT reached: if writer and reader disagreed, the row would
land where the narrowing never looks and the seat would go silently invisible
inside a thread it opted into. Probe: reverting `identify` to installedBy
kills all five, which is the derived expectation since every case depends on
the two spaces differing.

Also retired the stand-in in threadWakeScope.test.js — its fixture field is
now `botUserId`, opaque on purpose, because that suite is about set arithmetic
and should not have an opinion about what the key means. Whether it matches
the writer is now a different file's job.

287 tests across 20 threading suites green.

Co-authored-by: Claude Opus 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant