Skip to content

fix(backend): declare the conversation-scoped action-item due-range Firestore indexes (#10780) - #10786

Merged
kodjima33 merged 1 commit into
mainfrom
watchdog/issue-10780-action-items-conversation-due-index
Jul 28, 2026
Merged

kodjima33 merged 1 commit into
mainfrom
watchdog/issue-10780-action-items-conversation-due-index

Conversation

@kodjima33

@kodjima33 kodjima33 commented Jul 28, 2026 •

Copy link
Copy Markdown
Collaborator

Bug

GET /v1/action-items and the chat get_action_items tool accept conversation_id
alongside due_start_date/due_end_date. Every such read 500'd with
FailedPrecondition: 400 The query requires an index. Issue #10780.

Root cause

_apply_action_item_date_filters orders a due range ascending, and get_action_items
adds conversation_id == (and, for the completed bucket, completed ==) on top. That
needs two composites — (conversation_id ASC, due_at ASC) and
(completed ASC, conversation_id ASC, due_at ASC) — neither declared in
backend/database/firestore_index_registry.py nor deployed. #10777/#10778 declared only
the (completed ASC, due_at ASC) chain, so the conversation-scoped reads kept failing.

Fix

  • Declare both composites in the index registry and regenerate firestore.indexes.json.
  • Widen test_action_items_due_range_index_contract.py to every filter combination the
    endpoint accepts. The recorder now captures every query get_action_items builds (the
    completed bucket and the bounded legacy scan each start their own from
    db.collection('users')), and equality fields are compared as a set because Firestore
    orders the equality prefix itself.
  • Both indexes are already created and READY in based-hardware-dev and based-hardware,
    so the deploy-time reconcile check-only gate stays green.

Verified

  • Prod Firestore probe (read-only, non-existent uid) before the indexes existed:
    conversation_id + due range and conversation_id + completed + due range both raised
    FailedPrecondition; completed + due range was OK (control).
  • After creating the composites, re-probed based-hardware-dev once READY: both
    conversation_id chains return with no error.
  • backend/test.sh over the index registry, manifest, reconcile and query-contract tests:
    46 pass.
  • Removing the two registry entries fails the new parametrizations [conversation] and
    [conversation+completed]; restoring them passes.

Closes #10780

Failure-Class: none

🤖 automated by hourly watchdog — tested and merged

Review in cubic

…ndexes

GET /v1/action-items and the chat get_action_items tool accept conversation_id
alongside due_start_date/due_end_date. _apply_action_item_date_filters orders that
due range ascending, so those reads need composites on (conversation_id, due_at) and
(completed, conversation_id, due_at). Neither was declared in the index registry nor
deployed, so every conversation-scoped due-range read raised
FailedPrecondition: 400 The query requires an index -- the same failure class as #10777,
which only covered the (completed, due_at) chain.

Declares both composites, regenerates firestore.indexes.json, and widens the due-range
index contract test to every filter combination the endpoint accepts. The test now
records every query get_action_items builds (the completed bucket and the bounded legacy
scan each start their own) and compares equality fields as a set, because Firestore orders
the equality prefix itself.

Verified:
- prod Firestore probe (read-only, non-existent uid) before the indexes existed: both
  conversation_id chains raised FailedPrecondition; completed+due range was OK
- created both composites in based-hardware-dev and based-hardware; re-probed dev once
  READY: conversation_id+due and conversation_id+completed+due both return with no error
- backend/test.sh over the index registry, manifest, reconcile and query-contract tests:
  46 pass
- removing the two registry entries fails the new parametrizations
  ([conversation], [conversation+completed]); restoring them passes

Closes #10780
Failure-Class: none
@kodjima33

Copy link
Copy Markdown
Collaborator Author

Watchdog verification before merge (2026-07-28):

  • bash test.sh on this branch (file list runner) — tests/unit/test_action_items_due_range_index_contract.py 6/6 pass, plus test_firestore_indexes.py, test_firestore_index_config.py, test_firestore_query_contract.py all green.
  • Mutation check: deleting the two new FirestoreIndexRequirement entries from the registry fails test_due_range_composites_are_declared_in_the_firestore_index_manifest[conversation] / [conversation+completed] and test_generated_firestore_manifest_matches_the_checked_in_contract — the guard is real, not vacuous.
  • Prod (read-only, non-existent uid): both composites are now READY in based-hardware, and all three query shapes (conversation_id+due range, completed+conversation_id+due range, completed+due range) return OK instead of FailedPrecondition: 400 The query requires an index. This PR closes the declaration drift so a reconcile/redeploy can't drop the hand-created indexes.

🤖 automated by hourly watchdog — tested and merged

@kodjima33
kodjima33 merged commit 0e093fb into main Jul 28, 2026
40 checks passed
@kodjima33
kodjima33 deleted the watchdog/issue-10780-action-items-conversation-due-index branch July 28, 2026 18:52
undivisible added a commit that referenced this pull request Jul 29, 2026
Index declaration already landed via #10778/#10786; keep the behavioral
regression test and FC-undeclared-serving-query-index failure class.
undivisible pushed a commit to Archit-lal/omi that referenced this pull request Jul 29, 2026
…ndexes (BasedHardware#10786)

GET /v1/action-items and the chat get_action_items tool accept conversation_id
alongside due_start_date/due_end_date. _apply_action_item_date_filters orders that
due range ascending, so those reads need composites on (conversation_id, due_at) and
(completed, conversation_id, due_at). Neither was declared in the index registry nor
deployed, so every conversation-scoped due-range read raised
FailedPrecondition: 400 The query requires an index -- the same failure class as BasedHardware#10777,
which only covered the (completed, due_at) chain.

Declares both composites, regenerates firestore.indexes.json, and widens the due-range
index contract test to every filter combination the endpoint accepts. The test now
records every query get_action_items builds (the completed bucket and the bounded legacy
scan each start their own) and compares equality fields as a set, because Firestore orders
the equality prefix itself.

Verified:
- prod Firestore probe (read-only, non-existent uid) before the indexes existed: both
  conversation_id chains raised FailedPrecondition; completed+due range was OK
- created both composites in based-hardware-dev and based-hardware; re-probed dev once
  READY: conversation_id+due and conversation_id+completed+due both return with no error
- backend/test.sh over the index registry, manifest, reconcile and query-contract tests:
  46 pass
- removing the two registry entries fails the new parametrizations
  ([conversation], [conversation+completed]); restoring them passes

Closes BasedHardware#10780
Failure-Class: none
@undivisible undivisible added the AI label Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Action items filtered by conversation_id + a due-date range still 500: two more undeclared Firestore indexes

2 participants