Repository navigation
feat(tasks): task claims are leases — ADR-018 D4 backfill - #901
Merged
Merged
Conversation
claimedBy had no deadline: a dead claimant (closed laptop, killed wrapper) held a task forever, invisibly. Message claims shipped with a lease (#892) precisely to avoid this, which left two claim primitives with different liveness rules — the gap D4 names. The claim route now stamps claimExpiresAt (30 min — matches the pod's claim-the-orphan convention of racing on work stalled ~30 min) and the CAS admits four winners: unclaimed, the holder itself (renewal, same-call semantics as messageClaimService), a lapsed lease, or a LEGACY claim (claimExpiresAt null) whose claimedAt is older than one lease — legacy rows derive their effective expiry from claimedAt, so there is no migration and no instant steal of recently-claimed work. The 409 now names the holder AND when the lease frees (D3: losers stand down informed, not blind). commonly_claim_task's description (unpublished 0.3.0) carries the lease contract in the same falsifiable style as the tone contract. Service-tier tests cover all six behaviors. NOT verified locally: Node 26 removed SlowBuffer, which breaks jsonwebtoken's dep chain for every service-tier suite on this machine (the pre-existing sibling suite fails identically) — CI's Service Tests job is the verification tier. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XeUH4HVDsDHYPsHJthXjB8
Same limiter shape as task-create in this file (token-hash keyed), at 30/60s: renewals are re-claims, so the ceiling leaves room for a busy agent racing several tasks while a runaway loop still hits the wall inside one lease window. The gap predates this PR, but touching the handler makes it new code — and the route did gain a reason to be called more often (renewal). Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XeUH4HVDsDHYPsHJthXjB8
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.
What
D4's backfill: task claims get the same liveness rule as message claims.
claimedBypreviously had no deadline — a dead claimant held a task forever, invisibly.Task.claimExpiresAt(new, default null) + a 30-minute lease stamped at claim time (matches the pod's claim-the-orphan ~30-min convention).messageClaimService) / lapsed lease / legacy claim whoseclaimedAtis older than one lease. Legacy rows derive effective expiry fromclaimedAt— no migration, and no instant steal of work claimed minutes ago.claimExpiresAt, so a loser stands down informed (D3), knowing when racing again is legitimate.claimedAt.commonly_claim_task's description (unpublished 0.3.0) now carries the lease contract.Tests
6 service-tier tests through the real route (fresh lease, live-lease refusal with holder+expiry, self-renewal extends, lapsed-lease reclaim, recent-legacy protected, stale-legacy reclaimable).
Not verified locally (rule: say what you didn't verify): Node 26 removed
SlowBuffer, which breaksjsonwebtoken's dep chain for every service-tier suite on this machine — the pre-existing sibling suite (tasks.source-ref-idempotency) fails identically before any assertion runs. CI's Service Tests job (older Node) is the verification tier; treat a red there as a real finding, not flake.🤖 Generated with Claude Code
https://claude.ai/code/session_01XeUH4HVDsDHYPsHJthXjB8