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: 1 addition & 1 deletion loopx/capabilities/native_chat/github_pr_evidence.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def _git_origin_slug(repo_path: Path) -> str | None:
try:
completed = subprocess.run(
["git", "-C", str(repo_path), "config", "--get", "remote.origin.url"],
capture_output=True, text=True, check=False, timeout=3,
capture_output=True, text=True, encoding="utf-8", check=False, timeout=3,
)
if completed.returncode == 0:
return normalize_github_repo_slug(completed.stdout.strip())
Expand Down
2 changes: 1 addition & 1 deletion loopx/cli_commands/support_control_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def _upgrade_desktop(plan: dict[str, Any], timeout_seconds: int) -> dict[str, An
[str(app / "Contents/MacOS" / executable),
"--loopx-upgrade-prepare", f"--loopx-upgrade-request={request_id}",
f"--loopx-upgrade-channel={plan['channel']}"],
capture_output=True, text=True, timeout=timeout_seconds,
capture_output=True, text=True, encoding="utf-8", timeout=timeout_seconds,
)
result = json.loads(prepared.stdout)
target = result.get("target") if isinstance(result, dict) else None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def check_remote_authority_gateway_status(
env={key: os.environ[key] for key in ("PATH", "SystemRoot", "WINDIR", "TMPDIR", "TEMP")
if key in os.environ},
text=True,
encoding="utf-8",
capture_output=True,
check=True,
timeout=5,
Expand Down
2 changes: 1 addition & 1 deletion loopx/control_plane/status/goal_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def _read_page(self, goal_id, cursor, *, scope, load):
raise
with self._lock:
if pages is not self._pages:
raise SourceScopeError("The original Goal source became unavailable during the read")
raise ValueError("The original Goal source became unavailable during the read")
return {**page, "source": self.source.describe(), "goal_id": goal_id}

def history(self, goal_id, cursor=""):
Expand Down
5 changes: 4 additions & 1 deletion loopx/control_plane/turn_driver/host_process_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,10 @@ def run_host_process(
raise RuntimeError("Invalid managed Host process observation")
finally:
try:
if guarded is not None and (launch_deadline is not None or sys.exc_info()[0] is not None):
if guarded is not None and (
launch_deadline is not None
or (supervision == "direct" and sys.exc_info()[0] is not None)
):
# A failed handoff still owns the Goal fence. The TS bridge must
# report no launch or finish its Host cleanup before it releases.
_cancel_guarded_host(
Expand Down
2 changes: 1 addition & 1 deletion loopx/extensions/lark/cli_resolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def run(
if dispatch_guard is not None:
with dispatch_guard():
process = subprocess.Popen(
args, cwd=str(cwd) if cwd else None, env=env, text=True,
args, cwd=str(cwd) if cwd else None, env=env, text=True, encoding="utf-8",
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
)
with process:
Expand Down
2 changes: 1 addition & 1 deletion loopx/self_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -1512,7 +1512,7 @@ def execute_rollback_plan(
# Share the archive installer's exact guard through checks and recovery.
guard_path = release_root.parent / ".install-guard"
guard_path.parent.mkdir(parents=True, exist_ok=True)
promotion_guard = os.fdopen(_open_lock_descriptor(guard_path, flags=os.O_CREAT | os.O_RDWR), "r+")
promotion_guard = os.fdopen(_open_lock_descriptor(guard_path, flags=os.O_CREAT | os.O_RDWR), "r+", encoding="utf-8")
deadline = time.monotonic() + timeout_seconds
while not _try_acquire_kernel_lock(promotion_guard):
remaining = deadline - time.monotonic()
Expand Down
13 changes: 11 additions & 2 deletions tests/extensions/test_periodic_report_goal_channel_delivery.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
build_periodic_report_generation_bundle,
build_periodic_report_source_result,
)
from loopx.control_plane.goals.activation import build_goal_activation
from loopx.extensions.lark.goal_channel_contracts import (
GOAL_CHANNEL_BINDING_SCHEMA_VERSION,
write_goal_channel_binding,
Expand Down Expand Up @@ -873,7 +874,11 @@ def test_goal_channel_delivery_rejects_canonical_stop_before_send(
) -> None:
registry_path = tmp_path / ".loopx" / "registry.json"
stopped = _goal()
stopped["activation_state"] = "stopped"
stopped["activation"] = build_goal_activation(
state="stopped",
updated_at="2026-08-30T09:00:00Z",
reason="fixture stop",
)
_write_registry(registry_path, goal=stopped)
_write_binding(registry_path)
calls: list[list[str]] = []
Expand Down Expand Up @@ -981,7 +986,11 @@ def runner(
if "+messages-send" in args and not stopped:
stopped = True
stopped_goal = _goal()
stopped_goal["activation_state"] = "stopped"
stopped_goal["activation"] = build_goal_activation(
state="stopped",
updated_at="2026-08-30T09:00:00Z",
reason="fixture stop",
)
_write_registry(registry_path, goal=stopped_goal)
return result

Expand Down
1 change: 1 addition & 0 deletions tests/presentation/test_background_services_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def transport(_adapter, operation, **parameters):
server = ChatHTTPServer(("127.0.0.1", 0), ChatRequestHandler)
server.verbose = False
server.codex_account_service = CodexAccountService(tmp_path, start_observer=False)
(tmp_path / "registry.json").write_text('{"schema_version": 1, "goals": []}', encoding="utf-8")
server.manager_return_service = ReturnService(tmp_path / "runtime", tmp_path / "registry.json",
ChatSessionStore(tmp_path / "runtime"), lambda *_: pytest.fail("No send is authorized"))
server.lark_goal_topic_runtime = LarkGoalTopicRuntimeService(
Expand Down
25 changes: 21 additions & 4 deletions tests/test_chat_operation_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from loopx.chat_actions import ChatActionService, ProtectedActionGate
from loopx.control_plane.collaboration.operation_handoff import agent_operation_action
from loopx.control_plane.collaboration.inbox import pending
from loopx.control_plane.goals.activation import build_goal_activation
from loopx.capabilities.manager_context import turn_start_hook
from examples.operation_action_fixtures import (
GOAL_ID,
Expand Down Expand Up @@ -286,7 +287,11 @@ def test_managed_pending_reuses_registered_agent_and_goal_instance_scope(
)

registry = json.loads(service.registry_path.read_text())
registry["goals"][0]["activation_state"] = "stopped"
registry["goals"][0]["activation"] = build_goal_activation(
state="stopped",
updated_at="2026-01-01T00:00:00Z",
reason="fixture stop",
)
service.registry_path.write_text(json.dumps(registry))
# Stopping execution does not erase the original evidence-reconciliation locator.
historical = handler("loopx_operation", args, native)
Expand Down Expand Up @@ -682,7 +687,11 @@ def test_agent_handoff_fails_closed_on_expiry_binding_activation_or_terms_drift(
elif change == "archived":
registry["goals"][0]["status"] = "archived"
else:
registry["goals"][0]["activation_state"] = "stopped"
registry["goals"][0]["activation"] = build_goal_activation(
state="stopped",
updated_at="2026-01-01T00:00:00Z",
reason="fixture stop",
)
service.registry_path.write_text(json.dumps(registry))
else:
data = json.loads(store.path.read_text())
Expand Down Expand Up @@ -849,7 +858,11 @@ def test_unknown_result_never_grants_resubmission_and_late_evidence_does_not_req
**args,
)
registry = json.loads(service.registry_path.read_text())
registry["goals"][0]["activation_state"] = "stopped"
registry["goals"][0]["activation"] = build_goal_activation(
state="stopped",
updated_at="2026-01-01T00:00:00Z",
reason="fixture stop",
)
registry["goals"][0]["coordination"]["thread_agent_bindings"][0]["thread_id"] = (
"thread-replacement"
)
Expand Down Expand Up @@ -1022,7 +1035,11 @@ def test_replacement_session_reconciles_under_its_current_binding_without_recons
)
if historical:
registry = json.loads(service.registry_path.read_text())
registry["goals"][0]["activation_state"] = "stopped"
registry["goals"][0]["activation"] = build_goal_activation(
state="stopped",
updated_at="2026-01-01T00:00:00Z",
reason="fixture stop",
)
service.registry_path.write_text(json.dumps(registry))
after_expiry = (datetime.now(timezone.utc) + timedelta(hours=2)).isoformat()
monkeypatch.setattr("loopx.chat_action_store._utc_now", lambda: after_expiry)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_chat_status_owner.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_status_owner_imports_canonically_and_has_no_legacy_module():
code = """
import importlib.util
from loopx.chat.status_api import ChatStatusRequestMixin, goal_read_runtime_root
from loopx.chat.todo_detail import goal_read_runtime_root as todo_runtime_root
from loopx.chat.todo_source import goal_read_runtime_root as todo_runtime_root
from loopx.chat_server import ChatRequestHandler

assert issubclass(ChatRequestHandler, ChatStatusRequestMixin)
Expand All @@ -44,7 +44,7 @@ def test_status_owner_imports_canonically_and_has_no_legacy_module():
def test_registry_patch_reaches_already_imported_todo_consumer(
monkeypatch, tmp_path, source_bound, controller_root, expected,
):
from loopx.chat.todo_detail import goal_read_runtime_root
from loopx.chat.todo_source import goal_read_runtime_root

registry_path = tmp_path / "registry.json"
calls = []
Expand Down
2 changes: 1 addition & 1 deletion tests/test_contract_git_probe_budget.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def test_a_timed_out_probe_takes_the_helpers_it_started(
subprocess.run(
["git", "-C", str(repo), "config", "core.fsmonitor", str(hook)], check=True
)
monkeypatch.setattr(contract, "GIT_PROBE_TIMEOUT_SECONDS", 0.8)
monkeypatch.setattr(contract, "GIT_PROBE_TIMEOUT_SECONDS", 1.5)

started = time.monotonic()
with pytest.raises(contract.GitProbeUnavailable):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_doctor_git_probe_budget.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def test_a_blocked_query_takes_the_helpers_it_started(
["git", "-C", str(repo), "config", "core.fsmonitor", str(hook)], check=True
)

monkeypatch.setattr(doctor_git, "GIT_PROBE_TIMEOUT_SECONDS", 0.8)
monkeypatch.setattr(doctor_git, "GIT_PROBE_TIMEOUT_SECONDS", 1.5)
cleanup_calls: list[float] = []
original_terminate = doctor_git.terminate_process_tree

Expand Down
2 changes: 1 addition & 1 deletion tests/test_global_todo_readiness_characterization.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

FIXTURE = Path(__file__).parent / "fixtures/global_todo_readiness.json"
NOW = "2026-11-02T00:00:00+00:00"
BASE_REVISION = "d4aaaaefbd37a83a30f10681de839b45d631eeb9"
BASE_REVISION = "d210e4cc1d002f92498b2811c565b9430e79f4c1"


def observe(case, monkeypatch, tmp_path):
Expand Down
36 changes: 36 additions & 0 deletions tests/test_kunluncode_goal_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ def capture(command: list[str], **_kwargs) -> subprocess.CompletedProcess[str]:
),
"settlement_identity": identity.as_dict(),
"settlement_result": {"failure": None},
"settlement_progress": {
"schema_version": "quota_settlement_progress_v0",
"state": "settled",
"next_step": None,
"quota_spend_source": "heartbeat",
},
}
)
else:
Expand All @@ -188,6 +194,12 @@ def capture(command: list[str], **_kwargs) -> subprocess.CompletedProcess[str]:
"appended": True,
"settlement_identity": identity.as_dict(),
"settlement_result": {"failure": None},
"settlement_progress": {
"schema_version": "quota_settlement_progress_v0",
"state": "settled",
"next_step": None,
"quota_spend_source": "heartbeat",
},
}
)
return subprocess.CompletedProcess(command, 0, payload, "")
Expand Down Expand Up @@ -281,6 +293,12 @@ def capture(command: list[str], **_kwargs) -> subprocess.CompletedProcess[str]:
"completion_continuation": "active_goal",
"settlement_identity": identity.as_dict(),
"settlement_result": {"failure": None},
"settlement_progress": {
"schema_version": "quota_settlement_progress_v0",
"state": "settled",
"next_step": None,
"quota_spend_source": "heartbeat",
},
}
)
else:
Expand All @@ -290,6 +308,12 @@ def capture(command: list[str], **_kwargs) -> subprocess.CompletedProcess[str]:
"appended": True,
"settlement_identity": identity.as_dict(),
"settlement_result": {"failure": None},
"settlement_progress": {
"schema_version": "quota_settlement_progress_v0",
"state": "settled",
"next_step": None,
"quota_spend_source": "heartbeat",
},
}
)
return subprocess.CompletedProcess(command, 0, payload, "")
Expand Down Expand Up @@ -408,6 +432,12 @@ def capture(command: list[str], **_kwargs) -> subprocess.CompletedProcess[str]:
"status": "done",
"settlement_identity": identity.as_dict(),
"settlement_result": {"failure": None},
"settlement_progress": {
"schema_version": "quota_settlement_progress_v0",
"state": "settled",
"next_step": None,
"quota_spend_source": "heartbeat",
},
}
)
else:
Expand All @@ -417,6 +447,12 @@ def capture(command: list[str], **_kwargs) -> subprocess.CompletedProcess[str]:
"appended": True,
"settlement_identity": identity.as_dict(),
"settlement_result": {"failure": None},
"settlement_progress": {
"schema_version": "quota_settlement_progress_v0",
"state": "settled",
"next_step": None,
"quota_spend_source": "heartbeat",
},
}
)
return subprocess.CompletedProcess(command, 0, payload, "")
Expand Down
4 changes: 2 additions & 2 deletions tests/test_lark_event_collector_git_budget.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def test_the_next_question_is_not_asked_after_one_goes_unanswered(
"exit 0\n",
monkeypatch,
)
monkeypatch.setattr(event_collector, "GIT_PROBE_TIMEOUT_SECONDS", 0.5)
monkeypatch.setattr(event_collector, "GIT_PROBE_TIMEOUT_SECONDS", 1.5)

started = time.monotonic()
with pytest.raises(ValueError, match="needs a Git answer"):
Expand Down Expand Up @@ -141,7 +141,7 @@ def test_a_timed_out_probe_takes_the_helpers_it_started(
subprocess.run(
["git", "-C", str(project), "config", "core.fsmonitor", str(hook)], check=True
)
monkeypatch.setattr(event_collector, "GIT_PROBE_TIMEOUT_SECONDS", 0.8)
monkeypatch.setattr(event_collector, "GIT_PROBE_TIMEOUT_SECONDS", 1.5)

started = time.monotonic()
with pytest.raises(ValueError, match="needs a Git answer"):
Expand Down
5 changes: 4 additions & 1 deletion tests/test_lark_native_reply_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,10 @@ def test_unquoted_provider_root_keeps_plain_input_and_no_parent_read(ordinary):
assert native_request(transport, event)["message"] == event["content"]
calls = provider.calls[before:]
assert sum("+messages-mget" in args for args in calls) == 1
assert not any("api" in args for args in calls)
api_calls = [args[args.index("api"):] for args in calls if "api" in args]
assert api_calls == [
["api", "GET", f"/open-apis/im/v1/messages/{event['message_id']}", "--as", "bot"]
]
finally:
runtime.close()

Expand Down
Loading
Loading