- Project/component: DexDex main server control-plane contract
- Canonical path:
servers/dexdex-main-server - Role: Connect RPC business API boundary for workspace/task/session/PR/review/notification orchestration
- Runtime: Go Connect RPC server
- Primary language: Go
- Client engineers consuming business RPC and stream contracts
- Backend engineers implementing orchestration, state transitions, and polling
- Operators running single-instance or scale deployments
Contract alignment note:
- This contract defines the DexDex server architecture and API behavior target for this repository.
- Local implementation may diverge temporarily and must be synchronized in follow-up changes.
Core responsibilities:
- workspace CRUD and auth profile management (
CreateWorkspace,UpdateWorkspace,DeleteWorkspace,SetActiveWorkspace) - repository and repository-group lifecycle management
- UnitTask and SubTask orchestration (
CreateSubTask,ListSubTaskCommits,RetrySubTask) - worker dispatch and cancellation propagation (
CancelUnitTask,CancelSubTask,StopAgentSession) - agent session lifecycle queries (
ListAgentSessions,GetAgentSessionLog) - PR tracking, polling, and auto-fix control (
TrackPullRequest,RunAutoFixNow,SetAutoFixPolicy) - review assist and inline comment lifecycle (
ResolveReviewAssistItem) - badge theme management (
ListBadgeThemes,UpsertBadgeTheme) - notification record lifecycle
- event-stream fan-out and replay handoff
Architecture and deployment contracts:
- Main server is the canonical client-facing business boundary.
- Single-instance mode:
- SQLite primary store
- in-memory event propagation
- Scale mode:
- PostgreSQL primary store
- Redis stream/pubsub propagation
Task orchestration contracts:
CreateUnitTaskpersists queued top-level work and schedules initial SubTask.CreateUnitTaskaccepts exactly one selector (repository_group_idorrepository_id) and rejects zero/two-selector requests withINVALID_ARGUMENT.repository_idselector resolves to a deterministic singleton repository group (auto-repo-singleton-<repository_id>) via create-or-reuse.- System-managed singleton groups must satisfy the invariant: exactly one member and matching
repository_id; invariant violations fail withFAILED_PRECONDITION. - Cancellation contracts (
CancelUnitTask,CancelSubTask) propagate quickly to worker runtime. - Plan decision contracts enforce explicit state transitions and typed errors.
Repository-group lifecycle contracts:
- Repository-group IDs with the
auto-repo-singleton-prefix are reserved for system use and cannot be user-created. - System-managed singleton groups cannot be updated or deleted through user-facing repository-group APIs.
- Repository deletion must clean up its system-managed singleton group (if present) before deleting repository records.
PR management contracts:
- Poll provider state and detect actionable signals.
- Create remediation SubTasks for manual or auto-fix flows.
- Persist attempt budgets and blocked states.
Normalized session contract:
- main server consumes only normalized worker output payloads
- provider-native raw agent payloads are not public contract surface
Main server owns persistence for:
- workspace, repository, repository group
- UnitTask, SubTask, AgentSession metadata
- commit-chain metadata and task lifecycle state
- PR tracking and review assist data
- review inline comments and status
- notification records
- stream sequence offsets and replay anchors
- workspace-scoped authorization on every RPC
- bearer-token auth for shared/remote deployments
- strict input validation for repository refs, prompts, and review payloads
- no secret leakage in logs or stream payloads
Use structured log/slog with correlation keys:
request_idworkspace_idunit_task_idsub_task_idsession_idpr_tracking_id
Required log categories:
- task/subtask/session state transitions
- selector resolution (
repository_group_idvsrepository_id) and singleton-group create/reuse decisions - singleton-group lock-policy rejections (create/update/delete guardrails)
- worker dispatch/cancel outcomes
- PR polling snapshots and auto-fix decisions
- event-stream publish/replay health
- notification generation reasons
go test ./servers/dexdex-main-server/...- Contract-sensitive checks:
- workspace/repository/task/session API behavior
- plan-decision transition validation
- PR polling and remediation workflow behavior
- event-stream sequence/replay semantics
- Shared proto contracts:
protos/dexdex/v1/dexdex.proto - Worker integration contract:
docs/servers-dexdex-worker-server-foundation.md - Event streaming details:
docs/servers-dexdex-event-streaming-contract.md - PR workflow details:
docs/servers-dexdex-pr-management-contract.md - App integration:
docs/apps-dexdex-desktop-app-foundation.md
- Any server API/state/storage/orchestration contract change must update this file and
docs/project-dexdex.mdin the same change. - Stream or PR workflow changes must synchronize with dedicated server-domain contract docs.
- Proto-facing changes must synchronize with proto-domain contract docs.
docs/project-dexdex.mddocs/protos-dexdex-v1-contract.mddocs/protos-dexdex-api-contract.mddocs/servers-dexdex-worker-server-foundation.mddocs/servers-dexdex-event-streaming-contract.mddocs/servers-dexdex-pr-management-contract.md