Skip to content

fix(api): declare replace_artifact's conflict response - #2923

Open
Lumea-art wants to merge 3 commits into
oceanbase:masterfrom
Lumea-art:fix/replace-artifact-conflict-contract
Open

Lumea-art wants to merge 3 commits into
oceanbase:masterfrom
Lumea-art:fix/replace-artifact-conflict-contract

Conversation

@Lumea-art

@Lumea-art Lumea-art commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2551.

Change

replace_artifact can already return HTTP 409 invalid_memory_state: a replacement whose If-Match still identifies the content revision can conflict with the current lifecycle, for example after the Atomic Memory was merged into a successor. The Atomic Memory workflow and the Server documented it, but the canonical OpenAPI contract omitted the response.

This declares the existing Conflict response on the operation, adds the contract assertion, and regenerates the Python client/schema plus the Desktop operation/type artifacts from the changed contract.

The earlier Desktop qualification record is dropped: current master removed desktop/VALIDATION.md and its evidence field, so it no longer applies. The contract and generated artifacts are the complete change.

Validation

  • tests/test_api_contract.py + tests/test_desktop_contract.py → 66 passed.
  • Desktop generator run after rebasing onto current master; no generated drift remains.

AI assistance

Authored with AI assistance and reviewed by the contributor before submission.

@Lumea-art
Lumea-art force-pushed the fix/replace-artifact-conflict-contract branch from 53a4c4b to 13cb4bf Compare November 30, 2026 11:32
@AlexStocks AlexStocks added the 1.6.2 v1.6.2 release tracking label Nov 30, 2026
@Lumea-art
Lumea-art force-pushed the fix/replace-artifact-conflict-contract branch from 13cb4bf to 751c37c Compare December 1, 2026 14:52
@Lumea-art

Copy link
Copy Markdown
Contributor Author

Rebased onto current master and regenerated the Desktop contract identity/artifacts. master removed desktop/VALIDATION.md and the compatibility-record evidence field, so the old qualification record no longer applies; the branch now carries the contract change, the generated Python/JS/Desktop artifacts, and a bundled compatibility profile for the generated contract digest, with the contract tests passing.

@hidb4ai

hidb4ai commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Re-reviewed 81d7d2863321dd0dcfec866e0dc462e83704bbe8. Two merge-readiness blockers remain:

  • Against current master (f87bcc7538d631a7702cdc207cb5e2f0b7417e51), git merge-tree --write-tree reports conflicts in desktop/src-tauri/src/connections/compatibility.json, desktop/src-tauri/src/transport/operations.json, and desktop/ui/src/generated/operations.ts. Please reconcile with master and regenerate the contract identity/artifacts and matching compatibility profile from the resulting OpenAPI document.
  • The macOS Desktop job was cancelled. The required CI result reports desktop-validation: abandoned, so native macOS validation is incomplete. Please obtain successful required checks on the updated head and merge result.

I found no correctness defect in the 409 declaration. The current head passed a real TCP HTTP + Core + SQLite scenario: retain the ETag, merge the input, reject replacement of that input with 409 invalid_memory_state without advancing its revision, then successfully update and read back the successor. This does not establish native Desktop acceptance.

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

  • Resolve merge conflicts with the target branch.

A replacement whose If-Match still identifies the content revision can conflict
with the current lifecycle, for example when Atomic Memory was merged into a
successor; the Server already returns 409 invalid_memory_state, and the Atomic
Memory workflow documents it, but the canonical contract omitted the response.

Declare the shared Conflict response on replace_artifact, assert it in the
contract test, and regenerate the Python, JS and Desktop artifacts.
Regenerate the Desktop contract identity and operations from the rebased
OpenAPI document, and add the matching bundled compatibility profile built from
this branch's wheel.
@Lumea-art
Lumea-art force-pushed the fix/replace-artifact-conflict-contract branch from 81d7d28 to 1eb0c4b Compare December 2, 2026 05:20
@Lumea-art

Copy link
Copy Markdown
Contributor Author

Rebased onto current master (0b60e52) again and regenerated the Desktop artifacts from the resulting OpenAPI document. The compatibility profile now uses the regenerated contract digest and a wheel built from this branch. tests/test_desktop_contract.py and tests/test_api_contract.py pass (66 tests). The branch is MERGEABLE; CI is running on the new head.

@hidb4ai hidb4ai added module:core Core: PR changes under src/ module:desktop Primary module: desktop app and platform integration labels Dec 2, 2026
@Lumea-art

Copy link
Copy Markdown
Contributor Author

Current head 1eb0c4b is rebased onto master and mergeable; contract/desktop tests pass (66). The old CI run only failed check-website on a next/font build error and script-installation on PyPI-mirror timeouts (macOS/Windows), neither touching this contract change. The rest of the matrix is green; I'll refresh the run after the queue clears.

