refactor(server): move the team runtime into a postponed package (P1.1)

Team mode stays in the repository but is not built or shipped (ADR-0003).

- The team server (index.ts, config, db, daemons, plugins, proactive,
  routes, scheduler, services, ws, drizzle migrations) and its tests move
  from @waggle/server to packages/team-server (@waggle/team-server,
  private). It keeps its own copies of the logger and the agent-group
  executor, so it does not import @waggle/server. @clerk/fastify, bullmq,
  ioredis, postgres, drizzle-orm, drizzle-kit, cron-parser and
  @waggle/waggle-dance leave @waggle/server; the launcher drops the same
  team-only dependencies.
- build:packages no longer builds waggle-dance or the worker: nothing in
  the community edition imports them, and the worker's project reference
  would otherwise build the team server. The worker now imports from
  team-server; the team Dockerfile builds both explicitly.
- The sidecar no longer starts the team server when DATABASE_URL is set,
  and loses the team routes (/api/team/*, /api/teams), the WaggleDance
  routes and bridge (/api/waggle-dance/*), the Team server binding and
  egress guard, the WebSocket team client, the TeamSync cache and pushes,
  team audit forwarding, team workspace registration and the team
  capability-policy lookup in chat. The in-process room signal bus stays:
  agent groups, fleet runs and external tool runs use it.
  middleware/audit.ts was dead and is deleted.
- @waggle/core loses TeamSync and the teamServer part of WaggleConfig. A
  teamServer key in config.json is ignored and kept on save, as P0.1 does
  for the tier keys. Workspaces lose teamServerUrl and teamUserId; teamId
  and teamRole stay because workspaces from a shared data directory still
  carry them and the viewer write guards read them. POST /api/workspaces
  ignores team fields.
- The sidecar bundle no longer marks the team packages as external.

The agent still references the TeamSync type in orchestrator.ts and
pattern-write-back.ts; those files are being rewritten in P1.5 and drop
it there.

Logs UF-030 and UF-031 (team sync and team policy defects found while
removing the code).
This commit is contained in:
shumeiko.it
2026-10-24 11:53:23 +02:00
parent 0cbde468a9
commit c25efe6c44
136 changed files with 450 additions and 4990 deletions

View File

@@ -21,7 +21,6 @@ describe('Workspace & Session API', () => {
JSON.stringify({
defaultModel: 'test/model',
providers: {},
teamServer: { url: 'https://team.example.com' },
}),
'utf-8'
);
@@ -300,8 +299,10 @@ describe('Workspace & Session API', () => {
});
// --- I2: Team Workspace Creation ---
// The community edition has no team server (ADR-0003), so team fields in the
// request are ignored.
it('creates a team workspace with team fields', async () => {
it('ignores team fields when creating a workspace', async () => {
const res = await injectWithAuth(server, {
method: 'POST',
url: '/api/workspaces',
@@ -310,28 +311,15 @@ describe('Workspace & Session API', () => {
group: 'Team',
teamId: 'team-123',
teamServerUrl: 'https://team.example.com',
teamRole: 'member',
teamUserId: 'user-456',
teamRole: 'viewer',
},
});
expect(res.statusCode).toBe(201);
const body = JSON.parse(res.body);
expect(body.name).toBe('Team Project Alpha');
expect(body.group).toBe('Team');
expect(body.teamId).toBe('team-123');
expect(body.teamServerUrl).toBe('https://team.example.com');
expect(body.teamRole).toBe('member');
expect(body.teamUserId).toBe('user-456');
// Verify it appears in workspace list
const listRes = await injectWithAuth(server, {
method: 'GET',
url: '/api/workspaces',
});
const list = JSON.parse(listRes.body);
const teamWs = list.find((ws: { teamId?: string }) => ws.teamId === 'team-123');
expect(teamWs).toBeTruthy();
expect(teamWs.teamServerUrl).toBe('https://team.example.com');
expect(body.teamId).toBeUndefined();
expect(body.teamServerUrl).toBeUndefined();
expect(body.teamRole).toBeUndefined();
// Clean up
await injectWithAuth(server, { method: 'DELETE', url: `/api/workspaces/${body.id}` });
@@ -346,7 +334,6 @@ describe('Workspace & Session API', () => {
expect(res.statusCode).toBe(201);
const body = JSON.parse(res.body);
expect(body.teamId).toBeUndefined();
expect(body.teamServerUrl).toBeUndefined();
// Clean up
await injectWithAuth(server, { method: 'DELETE', url: `/api/workspaces/${body.id}` });
@@ -1210,19 +1197,12 @@ describe('Workspace & Session API', () => {
// J4: Team catch-up context
it('workspace context includes teamContext for team workspaces', async () => {
// Create a team workspace
const createRes = await injectWithAuth(server, {
method: 'POST',
url: '/api/workspaces',
payload: {
name: 'Team WS',
group: 'Team',
teamId: 'team-test-123',
teamServerUrl: 'https://team.example.com',
},
});
expect(createRes.statusCode).toBe(201);
const teamWsId = JSON.parse(createRes.body).id;
// A data directory shared with the commercial edition can hold team workspaces.
const teamWsId = server.workspaceManager.create({
name: 'Team WS',
group: 'Team',
teamId: 'team-test-123',
}).id;
// Get context
const contextRes = await injectWithAuth(server, {