Repository navigation
fix(backend): declare the (completed, due_at) action-items composite index - #10781
Conversation
…index _apply_action_item_date_filters orders a due-date range ascending and get_action_items adds the completed== equality, so every due-date filtered read needs (completed ASC, due_at ASC). Only the descending twin was ever deployed, and no action_items index was declared in the registry at all, so the generated manifest could not catch the gap and prod returned FailedPrecondition for both the chat get_action_items tool and GET /v1/action-items. Declare the index, regenerate the manifest, and guard it with a test that derives the required signature from the production query builder instead of restating it. fixes #10777 Failure-Class: new
d17968d to
c733eb9
Compare
undivisible
left a comment
There was a problem hiding this comment.
Looks good after resolving the main conflict.
The production fix for #10777 already landed via #10778 (and conversation-scoped indexes via #10786). This PR still adds real value: the behavioral query→manifest regression test and FC-undeclared-serving-query-index. Conflict resolution kept main’s index declarations (no duplicate registry entry) and retained those guardrails.
undivisible
left a comment
There was a problem hiding this comment.
Looks good after resolving the main conflict.
The production fix for #10777 already landed via #10778 (and conversation-scoped indexes via #10786). This PR still adds real value: the behavioral query→manifest regression test and FC-undeclared-serving-query-index. Conflict resolution kept main’s index declarations (no duplicate registry entry) and retained those guardrails.
…index (BasedHardware#10781) _apply_action_item_date_filters orders a due-date range ascending and get_action_items adds the completed== equality, so every due-date filtered read needs (completed ASC, due_at ASC). Only the descending twin was ever deployed, and no action_items index was declared in the registry at all, so the generated manifest could not catch the gap and prod returned FailedPrecondition for both the chat get_action_items tool and GET /v1/action-items. Declare the index, regenerate the manifest, and guard it with a test that derives the required signature from the production query builder instead of restating it. fixes BasedHardware#10777 Failure-Class: new Co-authored-by: Max Carter 祁明思 <[email protected]>
What
Declares the
action_itemscomposite index(completed ASC, due_at ASC, __name__ ASC)inbackend/database/firestore_index_registry.py, regeneratesfirestore.indexes.jsonfrom it, and adds the regression test that would have caught its absence.Why
Every due-date-filtered action-item read was 500ing in prod (#10777): 55
FailedPrecondition: 400 The query requires an indexin the 7 days to 2026-07-28, 50 of them in the last 24h. Both the chatget_action_itemstool andGET /v1/action-items?due_start_date=…take the same path —_apply_action_item_date_filtersorders a due range ascending,get_action_itemsadds thecompleted ==equality, and the only deployed composite was the descending twin(completed ASC, due_at DESC), which does not serve that ordering.Nothing declared any
action_itemsindex in the registry, so the generated manifest had noaction_itemsentry at all and no gate could catch the gap.Failure class
Failure-Class: new—FC-undeclared-serving-query-index: a serving query's required composite index must be declared in the repository registry, not exist only as a hand-created live index. The guard artifact is the new behavioral test below, which derives the required signature from the production query builder instead of restating it.What I tested
due_at >=/<=,order_by due_at ASC,completed == False:400 The query requires an index. That index is currently building and cannot be used yet.The index Firestore demands is exactly the one this PR declares;gcloud firestore indexes composite list --project=based-hardwareshows it asCREATING(hand-created during the incident) and the other fiveaction_itemscomposites asREADY.test_due_date_filtered_action_item_reads_have_a_declared_composite_indexmonkeypatchesdatabase.action_items.dbwith a recorder, calls the productionget_action_itemsfor a due range (parametrized overcompleted=None/False/True), derives each executed equality+ordering chain's required index signature, and asserts the generated manifest declares it.('action_items', 'COLLECTION', (('completed','ASCENDING'), ('due_at','ASCENDING'), ('__name__','ASCENDING'))) not in declared— the same signature Firestore's error hint names.backend/tests/unit/test_firestore_query_contract.py→ 11 passed (.venv/bin/python -m pytest, Python 3.11.15).python3 backend/scripts/generate_firestore_indexes.py→ manifest matches the registry;firestore_query_coverage.py --check-ratchetandcheck_firestore_model_read_boundary.py→ exit 0.make preflightwith this diff → 23 checks passed (includingfirestore-index-manifest,firestore-query-coverage,failure-class-protocol).black --line-length 120 --skip-string-normalization→ unchanged.test.sh. Everything passes except the local fast-unit CPU-time guard tripping under parallel load (CI uses the 1.0s ceiling) andtest_sync_v2.py::TestAsyncCoordinatorBehavioral::test_inline_renew_errors_cancel_before_capacity_admission_without_releasing_retry_material, which fails identically onorigin/main— pre-existing, unrelated to this change.Follow-up (not in this PR)
GET /v1/action-itemsalso acceptsconversation_idalongside a due range, and those combinations (conversation_id ASC, due_at ASC, plus thecompletedtriple) are neither declared nor deployed — same failure class, but provisioning two more composites on a hot collection is a separate call. Filed as #10780 rather than widened here.Fixes #10777
Failure-Class: new
Auto-generated from issue feedback by the mini issues-improver — tested and merged.