From be69f1d8fd978c6a405f2f3a9ce43347f18c14e8 Mon Sep 17 00:00:00 2001 From: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> Date: Thu, 26 Nov 2026 10:29:26 +0800 Subject: [PATCH 1/2] fix(attention_queue): align AttentionWaitingOn with status contract and wire AttentionQueueProjection Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> --- .../status/attention_projection.py | 11 +- .../status/goal_attention_projection.py | 7 +- .../status/monitor_display_projection.py | 5 +- .../work_items/attention_queue.py | 34 +++- .../work_items/attention_queue_types.py | 83 +++++++--- loopx/status.py | 8 +- .../test_attention_queue_contract.py | 151 ++++++++++++++++-- 7 files changed, 248 insertions(+), 51 deletions(-) diff --git a/loopx/control_plane/status/attention_projection.py b/loopx/control_plane/status/attention_projection.py index dd04a37ccb..8aa20cf734 100644 --- a/loopx/control_plane/status/attention_projection.py +++ b/loopx/control_plane/status/attention_projection.py @@ -2,6 +2,7 @@ from __future__ import annotations +from collections.abc import Sequence from typing import Any from ..todos.contract import ( @@ -14,6 +15,8 @@ todo_item_is_actionable_open, ) from ..work_items.attention_queue import ( + AttentionQueueItem, + AttentionQueueProjection, build_attention_queue_projection as _build_attention_queue_projection, ) from ..work_items.autonomous_candidates import ( @@ -60,11 +63,11 @@ def autonomous_monitor_candidates( def build_attention_queue_projection( *, - items: list[dict[str, Any]], + items: Sequence[AttentionQueueItem], goal_id_filter: str | None, - autonomous_backlog_candidates: dict[str, Any] | None, - autonomous_monitor_candidates: dict[str, Any] | None, -) -> dict[str, Any]: + autonomous_backlog_candidates: dict[str, object] | None, + autonomous_monitor_candidates: dict[str, object] | None, +) -> AttentionQueueProjection: return _build_attention_queue_projection( items=items, goal_id_filter=goal_id_filter, diff --git a/loopx/control_plane/status/goal_attention_projection.py b/loopx/control_plane/status/goal_attention_projection.py index 6b7d7e506e..e56d45f8e8 100644 --- a/loopx/control_plane/status/goal_attention_projection.py +++ b/loopx/control_plane/status/goal_attention_projection.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any +from typing import Any, Literal, get_args from ...operator_gate import ( DEFAULT_OPERATOR_GATE, @@ -47,12 +47,13 @@ PLANNED_CONTROLLER_OPT_IN_RECOMMENDED_ACTION = ( "先在 LoopX 完成 operator 判断;同意后项目 Agent 只执行 read-only map dry-run" ) -REGISTRY_WAITING_ON_OVERRIDES = { +RegistryWaitingOnOverride = Literal[ "user_or_controller", "controller", "codex", "external_evidence", -} +] +REGISTRY_WAITING_ON_OVERRIDES = set(get_args(RegistryWaitingOnOverride)) LEGACY_EXTERNAL_EVIDENCE_CLASSIFICATION_PREFIXES = ( "await_", "external_evidence_observation_", diff --git a/loopx/control_plane/status/monitor_display_projection.py b/loopx/control_plane/status/monitor_display_projection.py index 37b143f4b4..824a1bfbc4 100644 --- a/loopx/control_plane/status/monitor_display_projection.py +++ b/loopx/control_plane/status/monitor_display_projection.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any +from typing import Any, Literal from ..scheduler.monitor_display import ( attention_item_is_monitor_quiet_display_candidate as _attention_item_is_monitor_quiet_display_candidate, @@ -29,7 +29,8 @@ "No immediate agent work; keep the monitor quiet until a material monitor " "transition, regression, or concrete blocker appears." ) -MONITOR_SIGNAL_WAITING_ON = "monitor_signal" +MonitorSignalWaitingOn = Literal["monitor_signal"] +MONITOR_SIGNAL_WAITING_ON: MonitorSignalWaitingOn = "monitor_signal" def build_project_asset( diff --git a/loopx/control_plane/work_items/attention_queue.py b/loopx/control_plane/work_items/attention_queue.py index b1d6271cba..0f3421d19a 100644 --- a/loopx/control_plane/work_items/attention_queue.py +++ b/loopx/control_plane/work_items/attention_queue.py @@ -10,18 +10,18 @@ from ..goals.legacy_event_source import RetiredTodoEventSourceError from .attention_queue_types import ( ACTIONABLE_REGISTRY_SEVERITIES as ACTIONABLE_REGISTRY_SEVERITIES, + ATTENTION_WAITING_ON_VALUES as ATTENTION_WAITING_ON_VALUES, USER_OR_CONTROLLER_WAIT_STATES as USER_OR_CONTROLLER_WAIT_STATES, ActiveStateProjectAssetAttacher as ActiveStateProjectAssetAttacher, ActiveStateTodoAttentionBuilder as ActiveStateTodoAttentionBuilder, ActiveStateTodoFieldsBuilder as ActiveStateTodoFieldsBuilder, AttentionItemBuilder as AttentionItemBuilder, AttentionQueueContext as AttentionQueueContext, - AttentionQueueCounts as AttentionQueueCounts, + AttentionQueueItem as AttentionQueueItem, AttentionQueueProjection as AttentionQueueProjection, AttentionWaitingOn as AttentionWaitingOn, EnrichProjectAssetFn as EnrichProjectAssetFn, ExternalProgressReviewLoader as ExternalProgressReviewLoader, - GlobalRegistryFindingSeverity as GlobalRegistryFindingSeverity, GlobalRegistryShadowAttacher as GlobalRegistryShadowAttacher, GoalChannelProjectionAttacher as GoalChannelProjectionAttacher, LatestRunRecommendedActionBuilder as LatestRunRecommendedActionBuilder, @@ -99,12 +99,12 @@ def merge_global_registry_findings( def build_attention_queue_projection( *, - items: list[dict[str, object]], + items: Sequence[AttentionQueueItem], goal_id_filter: str | None, autonomous_backlog_candidates: dict[str, object] | None, autonomous_monitor_candidates: dict[str, object] | None, monitor_signal_waiting_on: str, -) -> dict[str, object]: +) -> AttentionQueueProjection: needs_user_or_controller = 0 needs_controller = 0 needs_codex = 0 @@ -123,7 +123,8 @@ def build_attention_queue_projection( if waiting_on == monitor_signal_waiting_on: watching_monitor += 1 - queue: dict[str, object] = { + queue_items = items if isinstance(items, list) else list(items) + queue: AttentionQueueProjection = { "available": True, "item_count": len(items), "needs_user_or_controller": needs_user_or_controller, @@ -131,7 +132,7 @@ def build_attention_queue_projection( "needs_codex": needs_codex, "watching_external_evidence": watching_external_evidence, "watching_monitor": watching_monitor, - "items": items, + "items": queue_items, } if goal_id_filter: queue["goal_filter"] = goal_id_filter @@ -449,6 +450,21 @@ def _build_goal_attention_item( return item +def _validated_queue_items( + items: Sequence[dict[str, object]], + *, + monitor_signal_waiting_on: str, +) -> list[AttentionQueueItem]: + validated: list[AttentionQueueItem] = [] + allowed = ATTENTION_WAITING_ON_VALUES | {monitor_signal_waiting_on} + for item in items: + waiting_on = item["waiting_on"] + if not isinstance(waiting_on, str) or waiting_on not in allowed: + raise ValueError(f"unsupported attention queue waiting_on: {waiting_on!r}") + validated.append(cast(AttentionQueueItem, item)) + return validated + + def build_attention_queue( *, contract: dict[str, object], @@ -461,7 +477,7 @@ def build_attention_queue( include_stopped_goal_context: bool = False, include_goal_channel_projection: bool = True, agent_lane_id: str | None = None, -) -> dict[str, object]: +) -> AttentionQueueProjection: """Build the executable attention queue or a stopped-Goal archive view. Normal callers omit stopped Goals because they must never become runnable @@ -522,7 +538,9 @@ def build_attention_queue( monitor_candidates = context.autonomous_monitor_candidates(items) return build_attention_queue_projection( - items=items, + items=_validated_queue_items( + items, monitor_signal_waiting_on=context.monitor_signal_waiting_on + ), goal_id_filter=goal_id_filter, autonomous_backlog_candidates=backlog_candidates, autonomous_monitor_candidates=monitor_candidates, diff --git a/loopx/control_plane/work_items/attention_queue_types.py b/loopx/control_plane/work_items/attention_queue_types.py index 4a1e36100c..c64e901d10 100644 --- a/loopx/control_plane/work_items/attention_queue_types.py +++ b/loopx/control_plane/work_items/attention_queue_types.py @@ -4,15 +4,13 @@ from collections.abc import Callable, Set as AbstractSet from dataclasses import dataclass from pathlib import Path -from typing import Literal, Protocol, TypedDict +from typing import Literal, NotRequired, Protocol, TypedDict, get_args -AttentionWaitingOn = Literal[ - "user_or_controller", - "controller", - "codex", - "external_evidence", -] -GlobalRegistryFindingSeverity = Literal["high", "action"] +from ..status.goal_attention_projection import RegistryWaitingOnOverride +from ..status.monitor_display_projection import MonitorSignalWaitingOn + +AttentionWaitingOn = Literal[RegistryWaitingOnOverride, MonitorSignalWaitingOn] +ATTENTION_WAITING_ON_VALUES: frozenset[str] = frozenset(get_args(AttentionWaitingOn)) USER_OR_CONTROLLER_WAIT_STATES: frozenset[str] = frozenset( {"user_or_controller", "controller"} @@ -20,26 +18,69 @@ ACTIONABLE_REGISTRY_SEVERITIES: frozenset[str] = frozenset({"high", "action"}) -class AttentionQueueCounts(TypedDict): - """Bucket counts emitted alongside attention queue items.""" +class AttentionQueueItem(TypedDict): + """Typed bucket entry and projected work item for the attention queue.""" + + waiting_on: AttentionWaitingOn + goal_id: NotRequired[str] + status: NotRequired[str] + severity: NotRequired[str] + recommended_action: NotRequired[str] + source: NotRequired[str] + project_asset: NotRequired[dict[str, object]] + quota: NotRequired[dict[str, object]] + user_todos: NotRequired[dict[str, object]] + agent_todos: NotRequired[dict[str, object]] + todo_state_file: NotRequired[str] + todo_source: NotRequired[str] + activation_state: NotRequired[str] + operator_question: NotRequired[str] + agent_command: NotRequired[str] + controller_stage: NotRequired[str] + missing_gates: NotRequired[list[str]] + next_handoff_condition: NotRequired[str] + lifecycle_phase: NotRequired[str] + lifecycle_flags: NotRequired[list[str]] + dreaming_proposal: NotRequired[dict[str, object]] + dreaming_lane_badge: NotRequired[dict[str, object]] + session_runtime_projection: NotRequired[dict[str, object]] + shadow_finding: NotRequired[object] + latest_run_recommended_action: NotRequired[str] + latest_run_recommended_action_source: NotRequired[str] + autonomous_replan_ack: NotRequired[dict[str, object]] + control_plane: NotRequired[dict[str, object]] + agent_lane_recommendation: NotRequired[dict[str, object]] + stale_latest_run_warning: NotRequired[dict[str, object]] + task_graph_projection: NotRequired[dict[str, object]] + evidence_log_read_receipts: NotRequired[object] + external_progress_review: NotRequired[dict[str, object]] + error_code: NotRequired[str] + authority_read: NotRequired[dict[str, object]] + state_incomplete: NotRequired[dict[str, object]] + execution_waiting_on: NotRequired[str] + monitor_display: NotRequired[dict[str, object]] + goal_objective: NotRequired[object] + active_state_next_action: NotRequired[object] + handoff_readiness: NotRequired[dict[str, object]] + dependency_blockers: NotRequired[list[dict[str, object]]] + agent_lane_id: NotRequired[str] + + +class AttentionQueueProjection(TypedDict): + """Structured shape of the serialized ``attention_queue`` projection.""" + available: bool item_count: int needs_user_or_controller: int needs_controller: int needs_codex: int watching_external_evidence: int watching_monitor: int - - -class AttentionQueueProjection(AttentionQueueCounts, total=False): - """Structured shape of the serialized ``attention_queue`` projection.""" - - available: bool - items: list[dict[str, object]] - goal_filter: str - goal_filter_applied: bool - autonomous_backlog_candidates: dict[str, object] - autonomous_monitor_candidates: dict[str, object] + items: list[AttentionQueueItem] + goal_filter: NotRequired[str] + goal_filter_applied: NotRequired[bool] + autonomous_backlog_candidates: NotRequired[dict[str, object]] + autonomous_monitor_candidates: NotRequired[dict[str, object]] class AttentionItemBuilder(Protocol): diff --git a/loopx/status.py b/loopx/status.py index 3e47daa17b..c942e5edcf 100644 --- a/loopx/status.py +++ b/loopx/status.py @@ -109,7 +109,7 @@ attention_item as _attention_item_read_model, ) from .control_plane.work_items.attention_queue import ( - AttentionQueueContext, + AttentionQueueContext, AttentionQueueItem, AttentionQueueProjection, build_attention_queue as _build_attention_queue_read_model, ) from .control_plane.work_items.autonomous_replan_ack import ( @@ -477,11 +477,11 @@ def autonomous_monitor_candidates( def build_attention_queue_projection( *, - items: list[dict[str, object]], + items: Sequence[AttentionQueueItem], goal_id_filter: str | None, autonomous_backlog_candidates: dict[str, object] | None, autonomous_monitor_candidates: dict[str, object] | None, -) -> dict[str, object]: +) -> AttentionQueueProjection: from .control_plane.status.attention_projection import ( build_attention_queue_projection as _build_attention_queue_projection, ) @@ -1035,7 +1035,7 @@ def build_attention_queue( include_goal_channel_projection: bool = True, tolerate_malformed_settlement_history: bool = False, agent_lane_id: str | None = None, -) -> dict[str, object]: +) -> AttentionQueueProjection: def request_active_state_todo_fields( goal: dict[str, object], *, diff --git a/tests/control_plane/test_attention_queue_contract.py b/tests/control_plane/test_attention_queue_contract.py index 11a6bdbc23..b0f18966ad 100644 --- a/tests/control_plane/test_attention_queue_contract.py +++ b/tests/control_plane/test_attention_queue_contract.py @@ -6,15 +6,27 @@ from collections.abc import Callable from dataclasses import dataclass, field, replace import io +import json from pathlib import Path +import subprocess +import sys import tokenize +from typing import get_args import pytest +from loopx import status as status_module from loopx.control_plane.coordination.local_authority import ( LocalCoordinationAuthorityUnavailable, ) from loopx.control_plane.goals.legacy_event_source import RetiredTodoEventSourceError +from loopx.control_plane.status import attention_projection as ap +from loopx.control_plane.status.goal_attention_projection import ( + REGISTRY_WAITING_ON_OVERRIDES, +) +from loopx.control_plane.status.monitor_display_projection import ( + MONITOR_SIGNAL_WAITING_ON, +) from loopx.control_plane.work_items import attention_queue as aq from loopx.control_plane.work_items import attention_queue_types as aqt @@ -283,41 +295,68 @@ def _attach_shadow(item: dict[str, object], finding: dict[str, object], /) -> No def test_attention_queue_static_hygiene_and_exports() -> None: aq_path = REPO_ROOT / "loopx/control_plane/work_items/attention_queue.py" types_path = REPO_ROOT / "loopx/control_plane/work_items/attention_queue_types.py" + status_path = REPO_ROOT / "loopx/status.py" test_path = Path(__file__).resolve() aq_src = aq_path.read_text(encoding="utf-8") types_src = types_path.read_text(encoding="utf-8") + status_src = status_path.read_text(encoding="utf-8") test_src = test_path.read_text(encoding="utf-8") assert len(aq_src.splitlines()) <= 550 assert len(types_src.splitlines()) < 750 - assert len(test_src.splitlines()) < 600 - for src in (aq_src, types_src, test_src): + assert len(test_src.splitlines()) < 750 + for src in (aq_src, types_src, status_src, test_src): assert _any_count(src) == 0 assert _comment_type_ignore_count(src) == 0 assert aq.AttentionQueueContext is aqt.AttentionQueueContext assert aq.AttentionQueueProjection is aqt.AttentionQueueProjection + assert aq.AttentionQueueItem is aqt.AttentionQueueItem + assert aq.AttentionWaitingOn is aqt.AttentionWaitingOn + assert aq.ATTENTION_WAITING_ON_VALUES is aqt.ATTENTION_WAITING_ON_VALUES assert aq.USER_OR_CONTROLLER_WAIT_STATES is aqt.USER_OR_CONTROLLER_WAIT_STATES assert aq.ACTIONABLE_REGISTRY_SEVERITIES is aqt.ACTIONABLE_REGISTRY_SEVERITIES + assert not hasattr(aq, "GlobalRegistryFindingSeverity") + assert not hasattr(aqt, "GlobalRegistryFindingSeverity") + assert not hasattr(aq, "AttentionQueueCounts") + assert not hasattr(aqt, "AttentionQueueCounts") + assert set(get_args(aq.AttentionWaitingOn)) == ( + set(REGISTRY_WAITING_ON_OVERRIDES) | {MONITOR_SIGNAL_WAITING_ON} + ) def test_build_attention_queue_projection_counts_and_optional_keys() -> None: - items: list[dict[str, object]] = [ + monitor_waiting: aq.AttentionWaitingOn = MONITOR_SIGNAL_WAITING_ON + items: list[aq.AttentionQueueItem] = [ {"goal_id": "g1", "waiting_on": "user_or_controller"}, {"goal_id": "g2", "waiting_on": "controller"}, {"goal_id": "g3", "waiting_on": "codex"}, {"goal_id": "g4", "waiting_on": "external_evidence"}, - {"goal_id": "g5", "waiting_on": "other"}, + {"goal_id": "g5", "waiting_on": monitor_waiting}, ] - projection = aq.build_attention_queue_projection( + projection: aq.AttentionQueueProjection = aq.build_attention_queue_projection( + items=items, + goal_id_filter=None, + autonomous_backlog_candidates={}, + autonomous_monitor_candidates=None, + monitor_signal_waiting_on=monitor_waiting, + ) + ap_projection: aq.AttentionQueueProjection = ap.build_attention_queue_projection( items=items, goal_id_filter=None, autonomous_backlog_candidates={}, autonomous_monitor_candidates=None, - monitor_signal_waiting_on="codex", ) - assert projection == { + status_projection: aq.AttentionQueueProjection = ( + status_module.build_attention_queue_projection( + items=items, + goal_id_filter=None, + autonomous_backlog_candidates={}, + autonomous_monitor_candidates=None, + ) + ) + expected: aq.AttentionQueueProjection = { "available": True, "item_count": 5, "needs_user_or_controller": 2, @@ -327,18 +366,112 @@ def test_build_attention_queue_projection_counts_and_optional_keys() -> None: "watching_monitor": 1, "items": items, } + assert projection == expected + assert ap_projection == expected + assert status_projection == expected assert "goal_filter" not in projection assert "autonomous_backlog_candidates" not in projection + codex_monitor = aq.build_attention_queue_projection( + items=items, + goal_id_filter=None, + autonomous_backlog_candidates=None, + autonomous_monitor_candidates=None, + monitor_signal_waiting_on="codex", + ) + assert codex_monitor["needs_codex"] == 1 + assert codex_monitor["watching_monitor"] == 1 + + malformed_raw = json.loads('[{"goal_id": "missing"}]') with pytest.raises(KeyError): aq.build_attention_queue_projection( - items=[{"goal_id": "missing"}], + items=malformed_raw, goal_id_filter=None, autonomous_backlog_candidates=None, autonomous_monitor_candidates=None, - monitor_signal_waiting_on="external_evidence", + monitor_signal_waiting_on=monitor_waiting, ) + bad_ctx = _build_context( + _FakeRecorder(), + goal_items={ + "g-bad": {"goal_id": "g-bad", "status": "ready", "waiting_on": "bogus_wait"} + }, + ) + with pytest.raises(ValueError, match="unsupported attention queue waiting_on"): + aq.build_attention_queue( + contract={"ok": True}, + history={"goals": [{"id": "g-bad", "registry_member": False}]}, + global_registry={"findings": []}, + context=bad_ctx, + ) + + +def test_mypy_strict_accepts_monitor_signal_and_rejects_waitng_on_typo( + tmp_path: Path, +) -> None: + positive = tmp_path / "positive_consumer.py" + positive.write_text( + "\n".join(( + "from pathlib import Path", + "from loopx import status as status_module", + "from loopx.control_plane.status import attention_projection as ap", + "from loopx.control_plane.status.monitor_display_projection import MONITOR_SIGNAL_WAITING_ON", + "from loopx.control_plane.work_items import attention_queue as aq", + "waiting: aq.AttentionWaitingOn = MONITOR_SIGNAL_WAITING_ON", + "item: aq.AttentionQueueItem = {'goal_id': 'g-mon', 'waiting_on': waiting}", + "p1: aq.AttentionQueueProjection = aq.build_attention_queue_projection(" + "items=[item], goal_id_filter=None, autonomous_backlog_candidates=None, " + "autonomous_monitor_candidates=None, monitor_signal_waiting_on=waiting)", + "p2: aq.AttentionQueueProjection = ap.build_attention_queue_projection(" + "items=[item], goal_id_filter=None, autonomous_backlog_candidates=None, " + "autonomous_monitor_candidates=None)", + "p3: aq.AttentionQueueProjection = status_module.build_attention_queue_projection(" + "items=[item], goal_id_filter=None, autonomous_backlog_candidates=None, " + "autonomous_monitor_candidates=None)", + "p4: aq.AttentionQueueProjection = status_module.build_attention_queue(" + "contract={}, history={}, global_registry={}, runtime_root=Path('.'))", + )), + encoding="utf-8", + ) + negative = tmp_path / "negative_typo_consumer.py" + negative.write_text( + "\n".join(( + "from loopx import status as status_module", + "from loopx.control_plane.status import attention_projection as ap", + "from loopx.control_plane.work_items import attention_queue as aq", + "aq.build_attention_queue_projection(" + "items=[{'goal_id': 'g1', 'waitng_on': 'codex'}], goal_id_filter=None, " + "autonomous_backlog_candidates=None, autonomous_monitor_candidates=None, " + "monitor_signal_waiting_on='monitor_signal')", + "ap.build_attention_queue_projection(" + "items=[{'goal_id': 'g1', 'waitng_on': 'codex'}], goal_id_filter=None, " + "autonomous_backlog_candidates=None, autonomous_monitor_candidates=None)", + "status_module.build_attention_queue_projection(" + "items=[{'goal_id': 'g1', 'waitng_on': 'codex'}], goal_id_filter=None, " + "autonomous_backlog_candidates=None, autonomous_monitor_candidates=None)", + )), + encoding="utf-8", + ) + shared = [ + sys.executable, "-m", "mypy", "--strict", "--explicit-package-bases", + "--cache-dir", str(tmp_path / ".mypy_cache"), + "--follow-imports=silent", "--config-file", str(REPO_ROOT / "pyproject.toml"), + "loopx/control_plane/status/monitor_display_projection.py", + "loopx/control_plane/work_items/attention_queue_types.py", + "loopx/control_plane/work_items/attention_queue.py", + "loopx/control_plane/status/attention_projection.py", + "loopx/status.py", + ] + pos_res = subprocess.run([*shared, str(positive)], cwd=REPO_ROOT, capture_output=True, text=True, check=False) + assert pos_res.returncode == 0, pos_res.stdout + pos_res.stderr + + neg_res = subprocess.run([*shared, str(negative)], cwd=REPO_ROOT, capture_output=True, text=True, check=False) + neg_lines = [line for line in neg_res.stdout.splitlines() if str(negative) in line and ": error:" in line] + assert neg_res.returncode != 0 and len(neg_lines) >= 6, neg_res.stdout + assert any("typeddict-item" in line and "waiting_on" in line for line in neg_lines), neg_res.stdout + assert any("typeddict-unknown-key" in line and "waitng_on" in line for line in neg_lines), neg_res.stdout + def test_merge_global_registry_findings_shadow_filter_and_validation() -> None: health_items: list[dict[str, object]] = [] From f0735e9045b619675f961df4c99e14edc6b0ba13 Mon Sep 17 00:00:00 2001 From: huangruiteng Date: Thu, 26 Nov 2026 16:19:52 +0800 Subject: [PATCH 2/2] fix(attention_queue): complete typed runtime fields Signed-off-by: huangruiteng --- loopx/control_plane/work_items/attention_queue_types.py | 3 +++ loopx/control_plane/work_items/attention_routing.py | 2 +- tests/control_plane/test_attention_queue_contract.py | 8 +++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/loopx/control_plane/work_items/attention_queue_types.py b/loopx/control_plane/work_items/attention_queue_types.py index c64e901d10..97bf0c5cca 100644 --- a/loopx/control_plane/work_items/attention_queue_types.py +++ b/loopx/control_plane/work_items/attention_queue_types.py @@ -64,6 +64,9 @@ class AttentionQueueItem(TypedDict): handoff_readiness: NotRequired[dict[str, object]] dependency_blockers: NotRequired[list[dict[str, object]]] agent_lane_id: NotRequired[str] + goal_channel_projection: NotRequired[dict[str, object]] + handoff_mode: NotRequired[str] + long_task_cadence_hint: NotRequired[dict[str, object]] class AttentionQueueProjection(TypedDict): diff --git a/loopx/control_plane/work_items/attention_routing.py b/loopx/control_plane/work_items/attention_routing.py index 8ea4b42466..2a50dfd69c 100644 --- a/loopx/control_plane/work_items/attention_routing.py +++ b/loopx/control_plane/work_items/attention_routing.py @@ -14,7 +14,7 @@ Optional[dict[str, Any]], ] OperatorQuestionBuilder = Callable[[str, str], str] -OperatorQuestionNormalizer = Callable[..., str] +OperatorQuestionNormalizer = Callable[..., str | None] RunHasExternalEvidenceWatchSignal = Callable[[dict[str, Any]], bool] SessionRuntimeProjectionFromRun = Callable[[Optional[dict[str, Any]]], Optional[dict[str, Any]]] PublicSafeText = Callable[..., Optional[str]] diff --git a/tests/control_plane/test_attention_queue_contract.py b/tests/control_plane/test_attention_queue_contract.py index b0f18966ad..93edfbb070 100644 --- a/tests/control_plane/test_attention_queue_contract.py +++ b/tests/control_plane/test_attention_queue_contract.py @@ -330,7 +330,13 @@ def test_build_attention_queue_projection_counts_and_optional_keys() -> None: monitor_waiting: aq.AttentionWaitingOn = MONITOR_SIGNAL_WAITING_ON items: list[aq.AttentionQueueItem] = [ {"goal_id": "g1", "waiting_on": "user_or_controller"}, - {"goal_id": "g2", "waiting_on": "controller"}, + { + "goal_id": "g2", + "waiting_on": "controller", + "goal_channel_projection": {"schema_version": "goal_channel_projection_v0"}, + "handoff_mode": "soft_claim", + "long_task_cadence_hint": {"state": "unknown"}, + }, {"goal_id": "g3", "waiting_on": "codex"}, {"goal_id": "g4", "waiting_on": "external_evidence"}, {"goal_id": "g5", "waiting_on": monitor_waiting},