| Name | Type | Description |
|---|---|---|
state_dir | Path | None | Default: NoneDirectory to create, defaulting to the active profile's.
|
Create a state directory and restrict it to its owner.
The state directory holds sessions.db and history.jsonl, which hold
full conversation content and are written with the default file mode. The
directory permissions are the only thing that keeps another local user out,
so every creator must go through this function rather than a bare mkdir.
Note:
Failures are logged, never raised. mkdir can fail on a read-only or
full filesystem, and chmod is routinely refused on CIFS/exFAT mounts.
Neither is a reason to abort the launch that needed the directory.
On Windows the chmod step is skipped. POSIX mode bits do not restrict
access there, so the directory keeps the ACL it inherits from its
parent and this function adds no protection of its own.