f/hold docs

Environment, mounts, and networks

This document describes the active runtime. Docker placement is defined in packages/skeleton/system/stack/stack.compose.yml; host-side ACA placement is in packages/lib/src/hosting/azure-template.ts. Both use the same published image.

The released runtime uses OpenCode 2. See the qualification report for verified native settings, persistence and API behavior; each release retains its own gates.

Host layout

Hosting connections and recent instance locators belong to the CLI/Admin host, in $XDG_CONFIG_HOME/fhold/hosting.json (default ~/.config/fhold/hosting.json). The same file holds small target-bound non-secret deployment drafts and operation continuations, not full Azure templates or credentials. These are not backup members. SSH paths resolve on the Docker host; ACA resource IDs are not filesystem homes. The implicit local workflow is unchanged. See hosted management.

SSH management executables live outside instance homes at ${XDG_CACHE_HOME:-$HOME/.cache}/fhold/management/<sha256>/fhold on the remote account. CLI/Admin ship both Linux architectures and cache exact bundled bytes atomically; operator-installed CLIs are neither consulted nor changed. Cached tools contain the matching managed Skeleton, not instance state or credentials. Old hashes remain until manually removed when unused. Preparing a connection does not update containers, managed home files or runtime intent. No container mount or privilege changes are introduced.

New named homes live under ~/fhold/instances/<name>; Admin's unnamed default is ~/fhold/instances/default. CLI --name/-n selects a directory name under that root or an absolute path. If absent, explicit FH_HOME takes precedence over cwd. The CLI resolves that choice once for every command and its child processes; users do not need to export a variable. Admin uses its default/recent home or a selected custom folder. Default changes never move an existing home; select its original path explicitly to continue managing it. ~/fhold can contain sibling backups/, docs/ or other local directories; only the selected instance directory is managed or backed up.

Manual full-instance export/import includes all six trees below (and extra home-owned files), while containers are stopped. It preserves native sessions, credentials and saved identity. Portable content deliberately omits runtime authority. Neither captures sources outside this folder or rolls back external checkpoint storage; see import/export.

The following paths are relative to that instance's home, not ~/fhold:

Host path Owner Purpose
system/ fhold release Exact managed harness policies, OpenCode assets and Compose files
config/ Operator Seed-once user preferences, AKM, Guardian and Compose settings; explicit custom policy overrides
config/recovery/include.json Operator Same-instance recovery selection/mount policy, not a portable backup member
knowledge/ Operator and AKM Knowledge, task sources, scoped user environment, provider auth
workspace/ Operator Trusted local agent workspace
state/stack.json Control plane Versioned stack intent
state/stack.env Control plane Non-secret values derived from StackConfig intent
state/installation.json Control plane Generated release/managed-image provenance, never an identity fallback
state/applied-runtime.json Control plane Private startup-input digest and pending-activation flag; no secret values; shared by CLI/Admin restart status
state/credentials/ Control plane/operator Named Guardian key directories plus derived key-free registry
state/portal-credentials/ Control plane Derived, adapter-scoped runtime keyrings
config/guardian/oauth.json Operator OAuth resource-server settings; disabled by default
config/guardian/oauth-identities.json Operator Exact OAuth issuer/subject to credential maps
state/secrets/ Control plane/operator File-backed runtime credentials
data/ Containers Assistant home, AKM state, portal SQLite files, audit logs
data/recovery/ Recovery worker Private destination/identity-scoped receipts and staging, never portable content

Updates replace only the allowlisted managed files in seed.ts. They seed operator files only when absent and never synchronize or delete whole directories.

Native system policies under system/assistant, system/codex and system/claude are release-owned and mounted read-only at the harnesses' system paths. Old config policy files are untouched and unreferenced unless a custom overlay explicitly mounts them; no migration or automatic compatibility layer is supplied. See managed harness configuration for exact mounts, task permissions and standalone deployment inputs.

Assistant OS keyring

