Skip to content

fix(atomic-memory): let one-pass recheck cite every Source of the window - #2839

Open
Fengzdadi wants to merge 2 commits into
oceanbase:masterfrom
Fengzdadi:fix/one-pass-recheck-window-evidence
Open

Fengzdadi wants to merge 2 commits into
oceanbase:masterfrom
Fengzdadi:fix/one-pass-recheck-window-evidence

Conversation

@Fengzdadi

@Fengzdadi Fengzdadi commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Which issue or RFC does this PR close?

No issue. Found in an audit of the one-pass processing mode added in #2729. Design: docs/zh/design/atomic_memory_one_pass_design.md §3.2 and §3.4.

Rationale for this change

Step 2 of a one-pass window accepts any evidence_id of the window. Step 3 (recheck) told the model to decide again "with the step 2 rules", but passed its evidence_ids straight to the reconciliation check, which builds its evidence only from the created memory and the recalled memories. A recheck that revised or merged a recalled memory and cited another Source of the same window was rejected with "write must have supported content and only supplied evidence". The correction message does not say which ids count, so the model could not fix it reliably, and once corrections ran out the flush failed and the whole window was retried.

What changes are included in this PR?

  • apply_one_pass_recheck takes the window's extraction input. A write's evidence_ids must be window evidence, the same rule and message as step 2. The cited evidence is added to the created memory before the decision is applied, so the published memory's evidence and Source lineage match what a step 2 write citing the same ids produces.
  • Ids outside the window are still rejected. A write without evidence_ids keeps the created memory's own evidence, as before.
  • When a recheck revision is not written because it only repeats the recalled memory, the created memory keeps the evidence and Source lineage it had before the recheck.
  • _recheck_one_pass passes the extraction input.
  • zh design doc §3.4 describes the step 3 evidence rule.

Are there any user-facing changes?

Yes. A one-pass recheck that cites another Source of the same window is now applied instead of failing the window. No API or persisted format changes.

How was this change tested?

  • New tests/e2e/test_atomic_memory_one_pass.py::test_recheck_accepts_every_evidence_id_of_the_window: a two-Source window where step 2 creates a memory from one Source and step 3 revises a recalled memory citing both. The revision keeps the recalled memory's identity and links both Sources. An id outside the window is still rejected and nothing is published. Without the fix the first case fails with the rejection above.
  • uv run pytest tests/e2e/test_atomic_memory_one_pass.py tests/builtin/artifacts/atomic_memory/test_prefixed_extraction.py: all passed.
  • make check: passed.
  • make unit-test: 13 failed, 120 errors, all in test_hook_characterization.py, test_session_start_shells.py, test_user_prompt_submit_shells.py, test_jev_rerank_comparison.py, test_ci_installation_roles.py and test_system_cli.py. The same files give the same 13 failures and 120 errors on unmodified master in the same offline environment (hook environments run uv sync and need network).

AI usage statement

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

Step 2 accepts any evidence_id of the window, but step 3 passed its evidence_ids
straight to the reconciliation check, which only knows the created memory's own
evidence and the recalled memories. A recheck that revised or merged a memory and
cited another Source of the same window was rejected, and once corrections ran
out the whole window failed and was retried.

Step 3 now validates evidence_ids against the window, as step 2 does, and adds
the cited evidence to the created memory before applying the decision. Ids
outside the window are still rejected.

@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 7361c97. No blocking findings. Allowing step 3 to cite the current window's evidence is consistent with step 2, while retaining rejection of out-of-window IDs and the existing reconciliation/publication checks. No database schema changes or new public interfaces.

}.values()
),
)
result.items[key] = proposal

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.

[P2] Preserve original evidence during redundant-revision recovery

When a recheck cites another window Source and returns a revise identical to the recalled target while the proposal text differs, _apply() recovers by retaining the proposal, but this assignment leaves the newly cited evidence and Source lineage attached. The retained memory can consequently be published without that Source's required date; restore the original proposal's evidence and lineage before recovery or keep the expansion temporary until the write succeeds.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in a1cd33b. When the recheck revision is redundant, the created memory is restored to what step 2 made before the recovery runs, so it keeps only the evidence and Source it was created from. test_recheck_accepts_every_evidence_id_of_the_window has a new case for this: the recheck revises the recalled memory to its own text and cites both Sources; the created memory is kept and links only its own Source. Without the restore the case fails with both Sources linked.

@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 a1cd33b. The reported redundant-revision lineage issue is fixed: recovery restores the original step-2 item before retaining it, so evidence from the unwritten revision does not leak into the published memory. I reproduced the lineage regression on the previous implementation and verified the corrected recovery and successful cross-Source recheck paths. No remaining blocking findings, database schema changes, or new public interfaces.

@AlexStocks AlexStocks added the 1.6.2 v1.6.2 release tracking label Nov 30, 2026
@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.

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