{"slug": "show-hn-argot-a-rust-ai-guardrail-based-on-your-codebase-ast-patterns", "title": "Show HN: Argot, a Rust AI guardrail based on your codebase AST patterns", "summary": "Argot, a Rust-based AI guardrail that uses a repository's AST patterns to detect foreign code changes, reports 97.3% recall on foreign patterns and 0.25% false positive rate on real edits, checking a diff in 200 ms. The tool, introduced on Hacker News, learns from a codebase's history to flag changes that are out of place, with benchmarks showing 620/637 (97.3%) fixture recall and 264/272 (97.1%) real recall across 36 and 25 corpora respectively, spanning 12 languages. Argot operates as a static binary with tree-sitter adapters and learned models per language, and integrates via CLI, skills, commit hooks, or GitHub Action.", "body_md": "### Learn the repository\n\n**argot init** learns the voice, semantic neighbours, architecture, and test signals on your machine.\n\nAI writes the code. argot harnesses it with the one thing that can’t hallucinate: **your repo’s own history**. Deterministic, measured, local.\n\n**97.3%** of foreign patterns caught · **0.25%** of real edits flagged\n\nchecks a diff in200 ms\n\nA concrete example\n\nClean, type-correct PRs can still be foreign to your repository. **This is its real output.**\n\nWhy this matters\n\nA green check can hide a weakened test. argot pairs it with the changed code and names both.\n\n154/164 (93.9%) — detector-specific fixture catch; controls and accepted-history results are separate. [Read the detector scope and controls.](/benchmarks)\n\nEvidence you can reproduce\n\n**argot audit** compares accepted changes with the repository history before them. Findings are prompts to inspect, not defect verdicts.\n\nThen run **argot init** and choose a recurring check path.\n\nMeasured, not promised\n\n97.3%\n\n620/637 (97.3%) — detector-specific fixture recall; not a product-wide accuracy claim. Fixture recall; the changed symbol is visible in the diff.\n\n36 corpora / 12 languages / visible foreign-import and foreign-api fixture symbols after excluded-host purge · d1007f50; generated_at=2026-07-28\n\n97.1%\n\n264/272 (97.1%) — detector-specific real recall; control result is separate. Authored internal layering violations across 25 corpora and 12 languages.\n\n25 corpora / 12 languages; authored internal layering violations · 7886a7967c6fe5b822a249083c7871894db1efcf; generated_at=2026-07-20\n\n93.9%\n\n154/164 (93.9%) — detector-specific fixture catch; controls and accepted-history results are separate. Authored production fit-to-check gaming fixtures.\n\n23 corpora / 12 languages; authored test-gaming fixtures, production fit→check · 1b0de32d; just integrity-verify, 2026-07-28\n\nOne **static binary**. Twelve languages — each with its own tree-sitter adapter and its own learned model:\n\nRecall on patterns planted in real files; false alarms on a temporal holdout. Even the structural blind spot — masked foreign — is published, not hidden.\n\nHow it works\n\nRun **argot init**, then choose the CLI, skills, a commit hook, or a GitHub Action. The Claude plugin adds a narrow pre-write prompt — not a full acceptance-time check.\n\nInstall the CLI\n\nseven on-demand skills for compatible hosts:\n\n`/argot-setup`\n\nreads your tree, writes argot.toml, verifies the catch`/argot-refresh`\n\nreviews scope and mutes, then refreshes the learned snapshot`/argot-check`\n\nscores each diff, flags what’s foreign — never blocks`/argot-review-pr`\n\nreviews one PR against your repo’s voice, no checkout`/argot-setup-ci`\n\na non-blocking voice score on every PR`/argot-write-rule`\n\nturns a convention you state into a tested rule`/argot-suggest-rules`\n\nfinds your conventions, codifies oneThe Claude plugin adds optional MCP context and a narrow, fail-open pre-write prompt; agents still decide when to call Argot. [Get the plugin →](/docs/plugin/)\n\n``` bash\n$ argot init\nStep 1/2: training voice model …\nStep 2/2: calibrating threshold …\n\nCorpus\n  1129 files · 503 learned · 626 tests/docs skipped\nVerdict: Ready\n\nSnapshot → .argot/ · voice · semantic index · health\nReview + commit → argot.toml · .argot/\nNext:  argot check\n```\n\nThe learned snapshot is committed; caches stay local. CI reads the base branch copy and never fits.\n\nThe whole model, in one glance\n\nArgot’s learned state is a **reviewed snapshot in Git**, not a hosted service. Every developer, agent, and PR compares against the same repository memory.\n\n**argot init** learns the voice, semantic neighbours, architecture, and test signals on your machine.\n\nReview and commit **argot.toml + .argot/**. It is repository-specific learned state, like a lockfile for checks.\n\nLocal tools, agents, and CI read that snapshot. A PR is judged against the **base branch**, so it cannot teach itself.\n\nAfter material accepted drift, status recommends **/argot-refresh**: review changed scope and mutes, fit locally, recommit.\n\nIntegrations\n\nThe GitHub Action reads the **committed base snapshot** and is non-blocking by default. Intentional divergence remains a human decision, recorded as an audit trail.\n\n**Start here:** open each row in the review queue.\n\n`crates/argot-cli/src/voice_diff.rs:202–282`\n\n**Evidence:** option, highlighted, Move — unfamiliar vocabulary here.\n\n**Review:** rewrite in the repository’s established form if unintended.\n\n`crates/argot-core/src/compose.rs:1–14`\n\n**Evidence:** `Lazy::new`\n\nis not used by similar code here.\n\n**Review:** compare the call with the repository’s established API.\n\n💬 Prompts for review, not proof of defects.\n\n`main`\n\n· CI never fits.Findings land on the PR. Snapshot health stays visible in the same summary.\n\nUnder the hood\n\nFour local engines, one static **Rust** binary — model included, nothing fetched — all grounded in your git history.\n\nA 15.6 MB table argot distilled from a code encoder turns every function into a vector — how argot knows you **already wrote this**. Nothing to download, no GPU, no cloud: it ships compiled in and works air-gapped.\n\nTwo frequency tables and a callee clustering — the imports, callees, and token shapes your repo **actually uses**.\n\nYour module-dependency topology. A new edge that **reverses the established direction** is flagged with the direction it breaks.\n\ntree-sitter tracks what every test asserts. A test **skipped, gutted, or deleted** beside a prod change gets paired and named.\n\nMeasured on FastAPI, laptop CPU. Single static binary — no Python, no Node, no model download, no GPU.\n\nAdvanced capabilities\n\n**argot conventions** finds the shared API and where code belongs. Turn one convention into a small, testable rule.\n\nwhere each kind of code lives — learned from your layout\n\n```\n// check.rhai — a route that existed before\n// this change, and is silently gone now\nlet now = [];\nfor m in ts_query(ROUTES) { now.push(m.text); }\nfor m in ts_query_old(ROUTES) {\n  if !now.contains(m.text) {\n    report(m.line, m.text + \" removed —\n      deprecate first (docs/api-lifecycle.md)\");\n  }\n}\n```\n\nMIT-licensed open source. Audit first, then choose the recurring check that fits your workflow.", "url": "https://wpnews.pro/news/show-hn-argot-a-rust-ai-guardrail-based-on-your-codebase-ast-patterns", "canonical_source": "https://argot.tmonier.com/", "published_at": "2026-08-03 12:12:51+00:00", "updated_at": "2026-08-03 12:24:44.368721+00:00", "lang": "en", "topics": ["developer-tools", "ai-tools", "machine-learning"], "entities": ["Argot", "Hacker News", "GitHub", "Claude"], "alternates": {"html": "https://wpnews.pro/news/show-hn-argot-a-rust-ai-guardrail-based-on-your-codebase-ast-patterns", "markdown": "https://wpnews.pro/news/show-hn-argot-a-rust-ai-guardrail-based-on-your-codebase-ast-patterns.md", "text": "https://wpnews.pro/news/show-hn-argot-a-rust-ai-guardrail-based-on-your-codebase-ast-patterns.txt", "jsonld": "https://wpnews.pro/news/show-hn-argot-a-rust-ai-guardrail-based-on-your-codebase-ast-patterns.jsonld"}}