Skip to main content

kahndor

    ## Project overview
    
    kahndor is the shared configuration and logging utility layer for the
    Solutions Brewer stack. It loads YAML and related configuration formats,
    resolves includes/overrides and templated values, caches results, and
    provides the `Logma` logging facade used across the ecosystem. kahndor
    is intentionally lightweight and dependency-minimal — every other
    SB-stack package depends on it.
    
    ## Features
    
    - **Cascade config loading** — load, merge, and override YAML files
      with the special `<(INCL)>` token for file inclusion.
    - **Memoization cache** — LRU-bounded in-memory cache with optional
      on-disk persistence, exposed via `kahndor.cache.Cache`.
    - **Logma logging** — structured, agent-aware logging facade via
      `kahndor.logma.Logma`.
    - **CLI** — `kahndor status`, `kahndor cache --stats/--clear`, plus
      utility and logging commands.
    - **Zero-config defaults** — sensible defaults baked in; overrides
      via `<project>/_data_/*.yaml`.
    
    ## Installation
    
    ```bash
    pip install kahndor
    ```
    
    From source:
    
    ```bash
    git clone https://github.com/solubrew/kahndor.git
    cd kahndor
    pip install -e ".[dev]"
    ```
    
    Runtime dependencies: `PyYAML`. Development: `pytest`, `pytest-asyncio`,
    `pytest-json-report`, `pytest-cov`, `ruff`.
    
    ## Quick start
    
    Load and merge a YAML configuration:
    
    ```python
    import kahndor
    
    cfg = kahndor.Instruct("config.yaml").select("ConfigA").override("config_b.yaml")
    print(cfg.dikt)
    ```
    
    Include another YAML file inline using the `<(INCL)>` token:
    
    ```yaml
    # config.yaml
    database:
        host: localhost
        port: 5432
        settings: <(INCL) settings.yaml>
    ```
    
    ```yaml
    # settings.yaml
    timeout: 30
    retry: 3
    ```
    
    Result:
    
    ```python
    {'database': {'host': 'localhost', 'port': 5432,
                  'settings': {'timeout': 30, 'retry': 3}}}
    ```
    
    Use the cache:
    
    ```python
    from kahndor.cache import Cache
    
    cache = Cache(max_memory_items=100)
    cache.set("user", "alice", {"name": "Alice", "role": "admin"})
    print(cache.get("user", "alice"))
    ```
    
    Use the logger:
    
    ```python
    from kahndor.logma import Logma
    
    logma = Logma(__name__)
    logma.info("kahndor ready")
    logma.error("something went wrong", extra={"agent": "arthr"})
    ```
    
    Use the CLI:
    
    ```bash
    kahndor status
    kahndor cache --stats
    kahndor --agent arthr cache --clear
    ```
    
    ## Usage
    
    ### Config cascade with `<(INCL)>`
    
    kahndor treats `<(INCL)>` specially during YAML load. The token is
    replaced with the contents of the referenced file (or kahndor
    attribute path, prefixed with `<(INCL)>`), enabling nested configs
    that read like prose:
    
    ```yaml
    paths:
        data: <(INCL) paths/data.yaml
        logs: <(INCL) paths/logs.yaml
    ```
    
    ### Selection and override
    
    ```python
    import kahndor
    
    # Load config.yaml, select the "production" section, override
    # values from prod-overrides.yaml.
    cfg = kahndor.Instruct("config.yaml") \
            .select("production") \
            .override("prod-overrides.yaml")
    ```
    
    ### Agent-aware logging
    
    ```python
    import os
    os.environ["KAHNDOR_AGENT"] = "arthr"
    
    from kahndor.logma import Logma
    logma = Logma(__name__)
    logma.info("started", extra={"component": "cli"})
    ```
    
    ## Development
    
    To set up a development environment and run the test suite locally:
    
    ```bash
    # Clone and install in editable mode with dev extras
    git clone https://github.com/solubrew/kahndor.git
    cd kahndor
    python -m pip install --upgrade pip
    pip install -e ".[dev]"
    pip install pytest pytest-asyncio pytest-json-report pytest-cov
    
    # Run the test suite
    pytest tests/ -v
    
    # Lint (matches CI)
    ruff check kahndor/
    
    # Confirm the package imports cleanly
    python -c "import kahndor; print(kahndor.__version__)"
    
    # Run the CLI
    kahndor status
    
    # Run the compliance audit
    python -m sasquatch.cli analyze -p . --skip-pii-secrets
    ```
    
    Before opening a pull request:
    
    ```bash
    pytest tests/ -v              # all tests pass
    ruff check kahndor/           # no lint errors
    sasquatch analyze -p . --skip-pii-secrets    # audit score >= 90%
    ```
    
    ## License
    
    kahndor is licensed under the MIT License. See the [LICENSE](LICENSE) file
    for more details.
    
    ## Contact
    
    For questions or suggestions, contact
    [solubrew@solutionsbrewer.com](mailto:solubrew@solutionsbrewer.com).

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kahndor-0.0.1.post3-cp312-cp312-manylinux_2_39_x86_64.whl (74.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.39+ x86-64

File details

Details for the file kahndor-0.0.1.post3-cp312-cp312-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for kahndor-0.0.1.post3-cp312-cp312-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 ffd3c9209c415cf979b1558143d63953dbcbd820237494e57313ee79bd2f1324
MD5 6a9473248065ddc9398c857519ca7a22
BLAKE2b-256 71cc3ca47d105174ab75a56ffb111c4ac88b79eef2aed3665121aec9ba71317f

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.1.post3 This release

1 file

0.0.1.post2

1 file

0.0.1.post1

1 file

0.0.1

1 file

0.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page