livery.workshop._governance¶
livery.workshop._governance ¶
Repository governance from the contracts: owners, the file, the config.
Each package's workshop.toml names who reviews it ([owners]
with users, teams, and approvals); the root contract's
own [owners] guard the governance declarations themselves, so
raising a reviewer count is a reviewed merge like any change. This
module turns those declarations into the forge's CODEOWNERS file (a
managed generated artifact the drift gate compares offline), into
the repository settings configure asserts, and into the
generated post-merge workflow that applies them, so nobody carries
forge-specific knowledge in their head.
Functions:
| Name | Description |
|---|---|
ci_environments |
Resolved deployment environment names from |
owners_of |
A contract's |
offline_forge |
The contract's forge backend with no credential attached. |
privileged_paths |
The authoritative root-relative paths guarded by root |
governance_entries |
The neutral ownership declarations, packages first and root guard last. |
codeowners_file |
The rendered codeowners artifact, or None with no declarations. |
governance_paths |
The paths whose change means governance may need re-applying. |
governance_config |
The approvals half of the repository settings. |
unknown_owners |
Declared owners the forge does not know, for configure's check. |
Attributes:
| Name | Type | Description |
|---|---|---|
DEFAULT_ENVIRONMENTS |
dict[str, str]
|
|
DEFAULT_ENVIRONMENTS
module-attribute
¶
ci_environments ¶
Resolved deployment environment names from [ci.environments].
Source code in packages/workshop/src/livery/workshop/_governance.py
owners_of ¶
A contract's (users, teams, approvals) owner declaration.
Approvals default to zero: declared owners document and route review without gating the merge until a count is asked for, which is what a solo maintainer needs (a forge that forbids self-approval deadlocks a solo repo on any required review).
Source code in packages/workshop/src/livery/workshop/_governance.py
offline_forge ¶
The contract's forge backend with no credential attached.
The codeowners rendering is pure string building, so the drift gate may hold a backend offline; nothing built here may be used for a network call.
Source code in packages/workshop/src/livery/workshop/_governance.py
privileged_paths ¶
The authoritative root-relative paths guarded by root [owners].
Every path that can alter CI execution, CI credentials, tool
resolution, root environment defaults, or governance rules comes
from this one function; CODEOWNERS generation, drift checking, and
security checks all read it. Per-package workshop.toml files
are intentionally omitted: edits to [owners] force a CODEOWNERS
diff (including # approvals: <n>), and edits to extensions,
dependencies, package names, or new CI points force diffs in
guarded root files via drift.check.
Source code in packages/workshop/src/livery/workshop/_governance.py
governance_entries ¶
governance_entries(root: Path) -> tuple[CodeownersEntry, ...]
The neutral ownership declarations, packages first and root guard last.
Each package's owners guard its directory; the root contract's
owners guard every pattern from privileged_paths under the
governance section. Package entries come first and the
governance section comes last so last-match-wins dialects (GitHub
and Gitea) never let a package rule shadow a privileged path, and
GitLab renders the governance entries in their own additive
[governance] section. A workspace with no owner declarations
anywhere answers empty, and no file is generated.
Source code in packages/workshop/src/livery/workshop/_governance.py
codeowners_file ¶
codeowners_file(root: Path) -> Codeowners | None
The rendered codeowners artifact, or None with no declarations.
Source code in packages/workshop/src/livery/workshop/_governance.py
governance_paths ¶
The paths whose change means governance may need re-applying.
Source code in packages/workshop/src/livery/workshop/_governance.py
governance_config ¶
governance_config(root: Path) -> RepoConfig
The approvals half of the repository settings.
The repo-wide count is the highest any declaration asks, because GitHub and Gitea express one count through protection; GitLab's per-path sections carry the rest, where a paid tier enforces them. No declarations anywhere means no approval requirement.
Source code in packages/workshop/src/livery/workshop/_governance.py
unknown_owners ¶
Declared owners the forge does not know, for configure's check.
Users are checked against members(owner), teams against
teams(owner); the answers are live listings, so this runs
only where the forge is already being spoken to, never on the
merge path.