Skip to content

feat(memory): reconcile duplicate and conflicting writes - #6981

Merged
chinawch007 merged 3 commits into
apache:rust-previewfrom
chinawch007:feat/ordinary-memory-pr2
Nov 18, 2026
Merged

chinawch007 merged 3 commits into
apache:rust-previewfrom
chinawch007:feat/ordinary-memory-pr2

Conversation

@chinawch007

Copy link
Copy Markdown
Contributor

Summary

Memory writes need to distinguish additional evidence from a new assertion, and prevent conflicting or previously deleted content from becoming effective under a new ID. This implements the PR2 write-reconciliation stage of the ordinary-memory migration.

  • Route single and batch management writes through conservative exact matching, indexed candidate retrieval and bounded semantic classification. Equivalent assertions reuse the current ID/version and append evidence; automatic replacements require verified, explicit and newer evidence.
  • Keep conflicts with user-protected assertions unresolved, retain assertion-version relationships, and include deleted/corrected content and confirmed aliases in restricted matching. Pending records are available through a management-only paginated query.
  • Classify outside the transaction, then revalidate scope generations, target versions, evidence and authority before an atomic commit. A changed scope permits one reinspection; Host receipts and auxiliary usage accounting preserve retry and recovery behavior.
  • Add API/SDK contracts, client receipt handling, migration/index maintenance and regression coverage, reusing the existing auxiliary model lifecycle.

For example, a confirmed “Postgres”/“PostgreSQL” equivalence adds evidence to the existing assertion. A conflicting automatic write against a user-protected assertion remains pending instead of becoming a second effective fact.

Refs #6959

Verification

Recorded focused checks:

  • State library tests: 44 passed; facts library tests: 36 passed.
  • Native memory:: tests: 4 passed, using a real Host with a controlled provider fixture for semantic calls, concurrent deletion/reclassification, authority rejection, restart and isolation.
  • Client pending-operation recovery test: 1 passed; CI planning tests: 19 passed.
  • SDK generation, verification of five declaration files and TypeScript checks: passed.
  • State strict Clippy, changed Rust formatting and git diff --check: passed.

Additional strict Native Clippy failed in unchanged driver, driver cleanup, notifications, history projection and scheduler code; dependency-inclusive Clippy also reported a provider-protocol warning. Full just check, cross-platform runners and production-model sampling were not run. Controlled provider judgments verify integration, not production semantic accuracy. The regression tests were not rerun against the base revision to establish a before/after failure comparison.

Migration and matching limits

Migration 0046_memory_resolution.sql builds an FTS5 trigram index for existing assertions and adds relation/provenance storage. Suppression retains matching content; deletion is not physical erasure.

Retrieval uses separate bounded budgets for ordinary, protected/pending and restricted candidates. The lexical fixture retrieves 5/6 examples; a translation without shared substrings is missed. This does not guarantee global semantic uniqueness or zero false merges/suppression. Recall integration, pinned projections/import handling, conversation extraction/authorization parsing and automatic triggers belong to subsequent PRs.

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: OpenAI Codex contributed implementation, regression tests and validation. Both implementation commits carry Generated-by: Codex; retain this trailer in the squash commit.

Checklist

  • Tests cover the change and fail without it
  • Format, typecheck and the affected suites pass locally

The first item remains unchecked because no base-revision failure comparison was run. The second refers to the focused checks listed above, not a successful full-repository check or Native strict Clippy run.

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

Reuse current assertions with incremental user evidence, preserve protected modes, and reject exact deleted or corrected assertions. Include Host concurrency and restart coverage and document the remaining PR2 scope.

Generated-by: Codex
Route single and batch management writes through bounded candidate snapshots, auxiliary semantic classification and scope-checked atomic commits. Preserve user authority, target identities and assertion provenance, retain unresolved conflicts, and enforce deletion suppression. Add pending queries, migration/index maintenance, SDK and client receipt integration, and Host/state regression coverage.

Document fixed budgets, retrieval fixture results and validation limits in the English and Chinese PR2 technical reports.

Generated-by: Codex
@chinawch007
chinawch007 force-pushed the feat/ordinary-memory-pr2 branch from 2c9666b to 408503e Compare November 18, 2026 00:35
@chinawch007
chinawch007 merged commit b257b85 into apache:rust-preview Nov 18, 2026
29 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant