[^<]+<\/a><\/h2>([^<]+)<\/p>/)?.[1] ?? "";
+ assertIncludes(listing, langSuffix === "zh" ? "记录分数" : "reported EdgeBench", "Blog catalog describes the recorded score pair scope");
+ for (const observedText of [snapshotSection, snapshotSvg, JSON.stringify(snapshot), listing]) {
+ if (/controlled|fixed Explore|holding Explore|同构|受控|固定 Explore|four.arm|四臂/i.test(observedText)) {
+ throw new Error("Reported score snapshot restored a controlled or mixed-arm claim: " + locale);
}
}
- for (const publicText of [article, twoArmSvg, JSON.stringify(audit)]) {
+ for (const publicText of [article, snapshotSvg, JSON.stringify(audit)]) {
if (/sforge/i.test(publicText)) {
throw new Error(`Internal benchmark name leaked into public context-delivery blog artifact (${locale})`);
}
@@ -466,6 +594,37 @@ async function assertClockLabelRejected(blogDir, { figure, declared, regressed }
}
}
+async function assertScoreMismatchRejected(blogDir) {
+ const temporaryRoot = await mkdtemp(join(tmpdir(), "loopx-blog-score-parity-"));
+ const fixtureBlog = join(temporaryRoot, "blog");
+ try {
+ await cp(blogDir, fixtureBlog, { recursive: true });
+ // Each mutation changes just one published representation (or its source provenance).
+ const data = "data/long-horizon-audit.json";
+ const en = "context-delivery/index.html";
+ const zh = "zh/context-delivery/index.html";
+ const svg = "images/context-delivery/stride-context-on-vs-off-en.svg";
+ for (const [path, before, after, expected] of [
+ [data, '"context_on_native": 80,', '"context_on_native": 5,', /snapshot direction or winner/],
+ [data, '"context_on_native": 80,', '"context_on_native": 81,', /table row differs.*Borden/],
+ [svg, "7,159 / 3,746", "7,159 / 3,747", /chart native example differs/],
+ [en, "33,090,430 (62.99", "13,090,430 (62.99", /table row differs.*OpenTTD/],
+ [zh, "(27.18 · 17h57m · 10 次)", "(27.18 · 17h57m · 1 次)", /table row differs.*Rust/],
+ [data, '"prior_public_ann_url": "https://github.com/', '"prior_public_ann_url": "https://example.invalid/', /immutable public sources/],
+ [data, '"direction": "lower",\n "metric_label_en": "Total cost"', '"direction": "higher",\n "metric_label_en": "Total cost"', /snapshot direction or winner/],
+ ]) {
+ const file = resolve(fixtureBlog, path);
+ const source = await readFile(file, "utf8");
+ assertIncludes(source, before, "Negative fixture must contain the original value: " + path);
+ await writeFile(file, source.replace(before, after));
+ await rejects(() => validateBilingualBlog(fixtureBlog), expected);
+ await writeFile(file, source);
+ }
+ } finally {
+ await rm(temporaryRoot, { recursive: true, force: true });
+ }
+}
+
const modulePath = fileURLToPath(import.meta.url);
if (process.argv[1] && resolve(process.argv[1]) === modulePath) {
const articleUrl = "https://loopx-project.github.io/loopx/blog/example/";
@@ -552,5 +711,6 @@ if (process.argv[1] && resolve(process.argv[1]) === modulePath) {
},
"中文主图恢复反馈口径也必须被配对标签检查拦下",
);
+ await assertScoreMismatchRejected(blogDir);
console.log(`blog-bilingual-index-smoke: ok (${articleSlugs.length} paired articles)`);
}
diff --git a/examples/bootstrap-command-pack-smoke.py b/examples/bootstrap-command-pack-smoke.py
index 10916a206d..d5303b3b3d 100644
--- a/examples/bootstrap-command-pack-smoke.py
+++ b/examples/bootstrap-command-pack-smoke.py
@@ -43,6 +43,7 @@ def assert_packet_summary_refs(
*,
packet_kind: str,
compact_projection_default: bool = False,
+ legacy_fields_retained: bool | None = None,
) -> dict[str, object]:
summary = payload["packet_summary"]
assert isinstance(summary, dict)
@@ -50,8 +51,10 @@ def assert_packet_summary_refs(
assert summary["packet_kind"] == packet_kind
compatibility = summary["compatibility"]
assert isinstance(compatibility, dict)
+ if legacy_fields_retained is None:
+ legacy_fields_retained = not compact_projection_default
assert compatibility == {
- "legacy_fields_retained": not compact_projection_default,
+ "legacy_fields_retained": legacy_fields_retained,
"compact_projection_default": compact_projection_default,
"removal_gate": "explicit_host_shadow_parity",
}
@@ -357,6 +360,8 @@ def test_start_goal_guided_previews_transaction_without_mutation() -> None:
selection_summary = assert_packet_summary_refs(
selection,
packet_kind="guided_start_host_surface_selection",
+ compact_projection_default=True,
+ legacy_fields_retained=True,
)
assert selection_summary["next_step_kind"] == "select_host_surface"
assert selection["guided_transaction"]["blocked_by"] == "host_surface_selection"
diff --git a/examples/canary/catalog-planner-smoke.py b/examples/canary/catalog-planner-smoke.py
index f27dc612cf..a3c1e19ff3 100644
--- a/examples/canary/catalog-planner-smoke.py
+++ b/examples/canary/catalog-planner-smoke.py
@@ -708,7 +708,7 @@ def assert_pr_release_and_refactor_profiles_select() -> None:
]
assert "python3 examples/control_plane/heartbeat-prompt-smoke.py" in runtime_connector_commands
assert (
- "python3 examples/codex-cli-tui-bootstrap-smoke-bundle-smoke.py"
+ "python3 examples/codex-cli-bootstrap-message-smoke.py"
in runtime_connector_commands
)
assert "python3 examples/claude-goalmode-lifecycle-smoke.py" in runtime_connector_commands
diff --git a/examples/cli-benchmark-boundary-command-modularization-smoke.py b/examples/cli-benchmark-boundary-command-modularization-smoke.py
deleted file mode 100644
index 18e984b3dc..0000000000
--- a/examples/cli-benchmark-boundary-command-modularization-smoke.py
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/usr/bin/env python3
-from __future__ import annotations
-
-import json
-import subprocess
-import sys
-from pathlib import Path
-
-
-ROOT = Path(__file__).resolve().parents[1]
-
-
-def run_cli(*args: str) -> subprocess.CompletedProcess[str]:
- return subprocess.run(
- [sys.executable, "-m", "loopx.cli", *args],
- cwd=ROOT,
- text=True,
- capture_output=True,
- check=False,
- )
-
-
-def assert_contains(text: str, needle: str) -> None:
- if needle not in text:
- raise AssertionError(f"expected to find {needle!r} in output:\n{text}")
-
-
-def main() -> int:
- cli_source = (ROOT / "loopx" / "cli.py").read_text(encoding="utf-8")
- init_source = (ROOT / "loopx" / "cli_commands" / "__init__.py").read_text(
- encoding="utf-8"
- )
- dispatch_source = (
- ROOT / "loopx" / "cli_commands" / "benchmark_dispatch.py"
- ).read_text(encoding="utf-8")
- boundary_source = (
- ROOT / "loopx" / "cli_commands" / "benchmark_boundary.py"
- ).read_text(encoding="utf-8")
-
- leaked_markers = [
- "benchmark_artifact_filter_parser = benchmark_sub.add_parser",
- "benchmark_candidate_source_parser = benchmark_sub.add_parser",
- "def render_benchmark_artifact_path_filter_markdown",
- ]
- for marker in leaked_markers:
- if marker in cli_source:
- raise AssertionError(f"{marker} leaked back into loopx/cli.py")
- assert_contains(dispatch_source, "register_benchmark_boundary_commands(benchmark_sub, add_subcommand_format)")
- assert_contains(dispatch_source, "handle_benchmark_boundary_command(")
- assert_contains(init_source, "register_benchmark_boundary_commands")
- assert_contains(init_source, "handle_benchmark_boundary_command")
- assert_contains(boundary_source, "BENCHMARK_TOOLKIT_COMMANDS")
- if "split-control-execution-seam" in boundary_source:
- raise AssertionError("legacy split-control code leaked into the active toolkit CLI")
-
- help_result = run_cli("benchmark", "classify-artifacts", "--help")
- if help_result.returncode != 0:
- raise AssertionError(help_result.stderr or help_result.stdout)
- assert_contains(help_result.stdout, "--allow-public-filename")
-
- classify_result = run_cli(
- "benchmark",
- "classify-artifacts",
- "benchmark_run.compact.json",
- "--format",
- "json",
- )
- if classify_result.returncode != 0:
- raise AssertionError(classify_result.stderr or classify_result.stdout)
- classify_payload = json.loads(classify_result.stdout)
- if classify_payload.get("path_recorded") is not False:
- raise AssertionError(classify_payload)
-
- print("cli-benchmark-boundary-command-modularization-smoke: ok")
- return 0
-
-
-if __name__ == "__main__":
- raise SystemExit(main())
diff --git a/examples/cli-bootstrap-rollout-helper-command-modularization-smoke.py b/examples/cli-bootstrap-rollout-helper-command-modularization-smoke.py
deleted file mode 100644
index fbf9a43c60..0000000000
--- a/examples/cli-bootstrap-rollout-helper-command-modularization-smoke.py
+++ /dev/null
@@ -1,148 +0,0 @@
-#!/usr/bin/env python3
-from __future__ import annotations
-
-import json
-import subprocess
-import sys
-import tempfile
-from pathlib import Path
-
-
-ROOT = Path(__file__).resolve().parents[1]
-CLI = ROOT / "loopx" / "cli.py"
-BOOTSTRAP_MODULE = ROOT / "loopx" / "cli_commands" / "bootstrap_connect.py"
-ROLLOUT_MODULE = ROOT / "loopx" / "cli_rollout.py"
-INIT = ROOT / "loopx" / "cli_commands" / "__init__.py"
-
-
-def run_cli(*args: str) -> subprocess.CompletedProcess[str]:
- return subprocess.run(
- [sys.executable, "-m", "loopx.cli", *args],
- cwd=ROOT,
- text=True,
- capture_output=True,
- check=False,
- )
-
-
-def require(condition: bool, message: str) -> None:
- if not condition:
- raise AssertionError(message)
-
-
-def require_success(result: subprocess.CompletedProcess[str]) -> str:
- if result.returncode != 0:
- raise AssertionError(
- f"expected success, got {result.returncode}\n"
- f"stdout:\n{result.stdout}\n\nstderr:\n{result.stderr}"
- )
- return result.stdout
-
-
-def require_json_success(result: subprocess.CompletedProcess[str]) -> dict[str, object]:
- stdout = require_success(result)
- payload = json.loads(stdout)
- require(payload.get("ok") is True, f"payload was not ok: {payload}")
- return payload
-
-
-def assert_source_shape() -> None:
- cli_source = CLI.read_text(encoding="utf-8")
- bootstrap_source = BOOTSTRAP_MODULE.read_text(encoding="utf-8")
- rollout_source = ROLLOUT_MODULE.read_text(encoding="utf-8")
- init_source = INIT.read_text(encoding="utf-8")
-
- forbidden_cli_markers = [
- "bootstrap_parser = sub.add_parser",
- "bootstrap_project(",
- "render_bootstrap_markdown",
- "DEFAULT_OBJECTIVE",
- "DEFAULT_DOMAIN",
- 'if args.command in {"bootstrap", "connect"}:',
- "def append_cli_rollout_event(",
- "def append_benchmark_run_rollout_event(",
- "def append_benchmark_result_rollout_event(",
- "def _benchmark_rollout_",
- "build_rollout_event(",
- "append_rollout_event(",
- ]
- for marker in forbidden_cli_markers:
- require(marker not in cli_source, f"bootstrap/rollout marker leaked into cli.py: {marker}")
-
- for marker in (
- "register_bootstrap_connect_command",
- "handle_bootstrap_connect_command",
- "bootstrap",
- "connect",
- "bootstrap_project(",
- ):
- require(marker in bootstrap_source, f"bootstrap module missing {marker}")
- for marker in (
- "append_cli_rollout_event",
- "build_rollout_event(",
- ):
- require(marker in rollout_source, f"rollout module missing {marker}")
- require("register_bootstrap_connect_command" in cli_source, "cli.py did not register bootstrap/connect")
- require("handle_bootstrap_connect_command" in cli_source, "cli.py did not dispatch bootstrap/connect")
- require("register_bootstrap_connect_command" in init_source, "__init__ omitted bootstrap registration")
- require("handle_bootstrap_connect_command" in init_source, "__init__ omitted bootstrap handler")
-
-
-def assert_help_surfaces() -> None:
- for command in ("bootstrap", "connect"):
- help_text = require_success(run_cli(command, "--help"))
- for option in (
- "--fork-goal",
- "--execution-minimum-scale",
- "--replace-state",
- "--no-global-sync",
- ):
- require(option in help_text, f"{command} help omitted {option}")
-
-
-def assert_bootstrap_dry_run() -> None:
- with tempfile.TemporaryDirectory(prefix="loopx-bootstrap-modular-smoke-") as tmp:
- root = Path(tmp)
- project = root / "project"
- project.mkdir()
- (project / "README.md").write_text("# Bootstrap Smoke\n", encoding="utf-8")
- registry = project / ".loopx" / "registry.json"
- payload = require_json_success(
- run_cli(
- "--format",
- "json",
- "--registry",
- str(registry),
- "--runtime-root",
- str(root / "runtime"),
- "connect",
- "--project",
- str(project),
- "--goal-id",
- "bootstrap-modular-smoke",
- "--objective",
- "Validate bootstrap/connect command modularization.",
- "--domain",
- "smoke",
- "--adapter-kind",
- "read_only_project_map_v0",
- "--adapter-status",
- "connected-read-only",
- "--dry-run",
- "--no-global-sync",
- )
- )
- require(payload.get("dry_run") is True, payload)
- require(payload.get("goal_id") == "bootstrap-modular-smoke", payload)
- require(not registry.exists(), "bootstrap dry-run wrote the registry")
-
-
-def main() -> None:
- assert_source_shape()
- assert_help_surfaces()
- assert_bootstrap_dry_run()
- print("cli-bootstrap-rollout-helper-modularization-smoke: ok")
-
-
-if __name__ == "__main__":
- main()
diff --git a/examples/cli-command-module-size-ownership-command-modularization-smoke.py b/examples/cli-command-module-size-ownership-command-modularization-smoke.py
index 8cefe282a2..8492f6e2e0 100644
--- a/examples/cli-command-module-size-ownership-command-modularization-smoke.py
+++ b/examples/cli-command-module-size-ownership-command-modularization-smoke.py
@@ -12,16 +12,9 @@
STARTER_MODULE_LIMITS = {
# Legacy command owners are frozen at their current baseline while each
# cohesive extraction lands; the default budget still catches new growth.
- "todo.py": 1098,
"starter.py": 180,
"starter_bootstrap.py": 220,
"starter_bootstrap_registration.py": 240,
- "starter_runtime_idle.py": 160,
- "starter_scheduler.py": 240,
- "starter_session_runtime.py": 220,
- "starter_visible_common.py": 120,
- "starter_visible_driver.py": 220,
- "starter_visible_pilot.py": 340,
}
STARTER_COMMAND_OWNERS = {
"start-goal": "start_goal.py",
@@ -29,21 +22,6 @@
"deliver-operation": "goal_channel_operation.py",
"new-project-prompt": "starter_bootstrap_registration.py",
"codex-cli-bootstrap-message": "starter_bootstrap_registration.py",
- "codex-cli-tui-bootstrap-smoke-bundle": "starter_bootstrap_registration.py",
- "codex-cli-exec-handoff": "starter_bootstrap_registration.py",
- "codex-cli-one-message-loop-pilot": "starter_visible_pilot.py",
- "codex-cli-visible-local-driver-pilot": "starter_visible_pilot.py",
- "codex-cli-bounded-visible-pilot-adapter": "starter_visible_pilot.py",
- "codex-cli-visible-first-response-capture-plan": "starter_visible_pilot.py",
- "codex-cli-visible-attach-acceptance": "starter_visible_pilot.py",
- "codex-cli-visible-driver-plan": "starter_visible_driver.py",
- "codex-cli-local-driver-plan": "starter_visible_driver.py",
- "codex-cli-visible-driver-run": "starter_visible_driver.py",
- "codex-cli-session-probe": "starter_session_runtime.py",
- "codex-cli-visible-session-proof": "starter_session_runtime.py",
- "codex-cli-runtime-idle-detector": "starter_session_runtime.py",
- "codex-cli-local-scheduler-tick": "starter_scheduler.py",
- "codex-cli-local-scheduler-exec": "starter_scheduler.py",
}
ADD_PARSER_RE = re.compile(
diff --git a/examples/cli-help-manpage-smoke.py b/examples/cli-help-manpage-smoke.py
index 218781f737..cdc8d506e6 100644
--- a/examples/cli-help-manpage-smoke.py
+++ b/examples/cli-help-manpage-smoke.py
@@ -30,7 +30,7 @@
)
-LONG_TAIL_COMMAND = "codex-cli-visible-first-response-capture-plan"
+LONG_TAIL_COMMAND = "configuration-backup"
def run_cli(*args: str) -> subprocess.CompletedProcess[str]:
diff --git a/examples/cli-history-command-modularization-smoke.py b/examples/cli-history-command-modularization-smoke.py
deleted file mode 100644
index f9ef9bba02..0000000000
--- a/examples/cli-history-command-modularization-smoke.py
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/usr/bin/env python3
-from __future__ import annotations
-
-import subprocess
-import sys
-from pathlib import Path
-
-
-ROOT = Path(__file__).resolve().parents[1]
-
-
-def run_cli(*args: str) -> subprocess.CompletedProcess[str]:
- return subprocess.run(
- [sys.executable, "-m", "loopx.cli", *args],
- cwd=ROOT,
- text=True,
- capture_output=True,
- check=False,
- )
-
-
-def assert_contains(text: str, needle: str) -> None:
- if needle not in text:
- raise AssertionError(f"expected to find {needle!r} in output:\n{text}")
-
-
-def assert_not_contains(text: str, needle: str) -> None:
- if needle in text:
- raise AssertionError(f"did not expect to find {needle!r} in output:\n{text}")
-
-
-def main() -> int:
- cli_source = (ROOT / "loopx" / "cli.py").read_text(encoding="utf-8")
- init_source = (ROOT / "loopx" / "cli_commands" / "__init__.py").read_text(
- encoding="utf-8"
- )
- history_source = (ROOT / "loopx" / "cli_commands" / "history.py").read_text(
- encoding="utf-8"
- )
-
- if "history_parser = sub.add_parser" in cli_source:
- raise AssertionError("history parser registration leaked back into loopx/cli.py")
- assert_contains(cli_source, "register_history_command(sub)")
- assert_contains(cli_source, "handle_history_command(")
- assert_contains(init_source, "register_history_command")
- assert_contains(init_source, "handle_history_command")
- assert_not_contains(history_source, "append_active_user_assisted_pilot")
- assert_contains(history_source, "render_index_duplicate_repair_markdown")
-
- help_result = run_cli("history", "--help")
- if help_result.returncode != 0:
- raise AssertionError(help_result.stderr or help_result.stdout)
- assert_not_contains(help_result.stdout, "append-active-user-assisted-pilot")
- assert_contains(help_result.stdout, "repair-index-duplicates")
- assert_contains(help_result.stdout, "rebuild-index-collisions")
- assert_not_contains(help_result.stdout, "--active-user-pilot-json")
-
- print("cli-history-command-modularization-smoke: ok")
- return 0
-
-
-if __name__ == "__main__":
- raise SystemExit(main())
diff --git a/examples/cli-project-lifecycle-command-modularization-smoke.py b/examples/cli-project-lifecycle-command-modularization-smoke.py
deleted file mode 100644
index b07af56074..0000000000
--- a/examples/cli-project-lifecycle-command-modularization-smoke.py
+++ /dev/null
@@ -1,442 +0,0 @@
-#!/usr/bin/env python3
-from __future__ import annotations
-
-import json
-import os
-import subprocess
-import sys
-import tempfile
-from contextlib import ExitStack
-from pathlib import Path
-
-from pytest import MonkeyPatch
-
-from loopx.control_plane.coordination.runtime_shadow import build_todo_runtime_shadow_projection
-from loopx.control_plane.effect_runtime import restart_effect_runtime
-from loopx.control_plane.todos.active_state_todo_parser import parse_todo_source
-from loopx.control_plane.todos.todo_summary import canonical_todo_read_record, structured_todo_item
-
-ROOT = Path(__file__).resolve().parents[1]
-sys.path.insert(0, str(ROOT / "tests" / "control_plane"))
-CLI = ROOT / "loopx" / "cli.py"
-MODULE = ROOT / "loopx" / "cli_commands" / "project_lifecycle.py"
-PROJECT_SKILL = ROOT / "skills" / "loopx-project" / "SKILL.md"
-# The `refresh-state` command owns its own module since #4521, so the markers
-# that belong to that command are required there instead of in the dispatcher.
-REFRESH_MODULE = ROOT / "loopx" / "cli_commands" / "project_lifecycle_refresh_state.py"
-INIT = ROOT / "loopx" / "cli_commands" / "__init__.py"
-GOAL_ID = "project-lifecycle-smoke"
-
-
-def run_cli(*args: str, cwd: Path = ROOT) -> subprocess.CompletedProcess[str]:
- env = {**os.environ, "PYTHONPATH": str(ROOT)}
- return subprocess.run(
- [sys.executable, "-m", "loopx.cli", *args],
- cwd=cwd,
- env=env,
- text=True,
- encoding="utf-8",
- errors="replace",
- capture_output=True,
- check=False,
- )
-
-
-def require(condition: bool, message: str) -> None:
- if not condition:
- raise AssertionError(message)
-
-
-def require_success(result: subprocess.CompletedProcess[str]) -> str:
- if result.returncode != 0:
- raise AssertionError(
- f"expected success, got {result.returncode}\n"
- f"stdout:\n{result.stdout}\n\nstderr:\n{result.stderr}"
- )
- return result.stdout
-
-
-def require_json_success(result: subprocess.CompletedProcess[str]) -> dict[str, object]:
- stdout = require_success(result)
- try:
- payload = json.loads(stdout)
- except json.JSONDecodeError as exc:
- raise AssertionError(f"expected JSON output, got:\n{stdout}") from exc
- require(payload.get("ok") is True, f"payload was not ok: {payload}")
- return payload
-
-
-def write_fixture(project: Path) -> tuple[Path, Path, Path]:
- from canonical_authority_fixture import initialize_canonical_authority
-
- runtime_root = project / "runtime"
- registry_path = project / ".loopx" / "registry.json"
- state_file = project / ".codex" / "goals" / GOAL_ID / "ACTIVE_GOAL_STATE.md"
- runs_dir = runtime_root / "goals" / GOAL_ID / "runs"
- run_json = runs_dir / "2026-06-22T00-00-00-smoke.json"
- run_md = runs_dir / "2026-06-22T00-00-00-smoke.md"
- index_path = runs_dir / "index.jsonl"
-
- registry_path.parent.mkdir(parents=True, exist_ok=True)
- state_file.parent.mkdir(parents=True, exist_ok=True)
- runs_dir.mkdir(parents=True, exist_ok=True)
- (project / "README.md").write_text("# Project Lifecycle Smoke\n", encoding="utf-8")
- state_file.write_text(
- "\n".join(
- [
- "---",
- f"goal_id: {GOAL_ID}",
- "updated_at: 2026-06-22T00:00:00+00:00",
- "---",
- "",
- "## Authority Sources",
- "",
- "- public fixture registry",
- "",
- "## Operating Contract",
- "",
- "- keep lifecycle command previews dry-run only",
- "",
- "## Work Clusters",
- "",
- "- CLI modularization smoke",
- "",
- "## Validation Surfaces",
- "",
- "- project lifecycle command smoke",
- "",
- "## Private/Public Boundary",
- "",
- "- fixture contains only public-safe synthetic values",
- "",
- "## Next Action",
- "",
- "- Continue project lifecycle command modularization smoke.",
- "",
- "## Agent Todo",
- "",
- "- [ ] [P1] Continue project lifecycle command modularization smoke.",
- " ",
- "",
- "## Progress Ledger",
- "",
- "- 2026-06-22T00:00:00+00:00: Fixture initialized.",
- "",
- ]
- ),
- encoding="utf-8",
- )
- registry_path.write_text(
- json.dumps(
- {
- "schema_version": "0.1",
- "registry_role": "project-local",
- "common_runtime_root": str(runtime_root),
- "goals": [
- {
- "id": GOAL_ID,
- "objective": "Validate project lifecycle CLI command modularization.",
- "domain": "smoke",
- "repo": str(project),
- "state_file": ".codex/goals/project-lifecycle-smoke/ACTIVE_GOAL_STATE.md",
- "status": "connected-read-only",
- "adapter": {
- "kind": "read_only_project_map_v0",
- "status": "connected-read-only",
- },
- "coordination": {
- "agent_model": "peer_v1",
- "registered_agents": ["codex-product-capability"],
- },
- "guards": ["dry-run smoke fixture only"],
- }
- ],
- },
- ensure_ascii=False,
- indent=2,
- )
- + "\n",
- encoding="utf-8",
- )
- run_record = {
- "generated_at": "2026-06-22T00:00:00+00:00",
- "goal_id": GOAL_ID,
- "classification": "state_refreshed",
- "recommended_action": "Continue project lifecycle command modularization smoke.",
- "health_check": "fixture run",
- "json_path": str(run_json),
- "markdown_path": str(run_md),
- }
- run_json.write_text(json.dumps(run_record, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
- run_md.write_text("# Fixture Run\n", encoding="utf-8")
- index_path.write_text(json.dumps(run_record, ensure_ascii=False) + "\n", encoding="utf-8")
- groups, _, _ = parse_todo_source(state_file.read_text(encoding="utf-8"))
- records = [canonical_todo_read_record(structured_todo_item(item, role=role,
- source_section=item["source_section"])) for role, rows in groups.items() for item in rows]
- initialize_canonical_authority(runtime_root, GOAL_ID, build_todo_runtime_shadow_projection(
- goal_id=GOAL_ID, todos=records, handoff_mode="soft_claim"), state_path=state_file, provider="sqlite")
- return registry_path, runtime_root, index_path
-
-
-def main() -> None:
- from canonical_authority_fixture import isolate_sqlite_runtime
-
- cli_source = CLI.read_text(encoding="utf-8")
- module_source = MODULE.read_text(encoding="utf-8")
- init_source = INIT.read_text(encoding="utf-8")
- project_skill = PROJECT_SKILL.read_text(encoding="utf-8")
- require("references/handoff-and-feedback.md" in project_skill, "reward procedure must be routed from skill")
- handoff = PROJECT_SKILL.parent / "references/handoff-and-feedback.md"
- reward_skill = handoff.read_text(encoding="utf-8").split("## Record Human Reward", 1)[1].split(
- "## Capability Context And Child Models", 1
- )[0]
-
- for marker in (
- "--dry-run",
- "--actor-kind owner",
- "--actor-kind controller",
- "Never infer",
- ):
- require(marker in reward_skill, f"project skill reward flow omitted {marker}")
-
- forbidden_cli_markers = [
- "refresh_state_parser = sub.add_parser",
- "read_only_map_parser = sub.add_parser",
- "reward_parser = sub.add_parser",
- 'gate_parser = sub.add_parser(\n "operator-gate"',
- "refresh_state_run(",
- "read_only_project_map_run(",
- "append_human_reward(",
- "record_operator_gate(",
- 'if args.command == "refresh-state":',
- 'if args.command == "read-only-map":',
- 'if args.command == "reward":',
- 'if args.command == "operator-gate":',
- ]
- for marker in forbidden_cli_markers:
- require(marker not in cli_source, f"project lifecycle marker leaked into cli.py: {marker}")
-
- for marker in (
- "PROJECT_LIFECYCLE_COMMANDS",
- "register_project_lifecycle_commands",
- "handle_project_lifecycle_command",
- "read-only-map",
- "reward",
- "operator-gate",
- ):
- require(marker in module_source, f"project lifecycle module missing {marker}")
- refresh_source = REFRESH_MODULE.read_text(encoding="utf-8")
- for marker in (
- "retry it before delivery",
- "refresh-state",
- ):
- require(marker in refresh_source, f"refresh-state module missing {marker}")
- sink_source = (MODULE.parent / "project_lifecycle_sinks.py").read_text(encoding="utf-8")
- for marker in (
- "apply_external_sink_postcondition",
- "delivery_postcondition",
- "blocks_delivery",
- ):
- require(marker in sink_source, f"project lifecycle sink module missing {marker}")
- require("register_project_lifecycle_commands" in cli_source, "cli.py did not register project lifecycle commands")
- runtime_source = (CLI.parent / "cli_runtime.py").read_text(encoding="utf-8")
- require("dispatch_common_command" in cli_source and "handle_project_lifecycle_command" in runtime_source,
- "CLI entrypoints did not share project lifecycle dispatch")
- require("register_project_lifecycle_commands" in init_source, "__init__ did not export project lifecycle registration")
- require("handle_project_lifecycle_command" in init_source, "__init__ did not export project lifecycle handler")
-
- for command, options in {
- "refresh-state": (
- "--delivery-outcome",
- "--agent-id",
- "--suppress-external-sinks",
- "--dry-run",
- ),
- "read-only-map": ("--recommended-action", "--dry-run"),
- "reward": ("--actor-kind", "--write-active-state-summary", "--lesson-kind", "--lesson-avoid", "--dry-run"),
- "operator-gate": ("--agent-command", "--no-global-sync"),
- }.items():
- help_text = require_success(run_cli(command, "--help"))
- for option in options:
- require(option in help_text, f"{command} help omitted {option}")
-
- with (tempfile.TemporaryDirectory(prefix="loopx-project-lifecycle-cli-") as tmp,
- MonkeyPatch.context() as patch, ExitStack() as cleanup):
- project = Path(tmp)
- isolate_sqlite_runtime(project, patch)
- patch.setenv("LOOPX_USAGE_PING", "0")
- cleanup.callback(restart_effect_runtime, wait_for_exit=True)
- registry_path, runtime_root, index_path = write_fixture(project)
- before_index = index_path.read_text(encoding="utf-8")
- command_prefix = (
- "--registry",
- str(registry_path),
- "--runtime-root",
- str(runtime_root),
- )
-
- refresh_payload = require_json_success(
- run_cli(
- *command_prefix,
- "refresh-state",
- "--goal-id",
- GOAL_ID,
- "--dry-run",
- "--no-global-sync",
- "--suppress-external-sinks",
- "--delivery-batch-scale",
- "implementation",
- "--delivery-outcome",
- "outcome_progress",
- "--format",
- "json",
- )
- )
- require(refresh_payload.get("dry_run") is True, "refresh-state should stay dry-run")
- require(refresh_payload.get("appended") is False, "refresh-state dry-run should not append")
- require(refresh_payload.get("delivery_outcome") == "outcome_progress", "refresh-state outcome changed")
- require(
- refresh_payload.get("external_sink_delivery_authorized") is False,
- "refresh-state did not project the external sink suppression boundary",
- )
-
- map_payload = require_json_success(
- run_cli(
- *command_prefix,
- "read-only-map",
- "--goal-id",
- GOAL_ID,
- "--dry-run",
- "--no-global-sync",
- "--format",
- "json",
- )
- )
- require(map_payload.get("dry_run") is True, "read-only-map should stay dry-run")
- require(map_payload.get("appended") is False, "read-only-map dry-run should not append")
- require(
- (map_payload.get("project_map") or {}).get("adapter_kind") == "read_only_project_map_v0",
- "read-only-map compact payload changed",
- )
-
- reward_payload = require_json_success(
- run_cli(
- *command_prefix,
- "reward",
- "--goal-id",
- GOAL_ID,
- "--decision",
- "continue_route",
- "--reward",
- "positive",
- "--reason-summary",
- "synthetic dry-run reward",
- "--follow-up",
- "continue modularization smoke",
- "--lesson-kind",
- "route",
- "--lesson-summary",
- "Keep modularization dry-run checks ahead of broad lifecycle rewrites.",
- "--lesson-avoid",
- "broad lifecycle rewrite before dry-run check",
- "--lesson-prefer",
- "modularization dry-run check",
- "--dry-run",
- "--format",
- "json",
- )
- )
- require(reward_payload.get("dry_run") is True, "reward should stay dry-run")
- require(reward_payload.get("appended") is False, "reward dry-run should not append")
- require(
- (reward_payload.get("human_reward") or {}).get("reward") == "positive",
- "reward payload polarity changed",
- )
- reward_lesson = (reward_payload.get("human_reward") or {}).get("lesson") or {}
- require(reward_lesson.get("kind") == "route", "reward lesson kind changed")
- require(
- reward_lesson.get("avoid") == ["broad lifecycle rewrite before dry-run check"],
- "reward lesson avoid changed",
- )
-
- rejected_reward = run_cli(
- *command_prefix,
- "reward",
- "--goal-id",
- GOAL_ID,
- "--decision",
- "continue_route",
- "--reward",
- "positive",
- "--reason-summary",
- "synthetic durable reward",
- "--format",
- "json",
- )
- require(rejected_reward.returncode == 1, "anonymous durable reward should fail")
- rejected_payload = json.loads(rejected_reward.stdout)
- require(
- "actor kind is required" in str(rejected_payload.get("error") or ""),
- f"anonymous durable reward returned the wrong error: {rejected_payload}",
- )
- require(index_path.read_text(encoding="utf-8") == before_index, "rejected reward mutated run index")
-
- durable_reward = require_json_success(
- run_cli(
- *command_prefix,
- "reward",
- "--goal-id",
- GOAL_ID,
- "--actor-kind",
- "owner",
- "--decision",
- "continue_route",
- "--reward",
- "positive",
- "--reason-summary",
- "synthetic durable reward",
- "--format",
- "json",
- )
- )
- require(durable_reward.get("actor_kind") == "owner", "durable reward lost its actor")
- persisted_reward = json.loads(index_path.read_text(encoding="utf-8").splitlines()[-1])
- require(
- (persisted_reward.get("human_reward") or {}).get("actor_kind") == "owner",
- "durable reward index row lost its actor",
- )
-
- gate_payload = require_json_success(
- run_cli(
- *command_prefix,
- "operator-gate",
- "--goal-id",
- GOAL_ID,
- "--decision",
- "defer",
- "--reason-summary",
- "synthetic dry-run gate",
- "--follow-up",
- "collect more smoke evidence",
- "--dry-run",
- "--no-global-sync",
- "--format",
- "json",
- )
- )
- require(gate_payload.get("dry_run") is True, "operator-gate should stay dry-run")
- require(gate_payload.get("appended") is False, "operator-gate dry-run should not append")
- require(
- (gate_payload.get("operator_gate") or {}).get("decision") == "defer",
- "operator-gate decision changed",
- )
- require(
- len(index_path.read_text(encoding="utf-8").splitlines()) == 2,
- "project lifecycle smoke wrote an unexpected number of run rows",
- )
-
- print("cli-project-lifecycle-command-modularization-smoke: ok")
-
-
-if __name__ == "__main__":
- main()
diff --git a/examples/cli-registry-admin-command-modularization-smoke.py b/examples/cli-registry-admin-command-modularization-smoke.py
deleted file mode 100644
index 896161f6c0..0000000000
--- a/examples/cli-registry-admin-command-modularization-smoke.py
+++ /dev/null
@@ -1,389 +0,0 @@
-#!/usr/bin/env python3
-from __future__ import annotations
-
-import json
-import os
-import subprocess
-import sys
-import tempfile
-from pathlib import Path
-
-
-ROOT = Path(__file__).resolve().parents[1]
-CLI = ROOT / "loopx" / "cli.py"
-MODULE = ROOT / "loopx" / "cli_commands" / "registry_admin.py"
-CONFIGURE_MODULE = ROOT / "loopx" / "cli_commands" / "registry_admin_configure.py"
-AUTHORITY_MODULE = ROOT / "loopx" / "cli_commands" / "registry_authority.py"
-LIFECYCLE_MODULE = ROOT / "loopx" / "cli_commands" / "registry_admin_lifecycle.py"
-THREAD_RESOLUTION_MODULE = (
- ROOT / "loopx" / "cli_commands" / "registry_admin_thread_resolution.py"
-)
-INIT = ROOT / "loopx" / "cli_commands" / "__init__.py"
-GOAL_ID = "registry-admin-smoke"
-
-def run_cli(*args: str) -> subprocess.CompletedProcess[str]:
- env = {**os.environ, "PYTHONPATH": str(ROOT)}
- return subprocess.run(
- [sys.executable, "-m", "loopx.cli", *args],
- cwd=ROOT,
- env=env,
- text=True,
- capture_output=True,
- check=False,
- )
-
-
-def require(condition: bool, message: str) -> None:
- if not condition:
- raise AssertionError(message)
-
-
-def require_success(result: subprocess.CompletedProcess[str]) -> str:
- if result.returncode != 0:
- raise AssertionError(
- f"expected success, got {result.returncode}\n"
- f"stdout:\n{result.stdout}\n\nstderr:\n{result.stderr}"
- )
- return result.stdout
-
-
-def require_json_success(result: subprocess.CompletedProcess[str]) -> dict[str, object]:
- stdout = require_success(result)
- try:
- payload = json.loads(stdout)
- except json.JSONDecodeError as exc:
- raise AssertionError(f"expected JSON output, got:\n{stdout}") from exc
- require(payload.get("ok") is True, f"payload was not ok: {payload}")
- return payload
-
-
-def run_json(command_prefix: tuple[str, ...], command: str, *args: str) -> dict[str, object]:
- return require_json_success(run_cli(*command_prefix, command, *args))
-
-def write_json(path: Path, payload: dict[str, object]) -> None:
- path.parent.mkdir(parents=True, exist_ok=True)
- path.write_text(json.dumps(payload, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
-
-
-def write_fixture(project: Path) -> tuple[Path, Path, Path, Path]:
- runtime_root = project / "runtime"
- registry_path = project / ".loopx" / "registry.json"
- legacy_registry_path = project / "legacy" / "registry.global.json"
- doc_registry_path = project / "DOC_REGISTRY.yaml"
- obsolete_runtime = runtime_root / "goals" / "obsolete-runtime-goal" / "runs"
- obsolete_runtime.mkdir(parents=True, exist_ok=True)
- state_file = project / ".codex" / "goals" / GOAL_ID / "ACTIVE_GOAL_STATE.md"
- state_file.parent.mkdir(parents=True, exist_ok=True)
- state_file.write_text("# Registry Admin Smoke State\n", encoding="utf-8")
- (project / "README.md").write_text("# Registry Admin Smoke\n", encoding="utf-8")
-
- goal = {
- "id": GOAL_ID,
- "objective": "Validate registry admin command modularization.",
- "domain": "smoke",
- "repo": str(project),
- "state_file": ".codex/goals/registry-admin-smoke/ACTIVE_GOAL_STATE.md",
- "status": "connected-read-only",
- "adapter": {"kind": "read_only_project_map_v0", "status": "connected-read-only"},
- "coordination": {
- "registered_agents": [{"id": "codex-main-control", "role": "primary"}],
- "agent_model": "peer_v1",
- },
- "guards": ["dry-run registry admin smoke fixture only"],
- }
- registry_payload = {
- "schema_version": "0.1",
- "registry_role": "project-local",
- "common_runtime_root": str(runtime_root),
- "goals": [goal],
- }
- write_json(registry_path, registry_payload)
- write_json(
- runtime_root / "registry.global.json",
- {
- "schema_version": "0.1",
- "registry_role": "global-local",
- "common_runtime_root": str(runtime_root),
- "goals": [{**goal, "source_registry": str(registry_path)}],
- },
- )
- write_json(
- legacy_registry_path,
- {
- "schema_version": "0.1",
- "common_runtime_root": str(project / "legacy-runtime"),
- "goals": [
- {
- "id": "legacy-smoke-goal",
- "objective": "Legacy smoke goal.",
- "repo": str(project / "legacy-repo"),
- "state_file": ".codex/goals/legacy-smoke-goal/ACTIVE_GOAL_STATE.md",
- "status": "legacy",
- }
- ],
- },
- )
- doc_registry_path.write_text(
- "version: doc_registry_v0\n"
- "updated_at: 2026-06-22T00:00:00+00:00\n"
- "default_entry_docs:\n"
- " - README.md\n"
- "topic_authority:\n"
- " issue_fix: README.md\n"
- "status_definitions:\n"
- " current: usable\n",
- encoding="utf-8",
- )
- return registry_path, runtime_root, legacy_registry_path, doc_registry_path
-
-
-def main() -> None:
- cli_source = CLI.read_text(encoding="utf-8")
- module_source = MODULE.read_text(encoding="utf-8")
- configure_source = CONFIGURE_MODULE.read_text(encoding="utf-8")
- authority_source = AUTHORITY_MODULE.read_text(encoding="utf-8")
- lifecycle_source = LIFECYCLE_MODULE.read_text(encoding="utf-8")
- thread_resolution_source = THREAD_RESOLUTION_MODULE.read_text(encoding="utf-8")
- registry_admin_family_source = (
- module_source
- + "\n"
- + configure_source
- + "\n"
- + authority_source
- + "\n"
- + lifecycle_source
- + "\n"
- + thread_resolution_source
- )
- init_source = INIT.read_text(encoding="utf-8")
-
- forbidden_cli_markers = [
- "configure_goal_parser = sub.add_parser",
- "register_agent_parser = sub.add_parser",
- "archive_runtime_parser = sub.add_parser",
- "retire_global_goal_parser = sub.add_parser",
- "sync_global_parser = sub.add_parser",
- "migrate_state_parser = sub.add_parser",
- "authority_parser = sub.add_parser",
- "doc_registry_authority_parser = sub.add_parser",
- "register_agent_via_source_registry(",
- "configure_goal(",
- "archive_runtime_goal(",
- "retire_global_registry_goals(",
- "migrate_legacy_state(",
- "register_authority_source(",
- "import_doc_registry_authority(",
- 'if args.command == "configure-goal":',
- 'if args.command == "register-agent":',
- 'if args.command == "archive-runtime":',
- 'if args.command == "retire-global-goal":',
- 'if args.command == "uninstall-project":',
- 'if args.command == "sync-global":',
- 'if args.command == "migrate-state":',
- 'if args.command == "register-authority-source":',
- 'if args.command == "import-doc-registry-authority":',
- ]
- for marker in forbidden_cli_markers:
- require(marker not in cli_source, f"registry admin marker leaked into cli.py: {marker}")
-
- for marker in (
- "REGISTRY_ADMIN_COMMANDS",
- "register_registry_admin_commands",
- "handle_registry_admin_command",
- "configure-goal",
- "register-agent",
- "archive-runtime",
- "retire-global-goal",
- "uninstall-project",
- "sync-global",
- "migrate-state",
- "register-authority-source",
- "import-doc-registry-authority",
- ):
- require(marker in registry_admin_family_source, f"registry admin command family missing {marker}")
- for marker in (
- "REGISTRY_AUTHORITY_COMMANDS",
- "register_registry_authority_commands",
- "handle_registry_authority_command",
- 'if args.command == "register-authority-source":',
- 'if args.command != "import-doc-registry-authority":',
- "register_authority_source(",
- "import_doc_registry_authority(",
- ):
- require(marker in authority_source, f"registry authority module missing {marker}")
- for marker in (
- "REGISTRY_LIFECYCLE_COMMANDS",
- "register_registry_lifecycle_commands",
- "handle_registry_lifecycle_command",
- 'if args.command == "archive-runtime":',
- 'if args.command == "retire-global-goal":',
- 'if args.command == "uninstall-project":',
- 'if args.command == "sync-global":',
- 'if args.command == "migrate-state":',
- "archive_runtime_goal(",
- "retire_global_registry_goals(",
- "uninstall_project(",
- "migrate_legacy_state(",
- ):
- require(marker in lifecycle_source, f"registry lifecycle module missing {marker}")
- for marker in ("register_registry_authority_commands", "handle_registry_authority_command"):
- require(marker in module_source, f"registry admin module should delegate authority commands through {marker}")
- for marker in (
- "register_registry_lifecycle_commands",
- "handle_registry_lifecycle_command",
- ):
- require(
- marker in module_source,
- f"registry admin module should delegate lifecycle commands through {marker}",
- )
- for marker in (
- "register_registry_thread_resolution_command",
- "handle_registry_thread_resolution_command",
- ):
- require(
- marker in module_source,
- f"registry admin module should delegate thread resolution through {marker}",
- )
- for marker in (
- "register_configure_goal_command",
- 'subparsers.add_parser(\n "configure-goal"',
- ):
- require(marker in configure_source, f"configure-goal command owner missing {marker}")
- require(
- "register_configure_goal_command(subparsers)" in module_source,
- "registry admin module should delegate configure-goal registration",
- )
- require("register_registry_admin_commands" in cli_source, "cli.py did not register registry admin commands")
- require("handle_registry_admin_command" in cli_source, "cli.py did not dispatch registry admin commands")
- require("register_registry_admin_commands" in init_source, "__init__ did not export registry admin registration")
- require("handle_registry_admin_command" in init_source, "__init__ did not export registry admin handler")
-
- for command, options in {
- "configure-goal": ("--quota-compute", "--registered-agent", "--execute"),
- "register-agent": ("--agent-id", "--require-new", "--execute"),
- "archive-runtime": ("--archive-root", "--allow-registered", "--execute"),
- "retire-global-goal": ("--goal-id", "--execute"),
- "uninstall-project": ("--goal-id", "--archive-state", "--remove-empty-registry", "--execute"),
- "sync-global": ("--replace-state", "--dry-run"),
- "migrate-state": ("--legacy-registry", "--goal-id-map", "--copy-runtime"),
- "register-authority-source": ("--source-ref", "--boundary", "--no-global-sync"),
- "import-doc-registry-authority": ("--doc-registry-path", "--import-topic-prefix", "--max-imported-topics"),
- }.items():
- help_text = require_success(run_cli(command, "--help"))
- for option in options:
- require(option in help_text, f"{command} help omitted {option}")
-
- with tempfile.TemporaryDirectory(prefix="loopx-registry-admin-cli-") as tmp:
- project = Path(tmp)
- registry_path, runtime_root, legacy_registry_path, doc_registry_path = write_fixture(project)
- command_prefix = ("--format", "json", "--registry", str(registry_path), "--runtime-root", str(runtime_root))
- registry_before = registry_path.read_text(encoding="utf-8")
-
- configure_payload = run_json(
- command_prefix,
- "configure-goal",
- "--goal-id",
- GOAL_ID,
- "--quota-compute",
- "2",
- "--registered-agent",
- "codex-product-capability",
- )
- require(configure_payload.get("dry_run") is True, "configure-goal should preview by default")
- require(configure_payload.get("written") is False, "configure-goal preview should not write")
-
- register_payload = run_json(
- command_prefix,
- "register-agent",
- "--goal-id",
- GOAL_ID,
- "--agent-id",
- "codex-product-capability",
- )
- require(register_payload.get("dry_run") is True, "register-agent should preview by default")
- require("codex-product-capability" in (register_payload.get("registered_agents") or []), register_payload)
-
- archive_payload = run_json(command_prefix, "archive-runtime", "--goal-id", "obsolete-runtime-goal")
- require(archive_payload.get("dry_run") is True, "archive-runtime should dry-run by default")
- require(archive_payload.get("archived") is False, "archive-runtime preview should not move")
- require((runtime_root / "goals" / "obsolete-runtime-goal").exists(), "archive-runtime preview moved source")
-
- uninstall_payload = run_json(command_prefix, "uninstall-project", "--goal-id", GOAL_ID, "--archive-state")
- require(uninstall_payload.get("dry_run") is True, "uninstall-project should dry-run by default")
- require(uninstall_payload.get("wrote_local_registry") is False, "uninstall-project preview should not write local registry")
- require(uninstall_payload.get("wrote_global_registry") is False, "uninstall-project preview should not write global registry")
- require(registry_path.read_text(encoding="utf-8") == registry_before, "uninstall-project preview changed registry")
-
- sync_payload = run_json(command_prefix, "sync-global", "--goal-id", GOAL_ID, "--dry-run")
- require(sync_payload.get("dry_run") is True, "sync-global should honor --dry-run")
- require(sync_payload.get("wrote") is False, "sync-global dry-run should not write")
-
- migrate_payload = run_json(
- command_prefix,
- "migrate-state",
- "--legacy-registry",
- str(legacy_registry_path),
- "--legacy-runtime-root",
- str(project / "legacy-runtime"),
- "--target-runtime-root",
- str(runtime_root),
- "--goal-id",
- "legacy-smoke-goal",
- "--goal-id-map",
- "legacy-smoke-goal=migrated-smoke-goal",
- "--no-global-sync",
- )
- require(migrate_payload.get("dry_run") is True, "migrate-state should dry-run by default")
- require(migrate_payload.get("wrote_project_registry") is False, "migrate-state preview should not write")
- require("migrated-smoke-goal" in (migrate_payload.get("migrated_goal_ids") or []), migrate_payload)
-
- authority_payload = run_json(
- command_prefix,
- "register-authority-source",
- "--goal-id",
- GOAL_ID,
- "--source-id",
- "source-smoke",
- "--source-ref",
- "https://example.com/public-smoke",
- "--source-kind",
- "doc",
- "--role",
- "smoke_authority",
- "--freshness",
- "current",
- "--topic",
- "issue_fix",
- "--dry-run",
- "--no-global-sync",
- )
- require(authority_payload.get("dry_run") is True, "authority registration should honor --dry-run")
- require(authority_payload.get("written") is False, "authority dry-run should not write")
- require(authority_payload.get("raw_source_ref_stored") is False, "authority source ref must stay redacted")
-
- doc_payload = run_json(
- command_prefix,
- "import-doc-registry-authority",
- "--goal-id",
- GOAL_ID,
- "--source-id",
- "doc-registry-smoke",
- "--doc-registry-path",
- str(doc_registry_path),
- "--topic",
- "content_ops",
- "--import-topic-prefix",
- "smoke:",
- "--dry-run",
- "--no-global-sync",
- )
- require(doc_payload.get("dry_run") is True, "doc registry import should honor --dry-run")
- require(doc_payload.get("written") is False, "doc registry import dry-run should not write")
- require(doc_payload.get("raw_doc_registry_path_stored") is False, "doc registry path must stay redacted")
- require(registry_path.read_text(encoding="utf-8") == registry_before, "dry-run commands mutated registry")
-
- print("cli-registry-admin-command-modularization-smoke: ok")
-
-
-if __name__ == "__main__":
- main()
diff --git a/examples/cli-starter-bootstrap-family-command-modularization-smoke.py b/examples/cli-starter-bootstrap-family-command-modularization-smoke.py
deleted file mode 100644
index 68002f731f..0000000000
--- a/examples/cli-starter-bootstrap-family-command-modularization-smoke.py
+++ /dev/null
@@ -1,190 +0,0 @@
-#!/usr/bin/env python3
-from __future__ import annotations
-
-import json
-import subprocess
-import sys
-from pathlib import Path
-
-
-ROOT = Path(__file__).resolve().parents[1]
-STARTER = ROOT / "loopx" / "cli_commands" / "starter.py"
-BOOTSTRAP = ROOT / "loopx" / "cli_commands" / "starter_bootstrap.py"
-BOOTSTRAP_REGISTRATION = ROOT / "loopx" / "cli_commands" / "starter_bootstrap_registration.py"
-START_GOAL = ROOT / "loopx" / "cli_commands" / "start_goal.py"
-INIT = ROOT / "loopx" / "cli_commands" / "__init__.py"
-
-
-def run_cli(*args: str) -> subprocess.CompletedProcess[str]:
- return subprocess.run(
- [sys.executable, "-m", "loopx.cli", *args],
- cwd=ROOT,
- text=True,
- capture_output=True,
- check=False,
- )
-
-
-def require(condition: bool, message: str) -> None:
- if not condition:
- raise AssertionError(message)
-
-
-def require_success(result: subprocess.CompletedProcess[str]) -> str:
- if result.returncode != 0:
- raise AssertionError(
- f"expected success, got {result.returncode}\n"
- f"stdout:\n{result.stdout}\n\nstderr:\n{result.stderr}"
- )
- return result.stdout
-
-
-def require_json_success(result: subprocess.CompletedProcess[str]) -> dict[str, object]:
- payload = json.loads(require_success(result))
- require(isinstance(payload, dict), "expected JSON object payload")
- require(payload.get("ok") is True, f"payload was not ok: {payload}")
- return payload
-
-
-def assert_source_shape() -> None:
- starter_source = STARTER.read_text(encoding="utf-8")
- bootstrap_source = BOOTSTRAP.read_text(encoding="utf-8")
- registration_source = BOOTSTRAP_REGISTRATION.read_text(encoding="utf-8")
- start_goal_source = START_GOAL.read_text(encoding="utf-8")
- init_source = INIT.read_text(encoding="utf-8")
-
- forbidden_starter_markers = [
- "DEFAULT_HANDOFF_ADAPTER_KIND",
- "build_new_project_prompt(",
- "render_new_project_prompt_markdown",
- "build_codex_cli_bootstrap_message(",
- "render_codex_cli_bootstrap_message_markdown",
- "build_codex_cli_tui_bootstrap_smoke_bundle(",
- "build_codex_cli_exec_handoff(",
- "def handle_new_project_prompt_command(",
- "def handle_codex_cli_bootstrap_message_command(",
- "def handle_codex_cli_tui_bootstrap_smoke_bundle_command(",
- "def handle_codex_cli_exec_handoff_command(",
- ]
- for marker in forbidden_starter_markers:
- require(marker not in starter_source, f"bootstrap/message marker leaked into starter.py: {marker}")
-
- for marker in (
- "register_starter_bootstrap_commands(subparsers)",
- "handle_starter_bootstrap_command(args, print_payload)",
- ):
- require(marker in starter_source, f"starter.py missing bootstrap delegation marker: {marker}")
-
- for marker in (
- "def handle_starter_bootstrap_command(",
- "def handle_new_project_prompt_command(",
- "def handle_codex_cli_bootstrap_message_command(",
- "def handle_codex_cli_tui_bootstrap_smoke_bundle_command(",
- "def handle_codex_cli_exec_handoff_command(",
- "build_new_project_prompt(",
- "build_codex_cli_exec_handoff(",
- ):
- require(marker in bootstrap_source, f"starter_bootstrap.py missing marker: {marker}")
-
- for marker in (
- "def register_starter_bootstrap_commands(",
- 'subparsers.add_parser(\n "agent-onboard"',
- 'subparsers.add_parser(\n "bootstrap-command-pack"',
- 'subparsers.add_parser(\n "new-project-prompt"',
- ):
- require(
- marker in registration_source,
- f"starter_bootstrap_registration.py missing marker: {marker}",
- )
-
- for marker in (
- "def register_start_goal_command(",
- 'subparsers.add_parser(\n "start-goal"',
- ):
- require(
- marker in start_goal_source,
- f"start_goal.py missing marker: {marker}",
- )
-
- for marker in (
- "handle_starter_bootstrap_command",
- "register_starter_bootstrap_commands",
- "handle_new_project_prompt_command",
- "handle_codex_cli_exec_handoff_command",
- ):
- require(marker in init_source, f"__init__ omitted bootstrap export: {marker}")
-
-
-def assert_cli_surfaces() -> None:
- for command, needles in {
- "new-project-prompt": ["--goal-doc", "--adapter-status", "--write-scope"],
- "codex-cli-bootstrap-message": ["--agent-id", "--message-only"],
- "codex-cli-tui-bootstrap-smoke-bundle": ["--agent-id", "--cli-bin"],
- "codex-cli-exec-handoff": ["--codex-bin", "--cli-bin"],
- }.items():
- help_text = require_success(run_cli(command, "--help"))
- for needle in needles:
- require(needle in help_text, f"{command} help omitted {needle}")
-
- prompt_payload = require_json_success(
- run_cli(
- "--format",
- "json",
- "new-project-prompt",
- "--project",
- ".",
- "--goal-doc",
- "README.md",
- "--goal-id",
- "starter-bootstrap-smoke",
- )
- )
- require(prompt_payload.get("goal_id") == "starter-bootstrap-smoke", prompt_payload)
-
- bootstrap_text = require_success(
- run_cli(
- "codex-cli-bootstrap-message",
- "--project",
- ".",
- "--goal-id",
- "starter-bootstrap-smoke",
- "--message-only",
- )
- )
- require("loopx" in bootstrap_text, "bootstrap message lost LoopX text")
-
- bundle_payload = require_json_success(
- run_cli(
- "--format",
- "json",
- "codex-cli-tui-bootstrap-smoke-bundle",
- "--project",
- ".",
- "--goal-id",
- "starter-bootstrap-smoke",
- )
- )
- require(bundle_payload.get("goal_id") == "starter-bootstrap-smoke", bundle_payload)
-
- handoff_payload = require_json_success(
- run_cli(
- "--format",
- "json",
- "codex-cli-exec-handoff",
- "--project",
- ".",
- "--goal-id",
- "starter-bootstrap-smoke",
- )
- )
- require(handoff_payload.get("goal_id") == "starter-bootstrap-smoke", handoff_payload)
-
-
-def main() -> None:
- assert_source_shape()
- assert_cli_surfaces()
- print("cli-starter-bootstrap-family-command-modularization-smoke: ok")
-
-
-if __name__ == "__main__":
- main()
diff --git a/examples/cli-starter-dispatch-command-modularization-smoke.py b/examples/cli-starter-dispatch-command-modularization-smoke.py
deleted file mode 100644
index ecf68c69ae..0000000000
--- a/examples/cli-starter-dispatch-command-modularization-smoke.py
+++ /dev/null
@@ -1,209 +0,0 @@
-#!/usr/bin/env python3
-from __future__ import annotations
-
-import json
-import subprocess
-import sys
-from pathlib import Path
-
-
-ROOT = Path(__file__).resolve().parents[1]
-CLI = ROOT / "loopx" / "cli.py"
-STARTER_MODULE = ROOT / "loopx" / "cli_commands" / "starter.py"
-VISIBLE_DRIVER_MODULE = ROOT / "loopx" / "cli_commands" / "starter_visible_driver.py"
-SCHEDULER_MODULE = ROOT / "loopx" / "cli_commands" / "starter_scheduler.py"
-SESSION_RUNTIME_MODULE = ROOT / "loopx" / "cli_commands" / "starter_session_runtime.py"
-INIT = ROOT / "loopx" / "cli_commands" / "__init__.py"
-
-
-def run_cli(*args: str) -> subprocess.CompletedProcess[str]:
- return subprocess.run(
- [sys.executable, "-m", "loopx.cli", *args],
- cwd=ROOT,
- text=True,
- capture_output=True,
- check=False,
- )
-
-
-def require(condition: bool, message: str) -> None:
- if not condition:
- raise AssertionError(message)
-
-
-def require_success(result: subprocess.CompletedProcess[str]) -> str:
- if result.returncode != 0:
- raise AssertionError(
- f"expected success, got {result.returncode}\n"
- f"stdout:\n{result.stdout}\n\nstderr:\n{result.stderr}"
- )
- return result.stdout
-
-
-def require_json_success(result: subprocess.CompletedProcess[str]) -> dict[str, object]:
- payload = json.loads(require_success(result))
- require(isinstance(payload, dict), "expected JSON object payload")
- require(payload.get("ok") is True, f"payload was not ok: {payload}")
- return payload
-
-
-def assert_source_shape() -> None:
- cli_source = CLI.read_text(encoding="utf-8")
- starter_source = STARTER_MODULE.read_text(encoding="utf-8")
- visible_driver_source = VISIBLE_DRIVER_MODULE.read_text(encoding="utf-8")
- scheduler_source = SCHEDULER_MODULE.read_text(encoding="utf-8")
- session_runtime_source = SESSION_RUNTIME_MODULE.read_text(encoding="utf-8")
- init_source = INIT.read_text(encoding="utf-8")
-
- starter_commands = [
- "new-project-prompt",
- "codex-cli-bootstrap-message",
- "codex-cli-tui-bootstrap-smoke-bundle",
- "codex-cli-one-message-loop-pilot",
- "codex-cli-visible-local-driver-pilot",
- "codex-cli-bounded-visible-pilot-adapter",
- "codex-cli-visible-first-response-capture-plan",
- "codex-cli-visible-attach-acceptance",
- "codex-cli-exec-handoff",
- "codex-cli-session-probe",
- "codex-cli-visible-driver-plan",
- "codex-cli-local-driver-plan",
- "codex-cli-visible-driver-run",
- "codex-cli-local-scheduler-tick",
- "codex-cli-local-scheduler-exec",
- "codex-cli-visible-session-proof",
- "codex-cli-runtime-idle-detector",
- "demo",
- ]
- for command in starter_commands:
- marker = f'if args.command == "{command}":'
- require(marker not in cli_source, f"starter dispatch branch leaked into cli.py: {marker}")
-
- forbidden_handler_markers = [
- "handle_new_project_prompt_command(",
- "handle_codex_cli_bootstrap_message_command(",
- "handle_codex_cli_visible_driver_run_command(",
- "handle_codex_cli_local_scheduler_exec_command(",
- "handle_demo_command(",
- ]
- for marker in forbidden_handler_markers:
- require(marker not in cli_source, f"starter handler marker leaked into cli.py: {marker}")
-
- require("register_starter_commands(sub)" in cli_source, "cli.py did not register starter commands")
- require("handle_starter_command(args, print_payload)" in cli_source, "cli.py did not call starter dispatcher")
- require("def handle_starter_command(" in starter_source, "starter module omitted dispatcher")
- require(
- "register_starter_visible_driver_commands(subparsers)" in starter_source,
- "starter module omitted visible-driver registration delegation",
- )
- require(
- "handle_starter_visible_driver_command(args, print_payload)" in starter_source,
- "starter module omitted visible-driver dispatch delegation",
- )
- require(
- "register_starter_session_runtime_commands(subparsers)" in starter_source,
- "starter module omitted session-runtime registration delegation",
- )
- require(
- "handle_starter_session_runtime_command(args, print_payload)" in starter_source,
- "starter module omitted session-runtime dispatch delegation",
- )
- require(
- "register_starter_scheduler_commands(subparsers)" in starter_source,
- "starter module omitted scheduler registration delegation",
- )
- require(
- "handle_starter_scheduler_command(args, print_payload)" in starter_source,
- "starter module omitted scheduler dispatch delegation",
- )
- require(
- '"codex-cli-visible-driver-run": handle_codex_cli_visible_driver_run_command' in visible_driver_source,
- "visible-driver module omitted visible driver run dispatch",
- )
- require(
- '"codex-cli-local-scheduler-exec": handle_codex_cli_local_scheduler_exec_command' in scheduler_source,
- "scheduler module omitted local scheduler exec dispatch",
- )
- require(
- '"codex-cli-runtime-idle-detector": handle_codex_cli_runtime_idle_detector_command' in session_runtime_source,
- "session-runtime module omitted runtime idle dispatch",
- )
- require('str(getattr(args, "command", "")) == "demo"' in starter_source, "starter dispatcher omitted demo")
- require("handle_starter_command" in init_source, "__init__ omitted starter dispatcher export")
-
-
-def assert_cli_surfaces() -> None:
- help_expectations = {
- "new-project-prompt": ["--goal-doc", "--write-scope"],
- "codex-cli-bootstrap-message": ["--agent-id", "--message-only"],
- "codex-cli-visible-driver-run": ["--proof-fixture", "--allow-headless-fallback"],
- "codex-cli-local-scheduler-exec": ["--guard-checked", "--candidate-command-prefix", "--quota-fixture"],
- "demo": ["--user-todo", "--agent-todo"],
- }
- for command, needles in help_expectations.items():
- help_text = require_success(run_cli(command, "--help"))
- for needle in needles:
- require(needle in help_text, f"{command} help omitted {needle}")
-
- prompt_payload = require_json_success(
- run_cli(
- "--format",
- "json",
- "new-project-prompt",
- "--project",
- ".",
- "--goal-doc",
- "README.md",
- "--goal-id",
- "starter-dispatch-smoke",
- )
- )
- require(prompt_payload.get("goal_id") == "starter-dispatch-smoke", prompt_payload)
-
- bootstrap_text = require_success(
- run_cli(
- "codex-cli-bootstrap-message",
- "--project",
- ".",
- "--goal-id",
- "starter-dispatch-smoke",
- "--message-only",
- )
- )
- require("loopx" in bootstrap_text, "message-only bootstrap output lost LoopX command text")
-
- capture_payload = require_json_success(
- run_cli(
- "--format",
- "json",
- "codex-cli-visible-first-response-capture-plan",
- "--project",
- ".",
- "--goal-id",
- "starter-dispatch-smoke",
- )
- )
- require(capture_payload.get("goal_id") == "starter-dispatch-smoke", capture_payload)
-
- handoff_payload = require_json_success(
- run_cli(
- "--format",
- "json",
- "codex-cli-exec-handoff",
- "--project",
- ".",
- "--goal-id",
- "starter-dispatch-smoke",
- )
- )
- require(handoff_payload.get("goal_id") == "starter-dispatch-smoke", handoff_payload)
-
-
-def main() -> None:
- assert_source_shape()
- assert_cli_surfaces()
- print("cli-starter-dispatch-command-modularization-smoke: ok")
-
-
-if __name__ == "__main__":
- main()
diff --git a/examples/cli-starter-runtime-family-command-modularization-smoke.py b/examples/cli-starter-runtime-family-command-modularization-smoke.py
deleted file mode 100644
index 64c9bd9530..0000000000
--- a/examples/cli-starter-runtime-family-command-modularization-smoke.py
+++ /dev/null
@@ -1,221 +0,0 @@
-#!/usr/bin/env python3
-from __future__ import annotations
-
-import json
-import subprocess
-import sys
-from pathlib import Path
-
-
-ROOT = Path(__file__).resolve().parents[1]
-STARTER = ROOT / "loopx" / "cli_commands" / "starter.py"
-SCHEDULER = ROOT / "loopx" / "cli_commands" / "starter_scheduler.py"
-SESSION_RUNTIME = ROOT / "loopx" / "cli_commands" / "starter_session_runtime.py"
-RUNTIME_IDLE = ROOT / "loopx" / "cli_commands" / "starter_runtime_idle.py"
-INIT = ROOT / "loopx" / "cli_commands" / "__init__.py"
-VISIBLE_HELP_FIXTURE = (
- ROOT / "examples" / "fixtures" / "codex-cli-visible-proof" / "codex-visible-resume-help.public.json"
-)
-VISIBLE_PROOF_FIXTURE = (
- ROOT / "examples" / "fixtures" / "codex-cli-visible-proof" / "visible-resume-proof.public.json"
-)
-RUNTIME_IDLE_FIXTURE = (
- ROOT / "examples" / "fixtures" / "codex-cli-visible-proof" / "runtime-idle-visible-resume.public.json"
-)
-
-
-SESSION_RUNTIME_COMMANDS = {
- "codex-cli-session-probe": ["--fixture", "--codex-bin"],
- "codex-cli-visible-session-proof": ["--proof-fixture", "--cli-bin"],
- "codex-cli-runtime-idle-detector": ["--idle-fixture", "--observe-local-runtime"],
-}
-SCHEDULER_COMMANDS = {
- "codex-cli-local-scheduler-tick": ["--proof-fixture", "--idle-fixture", "--quota-fixture", "--allow-headless-fallback"],
- "codex-cli-local-scheduler-exec": ["--guard-checked", "--candidate-command-prefix", "--quota-fixture", "--executor-timeout-seconds"],
-}
-
-
-def run_cli(*args: str) -> subprocess.CompletedProcess[str]:
- return subprocess.run(
- [sys.executable, "-m", "loopx.cli", *args],
- cwd=ROOT,
- text=True,
- capture_output=True,
- check=False,
- )
-
-
-def require(condition: bool, message: str) -> None:
- if not condition:
- raise AssertionError(message)
-
-
-def require_success(result: subprocess.CompletedProcess[str]) -> str:
- if result.returncode != 0:
- raise AssertionError(
- f"expected success, got {result.returncode}\n"
- f"stdout:\n{result.stdout}\n\nstderr:\n{result.stderr}"
- )
- return result.stdout
-
-
-def require_json_success(result: subprocess.CompletedProcess[str]) -> dict[str, object]:
- payload = json.loads(require_success(result))
- require(isinstance(payload, dict), "expected JSON object payload")
- require(payload.get("ok") is True, f"payload was not ok: {payload}")
- return payload
-
-
-def assert_source_shape() -> None:
- starter_source = STARTER.read_text(encoding="utf-8")
- scheduler_source = SCHEDULER.read_text(encoding="utf-8")
- session_runtime_source = SESSION_RUNTIME.read_text(encoding="utf-8")
- runtime_idle_source = RUNTIME_IDLE.read_text(encoding="utf-8")
- init_source = INIT.read_text(encoding="utf-8")
-
- forbidden_starter_markers = [
- "codex-cli-session-probe",
- "codex-cli-local-scheduler-tick",
- "codex-cli-local-scheduler-exec",
- "codex-cli-visible-session-proof",
- "codex-cli-runtime-idle-detector",
- "def handle_codex_cli_session_probe_command(",
- "def handle_codex_cli_local_scheduler_tick_command(",
- "def handle_codex_cli_local_scheduler_exec_command(",
- "def handle_codex_cli_visible_session_proof_command(",
- "def handle_codex_cli_runtime_idle_detector_command(",
- "build_codex_cli_local_scheduler_tick(",
- "build_codex_cli_local_scheduler_executor(",
- "build_codex_cli_visible_session_proof(",
- "build_codex_cli_runtime_idle_detector(",
- ]
- for marker in forbidden_starter_markers:
- require(marker not in starter_source, f"runtime/scheduler marker leaked into starter.py: {marker}")
-
- for marker in (
- "register_starter_session_runtime_commands(subparsers)",
- "handle_starter_session_runtime_command(args, print_payload)",
- "register_starter_scheduler_commands(subparsers)",
- "handle_starter_scheduler_command(args, print_payload)",
- ):
- require(marker in starter_source, f"starter.py missing delegation marker: {marker}")
-
- for command in SESSION_RUNTIME_COMMANDS:
- require(command in session_runtime_source, f"starter_session_runtime.py missing command: {command}")
- for marker in (
- "def register_starter_session_runtime_commands(",
- "def handle_starter_session_runtime_command(",
- "_SESSION_RUNTIME_HANDLERS",
- "build_codex_cli_visible_session_proof(",
- "build_codex_cli_runtime_idle_detector(",
- ):
- require(marker in session_runtime_source, f"starter_session_runtime.py missing marker: {marker}")
-
- for command in SCHEDULER_COMMANDS:
- require(command in scheduler_source, f"starter_scheduler.py missing command: {command}")
- for marker in (
- "def register_starter_scheduler_commands(",
- "def handle_starter_scheduler_command(",
- "_SCHEDULER_HANDLERS",
- "build_codex_cli_local_scheduler_tick(",
- "build_codex_cli_local_scheduler_executor(",
- ):
- require(marker in scheduler_source, f"starter_scheduler.py missing marker: {marker}")
-
- for marker in (
- "def _add_runtime_idle_observation_arguments(",
- "def _load_codex_cli_runtime_idle_payload(",
- ):
- require(marker in runtime_idle_source, f"starter_runtime_idle.py missing marker: {marker}")
-
- for marker in (
- "handle_starter_scheduler_command",
- "register_starter_scheduler_commands",
- "handle_starter_session_runtime_command",
- "register_starter_session_runtime_commands",
- "handle_codex_cli_runtime_idle_detector_command",
- "handle_codex_cli_local_scheduler_exec_command",
- ):
- require(marker in init_source, f"__init__ omitted runtime/scheduler export: {marker}")
-
-
-def assert_cli_surfaces() -> None:
- for command, needles in {**SESSION_RUNTIME_COMMANDS, **SCHEDULER_COMMANDS}.items():
- help_text = require_success(run_cli(command, "--help"))
- for needle in needles:
- require(needle in help_text, f"{command} help omitted {needle}")
-
- probe_payload = require_json_success(
- run_cli(
- "--format",
- "json",
- "codex-cli-session-probe",
- "--fixture",
- str(VISIBLE_HELP_FIXTURE),
- )
- )
- require(probe_payload.get("recommended_mode") == "visible_resume_or_remote_control_spike", probe_payload)
-
- proof_payload = require_json_success(
- run_cli(
- "--format",
- "json",
- "codex-cli-visible-session-proof",
- "--project",
- ".",
- "--goal-id",
- "starter-runtime-family-smoke",
- "--proof-fixture",
- str(VISIBLE_PROOF_FIXTURE),
- )
- )
- require(proof_payload.get("decision") == "visible_session_proof_passed", proof_payload)
-
- idle_payload = require_json_success(
- run_cli(
- "--format",
- "json",
- "codex-cli-runtime-idle-detector",
- "--project",
- ".",
- "--goal-id",
- "starter-runtime-family-smoke",
- "--idle-fixture",
- str(RUNTIME_IDLE_FIXTURE),
- )
- )
- require(idle_payload.get("decision") == "runtime_idle_detector_passed", idle_payload)
-
- scheduler_payload = require_json_success(
- run_cli(
- "--format",
- "json",
- "codex-cli-local-scheduler-exec",
- "--project",
- ".",
- "--goal-id",
- "starter-runtime-family-smoke",
- "--fixture",
- str(VISIBLE_HELP_FIXTURE),
- "--proof-fixture",
- str(VISIBLE_PROOF_FIXTURE),
- "--idle-fixture",
- str(RUNTIME_IDLE_FIXTURE),
- )
- )
- require(scheduler_payload.get("decision") == "visible_session_turn_candidate", scheduler_payload)
- boundary = scheduler_payload.get("boundary")
- require(isinstance(boundary, dict), scheduler_payload)
- require(boundary.get("runs_external_candidate") is False, scheduler_payload)
- require(boundary.get("runs_codex_candidate_possible") is False, scheduler_payload)
- require(boundary.get("requires_fresh_quota_guard_confirmation") is True, scheduler_payload)
-
-
-def main() -> None:
- assert_source_shape()
- assert_cli_surfaces()
- print("cli-starter-runtime-family-command-modularization-smoke: ok")
-
-
-if __name__ == "__main__":
- main()
diff --git a/examples/cli-starter-visible-driver-family-command-modularization-smoke.py b/examples/cli-starter-visible-driver-family-command-modularization-smoke.py
deleted file mode 100644
index 250dda24a7..0000000000
--- a/examples/cli-starter-visible-driver-family-command-modularization-smoke.py
+++ /dev/null
@@ -1,223 +0,0 @@
-#!/usr/bin/env python3
-from __future__ import annotations
-
-import json
-import subprocess
-import sys
-from pathlib import Path
-
-
-ROOT = Path(__file__).resolve().parents[1]
-STARTER = ROOT / "loopx" / "cli_commands" / "starter.py"
-VISIBLE_COMMON = ROOT / "loopx" / "cli_commands" / "starter_visible_common.py"
-VISIBLE_DRIVER = ROOT / "loopx" / "cli_commands" / "starter_visible_driver.py"
-VISIBLE_PILOT = ROOT / "loopx" / "cli_commands" / "starter_visible_pilot.py"
-RUNTIME_IDLE = ROOT / "loopx" / "cli_commands" / "starter_runtime_idle.py"
-INIT = ROOT / "loopx" / "cli_commands" / "__init__.py"
-VISIBLE_HELP_FIXTURE = (
- ROOT / "examples" / "fixtures" / "codex-cli-visible-proof" / "codex-visible-resume-help.public.json"
-)
-VISIBLE_PROOF_FIXTURE = (
- ROOT / "examples" / "fixtures" / "codex-cli-visible-proof" / "visible-resume-proof.public.json"
-)
-
-
-VISIBLE_PILOT_COMMANDS = {
- "codex-cli-one-message-loop-pilot": ["--proof-fixture", "--allow-headless-fallback"],
- "codex-cli-visible-local-driver-pilot": ["--idle-fixture", "--allow-headless-fallback"],
- "codex-cli-bounded-visible-pilot-adapter": ["--first-response-fixture", "--idle-fixture"],
- "codex-cli-visible-first-response-capture-plan": ["--first-response-path", "--idle-path"],
- "codex-cli-visible-attach-acceptance": ["--proof-fixture", "--idle-fixture"],
-}
-VISIBLE_DRIVER_COMMANDS = {
- "codex-cli-visible-driver-plan": ["--fixture", "--codex-bin"],
- "codex-cli-local-driver-plan": ["--fixture", "--codex-bin"],
- "codex-cli-visible-driver-run": ["--proof-fixture", "--allow-headless-fallback"],
-}
-
-
-def run_cli(*args: str) -> subprocess.CompletedProcess[str]:
- return subprocess.run(
- [sys.executable, "-m", "loopx.cli", *args],
- cwd=ROOT,
- text=True,
- capture_output=True,
- check=False,
- )
-
-
-def require(condition: bool, message: str) -> None:
- if not condition:
- raise AssertionError(message)
-
-
-def require_success(result: subprocess.CompletedProcess[str]) -> str:
- if result.returncode != 0:
- raise AssertionError(
- f"expected success, got {result.returncode}\n"
- f"stdout:\n{result.stdout}\n\nstderr:\n{result.stderr}"
- )
- return result.stdout
-
-
-def require_json_success(result: subprocess.CompletedProcess[str]) -> dict[str, object]:
- payload = json.loads(require_success(result))
- require(isinstance(payload, dict), "expected JSON object payload")
- require(payload.get("ok") is True, f"payload was not ok: {payload}")
- return payload
-
-
-def assert_source_shape() -> None:
- starter_source = STARTER.read_text(encoding="utf-8")
- visible_common_source = VISIBLE_COMMON.read_text(encoding="utf-8")
- visible_driver_source = VISIBLE_DRIVER.read_text(encoding="utf-8")
- visible_pilot_source = VISIBLE_PILOT.read_text(encoding="utf-8")
- runtime_idle_source = RUNTIME_IDLE.read_text(encoding="utf-8")
- init_source = INIT.read_text(encoding="utf-8")
-
- forbidden_starter_markers = [
- "build_codex_cli_one_message_loop_pilot(",
- "build_codex_cli_visible_local_driver_pilot(",
- "build_codex_cli_bounded_visible_pilot_adapter(",
- "build_codex_cli_visible_first_response_capture_plan(",
- "build_codex_cli_visible_attach_acceptance(",
- "build_codex_cli_visible_driver_plan(",
- "build_codex_cli_local_driver_plan(",
- "build_codex_cli_visible_driver_run_packet(",
- "def handle_codex_cli_one_message_loop_pilot_command(",
- "def handle_codex_cli_visible_local_driver_pilot_command(",
- "def handle_codex_cli_bounded_visible_pilot_adapter_command(",
- "def handle_codex_cli_visible_first_response_capture_plan_command(",
- "def handle_codex_cli_visible_attach_acceptance_command(",
- "def handle_codex_cli_visible_driver_plan_command(",
- "def handle_codex_cli_local_driver_plan_command(",
- "def handle_codex_cli_visible_driver_run_command(",
- ]
- for marker in forbidden_starter_markers:
- require(marker not in starter_source, f"visible-driver marker leaked into starter.py: {marker}")
-
- for marker in (
- "register_starter_visible_driver_commands(subparsers)",
- "handle_starter_visible_driver_command(args, print_payload)",
- ):
- require(marker in starter_source, f"starter.py missing visible-driver delegation marker: {marker}")
-
- for command in VISIBLE_PILOT_COMMANDS:
- require(command in visible_pilot_source, f"starter_visible_pilot.py missing command: {command}")
- require(command not in visible_driver_source, f"pilot command leaked into starter_visible_driver.py: {command}")
- for command in VISIBLE_DRIVER_COMMANDS:
- require(command in visible_driver_source, f"starter_visible_driver.py missing command: {command}")
-
- for marker in (
- "def register_starter_visible_driver_commands(",
- "def handle_starter_visible_driver_command(",
- "def handle_codex_cli_visible_driver_run_command(",
- "_VISIBLE_DRIVER_HANDLERS",
- ):
- require(marker in visible_driver_source, f"starter_visible_driver.py missing marker: {marker}")
- for marker in (
- "register_starter_visible_pilot_commands(subparsers)",
- "handle_starter_visible_pilot_command(args, print_payload)",
- ):
- require(marker in visible_driver_source, f"starter_visible_driver.py missing pilot delegation marker: {marker}")
- for marker in (
- "def register_starter_visible_pilot_commands(",
- "def handle_starter_visible_pilot_command(",
- "def handle_codex_cli_one_message_loop_pilot_command(",
- "def handle_codex_cli_visible_attach_acceptance_command(",
- "_VISIBLE_PILOT_HANDLERS",
- ):
- require(marker in visible_pilot_source, f"starter_visible_pilot.py missing marker: {marker}")
-
- for marker in (
- "def _add_project_arguments(",
- "def _add_codex_probe_arguments(",
- "def _add_optional_proof_fixture(",
- "def _add_headless_fallback_argument(",
- ):
- require(marker in visible_common_source, f"starter_visible_common.py missing marker: {marker}")
-
- for marker in (
- "def _add_runtime_idle_observation_arguments(",
- "def _load_codex_cli_runtime_idle_payload(",
- "build_codex_cli_runtime_idle_observation_payload(",
- ):
- require(marker in runtime_idle_source, f"starter_runtime_idle.py missing marker: {marker}")
-
- for marker in (
- "handle_starter_visible_driver_command",
- "handle_starter_visible_pilot_command",
- "register_starter_visible_driver_commands",
- "register_starter_visible_pilot_commands",
- "handle_codex_cli_visible_driver_run_command",
- ):
- require(marker in init_source, f"__init__ omitted visible-driver export: {marker}")
-
- require(len(visible_driver_source.splitlines()) <= 220, "starter_visible_driver.py exceeded size guard")
- require(len(visible_pilot_source.splitlines()) <= 340, "starter_visible_pilot.py exceeded size guard")
-
-
-def assert_cli_surfaces() -> None:
- for command, needles in {**VISIBLE_PILOT_COMMANDS, **VISIBLE_DRIVER_COMMANDS}.items():
- help_text = require_success(run_cli(command, "--help"))
- for needle in needles:
- require(needle in help_text, f"{command} help omitted {needle}")
-
- capture_payload = require_json_success(
- run_cli(
- "--format",
- "json",
- "codex-cli-visible-first-response-capture-plan",
- "--project",
- ".",
- "--goal-id",
- "starter-visible-driver-smoke",
- )
- )
- require(capture_payload.get("goal_id") == "starter-visible-driver-smoke", capture_payload)
-
- plan_payload = require_json_success(
- run_cli(
- "--format",
- "json",
- "codex-cli-visible-driver-plan",
- "--project",
- ".",
- "--goal-id",
- "starter-visible-driver-smoke",
- "--fixture",
- str(VISIBLE_HELP_FIXTURE),
- )
- )
- require(plan_payload.get("driver_mode") == "visible_resume_or_remote_control_spike", plan_payload)
-
- run_payload = require_json_success(
- run_cli(
- "--format",
- "json",
- "codex-cli-visible-driver-run",
- "--project",
- ".",
- "--goal-id",
- "starter-visible-driver-smoke",
- "--fixture",
- str(VISIBLE_HELP_FIXTURE),
- "--proof-fixture",
- str(VISIBLE_PROOF_FIXTURE),
- )
- )
- require(run_payload.get("decision") == "visible_session_turn_candidate", run_payload)
- boundary = run_payload.get("boundary")
- require(isinstance(boundary, dict), run_payload)
- require(boundary.get("runs_codex") is False, run_payload)
- require(boundary.get("mutates_codex_session") is False, run_payload)
-
-
-def main() -> None:
- assert_source_shape()
- assert_cli_surfaces()
- print("cli-starter-visible-driver-family-command-modularization-smoke: ok")
-
-
-if __name__ == "__main__":
- main()
diff --git a/examples/cli-support-control-command-modularization-smoke.py b/examples/cli-support-control-command-modularization-smoke.py
deleted file mode 100644
index 8866d63072..0000000000
--- a/examples/cli-support-control-command-modularization-smoke.py
+++ /dev/null
@@ -1,124 +0,0 @@
-#!/usr/bin/env python3
-from __future__ import annotations
-
-import subprocess
-import sys
-from pathlib import Path
-
-
-ROOT = Path(__file__).resolve().parents[1]
-CLI = ROOT / "loopx" / "cli.py"
-MODULE = ROOT / "loopx" / "cli_commands" / "support_control.py"
-HEARTBEAT = MODULE.with_name("support_control_heartbeat.py")
-INIT = ROOT / "loopx" / "cli_commands" / "__init__.py"
-
-
-def run_cli(*args: str) -> subprocess.CompletedProcess[str]:
- return subprocess.run(
- [sys.executable, "-m", "loopx.entrypoint", *args],
- cwd=ROOT,
- text=True,
- capture_output=True,
- check=False,
- )
-
-
-def require(condition: bool, message: str) -> None:
- if not condition:
- raise AssertionError(message)
-
-
-def require_success(result: subprocess.CompletedProcess[str]) -> str:
- if result.returncode != 0:
- raise AssertionError(
- f"expected success, got {result.returncode}\n"
- f"stdout:\n{result.stdout}\n\nstderr:\n{result.stderr}"
- )
- return result.stdout
-
-
-def main() -> None:
- cli_source = CLI.read_text(encoding="utf-8")
- module_source = MODULE.read_text(encoding="utf-8")
- init_source = INIT.read_text(encoding="utf-8")
-
- forbidden_cli_markers = [
- "backup_state_parser = sub.add_parser",
- "heartbeat_prompt_parser = sub.add_parser",
- "promotion_gate_parser = sub.add_parser",
- "upgrade_plan_parser = sub.add_parser",
- "update_parser = sub.add_parser",
- "registry_boundary_parser = sub.add_parser",
- "serve_status_parser = sub.add_parser",
- "chat_parser = sub.add_parser",
- "resolve_heartbeat_active_state(",
- "build_heartbeat_prompt(",
- "build_promotion_gate(",
- "build_upgrade_plan(",
- "build_update_plan(",
- "build_state_backup_plan(",
- "inspect_registry(",
- "inspect_registry_boundary(",
- "serve_status(",
- "serve_chat(",
- 'if args.command == "backup-state":',
- 'if args.command == "heartbeat-prompt":',
- 'if args.command == "promotion-gate":',
- 'if args.command == "upgrade-plan":',
- 'if args.command == "update":',
- 'if args.command == "registry":',
- 'if args.command == "registry-boundary":',
- 'if args.command == "serve-status":',
- 'if args.command == "chat":',
- ]
- for marker in forbidden_cli_markers:
- require(marker not in cli_source, f"support/control marker leaked into cli.py: {marker}")
-
- for marker in (
- "SUPPORT_CONTROL_COMMANDS",
- "register_support_control_commands",
- "handle_support_control_command",
- "backup-state",
- "chat",
- "promotion-gate",
- "upgrade-plan",
- "update",
- "registry-boundary",
- "serve-status",
- ):
- require(marker in module_source, f"support/control module missing {marker}")
- require("register_support_control_commands" in cli_source, "cli.py did not register support/control commands")
- require("handle_support_control_command" in cli_source, "cli.py did not dispatch support/control commands")
- require("register_support_control_commands" in init_source, "__init__ omitted support/control registration")
- require("handle_support_control_command" in init_source, "__init__ omitted support/control handler")
- heartbeat_source = HEARTBEAT.read_text(encoding="utf-8")
- require("build_heartbeat_prompt(" not in module_source, "support/control retained duplicate heartbeat dispatch")
- for marker in ("handle_heartbeat_prompt_command", "resolve_heartbeat_active_state", "build_heartbeat_prompt("):
- require(marker in heartbeat_source, f"heartbeat handler missing {marker}")
-
- for command, options in {
- "backup-state": (
- "--project",
- "--output-dir",
- "--backup-id",
- "--current-project-only",
- "--execute",
- ),
- "heartbeat-prompt": ("--goal-id", "--agent-id", "--thin"),
- "promotion-gate": ("--format",),
- "upgrade-plan": ("--installed-manifest", "--cli-bin", "--mode"),
- "update": ("--check", "--dry-run", "--execute"),
- "registry": (),
- "registry-boundary": ("--path", "--require-not-tracked", "--require-gitignored"),
- "serve-status": ("--global-registry", "--enable-reward-write-api", "--enable-control-plane-write-api"),
- "chat": ("--goal-id", "--codex-bin", "--no-open", "--global-registry"),
- }.items():
- help_text = require_success(run_cli(command, "--help"))
- for option in options:
- require(option in help_text, f"{command} help omitted {option}")
-
- print("cli-support-control-command-modularization-smoke: ok")
-
-
-if __name__ == "__main__":
- main()
diff --git a/examples/codex-app-control-plane-hook-cache-smoke.py b/examples/codex-app-control-plane-hook-cache-smoke.py
deleted file mode 100644
index 266007e261..0000000000
--- a/examples/codex-app-control-plane-hook-cache-smoke.py
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/usr/bin/env python3
-"""Smoke-test the Codex App control-plane hook/cache experiment contract."""
-
-from __future__ import annotations
-
-from pathlib import Path
-
-
-REPO_ROOT = Path(__file__).resolve().parents[1]
-DOC = REPO_ROOT / "docs/product/runtimes/codex-app/codex-app-control-plane-hook-cache.md"
-RUNTIME_INDEX = REPO_ROOT / "docs/product/runtimes/codex-app/README.md"
-
-
-def main() -> int:
- doc = DOC.read_text(encoding="utf-8")
- index = RUNTIME_INDEX.read_text(encoding="utf-8")
- normalized_doc = " ".join(doc.split())
-
- required_phrases = [
- "Status: experimental design note, default off.",
- "enabled_by_default: false",
- "mode: advisory_hint",
- "host-runtime hint",
- "LoopX remains authoritative",
- "Missing, stale, or mismatched hints fall back to the CLI.",
- "quiet_wait_cache_lab",
- "guard_projection_lab",
- "default_candidate",
- "Evidence Gates",
- "zero false run and zero false quiet-skip decisions",
- "public/private scans",
- "Fallback CLI Path",
- "Keep all delivery, writeback, publication, and quota spend decisions on the existing CLI guard.",
- ]
- for phrase in required_phrases:
- assert phrase in doc or phrase in normalized_doc, phrase
-
- forbidden_default_claims = [
- "enabled_by_default: true",
- "default enabled",
- "enable automatically",
- "replace quota should-run",
- ]
- lowered = doc.lower()
- for phrase in forbidden_default_claims:
- assert phrase not in lowered, phrase
-
- assert "codex-app-control-plane-hook-cache.md" in index, "runtime index link"
-
- print("codex-app-control-plane-hook-cache-smoke ok")
- return 0
-
-
-if __name__ == "__main__":
- raise SystemExit(main())
diff --git a/examples/codex-cli-bootstrap-message-smoke.py b/examples/codex-cli-bootstrap-message-smoke.py
index 1a69c41e14..3791217ccc 100644
--- a/examples/codex-cli-bootstrap-message-smoke.py
+++ b/examples/codex-cli-bootstrap-message-smoke.py
@@ -193,13 +193,12 @@ def assert_docs_surface_codex_cli_quickstart() -> None:
assert "Codex App gets a heartbeat automation body that starts at 3 minutes" in normalized_getting_started, getting_started
assert "transcript-free validation checklist" in normalized_getting_started, getting_started
assert "installs the generated LoopX goal/heartbeat loader immediately" in normalized_product_contract, product_contract
- assert "optional automation checks after the setup path works" in normalized_getting_started, getting_started
assert "first useful TUI response should be a control-plane snapshot" in normalized_product_contract, product_contract
assert "setup-only work" in normalized_product_contract, product_contract
- assert "loopx codex-cli-session-probe" in getting_started, getting_started
- assert "loopx codex-cli-exec-handoff --project . --goal-id " in getting_started, getting_started
+ assert "loopx turn plan" in getting_started, getting_started
+ assert "loopx turn run-once" in getting_started, getting_started
assert "headless-disabled boundary" in normalized_getting_started, getting_started
- assert "This command no longer prints a runnable `codex exec` handoff script" in product_contract, product_contract
+ assert "default Codex CLI LoopX setup-then-`/goal` path does not expose a headless fallback" in normalized_product_contract, product_contract
def main() -> int:
diff --git a/examples/codex-cli-bounded-visible-pilot-adapter-smoke.py b/examples/codex-cli-bounded-visible-pilot-adapter-smoke.py
deleted file mode 100644
index 8bb28ddf51..0000000000
--- a/examples/codex-cli-bounded-visible-pilot-adapter-smoke.py
+++ /dev/null
@@ -1,225 +0,0 @@
-#!/usr/bin/env python3
-"""Smoke-test the Codex CLI bounded visible pilot adapter packet."""
-
-from __future__ import annotations
-
-import copy
-import json
-import subprocess
-import sys
-import tempfile
-from pathlib import Path
-
-
-REPO_ROOT = Path(__file__).resolve().parents[1]
-if str(REPO_ROOT) not in sys.path:
- sys.path.insert(0, str(REPO_ROOT))
-
-from loopx.codex_cli_probe import ( # noqa: E402
- build_codex_cli_bounded_visible_pilot_adapter,
-)
-
-
-PROJECT = Path("/tmp/public-codex-cli-project")
-GOAL_ID = "public-codex-cli-goal"
-AGENT_ID = "codex-side-bypass"
-LIVE_PILOT_DOC = REPO_ROOT / "docs" / "product" / "runtimes" / "codex-cli" / "codex-cli-live-tui-first-message-pilot.md"
-PRODUCT_README = (
- REPO_ROOT / "docs" / "product" / "runtimes" / "codex-cli" / "README.md"
-)
-
-
-PASSING_FIRST_RESPONSE_FIXTURE = {
- "observed_surface": "codex_cli_tui_visible_window",
- "prompt_delivery": {
- "manual_or_visible_delivery": True,
- "prompt_public_safe": True,
- "argv_prompt_used": False,
- },
- "first_response": {
- "goal_id_visible": True,
- "user_gate_or_none_visible": True,
- "top_user_todo_or_none_visible": True,
- "top_agent_todo_visible": True,
- "next_safe_action_visible": True,
- "bounded_segment_started_or_blocker_written": True,
- },
- "interruptibility": {
- "user_can_interrupt": True,
- "manual_takeover_available": True,
- },
- "writeback": {
- "compact_evidence_planned": True,
- "quota_spend_after_writeback_only": True,
- },
- "boundary": {
- "reads_raw_transcripts": False,
- "reads_session_files": False,
- "reads_stdout_stderr": False,
- "reads_credentials": False,
- "mutates_hidden_session_state": False,
- "spends_quota_before_writeback": False,
- },
-}
-
-
-PASSING_IDLE_FIXTURE = {
- "observed_surface": "codex_cli_tui_visible_window",
- "idle_guard": {
- "no_active_human_typing": True,
- "no_running_turn": True,
- "checked_before_prompt": True,
- },
- "turn_visibility": {"visible_to_user": True},
- "interruptibility": {
- "user_can_interrupt": True,
- "manual_takeover_available": True,
- },
- "boundary": {
- "reads_raw_transcripts": False,
- "reads_session_files": False,
- "reads_stdout_stderr": False,
- "reads_credentials": False,
- "mutates_hidden_session_state": False,
- },
-}
-
-
-def build_adapter(
- *,
- first_response: dict[str, object] | None = None,
- idle: dict[str, object] | None = None,
-) -> dict[str, object]:
- return build_codex_cli_bounded_visible_pilot_adapter(
- project=PROJECT,
- goal_id=GOAL_ID,
- agent_id=AGENT_ID,
- cli_bin="loopx",
- first_response_payload=first_response,
- idle_payload=idle,
- )
-
-
-def assert_boundary(payload: dict[str, object]) -> None:
- boundary = payload["boundary"]
- assert boundary["adapter_packet_only"] is True, payload
- assert boundary["runs_codex"] is False, payload
- assert boundary["reads_raw_transcripts"] is False, payload
- assert boundary["reads_session_files"] is False, payload
- assert boundary["reads_stdout_stderr"] is False, payload
- assert boundary["reads_credentials"] is False, payload
- assert boundary["mutates_codex_session"] is False, payload
- assert boundary["writes_loopx_state"] is False, payload
- assert boundary["spends_loopx_quota"] is False, payload
- assert boundary["requires_visible_delivery"] is True, payload
- assert boundary["argv_prompt_rejected"] is True, payload
- assert boundary["success_claim_requires_first_response_and_idle"] is True, payload
-
-
-def run_cli(*extra_args: str) -> str:
- result = subprocess.run(
- [sys.executable, "-m", "loopx.cli", *extra_args],
- cwd=REPO_ROOT,
- check=True,
- capture_output=True,
- text=True,
- )
- return result.stdout
-
-
-def assert_docs() -> None:
- live_pilot = LIVE_PILOT_DOC.read_text(encoding="utf-8")
- product_readme = PRODUCT_README.read_text(encoding="utf-8")
- assert "codex-cli-bounded-visible-pilot-adapter" in live_pilot, live_pilot
- assert "public-first-response.json" in live_pilot, live_pilot
- assert "argv prompt" in live_pilot, live_pilot
- assert "Codex CLI bounded visible pilot adapter" in product_readme, product_readme
- assert "codex-cli-bounded-visible-pilot-adapter-smoke.py" in product_readme, product_readme
-
-
-def main() -> int:
- missing = build_adapter()
- assert missing["ok"] is True, missing
- assert missing["schema_version"] == "codex_cli_bounded_visible_pilot_adapter_v0", missing
- assert missing["decision"] == "bounded_visible_completion_evidence_required", missing
- assert missing["approved_for_live_tui_success_claim"] is False, missing
- assert "missing_first_response_evidence" in missing["blockers"], missing
- assert "missing_runtime_idle_evidence" in missing["blockers"], missing
- assert "codex-cli-bootstrap-message" in missing["commands"]["bootstrap_message"], missing
- assert "codex-cli-bounded-visible-pilot-adapter" in missing["commands"]["bounded_visible_pilot_adapter"], missing
- assert_boundary(missing)
-
- argv_leaking = copy.deepcopy(PASSING_FIRST_RESPONSE_FIXTURE)
- argv_leaking["prompt_delivery"]["argv_prompt_used"] = True
- rejected = build_adapter(first_response=argv_leaking, idle=PASSING_IDLE_FIXTURE)
- assert rejected["decision"] == "bounded_visible_first_response_incomplete", rejected
- assert rejected["approved_for_live_tui_success_claim"] is False, rejected
- assert "no_argv_prompt" in rejected["blockers"], rejected
- assert "argv_prompt_leakage_risk" in rejected["blockers"], rejected
- assert rejected["runtime_idle_detector"]["approved"] is True, rejected
- assert_boundary(rejected)
-
- passing = build_adapter(
- first_response=PASSING_FIRST_RESPONSE_FIXTURE,
- idle=PASSING_IDLE_FIXTURE,
- )
- assert passing["decision"] == "bounded_visible_pilot_ready_for_success_claim", passing
- assert passing["approved_for_live_tui_success_claim"] is True, passing
- assert passing["first_response"]["approved"] is True, passing
- assert passing["runtime_idle_detector"]["approved"] is True, passing
- assert passing["blockers"] == [], passing
- assert "--delivery-outcome outcome_progress" in passing["commands"]["success_writeback"], passing
- assert_boundary(passing)
-
- with tempfile.TemporaryDirectory(prefix="loopx-codex-cli-bounded-visible-") as tmp:
- tmp_path = Path(tmp)
- first_response_fixture = tmp_path / "public-first-response.json"
- first_response_fixture.write_text(json.dumps(PASSING_FIRST_RESPONSE_FIXTURE))
- idle_fixture = tmp_path / "public-runtime-idle.json"
- idle_fixture.write_text(json.dumps(PASSING_IDLE_FIXTURE))
-
- cli_json = json.loads(
- run_cli(
- "--format",
- "json",
- "codex-cli-bounded-visible-pilot-adapter",
- "--project",
- str(PROJECT),
- "--goal-id",
- GOAL_ID,
- "--agent-id",
- AGENT_ID,
- "--first-response-fixture",
- str(first_response_fixture),
- "--idle-fixture",
- str(idle_fixture),
- )
- )
- assert cli_json["decision"] == "bounded_visible_pilot_ready_for_success_claim", cli_json
- assert cli_json["approved_for_live_tui_success_claim"] is True, cli_json
- assert_boundary(cli_json)
-
- markdown = run_cli(
- "codex-cli-bounded-visible-pilot-adapter",
- "--project",
- str(PROJECT),
- "--goal-id",
- GOAL_ID,
- "--agent-id",
- AGENT_ID,
- "--first-response-fixture",
- str(first_response_fixture),
- "--idle-fixture",
- str(idle_fixture),
- )
- assert "# Codex CLI Bounded Visible Pilot Adapter" in markdown, markdown
- assert "approved_for_live_tui_success_claim" in markdown, markdown
- assert "argv_prompt_rejected" in markdown, markdown
-
- assert_docs()
- print("codex-cli-bounded-visible-pilot-adapter-smoke ok")
- return 0
-
-
-if __name__ == "__main__":
- raise SystemExit(main())
diff --git a/examples/codex-cli-exec-handoff-smoke.py b/examples/codex-cli-exec-handoff-smoke.py
deleted file mode 100644
index 4b717064a2..0000000000
--- a/examples/codex-cli-exec-handoff-smoke.py
+++ /dev/null
@@ -1,104 +0,0 @@
-#!/usr/bin/env python3
-"""Smoke-test the disabled Codex CLI exec handoff boundary."""
-
-from __future__ import annotations
-
-import json
-import subprocess
-import sys
-from pathlib import Path
-
-
-REPO_ROOT = Path(__file__).resolve().parents[1]
-if str(REPO_ROOT) not in sys.path:
- sys.path.insert(0, str(REPO_ROOT))
-
-from loopx.project_prompt import build_codex_cli_exec_handoff # noqa: E402
-
-
-PROJECT = Path("/tmp/public-codex-cli-project")
-GOAL_ID = "public-codex-cli-goal"
-AGENT_ID = "codex-side-bypass"
-
-
-def run_cli(*extra_args: str) -> str:
- result = subprocess.run(
- [sys.executable, "-m", "loopx.cli", *extra_args],
- cwd=REPO_ROOT,
- check=True,
- capture_output=True,
- text=True,
- )
- return result.stdout
-
-
-def assert_handoff_contract(payload: dict[str, object]) -> None:
- assert payload["ok"] is True, payload
- assert payload["schema_version"] == "codex_cli_exec_handoff_v0", payload
- assert payload["mode"] == "headless_fallback_disabled_for_goal_mode_bootstrap", payload
- assert payload["primary_experience"] == "codex_cli_tui_goal_bootstrap", payload
- assert payload["goal_id"] == GOAL_ID, payload
- assert payload["agent_id"] == AGENT_ID, payload
- command = str(payload["handoff_command"])
- message_only = str(payload["message_only_command"])
- assert command == "", payload
- assert "codex exec" not in command, payload
- assert "codex-cli-bootstrap-message" in message_only, payload
- assert "--message-only" in message_only, payload
- assert "disabled" in str(payload["disabled_reason"]).lower(), payload
- boundary = payload["boundary"]
- assert boundary["runs_codex"] is False, payload
- assert boundary["reads_raw_transcripts"] is False, payload
- assert boundary["reads_credentials"] is False, payload
- assert boundary["reads_session_files"] is False, payload
- assert boundary["mutates_codex_session"] is False, payload
- assert boundary["spends_loopx_quota"] is False, payload
- assert boundary["headless_execution_disabled"] is True, payload
- assert boundary["provides_executable_headless_command"] is False, payload
-
-
-def main() -> int:
- payload = build_codex_cli_exec_handoff(
- project=PROJECT,
- goal_id=GOAL_ID,
- agent_id=AGENT_ID,
- cli_bin="loopx",
- codex_bin="codex",
- )
- assert_handoff_contract(payload)
-
- cli_json = json.loads(
- run_cli(
- "--format",
- "json",
- "codex-cli-exec-handoff",
- "--project",
- str(PROJECT),
- "--goal-id",
- GOAL_ID,
- "--agent-id",
- AGENT_ID,
- )
- )
- assert_handoff_contract(cli_json)
-
- cli_markdown = run_cli(
- "codex-cli-exec-handoff",
- "--project",
- str(PROJECT),
- "--goal-id",
- GOAL_ID,
- "--agent-id",
- AGENT_ID,
- )
- assert "# Codex CLI Exec Handoff Disabled" in cli_markdown, cli_markdown
- assert "Headless `codex exec` handoff is disabled" in cli_markdown, cli_markdown
- assert "codex-cli-bootstrap-message" in cli_markdown, cli_markdown
- assert "cat <<'LOOPX_CODEX_PROMPT' | codex exec" not in cli_markdown, cli_markdown
-
- print("codex-cli-exec-handoff-smoke ok")
- return 0
-
-
-if __name__ == "__main__":
- raise SystemExit(main())
diff --git a/examples/codex-cli-first-run-rehearsal-smoke.py b/examples/codex-cli-first-run-rehearsal-smoke.py
index ac64e15fb8..f94bb87d6d 100644
--- a/examples/codex-cli-first-run-rehearsal-smoke.py
+++ b/examples/codex-cli-first-run-rehearsal-smoke.py
@@ -43,15 +43,12 @@ def assert_doc() -> None:
"Codex CLI First-Run Rehearsal",
"PyPI install/update with packaged workflow skills and an archive fallback",
"one-message Codex CLI TUI bootstrap",
- "proof-capture fixtures for later visible automation",
+ "bounded isolated-headless turns via `loopx turn`",
"Start LoopX for this repo",
"python3 -m pip install --upgrade loopx",
"loopx workflow-skills --install",
"loopx codex-cli-bootstrap-message --project . --goal-id --message-only",
- "loopx codex-cli-tui-bootstrap-smoke-bundle",
- "loopx --format json codex-cli-visible-attach-acceptance",
- "does not prove same-open-TUI automation",
- "Same-TUI automation stays optional until the proof path passes",
+ "Same-TUI automation stays optional until a safe attach primitive is proven",
"must not:",
"require cloning the LoopX repo",
"read raw Codex transcripts, session files, stdout, stderr, credentials, or private paths",
@@ -77,7 +74,7 @@ def assert_indexes() -> None:
assert f"../product/runtimes/codex-cli/{link}" in getting_started, getting_started
assert "PyPI" in product, product
assert "one-message TUI bootstrap" in product, product
- assert "proof-capture fixtures" in getting_started, getting_started
+ assert "explicit `loopx turn` boundaries" in getting_started, getting_started
def assert_cli_surfaces_align() -> None:
@@ -111,20 +108,6 @@ def assert_cli_surfaces_align() -> None:
assert "settlement_plan.ordered_steps" in normalized, message
assert "raw Codex transcripts" in normalized, message
- bundle = run_cli(
- "codex-cli-tui-bootstrap-smoke-bundle",
- "--project",
- "/tmp/public-codex-cli-project",
- "--goal-id",
- GOAL_ID,
- "--agent-id",
- AGENT_ID,
- )
- normalized_bundle = normalize(bundle)
- assert "Codex CLI TUI Bootstrap Smoke Bundle" in normalized_bundle, bundle
- assert "runs_codex: `False`" in normalized_bundle, bundle
- assert "requires_loopx_repo_clone: `False`" in normalized_bundle, bundle
-
def main() -> int:
assert_doc()
diff --git a/examples/codex-cli-live-tui-first-message-pilot-smoke.py b/examples/codex-cli-live-tui-first-message-pilot-smoke.py
deleted file mode 100644
index 02a159041f..0000000000
--- a/examples/codex-cli-live-tui-first-message-pilot-smoke.py
+++ /dev/null
@@ -1,112 +0,0 @@
-#!/usr/bin/env python3
-"""Validate the Codex CLI live TUI first-message pilot record."""
-
-from __future__ import annotations
-
-import subprocess
-import sys
-from pathlib import Path
-
-
-REPO_ROOT = Path(__file__).resolve().parents[1]
-DOC = REPO_ROOT / "docs" / "product" / "runtimes" / "codex-cli" / "codex-cli-live-tui-first-message-pilot.md"
-FIRST_RUN = REPO_ROOT / "docs" / "product" / "runtimes" / "codex-cli" / "codex-cli-first-run-rehearsal.md"
-PRODUCT_README = (
- REPO_ROOT / "docs" / "product" / "runtimes" / "codex-cli" / "README.md"
-)
-GOAL_ID = "public-live-tui-pilot-goal"
-AGENT_ID = "codex-side-bypass"
-
-
-def normalize(text: str) -> str:
- return " ".join(text.split())
-
-
-def run_cli(*args: str) -> str:
- result = subprocess.run(
- [sys.executable, "-m", "loopx.cli", *args],
- cwd=REPO_ROOT,
- check=True,
- text=True,
- capture_output=True,
- )
- return result.stdout
-
-
-def assert_doc() -> None:
- text = DOC.read_text(encoding="utf-8")
- normalized = normalize(text)
-
- must_have = (
- "Codex CLI Live TUI First-Message Pilot",
- "Status: blocker recorded; manual TUI bootstrap remains primary.",
- "Recorded: 2026-06-21.",
- "disposable public-safe repo",
- "codex [OPTIONS] [PROMPT]",
- "--no-alt-screen",
- "--cd ",
- "resume",
- "remote-control",
- "codex doctor",
- "did not produce bounded output before manual interrupt",
- "no bounded first-response or completion signal",
- "capture output exceeded the automation budget",
- "process remained active",
- "process command line",
- "live_tui_first_message_blocked_by_bounded_visible_completion_missing",
- "manual TUI bootstrap remains primary",
- "the user pastes one LoopX start message",
- "without leaking project-specific prompt text through process arguments",
- "raw transcript or session-file reads",
- "Codex CLI bounded visible pilot adapter",
- )
- for phrase in must_have:
- assert phrase in normalized, phrase
-
- assert "LoopX should not advertise automated `codex [PROMPT]` launch" in text
- assert "raw TUI output, Codex transcripts, session files" in normalized, text
- assert "without raw transcript or session-file reads" in normalized, text
-
-
-def assert_indexes() -> None:
- product = PRODUCT_README.read_text(encoding="utf-8")
- first_run = FIRST_RUN.read_text(encoding="utf-8")
- assert "codex-cli-live-tui-first-message-pilot.md" in product, product
- assert "Codex CLI live TUI first-message pilot" in product, product
- assert "Live TUI Pilot Note" in first_run, first_run
- assert (
- "Automated live launch needs a bounded visible completion proof first." in first_run
- ), first_run
-
-
-def assert_bootstrap_message_still_copy_first() -> None:
- message = run_cli(
- "codex-cli-bootstrap-message",
- "--project",
- "/tmp/loopx-live-tui-pilot.public",
- "--goal-id",
- GOAL_ID,
- "--agent-id",
- AGENT_ID,
- "--message-only",
- )
- normalized = normalize(message)
- assert message.startswith("Install and connect LoopX for this repo"), message
- assert not message.startswith("/goal "), message
- assert "Codex CLI TUI" in normalized, message
- assert "setup/bootstrap instruction" in normalized, message
- assert "/goal " in normalized, message
- assert "raw Codex transcripts" in normalized, message
- assert "watch, steer, review, and take over" in normalized, message
-
-
-def main() -> int:
- assert_doc()
- assert_indexes()
- assert_bootstrap_message_still_copy_first()
- print("codex-cli-live-tui-first-message-pilot-smoke ok")
- return 0
-
-
-if __name__ == "__main__":
- raise SystemExit(main())
diff --git a/examples/codex-cli-local-driver-plan-smoke.py b/examples/codex-cli-local-driver-plan-smoke.py
deleted file mode 100644
index 14d57c5171..0000000000
--- a/examples/codex-cli-local-driver-plan-smoke.py
+++ /dev/null
@@ -1,183 +0,0 @@
-#!/usr/bin/env python3
-"""Smoke-test the dry-run-first Codex CLI local driver plan."""
-
-from __future__ import annotations
-
-import json
-import subprocess
-import sys
-import tempfile
-from pathlib import Path
-
-
-REPO_ROOT = Path(__file__).resolve().parents[1]
-if str(REPO_ROOT) not in sys.path:
- sys.path.insert(0, str(REPO_ROOT))
-
-from loopx.codex_cli_probe import ( # noqa: E402
- build_codex_cli_local_driver_plan,
- classify_codex_cli_session_surface,
-)
-
-
-PROJECT = Path("/tmp/public-codex-cli-project")
-GOAL_ID = "public-codex-cli-goal"
-AGENT_ID = "codex-side-bypass"
-
-
-HELP_FIXTURE = {
- "root": """
-Usage: codex [OPTIONS] [PROMPT]
-
-Commands:
- exec Run Codex non-interactively
- resume Resume a previous conversation
-""",
- "exec": "Usage: codex exec [OPTIONS] [PROMPT]",
- "resume": "Usage: codex resume [SESSION_ID]",
-}
-
-
-REMOTE_RESUME_HELP_FIXTURE = {
- "root": """
-Usage: codex [OPTIONS] [PROMPT]
-
-Commands:
- exec
- remote-control Manage the app-server daemon with remote control enabled
- resume Resume a previous interactive session
-
-Options:
- --remote Connect the TUI to a remote app server endpoint
-""",
- "exec": "Usage: codex exec [OPTIONS] [PROMPT]",
- "resume": """
-Usage: codex resume [OPTIONS] [SESSION_ID] [PROMPT]
-
-Resume a previous interactive session.
-""",
-}
-
-
-ATTACH_HELP_FIXTURE = {
- "root": """
-Usage: codex [OPTIONS] [PROMPT]
-
-Commands:
- exec
- resume
- attach-session Send prompt to session after checking the idle TUI
-""",
- "exec": "Usage: codex exec [OPTIONS] [PROMPT]",
- "resume": "Usage: codex resume [SESSION_ID]",
-}
-
-
-def run_cli(*extra_args: str) -> str:
- result = subprocess.run(
- [sys.executable, "-m", "loopx.cli", *extra_args],
- cwd=REPO_ROOT,
- check=True,
- capture_output=True,
- text=True,
- )
- return result.stdout
-
-
-def assert_common_contract(payload: dict[str, object]) -> None:
- assert payload["ok"] is True, payload
- assert payload["schema_version"] == "codex_cli_local_driver_plan_v0", payload
- assert payload["driver_phase"] == "dry_run_plan", payload
- assert payload["goal_id"] == GOAL_ID, payload
- assert payload["agent_id"] == AGENT_ID, payload
- commands = payload["commands"]
- assert "quota should-run --goal-id public-codex-cli-goal --agent-id codex-side-bypass" in commands["quota_guard"], payload
- assert "codex-cli-visible-driver-plan" in commands["visible_driver_plan"], payload
- assert "codex-cli-bootstrap-message" in commands["tui_bootstrap_message"], payload
- assert commands["explicit_headless_fallback"] is None, payload
- assert "headless codex exec is disabled" in commands["headless_fallback_disabled"], payload
- assert payload["idle_guard"]["required"] is True, payload
- assert payload["idle_guard"]["implemented"] is False, payload
- policy = payload["execution_policy"]
- assert policy["tui_bootstrap_primary"] is True, payload
- assert policy["headless_execution_disabled"] is True, payload
- assert policy["same_session_attachment_requires_visible_proof"] is True, payload
- boundary = payload["boundary"]
- assert boundary["dry_run_plan_only"] is True, payload
- assert boundary["runs_codex"] is False, payload
- assert boundary["reads_raw_transcripts"] is False, payload
- assert boundary["reads_credentials"] is False, payload
- assert boundary["reads_session_files"] is False, payload
- assert boundary["mutates_codex_session"] is False, payload
- assert boundary["spends_loopx_quota"] is False, payload
-
-
-def build_plan(command_outputs: dict[str, str]) -> dict[str, object]:
- return build_codex_cli_local_driver_plan(
- project=PROJECT,
- goal_id=GOAL_ID,
- agent_id=AGENT_ID,
- cli_bin="loopx",
- codex_bin="codex",
- probe_payload=classify_codex_cli_session_surface(command_outputs=command_outputs),
- )
-
-
-def main() -> int:
- fallback_plan = build_plan(HELP_FIXTURE)
- assert_common_contract(fallback_plan)
- assert fallback_plan["driver_mode"] == "tui_bootstrap_only", fallback_plan
- assert fallback_plan["decision"] == "ask_user_to_start_from_tui", fallback_plan
-
- remote_plan = build_plan(REMOTE_RESUME_HELP_FIXTURE)
- assert_common_contract(remote_plan)
- assert remote_plan["driver_mode"] == "visible_resume_or_remote_control_spike", remote_plan
- assert remote_plan["decision"] == "run_visible_resume_or_remote_control_proof", remote_plan
-
- attach_plan = build_plan(ATTACH_HELP_FIXTURE)
- assert_common_contract(attach_plan)
- assert attach_plan["driver_mode"] == "session_attached_visible_turn", attach_plan
- assert attach_plan["decision"] == "attempt_visible_session_attach_after_idle_guard", attach_plan
-
- with tempfile.TemporaryDirectory(prefix="loopx-codex-cli-local-driver-") as tmp:
- fixture = Path(tmp) / "codex-remote-help.json"
- fixture.write_text(json.dumps({"command_outputs": REMOTE_RESUME_HELP_FIXTURE}))
- cli_json = json.loads(
- run_cli(
- "--format",
- "json",
- "codex-cli-local-driver-plan",
- "--project",
- str(PROJECT),
- "--goal-id",
- GOAL_ID,
- "--agent-id",
- AGENT_ID,
- "--fixture",
- str(fixture),
- )
- )
- assert_common_contract(cli_json)
- assert cli_json["driver_mode"] == "visible_resume_or_remote_control_spike", cli_json
-
- cli_markdown = run_cli(
- "codex-cli-local-driver-plan",
- "--project",
- str(PROJECT),
- "--goal-id",
- GOAL_ID,
- "--agent-id",
- AGENT_ID,
- "--fixture",
- str(fixture),
- )
- assert "# Codex CLI Local Driver Plan" in cli_markdown, cli_markdown
- assert "driver_phase: `dry_run_plan`" in cli_markdown, cli_markdown
- assert "headless_execution_disabled: `True`" in cli_markdown, cli_markdown
-
- print("codex-cli-local-driver-plan-smoke ok")
- return 0
-
-
-if __name__ == "__main__":
- raise SystemExit(main())
diff --git a/examples/codex-cli-local-scheduler-exec-smoke.py b/examples/codex-cli-local-scheduler-exec-smoke.py
deleted file mode 100644
index cbbe19e8ea..0000000000
--- a/examples/codex-cli-local-scheduler-exec-smoke.py
+++ /dev/null
@@ -1,359 +0,0 @@
-#!/usr/bin/env python3
-"""Smoke-test the Codex CLI local scheduler executor wrapper."""
-
-from __future__ import annotations
-
-import json
-import shlex
-import subprocess
-import sys
-import tempfile
-from pathlib import Path
-
-
-REPO_ROOT = Path(__file__).resolve().parents[1]
-if str(REPO_ROOT) not in sys.path:
- sys.path.insert(0, str(REPO_ROOT))
-
-from loopx.codex_cli_probe import ( # noqa: E402
- build_codex_cli_local_scheduler_executor,
- classify_codex_cli_session_surface,
- execute_codex_cli_local_scheduler_tick_result,
-)
-
-
-PROJECT = Path("/tmp/public-codex-cli-project")
-GOAL_ID = "public-codex-cli-goal"
-AGENT_ID = "codex-side-bypass"
-
-
-REMOTE_RESUME_HELP_FIXTURE = {
- "root": """
-Usage: codex [OPTIONS] [PROMPT]
-
-Commands:
- exec
- remote-control Manage the app-server daemon with remote control enabled
- resume Resume a previous interactive session
-
-Options:
- --remote Connect the TUI to a remote app server endpoint
-""",
- "exec": "Usage: codex exec [OPTIONS] [PROMPT]",
- "resume": """
-Usage: codex resume [OPTIONS] [SESSION_ID] [PROMPT]
-
-Resume a previous interactive session.
-""",
-}
-
-
-VISIBLE_PROOF_FIXTURE = {
- "observed_surface": "visible_resume_prompt",
- "recommended_command": f"{shlex.quote(sys.executable)} -c 'pass'",
- "user_opt_in": True,
- "quota_guard": {"passed": True},
- "idle_guard": {
- "no_active_human_typing": True,
- "no_running_turn": True,
- "checked_before_prompt": True,
- },
- "turn_visibility": {
- "visible_to_user": True,
- "prompt_public_safe": True,
- },
- "interruptibility": {
- "user_can_interrupt": True,
- "manual_takeover_available": True,
- },
- "boundary": {
- "reads_raw_transcripts": False,
- "reads_session_files": False,
- "reads_credentials": False,
- "mutates_hidden_session_state": False,
- "spends_quota_before_writeback": False,
- },
- "writeback": {"compact_evidence_planned": True},
-}
-
-
-RUNTIME_IDLE_FIXTURE = {
- "observed_surface": "visible_resume_prompt",
- "idle_guard": {
- "no_active_human_typing": True,
- "no_running_turn": True,
- "checked_before_prompt": True,
- },
- "turn_visibility": {"visible_to_user": True},
- "interruptibility": {
- "user_can_interrupt": True,
- "manual_takeover_available": True,
- },
- "boundary": {
- "reads_raw_transcripts": False,
- "reads_session_files": False,
- "reads_stdout_stderr": False,
- "reads_credentials": False,
- "mutates_hidden_session_state": False,
- },
-}
-
-
-def fake_runner_calls() -> tuple[list[dict[str, object]], object]:
- calls: list[dict[str, object]] = []
-
- def runner(command: str, *, timeout_seconds: float, capture_output: bool = False) -> dict[str, object]:
- calls.append(
- {
- "command": command,
- "timeout_seconds": timeout_seconds,
- "capture_output": capture_output,
- }
- )
- return {
- "attempted": True,
- "returncode": 0,
- "timed_out": False,
- "output_captured": capture_output,
- }
-
- return calls, runner
-
-
-def build_exec(
- *,
- proof_payload: dict[str, object] | None = VISIBLE_PROOF_FIXTURE,
- idle_payload: dict[str, object] | None = RUNTIME_IDLE_FIXTURE,
- execute_candidate: bool = False,
- execute_blocker_writeback: bool = False,
- guard_checked: bool = False,
- prefixes: list[str] | None = None,
- runner=None,
-) -> dict[str, object]:
- return build_codex_cli_local_scheduler_executor(
- project=PROJECT,
- goal_id=GOAL_ID,
- agent_id=AGENT_ID,
- cli_bin="loopx",
- codex_bin="codex",
- probe_payload=classify_codex_cli_session_surface(command_outputs=REMOTE_RESUME_HELP_FIXTURE),
- proof_payload=proof_payload,
- idle_payload=idle_payload,
- execute_candidate=execute_candidate,
- execute_blocker_writeback=execute_blocker_writeback,
- guard_checked=guard_checked,
- candidate_command_prefixes=prefixes or [],
- runner=runner,
- )
-
-
-def assert_executor_boundary(payload: dict[str, object]) -> None:
- assert payload["schema_version"] == "codex_cli_local_scheduler_executor_v0", payload
- boundary = payload["boundary"]
- assert boundary["executor_wrapper"] is True, payload
- assert boundary["requires_explicit_execute_flag"] is True, payload
- assert boundary["requires_fresh_quota_guard_confirmation"] is True, payload
- assert boundary["candidate_prefix_required"] is True, payload
- assert boundary["runtime_idle_detector_required_for_visible_candidate"] is True, payload
- assert boundary["reads_raw_transcripts"] is False, payload
- assert boundary["reads_credentials"] is False, payload
- assert boundary["reads_session_files"] is False, payload
- assert boundary["mutates_codex_session"] is False, payload
- assert boundary["candidate_output_captured"] is False, payload
- assert boundary["blocker_output_captured"] is False, payload
- assert boundary["spends_loopx_quota"] is False, payload
-
-
-def run_cli(*extra_args: str) -> str:
- result = subprocess.run(
- [sys.executable, "-m", "loopx.cli", *extra_args],
- cwd=REPO_ROOT,
- check=True,
- capture_output=True,
- text=True,
- )
- return result.stdout
-
-
-def main() -> int:
- calls, runner = fake_runner_calls()
-
- no_execute = build_exec(runner=runner)
- assert no_execute["ok"] is True, no_execute
- assert_executor_boundary(no_execute)
- assert no_execute["execution"]["executed"] is False, no_execute
- assert no_execute["execution"]["reason"] == "no_execute_flag", no_execute
- assert calls == [], calls
-
- guard_missing = build_exec(
- execute_candidate=True,
- prefixes=[sys.executable],
- runner=runner,
- )
- assert guard_missing["execution"]["reason"] == "fresh_quota_guard_confirmation_required", guard_missing
- assert calls == [], calls
-
- idle_missing = build_exec(
- idle_payload=None,
- execute_candidate=True,
- guard_checked=True,
- prefixes=[sys.executable],
- runner=runner,
- )
- assert idle_missing["scheduler_action"] == "write_precise_blocker", idle_missing
- assert idle_missing["scheduler_tick"]["precise_blocker"]["reason"] == "runtime_idle_evidence_missing", idle_missing
- assert idle_missing["execution"]["reason"] == "scheduler_action_not_candidate", idle_missing
- assert calls == [], calls
-
- tampered_tick = {
- "schema_version": "codex_cli_local_scheduler_tick_v0",
- "project": str(PROJECT),
- "goal_id": GOAL_ID,
- "agent_id": AGENT_ID,
- "cli_bin": "loopx",
- "codex_bin": "codex",
- "scheduler_phase": "tick_packet_no_execution",
- "scheduler_action": "external_visible_command_candidate",
- "decision": "visible_session_turn_candidate",
- "next_safe_step": "tampered visible candidate",
- "candidate_command": f"{shlex.quote(sys.executable)} -c 'pass'",
- "commands": {"scheduler_tick": "loopx codex-cli-local-scheduler-tick"},
- "visible_driver_run_packet": {
- "visible_session_proof": {"supplied": True, "approved": True}
- },
- "runtime_idle_detector": {"supplied": False, "approved": False},
- }
- tampered_reject = execute_codex_cli_local_scheduler_tick_result(
- tampered_tick,
- execute_candidate=True,
- guard_checked=True,
- candidate_command_prefixes=[sys.executable],
- runner=runner,
- )
- assert tampered_reject["execution"]["reason"] == "runtime_idle_detector_required", tampered_reject
- assert calls == [], calls
-
- prefix_missing = build_exec(
- execute_candidate=True,
- guard_checked=True,
- runner=runner,
- )
- assert prefix_missing["execution"]["reason"] == "candidate_command_prefix_required", prefix_missing
- assert calls == [], calls
-
- prefix_mismatch = build_exec(
- execute_candidate=True,
- guard_checked=True,
- prefixes=["definitely-not-python"],
- runner=runner,
- )
- assert prefix_mismatch["execution"]["reason"] == "candidate_command_prefix_mismatch", prefix_mismatch
- assert calls == [], calls
-
- candidate = build_exec(
- execute_candidate=True,
- guard_checked=True,
- prefixes=[sys.executable],
- runner=runner,
- )
- assert candidate["ok"] is True, candidate
- assert candidate["execution"]["executed"] is True, candidate
- assert candidate["execution"]["kind"] == "candidate_command", candidate
- assert candidate["execution"]["reason"] == "candidate_command_executed", candidate
- assert candidate["boundary"]["runs_external_candidate"] is True, candidate
- assert calls[-1]["capture_output"] is False, calls
-
- blocker = build_exec(
- proof_payload=None,
- execute_blocker_writeback=True,
- guard_checked=True,
- runner=runner,
- )
- assert blocker["ok"] is True, blocker
- assert blocker["execution"]["kind"] == "blocker_writeback", blocker
- assert "refresh-state" in calls[-1]["command"], calls
- assert blocker["boundary"]["writes_loopx_state"] is True, blocker
- assert blocker["boundary"]["spends_loopx_quota"] is False, blocker
- assert calls[-1]["capture_output"] is False, calls
-
- with tempfile.TemporaryDirectory(prefix="loopx-codex-cli-scheduler-exec-") as tmp:
- tmp_path = Path(tmp)
- help_fixture = tmp_path / "codex-remote-help.json"
- help_fixture.write_text(json.dumps({"command_outputs": REMOTE_RESUME_HELP_FIXTURE}))
- proof_fixture = tmp_path / "visible-proof.json"
- proof_fixture.write_text(json.dumps(VISIBLE_PROOF_FIXTURE))
- idle_fixture = tmp_path / "runtime-idle.json"
- idle_fixture.write_text(json.dumps(RUNTIME_IDLE_FIXTURE))
- missing_registry = tmp_path / "missing-registry.json"
- runtime_root = tmp_path / "runtime"
-
- cli_json = json.loads(
- run_cli(
- "--registry",
- str(missing_registry),
- "--runtime-root",
- str(runtime_root),
- "--format",
- "json",
- "codex-cli-local-scheduler-exec",
- "--project",
- str(PROJECT),
- "--goal-id",
- GOAL_ID,
- "--agent-id",
- AGENT_ID,
- "--fixture",
- str(help_fixture),
- )
- )
- assert_executor_boundary(cli_json)
- assert cli_json["execution"]["reason"] == "no_execute_flag", cli_json
-
- cli_prefix_reject = json.loads(
- run_cli(
- "--format",
- "json",
- "codex-cli-local-scheduler-exec",
- "--project",
- str(PROJECT),
- "--goal-id",
- GOAL_ID,
- "--agent-id",
- AGENT_ID,
- "--fixture",
- str(help_fixture),
- "--proof-fixture",
- str(proof_fixture),
- "--idle-fixture",
- str(idle_fixture),
- "--execute-candidate",
- "--guard-checked",
- "--candidate-command-prefix",
- "definitely-not-python",
- )
- )
- assert cli_prefix_reject["ok"] is True, cli_prefix_reject
- assert cli_prefix_reject["execution"]["executed"] is False, cli_prefix_reject
- assert cli_prefix_reject["execution"]["reason"] == "candidate_command_prefix_mismatch", cli_prefix_reject
-
- cli_markdown = run_cli(
- "codex-cli-local-scheduler-exec",
- "--project",
- str(PROJECT),
- "--goal-id",
- GOAL_ID,
- "--agent-id",
- AGENT_ID,
- "--fixture",
- str(help_fixture),
- )
- assert "# Codex CLI Local Scheduler Executor" in cli_markdown, cli_markdown
- assert "reason: `no_execute_flag`" in cli_markdown, cli_markdown
- assert "candidate_output_captured: `False`" in cli_markdown, cli_markdown
-
- print("codex-cli-local-scheduler-exec-smoke ok")
- return 0
-
-
-if __name__ == "__main__":
- raise SystemExit(main())
diff --git a/examples/codex-cli-local-scheduler-tick-smoke.py b/examples/codex-cli-local-scheduler-tick-smoke.py
deleted file mode 100644
index 0df0ccf48c..0000000000
--- a/examples/codex-cli-local-scheduler-tick-smoke.py
+++ /dev/null
@@ -1,353 +0,0 @@
-#!/usr/bin/env python3
-"""Smoke-test the Codex CLI local scheduler tick packet."""
-
-from __future__ import annotations
-
-import json
-import subprocess
-import sys
-import tempfile
-from pathlib import Path
-
-
-REPO_ROOT = Path(__file__).resolve().parents[1]
-if str(REPO_ROOT) not in sys.path:
- sys.path.insert(0, str(REPO_ROOT))
-
-from loopx.codex_cli_probe import ( # noqa: E402
- build_codex_cli_local_scheduler_tick,
- classify_codex_cli_session_surface,
-)
-
-
-PROJECT = Path("/tmp/public-codex-cli-project")
-GOAL_ID = "public-codex-cli-goal"
-AGENT_ID = "codex-side-bypass"
-
-
-FALLBACK_HELP_FIXTURE = {
- "root": """
-Usage: codex [OPTIONS] [PROMPT]
-
-Commands:
- exec Run Codex non-interactively
- resume Resume a previous conversation
-""",
- "exec": "Usage: codex exec [OPTIONS] [PROMPT]",
- "resume": "Usage: codex resume [SESSION_ID]",
-}
-
-
-REMOTE_RESUME_HELP_FIXTURE = {
- "root": """
-Usage: codex [OPTIONS] [PROMPT]
-
-Commands:
- exec
- remote-control Manage the app-server daemon with remote control enabled
- resume Resume a previous interactive session
-
-Options:
- --remote Connect the TUI to a remote app server endpoint
-""",
- "exec": "Usage: codex exec [OPTIONS] [PROMPT]",
- "resume": """
-Usage: codex resume [OPTIONS] [SESSION_ID] [PROMPT]
-
-Resume a previous interactive session.
-""",
-}
-
-
-VISIBLE_PROOF_FIXTURE = {
- "observed_surface": "visible_resume_prompt",
- "recommended_command": "codex resume public-session-id 'LoopX visible steering turn'",
- "user_opt_in": True,
- "quota_guard": {"passed": True},
- "idle_guard": {
- "no_active_human_typing": True,
- "no_running_turn": True,
- "checked_before_prompt": True,
- },
- "turn_visibility": {
- "visible_to_user": True,
- "prompt_public_safe": True,
- },
- "interruptibility": {
- "user_can_interrupt": True,
- "manual_takeover_available": True,
- },
- "boundary": {
- "reads_raw_transcripts": False,
- "reads_session_files": False,
- "reads_credentials": False,
- "mutates_hidden_session_state": False,
- "spends_quota_before_writeback": False,
- },
- "writeback": {"compact_evidence_planned": True},
-}
-
-
-RUNTIME_IDLE_FIXTURE = {
- "observed_surface": "visible_resume_prompt",
- "idle_guard": {
- "no_active_human_typing": True,
- "no_running_turn": True,
- "checked_before_prompt": True,
- },
- "turn_visibility": {"visible_to_user": True},
- "interruptibility": {
- "user_can_interrupt": True,
- "manual_takeover_available": True,
- },
- "boundary": {
- "reads_raw_transcripts": False,
- "reads_session_files": False,
- "reads_stdout_stderr": False,
- "reads_credentials": False,
- "mutates_hidden_session_state": False,
- },
-}
-
-
-QUOTA_HINT_FIXTURE = {
- "scheduler_hint": {
- "schema_version": "scheduler_hint_v0",
- "action": "backoff_until_reassigned",
- "cadence_class": "agent_scope_wait",
- "codex_app": {
- "recommended_interval_minutes": 10,
- "max_interval_minutes": 60,
- "unchanged_poll_backoff_multiplier": 2,
- "example_progression_minutes": [10, 20, 30, 60],
- },
- "unchanged_poll": {
- "limits": {
- "local_scheduler": 3,
- "codex_cli_tui": 3,
- "claude_code_loop": 3,
- },
- "after_limits": {
- "local_scheduler": "stop_tick_loop",
- "codex_cli_tui": "update_goal_blocked_keep_loopx_active",
- "claude_code_loop": "stop_loop",
- },
- "final_quota_replan_check_enabled": True,
- "final_quota_replan_check_action": "rerun_quota_should_run_once",
- },
- "reset_policy": {
- "schema_version": "scheduler_reset_policy_v0",
- "reset_token": "fixture-reset-001",
- "local_scheduler_initial_interval_minutes": 10,
- "codex_app_initial_rrule": "FREQ=MINUTELY;INTERVAL=10",
- },
- }
-}
-
-
-def assert_boundary(payload: dict[str, object]) -> None:
- assert payload["ok"] is True, payload
- assert payload["schema_version"] == "codex_cli_local_scheduler_tick_v0", payload
- assert payload["scheduler_phase"] == "tick_packet_no_execution", payload
- boundary = payload["boundary"]
- assert boundary["tick_packet_only"] is True, payload
- assert boundary["runs_codex"] is False, payload
- assert boundary["reads_raw_transcripts"] is False, payload
- assert boundary["reads_credentials"] is False, payload
- assert boundary["reads_session_files"] is False, payload
- assert boundary["mutates_codex_session"] is False, payload
- assert boundary["spends_loopx_quota"] is False, payload
- assert boundary["writes_loopx_state"] is False, payload
- assert boundary["visible_candidate_requires_runtime_idle_detector"] is True, payload
- assert boundary["headless_execution_disabled"] is True, payload
-
-
-def build_tick(
- command_outputs: dict[str, str],
- *,
- proof_payload: dict[str, object] | None = None,
- idle_payload: dict[str, object] | None = None,
- quota_payload: dict[str, object] | None = None,
- allow_headless_fallback: bool = False,
-) -> dict[str, object]:
- return build_codex_cli_local_scheduler_tick(
- project=PROJECT,
- goal_id=GOAL_ID,
- agent_id=AGENT_ID,
- cli_bin="loopx",
- codex_bin="codex",
- probe_payload=classify_codex_cli_session_surface(command_outputs=command_outputs),
- quota_payload=quota_payload,
- proof_payload=proof_payload,
- idle_payload=idle_payload,
- allow_headless_fallback=allow_headless_fallback,
- )
-
-
-def run_cli(*extra_args: str) -> str:
- result = subprocess.run(
- [sys.executable, "-m", "loopx.cli", *extra_args],
- cwd=REPO_ROOT,
- check=True,
- capture_output=True,
- text=True,
- )
- return result.stdout
-
-
-def main() -> int:
- proof_missing = build_tick(REMOTE_RESUME_HELP_FIXTURE)
- assert_boundary(proof_missing)
- assert proof_missing["scheduler_action"] == "write_precise_blocker", proof_missing
- assert proof_missing["precise_blocker"]["reason"] == "visible_session_proof_missing", proof_missing
- assert "refresh-state" in proof_missing["blocker_writeback_command"], proof_missing
- assert proof_missing["candidate_command"] is None, proof_missing
-
- tui_only = build_tick(FALLBACK_HELP_FIXTURE)
- assert_boundary(tui_only)
- assert tui_only["scheduler_action"] == "surface_tui_bootstrap", tui_only
- assert tui_only["candidate_command"] is None, tui_only
- assert tui_only["blocker_writeback_command"] is None, tui_only
-
- fallback_ignored = build_tick(FALLBACK_HELP_FIXTURE, allow_headless_fallback=True)
- assert_boundary(fallback_ignored)
- assert fallback_ignored["scheduler_action"] == "surface_tui_bootstrap", fallback_ignored
- assert fallback_ignored["candidate_command"] is None, fallback_ignored
- assert fallback_ignored["blocker_writeback_command"] is None, fallback_ignored
- assert any("allow_headless_fallback was ignored" in warning for warning in fallback_ignored["warnings"]), fallback_ignored
-
- visible_idle_missing = build_tick(REMOTE_RESUME_HELP_FIXTURE, proof_payload=VISIBLE_PROOF_FIXTURE)
- assert_boundary(visible_idle_missing)
- assert visible_idle_missing["scheduler_action"] == "write_precise_blocker", visible_idle_missing
- assert visible_idle_missing["precise_blocker"]["reason"] == "runtime_idle_evidence_missing", visible_idle_missing
- assert visible_idle_missing["runtime_idle_detector"]["approved"] is False, visible_idle_missing
- assert visible_idle_missing["candidate_command"] is None, visible_idle_missing
-
- visible_candidate = build_tick(
- REMOTE_RESUME_HELP_FIXTURE,
- proof_payload=VISIBLE_PROOF_FIXTURE,
- idle_payload=RUNTIME_IDLE_FIXTURE,
- )
- assert_boundary(visible_candidate)
- assert visible_candidate["scheduler_action"] == "external_visible_command_candidate", visible_candidate
- assert "codex resume public-session-id" in visible_candidate["candidate_command"], visible_candidate
- assert visible_candidate["runtime_idle_detector"]["approved"] is True, visible_candidate
-
- hinted_tick = build_tick(FALLBACK_HELP_FIXTURE, quota_payload=QUOTA_HINT_FIXTURE)
- assert hinted_tick["scheduler_hint"]["action"] == "backoff_until_reassigned", hinted_tick
- assert hinted_tick["launchd"]["recommended_interval_seconds"] == 600, hinted_tick
- assert hinted_tick["launchd"]["reset_token"] == "fixture-reset-001", hinted_tick
- assert hinted_tick["launchd"]["reset_interval_seconds"] == 600, hinted_tick
- assert hinted_tick["launchd"]["reset_policy"]["codex_app_initial_rrule"] == "FREQ=MINUTELY;INTERVAL=10", hinted_tick
- assert hinted_tick["scheduler_hint"]["codex_app"]["example_progression_minutes"] == [10, 20, 30, 60], hinted_tick
- assert hinted_tick["scheduler_hint"]["unchanged_poll"]["final_quota_replan_check_enabled"] is True, hinted_tick
-
- with tempfile.TemporaryDirectory(prefix="loopx-codex-cli-scheduler-tick-") as tmp:
- tmp_path = Path(tmp)
- help_fixture = tmp_path / "codex-remote-help.json"
- help_fixture.write_text(json.dumps({"command_outputs": REMOTE_RESUME_HELP_FIXTURE}))
- proof_fixture = tmp_path / "visible-proof.json"
- proof_fixture.write_text(json.dumps(VISIBLE_PROOF_FIXTURE))
- idle_fixture = tmp_path / "runtime-idle.json"
- idle_fixture.write_text(json.dumps(RUNTIME_IDLE_FIXTURE))
- quota_fixture = tmp_path / "quota.json"
- quota_fixture.write_text(json.dumps(QUOTA_HINT_FIXTURE))
- missing_registry = tmp_path / "missing-registry.json"
- runtime_root = tmp_path / "runtime"
-
- cli_json = json.loads(
- run_cli(
- "--registry",
- str(missing_registry),
- "--runtime-root",
- str(runtime_root),
- "--format",
- "json",
- "codex-cli-local-scheduler-tick",
- "--project",
- str(PROJECT),
- "--goal-id",
- GOAL_ID,
- "--agent-id",
- AGENT_ID,
- "--fixture",
- str(help_fixture),
- "--quota-fixture",
- str(quota_fixture),
- )
- )
- assert_boundary(cli_json)
- assert cli_json["scheduler_action"] == "write_precise_blocker", cli_json
- assert cli_json["scheduler_hint"]["action"] == "backoff_until_reassigned", cli_json
- assert cli_json["launchd"]["recommended_interval_seconds"] == 600, cli_json
-
- cli_proof_json = json.loads(
- run_cli(
- "--format",
- "json",
- "codex-cli-local-scheduler-tick",
- "--project",
- str(PROJECT),
- "--goal-id",
- GOAL_ID,
- "--agent-id",
- AGENT_ID,
- "--fixture",
- str(help_fixture),
- "--proof-fixture",
- str(proof_fixture),
- )
- )
- assert_boundary(cli_proof_json)
- assert cli_proof_json["scheduler_action"] == "write_precise_blocker", cli_proof_json
- assert cli_proof_json["precise_blocker"]["reason"] == "runtime_idle_evidence_missing", cli_proof_json
-
- cli_proof_idle_json = json.loads(
- run_cli(
- "--format",
- "json",
- "codex-cli-local-scheduler-tick",
- "--project",
- str(PROJECT),
- "--goal-id",
- GOAL_ID,
- "--agent-id",
- AGENT_ID,
- "--fixture",
- str(help_fixture),
- "--proof-fixture",
- str(proof_fixture),
- "--idle-fixture",
- str(idle_fixture),
- )
- )
- assert_boundary(cli_proof_idle_json)
- assert cli_proof_idle_json["scheduler_action"] == "external_visible_command_candidate", cli_proof_idle_json
- assert cli_proof_idle_json["runtime_idle_detector"]["approved"] is True, cli_proof_idle_json
-
- cli_markdown = run_cli(
- "codex-cli-local-scheduler-tick",
- "--project",
- str(PROJECT),
- "--goal-id",
- GOAL_ID,
- "--agent-id",
- AGENT_ID,
- "--fixture",
- str(help_fixture),
- "--quota-fixture",
- str(quota_fixture),
- )
- assert "# Codex CLI Local Scheduler Tick" in cli_markdown, cli_markdown
- assert "scheduler_action: `write_precise_blocker`" in cli_markdown, cli_markdown
- assert "local_progression_minutes: `[10, 20, 30, 60]`" in cli_markdown, cli_markdown
- assert "local_unchanged_poll_limit: `3`" in cli_markdown, cli_markdown
- assert "final_quota_replan_check:" in cli_markdown, cli_markdown
- assert "runs_codex: `False`" in cli_markdown, cli_markdown
-
- print("codex-cli-local-scheduler-tick-smoke ok")
- return 0
-
-
-if __name__ == "__main__":
- raise SystemExit(main())
diff --git a/examples/codex-cli-one-message-loop-pilot-smoke.py b/examples/codex-cli-one-message-loop-pilot-smoke.py
deleted file mode 100644
index 9be5cafa6a..0000000000
--- a/examples/codex-cli-one-message-loop-pilot-smoke.py
+++ /dev/null
@@ -1,277 +0,0 @@
-#!/usr/bin/env python3
-"""Smoke-test the Codex CLI one-message loop pilot packet."""
-
-from __future__ import annotations
-
-import json
-import subprocess
-import sys
-import tempfile
-from pathlib import Path
-
-
-REPO_ROOT = Path(__file__).resolve().parents[1]
-if str(REPO_ROOT) not in sys.path:
- sys.path.insert(0, str(REPO_ROOT))
-
-from loopx.codex_cli_probe import ( # noqa: E402
- build_codex_cli_one_message_loop_pilot,
- classify_codex_cli_session_surface,
-)
-
-
-PROJECT = Path("/tmp/public-codex-cli-project")
-GOAL_ID = "public-codex-cli-goal"
-AGENT_ID = "codex-side-bypass"
-
-
-REMOTE_RESUME_HELP_FIXTURE = {
- "root": """
-Usage: codex [OPTIONS] [PROMPT]
-
-Commands:
- exec
- remote-control Manage the app-server daemon with remote control enabled
- resume Resume a previous interactive session
-
-Options:
- --remote