Skip to content

Check new listings against GitHub, PyPI and npm in CI - #74

Open
Ker102 wants to merge 1 commit into
mainfrom
listing-source-check
Open

Ker102 wants to merge 1 commit into
mainfrom
listing-source-check

Conversation

@Ker102

@Ker102 Ker102 commented Dec 5, 2026

Copy link
Copy Markdown
Collaborator

Adds a sources job on pull requests that runs scripts/verify_sources.py against the listings a PR adds or changes. It reads public APIs only.

Fails when the repository is missing, private or archived; the license differs from the repository's; the package or the listed version was never published; or an install command names a different package.
Warns on an older version than the latest release, a version with no matching tag, or anything it couldn't check.

Run against the six open tanbopiao PRs (#68–#73) it flags zifu-memory (listing says Apache-2.0, repo is AGPL-3.0) and warns that sop-retrieval-mcp lists 0.1.21 while 0.1.22 is out. All 21 published listings pass with no errors.

review-agent.md now tells the review bot to treat a failure of this job as a finding.

🤖 Generated with Claude Code

Adds scripts/verify_sources.py and a 'sources' job on pull requests. It
fails when a listing's repository is missing, private or archived, its
license differs from the repository's, its package or version was never
published, or an install command names another package. It warns on an
outdated version or a version with no matching tag.
@openroot-review

openroot-review Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

OpenRoot Review

Confidence score: 5/5 · Safe to merge

The changes are purely additive CI checks, a new verification script, tests, and a documentation tweak; they do not alter production runtime behavior and only run in pull-request CI.

Summary

Adds a CI sources job that runs scripts/verify_sources.py against listings added or changed in a pull request, checking public GitHub, PyPI, and npm APIs. The script fails on missing/private/archived repos, license mismatches, unpublished packages or versions, and mismatched install commands; it warns on stale versions, missing tags, or uncheckable items. It also wires the job into .github/workflows/check.yml, adds unit tests, and updates review-agent.md so the review bot treats a job failure as a finding.

Key files to review (2)
  • scripts/verify_sources.py:90 — installed_packages only validates the first package named by pip/uv/npm install commands ([:1]), so a wrongly named second package slips through — the exact failure mode the job claims to catch
  • scripts/verify_sources.py:220 — one invalid listing or exception inside check aborts the whole main loop, leaving later listings unchecked

4 files reviewed · 3 comments (⚠️ 1 warning, 💡 2 suggestions)


Comment @openroot-review help to get the list of available commands and usage tips.

🌱 This review is free for OpenRoot members. Building something open source? Join us for free.

raise v.NotFound(url)
if url.endswith('/tags?per_page=100'):
return [{'name': t} for t in (tags or [])]
if 'api.github.com' in url:

@openroot-review openroot-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenRoot Review summary

The new scripts/verify_sources.py sources-check job is coherent and degrades well for network/API failures, but I found three defects tied to specific lines: (1) installed_packages keeps only the first package per install command ([:1] at lines 90/92/96/98), so pip install demo demo-evil validates only demo and lets a differently named second package pass — the exact failure mode the job advertises; (2) when a listing has a distribution registry URL but its install command names a package of another kind, neither branch of the install loop runs and the command is never checked (line 188); (3) main does not catch per-file exceptions, so one invalid listing aborts the whole job and leaves later listings unchecked (line 220). The workflow and review-agent.md changes look consistent with the script's CLI. I did not flag test code, per review guidance."

Key Issues

Issue Location
🔴 installed_packages only validates the first package named by pip/uv/npm install commands ([:1]), so a wrongly named second package slips through — the exact failure mode the job claims to catch scripts/verify_sources.py:90
🔴 one invalid listing or exception inside check aborts the whole main loop, leaving later listings unchecked scripts/verify_sources.py:220

Comment thread scripts/verify_sources.py
for i, word in enumerate(words[:-1]):
nxt = words[i + 1:]
if word in ('pip', 'pip3', 'pipx') and nxt and nxt[0] == 'install':
found += [('pypi', w) for w in nxt[1:] if not w.startswith('-')][:1]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug
⚠️ Warning

installed_packages ignores all but the first package in multi-package install co

installed_packages keeps only the first non-flag package after pip install / uv pip install / npm install because each comprehension ends with [:1] (lines 90, 92, 96, 98). So pip install demo demo-evil validates only demo; a second differently named package installs silently even though the job's stated failure mode is "an install command names a different package". Drop [:1] so every named package is checked against the listing.

Suggested change
found += [('pypi', w) for w in nxt[1:] if not w.startswith('-')][:1]
found += [('pypi', w) for w in nxt[1:] if not w.startswith('-')]

Prompt for AI Agents
In scripts/verify_sources.py, remove the `[:1]` slice from all four list comprehensions in `installed_packages` (lines 90, 92, 96 and 98) so every package named by pip/uv/npx install commands is validated against the listing, not just the first one.

Apply this code change:

                found += [('pypi', w) for w in nxt[1:] if not w.startswith('-')]

Not useful? Reply @openroot-review reject to dismiss this suggestion.

Comment thread scripts/verify_sources.py
# Install commands must name the listed package
for step in entry.get('installation') or []:
for kind, name in installed_packages(step.get('command', '')):
if ref and kind == ref[0]:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug
💡 Suggestion

Install commands in a different package manager than the distribution registry a

When an entry has a distribution registry URL (ref is set) but an install command names a package of another kind — e.g. a PyPI listing with npm install foo — neither branch runs: if ref and kind == ref[0] is false and elif not ref is false, so the command passes unchecked. Cross-registry install commands should at least be verified as published, mirroring the elif not ref branch.

Suggested change
if ref and kind == ref[0]:
if ref and kind == ref[0]:
if not same_package(kind, name, ref[1]):
errors.append(f'installation: `{step.get("command")}` installs {name}, not the listed package {ref[1]}')
elif not ref or kind != ref[0]:

Prompt for AI Agents
In scripts/verify_sources.py, in the install-command loop of `check`, change `elif not ref:` to `elif not ref or kind != ref[0]:` so install commands naming a package in a different registry than the listing's distribution URL are still verified as published (using the existing NotFound handling), instead of being silently skipped.

Apply this code change:

            if ref and kind == ref[0]:
                if not same_package(kind, name, ref[1]):
                    errors.append(f'installation: `{step.get("command")}` installs {name}, not the listed package {ref[1]}')
            elif not ref or kind != ref[0]:

Not useful? Reply @openroot-review reject to dismiss this suggestion.

Comment thread scripts/verify_sources.py
files = args.files or (changed_listings(args.base) if args.base else sorted((ROOT / 'data/listings').glob('*.json')))
report = ['## Listing source check', '']
failed = False
for path in files:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error Handling
💡 Suggestion

One unreadable or invalid listing aborts the whole check job

The per-file loop in main does not catch exceptions: invalid listing JSON (or a failure inside check) aborts the loop, so later listings are never checked and the job exits with a traceback instead of a per-file error annotation. Wrap each file's read/check in try/except, record an error for that file, and continue.

Suggested change
for path in files:
for path in files:
try:
entry = json.loads(Path(path).read_text(encoding='utf-8'))
errors, warnings = check(entry)
except Exception as error: # noqa: BLE001
errors = [f'could not check listing: {error}']
warnings = []

Prompt for AI Agents
In scripts/verify_sources.py, in `main`, wrap the per-file `json.loads` and `check(entry)` calls (the `for path in files:` block) in a try/except that records an error for that file and continues with the remaining files, so one bad listing does not abort the whole job.

Apply this code change:

    for path in files:
        try:
            entry = json.loads(Path(path).read_text(encoding='utf-8'))
            errors, warnings = check(entry)
        except Exception as error:  # noqa: BLE001
            errors = [f'could not check listing: {error}']
            warnings = []

Not useful? Reply @openroot-review reject to dismiss this suggestion.

This branch has not been deployed

No deployments
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.

2 participants