Skip to content

Commit 39f37bf

Browse files
authored
Merge pull request #9057 from loopx-project/codex/c1-scheduler-fallback-20261119
Use one C1 scheduler proposal through Codex fallback
2 parents 14dbfcb + 0946e69 commit 39f37bf

45 files changed

Lines changed: 491 additions & 450 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎docs/development/control-plane-course/07-host-scheduler-and-heartbeat.md‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -212,17 +212,17 @@ Scheduler ACK 本身不构成 delivery,不 spend。
212212

213213
### 兼容投影不能改变状态权威 / Compatibility preserves state authority
214214

215-
`app_automation` 与 `codex_app` 是同一 proposal 的宿主投影,不是两个 scheduler
216-
writer。读取优先采用 common state;仅有旧 Codex state 时,保留它经 TS 验证的
217-
`state_key`。两份投影的 backoff、host facts 与 ACK/failure 命令都必须携带同一个键。
218-
否则 common state 的当前 identity/index 会被误写到旧键,触发真实的初始档位冲突;
219-
即使 CAS digest 相等也不代表 proposal 的状态归属正确。
220-
221-
`app_automation` and `codex_app` project one proposal, not two scheduler writers.
222-
Reads prefer common state; a legacy-only Codex installation retains its
223-
TS-validated legacy key. Both projections must carry that same key through
224-
backoff, host facts and ACK/failure commands. Equal CAS digests do not prove that
225-
a proposal belongs to the chosen state scope.
215+
新决策统一使用 `app_automation` 携带调度建议和宿主行动。旧捕获仍可读取其中的
216+
`codex_app`。读取优先采用 common state。仅有旧 Codex state 时,保留 TS 验证过的
217+
`state_key`,并将同一个键贯穿 backoff、host facts 与 ACK/failure 命令。
218+
写回前须校验状态归属及 CAS 摘要,否则可能把已推进的档位写入错误的状态键。
219+
220+
New decisions use `app_automation` for the cadence proposal and Host actions.
221+
Saved captures can still carry `codex_app`. Reads prefer common state. A
222+
legacy-only Codex installation retains the TS-validated state key through
223+
backoff, Host facts, and ACK/failure commands. Before writing, validate the
224+
state scope and CAS digest to keep the recorded progression in its original
225+
state.
226226

227227
兼容 Python API 与手工 Codex CLI 未显式传 `state_key` 时,从当前 packet 取得实际键;
228228
显式键仍须匹配,不得静默改写。Trae 仍只接受 common key。这不是隐式迁移:不能把

‎docs/operations/automation-minimum-interval.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ caller intent, not authentication against other processes sharing the OS user.
3333

3434
For an already bound App turn, inspect its `quota should-run` scheduler packet
3535
using that turn's normal identity and selection contract. Do not create a new
36-
turn solely to observe a timer. `scheduler_hint.app_automation` and its legacy
37-
`codex_app` projection expose the floor, desired RRULE, apply/ACK state and
36+
turn solely to observe a timer. `scheduler_hint.app_automation` exposes the
37+
floor, desired RRULE, apply/ACK state and
3838
`guarantee`. Apply the desired schedule with the App's `automation_update` tool,
3939
preserving task binding, prompt, status and notification preference. Then view
4040
that same automation and compare its actual schedule before running the returned

