Repository navigation
feat(workflow): replace DynamicGroup rows in one batch spec - #1004
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Build and validate replacement rows comfy_cli/workflow_ops.py, tests/comfy_cli/test_dynamic_group.py, comfy_cli/skills/comfy/SKILL.md |
The new function validates supplied rows, applies template defaults, and generates writes for the row count and supplied fields. Connected or promoted rows stay at their indices. Tests cover validation, nested nodes, defaults, and pinned rows. |
Integrate row replacement into batches comfy_cli/workflow_ops.py, docs/op-vocabulary-v1.md, tests/comfy_cli/test_dynamic_group.py |
Batch dispatch processes row-replacement specs and records the widget targets they replace. Later conflicting writes are rejected. Documentation and tests describe operation ordering and batch conflicts. |
Sequence Diagram(s)
sequenceDiagram
participant BatchSpec
participant apply_specs
participant set_dynamic_group_rows
participant apply_op
BatchSpec->>apply_specs: Submit row replacement spec
apply_specs->>set_dynamic_group_rows: Resolve node and validate rows
set_dynamic_group_rows-->>apply_specs: Return workflow copy and ordered set_widget operations
apply_specs->>apply_op: Replay generated set_widget operations
Possibly related issues
- Decide which layer owns the DynamicGroup row-count bound ComfyUI_frontend#21288: The changes enforce the
maxschema bound or a fallback limit of 20 in comfy-cli, addressing the row-count bound described in the issue.
Possibly related PRs
- Comfy-Org/comfy-cli#1038: Both changes use promoted-widget resolution to identify DynamicGroup fields and their interior addresses.
- Comfy-Org/comfy-cli#908: The generated
set_widgetoperations are replayed under the operation contract changed by this PR.
Suggested reviewers: christian-byrne, skishore23
Priority:
Merge Risk: 
Minimal · up to 57481
-
The row-replacement change is mergeable after normal checks; no unresolved actionable issue is established.
Pre-merge checks: 
2
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
✨ Simplify code
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
There was a problem hiding this comment.
🔍 Cursor Review — Consolidated panel
Triggered by @jaeone94.
Found 5 finding(s).
| Severity | Count |
|---|---|
| 🟡 Medium | 4 |
| 🟢 Low | 1 |
Panel: 6/6 reviewers contributed findings.
There was a problem hiding this comment.
🔍 Cursor Review — Consolidated panel
Triggered by @jaeone94.
Round 2 — ledger: 5 prior finding(s) across 1 round(s) (0 never answered).
Found 7 finding(s).
| Severity | Count |
|---|---|
| 🟡 Medium | 2 |
| 🟢 Low | 3 |
| ⚪ Nit | 2 |
Panel: 6/6 reviewers contributed findings.
There was a problem hiding this comment.
🔍 Cursor Review — Consolidated panel
Triggered by @jaeone94.
Round 3 — ledger: 12 prior finding(s) across 2 round(s) (0 never answered).
Found 5 finding(s).
| Severity | Count |
|---|---|
| 🟡 Medium | 1 |
| 🟢 Low | 4 |
Panel: 6/6 reviewers contributed findings.
There was a problem hiding this comment.
🔍 Cursor Review — Consolidated panel
Triggered by @jaeone94.
Round 4 — ledger: 17 prior finding(s) across 3 round(s) (0 never answered).
Found 4 finding(s).
| Severity | Count |
|---|---|
| 🟢 Low | 2 |
| ⚪ Nit | 2 |
Panel: 5/6 reviewers contributed findings.
Reviewers that did not contribute: gpt-5.6-sol-xhigh:edge-case (error)
There was a problem hiding this comment.
🔍 Cursor Review — Consolidated panel
Triggered by @jaeone94.
Round 5 — ledger: 16 prior finding(s) across 3 round(s) (0 never answered).
Found 7 finding(s).
| Severity | Count |
|---|---|
| 🟡 Medium | 1 |
| 🟢 Low | 4 |
| ⚪ Nit | 2 |
Panel: 5/6 reviewers contributed findings.
Reviewers that did not contribute: gpt-5.6-sol-xhigh:edge-case (error)
| f"per batch (a stamp left by an earlier apply needs a higher base_version)" | ||
| ) | ||
|
|
||
| workflow, op = set_widget(workflow, graph, address, group, len(plan), actor=actor, base_version=base_version) |
There was a problem hiding this comment.
🟡 Medium — The round-3 reply says every write now lands on the node used by the owner check, pinning and stamp lookup. But the count and row writes go through the public set_widget, and that function retries on _inserted_node_id(...) after any ValueError, not only a not-found error. On a canvas that holds both node 1 and an insert:<op>:root:node:1 of the same type, a refusal specific to node 1 on the count write (e.g. disconnect shifted inputs before reducing their count) resizes the inserted copy instead. Row writes below node 1's old count still land on node 1, rows past it fail with "widget not found" and also fall through to the copy, and the batch reports success with both nodes half-rewritten. Call the implementation without the fallback here, or refuse when any returned op's _write_target is not at where.
Raised by 1 of 6 reviewers (claude-opus-5-5-xhigh adversarial).
There was a problem hiding this comment.
Fixed in 1a2969f. The count and row writes call _set_widget_impl directly on the resolved address, so a refusal on the owner can no longer be retried on an insert:… copy or a binding alias. The address is already resolved through _template_id before the owner check. Test: test_group_row_replacement_does_not_retry_a_refused_write_on_an_inserted_copy.
| return "is connected; disconnect it first" | ||
| return None | ||
|
|
||
| pinned = {r: reason for r in range(current) if (reason := pin_reason(r))} |
There was a problem hiding this comment.
🟢 Low — The round-3 reply showed that a stale legacy proxyWidgets entry does not redirect. A stale live link on a row at index >= current is a different case that the reply doesn't cover. pinned only scans range(current), so when the replacement regrows the group past that index, the row writes land on a field whose input still carries a link, and the link silently overrides the supplied value at run time. One way to get there: _write_dynamic_group_count matches removed-row inputs by inp["name"], so an input linked by widget name only (the shape used in this PR's pins_a_row_connected_by_widget_name_only test) survives a scalar set_widget loras 1 shrink with its link intact. Check linked against every index in range(len(plan)), and refuse (or pin) any recreated row that has a live link.
Raised by 3 of 6 reviewers (gpt-5.6-sol-xhigh adversarial, kimi-k3-high adversarial, kimi-k3-high edge-case).
↩︎ re-raise of #1004 (comment) (round 3)
There was a problem hiding this comment.
Fixed in 1a2969f. This is reproducible when the input does not shift: an input linked by widget.name only survives a scalar shrink. Before writing, rows from current up to the new length are checked against the linked names, and a match is refused with <group>.<N> still has a link from an earlier row; disconnect it first. Test: test_group_row_replacement_refuses_a_recreated_row_that_still_has_a_link.
| redirected = _promoted.resolve_write(workflow, graph, segments, address).redirected_from | ||
| except ValueError: # fed by another interior node: a plain link | ||
| redirected = None | ||
| if redirected: |
There was a problem hiding this comment.
🟢 Low — pin_reason treats a row as promoted only when redirected_from is set. The owner check above is stricter: it refuses any kind other than top/interior, even when redirected_from is None. So a row field that resolves to kind="host" with no redirect (e.g. promoted at the inner level of a nested subgraph) is neither pinned nor refused. It gets rewritten, and its emitted op claims a different LWW register than the where key the stamp pre-check looked up, which lets an earlier same-batch write to that field fall back to the op_id tiebreak. Pin or refuse any row whose resolved target is not a plain write on segments.
Raised by 1 of 6 reviewers (kimi-k3-high edge-case).
There was a problem hiding this comment.
Fixed in 1a2969f. A row is pinned as promoted when its resolved target is redirected or its kind is anything other than top/interior. That is the same condition the owner check uses, so a row is never rewritten through a different register than the one the stamp check looked up. I could not construct a group owner whose row field resolves to host without a redirect, so this has no dedicated test.
| if unknown: | ||
| raise ValueError(f"{group}: row {i} has unknown field(s) {unknown}; row fields: {', '.join(names)}") | ||
| for widget in widgets: | ||
| if widget.name not in row and _engine._widget_default(widget) is None: |
There was a problem hiding this comment.
🟢 Low — _widget_default falls back to the first enum option for a COMBO with no declared default, so lora_name is effectively never required. A row like {"strength": 0.8} silently picks whichever LoRA the server lists first, although SKILL.md and this error text say a field with no default must be supplied. The test only passes because its combo has options: []. Check the declared default for combo fields here, or document that a combo's first option is used.
Raised by 1 of 6 reviewers (claude-opus-5-5-xhigh edge-case).
There was a problem hiding this comment.
Documented in SKILL.md: a combo without a declared default takes its first option, so the agent should name the LoRA explicitly. The "no default" refusal covers only fields with no default at all. Using the first option is how the frontend fills a new row, so replacement keeps that default instead of adding a stricter one.
| address = "/".join(segments) if len(segments) > 1 else node_id | ||
| where = segments if len(segments) > 1 else str(node_id) | ||
| stamps = workflow.get("_widget_stamps") or {} | ||
| claimed = [group] + [f"{group}.{i}.{w.name}" for i, row in enumerate(plan) if row is not None for w in widgets] |
There was a problem hiding this comment.
🟢 Low — claimed covers only the count and the rows this call writes, so an earlier same-batch write to a row the replacement drops is accepted. For example, with 3 rows, set_widget loras.2.strength 0.3 followed by rows=[X, Y] succeeds, and the earlier op is still returned in ops even though the count write deletes that row. docs/op-vocabulary-v1.md says "an earlier write to the group in the same batch is refused". Either also check the stamps of rows len(plan)..current-1, or narrow that sentence.
Raised by 1 of 6 reviewers (claude-opus-5-5-xhigh edge-case).
There was a problem hiding this comment.
Fixed in 1a2969f. The stamp check also covers the rows the replacement drops (from the new length up to the current count), so an earlier same-batch write to a row that the count deletes is refused. Test: test_group_row_replacement_refuses_an_earlier_write_to_a_dropped_row.
| # and be settled by the random op_id. | ||
| target = _write_target(op) if op.get("op") == "set_widget" else None | ||
| if target in replaced: | ||
| count = "." not in target[2] |
There was a problem hiding this comment.
⚪ Nit — count = "." not in target[2] guesses that the target is the count register from the widget name. A DynamicGroup nested under a dynamic combo has a dotted name (see _write_target's note about model.reference_images.image_1), so a refused set_widget model.reference_images 4 gets the row-field hint "put the value in its rows instead". Record the count registers separately when filling replaced, and compare against those.
Raised by 1 of 6 reviewers (kimi-k3-high adversarial).
There was a problem hiding this comment.
Fixed in 1a2969f. replaced now records whether each claimed register is the count (the first op of the replacement). The hint uses that flag instead of guessing from a dot in the name.
| for i, row in enumerate(rows): | ||
| unknown = [key for key in row if key not in names] | ||
| if unknown: | ||
| raise ValueError(f"{group}: row {i} has unknown field(s) {unknown}; row fields: {', '.join(names)}") |
There was a problem hiding this comment.
⚪ Nit — row {i} here, and supply it in row {i} on line 819, count positions in the supplied rows list. Every other message and op address uses the group index (loras.N.*), and the two differ once a pinned row comes before the bad entry. With loras.0 connected and rows=[X, Y], a bad Y is reported as "row 1" but would land at loras.2. Say rows[{i}] instead.
Raised by 1 of 6 reviewers (claude-opus-5-5-xhigh edge-case).
There was a problem hiding this comment.
Fixed in 1a2969f. Both messages now say rows[i], which is the position in the supplied list, so it is not confused with the group index <group>.N.
1a2969f to
b7356d5
Compare
Add a `set_dynamic_group_rows` batch spec that replaces a group's rows with the complete desired list. It emits only existing `set_widget` ops: the row count, then every field of each written row. Rows with a connected field keep their index and values; supplied rows fill the other positions, and the spec refuses when a connected row would have to move. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Run the writes on a copy, resolve template ids and binding names like set_widget, rewrite seed control modes with their rows, pin rows whose field is promoted (including legacy proxyWidgets) or linked by widget name, and require fields that have no default.
An earlier write to the group at the same stamp would be settled by the random op_id tiebreak, so the count could be dropped. Also count pinned rows against the maximum, say whether a pinned row is linked or promoted, and skip non-string input names.
Check only the registers the replacement claims, so unrelated or stale stamps cannot break it, and write through the resolved owner path.
Refuse a later write only to a register the replacement wrote, report the stamp that holds the group, give the count its own hint, and name subgraph-input promotions as promoted.
Refuse a recreated row that still carries a link, guard earlier writes to dropped rows, pin rows whose write is not a plain owner write, and record which replaced register is the count.
b7356d5 to
1ec1f06
Compare
…p-replace # Conflicts: # comfy_cli/workflow_ops.py # tests/comfy_cli/test_dynamic_group.py
christian-byrne
left a comment
There was a problem hiding this comment.
the row-change contract question is ruled, and this PR's shape is the answer: whole-group replacement is accepted as the V1 contract and no structural row operation is added. comfy-multi-player #281/#282 and cloud #13279 stay closed as the named V2 rather than as abandoned work. The reasoning, the acceptance verdicts against concurrency, retry, identity, hidden rows and partial failure, and the trigger that would reopen the row-op route are in comfy-multi-player #293 (ADR-040). It depends on #292 (ADR-039), which rules that hidden rows are retained rather than deleted, which is the thing that makes replacement converge at all.
so the disposition here is keep the implemented shape, narrow what it claims, and take it out of draft. Five days in draft was the ruling being missing, not a problem with the code.
the one change that is worth treating as blocking is the sentence added to docs/op-vocabulary-v1.md: "The ops must replay in order, since the row writes address rows the count creates." that is true of comfy-cli's own model, which materializes rows from the count and answers widget not found for a field above it (the same mechanism #1006 describes), and it is not true of the shared document. dynamic-groups.ts isGroupField on comfy-multi-player #276 admits any row index below MAX_OVERFLOW_WIDGETS / fields.length, the allocation bound, not the current count, so a field write that arrives before the count that reveals it is stored hidden and becomes visible when the count lands. since op-vocabulary-v1.md is the frozen vocabulary other receivers pin, a universal ordering requirement written there would license a receiver to reject out-of-order arrival, which is a KA-4 divergence introduced by documentation rather than by code. would it work to scope it to the CLI's own apply_op replay, something like "comfy-cli's apply_op replays these in order because its workflow model materializes rows from the count; the shared document accepts them in any order"?
that scoping also unlocks a cheap improvement, non-blocking and probably a follow-up rather than this PR: once count-first is a CLI-local constraint rather than a contract requirement, the emission order is free to choose, and count-last on a grow is strictly better than count-first. with count first, a grow makes rows N..M-1 visible the instant the count lands, holding whatever registers were retained there from an earlier shrink, so the user sees stale rows that then fill in. with count last those writes stay hidden until the count reveals them already correct. a shrink is the opposite and wants count first. it narrows the partial-failure window rather than closing it, so it is worth only as much as it costs.
on the same-batch guard in apply_specs: the ADR records it as an exception with a sunset rather than as design, since it exists only because every op in a batch shares a stamp and the random op_id settles the tie. this PR already says #1007 lets it be revisited; could that be stated in the code comment next to replaced as well, so the guard carries its own retirement condition rather than relying on someone finding the PR description?
maximum = port.options.max if port.options.max is not None else 20 is the one thing deliberately not ruled. comfy-multi-player bounds counts by [group.min, MAX_OVERFLOW_WIDGETS / fields.length] and does not enforce the catalog max at all, on the stated grounds that the catalog controls layout rather than prompt validity, so there are currently two ceilings that disagree and a literal 20 with no cited source. that is the max-ownership question and it has its own owner; flagging it here only so it is not read as settled by this ruling.
last one, non-blocking: the read-to-write link race is in the PR description but not anywhere a user of the spec will see it. a link added to a row after the agent's read is not rechecked, so the refusal that protects connected rows can be bypassed by timing and that row rewritten under its link. the document layer cannot see this, since links and row fields are unrelated registers there, so SKILL.md or the vocabulary entry looks like the right home for it.
nothing else found. the validate-on-a-copy approach, refusing rather than moving a connected or promoted row, and replaying every emitted batch to the same canonical workflow are the three things that made the contract acceptable without an atomic operation, and the ADR says so explicitly.
The shared document accepts row writes in any order, so the vocabulary no longer states a universal ordering. The same-batch guards name #1007 as their retirement condition, and SKILL.md states the read-to-write link race.
|
@christian-byrne Thanks for the ruling. Addressed in 57481ed and the PR is out of draft.
The PR body now cites ADR-040 (comfy-multi-player #293) and ADR-039 (#292) instead of the proposal. Lint passes, and the DynamicGroup, vocabulary-contract, knowledge, command-mention and skill tests pass (462). |
christian-byrne
left a comment
There was a problem hiding this comment.
Approved after the DynamicGroup architecture audit. Whole-group replacement is the right V1 producer contract, hidden row registers remain retained, and the 215-test focused suite passes at this head.
Two scope notes are now recorded in ADR-040: equal-stamp actor ordering produces one complete winner only when both replacements write the same register set; pinned-row omission is the bounded exception. Also, frontend #21788 has settled max ownership: producers author within catalog min..max, while the shared document preserves counts within its resource bound. The fallback of 20 is consistent with the CLI catalog layout validator, which already applies the same fallback.
ELI5
To add, remove or reorder LoRA rows, the Agent sends the whole list of rows it wants. The CLI turns that list into ordinary widget edits: first the row count, then every field of every row. Rows that are wired to something, or promoted to a parent subgraph, stay exactly where they are.
Summary
set_dynamic_group_rowsbatch spec:{"op": "set_dynamic_group_rows", "node": 12, "group": "loras", "rows": [{...}]}. Omitted fields take the template default (a combo without one takes its first option). A field with no default at all must be supplied. A seed field's control mode is written with its row ("seed.0").set_widgetops, so the op vocabulary, comfy-multi-player and the doc host need no new operation. Oneapplycall is one batch. The spec runs on a copy, so a refused value leaves the caller's workflow unchanged. Another write in the batch to a register the spec claims (the count or a written row field), before or after the spec, is refused, because equal stamps would be settled by the randomop_idtiebreak (Two writes to the same widget in one apply batch keep a random value #1006). The guard comments name fix(workflow): let the later write in an apply batch win #1007, which makes the later write in a batch win, as their retirement condition. comfy-cli'sapply_opreplays the emitted ops in order (count first) because its workflow model materializes rows from the count; the shared document accepts them in any order.nameorwidget.name) or promoted, including legacyproxyWidgetsentries. Supplied rows fill the other positions in order. Pinned rows are left out ofrows, and supplied plus pinned rows must fit the group maximum. If a pinned row would have to move, the spec refuses and says whether to disconnect or unpromote it. No link is moved or rewired.9/1). Node addresses resolve likeset_widget: template ids of inserted nodes and print binding names are accepted. Promoted or redirected addresses are refused.docs/op-vocabulary-v1.mdas a batch spec, not an op kind. The skill also states the read-to-write link race.Implements the V1 row-change contract that Christian ruled on 2026-10-23: whole-group replacement, with no structural row operation. The rationale and reopen triggers are in comfy-multi-player #293 (ADR-040), which depends on #292 (ADR-039). Builds on #973 (merged).
Conflict policy (V1)
This is a bounded V1 conflict policy, not a replacement for stable row identity. One
applycall is one frame and one Undo unit, but the doc host applies each op in its own transaction, so the document mutation is not atomic. Accepted races:The durable model (comfy-multi-player #281, #282) stays closed as the named V2. ADR-040 lists the triggers that reopen it.
Not ruled here: the
maxfallback of20disagrees with comfy-multi-player's allocation bound. That is themax-ownership question (ComfyUI_frontend #21288). Emitting the count last on a grow is a possible follow-up.Verification
max, out-of-range value), an interior node, an unchanged direct caller after a refused value, seed control modes, an inserted node's template id, a row linked bywidget.nameonly, a legacyproxyWidgetspromotion, a field with no default, earlier and later same-batch writes to the group, pinned rows counted against the maximum, a stale legacy promotion of a recreated row, the reported holding stamp, a later write to a pinned row, subgraph-input promotion wording, no retry on an inserted copy after a refusal, a recreated row that still has a link, and an earlier write to a dropped row. Each emitted batch replays withapply_opto the same canonical workflow. Each test added for a Cursor review fix fails on the commit before that fix; the stale-promotion test pins existing behavior.comfy --json workflow apply wf.json --ops ops.jsonagainst the fixtureobject_infoemits 7set_widgetops and writes the expectedwidgets_values.ruff check .andruff format --check .pass. Full suite: 9,383 passed, 38 skipped. The 7 local failures (test_node_depsnon-PEP 440 version,test_httpsupplement roots, 5agent/test_commandgrant hints that expectcomfyon PATH) fail identically without this change.Provenance