Using hlock in CI¶
Commit harness.toml and harness.lock together, then have CI check that they still
match. If someone edits the manifest without re-locking, the build fails, just like
uv sync --locked or cargo build --locked.
Pinned locks
This page is about resolved locks. A pinned lock describes the
harness setup on a machine, and hlock check compares it with the setup on the machine
it runs on. A CI runner doesn't have your setup, so run that check where the setup
lives, before you commit.
hlock check¶
When the manifest has drifted, it exits 1 and prints both hashes:
$ hlock check
✗ drift: harness.toml changed since harness.lock was written
locked sha256:e6471474cb158117c727fbf3371e2287935d191f16c71c24c14ea80ca54693e2
live sha256:d4271d0bda41886908111b7a2346bc4856c4f3355a11856230054d717a4cd483
hint: re-lock with hlock resolve, then commit both files
The hash covers the whole file
The manifest hash is computed over the file as written, comments and whitespace
included. Any edit to harness.toml means re-running hlock resolve.
Declared dependencies¶
When the project declares dependencies, hlock sync --frozen installs
exactly what the lock pins and fails if harness.toml (or apm.yml) asks for something the
lock doesn't have, rather than updating the lock. It fetches each dependency at its commit
and checks its digest, so a CI runner gets what you got.
Audit the lock¶
hlock audit --ci checks the lock's integrity, scans what it places for hidden characters,
and enforces the project's policy, failing on warnings too.
--format sarif writes SARIF 2.1.0 for GitHub code scanning:
name: agent-audit
on:
pull_request:
paths: ["harness.lock", ".hlock/vendor/**", "hlock-policy.toml"]
jobs:
audit:
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
- run: uvx hlock audit --ci --format sarif -o hlock.sarif
- if: always()
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: hlock.sarif
A CI runner has approved no executables, so audit lists them without failing. A job that
syncs the lock passes hlock sync --trust, a statement that the lock was reviewed on the PR
that changed it.
Lint the instructions¶
hlock lint --ci fails on instruction text written for an earlier model in what
the lock places, for the lock's model or the one you name:
GitHub Actions¶
name: agent-lock
on:
pull_request:
paths: ["harness.toml", "harness.lock", "tasks/**"]
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
- run: uvx hlock check
Output is plain text when CI isn't a terminal, and you can force that anywhere with
NO_COLOR=1.
Smoke-test the locked agent¶
hlock run exits non-zero when the task fails, so a canary task can gate a deploy:
Use --json when a later step needs the outcome:
Scheduled re-tuning¶
hlock tune --strict exits non-zero unless it beats the current lock. A nightly
job can try, and open a PR only when there's a real improvement: