Expand description
Issue #88: project-root detection and palace-slug enforcement.
Why: prevents unbounded palace creation by anchoring palace names to the
canonical slug of the project directory that contains the CWD, or to the
personal sentinel for non-project contexts.
What: exports find_project_root, project_slug_at, project_slug,
validate_palace_name, PERSONAL_PALACE, and PROJECT_MARKERS.
Test: see unit tests inside this module.
Project-root detection, palace-slug derivation, and .trusty-tools/ pin
file management (issue #88 + Phase 1 of the .trusty-tools/ convention).
Why: unbounded palace creation leads to orphaned namespaces that no longer
correspond to any project on disk. Anchoring palace names to a stable,
filesystem-derived slug ensures each project gets exactly one palace and
makes “which palace am I in?” predictable from the working directory alone.
The personal palace is the single sanctioned exception for non-project
contexts (global notes, one-off sessions).
Sub-modules:
detection:find_project_root,PROJECT_MARKERS,TRUSTY_TOOLS_DIR,PERSONAL_PALACE,is_unsafe_pin_location.pin_file:ProjectPin,PIN_SCHEMA_VERSION,PIN_FILE_REL,read_project_pin,write_project_pin,project_slug_at,project_slug_at_readonly,project_slug,project_slug_from_basename.validation:validate_palace_name.
Test: project_slug_finds_git_root, project_slug_returns_none_without_markers,
project_slug_uses_first_ancestor_marker,
project_slug_personal_always_allowed,
pin_file_read_when_present, absent_pin_writes_computed_slug,
renamed_dir_with_pin_resolves_to_original_slug,
trusty_tools_dir_is_project_marker,
lazy_write_non_fatal_on_readonly_dir.
Structs§
- Project
Pin - Serialisable schema for
.trusty-tools/trusty-memory.yaml.
Constants§
- PERSONAL_
PALACE - Sentinel palace name that is always valid regardless of project context.
- PIN_
FILE_ REL - Relative path of the pin file within a project root.
- PIN_
SCHEMA_ VERSION - Schema version for
.trusty-tools/trusty-memory.yaml. - PROJECT_
MARKERS - File names that mark a directory as a project root.
- TRUSTY_
TOOLS_ DIR - The
.trusty-tools/directory name (used as a project marker).
Functions§
- find_
project_ root - Walk upward from
startand return the first ancestor directory (inclusive) that contains at least one project marker. - pinned_
slug_ at - Return the pinned palace slug for the project at or above
start, and ONLY when a committed pin file exists — never the basename fallback. - project_
slug - Derive a palace slug for the current working directory.
- project_
slug_ at - Derive a palace slug from the project root found at or above
start. - project_
slug_ at_ readonly - Derive a palace slug from the project root found at or above
start, WITHOUT the lazy-write side-effect. - project_
slug_ from_ basename - Compute the palace slug purely from the directory basename (the pre-Phase-1 logic, now extracted for composability).
- read_
project_ pin - Read the palace pin from
.trusty-tools/trusty-memory.yamlatroot. - validate_
palace_ name - Validate a proposed palace name against project-slug enforcement rules.
- write_
project_ pin - Write a palace pin to
.trusty-tools/trusty-memory.yamlatroot.