Skip to content

test(agent): pin sender telemetry routing and label wire-object cases - #19865

Merged
christian-byrne merged 4 commits into
mainfrom
op264-sender-telemetry-pins
Oct 3, 2026
Merged

christian-byrne merged 4 commits into
mainfrom
op264-sender-telemetry-pins

Conversation

@christian-byrne

@christian-byrne christian-byrne commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

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 the toJSON wire-object cases whose null and [] rows currently render as undefined, and adds the missing object-without-op_id row.

Changes

  • What: test-only. Three new opSender.test.ts cases, a relabelled chunkWireOps toJSON table with one new row, and a shared circularAddNode fixture; no production file is touched.
    • settles a displaced admission under the detach error type when sealing detaches — a detach() raised from seal()'s settlement callback must route the displaced admission through notifyDetachSettlement, so it reports failure_settling_agent_op_sender_detach and coalesces with the other detach-path settlements. Deleting the if (detached) branch of restoreReentrantAdmission leaves 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-reset abortAll() must stay distinguishable from the detach-path teardown slug. Hardcoding drainOutstanding's chunk error type back to failure_chunking_agent_op_sender_teardown leaves 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 — stateEpoch is bumped after admit()'s early returns precisely so a nested admit() 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.
    • the chunkWireOps toJSON cases are named via $label instead of %j. Under it.for, %j renders the null and [] rows as undefined, which together with the standalone undefined case gives three tests the name rejects 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 without op_id, is the only one that reaches the post-parse op_id check.
    • the circular add_node fixture, previously copied inline eleven times, is now one circularAddNode(id) helper.
  • Breaking: none.

Review Focus

Each case was validated by deleting the corresponding production branch on cdfb7f3 and 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.ts is 101 passed; typecheck, type-aware oxlint, the vitest-cleanup audit, oxfmt --check, eslint and fallow audit are 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.

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.
@christian-byrne
christian-byrne requested a review from a team October 2, 2026 03:05
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

🎨 Storybook: ✅ Built — View Storybook

Details

⏰ Completed at: 10/02/2026, 11:58:47 PM UTC

Links

🌾 Fallow: ✅ Passed

Fallow 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 measure

Executes the frontend JS of every registry pack that ships any, against this change, in both renderers. The eight ecosystem-matrix shard checks are a harness self-test; the pack verdict is matrix-verdict.

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

@christian-byrne christian-byrne added the cursor-review Trigger multi-model Cursor agent review on this PR label Oct 2, 2026
@coderabbitai

coderabbitai Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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
  • Configuration used: Repository: Comfy-Org/ComfyUI_frontend/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Team
  • Run ID: 793d1917-65a1-467b-b574-592382e30319
📥 Commits

Reviewing files that changed from the base of the PR and between ae0844d and 65edfad.

📒 Files selected for processing (2)
  • src/workbench/extensions/agent/crdt/opEnvelope.test.ts
  • src/workbench/extensions/agent/crdt/opSender.test.ts

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.


📝 Walkthrough

Walkthrough

The CRDT tests cover invalid serialization inputs, circular batches that cannot be chunk, and reentrant settlement and admission behavior.

Changes

CRDT operation sender tests

Layer / File(s) Summary
Invalid serialization cases
src/workbench/extensions/agent/crdt/opEnvelope.test.ts
The test uses labeled cases and adds an object missing op_id. The expected serialization error remains unchanged.
Circular batch settlement
src/workbench/extensions/agent/crdt/opSender.test.ts
A shared helper creates circular add-node operations. Tests cover teardown, abort, recovery, repeated chunk failures, telemetry, and valid-prefix handling.
Reentrant settlement and admission
src/workbench/extensions/agent/crdt/opSender.test.ts
Tests cover detachment during settlement and nested admission while unbound. After rebinding, the displaced outer admission is sent under wf-new.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Suggested reviewers: drjkl

Merge Risk: ⚪ Minimal · up to 65edf

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)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
End-To-End Regression Coverage For Fixes ✅ Passed The PR title and all four commit subjects do not contain bug-fix language such as “fix”, “fixed”, “fixes”, “fixing”, “bugfix”, or “hotfix”. Therefore the custom check does not require an end-to-end re…
Website End-To-End Regression Coverage ✅ Passed The changed files are src/workbench/extensions/agent/crdt/opEnvelope.test.ts and src/workbench/extensions/agent/crdt/opSender.test.ts. No files under apps/website/src/ or apps/website/public/ …
Adr Compliance For Entity/Litegraph Changes ✅ Passed The changed files are src/workbench/extensions/agent/crdt/opEnvelope.test.ts and src/workbench/extensions/agent/crdt/opSender.test.ts. They are outside src/lib/litegraph/, src/ecs/, and the li…
Title check ✅ Passed The title accurately summarizes the test changes: it pins sender telemetry routing and improves wire-object case labels.
Description check ✅ Passed The description follows the repository template and clearly documents the test changes, review focus, validation results, and why browser E2E does not apply.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Oct 2, 2026
@codecov

codecov Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

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     
Flag Coverage Δ
billing-web-unit ?
unit 82.31% <ø> (+0.06%) ⬆️
website-unit ?

Flags with carried forward coverage won't be shown. Click here to find out more.
see 1083 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions Bot added the risk:high PR risk grade (advisory shadow check; grader-owned) label Oct 2, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 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.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Oct 2, 2026
@datadog-official