‎docs/quota-allocation.md‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1798,6 +1798,11 @@ trigger uses a fresh Turn identity to evaluate the live frontier; it never
17981798
re-executes or spends for the closed Turn. Native Goal runtimes continue to that
17991799
fresh guard instead of blocking the Goal. Explicit Goal stop or quota pause
18001800
still takes precedence. Actual fresh-Turn waits retain their existing backoff.
1801+
New scheduler decisions expose App cadence, applicability, and follow-up
1802+
commands only under `scheduler_hint.app_automation`. This includes shutdown,
1803+
minimum-interval waits, and the explicit unavailable state for schedulers owned
1804+
outside the App. A saved decision retains its original representation. Older
1805+
Codex state still uses its recorded state key when it is the selected authority.
18011806
For Codex App and local schedulers, `recommended_interval_minutes` is the next
18021807
target interval. For Codex App heartbeats, `recommended_rrule` is emitted only
18031808
when `app_automation.stateful_backoff.apply_needed=true`; if the desired RRULE is
@@ -1823,10 +1828,16 @@ CLI-produced ACK hints bind that argument vector to the exact registry and
18231828
effective runtime root that produced `quota should-run`. Hosts must execute the
18241829
complete vector; stripping its leading global options can route a
18251830
project-launched ACK into project-local scheduler state instead of the shared
1826-
control plane. `fallback_hint.cli_args` receives the same registry binding, and
1827-
its `--turn-instance-id` value is always the reference the current host shell can
1828-
expand: `"${LOOPX_TURN:?}"` on POSIX and `$LOOPX_TURN` on native Windows, so a
1829-
PowerShell host does not replay an empty Turn. When the decision is
1831+
control plane. `fallback_hint.cli_args` receives the same registry and runtime
1832+
root bindings. The bridge reads `scheduler_hint.app_automation` from the
1833+
complete decision. It accepts a legacy `codex_app` packet from an earlier CLI
1834+
version. An executable-bound guard also passes its selected CLI to the
1835+
bridge. When that installation ships an executable POSIX fallback launcher
1836+
beside the CLI, the command also names that launcher. For older saved commands
1837+
without a runtime root, the registry route supplies it. When the Turn is still
1838+
expressed as a shell variable, the
1839+
fallback's `--turn-instance-id` uses `"${LOOPX_TURN:?}"` on POSIX and
1840+
`$LOOPX_TURN` on native Windows. When the decision is
18301841
heartbeat-receipted, ACK, failure, and fallback hints also bind the originating
18311842
concrete `turn_instance_id`, and `fallback_hint.route_binding.turn_instance_bound`
18321843
records whether that binding is present. The follow-up rebuilds the same

