Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 33 additions & 4 deletions .claude/skills/deep-code-review/scripts/dependency_currency.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@
("gradle", "org.springframework:spring-webmvc"): "spring-framework", ("gradle", "org.springframework:spring-webflux"): "spring-framework",
("gradle", "org.springframework:spring-aop"): "spring-framework", ("gradle", "org.springframework:spring-jdbc"): "spring-framework",
("gradle", "org.springframework:spring-tx"): "spring-framework", ("gradle", "org.springframework:spring-orm"): "spring-framework",
("gradle", "org.springframework:spring-expression"): "spring-framework", ("gradle", "org.springframework:spring-test"): "spring-framework"}
("gradle", "org.springframework:spring-expression"): "spring-framework", ("gradle", "org.springframework:spring-test"): "spring-framework",
("maven", "io.dropwizard:dropwizard-core"): "dropwizard", ("gradle", "io.dropwizard:dropwizard-core"): "dropwizard",
("maven", "io.dropwizard:dropwizard-bom"): "dropwizard", ("gradle", "io.dropwizard:dropwizard-bom"): "dropwizard"}
RT_TOOLS = {"nodejs": "nodejs", "node": "nodejs", "python": "python", "ruby": "ruby", "golang": "go", "go": "go", "rust": "rust", "php": "php", "elixir": "elixir", "erlang": "erlang"}


Expand Down Expand Up @@ -614,7 +616,7 @@ def versions(eco, name, cur=""):
vs = [v for v, fs in d["releases"].items() if fs and not all(f.get("yanked") for f in fs)]
elif eco == "go":
esc = "/".join(q(re.sub(r"[A-Z]", lambda m: "!" + m[0].lower(), x), safe="!") for x in name.split("/"))
vs = [v for v in net.get(f"https://proxy.golang.org/{esc}/@v/list").split() if "+incompatible" not in v]
vs = [v for v in net.get(f"https://proxy.golang.org/{esc}/@v/list").split() if "+incompatible" not in v] # the proxy's @latest skips +incompatible tags once a module has a go.mod; ponytail: a pre-modules repo whose only newer major is +incompatible reads as current, query @latest if that matters
elif eco in ("maven", "gradle"):
g, a = name.split(":")
gp = "/".join(qp(x) for x in g.split("."))
Expand Down Expand Up @@ -649,12 +651,21 @@ def ls_remote_latest(repo, err):
return max(tags, key=vkey)


FLOAT_TAGS = {} # repo -> highest tag found behind a floating major release, so many `uses:` lines of one action cost one ls-remote


def gh_latest(repo):
"""Return the latest stable release tag of an owner/repo: releases/latest, else the highest stable tag."""
repo = qp(repo)
try:
try:
return net.json(f"https://api.github.com/repos/{repo}/releases/latest")["tag_name"]
tag = net.json(f"https://api.github.com/repos/{repo}/releases/latest")["tag_name"]
if re.fullmatch(r"v?\d+", tag): # a floating major alias ("v6") lags point releases such as v6.1.2: take the highest tag instead
try:
tag = FLOAT_TAGS[repo] if repo in FLOAT_TAGS else FLOAT_TAGS.setdefault(repo, ls_remote_latest(repo, OSError()))
except OSError:
pass # a failed ls-remote is not cached; the alias tag stands
return tag
except NotFound:
t = [e["name"] for e in net.json(f"https://api.github.com/repos/{repo}/tags?per_page=100") if re.match(r"v?\d+(\.\d+)*$", e["name"])]
if not t:
Expand Down Expand Up @@ -903,7 +914,7 @@ def read(root, rel):


VENDOR_CAP = 200 # vendored rows listed before one overflow row
VMANIFEST = re.compile(r"package\.json|composer\.json|go\.mod|pom\.xml|Cargo\.toml|pyproject\.toml|setup\.py|.*\.gemspec")
VMANIFEST = re.compile(r"PKG-INFO|package\.json|composer\.json|go\.mod|pom\.xml|Cargo\.toml|pyproject\.toml|setup\.py|.*\.gemspec")


