Skip to content

feat(backend): prevent Firestore query contract regressions - #9668

Merged
Git-on-my-level merged 2 commits into
BasedHardware:mainfrom
Git-on-my-level:codex/issue-9662-firestore-contracts
Jul 14, 2026
Merged

Git-on-my-level merged 2 commits into
BasedHardware:mainfrom
Git-on-my-level:codex/issue-9662-firestore-contracts

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Jul 14, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #9662.

  • register and generate the missing What Matters Now attention-override composite index
  • add an AST query-shape inventory, committed debt baseline, and CI ratchet
  • deploy generated indexes and wait for Firestore READY before backend traffic shifts
  • restore bounded fresh-transaction retries and safe 503 mapping for action-item and memory-ledger contention
  • add a redacted development post-deploy What Matters Now smoke

Root cause and durable guard

The serving attention-override query had no generated composite-index declaration, while direct serving query chains had no repository-wide registration or deployment-readiness contract. Action-item and memory-ledger transactions could also surface retryable Firestore Aborted contention before the SDK retry path.

This PR makes the index source of truth explicit, blocks new unregistered/unsupported serving query shapes, verifies the checked-in manifest, waits for every declared index to become READY, and uses fresh bounded transaction retries with regression coverage.

Product invariants affected

  • INV-MEM-1

Verification

  • cd backend && bash test.sh — passed (the codebase-wide AST assertions are correctly marked slow; the mandatory preflight ratchet executes them)
  • cd backend && bash scripts/typecheck.sh — 0 errors
  • make preflight with this PR body — 15 checks passed
  • actionlint .github/workflows/gcp_backend.yml .github/workflows/gcp_backend_auto_dev.yml

The post-deploy smoke is exercised by the development workflow after traffic moves; it intentionally emits only its HTTP status and requires the pre-provisioned OMI_TASK_INTELLIGENCE_SMOKE_UID secret.

Review in cubic

Git-on-my-level and others added 2 commits July 14, 2026 07:37
Root cause: concurrent same-user reads can raise Firestore Aborted before the SDK commit retry path, and the memory ledger reused a stateful transactional wrapper across threads. Add bounded fresh-transaction retries for direct or explicitly caused Aborted errors, isolate SDK wrappers per call, preserve idempotent writes, enqueue projections only after success, and map exhaustion to a generic 503.

Verification: focused memory/action-item/task-sharing tests passed; full functional backend suite completed with unrelated duration-guard reruns; Pyright 0 errors; import-purity, module-stub, and async-blocker scans passed.
@Git-on-my-level
Git-on-my-level merged commit 4410b60 into BasedHardware:main Jul 14, 2026
22 of 25 checks passed
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.

Prevent Firestore query/index and transaction-contract regressions in backend

1 participant