Every Assistant edition includes GNOME Keyring's native Secret Service provider, secret-tool, and a private D-Bus session. They run as the assistant's non-root identity, with only the secrets component enabled. OpenCode tools, scheduled processes, included native harnesses and ordinary docker exec sessions inherit the same bus address. Applications still choose their own native credential backend; installing Secret Service does not rewrite AKM or harness authentication settings.

CLI/Admin Docker and SSH installs create an independent unlock secret at state/secrets/fhold_keyring_password (mode 0600), preserved on update and mounted read-only as /run/secrets/assistant_keyring_password. New ACA installs use an independent native Container Apps secret mounted at /run/secrets/keyring-password. These managed deployments use an encrypted persistent native login keyring. Keep the unlock secret separately from Assistant recovery checkpoints.

Standalone images without FH_KEYRING_PASSWORD_FILE use a session-only collection on new homes: usable without setup, but entries disappear when the container restarts. Existing persistent default collections are preserved, including locked ones. fhold-keyring status checks the actual collection's lock state without creating or unlocking it. An unavailable or locked keyring is reported as degraded without stopping the assistant.

For standalone encrypted persistence, create an unlock-password file outside the Assistant home and mount it read-only, then set FH_KEYRING_PASSWORD_FILE to its container path. Supply the exact password bytes (for example, write with printf '%s'); it is not the OpenCode server password. A new native login keyring is created and unlocked on boot; an existing one requires its original password. Neither a missing nor a wrong password resets existing credentials or enables plaintext persistence. Keep the unlock secret separately from keyring files and recovery checkpoints.

For an operator-supplied replacement secret, merge this into config/stack/custom.compose.yml (normal managed installs need no overlay):

services:
  assistant:
    environment:
      FH_KEYRING_PASSWORD_FILE: /run/secrets/assistant_keyring_password
    volumes:
      - /absolute/private/keyring-password:/run/secrets/assistant_keyring_password:ro

The file must be readable by the configured Assistant UID. Native encrypted files live in $HOME/.local/share/keyrings, covered by default Assistant recovery and stopped full-instance export. Restores require the separately retained password; session-only secrets are not backup members. Do not mount the host desktop bus or keyring into Assistant. The default socket is /tmp/fhold-session/bus; if overriding XDG_RUNTIME_DIR, also set a matching DBUS_SESSION_BUS_ADDRESS=unix:path=.../bus.

Host-side Compose variables

The control plane writes or preserves these non-secret values in state/stack.env:

Variable Meaning
FH_HOME Absolute stack home
FH_PROJECT_NAME Persisted instance name, or stable per-canonical-home default, from deployment intent
FH_INSTANCE_HOSTNAME Derived Assistant OS hostname from that same project name; not another user setting
FH_OPENCODE_PREFERENCES_FILE Derived native write target: existing opencode.jsonc, otherwise opencode.json, otherwise config.json; fresh homes seed opencode.json. Not a user setting.
FH_UID, FH_GID Non-root container identity
FH_IMAGE_NAMESPACE Image namespace; default fwdslsh (public Docker Hub); fhold selects local builds
FH_STACK_CONFIG_VERSION Derived intent schema version
FH_ENABLED_ADDONS Derived profiles: gateway,discord,slack
FH_ASSISTANT_BIND_ADDRESS Derived native OpenCode host bind
FH_ASSISTANT_PORT Derived native OpenCode host port
FH_TIMEZONE Derived schedule timezone. Learning is AKM's own setting (akm setup --learning), not a Compose variable.
FH_CODEX_REMOTE, FH_CLAUDE_REMOTE Independent native supervisor startup switches, both default 1; optional 0 keeps a worker off without removing account state. Native sign-in/consent is still required.
FH_CODEX_SANDBOX Native Codex isolation: workspace-write default, read-only, or explicit danger-full-access container isolation; task approvals follow native policy
FH_GUARDIAN_BIND_ADDRESS Derived Guardian host bind
FH_GUARDIAN_PORT Derived Guardian host port
DISCORD_ALLOWED_GUILDS, DISCORD_ALLOWED_ROLES Derived Discord scope
DISCORD_ALLOWED_USERS, DISCORD_BLOCKED_USERS Derived Discord user scope
SLACK_ALLOWED_CHANNELS Derived Slack channel scope
SLACK_ALLOWED_USERS, SLACK_BLOCKED_USERS Derived Slack user scope
FH_SETUP_COMPLETE Install completion marker
FH_RECOVERY_URL, FH_INSTANCE_ID Derived recovery enable/destination and stable identity; file destinations use /recovery inside the container
FH_RECOVERY_DIRECTORY Exact operator backup bind root; off/Blob use an unused private placeholder under state/
FH_RECOVERY_INTERVAL_SECONDS, FH_RECOVERY_MAX_UNSAVED_SECONDS, FH_RECOVERY_OPERATION_TIMEOUT_SECONDS Capture cadence, overdue-backup warning threshold and operation deadline from recovery intent
FH_RECOVERY_INCLUDE_FILE, FH_RECOVERY_STATE_DIR Fixed policy and namespace-scoped private-state container locations
FH_RECOVERY_CREDENTIAL_FILE, FH_RECOVERY_CLIENT_ID Private file path or optional managed identity UUID, never a credential value
FH_ASSISTANT_STOP_GRACE Derived complete writer/final-recovery shutdown budget

