refactor: remove the billing tier model (P0.1)

The community edition has no monetization (ADR-0001). Remove the tier
model (packages/shared/src/tiers.ts), the requireTier middleware and every
tier gate, GET/PATCH /api/tier and the trial start, and the Stripe
integration, which depends on the tier model.

Personal features a tier used to limit are open to everyone: unlimited
workspaces and connectors, every embedding provider including LiteLLM,
per-workspace costs, Approvals. The workspace session cap is one constant
(100). Team and enterprise surfaces are hidden instead of unlocked (team
dock zone, Settings Team/Enterprise/Plan tabs, workspace Team tab);
cloud sync reports unavailable, as it did for free users.

The sidecar ignores the tier keys in config.json but does not delete them:
both editions may still share ~/.waggle.

Web billing UI is deleted: plan cards, upgrade and trial modals, payment
success route, the KVARK sales block, tier 403 handling.
This commit is contained in:
shumeiko.it
2026-10-15 19:31:50 +02:00
parent 369d8269c1
commit fe2eb0f648
117 changed files with 342 additions and 6424 deletions

View File

@@ -1,7 +1,7 @@
/**
* Embedding routing API tests (steal #10) —
* GET /api/embedding/status (enriched: configuredProvider + envOverride)
* POST /api/embedding/provider (validate → tier-gate → persist → restartRequired)
* POST /api/embedding/provider (validate → persist → restartRequired)
*
* Note: vitest.setup.ts pins EMBEDDING_PROVIDER='mock' for the whole suite, so the
* env-override branch would otherwise 409 every write. We clear it per-test to
@@ -28,7 +28,6 @@ describe('Embedding routing API', () => {
beforeAll(async () => {
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'waggle-embrouting-test-'));
// No `tier` field → effective tier resolves to FREE (litellm gated off).
fs.writeFileSync(path.join(tmpDir, 'config.json'), JSON.stringify({}));
fs.mkdirSync(path.join(tmpDir, 'skills'), { recursive: true });
fs.writeFileSync(path.join(tmpDir, 'skills', '.starter-installed'), 'test');
@@ -86,19 +85,16 @@ describe('Embedding routing API', () => {
expect(res.statusCode).toBe(400);
});
it('POST /api/embedding/provider tier-gates litellm on FREE with 403', async () => {
it('POST /api/embedding/provider accepts litellm (every provider is selectable)', async () => {
const res = await injectWithAuth(server, {
method: 'POST',
url: '/api/embedding/provider',
payload: { provider: 'litellm' },
});
expect(res.statusCode).toBe(403);
expect(res.statusCode).toBe(200);
const body = JSON.parse(res.body);
expect(body.error).toBe('TIER_REQUIRED');
expect(body.requiredTier).toBeDefined();
expect(body.currentTier).toBe('FREE');
// Rejected write must not have persisted.
expect(readConfig().embedding).toBeUndefined();
expect(body.configuredProvider).toBe('litellm');
expect((readConfig().embedding as { provider?: string }).provider).toBe('litellm');
});
it('POST /api/embedding/provider persists "auto" (no restart required)', async () => {
@@ -114,11 +110,11 @@ describe('Embedding routing API', () => {
expect((readConfig().embedding as { provider?: string }).provider).toBe('auto');
});
it('POST /api/embedding/provider persists a tier-allowed provider with restartRequired', async () => {
it('POST /api/embedding/provider persists an explicit provider with restartRequired', async () => {
const res = await injectWithAuth(server, {
method: 'POST',
url: '/api/embedding/provider',
payload: { provider: 'inprocess' }, // FREE allows inprocess
payload: { provider: 'inprocess' },
});
expect(res.statusCode).toBe(200);
const body = JSON.parse(res.body);

View File

@@ -53,6 +53,7 @@ describe('Fleet Routes', () => {
it('returns empty array when session manager has no active sessions', async () => {
const mockManager = {
getActive: () => [],
getMaxSessions: () => 100,
};
server = createTestServer(mockManager);
const res = await server.inject({ method: 'GET', url: '/api/fleet' });
@@ -61,7 +62,7 @@ describe('Fleet Routes', () => {
const body = res.json();
expect(body.sessions).toEqual([]);
expect(body.count).toBe(0);
expect(body.maxSessions).toBe(10); // FREE (Solo) session cap — raised from 3 in the 2026-07-05 Solo-vs-Team migration
expect(body.maxSessions).toBe(100); // reported from the session manager
});
it('returns agent status when sessions exist', async () => {
@@ -83,6 +84,7 @@ describe('Fleet Routes', () => {
lastActivity: now - 60000,
},
],
getMaxSessions: () => 100,
};
server = createTestServer(mockManager);
const res = await server.inject({ method: 'GET', url: '/api/fleet' });
@@ -90,7 +92,7 @@ describe('Fleet Routes', () => {
expect(res.statusCode).toBe(200);
const body = res.json();
expect(body.count).toBe(2);
expect(body.maxSessions).toBe(10); // FREE (Solo) session cap — raised from 3 in the 2026-07-05 Solo-vs-Team migration
expect(body.maxSessions).toBe(100); // reported from the session manager
expect(body.sessions).toHaveLength(2);
// First session