Skip to content

[Backport core/1.55] Settle outstanding agent operations during detach - #19602

Merged
christian-byrne merged 1 commit into
core/1.55from
backport-19595-core-1.55
Sep 30, 2026
Merged

christian-byrne merged 1 commit into
core/1.55from
backport-19595-core-1.55

Conversation

@christian-byrne

Copy link
Copy Markdown
Contributor

Summary

Manual core/1.55 backport of #19595. It settles in-flight, queued, open, and post-detach agent operations without silent drops, isolates settlement-listener failures, and preserves late-result accounting.

Validation

  • focused sender and coalescer suites: 64 tests passed
  • app typecheck passed
  • cherry-pick applied without conflicts
  • source PR passed fallow, lint, typecheck, agent review, and 100% diff coverage

## Summary

Clean replacement for #18276. It preserves the reviewed three-file
detach fix without the old branch history that violated the
commit-trailer policy.

- settle in-flight, queued, and open CRDT batches when the sender
detaches
- isolate settlement-listener failures so later batches still settle and
unsubscribe still runs
- keep detach idempotent
- preserve the late-result accounting merged in #18538

## Validation

- `opSender.test.ts` and `opCoalescer.test.ts`: 61 tests passed
- app typecheck passed
- changed-file ESLint, Oxlint, and formatting checks passed
- pre-commit quality gates passed

## End-to-end coverage

No new browser test is included because this fix is at the sender
teardown boundary: the regression is the exact settlement outcome and
callback order for in-memory queued batches, including a failed initial
transport send. Those states are not observable through the browser UI.
The focused unit tests exercise the timer, transport, settlement, and
repeated-detach boundaries directly, and the changed production lines
have 100% diff coverage.
@coderabbitai

coderabbitai Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Ignore keyword(s) in the title.

⛔ Ignored keywords (2)
  • [release]
  • [backport

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository: Comfy-Org/ComfyUI_frontend/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Team

Run ID: 466f40eb-0bc1-4d9a-bcd4-301fd42dcbf3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

🎭 Playwright: ✅ 2121 passed, 0 failed · 2 flaky

📊 Browser Reports
  • chromium: View Report (✅ 2100 / ❌ 0 / ⚠️ 2 / ⏭️ 13)
  • chromium-2x: View Report (✅ 2 / ❌ 0 / ⚠️ 0 / ⏭️ 0)
  • chromium-0.5x: View Report (✅ 1 / ❌ 0 / ⚠️ 0 / ⏭️ 0)
  • mobile-chrome: View Report (✅ 18 / ❌ 0 / ⚠️ 0 / ⏭️ 0)

🎨 Storybook: ✅ Built — View Storybook

Details

⏰ Completed at: 09/30/2026, 08:19:49 AM 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 51bf8b857d68836e582cfd607fad13a021f7f0a3

Full docs: ADR-DEVEX-LINT-0015

🧩 Custom Nodes Ecosystem Matrix: ✅ Passed

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.

Stage Result What a failure here means
pin-status success Informational. It never fails the build; it warns when the corpus snapshot is over 30 days old.
corpus success Infrastructure: the pack mirror could not be fetched, validated or cached. Not your diff.
shards success Harness integrity, not pack breakage. A shard only checks that every built spec wrote its row; vitest's own exit code is deliberately ignored because pack code leaks unhandled rejections.
verdicts success The population verdict per renderer. This is the stage that judges packs. Exit 1 is FAIL; exit 2 is withheld — rows were missing, so nothing was measured, which is not the same as your change breaking packs.
detection-proofs success The instrument self-test: the matrix must FAIL on a deliberately poisoned corpus. A failure here means the gate cannot be trusted this run, in either direction.

On a pin-bump PR, a red gate means the ecosystem moved — not that your diff broke something. That is what the bump PR is for. Outside a pin bump or a cold rebuild of the unpinned tail, a red means the diff.

Note the corpus size and the executed count are different numbers, and the verdict is against the executed count: roughly 3,100 of ~5,100 packs ship no extension-shaped JS and are 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

@github-actions
github-actions Bot requested a review from ryan-di September 30, 2026 08:18
@christian-byrne christian-byrne added backport Backporting a PR onto a release candidate cursor-review Trigger multi-model Cursor agent review on this PR labels Sep 30, 2026
@christian-byrne
christian-byrne merged commit 7c1c1c6 into core/1.55 Sep 30, 2026
117 of 118 checks passed
@christian-byrne
christian-byrne deleted the backport-19595-core-1.55 branch September 30, 2026 08:22
@github-actions github-actions Bot added the risk:high PR risk grade (advisory shadow check; grader-owned) label Sep 30, 2026
@codecov

codecov Bot commented Sep 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@              Coverage Diff              @@
##           core/1.55   #19602      +/-   ##
=============================================
- Coverage      84.65%   84.65%   -0.01%     
=============================================
  Files           2314     2314              
  Lines         131514   131531      +17     
  Branches       33212    35095    +1883     
=============================================
+ Hits          111328   111341      +13     
- Misses         19828    19832       +4     
  Partials         358      358              
Flag Coverage Δ
unit 80.55% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/workbench/extensions/agent/crdt/opSender.ts 100.00% <100.00%> (ø)

... and 1 file 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 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 6 finding(s).

Severity Count
🟡 Medium 3
🟢 Low 3

Panel: 8/8 reviewers contributed findings.

queue.length = 0
open = null
unsubscribe()
try {

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.

🟡 Medium — detach() now sets detached = true and delegates all clearing to drainOutstanding(), whose first statement seal() runs chunkWireOps -> JSON.stringify over every open op and can throw on a non-serializable value (BigInt, circular widget value); a throw there — or from unsubscribe() — leaves inFlight with its armed timer, queue, and open populated, which the old straight-line clears could never do. The new if (detached) return makes every retry a no-op, so that half-torn-down state is permanent and contradicts the "permanently stop this sender" contract. Splice the queue and null inFlight/open (clearing the timer) before the chunking work, or clear in the finally; abortAll() has the same exposure with no finally at all. Raised by 4 of 8 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case, gpt-5.6-sol-max adversarial, gpt-5.6-sol-max edge-case).

}
}

