Skip to content

feat(workflow): replace DynamicGroup rows in one batch spec - #1004

Merged
jaeone94 merged 8 commits into
mainfrom
jaeone94/dynamic-group-replace
Oct 27, 2026
Merged

jaeone94 merged 8 commits into
mainfrom
jaeone94/dynamic-group-replace

Conversation

@jaeone94

@jaeone94 jaeone94 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Add the set_dynamic_group_rows batch 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").
  • The spec emits only existing set_widget ops, so the op vocabulary, comfy-multi-player and the doc host need no new operation. One apply call 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 random op_id tiebreak (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's apply_op replays the emitted ops in order (count first) because its workflow model materializes rows from the count; the shared document accepts them in any order.
  • A row keeps its index and values if any field is connected (matched by input name or widget.name) or promoted, including legacy proxyWidgets entries. Supplied rows fill the other positions in order. Pinned rows are left out of rows, 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.
  • Works on top-level nodes and unpromoted interior nodes (9/1). Node addresses resolve like set_widget: template ids of inserted nodes and print binding names are accepted. Promoted or redirected addresses are refused.
  • Document the spec in the agent skill and in docs/op-vocabulary-v1.md as 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 apply call 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:

  • Partial application. If a later op is rejected, the count and the fields written before it stay. The spec validates on a copy first, so a rejection should only come from a concurrent change or a version mismatch.
  • Concurrent writes. The count and each row field settle as separate registers, so two concurrent writers can leave a mix of both.
  • Read-to-write link race. A link added to a row after the Agent's read isn't rechecked, so that row can be rewritten under the link.

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 max fallback of 20 disagrees with comfy-multi-player's allocation bound. That is the max-ownership question (ComfyUI_frontend #21288). Emitting the count last on a grow is a possible follow-up.

Verification

  • 28 new test cases: grow and rewrite, middle-row removal, connected row kept in place, refusal to move a connected row, invalid rows (unknown field, non-list, above 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 by widget.name only, a legacy proxyWidgets promotion, 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 with apply_op to 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.json against the fixture object_info emits 7 set_widget ops and writes the expected widgets_values.
  • ruff check . and ruff format --check . pass. Full suite: 9,383 passed, 38 skipped. The 7 local failures (test_node_deps non-PEP 440 version, test_http supplement roots, 5 agent/test_command grant hints that expect comfy on PATH) fail identically without this change.

Provenance

  • Authored by: interactive session.
  • Deviations: the in-app Agent → doc host → canvas path is not exercised here; that end-to-end proof remains a separate gate.

@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 9c0d3458-e341-485e-9c75-8fd7d6d50eba
Commits

Reviewing files that changed from the base of the PR and between 1513a70 and 57481ed.

Files selected for processing: 4
  • comfy_cli/skills/comfy/SKILL.md
  • comfy_cli/workflow_ops.py
  • docs/op-vocabulary-v1.md
  • tests/comfy_cli/test_dynamic_group.py

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Walkthrough

Adds set_dynamic_group_rows to replace DynamicGroup rows, preserve connected or promoted rows at their indices, and generate set_widget operations. Batch processing now handles these specs and rejects conflicting writes. Guidance and tests describe the behavior.

Changes: DynamicGroup row replacement

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
Loading

Possibly related issues

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_widget operations are replayed under the operation contract changed by this PR.

Suggested reviewers: christian-byrne, skishore23

Priority: Normal

Merge Risk: Minimal · up to 57481

The row-replacement change is mergeable after normal checks; no unresolved actionable issue is established.

Pre-merge checks: Passed 2
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.
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.

@jaeone94 jaeone94 added the cursor-review Request Cursor bot review label Oct 13, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

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 @jaeone94.

Found 5 finding(s).

Severity Count
🟡 Medium 4
🟢 Low 1

Panel: 6/6 reviewers contributed findings.

Comment thread comfy_cli/workflow_ops.py Resolved
Comment thread comfy_cli/workflow_ops.py Resolved
Comment thread comfy_cli/workflow_ops.py Resolved
Comment thread comfy_cli/workflow_ops.py Resolved
Comment thread comfy_cli/workflow_ops.py Resolved
@jaeone94 jaeone94 added cursor-review Request Cursor bot review and removed cursor-review Request Cursor bot review labels Oct 13, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

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

Comment thread comfy_cli/workflow_ops.py Resolved
Comment thread comfy_cli/workflow_ops.py Resolved
Comment thread comfy_cli/skills/comfy/SKILL.md Resolved
Comment thread comfy_cli/workflow_ops.py Resolved
Comment thread comfy_cli/workflow_ops.py Resolved
Comment thread comfy_cli/workflow_ops.py Resolved
Comment thread comfy_cli/workflow_ops.py Resolved
@jaeone94 jaeone94 added cursor-review Request Cursor bot review and removed cursor-review Request Cursor bot review labels Oct 13, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

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

Comment thread comfy_cli/workflow_ops.py Resolved
Comment thread comfy_cli/workflow_ops.py Resolved
Comment thread comfy_cli/workflow_ops.py Resolved
Comment thread comfy_cli/workflow_ops.py Resolved
Comment thread comfy_cli/workflow_ops.py Resolved
@jaeone94 jaeone94 added cursor-review Request Cursor bot review and removed cursor-review Request Cursor bot review labels Oct 14, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

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

Comment thread comfy_cli/workflow_ops.py Resolved
Comment thread comfy_cli/workflow_ops.py Resolved
Comment thread comfy_cli/workflow_ops.py Resolved
Comment thread comfy_cli/workflow_ops.py Resolved
@jaeone94 jaeone94 added cursor-review Request Cursor bot review and removed cursor-review Request Cursor bot review labels Oct 14, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

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

Comment thread comfy_cli/workflow_ops.py Outdated
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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 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).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment thread comfy_cli/workflow_ops.py
return "is connected; disconnect it first"
return None

pinned = {r: reason for r in range(current) if (reason := pin_reason(r))}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment thread comfy_cli/workflow_ops.py Outdated
redirected = _promoted.resolve_write(workflow, graph, segments, address).redirected_from
except ValueError: # fed by another interior node: a plain link
redirected = None
if redirected:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 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).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment thread comfy_cli/workflow_ops.py
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:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 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).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment thread comfy_cli/workflow_ops.py Outdated
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]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 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).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment thread comfy_cli/workflow_ops.py Outdated
# 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]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚪ 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).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment thread comfy_cli/workflow_ops.py Outdated
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)}")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚪ 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).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

