7.9 KiB
Local project server
WRK-000E / DEC-0001 separates process lifetime from command lifetime. The public
aie interface stays unchanged: a lightweight client discovers a project's server,
starts it when needed, and forwards literal arguments and the caller's working
directory. Spring starts only in the persistent server. Native GraalVM is the
distribution default; the same entry point supports a JVM for development.
aie start waits for readiness and reuses a compatible running instance. aie stop
drains admitted operations and is successful when already stopped. Normal commands
can start the server again. Idle servers stop after 30 minutes with no active jobs;
the timeout is configurable. Help, version, initialization and bootstrap guidance
do not need a server. request create also runs directly in the client and writes
only a textual file to the destination inbox. request list/show/incorporate use
the server for explicit treatment; see Requests.
aie status retains its existing project-status meaning.
The canonical project path owns an exclusive OS lock and a loopback-only ephemeral
port. A private descriptor under .ai-engineering/.local/server/ contains the
instance identity, process, protocol/build identity, endpoint and capability token.
Clients authenticate and verify identity, and never infer ownership from a PID or
port alone. Startup is coordinated; incompatible versions drain before replacement.
HTTP messages are versioned JSON. Commands are parsed with Picocli, not a shell. Each request gets fresh parser, writers, reader and project context. No process-wide working directory or standard streams are redirected. Output and errors remain separate and the original exit code is returned. Interactive input is requested only when the command reads it. Jobs expose progress, input, completion and cooperative cancellation; a cancellation request never asserts rollback.
Reads are bounded and concurrent. Writes are coordinated at their existing transaction/lock boundaries; a provider call or an input prompt must not retain a database transaction or monopolize the command executor. Native/file storage and all human-authority checks retain their existing contracts.
Mutations have a durable intent, request fingerprint and recoverable result in private local operational state, separate from canonical engineering memory. Repeated IDs cannot execute twice or change their arguments. A crash between effects and a completed result leaves an explicitly unknown outcome, requiring inspection rather than replay. This is not an exactly-once guarantee. Tokens, credentials, environment dumps and transport logs are not canonical evidence.
Acceptance targets on the recorded native test machine are p95 <= 100 ms for a
fresh client's work show roundtrip to a ready server, and <= 1 s from aie start
to readiness. The nominal disposable dataset has 100 Works and 10 notes per Work,
without Git or provider/network work. Record build hash, hardware, first use and
ready-server distributions, and memory at 1/5/10 active projects. These targets must
be measured; external framework benchmarks are not proof that AIE meets them.
The native measurements now meet both targets on the recorded test machine. See current SSE results and the earlier polling measurements, including the initial failed implementation and parser correction.
Operation and limits
aie server status returns process status as JSON without starting a server. It
distinguishes STOPPED, STARTING, RUNNING and UNREACHABLE. aie start defaults to a
15-second readiness timeout; aie stop defaults to a 30-second drain timeout.
--timeout-seconds N overrides either. A stop timeout leaves the server draining;
active effects are not killed or rolled back. Changing the idle timeout with
start --idle-timeout-seconds N drains and replaces an existing instance when needed.
The override applies to that instance; a new automatic start defaults to 1,800 seconds.
The server inherits the environment of the client that starts it. Restart it after changing PATH, provider executables or environment-based credentials. Per-call cwd, arguments, input and output are isolated; environment dumps are not forwarded or stored in Work memory. Relative files resolve from the calling client's cwd.
HTTP protocol 1 is independent of engineering contract 4. The instance listens only
on 127.0.0.1, authenticates a private capability token, verifies instance identity
and rejects browser-origin requests. Startup and ownership use separate exclusive
OS locks. A stale descriptor without a lock owner can be replaced. A live but
unreachable owner is diagnosed rather than killed. Different compatible-protocol
builds drain before replacement; an unsupported protocol requires its matching CLI
to stop it. Ports can change after a restart.
The protocol provides GET /health, POST /execute, GET /requests/UUID, GET
/requests/UUID/events, POST /input, POST /cancel and POST /stop. Requests contain the canonical project,
calling cwd, literal argv, UUID and console-input capability. Responses carry state,
stdout, stderr, exit code, input sequence and cancellation status. Input retries
reuse the same sequence. Operations report QUEUED, RUNNING, COMPLETED or UNKNOWN.
Pending invocations open an SSE subscription; immediate terminal responses stay
JSON. The client reports the request ID when opening the stream and progress every
five seconds while waiting. It does not poll job results. No execution is silently
resubmitted after an ambiguous connection loss. Input-response uncertainty and server
restart use a one-off result lookup, not periodic monitoring.
SSE resumes with Last-Event-ID; expired cursors get an explicit snapshot. The
client checks overlaps and previously delivered prefixes before appending output.
After three reconnect attempts with 100/200/400 ms backoff, it reports the request
as recoverable and exits without cancelling/replaying it. The SSE read timeout is
five seconds and server heartbeats arrive every second. A crash can leave less
recoverable output than was already printed; a prefix gap is reported together
with the unknown outcome, never replaced silently. See event framing and resource
bounds.
Four ordinary workers and a 64-entry queue handle short commands; up to four dedicated workers handle provider jobs and guided survey input. Total active/queued admission is bounded. An interactive wait or provider call does not retain a database transaction. Writers keep the existing bounded SQLite/publication coordination. SSE uses a separate executor with at most 16 streams per project and two per job. Two-second blocked writes detach the subscriber; they do not cancel its job. Streams/heartbeats alone do not postpone idle shutdown. Once jobs finish, drain allows one second for terminal notification before closing remaining streams; durable results remain available for recovery.
JSON request bodies are limited to 1 MiB; accumulated output is limited to 8 MiB
characters per stream, with explicit failure on overflow. Response/receipt reads
are limited to 128 MiB. Large work context, input or provider workloads need their
own capacity assessment; the simple-query target does not cover them.
aie server request UUID can start the server to inspect a durable result;
aie server cancel UUID addresses an existing server. Completed read results are
persisted too, so cache eviction does not lose a waiting client's output. Receipts
are private files containing fingerprints, outcomes and command output. They remain
after stop/restart and currently have no automatic pruning. Preserve receipts while
outcomes need recovery; removing them also removes their deduplication history.
Do not remove state while a server is running or an interrupted mutation is unresolved.
Canonical Works, decisions, approvals and evidence continue to belong to SQLite or
the selected legacy backend, not to these operational receipts.