Repository navigation
test(control-plane): cover run ingress, admin gate and deploy; add CI - #4
Open
nikolas-sapa wants to merge 1 commit into
Open
nikolas-sapa wants to merge 1 commit into
nikolas-sapa wants to merge 1 commit into
Conversation
Extract the Hono routes from server.ts into createApp(deps) so the control plane's core path (key auth -> budget gate -> execution -> metering) can be tested without a Convex deployment or LLM. server.ts keeps env loading and serve() only; route behavior is unchanged. Adds 25 control-plane tests and a GitHub Actions workflow running npm test plus package typechecks. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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.
Summary
The control plane is Helm's core path (agent key auth -> monthly budget gate -> execution -> per-run ceiling -> metering/record, plus the admin-gated dashboard and deploy API), but it had zero tests and the repo had no CI.
apps/control-plane/src/server.tsintocreateApp(deps)insrc/app.ts.server.tsnow only loads env, builds the Convex client, and callsserve(). Route logic is moved verbatim; the only change is that runtime functions (runWithProvider,runBundle,providerFromEnv), the provisioner and the bundle-exec env are injectable, defaulting to the real implementations.apps/control-plane/test/app.test.ts(25 tests) usingapp.request()with a fake Convex client: unknown agent 404, wrong/missing key 401, disabled 403, no policy 500, monthly cap 429 with zero-tokenbudget_exceededrow and no execution, happy path metering + Convex env injection, input redaction, per-run ceiling, bundle refusal withoutHELM_TRUST_DEPLOYERS, docker mode fail-closed, trusted bundle execution, admin gate on all 5 admin routes (missing/wrong/agent-key tokens, no Convex calls), nokeyHash/deploy key in responses, status validation, deploy provisioning failure (no agent registered), deploy hashes key and ignores bodyownerId.vitest.config.mts: new@helm/control-planeproject.convex/_generatedis gitignored, so the project aliases../convex/_generated/api.jsto a stub exportinganyApi(which is what the generated module is at runtime)..github/workflows/ci.yml:npm ci,npm test,tsc --noEmitforpackages/{core,agent,runtime,cli}on push to main and PRs. Control-plane typecheck is not in CI because it needsconvex codegenagainst a deployment.Security review: this touches tests around auth, the kill switch (disable) and budget gates. No behavior change intended, but please review that
app.tsmatches the oldserver.tsroutes.Observed, not changed (follow-up candidates):
/a/:slug/runreturns 403 "agent disabled" before verifying the key, so unauthenticated callers can learn an agent's status;isAdminuses===rather than a constant-time compare.Test plan
npm test: 14 files, 90 tests pass (65 before + 25 new)app.tssoisAdminreturnstrueand the monthly-cap branch is skipped -> 7 tests went red; restored -> greentsc --noEmitclean for all 4 packages and forapps/control-plane(with locally generated_generated)server.tsboots with a dummyCONVEX_URL;/health200,/200,/api/agentswithout token 401