The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test: port main-added cron/bot tests onto the canonical owner contract
Teknium3e2162a7b7e7
diff --git a/tests/cron/conftest.py b/tests/cron/conftest.pyindex e6131c23eed..833e23edc08 100644--- a/tests/cron/conftest.py+++ b/tests/cron/conftest.py@@ -84,12 +84,11 @@ def _reset_session_context_vars():_reset_all()-def cron_owner(monkeypatch):- """Replace only the client transport with the production owner execution seam.+def owner_execution_runner():+ """The production owner execution seam as a ``run_canonical_job`` replacement.- This is not admission/RPC coverage. Tests requesting it exercise the real- scheduler under the exact owner-store identity and profile scope.+ This is not admission/RPC coverage: the real scheduler runs under the exact owner-store+ identity and profile scope. A plain function so a subprocess tick can install it too."""from gateway.session_contract import SessionReffrom gateway.session_cron import current_execution, execute@@ -130,5 +129,12 @@ def cron_owner(monkeypatch):finally:release(db)+ return run+++def cron_owner(monkeypatch):+ """Replace only the client transport with the production owner execution seam."""+ run = owner_execution_runner()monkeypatch.setattr("cron.scheduler_authority.run_canonical_job", run)return rundiff --git a/tests/cron/test_context_from_response_extraction.py b/tests/cron/test_context_from_response_extraction.pyindex f2dbf26bb6a..c1ee1d6a6e7 100644--- a/tests/cron/test_context_from_response_extraction.py+++ b/tests/cron/test_context_from_response_extraction.py@@ -118,7 +118,7 @@ class TestScriptModeArchives:assert "```\nplain script payload\nline two\n```" in prompt-def test_writer_reader_preserve_response_with_nested_frames(cron_env, monkeypatch):+def test_writer_reader_preserve_response_with_nested_frames(cron_env, monkeypatch, cron_owner):from cron.jobs import create_job, save_job_outputfrom cron.scheduler_prompt import _inject_context_from@@ -135,7 +135,7 @@ def test_writer_reader_preserve_response_with_nested_frames(cron_env, monkeypatcassert "Original prompt noise" not in prompt-def test_truncated_outer_frame_cannot_promote_a_quoted_inner_frame(cron_env, monkeypatch):+def test_truncated_outer_frame_cannot_promote_a_quoted_inner_frame(cron_env, monkeypatch, cron_owner):import osfrom cron.jobs import create_job, save_job_output, OUTPUT_DIRfrom cron.scheduler_prompt import _inject_context_fromdiff --git a/tests/cron/test_cron_execution_identity.py b/tests/cron/test_cron_execution_identity.pyindex a2082f6322d..84764264e9c 100644--- a/tests/cron/test_cron_execution_identity.py+++ b/tests/cron/test_cron_execution_identity.py@@ -28,8 +28,11 @@ def register(ctx):_TICK = '''import json, sys-from cron import scheduler+from cron import scheduler, scheduler_authorityfrom cron.executions import list_executions+from tests.cron.conftest import owner_execution_runner+# Cron executes inside the profile's owner; run the owner's execution seam in-process.+scheduler_authority.run_canonical_job = owner_execution_runner()from hermes_cli.plugins import get_plugin_managerscheduler.tick(verbose=False, sync=True)ctx = get_plugin_manager()._plugins["cron-identity-probe"].module.CTXdiff --git a/tests/cron/test_unreachable_retry.py b/tests/cron/test_unreachable_retry.pyindex 17cff91cd63..b99b1994339 100644--- a/tests/cron/test_unreachable_retry.py+++ b/tests/cron/test_unreachable_retry.py@@ -149,10 +149,13 @@ def test_ladder_reruns_do_not_spend_extra_repeat_budget(tmp_cron_home, monkeypatjob_id = create_job("digest", "every 24h", repeat=2)["id"]held = []- for _ in range(1 + len(ur.RETRY_DELAYS_SECONDS)): # the occurrence, then every rung+ # Every fire (the occurrence and each rung) carries its own execution id, as in production:+ # completions are deduplicated per execution, so a reused id would make later rungs no-ops.+ for rung in range(1 + len(ur.RETRY_DELAYS_SECONDS)): # the occurrence, then every rung+ execution_id = f"exec-{rung}"clock[0] = datetime.fromisoformat(get_job(job_id)["next_run_at"]) + timedelta(seconds=1)due = next(d for d in get_due_jobs() if d["id"] == job_id)- assert sched._process_due_job(dict(due, execution_id="exec"), None, None, False)+ assert sched._process_due_job(dict(due, execution_id=execution_id), None, None, False)run = runs[-1]if rung_tail == "crash" and held:assert sched._run_one_job_body(run) is False@@ -181,7 +184,7 @@ def test_ladder_reruns_do_not_spend_extra_repeat_budget(tmp_cron_home, monkeypatheld.append(ur.will_retry(run))assert sched._finish_completed_run(sched._RunDelivery(job=run, success=False, error="ConnectError: dns"),- run["fire_claim"]["by"], "exec")+ run["fire_claim"]["by"], execution_id)assert get_job(job_id)["repeat"]["completed"] == 1, "only the occurrence itself counts"j = get_job(job_id)diff --git a/tests/tools/test_bot_mode_dm_entry.py b/tests/tools/test_bot_mode_dm_entry.pyindex a15d6dbd170..1cc3e67165e 100644--- a/tests/tools/test_bot_mode_dm_entry.py+++ b/tests/tools/test_bot_mode_dm_entry.py@@ -77,8 +77,10 @@ def _run(argv, env):def test_delivery_runner_admits_through_dependencies_it_activates(tmp_path, committed_home):"""Live admission (``_admit_live_dm``) imports Hermes' third-party graph. Launched bare, the- runner must activate the committed environment, find no live owner, and hand the DM to the- transport, which consumes the file — never report an ``ambiguous`` import failure."""+ runner must activate the committed environment and find no live owner — never report an+ ``ambiguous`` import failure. With no owner the local CLI transport fallback is retired: the+ runner answers the typed not-ready refusal and retains the DM, never handing it to the+ transport."""_home, env = committed_homeprofile_home = tmp_path / "profile"profile_home.mkdir()@@ -91,9 +93,12 @@ def test_delivery_runner_admits_through_dependencies_it_activates(tmp_path, comm"--profile-home", str(profile_home), *transport], env)assert "No module named" not in result.stdout + result.stderr, result- assert result.returncode == 0, result- assert result.stdout.strip() == "hello teammate"- assert not dm_file.exists()+ assert result.returncode == 1, result+ payload = json.loads(result.stdout)+ assert payload["delivery_id"] == _dm_delivery_id(str(dm_file)), payload+ assert "profile authority is not ready" in payload["error"], payload+ assert "hello teammate" not in result.stdout # the transport never ran+ assert dm_file.read_text(encoding="utf-8") == "hello teammate"def test_delivery_runner_that_cannot_activate_names_the_repair_remedy(tmp_path, uncommittable_home):