mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-09-04 10:11:46 +03:00
fix(cron): report reconciled startup job count
This commit is contained in:
@@ -3216,13 +3216,14 @@ def test_gateway_local_trigger_queue_submits_agent_turns(
|
||||
return None
|
||||
|
||||
def status(self) -> dict[str, int]:
|
||||
seen.setdefault("cron_reconciliation", []).append("status")
|
||||
return {"jobs": 0}
|
||||
|
||||
def register_system_job(self, _job) -> None:
|
||||
return None
|
||||
|
||||
def remove_system_job(self, job_id: str) -> bool:
|
||||
seen.setdefault("removed_system_jobs", []).append(job_id)
|
||||
seen.setdefault("cron_reconciliation", []).append(f"remove:{job_id}")
|
||||
return False
|
||||
|
||||
class _FakeAgentLoop(_GatewayAgentContractStub):
|
||||
@@ -3301,8 +3302,7 @@ def test_gateway_local_trigger_queue_submits_agent_turns(
|
||||
turn_delivery_factory = agent_kwargs["turn_delivery_factory"]
|
||||
assert isinstance(turn_delivery_factory, TurnDeliveryFactory)
|
||||
assert turn_delivery_factory.bus is bus
|
||||
# Disabled system jobs must be retired on startup, not just unregistered.
|
||||
assert seen["removed_system_jobs"] == ["dream", "heartbeat"]
|
||||
assert seen["cron_reconciliation"] == ["remove:dream", "remove:heartbeat", "status"]
|
||||
assert isinstance(turn_delivery_factory.route_policy, WebuiTurnRoutePolicy)
|
||||
assert turn_delivery_factory.route_policy.sessions is agent.sessions
|
||||
|
||||
|
||||
@@ -786,8 +786,6 @@ def test_remove_job_refuses_system_jobs(tmp_path) -> None:
|
||||
|
||||
|
||||
def test_remove_system_job_retires_persisted_system_job(tmp_path) -> None:
|
||||
"""Disabling a system job (e.g. gateway.heartbeat.enabled=false) must
|
||||
actually retire the previously persisted job, not just skip registration."""
|
||||
store_path = tmp_path / "cron" / "jobs.json"
|
||||
service = CronService(store_path)
|
||||
service.register_system_job(CronJob(
|
||||
@@ -802,12 +800,8 @@ def test_remove_system_job_retires_persisted_system_job(tmp_path) -> None:
|
||||
|
||||
assert removed is True
|
||||
assert service.get_job("heartbeat") is None
|
||||
# Removal must persist: a fresh instance (next gateway start) must not
|
||||
# resurrect the job from the on-disk store.
|
||||
assert CronService(store_path).get_job("heartbeat") is None
|
||||
# Idempotent: removing a missing system job reports False without raising.
|
||||
assert service.remove_system_job("heartbeat") is False
|
||||
# User-facing removal still protects remaining system jobs.
|
||||
other = CronService(store_path)
|
||||
other.register_system_job(CronJob(
|
||||
id="dream",
|
||||
@@ -819,7 +813,6 @@ def test_remove_system_job_retires_persisted_system_job(tmp_path) -> None:
|
||||
|
||||
|
||||
def test_remove_system_job_without_store_file(tmp_path) -> None:
|
||||
"""Fresh install with the system job disabled: no jobs.json exists yet."""
|
||||
store_path = tmp_path / "cron" / "jobs.json"
|
||||
service = CronService(store_path)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user