Repository navigation
π fix(task-mcp): a remote task's MCP token works for as long as its lease is renewed - #16915
Conversation
β¦ease is renewed With task_mcp.remote_enabled, the task MCP bearer handed out in task_assign expired with the first task-lease window (assignment + 30 minutes). The hub renews that lease on every accepted task_progress but mints the token once and never re-sends it, so a task that ran longer got HTTP 403 from its task MCP from minute 30 on. The token's own expiry is now only a hard cap, 24 hours after assignment. Before the cap the server-side lease record decides, as it already did: no record, an expired record, or one holding another token id or hash refuses the token, so it still never outlives its lease. No check is loosened; only the expiry stamped at the two mint sites (selectTask, standby dispatch) changes. Docs describe the rule; tests pin both directions. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Danathar <Danathar@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
There was a problem hiding this comment.
Decision needed: @clubanderson should confirm that a remote contributor's task-MCP token may stay presentable for up to 24h after assignment (previously 30 min), given revocation now rests entirely on the server-side lease record.
The code is correct for what it sets out to do; the only thing I am not willing to settle alone is the credential-lifetime policy, because the author is an OWNERS approver and this widens how long one minted token is accepted.
Verified against v6
- The revocation claim holds:
authenticateTaskMCPLease(pkg/dashboard/task_mcp_lease.go:136-170on base) requires a live lease record for{identity, task},!time.Now().After(l.expiresAt), matchingmcpTokenID, constant-timemcpTokenHashmatch, same repo/number, and stage. So before the cap the token lives exactly as long as the lease β release/yank/complete delete the record, and an unrenewed lease lapses vial.expiresAt. renewLease(contribute_leases.go:883) advancesl.expiresAt = now.Add(leaseTTL)on each accepted progress report; nothing re-minted the token, which is the 30-minute cliff the PR fixes.taskMCPLeaseTokenMaxTTL = config.DefaultTaskMCPLaunchTokenTTLis 24h (pkg/config/task_mcp_config.go:13), and both mint sites (contribute_select.go:1426,contribute_standby_dispatch.go:340) now passassignedAt.Add(taskMCPLeaseTokenMaxTTL); the token'sexpis still enforced bytaskmcp.VerifyLeaseToken, so the cap is real.- Design doc and contributor-relay doc updated to say
mcp.expires_atis an upper bound, not the lease window.go build ./pkg/dashboard/clean ond3b970c.
What a maintainer should weigh: a leaked lease token was previously dead within 30 minutes regardless of lease state; now it is usable for as long as the compromised relay keeps the lease renewed, up to 24h. Mitigations already present: per-request lease-record check, HMAC-signed claims, rate limiting (allowTaskMCPCall), read-only tool set. If that trade is acceptable, this looks correct to me. Sign-off survives the squash and native-queue-policy show CANCELLED rather than failed on this head β likely a concurrency cancel; a re-run should settle them.
β hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Needs a decision, not a merge:
Head: verdict requires_human @d3b970c, 65/65 checks green, DCO yes, soak 0s of 10m0s. How to release it:
Clear the cause and the hive re-evaluates on its next pass; the stage moves to |
Summary
On hives with
task_mcp.remote_enabled, a remote contributor's task MCP stopped answering 30 minutes after the task was assigned. The token it uses expired with the first task-lease window, although the hub keeps renewing that lease while the relay reports progress. Any task that ran longer got HTTP 403 from its task MCP for the rest of the task. The token now works for as long as the hub's lease on the task is alive, and for no more than 24 hours after assignment. It is still refused the moment the lease ends.What went wrong
The hub mints the token once, at assignment, and never sends a new one. It stamped the token with the end of the first lease window: assignment plus 30 minutes. Every accepted
task_progressmoves the lease forward. Nothing moved the token.A task assigned 31 minutes ago, whose relay reported progress 30 seconds ago, before this change:
The docs said the token has "the same expiry as the hub's task lease". That was only true for the first 30 minutes.
What changes
mcp.expires_atintask_assignnow carries the cap, not the end of the first lease window. The reference relay only writes that value into its MCP config.Why this is safe: the token cannot outlive its lease. The checks that tie it to the lease were already there and are unchanged.
How long a leaked token works:
Not in this change:
task_mcp.launch_token_ttlstill covers hub-launched agents only.Files
src/pkg/dashboard/task_mcp_lease.go: new constanttaskMCPLeaseTokenMaxTTL(24 hours); comments onmintTaskMCPForAssignmentandauthenticateTaskMCPLeasestate the rule. No logic change.src/pkg/dashboard/contribute_select.go:selectTaskPassstamps the token with the cap.src/pkg/dashboard/contribute_standby_dispatch.go:assignStandbyTaskstamps the token with the cap.src/pkg/dashboard/task_mcp_lease_lifetime_test.go: the new tests.src/docs/design/task-mcp.md: the lifetime rule, and whatexpires_atmeans.src/docs/contributor-relay.md: the same, in one sentence, for contributors.changelog.d/fixed-task-mcp-lease-token-renewal.md: the release note.Tests
These fail without the change:
TestTaskAssignMCPTokenOutlivesFirstLeaseWindow: a realreadytotask_assignround trip. The token must still verify 31 minutes and 23h59m after assignment, and must be refused after 24 hours.TestStandbyDispatchMCPTokenOutlivesFirstLeaseWindow: the same for a standby dispatch.TestContributeMCPRenewedLeaseKeepsItsTokenWorking: a task assigned 31 minutes or 6 hours ago, with its lease renewed 30 seconds ago, gets 200 from the endpoint.These pass with and without the change. They pin the checks that make the longer cap safe:
TestContributeMCPLeaseTokenDiesWithItsLease: 403 after the task is released, after the lease expires unrenewed, after the expired lease is pruned, after the task goes to another contributor, after the lease is recorded again, and after a newer token replaces this one.TestContributeMCPLeaseTokenIsMatchedByHash: a re-signed copy with the same token id and a later expiry gets 403.TestContributeMCPLeaseTokenRefusedPastItsHardCap: 403 past the cap although the lease is still being renewed, 200 one hour before it.With the lease-expiry, token-id and token-hash checks switched off by hand, four of those pins fail. So they do guard the checks.
go test -count=1 -run 'TaskMCP|ContributeMCP|LeaseToken|Lease|Standby|TaskAssign|SelectTask' ./pkg/dashboard/passes, and so doesgo test -count=1 ./crux/taskmcp/.π€ Generated with Claude Code