@frf12

frf12 commented Dec 2, 2026

Copy link
Copy Markdown
Member

Closing as a duplicate of #2553, which was opened earlier for the same replacement-conflict contract and includes SQLite/HTTP regression coverage. We will continue the fix and current-master validation in #2553.

@frf12 frf12 closed this Dec 2, 2026
@frf12

frf12 commented Dec 2, 2026

Copy link
Copy Markdown
Member

Reopening: I closed this PR in error while comparing it with #2553. That closure was my mistake. Apologies for interrupting the contribution; this PR remains open for review.

@jasper-yl

Copy link
Copy Markdown
Contributor

Compared this with #2553 at 1eb0c4be8 / d102ecda0. The contract change is identical in both (the 409: Conflict declaration on replace_artifact plus regenerated outputs), and both merge cleanly into current master. Two suggestions for this PR:

  • The description still says the Desktop qualification record is dropped, but the diff adds sqlite-replace-artifact-conflict-eef8209-v1 to compatibility.json. Please update the description to match.
  • test_replace_artifact_declares_the_conflict_response only asserts that the YAML contains the declaration. A behavior test would protect more: merge two Atomic Memories, replace an input with its original ETag, and assert 409 invalid_memory_state, unchanged content, and the declaration in the served /openapi.json. fix(api): declare 409 for artifact replacement #2553 has such a test.

中文:两个 PR 的契约改动相同,都能干净合入当前 master。对本 PR 有两点建议:更新描述(兼容性记录实际是新增而非删除);把测试换成行为测试(合并两条 Atomic Memory 后用原 ETag 替换输入,断言 409 invalid_memory_state、内容不变、服务端 /openapi.json 有该声明),#2553 里有这样的测试可参考。

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

Reviewed 1eb0c4b. Declaring the existing 409 Conflict is consistent with the actual replacement operation, and the Python/Desktop artifacts regenerate without drift. A real TCP HTTP/Core/SQLite flow returned invalid_memory_state for replacement of a merged input with its still-current ETag, preserved that revision, and successfully replaced/read back the active successor. No database tables or new endpoints are introduced.

Merge confidence: 85/100. CI is not fully green: the failed run shows next/font compilation failure and macOS/Windows package-download timeouts; another run is queued. Those outstanding checks remain separate from this code approval.

@hireview001

Copy link
Copy Markdown
Collaborator

The affected modules are Desktop, Core. @PsiACE, please coordinate follow-up. Desktop: @PsiACE @knqiufan; Core: @hidb4ai @frf12 @Fengzdadi @beatenevo. Please coordinate the review of the affected changes.

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

Reviewed 1eb0c4b. The 409 declaration matches what the Server returns, and the generated files match the contract. The failed harness-validation / Acceptance (sqlite) job isn't caused by this change: the same step failed on master's 38fa902 run.

#2553 makes the same declaration. I'd continue #2551 there and close this PR as a duplicate: its test covers the 409 and the served contract, its Desktop record reproduces from its recorded commit, and it was opened first. If this PR continues instead, two things need to change first.

Needs a change

  1. The Desktop record doesn't reproduce from its serverCommit. Inline on compatibility.json.
  2. The description says the qualification record is dropped, but the diff adds one. jasper-yl raised this on 12-02, and it's still the case. Please replace that paragraph with how the record was qualified: how the wheel was built and what the native run covered.

Comment on lines +2007 to +2009
"serverCommit": "eef82096a4947405feb55e63fbdd9768c4581a34",
"contractSha256": "ce939d9d5985fea5921575c18766abc5b67e4c4b35c09da5ce86e16951b06793",
"artifactSha256": "d25e21d9d4af4a82bd4c28edbb350d8739b024b1e58a67d96d171377c76b975c",

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.

This record's wheel digest doesn't reproduce from its serverCommit.

artifactSha256 names the exact Server build this record was qualified against. desktop/tests/real_server.py --product-qualification checks the wheel against it before it starts the Server, and product preparation requires the record to match the actual Server build.

I built eef8209 cleanly: git archive, then uv build --wheel with version 1.6.2.dev80+geef82096a and hatchling 1.33.0. The wheel's SHA-256 is 01c8f5c6…, not d25e21d9…, and the harness's product_profile() rejects it with product_qualification_mismatch. The same steps reproduce #2553's recorded wheel byte for byte, so the build is deterministic. I also tried the versions a dirty tree at eef8209 would get on 12-01 or 12-02, and the versions of fe31aec and 1eb0c4b. None gives d25e21d9….

If this PR continues, please rebuild the wheel from the committed serverCommit, rerun the native qualification against that wheel, and update the record.

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

1.6.2 v1.6.2 release tracking module:core Core: PR changes under src/ module:desktop Primary module: desktop app and platform integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(api): replace_artifact omits HTTP 409 from OpenAPI

7 participants