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
6 changes: 6 additions & 0 deletions examples/operation_action_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def service(
)
registry = project / ".loopx" / "registry.json"
registry.parent.mkdir()
from loopx.control_plane.goals.activation import build_goal_activation
registry.write_text(
json.dumps(
{
Expand All @@ -49,6 +50,11 @@ def service(
"id": goal_id,
"repo": str(project),
"state_file": "ACTIVE_GOAL_STATE.md",
"activation": build_goal_activation(
state="active",
updated_at="2026-01-01T00:00:00Z",
reason="fixture active",
),
"coordination": {
"registered_agents": ["finance-fixture-agent"]
},
Expand Down
8 changes: 5 additions & 3 deletions loopx/cli_commands/quota_result_delivery.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,11 @@ def emit_quota_result(
capture_sha256: str | None = None
saved_decision = payload

def record_capture(decision: dict[str, object], digest: str) -> None:
def record_capture(decision: dict[str, object], digest: str | None) -> None:
nonlocal saved_decision, capture_sha256
saved_decision = decision
capture_sha256 = digest
if digest is not None:
capture_sha256 = digest

try:
return _publish_quota_result(
Expand Down Expand Up @@ -225,7 +226,7 @@ def _publish_quota_result(
capture_directory: Path | None,
detail_sections: frozenset[str],
print_payload: PrintPayload,
record_capture: Callable[[dict[str, object], str], None],
record_capture: Callable[[dict[str, object], str | None], None],
) -> int:
from ..command_invocation import current_loopx_cli_argv

Expand Down Expand Up @@ -305,6 +306,7 @@ def _publish_quota_result(
quota_module._export("attach_host_poll_receipt")(
context.status_payload, args, payload, registry_path=registry_path,
)
record_capture(payload, None)
native_context = context_delivery_enabled and bool(
getattr(args, "codex_context_dir", None)
or getattr(args, "codex_context_root", None)
Expand Down
18 changes: 17 additions & 1 deletion loopx/cli_commands/turn_run_once.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,20 @@ def refresh_candidate(
# Do not overwrite task context before refresh can reject a result.
progress_observation = result.get("progress_observation")
vision, explore_result = split_candidate_vision(result)
recovery_turn_instance_id = (
settlement_identity.turn_instance_id
if (
bool(args.retry_failed_turn)
and not dry_run
and completion_turn_key == settlement_identity.turn_instance_id
)
else None
)
refresh_task_lease_proof = (
None
if completion_todo_id is not None and (recovery_turn_instance_id is None or rebound_lease_active)
else task_lease_proof
)
return refresh_state_run(
registry_path=registry_path,
runtime_root_override=runtime_root_arg,
Expand Down Expand Up @@ -313,7 +327,9 @@ def refresh_candidate(
dry_run=dry_run,
sync_global=not bool(args.no_global_sync),
goal_ref=goal_ref,
task_lease_proof=None if completion_todo_id is not None else task_lease_proof,
task_lease_proof=refresh_task_lease_proof,
allow_same_generation_lease_renewal=refresh_task_lease_proof is not None,
validation_recovery_turn_instance_id=recovery_turn_instance_id,
)
# A Todo-less native governance Turn has no business artifact/argv.
# Its independent validator is the canonical semantic writeback preview,
Expand Down
25 changes: 23 additions & 2 deletions loopx/control_plane/goals/goal_frontier/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
declared_fallback_gap_from_agent_vision,
parse_fallback_declarations, # noqa: F401
)
from .long_todo_chain import LONG_TODO_CHAIN_TRIGGER, evaluate_long_todo_chain
from .long_todo_chain import LONG_TODO_CHAIN_TRIGGER, LongTodoChainAckDecision, evaluate_long_todo_chain # noqa: E501
from .replan_rules import (
GoalFrontierReplanFacts,
GoalFrontierReplanRule,
Expand All @@ -90,6 +90,7 @@
_latest_runs_for_goal,
latest_agent_vision_from_runs as latest_agent_vision_from_runs,
latest_agent_vision_from_status_payload,
latest_autonomous_replan_ack_from_status_payload,
receipt_bound_replan_ack_history,
latest_missing_vision_checkpoint_from_status_payload,
latest_replan_ack_feedback_from_status_payload,
Expand Down Expand Up @@ -900,6 +901,7 @@ def derive_goal_frontier_replan_obligation_from_summaries(
existing_replan_obligation: dict[str, Any] | None,
agent_todo_source_items: list[dict[str, Any]] | None = None,
latest_replan_ack: dict[str, Any] | None = None,
prior_rearm_ack: dict[str, Any] | None = None,
current_transition_replan_ack: dict[str, Any] | None = None,
acceptance_gaps: list[dict[str, Any]] | None = None,
monitor_lane_semantically_valid: bool = True,
Expand Down Expand Up @@ -972,6 +974,16 @@ def derive_goal_frontier_replan_obligation_from_summaries(
agent_todo_source_items=agent_todo_source_items,
latest_replan_ack=current_transition_replan_ack or latest_replan_ack,
)
if (long_chain_ack_decision and not long_chain_ack_decision.acknowledged
and long_chain_ack_decision.rearmed_after_obligation_id is None and prior_rearm_ack is not None):
_, prior_decision = evaluate_long_todo_chain(
agent_todo_summary=agent_todo_summary, agent_counts=agent_counts, frontier_counts=frontier_counts,
agent_id=agent_id, agent_todo_source_items=agent_todo_source_items, latest_replan_ack=prior_rearm_ack,
)
if prior_decision and not prior_decision.acknowledged and prior_decision.rearmed_after_obligation_id is not None:
long_chain_ack_decision = LongTodoChainAckDecision(
acknowledged=False, rearmed_after_obligation_id=prior_decision.rearmed_after_obligation_id,
)
replan_rule = select_goal_frontier_replan_rule(
GoalFrontierReplanFacts(
existing_replan_required=autonomous_replan_is_required(
Expand Down Expand Up @@ -1126,7 +1138,7 @@ def derive_goal_frontier_replan_obligation_from_summaries(
if outcome_gap is not None and outcome_gap not in trigger_gaps:
trigger_gaps.append(outcome_gap)
rearmed_after_obligation_id = _acknowledged_replan_obligation_id(
latest_replan_ack
latest_replan_ack or prior_rearm_ack
)
return build_autonomous_replan_obligation_payload(
schema_version=AUTONOMOUS_REPLAN_OBLIGATION_SCHEMA_VERSION,
Expand Down Expand Up @@ -1634,6 +1646,14 @@ def build_goal_frontier_projection_context_from_status(
agent_id=agent_id,
registered_agent_ids=registered_agent_ids,
)
prior_rearm_ack = None
if receipt_bound_replan_obligation_id and latest_agent_replan_ack is None:
candidate_prior_ack = latest_autonomous_replan_ack_from_status_payload(
status_payload, goal_id=goal_id, agent_id=agent_id,
neutral_classifications=neutral_replan_ack_classifications,
)
if _acknowledged_replan_obligation_id(candidate_prior_ack) != receipt_bound_replan_obligation_id:
prior_rearm_ack = candidate_prior_ack
frontier_replan_obligation = derive_goal_frontier_replan_obligation_from_summaries(
user_todo_summary=user_todo_summary,
agent_todo_summary=agent_todo_summary,
Expand All @@ -1642,6 +1662,7 @@ def build_goal_frontier_projection_context_from_status(
existing_replan_obligation=replan_obligation,
agent_todo_source_items=agent_todo_source_items,
latest_replan_ack=effective_replan_ack,
prior_rearm_ack=prior_rearm_ack,
current_transition_replan_ack=replan_transition_ack,
_frontier_counts=frontier_counts,
acceptance_gaps=acceptance_gaps,
Expand Down
Loading
Loading