Skip to content

fix(backend): keep memories user_review list filter in Python - #11915

Merged
undivisible merged 1 commit into
mainfrom
cursor/memories-user-review-firestore-filter-a492
Aug 20, 2026
Merged

undivisible merged 1 commit into
mainfrom
cursor/memories-user-review-firestore-filter-a492

Conversation

@undivisible

@undivisible undivisible commented Aug 20, 2026 •

Copy link
Copy Markdown
Collaborator

What changed and why

Investigated moving the user_review list filter in backend/database/memories.py into Firestore. Firestore cannot express user_review is not False without dropping legacy docs that omit the field (#4498): inequality / not-in / != exclude missing fields, and == None only matches explicit null. Closest safe query remains category/date bounds + scoring order + limit/offset, with visibility applied in Python via a shared helper (same semantics as before).

Product invariants affected

  • INV-MEM-1

How it was verified

cd backend && source .venv/bin/activate
python -m pytest tests/unit/test_memories_user_review.py tests/unit/test_bounded_firestore_list_reads.py tests/unit/test_memories_pagination_clamp.py tests/unit/test_firestore_di_seam.py -q
# 34 passed

External API results unchanged: still includes missing/None/True user_review, excludes False, and keeps default invalid_at exclusion.

Tests

  • Extended tests/unit/test_memories_user_review.py to exercise production _memory_passes_list_visibility
  • Added scoring-path fake asserting no user_review/invalid_at FieldFilter while Python still filters correctly
  • Added merge-index coverage for the same helper

Failure class (fixes)

Failure-Class: none

Open in Web Open in Cursor 

Review in cubic

Firestore cannot express user_review is not False without dropping legacy
docs that omit the field (#4498). Document that constraint, share one
visibility helper for list paths, and assert the scoring query omits
unsafe user_review/invalid_at FieldFilters.

Failure-Class: none

Co-authored-by: Max Carter 祁明思 <[email protected]>
@undivisible
undivisible marked this pull request as ready for review August 20, 2026 10:05
@cursor

cursor Bot commented Aug 20, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_05547b8a-f406-454f-a508-c8f7064ae720)

@undivisible
undivisible merged commit f057bb5 into main Aug 20, 2026
43 checks passed
@undivisible
undivisible deleted the cursor/memories-user-review-firestore-filter-a492 branch August 20, 2026 10:05

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: db47a543d5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +41 to +45
def where(self, *args, **kwargs):
filt = kwargs.get('filter') or (args[0] if args else None)
q = _RecordingQuery(self._db, self._docs, self._filters + [filt])
q._limit = self._limit
q._offset = self._offset

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Exercise Firestore query semantics in the regression

Because this regression is specifically about which Firestore predicates preserve missing-field documents, a fake whose where() only records predicates cannot validate the behavior it claims: a positional where('user_review', '!=', False) would still return keep-missing, and the later object-attribute check would not detect the field. Cover this query behavior with the Firestore emulator or a fake that enforces Firestore's constraint semantics.

AGENTS.md reference: backend/AGENTS.md:L214-L214

Useful? React with 👍 / 👎.

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.

2 participants