paths
paths
¶
Platform-aware path resolution for the terok-sandbox subsystems.
Generic namespace resolvers (namespace_state_dir
and friends) and the layered config readers
(read_config_section,
read_config_top_level)
live in terok_util.paths now. This module
re-exports them so the existing
from .paths import namespace_state_dir callsites keep working,
and adds sandbox-specific thin wrappers that bind sandbox's own
subsystems (vault, gate, hooks) to those resolvers.
__all__ = ['config_file_paths', 'config_root', 'namespace_config_dir', 'namespace_config_root', 'namespace_runtime_dir', 'namespace_state_dir', 'plaintext_passphrase_config_path', 'port_registry_dir', 'read_config_section', 'read_config_top_level', 'runtime_root', 'state_root', 'vault_root']
module-attribute
¶
plaintext_passphrase_config_path()
¶
Locate the config file that sets credentials.passphrase (or None).
Walks the same layered files as
read_config_section
and returns the highest-priority path that explicitly sets
passphrase — useful for the visibility WARNING (sandbox#282),
which needs to name the file so the operator can clean it up
before moving to a sealed tier.
Per-file failures (unreadable, malformed YAML, non-mapping
top-level) are swallowed and the walk continues — same fail-silent
contract as read_config_section,
since this helper feeds visibility surfaces (vault status,
sickbay) that must never crash on a bad config layer.
Source code in src/terok_sandbox/paths.py
config_root()
¶
Base directory for sandbox configuration.
Priority: TEROK_SANDBOX_CONFIG_DIR → /etc/terok/sandbox (root)
→ ~/.config/terok/sandbox.
Source code in src/terok_sandbox/paths.py
state_root()
¶
Writable state root for sandbox (tasks, tokens, caches).
Priority: TEROK_SANDBOX_STATE_DIR → /var/lib/terok/sandbox (root)
→ ~/.local/share/terok/sandbox.
Source code in src/terok_sandbox/paths.py
port_registry_dir()
¶
Shared port registry directory (file-based multi-user isolation).
Priority: TEROK_PORT_REGISTRY_DIR env var
→ config.yml paths.port_registry_dir
→ /tmp/terok-ports.
Admins on multi-user hosts can point this at a persistent directory
(e.g. /var/lib/terok/ports) so that port claims survive reboots.
Source code in src/terok_sandbox/paths.py
runtime_root()
¶
Transient runtime directory for sandbox (PID files, sockets).
Priority: TEROK_SANDBOX_RUNTIME_DIR → /run/terok/sandbox (root) →
$XDG_RUNTIME_DIR/terok/sandbox → $XDG_STATE_HOME/terok/sandbox →
~/.local/state/terok/sandbox.
Source code in src/terok_sandbox/paths.py
vault_root()
¶
Shared vault directory used by all terok ecosystem packages.
Priority: TEROK_VAULT_DIR → /var/lib/terok/vault (root)
→ XDG data dir.
Migration: detects the pre-0.8 credentials/ directory and the legacy
TEROK_CREDENTIALS_DIR env var, emitting warnings when found.
Source code in src/terok_sandbox/paths.py
namespace_config_root()
¶
Return the top-level terok config root (namespace, not sandbox-scoped).
Used for cross-package paths like shield profiles that live under
the shared ~/.config/terok/ namespace rather than under any single
package's config directory.