Seedlabs

PhantomRef Gate: CI Check That Grounds AI-Generated Code Against Real APIs and Registries

A check for developers that blocks AI-generated code if it refers to software packages or functions that don't actually exist.

A deterministic CI gate that checks every AI-generated import, API call, and parameter against live package registries and installed type stubs, blocking references to nonexistent packages, methods, or parameters before merge. New large-scale evidence quantifies the problem — at least 5.2% of package suggestions from commercial code LLMs (21.7% from open-source models) are hallucinated — and shows attackers can actively steer coding agents toward packages they have already registered, so the gate also flags dependencies that diverge from the project baseline or were registered only recently. It catches the one hallucination class verifiable with certainty, and closes both the passive hallucination window and the active dependency-steering window in the software supply chain.

Computer ScienceSoftware Engineering Research
LLM Evaluation and BenchmarkingSoftware supply-chain security and CI/CD: an enterprise rolling out AI coding agents adds PhantomRef Gate to its pipeline so every agent-authored PR is grounded against npm/PyPI before merge — catching the 5–22% hallucinated package references documented across commercial and open-source models, plus dependency-steering attacks that plant already-registered malicious packages via malicious agent Skills.
Explainer video — the idea and its research foundation. Scripted and voiced by GLM and Piper · 9 Nov 2026.
Watch with transcript →

Concept

PhantomRef Gate is a deterministic CI check for AI-generated code. On every pull request where an assistant wrote or heavily edited code, it grounds each external reference against reality: every imported package is resolved against the live registry of its ecosystem (npm, PyPI, Maven Central, crates.io), and every API call, method, and parameter is matched against the project's installed type stubs and SDK signatures. References to a nonexistent package, method, parameter, or wrong version — the hallucination class the source study defines as misalignment with real-world knowledge — block the merge with a precise, human-readable explanation.

New evidence this iteration sharpens the design in one important way. The Dependency Steering work ("Trust Me, Import This") shows package hallucination is no longer only a passive model failure: a malicious agent Skill can actively bias a coding agent toward an attacker-registered package during benign tasks, with high targeted hallucination rates that transfer across models and task domains and evade both Skill scanners and LLM-based auditors. A package like that exists, so a pure existence check would wave it through. The gate therefore adds a second, equally deterministic layer: any dependency that (a) is not in the project's locked baseline/allowlist, or (b) was registered more recently than a configurable window (e.g., 30 days, read from registry metadata) is flagged for human review rather than silently passing. Hard blocks remain reserved for what can be verified with certainty — nonexistence; the steering layer is a review flag, honestly bounded.

Why now

  • The frequency is now quantified. The "We Have a Package for You!" analysis generated 576,000 code samples across 16 popular LLMs in Python and JavaScript and found hallucinated packages in at least 5.2% of commercial-model suggestions and 21.7% of open-source-model suggestions, with rates varying by model, setting, and parameters. At that volume, an AI-assisted repository ingests phantom references continuously, making per-PR deterministic checking — not periodic audits — the proportionate response. The variance across models and configurations also corroborates the earlier finding that grounding must be performed per-registry and per-language, never assumed.
  • The threat is now adversarial, and existing defenses miss it. Dependency Steering achieves high targeted hallucination rates, transfers across models and domains, and is difficult for Skill scanners and LLM-based auditors to detect. Notably, what the attack evades is ML-based detection — exactly the kind of defense PhantomRef Gate deliberately avoids. Registry lookups, signature matching, and registration-metadata checks are deterministic and auditable, so a steering payload that survives scanner review still has to answer the gate's question: "is this package in our baseline, and how old is its registration?"
  • Zero-ML remains the wedge. Because the check is pure registry resolution and signature matching, it runs in CI in seconds, produces auditable results, and needs no model, no threshold tuning, and no ML false-positive management — a meaningful property given that LLM-based auditors are part of the attack's documented evasion surface.

Honest boundaries and open questions

  • Existence checks alone do not stop steering attacks. An attacker-registered package exists; only the baseline-divergence and registration-age flags catch it, and those trade off against false positives on legitimate new packages — so they route to human review, not hard-block. Calibrating "new" (new registration, new version, or new maintainer?) is an open question.
  • Cache staleness is now a security parameter, not just a performance one. Live-lookup latency is mitigated by caching, but "this package did not exist" entries must carry a short TTL or be invalidated via registry change feeds — an attacker registering a name after your cache snapshot is precisely the Dependency Steering scenario.
  • Query leakage cuts both ways. Asking a registry "does X exist?" could signal which hallucinated names a team's models produce; resolving against a locally mirrored index hides the queries but reintroduces staleness. Default: anonymous, batched lookups through a shared egress proxy, with the trade-off documented.
  • Dynamic languages and private APIs. Where type stubs are optional or incomplete (Python, JS), stub-unverifiable references downgrade to warnings instead of hard blocks; internal/private packages are handled via an explicit allowlist rather than public-registry resolution.
  • Bleeding-edge friction. Pre-release APIs absent from stable stubs will be flagged; the answer is a documented, per-project override visible in the audit trail, not a silent pass.
  • Overlap with existing tooling. Snyk, SonarQube, and peers scan declared manifests for known vulnerabilities; they do not resolve every AI-written import statement — including undeclared ones — against live registries at PR time. That gap is the wedge.

