Skip to main content

Module private_state

Module private_state 

Source
Expand description

Private mutable state beneath ~/.trusty-code/ (#5426, epic #2892).

Why: transcripts, logs, compression telemetry, daemon discovery files, and channel cursors are per-user runtime state, not project configuration. They were already landing in ~/.trusty-code via workstreams::default_data_dir, but nothing named that directory as PRIVATE and nothing set its mode, so a default-umask machine left 0755 — world-readable transcripts of whatever the harness was asked to work on.

What: private_state_dir_at is the hermetic resolver (an explicit $HOME, so tests never touch a real home directory and never mutate the environment); private_state_dir is the production wrapper. ensure_private_state_dir_at creates the tree and TIGHTENS the mode to 0700 on Unix — including on a directory that already existed with a permissive mode, since the common case is an upgrade over an existing ~/.trusty-code. is_restrictive is the predicate the tests and the tcode config paths diagnostic both assert on.

Test: paths::private_state_tests::*.

Constants§

NON_OWNER_BITS
The permission bits that must be clear for a directory to count as private.
PRIVATE_DIR_MODE
The Unix mode private state is held at: owner-only, no group, no other.

Functions§

ensure_private_state_dir
Create and tighten the production ~/.trusty-code.
ensure_private_state_dir_at
Create the private state directory and tighten it to owner-only.
is_restrictive
Whether a directory’s permissions keep it private to its owner.
private_state_dir
Resolve the production private state directory, ~/.trusty-code.
private_state_dir_at
Resolve the private state directory beneath an explicit home directory.