fix(deploy): scope harness credential probes to deploy auth - #335
Conversation
Session-Id: 01a06c6f-8413-7fd0-b597-e34a2d154421
|
Warning Review limit reachedNext included review available in 8 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 78d2535e7c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
All reported issues were addressed across 3 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Session-Id: 01a06c6f-8413-7fd0-b597-e34a2d154421
Comparing the deploy token after refreshing stored auth made a same-identity rotation look like an unrelated login. That turned authoritative credential checks into indeterminate results and could strand post-connect polling. Verify the stored token before refresh, then reuse the resulting refresh-capable client throughout the credential flow. Unrelated workspace deploy tokens still fail the identity check without issuing a misleading user-scoped request.
Review follow-upAddressed the remaining token-rotation finding in The probe still requires the deploy token to match the stored login, but now establishes that identity continuity before refreshing. It then reuses the resulting refresh-capable client for the full credential flow. This keeps unrelated CI/workspace tokens isolated while preventing a same-session refresh from turning later normal-harness or Non-vacuity mutations
Each mutation was reverted before final validation. Validation
|
Summary
/api/v1/cloud-agentsresponses from an unrelated stored user login as authoritative for a workspace-token deploynull), preserving the existing cloud-authority fallbackfalsewhen the same deploy credential can list agents and the provider is genuinely absentharness=claude,modelProvider=anthropic,authType=oauth_token) with no harness-source override--reconnectcannot verify completion under the deploy identity, instead of connecting and pollingnullfor 60 secondsProven root cause
The credential row itself already matches the CLI predicate: a Claude persona derives
anthropic;connectedHarnessEntriesaccepts bothanthropicand itsclaudealias;status=connectedis accepted; andauthType,credentialExpiresAt, andlastErrorare not exclusion criteria.The false answer came from identity scope instead:
fetchCloudAgentsignored the deployment bearer (WORKFORCE_WORKSPACE_TOKEN) and built its client fromreadStoredAuth(), an independent stored user login.packages/web/app/api/v1/cloud-agents/route.tsgates the route to session/cli:auth, then queriesprovider_credentialswith bothuser_id = auth.userIdandworkspace_id = auth.workspaceId.subjectType=citokens with deployment scopes, notcli:auth; presenting that deploy token to/cloud-agentsreturns 403. Presenting the unrelated stored login can instead return 200 plus an empty list for that login's user/current workspace.false.The fix requires identity continuity before trusting the list. If the stored access token differs from the token driving this deploy, the probe returns
nullwithout issuing the misleading request. A 403 also returnsnull. This uses the existing deliberate tri-state path; it does not turn every result into OAuth. A same-token 200 response with no matching connected row still returnsfalseand fails--no-prompt.Cloud route proof inspected at AgentWorkforce/cloud commit
a7ebcc55c7e3bd35d9663534843dc3239e152d71:packages/web/app/api/v1/cloud-agents/route.tspackages/web/lib/auth/request-auth.tspackages/web/app/api/v1/workspaces/[workspaceId]/deployment-api-tokens/route.tspackages/web/app/api/v1/workspaces/[workspaceId]/provider-credentials/setup-token/route.tsVerification
pnpm --filter @agentworkforce/deploy test— 280 passedpnpm typecheck— clean across the workspace and examplesgit diff --check— cleanTargeted mutation proof (each mutation was applied, its focused test run failed, then production code was restored):
credentials are not connectederrorcloud harness check failed: 403claudealias from Anthropic matching → the setup-token regression failed withclaude credentials are not connectedThe completed Codex review identified the reconnect/poll edge case; the second commit fixes it for both normal harness and
useSubscriptionflows and adds regressions for both.Wider preflight issue
This is another instance of a preflight reporting the operator's configuration as broken when its actual requirement was narrower: it needed an identity authorized to observe that configuration. Preflight results should distinguish absent from unobservable/insufficiently scoped and report the missing observation capability rather than asserting that the customer's resource is missing. This PR fixes that distinction for the harness credential probe without broadening the genuinely-absent case.