Project, namespace and image pins belong to deployment in StackConfig. FH_ASSISTANT_VERSION, FH_GUARDIAN_VERSION and FH_PORTAL_VERSION are derived Compose inputs. Managed image defaults advance together on update; explicit pins survive. state/installation.json records verified build-release provenance, not product identity; StackConfig's product: "fhold" remains required.

GUARDIAN_ALLOWED_ORIGINS, GUARDIAN_MODERATION_TIMEOUT_MS, and GUARDIAN_ASSISTANT_TIMEOUT_MS are advanced Guardian settings. They may be passed to the host command or preserved in stack.env; neither may contain a credential. The escalation threshold is a managed security value and cannot be raised through the user overlay.

Only fhold, Guardian, Discord, and Slack interpolation keys from stack.env are copied into the Docker client process. Process-control values such as DOCKER_HOST, PATH, and COMPOSE_FILE are never trusted from that file. The same sanitized environment is used for preflight and activation.

File secrets

Host file under state/secrets/ Consumers
fhold_opencode_password Assistant, Guardian
fhold_guardian_handle_key Guardian handle encryption and ownership proofs
discord_bot_token Discord adapter
slack_bot_token Slack adapter
slack_app_token Slack adapter
fhold_recovery_connection_string Assistant recovery only; private standard Blob credential file

Named Guardian keys live at state/credentials/<username>/key; generated keys contain 32 random bytes encoded as base64url. Guardian mounts the complete credential store read-only. Each portal mounts only its generated keyring, containing the fallback and credentials referenced by that portal's config/portal/<adapter>/credentials.json user map. Bot-token files are created empty and must be filled through fhold portal token or Admin before their portal is enabled. Other secrets are mounted through Compose secrets; no secret value belongs in an environment variable.

OpenCode v2 owns provider credentials in its native SQLite database under data/assistant/.local/share/opencode/. Guardian uses Assistant's tool-free native generation API and receives no provider credentials. The old knowledge/secrets/auth.json is mounted at OpenCode's data-directory auth.json. OpenCode imports it once, natively, only while migrating a database created before its legacy-credential migration; a new database ignores it. fhold never converts it, and it is not the active v2 credential store.

Assistant

Assistant joins only agent_net and publishes the native OpenCode server as ${FH_ASSISTANT_BIND_ADDRESS:-127.0.0.1}:${FH_ASSISTANT_PORT:-3810}:4096. The values are derived from StackConfig and may not be changed by the custom Compose overlay. Any non-loopback bind is an explicit operator choice and bypasses Guardian.

