Repository navigation
Conversation
Resolve eligible copies before one atomic Firestore transaction so a later source-read, write, or delivery failure cannot strand a partially accepted share. Add unit and real-emulator regressions. Failure-Class: FC-durable-record-gated-on-delivery-reachability
This was referenced Sep 27, 2026
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.
Summary
Fixes #19433.
Accepting several shared tasks could permanently save only the first few. The route claimed the share in Redis, then read, saved, indexed, and scheduled a reminder for each task individually. Once one task was saved, a later failure left the claim consumed: the endpoint failed and every retry returned
409, stranding the missing tasks.This change prepares all eligible copies first and uses the existing
create_action_items_batchFirestore transaction. Indexing, reminders, and Chat-first wake-up follow the complete database write. It retains the current maximum of 20 shared tasks, account-generation fence, provenance, duplicate-accept behavior, and response schema.No new database schema, retry service, receipt protocol, dependency, or mobile/hardware change.
Evidence
On unchanged
main(ee071b242a), three behavioral regressions fail against the real HTTP route, Firestore SDK, and local Firestore emulator:After the change, all four emulator tests pass: failed preparation/writes leave zero copies and can retry both tasks; a delivery failure cannot lose later canonical tasks; concurrent accepts yield one complete copy set (
200+409) with the correct generation/provenance.firebase emulators:exec --only firestore --project demo-task-sharing \ 'PYTHONPATH=backend backend/.venv/bin/pytest -q backend/tests/integration/test_shared_task_acceptance_atomic_emulator.py'The emulator proof is an explicitly run integration suite, not part of the default unit selector. Default CI regression coverage lives in the existing
test_shared_action_items.pysuite: no writes before all source reads, one batch for 20 tasks, no delivery before persistence, rollback on pre-commit failure, locked/deleted races, metadata alignment after filtering, and no duplicate acceptance release after delivery failure. Existing sharing tests are migrated to the batch database boundary, not deleted or weakened.Verification
backend/test.shrunner:test_shared_action_items,test_task_sharing,test_action_item_idempotency,test_action_item_canonical_contract,test_action_item_reminder_cancel_on_complete,test_action_item_vector_best_effort,test_workstream_core, andtest_workstream_router_contract.bash backend/scripts/typecheck.sh: 0 errors; existing warnings remain.127.0.0.1:10274: injected write failure → HTTP 500, 0 persisted tasks; retry → HTTP 200, 2 tasks; duplicate accept → HTTP 409, still 2 tasks. Both local servers were stopped afterward.OMI_PR_BODY_FILE=/tmp/omi-19433-pr-body.md make preflight: 31 checks passed. The history-based guard reported its existing shallow-clone skip; this is not a claim that the skipped guard ran.e65e0cddc7, including type-checking. Full GitHub CI is a separate check.All records are synthetic, Redis and external delivery are local substitutes, authentication is a test dependency override, and outbound Python network calls are blocked. No production request, account modification, real reminder, or physical device claim.
Scope and limitations
This fixes partial-copy failures, not the complete Redis/Firestore acceptance lifecycle. Process death after the Redis claim, ambiguous Firestore commit outcomes, and historical partial accepts remain separate recovery limitations. Delivery failure can still surface an error after saving tasks; this PR ensures it cannot prevent later tasks from being persisted. It does not add a durable delivery outbox or promise notification retries.
#18719 adds claim/provenance assertions; it does not fix production persistence. Its individual-create mocks will need migrating to the batch call if this lands first. #19409 concerns desktop share attribution, not copying.
Why not a new guard or coordinator? The shared transaction primitive already exists. This route now uses it instead of constructing a multi-commit copy loop. Behavioral tests execute the route, and the emulator verifies actual rollback rather than relying on a lenient transaction fake.
Product invariants affected
none — preserves existing task creation, sharing, and account-generation semantics.
Failure-Class: FC-durable-record-gated-on-delivery-reachability
Line-Count-Exception: backend/routers/action_items.py | 1130 -> 1135 | Prepare the whole share before the existing atomic batch write and defer delivery until all copies are durable; five net lines avoid partial-copy loss without introducing a new persistence path.