Repository navigation
A task.create idempotency key is scoped to its poster - #233
Merged
Merged
Conversation
The key lookup, its lease and its dedup token named only (org, inbox, key), so a second poster reusing a key got the first poster's task back, brief included, and its own task was never stored. All three now include the poster's server-set subject: another poster's same key stores its own task. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ild before Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ith another Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… build does not share Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…try finds its task Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ate's is not Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…created token Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ves them Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
zlareb1
force-pushed
the
fix/task-idempotency-per-poster
branch
from
November 3, 2026 22:42
712d0d6 to
b271a5b
Compare
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.
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
A
task.createidempotency key belongs to its poster: another poster that sends the same key into the same inbox now stores its own task instead of receiving the first poster's task and brief.Why
Failing case: poster A creates a task in inbox X with
idempotency_key="finding-42"and a confidential brief. Poster B, listed in X's posters but with no read on X's owner namespace, creates with the same key.fetch_task_by_idempotency_keyfiltered only on(org, inbox, key), so B gotcreated=falseand A's task back, title, brief and outcome included, whichtask.getrefuses B. B's own task was never stored. Keys derived from the work item (a finding id, a PR number) collide in practice.Pattern: a lookup by a caller-chosen key that leaves the caller out of the key.
Fix: the key lookup, the key's lease (
_one_create_per_key) and the insert's dedup token (insert_created_task) now include the poster's server-set subject (_caller_subject, the token subject; the storedfrom_subject). A retry by the same poster still finds its first task.Scope and risk
server/tasks/store/repo.py,server/tasks/app/transitions.py, the field comment onTaskCreateInput.idempotency_key, and the docs that describe the key. No column or migration:from_subjectis already stored on every task row. Concurrency is unchanged for one poster; two posters with one key no longer serialize on one lease. The lease name and dedup token come from one digest (repo.create_key_digest).Compatibility, rollout and rollback
created=truewith its own task.docs/architecture/rolling-upgrades.mdrule 10 allows. Rule 10 also said the build before takes no lease and writes a random token; that described a build older than N-1, and it now says the ready-event delivery's lease and token are shared across builds while the create's are not. A retry that crosses builds still finds the task, since both builds' lookups match it. N-1 replicas keep answering another poster's task for a reused key until they stop serving.Tests
tests/unit/test_task_inbox.py::test_another_posters_idempotency_key_stores_its_own_task: failed before the fix (B gotcreated=falseand A's task id), passes after; also checks the same poster's retry still dedups.tests/integration/test_task_inbox.py::test_a_poster_reusing_another_posters_key_gets_its_own_task: two minted service-account tokens post one key over HTTP; the second getscreated=true, its own task, and none of the first one's title or brief; its own retry dedups.tests/integration/test_task_create_dedup_live_ch.py:test_another_posters_create_with_the_key_is_not_dropped_by_its_token(the second poster's row lands on its first insert and reads back whole) andtest_this_builds_retry_finds_the_task_an_old_builds_create_stored(a cross-build retry by one poster finds its task). The previous build's stand-in create now posts as the subject this build stamps and inserts under that build's exact key token.test_an_old_builds_delivery_after_this_builds_posts_a_second_eventandtest_this_builds_delivery_after_an_old_builds_reports_its_own_event: they modelled a build from before the delivery's lease and token, which no longer runs beside this one.tests/unit/test_task_inbox.py,test_task_watch.py,test_task_cursor_server_clock.py,test_inbox_trust_by_subject.py,test_inbox_gate_friction.py,test_sdk_tasks.py,test_docs_reference.py,test_public_copy.py,test_agent_instructions.py,test_doc_links.pypass.make format lint typecheckclean.tests/integration/test_task_create_dedup_live_ch.pyruns in CI.AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Claude Code. Checked the lookup, lease and token paths and the rolling-upgrade interaction by reading the code.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheckandmake test-unitpass; the integration suite passes if server behaviour changed.docs/describe the system as it now is, and this description names any operator steps and wire changes.git commit -s), as CONTRIBUTING.md asks.🤖 Generated with Claude Code