{"slug": "show-hn-diffpact-local-git-task-contracts-and-review-gates-for-ai-agents", "title": "Show HN: Diffpact – Local Git task contracts and review gates for AI agents", "summary": "InterfaceDelta released Diffpact, an MIT-licensed, zero-runtime-dependency Node >= 22.6 tool that enforces SHA-pinned Git task contracts and review gates for multi-agent coding workflows, installable via `npm install -g diffpact`. Diffpact blocks edits to `.git/`, symlinks, submodules and destructive shell or inline interpreter commands before and after execution, returns exit code 2 (INCOMPLETE) instead of 0 when check lists are empty or test suites are skipped, and requires distinct implementer and reviewer identities with raw-diff attestation. The tool ships drop-in configs for Claude Code, OpenAI Codex CLI, Crush, Google Gemini CLI/Antigravity and @vercel/board, and adds a `diffpact merge-verify` gate that runs the union of participating contracts' checks on merged trees and writes a signed merge-receipt.json.", "body_md": "**Local, stateless Git task contracts, deterministic diff boundaries, post-merge verification, and cross-harness review gates for multi-agent coding workflows.**\n\nBuilt by [InterfaceDelta](https://interfacedelta.com) · MIT License · Zero runtime dependencies · Node `>= 22.6` · [Changelog](https://github.com/interface-delta/diffpact/blob/main/CHANGELOG.md) ·  \n\nChoose one installation method (zero runtime dependencies, Node `>= 22.6`):\n\n**Option A (Recommended): Install globally from npm**\n\n```\nnpm install -g diffpact\n```\n\nOr run without installing globally:\n\n```\nnpx diffpact doctor\n```\n\n**Option B: Clone from GitHub and symlink globally** *(runs `npm run build` automatically)*\n\n```\ngit clone https://github.com/interface-delta/diffpact.git\ncd diffpact && npm link\n```\n\n**Option C: Install globally from a local checkout**\n\n```\nnpm install -g /path/to/diffpact\n```\n\n**Verify your environment and try the 30-second self-contained quickstart demo:**\n\n```\ndiffpact doctor\nnpm run quickstart\n```\n\nSee [examples/quickstart/](https://github.com/interface-delta/diffpact/blob/main/examples/quickstart) for the interactive walkthrough and [examples/harnesses/](https://github.com/interface-delta/diffpact/blob/main/examples/harnesses) for drop-in Claude Code, Codex CLI, Crush, Gemini/Antigravity, and `@vercel/board` configs.\n\nEvery command supports per-command help:\n\n```\ndiffpact <command> --help\ndiffpact help <command>\n```\n\nShared message boards (`@vercel/board`) and subagent harnesses let multiple coding agents claim tasks in parallel—but ticket locks alone do not stop agents from editing forbidden files, skipping test suites while exiting `0`, silently altering pinned constants, introducing regressions when two parallel branches are merged, or rubber-stamping their own commits.\n\n`diffpact` enforces explicit, SHA-pinned **Task Contracts** directly against Git:\n\n- **100% Local & Stateless:** No daemon, no database, no sign-up. Truth is recomputed directly from Git (`HEAD` ,`git diff -M -z` , untracked files, and symlink checks) plus RFC 8785 canonical SHA-256 receipts.\n- **Boundary Precedence (`.git` deny > `forbidden` > `read_only` > `allowed`):** Unconditionally blocks`.git/` metadata/hook tampering, symlinks (`120000` ), submodules (`160000` ), unauthorized edits/renames (`-M -z` ), and destructive shell or inline interpreter commands (`Bash` ,`python -c` ,`node -e` )*before* and*after* execution.\n- **No Silent Zero:** Empty check lists, skipped test suites (`vitest` /`node --test` /`jest` skipped counts), or missing commits return exit code`2` (`INCOMPLETE` ), never`0` .\n- **Non-Self-Certified, Diff-Bound Review:** Enforces distinct implementer vs. reviewer identities, explicit raw-diff attestation (`--diff-sha <sha>` from`diffpact diff` or`--inspected-raw-diff` ), optional orchestrator HMAC signing (`DIFFPACT_REVIEWER_SECRET` , automatically stripped from worker subprocesses), and automatic invalidation (`exit 3` ) if`HEAD` moves.\n- **Worktree Lifecycle & Durable Evidence Archiving:**`diffpact worktree create --share-node-modules` handles standard repos, npm/pnpm monorepo workspace overlays, and subdirectory apps (`site/node_modules` ).`diffpact worktree remove` automatically archives`.diffpact/` evidence (`contract.json` ,`receipt.json` ,`reviews/` ,`report.md` ,`report.json` ) to`<main>/.diffpact/archive/` before removing the worktree.\n- **Post-Merge Integration Gate (`diffpact merge-verify`):** After joining 2+ parallel branches onto` main` , runs the deduplicated union of all participating contracts' checks and path boundaries on the merged tree and writes a signed`merge-receipt.json` .\n- **Cross-Harness Support:** Ready out of the box for**Claude Code** ,**OpenAI Codex CLI** ,**Crush** ,**Google Gemini CLI / Antigravity (`agy` & `agy-worker`)** , and**`@vercel/board`** .\n\nIn a typical single-agent workflow, the moment `npm run typecheck` and `npm test` exit `0`, the branch looks ready to merge. Here is an actual generalized trajectory from a 7-package TypeScript monorepo running `diffpact v0.4.x` with two separate models (Author Agent A and Independent Reviewer Agent B):\n\n```\nworktree create --share-node-modules  (7 local workspace packages linked, ~10s)\n  └─▶ Author Agent A implements feature + tests ──▶ diffpact verify: PASS (exit 0)\n        └─▶ diffpact status --require-review ──▶ HOLD (exit 2: review missing)\n              └─▶ Reviewer Agent B runs `diffpact diff` (~90s raw-diff audit)\n                    └─▶ REQUEST_CHANGES: 6 real bugs caught before merge!\n                          1. Async cancellation race (queue cleared, active fetch unguarded)\n                          2. Missing DOM data-attribute breaking replay buttons on one variant\n                          3. Background audio volume left un-ducked during modal transition\n                          4. Test file silently swallowing a ReferenceError inside try/catch\n                          5. Missing profile metadata in peer-to-peer rendering path\n                          6. Automated system notices unintentionally triggering TTS playback\n              └─▶ Orchestrator runs `diffpact amend --add-allow packages/core/src/index.ts`\n                  (hash-chained scope expansion required for bug #5; old receipt invalidated)\n        └─▶ Author fixes all 6 bugs ──▶ diffpact verify: PASS (exit 0)\n  └─▶ Reviewer B signs `diffpact review --diff-sha <sha> --verdict approve` (mode=diff-sha-bound)\n        └─▶ diffpact status --require-review ──▶ PASS (exit 0, review: approved 1/1)\n              └─▶ diffpact worktree remove --require-verified --delete-branch\n                  (archived contract, receipt, amendment chain, reviews & reports to .diffpact/archive/)\n```\n\n**Measured overhead:** ~25 seconds for worktree setup, contract pinning, and archiving + ~90 seconds for independent raw-diff review — **6 subtle production bugs stopped before a single line touched `main`**, including a broken test that had exited `0`.\n\n```\n# 0. Inspect environment, Git setup, and installed agent CLIs (with root/sandbox warnings)\ndiffpact doctor\n\n# 1. Create an isolated linked worktree with clean dependency sharing\n#    (monorepo workspace-aware; auto-discovers subdir apps like site/node_modules or use --node-modules-dir)\ndiffpact worktree create /var/tmp/wt-normalizer --branch feat/normalizer --share-node-modules\ncd /var/tmp/wt-normalizer\n\n# 2. Initialize a SHA-pinned task contract (with blocking + advisory checks and timeouts)\ndiffpact init \\\n  --task-id \"feat-normalizer-01\" \\\n  --mission \"Implement normalizer slice without touching migrations\" \\\n  --allow \"src/normalizer/**\" \\\n  --allow \"test/normalizer/**\" \\\n  --read-only \"src/common/**\" \\\n  --forbid \"migrations/**\" \\\n  --forbid \"package.json\" \\\n  --check \"typecheck=npm run typecheck\" \\\n  --check \"unit=npm test\" \\\n  --check-timeout \"unit=60\" \\\n  --advisory-check \"baseline=npm run test:baseline\" \\\n  --implementer \"codex-worker:sess-01:codex\"\n\n# Tip for zsh users: wrap shell variables inside colon-delimited identity strings in braces\n# (e.g. \"codex:s-${n}:codex\") or single quotes ('codex:s-1:codex'), because zsh parses\n# unbraced \"$n:c\" in \"codex:s-$n:codex\" as a `:c` parameter expansion modifier.\n\n# 3. Run any supported harness (claude | codex | crush | agy | gemini) with pre/post gate & live heartbeats\ndiffpact run --harness codex --model gpt-6-astra --prompt \"Implement .diffpact/contract.json\" --heartbeat-sec 30\n# (Or wrap any custom worker command: diffpact exec [--resume] -- <cmd...>)\n\n# 4. Check status (explicitly shows whether review is still missing)\ndiffpact status\n# -> diffpact status: PASS (exit 0) — Checks verified; review: missing (0/1 — run `diffpact status --require-review` before merge)\n\n# 5. Inspect the primary raw Git diff & record an independent, diff-SHA-bound review\ndiffpact diff\ndiffpact review \\\n  --reviewer \"claude-rev:sess-99:claude-code\" \\\n  --verdict approve \\\n  --diff-sha <raw_diff_sha256_prefix> \\\n  --summary \"Verified raw diff and edge cases\"\n\n# 6. Gate merge (fails closed until verified + independently reviewed)\ndiffpact status --require-review\ndiffpact report --format markdown\n\n# 7. Merge into main, then clean up worktree (auto-archives .diffpact/ evidence to <main>/.diffpact/archive/)\ncd /path/to/main-repo\ngit merge --squash feat/normalizer && git commit -m \"feat: normalizer\"\ndiffpact worktree remove /var/tmp/wt-normalizer --require-verified --delete-branch\n\n# 8. Post-merge verification across 2+ merged contracts / archived bundles\n#    Recommended order: run merge-verify right after merging BEFORE any manual follow-up fixes on main.\ndiffpact merge-verify \\\n  --from .diffpact/archive/<bundle-branch-a> \\\n  --from .diffpact/archive/<bundle-branch-b>\n\n#    If the orchestrator had to make small post-merge integration glue fixes on main, either:\n#    (a) declare those files explicitly (recorded in merge-receipt.json; global forbidden paths stay blocked):\ndiffpact merge-verify \\\n  --from .diffpact/archive/<bundle-branch-a> \\\n  --from .diffpact/archive/<bundle-branch-b> \\\n  --allow-integration \"src/index.ts\" \\\n  --reason \"Wire exported routes from both merged slices\"\n#    or (b) pass a lightweight follow-up contract via an extra `--from <contract.json>`.\n#    If unrelated local untracked scratch notes sit on main, pass `--allow-untracked`\n#    (alias `--committed-only`) to verify only the committed merge diff while still blocking dirty tracked files.\n```\n\nRun `diffpact <command> --help` for full flags and examples on any command.\n\n| Command | Purpose | \n|---|---|\n| `diffpact doctor` | Probe Node, Git, `.git/info/exclude` , installed agent CLIs (`claude` ,`codex` ,`crush` ,`agy` ,`gemini` ,`vercel` ), and root/sandbox warnings | \n| `diffpact worktree create` | Create linked Git worktree with `.diffpact/` pre-excluded + workspace/subdir-aware`--share-node-modules` | \n| `diffpact worktree remove` | Auto-archive `.diffpact/` evidence + reports to`<main>/.diffpact/archive/` , gate via`--require-verified` , and delete merged/squashed branch | \n| `diffpact init` | Create `.diffpact/contract.json` pinned to`starting_sha` , path boundaries, checks, timeouts, and advisory checks | \n| `diffpact amend` | Record hash-chained scope or `starting_sha` amendment in`.diffpact/amendments.jsonl` | \n| `diffpact run` | Harness-aware launcher ( `claude` ,`codex` ,`crush` ,`agy` ,`gemini` ) with linked-worktree Codex`--add-dir` , root-safe Claude flags, isolated Crush`--data-dir` , heartbeats, and host`verify` | \n| `diffpact exec` (`wrap` ) | Wrap any worker command with pre-flight boundary check ( `--resume` for in-scope dirty trees), tamper guard, and post-flight`verify` | \n| `diffpact verify` | Recompute Git diff boundaries, version pins, lockfiles, and run required + advisory checks ( `receipt.json` ) | \n| `diffpact merge-verify` | Post-merge gate across 2+ merged contracts/archives: verifies combined path boundaries and runs the union of all checks ( `merge-receipt.json` ) | \n| `diffpact diff` | Print primary raw Git diff ( `starting_sha..HEAD` ) and canonical`raw_diff_sha256` token for independent review | \n| `diffpact review` | Record non-self-certified review attestation ( `--diff-sha` or`--inspected-raw-diff` ; optional`DIFFPACT_REVIEWER_SECRET` HMAC) | \n| `diffpact status` | Fast read-only gate check against live Git `HEAD` (shows explicit`review: missing/approved/stale` even without`--require-review` ) | \n| `diffpact report` | Emit Markdown PR card, canonical JSON bundle, or SARIF 2.1.0 report | \n| `diffpact delegate` | Create monotonically narrowed child subcontract conserving parent `max_budget_usd` | \n| `diffpact install-hooks` | Idempotently merge `diffpact` hooks into`claude-code` ,`codex` ,`gemini` , or`agy` configs | \n| `diffpact print-config` | Print drop-in hook JSON config for `claude-code` ,`codex` ,`gemini` , or`agy` | \n| `diffpact board` | `@vercel/board` adapter (`post-contract` /`complete` gate) | \n| `diffpact agy-verify-patch` | Verify unattended `agy-worker --diff` unified patch before`git apply` | \n\nBecause a local CLI has no central identity server, a plain `--reviewer` flag is self-declared unless bound by your orchestrator. `diffpact` supports three escalating levels of review assurance:\n\n1. **Diff-SHA Binding (`--diff-sha <sha>`):** Reviewer runs` diffpact diff` and passes the exact`raw_diff_sha256` prefix (`>= 12` hex chars), proving the review targets the exact inspected diff bytes.\n2. **Orchestrator HMAC Signing (`DIFFPACT_REVIEWER_SECRET`):** Export` DIFFPACT_REVIEWER_SECRET` in your orchestrator shell.`diffpact exec` and`diffpact run` automatically**strip**`DIFFPACT_REVIEWER_SECRET` from worker subprocesses, so a worker agent cannot forge a valid`diffpact review` attestation—only processes holding the orchestrator's secret pass`diffpact status --require-review` .\n3. **Wrapped Read-Only Reviewer (`--adapter codex -- <cmd...>`):** Spawns an independent read-only Codex session, extracts its real`thread_id` , and rejects any mutation of the working tree.\n\n| Exit Code | Status | Meaning | \n|---|---|---|\n| `0` | `PASS` | Boundaries, version pins, checks, and (when required) independent reviews verified against `HEAD` | \n| `1` | `VIOLATION` | Path/symlink/shell boundary breached, self-certification or forged HMAC, diff-SHA mismatch, budget exceeded, or check failed | \n| `2` | `INCOMPLETE` | Missing contract/receipt/review, unattested raw-diff inspection, zero commits, or skipped tests ( *No Silent Zero* ) | \n| `3` | `STALE` | Git `HEAD` or`contract.json` moved after receipt or review was issued | \n\n*Built and maintained by [InterfaceDelta](https://interfacedelta.com): human-architected and developed with multi-model coding agents (Gemini, Claude Code, and OpenAI Codex) governed by `diffpact` itself with mandatory cross-model raw-diff review.*", "url": "https://wpnews.pro/news/show-hn-diffpact-local-git-task-contracts-and-review-gates-for-ai-agents", "canonical_source": "https://github.com/interface-delta/diffpact", "published_at": "2026-12-01 15:05:34+00:00", "updated_at": "2026-12-01 15:18:14.782559+00:00", "lang": "en", "topics": ["ai-agents", "developer-tools", "ai-tools"], "entities": ["InterfaceDelta", "Diffpact", "Claude Code", "OpenAI Codex CLI", "Crush", "Google Gemini CLI", "Antigravity", "@vercel/board"], "also_reported_by": [], "takeaway": "Diffpact pins each agent task to a SHA-bound contract and returns exit code 2 (INCOMPLETE) rather than 0 when check lists are empty or test suites are skipped, and invalidates reviews with exit 3 if HEAD moves.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/show-hn-diffpact-local-git-task-contracts-and-review-gates-for-ai-agents", "markdown": "https://wpnews.pro/news/show-hn-diffpact-local-git-task-contracts-and-review-gates-for-ai-agents.md", "text": "https://wpnews.pro/news/show-hn-diffpact-local-git-task-contracts-and-review-gates-for-ai-agents.txt", "jsonld": "https://wpnews.pro/news/show-hn-diffpact-local-git-task-contracts-and-review-gates-for-ai-agents.jsonld"}}