def vendored_rows(root, files):
Expand All @@ -926,6 +937,8 @@ def vendored_rows(root, files):
txt = read(root, mf) if mf and not (DEADLINE and time.time() > DEADLINE) else None # reads count against --budget
if txt and mf.endswith(("package.json", "composer.json")):
name = json.loads(txt).get("name") or name
elif txt and mf.endswith("PKG-INFO"):
name = re.search(r"(?m)^Name:\s*(\S+)", txt)[1]
elif txt and mf.endswith("go.mod"):
name = re.search(r"(?m)^module\s+(\S+)", txt)[1]
elif txt and mf.endswith(("Cargo.toml", "pyproject.toml")):
Expand Down Expand Up @@ -1175,6 +1188,9 @@ def gsub(f, txt):
elif b in ("rust-toolchain", "rust-toolchain.toml"):
if (m := re.search(r"""(?m)^\s*(?:channel\s*=\s*["'])?(\d+\.\d+(?:\.\d+)?)\b""", txt)): # nightly/stable/beta float: no version to compare
rows.append(("runtime", f, "rust", m[1], "rust"))
elif b == "gradle-wrapper.properties":
if (m := re.search(r"(?m)^distributionUrl=.*/gradle-(\d+(?:\.\d+)*)-(?:bin|all)\.zip", txt)):
rows.append(("runtime", f, "gradle", m[1], "gradle"))
elif b in (".tool-versions", "mise.toml", ".mise.toml"):
rows.extend(("runtime", f, prod, ver, prod) for prod, ver in p_tool_versions(txt, b))
elif b in (".nvmrc", ".node-version", ".python-version", ".ruby-version", ".php-version"):
Expand Down Expand Up @@ -1278,6 +1294,19 @@ def piplock(d):
deps.extend((f, "pip", n, v) for n, s in specs if (v := exact("pip", s)))
except Exception as e:
nr(f, b, f"could not parse ({type(e).__name__}: {e})")
gd = {} # one module declared at different versions in two files of the same Gradle project (build file vs version catalog, ...)
for f, eco, n, v in deps:
b, d = os.path.basename(f), os.path.dirname(f)
if eco == "gradle" and b != "gradle.lockfile" and not is_pre("gradle", v):
gd.setdefault((os.path.dirname(d) if b.endswith(".versions.toml") and os.path.basename(d) == "gradle" else d, n), set()).add((v, f))
for (_, n), m in sorted(gd.items()):
per = {}
for v, f in m:
per.setdefault(f, set()).add(pk("gradle", v))
if len(per) > 1 and all(len(s) == 1 for s in per.values()) and len(set().union(*per.values())) > 1: # a file that itself declares two versions (two catalog aliases) is ambiguous: skip
s = sorted(m, key=lambda x: pk("gradle", x[0]))
(v, f), (v2, f2) = s[0], s[-1] # lowest vs highest: different versions, so different files
rows.append(row(f, n, "gradle", "drift", v, note=f"{f} declares {v} but {f2} declares {v2}; one of them is stale"))
return deps, rows


