Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions loopx/canary/module_metric_baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@
"dict_any_count": 0
},
"loopx/status.py": {
"any_count": 180,
"any_count": 0,
"dict_any_count": 0,
"lines": 1999
"lines": 1339
},
"loopx/todos.py": {
"any_count": 48,
Expand Down
3 changes: 2 additions & 1 deletion loopx/control_plane/projects/registry_codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

from ..content_digest import ENVELOPED_SHA256_PATTERN
from ..goals.activation import require_current_registry_goal_activation
from ..runtime.document_io import fsync_state_directory
from ..runtime.private_permissions import protect_private_path, require_private_path
from ...file_lock import exclusive_cross_runtime_file_lock
from ...paths import GLOBAL_REGISTRY_FILENAME
Expand Down Expand Up @@ -426,6 +425,8 @@ def backup_preimage(self) -> Path:
"""Verify a private original-byte backup before a caller's migration."""
if not self._existed or self._finished:
raise RuntimeError("registry backup requires an open existing transaction")
from ..runtime.document_io import fsync_state_directory

raw = self._document.raw_bytes
if self._path.read_bytes() != raw:
raise ProjectRegistryMutationError("Registry changed before preimage backup")
Expand Down
2 changes: 1 addition & 1 deletion loopx/control_plane/status/run_projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
latest_agent_lane_run as _latest_agent_lane_run,
latest_run_recommended_action_for_projection as _latest_run_recommended_action_for_projection,
)
from ..progress_scope import AGENT_LANE_PROGRESS_SCOPE
from ..progress_scope import AGENT_LANE_PROGRESS_SCOPE as AGENT_LANE_PROGRESS_SCOPE
from ..runtime.public_safety import public_safe_compact_text
from ..runtime.run_history import latest_run as _latest_run
from ..runtime.time import parse_timestamp
Expand Down
4 changes: 2 additions & 2 deletions loopx/control_plane/work_items/attention_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ class AttentionQueueContext:
latest_autonomous_replan_ack_for_projection: Callable[[list[dict[str, Any]] | None], dict[str, Any] | None]
compact_control_plane_policy: Callable[[Any], dict[str, Any]]
subagent_activity_for_goal: Callable[[dict[str, Any]], dict[str, Any] | None]
interface_budget_cadence_for_runs: Callable[[list[dict[str, Any]]], dict[str, Any]]
interface_budget_cadence_for_runs: Callable[[list[dict[str, Any]]], dict[str, Any] | None]
active_state_projection_warning: Callable[[dict[str, Any], dict[str, Any] | None], dict[str, Any] | None]
enrich_project_asset: Callable[..., None]
project_asset_latest_validation: Callable[[dict[str, Any] | None], dict[str, Any] | None]
attach_active_state_project_asset_fields: Callable[..., None]
attach_active_state_project_asset_fields: Callable[..., object]
sync_connected_attention_action_from_todos: Callable[[dict[str, Any]], None]
quota_status: Callable[..., dict[str, Any]]
quota_with_handoff_outcome_floor: Callable[..., dict[str, Any]]
Expand Down
19 changes: 12 additions & 7 deletions loopx/feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from pathlib import Path

from .control_plane.runtime.time import chronology_key
from .history import append_run_index_record, load_index, load_registry
from .paths import resolve_runtime_root
from .public_safe_text import (
PRIVATE_TEXT_PATTERNS as SHARED_PRIVATE_TEXT_PATTERNS,
Expand All @@ -27,10 +26,16 @@
"require_prose_state_write_allowed": "loopx.control_plane.coordination.legacy_writer_fence",
"atomic_write_state_text": "loopx.control_plane.runtime.document_io",
}
_LAZY_IMPORTS = {
**_MUTATION_ADAPTERS,
"append_run_index_record": "loopx.history",
"load_index": "loopx.history",
"load_registry": "loopx.history",
}


def __getattr__(name: str) -> Any:
owner = _MUTATION_ADAPTERS.get(name)
owner = _LAZY_IMPORTS.get(name)
if owner is None:
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
value = getattr(_import_module(owner), name)
Expand All @@ -39,7 +44,7 @@ def __getattr__(name: str) -> Any:


def __dir__() -> list[str]:
return sorted(set(globals()) | set(_MUTATION_ADAPTERS))
return sorted(set(globals()) | set(_LAZY_IMPORTS))


def _mutation_adapter(name: str) -> Any:
Expand Down Expand Up @@ -442,10 +447,10 @@ def append_human_reward(
_mutation_adapter("atomic_write_state_text")
actor = normalize_owner_controller_actor(actor_kind, required=not dry_run)
validate_goal_id(goal_id)
registry = load_registry(registry_path)
registry = _mutation_adapter("load_registry")(registry_path)
runtime_root = resolve_runtime_root(registry, runtime_root_override, registry_path=registry_path)
index_path = runtime_root / "goals" / goal_id / "runs" / "index.jsonl"
runs, raw_count = load_index(index_path)
runs, raw_count = _mutation_adapter("load_index")(index_path)
selected = select_run(runs, run_generated_at)

missing_paths = [
Expand Down Expand Up @@ -519,7 +524,7 @@ def append_human_reward(
)
state_text_to_write = planned if changed else None
index_path.parent.mkdir(parents=True, exist_ok=True)
append_run_index_record(index_path, index_record)
_mutation_adapter("append_run_index_record")(index_path, index_record)
if state_file_to_write and state_text_to_write is not None:
try:
_mutation_adapter("atomic_write_state_text")(state_file_to_write, state_text_to_write)
Expand Down Expand Up @@ -652,4 +657,4 @@ def render_reward_markdown(payload: dict[str, Any]) -> str:


# Keep the historical star-import surface, including the deferred adapters.
__all__ = [name for name in globals() if not name.startswith("_")] + list(_MUTATION_ADAPTERS)
__all__ = [name for name in globals() if not name.startswith("_")] + list(_LAZY_IMPORTS)
Loading
Loading