Repository navigation
test(agent): pin sender telemetry routing and label wire-object cases - #19865
Conversation
Three fixes that landed in #19852 changed behaviour that no test distinguishes. Deleting each one on current main leaves all 97 sender and envelope tests green: - the detach branch of restoreReentrantAdmission: a detach() raised from seal()'s settlement callback must settle the displaced admission through the detach notifier, so it reports failure_settling_agent_op_sender_detach and coalesces with the other detach-path settlements - abortAll()'s caller-supplied chunk error type: an open batch that cannot be chunked during a doc-reset abort must stay distinguishable from the detach-path teardown slug in telemetry - the epoch bump sitting after admit()'s early returns: a nested admit() that only settles itself because the doc is unbound must not invalidate the outer admission, whose ops are already applied locally Also name the toJSON wire-object cases. Under it.for, %j renders both null and [] as "undefined", so three tests in chunkWireOps share the name "rejects an op whose toJSON returns undefined" and the two cases the guard exists for are the mislabelled ones.
🎨 Storybook: ✅ Built — View Storybook🌾 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 c28e82c20bc46aa07172dd509faaf9c87973f233
Full docs: ADR-DEVEX-LINT-0015 🧩 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 |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review. Your free on-demand review promotion remains active until October 9, 2026 at 6:00 PM UTC. 📝 WalkthroughWalkthroughThe CRDT tests cover invalid serialization inputs, circular batches that cannot be chunk, and reentrant settlement and admission behavior. ChangesCRDT operation sender tests
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Other Suggested reviewers: Merge Risk: ⚪ Minimal · up to The change adds targeted CRDT regression tests without an identified production behavior risk; no merge-blocking issue is established. 🚥 Pre-merge checks | ✅ 7✅ Passed checks (7 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #19865 +/- ##
==========================================
+ Coverage 84.76% 85.14% +0.38%
==========================================
Files 3422 2410 -1012
Lines 164026 139564 -24462
Branches 42804 36045 -6759
==========================================
- Hits 139043 118838 -20205
+ Misses 23036 20356 -2680
+ Partials 1947 370 -1577
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 3 finding(s).
| Severity | Count |
|---|---|
| 🟡 Medium | 1 |
| 🟢 Low | 1 |
| ⚪ Nit | 1 |
Panel: 8/8 reviewers contributed findings.
This comment has been minimized.
This comment has been minimized.
DrJKL
left a comment
There was a problem hiding this comment.
Verdict: ready to approve. The three new sender tests each fail under exactly the production mutation the description names, and nothing else does. What's left is P3 cleanup and a stale description.
I reproduced each mutation claim at ae0844d. Deleting the if (detached) branch of restoreReentrantAdmission, hardcoding the abort chunk slug to failure_chunking_agent_op_sender_teardown, and moving stateEpoch++ to the top of admit() each turn exactly one test red: the matching new test, with 100 others passing. Against the base tests, all three mutations leave 97/97 green, so these cases close a real gap. Removing the post-parse op_id check fails only the new an object without op_id row.
Inline: 5 comments, all P3 (fixture duplication, two redundant not.toThrow wrappers, an unneeded callback annotation, a comment that restates production code).
Findings without an anchorable line
- P3, PR description is stale at this head. It says the focused run is "100 passed". At
ae0844dit is 101 (Tests 101 passed (101)). The fourth bullet describes only the$labelrelabel. It does not mention the fifth row (an object without op_id) thatbe44c5dadded, or that the mint-cursor bug found while writing the unbound test moved to #19871. Suggested wording: "adds threeopSendertests, relabels the four existingchunkWireOpsrows, and adds a fifth row for an object withoutop_id; 101 passed; the mint-cursor production fix is carried by #19871." - P3, the
%jclaim overstates the collision. The description says thetoJSONcases "currently all render asundefined" and that "three tests in that block" share the name. A verbose run of the base file renders the table asundefined,42,"not-an-operation",undefined. Only thenulland[]rows collide insideit.for. The thirdrejects an op whose toJSON returns undefinedis the standalone explicit-undefined test at baseopEnvelope.test.ts:140-147. The fix is right. Only the explanation needs adjusting: "%jrenders thenulland[]rows asundefined, which together with the standalone undefined case gives three tests the same name."
Existing findings confirmed or contested
- Mint cursor pinned to
nullby the nested unbound admit (thread). Confirmed as a real production bug. I appendedadmit([addNode(4)]); flush()to the unbound test and gotexpected [ 41, 41 ] to deeply equal [ 41, 42 ]. This PR doesn't introduce it, and the new test doesn't bless it: node 2 is minted before the nested admit toucheslastMintedWorkflowId, and the test never mints again. I agree with deferring it. #19871 at1055431fixesopSender.tsand pins the same defect more directly inan admission taken while unbound leaves the bound workflow its own counter(toEqual([41, 42])) without reentrancy. Adding the assertion here would only fail until #19871 lands. - Detach listener threw without recording the outcome (thread). Addressed in
be44c5d. Line 1238 pushes the outcome before the conditional detach and the throw, and the test now pins node 2 asundeliverable. With the detached branch deleted, this is the only failing test. - No row reached the post-parse
op_idcheck (thread). Addressed inbe44c5d. Deleting theop_idchecks inwireSizefails only thean object without op_idrow, and the other four rows stay green.
Review record
- P3 circular fixture copied three more times: this review, open (optional cleanup).
- P3 Nit redundant
not.toThrowat 965 and 1247: this review, open. - P3 Nit
{ serialized: unknown }annotation: this review, open. - P3 comment restating
wireSizeguards: this review, open. - P3 stale description (count, fifth row, #19871): this review, open.
- P3
%jcollision explanation: this review, open. - Bot Medium mint cursor: confirmed real, deferred to #19871 (author reply in thread).
- Bot Low listener outcome: addressed in
be44c5d. - Bot Nit object-without-
op_idrow: addressed inbe44c5d.
Checks at ae0844d: vitest run opSender.test.ts opEnvelope.test.ts 101 passed; eslint and oxfmt --check on both files clean; four production mutations, each red on exactly its named test; the same three sender mutations against base tests stay 97/97 green; hosted CI is green (unit shards, lint-pr / typecheck, lint-pr / lint, fallow, e2e-status).
Checked and cleared
- Register
localSender.detach()withonTestFinishedin the unbound test so it runs when an assertion fails. Rejected: nothing leaks.onOpsResultis() => vi.fn(), so there is no subscription,beforeEachreinstalls fake timers, and 17 sibling tests use the same end-of-testdetach(). - Fold the new abort test into a table with the existing teardown chunk-error test. Rejected: the teardown test also owns unsubscribe and permanent detach, so a shared table would need a branch per row.
- Extract a factory for the two local
createOpSenderdeps objects. Rejected: the workflow variable and settlement callback are the scenario under test, and keeping them visible is the point. - Type widening
AddNodeOperation['node'] & Record<string, unknown>, the'node_id' in opnarrowing, andlet workflow: string | null: no assertion, noany, matches existing patterns in the file. - Test names against assertions: all three describe what they assert.
Coverage
Depth standard. Lanes: correctness, maintainability, idiomaticity, tests, documentation. Lenses: blast-radius, regression-risk-reviewer, idempotency, shared-state, boundary-discipline, fix-root-causes; ponytail, no-comments, minimize-reader-load, subtract-before-you-add, laziness-protocol, migrate-callers; typescript-best-practices, type-system-discipline; designing-test-suites, reviewing-unit-tests, test-mock-quality-analysis, consolidating-test-setup, prove-it-works; technical-writing. No lane skipped. Playwright lenses not applicable (no browser tests changed). useAgentCrdtFollower.ts not opened, since production code is unchanged.
| const circularNode = addNode(1) | ||
| const node: AddNodeOperation['node'] & Record<string, unknown> = { | ||
| ...circularNode.node | ||
| } | ||
| node.circular = node | ||
| circularNode.node = node |
There was a problem hiding this comment.
P3: This is the same six-line circular add_node fixture copied for the third time in this PR (also 1222-1227 and 1263-1268). The file goes from 8 copies at base to 11. Every copy means "an add-node op that JSON.stringify rejects", and only the id varies. One helper next to addNode would make each test open with its scenario instead of fixture plumbing:
function circularAddNode(id: number): AddNodeOperation {
const operation = addNode(id)
const node: AddNodeOperation['node'] & Record<string, unknown> = {
...operation.node
}
node.circular = node
operation.node = node
return operation
}Then each of the three new blocks becomes const circularNode = circularAddNode(1). Migrating the eight older copies can wait. I wrote this as prose instead of a suggestion block because the helper belongs next to addNode at lines 81-89, which is outside the diff hunks, so a block here would reference an undefined function.
There was a problem hiding this comment.
Addressed in 65edfad: circularAddNode(id) now sits next to addNode, and all eleven inline copies plus both enqueueCircular helpers use it.
| circularNode.node = node | ||
| sender.admit([circularNode]) | ||
|
|
||
| expect(() => sender.abortAll()).not.toThrow() |
There was a problem hiding this comment.
P3 Nit: The not.toThrow() wrapper adds no falsifier. If abortAll() threw, the test would fail on that throw before reaching the pending(), settlement, and reportError assertions below. Calling it directly says the same thing with less noise. I know the sibling teardown test at 942 uses the same form, so take this as optional.
| expect(() => sender.abortAll()).not.toThrow() | |
| sender.abortAll() |
There was a problem hiding this comment.
Addressed in 65edfad: sender.abortAll() is now called directly.
| localSender.admit([circularNode]) | ||
| workflow = 'wf-new' | ||
|
|
||
| expect(() => localSender.admit([addNode(2)])).not.toThrow() |
There was a problem hiding this comment.
P3 Nit: Same as line 965. A listener boom escaping admit() would already fail the test, and the settlement and reportError assertions below pin the behavior.
| expect(() => localSender.admit([addNode(2)])).not.toThrow() | |
| localSender.admit([addNode(2)]) |
There was a problem hiding this comment.
Addressed in 65edfad: localSender.admit([addNode(2)]) is now called directly.
| // The only row that reaches the post-parse op_id check; every other | ||
| // serialized form is refused by the leading-brace guard above it. |
There was a problem hiding this comment.
P3: The row label an object without op_id already says what makes this row different. The comment restates the order of checks inside wireSize in opEnvelope.ts, and "the leading-brace guard above it" points at code in another file, not anything above this line. If wireSize reorders its checks, the comment goes wrong and every test stays green.
| // The only row that reaches the post-parse op_id check; every other | |
| // serialized form is refused by the leading-brace guard above it. |
| { label: 'an object without op_id', serialized: { op: 'add_node' } } | ||
| ])( | ||
| 'rejects an op whose toJSON returns $label', | ||
| ({ serialized }: { serialized: unknown }) => { |
There was a problem hiding this comment.
P3 Nit: The annotation isn't needed. Vitest's it.for infers the row type from the table. I deleted it in a scratch copy and tsc --noEmit on this file exits 0. Leaving it in suggests the inference needs a workaround, and it widens serialized to unknown for no reason.
| ({ serialized }: { serialized: unknown }) => { | |
| ({ serialized }) => { |
There was a problem hiding this comment.
Addressed in 65edfad: annotation removed; typecheck:app passes with the inferred row type.
DrJKL
left a comment
There was a problem hiding this comment.
Verdict: approved at 65edfad. The three new sender tests each fail under exactly the production mutation they name, and every finding from my earlier review is addressed.
I pushed 65edfad at the maintainer's request to close my own P3 findings, and updated the description to match the head. The commit is test-only: it adds a circularAddNode(id) fixture (11 inline copies and both enqueueCircular helpers now use it), drops the two redundant not.toThrow() wrappers in the new tests, removes the comment that restated wireSize, and drops the { serialized: unknown } annotation. Net -64 lines.
Review record
- P3 circular fixture copied three more times (review): addressed in
65edfad(reply). - P3 Nit redundant
not.toThrowat the abort test: addressed in65edfad(reply). - P3 Nit redundant
not.toThrowat the detach test: addressed in65edfad(reply). - P3 comment restating
wireSizeguards: addressed in65edfad(reply). - P3 Nit
{ serialized: unknown }annotation: addressed in65edfad(reply). - P3 stale description (101 passed, fifth row, #19871): description updated.
- P3
%jcollision explanation: description updated to say thenulland[]rows collide with the standalone undefined case. - Bot Medium mint cursor pinned to
null(thread): confirmed real ([41, 41]instead of[41, 42]), not introduced here; fix and regression test carried by #19871. - Bot Low listener outcome (thread): addressed in
be44c5d. - Bot Nit object-without-
op_idrow (thread): addressed inbe44c5d.
Checks at 65edfad: vitest run opSender.test.ts opEnvelope.test.ts 101 passed; pre-commit oxfmt, type-aware oxlint, eslint, and typecheck:app passed; the three sender mutations (delete the if (detached) branch, teardown slug on abort, stateEpoch++ moved before minting) each fail exactly their named test with 100 others passing; hosted CI green (55 success, 42 skipped, 0 failed), including all 8 unit shards, unit / test, lint-pr / typecheck, lint-pr / lint, and fallow.
…#19871) ## Summary Fixes three related `OpSender` admission issues: duplicate creator-owned Lamport counters after workflow transitions, displaced admissions being dropped during reentrant sealing, and delivery starting before an admission is fully placed. ## What - Keep one mint cursor per workflow and advance it only after an admission has a target. - Preserve a displaced admission at its original queue position with its original `op_id`s. - Defer the delivery pump for the full admission so earlier-minted operations are placed before work enqueued by reentrant serialization. - Relative to `main`, change `resumes a pump requested during workflow-change sealing` from "node 3 delivered first" — the dropped-admission outcome — to "node 2 first, displaced admission kept", and add the abort-slug `reportError` assertions to `does not rechunk a prefix after serialization aborts and throws`. Comfy-Org#19874 had already moved both tests off their older values. - Add regressions for unbound admission, switching away and back, re-subscribing before acknowledgement, and resetting one workflow without resetting another workflow's cursor. - Pin the cursor against two mutants that left the suite fully green (`2b89b579f6`). These two pass on base production code: they do not pin new behavior, they stop the new cursor from silently losing behavior the old single-cursor code also had. - `lastMintedVersions.set(target, baseVersion)` in place of `baseVersion + minted.length - 1`. Every other cursor test admits one operation at a time, so the cursor's dependence on the admission's length was unasserted. Under the mutant a three-operation admission followed by another admission in the same tick re-mints `base_version` 42 and duplicates `(actor, 42)` on one document. Reachable: an undo/redo restore makes `restoreOpMinter` admit a whole multi-operation diff synchronously from `onAfterGraphConfigure`, while `docOpMinter`'s already-queued microtask admits again before the coalescer's deferred flush — two admissions, one flush, the first multi-operation. - `Math.max(observed, lastMinted + 1)` reduced to `lastMinted + 1`. No test advanced the observed sequence past the cursor, so the floor keeping a stamp at or above the sequence this follower has observed was unasserted. ## Breaking None. No exported signatures change. ## Ordering and cursor rationale Mint order is preserved within each document. A reentrant seal can change transport order across documents, but those operations have no shared document ordering relation. Workflow cursors have no capacity- or age-based eviction. During re-subscription, the observed sequence is `0` until acknowledgement, so the retained cursor is the only safe floor above stamps this actor previously minted for that workflow. A document reset clears only that document's cursor because only its lineage has been replaced. The `opSender.test.ts` conflict with Comfy-Org#19874 was resolved by merging `main` at `0a0595747b`: this branch's pump expectation and both `reportError` assertions were kept, main's `summarizeSettlement` and `nodeIdsOf` helpers were adopted, and `opSender.ts` was left byte-identical to the pre-merge head. ## Verification At head `2b89b579f6`: - `src/workbench/extensions/agent/crdt/opSender.test.ts`: 93 passed. - The same tests against base production `opSender.ts` (`b365e2a847`): 5 failed, 88 passed. The failures are the four cursor regressions plus `resumes a pump requested during workflow-change sealing`. - Mutation results, each run as the only change to `opSender.ts`: - `abortAll` clearing every cursor → 1 failed (reset isolation). - Restoring an LRU cursor bound of 1 → 3 failed (reset isolation, switch-away-and-back, unacknowledged re-subscribe). - Displaced admission settled `undeliverable` again → 1 failed (the pump test). - Removing `admit`'s pump deferral → 1 failed (the pump test). - Placing the displaced admission at the current queue tail instead of its admitted index → 1 failed (the pump test). - Appending the displaced admission after the nested group instead of prepending → 1 failed (same-workflow reentrant order). - Cursor set to `baseVersion` → 1 failed (the new multi-operation pin); `Math.max` floor dropped → 1 failed (the new observed-sequence pin). Both were green before this commit. - Agent extension suite: 136 files, 2,616 passed, 1 pre-existing expected-fail in `semanticLayoutSeparation.guard.test.ts`. - `pnpm typecheck`, oxfmt, ESLint, type-aware oxlint, and the vitest-cleanup oxlint config all clean on the changed file. - `fallow audit --changed-since origin/main`: verdict `pass`, 0 introduced findings (1 inherited complexity finding on `opSender.ts`). - Trial merge of current `main` (`cb92c2272`) is clean, and Comfy-Org#19865's new `opSender.test.ts` cases pass against this head's `opSender.ts`: 94 passed. - The black-box carrier is Comfy-Org#19876 (`agentHumanEditAfterOtherWorkflowReset.spec.ts`), stacked so this PR stays production plus unit tests. It proves the cursor half; there is no black-box case yet for a displaced admission still reaching the wire.
Summary
Three behaviours that #19852 deliberately fixed are not distinguished by any test on current
main; this adds one mutation-sensitive case per fix, names thetoJSONwire-object cases whosenulland[]rows currently render asundefined, and adds the missing object-without-op_idrow.Changes
opSender.test.tscases, a relabelledchunkWireOpstoJSONtable with one new row, and a sharedcircularAddNodefixture; no production file is touched.settles a displaced admission under the detach error type when sealing detaches— adetach()raised fromseal()'s settlement callback must route the displaced admission throughnotifyDetachSettlement, so it reportsfailure_settling_agent_op_sender_detachand coalesces with the other detach-path settlements. Deleting theif (detached)branch ofrestoreReentrantAdmissionleaves every other test green.reports an open batch it cannot chunk on abort under the abort error type— an open batch that cannot be chunked during a doc-resetabortAll()must stay distinguishable from the detach-path teardown slug. HardcodingdrainOutstanding's chunk error type back tofailure_chunking_agent_op_sender_teardownleaves every other test green; the detach slug is already pinned, the abort slug was not.keeps a displaced admission when a nested admit only settles itself unbound—stateEpochis bumped afteradmit()'s early returns precisely so a nestedadmit()that only settles itself (because the doc is unbound) does not invalidate the outer admission, whose ops are already applied to the local graph. Moving the bump to function entry leaves every other test green.chunkWireOpstoJSONcases are named via$labelinstead of%j. Underit.for,%jrenders thenulland[]rows asundefined, which together with the standalone undefined case gives three tests the namerejects an op whose toJSON returns undefined— and the two rows the guard was added for are the two that lose their labels. A fifth row, an object withoutop_id, is the only one that reaches the post-parseop_idcheck.add_nodefixture, previously copied inline eleven times, is now onecircularAddNode(id)helper.Review Focus
Each case was validated by deleting the corresponding production branch on
cdfb7f3and confirming that exactly that case fails and nothing else does.pnpm vitest run src/workbench/extensions/agent/crdt/opSender.test.ts src/workbench/extensions/agent/crdt/opEnvelope.test.tsis 101 passed;typecheck, type-awareoxlint, the vitest-cleanup audit,oxfmt --check,eslintandfallow auditare clean.Browser E2E is not applicable: all three paths require synchronous settlement-callback reentrancy and injected unserializable payloads that are not reachable through a stable browser surface. These assert the sender's observable telemetry contract and admission ordering, which is where the behaviour lives.
The unbound-reentry case surfaced a separate mint-cursor bug (a later admission re-mints the same
base_version); its production fix and regression test are carried by #19871.Follow-up to #19852 and #19859.