Skip to content

fix(api): declare 409 for artifact replacement - #2553

Open
frf12 wants to merge 4 commits into
oceanbase:masterfrom
frf12:codex/openapi-artifact-conflict
Open

frf12 wants to merge 4 commits into
oceanbase:masterfrom
frf12:codex/openapi-artifact-conflict

Conversation

@frf12

@frf12 frf12 commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Problem and change

Closes #2551.

Replacing an Atomic Memory that has been merged or retired returns 409 invalid_memory_state, even when If-Match still matches its content revision. The canonical OpenAPI contract now declares that response and explains the state restriction; generated Python and Desktop contracts match it.

The SQLite/HTTP regression creates and merges memories through the public client, attempts replacement with the original ETag, verifies the 409 response and unchanged original/successor content, and checks the served OpenAPI declaration. Runtime behavior and public request shapes are unchanged.

Validation

  • make contract-test: 69 passed.
  • Replacement-conflict, generation/merge and cascade-restoration E2E tests, plus API/JavaScript contract tests: 83 passed.
  • Search-scoring and operational-metrics tests cited in the earlier review: 27 passed.
  • tests/test_desktop_fixture_qualification.py: 7 passed.
  • pnpm --dir desktop generate:check and uv run --locked prek run -a: passed.
  • Native Rust 1.95.0 Desktop probe against the exact built Server wheel: loopback anonymous, loopback bearer, HTTPS bearer with a base path, and provider authentication. These are independent local HTTP/TLS processes with real SQLite storage; they do not establish external deployment or installed GUI acceptance.

Desktop qualification

  • Profile: sqlite-artifact-conflict-a9a4605a-v1
  • Server source: a9a4605acca26e6c92b920744026472846dac664
  • Wheel: powercontext-1.6.2.dev84+ga9a4605ac-py3-none-any.whl
  • Wheel SHA-256: ab5e787600205f18ac610de025afa988df24b0f106f0d03b39a9c37a6a224a24
  • Contract SHA-256: bbf07c32df6c28930ea85d8cfd82af021059314a0e1d8f532cd135ea22921f12

The wheel runtime files were compared individually with the committed source. The product probe uses the bundled profile and verifies the exact artifact and contract identities. Existing qualification records remain unchanged.

AI usage

Implemented and reviewed with OpenAI Codex assistance.

@AlexStocks AlexStocks added the 1.5.2 v1.5.2 release tracking label Nov 9, 2026

@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 87d7b519. The added 409 response matches the existing runtime behavior; I found no new correctness defect in this patch. Merge readiness still needs attention:

  • Merging current master (63f021d6) conflicts in desktop/VALIDATION.md, desktop/src-tauri/src/connections/compatibility.json, desktop/src-tauri/src/transport/operations.json, and desktop/ui/src/generated/operations.ts. The combined OpenAPI contract hashes to 9acf2a1837938f1ba3cd3b7e61f419781d37f88cc591440aaa6dbd7f42b07d64, which has no qualification record in either branch. Please integrate master, regenerate the contract outputs, and qualify the resulting digest against the exact Server artifact before merging.
  • The failing unit job reports the OceanBase scoring test double missing run_sync and the operational-metrics last_failure assertion. Both failures reproduce at the original base (c4c95e465) and this head, so they are pre-existing failures. The upgrade gate also fails because upgrade acceptance was skipped. Please get fresh CI results after integration.

