Skip to content

test(threading): the read-failure safety property had no executing test - #1162

Merged
lilyshen0722 merged 1 commit into
mainfrom
test/read-failure-expands-executing
Aug 23, 2026
Merged

lilyshen0722 merged 1 commit into
mainfrom
test/read-failure-expands-executing

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

@sprint-review's read of the source-regex block in threadUserState.test.js (57150): all five tests were expect(CONTROLLER_SRC).toMatch(...). Their clearest proof was the one asserting the literal shape of a catch block — reformat it and the test goes red while the behaviour is intact; regress the behaviour and it stays green.

Checking what that block was the only cover for turned up a gap rather than a redundancy: nothing anywhere executed a failing ledger read. That is the safety direction. A collapsed thread hides history invisibly; an expanded one is noisy and one click from fixed. So a DB error must expand.

What this does

Converts it in threadStateReadContract.test.js, which runs the real handler: force the migration_records query to reject, assert every root comes back expanded, assert the caller sees a payload rather than an error.

The CONTROL is load-bearing. "Everything expanded" also passes from a read broken badly enough to return junk, so the control seeds the same ledger row without the failure and asserts those roots collapse. Only the injected failure flips them.

Probe

Ran both directions before trusting it:

mutation result
catch returns cutoffUnknown: false (behaviour flipped) 1 failed — the ledger query throwing renders every root EXPANDED
catch reformatted across three lines (behaviour intact) 19 passed

That is the inverse of what the regex did.

One textual assertion stays

not.toMatch(/backfillPending/) — the exception that shows the rule. It claims code is absent, which no execution can demonstrate: a dead branch that never runs is invisible to a behavioural test and still sitting there for the next reader to revive.

npx jest __tests__/unit/models/thread __tests__/unit/controllers/thread → 10 suites, 143 passed.

🤖 Generated with Claude Code

@sprint-review, on the source-regex block in threadUserState.test.js: all
five tests were `expect(CONTROLLER_SRC).toMatch(...)`, and their clearest
proof was that one asserted the literal shape of a catch block — a reformat
turns it red while the behaviour is intact, and a behavioural regression
walks past it.

Checking what that block was the only cover for turned up a real gap rather
than a redundancy: nothing anywhere executed a failing ledger read. That is
the safety direction. A collapsed thread hides history invisibly; an
expanded one is noisy and one click from fixed. So a DB error must expand.

Converts it in threadStateReadContract.test.js, which runs the real handler:
force the migration_records query to reject, assert every root comes back
expanded, and assert the caller sees a payload rather than an error.

The CONTROL is load-bearing. An "everything expanded" assertion also passes
from a read broken badly enough to return junk, so the control seeds the
same ledger row WITHOUT the failure and asserts those roots collapse. Only
the injected failure flips them.

Probed both directions before trusting it: flipping the catch to
cutoffUnknown: false kills the test (1 failed), and reformatting the catch
across three lines kills nothing. That is the inverse of what the regex did.

Keeps one textual assertion, and it is the exception that shows the rule:
`not.toMatch(/backfillPending/)` claims code is ABSENT, which no execution
can demonstrate — a dead branch that never runs is invisible to a
behavioural test and still sitting there for the next reader to revive.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@lilyshen0722
lilyshen0722 merged commit 296582b into main Aug 23, 2026
11 checks passed
@lilyshen0722
lilyshen0722 deleted the test/read-failure-expands-executing branch August 23, 2026 04:45
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