Skip to content
Merged
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
2 changes: 2 additions & 0 deletions loopx/capabilities/reward_memory/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from importlib import import_module
from typing import Any

_SCOPED_FEEDBACK_ADAPTER = "scoped_feedback"

# Turn hooks import one owner submodule; they do not select evaluation, dogfood
# or Codex App staging. Keep compatibility exports identical to their owners
# without importing every reward-memory workflow when a submodule loads.
Expand Down
11 changes: 7 additions & 4 deletions loopx/capabilities/reward_memory/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@
from ..context_providers import build_context_provider
from ..context_providers.base import ContextProvider
from ..context_providers.openviking_scope import classify_openviking_scope
from .application import TOKEN_RE, normalize_reward_memory_provider_binding
from .ingestion import normalize_reward_memory_standing_policy
from .registry import MAX_CORPORA, normalize_reward_memory_corpus
from .scoped_feedback import SCOPED_FEEDBACK_ADAPTER
from . import _SCOPED_FEEDBACK_ADAPTER as SCOPED_FEEDBACK_ADAPTER


REWARD_MEMORY_EXPERIMENT_SCHEMA_VERSION = "reward_memory_experiment_config_v1"
Expand Down Expand Up @@ -189,6 +186,8 @@ def _materialize_provider_binding(
corpus: Mapping[str, Any],
scope_ref: str,
) -> dict[str, Any]:
from .application import normalize_reward_memory_provider_binding

raw = {
key: project_binding[key]
for key in (
Expand Down Expand Up @@ -454,6 +453,10 @@ def preflight_reward_memory_experiment_config(


def _normalize_v1(raw: Mapping[str, Any]) -> dict[str, Any]:
from .application import TOKEN_RE
from .ingestion import normalize_reward_memory_standing_policy
from .registry import MAX_CORPORA, normalize_reward_memory_corpus

_strict_object(
raw, label="reward-memory experiment config", allowed=_V1_CONFIG_FIELDS
)
Expand Down
3 changes: 2 additions & 1 deletion loopx/capabilities/reward_memory/scoped_feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@

from ...control_plane.runtime.public_safety import public_safe_compact_text
from ..context_providers.base import ContextProvider
from . import _SCOPED_FEEDBACK_ADAPTER
from .candidate_review import build_reward_memory_candidate
from .ingestion import (
ingest_reward_memory_candidate,
normalize_reward_memory_standing_policy,
)


SCOPED_FEEDBACK_ADAPTER = "scoped_feedback"
SCOPED_FEEDBACK_ADAPTER = _SCOPED_FEEDBACK_ADAPTER
SCOPED_FEEDBACK_EVENT_SCHEMA_VERSION = "scoped_feedback_reward_memory_event_v0"
SCOPED_FEEDBACK_ADAPTER_SCHEMA_VERSION = (
"scoped_feedback_reward_memory_candidate_adapter_v0"
Expand Down
26 changes: 26 additions & 0 deletions tests/capabilities/test_reward_memory_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import copy
import hashlib
import json
import subprocess
import sys
from pathlib import Path
from typing import Any

Expand Down Expand Up @@ -635,6 +637,30 @@ def test_configure_goal_requires_write_preflight_and_persists_receipt(
assert resolved is not None


def test_disabled_experiment_status_leaves_active_config_owners_unloaded(
tmp_path: Path,
) -> None:
registry, _, _ = _experiment(tmp_path)
configuration = json.loads(registry.read_text(encoding="utf-8"))
configuration["goals"][0]["control_plane"]["reward_memory"]["enabled"] = False
registry.write_text(json.dumps(configuration), encoding="utf-8")
probe = """
from pathlib import Path
import sys

from loopx.capabilities.reward_memory.experiment import resolve_reward_memory_experiment

status, configuration = resolve_reward_memory_experiment(
registry_path=Path(sys.argv[1]), goal_id="reward-memory-goal", agent_id="pilot",
)
assert status["status"] == "disabled" and configuration is None
package = "loopx.capabilities.reward_memory."
config_owners = ("application", "ingestion", "registry", "scoped_feedback")
assert not any(package + name in sys.modules for name in config_owners)
"""
subprocess.run([sys.executable, "-c", probe, str(registry)], cwd=REPO_ROOT, check=True)


def test_status_is_agent_scoped_and_public_safe(tmp_path: Path) -> None:
registry_path, _, _ = _experiment(tmp_path)

Expand Down