Skip to content

fix(rules): a repo with no GitHub remote is private, not a lookup failure - #289

Merged
CryptoJones merged 2 commits into
mainfrom
fix/rules-visibility-no-github-remote
Sep 9, 2026
Merged

fix(rules): a repo with no GitHub remote is private, not a lookup failure#289
CryptoJones merged 2 commits into
mainfrom
fix/rules-visibility-no-github-remote

Conversation

@CryptoJones

Copy link
Copy Markdown
Owner

Problem

omind doctor reports hook failure(s) recorded in the last 7 days, and hook-failures.log is full of:

rules_visibility(/…/OMI): RuntimeError('gh visibility lookup failed')

Root cause: _repo_visibility() runs gh repo view --json visibility in the repo and treats every non-success identically — breadcrumb a failure and return UNKNOWN. But the OMI vault has no GitHub remote (it pushes only to pluto/seed over SSH), so gh returns "none of the git remotes … point to a known GitHub host." That is expected, not a failure — yet it logged a hook failure on every repo-work turn in the vault (measured: one per OMI commit, all day).

Fix

Add _has_github_remote() and branch on it when gh yields no usable visibility:

  • No GitHub remote → the repo is by definition not public: classify it private (visibility-conditioned public-repo rules then correctly do not fire), cache it, and do not breadcrumb.
  • Has a GitHub remote but gh failed (auth, network) → still a real error: UNKNOWN + breadcrumb, unchanged fail-open behaviour.

Tests

  • test_no_github_remote_is_private_not_a_failure — vault case returns private, zero breadcrumbs.
  • test_github_remote_but_gh_fails_is_unknown_and_breadcrumbed — genuine failure still UNKNOWN + breadcrumb.

Full gate green locally: ruff clean, mypy --strict clean, pytest 983 passed / 1 skipped.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AVQmw9hU7wCegqem9trv8A

Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/

@coderabbitai

coderabbitai Bot commented Aug 29, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 4808677f-b389-48e9-948d-538f4cba4304


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread src/omind/rules.py Fixed
…lure

_repo_visibility() ran `gh repo view` and treated any non-success the same:
breadcrumb "gh visibility lookup failed" and return UNKNOWN. But a repo with
no GitHub remote at all (e.g. the OMI mesh vault, which pushes only to
pluto/seed over SSH) is not a gh failure - gh legitimately cannot classify a
non-GitHub repo. That logged a hook failure on every repo-work turn in such a
vault (surfaced by `omind doctor`).

Add _has_github_remote() to tell the two apart: no GitHub remote -> classify
private (public-repo rules then correctly do not fire) and cache it, no
breadcrumb; a repo that HAS a GitHub remote yet fails lookup is still a real
error -> UNKNOWN + breadcrumb (unchanged fail-open).

Tests: vault case is private with no breadcrumb; gh-remote-but-gh-fails still
UNKNOWN + breadcrumb.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AVQmw9hU7wCegqem9trv8A
@CryptoJones
CryptoJones force-pushed the fix/rules-visibility-no-github-remote branch from 9cdc3f5 to 76a5480 Compare September 9, 2026 18:36
CodeQL py/incomplete-url-substring-sanitization (high) on this branch:
`"github.com" in proc.stdout.lower()` also matches a host that merely
contains the string. `https://github.com.evil.example/x` and
`https://not-github.com/x` both passed.

That is not cosmetic here. _has_github_remote decides whether a repo is
classified at all, which decides repo visibility, which decides whether the
public-repo branch+PR deny fires. A misclassified remote turns the deny into
silence — the guard reports itself as functioning while enforcing nothing.

Remote URLs are now pulled out of `git remote -v` and matched on parsed host
(github.com or a subdomain), covering https, scp-like `git@host:path`,
embedded credentials, ports and case.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DRXCexxuJWz949htNeqFZj
@CryptoJones
CryptoJones merged commit 98ca255 into main Sep 9, 2026
17 checks passed
@CryptoJones
CryptoJones deleted the fix/rules-visibility-no-github-remote branch September 9, 2026 20:42
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