test(deploy): characterize cloud subscription credential flow#228
Conversation
Adds 9 characterization tests for ensureCloudSubscriptionReady, validateCloudSubscriptionSupport, and resolveSubscriptionHarnessSource (the subscription variant of the credential flow, previously uncovered). Tests freeze the deploy-time contract that workforce#196 regressed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThis PR adds a comprehensive Node.js test suite characterizing the cloud subscription credential flow contract for deploy-time logic. The suite covers subscription source validation, BYOK credential handling with environment variable precedence, and OAuth agent connection with polling and selection logic. ChangesCloud Subscription Credential Flow Test Suite
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Code Review
This pull request introduces a new test suite in packages/deploy/src/modes/cloud-subscription.test.ts to characterize and freeze the deploy-time contract for the cloud subscription credential flow. It includes tests for validateCloudSubscriptionSupport and ensureCloudSubscriptionReady across both BYOK and OAuth flows, ensuring proper handling of prompts, environment variables, and API polling. There are no review comments, and I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
🧹 Nitpick comments (2)
packages/deploy/src/modes/cloud-subscription.test.ts (2)
249-284: 💤 Low valueOptional: Dead code after assert.fail.
Line 257 contains
return originalPrompt('');which is unreachable becauseassert.failthrows. The code is present for type consistency, but you could simplify by returning a value directly without the originalPrompt call.♻️ Proposed cleanup
io.prompt = async () => { assert.fail('io.prompt must not be called when WORKFORCE_DEPLOY_BYOK_KEY is set'); - return originalPrompt(''); + return ''; };🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/deploy/src/modes/cloud-subscription.test.ts` around lines 249 - 284, The override of io.prompt in the test "ensureCloudSubscriptionReady byok leg uses WORKFORCE_DEPLOY_BYOK_KEY without prompting" contains dead code: after assert.fail() the subsequent return originalPrompt('') is unreachable; simplify by removing the originalPrompt call and return a direct value (e.g., an empty string or the expected prompt result) from the io.prompt stub, and drop the originalPrompt binding if it’s no longer used to keep the test concise and type-correct.
405-452: 💤 Low valueOptional: Redundant persona override.
Lines 436-437 override
harness: 'codex', model: 'openai-codex/test', which exactly matches the defaults from thepersona()helper (lines 45-46). The override can be omitted for brevity.♻️ Proposed cleanup
ensureCloudSubscriptionReady(subscriptionArgs(io, { - persona: persona({ harness: 'codex', model: 'openai-codex/test' }), + persona: persona(), harnessSource: 'oauth', noPrompt: true }))🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/deploy/src/modes/cloud-subscription.test.ts` around lines 405 - 452, The test 'ensureCloudSubscriptionReady oauth leg returns { provider } without credentialSelections for non-anthropic when no anthropic fallback' contains a redundant persona override: remove the explicit override object { harness: 'codex', model: 'openai-codex/test' } passed into persona() in the subscriptionArgs call since persona() already defaults to those values; update the call to subscriptionArgs(..., { persona: persona(), harnessSource: 'oauth', noPrompt: true }) (or simply persona() inlined) so the test is shorter and behavior unchanged, leaving ensureCloudSubscriptionReady and subscriptionArgs usage intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/deploy/src/modes/cloud-subscription.test.ts`:
- Around line 249-284: The override of io.prompt in the test
"ensureCloudSubscriptionReady byok leg uses WORKFORCE_DEPLOY_BYOK_KEY without
prompting" contains dead code: after assert.fail() the subsequent return
originalPrompt('') is unreachable; simplify by removing the originalPrompt call
and return a direct value (e.g., an empty string or the expected prompt result)
from the io.prompt stub, and drop the originalPrompt binding if it’s no longer
used to keep the test concise and type-correct.
- Around line 405-452: The test 'ensureCloudSubscriptionReady oauth leg returns
{ provider } without credentialSelections for non-anthropic when no anthropic
fallback' contains a redundant persona override: remove the explicit override
object { harness: 'codex', model: 'openai-codex/test' } passed into persona() in
the subscriptionArgs call since persona() already defaults to those values;
update the call to subscriptionArgs(..., { persona: persona(), harnessSource:
'oauth', noPrompt: true }) (or simply persona() inlined) so the test is shorter
and behavior unchanged, leaving ensureCloudSubscriptionReady and
subscriptionArgs usage intact.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 83116803-ddf5-4264-9a88-f87a626bb424
📒 Files selected for processing (1)
packages/deploy/src/modes/cloud-subscription.test.ts
Summary
Adds characterization tests for the cloud subscription credential flow —
ensureCloudSubscriptionReadyandvalidateCloudSubscriptionSupportinpackages/deploy/src/modes/cloud/index.ts. The main harness credential flow is well covered (~28 tests incloud.test.ts), but the subscription variant had zero test references despite being an exported API consumed bydeploy.ts— and this area has regressed before (#196: oauth legs deployed withoutcredentialSelections, stubbingctx.llmon every fire).No production code changes — one new test file,
packages/deploy/src/modes/cloud-subscription.test.ts(9 tests, modeled on the structure ofcloud.test.ts):--harness-source planrejected with theuseSubscription:trueguidance (both via arg andWORKFORCE_DEPLOY_HARNESS_SOURCE); defaults to oauth, throwing the not-connected error under--no-promptwhen/api/v1/cloud-agentshas no connected row.{ provider, credentialSelections }shape; missing-key error under--no-prompt;WORKFORCE_DEPLOY_BYOK_KEYused without prompting (test fails ifio.promptis called).connectProvider; connect-then-poll path (confirm →connectProvider→ polls/cloud-agentsuntil connected → selections); the deploy/cloud: oauth harness legs never stamp credentialSelections — ctx.llm stubs on every CLI oauth deploy #196-adjacent shape — non-anthropic persona with no anthropic fallback returns{ provider }without acredentialSelectionskey.These tests freeze the deploy-time contract around
/api/v1/cloud-agentsand also unblock the planned split of the 1,270-line cloud module (the subscription functions move in that refactor; they're now characterized before they move).Verification
pnpm --filter @agentworkforce/deploy test→ 196 pass, 0 fail (187 baseline + 9 new)pnpm typecheck→ clean🤖 Generated with Claude Code