@jaeone94
jaeone94 force-pushed the jaeone94/dynamic-group-replace branch from 1a2969f to b7356d5 Compare October 14, 2026 04:26
Base automatically changed from jaeone94/test-dynamic-group-compat to main October 14, 2026 09:23
jaeone94 and others added 6 commits October 14, 2026 18:24
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.
…p-replace

# Conflicts:
#	comfy_cli/workflow_ops.py
#	tests/comfy_cli/test_dynamic_group.py

@christian-byrne christian-byrne 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.

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.
@jaeone94
jaeone94 marked this pull request as ready for review October 25, 2026 10:38
@jaeone94

Copy link
Copy Markdown
Contributor Author

@christian-byrne Thanks for the ruling. Addressed in 57481ed and the PR is out of draft.

  • Replay order (blocking): docs/op-vocabulary-v1.md now scopes it to comfy-cli, using your wording: "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." The set_dynamic_group_rows docstring says the same.
  • Same-batch guards: both name fix(workflow): let the later write in an apply batch win #1007 as their retirement condition, the later-write comment in apply_specs next to replaced and the earlier-write check in set_dynamic_group_rows' docstring.
  • Read-to-write link race: SKILL.md now says links are checked when the workflow is read, so a link added after that read is not rechecked and the row can be rewritten under it.
  • Count last on a grow: left as a follow-up, as you suggested.
  • max fallback of 20: unchanged. The PR body now marks it as the open max-ownership question (ComfyUI_frontend #21288), not settled by this ruling.

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 christian-byrne 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.

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.

@jaeone94
jaeone94 merged commit 4d054af into main Oct 27, 2026
19 checks passed
@jaeone94
jaeone94 deleted the jaeone94/dynamic-group-replace branch October 27, 2026 00:19
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cursor-review Request Cursor bot review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants