Skip to content

prod-code v0.1.0

Choose a tag to compare

@alex09x alex09x released this 19 Sep 21:29
· 96 commits to main since this release

First release of prod-code, the Remote Code Intelligence gateway: one warm, in-memory
analysis server on the LAN that a fleet of AI coding agents and thin clients query instead of
each running its own language server and build on a laptop.

Gateway and engines

  • prod-code-server: TCP gateway with a JSON wire protocol, multi-tenant workspace manager
    with leader/follower loading, per-session views and path translation.
  • In-memory Rust engine on ra_ap_ide (rust-analyzer as a library): the Cargo workspace is
    loaded once into a Salsa database; hover, definition, references and document symbols run
    from RAM in 1–4 ms server-side. Live buffers are applied straight into the database; a
    re-open with identical text is a no-op and keeps the caches warm.
  • Per-session buffer overlays: concurrent sessions on one workspace each see their own
    unsaved edits; queries run under the engine lock together with view activation, so a
    concurrent edit can no longer cancel an in-flight query into a null result.
  • Managed Go engine (gopls) and a generic LSP engine for other languages; engine kind is
    detected from the workspace manifest and reloaded if the detected kind changes.
  • Janitor: engines idle for 30 minutes are unloaded (--idle-evict-secs), worktree workspace
    copies unused for 7 days are pruned (--prune-worktree-days); child language servers are
    killed with their engine; ~/.cargo/bin is put first on PATH.

Isolated workspace per git worktree

  • Every git worktree identifies itself as <origin>--wt-<hash> and gets its own server
    workspace and analysis database; the main checkout keeps its own. Diverged worktrees can no
    longer see each other's edits (the shared mode remains available in the benchmark as a
    diagnostic).
  • First contact sends a manifest (path, size, FNV-1a hash) instead of the tree: the gateway
    seeds a new worktree from the origin repository's copy, deletes what the client does not
    have and asks only for missing files. A fresh BTCR worktree: 0.4 s instead of ~7 s.

Sync

  • Watermark-based incremental sync per worktree: commits since the last sync
    (git diff <base>), dirty and untracked files, reverts of previously dirty files, and lock
    files; git diff is skipped when HEAD has not moved. Persistent state lives under
    ~/.local/share/prod_code/sync/, versioned with the relevance filter.
  • Pre-flight sync runs before the handshake so a new workspace directory is populated before
    engine detection; a client whose watermark disagrees with the gateway (reset server
    directory) self-heals with a full resync.
  • File content travels as base64: a 10.8 MB workspace syncs in 0.76 s over 10G instead of 8 s.
  • The MCP server watches the workspace tree and runs the pre-flight sync only after a change.

Remote build and test execution (Phase 6 foundation)

  • prod-code exec -- <argv> and the MCP tool code_exec run a command on the gateway inside
    the checkout's server copy, stream stdout/stderr back and return the remote exit code.
    Build artifacts stay on the server per workspace, so every worktree keeps a warm cache.
  • Files the command creates, changes or deletes (formatters, generators, lockfiles) are
    written back into the checkout and recorded in the watermark. Commands run in their own
    process group and are killed on timeout or client disconnect.
  • Measured on the prod-code repository itself: workspace clippy plus all crate tests in
    5.8 s on the 32-core gateway host, nothing compiled on the developer's machine.

Clients

  • prod-code CLI: status, sync, hover, def, refs, symbols (1-based positions),
    lsp (stdio bridge), mcp, exec, bench, divergent-bench; PROD_CODE_TIMING=1 prints
    per-phase timings of a query.
  • Native MCP server with code_definition, code_references, code_outline, code_hover,
    code_status, code_sync, code_exec for Claude, Codex and other agent frameworks.

Benchmarks

  • bench: persistent pipelined sessions; 40k hover/s at p50 1.4 ms, p99 3.5 ms against a
    warm Rust workspace.
  • divergent-bench: forks four worktrees of a real repository (signature change, manifest
    change, untracked file with a new symbol), runs 10+ concurrent workers and asserts zero
    cross-worktree bleed; --persistent reuses one session per worker like an agent process.
    Isolated mode passes on BTCR (Rust) and CodeHaus (Go) with zero errors.

Known limitations

  • Shared (coalesced) workspaces are diagnostic only; production isolates worktrees.
  • A one-shot CLI query costs ~80 ms, of which ~70 ms are two git subprocesses on the
    client; long-lived agents avoid this through the MCP server's change watcher.
  • Cluster features (Phase 5), C/C++, TypeScript, Python and Swift engines (Phase 3.4–3.7) are
    not implemented yet; see ROADMAP.md.