‎examples/agent-diagnose-packet-smoke.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def main() -> int:
357357
scheduler_hint = selected["quota_signals"]["scheduler_hint"]
358358
assert scheduler_hint["schema_version"] == "diagnose_scheduler_hint_summary_v0", selected
359359
assert "local_scheduler" not in str(scheduler_hint), scheduler_hint
360-
assert scheduler_hint["codex_app"]["no_spend_for_cadence_change"] is True, scheduler_hint
360+
assert scheduler_hint["app_automation"]["no_spend_for_cadence_change"] is True, scheduler_hint
361361
assert selected["agent_reasoning_checklist"], selected
362362
assert any(
363363
" diagnose " in command and f"--goal-id {GOAL_ID}" in command

‎examples/control_plane/control-plane-integrated-canary-smoke.py‎

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
PRIMARY_AGENT_ID = "codex-main-control"
3333
CANARY_TODO_ID = "todo_integrated_canary"
3434
CANARY_TODO_TITLE = "Design bounded status/quota/review-packet/Todo/read-path canary"
35+
DURABLE_NEXT_ACTION = "Keep the fixture-only integrated canary under two minutes."
3536
SUCCESSOR_TODO_TITLE = "Continue integrated canonical successor routing canary"
3637
CONTINUATION_TITLE = "[P1] Continue same-agent canonical continuation through status and quota."
3738
MONITOR_TODO_ID = "todo_integrated_due_monitor"
@@ -54,7 +55,7 @@ def write_fixture(root: Path) -> tuple[Path, Path, Path]:
5455
"---\n\n"
5556
"# Control Plane Integrated Canary\n\n"
5657
"## Next Action\n\n"
57-
"- Keep the fixture-only integrated canary under two minutes.\n\n"
58+
f"- {DURABLE_NEXT_ACTION}\n\n"
5859
"## Agent Todo\n\n"
5960
"- [ ] [P2] Markdown fallback todo that should lose to the event log.\n"
6061
" <!-- loopx:todo todo_id=todo_markdown_fallback status=open "
@@ -176,17 +177,17 @@ def find_queue_item(status_payload: dict[str, Any], *, goal_id: str = GOAL_ID) -
176177
def assert_selected_agent_todo(
177178
summary: dict[str, Any],
178179
*,
179-
compact_quota: bool = False,
180+
complete_quota: bool = False,
180181
) -> None:
181-
item_lane = "first_executable_items" if compact_quota else "first_open_items"
182+
item_lane = "first_executable_items" if complete_quota else "first_open_items"
182183
items = summary.get(item_lane) if isinstance(summary.get(item_lane), list) else []
183-
if not items and not compact_quota:
184+
if not items and not complete_quota:
184185
items = summary.get("items") if isinstance(summary.get("items"), list) else []
185186
assert [item.get("todo_id") for item in items] == [CANARY_TODO_ID], summary
186187
item = items[0]
187-
if compact_quota:
188+
if complete_quota:
188189
assert summary["payload_compaction"]["schema_version"] == (
189-
"quota_cli_todo_summary_compaction_v0"
190+
"quota_todo_summary_payload_compaction_v0"
190191
), summary
191192
assert item["text"] == f"[P1] {CANARY_TODO_TITLE}", summary
192193
# The shared diagnostic projection retains each visible record in full.
@@ -228,7 +229,7 @@ def assert_bounded_delivery_state_machine_bundle(quota_payload: dict[str, Any])
228229
scheduler = quota_payload["scheduler_hint"]
229230
assert scheduler["action"] == "run_now", scheduler
230231
assert scheduler["cadence_class"] == "active_work", scheduler
231-
codex_app = scheduler["codex_app"]
232+
codex_app = scheduler["app_automation"]
232233
assert codex_app["recommended_rrule"] == "FREQ=MINUTELY;INTERVAL=3", scheduler
233234
assert codex_app["no_spend_for_cadence_change"] is True, scheduler
234235
assert codex_app["stateful_backoff"]["apply_needed"] is True, scheduler
@@ -259,7 +260,7 @@ def assert_scheduler_ack_state_machine(
259260
runtime_root: Path,
260261
quota_payload: dict[str, Any],
261262
) -> dict[str, Any]:
262-
codex_app = quota_payload["scheduler_hint"]["codex_app"]
263+
codex_app = quota_payload["scheduler_hint"]["app_automation"]
263264
backoff = codex_app["stateful_backoff"]
264265
ack_payload = run_cli(
265266
registry_path,
@@ -300,7 +301,7 @@ def assert_scheduler_ack_state_machine(
300301
AGENT_ID,
301302
"--codex-app",
302303
)
303-
steady_codex_app = steady_payload["scheduler_hint"]["codex_app"]
304+
steady_codex_app = steady_payload["scheduler_hint"]["app_automation"]
304305
assert steady_codex_app["stateful_backoff"]["apply_needed"] is False, steady_payload
305306
assert steady_codex_app["stateful_backoff"]["state_status"] == "same_identity", steady_payload
306307
assert steady_codex_app["host_action"] == "none", steady_payload
@@ -394,9 +395,9 @@ def assert_todo_completion_successor_state_machine(
394395
assert routed["effective_action"] == "normal_run", routed
395396
assert routed["agent_lane_next_action"]["todo_id"] == successor_id, routed
396397
assert routed["agent_lane_next_action"]["text"] == f"[P1] {SUCCESSOR_TODO_TITLE}", routed
397-
assert "title" not in routed["agent_lane_next_action"], routed
398+
assert routed["agent_lane_next_action"]["title"] == SUCCESSOR_TODO_TITLE, routed
398399
assert routed["agent_lane_next_action"]["preserves_goal_next_action"] is True, routed
399-
assert "active_state_next_action" not in routed, routed
400+
assert routed["active_state_next_action"] == DURABLE_NEXT_ACTION, routed
400401
assert routed["goal_route_hint"]["selected_action_differs_from_durable"] is True, routed
401402
assert routed["goal_route_hint"]["goal_next_action_mutation"] == "none", routed
402403
assert routed["interaction_contract"]["mode"] == "bounded_delivery", routed
@@ -499,6 +500,7 @@ def assert_due_monitor_poll_state_machine(root: Path, *, provider: str) -> None:
499500
"--codex-app",
500501
)
501502
assert quota_payload["ok"] is True, quota_payload
503+
assert quota_payload["schema_version"] == "loopx_turn_envelope_v1", quota_payload
502504
assert quota_payload["should_run"] is True, quota_payload
503505
assert quota_payload["decision"] == "run", quota_payload
504506
assert quota_payload["effective_action"] == "normal_run", quota_payload
@@ -790,7 +792,7 @@ def run_fixture_canary(root: Path, *, provider: str) -> None:
790792
assert CANARY_TODO_TITLE in quota_payload["recommended_action"], quota_payload
791793
assert_selected_agent_todo(
792794
quota_payload["agent_todo_summary"],
793-
compact_quota=True,
795+
complete_quota=True,
794796
)
795797
assert_bounded_delivery_state_machine_bundle(quota_payload)
796798
assert_scheduler_ack_state_machine(registry_path, runtime_root, quota_payload)

‎examples/control_plane/control-plane-risk-characterization-smoke.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -454,12 +454,12 @@ def assert_reassignment_scheduler_contract() -> None:
454454
scheduler = quota["scheduler_hint"]
455455
assert scheduler["action"] == "backoff_until_reassigned", scheduler
456456
assert scheduler["cadence_class"] == "agent_scope_wait", scheduler
457-
assert scheduler["codex_app"]["recommended_rrule"] == (
457+
assert scheduler["app_automation"]["recommended_rrule"] == (
458458
"FREQ=MINUTELY;INTERVAL=10"
459459
), scheduler
460-
assert scheduler["codex_app"]["recommended_interval_minutes"] == 10, scheduler
461-
assert scheduler["codex_app"]["stateful_backoff"]["apply_needed"] is True, scheduler
462-
assert scheduler["codex_app"]["no_spend_for_cadence_change"] is True, scheduler
460+
assert scheduler["app_automation"]["recommended_interval_minutes"] == 10, scheduler
461+
assert scheduler["app_automation"]["stateful_backoff"]["apply_needed"] is True, scheduler
462+
assert scheduler["app_automation"]["no_spend_for_cadence_change"] is True, scheduler
463463

464464
packet = build_review_packet(payload, goal_id=GOAL_ID)
465465
assert packet["ok"] is True, packet

‎examples/control_plane/heartbeat-quota-flow-smoke.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -812,8 +812,8 @@ def main() -> int:
812812
assert first_guard["automation_liveness"]["pause_allowed"] is False, first_guard
813813
assert first_guard["scheduler_hint"]["action"] == "backoff_until_material_transition", first_guard
814814
assert first_guard["scheduler_hint"]["cadence_class"] == "monitor_wait", first_guard
815-
assert first_guard["scheduler_hint"]["codex_app"]["recommended_interval_minutes"] == 15, first_guard
816-
assert first_guard["scheduler_hint"]["codex_app"]["recommended_rrule"] == (
815+
assert first_guard["scheduler_hint"]["app_automation"]["recommended_interval_minutes"] == 15, first_guard
816+
assert first_guard["scheduler_hint"]["app_automation"]["recommended_rrule"] == (
817817
"FREQ=MINUTELY;INTERVAL=15"
818818
), first_guard
819819
reset = first_guard["scheduler_hint"]["reset_policy"]

‎examples/control_plane/interaction-contract-state-machine-smoke.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def _assert_cross_layer_case(
291291
assert contract["agent_channel"]["quiet_noop_allowed"] is quiet, (name, contract)
292292
assert contract["cli_channel"]["spend_after_validation"] is spend, (name, contract)
293293
assert scheduler_hint["action"] == scheduler, (name, scheduler_hint)
294-
assert scheduler_hint["codex_app"]["recommended_interval_minutes"] == interval, (
294+
assert scheduler_hint["app_automation"]["recommended_interval_minutes"] == interval, (
295295
name,
296296
scheduler_hint,
297297
)

‎examples/control_plane/monitor-poll-writeback-smoke.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ def assert_material_transition_followup() -> None:
657657
scheduler = handoff["scheduler_hint"]
658658
assert scheduler["action"] == "run_now", scheduler
659659
assert scheduler["cadence_class"] == "active_work", scheduler
660-
assert scheduler["codex_app"]["recommended_rrule"] == "FREQ=MINUTELY;INTERVAL=3", scheduler
660+
assert scheduler["app_automation"]["recommended_rrule"] == "FREQ=MINUTELY;INTERVAL=3", scheduler
661661
contract = handoff["interaction_contract"]
662662
assert contract["agent_channel"]["must_attempt"] is True, contract
663663
assert contract["agent_channel"]["delivery_allowed"] is False, contract
@@ -1119,7 +1119,7 @@ def assert_cli_monitor_poll_preserves_codex_app_scheduler_context() -> None:
11191119
with tempfile.TemporaryDirectory(prefix="loopx-monitor-poll-codex-app-") as tmp:
11201120
hints = cli_monitor_poll_scheduler_hints(write_fixture(Path(tmp))[0], "--codex-app")
11211121
for scheduler_hint in hints:
1122-
assert scheduler_hint["codex_app"]["applicability"] == "applicable", scheduler_hint
1122+
assert scheduler_hint["app_automation"]["applicability"] == "applicable", scheduler_hint
11231123
assert scheduler_hint["action"] != "repair_scheduler_execution_context", scheduler_hint
11241124

11251125

@@ -1132,8 +1132,8 @@ def assert_cli_monitor_poll_preserves_outer_controller_scheduler_context() -> No
11321132
execution_context = scheduler_hint["execution_context"]
11331133
execution_phase = scheduler_hint["execution_phase"]
11341134
assert scheduler_hint["action"] != "repair_scheduler_execution_context", scheduler_hint
1135-
assert scheduler_hint["codex_app"]["applicability"] == "not_applicable", scheduler_hint
1136-
assert "stateful_backoff" not in scheduler_hint["codex_app"], scheduler_hint
1135+
assert scheduler_hint["app_automation"]["applicability"] == "not_applicable", scheduler_hint
1136+
assert "stateful_backoff" not in scheduler_hint["app_automation"], scheduler_hint
11371137
assert (
11381138
execution_context["host_surface"],
11391139
execution_context["scheduler_owner"],
@@ -1161,8 +1161,8 @@ def assert_cli_monitor_poll_invalid_scheduler_context_fails_closed() -> None:
11611161
execution_context = scheduler_hint["execution_context"]
11621162
execution_phase = scheduler_hint["execution_phase"]
11631163
assert scheduler_hint["action"] == "repair_scheduler_execution_context", scheduler_hint
1164-
assert scheduler_hint["codex_app"]["applicability"] == "blocked_invalid_context", scheduler_hint
1165-
assert "stateful_backoff" not in scheduler_hint["codex_app"], scheduler_hint
1164+
assert scheduler_hint["app_automation"]["applicability"] == "blocked_invalid_context", scheduler_hint
1165+
assert "stateful_backoff" not in scheduler_hint["app_automation"], scheduler_hint
11661166
assert execution_context["valid"] is False, scheduler_hint
11671167
assert execution_context["errors"] == [
11681168
"outer_controller requires execution_mode=isolated_headless"

0 commit comments

Comments
 (0)