Skip to content

Commit 0d3c6b1

Browse files
committed
refactor(status): move registry health projections into bounded module
1 parent eea548e commit 0d3c6b1

2 files changed

Lines changed: 78 additions & 18 deletions

File tree

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
"""Registry health status projections inside the `status` bounded context."""
2+
3+
from __future__ import annotations
4+
5+
from pathlib import Path
6+
from typing import Any
7+
8+
from ...history import load_registry
9+
from ...paths import global_registry_path
10+
from ...registry import registry_goals
11+
from ..goals.global_registry_health import (
12+
collect_global_registry_health as _collect_global_registry_health,
13+
)
14+
from ..goals.global_registry_shadow import attach_global_registry_shadow_finding
15+
from ..goals.path_resolution import (
16+
resolve_goal_local_path,
17+
same_path,
18+
)
19+
from ..runtime.time import parse_timestamp
20+
from ..work_items.attention_item import attention_item
21+
from ..work_items.attention_queue import (
22+
merge_global_registry_findings as _merge_global_registry_findings,
23+
)
24+
25+
26+
SOURCE_REGISTRY_SHADOW_FINDINGS = {
27+
"source_registry_missing",
28+
"stale_source_registry",
29+
}
30+
31+
32+
def merge_global_registry_attention_findings(
33+
*,
34+
health_items: list[dict[str, Any]],
35+
history_items: list[dict[str, Any]],
36+
findings: list[Any],
37+
goal_id_filter: str | None,
38+
) -> None:
39+
_merge_global_registry_findings(
40+
health_items=health_items,
41+
history_items=history_items,
42+
findings=findings,
43+
goal_id_filter=goal_id_filter,
44+
source_registry_shadow_findings=SOURCE_REGISTRY_SHADOW_FINDINGS,
45+
attention_item=attention_item,
46+
attach_global_registry_shadow_finding=attach_global_registry_shadow_finding,
47+
)
48+
49+
50+
def collect_global_registry_health(
51+
*,
52+
registry_path: Path,
53+
runtime_root: Path,
54+
current_registry: dict[str, Any],
55+
) -> dict[str, Any]:
56+
return _collect_global_registry_health(
57+
registry_path=registry_path,
58+
runtime_root=runtime_root,
59+
current_registry=current_registry,
60+
global_registry_path=global_registry_path,
61+
load_registry=load_registry,
62+
registry_goals=registry_goals,
63+
same_path=same_path,
64+
resolve_goal_local_path=resolve_goal_local_path,
65+
parse_timestamp=parse_timestamp,
66+
)

loopx/status.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
from .interface_budget import interface_budget_cadence_for_runs
4444
from .long_task_cadence import build_long_task_cadence_hint
4545
from .orchestration import compact_orchestration_policy
46-
from .paths import global_registry_path, resolve_runtime_root
46+
from .paths import resolve_runtime_root
4747
from .control_plane.work_items.task_graph import (
4848
build_task_graph_projection as _build_task_graph_projection_read_model,
4949
)
@@ -85,7 +85,6 @@
8585
from .control_plane.work_items.attention_queue import (
8686
AttentionQueueContext,
8787
build_attention_queue as _build_attention_queue_read_model,
88-
merge_global_registry_findings as _merge_global_registry_findings_read_model,
8988
)
9089
from .control_plane.work_items.autonomous_replan_ack import (
9190
AUTONOMOUS_REPLAN_ACK_MATERIAL_RUN_WINDOW,
@@ -186,10 +185,7 @@
186185
from .control_plane.goals.global_registry_shadow import (
187186
attach_global_registry_shadow_finding,
188187
)
189-
from .control_plane.goals.global_registry_health import (
190-
collect_global_registry_health as _collect_global_registry_health_read_model,
191-
)
192-
from .control_plane.goals.path_resolution import resolve_goal_local_path, same_path
188+
from .control_plane.goals.path_resolution import resolve_goal_local_path
193189
from .control_plane.goals.goal_channel import (
194190
attach_goal_channel_projection as _attach_goal_channel_projection_read_model,
195191
)
@@ -245,7 +241,6 @@
245241
)
246242
from .promotion_gate import build_promotion_gate
247243
from .quota import quota_status, quota_with_handoff_outcome_floor
248-
from .registry import registry_goals
249244
from .rollout_event_log import load_rollout_events, rollout_event_log_path
250245
from .state_projection import (
251246
active_state_next_action_entries,
@@ -2506,14 +2501,15 @@ def merge_global_registry_attention_findings(
25062501
findings: list[Any],
25072502
goal_id_filter: str | None,
25082503
) -> None:
2509-
_merge_global_registry_findings_read_model(
2504+
from .control_plane.status.registry_health_projection import (
2505+
merge_global_registry_attention_findings as _merge_global_registry_attention_findings,
2506+
)
2507+
2508+
_merge_global_registry_attention_findings(
25102509
health_items=health_items,
25112510
history_items=history_items,
25122511
findings=findings,
25132512
goal_id_filter=goal_id_filter,
2514-
source_registry_shadow_findings=SOURCE_REGISTRY_SHADOW_FINDINGS,
2515-
attention_item=attention_item,
2516-
attach_global_registry_shadow_finding=attach_global_registry_shadow_finding,
25172513
)
25182514

25192515

@@ -2523,16 +2519,14 @@ def collect_global_registry_health(
25232519
runtime_root: Path,
25242520
current_registry: dict[str, Any],
25252521
) -> dict[str, Any]:
2526-
return _collect_global_registry_health_read_model(
2522+
from .control_plane.status.registry_health_projection import (
2523+
collect_global_registry_health as _collect_global_registry_health,
2524+
)
2525+
2526+
return _collect_global_registry_health(
25272527
registry_path=registry_path,
25282528
runtime_root=runtime_root,
25292529
current_registry=current_registry,
2530-
global_registry_path=global_registry_path,
2531-
load_registry=load_registry,
2532-
registry_goals=registry_goals,
2533-
same_path=same_path,
2534-
resolve_goal_local_path=resolve_goal_local_path,
2535-
parse_timestamp=parse_timestamp,
25362530
)
25372531

25382532

0 commit comments

Comments
 (0)