fix(validator): scan tool-root Python and 'from socket import' for telemetry - #1070
Open
potiuk wants to merge 1 commit into
Open
fix(validator): scan tool-root Python and 'from socket import' for telemetry#1070potiuk wants to merge 1 commit into
potiuk wants to merge 1 commit into
Conversation
…lemetry Closes apache#783. tool.md promised that 'a substrate tool that accidentally grows a network import is caught before it is merged'. For 11 Python files it did not. - Scan every .py the tool owns, not just tools/<name>/src/. Several substrate tools keep Python at the tool root -- pr-management-stats/ {dashboard,reference}.py, security-tracker-stats-dashboard/ {fetch_roster,fetch_prs,render}.py, dashboard-generator/reference.py -- and a src/-only scan exempted all of them. tests/ stays excluded: a test may legitimately import a network module to assert it is unreachable. - Add the 'from socket import' companion pattern. Every sibling pattern already accepted both forms; socket accepted only 'import socket'. - Correct the tool.md guarantee. It now states the real scope and two limits it previously implied away: the check is advisory unless --strict, and the library list is non-exhaustive. It is a tripwire the reviewer reads, not a gate that blocks the merge. Verified by planting both defects in real tool-root files: the original validator reported 0 violations, the fixed one reports 2. Clean tree is 0 before and after, so no existing tool is newly flagged. Three tests added. The two behavioural ones fail on the previous implementation with 'assert 0 == 1'; the tests/-exclusion one is a guard against a future scan broadening that would start flagging test files. Generated-by: Claude Code (Opus 5)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #783.
tools/egress-gateway/tool.mdpromised that "a substrate tool that accidentally grows a network import is caught before it is merged." For 11 Python files it did not..pythe tool owns, not justtools/<name>/src/. Several substrate tools keep Python at the tool root —pr-management-stats/{dashboard,reference}.py,security-tracker-stats-dashboard/{fetch_roster,fetch_prs,render}.py,dashboard-generator/reference.py— and asrc/-only scan exempted every one of them.tests/stays excluded: a test may legitimately import a network module to assert it is unreachable.from socket importcompanion pattern. Every sibling pattern already accepted bothimport xandfrom x import;socketaccepted only the former. Clearly an oversight rather than a decision.tool.mdguarantee so it states the real scope and the two limits it previously implied away.Type of change
.claude/skills/<name>/) — eval fixtures updated belowtools/<system>/*.md)tools/*/withpyproject.toml)docs/,README.md,CONTRIBUTING.md)projects/_template/)prek, workflows, validators)Test plan
prek run --filesgreen on all three files (ruff, ruff-format, mypy, pytest, markdownlint, typos, lychee, skill-and-tool-validate)uv run --directory tools/skill-and-tool-validator --group dev pytestpassesBefore/after proven by planting the defects.
import requestsadded totools/pr-management-stats/dashboard.pyandfrom socket import sockettoreference.py— both real tool-root files:main)Clean tree is 0 violations before and after, so no existing tool is newly flagged and this does not turn CI red on merge
Three tests added; the two behavioural ones fail on the previous implementation with
assert 0 == 1RFC-AI-0004 compliance
Linked issues
Closes #783. Follow-up from the review of #763.
Notes for reviewers
On the
tool.mdrewording. I first considered only widening the scan and leaving the prose. That would still have overclaimed: the check is SOFT unless--strict, so an accidental import can merge on a run without the flag. The doc now says plainly that it is "a tripwire the reviewer reads, not a gate that stops the merge", and that the library list is deliberately non-exhaustive. A guarantee that overstates its own strength is worse than a narrower one stated accurately — someone reads it and stops looking.On the
tests/exclusion. Deliberate, and the third test pins it. Broadening the scan without it would have started flagging test files that importrequestsprecisely to assert it cannot reach anywhere — a check that fires on its own negative controls trains people to ignore it.Verification method. The clean tree reports 0 violations both before and after, so a passing run proves nothing on its own. The planted-defect comparison in the test plan above is what establishes that the broadened scan actually reaches the new files.