Host source Container target Mode
data/assistant /home/fhold read/write
config/assistant /home/fhold/.config/opencode read/write native user settings/plugins directory; supports atomic editor saves
knowledge/secrets/auth.json /home/fhold/.local/share/opencode/auth.json Legacy file read only by OpenCode's own one-time migration
system/assistant /etc/opencode read-only
system/codex/config.toml /etc/codex/config.toml read-only individual file
system/codex/requirements.toml /etc/codex/requirements.toml read-only individual file
system/claude/managed-settings.json /etc/claude-code/managed-settings.json read-only individual file
config/akm /etc/akm read-write; native AKM settings and task activation, no delegated ingress credentials
knowledge /stash read/write
data/akm/cache /opt/akm/cache read/write
data/akm/data /opt/akm/data read/write
workspace /work read/write

Assistant's native API credential is the OpenCode server password. It receives no Guardian, portal, bot, Docker, or host-admin credential. Optional recovery uses a separate storage-only connection-string file; it is not an ingress credential and its value never appears in environment settings.

Admin makes narrow native provider/model preference edits and verifies the effective result through OpenCode's authenticated API. Native file watching applies ordinary and atomic saves; no explicit reload or process/container restart is needed. Managed plugins and system policy remain read-only. OpenCode's policy is system/assistant/opencode.json, with no default nested mount hiding it. Individual Codex/Claude mounts preserve the image's /etc/codex/hooks.json and /etc/claude-code/managed-settings.d/10-fhold.json. OPENCODE_CONFIG selects the derived preferred filename inside the writable user-config directory. Selecting a different filename requires fhold restart to change that startup environment value; editing the selected file or a local user plugin does not. Container changes and read-only policy replacement still use the normal persistent pending-restart/apply workflow.

The OS account and home are fhold and /home/fhold; native OpenCode Basic authentication uses username opencode. /fhold-bundle is an image-baked, root-owned read-only AKM skills source, shared with the native fhold plugins. Custom AKM configuration is preserved; it does not prevent the built-in skills from being available through the native harness integrations.

FH_KEEPALIVE_URL optionally enables conditional HTTP heartbeats using the existing scheduler, including when user schedules are disabled. Authentication is opt-in with FH_KEEPALIVE_AUTH=opencode or a mounted FH_KEEPALIVE_AUTHORIZATION_FILE. URLs and credentials are never logged. See harness plugins and keep-alive for behavior, native approval, custom deployment configuration and the best-effort boundary.

