Skip to content

[bugfix] creation: accept multiple prompt references in one command - #636

Open
barkly1te wants to merge 10 commits into
ThinkFlowLab:mainfrom
barkly1te:fix/a1-atomic-prompt-references
Open

barkly1te wants to merge 10 commits into
ThinkFlowLab:mainfrom
barkly1te:fix/a1-atomic-prompt-references

Conversation

@barkly1te

@barkly1te barkly1te commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #638.

Why

Creating a generation node with two prompt references used to validate the first reference before the second had been saved. Agent requests that supply only the required fields also need a distinct order for each reference.

What changed

Write the node and its references before checking the complete snapshot. Fill omitted orders from the array position, preserve explicit orders, and reject collisions without publishing any project changes. Direct and batch creation share the same validation used by the browser and Agent entry points.

Select the replay rule from the stored commit. Commit validation and retry comparison use that choice. Existing fingerprints and commit and journal formats are preserved.

Tradeoffs

Historical commands replay by their original rule. Older readers can reopen completed rejections with positional orders. Recover a pending version 2 journal on the patched build before downgrading. An older reader needs a backup from before a successful command that wrote a positional fingerprint.

Verification

  • Five reproduction cases failed on main and passed on the candidate. The same input sent from the browser's creation client now saves [0, 1] and shows both edges after reopening. The missing-source request leaves the snapshot unchanged and creates zero jobs. Screenshots, input, and receipts
  • All 1,280 direct and batch replay comparisons agree with the pre-refactor implementation. A real project reopened on the old reader after four rejections, and its edit survived upgrade. The original inputs replayed their old receipts and all four changed-order requests conflicted. Replay and rollback evidence
  • Windows passed 256 focused tests with six POSIX-only skips, 1,109 frontend tests, generated contracts, import boundaries, and i18n and browser catalog checks. All nine bundled Windows OpenCode tests passed with a mock model.
  • The local merge against current main matches the file tree tested during pre-review. Merge-tree comparison
  • Release checks, CodeQL, and DSH on this head are pending. The prior head passed Python, frontend, and assistant browser checks. Its isolated and voice browser jobs reached the runner limit during dependency setup. Previous Release run

Independent pre-review

93/100. Reviewed base f3251839da5a52818ade05eec766fee3cc51d3f9 and head 44ef6d952ee02fddd106c358323aae00b401d9e0. Scope, correctness, claim evidence, and simplicity scored 3/3. Validation scored 2/3 while same-head GitHub checks, including the desktop installer jobs, were pending. Independent review found no blocking changes and confirmed the effective merge tree matches the locally tested integration.

@david6666666 david6666666 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

WITHHOLD 3aafd0a Refs #632

当前证据暂定 93/100,非批准分。 范围、正确性、验证、主张证据、简洁度依次为 3/3、3/3、2/3、3/3、3/3。

下载核对了前后截图和 CLI 回执:同一组替身图片,旧版拒绝命令,新版重开后保留新节点和两条引用边;没有生成任务,不算真实 Agent 或供应商验证。实现先写齐引用再校验整个快照,直接命令和批量回滚均有回归。我未运行 PR 代码。当前 Release Python 的原生 OpenCode 技能发现和图像用例失败,CodeQL、DSH 和浏览器绿;先等同一提交的必需检查通过。

Dot,代表 @david6666666 作非表决评审。

@Redivesue

Copy link
Copy Markdown
Contributor

感谢认领 A1,修复的位置是对的:canvas.createGeneration 先把全部引用写进去,再对完整快照做一次校验;逐来源的检查抽成了 _write_reference / _validate_reference_source,单独的 reference.add/update/restore 也走同一套逻辑,没有为某个入口开例外。

我在本地用 3aafd0ab 复跑了:

  • 本 PR 新增的 8 个用例和 tests/test_creation_canvas_service.py 全部通过;
  • roadmap 里 A1 的复现用例,在显式传 order 时由 rejected 变为 applied。

有一个需要先定下来的问题:引用的 order 缺省值

order 不是必填字段,默认是 0。如果两个引用都只按必填字段填写(不传 order),在本 PR 上仍会被拒,只是报错换了:

main @ ae5003b6 : invalid_input  Prompt references must belong to the same generation spec
PR   @ 3aafd0ab : invalid_input  Reference order is duplicated for its target

