|
31 | 31 | from .control_plane.work_items.repair_delta import ( |
32 | 32 | REPAIR_DELTA_CONTRACT_SCHEMA_VERSION as REPAIR_DELTA_CONTRACT_SCHEMA_VERSION, |
33 | 33 | REPAIR_DELTA_KIND_CHOICES as REPAIR_DELTA_KIND_CHOICES, |
34 | | - build_repair_delta_contract, |
35 | 34 | normalize_repair_delta_kinds, |
36 | | - repair_delta_kinds_have_accountable_progress, |
37 | | -) |
38 | | -from .control_plane.work_items.autonomous_replan_ack import ( |
39 | | - latest_monitor_replan_frontier_identity, |
40 | | - watch_lane_continuation_todo_ids, |
41 | 35 | ) |
42 | 36 | from .control_plane.work_items.progress_observation import ( |
43 | 37 | normalize_progress_observation, |
44 | 38 | ) |
45 | 39 | from .control_plane.work_items.semantic_replan_writeback import ( |
46 | | - enforce_open_replan_writeback, |
| 40 | + qualify_refresh_replan_writeback, |
47 | 41 | ) |
48 | 42 | from .control_plane.runtime.shared_runtime_refresh_projection import ( |
49 | 43 | build_shared_runtime_projection, |
|
84 | 78 | normalize_todo_claimed_by, |
85 | 79 | normalize_todo_replan_obligation_id, |
86 | 80 | ) |
87 | | -from .control_plane.todos.active_state_todo_parser import parse_active_state_todos |
88 | 81 | from .control_plane.todos.completion_validation_accountability import ( |
89 | 82 | require_accountable_completion_validation, |
90 | 83 | ) |
@@ -232,13 +225,6 @@ def normalize_progress_scope(value: str | None) -> str: |
232 | 225 | return normalized |
233 | 226 |
|
234 | 227 |
|
235 | | -def _noop_classification_for(classification: str) -> str: |
236 | | - normalized = str(classification or "").strip().lower() |
237 | | - if "repair" in normalized and "replan" not in normalized: |
238 | | - return "repair_noop" |
239 | | - return "replan_noop" |
240 | | - |
241 | | - |
242 | 228 | def next_action_section_bounds(lines: list[str]) -> tuple[int, int] | None: |
243 | 229 | for index, line in enumerate(lines): |
244 | 230 | if line.strip() != "## Next Action": |
@@ -1148,78 +1134,35 @@ def refresh_state_run( |
1148 | 1134 | else: |
1149 | 1135 | action, recommended_action_source = derive_recommended_action_with_source(state_text) |
1150 | 1136 | validate_local_control_text("recommended_action", action) |
1151 | | - repair_delta_contract: dict[str, Any] | None = None |
1152 | | - validated_repair_delta_kinds: list[str] = [] |
1153 | 1137 | requested_classification = classification |
1154 | | - requested_delivery_outcome = normalized_delivery_outcome |
1155 | | - effective_autonomous_replan_recorded = bool(autonomous_replan_recorded) |
1156 | | - if autonomous_replan_recorded: |
1157 | | - repair_delta_contract = build_repair_delta_contract( |
1158 | | - requested_delta_kinds=normalized_repair_delta_kinds, |
1159 | | - active_state_next_action_update=active_state_next_action_update, |
1160 | | - agent_vision=agent_vision, |
1161 | | - existing_agent_vision=existing_agent_vision, |
1162 | | - agent_todo_summary=parse_active_state_todos( |
1163 | | - state_text, item_limit=None |
1164 | | - ).get("agent_todos"), |
1165 | | - agent_id=normalized_agent_id or None, |
1166 | | - dry_run=dry_run, |
1167 | | - selected_todo_id=(settlement_identity.todo_id if settlement_identity else None), |
1168 | | - newest_first_runs=newest_first_runs, |
1169 | | - ) |
1170 | | - validated_repair_delta_kinds = list( |
1171 | | - repair_delta_contract.get("delta_kinds") or [] |
1172 | | - ) |
1173 | | - if not repair_delta_contract["delta_present"]: |
1174 | | - classification = _noop_classification_for(classification) |
1175 | | - effective_autonomous_replan_recorded = False |
1176 | | - if normalized_delivery_outcome in {"outcome_progress", "primary_goal_outcome"}: |
1177 | | - normalized_delivery_outcome = "outcome_gap" |
1178 | | - elif ( |
1179 | | - normalized_delivery_outcome in {"outcome_progress", "primary_goal_outcome"} |
1180 | | - and not repair_delta_kinds_have_accountable_progress( |
1181 | | - validated_repair_delta_kinds |
1182 | | - ) |
1183 | | - ): |
1184 | | - normalized_delivery_outcome = "outcome_gap" |
1185 | | - if effective_autonomous_replan_recorded and normalized_agent_id: |
1186 | | - autonomous_replan_frontier_identity = ( |
1187 | | - latest_monitor_replan_frontier_identity( |
1188 | | - newest_first_runs, |
1189 | | - agent_id=normalized_agent_id, |
1190 | | - watch_todo_ids=watch_lane_continuation_todo_ids( |
1191 | | - repair_delta_contract |
1192 | | - ), |
1193 | | - ) |
1194 | | - ) |
1195 | | - replan_semantic_delta = enforce_open_replan_writeback( |
| 1138 | + replan_qualification = qualify_refresh_replan_writeback( |
| 1139 | + autonomous_replan_recorded=autonomous_replan_recorded, |
| 1140 | + requested_delta_kinds=normalized_repair_delta_kinds, |
| 1141 | + active_state_next_action_update=active_state_next_action_update, |
| 1142 | + agent_vision=agent_vision, |
| 1143 | + existing_agent_vision=existing_agent_vision, |
| 1144 | + agent_id=normalized_agent_id, |
| 1145 | + dry_run=dry_run, |
| 1146 | + settlement_todo_id=(settlement_identity.todo_id if settlement_identity else None), |
| 1147 | + settlement_bound=settlement_identity is not None, |
1196 | 1148 | newest_first_runs=newest_first_runs, |
1197 | 1149 | state_text=state_text, |
1198 | | - agent_id=normalized_agent_id, |
1199 | 1150 | goal_id=safe_goal_id, |
1200 | 1151 | progress_observation=normalized_progress_observation, |
1201 | 1152 | registry_goal=registry_goal, |
1202 | | - agent_vision=agent_vision, |
1203 | 1153 | completion_todo_id=completion_todo_id, |
1204 | 1154 | completion_turn_key=completion_turn_key, |
| 1155 | + classification=classification, |
| 1156 | + delivery_outcome=normalized_delivery_outcome, |
| 1157 | + ) |
| 1158 | + repair_delta_contract = replan_qualification.repair_delta_contract |
| 1159 | + replan_semantic_delta = replan_qualification.semantic_delta |
| 1160 | + autonomous_replan_frontier_identity = replan_qualification.frontier_identity |
| 1161 | + classification = replan_qualification.classification |
| 1162 | + normalized_delivery_outcome = replan_qualification.delivery_outcome |
| 1163 | + effective_autonomous_replan_recorded = ( |
| 1164 | + replan_qualification.autonomous_replan_recorded |
1205 | 1165 | ) |
1206 | | - if replan_semantic_delta: |
1207 | | - effective_autonomous_replan_recorded = True |
1208 | | - # The semantic gate is authoritative for an open replan obligation. |
1209 | | - # A repair-delta label may fail to describe the state change while the |
1210 | | - # same writeback still carries a fresh accepted typed observation. In |
1211 | | - # that case this is not a noop: preserve the caller's accountable |
1212 | | - # settlement outcome so the durable run and receipt remain one chain. |
1213 | | - classification = requested_classification |
1214 | | - normalized_delivery_outcome = requested_delivery_outcome |
1215 | | - if ( |
1216 | | - settlement_identity is not None |
1217 | | - and normalized_delivery_outcome not in ACCOUNTABLE_DELIVERY_OUTCOMES |
1218 | | - ): |
1219 | | - raise ValueError( |
1220 | | - "turn-scoped refresh-state produced no accountable semantic delta; " |
1221 | | - "no state or settlement receipt was written" |
1222 | | - ) |
1223 | 1166 | vision_checkpoint = build_vision_checkpoint( |
1224 | 1167 | agent_id=normalized_agent_id or None, |
1225 | 1168 | agent_vision=agent_vision, |
|
0 commit comments