Skip to content

Latest commit

 

History

History
101 lines (70 loc) · 4.3 KB

visibility.md

File metadata and controls

101 lines (70 loc) · 4.3 KB

visibility.py

Revision: 1 Last modified: 2026-12-04T19:00:00Z

Overview

visibility.py resolves repository visibility and the owning-repo routing rule for the Issues mirror (anchor §11.4.300(D)).

Its governing rule is blunt: undetermined visibility BLOCKS. It never defaults to public, and it never defaults to private.

Both defaults are wrong. Defaulting to public publishes a private project's items. Defaulting to private quietly stops mirroring a public one and looks like success. So an unresolved visibility is an error, not a guess — the run reports cannot-determine (2).

It also parses both common repository-URL shapes:

  • scp-like — git@host:owner/repo (_SCP);
  • URL form — https://, ssh://, git://, optionally with a user and a port (_URL).

Nested groups

_NESTED_HOSTS = {"gitlab.com"} — on a host with nested groups, the owner keeps the whole group path. On GitLab, group/subgroup/project has owner group/subgroup, not group. Getting that wrong would address the wrong project (and in the worst case a same-named project in another group).

Prerequisites

  • python3 (standard library only: re).
  • A repository remote or URL to parse, and a live source for visibility (the target's repo_info).
  • No credentials are read by this module.

Usage examples

from issue_sync import visibility as vis

# normalise a remote URL into (host, owner, repo)
host, owner, repo = vis.canonical_repo("git@github.com:vasic-digital/constitution.git")

# nested group on GitLab: owner keeps the whole group path
vis.canonical_repo("git@gitlab.com:group/subgroup/project.git")

# resolve visibility live; an undetermined result must block, not default
state = vis.resolve(...)   # UNCONFIRMED: exact resolver name

UNCONFIRMED: the exact visibility-resolver function name was not read while writing this guide. Inspect before use: python3 -c "import issue_sync.visibility as v; print([n for n in dir(v) if not n.startswith('_')])".

Exported surface

Name Kind Contract
canonical_repo(url) function Parses an scp-like or URL-form remote into a canonical (host, owner, repo), applying nested-group handling.
_SCP regex scp-like form: [user@]host:path.
_URL regex https / ssh / git URL form, optional user and port.
_NESTED_HOSTS set {"gitlab.com"} — hosts where the owner keeps the whole group path.

Exit codes

A library, so no exit codes. The undetermined outcome propagates to the caller as the package's 2 (cannot determine) and blocks the leg.

Edge cases

  • Visibility cannot be resolved (API unreachable, permissions, ambiguous). Blocks (2). Never assumed public or private.
  • A GitLab nested group. Owner is the whole group path (group/subgroup), not the first segment.
  • An SSH URL with a port. Handled by _URL.
  • An scp-like remote with no user. Handled by _SCP (the user part is optional).
  • A trailing .git. Normalised away so the same repository does not appear as two identities.
  • A relative or malformed remote. Not a canonical repository; the caller cannot route it.
  • A host that serves both public and private projects. Visibility is per-repository, resolved live — not inferred from the host.
  • A same-named project in two groups. Exactly why nested groups keep the full path.

Internal behaviour

  1. Determines which form the remote takes (_SCP or _URL) and extracts host and path.
  2. Splits the path into owner/repo, applying the nested-group rule for hosts in _NESTED_HOSTS.
  3. Strips a trailing .git.
  4. For visibility: queries the target's repo_info live and maps the answer to public/private.
  5. An unresolvable answer is returned as undetermined so the caller blocks.

Related scripts

Used by cli.py, pipeline.py and engine.py.

Related: registry.py (host → adapter; the complementary routing decision), store.py, payload.py.

See also docs/scripts/registry.md, docs/scripts/cli.md and docs/scripts/engine.md.

Last verified

2026-12-04 — python3 -c "import ast;ast.parse(open('scripts/issue_sync/visibility.py').read())" → exit 0. python3 -c "import issue_sync.visibility as v; print(v.canonical_repo('git@github.com:o/r.git'))" prints ('github.com', 'o', 'r').