gate.py python
40 lines 1.2 KB
Raw
sha256:c07f2f34a0db9f43fe866f157d1935322008545ff8940c06c7c921eb219c55ab NXP-b DONE: independent BV-r2 pass + ISR (SD-17) Human minor ⚠ breaking 21 hours ago
1 """Module and hook gates for L2 commands (§K9.2 / §K9.8)."""
2
3 from __future__ import annotations
4
5 from pathlib import Path
6
7 from adapters.config import HonestyConfig, OverseerConfig
8 from cli.paths import confine_path
9
10
11 ROLES_FILE_V1_WARNING = (
12 "honesty.roles_file is set but v1 does not load roster content for enforcement "
13 "(role gates remain enum-only)"
14 )
15
16
17 def honesty_module_disabled(config: OverseerConfig) -> bool:
18 """Return True when the L2 operational gate is off."""
19 return not config.honesty.enabled
20
21
22 def check_roles_file(
23 honesty: HonestyConfig,
24 repo_root: Path,
25 ) -> tuple[int | None, str | None]:
26 """Apply roles_file v1 path rule; return (exit_code, warning)."""
27 if honesty.roles_file is None:
28 return None, None
29 try:
30 roles_path = confine_path(repo_root, honesty.roles_file)
31 except Exception:
32 return 4, None
33 if not roles_path.is_file():
34 return 4, None
35 return None, ROLES_FILE_V1_WARNING
36
37
38 def hook_enabled(config: OverseerConfig, hook: str) -> bool:
39 """Return True when ``hook`` is in the effective require_verdict_on set."""
40 return hook in config.honesty.require_verdict_on
File History 1 commit
sha256:c07f2f34a0db9f43fe866f157d1935322008545ff8940c06c7c921eb219c55ab NXP-b DONE: independent BV-r2 pass + ISR (SD-17) Human minor 21 hours ago