fix(#149): sign effort-drift POST + regenerate stale status hooks - #659
Open
bradbrok wants to merge 1 commit into
Open
fix(#149): sign effort-drift POST + regenerate stale status hooks#659bradbrok wants to merge 1 commit into
bradbrok wants to merge 1 commit into
Conversation
Isolated agents (per-agent-key only, global secret rejected per #640) got 401s on two hook-driven endpoints, surfaced deploying #655 to the POS- Specialists Pi: - /agents/{name}/effort-drift: hook_verify_effort.py's _post_drift sent NO signature (only x-pinky-agent), so verify_internal_request rejected it for EVERY agent. Now HMAC-signs (PINKY_AGENT_KEY, falling back to PINKY_SESSION_SECRET) over "agent\nPOST\npath\nts" and skips when no secret is present (an unsigned request would only 401). - /agents/{name}/status: hook_working.py/hook_idle.py were written only if-missing, so agents created before per-agent-key signing (#623) kept stale hooks signing with only the global secret. Route them through _write_hook_if_changed so ensure_workspace_hooks regenerates them with the current per-agent-key template on the next session start. Tests: drift POST is signed + verifiable under allow_global_secret=False (isolated policy); no-secret skips the POST; stale status hook is rewritten. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Why
Deploying #655 (main) to the POS-Specialists Pi surfaced 401s for the isolated agent
ivanon two hook-driven endpoints —POST /agents/ivan/status(6x) andPOST /agents/ivan/effort-drift(5x) — that returned 0 on the prior #635 build. Core transport (/transport/*,/heartbeat, inbox, tasks) was unaffected, so this only degraded live-status + effort telemetry, but it's a real regression from the #149 phase-3 isolation tightening (#640 fail-closes the global secret for isolated tenants).Root cause
/effort-drift—hook_verify_effort.py's_post_drift()set onlyx-pinky-agentand never signed the request.verify_internal_request(auth.py) requires an HMAC overagent\nMETHOD\npath\nts, so these POSTs were rejected for every agent (the endpoint is newer than the hook's signing)./status— thehook_working.py/hook_idle.pytemplate is correct (PINKY_AGENT_KEYfirst), but they were written only if-missing. Agents created before per-agent-key signing (Transport auth for the shared MCP (per-agent bearer token bound to session) #623) kept stale hooks that sign with only the global secret, which feat(#149): reject global-secret auth for isolated callers (phase-3 inc2) #640 now rejects for isolated agents.Fix
_post_drift()now HMAC-signs withPINKY_AGENT_KEY(falling back toPINKY_SESSION_SECRET) and addsx-pinky-timestamp+x-pinky-signature; skips silently when no secret is present.hook_working.py/hook_idle.pynow go through_write_hook_if_changed(like the 5 tmux hooks), soensure_workspace_hooks(runs at streaming-start) regenerates stale hooks with the current per-agent-key template.Tests
allow_global_secret=False(the isolated policy) with the per-agent key; a wrong global secret does not help.hook_working.pyis rewritten to the per-agent-key template.Full suite green locally (2701 passed, 1 skipped; nacl tests excluded per local-env gotcha — CI runs them).
Deploy note
Takes effect on an agent's next session start (hook regeneration). The Pi is currently on #655 with this regression live; redeploying this branch + restart will clear ivan's 401s.