Skip to content

[Backport cloud/1.55] Settle outstanding agent operations during detach - #19603

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

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

Conversation

@christian-byrne

Copy link
Copy Markdown
Contributor

Summary

Manual cloud/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: e488c2a3-0aaf-4847-b4d4-58c8ad21cef9

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.

@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
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

🎨 Storybook: ✅ Built — View Storybook

Details

⏰ Completed at: 09/30/2026, 08:22:48 AM UTC

Links

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

📊 Browser Reports
  • chromium: View Report (✅ 2100 / ❌ 0 / ⚠️ 1 / ⏭️ 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)

🌾 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 e268690bf686b08ac522cc2abf6a2adb8a8f1df3

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:21
@christian-byrne
christian-byrne merged commit 7e2d6c9 into cloud/1.55 Sep 30, 2026
97 checks passed
@christian-byrne
christian-byrne deleted the backport-19595-cloud-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              @@
##             cloud/1.55   #19603   +/-   ##
=============================================
  Coverage              ?   80.55%           
=============================================
  Files                 ?     2210           
  Lines                 ?   117142           
  Branches              ?    35458           
=============================================
  Hits                  ?    94364           
  Misses                ?    22391           
  Partials              ?      387           
Flag Coverage Δ
unit 80.55% <100.00%> (?)

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%> (ø)
🚀 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 5 finding(s).

Severity Count
🟡 Medium 2
🟢 Low 3

Panel: 8/8 reviewers contributed findings.

}
}

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 — settle() still calls deps.onBatchSettled(outcome) raw, so the throwing listener this change hardens against still escapes on the acknowledged/timeout path — and the consequence is worse there: settle() nulls inFlight before notifying but calls pump() after, so a throw leaves queued batches with nothing in flight and no timer armed until an unrelated enqueue()/flush() happens to pump them, while the exception escapes into the doc_ops_result dispatch and the result-timeout callback. Route this call through guardedSettlementNotifier as well.

Raised by 3 of 8 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case, kimi-k3-max adversarial).

}

function drainOutstanding(notify: (outcome: BatchOutcome) => void): void {
seal()

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 — drainOutstanding() begins with seal() — which chunks the open batch and JSON-serializes each op for wire sizing — before clearing the in-flight timer or splicing the queue, so a non-serializable widget value (circular ref, BigInt, throwing toJSON) aborts teardown half-done: in detach() detached is already latched, the result-timeout timer stays armed, pending() stays non-zero and nothing is settled; in abortAll() old-lineage in-flight/queued work survives the reset. The previous detach() cleared the timer and queue unconditionally — do that before, or independently of, the fallible sealing work.

Raised by 2 of 8 reviewers (gpt-5.6-sol-max adversarial, claude-opus-5-thinking-max adversarial).

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

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 — The detached branch constructs a new guardedSettlementNotifier on every admit() call, so reportedFailure resets each time and the report-once behavior the new detach tests pin does not hold here. Since admit no longer bails when detached, a listener that throws consistently (e.g. settleHumanOps reaching a projection already destroyed in teardown) emits one reportError per admitted batch, and a single node drag admits many — hoist one notifier per sender, or reuse the detach-time one, to bound it.

Raised by 5 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, kimi-k3-max edge-case).

return
}
if (workflowId === null) {
deps.onBatchSettled({ state: 'undeliverable', ops: minted })

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 — The workflowId === null branch sits two lines below the newly guarded detached branch but still calls deps.onBatchSettled raw, so a throwing listener propagates out of admit()/enqueue() into the graph-mutation caller after lastMintedVersion was already advanced on line 333 — the ops are lost and the version counter has moved. Use the same notifier here so all three settle-on-admit paths behave alike.

Raised by 4 of 8 reviewers (claude-opus-5-thinking-max adversarial, kimi-k3-max adversarial, claude-opus-5-thinking-max edge-case, kimi-k3-max edge-case).


function drainOutstanding(notify: (outcome: BatchOutcome) => void): void {
seal()
const queued = queue.splice(0)

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 — drainOutstanding splices the queue and nulls inFlight before notifying, and the guard swallows every failure after the first report, so a batch whose settleHumanOps throws is dropped from the sender while projection.settleLocalWrites never runs for it — those optimistic local writes stay pending forever, with at most one reportError per drain no matter how many batches failed. Consider surfacing the failure count (or settling the projection defensively) so the divergence isn't invisible.

Raised by 1 of 8 reviewers (claude-opus-5-thinking-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