Repository navigation
Conversation
Add an optional idempotency_key to remember_memory. A retry with the same key and content replays the original creation; different content returns 409 idempotency_conflict. Keys live 24 hours on the database clock in a per-Scope, per-principal namespace and are stored as digests only. Adds migration v1_5_2_001 for SQLite and MySQL-dialect backends, exposes the field over HTTP, the SDK, and MCP, keeps it hidden in Dify, and documents the behavior in both locales. Closes oceanbase#2521
Bind the bundled Desktop contract to Server source df79da6 and its built wheel after the native probe passed all four connection modes.
hidb4ai
left a comment
There was a problem hiding this comment.
The keyed in-process SDK path can replay a creation after scope contribution has been revoked. Please apply the required current authorization before receipt lookup; the inline comment includes a reproduced case.
An in-process keyed create returned a replay or a conflict before the caller's creation authority was checked. Require it before the receipt lookup so a revoked contributor learns nothing from an old key.
| raise InvalidBaseAccessRequestError( | ||
| "idempotency_key", "must be 1 to 256 printable ASCII characters, no spaces" | ||
| ) | ||
| principal = None if context is None or context.principal is None else context.principal |
There was a problem hiding this comment.
[P2] Share the SDK key namespace when access control is disabled
This branch includes the principal from a valid ArtifactSearchExecutionContext(principal=alice, trusted_local=True) despite its absent access service, so submitting the same key/content without context and retrying with that context selects different receipts and creates duplicate memories, contrary to RFC 1809. Use an empty namespace principal whenever access control is disabled.
There was a problem hiding this comment.
Verified on 79daca2: _create_keyed now selects an absent principal whenever the execution context has no access service. The public SDK regression creates without a context and retries with a trusted-local principal, returning the same original creation. The per-principal and revoked-contributor regressions also pass. This finding no longer reproduces.
A context that named a principal without an access service put that principal into the key namespace, so the same key and content created a second memory. Use the empty principal unless access is enforced.
hireview001
left a comment
There was a problem hiding this comment.
- CI failed: CI result (failure).
- CI failed: Upgrade release gate (failure).
- CI failed: CI preflight (failure).
- CI failed: Main (failure). Failed steps: CI preflight / Check OpenAPI contract; Upgrade release gate / Require the selected parallel acceptance workflow; CI result / Require successful selected checks.
| @@ -1,5 +1,5 @@ | |||
| { | |||
| "contractSha256": "e1ff2e3ad1d6a09a9288c4c66e111a54c4979026e29806ff70543988b8e29220", | |||
| "contractSha256": "36eb4ebc989a34be1872cd220c5289df81d690ea57d9e5565d50d06046ac9a81", | |||
There was a problem hiding this comment.
[P1] Register qualification for the new Desktop contract
The new bundled digest matches neither a profile nor an authenticated-client mapping in compatibility.json, so check_expected disables business operations on saved connections and connect_local rejects local setup with CompatibilityUnverified. Qualify this exact contract and register its evidence so Desktop connection workflows remain usable.
There was a problem hiding this comment.
Still open on 6224c9fd.
desktop/src-tauri/src/transport/operations.jsoncarriescontractSha256 = 71296c61a668467c03235d1dd2395ef69ac7f60476c8de0987eec455f1c72e75.desktop/src-tauri/src/connections/compatibility.jsonholds 74 records and none carries that digest. The two closest,sqlite-memory-idempotency-df79da6b-v1(e0e147b6…) andsqlite-memory-idempotency-bc11d08e-v1(36eb4ebc…), qualify earlier contract revisions only.tests/test_desktop_contract.py::test_bundled_desktop_contract_has_a_qualified_business_profilefails the same way on an exact-head mirror and on CI:make contract-teststops attests/test_desktop_contract.py:70withAssertionError: The bundled Desktop contract has no qualified profile for save, search and exact reads(Makefile:174, job 131807510532,1 failed, 67 passed).
The managed digest is not implicated: scripts/upgrade_release_gate.py::managed_digest recomputes to the declared value on this head, and the Upgrade release gate failure is only the downstream SCOPE_RESULT=failure propagation from this job.
There was a problem hiding this comment.
当前 head 6dce4701 上本条已闭合,给一份可复算的核对结果。
契约摘要一致
desktop/src-tauri/src/transport/operations.json现为contractSha256 = f41106d8716b5acc5212afcf515b45d58f963d6b10c0c158b85afe54a7acd731。- 我用
tests/test_desktop_contract.py:36-48的同一算法(sha256(openapi/powercontext.yaml 字节,CRLF→LF))对 head 的契约实算:文件 513499 字节、不含 CRLF,得到f41106d8…,与声明值逐字节相同。
资格记录已存在且覆盖所需操作
compatibility.json现有 90 条记录,命中该摘要的是sqlite-memory-release-efd4be07-v1(serverCommit=efd4be0731bc4683be4e2a66fc045cd808d00eb8),其operations含remember_memory、search_memory、get_artifact_revision。tests/test_desktop_contract.py::test_bundled_desktop_contract_has_a_qualified_business_profile的三项必需操作(save / search / exact reads)因此都能被同一 profile 满足。
也就是说上一轮"bundled digest 无资格记录"的路径不再成立,本线程按已修复处理。
There was a problem hiding this comment.
在 head b89e2d81 上复核,这条 P1 的前提已经不再成立。可复算的四点:
- head 的
openapi/powercontext.yamlsha256 =afa4523d92f32dc64a39e5b455214c1cf93172f9a696301331407dcf94bb8f19(516393 字节)。 desktop/src-tauri/src/connections/compatibility.json的新增记录sqlite-memory-1-6-3db8c17d-v1:serverCommit = 3db8c17d45a73dd07df989c00c2101f18b6a1c77、contractSha256 = afa4523d92f32dc64a39e5b455214c1cf93172f9a696301331407dcf94bb8f19、artifactSha256 = fbd66f53e645ecfaee171e6e3498f20a5078a44183c4329b81f607ae69d9a8f4,其中contractSha256与上面的 openapi 摘要逐字相等,operations覆盖remember_memory、search_memory等十三项。- 该记录的
evidence是desktop/VALIDATION.md#server-3db8c17d-16-and-keyed-memory-protocol-qualification,对应小节## Server 3db8c17d 1.6 and keyed Memory protocol qualification在 head 上存在(VALIDATION.md 第 4435 行起)。 - head 上
scripts/upgrade_release_gate.py退出码 0,scripts/generate_api.py --check、scripts/generate_js_operations.py --check均退出码 0。
所以“新的 bundled digest 既不对应 profile 也不对应 authenticated-client 映射”在当前 head 不再成立。如果仍看到不匹配,请附上核对用的 head 与摘要值。
The creation preflight skipped authorization whenever a context had no access service, so an explicit untrusted context could tell an occupied key from a free one through the conflict error. Only an absent context now skips the check; the domain policy decides the rest.
Bind the bundled Desktop contract to Server source bc11d08 and its built wheel after the native probe passed all four connection modes.
hidb4ai
left a comment
There was a problem hiding this comment.
Re-reviewed 6224c9fd. The revoked-contributor and untrusted-context cases in my earlier authorization thread are fixed; I am resolving that thread.
The remaining blocker is the existing Desktop contract qualification finding, which I independently reproduced on this head. The current bundled contract has no matching qualification or authenticated-client mapping, so the native connection checks cannot enable business operations or accept local setup. Please qualify the current contract and register its evidence, then rerun the contract checks. The upgrade-gate failure is downstream of the preflight failure, not a separate reproduced migration defect.
hidb4ai
left a comment
There was a problem hiding this comment.
Re-reviewed d47074dd550f2875634d17ba7ee157b52281df39. The previous Desktop contract/qualification and shared-000 findings are resolved.
One integration blocker remains against the newer master a137123c663307d16721625601bc602360ff0f62: git merge-tree --write-tree a137123c d47074dd exits 1 with a single conflict in release/upgrade-support.json. The combined tree's managed persistence inputs are byte-identical to this PR head, so their expected digest is still 6fb6f854b5e0ad5955e4e253b4df004abc94062787a95322aad41aebaddbb6b8. Please reconcile the policy while preserving both change rationales, then run the upgrade-policy check and CI on the combined result. No migration reordering or new revision is needed; the current functional results apply to this PR head.
hireview001
left a comment
There was a problem hiding this comment.
- Resolve merge conflicts with the target branch.
| # limitations under the License. | ||
|
|
||
| """Register the disposable historical Atomic Memory alias projection.""" | ||
| """Add the historical Atomic Memory alias projection and keyed creation receipts.""" |
There was a problem hiding this comment.
[P2] 本 PR 改的是共享草稿 000,而 #2917 正在把同一个 000 冻结成 v1_6_1;合入顺序会决定这次改动是否落地
本 PR 对 server_resources/versions/000.py 只改 docstring(加 keyed creation receipts),对 schemas/sqlite-000.json / mysql-000.json 与 manifest.json 追加语句和校验和;基 blob 是 648a1fb034。
同时在飞的 #2917(release 1.6.1)从同一个 648a1fb034 把该文件重命名为 versions/v1_6_1.py,并把 revision = "000" 改成 v1_6_1、资源路径改成 schemas/sqlite-v1_6_1.json(mysql 侧与 schemas 同步重命名)。也就是说两份分支都从同一起点改 000,只是 #2917 还改了文件名。
若 #2917 先合入,本 PR 的 rebase 会按旧路径把 versions/000.py 重新创建出来,down_revision 仍是 v1_6_0 —— 与已冻结的 v1_6_1 形成两个 head,schema_release.py check 与 Upgrade release gate 会直接红;schemas/sqlite-000.json 同样会被复活。若本 PR 先合入,#2917 的冻结需要带上这些 DDL 与校验和(它当前的重命名树并不包含本 PR 的 receipt 语句)。
建议:明确两者的合入顺序并写进 PR 描述。若 #2917 先走,本 PR rebase 后应把 docstring、schema 语句和 manifest 校验和全部落到 v1_6_1(manifest.json 的键也从 000 改成 v1_6_1);若本 PR 先走,请在 #2917 里补一条说明,确认冻结树包含这些语句。
There was a problem hiding this comment.
Coordination note for 97f81fb45: the current v1_6_0 -> 000 chain is valid against master 246f70beb; #2917 is still open. The release-first remedy above needs one correction: the repository migration policy forbids adding this PR's DDL to an already frozen v1_6_1.
- If feat(memory): make keyed remember_memory writes idempotent #2583 merges first, chore(release): prepare PowerContext 1.6.1 #2917 must refresh its freeze from the combined
000, including the receipt table. - If chore(release): prepare PowerContext 1.6.1 #2917 merges first, this PR must preserve frozen
v1_6_1and introduce a new draft000withdown_revision = "v1_6_1", containing only its remaining schema changes. Synchronize the draft resources, source/profile registrations, fingerprints, native recovery layouts and persistence digest, then validate the updated merge result.
This is merge-order coordination, not a demonstrated two-head defect in the current PR tree. See the migration policy.
hidb4ai
left a comment
There was a problem hiding this comment.
Re-reviewed 97f81fb45 against master 246f70beb; the previous merge conflict is resolved. Required CI validation is still incomplete: Python 3.11 E2E shard 0 failed test_default_recorder_write_contention_is_bounded_and_does_not_break_later_operations because the contended statistics write took 1.069 seconds against its 1-second bound. The selected installed-release upgrade jobs were then skipped, so the upgrade gate and aggregate CI result also failed.
The individual test passes locally on both this head and its base, and the base's corresponding CI shard passed. That does not establish the cause of the runner failure. Please diagnose it and obtain successful required CI, including the selected upgrade acceptance, on the up-to-date merge result before merging. Local functional checks do not replace that missing matrix.
The failing Python 3.11 shard starts 32 xdist workers. In a four-CPU container, repeated write-contention cases fail 10/30 at 32 workers and 2/30 at 16 workers, while 8 workers pass 30/30 and the focused suite passes 287 tests. Bound E2E workers to 8, matching the unit job, to reduce scheduling contention while retaining the existing write-time assertions. The exact original 1.069-second failure remains unproven locally.
Qualify Server deedec9 against all thirteen Desktop operations in anonymous loopback, static Bearer, HTTPS with CA/base path, and Provider modes. All 842 packaged runtime files match the source. Native sessions pass 9 tests, IPC generation matches, and the replacement UI passes 86 tests. Record exact contract and wheel digests in the product catalog.
hidb4ai
left a comment
There was a problem hiding this comment.
Re-reviewed 9747f0867. The previous Python 3.11 E2E failure and selected SQLite installed-release upgrade checks are now green. Two integration gates remain:
- Merging this head with current master
edd90eb85produces content conflicts indesktop/src-tauri/src/connections/compatibility.json,desktop/src-tauri/src/transport/operations.json, anddesktop/ui/src/generated/operations.ts. GitHub also reportsCONFLICTING/DIRTY. Reconcile the compatibility entries and regenerate the contract artifacts from the combined OpenAPI source, then validate that merged result. - Required CI is incomplete: macOS Intel Desktop validation times out after 5000 ms in
removes cached private Memory results after a stale_context read failure(desktop/ui/tests/app.test.tsx:150), and the macOS arm64 managed-resource candidate is cancelled. These leave aggregate CI failed. The timed-out test and Desktop application code are unchanged from the PR base, and the other Desktop platforms pass; this does not establish a PR regression. Please diagnose the Intel runner failure without weakening the privacy assertion and complete the required checks on the updated merge result.
|
The affected modules are Core, Desktop. @hidb4ai, please coordinate follow-up. Core: @hidb4ai @frf12 @Fengzdadi @beatenevo; Desktop: @PsiACE @knqiufan. Please coordinate the review of the affected changes. |
hireview001
left a comment
There was a problem hiding this comment.
- Resolve merge conflicts with the target branch.
hidb4ai
left a comment
There was a problem hiding this comment.
Reviewed 79daca2. Keyed creation, authorization and original-result replay are consistent with the contract; the old SDK namespace finding is fixed. The receipt table is correctly in the cumulative 000 after v1_6_0, with frozen history preserved. Actual 1.6.1-to-000 upgrades on SQLite and OceanBase preserved existing data and added only the receipt table. Keyed replay survived restart; six concurrent OceanBase requests created one memory. SQLite additionally passed real embedding, generation and recall. Merge score: 75/100. No approval because this adds a database table. Resolve the current Desktop test conflict and validate the merged result before merging. The fixed Python worker count also needs the evidence requested below.
| env: | ||
| PYTEST_ADDOPTS: --require-dsh-config-runtime --require-claude-code-python-floor | ||
| # Limit contention for tests that spawn subprocesses with fixed deadlines. | ||
| PYTEST_WORKERS: "8" |
There was a problem hiding this comment.
Design note (non-blocking): this fixes both unit and E2E concurrency at eight workers for every Python runner. The repository CI policy requires measured sizing rather than a precautionary fixed cap. The PR description reports CPU measurements for the Desktop UI test, which do not establish the Python runner limit. Please include the relevant runner CPU/memory and subprocess-contention measurements that justify eight, or retain the existing worker selection and isolate the demonstrated deadline-sensitive case. The same point applies to the E2E override below.
happy-v587
left a comment
There was a problem hiding this comment.
Reviewed independently (branch @ 79daca2, full clone, real runs on macOS):
Verified green locally
tests/e2e/test_remember_memory_idempotency.py+tests/test_mcp.py: 32 passed — covers replay-equality, creation-state replay after later changes, 409-without-write on content mismatch, invalid keys rejected before any write, expiry + bounded cleanup (32), in-process and multiprocessing concurrency (exactly-once, winner replays, losers 409 withdetails.kind = memory_idempotency_key), per-principal namespaces under enforced access, re-authorization on replay, and the untrusted-context key-probe denial.- Migration suites (
test_full_server_migrations,test_portable_storage_migration,test_migration_revision_names,test_managed_atomic_maintenance,test_mysql_migration_runner,test_managed_processing_maintenance,test_registered_source_maintenance_cli): 81 passed / 80 skipped (MySQL/SeekDB need the dedicated backend env). Draft000adds onlypc_atomic_memory_idempotency+ expiry index; SQLite and MySQL resources are synchronized on the samev1_6_0predecessor, frozen fingerprints preserved. - CI on this head: 74 checks pass, 0 fail.
Design review: sound.
- Authorize-before-lookup ordering means a replay/conflict is never disclosed to a caller who lost create authority; replays re-authorize and re-read the exact revision with current authz.
- Receipt binding commits in the same transaction as the creation; concurrent claims resolved via the primary key (
IntegrityError→ re-lookup → replay), verified by both barrier tests. - Only SHA-256 digests of namespace and RFC 8785 content are persisted — no raw key, principal, or body;
digest_versiongates future digest evolution (request_digestreturns None for unknown versions, so cross-version binaries fail closed rather than silently mismatching... worth confirming that a mixed-fleet 24h window can't loop-conflict, but version bumps are opt-in and none exist yet). - Expired-key replacement deletes only rows still expired at the write, so a concurrently committed live key is never clobbered; failed cleanup is logged content-free and never changes the write result.
- HTTP 409 mapping goes through
BaseValueConflictError("memory_idempotency_key")→idempotency_conflict; the OpenAPI description, generated clients, Desktop bindings, MCP description, and Skill guidance are all updated; Dify keeps it hidden as stated.
Non-blocking observations:
create_keyed_atomic_memoryrunsrequest_digest(command)eagerly for validation but discards the value;bind_receiptrecomputes it inside the transaction. Harmless double-compute; a comment or reuse would be marginally cleaner.- The e2e suite doesn't exercise a digest_version ≠ 1 row (the fail-closed path is only visible via unit-level reading). Fine while version 1 is the only version.
- The PR is marked
dirtyon GitHub right now —git merge-treeshows conflict against current master (likely inrelease/upgrade-support.json/shared draft files touched by the 1.6.2 line). Same reconciliation round as #2894; needs one more merge pass against the current base before the final CI gate.
No correctness blockers from me.
happy-v587
left a comment
There was a problem hiding this comment.
Verified locally in my earlier review (full clone + real test runs, see my COMMENTED review below): all relevant suites pass, no blockers. Approving as confirmed by the project owner.
Which issue or RFC does this PR close?
Closes #2521.
Rationale for this change
A client that times out on
remember_memorycannot tell whether the write was committed, and a blind retry creates a duplicate memory. An optional idempotency key lets the caller retry the same creation safely. The receipt table is added in the shared migration draft000, immediately after the frozenv1_6_0baseline.What changes are included in this PR?
remember_memoryaccepts an optionalidempotency_key(^[!-~]{1,256}$, compared byte for byte). The same rule applies over HTTP and the in-process SDK.changed: true. Replays are re-authorized and do not extend the key.409 idempotency_conflictwithdetails.kind = "memory_idempotency_key"and writes nothing.000addspc_atomic_memory_idempotencyfor SQLite and the MySQL dialect. Both dialects declarev1_6_0as the predecessor. The source manifests, final SQLite fingerprints, readiness registrations and upgrade policy reflect that chain. Frozen migration resources and fingerprints are preserved.atomic_memory.idempotency.cleanup_failedand never changes the write result.Out of scope: deduplication across different keys, changes to
expected_revision, automatic client retries, and a general idempotency framework.Are there any user-facing changes?
Yes, additive.
remember_memorygains an optionalidempotency_key, and a new409 idempotency_conflictresponse applies only to keyed requests. Requests without a key behave as before. The idempotency table is added in the shared draft000after the frozenv1_6_0baseline. The schema change rewrites no existing data. Release preparation freezes000under the declared release revision. Development databases and plans from the prior unpublishedv1_5_2_001revision must be rebuilt.How was this change tested?
The combined tree includes master
0b60e52acfcefe2fe64cca52249db83c98d9a3ba. Merge commit0d1bfe33areconciles all historical Desktop qualification records and regenerates the contract bindings.79daca289registers the tested product artifact.ty checkpassed. Frozen migration history matches master; the single draft head remains000. The upgrade-policy digest check passed.sqlite-memory-1-6-0d1bfe33-v1covers all thirteen Desktop operations.powercontext-1.5.3.dev651+g0d1bfe33a-py3-none-any.whl: SHA-2560480c6c1cb945cc6908bca03b4c11b99903438da19f19f4f58bc53401b19af1d. All 848 packaged runtime files match commit0d1bfe33a3b894086b9c6e5c324b70f85df7cb73. OpenAPI SHA-256:727649c606e096a92d88e56959e24e751df9398fd90175464b59f44b98cd40b6.Required CI has been triggered on
79daca289. macOS Intel/arm64 validation, native backend acceptance and the complete selected installed-release upgrade matrix remain pending; local Linux tests do not replace those gates. Installed WebView and platform keyring qualification remain separate.Merge coordination
This PR targets 1.6.2 and includes release preparation #2917, merged as
25f300ad0. That release sets API metadata to 1.6.1 and retainsv1_6_0as the last frozen database revision. Both registered source paths therefore continue asv1_6_0 -> 000for keyed Memory receipts. Release preparation for 1.6.2 freezes the shared draft under the declared release revision.The merged tree preserves #2935's removal of historical alias recall. Draft
000contains only the receipt table and expiry index, with synchronized SQLite/MySQL resources, registrations, fingerprints, recovery layouts and persistence digest.The tree includes the replacement Desktop from #2730. Its generated bindings and product compatibility catalog reflect the combined contract. Required CI and installed-release upgrade acceptance must pass on the current branch before merge.
AI usage statement
Claude Code (Claude Fable 5.2) assisted with the implementation, design analysis, tests and documentation. OpenAI Codex assisted with migration dependency reconciliation, conflict resolution, regression tests, generated contracts and real-Server Desktop protocol qualification.