closure_drift
closure_drift
Does v1.4.2 mean one thing in your repository?
$ git clone -q https://github.com/psf/requests && cd requests
$ closure-drift --compare v2.16.0 v2.16.1
A v2.16.0 (commit bcd0e170ac20)
label 2.16.0
closure 3d2886b87c2a7b94 17 file(s)
B v2.16.1 (commit f687e9f3d8b0)
label 2.16.0
closure 696b71ed6023f563 18 file(s)
changed requests/__init__.py
only in B requests/packages.py
==============================================================
DIFFERS UNDER ONE LABEL: both declare 2.16.0, and the code differs
in 2 path(s). If both were published, that label names two things.Check it without this tool: git show v2.16.1:requests/__version__.py says 2.16.0. closure_drift reads
the git history, not a package index: it shows what the tags contain, not which commit a published package
was built from.
A version is a string a human edits. When two releases share a version and differ in code, one address names two artefacts — and nothing notices, because the version is all that was recorded.
One command checks it. Read-only, one file, no dependencies, no network.
Run it
curl -sO https://raw.githubusercontent.com/luizfnsilva/closure_drift/v1.1.1/closure_drift.py
python3 closure_drift.py # inside any git repositoryor pipx run --spec git+https://github.com/luizfnsilva/closure_drift@v1.1.1 closure-drift.
Needs Python 3.9+ and git. To see the three possible answers first: python3 examples/demo.py, or read docs/DEMOS.md.
Related MCP server: mcp-gerrit-code-review
Check before you tag
--would-tag answers: if I tag this commit now, does its version already name different code?
# GitHub Actions
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- uses: luizfnsilva/closure_drift@v1.1.1# pre-commit, on git push
- repo: https://github.com/luizfnsilva/closure_drift
rev: v1.1.1
hooks: [{ id: closure-drift-would-tag }]Other pipelines: docs/CI.md.
For AI agents
An agent that tags and publishes can ask the same question first. integrations/
has an MCP server (standard library only) with a would_tag tool, and a rule to paste into
AGENTS.md, CLAUDE.md or .cursorrules. The server makes the check available; the agent has to
call it and respect the answer. The barrier is CI.
The answer
verdict | exit | |
| 0 | every label names one closure, over at least as many points compared as not |
| 1 | a label names more than one closure |
any other verdict (list) | 2 | not enough to tell; the report says why |
refusal | 2 | cause on stderr |
Exit 0 means clean and nothing else. No input we tried produces a traceback, and no failure exits 1.
label — the version your project declares at each tag: in its build files, in the module they point to, or the tag itself when the version is derived from it
closure — SHA-256 over
(path, git object id)of the files that determine your output
The report also says how many tags it could not compare.
Options
| would tagging this commit reuse a label? |
| only these tags are publication points (monorepos) |
| you publish at every commit |
| which files determine your output |
|
|
| which paths differ under a label in drift |
| two tags side by side |
| where the label is |
| only tags of versions you published: a local list, one per line |
|
|
| a file's mode (executable bit, symlink) is part of the closure |
| one component of a monorepo (below) |
| report (contract), README badge, bug-report block |
Settings can be committed in .closure-drift.json. Flags override it, except beside components,
where they need --component; a broken file is refused.
A monorepo declares its components, and gets one verdict each:
{"components": {
"python": {"tags": ["py-*"], "version_file": "py/pyproject.toml", "closure": ["py/**"]},
"rust": {"tags": ["rs-*"], "version_file": "rs/Cargo.toml", "closure": ["rs/**"]}
}}The answer is drift if any component is in drift, clean if all are clean, otherwise
incomplete. Components are declared, never guessed. A gate in such a repository passes
--component NAME to --would-tag.
What it found
The 100 most-downloaded PyPI projects with a public repository, at the defaults, measured with a build of 0.10.0 that prints the same reports as the release — rule and method fixed before the first run; no repository tuned (full table and every collision):
repositories | |
| 59 |
| 29 |
| 4 |
no version label found, or inconclusive | 8 |
A version label names two different code states in 29 of the 88 decided, 29 of all 100. Each
of the 87 labels is in collisions.tsv, one line per tag involved, reproducible by hand:
$ closure-drift --compare v2.16.0 v2.16.1 # in psf/requests
DIFFERS UNDER ONE LABEL: both declare 2.16.0, and the code differs in 2 path(s).A collision is not a verdict on a project. The usual causes are a tag created without bumping the
version, branch markers such as 7.x, and tag families in a monorepo. A first run, kept in the
repository, decided only 63 of 100 — it read the version from one file chosen at HEAD — and that
is why this release finds the label where each project keeps it.
Six reference repositories, measured with 1.0.0 at every tag (tools/reference/):
Repository | verdict | labels in drift | tags compared |
| drift | 3 of 66 | 71 of 71 |
| drift | 3 of 140 | 145 of 162 |
| clean | 0 of 50 | 50 of 53 |
| clean | 0 of 88 | 88 of 88 |
| drift | 2 of 4 | 6 of 15 |
| drift | 60 of 107 | 209 of 440 |
Two causes: a release tagged without bumping the version (impress.js), and tag families sharing
one version file (lodash). Neither project is badly run. --would-tag addresses the first,
--tags or components the second.
Limits
It never runs your code and attests nothing.
cleanis about addressing, not reproducibility.A change of file mode alone is not seen, unless
--modes.Never in the closure: folders
test/,tests/,spec/,docs/,vendor/,node_modules/,.git/; files named*_test.*,*.test.*,*.md.The default closure globs are a guess. Pass
--closure.Labels are compared as written:
1.0and1.0.0are two labels, unless--label-equality version.It reads git, not a package index: a tag never released counts, unless
--publishedlists what was. A tag left off the list is left out of the analysis, not shown unpublished.How the label is found is a set of rules, not a build:
docs/LABELS.md.In a gate, pass
--version-file, or--published: the rules can still read the wrong file when one tag happens to agree with it.
Every failure found so far: docs/FAILURES.md. More: SCOPE.md,
docs/WHY.md.
Safety
It starts git and, for a version pattern you supply, itself; nothing else. It never writes to the repository, and does not run commands named
in that repository's git config. What is defended and what is not:
THREAT_MODEL.md. Reporting: SECURITY.md.
Tests
Four suites, each pre-registered before the code. Scores are never added together.
suite | macOS, Python 3.14 |
| 199 declared · 198 green · 0 red · 1 not run |
| 56 mutants · 56 caught · 0 not caught |
| 315 attacks · 304 as required · 2 loose · 9 not run; the 2 loose are declared limits ( |
| 17 properties · 17 green · 0 red · 10 controls · 10 caught |
CI runs the same four on Linux (Python 3.9 to 3.14), macOS and Windows; what each platform could not
run is in
tests/RECORD.md. These scores describe the cases executed, not inputs nobody
tried. ./reproduce.sh runs all of it. The 100 projects of the study are also a regression corpus,
pinned to recorded commits: 1.1.0 gives the recorded answer on all 100, as predicted before it ran
(tools/regression/).
Ten large repositories (the Linux kernel, LLVM, CPython and seven more), protocol written
first. Every tag of the kernel: 6.5 GB for the whole process tree with 0.9.1, 900 MB with 1.0.0.
0.9.1 gave three wrong or near-empty answers there; 1.0.0 gives none of them. With a declared
version file (docs/LABELS.md) every tag of the kernel is compared: clean,
947 of 947, in four minutes.
tools/benchmark/READING.md.
Send a result
RESULTS.md is for measurements made by someone other than the author. It is still
empty. closure-drift --json > result.json, then
open an issue
or write to lfnsilva.invest@gmail.com. A result showing the tool is wrong is the most useful kind.
Version
1.1.1 fixes O11: a version file over the size limit (1 MB) is named and the answer is
incomplete, never clean. It adds integrations/ for AI agents. 1.1.0 (script sha256 e2a67a5a9148fe273d2c95ad4bcce9bc589a43711fc34443a4a9491fde575913)
adds --published, three version sources, an earlier refusal and two opt-in comparisons; with
no new option, results change only under --at commits (CHANGELOG.md). What it
had to meet was written first (tests/PREREGISTRATION.md §16), and a
reviewer who did not write it found 13 problems before the tag (docs/REVIEW-1.1.0.md).
SCOPE.md says what stays stable until 2.0.
Apache-2.0. Cite the version DOI, under concept DOI 10.5281/zenodo.21763931
(CITATION.cff). Planned next: ROADMAP.md.
Available Tools
4 toolscheck_versionsB
Does each version label in this git repository name exactly one code state across its tags? Read-only.
| Name | Required | Description | Default |
|---|---|---|---|
| repo | Yes | path to a local git repository | |
| strict | No | clean only if every tag scanned was compared | |
| published_file | No | optional file with the versions actually released, one per line |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden, and it does disclose the operation is read-only, which is the key safety fact for a mutation-averse agent. However, it says nothing about what constitutes a failure result, error behavior, or cost of scanning many tags.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two tight sentences: the core question first, the safety qualifier second. Nothing is padded, and the purpose is front-loaded.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
There is no output schema and no annotations, so the description should clarify what the tool returns (a boolean verdict, offending labels, etc.) and how strict/published_file alter the result. It defines the check conceptually but leaves result interpretation to inference.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so repo, strict, and published_file are already documented in the schema. The description never references strict or published_file, so it adds no meaning beyond the provided field descriptions; baseline 3 applies.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a precise check: whether each version label names exactly one code state across tags in a git repository. The resource (version labels, tags, repo) is specific, though the verb is framed as a question rather than an action, and no sibling tool is named for contrast.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
There is no guidance on when to run this versus siblings like would_tag, explain_label, or compare, and no prerequisites stated beyond needing a repository. 'Read-only' hints at safe usage but is not a routing condition.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
compareB
Compare two tags or commits: their version labels, closures and the paths that differ. Read-only.
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes | ||
| b | Yes | ||
| repo | Yes | path to a local git repository |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the burden; it does declare 'Read-only,' which substitutes for readOnlyHint and is the key safety fact. It also names the categories of output (labels, closures, differing paths). It stops short of describing error behavior for unknown refs or whether the diff is symmetric.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
One dense sentence plus a two-word safety tag. The operation and its outputs are front-loaded with zero filler; every clause carries information.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a 3-parameter read-only tool with no output schema, the description adequately conveys inputs and output categories but omits directionality of a vs b, behavior on invalid refs, and any pagination or size limits on the differing-paths list.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 33%: only 'repo' is documented in the schema. The description compensates by explaining that a and b are 'two tags or commits', which is the essential semantics of those two params. It does not clarify ordering/direction of the comparison, which matters for interpreting 'paths that differ'.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific verb (compare) and the resources it operates on (two tags or commits), plus what is produced: version labels, closures, and differing paths. It is clear on its own, though it never contrasts itself with siblings like check_versions or explain_label.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No explicit when-to-use guidance, prerequisites, or named alternatives. The phrase 'two tags or commits' implies the input context, but an agent must infer when compare is preferable to check_versions or explain_label.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
explain_labelB
List the paths that differ under one version label found in drift. Read-only.
| Name | Required | Description | Default |
|---|---|---|---|
| repo | Yes | path to a local git repository | |
| label | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full disclosure burden. It does state 'Read-only', which usefully signals a safe non-mutating operation, but it says nothing about how it behaves when the label is absent, what 'drift' refers to, or any error outcomes.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two short sentences with the core action front-loaded and zero padding; 'Read-only' is a clipped fragment but semantically efficient. Appropriately sized for a simple list operation.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a two-param read tool with no annotations and no output schema, the description is minimally adequate: it explains the action and lists paths. However, it never defines 'drift', gives no sense of the returned list's structure, and leaves one parameter unaddressed.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 50%: 'repo' is documented in the schema, but 'label' has no schema description. The description partially compensates by clarifying 'label' as a 'version label', adding meaning beyond the schema, but 'repo' receives no additional context.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific verb and resource: list the differing paths under a version label. This is clear enough to act on, but it does not differentiate itself from the sibling 'compare' tool, which likely also surfaces differences, leaving the agent to infer which is appropriate.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
There is no when-to-use guidance, no condition selecting this over alternatives like 'compare' or 'check_versions', and no prerequisites stated. The only guidance-like content is 'Read-only', which is a safety trait rather than usage direction.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
would_tagA
Run BEFORE creating a release tag: would HEAD reuse a version label that already names other code? Read-only.
| Name | Required | Description | Default |
|---|---|---|---|
| repo | Yes | path to a local git repository |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden, and it does disclose the key behavioral trait: "Read-only." That tells the agent the operation is non-mutating. It doesn't cover return format or edge-case behavior, but for a simple pre-flight query that is a minor gap.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single tight sentence that front-loads the operative guidance ("Run BEFORE creating a release tag") and ends with the safety trait. No wasted words.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a one-parameter, read-only pre-flight check with no output schema, the description supplies the purpose, timing, and safety profile an agent needs. Only the expected result format is left implicit, which is acceptable here.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100% with a single required parameter (repo, documented as "path to a local git repository"). The description adds no additional parameter detail, so the schema does the heavy lifting; baseline 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb and resource: checking whether HEAD would reuse a version label already naming other code. It clearly frames the operation as a tag-label collision check, though the phrasing as a question is slightly indirect and doesn't explicitly name the sibling it differs from (check_versions, explain_label, compare).
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
"Run BEFORE creating a release tag" gives explicit timing/context for when to invoke the tool. It stops short of naming alternatives or when-not conditions, but the trigger condition is unambiguous.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
4 tool updates
v1.1.1- First observed
check_versions - First observed
compare - First observed
explain_label - First observed
would_tag
TDQS
Scored across 4 tools
Each tool has a distinct read-only purpose: repository-wide label check, HEAD preflight, per-label path explanation, and two-ref comparison. However, explain_label and compare both list differing paths, and would_tag is a specific case of check_versions, creating minor overlap.
All names use snake_case, but the verb patterns are mixed: check_versions and explain_label follow verb_noun, compare is a bare verb, and would_tag is an unusual modal_verb construction. The inconsistency is noticeable though names remain readable.
Four tools is well-scoped for a specialized read-only drift-analysis server; each tool covers a distinct analysis step (bulk check, preflight, explain, compare) and none feels redundant.
The set covers the core drift-analysis workflow: detect drift, preflight a tag, investigate a drifting label, and compare refs. A minor gap is the lack of a standalone tool to list all version labels or inspect a single non-drift label's closure.
Maintenance
Related MCP Connectors
MCP server for visual regression testing: triage a PR's UI diffs from your coding agent.
Ovanek MCP: Model Context Protocol server for Ovanek platform tools; writes are dry-run by default.
MCP server (stdio): validate JSON against JSON Schema (draft-07 / 2020-12) via the AgentForge API
Related MCP Servers
- FlicenseCqualityDmaintenanceMCP server providing Git-related functionalities, primarily a tool to generate diffs for Git merge commits against their first parent.4-
- AlicenseAqualityCmaintenanceMCP Server providing AI agents with tooling for Gerrit code review workflows via stdio transport.1810 npm1MIT
- AlicenseNot gradedqualityBmaintenanceZero-dependency stdio MCP server for token-aware prompt version diffs. Compare prompts or files and get machine-readable token delta reports with confidence labels.MIT
- AlicenseNot gradedqualityAmaintenanceA local git MCP server. It exposes 12 git operations to an MCP client over stdio, allowing the client to inspect and work with a git repository on your machine, including status, diffs, log, branches, staging, and commits.MIT