"evidence": "desktop/VALIDATION.md#server-c00dbf14-source-plugin-protocol-qualification"
},
{
"id": "sqlite-artifact-conflict-8dc98e49-v1",

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.

[P2] 资格记录绑定的是 rebase 前的契约摘要,而当前分支已经冲突,合并后这条记录一定失效

该 profile 的 contractSha256: ad2a39e2dd63… 与 head 的 openapi/powercontext.yaml 一致:本地复算 sha256(openapi 字节,CRLF→LF) = ad2a39e2dd633c373dc8cd24af22a8923bcbda1c84fc3825ba21349f0496b878,也等于 serverCommit 8dc98e49 那一版(head 提交只加了 VALIDATION.md 与本 profile)。head 上 pytest tests/e2e/test_atomic_memory_replace_conflict.py tests/test_desktop_contract.py 4 项全绿,PR 内部是自洽的。

问题在合并面:

  • master 现在 cc752d8a,其摘要已是 93b733bd…;本 PR base 还是 c4c95e46(摘要 3ea9f066…),GitHub 侧 mergeable_state=DIRTY。
  • 本地 git merge-tree --write-tree master refs/pr/2553 在四个文件上冲突:desktop/VALIDATION.md、desktop/src-tauri/src/connections/compatibility.json、desktop/src-tauri/src/transport/operations.json、desktop/ui/src/generated/operations.ts——正好是承载契约摘要与资格记录的那四个。
  • 解决冲突必然改变摘要,ad2a39e2… 不可能等于合并后的契约;届时 test_bundled_desktop_contract_has_a_qualified_business_profile 要求一个匹配新摘要的 profile,而这里记录的 wheel(powercontext-1.5.1.dev220+g8dc98e49b)与 macOS 26.2 四个真实模式的结果都绑定在旧摘要上,无法复用 ⇒ 还需要一次新的 macOS 资格跑。

建议:先 rebase 到当前 master,再重跑 pnpm --dir desktop generate 与 qualify,按最终摘要更新 desktop/VALIDATION.md 与 profile;在此之前不要把 Desktop 部分当作已完成。

另记一个缺口(未归责本 PR):该 head 的 tests (3.11, unit) 有 2 个失败——tests/builtin/persistence/test_atomic_memory_search_scoring.py[mysql-0.5-oceanbase_match] 报 'Connection' object has no attribute 'run_sync',tests/test_operational_metrics.py::test_healthy_combined_api_exposes_idle_stalled_and_stopped_processing[timeout-False] 报 ExtractionFailure(code='scope_discovery_failed')。这两处文件本 PR 未触及,归为 base drift / 时间敏感抖动,但它意味着该 head 缺少可判定的验收证据。

@frf12 frf12 Dec 2, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Resolved against current master 07f419041 in d102ecda0. Regenerated the Python and Desktop contracts and replaced this PR's old qualification with sqlite-artifact-conflict-a9a4605a-v1; all pre-existing master profiles are preserved. The committed Server source is a9a4605acca26e6c92b920744026472846dac664, contract SHA-256 is bbf07c32df6c28930ea85d8cfd82af021059314a0e1d8f532cd135ea22921f12, and the exact built wheel SHA-256 is ab5e787600205f18ac610de025afa988df24b0f106f0d03b39a9c37a6a224a24. Wheel runtime files were also compared individually with that commit.

The bundled-product native Desktop probe passed all four real SQLite/HTTP/TLS modes on macOS arm64, including anonymous, bearer, HTTPS with a base path, and provider authentication. The qualification report's dirty flag reflects only the new profile record before its final commit; the Server source and generated contract were already committed. This is native protocol evidence, not installed GUI or external deployment acceptance. Current master has removed desktop/VALIDATION.md and the evidence field, so those obsolete fields were not restored.

make contract-test passed 69 tests; related replacement/merge/restoration and API checks passed 83; the two previously failing test modules passed 27 tests. The PR description records the exact qualification identities and validation. Fresh CI was requested after pushing this head, but GitHub has not yet created a current-head run. GitHub is reporting a Webhooks/Actions incident that can delay or prevent workflow starts: https://www.githubstatus.com/incidents/121bhnw0ptrb . Another review has been requested; current-head CI and approvals remain outstanding.

@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.
  • CI failed: CI result (failure).
  • CI failed: Upgrade release gate (failure).
  • CI did not complete: tests (3.12, e2e) (cancelled).
  • CI did not complete: tests (3.14, unit) (cancelled).
  • CI failed: tests (3.11, unit) (failure).
  • CI failed: Main (failure). Failed steps: tests (3.11, unit) / Run unit tests; tests (3.14, unit) / Run unit tests; tests (3.12, e2e) / Run remaining end-to-end tests.

@hidb4ai hidb4ai removed the 1.5.2 v1.5.2 release tracking label Nov 15, 2026
@AlexStocks AlexStocks added the 1.6.0 v1.6.0 release tracking label Nov 17, 2026

@PsiACE PsiACE left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I found no other issues with the change. Please resolve the merge conflicts and revalidate the generated API contract before merging. Thanks!

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

@AlexStocks AlexStocks added 1.6.1 v1.6.1 release tracking 1.6.2 v1.6.2 release tracking and removed 1.6.0 v1.6.0 release tracking 1.6.1 v1.6.1 release tracking labels Nov 24, 2026
@hidb4ai hidb4ai added module:core Core: PR changes under src/ module:desktop Primary module: desktop app and platform integration labels Dec 2, 2026
@frf12
frf12 requested review from AlexStocks and hidb4ai December 2, 2026 17:10
@frf12
frf12 marked this pull request as draft December 2, 2026 17:11
@frf12
frf12 marked this pull request as ready for review December 2, 2026 17:11
@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.

@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 d102ecd. The added 409 declaration matches existing Atomic Memory replacement behavior; the SQLite/public-client regression confirms the rejected replacement preserves both original and successor content. Generated contracts and the bundled Desktop qualification digest match, and the affected contract files remain unchanged in the clean merge with current master. No actionable defect or added database table. Merge score: 85/100. Current full Actions validation is still absent/skipped; approval does not replace the required CI gates.

@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 d102ecd. Declaring 409 on replace_artifact matches what the Server already returns. The new e2e test covers both the response and the served contract: on master source it fails only at the /openapi.json assertion, because the 409 and the unchanged contents already hold there. The added description is also right for retired memories: replacing a retired merge result with its current ETag returns 409 invalid_memory_state, and with its earlier ETag 412 revision_conflict.

The Desktop record reproduces. A clean build of a9a4605 as 1.6.2.dev84+ga9a4605ac gives the recorded artifactSha256 byte for byte, and the product check in desktop/tests/real_server.py accepts that wheel for sqlite-artifact-conflict-a9a4605a-v1. I didn't rerun the native probe.

No blocking concerns in the change, but CI hasn't run on this head. The only Main run for d102ecd (46933793440) skipped all 45 jobs: CI preflight runs only for non-draft PRs, and that run's event saw the PR as a draft. A rerun replays the same event, so a new run needs a push or a close and reopen. I'll come back to approve once a run has completed.

#2923 makes the same declaration. I've suggested there that #2551 continues here.

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

6 participants