返回资讯中心
外部精选
软件工程
#开发者实时流

Checkwash 上线:用 Git diff 检测削弱测试的改动,全程离线不依赖 LLM

来源标题:Show HN: Checkwash – flag Git diffs that weaken your tests (offline, no LLM)

开发者发布 Checkwash,它读取 Git diff,标记删除断言、跳过测试、放宽期望值、让 CI 不再报错等削弱测试有效性的改动模式。工具完全本地运行,不使用 LLM,分析时无网络,也不执行用户代码,需 Python 3.11+、Git 和 Claude Code,可通过 PyPI 安装。

Hacker News 最新taipei493142026/11/25 · 今天30 分钟阅读

以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。

Check whether a code change weakens your tests.

A test can pass after it stops checking something useful. checkwash reads your Git diff and flags known patterns such as deleted assertions, skipped tests, relaxed expectations, and CI checks that stop failing.

  • assert total == 105.3
  • assert total > 0

The new assertion accepts many incorrect totals. checkwash flags changes like this for review, including changes written by coding agents.

Runs locally. No LLM. No network during analysis. Never executes your code.

These examples use 0.13.2. The installation guide tracks the latest verified CLI download and Action pin. The 0.13.2 release guide describes the Python import fixes, CLI changes and measured Django scan times.

Already installed from PyPI? From your Git repository, run python -m checkwash check to review your uncommitted changes. Use the Python that installed the package, including the interpreter in the CheckWash environment if you used pipx. This also works when Windows blocks the checkwash.exe launcher.

Try the offline demo · Install Claude Code hooks · Require the GitHub Action

You need Python 3.11+, Git and Claude Code. Install the CLI, then run the hook installer from the root of your repository:

pipx install checkwash==0.13.2 checkwash hook install --agent claude-code --local

This writes checkwash's hooks to .claude/settings.local.json, your machine-local Claude Code settings (--local is the default; --shared writes .claude/settings.json without the PreToolUse prompt):

Both hooks are author-side checks: edits made through Bash bypass the PreToolUse ask, and engine errors in the Stop hook report a non-blocking note (except working-tree files over the size limit). To enforce verdicts on merges, configure the required CI check under Use it in CI. Hook limits are documented in the 0.11.0 known issues.

You need Python 3.11+ and Git. Download the single-file zipapp and run the built-in offline examples first.

Windows PowerShell (including 5.1, where curl aliases Invoke-WebRequest):

curl.exe -LO https://github.com/taipei49314/checkwash/releases/download/v0.13.2/checkwash.pyz python checkwash.pyz --version python checkwash.pyz demo

macOS/Linux or Git Bash:

curl -LO https://github.com/taipei49314/checkwash/releases/download/v0.13.2/checkwash.pyz python checkwash.pyz --version python checkwash.pyz demo

You can also download checkwash.pyz in your browser. Then, from a Git repository with at least two commits:

python checkwash.pyz check HEAD~1..HEAD

Uncommitted changes: python checkwash.pyz check

Branch review from merge base: python checkwash.pyz check BASE...HEAD (BASE..HEAD compares the two snapshots directly)

Hands-on walkthrough: follow examples/invoice to watch a failing test, a one-line shortcut edit that makes it green without fixing the bug, and checkwash's block.

