From a52afc8cf2a58e8ea2bd1700a5c3fddc3550d764 Mon Sep 17 00:00:00 2001 From: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> Date: Thu, 19 Nov 2026 05:00:31 +0800 Subject: [PATCH 1/6] fix(scheduler): keep Codex fallback on the original C1 runtime Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> --- docs/quota-allocation.md | 11 ++-- loopx/control_plane/quota/live_decision.py | 4 +- scripts/codex_app_apply_rrule.py | 63 ++++++++++++------- .../test_scheduler_fallback_hint.py | 11 ++-- tests/test_codex_app_apply_rrule.py | 38 +++++++++++ 5 files changed, 94 insertions(+), 33 deletions(-) diff --git a/docs/quota-allocation.md b/docs/quota-allocation.md index b907de93e3..afdb3e59ed 100644 --- a/docs/quota-allocation.md +++ b/docs/quota-allocation.md @@ -1823,10 +1823,13 @@ CLI-produced ACK hints bind that argument vector to the exact registry and effective runtime root that produced `quota should-run`. Hosts must execute the complete vector; stripping its leading global options can route a project-launched ACK into project-local scheduler state instead of the shared -control plane. `fallback_hint.cli_args` receives the same registry binding, and -its `--turn-instance-id` value is always the reference the current host shell can -expand: `"${LOOPX_TURN:?}"` on POSIX and `$LOOPX_TURN` on native Windows, so a -PowerShell host does not replay an empty Turn. When the decision is +control plane. `fallback_hint.cli_args` receives the same registry and runtime +root bindings. The bridge reads `scheduler_hint.app_automation` from the +complete decision and reads `codex_app` for earlier CLI payloads that lack the +canonical field. For older saved commands without a runtime root, the registry +route supplies it. When the Turn is still expressed as a shell variable, the +fallback's `--turn-instance-id` uses `"${LOOPX_TURN:?}"` on POSIX and +`$LOOPX_TURN` on native Windows. When the decision is heartbeat-receipted, ACK, failure, and fallback hints also bind the originating concrete `turn_instance_id`, and `fallback_hint.route_binding.turn_instance_bound` records whether that binding is present. The follow-up rebuilds the same diff --git a/loopx/control_plane/quota/live_decision.py b/loopx/control_plane/quota/live_decision.py index f3985881a6..a629b68019 100644 --- a/loopx/control_plane/quota/live_decision.py +++ b/loopx/control_plane/quota/live_decision.py @@ -518,6 +518,8 @@ def bind_scheduler_followup_cli_routes( cli_args[0], "--registry", str(registry_path.expanduser().resolve()), + "--runtime-root", + str(runtime_root.expanduser().resolve()), *cli_args[1:], ] safe_turn_instance_id = str(turn_instance_id or "").strip() @@ -539,7 +541,7 @@ def bind_scheduler_followup_cli_routes( "schema_version": "codex_app_scheduler_fallback_route_v0", "source": source, "registry_bound": True, - "runtime_root_bound": False, + "runtime_root_bound": True, "turn_instance_bound": bool(safe_turn_instance_id), } continue diff --git a/scripts/codex_app_apply_rrule.py b/scripts/codex_app_apply_rrule.py index cd96b22078..ccf6cee3f1 100644 --- a/scripts/codex_app_apply_rrule.py +++ b/scripts/codex_app_apply_rrule.py @@ -4,7 +4,8 @@ Fallback host bridge for hosts where the Codex App does not expose ``automation_update``. The script: -1. reads ``loopx quota should-run`` and its ``scheduler_hint.codex_app``; +1. replays the original registry, runtime and Turn through ``loopx quota + should-run`` and consumes ``scheduler_hint.app_automation``; 2. when ``stateful_backoff.apply_needed=true`` and ``recommended_rrule`` is present, creates the automation TOML and ``automations`` row when they are missing, backs up the Codex App automation SQLite database, and updates @@ -30,8 +31,9 @@ from pathlib import Path from typing import Any -from loopx.turn_identity import normalize_turn_instance_id +from loopx.control_plane.quota.turn_envelope import COMPLETE_TURN_DECISION_VERSION from loopx.paths import global_registry_path, select_default_runtime_root +from loopx.turn_identity import normalize_turn_instance_id _FAILURE_OUTPUT_LIMIT = 2_000 @@ -100,19 +102,22 @@ def _load_registry_goal(registry: Path, goal_id: str) -> dict[str, Any]: return {} +def _loopx_json_route(loopx: str, registry: Path, runtime_root: Path | None) -> list[str]: + command = [loopx, "--format", "json", "--registry", str(registry)] + if runtime_root is not None: + command.extend(["--runtime-root", str(runtime_root)]) + return command + + def _heartbeat_task_body( *, loopx: str, registry: Path, goal_id: str, agent_id: str, + runtime_root: Path | None = None, ) -> str: - command = [ - loopx, - "--format", - "json", - "--registry", - str(registry), + command = _loopx_json_route(loopx, registry, runtime_root) + [ "heartbeat-prompt", "--thin", "--goal-id", @@ -337,6 +342,7 @@ def _ensure_automation( agent_id: str, rrule: str, backup_path: Path | None, + runtime_root: Path | None = None, ) -> bool: toml_path = automations_root / automation_id / "automation.toml" if toml_path.exists() and _sqlite_row_exists(db_path, automation_id): @@ -356,6 +362,7 @@ def _ensure_automation( registry=registry, goal_id=goal_id, agent_id=agent_id, + runtime_root=runtime_root, ) else: prompt = _heartbeat_task_body( @@ -363,6 +370,7 @@ def _ensure_automation( registry=registry, goal_id=goal_id, agent_id=agent_id, + runtime_root=runtime_root, ) _write_automation_toml( toml_path, @@ -392,14 +400,10 @@ def _load_scheduler_hint( agent_id: str, parent_turn_instance_id: str, capabilities: list[str], + runtime_root: Path | None = None, ) -> tuple[dict[str, Any], dict[str, Any]]: turn_instance_id = _scheduler_hint_turn_instance_id(parent_turn_instance_id) - command = [ - loopx, - "--format", - "json", - "--registry", - str(registry), + command = _loopx_json_route(loopx, registry, runtime_root) + [ "quota", "should-run", "--goal-id", @@ -434,14 +438,18 @@ def _load_scheduler_hint( payload = json.loads(completed.stdout) except json.JSONDecodeError as exc: raise SystemExit(f"loopx should-run returned invalid JSON: {exc}") from exc - hint = payload.get("scheduler_hint", {}) - codex_app = hint.get("codex_app", {}) - if not isinstance(codex_app, dict): - codex_app = {} - stateful = codex_app.get("stateful_backoff", {}) + hint = payload.get("scheduler_hint") if isinstance(payload, dict) else None + if not isinstance(hint, dict): + return {}, {} + app = hint.get("app_automation") + if "app_automation" not in hint and payload.get("schema_version") != COMPLETE_TURN_DECISION_VERSION: + app = hint.get("codex_app") + if not isinstance(app, dict): + return {}, {} + stateful = app.get("stateful_backoff", {}) if not isinstance(stateful, dict): stateful = {} - return codex_app, stateful + return app, stateful def _update_toml(toml_path: Path, rrule: str) -> None: @@ -522,6 +530,11 @@ def _parse_args(argv: list[str]) -> argparse.Namespace: type=Path, help="Global registry; defaults to the selected LoopX local state route.", ) + parser.add_argument( + "--runtime-root", + type=Path, + help="Original runtime root of the parent Turn. Defaults to the registry route.", + ) parser.add_argument("--automation-id", default="loopx") parser.add_argument( "--automations-root", @@ -550,23 +563,24 @@ def _parse_args(argv: list[str]) -> argparse.Namespace: parser.add_argument("--dry-run", action="store_true") args = parser.parse_args(argv) if args.registry is None: - args.registry = global_registry_path(select_default_runtime_root()) + args.registry = global_registry_path(args.runtime_root or select_default_runtime_root()) return args def main(argv: list[str] | None = None) -> int: args = _parse_args(sys.argv[1:] if argv is None else argv) - codex_app, stateful = _load_scheduler_hint( + app, stateful = _load_scheduler_hint( loopx=args.loopx, registry=args.registry, goal_id=args.goal_id, agent_id=args.agent_id, parent_turn_instance_id=args.turn_instance_id, capabilities=args.capability, + runtime_root=args.runtime_root, ) apply_needed = stateful.get("apply_needed") is True - rrule = codex_app.get("recommended_rrule") or stateful.get("current_rrule") - ack_hint = codex_app.get("ack_hint", {}) + rrule = app.get("recommended_rrule") or stateful.get("current_rrule") + ack_hint = app.get("ack_hint", {}) ack_args = ack_hint.get("cli_args") if isinstance(ack_hint, dict) else None toml_path = args.automations_root / args.automation_id / "automation.toml" toml_missing = not toml_path.exists() @@ -623,6 +637,7 @@ def main(argv: list[str] | None = None) -> int: agent_id=args.agent_id, rrule=rrule, backup_path=backup_path, + runtime_root=args.runtime_root, ) print(f"created missing automation: {args.automation_id}") _update_toml(toml_path, rrule) diff --git a/tests/control_plane/test_scheduler_fallback_hint.py b/tests/control_plane/test_scheduler_fallback_hint.py index 1ef74314e8..a4d63dc9ba 100644 --- a/tests/control_plane/test_scheduler_fallback_hint.py +++ b/tests/control_plane/test_scheduler_fallback_hint.py @@ -168,7 +168,7 @@ def test_settled_cadence_omits_fallback_hint(tmp_path: Path) -> None: assert "fallback_hint" not in second["codex_app"] -def test_fallback_hint_cli_route_binds_registry(tmp_path: Path) -> None: +def test_fallback_hint_cli_route_binds_registry_and_runtime(tmp_path: Path) -> None: payload = { "scheduler_hint": { "app_automation": { @@ -189,22 +189,25 @@ def test_fallback_hint_cli_route_binds_registry(tmp_path: Path) -> None: } } registry_path = tmp_path / "registry.json" + runtime_root = tmp_path / "runtime" bind_scheduler_followup_cli_routes( payload, registry_path=registry_path, - runtime_root=tmp_path / "runtime", + runtime_root=runtime_root, ) fallback = payload["scheduler_hint"]["app_automation"]["fallback_hint"] - assert fallback["cli_args"][:3] == [ + assert fallback["cli_args"][:5] == [ "loopx-apply-rrule", "--registry", str(registry_path.resolve()), + "--runtime-root", + str(runtime_root.resolve()), ] assert fallback["route_binding"]["schema_version"] == ( "codex_app_scheduler_fallback_route_v0" ) assert fallback["route_binding"]["registry_bound"] is True - assert fallback["route_binding"]["runtime_root_bound"] is False + assert fallback["route_binding"]["runtime_root_bound"] is True def _fallback_payload() -> dict: diff --git a/tests/test_codex_app_apply_rrule.py b/tests/test_codex_app_apply_rrule.py index 8e96ac160d..1ccf85466d 100644 --- a/tests/test_codex_app_apply_rrule.py +++ b/tests/test_codex_app_apply_rrule.py @@ -12,6 +12,7 @@ import pytest from loopx.cli import build_parser +from loopx.control_plane.quota.turn_envelope import COMPLETE_TURN_DECISION_VERSION from scripts.codex_app_apply_rrule import ( _load_scheduler_hint, _now_ms, @@ -167,6 +168,37 @@ def fake_run(command, **kwargs): assert "--available-capability" not in calls[0] +@pytest.mark.parametrize("has_canonical_hint", [True, False]) +def test_complete_hint_uses_only_canonical_scheduler_facts( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch, has_canonical_hint: bool +) -> None: + payload = _hint_payload(apply_needed=True) + payload["schema_version"] = COMPLETE_TURN_DECISION_VERSION + canonical = {"stateful_backoff": {"apply_needed": False, "ack_needed": True}} + if has_canonical_hint: + payload["scheduler_hint"]["app_automation"] = canonical + bound_root = tmp_path / "original-runtime" + + def fake_run(command, **kwargs): + option = command.index("--runtime-root") + assert command[option + 1] == str(bound_root) + assert command[option + 2 : option + 4] == ["quota", "should-run"] + return _FakeCompleted(payload) + + monkeypatch.setattr("scripts.codex_app_apply_rrule.subprocess.run", fake_run) + app, state = _load_scheduler_hint( + loopx="loopx", + registry=tmp_path / "registry.json", + goal_id="loopx-meta", + agent_id="codex-fixture", + parent_turn_instance_id="original-turn", + capabilities=[], + runtime_root=bound_root, + ) + assert app == (canonical if has_canonical_hint else {}) + assert state.get("apply_needed") is not True + + def test_default_app_stores_follow_codex_home_and_capabilities_are_explicit( tmp_path: Path, monkeypatch, @@ -404,6 +436,7 @@ def test_apply_creates_missing_automation_toml_and_sqlite( automations_root = tmp_path / "automations" db_path = tmp_path / "codex-dev.db" registry_path = tmp_path / "registry.json" + runtime_root = tmp_path / "original-runtime" sqlite3.connect(str(db_path)).close() registry_path.write_text( json.dumps( @@ -429,6 +462,9 @@ def test_apply_creates_missing_automation_toml_and_sqlite( calls: list[list[str]] = [] def fake_run(command, **kwargs): + if "should-run" in command or "heartbeat-prompt" in command: + option = command.index("--runtime-root") + assert command[option + 1] == str(runtime_root) if "should-run" in command: return _FakeCompleted(_hint_payload(apply_needed=True)) if "heartbeat-prompt" in command: @@ -454,6 +490,8 @@ def fake_run(command, **kwargs): str(db_path), "--registry", str(registry_path), + "--runtime-root", + str(runtime_root), "--goal-id", "goal", "--agent-id", From e2b3362559004fc268ea318055190c68248984c4 Mon Sep 17 00:00:00 2001 From: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> Date: Thu, 19 Nov 2026 05:28:06 +0800 Subject: [PATCH 2/6] fix(scheduler): pin the originating fallback launchers Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> --- docs/quota-allocation.md | 7 ++-- loopx/control_plane/quota/live_decision.py | 23 +++++++++++-- .../test_scheduler_fallback_hint.py | 33 +++++++++++++++++++ 3 files changed, 59 insertions(+), 4 deletions(-) diff --git a/docs/quota-allocation.md b/docs/quota-allocation.md index afdb3e59ed..f92d538eb3 100644 --- a/docs/quota-allocation.md +++ b/docs/quota-allocation.md @@ -1826,8 +1826,11 @@ project-launched ACK into project-local scheduler state instead of the shared control plane. `fallback_hint.cli_args` receives the same registry and runtime root bindings. The bridge reads `scheduler_hint.app_automation` from the complete decision and reads `codex_app` for earlier CLI payloads that lack the -canonical field. For older saved commands without a runtime root, the registry -route supplies it. When the Turn is still expressed as a shell variable, the +canonical field. An executable-bound guard also passes its selected CLI to the +bridge. When that installation ships an executable POSIX fallback launcher +beside the CLI, the command also names that launcher. For older saved commands +without a runtime root, the registry route supplies it. When the Turn is still +expressed as a shell variable, the fallback's `--turn-instance-id` uses `"${LOOPX_TURN:?}"` on POSIX and `$LOOPX_TURN` on native Windows. When the decision is heartbeat-receipted, ACK, failure, and fallback hints also bind the originating diff --git a/loopx/control_plane/quota/live_decision.py b/loopx/control_plane/quota/live_decision.py index a629b68019..99078a0947 100644 --- a/loopx/control_plane/quota/live_decision.py +++ b/loopx/control_plane/quota/live_decision.py @@ -1,6 +1,7 @@ from __future__ import annotations from .effective_action import EffectiveAction +import os import shlex from collections.abc import Callable, Mapping, Sequence from functools import partial @@ -9,7 +10,7 @@ from ...quota import build_quota_should_run from ...agent_registry import load_goal_from_registry, registered_agent_ids_for_goal -from ...command_invocation import loopx_cli_argv +from ...command_invocation import current_loopx_cli_argv, loopx_cli_argv from ..agent_context import project_agent_context, project_goal_agent_context from ..agents.identity import build_quota_agent_identity from ..runtime.time import now_utc_iso @@ -484,6 +485,21 @@ def _bind_followup_turn_argument( return str(cli_args[index + 1]) +def _scheduler_fallback_launcher() -> list[str]: + """Keep an executable-bound replay on its selected Core installation.""" + fallback = "loopx-apply-rrule" + route = current_loopx_cli_argv() + if route[1:] != ["--cli-bin", route[0]]: + return [fallback] + executable = Path(route[0]) + if executable.is_absolute() and executable.is_file(): + executable = executable.resolve() + companion = executable.with_name(fallback) + if os.name != "nt" and companion.is_file() and os.access(companion, os.X_OK): + fallback = str(companion) + return [fallback, "--loopx", str(executable)] + + def bind_scheduler_followup_cli_routes( payload: dict[str, Any], *, @@ -503,6 +519,7 @@ def bind_scheduler_followup_cli_routes( for packet_key in ("app_automation", "codex_app") if isinstance((packet := scheduler_hint.get(packet_key)), dict) ] + fallback_launcher: list[str] | None = None for app_packet in app_packets: for hint_name in ("ack_hint", "failure_hint", "fallback_hint"): followup_hint = app_packet.get(hint_name) @@ -514,8 +531,10 @@ def bind_scheduler_followup_cli_routes( if hint_name == "fallback_hint": if cli_args[0] != "loopx-apply-rrule" or "--registry" in cli_args: continue + if fallback_launcher is None: + fallback_launcher = _scheduler_fallback_launcher() bound_cli_args = [ - cli_args[0], + *fallback_launcher, "--registry", str(registry_path.expanduser().resolve()), "--runtime-root", diff --git a/tests/control_plane/test_scheduler_fallback_hint.py b/tests/control_plane/test_scheduler_fallback_hint.py index a4d63dc9ba..3daed308f1 100644 --- a/tests/control_plane/test_scheduler_fallback_hint.py +++ b/tests/control_plane/test_scheduler_fallback_hint.py @@ -1,5 +1,6 @@ from __future__ import annotations +import os import sys from datetime import datetime, timezone from pathlib import Path @@ -238,6 +239,38 @@ def _fallback_payload() -> dict: } +@pytest.mark.skipif(os.name == "nt", reason="the co-installed fallback launcher is a shell entrypoint") +@pytest.mark.parametrize("has_companion", [True, False]) +def test_fallback_replays_the_bound_cli_and_its_companion( + tmp_path: Path, has_companion: bool, +) -> None: + release = tmp_path / "selected release" + release.mkdir() + executable = release / "loopx" + executable.touch() + executable.chmod(0o700) + alias = tmp_path / "loopx" + alias.symlink_to(executable) + companion = release / "loopx-apply-rrule" + if has_companion: + companion.touch() + companion.chmod(0o700) + + payload = _fallback_payload() + with loopx_cli_route(str(alias)): + bind_scheduler_followup_cli_routes( + payload, + registry_path=tmp_path / "registry.json", + runtime_root=tmp_path / "runtime", + turn_instance_id="original-turn", + ) + + fallback = payload["scheduler_hint"]["app_automation"]["fallback_hint"] + command = str(companion) if has_companion else "loopx-apply-rrule" + assert fallback["cli_args"][:3] == [command, "--loopx", str(executable)] + assert fallback["cli_args"][-2:] == ["--turn-instance-id", "original-turn"] + + def test_fallback_hint_binds_the_receipted_turn(tmp_path: Path) -> None: payload = _fallback_payload() From 1f5c73a34d7783ad8d641739036bdbd82d5d1f3e Mon Sep 17 00:00:00 2001 From: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> Date: Thu, 19 Nov 2026 05:59:11 +0800 Subject: [PATCH 3/6] Retire the duplicate Codex App scheduler projection Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> --- .../07-host-scheduler-and-heartbeat.md | 22 +-- .../operations/automation-minimum-interval.md | 4 +- docs/quota-allocation.md | 9 +- examples/agent-diagnose-packet-smoke.py | 2 +- .../control-plane-integrated-canary-smoke.py | 26 ++-- ...ntrol-plane-risk-characterization-smoke.py | 8 +- .../heartbeat-quota-flow-smoke.py | 4 +- ...nteraction-contract-state-machine-smoke.py | 2 +- .../monitor-poll-writeback-smoke.py | 12 +- .../monitor-scheduler-contract-smoke.py | 20 +-- .../quota-agent-scoped-user-gate-smoke.py | 14 +- ...ta-cleared-blocker-successor-gate-smoke.py | 8 +- examples/control_plane/quota-plan-smoke.py | 6 +- .../quota-scheduler-state-ack-smoke.py | 4 +- .../quota-terminal-no-followup-smoke.py | 13 +- examples/control_plane/quota_plan_fixtures.py | 2 +- ...status-quota-review-packet-parity-smoke.py | 2 +- .../control_plane/task-orchestration-smoke.py | 4 +- loopx/control_plane/quota/live_decision.py | 147 +++++++++--------- loopx/control_plane/quota/scheduler_ack.py | 20 +-- loopx/control_plane/scheduler/hint.ts | 31 ++-- .../control_plane/scheduler/hint_execution.ts | 24 +-- .../control_plane/scheduler/hint_followup.ts | 12 -- .../control_plane/scheduler/scheduler_hint.py | 12 +- tests/control_plane/test_goal_activation.py | 2 +- .../test_quota_paused_precedence.py | 2 +- .../test_quota_settlement_cli.py | 4 +- ...test_scheduler_ack_current_host_binding.py | 16 +- .../test_scheduler_ack_decision_table.py | 7 +- .../test_scheduler_arbitration_native_cli.py | 12 +- .../test_scheduler_backoff_convergence.py | 48 +++--- .../test_scheduler_compat_state_key.py | 5 +- .../test_scheduler_execution_context.py | 71 +++------ .../test_scheduler_fallback_hint.py | 10 +- .../test_scheduler_host_failure_cache.py | 20 +-- ..._scheduler_host_followup_hint_transport.py | 2 +- .../test_scheduler_interaction_arbitration.py | 16 +- .../test_user_gate_lane_progress.py | 18 +-- tests/test_automation_cadence.py | 8 +- tests/test_loopx_turn_driver.py | 14 +- tests/test_scheduler_native_launcher.py | 2 +- 41 files changed, 300 insertions(+), 365 deletions(-) diff --git a/docs/development/control-plane-course/07-host-scheduler-and-heartbeat.md b/docs/development/control-plane-course/07-host-scheduler-and-heartbeat.md index ae8c0f90b7..d7996da2ef 100644 --- a/docs/development/control-plane-course/07-host-scheduler-and-heartbeat.md +++ b/docs/development/control-plane-course/07-host-scheduler-and-heartbeat.md @@ -212,17 +212,17 @@ Scheduler ACK 本身不构成 delivery,不 spend。 ### 兼容投影不能改变状态权威 / Compatibility preserves state authority -`app_automation` 与 `codex_app` 是同一 proposal 的宿主投影,不是两个 scheduler -writer。读取优先采用 common state;仅有旧 Codex state 时,保留它经 TS 验证的 -`state_key`。两份投影的 backoff、host facts 与 ACK/failure 命令都必须携带同一个键。 -否则 common state 的当前 identity/index 会被误写到旧键,触发真实的初始档位冲突; -即使 CAS digest 相等也不代表 proposal 的状态归属正确。 - -`app_automation` and `codex_app` project one proposal, not two scheduler writers. -Reads prefer common state; a legacy-only Codex installation retains its -TS-validated legacy key. Both projections must carry that same key through -backoff, host facts and ACK/failure commands. Equal CAS digests do not prove that -a proposal belongs to the chosen state scope. +新决策统一使用 `app_automation` 携带调度建议和宿主行动。旧捕获仍可读取其中的 +`codex_app`。读取优先采用 common state。仅有旧 Codex state 时,保留 TS 验证过的 +`state_key`,并将同一个键贯穿 backoff、host facts 与 ACK/failure 命令。 +写回前须校验状态归属及 CAS 摘要,否则可能把已推进的档位写入错误的状态键。 + +New decisions use `app_automation` for the cadence proposal and Host actions. +Saved captures can still carry `codex_app`. Reads prefer common state. A +legacy-only Codex installation retains the TS-validated state key through +backoff, Host facts, and ACK/failure commands. Before writing, validate the +state scope and CAS digest to keep the recorded progression in its original +state. 兼容 Python API 与手工 Codex CLI 未显式传 `state_key` 时,从当前 packet 取得实际键; 显式键仍须匹配,不得静默改写。Trae 仍只接受 common key。这不是隐式迁移:不能把 diff --git a/docs/operations/automation-minimum-interval.md b/docs/operations/automation-minimum-interval.md index 7f701d62dc..8d4108440b 100644 --- a/docs/operations/automation-minimum-interval.md +++ b/docs/operations/automation-minimum-interval.md @@ -33,8 +33,8 @@ caller intent, not authentication against other processes sharing the OS user. For an already bound App turn, inspect its `quota should-run` scheduler packet using that turn's normal identity and selection contract. Do not create a new -turn solely to observe a timer. `scheduler_hint.app_automation` and its legacy -`codex_app` projection expose the floor, desired RRULE, apply/ACK state and +turn solely to observe a timer. `scheduler_hint.app_automation` exposes the +floor, desired RRULE, apply/ACK state and `guarantee`. Apply the desired schedule with the App's `automation_update` tool, preserving task binding, prompt, status and notification preference. Then view that same automation and compare its actual schedule before running the returned diff --git a/docs/quota-allocation.md b/docs/quota-allocation.md index f92d538eb3..16cb1a44f1 100644 --- a/docs/quota-allocation.md +++ b/docs/quota-allocation.md @@ -1798,6 +1798,11 @@ trigger uses a fresh Turn identity to evaluate the live frontier; it never re-executes or spends for the closed Turn. Native Goal runtimes continue to that fresh guard instead of blocking the Goal. Explicit Goal stop or quota pause still takes precedence. Actual fresh-Turn waits retain their existing backoff. +New scheduler decisions expose App cadence, applicability, and follow-up +commands only under `scheduler_hint.app_automation`. This includes shutdown, +minimum-interval waits, and the explicit unavailable state for schedulers owned +outside the App. A saved decision retains its original representation. Older +Codex state still uses its recorded state key when it is the selected authority. For Codex App and local schedulers, `recommended_interval_minutes` is the next target interval. For Codex App heartbeats, `recommended_rrule` is emitted only when `app_automation.stateful_backoff.apply_needed=true`; if the desired RRULE is @@ -1825,8 +1830,8 @@ complete vector; stripping its leading global options can route a project-launched ACK into project-local scheduler state instead of the shared control plane. `fallback_hint.cli_args` receives the same registry and runtime root bindings. The bridge reads `scheduler_hint.app_automation` from the -complete decision and reads `codex_app` for earlier CLI payloads that lack the -canonical field. An executable-bound guard also passes its selected CLI to the +complete decision. It accepts a legacy `codex_app` packet from an earlier CLI +version. An executable-bound guard also passes its selected CLI to the bridge. When that installation ships an executable POSIX fallback launcher beside the CLI, the command also names that launcher. For older saved commands without a runtime root, the registry route supplies it. When the Turn is still diff --git a/examples/agent-diagnose-packet-smoke.py b/examples/agent-diagnose-packet-smoke.py index 968eafe478..935bdae529 100644 --- a/examples/agent-diagnose-packet-smoke.py +++ b/examples/agent-diagnose-packet-smoke.py @@ -357,7 +357,7 @@ def main() -> int: scheduler_hint = selected["quota_signals"]["scheduler_hint"] assert scheduler_hint["schema_version"] == "diagnose_scheduler_hint_summary_v0", selected assert "local_scheduler" not in str(scheduler_hint), scheduler_hint - assert scheduler_hint["codex_app"]["no_spend_for_cadence_change"] is True, scheduler_hint + assert scheduler_hint["app_automation"]["no_spend_for_cadence_change"] is True, scheduler_hint assert selected["agent_reasoning_checklist"], selected assert any( " diagnose " in command and f"--goal-id {GOAL_ID}" in command diff --git a/examples/control_plane/control-plane-integrated-canary-smoke.py b/examples/control_plane/control-plane-integrated-canary-smoke.py index c1ca0a8c28..3d9a9df544 100644 --- a/examples/control_plane/control-plane-integrated-canary-smoke.py +++ b/examples/control_plane/control-plane-integrated-canary-smoke.py @@ -32,6 +32,7 @@ PRIMARY_AGENT_ID = "codex-main-control" CANARY_TODO_ID = "todo_integrated_canary" CANARY_TODO_TITLE = "Design bounded status/quota/review-packet/Todo/read-path canary" +DURABLE_NEXT_ACTION = "Keep the fixture-only integrated canary under two minutes." SUCCESSOR_TODO_TITLE = "Continue integrated canonical successor routing canary" CONTINUATION_TITLE = "[P1] Continue same-agent canonical continuation through status and quota." MONITOR_TODO_ID = "todo_integrated_due_monitor" @@ -54,7 +55,7 @@ def write_fixture(root: Path) -> tuple[Path, Path, Path]: "---\n\n" "# Control Plane Integrated Canary\n\n" "## Next Action\n\n" - "- Keep the fixture-only integrated canary under two minutes.\n\n" + f"- {DURABLE_NEXT_ACTION}\n\n" "## Agent Todo\n\n" "- [ ] [P2] Markdown fallback todo that should lose to the event log.\n" "