1b58bc325e
This branch's uncommitted WIP, committed together (entangled at file level). Distinct pieces of work: Freestyle QA fixes (this session): - FileEditTool: pre-validate replace anchor in validateRequest — reject a missing/ambiguous target BEFORE the approval gate, mirroring read/write's file-not-found / read-before-write pre-checks. Shared not-found/ambiguous messages between validate and execute so they can't drift. - PlanGrounder: add `scanned` flag; when no RepoMapComputedEvent was recorded, repoMapPaths is "unknown" not "empty workspace" — skip scope grounding (which proves a path ABSENT) so real paths (apps/server/**) aren't falsely rejected. Build-manifest check still runs. - FreestyleDriver: wire scanned=(repoMap!=null); on plan rejection emit a session-terminal WorkflowFailedEvent so a rejected run reads FAILED, not the COMPLETED-lie (last verdict was the planning-phase WorkflowCompleted). - ServerModule: resolve project-memory workspace root from the session's bound workspace (sessionWorkspaceRoot) instead of boot-static pm.repoRoot(), fixing the workspace-binding divergence (correx vs empty scratch dir). Retire tracked in Vikunja #266. - LaunchRegistrationRaceTest: join registered jobs before asserting launchCount — computeIfAbsent returns the Job immediately but the fire-and-forget launch body lagged awaitAll (the 49-vs-50 flake). ACR concept-compiler experiment (pre-existing WIP on this branch): - ExecutionPlanCompiler/Model/PlanLinter, #264 needs-seam (sessionArtifacts), LSP diagnostics subsystem (LspDiagnosticEvents/Runner/Lsp4j), BootWorkspace, config surface, workflow prompts/schemas, orchestrator advance-don't-rerun. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2.9 KiB
2.9 KiB
apps/server
Purpose
Ktor HTTP + WebSocket server. Exposes the orchestration kernel to CLI and TUI clients, manages session lifecycle, and streams events over WebSocket.
Ownership
All sources under apps/server/src/.
Local Contracts
HTTP REST routes
GET/POST /sessions— session browse and start (POSTaccepts an optionalintentbrief, parity with the WSStartSession)POST /sessions/{id}/resume— resume a session after restartGET/POST /tasks— task listing and managementGET/POST /providers— provider configurationGET/POST /workflows— workflow managementGET /health— health report (probes: event-store, llama-server, disk watermark)GET /stats— metrics report (MetricsProjection)GET /metrics/tool-reliability— per-model tool-call validity across the event log (ToolReliabilityInspectionService); groundwork for capability-aware routing- Optional
[git]transport createsrun/<sessionId>from a server-local checkout and pushes it at terminal state; clients review with ordinary Git and never supply a remote URL ascwd. - Repo-map L3 embeddings use bounded, recorded source descriptors (module/package, imports, leading purpose comment, symbols); raw file bodies are never embedded. Their versioned
repomap:v2namespace forces a one-time re-embed when the semantic document format changes. - At boot,
tools.workspace_rootis the authoritative tool jail and project-observation root. A configuredtools.working_dirmay only remain distinct when it is contained by that root; an outside value is clamped toworkspace_root. Project memory and repo-map indexing are also rebound toworkspace_root, so a stale[project].rootcannot inject files from outside the session workspace.
WebSocket protocol (/ws)
- ServerMessage (server → client): sealed hierarchy —
SessionMessage(event-derived, carriessequence+sessionSequence) andNonEventMessage(control/infra). Variants include session lifecycle, approval requests, clarification requests, narration, proposed workflows, health/metrics pushes. - ClientMessage (client → server):
StartSession,ApproveToolCall,RejectToolCall,GrantApproval,AnswerClarification,SetChatMode, and others. - All protocol types are in
protocol/(Dtos.kt, ServerMessage.kt, ClientMessage.kt, ProtocolSerializer.kt).
Health monitoring
HealthMonitorruns probes on a schedule; results folded viaHealthProjectionintoHealthState.- Adding a probe: implement
HealthProbe, register inServerModule.
Work Guidance
- Follow Kotlin rules in root CLAUDE.md.
- Route handlers must not contain domain logic — delegate to core services injected via
ServerModule. - New WS message variants require updating both
ServerMessage/ClientMessagesealed classes andProtocolSerializer.
Verification
./gradlew :apps:server:test --rerun-tasks
Child DOX Index
No child AGENTS.md (leaf module).