Heurix (hx)
Deterministic Codebase Scanner & Automated YAML Synthesizer
100% Deterministic • Offline-Capable • Deep Heuristic Analysis • Non-Destructive AST Smart Merge
Overview
Heurix (CLI alias: hx) is an offline-capable, pure-logic codebase scanner and infrastructure YAML synthesizer. It inspects .gitignore-filtered repository files once via RepoIndexer into a strongly-typed Pydantic ProjectContext Intermediate Representation (IR), cross-references lockfiles, manifests, Dockerfiles, compose configurations, .env templates, and cloud deployment targets, and deterministically synthesizes schema-validated CI/CD workflows, Dependabot maintenance files, and Kubernetes manifests.
Why Pure Logic?
- 100% Deterministic & Reproducible: No LLM hallucinations or non-determinism; vetted action pins with least-privilege
permissions: contents: readand customizable action versions/commit SHAs via.heurix.toml. - Instantaneous & Offline: Runs locally in milliseconds without network calls or API keys. The one exception is
hx pin, which you run explicitly to resolve action tags to commit SHAs. - Non-Destructive AST Smart Merge: Traverses
ruamel.yamlASTs recursively to preserve comments, custom user jobs, triggers, and any step tagged with# @heurix:preserveor# @autoyaml:preserveacross repeated runs. - Pre-Flight Schema Validation: Validates single- and multi-document YAML outputs against JSON schemas (
PreflightValidator) before writing a single byte to disk, with symlink/path-traversal protection. - Structural Drift Detection:
hx checkparses existing CI workflows and Dependabot configs structurally to detect missing backing services, pinned runtime mismatches, or outdated package manager setup.
Documentation & Interactive Playground
- Web Docs & Live Playground:
https://naveen-boddepalli.github.io/heurix/ - LLM Context Index:
llms.txt(andhttps://naveen-boddepalli.github.io/heurix/llms-full.txt) - Guides & Reference Docs (
docs/):docs/getting-started.md— installation, first scan, and.heurix.tomloverridesdocs/heuristics.md— full matrix for all 8 ecosystem detectorsdocs/cli-reference.md— commands, flags, interactive prompts, and exit codesdocs/smart-merge.md—ruamel.yamlAST merging and# @heurix:preservedocs/kubernetes-and-ci.md— synthesized GitHub Actions, Dependabot, andk8s/outputsdocs/drift-detection.md— runninghx checkin CI and pre-commit hooksdocs/architecture.md— unidirectional 5-layer IR architecture
How Heurix Compares
| Tool | What it does | How Heurix relates |
|---|---|---|
| GitHub starter workflows | Language templates offered in the Actions tab, which you edit by hand | hx generate fills in runtime versions, the package manager, backing services and env vars from the repo, and re-running it merges into your edited file instead of replacing it |
| zizmor | Security audit of GitHub Actions workflows | hx check --security runs 7 checks named after the equivalent zizmor audits and honours # zizmor: ignore[...]; use zizmor for a broader audit |
| actionlint | Syntax, expression and shell checks for workflow files | Heurix validates generated YAML against a schema but doesn't lint workflow syntax; run both |
| pinact, ratchet | Pin action refs to commit SHAs | hx pin does the same for .github/workflows/*.yml, resolving tags with git ls-remote |
Heurix also checks a workflow against the repo it lives in (hx check reports missing services, outdated runtime versions and package-manager mismatches), and generates Dependabot config and Kubernetes manifests from the same scan.
Use It as a GitHub Action
Fail a pull request when its workflows drift from the repository or have security issues. GitHub's Ubuntu and macOS runners already have the Python 3.10+ the action needs; Windows runners aren't supported.
name: Heurix
on: [push, pull_request]
permissions:
contents: read
jobs:
heurix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: Naveen-Boddepalli/heurix@<commit-sha> # v0.5.0
Pin the action to the release's commit SHA, as hx check --security recommends for any third-party action, or to the tag (@v0.5.0) if you prefer. To show findings in the Security → Code scanning tab, write a SARIF report and upload it before failing the job:
permissions:
contents: read
security-events: write
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- id: heurix
uses: Naveen-Boddepalli/heurix@<commit-sha> # v0.5.0
with:
format: sarif
output-file: heurix.sarif
fail-on-findings: false
- uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: heurix.sarif
- if: steps.heurix.outputs.exit-code != '0'
run: exit 1
All inputs (path, security, format, output-file, fail-on-findings, version) are described in docs/drift-detection.md.
Installation & Deployment
1. Install via PyPI
pip install heurix
# or with pipx for isolated global CLI access (recommended)
pipx install heurix
2. Standalone One-Line Installer
curl -fsSL https://raw.githubusercontent.com/Naveen-Boddepalli/heurix/main/install.sh | bash
3. Docker Container (No Python installation required)
docker run --rm -v $(pwd):/workspace ghcr.io/naveen-boddepalli/heurix:latest generate
4. Local Development & Global Shell Alias
Clone the repository and install in editable mode:
git clone https://github.com/Naveen-Boddepalli/heurix.git
cd heurix
python3 -m venv .venv
source .venv/bin/activate
pip install -e '.[dev,build]'
To run hx from anywhere in your shell, add this to your ~/.zshrc or ~/.bashrc:
alias hx="/path/to/heurix/.venv/bin/hx"
Or execute directly from the repository root using ./hx.
Deployment & CI/CD Pipelines
The repository includes automated build, test, and publishing workflows:
- Continuous Integration (
.github/workflows/ci.yml): On pull requests and pushes tomain, lints with ruff and runs the test suite with branch coverage (85% floor) on Python 3.10–3.12, plus a job that checksruff formatandmypy. - PyPI Trusted Publishing (
.github/workflows/publish-pypi.yml): Builds sdist and wheel distributions and publishes to PyPI via GitHub Actions OIDC trusted publishing on release orv*.*.*tag push (plus manualworkflow_dispatchfor TestPyPI/PyPI). - Multi-Platform Docker Publishing (
.github/workflows/docker-publish.yml): Builds multi-arch (linux/amd64,linux/arm64) container images and publishes toghcr.io/naveen-boddepalli/heurix:latest. - GitHub Pages Docs & Playground (
.github/workflows/pages.yml): Syncsdocs/andllms.txt, builds the React + Vite frontend (site/), and deploys to GitHub Pages on push tomain. - Production
Dockerfile&.dockerignore: Multi-stage minimal container runtime with a non-root user and/workspacemount point. - Homebrew Formula (
packaging/homebrew/heurix.rb): Tap-ready formula forbrew install. Makefile: Developer tasks (make test,make check,make build,make docker-build,make docker-run,make site-dev,make site-build,make clean).
CLI Commands & Usage
Both hx and heurix invoke the CLI. Running hx with no subcommand runs hx generate.
1. hx generate (or hx)
Scans the codebase, runs heuristic detectors, validates synthesized YAML, and writes or non-destructively merges outputs.
# Scan and generate with step-by-step explainability log
hx generate
# Preview synthesized files without modifying disk (Dry Run)
hx generate --dry-run
# Show colorized terminal diff of proposed changes
hx generate --diff
# Non-interactive mode (auto-apply changes without prompts)
hx generate --yes
# Skip Kubernetes manifest synthesis
hx generate --no-k8s
# Target a specific repository path
hx generate --path /path/to/project
When an existing file would change in interactive mode, Heurix lets you choose between applying the AST smart merge, previewing the colorized diff (and re-prompting), creating a .bak backup before overwriting, or skipping the file.
2. hx diff
Compare existing repository configs against synthesized & smart-merged outputs without writing changes:
hx diff
3. hx check (Continuous Drift Detection & Security Audit)
Verifies structurally whether .github/workflows/ci.yml and .github/dependabot.yml match current codebase dependencies, pinned versions, backing services, and package managers. Exits with code 0 if synchronized, or 1 if drift is detected (ideal for CI and Git pre-commit hooks):
hx check
Add --security to audit every workflow for excessive token permissions, unpinned third-party actions, pull_request_target, template injection and persisted checkout credentials (rule IDs match zizmor). --format json or --format sarif prints a machine-readable report; SARIF uploads to GitHub code scanning:
hx check --security
hx check --security --format sarif > heurix.sarif
In GitHub Actions you can also use Heurix as an action; see docs/drift-detection.md for its inputs:
- uses: Naveen-Boddepalli/heurix@<commit-sha> # vX.Y.Z
with:
security: true
4. hx pin
Pin every workflow action to a full commit SHA, keeping the tag as a comment that Dependabot uses to update it (uses: actions/checkout@<sha> # v7). Refs are resolved with git ls-remote, so no token is needed. In repositories that use a GitHub Actions lockfile (.github/workflows/actions.lock), use gh actions-lock instead; hx generate keeps locked refs and hx check reports actions missing from the lockfile.
hx pin --dry-run
hx pin
5. hx scan
Inspect the strongly-typed ProjectContext Intermediate Representation (IR) as JSON:
hx scan
6. hx init & .heurix.toml Policy Overrides
Initialize an optional .heurix.toml policy file for custom runners, synthesizer toggles, action SHA pinning, or version overrides:
hx init
Supported .heurix.toml sections:
[engine]:runner(e.g.,"ubuntu-latest"),non_destructive(true/false)[ci]:include_dependabot,include_k8s,default_branch,pin_actions,action_shas(40-char commit SHA mapping),paths/paths_ignore(trigger path filters forpushandpull_request)[overrides]: explicit language runtime pins (python = "3.12",node = "20.x", etc.)
Deep Heuristic Capabilities
- Weighted Polyglot Ecosystem Detection: Scores root manifests and source file counts across Python, Node.js/TypeScript, Rust, Go, and C/C++ so primary language selection is deterministic and resilient to polyglot repos.
- Exact Version Pinning: Discovers runtime pins from
.python-version,.tool-versions,pyproject.toml,.nvmrc(preserving exact semver pins),.node-version,package.json,rust-toolchain.toml,go.mod, andCMakeLists.txt(CMAKE_CXX_STANDARD). - Lockfile & Virtualenv-Aware Commands: Selects install, lint, build, and test commands plus caching for
uv(uv run ...),poetry(poetry run ...),pipenv,pip,pnpm,yarn,bun,npm,cargo,go,cmake,conan,vcpkg, andmake(guardingMakefiledetection so non-C/C++ repos are never misclassified, and sequencingclang-tidyafter CMake builds only when.clang-tidyexists). - Automatic Backing Service Provisioning: Infers
postgres,redis, andmongodbfrom dependency manifests (Python:psycopg2,asyncpg,pymongo,motor,mongoengine,beanie; Node.js:prisma,ioredis,mongoose,mongodb) and externaldocker-compose.ymlservices, aligning test credentials and configuring health checks and ports. - Environment & Secret Isolation: Parses
.env.example/.env.template/.env.sample/.env.dist/.env.local.example, separating non-sensitive defaults (env:andk8s/configmap.yaml) from sensitive keys (test_secretswired to${{ secrets.KEY }},deployment_secretsisolated to deploy jobs), and enforcing top-levelpermissions: contents: read. - Cloud Deployment Target Detection (
CloudDetector): Detects Vercel (vercel.json,.vercel, serverlessapi/routes) and Firebase (firebase.json,.firebasercproject ID and features), wiring required secrets and generating conditionaldeploy_vercel/deploy_firebasejobs. - Monorepo Topology: Detects
pnpm-workspace.yaml,turbo.json,nx.json, andpackage.jsonworkspaces, enumerating sub-packages and adding Dependabot entries. - Hardened Kubernetes & Kind Manifests (
k8s/): Generates production-hardened manifests with pod and containersecurityContext(runAsNonRoot: true,allowPrivilegeEscalation: false,readOnlyRootFilesystem: true,drop: [ALL]capabilities),k8s/deployment.yaml,k8s/service.yaml,k8s/ingress.yaml(ingressClassName: nginx),k8s/configmap.yaml,k8s/secret.yaml, andk8s/kind-config.yaml. - Maintenance & Safety Controls: Synthesizes
.github/dependabot.ymlcoveringgithub-actionsand every detected ecosystem, with empty directory guards that prevent generating hollow workflows on repos with no code.
Project Structure
heurix/
├── pyproject.toml # Build & dependency metadata (scripts: hx, heurix)
├── Makefile # Dev, test, Docker, build, and docs site tasks
├── Dockerfile # Multi-stage production container image
├── heurix.md # Master architecture & product plan
├── llms.txt # LLM-friendly project index
├── hx # Direct executable wrapper
├── docs/ # Guides, CLI reference, and architecture docs
├── site/ # Interactive Vite + React docs & playground frontend
├── .github/workflows/ # ci.yml, pages.yml, docker-publish.yml, publish-pypi.yml
├── src/
│ └── heurix/
│ ├── cli.py # Typer CLI entrypoint & path-safe file writer
│ ├── core/
│ │ ├── context.py # Pydantic ProjectContext IR & DeploymentTarget models
│ │ ├── indexer.py # .gitignore-aware repo indexer & language scorer
│ │ ├── merger.py # ruamel.yaml recursive AST merge & comment preservation
│ │ ├── validator.py # Multi-doc pre-flight JSON schema validator
│ │ ├── drift.py # Structural AST drift detection engine
│ │ ├── security.py # hx check --security: workflow security audit rules
│ │ ├── lockfile.py # GitHub Actions workflow lockfile (actions.lock) reader
│ │ └── pinning.py # hx pin: resolve action tags to commit SHAs
│ ├── detectors/ # Modular language, infra & cloud providers
│ │ ├── base.py
│ │ ├── python_detector.py
│ │ ├── node_detector.py
│ │ ├── rust_detector.py
│ │ ├── go_detector.py
│ │ ├── cpp_detector.py
│ │ ├── docker_detector.py
│ │ ├── env_detector.py
│ │ └── cloud_detector.py
│ ├── synthesizers/ # Deterministic YAML generators
│ │ ├── base.py
│ │ ├── github_actions.py
│ │ ├── maintenance.py
│ │ └── kubernetes.py
│ └── ui/
│ ├── console.py # Rich explain-tree and summary tables
│ ├── differ.py # Colorized terminal diff viewer
│ ├── prompts.py # Interactive conflict resolution prompts
│ └── report.py # hx check --format json / sarif report renderers
└── tests/ # pytest suite (coverage gated in CI)
Running Tests, Quality Gates & Site Build
# Run full test suite
.venv/bin/pytest -v
# Run every CI gate: ruff lint, ruff format check, mypy, and tests with coverage (85% floor)
make qa
# Check this repo's own workflows for drift and security issues (same as `make check` and CI)
.venv/bin/hx check --security
# Build docs & interactive playground locally
make site-build
Metadata
Release files for heurix 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| heurix-0.5.0.tar.gz | 129.2 kB | Without provenance | Details for heurix-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| heurix-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for heurix-0.5.0-py3-none-any.whl |
Total release size: 266.8 kB
Release files / heurix-0.5.0.tar.gz
| Download URL | heurix-0.5.0.tar.gz |
|---|---|
| Size | 129.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6897c252aecf90412a07b2ca9d8d2e7e1dde21762565370a25f18663907fa92e
|
|
BLAKE2b-256 checksum How to use checksums |
c735b5f44b085625040030f31973aedd0611cfefa97f5805f98125405cfec711
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / heurix-0.5.0-py3-none-any.whl
| Download URL | heurix-0.5.0-py3-none-any.whl |
|---|---|
| Size | 137.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f8a9fbde363df8962c4f9477da51bb3feb4356a5a23de243fed703922eacda78
|
|
BLAKE2b-256 checksum How to use checksums |
61e2079bb4d8321dbd64adb4dfa4cc3673d25eb711a63b7dfd76f3b6a704f9a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for heurix 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.