Repository navigation
SCA-374: degrade memories first-page 503s by type, not detail string - #12400
Merged
Git-on-my-level merged 2 commits intoAug 29, 2026
Merged
Conversation
…ring GET /v3/memories recoverability was still an allowlist of detail strings that grew from 2 entries to 4 for the same backing-store failure. Catch MemoryBackingStoreUnavailable instead, record the offset-read fallback, and assert mixed-direction list-scan indexes from Firestore's rule independently of the generator. Failure-Class: FC-undeclared-serving-query-index Co-authored-by: Cursor <[email protected]>
The route now catches MemoryBackingStoreUnavailable by type, so the detail constant is unused and fails pyright reportUnusedImport. Co-authored-by: Cursor <[email protected]>
Git-on-my-level
deleted the
fix/sca-374-memories-503-firestore-hardening
branch
August 29, 2026 23:01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed and why
SCA-374: rebase the remaining memories-503 hardening onto current
main.The generator mixed-direction rule and the
"Historical memory unavailable"allowlist entry are already on
mainand are not re-shipped.GET /v3/memoriesfirst-page recoverability was still keyed on a detail-stringallowlist that has grown from 2 entries to 4 for the same bug. This PR replaces
that allowlist with
MemoryBackingStoreUnavailable(stream:canonical/historical/cursor), so a renamed or newly added unavailablemessage degrades to the offset read instead of escaping as a hard 503.
The degraded path now calls
record_fallbackand logs the failing stream.An independent-oracle test restates Firestore's automatic single-field rule
and asserts every composite-requiring
QUERY_SPECis in the checked-inmanifest — including the three list-scan specs from #11684 — so a generator
shortcut cannot make both sides of the existing generator-vs-file test wrong
together.
Closes SCA-374
Product invariants affected
Line-Count-Exception: backend/utils/memory/memory_service.py | 3922 -> 3939 | add MemoryBackingStoreUnavailable and convert list-scan 503s onto that type in the module the issue names as the owner
How it was verified
Result: all four files passed
(
test_firestore_query_contract.py47 passed / 2 deselected;test_memories_pagination_clamp.py12 passed;test_list_read_budget_contract.py34 passed;test_universal_memory_list_cursor.py20 passed).Did not exercise a live Firestore
FAILED_PRECONDITIONagainst production;the unit tests drive the typed exception through the real first-page fallback
and the historical adapter with the prod index-building error.
Tests
test_first_page_falls_back_on_typed_unavailable_regardless_of_detail—a new detail string on the typed exception still degrades.
test_first_page_does_not_match_unavailable_detail_strings— a matchingstring on a plain HTTPException does not fall back.
test_first_page_fallback_records_degraded_firestore_read—record_fallbackfires with
component=firestore_read,from_mode=cursor_page,to_mode=offset_read,outcome=degraded.test_every_composite_requiring_query_spec_is_declared_in_the_checked_in_manifestplus
_platform_requires_compositeandtest_manifest_generator_classifies_the_firestore_single_field_rule.Failure class (fixes)
Failure-Class: FC-undeclared-serving-query-index
New guards (only when adding a check or ratchet)
The independent-oracle test would have caught the #11684 generator shortcut
that shipped GET /v3/memories 503 on 2026-08-17: the existing
generator-vs-checked-in-file test passes when both sides are wrong together.
It lives next to that contract in
test_firestore_query_contract.pyratherthan a new shared primitive because the rule is Firestore-index-specific.