Running check from a subdirectory analyses the whole repository from its Git root and notes that root on stderr (#416). For JSON/SARIF output and machine integration, see the embedding guide and stability contracts.

To stop a merge, make the checkwash status check required in your repository's branch rules. Installing the tool or adding a workflow alone does not enforce its verdict.

Save this as .github/workflows/checkwash.yml:

.github/workflows/checkwash.yml

on: [pull_request]

permissions: contents: read

jobs: checkwash: runs-on: ubuntu-latest steps:

  • uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 persist-credentials: false
  • uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: python-version: "3.12"
  • uses: taipei49314/checkwash/action@4ecb0b0efa2febe7dcacae7f4114e98877205128 # v0.13.2

After the workflow runs once, open Settings → Rules → Rulesets and require the checkwash status context (keep the job unconditional). Repository administrators with a clone of this project can also add the ruleset via:

gh api repos/OWNER/REPO/rulesets --method POST --input action/required-ruleset.json

checkwash doctor checks the local workflow file (it cannot inspect live GitHub branch protection). When upgrading, update the CLI and local hooks before bumping the Action pin; see CI details.

Result What to do

Pass · exit 0 No finding requires blocking under your configuration. Keep running your normal test suite and code review.

Block · exit 1 Read the finding and the diff. It may be weakened verification or a false positive.

Error · exit 2 Resolve the input or analysis error before relying on the result.

The default threshold is high: a visible warn still passes.

Read the finding. For the diff at the top of this page inside test_invoice_total in tests/test_billing.py, checkwash prints:

ASSERT_WEAKENED HIGH tests/test_billing.py :: test_invoice_total test_invoice_total: assertion strength EXACT_VALUE(90) -> BOUND(40) why high: NO_PROD_CHANGE_IN_DIFF no de-escalator applied before assert total == 105.3 after assert total > 0

EXACT_VALUE(90) -> BOUND(40) ranks assertion strength before and after; why high names the escalator (NO_PROD_CHANGE_IN_DIFF, or REPAIR_EVIDENCE_REFUSED when weakened alongside a production edit). Use checkwash check --format json for machine-readable output.

Fix the change, or record a reviewed exemption. If the test was weakened by mistake, restore it and fix the code. If the weaker test is intentional, record a time-boxed exemption (90 days default, 180 max) using the fingerprint printed in the report:

checkwash allow "<the fingerprint from the report>" --reason "why the weaker test is correct"

Configuration and exemptions are read strictly from the base side of the diff (comparing .checkwash/ against any .greenwash/ predecessor), so a PR cannot exempt or relax rules for itself: merge the ledger entry through code review first, and protect .checkwash/ and .greenwash/ with CODEOWNERS (exemption rules).

For a local main...branch check, merge or rebase onto the updated main so the common ancestor includes the exemption. On GitHub, push to the pull request branch or use Update branch to trigger a new pull request event. Re-running an old job uses the original event's commits.

Report a false block. If checkwash blocks an honest change, check the failure ledger first, then open an issue with the checkwash blocked honest work template (checkwash check --format json plus the diff). Accepted reports become regression fixtures crediting the reporter.

checkwash is alpha. A pass means no known tampering pattern was flagged at or above your threshold; it does not prove a change is correct or honest. Python is the primary supported language; JS/TS support covers a bounded set of patterns.

Four core limits to know before relying on a pass:

Honest changes can pass, warn or block. When a deprecated function and its whole test are removed together, PROD_SYMBOL_REMOVED can hold the finding at warn. When behaviour changes and a test's expected value changes with it, the report can credit the production change (REPAIR_EVIDENCE). Python refuses that credit for a removed assertion or deleted test. JS/TS can give it in both cases. Both languages refuse it for a weakened assertion or loosened tolerance. If a legitimate change still blocks, review the finding before requesting an exemption.

On the project's 60-case refactor corpus (57 strictly qualified), the expected-verdict table (benchmarks/refactors/expected.json) and the published 0.12.0 CLI mark 6 of 60 as blocking (4 among the 57, including known false blocks CASE_020_windows and CASE_029_flatten). Changed files over 1,000,000 bytes are not read (non-Python assets/docs warn on stderr; test, CI, guardrail, .py or pytest config files over the cap exit 2).

Subdirectory instruction files, CLAUDE.local.md, lowercase claude.md, .gitattributes working-tree-encoding rules, and other agents' config filenames are not guarded by default. GUARDRAIL_ADDITIVE on root CLAUDE.md covers only strict inert appends at end-of-file separated by a blank line (no ---, code fences, HTML comments, [label]: definitions or invisible Unicode formatting characters), and stays at warn even if an appended plain-text line contradicts earlier prose or adds an @path import.

To let a blocking guardrail edit through, record a reviewed exemption or override [roles].guardrail in a base-side .checkwash/config.toml (or .greenwash/config.toml if your repository uses that directory):

[roles] guardrail = ["AGENTS.md", ".cursorrules", ".claude/", ".checkwash/", ".greenwash/**"]

Because this list replaces the default, keep .checkwash/** and .greenwash/** in it so checkwash continues guarding its own config and ledger. Creating a new config file is a warn; editing an already-tracked config is itself a critical guardrail edit until merged to the base.

REPAIR_EVIDENCE describes related changes in the same diff; it does not prove a repair is semantically valid, and a no-op production edit (such as + 0) can earn it (#419). From 0.12.0 (0.13.0 known issues, 0.12.0 known issues, 0.11.0 known issues), weakened or loosened assertions and skips on live tests refuse repair evidence in both languages. Removing an assertion or a whole test also refuses that credit in Python. JS/TS can still credit a related change for those removals. A Python test deletion held at warn by PROD_SYMBOL_REMOVED uses a separate rule about a removed production symbol. Review the reason printed with the finding. For stricter enforcement, see the fail-on: warn and base-side oracle_freeze options in the enterprise hardening guide.

In JS/TS (since v0.9.0, #428), each test.each, it.each and test.for table with a static title is a unit whose rows are counted when written as an inline array, tagged template or same-file const used only as a table; describe.each rows and computed-title tables remain unread.

For the 60-case refactor corpus, 6 of 60 (4 of 57 strictly qualified) is the static source readback retained since the D-185 dispositions and matched by the published 0.12.0 CLI on Windows (2026-11-10 UTC). Earlier historical snapshots in the repository record 22/60 blocks (36.7%) at v0.3.1 (benchmarks/refactors/results-latest.json) and 4/60 (2/57 strictly qualified, with three fixture errors) in a pre-v0.3.4 source replay; those historical records are preserved unchanged and are selected examples rather than a general false-positive rate.

Since v0.9.0 (#454, #455), oversized non-Python assets, lockfiles, docs and non-Python production sources are set aside without earning repair evidence: --format json lists them under unread, SARIF emits a tool execution notification, and terminal output prints a ! note (opening with analysis incomplete when there are zero findings); --format hook-json and --emit-ir omit unread.

Any oversized file a detector or import resolver must read—test, conftest, CI, guardrail, snapshot, JS setup, runner script, .py module, pytest config (pytest.ini, .pytest.ini, pytest.toml, .pytest.toml, tox.ini, setup.cfg, pyproject.toml) at any depth, or non-generated scripts/** file—stops the run with exit 2 (--format json prints {"unread": [...]} except on an unread symlinked pytest-config target in range mode; term and SARIF stay empty). checkwash streams up to 64,000,000 bytes per Git side and inspects the first 200 bytes of oversized sides solely to detect shell shebangs (an extensionless file with a side over 64 MB still stops the run). Generated paths (build/, dist/, node_modules/) are set aside unless they match .py, pytest config, CI, runner script or unknown-shebang extensionless rules. At the base, oversized root poetry.lock/uv.lock warn on stderr, while oversized root pyproject.toml or requirements*.txt exit 2 across term/json/SARIF. In the Claude Code Stop hook (--format hook-json), engine errors report a non-blocking message and exit 0, except when a file changed by the hook's diff exceeds the limit in the working tree, which blocks the stop and asks to shrink, split o

正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。

打开原文
去社区讨论 →