diff --git a/services/cloud-agent-next/src/control-plane/sandbox/routes.ts b/services/cloud-agent-next/src/control-plane/sandbox/routes.ts index e3f1d1b2167..ff7a561c560 100644 --- a/services/cloud-agent-next/src/control-plane/sandbox/routes.ts +++ b/services/cloud-agent-next/src/control-plane/sandbox/routes.ts @@ -185,8 +185,6 @@ export function routeView( return { state: 'preparing', attemptId: route.attemptId, ...sandboxProgress }; } -// --- storage ----------------------------------------------------------------- - export async function readRoute(db: RouteDatabase, sessionId: string): Promise { const rows = await db.select().from(routesTable).where(eq(routesTable.session_id, sessionId)); const row = rows[0]; @@ -244,8 +242,6 @@ export async function earliestRouteDeadlineAt(db: RouteDatabase): Promise { this.initialized = ctx.blockConcurrencyWhile(() => this.initializeStorage()); } - // --- lifecycle entry points ------------------------------------------------- - /** * Establishes the provider pin and starts the allocation. `prepare` starts an * allocation from the stored pin without going through here, so callers that @@ -727,8 +725,6 @@ export class SandboxControlV2 extends DurableObject { }; } - // --- routes (B3) ------------------------------------------------------------ - /** * Session DO -> Sandbox DO (spec §10). Returns the route view at once and * never waits for a provider call. An absent or `failed` route starts a new @@ -839,8 +835,6 @@ export class SandboxControlV2 extends DurableObject { }); } - // --- worktree deletion (B10) ------------------------------------------------ - /** * Worker -> Sandbox DO (spec §6 "Billing, credentials and deletion"). Port of * the legacy DO cleanup: when the provider stop or the shared runtime is @@ -1031,8 +1025,6 @@ export class SandboxControlV2 extends DurableObject { return (await this.observeWorktreeRuntime(plan.providerRef)).status === 'terminal'; } - // --- worktree changes (B10) ------------------------------------------------- - /** * Session DO -> Sandbox DO (spec §10). Forwards one worktree-change request * to the wrapper and returns its result. The Sandbox DO owns no snapshot @@ -1062,8 +1054,6 @@ export class SandboxControlV2 extends DurableObject { return this.beginWrapperControlRequest(frame); } - // --- terminals (B10) -------------------------------------------------------- - /** * Session DO -> Sandbox DO (spec §10). Forwards exactly one terminal * create/resize/close/connect request to the wrapper and returns its result. @@ -1083,8 +1073,6 @@ export class SandboxControlV2 extends DurableObject { return this.beginWrapperControlRequest(terminalRequestFrame(crypto.randomUUID(), input)); } - // --- preview ---------------------------------------------------------------- - /** * Off-queue read the Session DO uses to resolve one preview's provider * coordinates. It never enqueues, so a preview never waits behind the control @@ -1207,8 +1195,6 @@ export class SandboxControlV2 extends DurableObject { ); } - // --- credentials (B3) ------------------------------------------------------- - /** * Contained outbound credential lookup (spec §6/§10), same request shape as * `src/sandbox-outbound.ts` calls today. Matches the grant by alias, re-checks @@ -1724,8 +1710,6 @@ export class SandboxControlV2 extends DurableObject { }); } - // --- init and storage cutover ---------------------------------------------- - private async initializeStorage(): Promise { const generation = await this.ctx.storage.get(GENERATION_KEY); if (generation === undefined) { @@ -1948,8 +1932,6 @@ export class SandboxControlV2 extends DurableObject { }; } - // --- allocation events and effects ----------------------------------------- - private async applyEvent(event: AllocationEvent): Promise { const previous = await this.readAllocation(); const timers = { ...this.sandboxTimers() }; @@ -2046,8 +2028,6 @@ export class SandboxControlV2 extends DurableObject { }; } - // --- route execution and notifications (B3) --------------------------------- - private async runPrepare( spec: ControlPlaneRouteSpec, source: ControlPlaneCredentialSource, @@ -2887,8 +2867,6 @@ export class SandboxControlV2 extends DurableObject { return isAdoptableWorktreeScope({ grant, acceptedMarker: marker }); } - // --- contained credential helpers (B3) -------------------------------------- - /** The managed outbound container id for the current provider/allocation. */ private outboundContainerIdFor(state: AllocationState): string | null { // The container is the containment boundary. When containment is off there @@ -4487,8 +4465,6 @@ export class SandboxControlV2 extends DurableObject { await this.enqueue(() => this.applyEvent(event)); } - // --- wrapper socket --------------------------------------------------------- - private readAttachment(ws: WebSocket): WrapperSocketAttachment | null { const parsed = wrapperSocketAttachmentSchema.safeParse(ws.deserializeAttachment()); return parsed.success ? parsed.data : null; @@ -4957,8 +4933,6 @@ export class SandboxControlV2 extends DurableObject { await this.billingRuntime.defer(generation, callback); } - // --- provider selection ----------------------------------------------------- - private ensureVercelBillingRuntime() { return this.billingRuntime.ensureRuntime(); } @@ -5028,8 +5002,6 @@ export class SandboxControlV2 extends DurableObject { return resolved === undefined ? undefined : { ...resolved, teamId: locator.teamId }; } - // --- storage ---------------------------------------------------------------- - private async retryAllowed(): Promise { return routeRetryAllowed(this.routeContext(await this.readAllocation())); } diff --git a/services/cloud-agent-next/src/control-plane/session/session-do.ts b/services/cloud-agent-next/src/control-plane/session/session-do.ts index e41390c265e..971938e9f4d 100644 --- a/services/cloud-agent-next/src/control-plane/session/session-do.ts +++ b/services/cloud-agent-next/src/control-plane/session/session-do.ts @@ -641,8 +641,6 @@ export class SandboxSessionV2 extends DurableObject { return peer.worktreeCapture(input); } - // --- init and storage cutover ---------------------------------------------- - private async initializeStorage(): Promise { const generation = await this.ctx.storage.get(GENERATION_KEY); if (generation !== GENERATION) { @@ -702,8 +700,6 @@ export class SandboxSessionV2 extends DurableObject { } } - // --- registration ----------------------------------------------------------- - async registerSession(input: ControlPlaneSessionRegistration): Promise<{ ok: true }> { await this.initialized; const registration = controlPlaneSessionRegistrationSchema.parse(input); @@ -1218,8 +1214,6 @@ export class SandboxSessionV2 extends DurableObject { return { type: 'ok', authorization }; } - // --- message flow ----------------------------------------------------------- - async send(intent: ControlPlanePromptPayload): Promise { await this.initialized; if (this.registration === null) return { type: 'session-not-found' }; @@ -1373,8 +1367,6 @@ export class SandboxSessionV2 extends DurableObject { } } - // --- notifications (spec §10) ---------------------------------------------- - async onRoute(update: ControlPlaneRouteUpdate): Promise { await this.initialized; if (this.registration === null) return; @@ -1510,8 +1502,6 @@ export class SandboxSessionV2 extends DurableObject { }); } - // --- worktree changes (B10) ------------------------------------------------- - async getWorktreeChanges(): Promise { await this.initialized; return this.worktreeChanges.get(); @@ -1526,8 +1516,6 @@ export class SandboxSessionV2 extends DurableObject { return this.worktreeChanges.refresh(); } - // --- backstop alarm --------------------------------------------------------- - async alarm(): Promise { await this.initialized; if (this.registration === null) return; @@ -1582,8 +1570,6 @@ export class SandboxSessionV2 extends DurableObject { await this.ctx.storage.setAlarm(Math.min(...candidates)); } - // --- reads ------------------------------------------------------------------ - async getSession(): Promise { await this.initialized; if (this.registration === null) return { type: 'session-not-found' }; @@ -1767,8 +1753,6 @@ export class SandboxSessionV2 extends DurableObject { return closed; } - // --- delete and worktree deletion ------------------------------------------ - /** * C1c: updates a prepared session's callback target (legacy `tryUpdate`, * retained for `services/code-review-infra`). Stores the same grouped @@ -2015,8 +1999,6 @@ export class SandboxSessionV2 extends DurableObject { this.preparationRecorders.clear(); } - // --- terminals (B10) -------------------------------------------------------- - /** Worker-facing terminal RPC (spec §10); routing/handler wiring is C1. */ async terminalCreate(input: { operationId: string; @@ -2041,8 +2023,6 @@ export class SandboxSessionV2 extends DurableObject { return this.terminals.close(input); } - // --- preview ---------------------------------------------------------------- - /** * Worker-facing preview resolver (spec §10). Runs on the RPC path, not the * operation queue, so a preview never waits behind queued messages. It owns @@ -2054,8 +2034,6 @@ export class SandboxSessionV2 extends DurableObject { return this.preview.resolve(); } - // --- stream ----------------------------------------------------------------- - async fetch(request: Request): Promise { await this.initialized; const pathname = new URL(request.url).pathname; @@ -2129,8 +2107,6 @@ export class SandboxSessionV2 extends DurableObject { }); } - // --- route view ------------------------------------------------------------- - private async applyView(view: ControlPlaneRouteView, pass = this.transportPass()): Promise { // The route view is the source of the preparation row: the previous // persisted view names the attempt that is open, so a transition closes it @@ -2509,8 +2485,6 @@ export class SandboxSessionV2 extends DurableObject { return namespace === undefined ? null : namespace.getByName(sandboxId); } - // --- preparation progress --------------------------------------------------- - /** * The preparation attempt id is the route attempt id (spec §10); the trigger * is the oldest queued message. The recorder owns step continuity and the @@ -2646,8 +2620,6 @@ export class SandboxSessionV2 extends DurableObject { return this.route.state === 'unknown' ? null : this.route.attemptId; } - // --- settlement and message events ----------------------------------------- - private async settleMessages( messageIds: readonly string[], status: Extract, @@ -2867,8 +2839,6 @@ export class SandboxSessionV2 extends DurableObject { this.streamHandler().broadcastEvent(event); } - // --- connected-event projections ------------------------------------------- - private deriveCloudStatus(): { type: 'preparing' | 'ready' | 'finalizing' | 'error'; step?: string; @@ -2956,8 +2926,6 @@ export class SandboxSessionV2 extends DurableObject { }; } - // --- storage ---------------------------------------------------------------- - private async loadMessages(): Promise { const rows = await this.db .select() diff --git a/services/cloud-agent-next/src/persistence/CloudAgentSession.ts b/services/cloud-agent-next/src/persistence/CloudAgentSession.ts index b19778dec07..5fbb77536a0 100644 --- a/services/cloud-agent-next/src/persistence/CloudAgentSession.ts +++ b/services/cloud-agent-next/src/persistence/CloudAgentSession.ts @@ -505,8 +505,6 @@ export class CloudAgentSession extends DurableObject { constructor(ctx: DurableObjectState, env: WorkerEnv) { super(ctx, env); - // Extract sessionId from DO name pattern: "userId:sessionId" - // The DO name is set by the worker when creating the stub. // Split on the *last* colon because userId may contain colons // (e.g. "oauth/google:12345:agent_abc" → sessionId = "agent_abc"). const doName = ctx.id.name; @@ -1278,7 +1276,6 @@ export class CloudAgentSession extends DurableObject { return response; } - // Route ingest WebSocket (internal only - from queue consumer) if (url.pathname === '/ingest') { if (await this.hasDeletionIntent()) { return new Response('Session not found', { status: 404 }); @@ -1303,9 +1300,6 @@ export class CloudAgentSession extends DurableObject { await ingestHandler.handleIngestMessage(ws, message); return; } - - // Stream connections are server-push only, ignore client messages - // Future: could handle client commands like subscribe/unsubscribe } /** diff --git a/services/cloud-agent-next/src/persistence/schemas.ts b/services/cloud-agent-next/src/persistence/schemas.ts index a4b40ca3662..048cbe55eae 100644 --- a/services/cloud-agent-next/src/persistence/schemas.ts +++ b/services/cloud-agent-next/src/persistence/schemas.ts @@ -226,8 +226,6 @@ export const MCPServerConfigSchema = z.discriminatedUnion('type', [ MCPRemoteServerConfigSchema, ]); -// --- Runtime instructions --- - /** * Runtime instruction schema. Each entry is materialized to * `${SESSION_HOME}/.kilocode/rules/.md` at preparation time, alongside @@ -278,8 +276,6 @@ export const InitialExecutionPayloadSchema = z.discriminatedUnion('type', [ export type InitialExecutionPayload = z.infer; -// --- Profile bundle --- - /** * Schema for the profile-derived configuration bundle persisted with a * session. Current metadata stores this under the nested `profile` key. @@ -341,7 +337,6 @@ export const MetadataSchema = z.object({ * legacy record parsing. */ profile: SessionProfileBundleSchema.optional(), - // --- Legacy flat profile fields (read-only fallback, no longer written) --- ...SharedSessionProfileFields, upstreamBranch: branchNameSchema.optional(), kiloSessionId: z.string().optional(), diff --git a/services/cloud-agent-next/src/session/session-registration.ts b/services/cloud-agent-next/src/session/session-registration.ts index e4dad6117a9..061bc0301b9 100644 --- a/services/cloud-agent-next/src/session/session-registration.ts +++ b/services/cloud-agent-next/src/session/session-registration.ts @@ -276,8 +276,6 @@ type NewSessionAllocation = SessionRegistrationResult & { runtimeAuthorization?: { token: string; seal: string }; }; -// ----- operation-ledger boundary (P1-A-08b) ----------------------------------- - /** * Allocation failure stages reported to the operation ledger, matching the * `session_create_settled` `failure_stage` enum for pre-DO work. @@ -1630,8 +1628,6 @@ export async function startNewSession( return registerAndAdmitInitialTurn(input, ctx, options, allocation, ledger); } -// ----- ledger-guarded session creation ---------------------------------------- - /** * Ledger `canonical_result` key holding the SHA-256 fingerprint of the immutable * create intent, recorded with the first admitted create's progress. A same-key diff --git a/services/cloud-agent-next/src/shared/control-plane-protocol.ts b/services/cloud-agent-next/src/shared/control-plane-protocol.ts index dcdd819feb0..d51ca76659a 100644 --- a/services/cloud-agent-next/src/shared/control-plane-protocol.ts +++ b/services/cloud-agent-next/src/shared/control-plane-protocol.ts @@ -1000,8 +1000,6 @@ const controlPlaneWorktreeDeleteFrameSchema = z }) .strict(); -// --- terminals (B10) -------------------------------------------------------- - /** * Session DO -> Sandbox DO terminal request (spec §10). The Sandbox DO forwards * exactly one request frame and returns the wrapper's `terminal.result`. The diff --git a/services/cloud-agent-next/src/shared/runtime-profile.ts b/services/cloud-agent-next/src/shared/runtime-profile.ts index cd690fafa72..0f186847864 100644 --- a/services/cloud-agent-next/src/shared/runtime-profile.ts +++ b/services/cloud-agent-next/src/shared/runtime-profile.ts @@ -88,8 +88,6 @@ export const RuntimeSkillsSchema = z export type RuntimeSkillInput = z.infer; -// --- Runtime agents --- - const PermissionActionSchema = z.enum(['allow', 'ask', 'deny']); // Flat permissive shape — the runtime tolerates any shape the CLI accepts // (bare action string, per-tool map with per-pattern maps, null sentinels). @@ -154,8 +152,6 @@ export const RuntimeAgentsSchema = z export type RuntimeAgentInput = z.infer; -// --- Runtime kilo commands --- - export const RuntimeKiloCommandSchema = z.object({ name: z .string() diff --git a/services/cloud-agent-next/src/websocket/ingest.test.ts b/services/cloud-agent-next/src/websocket/ingest.test.ts index e156d4d1064..c93cf1acc80 100644 --- a/services/cloud-agent-next/src/websocket/ingest.test.ts +++ b/services/cloud-agent-next/src/websocket/ingest.test.ts @@ -185,8 +185,6 @@ describe('createIngestHandler', () => { }); } - // --- kilocode events: upsert path --- - it('message.updated is upserted by entity ID', async () => { const eventQueries = createFakeEventQueries(); (eventQueries as unknown as Record).upsert = vi.fn().mockReturnValue(42); @@ -362,8 +360,6 @@ describe('createIngestHandler', () => { }); }); - // --- kilocode events: plain insert path (PERSISTED_KILO_EVENT_NAMES) --- - it.each([ 'message.part.removed', 'session.created', @@ -391,8 +387,6 @@ describe('createIngestHandler', () => { expect(broadcastFn).toHaveBeenCalledWith(expect.objectContaining({ id: 1 })); }); - // --- kilocode events: broadcast-only (not in any allowlist) --- - it.each([ 'question.asked', 'question.replied', @@ -422,8 +416,6 @@ describe('createIngestHandler', () => { ); }); - // --- non-kilocode: plain insert path (PERSISTED_STREAM_EVENT_TYPES) --- - it.each(['complete', 'interrupted', 'error', 'autocommit_started', 'autocommit_completed'])( 'stream event %s is plain-inserted', async eventType => { @@ -445,8 +437,6 @@ describe('createIngestHandler', () => { } ); - // --- non-kilocode: broadcast-only (not in PERSISTED_STREAM_EVENT_TYPES) --- - it.each(['heartbeat', 'pong', 'output', 'status', 'started', 'wrapper_resumed'])( 'stream event %s is broadcast-only', async eventType => {