Expand Down
2 changes: 1 addition & 1 deletion .claude/skills/deep-code-review/scripts/review_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ fi
# Built-in, no tool to install: dependency currency (dependency_currency.py). Reads each changed manifest, lockfile (direct + transitive), Dockerfile, workflow and runtime pin (vendored dirs are flagged), asks the ecosystem registries for the newest stable release,
# OSV for known vulnerabilities and CISA KEV for exploited ones, and endoflife.date for end-of-life runtimes. Rows: tool dep-currency, rule kev|vulnerable|eol|outdated|drift|unpinned|vendored|not-checked (KEV first); a lookup that fails is a not-checked row (NOT RUN), never "up to date". Needs network; unleased.
dc="$here/dependency_currency.py"
dcf=$(printf '%s\n' "$all" | grep -E '(^|/)(package(-lock)?\.json|npm-shrinkwrap\.json|uv\.lock|setup\.py|\.tool-versions|\.?mise\.toml|\.php-version|vendor/composer/installed\.json|buildSrc/.*\.kt|yarn\.lock|[^/]*(requirements|constraints?)[^/]*\.(txt|in)|(requirements?|reqs?)/[^/]+\.(txt|in)|poetry\.lock|Pipfile(\.lock)?|setup\.cfg|rust-toolchain(\.toml)?|gradle\.properties|go\.mod|pom\.xml|[^/]*\.gradle(\.kts)?|gradle\.lockfile|lockfile\.json|[^/]*\.versions\.toml|Cargo\.(toml|lock)|composer\.(json|lock)|Dockerfile[^/]*|[^/]*\.Dockerfile|\.nvmrc|\.node-version|\.python-version|\.ruby-version|pnpm-lock\.yaml|pyproject\.toml|(docker-)?compose[^/]*\.ya?ml|action\.ya?ml|\.github/(workflows|actions)/.*\.ya?ml)$' || true)
dcf=$(printf '%s\n' "$all" | grep -E '(^|/)(package(-lock)?\.json|npm-shrinkwrap\.json|uv\.lock|setup\.py|\.tool-versions|\.?mise\.toml|\.php-version|vendor/composer/installed\.json|buildSrc/.*\.kt|yarn\.lock|[^/]*(requirements|constraints?)[^/]*\.(txt|in)|(requirements?|reqs?)/[^/]+\.(txt|in)|poetry\.lock|Pipfile(\.lock)?|setup\.cfg|rust-toolchain(\.toml)?|gradle\.properties|gradle-wrapper\.properties|go\.mod|pom\.xml|[^/]*\.gradle(\.kts)?|gradle\.lockfile|lockfile\.json|[^/]*\.versions\.toml|Cargo\.(toml|lock)|composer\.(json|lock)|Dockerfile[^/]*|[^/]*\.Dockerfile|\.nvmrc|\.node-version|\.python-version|\.ruby-version|pnpm-lock\.yaml|pyproject\.toml|(docker-)?compose[^/]*\.ya?ml|action\.ya?ml|\.github/(workflows|actions)/.*\.ya?ml|PKG-INFO)$' || true) # PKG-INFO: a vendored Python package has no package.json-style manifest, only this
dcy=$(printf '%s\n' "$all" | grep -E '\.ya?ml$' | tr '\n' '\0' | xargs -0 grep -lsE -m1 -- '^apiVersion:' || true) # Kubernetes manifests: container images
[ -n "$dcy" ] && dcf=$(printf '%s\n%s\n' "$dcf" "$dcy" | sed '/^$/d' | sort -u)
if [ -n "$dcf" ]; then
Expand Down
4 changes: 2 additions & 2 deletions SHA256SUMS
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ ed0f0c1eebfdca4dcbaafbf5c2f7b5cc93884de38715b57db894e0f210a811f9 .claude/skills
6632d4fa969875bb8a26fd8fd1677c3a5eaeeadbea00cb28c88a22d3d9dd4138 .claude/skills/deep-code-review/scripts/context_pack.py
1e278d17eebac5688697ac8932e7b6f638343b55aecb8536bf7761bdf2c939ef .claude/skills/deep-code-review/scripts/cost_limit_map.py
c5b40f3f0d3fb174e6c9490150c7b85723de33f95d3fab87d60214d4939401a8 .claude/skills/deep-code-review/scripts/coverage_ledger.py
012c657088021d8e8d58a36adae8955f03a1cec15b7326952dac37114f21570b .claude/skills/deep-code-review/scripts/dependency_currency.py
ab34c3abf14ca8fcbb1a5e95c4837634b2523ea31f9459b3b284cde9ae7eea56 .claude/skills/deep-code-review/scripts/dependency_currency.py
36c1447a65135496c519397c04c6a74ef066bd01399d593907e598b8d2038498 .claude/skills/deep-code-review/scripts/derived_numbers.py
662031286d4a29aff2e1aaa5cb4fa287ab99f9c7b5124085ea47da3dc66622cc .claude/skills/deep-code-review/scripts/design_drift.py
254f1016d76feb5fc2c26925b74ccc1158343d5075efcf875ef1a60305bab827 .claude/skills/deep-code-review/scripts/dynamic_probe.py
Expand Down Expand Up @@ -403,7 +403,7 @@ e2903a566deee3423cc377b000475b30d6698ccebd640cb62b86b6d2001c4822 .claude/skills
b01cae69d80ca560cc414c1c70ef0ddfdbb910da5b68df4e9d46cf0daf3f8b16 .claude/skills/deep-code-review/scripts/provision_tools.sh
e1d1d2eab715ef280b8c211a9da15ebe6b87969de89d7028d7f1cc82d64fc1f0 .claude/skills/deep-code-review/scripts/reaper_lint.py
8545b85530f9c456880faf1d5613e7106467a20c58c97bdff2d745e7e86c2585 .claude/skills/deep-code-review/scripts/report_contract_lint.py
a8995d870cb71f0b71132888f1b8992da73a80c70d5adf8c687e7e97bf17431a .claude/skills/deep-code-review/scripts/review_checks.sh
270a967799de09cb74b79effe32cfce8ae600716fc418ebe2ef231391209b822 .claude/skills/deep-code-review/scripts/review_checks.sh
8c87c02a050a975e453b52ecacbaf01481c7134466a9c67feaf409d22e36d9f7 .claude/skills/deep-code-review/scripts/review_feedback.py
3d0cee729ca0dc743ebef83b96e6bff55c167445570635a800caa0c0a84e6843 .claude/skills/deep-code-review/scripts/route_auth_map.py
859c67d6a6a781c873f47d5662d403da2321da53e6994ca3d0ccdbf74afd39ac .claude/skills/deep-code-review/scripts/score_review.py
Expand Down
2 changes: 2 additions & 0 deletions changelog.d/currency-set7-root-causes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### Fixed
- Currency detector, five set-7 misses: a GitHub release tagged with a bare major (`v6`) no longer hides newer point-release tags (one `git ls-remote` per repo); Dropwizard coordinates feed the end-of-life check; `gradle-wrapper.properties` is a Gradle runtime pin; the same Gradle module at two versions in a build file and a version catalog is a drift row (not when one file itself declares two versions, such as two catalog aliases); `review_checks.sh` hands `PKG-INFO` to the detector, so a vendored Python package (no package.json-style manifest) gets its vendored row. The sixth set-7 miss (Go `github.com/mattn/go-sqlite3`) was a truth error, not a detector miss: the Go proxy's `@latest` is v1.14.x, while the set-7 truth recorded v2.0.3+incompatible. The detector keeps `+incompatible` tags out of latest, and a regression test pins that.
2 changes: 2 additions & 0 deletions scripts/ci-tests.d/dependency-currency-g5r15.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Registers the set-7 currency root-cause regression tests (Go +incompatible, floating major tag, Dropwizard EOL, Gradle wrapper pin, Gradle catalog drift, vendored dir without manifest). Offline.
python3 scripts/test_dependency_currency_g5r15.py
86 changes: 86 additions & 0 deletions scripts/test_dependency_currency_g5r15.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/usr/bin/env python3
"""Regression tests for dependency_currency.py / review_checks.sh root causes found by the set-7 scored run: Go +incompatible tags stay out of latest, a floating
major release tag hiding point releases, framework EOL for Dropwizard, the Gradle wrapper as a runtime pin, Gradle build-file vs version-catalog drift, and
vendored dirs that hold no recognised manifest. Fictional names; every HTTP call mocked."""
import importlib.util, os, re, tempfile, unittest

