Imports:
  - Types:
      - parse_env_yaml
    Usages:
      - env-variables
    From: goga/config/yaml

Usages:
  convention: .goga/usages/conventions.md

Annotations: |
  The `convention` practice is used for:
  - Working with the codebase
  - Organizing the REPL development cycle
  - Debugging and testing
  - Organizing the test infrastructure
  - Understanding the general principles and rules of
    development and testing in the project

  This cell owns the read side of the tool-config standard: the
  standardized path composition of one tool config file and its raw
  passthrough load. The write side buffers verbatim filenames under
  the same path standard; this loader reads them back with no
  interpretation — the content belongs to the tool that owns it.
  Parse a present tool config file through `parse_env_yaml` — the
  environment-aware loader of the configuration family (per
  `env-variables`). The read side stays a raw passthrough:
  !ENV NAME scalars resolve to plain strings at load time, and the
  content belongs to the tool that owns it — no models, no structural
  expectations, no validation. Use relative imports.

---

"load_tool_config(tool: str, filename: str, root: Path | None = None) -> data: object | None":
  location: loader.py
  annotations: |
    Load one tool config file — the read-side counterpart of the
    tool-config write standard.

    `tool`: the tool identity — the directory name under .goga/tools
    `filename`: the config file name, verbatim with extension — exact
                match
    `root`: optional root-directory override for tests; None uses the
            project-root anchor of the configuration loaders
    `data`: the raw parsed content as-is — a mapping, a string, a
            list, whatever the YAML parses to — or None when the file
            is absent

    Apply the `convention` practice for the data-model rules and
    intra-package imports.
    Parse through `parse_env_yaml` (per `env-variables`)
    — no local tag handling.

    Algorithm:
    1. Compose the path <root>/.goga/tools/<tool>/<filename> with
       `filename` taken verbatim
    2. A `filename` that is empty, carries a path separator, or equals
       . or .. — a non-flat name segment — is a clean error before any read
    3. An absent file returns None — absence is the normal state of a
       tool config
    4. A present file parses via `parse_env_yaml` — the
       environment-aware loader (!ENV NAME scalars
       resolve to plain strings at load time, unset resolves to ""); the
       raw value returns as-is — yaml errors, including constructor
       errors of malformed tag use, propagate unchanged through the
       library's error machinery

    Requirements:
    - Path standardization only — the same standard as the write side
    - No content models, no structural expectations, no validation
    - No merging with any configuration layer, no caching
    - Environment references resolve at load time — a tool config file
      may carry !ENV NAME scalars under the same rule as the
      project configuration; the resolved strings flow into the raw value
      the consuming tool interprets

    Constraints:
    - Do not interpret the content — interpreting is the consuming
      tool's responsibility
    - Do not resolve !ENV references in this cell — loading goes
      through `parse_env_yaml`; no local tag handling exists

---

Author: Goga
CreatedAt: 29/09/26
Description: |
  Owner of the read side of the tool-config standard.
