Server readiness: what is left
Companion to server-readiness.md. All fifteen tasks of that plan are implemented and committed on docs/deployment-and-secrets; this file is everything that is not done, so the work can continue in a fresh session without this chat.
Written 2026-11-08, at branch head 1e1d65b (30 commits over main).
State at that commit: pnpm typecheck, pnpm lint, pnpm format:check clean; pnpm test green — 800 engine, 186 web, 57 shared. Task 4.4 (owner verdict on a task) was deliberately not implemented: the plan makes it conditional on seeing the Usage page first.
1. Owner steps that nothing else can replace
Gate 1 — the claude login inside the rehearsal container
The image is built and inspected: user jarvis (uid 1000), HOME=/home/jarvis, Node 22.23.4, pnpm 10.23.0, claude 2.1.319, no ANTHROPIC* variable, every published port on host_ip: 127.0.0.1, and /home/jarvis/.jarvis/jarvis.config.json already seeded in the jarvis-home volume with repo.path=/work/repo, claudeBinary: "claude" and haiku models. What is missing is only the credential, and the macOS login lives in the Keychain, so it cannot be copied in.
docker compose --profile server run --rm --no-deps engine claude # then /login, paste the code, exitThen the rest of Gate 1, which can be run by anyone (or by an agent) once the login exists:
docker compose --profile server run --rm --no-deps engine claude auth status --json
docker compose --profile server run --rm --no-deps engine ls -la /home/jarvis/.claude/.credentials.json # expect mode 600
docker compose --profile server run --rm --no-deps engine claude -p "ping"
docker compose --profile server up -d
curl -s http://127.0.0.1:4310/api/health
# then open http://127.0.0.1:5180 and send a message; a dispatcher run must answerNote while doing this: the web container shares the engine's network namespace, so recreating the engine container leaves web attached to a dead namespace until it is recreated too.
Git history was rewritten — any other clone must be reset
On 2026-11-08 every commit on main, docs/github-pages and docs/deployment-and-secrets was re-authored to the personal address (the work account's e-mail had been the git identity) and force-pushed. Shas changed.
- A clone that fetched the old commits will break on
git pull. Fix it withgit fetch origin && git reset --hard origin/<branch>. This applies to the VPS checkout. - The local repository still holds the pre-rewrite objects in
.git/refs/originaland the reflog. Purging them is irreversible and was left to the owner:rm -rf .git/refs/original && git reflog expire --expire=now --all && git gc --prune=now - A force-push does not delete old objects on GitHub immediately: the old shas may stay reachable by direct reference until GitHub's own garbage collection runs. If that matters, the robust answers are recreating the repository or asking GitHub support.
git config --global user.emailis still the work address by the owner's choice, so every new personal repository needsgit config user.emailset locally right aftergit init, or its first commit carries the work identity again.
Merging
The owner chose commits on this branch with no PR, so the merge into main is a local decision that has not been made yet.
2. Findings from the final whole-branch review
Verdict: merge after fixes — four Important, no Critical. The four cross-cutting seams were traced end to end and hold (the probe cache and its single producer, the expired-login run gate, the event vocabulary, and the telemetry path into a child's environment), as do all five of the plan's Review Focus invariants, and every credential was traced for exposure through logs, argv, committed files, child processes and error messages.
Important 1 — stopReason is in the log contract but no producer writes it
engine/src/application/ports/logger.ts:6listsstopReasonamong the fixed context keys (the contract with the log pipeline, ADR-0016), butengine/src/application/runs/run-sink.ts:86-99writesrun.finishedwithrunId, sessionId, taskId, threadId, role, costUsd, turns, durationMsand nostopReason. Task 4.1 addedruns.stop_reasonto the schema, the domain, the DTO and the Usage page, but did not close this seam.The producer should move, not the contract.
stopReasonis the whole reason ADR-0016 wants structured logs — "why did it go badly" without readingrun_events— and the value is already on therunobject in that exact line of code.The fix, one line in
run-sink.ts'srun.finishedcontext:ts...(run.stopReason === null ? {} : { stopReason: run.stopReason }),Strictly,
config.alloyand the dashboard need no change: the field rides along in the JSON line and{unit="jarvis-engine.service", event="run.finished"} | json | stopReason="max_turns"works as is. Optionally, addstopReason = "stopReason"tostage.json.expressionsandstopReason = ""tostage.labels.valuesindeploy/alloy/config.alloy— seven possible values, so it is safe as a label and turns "which runs went badly" into a selector rather than a line filter.Two statements become false once this is fixed and must be updated in the same change:
deploy/alloy/README.md("stopReasonis not logged yet (a later task). No panel needs it…") and the "UNVERIFIED until Gate 3" markdown panel indeploy/grafana/jarvis-overview.json.
Important 2 — a Grafana credential the instructions create and nothing reads
.env.example:27asks the owner to fill inOTEL_EXPORTER_OTLP_HEADERS; ADR-0016:41 confirms it ("live in~/.jarvis/.envor Infisical");deployment.md§3 says to put "variables as in.env.example" into Infisicalprod. Nothing reads it. Alloy authenticates withGRAFANA_LOKI_URL,GRAFANA_LOKI_USER,GRAFANA_OTLP_ENDPOINT,GRAFANA_OTLP_USERandGRAFANA_CLOUD_TOKEN(deploy/alloy/config.alloy:77-116, and the table indeploy/alloy/README.md:18-22); the engine never consumes it; a child never receives it, which is pinned byenv.test.ts:133.- Why it matters: following the instructions puts a Grafana Cloud token into the engine process's environment for no purpose, where a child
claudecan read it through/proc/<engine>/environ. It is a new instance of the accepted/procrisk, and the only place in the branch that adds a path to a credential with no need for it. - Fix: remove the line from
.env.example(or comment it out saying the credentials live only in/etc/jarvis/alloy.envand that Alloy readsGRAFANA_*), and rewrite the ADR-0016:41 bullet to name the five realGRAFANA_*variables instead ofOTEL_EXPORTER_OTLP_HEADERS.
Important 3 — ExecStartPost contradicts the "Postgres down" invariant
deploy/systemd/jarvis-engine.service:14runscurl -fsS http://127.0.0.1:4310/api/health, and-ftreats a 503 as failure. But 503 is exactly "Postgres is down, the engine is alive" — the behaviour Review Focus #2 protects and which was verified live.- If Postgres has not come up (and
After=docker.servicedoes not guarantee it, asdeploy/README.md:60itself admits), the unit loops about every 68 seconds: the engine starts, answers 503 honestly for 60 seconds, systemd kills it,RestartSec=5, again. The defaultStartLimitBurstnever trips (it needs 5 starts in 10 seconds), so the loop does not stop. - Why it matters:
deploy/README.md:60claims "Restart=on-failurecovers that gap", but the loop does not close it — it hides the real cause and makes journald unreadable at exactly the moment someone is reading it, which breaks the one answer ("is it alive") this branch exists to provide. - Fix, any one of: (a) accept both 200 and 503 —
curl -sS -o /dev/null -w '%{http_code}'checked against200|503; (b) add a real dependency on the Postgres unit or container; (c) dropExecStartPostand rely on the heartbeat. Correctdeploy/README.md:60in the same change.
Important 4 — the observability half is unreachable from the runbook
grep -rn "alloy\|Alloy\|telemetry\|heartbeat\|healthchecks" docs/architecture/deployment.md README.md docs/architecture/README.mdreturns zero hits. The file table indeploy/README.md:6-10lists only the two units and../scripts/with-secrets.sh, and mentions neitheralloy/norgrafana/.- Why it matters: an operator who follows
deployment.mdfrom §1 to §6 — the only complete runbook — ends up with a server with no Alloy, noHEARTBEAT_URLand no telemetry, that is, without either of the two answers the branch was built for. ADR-0016 is implemented indeploy/but not wired into the deployment process. - Fix (minimal sufficient): a §4a "Telemetry and liveness" in
deployment.md— three or four lines pointing atdeploy/alloy/README.mdand namingHEARTBEAT_URLandtelemetry.enabled— plus two rows indeploy/README.md's table foralloy/andgrafana/.
The reviewer's own must-fix list, in order
Everything else it judged safe to carry.
- Important 1 —
stopReasononrun.finished, plus removing the two "not logged yet" statements. - Important 2 — the dead
OTEL_EXPORTER_OTLP_HEADERSline and the ADR-0016:41 sentence. - Important 4, minimal scope — two rows in
deploy/README.md's table and a pointer fromdeployment.mdtodeploy/alloy/README.md. - Important 3 — the reviewer would have fixed it immediately with option (a), about five minutes' work, but accepted it as a recorded follow-up with one condition: before the first
systemctl enable. Nothing else on this page carries a deadline like that.
Triage of the deferred minors
Three of the eleven are already closed on the branch and should simply be struck from the register, not fixed:
container.ts's stale comment and theLISTEN_HOSTnaming — already renamed toLOOPBACK_HOSTand the comment corrected (container.ts:72,server.ts:15).- The healthcheck and README
curlon/api/overview— both now/api/health(compose.yaml:49,README.md:73). network_mode: service:enginebeing brittle — the README already says so; only the optional part (restoring a separate network whenweb/vite.config.tsis next touched) remains.
The remaining eight were all triaged defer, with these reasons:
| Minor | Why it can wait |
|---|---|
Unpinned ubuntu:24.04, curl | bash installs, unused gnupg | The image is a rehearsal, not a deployment target (ADR-0016), and pinning by digest would break rebuilds when the base updates. |
No test that listen() uses env.listenHost | The path was verified live in the container (host_ip: 127.0.0.1 plus a working /api/health), and the type is held by typecheck. |
JARVIS_INSIDE_CONTAINER=1 defeating the guard on a host | That is the brief's design, not a defect: the guard is against a mistake, not against the owner. |
The INFISICAL_API_URL comment, PATH only in deploy/README.md, the fallback stderr line | All three are covered by the "Not verified yet" section, and the Infisical path has to be walked by hand at first run anyway. |
No test that startTimers starts and stops the probe-refresh job | The watcher and supervision timers have the same gap — a pre-existing pattern, not a regression of this branch. |
| The pool piling up pings under a hung Postgres | A pool-level change (connectionTimeoutMillis, statement_timeout) outside the task; no server exists yet, so the exposure window is zero. Worth being the first follow-up before the first unattended run. |
Stale summary/checkedAt on a kept cache entry | Nothing consumes those fields from last() — Health does not carry them and /api/connections takes a fresh check() — so there is no observable effect today. |
permission.answered not distinguishing a timeout from an orphaned run | Same category as Important 1 (widening the log context); the status in the message text already distinguishes them. Sensible to do together with stopReason while that contract is open. |
3. Deferred minors carried from the task reviews
Each was raised by a reviewer and consciously not blocked on.
| Area | Item |
|---|---|
| Runtime image | network_mode: service:engine is brittle: recreating the engine container leaves web without a network until it is recreated too. The README should say so, and a task that touches web/vite.config.ts should restore a separate network. |
| Runtime image | ubuntu:24.04 is not pinned by digest; NodeSource and claude.ai/install.sh are curl | bash with no pinned version; gnupg is installed but unused. |
| Engine config | No test asserts that listen() actually uses env.listenHost — only loadEnv is covered. |
| Engine config | JARVIS_INSIDE_CONTAINER=1 left in a host shell alongside a non-loopback host defeats the loopback guard. This follows from the design, not a defect. |
| Deploy docs | The with-secrets.sh comment mentions INFISICAL_API_URL for a non-US host, which is unverified; the PATH requirement lives only in deploy/README.md, not in deployment.md §4; the fallback stderr line prints on every laptop invocation. |
| Health | Nothing tests that startTimers starts and stops the probe-refresh job — the watcher and supervision timers have the same gap, so it is a pre-existing pattern. |
| Health | Under a hung Postgres, every /api/health call starts a ping the pool never releases, so requests can pile up in the pool queue. Consider connectionTimeoutMillis and statement_timeout on the pool. |
| Health | When the cache keeps a previous entry because the CLI did not answer, that entry's summary and checkedAt grow stale. |
| Logging | permission.answered is also logged for the orphaned path (reason: 'run_ended'), and the reason is not in the line, so a timeout and an orphaned run differ only by status text. |
| Heartbeat | No test covers stop() while a fetch hangs beyond its 5-second abort. |
| Connectors | .env.example names GOOGLE_APPLICATION_CREDENTIALS where the plan said GOOGLE_SERVICE_ACCOUNT_JSON; the former is correct for the chosen server (it reads a file path, not JSON). |
4. Never executed, by necessity
Nothing below was verifiable on the laptop, and each is stated in its own README too.
- Alloy:
deploy/alloy/config.alloyhas never been run;alloy fmtandalloy validatewere unavailable. The Loki queries indeploy/grafana/jarvis-overview.jsonare likewise unexercised. - Claude Code metric names (for example
claude_code_token_usage_tokens_total) come from the CLI's "Monitoring usage" documentation, not from an observed export. The dashboard says so on its first panel. (ThemodelUsagefield names were separately verified against CLI 2.1.318 on 2026-11-08 and are correct:inputTokens,outputTokens,cacheReadInputTokens,cacheCreationInputTokens,costUSD.) - The Alloy service user: the credential file is specified as
/etc/jarvis/alloy.env,root:alloy, mode0640. Which user the distribution's Alloy package runs as was not confirmed;deploy/alloy/README.mdsays how to check. If only systemd reads the file,root:root 0600would be stricter and sufficient. - The Infisical branch of
scripts/with-secrets.sh: the CLI is not installed locally, so only the fallback path (noINFISICAL_CLIENT_ID→ plainexec) was executed. The flags--method=universal-auth,--silent,--plainand the variable names come from knowledge of the CLI, not from a run. - The systemd units: never loaded.
ExecStartPostcurls/api/health, which only exists from this branch on. - The Google connector: no Google Cloud project, no token, nothing authorised. Four items are listed in
docs/architecture/connectors.mdunder "verify at first setup", including whether a service account can read a personal (non-Workspace) account's Doc, whetherdrive.readonlyalone suffices for the Docs API, whether publishing the consent screen needs verification for these scopes, and how theauthcommand receives the client id and secret. - The e2e suite (
pnpm --filter @jarvis/web e2e) was not run at any point in this work.
5. Decisions taken on the owner's behalf that are worth a second look
Thirty-eight rulings were recorded while executing the plan. These are the ones whose cost, if wrong, is not merely cosmetic:
- A child
claudecan read the engine's secrets through/proc. It runs as the same user as the engine, so thechild-env.tsallow-list protects inheritance but not a sibling read — includingINFISICAL_TOKENandGITHUB_TOKEN. Accepted and documented (deploy/README.md, ADR-0015 Consequences). The real fix is running child processes under a separate uid, which touches ADR-0015, the worktree permissions and~/.claude, and is its own task. - The Google token must be minted read-only on the laptop.
GOOGLE_DRIVE_MCP_SCOPESdoes nothing in external-token mode, and the server's defaults grant write access to Drive, Docs, Sheets, Slides and Calendar.connectors.mdstep 2 carries the warning and the exact command. If the token is ever re-minted carelessly, a run can modify the owner's whole Drive. - The run gate opens between probe ticks. The expired-login gate reads a cache refreshed every five minutes, and before the first refresh the cache is empty, so the gate is open. Inherent to a cached probe.
- Day buckets are UTC, the budget resets at local midnight.
/api/usagegroups by UTC day whiledailyBudgetUsdusesstartOfLocalDay, so the two "today" numbers legitimately differ. The Usage page labels it; nothing reconciles them. stop_reasonis derived from the resultsubtype, not from the CLI's ownterminal_reason. Note that the CLI's top-levelstop_reasonis the model's API stop reason (end_turn), a different concept that shares the name;terminal_reasonis its run-level one. If the mapping ever moves toterminal_reason, the column's values change meaning once.- Fastify's request log is separate from
JARVIS_LOG_LEVEL, which drives the application's lifecycle lines; onlyerrormaps through.infoin pino would mean two lines per HTTP request from a polling SPA. - The Grafana dashboard's "engine up" panel is a proxy — the age of the newest engine log line — because the engine logs only heartbeat failures. A healthy but idle engine looks stale there; healthchecks.io is the real liveness signal.
The full list, with the reasoning and the stated cost of each being wrong, is in the execution ledger at .superpowers/sdd/server-readiness/progress.md (git-ignored, local to the machine this ran on). That file also holds every task's implementer report path and the pre-flight conflict scan.