This comment has been minimized.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Oct 2, 2026
@github-actions github-actions Bot added risk:medium PR risk grade (advisory shadow check; grader-owned) and removed risk:high PR risk grade (advisory shadow check; grader-owned) labels Oct 2, 2026
@DrJKL
DrJKL self-requested a review October 2, 2026 11:11

@DrJKL DrJKL left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
  1. P3, PR description is stale at this head. It says the focused run is "100 passed". At ae0844d it is 101 (Tests 101 passed (101)). The fourth bullet describes only the $label relabel. It does not mention the fifth row (an object without op_id) that be44c5d added, or that the mint-cursor bug found while writing the unbound test moved to #19871. Suggested wording: "adds three opSender tests, relabels the four existing chunkWireOps rows, and adds a fifth row for an object without op_id; 101 passed; the mint-cursor production fix is carried by #19871."
  2. P3, the %j claim overstates the collision. The description says the toJSON cases "currently all render as undefined" and that "three tests in that block" share the name. A verbose run of the base file renders the table as undefined, 42, "not-an-operation", undefined. Only the null and [] rows collide inside it.for. The third rejects an op whose toJSON returns undefined is the standalone explicit-undefined test at base opEnvelope.test.ts:140-147. The fix is right. Only the explanation needs adjusting: "%j renders the null and [] rows as undefined, which together with the standalone undefined case gives three tests the same name."
Existing findings confirmed or contested
  1. Mint cursor pinned to null by the nested unbound admit (thread). Confirmed as a real production bug. I appended admit([addNode(4)]); flush() to the unbound test and got expected [ 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 touches lastMintedWorkflowId, and the test never mints again. I agree with deferring it. #19871 at 1055431 fixes opSender.ts and pins the same defect more directly in an 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.
  2. 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 as undeliverable. With the detached branch deleted, this is the only failing test.
  3. No row reached the post-parse op_id check (thread). Addressed in be44c5d. Deleting the op_id checks in wireSize fails only the an object without op_id row, 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.toThrow at 965 and 1247: this review, open.
  • P3 Nit { serialized: unknown } annotation: this review, open.
  • P3 comment restating wireSize guards: this review, open.
  • P3 stale description (count, fifth row, #19871): this review, open.
  • P3 %j collision 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_id row: addressed in be44c5d.

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() with onTestFinished in the unbound test so it runs when an assertion fails. Rejected: nothing leaks. onOpsResult is () => vi.fn(), so there is no subscription, beforeEach reinstalls fake timers, and 17 sibling tests use the same end-of-test detach().
  • 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 createOpSender deps 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 op narrowing, and let workflow: string | null: no assertion, no any, 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.

Comment on lines +957 to +962
const circularNode = addNode(1)
const node: AddNodeOperation['node'] & Record<string, unknown> = {
...circularNode.node
}
node.circular = node
circularNode.node = node

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
expect(() => sender.abortAll()).not.toThrow()
sender.abortAll()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 65edfad: sender.abortAll() is now called directly.

localSender.admit([circularNode])
workflow = 'wf-new'

expect(() => localSender.admit([addNode(2)])).not.toThrow()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
expect(() => localSender.admit([addNode(2)])).not.toThrow()
localSender.admit([addNode(2)])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 65edfad: localSender.admit([addNode(2)]) is now called directly.

Comment on lines +154 to +155
// The only row that reaches the post-parse op_id check; every other
// serialized form is refused by the leading-brace guard above it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
// The only row that reaches the post-parse op_id check; every other
// serialized form is refused by the leading-brace guard above it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 65edfad: comment removed.

{ label: 'an object without op_id', serialized: { op: 'add_node' } }
])(
'rejects an op whose toJSON returns $label',
({ serialized }: { serialized: unknown }) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
({ serialized }: { serialized: unknown }) => {
({ serialized }) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 65edfad: annotation removed; typecheck:app passes with the inferred row type.

@github-actions github-actions Bot added risk:high PR risk grade (advisory shadow check; grader-owned) and removed risk:medium PR risk grade (advisory shadow check; grader-owned) labels Oct 3, 2026

@DrJKL DrJKL left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.toThrow at the abort test: addressed in 65edfad (reply).
  • P3 Nit redundant not.toThrow at the detach test: addressed in 65edfad (reply).
  • P3 comment restating wireSize guards: addressed in 65edfad (reply).
  • P3 Nit { serialized: unknown } annotation: addressed in 65edfad (reply).
  • P3 stale description (101 passed, fifth row, #19871): description updated.
  • P3 %j collision explanation: description updated to say the null and [] 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_id row (thread): addressed in be44c5d.

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.

@DrJKL DrJKL removed their assignment Oct 3, 2026
@christian-byrne
christian-byrne added this pull request to the merge queue Oct 3, 2026
Merged via the queue into main with commit 142e4c7 Oct 3, 2026
99 checks passed
@christian-byrne
christian-byrne deleted the op264-sender-telemetry-pins branch October 3, 2026 01:15
Penguinjanator pushed a commit to Penguinjanator/ComfyUI_frontend that referenced this pull request Oct 7, 2026
…#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cursor-review Trigger multi-model Cursor agent review on this PR risk:high PR risk grade (advisory shadow check; grader-owned)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants