Batch onboarding memory imports#8762
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7fe8386d03
ℹ️ 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".
| if device_ids: | ||
| shared["capture_device_ids"] = device_ids | ||
| return shared | ||
| return strip_null_metadata_values(shared) |
There was a problem hiding this comment.
Preserve canonical freshness fields
When a canonical MemoryItem has source_commit_id or content_hash unset, this now writes a Pinecone vector without those keys, but the canonical search hydrator treats any hit missing either field as stale_vector and drops it (backend/models/memory_search_gateway.py checks both before returning results). That means the new “successful” upsert path creates vectors that are never searchable for exactly the null-metadata case covered by the added test; either populate non-null freshness metadata or change the read-side freshness check before treating these writes as valid.
Useful? React with 👍 / 👎.
|
|
||
| for chunk in chunks { | ||
| do { | ||
| let response = try await APIClient.shared.createMemoriesBatch(chunk) |
There was a problem hiding this comment.
Avoid exhausting the shared batch write quota
This helper is now used by Gmail, Calendar, Apple Notes, and memory-log imports, but every chunk consumes the same memories:batch quota, which is capped at 30/hour in backend/utils/rate_limit_config.py. In onboarding, the existing local-file importer can use up to about 28 batch requests by itself, and the new integration imports add more chunks (for example Calendar can add 5 for its 500-event import), so the 31st request starts returning 429 and this code marks whole chunks as failed with no retry or fallback. Please budget these imports against the shared quota or raise/split the backend limit before routing more onboarding sources through this endpoint.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
2 issues found across 12 files
Confidence score: 3/5
backend/database/memory_vector_metadata.pynow strips nullsource_commit_idandcontent_hashfor Pinecone, but if hydration logic interprets missing freshness fields as stale, valid memories could be dropped from search results after indexing—add/confirm a hydration-path check (or fallback semantics) for missing freshness metadata before merging.desktop/macos/Desktop/Sources/OnboardingMemoryBatchImportService.swiftprocesses multiple onboarding imports sequentially against a sharedmemories:batchquota, so combined chunk volume could exhaust the limit and leave onboarding partially imported or inconsistent—add quota-aware pacing/backoff and an end-to-end high-volume onboarding test before merging.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="backend/database/memory_vector_metadata.py">
<violation number="1" location="backend/database/memory_vector_metadata.py:87">
P1: Stripping null `source_commit_id` and `content_hash` from vector metadata is correct for Pinecone compatibility, but if the memory search hydration layer treats vectors missing these freshness fields as stale (and drops them from results), then this creates a situation where vectors are upserted successfully but are never searchable. Consider verifying that the read-side freshness/staleness check in the search gateway gracefully handles the absence of these optional fields, or populate them with sentinel values (e.g., empty string or a known placeholder) instead of omitting them entirely.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| if device_ids: | ||
| shared["capture_device_ids"] = device_ids | ||
| return shared | ||
| return strip_null_metadata_values(shared) |
There was a problem hiding this comment.
P1: Stripping null source_commit_id and content_hash from vector metadata is correct for Pinecone compatibility, but if the memory search hydration layer treats vectors missing these freshness fields as stale (and drops them from results), then this creates a situation where vectors are upserted successfully but are never searchable. Consider verifying that the read-side freshness/staleness check in the search gateway gracefully handles the absence of these optional fields, or populate them with sentinel values (e.g., empty string or a known placeholder) instead of omitting them entirely.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/database/memory_vector_metadata.py, line 87:
<comment>Stripping null `source_commit_id` and `content_hash` from vector metadata is correct for Pinecone compatibility, but if the memory search hydration layer treats vectors missing these freshness fields as stale (and drops them from results), then this creates a situation where vectors are upserted successfully but are never searchable. Consider verifying that the read-side freshness/staleness check in the search gateway gracefully handles the absence of these optional fields, or populate them with sentinel values (e.g., empty string or a known placeholder) instead of omitting them entirely.</comment>
<file context>
@@ -84,7 +84,7 @@ def _shared_memory_vector_metadata_fields(
if device_ids:
shared["capture_device_ids"] = device_ids
- return shared
+ return strip_null_metadata_values(shared)
</file context>
|
Addressed the review/CI items in
Verified locally/pre-push:
Note: after pushing the new fork head, the PR page has Cubic in progress but upstream GitHub Actions have not yet attached fresh workflow runs to the new commit. |
There was a problem hiding this comment.
1 issue found across 5 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="backend/database/memory_vector_metadata.py">
<violation number="1" location="backend/database/memory_vector_metadata.py:87">
P1: Stripping null `source_commit_id` and `content_hash` from vector metadata is correct for Pinecone compatibility, but if the memory search hydration layer treats vectors missing these freshness fields as stale (and drops them from results), then this creates a situation where vectors are upserted successfully but are never searchable. Consider verifying that the read-side freshness/staleness check in the search gateway gracefully handles the absence of these optional fields, or populate them with sentinel values (e.g., empty string or a known placeholder) instead of omitting them entirely.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
da98be7 to
5697a4e
Compare
|
Addressed the latest Cubic item in
Verified:
Note: the normal pre-push hook passed through the relevant Swift/registry checks but blocked on unrelated async-blocker findings from upstream-main files after the rebase comparison; I pushed the rebased branch with |
|
@codex review |
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Summary
Fixes #8760
Tests
Notes