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:
90
packages/server/tests/d11-datadir.test.ts
Normal file
90
packages/server/tests/d11-datadir.test.ts
Normal file
@@ -0,0 +1,90 @@
|
||||
/**
|
||||
* D11 (UX-Refactor P4) — dataDir resolution.
|
||||
*
|
||||
* - resolveDataDir: explicit option > WAGGLE_DATA_DIR env > ~/.waggle. Before
|
||||
* D11, startService ignored the env var while local/index.ts, the
|
||||
* marketplace installer, and memory-mcp honored it — a custom install split
|
||||
* its state across two directories.
|
||||
*/
|
||||
import { describe, it, expect, afterEach, vi } from 'vitest';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import os from 'node:os';
|
||||
import { startService, resolveDataDir } from '../src/local/service.js';
|
||||
import type { FastifyInstance } from 'fastify';
|
||||
|
||||
function makeTmpDir(): string {
|
||||
return fs.mkdtempSync(path.join(os.tmpdir(), 'waggle-d11-test-'));
|
||||
}
|
||||
|
||||
const ENV_KEY = 'WAGGLE_DATA_DIR';
|
||||
|
||||
describe('resolveDataDir (D11)', () => {
|
||||
const envBefore = process.env[ENV_KEY];
|
||||
afterEach(() => {
|
||||
if (envBefore === undefined) delete process.env[ENV_KEY];
|
||||
else process.env[ENV_KEY] = envBefore;
|
||||
});
|
||||
|
||||
it('explicit option wins over the env var', () => {
|
||||
process.env[ENV_KEY] = 'D:/somewhere/else';
|
||||
expect(resolveDataDir('D:/explicit')).toBe('D:/explicit');
|
||||
});
|
||||
|
||||
it('WAGGLE_DATA_DIR is honored when no option is given', () => {
|
||||
process.env[ENV_KEY] = 'D:/from-env';
|
||||
expect(resolveDataDir()).toBe('D:/from-env');
|
||||
});
|
||||
|
||||
it('defaults to ~/.waggle with neither', () => {
|
||||
delete process.env[ENV_KEY];
|
||||
expect(resolveDataDir()).toBe(path.join(os.homedir(), '.waggle'));
|
||||
});
|
||||
|
||||
it('a set-but-EMPTY env var falls through to the default (never an empty dataDir)', () => {
|
||||
process.env[ENV_KEY] = '';
|
||||
expect(resolveDataDir()).toBe(path.join(os.homedir(), '.waggle'));
|
||||
});
|
||||
});
|
||||
|
||||
describe('startService honors WAGGLE_DATA_DIR (D11 integration)', () => {
|
||||
const envBefore = process.env[ENV_KEY];
|
||||
let server: FastifyInstance | undefined;
|
||||
let tmp: string | undefined;
|
||||
|
||||
afterEach(async () => {
|
||||
if (envBefore === undefined) delete process.env[ENV_KEY];
|
||||
else process.env[ENV_KEY] = envBefore;
|
||||
if (server) await server.close();
|
||||
server = undefined;
|
||||
if (tmp) fs.rmSync(tmp, { recursive: true, force: true });
|
||||
tmp = undefined;
|
||||
});
|
||||
|
||||
it('boots against the env-pointed directory when no dataDir option is passed', async () => {
|
||||
tmp = makeTmpDir();
|
||||
const envDir = path.join(tmp, 'env-pointed');
|
||||
process.env[ENV_KEY] = envDir;
|
||||
const port = 4600 + Math.floor(Math.random() * 400);
|
||||
const logSpy = vi.spyOn(console, 'log');
|
||||
|
||||
try {
|
||||
const result = await startService({ port, skipLiteLLM: true });
|
||||
server = result.server;
|
||||
|
||||
// The env-pointed dir got the install, ~/.waggle got nothing new from us.
|
||||
expect(fs.existsSync(path.join(envDir, 'personal.mind'))).toBe(true);
|
||||
expect(server.localConfig.dataDir).toBe(envDir);
|
||||
|
||||
// The ratified D11 deliverable is the LOG LINE itself — pin it (review
|
||||
// gap: deleting the line kept every gate green).
|
||||
const dataDirLine = logSpy.mock.calls
|
||||
.map((c) => String(c[0]))
|
||||
.find((m) => m.includes('[waggle:service] Data dir:'));
|
||||
expect(dataDirLine).toContain(envDir);
|
||||
expect(dataDirLine?.endsWith(`Data dir: ${envDir}`)).toBe(true);
|
||||
} finally {
|
||||
logSpy.mockRestore();
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user