Repository navigation
docs: configuration reference and glossary (PR 5a of REORG-PLAN) - #493
Conversation
- docs/reference/configuration.md: environment variables by component (supervisor, worker, relay, control plane, sandbox workers, mocactl), with defaults, required/refusal behaviour, secret handling and which values must agree across components. Knative-only variables are listed separately; known inconsistencies are noted. - docs/glossary.md: leaf, archetype, brain and hands, supervisor, worker, sandbox, relay, tier and affinity, control plane, config bundle, human gate. - Link both from docs/index.md and the README; update REORG-PLAN (PR 5a). Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Thanks, this fills a real gap. Most of the reference holds up: I checked roughly 200 claims against the code at 0931b20 (the process.env / os.Getenv reads, templates, manifests, Compose, installers), and the supervisor table, relay ports and fail-closed tokens, the control-plane secrets and TTLs, the container-worker defaults, mocactl and the "Known inconsistencies" section all match. Every new link and anchor resolves.
Requesting changes because a reference page is only useful if operators can trust each row, and a handful of rows describe behaviour the code doesn't have (inline, must-fix):
SH_MODEL: a session's config bundle does not override it on/turn.- The "Legacy: Knative-only" table lists variables the P6 worker reads, most importantly
KAGENTI_SANDBOX_CWD, which must equal the sandbox worker'sSH_WORKSPACE_ROOT. - MicroVM
WORKER_MAX_CONCURRENTdefaults to 16 and is fatal on a bad value, not "the same" as the container worker's 4/fallback. SH_RELAY_TOKEN_<sandboxId>: nothing converts dashes to underscores.
The rest are suggestions and nits.
Your open questions
- Pi provider variables: the comment at
packages/knative-server/src/server-process.ts:17-22lists them by shape (*_API_KEY,*_AUTH_TOKEN,*_OAUTH_TOKEN,HF_TOKEN,COPILOT_GITHUB_TOKEN, the Bedrock AWS and Vertex ADC sources, from pi-aienv-api-keys.ts), andserver-process.test.tschecks it against pi's own lookup. That's enough to drop the (unverified) mark. UndermultitenancyscrubAmbientCredentialsdeletes all of them, not onlyANTHROPIC_API_KEY; rows 95-98 should say so. --role=leaf: the P6 spec still reserves it for queued leaf work in round two (docs/specs/2026-09-08-p6-vm-process-manager-design.md§3.3), but today the worker exits 2 for any role other thanturn(worker.ts:270-274). See the glossary comment.SH_PUBLIC_HARNESS_URLand the VM relay secrets: documenting them as they are seems right to me. They are maintainer calls rather than doc bugs.
Variables read by the code that aren't in the reference (optional): MOCA_WORKLOAD_DELETED_TTL_SECONDS (default 86400, workloads.ts:123), SH_ALLOW_INSTANCE_TYPE_MISMATCH (microVM snapshot-instance check bypass, microvm-worker/main.go:278), MOCACTL_BASE_URL (scripts/install-mocactl.sh), and the fact that CREDENTIALS_DIRECTORY drives the lookup for all four control-plane secrets. Also note that the Context Service rows are only checked per request: a missing CONTEXT_SERVICE_TOKEN returns 500 workloads_misconfigured, not a boot failure (workloads.ts:415-420).
CI: check failed at its Test step. This PR changes only Markdown, no test reads these files, and main passes check on the same base (98367da), so it looks like a flake. A re-run should clear it.
| | `SH_TURN_LOG_TTL_S` | `86400` | Blank or invalid falls back | A finished turn stays replayable this long | | ||
| | `SH_TURN_STREAM_TOOL_RESULT_PREVIEW_BYTES` | `2048` | | Byte cap on `tool_result` previews in the stream | | ||
| | `SH_MODEL_PROVIDER` | `anthropic` | | Model provider | | ||
| | `SH_MODEL` | `claude-opus-4-8` | A blank value is kept as an empty string. A session's config bundle overrides it | Model id | |
There was a problem hiding this comment.
must-fix: "A session's config bundle overrides it" isn't true for /turn. The model comes from input.selection ?? resolveModelSelection(config) (harness/src/run-turn.ts:978), which is config?.model ?? env.SH_MODEL ?? 'claude-opus-4-8' (:356). But buildConfig in packages/knative-server/src/server.ts never sets config.model, and the config bundle (packages/config-bundle, promoted-config.ts) has no model field. Only leaves override it, from the leaf envelope or leaf config (run-leaf.ts:369/494/645). Suggest: "A leaf's envelope may override it; sessions always use it."
| | `KAGENTI_SYNC_SATURATION_WAIT_MS`, `_BACKOFF_MS`, `_MAX_BACKOFF_MS` | `/runs` sync saturation retry (defaults `30000`, `250`, `5000`) | | ||
| | `KAGENTI_SYNC_SATURATION_RETRY_AFTER_S` (default `5`) | Also used for `/turn` retry headers, so live on P6 | | ||
| | `SH_SERVICE_URL`, `JOB_NAME`, `CRON_CONFIG` | The CronJob on-ramp (`cron-dispatch`) | | ||
| | `KAGENTI_SANDBOX_POD`, `_NAME`, `_NAMESPACE`, `_CONTEXT`, `_CWD`, `KAGENTI_EXEC_TIMING` | Single-pod `kubectl exec` sandbox transport | |
There was a problem hiding this comment.
must-fix: several rows here aren't Knative-only. The P6 worker serves the same handler (packages/knative-server/src/worker.ts:5), so:
KAGENTI_SANDBOX_NAMESPACE/_CONTEXT/_CWDare read on the P6 pool/records path wheneverKAGENTI_SANDBOX_POOL_SELECTORis set, and both Compose and k8s set it (harness/src/select-sandbox.ts:618-620).KAGENTI_SANDBOX_CWD(default/workspace) must equal the sandbox worker'sSH_WORKSPACE_ROOT, or sessions don't get their own<root>/<sessionId>directory (select-sandbox.ts:385-404). That's an operator-facing rule and belongs in the worker sandbox table.KAGENTI_SANDBOX_POOL_SELECTORitself isn't listed anywhere.- Sync
POST /runsruns on P6 (the migration guide says sync/runsis unaffected), soKAGENTI_SYNC_SATURATION_WAIT_MS/_BACKOFF_MS/_MAX_BACKOFF_MSandLEAF_RESULT_TTL_SECONDSare live (server.ts:47, 870-896).
Suggest moving these up and keeping only K_*, the cron-dispatch trio, KAGENTI_SANDBOX_POD/_NAME and KAGENTI_EXEC_TIMING here. Also, a blank LEAF_RESULT_TTL_SECONDS= parses to NaN (parseInt(... ?? '86400')), which is another exception to the "blank means default" convention.
|
|
||
| ### MicroVM worker (`remote-worker/cmd/microvm-worker`) | ||
|
|
||
| It reads the same `RELAY_*` and `SANDBOX_*` variables (defaults `SANDBOX_ID=sbx-microvm-1`, |
There was a problem hiding this comment.
must-fix: the microVM worker's WORKER_MAX_CONCURRENT isn't the same knob as the container worker's. It defaults to 16 (microvmDefaultConcurrency, remote-worker/cmd/microvm-worker/main.go:84), and a malformed or non-positive value is fatal rather than falling back (:134-146). Since SH_MAX_COMMITTED_MB has to be sized against the slot count, an operator reading "4" here would undersize it. Give it its own row.
| | `MOCA_RELAY_EXEC_ADDR` | unset (exec shares the attach listener) | Templates set a separate listener. The supervisor's `SH_RELAY_ADDR` must dial this | Bind address for `SandboxExec` | | ||
| | `MOCA_RELAY_EXEC_TOKEN` | none | **Secret, required.** The relay refuses to boot without it, or if it equals `SH_RELAY_TOKEN` or any per-sandbox token | Exec caller credential; must equal the supervisor's | | ||
| | `SH_RELAY_TOKEN` | none | **Secret.** Attach is fail-closed: with no token every attach is rejected. An empty value counts as missing | Shared sandbox attach token; must match each sandbox's `SANDBOX_TOKEN` | | ||
| | `SH_RELAY_TOKEN_<sandboxId>` | falls back to `SH_RELAY_TOKEN` | **Secret.** Id must match `^[A-Za-z_][A-Za-z0-9_]*$`; `DIR` is reserved. `setup-microvm.sh` writes these | Per-sandbox token (dashes in an id become underscores; systemd drops dashed names) | |
There was a problem hiding this comment.
must-fix: nothing converts dashes. The relay looks up env[SH_RELAY_TOKEN_${sandboxId}] ?? env.SH_RELAY_TOKEN verbatim (packages/sandbox-relay/src/main.ts:336), so a sandbox foo-1 never matches SH_RELAY_TOKEN_foo_1, and it silently falls back to the shared token. The ^[A-Za-z_][A-Za-z0-9_]*$ rule is enforced by setup-microvm.sh (which rejects dashed ids) and by the relay only for SH_RELAY_TOKEN_DIR files (main.ts:298, 325). Suggest: "Ids with a dash can't have a per-sandbox env token (systemd drops the name); they use SH_RELAY_TOKEN or a SH_RELAY_TOKEN_DIR file." Related: a DIR file equal to the exec token is refused per attach (:340), not at boot as the MOCA_RELAY_EXEC_TOKEN row implies.
| - **Blank values.** A blank line (`X=`) means "use the default" for most numeric knobs. Exceptions: | ||
| blank `SH_TURNS_PER_WORKER` refuses to boot, and a blank `SH_MODEL` is kept as an empty string | ||
| rather than defaulting. | ||
| - **Strict vs lenient parsing.** The supervisor and `SH_ROUTING_POLICY` refuse a bad value. The |
There was a problem hiding this comment.
suggestion: the strict/lenient split is broader than the code.
- In the control plane only
intEnvis lenient (packages/control-plane/src/main.ts:34-37, and it also accepts1.9,1e4and0x1F90with no upper bound).byteBudgetEnvandurlEnvrefuse to boot (:43-67), as this page itself says at line 163. - In the other direction, the workers in the supervisor's unit parse leniently (
SH_STATS_INTERVAL_MS,KAGENTI_SYNC_SATURATION_*, lease and affinity timings). "The supervisor's ownconfig.ts" would be accurate. - Worth adding: the refresh TTLs fall back silently too, so
SH_REFRESH_REUSE_GRACE_SECONDS=0becomes 30 and the grace can't be disabled.
|
|
||
| ## human gate | ||
|
|
||
| A pause point: a leaf or turn stops with `awaiting_approval` and resumes or terminates on |
There was a problem hiding this comment.
nit: the human-gate spec covers leaves and gate markers (docs/specs/2026-06-28-human-gate-design.md). I found no /turn gate path, and the sync /runs wire status is paused (server.ts:923-926), with awaiting_approval being the marker. Also, the archetypes spec calls B an "iterative role-based loop" (docs/specs/2026-06-26-pipeline-archetypes-requirements.md:18), while the README calls it the human gate. Worth a word on which one the glossary follows.
|
|
||
| ## config bundle | ||
|
|
||
| A content-addressed tar of a user's `.claude/skills` and `.claude/commands` that a session or leaf |
There was a problem hiding this comment.
nit: the bundle also carries the CLAUDE.md chain and the memory index/files under context/ (packages/config-bundle/src/build.ts:110-125), not only skills and commands.
| | `SH_JAILER_BIN`, `SH_FIRECRACKER_BIN`, `SH_CHROOT_BASE` | PATH, `/srv/jail` | Binary and jail locations | | ||
| | `SH_WORKSPACE_IMAGE_MB` | `2048` | Positive integer | | ||
| | `SH_SNAPSHOT_IMAGE` | `default` | | | ||
| | `SH_VIRTIOFSD_UID`, `SH_VIRTIOFSD_GID` | `65534` | Positive integers | |
There was a problem hiding this comment.
nit: SH_VIRTIOFSD_UID / _GID are read only in the Cloud Hypervisor arm (remote-worker/internal/vmpool/launcher_env.go:195-202), so with the default SH_VMM=firecracker they do nothing. Move them next to the SH_CHV_* note.
| | ------------------------------------------------------- | ----------------- | ------------------------------------------------------------------------------------ | | ||
| | `SH_SNAPSHOT_DIR` | none | **Required** | | ||
| | `SH_WORKSPACE_ROOT` | none | **Required** | | ||
| | `SH_MAX_COMMITTED_MB` | none | **Required**, positive integer. Without it the OOM gate is absent | |
There was a problem hiding this comment.
nit: "Without it the OOM gate is absent" reads as if the variable were optional. Without it the worker refuses to start (microvm-worker/main.go:163-167).
| | Demos | FIXED by PR 1 (#488) | Three Knative demos bannered (#485/#486); `docs/demos/README.md` "the two above" wording fixed | | ||
| | Terminology drift | OPEN | README `@sh/experiments` (removed by PR 4; `SH_HARNESS_DIR` is a real variable read by `/promote`, not a leftover); `serverless-harness`/`KAGENTI_`/`@sh/` still in 20 files outside specs/ADRs (`deploy/vm`, `P4-ON-P6.md`, demos) | | ||
| | Glossary (2 terms) | OPEN | 39 lines | | ||
| | Glossary (2 terms) | FIXED by PR 5a | Adds leaf, archetype, brain and hands, supervisor, worker, sandbox, relay, tier and affinity, control plane, config bundle and human gate | |
There was a problem hiding this comment.
nit: this marks the glossary fixed, but §2's note (line 131: "leaf: undefined in glossary … Glossary defines only session, turn, run") and open question 8 still read as open, and the planned term "handler" (line 424) wasn't added.
Configuration reference: - SH_MODEL: sessions always use it; only a leaf can override it. - Move the KAGENTI_SANDBOX_* pool, cwd and sync-saturation settings and LEAF_RESULT_TTL_SECONDS out of the Legacy table; document that KAGENTI_SANDBOX_CWD must equal the sandbox worker's SH_WORKSPACE_ROOT. - Per-sandbox relay tokens are looked up verbatim (no dash conversion); a token-dir file equal to the exec token is refused at attach time. - MicroVM WORKER_MAX_CONCURRENT has its own row (default 16, fatal on a bad value); SH_MAX_COMMITTED_MB is required; VIRTIOFSD uid/gid are Cloud Hypervisor only; add SH_ALLOW_INSTANCE_TYPE_MISMATCH. - Correct the strict/lenient parsing description, SH_MODEL_API values, openai-completions-only settings, SH_RELAY_ADDR matching, the sandbox command environment strip list and the installer-time grouping. - Document the multi-tenancy credential scrub, CREDENTIALS_DIRECTORY, per-request Context Service checks and MOCA_WORKLOAD_DELETED_TTL_SECONDS. Glossary and plan: - leaf: --role=leaf is reserved but not implemented; re-entrancy wording. - relay, config bundle and human gate wording; add handler. - REORG-PLAN: leaf row and open question 8 answered. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
|
Addressed in d2f9b4b. Must-fix: The earlier |
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Thanks for the quick turnaround. I checked d2f9b4b against the code, and all four must-fixes are resolved: SH_MODEL (sessions always use it), the KAGENTI_SANDBOX_*/sync-saturation/LEAF_RESULT_TTL_SECONDS rows moved out of Legacy, including the KAGENTI_SANDBOX_CWD = SH_WORKSPACE_ROOT rule, the microVM WORKER_MAX_CONCURRENT row (16, fatal on a bad value), and the verbatim relay-token lookup. The suggestions and nits are addressed too. I also checked the new claims: CREDENTIALS_DIRECTORY (four secrets, both present is fatal, systemd-credentials.ts), the intEnv 0 → 30 grace, MOCACTL_BASE_URL https-only, SH_ALLOW_INSTANCE_TYPE_MISMATCH, and the scrubAmbientCredentials scope. All of them match.
Two small things inline, neither blocking.
| | `MOCA_CONTEXT_STORAGE_CLASSES` | empty (any class rejected) | | | ||
|
|
||
| These settings are checked per request, not at boot: a missing `CONTEXT_SERVICE_TOKEN` or URL returns | ||
| 500 `workloads_misconfigured`. |
There was a problem hiding this comment.
suggestion: CONTEXT_SERVICE_URL isn't one of the per-request checks. Without it, workloadsEnabled() is false (workloads.ts:68), so the routes answer 501 workloads_unavailable, as line 123 says. assertContextServiceSettings (context-service.ts:87-90) checks CONTEXT_SERVICE_TOKEN and CONTEXT_SERVICE_PUBLIC_URL, and it also rejects a public URL that isn't http(s) or that carries credentials. Suggest: "a missing CONTEXT_SERVICE_TOKEN or a missing or invalid CONTEXT_SERVICE_PUBLIC_URL returns 500 workloads_misconfigured."
| | Variable | Default | Notes | | ||
| | ------------------------------------------------------- | ----------------- | -------------------------------------------------------------------------------------------------------------- | | ||
| | `SH_SNAPSHOT_DIR` | none | **Required** | | ||
| | `WORKER_MAX_CONCURRENT` | `16` | Positive integer; a malformed or non-positive value is **fatal**, not a fallback. Not the container worker's 4 | Concurrency slots; size `SH_MAX_COMMITTED_MB` against it | |
There was a problem hiding this comment.
nit: this row and the rows at 220 and 222 have four cells, but the table has three columns (Variable / Default / Notes). GFM drops the extra cell, so "Concurrency slots; size SH_MAX_COMMITTED_MB against it", "Committed-memory (OOM) gate" and "Skip the hardware-match check" don't render. Fold them into Notes, or add a Meaning column.
Summary
PR 5a of
docs/REORG-PLAN.md(item 5 split into 5a/5b/5c): the configuration reference and the glossary. Docs only. Based onmainafter #492.docs/reference/configuration.md: environment variables by component (supervisor, worker, relay, control plane, container and microVM sandbox workers,mocactl), each with default, required/refusal behaviour, secret handling and the values that must agree across components (relay and supervisor ports and tokens, tier names, affinity TTL). Installer-time variables and the Knative-only variables are listed separately, and a short "known inconsistencies" section records what I found.docs/glossary.md: adds leaf, archetype, brain and hands, supervisor, worker, sandbox, relay, tier and affinity, control plane, config bundle, human gate, each citing its ADR or spec.docs/index.mdand the README; the plan file records 5a as shipped.How it was built
Extracted from the code (the
process.envreads, with file and line), then cross-checked againstdeploy/vm/env/*.env.example, the K8s manifests, the Compose file andinstall.sh. I re-checked a sample against the code (supervisor defaults,SANDBOX_TIERdefaults, relay token rules, boot-time sandbox checks). I did not run any deployment.Please check
pi-fork/isn't built in my worktree); a few variables with no reader found (SH_WORKER_ID,SH_PERSISTENT_EXEC,ANTHROPIC_MODEL).SH_PUBLIC_HARNESS_URL: the VM template says REQUIRED, the code treats it as optional (discovery returnsharnessUrl: null), and only the installer enforces it. The reference says so. Should the template wording change instead?MOCA_RELAY_EXEC_TOKENandSH_RELAY_TOKENare plainEnvironmentFilelines, notLoadCredential. The reference documents that as is; say if you consider it a bug.leafentry says--role=leafworkers are the role reserved for queued leaf work, taken from the P6 spec; confirm that is still the intent (open question 8).Not in this PR
5b (install-cli,
backend-*entry pages,first-run,cli-mocactl,http-api,leaf-and-envelope) and 5c (concepts).Verification
scripts/check-doc-links.pyreports 0 broken links; Prettier run on changed files.make lintnot run locally (nonode_modulesin this worktree); CI will.Assisted-By: Claude (Anthropic AI) [email protected]