Skip to content

feat(atomic-memory): recall merged memories through historical aliases - #2674

Open
Tech-Circle-48 wants to merge 10 commits into
oceanbase:masterfrom
Tech-Circle-48:2326
Open

Tech-Circle-48 wants to merge 10 commits into
oceanbase:masterfrom
Tech-Circle-48:2326

Conversation

@Tech-Circle-48

Copy link
Copy Markdown
Contributor

Which issue or RFC does this PR close?

Closes #2326.

Rationale for this change

After a memory is merged, its historical wording may no longer match its active successor. Repeating that wording can therefore create a duplicate active identity. Historical aliases allow reconciliation to consider the current successor under existing filtering, authorization and decision rules.

What changes are included in this PR?

  • Add the derived pc_atomic_memory_alias projection and transactional lifecycle maintenance.
  • Recall historical wording through text/vector channels and resolve Scope-local merge chains, with cycle detection and a 64-edge limit.
  • Preserve direct-hit priority, exact-version checks, authorization and comparison budgets.
  • Add the default-enabled atomic_memory_alias_recall switch; disabling it skips alias queries.
  • Extend projection rebuilding to recover merged aliases, preserve compatible vectors, regenerate missing/incompatible vectors and verify the resulting alias set.
  • Register schema revision v1_5_0_006 without changing frozen historical migration contracts.
  • Add regression, lifecycle, authorization, snapshot, rebuild and upgrade tests, and update English/Chinese operations documentation.

Are there any user-facing changes?

Reconciliation can now find an active successor through a merged memory's historical wording. Public search, content/state models, reconciliation actions and prompts retain their existing semantics.

Managed databases require an explicit schema upgrade. Existing merged records require a separate projection rebuild to populate aliases.

Empty projections or embedding-profile changes may regenerate vectors. Nondeterministic embedding services cannot reproduce deleted historical vector bytes from authority alone.

How was this change tested?

  • Ran the fixed-vector regression before implementation and confirmed duplicate identity creation.
  • Final alias, rebuild, schema and managed-maintenance regression group: 42 passed.
  • Historical Server migration suite after the compatibility fix: 59 passed.
  • Spawned supervisor Worker test: 1 passed.
  • Broader Atomic Memory E2E/persistence run: 1,278 passed and 340 skipped; its historical-conversion failures were fixed and covered by the subsequent 59-test run, and its sandbox-blocked Worker test passed when rerun outside the sandbox.
  • uv run prek run -a: passed.
  • Ruff checks for newly added Python files, ty check and git diff --check: passed.
  • Independent code reviews found no blocking correctness issues.

Authored SQLite cases used deterministic vectors. Historical wording changed from create to noop, adding one successor candidate and approximately 217 estimated input tokens. The unrelated-fact control retained create with no token increase.

Actual SQLite behavior was exercised. OceanBase/MySQL validation covered generated SQL and schema fixtures; no real OceanBase service or real embedding/generation model acceptance was performed.

AI usage statement

Comment thread release/upgrade-support.json Resolved

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

The Atomic maintenance initialization regression below blocks approval.

Design note (non-blocking): #2326 specifies a lexical baseline and a separately evaluated historical-vector rollout. This implementation enables both by default, while the reported comparison uses deterministic vectors and covers only repeated wording and an unrelated control. Please reconcile that scope/default decision with the issue and provide the requested lexical-versus-vector and total-flush cost evidence, or retain an opt-in rollout until that decision is made.

@hidb4ai

hidb4ai commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Design note (non-blocking): Could we reuse the existing revision history and authoritative merge links for this lookup instead of introducing pc_atomic_memory_alias?

I understand that resolving a known merged identity is different from discovering it through historical wording. However, the historical content and merge relationships already exist. Please explain what prevents us from searching the selected revisions of currently merged identities, then resolving their active successors under the existing authorization checks.

Before adding another table and its lifecycle/rebuild logic, please compare that approach with the proposed projection, including query support and measured cost. If a separate projection is necessary, please also justify historical vector storage separately from the lexical baseline.

@AlexStocks AlexStocks added the 1.6.0 v1.6.0 release tracking label Nov 17, 2026
happy-v587 added a commit to happy-v587/powercontext that referenced this pull request Nov 17, 2026
PR oceanbase#2674 registers the same v1_5_0_006 ID and adds identically named
migration files; two linear chains cannot share a revision ID. Renumber
the prepare diagnostics revision, its schema resources, manifest
registrations, docs and target-revision assertions, and refresh the
compatibility review digest.

Co-Authored-By: Claude Code <noreply@anthropic.com>

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

@frf12

frf12 commented Nov 18, 2026

Copy link
Copy Markdown
Member

The old queued CI run was cancelled while migrating eligible Linux checks to the internal runner pools in #2711.

At head fd7a73053, this PR has merge conflicts with master 07621c869. Conflicts affect upgrade metadata, server migration manifests, and the related migration tests, including:

  • release/upgrade-support.json
  • src/powercontext/builtin/persistence/migrations/server_resources/manifest.json
  • tests/builtin/persistence/test_full_server_migrations.py

Please sync the branch with master, resolve the conflicts, and push the update. GitHub cannot start a new pull_request workflow while the conflicts remain; eligible Linux checks can then use the updated internal-runner routing.

else:
raise AtomicMemoryIndexError("dialect", "Atomic Memory projection needs SQLite or MySQL")
await connection.execute(statement, values)
if self.alias_table not in self.tables:

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] self.alias_table not in self.tables 恒为 False,注释描述的清理豁免永远不会生效

:975 把 alias_table 无条件放进 self.tables,且 self.tables 只有这一处赋值:

self.alias_table = atomic_memory_alias_table(table.c.embedding.type)
self.tables: tuple[Table, ...] = (table, self.alias_table, ...)

因此 :1075 的 if self.alias_table not in self.tables: return 在对象构造完成后不可能成立,replace_many() 末尾的 alias 清理对所有路径都会执行。注释「Frozen historical conversion publishes before the alias revision / Only the registered current layout owns outgoing alias cleanup」描述的是一个真实场景,但这个判据表达不出来它。

两种可能都不理想:该场景不存在时,这里是死代码,且注释会让人以为有保护;该场景存在时(冻结历史转换早于 alias revision 建表),replace_many() 会对尚未创建的 pc_atomic_memory_alias 执行 DELETE,在 SQLite 上就是 no such table。

建议把判据换成能表达该场景的事实(连接上的实际表清单、或索引是否注册了 alias 表),或者删掉分支并把注释改为「alias 清理随 tables 一同注册」。若判断该场景不必保留,补一条在 alias 表缺失的连接上调用 replace_many() 的用例即可把这个分支的语义钉住。

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.0 v1.6.0 release tracking

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(atomic-memory): alias recall so a merged memory's historical wording still reaches its live successor

5 participants