Skip to content

Commit 70bc981

Browse files
authored
Merge pull request #6393 from loopx-project/codex/monitor-workspace-route-20261014
2 parents 77627b6 + c584af5 commit 70bc981

2 files changed

Lines changed: 96 additions & 1 deletion

File tree

‎loopx/control_plane/quota/should_run.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,13 @@ def _apply_selected_todo_guards(
127127
local_workspace = observe_goal_local_workspace(
128128
prepared.item, selected_todo, goal_boundary.get("write_scope", [])
129129
)
130-
if not prepared.inbox_priority_due:
130+
if not prepared.inbox_priority_due and not (
131+
selected_todo is None and route.replan_decision_allowed
132+
):
133+
# Autonomous replan owns this Turn before any delivery Todo is selected.
134+
# Falling back to the first executable Todo here can attach that Todo's
135+
# workspace guard to a later route (for example, a due read-only monitor)
136+
# even though the guarded Todo was never selected for execution.
131137
workspace_guard = build_agent_workspace_guard(
132138
prepared.item,
133139
prepared.agent_identity,

‎tests/control_plane/test_quota_boundary_projection_selection.py‎

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,95 @@ def _record_workspace_guard_selection(
8686
assert "boundary_projection_gap" not in packet
8787

8888

89+
def test_replan_route_does_not_leak_an_unselected_workspace_guard_to_monitor(
90+
tmp_path: Any,
91+
) -> None:
92+
product_delivery = quota_todo_item(
93+
todo_id="todo_product_delivery001",
94+
priority="P1",
95+
title="Implement the product change.",
96+
claimed_by=AGENT_ID,
97+
task_repository="git:github.com/example/product",
98+
required_write_scopes=["src/**"],
99+
)
100+
due_monitor = quota_todo_item(
101+
todo_id="todo_due_monitor001",
102+
index=2,
103+
priority="P0",
104+
title="Observe the benchmark run.",
105+
task_class="continuous_monitor",
106+
action_kind="monitor",
107+
claimed_by=AGENT_ID,
108+
task_repository="git:github.com/example/benchmark",
109+
target_key="benchmark-run",
110+
cadence="1h",
111+
next_due_at="2020-01-01T00:00:00Z",
112+
)
113+
replan_obligation = {
114+
"schema_version": "autonomous_replan_obligation_v0",
115+
"required": True,
116+
"stall_threshold": 2,
117+
"trigger_count": 1,
118+
"triggers": [{
119+
"kind": "periodic_review_due",
120+
"section": "run_history",
121+
"text": "periodic route review is due",
122+
"run_count": 6,
123+
"threshold": 6,
124+
"agent_id": AGENT_ID,
125+
}],
126+
"guidance_actions": ["keep", "split", "add", "retire", "ask_decision"],
127+
"todo_actions": [{
128+
"action": "add",
129+
"role": "agent",
130+
"priority": "P1",
131+
"text": "write a compact replan record",
132+
}],
133+
"stop_condition": "stop at an authority boundary",
134+
"recommended_action": "run the periodic route review",
135+
"agent_id": AGENT_ID,
136+
"replan_novelty_policy": {
137+
"schema_version": "replan_evidence_delivery_policy_v0",
138+
"evidence_source": "compact_run_history",
139+
"delivery": "host_projected",
140+
"writeback": "typed_semantic_delta",
141+
},
142+
"obligation_id": "replan-0123456789abcdef",
143+
}
144+
status = quota_status_payload(
145+
goal_id=GOAL_ID,
146+
status="active",
147+
agent_todo_items=[product_delivery, due_monitor],
148+
recommended_action=product_delivery["text"],
149+
coordination={
150+
"agent_model": "peer_v1",
151+
"registered_agents": [AGENT_ID, "codex-peer"],
152+
"write_scope": ["src/**"],
153+
},
154+
claim_scope_agent_id=AGENT_ID,
155+
item_extra={"autonomous_replan_obligation": replan_obligation},
156+
project_asset_extra={
157+
"autonomous_replan_obligation": replan_obligation,
158+
"autonomous_replan_obligations_by_agent": {
159+
AGENT_ID: replan_obligation,
160+
},
161+
},
162+
)
163+
164+
packet = build_quota_should_run(
165+
status,
166+
goal_id=GOAL_ID,
167+
agent_id=AGENT_ID,
168+
workspace_path=tmp_path,
169+
)
170+
171+
assert packet["decision"] == "autonomous_replan_required"
172+
assert packet["effective_action"] == "autonomous_replan_required"
173+
assert packet["work_lane_contract"]["selected_todo_id"] == due_monitor["todo_id"]
174+
assert packet["selected_todo"] is None
175+
assert "workspace_guard" not in packet
176+
177+
89178
@pytest.mark.parametrize("other_agent_gate", [False, True])
90179
def test_workspace_guard_keeps_alternative_todo_selection_available(
91180
monkeypatch: pytest.MonkeyPatch,

0 commit comments

Comments
 (0)