feat: Phase 4 teardown — remove Go codecontext sidecar from deployment

- Remove codecontext service block from docker-compose.yml
- Remove CODECONTEXT_URL env var
- Delete codecontext/Dockerfile
- Update callCodecontext() to try boocontext MCP first with HTTP fallback
- Graceful degradation: if boocontext MCP unavailable, tools still work via HTTP
This commit is contained in:
2026-06-08 02:16:02 +00:00
parent 917a229363
commit 7cb692d8be
3 changed files with 11 additions and 92 deletions

View File

@@ -26,6 +26,7 @@
import { access, copyFile, realpath } from 'node:fs/promises';
import { isAbsolute, join, resolve, sep } from 'node:path';
import { truncateIfNeeded } from './truncate.js';
import { callBoocontext } from './boocontext_client.js';
// v1.13.12 fix: codecontext crashes on empty source files (upstream issue #37)
// when it can't ignore them. The .codecontextignore.template ships with the
@@ -119,11 +120,16 @@ export async function callCodecontext(
req: CodecontextRequest,
fetcher: typeof fetch = fetch,
): Promise<CodecontextResponse> {
// DEPRECATED: This function routes through the Go codecontext sidecar at
// http://codecontext:8080. New callers should use boocontext MCP instead.
console.warn(
`[deprecated] callCodecontext("${req.toolName}") — route through boocontext MCP instead`,
);
// Phase 4: try boocontext MCP first. Falls back to the HTTP sidecar if the
// MCP server is not available or the tool doesn't exist there.
try {
return await callBoocontext({ toolName: req.toolName, args: req.args });
} catch (err) {
console.warn(
`[codecontext_client] boocontext MCP unavailable for "${req.toolName}", falling back to HTTP sidecar: ${err instanceof Error ? err.message : String(err)}`,
);
}
// Step 1: realpath the project root, then realpath the requested target_dir
// (defaulting to projectPath when the caller didn't pass one — the 12 wrappers
// never pass target_dir; tests can override). A non-existent target_dir

View File

@@ -1,44 +0,0 @@
# v2.8 — boocontext sidecar container.
# Multi-stage build: Go shim from golang:1.24-alpine, boocontext MCP aggregator
# from node:20-alpine, then an alpine:3.20 runtime holding both.
#
# The shim spawns boocontext as a child MCP process over stdio NDJSON,
# translating HTTP requests to MCP tools/call.
#
# To stage the fork source for a Docker build:
# tar -czf codecontext/fork.tar.gz -C /opt/forks/boocontext \
# --exclude=.git --exclude=node_modules --exclude=dist
# Stage 1: Go shim builder
FROM golang:1.24-alpine AS shim-builder
WORKDIR /build/shim
RUN apk add --no-cache ca-certificates
COPY go.mod ./
COPY shim.go ./
RUN CGO_ENABLED=0 GOOS=linux go build -o /build/shim-bin ./
# Stage 2: boocontext MCP builder (pnpm project)
FROM node:20-alpine AS boocontext-builder
WORKDIR /build/boocontext
RUN apk add --no-cache git python3 make g++ ca-certificates
RUN npm install -g pnpm@9 --silent
COPY fork.tar.gz /build/fork.tar.gz
RUN mkdir -p /build/boocontext && tar -xzf /build/fork.tar.gz -C /build/boocontext
WORKDIR /build/boocontext
RUN pnpm install --frozen-lockfile && pnpm run build
# Stage 3: Runtime
FROM alpine:3.20
# uv intentionally not installed — container network blocks astral.sh.
# tree-sitter-analyzer child server (uvx) won't start in-container, but
# boocontext logs a graceful warning; TSA-backed tools fall through.
RUN apk add --no-cache ca-certificates nodejs
COPY --from=shim-builder /build/shim-bin /usr/local/bin/shim
COPY --from=boocontext-builder /build/boocontext/dist /usr/local/lib/boocontext/dist
COPY --from=boocontext-builder /build/boocontext/node_modules /usr/local/lib/boocontext/node_modules
COPY --from=boocontext-builder /build/boocontext/package.json /usr/local/lib/boocontext/package.json
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s \
CMD wget -qO- http://localhost:8080/health || exit 1
ENTRYPOINT ["/usr/local/bin/shim"]

View File

@@ -7,7 +7,6 @@ services:
- "100.114.205.53:9500:3000"
env_file: .env
environment:
CODECONTEXT_URL: http://codecontext:8080
CONTAINER_GUIDANCE_FILE: /app/BOOCHAT.md
DATABASE_URL: postgres://boocode:${POSTGRES_PASSWORD}@boocode_db:5432/boochat
BOOCODER_URL: http://100.114.205.53:9502
@@ -91,48 +90,6 @@ services:
networks:
- boocode_net
# v1.12 Track B: codecontext sidecar. Stdio MCP server wrapped by a small
# HTTP shim (see ./codecontext/). No host port — reached from boocode at
# http://codecontext:8080 over the boocode_net bridge.
#
# DEPRECATED (Phase 4, Domain 2, v2.8.14): Superseded by the boocontext
# MCP server. The 16 codecontext tool wrappers still use this sidecar via
# HTTP but should route through the boocontext MCP instead. Keep the
# service running for backward compatibility until all callers migrate.
# Remove this block after full migration — see codecontext_client.ts and
# factory.ts for deprecation markers.
#
# Mounts /opt:/opt:ro (not just /opt/projects:ro): BooCode projects live
# at /opt/<slug> on the host, not exclusively under /opt/projects. The
# mount must cover anywhere a project.path could resolve to. Read-only
# because codecontext only analyzes — never writes. The model can't
# arbitrarily set target_dir to a sensitive subtree because the B.2
# wrappers validate target_dir against project.path before calling the
# shim, and the shim isn't reachable from outside boocode_net.
codecontext:
build:
context: ./codecontext
container_name: boocode_codecontext
ports:
- "127.0.0.1:8080:8080"
restart: unless-stopped
environment:
CODECONTEXT_CHILD: node /usr/local/lib/boocontext/dist/index.js --mcp
TYPE_INJECT_MCP_PATH: /opt/type-inject/packages/mcp/dist/index.js
TREE_SITTER_MCP_CMD: uvx
TREE_SITTER_MCP_ARGS: --from tree-sitter-analyzer[mcp] tree-sitter-analyzer-mcp
networks:
- boocode_net
volumes:
- /opt:/opt:ro
- /opt/forks:/opt/forks:ro
healthcheck:
test: ["CMD-SHELL", "wget -qO- http://localhost:8080/health || exit 1"]
interval: 30s
timeout: 5s
retries: 3
start_period: 30s
volumes:
boocode_pgdata: