PRD: Runtime v1 (Channel/Branch/Worker) for Spacebot-Core
1. Document Status
- Version:
1.0 - Date:
2026-03-03 - Status:
Draft for implementation and alignment - Owners:
Core,AgentRuntime,Dashboard
2. Product Context
Runtime v1 is a control-plane protocol and orchestration layer for multi-agent execution with token-efficient context handling.
MVP scope stays a vertical slice:
- Backend:
Core - Frontend:
Dashboard
Runtime model for v1 includes five entities:
ChannelBranchWorkerCompactorVisor
3. Goals
- Provide deterministic, rule-based routing for channel messages.
- Support branch-based context fork for focused work and concise return to channel.
- Support worker execution in two modes:
fire_and_forgetandinteractive. - Keep context/token costs stable via typed short payloads and artifact/memory references.
- Provide event-level observability and replay-friendly persistence for runtime operations.
- Provide operator visibility in Dashboard: chat, tasks, workers, artifacts, activity feed.
4. Non-goals (MVP)
- Full autonomous LLM router (policy remains rule-based).
- Full branch transcript persistence.
- Distributed multi-node scheduling.
- External vector DB integration.
- Production-grade RBAC and hardened sandbox profiles.
5. Success Metrics
- Functional:
- 100% support for defined v1 message envelope and message types.
- Interactive routing to worker is accepted and reflected in worker status transitions.
- Reliability:
- No channel crash on compaction threshold handling (
80/85/95). - Runtime restart retains persisted events, artifacts, bulletins, and task/project state.
- Token economy:
- Average payload size for runtime events remains under target limit (target set by team per environment).
6. Functional Requirements
FR-1: Protocol Envelope v1
All runtime events must use one JSON envelope:
protocolVersionmessageIdmessageTypetstraceIdchannelIdtaskId?branchId?workerId?payloadextensions
Compatibility rule:
- Backward-compatible additive changes only.
- Unknown fields are ignored by consumers.
FR-2: Message Types v1
Required message types:
channel.message.receivedchannel.route.decidedbranch.spawnedbranch.conclusionworker.spawnedworker.progressworker.completedworker.failedcompactor.threshold.hitcompactor.summary.appliedvisor.bulletin.generated
FR-3: Channel Runtime
- Accept user message as entry point.
- Build routing context with system/policy context.
- Decide route by rule-based policy:
respondspawn_branchspawn_worker
- Route message into interactive worker when requested.
FR-4: Branch Runtime
- Fork channel context with unique
branchId. - Provide memory tools:
memory_recallmemory_save
- Allow worker spawn from branch context.
- Return only:
conclusionartifactRefsmemoryRefstokenUsage
- Do not persist full branch transcript in v1.
FR-5: Worker Runtime
- Accept
WorkerTaskSpecwith declared toolset. - Support two modes:
fire_and_forgetinteractive
- In interactive mode accept route messages from Channel.
- Return short structured report and artifact references.
- Emit lifecycle events (
spawned/progress/completed/failed).
FR-6: Compactor
- Evaluate channel context utilization thresholds:
>80%:soft>85%:aggressive>95%:emergency
- Compactor is orchestration-only (non-LLM).
- Summaries are generated by background workers.
- Publish threshold and summary-applied events.
FR-7: Visor
- Consume runtime event stream (
broadcast). - Build periodic memory bulletin.
- Persist bulletin in memory store.
- Deliver digest into active channels.
FR-8: Public API
Required endpoints:
POST /v1/channels/{id}/messagesPOST /v1/channels/{id}/route/{workerId}GET /v1/channels/{id}/stateGET /v1/bulletinsPOST /v1/workersGET /v1/artifacts/{id}/content
FR-9: Persistence
SQLite schema for MVP must include:
channelstaskseventsartifactsmemory_bulletinstoken_usage
FR-10: Dashboard (MVP)
- Chat interaction with channel.
- Runtime task visibility.
- Artifact content viewer.
- Worker/branch activity feed.
7. Acceptance Scenarios
- Channel receives task, spawns Branch, Branch spawns Worker, Channel receives conclusion-only output.
- Interactive worker receives routed message and updates behavior/status.
- Compactor schedules expected summarize level at
80/85/95thresholds without channel failure. - Visor bulletin is generated by schedule, stored in memory, and delivered as channel digest.
- Token regression test validates event payload budget.
- Recovery test validates restore after Core restart for channels/tasks/events/artifacts.
8. Technical Constraints
- Protocol format in v1 is JSON (not Protobuf).
- Dashboard remains in
/Dashboard. - Desktop app (
/Sources/App) is out of MVP critical path. - Branch full transcript persistence is out of v1.
- Additive schema evolution only.
9. Delivery Plan
MVP
- Finalize
protocol-v1.mdwith schema examples. - Event bus + broadcast wiring in Core.
- Channel state machine + route policy.
- Branch lifecycle + memory adapter.
- Worker lifecycle + interactive route bridge.
- Compactor threshold orchestration.
- Visor bulletin pipeline.
- Dashboard runtime views.
- SQLite schema and persistence integration.
- Docker Compose for
core + dashboard.
Post-MVP
- Proxy layer (global + plugin mode).
- ACP/Telegram/additional providers.
- GUI parity in
/Sources/App. - External vector backend and multi-node scheduling.
- Security hardening (sandbox profiles, RBAC, quotas, audit export).