Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Restore scoped governance audit signal

pulse-triage[bot]d732b5a9e85c
diff --git a/.github/workflows/README.md b/.github/workflows/README.md
index 5846223fbd..a0fef8c6a8 100644
--- a/.github/workflows/README.md
+++ b/.github/workflows/README.md
@@ -21,11 +21,11 @@ interpolated into the generated shell program.
Workflows triggered by `pull_request` cannot reference confidential repository
secrets. Canonical governance therefore keeps its pull-request checks local to
the public checkout. `canonical-private-governance.yml` performs cross-repo
-status, control-plane, mobile compatibility, and repo-governance checks only
-after a push to `main`, so unmerged pull-request code cannot replace the
-instructions that receive `WORKFLOW_PAT`. `PULSE_LICENSE_PUBLIC_KEY` is the sole
-explicit PR exception because that legacy secret value is intentionally
-non-confidential.
+status, control-plane, subsystem-registry, mobile compatibility, and
+repo-governance checks only after a push to `main`, so unmerged pull-request
+code cannot replace the instructions that receive `WORKFLOW_PAT`.
+`PULSE_LICENSE_PUBLIC_KEY` is the sole explicit PR exception because that
+legacy secret value is intentionally non-confidential.
## Release Continuity
diff --git a/.github/workflows/canonical-governance.yml b/.github/workflows/canonical-governance.yml
index 2296f246ba..86e920dbf2 100644
--- a/.github/workflows/canonical-governance.yml
+++ b/.github/workflows/canonical-governance.yml
@@ -128,7 +128,9 @@ jobs:
run: python3 scripts/release_control/pulse_intelligence_gate_test.py
- name: Run registry audit
- run: python3 scripts/release_control/registry_audit.py --check
+ # Pull requests have only the public checkout. Audit every public path
+ # here; the push-only private workflow audits the complete repo set.
+ run: python3 scripts/release_control/registry_audit.py --check --repo-scope pulse
- name: Run canonical mutation registry audits
run: go test ./internal/mutationregistry ./internal/ai/tools -run 'Test(EveryRegisteredMutationHasDisposition|InfrastructureAPIRoutesResolveToRegistry|TransportCommandCatalogsResolveToRegistry|PatrolJobRegistrationResolvesToRegistry|RuntimeCandidateAuditNegativeFixtures|ActionRouteMethodAuthorityIsExactAndLookalikesFailClosed|NonAdmittingTransportMessagesCannotCarryDispatchAuthority|UnknownTransportLookalikeFailsClosed|RegisteredModelMutationSchemasResolveToClosedRegistry|RetiredMutationAliasesCannotShadowExtensions)' -count=1
diff --git a/.github/workflows/canonical-private-governance.yml b/.github/workflows/canonical-private-governance.yml
index 2921382a39..428ab6856e 100644
--- a/.github/workflows/canonical-private-governance.yml
+++ b/.github/workflows/canonical-private-governance.yml
@@ -106,6 +106,9 @@ jobs:
PULSE_REPO_ROOT_PULSE_MOBILE: ${{ github.workspace }}/repos/pulse-mobile
run: python3 scripts/release_control/control_plane_audit.py --check
+ - name: Run complete cross-repository registry audit
+ run: python3 scripts/release_control/registry_audit.py --check
+
- name: Run repo governance guardrail tests
env:
PULSE_REPO_ROOT_PULSE: ${{ github.workspace }}/repos/pulse
diff --git a/internal/repoctl/canonical_development_protocol_test.go b/internal/repoctl/canonical_development_protocol_test.go
index ac55a4932b..17ad16fd71 100644
--- a/internal/repoctl/canonical_development_protocol_test.go
+++ b/internal/repoctl/canonical_development_protocol_test.go
@@ -1867,7 +1867,7 @@ func TestCanonicalGovernanceRunsInCI(t *testing.T) {
"npm ci --ignore-scripts --no-audit --no-fund",
"python3 scripts/release_control/canonical_completion_guard.py --files-from-stdin",
"python3 scripts/release_control/browser_verification_guard.py",
- "python3 scripts/release_control/registry_audit.py --check",
+ "python3 scripts/release_control/registry_audit.py --check --repo-scope pulse",
"python3 scripts/release_control/contract_audit.py --check",
"python3 scripts/release_control/readiness_assertion_guard.py --active-target --proof-type automated",
"python3 scripts/release_control/readiness_assertion_guard.py --active-target --proof-type hybrid",
@@ -1906,6 +1906,7 @@ func TestCanonicalGovernanceRunsInCI(t *testing.T) {
"PULSE_REPO_ROOT_PULSE_MOBILE",
"python3 scripts/release_control/status_audit.py --check",
"python3 scripts/release_control/control_plane_audit.py --check",
+ "python3 scripts/release_control/registry_audit.py --check",
"go test ./internal/repoctl -count=1",
})
if strings.Contains(privateWorkflow, "pull_request:") || strings.Contains(privateWorkflow, "workflow_dispatch:") {
diff --git a/scripts/release_control/registry_audit.py b/scripts/release_control/registry_audit.py
index 925755e4a2..18e317db02 100644
--- a/scripts/release_control/registry_audit.py
+++ b/scripts/release_control/registry_audit.py
@@ -60,6 +60,35 @@ def sorted_casefold(values: list[str]) -> list[str]:
return sorted(values, key=lambda value: value.casefold())
+def path_repository(
+ path: str,
+ *,
+ known_repo_ids: set[str],
+ local_repo: str,
+) -> str:
+ """Return the canonical repository that owns a registry path."""
+ qualifier, separator, _ = path.partition(":")
+ if separator and qualifier in known_repo_ids:
+ return qualifier
+ return local_repo
+
+
+def path_is_in_scope(
+ path: str,
+ *,
+ audited_repo_ids: set[str] | None,
+ known_repo_ids: set[str],
+ local_repo: str,
+) -> bool:
+ if audited_repo_ids is None:
+ return True
+ return path_repository(
+ path,
+ known_repo_ids=known_repo_ids,
+ local_repo=local_repo,
+ ) in audited_repo_ids
+
+
def tracked_repo_files() -> set[str]:
local_repo = canonical_repo_id(REPO_ROOT)
return tracked_workspace_files(active_repos=[local_repo], local_repo=local_repo)
@@ -108,11 +137,21 @@ def validate_path_reference(
errors: list[str],
tracked_files: set[str],
require_file: bool = True,
+ audited_repo_ids: set[str] | None = None,
+ known_repo_ids: set[str] | None = None,
+ local_repo: str = "pulse",
) -> None:
normalized = clean_relative_path(path)
if normalized != path or path.startswith("../") or "/../" in path or Path(path).is_absolute():
errors.append(f"{context} must be a clean repo-relative path: {path!r}")
return
+ if not path_is_in_scope(
+ path,
+ audited_repo_ids=audited_repo_ids,
+ known_repo_ids=known_repo_ids or {local_repo},
+ local_repo=local_repo,
+ ):
+ return
if require_file and path not in tracked_files:
errors.append(f"{context} missing tracked file {path!r}")
@@ -123,12 +162,22 @@ def validate_prefix(
context: str,
errors: list[str],
tracked_files: set[str],
+ audited_repo_ids: set[str] | None = None,
+ known_repo_ids: set[str] | None = None,
+ local_repo: str = "pulse",
) -> None:
normalized = clean_relative_path(prefix.rstrip("/"))
raw = prefix.rstrip("/")
if normalized != raw or raw.startswith("../") or "/../" in raw or Path(raw).is_absolute():
errors.append(f"{context} must be a clean repo-relative prefix: {prefix!r}")
return
+ if not path_is_in_scope(
+ prefix,
+ audited_repo_ids=audited_repo_ids,
+ known_repo_ids=known_repo_ids or {local_repo},
+ local_repo=local_repo,
+ ):
+ return
if not any(path.startswith(prefix) for path in tracked_files):
errors.append(f"{context} does not match any tracked files: {prefix!r}")
@@ -149,6 +198,9 @@ def audit_registry_payload(
tracked_files: set[str],
status_lane_ids: set[str],
schema_contract: dict[str, Any] | None = None,
+ audited_repo_ids: set[str] | None = None,
+ known_repo_ids: set[str] | None = None,
+ local_repo: str = "pulse",
) -> dict[str, Any]:
contract = schema_contract or DEFAULT_REGISTRY_SCHEMA_CONTRACT
schema = contract["schema"]
@@ -159,6 +211,21 @@ def audit_registry_payload(
required_shared_ownership_fields = set(contract["required_shared_ownership_fields"])
errors: list[str] = []
warnings: list[str] = []
+ known_repos = known_repo_ids or {local_repo}
+
+ def in_scope(path: str) -> bool:
+ return path_is_in_scope(
+ path,
+ audited_repo_ids=audited_repo_ids,
+ known_repo_ids=known_repos,
+ local_repo=local_repo,
+ )
+
+ path_validation_scope = {
+ "audited_repo_ids": audited_repo_ids,
+ "known_repo_ids": known_repos,
+ "local_repo": local_repo,
+ }
for field in sorted(required_top_level_fields):
if field not in payload:
@@ -217,6 +284,7 @@ def audit_registry_payload(
context=f"{context}.contract",
errors=errors,
tracked_files=tracked_files,
+ **path_validation_scope,
)
if contract in seen_contracts:
errors.append(f"{context} duplicates contract path {contract!r}")
@@ -240,6 +308,7 @@ def audit_registry_payload(
context=f"{context}.owned_prefixes[{prefix_index}]",
errors=errors,
tracked_files=tracked_files,
+ **path_validation_scope,
)
owned_files = raw_subsystem.get("owned_files")
@@ -260,6 +329,7 @@ def audit_registry_payload(
context=f"{context}.owned_files[{file_index}]",
errors=errors,
tracked_files=tracked_files,
+ **path_validation_scope,
)
verification = raw_subsystem.get("verification")
@@ -295,6 +365,7 @@ def audit_registry_payload(
context=f"{context}.verification.test_prefixes[{prefix_index}]",
errors=errors,
tracked_files=tracked_files,
+ **path_validation_scope,
)
exact_files = verification.get("exact_files")
@@ -315,6 +386,7 @@ def audit_registry_payload(
context=f"{context}.verification.exact_files[{file_index}]",
errors=errors,
tracked_files=tracked_files,
+ **path_validation_scope,
)
path_policies = verification.get("path_policies")
@@ -376,6 +448,7 @@ def audit_registry_payload(
context=f"{policy_context}.match_prefixes[{prefix_index}]",
errors=errors,
tracked_files=tracked_files,
+ **path_validation_scope,
)
for file_index, path in enumerate(match_files):
@@ -387,6 +460,7 @@ def audit_registry_payload(
context=f"{policy_context}.match_files[{file_index}]",
errors=errors,
tracked_files=tracked_files,
+ **path_validation_scope,
)
if not isinstance(raw_policy.get("allow_same_subsystem_tests"), bool):
@@ -410,6 +484,7 @@ def audit_registry_payload(
context=f"{policy_context}.test_prefixes[{prefix_index}]",
errors=errors,
tracked_files=tracked_files,
+ **path_validation_scope,
)
policy_exact_files = raw_policy.get("exact_files")
@@ -430,6 +505,7 @@ def audit_registry_payload(
context=f"{policy_context}.exact_files[{file_index}]",
errors=errors,
tracked_files=tracked_files,
+ **path_validation_scope,
)
valid_policies.append((policy_context, raw_policy))
@@ -437,12 +513,21 @@ def audit_registry_payload(
owned_runtime = owned_runtime_files(raw_subsystem, tracked_files)
previous_policies: list[dict[str, Any]] = []
for policy_context, policy in valid_policies:
+ policy_match_paths = list(policy.get("match_prefixes", [])) + list(
+ policy.get("match_files", [])
+ )
+ if audited_repo_ids is not None and not any(in_scope(path) for path in policy_match_paths):
+ continue
+ policy_fully_in_scope = audited_repo_ids is None or all(
+ in_scope(path) for path in policy_match_paths
+ )
matched_owned_runtime = [path for path in owned_runtime if path_policy_matches(policy, path)]
if not matched_owned_runtime:
- errors.append(f"{policy_context} does not match any owned runtime files")
+ if policy_fully_in_scope:
+ errors.append(f"{policy_context} does not match any owned runtime files")
previous_policies.append(policy)
continue
- if previous_policies and all(
+ if policy_fully_in_scope and previous_policies and all(
any(path_policy_matches(previous_policy, path) for previous_policy in previous_policies)
for path in matched_owned_runtime
):
@@ -493,6 +578,7 @@ def audit_registry_payload(
seen_shared_paths: set[str] = set()
declared_shared_paths: list[str] = []
+ scoped_declared_shared_paths: list[str] = []
for index, raw_shared in enumerate(raw_shared_ownerships):
context = f"shared_ownerships[{index}]"
if not isinstance(raw_shared, dict):
@@ -507,11 +593,14 @@ def audit_registry_payload(
errors.append(f"{context}.path must be a non-empty string")
continue
declared_shared_paths.append(path)
+ if in_scope(path):
+ scoped_declared_shared_paths.append(path)
validate_path_reference(
path,
context=f"{context}.path",
errors=errors,
tracked_files=tracked_files,
+ **path_validation_scope,
)
if path in seen_shared_paths:
errors.append(f"{context}.path duplicates shared ownership entry for {path!r}")
@@ -539,6 +628,9 @@ def audit_registry_payload(
if normalized_subsystems != sorted_casefold(normalized_subsystems):
errors.append(f"{context}.subsystems must be sorted lexicographically")
+ if not in_scope(path):
+ continue
+
actual = actual_shared_ownership.get(path)
if actual is None:
errors.append(f"{context}.path = {path!r} is not an actual shared-owned runtime file")
@@ -548,7 +640,7 @@ def audit_registry_payload(
if declared_shared_paths != sorted_casefold(declared_shared_paths):
errors.append("registry.json shared_ownerships must be sorted by path")
- declared_shared_ownership = set(declared_shared_paths)
+ declared_shared_ownership = set(scoped_declared_shared_paths)
for path in sorted(set(actual_shared_ownership) - declared_shared_ownership, key=str.casefold):
errors.append(
f"registry.json missing shared ownership entry for {path!r} owned by {actual_shared_ownership[path]!r}"
@@ -591,6 +683,16 @@ def parse_args(argv: list[str]) -> argparse.Namespace:
action="store_true",
help="Read registry control files from the git index instead of the working tree.",
)
+ parser.add_argument(
+ "--repo-scope",
+ action="append",
+ default=[],
+ metavar="REPO_ID",
+ help=(
+ "Audit paths for one available repository. Repeat to audit multiple "
+ "repositories; the default audits the complete active profile."
+ ),
+ )
return parser.parse_args(argv)
@@ -632,6 +734,34 @@ def main(argv: list[str] | None = None) -> int:
if isinstance(repo_id, str) and repo_id.strip()
] or [canonical_repo_id(REPO_ROOT)]
local_repo = canonical_repo_id(REPO_ROOT)
+ requested_repos = args.repo_scope or active_repos
+ scope_errors: list[str] = []
+ if len(requested_repos) != len(set(requested_repos)):
+ scope_errors.append("--repo-scope must not contain duplicate repository ids")
+ unknown_repos = sorted(set(requested_repos) - set(active_repos), key=str.casefold)
+ if unknown_repos:
+ scope_errors.append(
+ "--repo-scope contains repositories outside the active profile: "
+ + ", ".join(unknown_repos)
+ )
+ if local_repo not in requested_repos:
+ scope_errors.append(f"--repo-scope must include the local control-plane repository {local_repo!r}")
+
+ context = repo_root_context(REPO_ROOT)
+ missing_repos = [
+ repo_id
+ for repo_id in requested_repos
+ if not (
+ context.execution_root
+ if repo_id == local_repo
+ else context.workspace_repos_root / repo_id
+ ).is_dir()
+ ]
+ if missing_repos:
+ scope_errors.append(
+ "registry audit requires unavailable repository checkout(s): "
+ + ", ".join(missing_repos)
+ )
lane_ids = {
lane.get("id")
for lane in status_payload.get("lanes", [])
@@ -639,10 +769,14 @@ def main(argv: list[str] | None = None) -> int:
}
report = audit_registry_payload(
load_registry_payload(staged=args.staged),
- tracked_files=tracked_workspace_files(active_repos=active_repos, local_repo=local_repo),
+ tracked_files=tracked_workspace_files(active_repos=requested_repos, local_repo=local_repo),
status_lane_ids=lane_ids,
schema_contract=registry_schema_contract(staged=args.staged),
+ audited_repo_ids=set(requested_repos) if args.repo_scope else None,
+ known_repo_ids=set(active_repos),
+ local_repo=local_repo,
)
+ report["errors"] = scope_errors + report["errors"]
output = render_pretty(report) if args.pretty else json.dumps(report, indent=2, sort_keys=True)
print(output)
if args.check and report["errors"]:
diff --git a/scripts/release_control/registry_audit_test.py b/scripts/release_control/registry_audit_test.py
index 4241d97ace..1118e6c6fb 100644
--- a/scripts/release_control/registry_audit_test.py
+++ b/scripts/release_control/registry_audit_test.py
@@ -43,6 +43,10 @@ class RegistryAuditTest(unittest.TestCase):
self.assertTrue(args.check)
self.assertTrue(args.staged)
+ def test_parse_args_accepts_explicit_repository_scope(self) -> None:
+ args = parse_args(["--check", "--repo-scope", "pulse"])
+ self.assertEqual(args.repo_scope, ["pulse"])
+
def test_trust_gate_regression_proofs_are_registered_to_exact_policies(self) -> None:
registry = registry_audit.load_registry_payload()
rules = {rule["id"]: rule for rule in registry["subsystems"]}
@@ -619,6 +623,59 @@ class RegistryAuditTest(unittest.TestCase):
self.assertEqual(report["errors"], [])
self.assertEqual(report["subsystems"][0]["owned_runtime_file_count"], 1)
+ def test_public_scope_defers_unavailable_cross_repo_paths(self) -> None:
+ payload = {
+ "version": 13,
+ "shared_ownerships": [],
+ "subsystems": [
+ {
+ "id": "relay-runtime",
+ "lane": "L7",
+ "contract": "docs/release-control/v6/internal/subsystems/relay-runtime.md",
+ "owned_prefixes": ["pulse-mobile:src/relay/"],
+ "owned_files": [],
+ "verification": {
+ "allow_same_subsystem_tests": True,
+ "test_prefixes": [],
+ "exact_files": ["pulse-mobile:src/relay/__tests__/client.test.ts"],
+ "require_explicit_path_policy_coverage": True,
+ "path_policies": [
+ {
+ "id": "mobile-relay-runtime",
+ "label": "mobile relay runtime proof",
+ "match_prefixes": ["pulse-mobile:src/relay/"],
+ "match_files": [],
+ "allow_same_subsystem_tests": False,
+ "test_prefixes": [],
+ "exact_files": ["pulse-mobile:src/relay/__tests__/client.test.ts"],
+ }
+ ],
+ },
+ }
+ ],
+ }
+ tracked_files = {"docs/release-control/v6/internal/subsystems/relay-runtime.md"}
+
+ report = audit_registry_payload(
+ payload,
+ tracked_files=tracked_files,
+ status_lane_ids={"L7"},
+ audited_repo_ids={"pulse"},
+ known_repo_ids={"pulse", "pulse-mobile"},
+ )
+
+ self.assertEqual(report["errors"], [])
+ self.assertEqual(report["subsystems"][0]["owned_runtime_file_count"], 0)
+
+ missing_public_contract = audit_registry_payload(
+ payload,
+ tracked_files=set(),
+ status_lane_ids={"L7"},
+ audited_repo_ids={"pulse"},
+ known_repo_ids={"pulse", "pulse-mobile"},
+ )
+ self.assertIn("relay-runtime.md", "\n".join(missing_public_contract["errors"]))
+
def test_audit_registry_payload_flags_unknown_lane_and_missing_contract(self) -> None:
payload = {
"version": 13,