Repository navigation
test: fix rebind assertion in follower_replaced CRDT test - #19584
Conversation
Follow-up to #19522. Cursor review flagged that the test asserted bind was "lastCalledWith" the SAME follower object throughout, so it could not distinguish a correct rebind from a stale one. Mirror the sibling doc_reset test's pattern: assign a genuinely different follower object before dispatching follower_replaced and assert bind was called with that new object. Also retitle the test (workflowId never actually changed, so "a deliberate workflow switch" was misleading) and assert replaceOnNextFrame is not armed on this path. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018MwRoaxpVReK7UMkaC5NxA
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
🎨 Storybook: ✅ Built — View Storybook🧩 Custom Nodes Ecosystem Matrix: 🟡 Withheld — could not measureExecutes the frontend JS of every registry pack that ships any, against this change, in both renderers. The eight This candidate changes nothing the matrix measures, so every expensive stage was skipped. Reproduce locally# build one shard's fixture, then run it
python3 scripts/registry-census/build_matrix.py --shard 1/4
MATRIX_RENDERER=vue MATRIX_VUE=1 \
npx vitest run --config vitest.matrix.config.mts
Full docs: scripts/registry-census/README.md 🌾 Fallow: ✅ PassedFallow audits the diff for duplication, complexity and dead code. It gates on new findings only, so when the audit completes, a red is something this PR introduced or moved — never inherited backlog. A red can also mean the audit itself did not finish; the details below say which happened. No new findings in the changed files. Reproduce locally# the base the gate compared against
npx fallow audit --root . --quiet --format json \
--changed-since b16e68a9188a82f3d9089c3ca5542146e769f71b
Full docs: ADR-DEVEX-LINT-0015 |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #19584 +/- ##
==========================================
- Coverage 85.18% 83.72% -1.47%
==========================================
Files 2414 2422 +8
Lines 136302 145180 +8878
Branches 36903 39923 +3020
==========================================
+ Hits 116114 121553 +5439
- Misses 19716 23252 +3536
+ Partials 472 375 -97
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🔍 Cursor Review — Consolidated panel
Triggered by @christian-byrne.
Found 1 finding(s).
| Severity | Count |
|---|---|
| 🟢 Low | 1 |
Panel: 8/8 reviewers contributed findings.
There was a problem hiding this comment.
🔍 Cursor Review — Consolidated panel
Triggered by @christian-byrne.
Round 2 — ledger: 1 prior finding(s) across 1 round(s) (0 never answered).
Found 2 finding(s).
| Severity | Count |
|---|---|
| ⚪ Nit | 2 |
Panel: 8/8 reviewers contributed findings.
There was a problem hiding this comment.
🔍 Cursor Review — Consolidated panel
Triggered by @christian-byrne.
Round 3 — ledger: 3 prior finding(s) across 2 round(s) (0 never answered).
Found 2 finding(s).
| Severity | Count |
|---|---|
| 🟢 Low | 1 |
| ⚪ Nit | 1 |
Panel: 8/8 reviewers contributed findings.
There was a problem hiding this comment.
🔍 Cursor Review — Consolidated panel
Triggered by @christian-byrne.
Round 4 — ledger: 5 prior finding(s) across 3 round(s) (0 never answered).
Found 2 finding(s).
| Severity | Count |
|---|---|
| 🟢 Low | 1 |
| ⚪ Nit | 1 |
Panel: 8/8 reviewers contributed findings.
There was a problem hiding this comment.
🔍 Cursor Review — Consolidated panel
Triggered by @christian-byrne.
Round 5 — ledger: 6 prior finding(s) across 3 round(s) (0 never answered).
Found 3 finding(s).
| Severity | Count |
|---|---|
| 🟡 Medium | 1 |
| 🟢 Low | 2 |
Panel: 8/8 reviewers contributed findings.
There was a problem hiding this comment.
🔍 Cursor Review — Consolidated panel
Triggered by @christian-byrne.
Round 6 — ledger: 7 prior finding(s) across 3 round(s) (3 never answered).
Found 3 finding(s).
| Severity | Count |
|---|---|
| 🟡 Medium | 1 |
| ⚪ Nit | 2 |
Panel: 8/8 reviewers contributed findings.
christian-byrne
left a comment
There was a problem hiding this comment.
Reviewed exact head 5a74242dfdf88981b2fc892f833162ad46f11d6b against current production follower-switch ordering and all six Cursor rounds. The test now drives the real reactive wf-1→wf-2 switch, mirrors synchronous follower_replaced emission from subscribe, pins wf-1 unbind, wf-2 bind-before-subscribe intent, strict replacement identity, discard-before-rebind ordering, zeroed applied state despite a nonzero replacement counter, and no reset arm. Local exact-file proof: NODE_OPTIONS=--no-experimental-webstorage pnpm vitest run src/workbench/extensions/agent/crdt/useAgentCrdtFollower.test.ts (88/88). Mutation proof: binding a captured stale follower fails this case at the strict identity assertion. Hosted checks are green or still settling from this exact head; do not merge until all required checks complete. No remaining code finding.
Summary
Follow-up to #19522: fixes a test-quality gap in
useAgentCrdtFollower.test.tsthat Cursor's review bot correctly identified (review comment).Changes
What: In the test
a follower_replaced ... still rebinds and clears applied state(around line 705 onmain),bridge().followerwas never reassigned to a different object before thefollower_replaceddispatch. That meant the assertionexpect(projectionState.bind).toHaveBeenLastCalledWith('wf-1', bridge().follower)compared the same object reference to itself — it could pass even if the rebind logic used a stale follower, so it couldn't actually distinguish a correct rebind from a broken one.Before: the test asserted
bindwas last called withbridge().follower, read after the dispatch, which is always the same object the test started with (nothing in the test ever changes it). A regression that rebinds using a captured/stale follower reference instead of the live one would still pass this assertion.After: mirroring the sibling
doc_reset-then-follower_replacedtest a few hundred lines down (which doesbridge().follower = { updatesApplied: 0, doc: replacementDoc }before dispatching), this test now assigns a genuinely new follower object tobridge().followerbefore dispatchingfollower_replaced, and assertsbindwas called with that new object. This actually exercises the rebind.Also addressed, both flagged in the same review:
workflowIdnever changed (stayed'wf-1'throughout), so that scenario wasn't actually exercised. Retitled to "a follower_replaced for the same workflow with no preceding doc_reset (e.g. a resubscribe swap)..." to match what it actually tests.expect(projectionState.replaceOnNextFrame).not.toHaveBeenCalled()to assert this path deliberately does not arm a lineage replacement, distinguishing it from the reset-then-replace sibling test.Breaking: none.
Dependencies: none.
Review Focus
onFollowerReplacedinuseAgentCrdtFollower.tsto rebind with a stale/captured follower reference instead of the livebridge.follower, ran the suite, saw both this test and the siblingdoc_resettest fail, then reverted the change.git diffconfirms only the test file changed in the final commit.useAgentCrdtFollower.test.tspass;eslint/oxlint/typecheck:app(run via the pre-commit hook) are clean on the changed file.🤖 Generated with Claude Code
https://claude.ai/code/session_018MwRoaxpVReK7UMkaC5NxA
Generated by Claude Code