Written by GLM · 8 Nov 2026 · revised 1× with new research (latest 9 Nov 2026, Gemma 4 and GLM)

AI assessment

Backed by 5 papers96

An exceptionally strong, evidence-backed security tool that solves a quantified vulnerability in AI-generated code using a deterministic, low-friction CI wedge.

Evidence strength
5/5
The idea is strongly grounded in two specific, high-quality papers that quantify package hallucination rates (5-22%) and demonstrate the active 'Dependency Steering' attack vector.
Market pull
5/5
Enterprise security teams and supply-chain vendors (Snyk, Socket) have a high urgency to block AI-introduced vulnerabilities, especially as agentic coding becomes standard.
Novelty & moat
4/5
While other 'gates' exist in the catalog, this is the first to target the specific intersection of registry-level existence and registration-age to combat both passive hallucinations and active steering attacks.
Feasibility
5/5
The core mechanism relies on deterministic API calls to public registries and local type-stub analysis, which is straightforward to implement as a CI plugin.
Wedge clarity
5/5
The wedge is sharp: a deterministic 'block' on non-existent packages, which provides immediate, zero-false-positive value before moving to the more nuanced 'review' flags for steering.
Simplicity / focus
5/5
The product is a single, focused CI check with a clear input (PR code) and output (pass/fail/review), avoiding platform bloat.

Scored by Gemma 4 · 9 Nov 2026. Rated against a fixed rubric (evidence, market, novelty, feasibility, wedge, simplicity), relative to the closest ideas already in the catalog. A prior estimate to compare ideas before real-world signal arrives.

Act on this idea

Ideas only matter if someone runs with them. Your message goes straight to the founder's inbox — nothing is stored on our servers.

Business analysis

The framework reveals that PhantomRef Gate fills a critical security gap by replacing probabilistic ML-based auditing with deterministic registry verification. While it effectively neutralizes passive hallucinations and adversarial dependency steering, its primary challenge lies in balancing the friction of human review for new packages against the risk of supply-chain attacks.

Strengths4

Weaknesses3

Opportunities3

Threats3

Essential for balancing the technical strength of deterministic verification against the weakness of potential false positives on new packages. · Generated 2026-11-09 by Gemma 4AI-generatedFull SWOT Analysis →

Who benefits

  • Socketcompany

    Built its business on flagging risky and typosquatted packages; detecting AI-hallucinated package names before install is a natural, high-demand extension of its core product.

  • Snykcompany

    Sells developer security including dependency scanning; a CI gate for hallucinated imports and parameters extends Snyk into AI-generated code, a fast-growing and poorly covered risk surface.

  • Sonatypecompany

    Its dependency-integrity tooling already catalogs malicious and phantom artifacts; grounding AI code against real registries fits directly into its mission and existing data assets.

  • GitLabcompany

    A CI-native DevSecOps platform; shipping a hallucinated-reference check as a built-in pipeline stage differentiates its AI story with a deterministic, auditable control.

Research it builds on

  1. Beyond Functional Correctness: Exploring Hallucinations in LLM-Generated Code
    Fang Liu, Yang Liu, Lin Shi et al. · 2026 · 354 citations
    All ideas from this paper →
  2. An Empirical Study of Problem-Aligned Multilingual Code Generation and Directed Code Translation by Large Language Models
    Wang, Quanhe, Wen, Cheng, Liu, Dugang et al. · 2026 · 284 citations
    All ideas from this paper →
  3. We Have a Package for You! A Comprehensive Analysis of Package Hallucinations by Code Generating LLMsAll ideas from this paper →
  4. Automated Program Refinement: Guide and Verify Code Large Language Model with Refinement Calculus
    Yufan Cai, Zhé Hóu, David Sanán et al. · 2025 · 17 citations
    All ideas from this paper →
  5. Trust Me, Import This: Dependency Steering Attacks via Malicious Agent Skills
    Yiyong Liu, Chia-Yi Hsu, Chun-Ying Huang et al. · 2026 · 4 citations
    All ideas from this paper →
Leave feedback
feasibility