新增用例里写了 order=order,所以没有碰到。对 Agent 来说,帮助的示例里没有 references,报错也没有提示要补 order,所以按帮助写出来的命令修复后仍会失败,A1 想解决的场景(一次创建里引用多个新建引用)在实际使用中还走不通。

维护者这边决定把它放在 A1 里一起解决,麻烦在本 PR 中补上:

  • canvas.createGeneration 对没有显式给出 order 的引用按数组位置补齐(0、1、2…);显式给出的值不动,冲突时照旧拒绝;
  • 加一个不传 order 的用例,断言 applied,且保存后的顺序为 0、1。

这样 Agent 按帮助只填必填字段时也能一次通过,A2 就不用再为这一点改帮助和报错。

可选补充(不阻塞)

  • A1 验收里还列了"图片加文本的混合引用 applied"和"来源类型不能作为参考时 rejected",现在的参数化只用了两个文本来源,方便的话顺手加上。

CI

checks / python 只失败在两个真实 OpenCode 集成用例上(test_real_opencode_native_skill_and_gateway_write 的 skill 发现、test_real_opencode_native_visual_input 超时),其余 3279 个通过,看起来和这个改动无关,定下上面的处理后重跑一次即可。

A1 的 issue 已开为 #638,并回填到 #632。请把 PR 描述里的 Refs #632 (A1) 改为 Fixes #638。

@david6666666 david6666666 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

REQUEST CHANGES 3aafd0a Refs #632 / #638

当前证据暂定 80/100,非批准分。 范围 2/3、正确性 2/3、验证 2/3、主张证据 3/3、简洁度 3/3。

上轮核对的截图和回执仍证明显式传入 order: 0/1 的路径修好了,但没有覆盖默认值。我复查了当前源码:不填时两条引用都会拿到 0,完整快照仍会拒绝重复顺序。按 #638 把省略值和显式值分开处理,并补回归。Release 仍红在原生 OpenCode 检查;我没运行 PR 代码。

Dot,代表 @david6666666 作非表决复审。

Comment thread tests/test_creation_canvas_service.py Outdated
]),
item=dict(id=item_id, projectId=pid, kind='image',
binding=dict(role='generation', objectRef=dict(id=spec_id))),
references=[dict(id=ref_id, projectId=pid, targetSpecId=spec_id, order=order,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这组用例总会传 order,没走到只按必填字段调用的分支。除了两条都省略,也建议加一个一显式一省略的用例:显式 0 应保留,另一条按数组位置补;如果补出的值和显式位置冲突,要确认仍拒绝,不要静默重排。

Fill omitted orders while parsing canvas.createGeneration so CLI serialization and other entry points use the same effective order. Preserve explicit values and let project validation reject collisions.

The focused direct and batch suite had 8 failures and 10 passes before the change. All 18 pass after it, including persisted order, mixed media, replay, and rollback.

Copy link
Copy Markdown
Contributor Author

@Redivesue I pushed 8dcc33bd and changed the PR to Fixes #638. canvas.createGeneration now fills omitted orders by array position during shared command parsing. Explicit orders, including 0, stay as supplied. A collision still rejects the entire command.

I ran the same CLI payload with both orders omitted. 3aafd0ab rejected it and left the project unchanged. 8dcc33bd applied it, saved orders 0, 1, and showed the new node and both edges after reloading the canvas. Before and after screenshots, CLI receipts, and input

All 18 focused cases and 582 related Python tests passed. The focused cases cover direct and batch creation, mixed explicit and omitted orders, collisions, mixed image and text references, and rollback for incompatible sources. I also documented the upgrade replay case in the PR description. Ready for another look.

@david6666666 david6666666 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

WITHHOLD 8dcc33b Fixes #638

当前证据暂定 85/100,非批准分。 范围 3/3、正确性 2/3、验证 2/3、主张证据 3/3、简洁度 3/3。

我下载核对了新截图和两份 CLI 回执:两条都不填时,旧版拒绝,新版保存为 0、1,重开仍有两条边。混合显式、省略和冲突的新增用例也读过。剩下一处升级兼容问题:旧版已经成功的命令,用原始请求体和相同 ID 跨版本重试,会因新默认值返回 command_conflict。保存的项目能读,但超时后自动重试的调用者不一定有改写过的请求。已在线内建议保留旧回执的重试语义。CodeQL、DSH 已绿,Release 尚未完成。我未运行 PR 代码或真实 Agent。

Dot,代表 @david6666666 作非表决复审。

@classmethod
def fill_reference_orders(cls, references: tuple[Reference, ...]) -> tuple[Reference, ...]:
return tuple(
reference if 'order' in reference.model_fields_set else reference.model_copy(update={'order': position})

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这里在解析时就补了顺序,旧版已成功的原始请求重试同一个 command ID 时,可能在读回执前就变了指纹。PR 正文的 7, 0 例子已经观察到这个差异。能否让旧回执仍认原始请求,只对新命令应用位置默认值?建议回归同时断言旧重试返回原回执、新命令仍保存位置顺序。

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 3ed47cdc. The original request now keeps its omitted order through JSON serialization, and receipt lookup uses the fingerprint rule under which the command was recorded.

I retried the same request and command ID against one project created on ae5003b6. 8dcc33bd returned command_conflict. 3ed47cdc returns the exact original receipt and leaves the saved [7, 0] unchanged. A new command with the same order pattern saves [7, 1]. Changing the second order to explicit 0 on that new command’s ID still returns command_conflict. CLI inputs, before and after receipts, and canvas screenshots

The direct and batch replay regressions pass, along with all 22 focused cases and 586 related Python tests. The PR description also records that older builds cannot verify a new multi-reference record written by the patched build.

Keep omitted orders through command serialization. Match legacy receipts with their original fingerprint rule and use position-based orders for new commands. Separate the fingerprint formats so a changed order still conflicts on a new command ID replay.

The new legacy direct and batch replay tests reproduced command_conflict before the change. Both pass now, and both current-record conflict cases still pass.

@david6666666 david6666666 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

WITHHOLD 3ed47cd Fixes #638

当前证据暂定 82/100,非批准分。 范围 3/3、正确性 2/3、验证 3/3、主张证据 2/3、简洁度 3/3。

上轮的重试问题修好了。我对比了两份 JSON,旧请求用同一个 ID 重试返回的回执完全一致,原项目仍是 [7, 0];新命令保存为 [7, 1],修改后再用同一 ID 仍会被拒。前后截图也能核对两组连线。同一提交的 Release 七项、CodeQL 和 DSH 全部通过。我没有重跑程序;CLI 和画布截图不是 #638 要求的 UI 与 Agent 入口等效验证。

剩下是回退范围:新指纹会用于所有多引用创建,连每个顺序都已显式给出的请求也会写出旧版读不了的记录。已在线内建议缩小影响或明确旧版回退的取舍。下一步补 UI 与 Agent 入口验收,并确认回退策略。

Dot,代表 @david6666666 作非表决复审。

return digest(command)
def command_fingerprint(command: Command, *, legacy: bool = False) -> str:
operations = command.payload.operations if command.type == 'creation.batch' else (command,)
if not legacy and any(operation.type == 'canvas.createGeneration' and len(operation.payload.references) > 1

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

旧回执的兼容修好了。这里也会给全部显式填了 order 的多引用命令写新指纹,即使这次没用到位置默认值。作者的降级实测已经看到 storage_unavailable;这会不会把本来不需要新语义的项目也挡在旧版本之外?建议评估能否缩小写入范围;如果必须统一切换,请明确记录格式的回退策略。

@barkly1te barkly1te Dec 2, 2026 •

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.

I narrowed the write scope in 2f7ac187. A request keeps the legacy fingerprint when every order after the first is explicitly nonzero. The older build reopened an explicit [0, 1] project with an identical snapshot. The same check returned storage_unavailable on 3ed47cdc. Omitting the first order also stays compatible.

A later omission and an explicit zero still use the positional fingerprint. The old rule hashes [7, 0] and [7, omitted] alike, but the patched build saves [7, 0] and [7, 1] respectively. Keeping the positional fingerprint in those cases preserves the same-ID conflict check. For a project with such a record, rollback to an older build requires a backup from before the record was written.

I also verified that the original upstream request replays its exact receipt. The browser’s creationClient.command and Agent’s ToolGateway saved [0, 1] from the same omitted-order input and both rejected a missing source without leaving partial objects or jobs. Old-reader results, receipts, inputs, and browser screenshot

@david6666666 , would this narrower rollback boundary be acceptable for A1?

Keep legacy fingerprints when every reference after the first has a nonzero order. A zero at any later position can represent an omitted value or an explicit zero under the old rule. Keep those inputs distinct and preserve replay of positional receipts.

@david6666666 david6666666 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

WITHHOLD 2f7ac18 Fixes #638

当前证据暂定 85/100,非批准分。 范围 3/3、正确性 2/3、验证 2/3、主张证据 3/3、简洁度 3/3。

我看了回执和画布截图。旧版能读新版写出的显式 [0, 1],只省略第一项也能读;浏览器和 Agent 工具入口的测试都保存了 [0, 1],缺失来源都被拒、未创建对象或任务。对于确实写了新顺序语义的成功记录,缩小后的回退边界合理。还有一种容易漏掉的情况:被拒的命令也会写入历史。即使画布没改,旧版也可能读不了项目。已在线内标出,建议用旧版重新打开失败后的项目验证。

CodeQL、DSH 已通过;当前 Release 红在 OpenCode 图像集成超时,常规 Python 3351 项通过。未运行 PR 代码或真实模型。

Dot,代表 @david6666666 作非表决复审。

and any(reference.order == 0 for reference in operation.payload.references[1:])
for operation in operations
)
order_rule = 'position' if ambiguous_legacy_order else 'legacy'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这里按输入选新指纹,不区分命令结果。creation_publication._make_record 会把 rejected 回执也写成提交,所以附件里的「省略后续 order + 来源不存在」虽然没有改画布,可能已经让旧版读不了这个项目。能否补一条回退负例:旧版建工程 → 新版只提交这个失败命令 → 旧版重开?如果必须保留新格式的失败回执,备份边界也应明确包含失败尝试。

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.

I reproduced the rollback case and fixed it in 08d7ce93. Upstream ae5003b6 created the project in both runs. With writer 2f7ac187, the missing-source command returned missing_object and left the snapshot unchanged, but upstream then returned 409 storage_unavailable. With 08d7ce93, upstream opened the same snapshot with HTTP 200 and read the original rejection receipt.

The patch stores the rejected command's effective orders with a digest the old reader can verify. I also saved a text asset on the old build and upgraded again. The edit survived, the original request replayed the exact rejection, and changing the omitted order to explicit 0 returned command_conflict.

A pending journal still needs recovery on the patched build before rollback. A completed rejection written by this patch can be opened and edited on the old build. Before and after results, repro steps, and recovery evidence

Persist effective orders and a legacy digest for ambiguous rejected commands. Keep the positional replay rule in the compatible commit envelope. A version 2 pending journal keeps older builds from rewriting that envelope during recovery.

@david6666666 david6666666 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

PASS 08d7ce9 Fixes #638

97/100(本条非表决)。范围 3/3、正确性 3/3、验证 3/3、主张证据 3/3、简洁度 2/3。

上轮的失败回执回退问题已修。我比对了固定回执:同一个缺失来源请求被拒后,旧版重开从 409 变为 200,快照不变;旧版继续编辑后再升级,编辑保留,原请求返回同一回执,改第二个 order 为显式 0 则冲突。两个中断点的回执也显示,需先用新版恢复待处理日志,再回退。成功写入的新顺序记录仍有已说明的回退边界。这一兼容做法增加了日志版本与序列化分支,因此简洁度扣一档。

同 head Release 七项、CodeQL 和 DSH 已过;当前 main 增量只在 CI 工具安装,GitHub 显示无冲突。已读源码和回执,未重跑应用或真实 provider。本条是技术结论,不是原生 Approve;当前 head 未核实明确投票邀请。

Dot,代表 @david6666666 作非表决复审。
Coordinator: verify formal reviewer and final merge gates before integration.

@david6666666 david6666666 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

WITHHOLD 7dfaacb Fixes #638

真实冲突已解决,合并后的共享参考写入仍保留 main 的来源身份规则。我核对了这个 SHA 的回执和重开截图:Browser 和 Agent 都写入 [0,1],缺失来源会拒绝且不创建 job;两个旧 reader 在拒绝后能重开并编辑,升级仍读回同一回执。成功写入的新顺序记录仍受 PR 已说明的降级边界约束。

Ran: 核对 diff、截图与固定回执。当前 Release 红在 Bundled OpenCode gateway 集成,浏览器和 CodeQL 已过。Not run: 未独立执行应用或 provider。先等同 SHA 的 Release 门禁通过,不需因 main 前进再 rebase。

当前证据暂定 90/100,非批准分。 范围 3/3、正确性 3/3、验证 2/3、主张证据 3/3、简洁度 2/3。

Dot,代表 @david6666666 作非表决复审。

Copy link
Copy Markdown
Contributor Author

@david6666666 Could you rerun the failed jobs in Release checks for 7dfaacb9? GitHub denied my rerun request because my account lacks write access to the upstream repository.

The Python job hit its 60-second timeout in test_real_opencode_native_visual_input[image-model] during the bundled OpenCode step. The aggregate check failed because the Python job failed. The regular Python suite passed 3,375 tests. PR Python log

The same test timed out on the base commit main@147b1832 without the A1 patch. I also reran the bundled OpenCode test selection locally on 7dfaacb9 on macOS and got 7 passes with 2 Windows-only skips. The base failure and local result point to the OpenCode integration issue tracked in #162. Base Python log

codex added 2 commits December 4, 2026 13:04
## summary

Exercise two omitted reference orders through the Agent tool gateway. Verify that a missing source rejects the request without changing the project or creating jobs.

@david6666666 david6666666 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

WITHHOLD be2f312 Fixes #638

核对了新 head 的前后截图和回执:原版拒绝,两条引用在候选版按 [0, 1] 保存并在重开后显示,缺失来源拒绝后不产生 job。旧请求能按原规则重放;成功写入新 positional fingerprint 后仍不能直接降级,这个限制已在 PR 明示。新的 CodeQL/DSH 已过,继续按这个 head 核对 Release,不因 main 单独推进要求反复 rebase。

当前证据暂定 90/100(范围 3,正确性 3,验证 2,主张证据 3,简洁性 2;均满分 3)。Release:仍在跑。Ran: 变更、截图、固定回执及 CI 核对。Not run: 本地浏览器、Agent 或 provider。

Dot,代表 @david6666666;非表决。

@david6666666 david6666666 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

WITHHOLD be2f312 Fixes #638

这个 head 的 Release checks 已结算,不再是 running:browser 组合被取消,aggregate 因此未过;Python、frontend、static、CodeQL/DSH 则已通过。取消不证明参考图逻辑有回归,也不能记成 Release 通过。原先核对的两条引用重开和缺失来源拒绝证据仍有效。

维持当前证据暂定 90/100(范围 3,正确性 3,验证 2,主张证据 3,简洁性 2)。Ran: 同 SHA 的 Actions job 与 aggregate 日志核对。Not run: 本地浏览器、Agent 或 provider。先查取消来源,不因 main 单独推进要求 rebase。

Dot,代表 @david6666666;非表决。

## summary

Derive replay identity from the stored command and receipt. Use the same rule to validate a commit and compare retries while preserving existing fingerprints and journal formats.

@david6666666 david6666666 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

PASS 44ef6d9 Fixes #638

97/100(范围 3、正确性 3、验证 3、主张证据 3、简洁度 2;满分各 3)。这次 replay 先从已保存记录确定 legacy / position 规则,再用同一规则校验重试输入,不再用新请求反推旧 commit 的写入方式。回执格式没变,成功写入新 positional fingerprint 后仍不能直接降级。

Ran: 核对增量、固定 SHA 的前后回执和 merge-tree 记录。作者证据里,旧版拒绝的双引用请求在候选版保存 [0, 1],重开仍在;1,280 个 direct/batch 比对一致,四条旧拒绝可重放,显式变更顺序仍冲突。同 SHA Release checks、CodeQL、DSH 全绿,GitHub 当前无冲突。Not run: 我未独立重跑浏览器或 provider;本条非表决。

Dot,代表 @david6666666 作非表决复审。
Coordinator: 由仓库已授权角色核对正式审批及合入门槛。

This branch has not been deployed

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

Labels

area:canvas Canvas, nodes and direct manipulation type:bug Something is broken

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bugfix] creation: 一次创建中提示词引用多个新建引用时被拒绝 (week1-1130-1206)

4 participants