Expand description
Trusty Code’s own configuration and state layout (#5426, epic #2892).
Why: every discovery site used to join the literal .claude/ itself, which
made another product’s directory the source of truth for this one and left
nothing stopping a write INTO it. #5426 makes <project>/.trusty-code/ the
read-preferred and write-only location, with .claude/ (and .open-mpm/)
demoted to compatibility inputs.
What: resolve_project_entry (the one precedence rule: .trusty-code →
.claude → .open-mpm, then a native default) plus the per-entry
agents_dir/skills_dir/plugins_dir/settings_file wrappers;
native_config_dir/check_native_write_target (the write boundary, symlink
escapes included); private_state (~/.trusty-code/, mode 0700); and
import (the deterministic, non-overwriting .claude/ import).
Test: paths::tests::*, paths::private_state::private_state_tests::*,
paths::import::import_tests::*.
Trusty Code’s own configuration and state layout (#5426, epic #2892).
Why: every discovery site in this crate hard-coded .claude/ — the agents
directory, the skills directory, the plugin tree, settings.json, and the
project context file each joined that literal themselves. That made
Claude Code’s directory the source of truth for a product that is not Claude
Code: a clean project could not install or run without a .claude/ tree, and
nothing stopped Trusty Code writing INTO another product’s directory. #5426
inverts the relationship. <project>/.trusty-code/ is where Trusty Code
reads and — critically — the ONLY place it writes; .claude/ (and the older
.open-mpm/) stay readable as compatibility INPUTS, never as write targets.
What: one resolver, resolve_project_entry, that every discovery site
calls instead of joining a literal. It walks SEARCH_ROOTS in order and
reports the winning source (ConfigSource) alongside the path, so
diagnostics can answer “which directory won, and what else was tried?”
without re-deriving the rule. native_config_dir and
check_native_write_target are the write half: a path that is not beneath
<project>/.trusty-code/ — including one that reaches outside it through a
symlink — is refused rather than written. private_state owns the private
mutable half (~/.trusty-code/, mode 0700), and import owns the
deterministic, non-overwriting legacy import from .claude/.
Precedence, and where it is documented. The order is
.trusty-code/ → .claude/ → .open-mpm/, then a default that names
.trusty-code/ even when nothing exists yet. The operator-facing statement
of that rule, including the fallback and warning behaviour, lives in
the crate README — this
module is its implementation, not a second specification.
Test: paths::tests::*, paths::private_state_tests::*,
paths::import_tests::*.
Every link below is written as a crate::paths::… reference definition
rather than a bare [name]. This module carries outer /// docs at its
pub mod paths; declaration in lib.rs as well as these inner //! docs,
and rustdoc resolves the merged block in the scope of its first fragment —
the crate root — where none of these names exist. See #7001.
Modules§
- import
- Deterministic, reversible legacy import from
.claude/into.trusty-code/(#5426, epic #2892). - private_
state - Private mutable state beneath
~/.trusty-code/(#5426, epic #2892). - write_
dir - Pinned, symlink-refusing write handles beneath
<project>/.trusty-code/(#7779).
Structs§
- Resolved
Config - What a project-scoped lookup resolved to, and what it had to skip to get there.
Enums§
- Config
Source - Which configuration root a resolved path came from.
- Entry
Kind - Whether a lookup targets a directory or a single file.
- Write
Target Error - Why a candidate write target was refused.
Constants§
- CLAUDE_
COMPAT_ DIRNAME - Claude Code’s project configuration directory name.
- OPEN_
MPM_ LEGACY_ DIRNAME - The pre-Claude-Code open-mpm configuration directory name.
- SEARCH_
ROOTS - The search order every project-scoped lookup walks, highest precedence first.
- SECRET_
KEY_ EXEMPTIONS - Whole keys that name a COUNT rather than a credential.
- SECRET_
KEY_ HINTS - Normalised key words whose presence marks a value as secret-bearing.
- SETTINGS_
FILENAME - The project-settings filename, shared by both configuration roots.
- TRUSTY_
CODE_ DIRNAME - Trusty Code’s own project configuration directory name.
Functions§
- agents_
dir - The agents directory for a project root.
- check_
native_ write_ target - Refuse any write target that is not genuinely beneath
<project>/.trusty-code/. - find_
secret_ key - Find the first secret-bearing key path in a JSON value, if any.
- is_
secret_ key - Whether one JSON key names a credential.
- native_
child - A path beneath
native_config_dir. - native_
config_ dir - Trusty Code’s own project configuration directory — the ONLY write target.
- plugins_
dir - The plugins directory for a project root.
- resolve_
project_ entry - Resolve one project-scoped configuration entry across
SEARCH_ROOTS. - settings_
file - The
settings.jsonfile for a project root. - skills_
dir - The skills directory for a project root.