Architecture

Local-first, with an explicit hosted boundary

Current local path

  1. The editor or TUI launches the standalone LSP server over stdio.
  2. Document open/change notifications update the server's in-memory text and function index.
  3. Tree-sitter indexes top-level functions and methods for Rust, Python, JavaScript/TypeScript, and Go.
  4. Symbol metadata and lifecycle state are written to .stubforge/state.db; source text is not stored in that database.

Transport boundaries

Editor traffic uses standard LSP Content-Length framing over stdio. The original hosted TUI currently calls the Worker’s HTTP JSON API; the standalone LSP server and local TUI do not yet synchronize to hosted services. Any future persistent sync connection is a separate protocol, not LSP Content-Length framing over WebSocket.

Planned hosted path

Hosted requests use the account portal’s scoped API keys. The Worker validates each key against the D1 control store and routes by account plus project ID, so matching project names in different accounts have different Durable Objects. It applies a 10 MiB request-body cap, a 1,000-request daily account quota, and an estimated 10,000-neuron daily account quota across projects. Project metadata and execution state live in DO SQLite. Customer billing checkout is intentionally deferred.

Recovery

The local LSP persists batch items and proposal attempts in SQLite. On TUI restart it restores an in-review proposal or continues queued items; source edits are still guarded against stale document content. Durable Object hibernation resets in-memory state when the object wakes, so hosted work must likewise be represented in persistent storage and resumed through alarms or another durable queue.

Editor edit ownership

The server returns versioned workspace edits and leaves application to the client, preserving unsaved editor buffers as the source of truth. Single-symbol local generation is available through the LSP custom method; the standalone TUI previews the replacement and only writes it after explicit acceptance. Local proposal attempts, review outcomes, and dependency-aware batch state are persisted. Ready independent work is generated concurrently within a configured limit, while dependency gates, symbol locks, rejection cascades, restart recovery, and prior-attempt retry context are handled by the local store and LSP server.