agentleFS
d-o-hubd-o-hub/do-harness/AGENTS.md

do-harness

AGENTS.md1 starsChanged 30 days agoMITView on GitHub

The file

We split this AGENTS.md into the rules it gives an agent

12 rules. About 0 are common, 2 are distinctive, and 10 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 10

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Workspace Cleanliness: All skills reside in .agents/skills/.

    line 14
  2. Very specific:

    Read-only planning runs with --read-only and inspects pinned upstream source if the object is not local.

    line 53
  3. Very specific:

    Read the affected code and docs before editing, and load only the skill whose contract matches the task: run do-harness skills suggest …

    line 56
  4. Very specific:

    Run the sensors applicable to what changed (do-harness verify --set verification --changed, or the targeted individual checks below).

    line 62
  5. Distinctive:

    Localized behavioral bugs: keep a failing regression test for the defect (red), implement the fix (green), then run the applicable sensors.

    line 81
  6. Very specific:

    Compound dependent work: use .agents/skills/htn-planner to decompose genuinely multi-step or dependent requests into ordered subtasks.

    line 82
  7. Very specific:

    Durable state transitions/projections: use .agents/skills/event-modeler (Commands → Events → Projections) when the change introduces or …

    line 83
  8. Distinctive:

    Fail-Fast Policy: If a computational sensor fails 3 consecutive times on the same subtask, halt, record the error signature in libSQL, and …

    line 91
  9. Very specific:

    Read the rules before committing: npx commitlint --print-config json

    line 131
  10. Very specific:

    If the commit-msg hook rejects a commit, fix the rules named in brackets (e.g.

    line 133
  11. Very specific:

    Steering loop: if a sensor fires more than 2 times in one sprint, update the matching feedforward guide (or create one via …

    line 144
  12. Very specific:

    Metrics events: after non-trivial tasks, write a JSON event to .agents/events/YYYY/MM/DD/.

    line 146

≈ “Common” is an estimate: at least 1 in 5 of the 45,344 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

AGENTS.md — Autonomous & Interactive Agent Execution Harness

1. System Operating Invariants (Hard Constraints)

  • Latest-main First: Every new top-level repository work request MUST begin by checking and obtaining latest origin/main before planning, code inspection, editing, or subagent delegation (do-harness sync [--switch] [--read-only] [--format json]; bootstrap fallback: .agents/skills/harness/scripts/latest-main.sh [--root DIR] [--read-only] when the installed binary predates the command). The command fetches origin/main; --switch checks out and fast-forwards a clean main; --read-only only queries git ls-remote. Clean main can fast-forward only; dirty, diverged, or in-progress branches are never reset, auto-stashed, or automatically rebased, and --reset-diverged is reserved for explicit human-approved recovery because it creates a backup branch before resetting. For new work, branch from the fresh base without discarding existing work; for ongoing PR work, record the fetched base and retain existing branch-update rules. In read-only/dry-run mode, report advertised SHA and local HEAD separately, and inspect upstream sources pinned to that SHA if the object is unavailable locally. Network or fetch failure blocks claims of freshness; do not substitute stale source as latest. Verification never mutates Git state.
  • Modularity Cap: Maximum 500 Lines of Code (LOC) per source file. Decompose when nearing 450 LOC.
  • Repository-Agnostic Capability Contract: do-harness is a harness for every codebase, not this repository. Every capability it ships — gates, checks, measurements, workflow commands — is a native do-harness CLI subcommand that runs on Linux, macOS and Windows, in any git repository, without this checkout's scripts, Python, or a POSIX shell. Repository-local scripts/** are development tooling for this repository only and are never a capability's delivery surface; when a capability outgrows a script, it is ported into the CLI (the pattern of loc and helpers, now also design-review). Validate every change against this contract before it lands: an adopter in a different repository, on a different OS, must get identical behavior. A capability that only works here is a defect, not a feature.
  • Persistence Engine: Local libSQL instance (.do-harness/agent_state.db) for tracking beats, task execution traces, and learned heuristics. The database is local state and is never committed (.do-harness/ is ignored): a live SQLite file has no diff or merge, carries -wal/-shm sidecars, and a copy taken while a transaction is active can be corrupt. Version the contract instead — crates/db/migrations/*.sql, plans/*.json, and task export snapshots (see docs/retention.md).
  • Persistence & Roadmap: The do-harness-db repository layer implements persistence writers for tasks, beats, traces, heuristics, error signatures, and skill evals (verify --record persists beats scoped to --task or git branch, resetting strikes on pass; task list/task export read task state). The workflow runtime (task add/advance/done/fail, gated on plans/methods.json and named sensor ok beats, with typed Commands/Events and TaskBoard projections), fail-fast recovery (errors list/clear, strike counters scoped per workstream), the sandboxed skill-eval runner (do-harness eval with blessed tamper-evident baselines and eval --agent-cmd lift measurement), the metrics command, the deterministic DORA collector (dora), and commit enforcement (check-commitlint.sh) are implemented. The development-signal contract ([signal-sets] + verify --set, when-changed + verify --changed/explain, workspace/policy fingerprints, evidence schema v4, and status reporting) is documented in plans/development-signals-epic.md. Architecture policies and sensor decisions live in plans/invariants.json. Distilled operational heuristics reside in .agents/skills/harness/references/heuristics.md. Release distribution (multi-platform static binaries, cargo-binstall metadata, zero-install npm platform packages, automated SemVer release proposals via scripts/release-manager.sh and .github/workflows/auto-release.yml, and post-publication verification) is documented in docs/releasing.md and plans/distribution-epic.md. MCP conformance and governance policies are tracked in plans/mcp-conformance-epic.md and plans/agt-governance-epic.md.
  • Verification Priority: Computational sensors (cargo test, cargo check, linters) strictly supersede LLM self-assessment.
  • Workspace Cleanliness: All skills reside in .agents/skills/. Task tracking resides in plans/. Architecture rules are executable invariants, not prose ADRs (see §7).

2. Ordinary Working Route (Proportional)

[ Objective / User Request ]
             │
             ▼
[ 0. Baseline Freshness (.agents/skills/harness/scripts/latest-main.sh) ]
             │
             ▼
[ 1. Inspect Relevant Context ]
             │
             ▼
[ 2. Scoped Change (apply only the methods the change needs) ]
             │
             ▼
[ 3. Applicable Deterministic Checks (sensors for what changed) ]
             │
             ▼
[ 4. Required Current Completion Evidence (verify + status) ]

The ordinary route is proportional to the change. It does not prescribe a fixed ceremony: decomposition, event modeling, spikes, and distillation are tools applied when a specific change justifies them, not phases every change must pass through. The completion gates below remain mandatory however small or mechanical the change is.


3. The Ordinary Workflow

Step 0: Baseline Freshness (Latest-main First)

  • At the boundary of every new top-level repository work request, execute do-harness sync --format json; use the latest-main.sh fallback above only when the installed binary predates the command.
  • do-harness sync fetches origin/main; --switch checks out a clean main and fast-forwards it; --read-only queries without fetching; --reset-diverged backs up and resets only when recovery is explicitly approved. Exit 1 means a dirty or diverged checkout was refused; exit 2 is a git, remote, or config failure.
  • Clean main fast-forwards only. For new work, branch from the refreshed tip; dirty or active feature branches are never reset, auto-stashed, or automatically rebased.
  • Read-only planning runs with --read-only and inspects pinned upstream source if the object is not local. Remote failure fails closed.

Step 1: Inspect Relevant Context

  • Read the affected code and docs before editing, and load only the skill whose contract matches the task: run do-harness skills suggest --query "<task>" --limit 5, inspect the candidate metadata, and read only the selected SKILL.md and its references.

Step 2: Scoped Change

  • Implement the minimal change the request calls for, using the project's conventions. Specialized methods are applied only when the change actually needs them (see "Choosing Methods Proportionately"): a typo fix does not need HTN decomposition or an event schema, and a green PR does not compel a skill update.

Step 3: Applicable Deterministic Checks

  • Run the sensors applicable to what changed (do-harness verify --set verification --changed, or the targeted individual checks below). Computational sensors strictly supersede LLM self-assessment.
  • For targeted re-runs after a specific sensor fires (self-correction protocol), invoke the individual command:<!-- example: id=agents_targeted_reruns classification=illustrative reason="Targeted cargo re-runs" -->
    cargo check --workspace
    cargo nextest run --workspace
    cargo clippy --workspace --all-targets -- -D warnings
  • Refactor if necessary while respecting the 500 LOC ceiling. Run the full suite via the unified entrypoint (do-harness verify runs every configured sensor — see [[sensors]] in do-harness.toml):<!-- example: id=agents_verify classification=illustrative reason="Self-correction verify command" -->
    do-harness verify

Step 4: Required Current Completion Evidence

  • A change is complete only when its verification evidence is current and non-vacuous: run do-harness verify --set verification --strict (or the verify gate the change targets), then confirm do-harness status --set verification is green. Stale evidence — workspace or policy changed since verification — is red, not a pass; a sensor that ran zero checks is a failed gate (see §4).

Choosing Methods Proportionately

  • Trivial or mechanical changes (e.g., a docs typo, a rename, a formatting fix): inspect, make the scoped edit, run the applicable checks, confirm completion evidence. No HTN plan, event schema, or distillation artifacts are produced.
  • Localized behavioral bugs: keep a failing regression test for the defect (red), implement the fix (green), then run the applicable sensors. Prose and mechanical changes do not require a ceremonial red/green fixture.
  • Compound dependent work: use .agents/skills/htn-planner to decompose genuinely multi-step or dependent requests into ordered subtasks; persist the plan only when tracking the work needs it.
  • Durable state transitions/projections: use .agents/skills/event-modeler (Commands → Events → Projections) when the change introduces or modifies domain state transitions that justify Given-When-Then contracts.
  • Concrete external uncertainty: isolate an uncertain API, performance boundary, or novel integration in a spike via .agents/skills/spike-runner; record findings, then clean up scratch code.
  • Distillation: extract reusable lessons with .agents/skills/skill-distiller only when a repeated or consequential failure (or a resolved spike constraint) supplies evidence worth generalizing. Successful work prompts a review for reusable learning; concluding there is no reusable lesson without touching a skill is a valid outcome.

4. CLI Tool Protocol & Guardrails

  • File Edits: Inspect AST / types before rewriting files.
  • Fail-Fast Policy: If a computational sensor fails 3 consecutive times on the same subtask, halt, record the error signature in libSQL, and surface a diagnostic to the developer.
  • No Hallucinated Success: A subtask is complete only when verified by automated exit codes.
  • No Vacuous Gates: a green sensor that executed zero checks is a failed gate, not evidence. Treat 0 tests run or empty sensor output as RED: add a real check (e.g. a doc-test on a public API) or cite the committed can-fail proof for that sensor (the dogfood.rs broken-doctest fixture is the model for doctest).
  • Hooks: do-harness hook install writes .git/hooks/pre-commit (fmt + loc, run with --record so beats persist), commit-msg (commitlint), and pre-push (full verify); uninstall/status remove/inspect managed hooks. Hooks resolve the binary from DO_HARNESS_BIN, PATH, or target/release/do-harness (build it or set the env var in dev). Keep the PATH-installed binary current: after cargo build --release -p do-harness in a dev checkout, also refresh the installed binary (cp target/release/do-harness "$(command -v do-harness)") so plain do-harness invocations — scripts, skills, operator muscle memory — never run a stale release; a stale PATH binary is the same defect class as a stale target/release one (it predates the config schema and fails closed on new fields), and every session uses the latest version on PATH. Leave CARGO_TARGET_DIR unset in a development checkout: the Cargo Book's default is a private target at the workspace root, and a shared target dir is the one setting that silently decouples the binary from the tree — target/release/do-harness then goes stale, the binary predates the schema (fail-closed doctor/init-db --check skew), and hooks verify old code. Redirect it only for a deliberate isolated purpose (a coverage or sandbox target dir), never as a machine-wide convenience: over one target dir Cargo locks the entire build cache, so concurrent jobs serialise and cargo clean removes every workspace's cache (Rust Project Goals, "Rework Cargo Build Dir Layout"), while cross-checkout interference has produced spurious can't find crate failures (rust-lang/cargo#14053). To share build results across workspaces use RUSTC_WRAPPER=sccache, which the Cargo Book's "Shared cache" section documents for exactly that purpose, instead of sharing the target dir. If a checkout is already redirected, do not guess the path — resolve it with cargo metadata --format-version 1 --no-deps | jq -r .target_directory and export DO_HARNESS_BIN=<that>/release/do-harness (after cargo build --release -p do-harness) for every verify, hook, and commit invocation, and treat the is older than workspace sources warning as a hard stop, never background noise. On memory-constrained machines also export CARGO_BUILD_JOBS=2 and CARGO_INCREMENTAL=0 (the CI setting in verify.yml) before any verify or push: an uncapped full verify invoked the host OOM killer on 2026-10-14. Distinguish the two memory failure classes before acting, because the remedies differ: the kernel OOM killer sends SIGKILL — exit 137, 128 + signal (Rust Project Primer, "Linking"), with matching memory.events oom_kill counts in the container — while a graceful SIGTERM/signal: 15 at a reproducible early point in one large link, with oom 0/oom_kill 0 and no dmesg kill line, is a container or orchestrator watchdog and is not fixed by CARGO_BUILD_JOBS. For that class the documented remedy is [profile.dev] split-debuginfo = "packed", which the Cargo maintainer measures at "half of the memory usage per invocation" (rust-lang/cargo#9157) and which The Rust Project Primer's "Linking" chapter lists among the three ways to cut linker work; measured here on 2026-11-16, it lowered a 6.24 GB link peak to 5.70 GB and linked clean in 31 s. Do not reach for -C codegen-units=N or -C debuginfo=0: the first changes codegen to solve a linker problem, and the second is already covered by this workspace's debug = "line-tables-only". Do not assume lld is the fix either — since Rust 1.90 rust-lld is already the default linker on x86_64-unknown-linux-gnu (Rust Blog, "Faster linking times with 1.90.0 stable on Linux using the LLD linker"); confirm with readelf -p .comment <binary> before changing a linker setting. Where swapon is unavailable (some containers reject it with Invalid argument), the CI "add a 4 GB swap file" remedy does not exist and the profile fix is the only lever. Any flag used only to make a build complete is never sensor evidence — warm the cache with it if it helps, then run the sensor with the repository's real configuration, and in CI let verify.yml be the authority when a local container cannot reproduce the build at all.
  • Workflow gates: pre-commit = do-harness verify --fail-fast --only fmt --only loc; pre-push = do-harness verify --fail-fast; CI = verify.yml lints shell + cargo check -p guardian-proxy (default features; the feature-on suites run through the check-agt/check-mcp sensors) + do-harness verify --set verification --format json --strict (exit 0/1/2) + do-harness status --set verification (must be green) + verify --set scheduled + dogfood init && verify + do-harness eval --strict-fixtures, alongside source-distribution, msrv, dsh-bundle, and windows jobs. The heavy release preflight and scheduled jobs add a 4 GB swap file and run coverage with CARGO_BUILD_JOBS=1 and NEXTEST_TEST_THREADS=1: the instrumented suite is the documented ~11 GB OOM amplifier, and a hosted runner starved under memory pressure reports only exit 143 plus a shutdown signal. Their runner is pinned to ubuntu-24.04 because ubuntu-latest migrates to 26.04 from 2026-10-19.
  • Workflow YAML guardrail: keep .github/**/*.yml and .github/**/*.yaml in the repository's yamllint style, using block mappings for workflow environment and configuration tables. Do not replace them with compact { ... } mappings to save lines: yamllint rejects spaces inside flow braces here. After any workflow/config edit, run bash scripts/check-yamllint.sh and bash scripts/check-actionlint.sh (or do-harness verify --only yamllint --only actionlint) before broader verification; formatting sensors take precedence over line-count compression.
  • Main release gate: the current verify.yml main-branch path selects the strict main signal set, which is the ordinary verification surface; expensive coverage and powerset checks remain in the scheduled and final release gates so every push gets fast feedback without weakening release proof. Warnings, skips, missing tools, and stale evidence are red. auto-release.yml consumes only a successful verify run for the exact current main SHA, waits for at least three release-worthy commits since the published release unless manually forced, and never treats a tag without a GitHub Release as complete. Code, test, security, and dependency failures on main are human work: no workflow writes a repair directly to main.
  • Immutable action references: every external action and reusable workflow in .github/workflows/** must reference a full 40-hexadecimal commit SHA, and every Docker action image must carry a sha256: digest; a tag, a branch, a short SHA, or an expression is rejected with the file and line. actionlint proves the workflow is valid, action-pins proves its dependencies cannot move under you. Run bash scripts/check-action-pins.sh (or do-harness verify --only action-pins) after any workflow edit. The check is offline — it never calls the GitHub API and never resolves a tag — so it proves the shape of a reference, not that the commit exists. Source: GitHub's security hardening guidance.
  • Repository-agnostic output: the CLI must work in every GitHub repository, so no shipped surface may name this one where the current repository is meant. A hardcoded owner/repo is a silent defect: it is a plausible link, not a crash, and it does the wrong thing in every adopting checkout — feedback would file an adopter's incident against this project, and a readiness or metrics report would attribute another repository's checks. Derive the identity at runtime (gh repo view --json nameWithOwner --jq .nameWithOwner, or the origin remote) and fail closed when it cannot be derived; require it as an explicit argument when the command targets a repository other than the one it runs in. The same rule covers scaffolded artifacts: anything init writes into an adopting repository must describe that repository, with no link back here except the install line that fetches the tool. The only permitted hardcoded references are the tool's own identity surfaces — its docs landing link, its install script and the release/registry remediations that quote DO_HARNESS_REPO or ${GITHUB_REPOSITORY} — and each one carries its reason in the allowlist of scripts/check-repo-links.sh. That script is the repo-links sensor: it scans the shipped sources, the scaffolded templates and the release scripts, and --self-test proves both directions (a leak is rejected, test fixtures and identity surfaces are not). Test fixtures use neutral values (acme/widget, example.invalid) rather than this repository's name.
  • Portable gates: every sensor the harness ships, scaffolds, or recommends must run on Linux, macOS and Windows without a POSIX shell. Gate the check with a native subcommand (do-harness loc --strict, do-harness helpers <name> (commitlint, deps, audit)) and never wire bash scripts/*.sh as the sensor argv: a Windows adopter whose only bash is the WSL launcher fails before the check measures anything, and the sensor then reads as a tooling failure rather than a code verdict. The same rule governs capabilities, not just gates: a shipped feature (measurement, review, workflow) is a native CLI subcommand usable in any repository (do-harness design-review is the pattern), never a repo-local Python or shell script an adopter cannot run. The scripts/check-*.sh files stay as thin delegating wrappers for configs that already name them, and do-harness doctor reports a shell-routed helper as a helper-portability warning naming the native command to switch to — treat that warning as a defect to fix, not advice. scripts/check-repo-links.sh enforces the sibling rule for repository identity; a gate that ships a shell requirement is the same class of defect.
  • Documentation contract: after any change to the CLI surface or a maintained document, regenerate the mechanical blocks (python3 scripts/docs.py sync --write), inspect that diff, run the three docs checks (python3 scripts/docs.py sync --check, python3 scripts/docs.py examples --check, python3 scripts/docs.py links --check), then review the affected narrative by hand — the checks prove the mechanical facts, never the prose; scope, exemptions, and recovery live in docs/documentation-contract.md. The man page is the one generated artifact docs.py does not write: regenerate it with target/release/do-harness man man (it needs a built binary, and the committed page only carries the semantic version — the build fingerprint is normalised away), because man_sync inside the test sensor is otherwise the first thing to notice a CLI change, ten CI minutes later.
  • PR lifecycle: after opening a PR, load .agents/skills/pr-triage and run the sweep without waiting to be asked (review/roast the diff, resolve threads, wait for every check, merge with gh pr merge --squash --match-head-commit <validated head>; never auto-merge; a draft, hold/wip/do-not-merge label, or "do not merge" remark is a hard stop — report it, never gh pr ready a pull request to make a merge possible, and never merge a draft without explicit human approval recorded in the session, which .agents/skills/pr-triage/scripts/merge.sh enforces immediately before the merge from the authorizing pr ready receipt). In a dev checkout set DO_HARNESS_BIN=target/release/do-harness so the skill uses do-harness pr review instead of falling back to the full diff.
  • Persistence commands: do-harness task list/task export surface task state (libSQL is the source of truth; export writes plans/tasks.json with a board summary and task import --check validates freshness — import is validation-only by design, since ids are database-assigned and the event log is append-only, so a snapshot cannot be replayed back into the database); verify --record persists beats (scoped to the current git branch by default, to --task <id> when passed, or --global), and bumps error signatures for failing sensors; per-sensor severity = "error"|"warn" (with allow_failure as the deprecated warn alias) makes warn failures advisory except under --strict outside feedback, and warn strikes quarantine after 3; FINDINGS: <n> markers ratchet against the committed plans/baselines.json, which verify --record --bless only lowers (raise refused, bless history in libSQL); task add/advance/fail, trace add/list, distill, eval, metrics, and maintenance --prune-beats are implemented. plans/methods.json ships vertical-event-slice, spike-and-resolve, and decision (a promotion verdict gated on the decision-agnostic check-promotions). The global --dry-run covers every mutating task action including add and export; task remove refuses a task that has workflow events rather than deleting hash-chained audit rows.
  • Unattended jobs: do-harness job run --spec <FILE> executes one explicitly authorized task through an external executor in a disposable worktree at a pinned revision, within finite attempt and time budgets. Completion requires fresh strict evidence (verify --set … --strict --record --unchanged=run followed by status green); an executor exit status or "done" claim is never proof. Stops are typed blocked receipts under .do-harness/jobs/, resume continues the remaining budget without renewing it or repeating a completed repair, project policy may declare deterministic [[repairs]] in do-harness.toml, the spec must name the external isolation mechanism because a worktree alone is not a process/network/filesystem sandbox, and no sensor, hook, or CI path launches a job, so deterministic verification never starts a paid model. See docs/unattended-jobs.md.
  • Background job output: a detached command runs in its own shell, so a log it writes under /tmp is not readable from a later tool call or by another agent, while the same write inside the workspace is (observed 2026-11-15: a detached merge loop's /tmp log did not exist for the next call, and the identical write under .do-harness/logs/ did). Long-running output therefore goes inside the workspace — bash scripts/run-logged.sh <name> -- <command...> tees to .do-harness/logs/<name>.log, gitignored, and exits with the command's status — or is read from the job's own completion output. /tmp is never the hand-off surface between turns or between agents, and /tmp builds are the same mistake: point a linked worktree's CARGO_TARGET_DIR at a per-worktree directory on the main filesystem (never one directory shared by several checkouts, whose artefacts produce spurious test failures).
  • Worktree hygiene: a squash merge lands the change in main but leaves the branch's linked worktree behind — the branch tip keeps its pre-merge commits, so git branch --merged never lists it and nothing removes it. scripts/prune-worktrees.sh decides from evidence: default dry run, --apply removes a worktree only when its work is provably landed (merged PR head ref, zero commits ahead of origin/main, a tree identical to it, or every commit patch-equivalent upstream), and --apply --unmerged-checkouts drops the checkout of a clean, local-only branch while keeping the branch ref. It never force-removes, never touches the repository's own checkout, and never touches a worktree with uncommitted changes. Run it after a merge (the pr-triage sweep's last step does), and treat the kept entries as the inventory of outstanding local work.
  • Signal commands: verify --set <set> runs one development decision's sensors (writing .do-harness/evidence.<set>.json); verify --changed / explain --set <set> --changed apply deterministic when-changed selection (fail-closed when git state is unreadable); status --set <set> reports evidence freshness green|red|stale|missing without running sensors; list --sets enumerates configured sets.
  • LOC feedforward: the 500-LOC ceiling is enforced by the loc sensor, which runs the native gate do-harness loc --strict: plain do-harness loc reports and exits 0 (a query an agent can loop over), while --strict exits 1 on any file over the ceiling. The gate is native, not scripts/check-loc.sh, because a harness gate must run on every host — a Windows adopter whose only bash is the WSL launcher cannot run the shell wrapper, and doctor flags that wiring as a helper-portability warning. On failure the command reports the over-limit rows and a FINDINGS: <n> count for the blessed ratchet; --dir/--ext widen or narrow the scan beyond default workspace language roots (generated trees are pruned), so a front-end tree gets the same ceiling from do-harness.toml without forking the command. --format json reports the same rows as one parseable value (no marker line). do-harness split <file> [--dry-run] [--target <name>] performs the decomposition: it extracts the inline #[cfg(test)] module to <stem>_tests.rs (declared with #[path = ...]), or the largest top-level item that both fits the ceiling and brings the source under it, and refuses with a diagnostic rather than emitting code that cannot compile (macro_rules!, include!, non-test #[cfg]).
  • Sensor policy decisions: explicit wontfix entries (gitleaks, SBOM, lockfile freshness, eval bless-drift) live in plans/invariants.json; do-harness seed --prune keeps libSQL in sync and drops stale rows. shell (shellcheck, fail-closed in CI), actionlint (GitHub Actions workflow semantics; tool-dependent so it SKIPs locally and fails closed under CI=true/DO_HARNESS_REQUIRE_TOOLS=1, mirroring shellcheck), action-pins (every external action and reusable workflow must reference a full 40-hexadecimal commit SHA and every Docker action image a sha256: digest; the parser is PyYAML, so a missing parser SKIPs locally and fails closed under CI=true/DO_HARNESS_REQUIRE_TOOLS=1, mirroring the actionlint policy), workflow-shell (every workflow run: block is re-checked with shellcheck's SC2154 enabled after its workflow-, job- and step-level env: keys are declared, which actionlint cannot do because it excludes that check for embedded scripts: a step that reads a variable it only wrote to $GITHUB_OUTPUT fails this gate instead of failing the release run, and --self-test proves both directions), docs-sync (the generated regions of README.md and docs/cli.md, plus tests/fixtures/cli-contract.json, must render byte-for-byte from the Clap definitions; repair with python3 scripts/docs.py sync --write, never by hand-editing a region), docs-examples (every <!-- example: ... --> block in a maintained document executes against its manifest fixture, or parses as its classification declares; an unmarked CLI/config fence fails), docs-links (maintained-document link and anchor existence, inventoried by docs/contracts.toml, which is what exempts historical, fixture, and vendored documents; fails closed on an empty inventory), check-agt (guardian-proxy governance feature), check-mcp (guardian-proxy MCP surface feature), powerset (guardian-proxy feature-powerset check), machete (unused-dependency pruning), magic-numbers (section 5's named-constants rule, warn severity with a blessed findings baseline so only an increase fails), untrusted-ingest (the pr-triage skill is the only component whose input is attacker-controlled by design: its ingest scripts must hold no dynamic-execution sink — eval, sh -c, child_process.exec, shell-enabled spawn — and its untrusted-data contract clause must still be stated; a sink lint, not a taint tracker, so it proves the dangerous sinks are absent rather than exhaustively proving no path exists), and repo-links (the CLI works in every GitHub repository: no shipped source, scaffolded template or release script names this one where the current repository is meant; the tool's own identity links are allowlisted with a reason and --self-test proves both directions), check-promotions (every recorded *-promotion verdict must agree with the shipped Cargo defaults — a coherence gate only; it does not re-derive GA, because the GA watch exits 0 on every verdict and needs the network, so the dated verdict stays recorded epic evidence) are workspace sensors.
  • Release derivation: scripts/release-manager.sh is the one release entry point. status and next [--format json] derive the bump from the conventional commits since the last release tag, prepare <version> [--no-lock] [--no-man] applies it to every managed manifest ([workspace.package].version, the intra-workspace requirement pins in the member manifests, Cargo.lock, the six npm manifests, man/do-harness.1), and --self-test pins the rules and the fail-closed guards as the release-manager sensor; the release-gated release-manager-e2e sensor runs the opt-in --e2e (the real prepare in a scratch git worktree, asserting cargo metadata --locked after the bump) and the hermetic publish-npm sensor runs scripts/publish-npm.sh --self-test, neither of them in verification. It validates a version as plain MAJOR.MINOR.PATCH before it can reach sed (pre-release and build metadata are refused), validates the git ref before use, and fails closed on a rev-list/git log error instead of deriving bump=none from a broken range. The bump policy sends breaking changes to the major at ≥1.0 and the minor at 0.x, feat to the minor, and fix/perf or a non-conventional subject to the patch. Other conventional types release nothing on their own. 0.0.x stays on patches whatever the commits. The proposal flags declared breaking changes so maintainers can document migration steps. It resolves its root from its own location, so invoking another checkout's copy operates on that tree: pass --root <dir> when you mean a different one. Tagging is deliberately not part of it — main requires pull requests, so the bump lands as a reviewed PR and .github/workflows/auto-release.yml refreshes that PR (branch and body, retiring any superseded automation-owned release/v* proposal) and tags it after the merge, and only when github.ref == 'refs/heads/main'; the release is complete only once its GitHub Release exists — ship tags the commit, and crates.io, npm and the Release are created afterwards by release.yml, so a tag is intent, not a finished release — and a basis tag with no published Release derives bump=pending-release instead of a version, retiring any open proposal with held: …, through next --published <tag[,tag]> filled by auto-release.yml from gh release list --exclude-drafts (absent means "not told", the backwards-compatible default; present-but-empty means "nothing has published" and blocks every bump); release.yml serializes runs on the effective release tag with queue: max, and scripts/publish-npm.sh sends an out-of-order publish out under --tag backfill so npm's latest never moves backwards. Release mechanics and the bump policy table live in docs/releasing.md ("Cutting a release").
  • Artifact Provenance Contract: language-neutral verification of release-artifact provenance (e.g., artifact-provenance sensor). Required inputs: artifact path(s) (ARTIFACT_PATHS), expected digest (EXPECTED_DIGEST), and verification mode (VERIFY_MODE). Evidence output must emit a COVERAGE: <json> record containing artifact, digest, status (pass|fail), and reason on failure. Only digest-only is implemented: reserved modes (slsa, github-attestation, sbom, strict) fail closed rather than reporting a pass they did not verify.
  • Root discovery: the CLI walks up from cwd for do-harness.toml, or AGENTS.md with .do-harness/ or plans/invariants.json; override with --root. An explicit --root DIR selects exactly <resolved DIR>/do-harness.toml as a required file: policy-consuming commands (verify, list, explain, status, hook install) exit 2 before sensors, beat recording, or evidence writes when it is missing, unless --config FILE names another policy file. No ancestor or built-in-pack fallback applies to an explicitly targeted directory.

5. Concrete Rust Conventions

  • Error Handling: thiserror enums in libraries, anyhow in binaries. No unwrap() in library code.
  • Safety: #![forbid(unsafe_code)] at workspace and crate roots.
  • Config & Events: #[serde(deny_unknown_fields)] on config and event structs.
  • Constants: Named constants over magic numbers.
  • Async: #[tokio::main(flavor = "current_thread")] for CLI binaries; sync main when no async is required. Follow workload-aware Tokio guidance (template #336, .agents/skills/tokio-performance/SKILL.md): short bounded CPU (<10–100µs) stays on worker threads; reserve spawn_blocking/pools for genuinely blocking disk/FFI or sustained heavy CPU (>1ms). Review flags: unbounded spawn fan-out, lock-across-.await, and repeatedly-ready loops.
  • Commits: Conventional commits with lowercase subject lines.
  • MSRV: rust-version is a compile gate, not a lint. A language feature newer than the declared minimum (an if let … && let … chain needs 1.88 against a 1.85 floor) compiles and lints clean locally and fails only the msrv job, because clippy's MSRV-aware lints merely suppress suggestions. Prove the change with cargo +1.85.0 check --workspace (that toolchain is installed) before pushing, or expect the CI msrv job to be the first witness.
  • Cross-target code: a #[cfg(unix)]/#[cfg(windows)] block is not compiled on the other host, so a locally green tree can still break the Windows runner. Gate an import with the same cfg as its only use, and never compare a raw fixture path against a message that prints a canonical path: Path::canonicalize yields a verbatim \\?\… path on Windows (strip it with util::without_verbatim_prefix) and expands the runner's short temp directory, so assert on the file name and the targeted directory instead.

Commit convention

This repository enforces its commit convention with commitlint.

  • Read the rules before committing: npx commitlint --print-config json
  • Validate a message before using it: printf '%s' "<message>" | npx commitlint (exit 0 = valid)
  • If the commit-msg hook rejects a commit, fix the rules named in brackets (e.g. [subject-case]) and retry.
  • Never use git commit --no-verify.
  • Rule: The entire subject line (type, scope, and description) must be lowercase. For example: feat(ci): add guardrails — not feat(ci): add CI guardrails.
  • Dependencies: Declare versions in [workspace.dependencies] with caret ranges; commit Cargo.lock for binary applications.

6. Harness Engineering Model (Feedforward + Feedback)

  • Feedforward guides (read before coding): AGENTS.md, .agents/skills/ — context, constraints, conventions.
  • Feedback sensors (fire after coding): cargo check --workspace, cargo nextest run --workspace, cargo clippy --workspace --all-targets, cargo fmt --check — these are the check, test, clippy and fmt sensor arguments verbatim (do-harness.toml), so a local run cannot pass where the sensor fails; computational output strictly supersedes LLM self-assessment.
  • Self-correction protocol: classify the failure, apply the minimal fix, re-run the specific sensor, proceed only when green. See .agents/skills/harness.
  • Steering loop: if a sensor fires more than 2 times in one sprint, update the matching feedforward guide (or create one via .agents/skills/skill-distiller) so sensors fire less over time.
  • Source grounding: claims about tool behaviour or "best practice" cite the current official document, fetched and quoted at the time (upstream man/adoc page, vendor docs, spec) with the version verified against; search-result snippets are pointers, never evidence.
  • Metrics events: after non-trivial tasks, write a JSON event to .agents/events/YYYY/MM/DD/. For agent token usage, python3 scripts/token-usage.py reads OpenCode's per-session counters read-only and writes one event with input/output/reasoning/cache_read/cache_write/total — token counts only, no cost (see docs/retention.md).

7. Executable Architecture Invariants (Replacing Free-Form ADRs)

Architecture rules are machine-verifiable, not prose. Three structures:

  1. Schema Contracts (crates/types): Rust types encode the rules — DecisionHeader { invariant, rationale, sensor, category }, typed HTN (Method, Subtask, Precondition, TaskState), and event-sourcing traits (Command, DomainEvent, Projection). Invalid states are unrepresentable; #[serde(deny_unknown_fields)] rejects stale payloads.
  2. Static Invariants (linters & scripts): enforced computationally —
    • 500 LOC ceiling: do-harness loc --strict (the loc sensor)
    • dependency direction (types must not depend on storage/adapters): scripts/check-deps.sh + cargo deny check (deny.toml)
    • cargo clippy --workspace --all-targets -- -D warnings (workspace.lints, .clippy.toml)
  3. Machine-Readable Decision Headers: each decision carries Invariant / Rationale / Sensor. Source of truth: plans/invariants.json; persisted to libSQL via cargo run -p do-harness-db --bin seed_invariants (upsert into the invariants table).

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.