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: read and 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.yaml ASTs recursively to preserve comments, custom user jobs, triggers, and any step tagged with # @heurix:preserve or # @autoyaml:preserve across 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 check parses 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 (and https://naveen-boddepalli.github.io/heurix/llms-full.txt)
- Guides & Reference Docs (
docs/):
docs/getting-started.md — installation, first scan, and .heurix.toml overrides
docs/heuristics.md — full matrix for all 8 ecosystem detectors
docs/cli-reference.md — commands, flags, interactive prompts, and exit codes
docs/smart-merge.md — ruamel.yaml AST merging and # @heurix:preserve
docs/kubernetes-and-ci.md — synthesized GitHub Actions, Dependabot, and k8s/ outputs
docs/drift-detection.md — running hx check in CI and pre-commit hooks
docs/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 to main, lints with ruff and runs the test suite with branch coverage (85% floor) on Python 3.10–3.12, plus a job that checks ruff format and mypy.
- 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 or v*.*.* tag push (plus manual workflow_dispatch for TestPyPI/PyPI).
- Multi-Platform Docker Publishing (
.github/workflows/docker-publish.yml): Builds multi-arch (linux/amd64, linux/arm64) container images and publishes to ghcr.io/naveen-boddepalli/heurix:latest.
- GitHub Pages Docs & Playground (
.github/workflows/pages.yml): Syncs docs/ and llms.txt, builds the React + Vite frontend (site/), and deploys to GitHub Pages on push to main.
- Production
Dockerfile & .dockerignore: Multi-stage minimal container runtime with a non-root user and /workspace mount point.
- Homebrew Formula (
packaging/homebrew/heurix.rb): Tap-ready formula for brew 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 for push and pull_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, and CMakeLists.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, and make (guarding Makefile detection so non-C/C++ repos are never misclassified, and sequencing clang-tidy after CMake builds only when .clang-tidy exists).
- Automatic Backing Service Provisioning: Infers
postgres, redis, and mongodb from dependency manifests (Python: psycopg2, asyncpg, pymongo, motor, mongoengine, beanie; Node.js: prisma, ioredis, mongoose, mongodb) and external docker-compose.yml services, 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: and k8s/configmap.yaml) from sensitive keys (test_secrets wired to ${{ secrets.KEY }}, deployment_secrets isolated to deploy jobs), and enforcing top-level permissions: contents: read.
- Cloud Deployment Target Detection (
CloudDetector): Detects Vercel (vercel.json, .vercel, serverless api/ routes) and Firebase (firebase.json, .firebaserc project ID and features), wiring required secrets and generating conditional deploy_vercel / deploy_firebase jobs.
- Monorepo Topology: Detects
pnpm-workspace.yaml, turbo.json, nx.json, and package.json workspaces, enumerating sub-packages and adding Dependabot entries.
- Hardened Kubernetes & Kind Manifests (
k8s/): Generates production-hardened manifests with pod and container securityContext (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, and k8s/kind-config.yaml.
- Maintenance & Safety Controls: Synthesizes
.github/dependabot.yml covering github-actions and every detected ecosystem, with empty directory guards that prevent generating hollow workflows on repos with no code.
Project Structure