FH_OPENCODE_CORS optionally lists extra browser origins that OpenCode accepts, comma-separated, for a web UI on another origin, such as one attaching native client-MCP tools. Each entry is passed to opencode serve as --cors and must be an exact http or https origin as browsers send it: lowercase host, no path, trailing slash, wildcard, credentials or default port (for example https://ui.example.com). One invalid entry discards the list and is reported as an invalid runtime setting; OpenCode then allows only its default origins (localhost, 127.0.0.1, its desktop app and *.opencode.ai). A listed origin can call the whole authenticated OpenCode API from a browser, not only client-MCP, so list only origins you trust as much as OpenCode itself. OpenCode's own authentication and single-use connection tickets still apply. Set it in the deployment's container environment or a custom Compose overlay.

Invalid optional settings log their names and degrade only the affected feature. Malformed scheduler intent disables scheduling; numeric recovery/shutdown tuning falls back to its documented defaults. Core health remains successful when the authenticated agent is usable. Docker's health output carries optional-feature warnings into CLI status and Admin; unavailable diagnostics never restart the container. Authentication, safe restore and actual exclusive ownership remain required.

Managed recovery additionally binds config/recovery/include.json read-only at /run/fhold-recovery/include.json, data/recovery read/write at /run/fhold-recovery-state, and the exact selected private backup directory at /recovery. The destination must be outside the instance home and cannot be its parent; links are refused before saving. Off/Blob mode uses an empty private bind placeholder. Existing operator directories are not chmodded. Operators own custom overlays and their effects. The native recovery engine still validates checkpoint identity, integrity and ownership. No new service is introduced.

Standalone recovery optionally uses externally supplied FH_RECOVERY_INCLUDE_FILE for additional paths/SQLite and versioned mount policy. Explicit exclusions, required external mounts and opt-in network discovery do not change normal Compose volume coverage. SQLite stays local; the recovery engine neither provisions nor restores independent mounts. See Assistant recovery for the schema, private inspection and stopped-writer policy transition.

ACA placement

Fresh ACA installation keeps /home/fhold, /work, /stash, /opt/akm/data and /etc/akm on the image-owned writable container layer. Any container recreation can lose that layer; the existing recovery worker restores its last accepted checkpoint before starting writers. New installs stage checkpoints locally and copy completed files to a dedicated Azure Files SMB backup share at /recovery. The share is never a live SQLite mount and does not need hard links. Replica-scoped EmptyDir retention is not selected by default and was not qualified in ACA; no startup chown/init workaround is added.

The provider creates or reuses an environment/storage account, creates a private per-instance SMB backup share, and registers it with the ACA environment. ARM supplies the account key directly to the native environment storage resource; it is not placed in Assistant environment variables or local preferences. The finite initialization Job and Assistant mount the same share. Explicit recovery: "azblob" retains the deprecated Blob container/user-assigned identity path, which remains supported. Existing deployments are not migrated. The password and recovery policy use ordinary ACA secret-file mounts. The generated runtime receives TZ (not Docker's FH_TIMEZONE intent), stable FH_INSTANCE_ID and the existing recovery variables. Native account files stay native and are checkpointed, not copied into Azure environment settings.

Optional existing environment Files storage can mount independent project folders. Those paths are required external mounts and excluded from recovery. The provider does not move project files into them. The dedicated backup share is separate from these independent project mounts. Live native databases stay local. Existing deployment mounts, secrets and identities remain unchanged unless the user requests the corresponding supported edit. Cloud full export/import is not implemented. See hosting and qualification limits.

Optional native Codex/Claude Code remote workers inherit the same nonroot container boundary, with no additional mounts or ports. Their own native sign-in state persists under data/assistant; it is not a delegated Guardian credential or portable OpenCode provider auth. Child environments omit OpenCode server credentials and ingress settings. The mounted filesystem remains trusted native agent access, not a Guardian policy boundary. See native remote access.

Guardian

Guardian joins agent_net and ingress_net. It publishes ${FH_GUARDIAN_BIND_ADDRESS:-127.0.0.1}:${FH_GUARDIAN_PORT:-3830}:8080 only when an ingress profile is enabled.

Host source Container target Mode
data/logs /opt/fhold/logs read/write
config/guardian Guardian settings and moderator model selection read-only
workspace /work read-only
state/credentials /run/fhold-credentials read-only

Guardian receives the named credential store, handle-signing key, and upstream OpenCode password. It has no persistent application database or writable copy of provider credentials. Each registry record selects a fixed managed Assistant agent profile. Guardian reads files through its own read-only workspace mount so MCP workspace access can reject canonical paths and file descriptors that escape /work; it never delegates that authorization decision to OpenCode's native file API.

The read-only config/guardian mount also carries oauth.json and oauth-identities.json. Both are mode 0600 operator files. They contain public identity-provider metadata and identity-to-credential names, never an OAuth token or client secret. Guardian reads identity mappings per request; resource-server configuration changes require a restart.

Authenticated, admitted MCP requests use Bun's native per-request idle-timeout override: quiet streams remain open while tools run. Ordinary HTTP and rejected requests retain their usual timeout. Body limits, authentication, rate limits and bounded native operations remain unchanged; no artificial progress is generated.

Portal adapters

Discord and Slack join only ingress_net, publish no host ports, and call http://guardian:8080/mcp. Each gets only its generated named-credential keyring, platform credential files, and one adapter-specific data/portal/<adapter> volume containing SQLite continuity state.

Container hardening

All four managed services:

Optional fhold doctor diagnostics check the resolved managed file plus user overlay only for the shipped security defaults: root users on the product services, privileged containers, added capabilities, host network/PID/IPC namespaces or devices, container-runtime mounts (such as docker.sock) on any service, any service other than Assistant and Guardian on agent_net (or other than Guardian bridging it to ingress_net), and Compose secrets that are not files inside FH_HOME. These are advisory diagnostics, not start/restart/update policy gates. Operators own custom overlay behavior. Native Compose parsing, instance targeting and actual recovery integrity/ownership checks still apply.