function settle(outcome: BatchOutcome): void {

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.

🟡 Medium — This PR adds guardedSettlementNotifier on the premise that deps.onBatchSettled can throw, but settle() — the path every acknowledged, unacknowledged, and unbound batch takes — still calls it bare, after inFlight = null and before pump(). A throwing listener therefore leaves inFlight === null with a non-empty queue and no armed timer, stalling the FIFO until some unrelated later enqueue()/flush() happens to re-drive it, and it cuts the abortIfUnbound() settle->pump->transmit cascade short. Raised by 2 of 8 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case).

})
return
}
if (workflowId === null) {

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.

🟡 Medium — The new detached branch just above routes its settlement through guardedSettlementNotifier, but this sibling workflowId === null branch still calls deps.onBatchSettled unguarded. admit is invoked synchronously from graph-mutation code via coalescer.enqueue, so a throwing listener escapes into the middle of a litegraph edit instead of being contained, after projection.noteLocalWrites() has already recorded the write. Both branches settle the same { state: 'undeliverable', ops: minted } outcome and should share the guard. Raised by 3 of 8 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case, gemini-3.1-pro adversarial).

mintWireOps([operation], { actor, baseVersion: baseVersion + index })
)
lastMintedVersion = baseVersion + minted.length - 1
if (detached) {

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.

🟢 Low — A fresh guardedSettlementNotifier is constructed on every detached admission, so its reportedFailure latch is always false and the once-only dedupe never takes effect here. A systematically throwing onBatchSettled emits one reportError per post-detach admit — from a hot edit path — which is exactly the telemetry flood the latch was added to prevent in detach()/abortAll(). Hoisting one detach-scoped notifier into the closure would bound it. Raised by 6 of 8 reviewers (claude-opus-5-thinking-max adversarial, gemini-3.1-pro adversarial, kimi-k3-max adversarial, claude-opus-5-thinking-max edge-case, gemini-3.1-pro edge-case, kimi-k3-max edge-case).

lastMintedVersion = baseVersion + minted.length - 1
if (detached) {
guardedSettlementNotifier('failure_settling_agent_op_sender_detach')({
state: 'undeliverable',

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.

🟢 Low — This path settles all minted ops as one outcome without passing them through chunkWireOps, so admit(300 ops) after detach emits a single 300-op undeliverable batch, while the new test at opSender.test.ts pins [256, 44] for the same 300 ops admitted just before detach. onBatchSettled consumers therefore see batch sizes that depend only on which side of detach() an admission landed. Raised by 2 of 8 reviewers (gemini-3.1-pro adversarial, claude-opus-5-thinking-max edge-case).


function admit(operations: GraphOperation[]): void {
if (detached || operations.length === 0) return
if (operations.length === 0) return

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.

🟢 Low — Dropping detached from this guard means a permanently stopped sender still calls deps.workflowId(), deps.baseVersion(), and deps.actor(), mints a fresh uuid per op, and advances lastMintedVersion after the owner explicitly detached. In useAgentCrdtFollower's teardown, sender.detach() runs several steps before projection.destroy(), so a late admission settles against an about-to-be-destroyed projection. Settling without minting (or guarding the dep reads) would keep the intended undeliverable behavior without the extra exposure. Raised by 3 of 8 reviewers (gemini-3.1-pro adversarial, claude-opus-5-thinking-max adversarial, kimi-k3-max adversarial).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Backporting a PR onto a release candidate 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