Repository navigation
Add the plan-fit endpoint: what a workspace keeps on Starter or Team - #1601
Open
helpcodeai wants to merge 2 commits into
Open
helpcodeai wants to merge 2 commits into
helpcodeai wants to merge 2 commits into
Conversation
8 of 14 tasks
7 of 14 tasks
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
Before a Cloud workspace picks a plan, it should know what that plan keeps and what it pauses. This PR adds the data. The dashboard warning before checkout (next PR) and the automatic downgrade (the PR after) both use it. One ranking serves both, so the warning and the downgrade always name the same connectors.
Changes
license/plan-fit.ts(pure functions):CLOUD_PLAN_LIMITS: Starter 5/3/1, Team 15/10/3, mirroring the licence site.rankForCap: most tool calls in the last 30 days first, then the most recently changed, then by id.evaluatePlanFit: per axis{ current, max, over }for connectors, MCP servers, users, File Search folders, files and storage, saved code tools and code runs this month; inline code in use against included;keepandpauselists for connectors, MCP servers and File Search folders.anonymizePlanFit: drops names for the page without a sign-in.license/plan-fit.service.ts: reads one workspace snapshot. It counts active connectors and servers, keeps File Search folders apart and leaves the File Share connector out. File counts go throughFileSearchRepository.withTenant. Every query filters onorganizationId.GET /api/license/plan-fit[?plan=starter|team]: JWT or management key, so the CLI can call it. 404 on self-hosted and without a workspace, 400 for any other plan./api/license/reactivate/:tokenreturnsplanFitfor both plans without connector or server names. That page opens without a sign-in. If the read fails, the page still answers withplanFit: null.GET /api/license/usageand the trial creation caps count only active connectors and MCP servers, and leave File Search folders out (File Search has its own limits). A paused connector can be swapped back in. On Cloud today, 5 of about 9,700 connectors are inactive.paywall_actionacceptsplan_fit_shownandplan_fit_details_opened, so the next PR can track the block.operations.ts(license planFitForUser); README recipe "Check what a plan change would pause (Cloud)". No new command is needed:amcp apicalls any path.Cloud vs self-hosted: Cloud only. On self-hosted the endpoint answers 404 and the usage counts keep their meaning there (no caps).
Type
Testing
In
packages/backend, afternpx prisma generate:npx jest --maxWorkers=4 src/license src/auth src/file-search src/audit src/mcp-servers: all pass exceptsrc/auth/jwt-or-management-key.guard*.spec.ts. Those 13 tests need a local Postgres and fail the same way onmainin this environment (baseline, not touched here).plan-fit.spec.ts: ranking, evaluation for Starter and Team, inline code, anonymizing, and snapshot queries scoped to the org;plan-fit(both plans, one plan, 400, 404 on self-hosted or without a workspace);planFit: null);getUsagecounting filters.npm run lint: 0 errors. The 11 warnings already exist on main.npx tsc --noEmit -p tsconfig.json: clean.In
packages/cli,npm test: 0 failed, 2 skipped.Checklist
npm test)Related Issues
Second step of the Team-trial plan, after #1599 (trial limits = Team). Next: the warning UI, then the automatic downgrade.