Skip to content

fix(atomic-memory): keep alias-only hits in one-pass related recall - #2842

Open
Fengzdadi wants to merge 1 commit into
oceanbase:masterfrom
Fengzdadi:fix/one-pass-alias-recall-limit
Open

Fengzdadi wants to merge 1 commit into
oceanbase:masterfrom
Fengzdadi:fix/one-pass-alias-recall-limit

Conversation

@Fengzdadi

Copy link
Copy Markdown
Collaborator

Which issue or RFC does this PR close?

No issue. Follow-up to #2674 (alias recall) and #2729/#2775 (one-pass processing), found in an audit of the one-pass processing mode.

Rationale for this change

One-pass processing reads at most ONE_PASS_MEMORIES_PER_QUERY (5) related memories per query. With atomic_memory_alias_recall on, _combine_related_ranks appends alias-only successors after every direct hit, and _recall_related_items then cut the combined list to 5. Alias ranks carry no score, so they always sorted last: once a query had five direct hits, a merged memory reachable only through its historical wording was never shown to the model, even when that wording matched the observation exactly, and the duplicate was not caught. Per-candidate mode passes no limit and was unaffected.

What changes are included in this PR?

  • With a limit, related recall keeps the first limit direct hits in rank order, then up to limit alias-matched successors outside them, in the alias query's stable identity order. A memory hit directly beyond the limit and also through an alias counts in the alias part. The revision/state-version agreement check is unchanged.
  • One query can now show up to 10 memories; the 40-memory total and the step-two input budget check (operations_input_over_budget, measured on the rendered message) are unchanged and still fall back to per-candidate processing when exceeded.
  • Behaviour without a limit (per-candidate mode) and with alias recall off is unchanged. No new queries; persistence is untouched.
  • Docs: one-pass design §3.5 (zh) and the alias section of the Atomic Memory migration guide (en/zh).

Are there any user-facing changes?

Yes. One-pass processing can now compare a new observation with a merged memory through its historical wording when the query also has five or more direct hits. No API or persisted format changes.

How was this change tested?

  • New e2e regression test test_memory_reachable_only_through_its_historical_wording_is_shown_beside_closer_hits in tests/e2e/test_atomic_memory_one_pass.py (SQLite, FTS, one-pass): fails with the runtime change reverted (the merged memory is not shown), passes with it.
  • pytest tests/e2e/test_atomic_memory_one_pass.py tests/e2e/test_atomic_memory_alias_recall.py tests/e2e/test_atomic_memory_alias_edges.py tests/e2e/test_atomic_memory_alias_rebuild.py tests/test_atomic_memory_alias_upgrade.py: 59 passed.
  • make check: passed.
  • make unit-test (offline): 13 failed, 120 errors, limited to tests that run uv sync and need network or are environment-specific; the same failures occur without this change.
  • Not run: the OceanBase backend.

AI usage statement

This change was written with Claude Code (Claude Opus 5.5).

One-pass processing reads at most five related memories per query. With
alias recall on, alias-only successors were appended after every direct
hit and then cut with the direct hits, so five direct hits hid a memory
reachable only through its historical wording, even when that wording
matched the observation exactly, and the duplicate went uncaught.

With a limit, keep the first `limit` direct hits and then up to `limit`
alias-matched successors outside them, in alias order. Behaviour without
a limit and with alias recall off is unchanged.

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

No blocking findings at 02e12bf. The separate alias allowance fixes the crowd-out while retaining snapshot/version checks and the existing display and input budgets. No new tables, migrations, or public interfaces. Real SQLite and OceanBase runs with the configured LLM confirmed that creation rechecks receive five direct hits plus the alias successor, with persisted readback after reopening. This validates visibility, not a guarantee that the model will merge or deduplicate.

@AlexStocks AlexStocks added the 1.6.2 v1.6.2 release tracking label Nov 30, 2026

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

@hidb4ai hidb4ai added the module:core Core: PR changes under src/ label Dec 2, 2026
@hireview001

Copy link
Copy Markdown
Collaborator

The affected modules are Core. @hidb4ai, please coordinate follow-up. 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.

The change is sound against its original alias-recall baseline, but current master has intentionally withdrawn that feature in #2935 (a194e66), including its configuration and unpublished 000 migration. Merging 02e12bf with current master now conflicts in atomic_memory_processing.py and both migration guides. Please reconcile this PR with that product decision and the current baseline before merging; the earlier approval does not validate a reintroduction or a resolved merge.

Current-head focused tests and a real configured-LLM/SQLite processing-and-reopen flow pass. The live model chose a different recall query, so the five-direct-plus-alias crowd-out case is established by the deterministic regression, not by that live run. No new defect was found in the bounded selection algorithm itself.

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/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants