Skip to content

paths

diapason.learning.spec_search.storage.paths

Filesystem path resolution for the spec-search subsystem.

The keystone of artifact isolation (spec §11): the resolved spec-search root must NEVER be inside the Diapason source tree. resolve_spec_search_root walks up from this module's __file__ looking for a pyproject.toml that identifies the Diapason source root, then refuses to operate if the resolved root is inside it. Defense in depth — if a user accidentally points DIAPASON_HOME at the repo, the system fails loudly instead of silently writing artifacts into the working tree.

ConfigurationError

Bases: RuntimeError

Raised when the resolved home directory would violate isolation guarantees.

ensure_spec_search_dirs()

Create the spec-search directory layout if missing.

Returns the spec-search root. Creates sessions/, benchmarks/, benchmarks/reference_outputs/, and pending_review/ underneath it, all with restrictive 0o700 permissions via secure_mkdir.

resolve_spec_search_root()

Return the absolute path of the spec-search root directory.

The root is $DIAPASON_HOME/learning (or ~/.diapason/learning by default). Raises ConfigurationError if the resolved path lies inside the Diapason source tree, to prevent dev artifacts from leaking into the repo.