26 lines
1.2 KiB
Markdown
26 lines
1.2 KiB
Markdown
|
|
# Task ID: 143
|
||
|
|
|
||
|
|
**Title:** SessionService for pod provisioning and lifecycle
|
||
|
|
|
||
|
|
**Status:** pending
|
||
|
|
|
||
|
|
**Dependencies:** 121, 132, 141, 142
|
||
|
|
|
||
|
|
**Priority:** high
|
||
|
|
|
||
|
|
**Description:** Create SessionService handling AgentSession creation, repo-clone init container, credential resolution, and GC sweep
|
||
|
|
|
||
|
|
**Details:**
|
||
|
|
|
||
|
|
Create src/mcpd/src/services/session.service.ts:
|
||
|
|
1. create(agentId, projectId, taskId?, image, expiresAt): create AgentSession row in pending state
|
||
|
|
2. provision(sessionId): resolve project's CodeRepo list, resolve credentials via SecretService (fail on resolution error like InstanceService.attemptStart), build ContainerSpec with init container that clones repos to workspace volume, create pod via orchestrator, transition to running
|
||
|
|
3. end(sessionId): stop container, mark ended
|
||
|
|
4. getById(), listByFilters()
|
||
|
|
5. GC sweep: find sessions where now() > expiresAt, stop containers, mark ended. Run in same style as inference-task sweep in main.ts
|
||
|
|
6. Note: assumes single mcpd replica (no leader election)
|
||
|
|
|
||
|
|
**Test Strategy:**
|
||
|
|
|
||
|
|
Unit tests: test provision builds correct init container command, test credential resolution failure aborts provision, test GC sweep marks expired sessions ended.
|