wishforge-ide/apps/api/src/workspace-lifecycle-http.ts
eust-w 3931bf94f0 refactor: hand off between IDE and agents through Git only
The IDE carried a second, Theia-internal coordination system: multi-
client save barriers, a hash-chained snapshot store, IndexedDB draft
recovery, transferable debugger-control leases that intercepted
Theia's plugin RPC, Ed25519 actor assertions from the gateway, and an
API gate that blocked every agent integration while any IDE workspace
was open until a human imported a coordinated snapshot. It depended on
Theia internals, made F5 debugging require five environment variables
plus a gateway-signed header, and stalled agent runs. IDE and agents
now hand off through Git commits (docs/architecture.md ADR-7).

- Delete apps/ide/coordination, apps/ide/security, the policy
  extension's coordination/draft/DAP-guard/lifecycle-safety modules and
  the unused product.json; the policy extension keeps only the managed
  extension allow-list and scoped collaboration.
- API: workspace snapshot import/match/check routes are gone. The
  project integration lease (one integrating run per project, fenced)
  moves to domain/integration-lease.ts and is still enforced on
  integrate/build transitions and build evidence.
- Workspace lifecycle: pause/resume no longer requires a save barrier;
  automatic sleep needs 30 idle minutes and zero gateway connections,
  which the gateway now reports itself. The lifecycle/integration
  authorize relays and the gateway's assertion signing are removed;
  gateway edit roles match the contract roles.
- Worker: no snapshot matching, workspace-input gate or local lock
  file during integration; runtime workspace-snapshot is removed.
- Web: the snapshot import panel is removed from run detail.
- Provisioner workspaces no longer mount coordination state or the
  gateway public key; local setup no longer generates gateway keys.

The local Theia build under apps/ide/lib must be rebuilt to pick up the
slimmer policy extension.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 13:56:22 +08:00

26 lines
981 B
TypeScript

import { Body, Controller, Inject, Param, Post, Req } from '@nestjs/common';
import { z } from 'zod';
import type { Request } from 'express';
import type { Actor } from '@wishforge/contracts';
import { Services } from './http.js';
import { WorkspaceLifecycle } from './domain/workspace-lifecycle.js';
type AuthRequest = Request & { actor: Actor };
@Controller('v1/workspaces')
export class WorkspaceLifecycleController {
constructor(@Inject(Services) private s: Services) {}
@Post(':id/lifecycle') async control(@Req() req: AuthRequest, @Param('id') id: string, @Body() body: unknown) {
const input = z
.object({ action: z.enum(['pause', 'resume']), confirmation: z.literal('change-workspace-lifecycle') })
.strict()
.parse(body);
return {
data: await new WorkspaceLifecycle(this.s.control.store, this.s.control.env).manual(
req.actor,
id,
input.action,
req.header('Idempotency-Key') ?? '',
),
};
}
}