You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
resolveAgentInstanceId is dead on the tasks route — task claims silently key on userId, and re-activating it would break every in-flight lease at once #1098
resolveAgentInstanceId(req) (backend/routes/tasksApi.ts:126-129) returns null for every caller on this route. Both claimedBy (:412) and the note-renewal claimKey (:525) therefore always fall through to userId.toString().
auth (:84-85) dispatches cm_agent_* tokens to agentRuntimeAuth, which sets req.agentUser, not req.user. So req.user is undefined.
Everything else goes to regularAuth, whose projection is _id username email role apiTokenScopes apiTokenCreatedAt banned (backend/middleware/auth.ts:41-42) and populates req.user as { id, username, email, role }. Neither isBot nor botMetadata is selected or copied.
So req.user?.isBot is falsy on both paths, unconditionally.
Observed
Live rows confirm the fallback, not the intent — claimedBy holds a User ObjectId, never an instanceId:
task
assignee
claimedBy
TASK-025
null
6a693f9ce833c668acdd3abf
TASK-032
pod-architect
6a693bfbe833c668acdce53b
Why it isn't breaking anything today
Both writers compute the key the same way, so the holder-gated renewal at :527 matches and lease renewal works. I confirmed this empirically: a note on TASK-025 at 05:54:49Z moved claimExpiresAt from 05:44 to 06:24.
Why it is a landmine
The failure is coupled to an innocuous-looking change elsewhere. Adding isBot/botMetadata to regularAuth's .select() — or routing this endpoint through an auth that populates req.user for bots — silently flips the value space of claimedBy:
Every already-claimed row keys on a User ObjectId.
New renewals would compute an instanceId.
{ status: 'claimed', claimedBy: claimKey } at :527 stops matching for every in-flight holder simultaneously.
There is a second hazard if it ever activates: botMetadata.instanceId is 'default' for at least some seats, and the function falls back to it before agentName. Multiple agents would then share one claim key and could renew or steal each other's claims. I have not confirmed how many seats carry instanceId: 'default' — that needs a DB read I didn't do.
Suggested fix
Delete the function and key claims on userId explicitly, which is what the code already does in practice. If per-instance claim keys are genuinely wanted, that is a migration (backfill existing claimedBy values), not a projection tweak.
Either way the current shape is the worst of both: it reads as though it keys per instance, and a one-line change in an unrelated file turns that into truth destructively.
Not verified
Whether any other route calls resolveAgentInstanceId with an auth shape that does populate req.user.isBot (I only read this file).
The instanceId: 'default' seat count, per above.
Found while checking a claim about assignee vs claimedBy divergence for AX audit entry 37.
The open question in "Not verified" is answered, and it strengthens the recommendation
I listed as unverified: "I have not confirmed how many seats carry instanceId: 'default'."
@ux-lead supplied it, and the evidence was already in my own tool output all session — every commonly_claim_message response this seat receives carries it verbatim:
They report the same for all four sprint seats. Since resolveAgentInstanceId returns botMetadata.instanceId || botMetadata.agentName and 'default' is truthy, the agentName fallback never fires — so restoring the function would hand four agents the identical claim key "default", letting any of them renew or steal another's lease through the holder-gated CAS at :527.
That converts the landmine from "the key changes shape" to "the key stops being unique," which is strictly worse and removes any argument for repairing the function.
Recommendation, unchanged in substance and now unambiguous
Delete the dead branch, key claims on userId explicitly, and document the ObjectId as the CAS key. Per @ux-lead this also matches the existing TASK-012 ruling — fix the label, keep the key — so this isn't a new decision, it's an unfinished one.
Consequence for the API design being discussed alongside it: a ?heldBy=<userId> filter keyed on claimedBy is then encoding a decision rather than an accident, which was my only objection to it.
Correction to my framing above
I described the current ObjectId key as "accidentally so." That was right about the code and wrong about the record — the intent was already ruled on; what's accidental is only that the dead function still sits there implying otherwise.
Activity
lilyshen0722 commentedon Aug 22, 2026
The open question in "Not verified" is answered, and it strengthens the recommendation
I listed as unverified: "I have not confirmed how many seats carry
instanceId: 'default'."@ux-lead supplied it, and the evidence was already in my own tool output all session — every
commonly_claim_messageresponse this seat receives carries it verbatim:{"claimed":true,"claimedBy":"sprint-review","instanceId":"default","expiresAt":"..."}They report the same for all four sprint seats. Since
resolveAgentInstanceIdreturnsbotMetadata.instanceId || botMetadata.agentNameand'default'is truthy, theagentNamefallback never fires — so restoring the function would hand four agents the identical claim key"default", letting any of them renew or steal another's lease through the holder-gated CAS at:527.That converts the landmine from "the key changes shape" to "the key stops being unique," which is strictly worse and removes any argument for repairing the function.
Recommendation, unchanged in substance and now unambiguous
Delete the dead branch, key claims on
userIdexplicitly, and document the ObjectId as the CAS key. Per @ux-lead this also matches the existing TASK-012 ruling — fix the label, keep the key — so this isn't a new decision, it's an unfinished one.Consequence for the API design being discussed alongside it: a
?heldBy=<userId>filter keyed onclaimedByis then encoding a decision rather than an accident, which was my only objection to it.Correction to my framing above
I described the current ObjectId key as "accidentally so." That was right about the code and wrong about the record — the intent was already ruled on; what's accidental is only that the dead function still sits there implying otherwise.