HERE = os.path.dirname(os.path.abspath(__file__))
spec = importlib.util.spec_from_file_location("dc", os.path.join(HERE, "..", ".claude/skills/deep-code-review/scripts/dependency_currency.py"))
dc = importlib.util.module_from_spec(spec)
spec.loader.exec_module(dc)


def collect(files):
"""Write files (path -> text) to a temp repo and return dc.collect's (deps, rows)."""
with tempfile.TemporaryDirectory() as d:
for f, t in files.items():
os.makedirs(os.path.dirname(os.path.join(d, f)) or d, exist_ok=True)
with open(os.path.join(d, f), "w") as fh:
fh.write(t)
return dc.collect(d, sorted(files), "2026-11-04")


class G5R15(unittest.TestCase):
def test_go_incompatible_tag_is_not_latest(self):
"""A +incompatible tag is not the module's latest: the Go proxy's @latest skips it once the module has a go.mod (go-sqlite3: v1.14.x, not v2.0.3+incompatible)."""
old = dc.net.get
dc.net.get = lambda url, data=None, headers=None: "v1.0.0\nv1.0.9\nv3.1.0+incompatible\n"
try:
self.assertEqual(dc.versions("go", "example.com/fict/mod")[-1], "v1.0.9")
finally:
dc.net.get = old

def test_floating_major_release_tag_does_not_hide_point_releases(self):
"""releases/latest tagged `v6` while v6.1.2 exists: the highest tag wins, so v6.1.0 is behind it."""
old_net, old_ls = dc.net.json, dc.ls_remote_latest
dc.net.json = lambda url, headers=None: {"tag_name": "v6"}
calls = []
dc.ls_remote_latest = lambda repo, err: calls.append(repo) or "v6.1.2"
try:
self.assertEqual([dc.gh_latest("fict/act") for _ in range(3)], ["v6.1.2"] * 3)
finally:
dc.net.json, dc.ls_remote_latest = old_net, old_ls
self.assertEqual(calls, ["fict/act"]) # one ls-remote per repo, however many `uses:` lines name it

def test_dropwizard_core_is_a_framework(self):
"""io.dropwizard:dropwizard-core feeds the endoflife.date `dropwizard` product, in Maven and Gradle."""
self.assertEqual({dc.FRAMEWORKS[(e, "io.dropwizard:dropwizard-core")] for e in ("maven", "gradle")}, {"dropwizard"})

def test_gradle_wrapper_is_a_runtime_pin(self):
"""gradle-wrapper.properties distributionUrl yields a `gradle` runtime tuple (bin and all distributions)."""
for kind in ("bin", "all"):
_, rows = collect({"gradle/wrapper/gradle-wrapper.properties": f"distributionUrl=https\\://services.example.com/distributions/gradle-7.4.1-{kind}.zip\n"})
self.assertEqual([r[2:4] for r in rows if isinstance(r, tuple)], [("gradle", "7.4.1")])

def test_gradle_build_file_vs_catalog_drift(self):
"""The same module at two versions in build.gradle and gradle/libs.versions.toml (no lockfile) is a drift row; equal versions are not."""
files = {"build.gradle": 'dependencies { implementation "org.fict:lib:1.0.1" }\n',
"gradle/libs.versions.toml": '[versions]\nlib = "1.0.3"\n[libraries]\nlib = { module = "org.fict:lib", version.ref = "lib" }\n'}
_, rows = collect(files)
self.assertEqual([r["name"] for r in rows if isinstance(r, dict) and r["status"] == "drift"], ["org.fict:lib"])
files["build.gradle"] = files["build.gradle"].replace("1.0.1", "1.0.3")
_, rows = collect(files)
self.assertEqual([r for r in rows if isinstance(r, dict) and r["status"] == "drift"], [])
files["gradle/libs.versions.toml"] = '[libraries]\nlib = "org.fict:lib:1.0.3"\nlib-old = "org.fict:lib:1.0.1"\n' # two aliases in one file: ambiguous, no row
_, rows = collect(files)
self.assertEqual([r for r in rows if isinstance(r, dict) and r["status"] == "drift"], [])

def test_vendored_dir_without_manifest_gets_a_row(self):
"""A vendored dir holding only PKG-INFO and sources is one vendored row named from PKG-INFO's Name; review_checks.sh now hands PKG-INFO over."""
rows = dc.vendored_rows(os.path.join(HERE, "nonexistent"), ["vendor/fictpkg/fictpkg.py"])
self.assertEqual([(r["file"], r["status"]) for r in rows], [("vendor/fictpkg", "vendored")])
with tempfile.TemporaryDirectory() as d:
os.makedirs(os.path.join(d, "vendor/x"))
with open(os.path.join(d, "vendor/x/PKG-INFO"), "w") as fh:
fh.write("Metadata-Version: 2.1\nName: fictpkg\nVersion: 1.0.5\n")
self.assertEqual([r["name"] for r in dc.vendored_rows(d, ["vendor/x/PKG-INFO", "vendor/x/m.py"])], ["fictpkg"])
with open(os.path.join(HERE, "..", ".claude/skills/deep-code-review/scripts/review_checks.sh")) as fh:
sh = fh.read()
rx = re.search(r"dcf=\$\(printf '%s\\n' \"\$all\" \| grep -E '(.*)' \|\| true\)", sh)[1]
for f in ("vendor/fictpkg/PKG-INFO", "gradle/wrapper/gradle-wrapper.properties"):
self.assertTrue(re.search(rx.replace("[^/]*", "[^/]*"), f), f)
self.assertFalse(re.search(rx, "vendor/fictpkg/fictpkg.py"))


if __name__ == "__main__":
unittest.main()
Loading