Skip to content

feat: block dependencies that don't exist on their registry - #91

Merged
algomaster99 merged 3 commits into
mainfrom
feat/flag-hallucinated-packages
Oct 15, 2026
Merged

algomaster99 merged 3 commits into
mainfrom
feat/flag-hallucinated-packages

Conversation

@algomaster99

@algomaster99 algomaster99 commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

When a package's registry answers 404 (or 410 from the Go proxy) and the ecosyste.ms fallback doesn't know the package either, the hook now blocks the write and tells the agent the name is likely hallucinated. Before, an unknown package made pins.Diff error out and the hook failed open, so a made-up name went through silently. Network errors, rate limits and 5xx responses still fail open.

Writing requirements.txt with requests==2.34.2 and huggingface-cli-utils==0.3.1, before:

hook: resolving huggingface-cli-utils: no latest version found
exit=0

After:

these dependencies don't exist on their registry, so they're likely hallucinated; use a real package instead:
  huggingface-cli-utils  0.3.1
exit=2

The same check applies to pins made through npm install/pip install/cargo add/go get on Bash, and yul scan lists such dependencies in their own group. go.mod modules with a replace directive (e.g. a local ../lib) are skipped, since they're expected to be missing upstream. A newly added Maven -SNAPSHOT that's missing on Central is blocked like any other missing dependency. Scoped npm packages are unaffected because npm answers 401, not 404, for a missing scope, and GitHub Actions aren't covered.

One known gap: an unscoped package hosted only on a private registry (an .npmrc registry, a private pip index, an internal Nexus) also 404s on the public one, so it gets blocked too.

None of the final manifests in the DeepSeek V4.1 Flash and Opus 5.5 benchmark runs trip the new check.

🤖 Generated with Claude Code

A 404 (or the Go proxy's 410) from a package's registry, unconfirmed by
the ecosyste.ms fallback, now blocks the write as a likely hallucinated
name instead of failing open. go.mod modules with a replace directive and
Maven -SNAPSHOT versions are skipped, since they're expected to be missing
upstream.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread pkg/maven/pom.go Outdated
A -SNAPSHOT version that's missing on Maven Central is no longer exempted
from the hallucinated-dependency check. One already present before the
write is still left alone, since pins.Diff only checks new or changed pins.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread pkg/util/pins/pins_test.go Outdated
The not-found check only looks at the package name, so a range pin
doesn't exercise anything an exact pin doesn't.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@algomaster99
algomaster99 merged commit e26e665 into main Oct 15, 2026
2 checks passed
@algomaster99
algomaster99 deleted the feat/flag-hallucinated-packages branch October 15, 2026 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant