Skip to content

docs: configuration reference and glossary (PR 5a of REORG-PLAN) - #493

Merged
pdettori merged 2 commits into
rossoctl:mainfrom
pdettori:docs/config-reference-pr5a
Oct 12, 2026
Merged

pdettori merged 2 commits into
rossoctl:mainfrom
pdettori:docs/config-reference-pr5a

Conversation

@pdettori

Copy link
Copy Markdown
Member

Summary

PR 5a of docs/REORG-PLAN.md (item 5 split into 5a/5b/5c): the configuration reference and the glossary. Docs only. Based on main after #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.
  • Both are linked from docs/index.md and the README; the plan file records 5a as shipped.

How it was built

Extracted from the code (the process.env reads, with file and line), then cross-checked against deploy/vm/env/*.env.example, the K8s manifests, the Compose file and install.sh. I re-checked a sample against the code (supervisor defaults, SANDBOX_TIER defaults, relay token rules, boot-time sandbox checks). I did not run any deployment.

Please check

  • Unverified: which provider variables Pi itself reads (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 returns harnessUrl: null), and only the installer enforces it. The reference says so. Should the template wording change instead?
  • Secrets on a VM: MOCA_RELAY_EXEC_TOKEN and SH_RELAY_TOKEN are plain EnvironmentFile lines, not LoadCredential. The reference documents that as is; say if you consider it a bug.
  • The glossary's leaf entry says --role=leaf workers 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.py reports 0 broken links; Prettier run on changed files. make lint not run locally (no node_modules in this worktree); CI will.

Assisted-By: Claude (Anthropic AI) [email protected]

- 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]>
@pdettori pdettori added the ready-for-ai-review Request automated AI code review from clawgenti label Oct 12, 2026

@ingpaolodettori-dev ingpaolodettori-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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):

  1. SH_MODEL: a session's config bundle does not override it on /turn.
  2. The "Legacy: Knative-only" table lists variables the P6 worker reads, most importantly KAGENTI_SANDBOX_CWD, which must equal the sandbox worker's SH_WORKSPACE_ROOT.
  3. MicroVM WORKER_MAX_CONCURRENT defaults to 16 and is fatal on a bad value, not "the same" as the container worker's 4/fallback.
  4. 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-22 lists them by shape (*_API_KEY, *_AUTH_TOKEN, *_OAUTH_TOKEN, HF_TOKEN, COPILOT_GITHUB_TOKEN, the Bedrock AWS and Vertex ADC sources, from pi-ai env-api-keys.ts), and server-process.test.ts checks it against pi's own lookup. That's enough to drop the (unverified) mark. Under multi tenancy scrubAmbientCredentials deletes all of them, not only ANTHROPIC_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 than turn (worker.ts:270-274). See the glossary comment.
  • SH_PUBLIC_HARNESS_URL and 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.

Comment thread docs/reference/configuration.md Outdated
| `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 |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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."

Comment thread docs/reference/configuration.md Outdated
| `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 |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 / _CWD are read on the P6 pool/records path whenever KAGENTI_SANDBOX_POOL_SELECTOR is 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's SH_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_SELECTOR itself isn't listed anywhere.
  • Sync POST /runs runs on P6 (the migration guide says sync /runs is unaffected), so KAGENTI_SYNC_SATURATION_WAIT_MS / _BACKOFF_MS / _MAX_BACKOFF_MS and LEAF_RESULT_TTL_SECONDS are 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`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread docs/reference/configuration.md Outdated
| `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) |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread docs/reference/configuration.md Outdated
- **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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: the strict/lenient split is broader than the code.

  • In the control plane only intEnv is lenient (packages/control-plane/src/main.ts:34-37, and it also accepts 1.9, 1e4 and 0x1F90 with no upper bound). byteBudgetEnv and urlEnv refuse 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 own config.ts" would be accurate.
  • Worth adding: the refresh TTLs fall back silently too, so SH_REFRESH_REUSE_GRACE_SECONDS=0 becomes 30 and the grace can't be disabled.

Comment thread docs/glossary.md Outdated

## human gate

A pause point: a leaf or turn stops with `awaiting_approval` and resumes or terminates on

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread docs/glossary.md Outdated

## config bundle

A content-addressed tar of a user's `.claude/skills` and `.claude/commands` that a session or leaf

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread docs/reference/configuration.md Outdated
| `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 |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread docs/reference/configuration.md Outdated
| ------------------------------------------------------- | ----------------- | ------------------------------------------------------------------------------------ |
| `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 |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Comment thread docs/REORG-PLAN.md
| 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 |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>
@pdettori

Copy link
Copy Markdown
Member Author

Addressed in d2f9b4b. Must-fix: SH_MODEL (sessions always use it; only a leaf can override it); the KAGENTI_SANDBOX_NAMESPACE/CONTEXT/CWD, sync-saturation and LEAF_RESULT_TTL_SECONDS rows moved out of the Legacy table, with the KAGENTI_SANDBOX_CWD = sandbox SH_WORKSPACE_ROOT rule; the microVM WORKER_MAX_CONCURRENT has its own row (default 16, fatal on a bad value); the relay per-sandbox token text no longer claims dash conversion, and the token-dir/exec-token clash is described as an attach-time refusal. Suggestions and nits: strict/lenient parsing rewritten (including the refresh-grace-of-0 case), SH_MODEL_API values and the openai-completions-only settings, SH_RELAY_ADDR port matching, exact sandbox-command strip list, installer-time grouping, the multi-tenancy credential scrub (the (unverified) marker is gone), CREDENTIALS_DIRECTORY, the per-request Context Service check, MOCA_WORKLOAD_DELETED_TTL_SECONDS, SH_ALLOW_INSTANCE_TYPE_MISMATCH, MOCACTL_BASE_URL, SH_MAX_COMMITTED_MB wording and the CH-only virtiofsd variables. Glossary: --role=leaf reserved but not implemented, re-entrancy wording, relay exec listener, config-bundle contents, human-gate wording, and a new handler entry. Plan: the leaf row and open question 8 are answered.

The earlier check failure was packages/mocactl/test/use-session.test.tsx (a timing-sensitive tick(5) assertion), unrelated to Markdown; a fresh run is in progress on the new commit.

@ingpaolodettori-dev ingpaolodettori-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@pdettori
pdettori merged commit 5f1fec8 into rossoctl:main Oct 12, 2026
14 checks passed
@pdettori
pdettori deleted the docs/config-reference-pr5a branch October 12, 2026 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants