@@ -286,6 +286,8 @@ def test_command_reference_does_not_require_default_runtime_route(
286286 (["global-risks" , "--help" ], "loopx.cli_commands.summary_all_registration" , "loopx.cli_commands.summary_all" ),
287287 (["turn" , "--help" ], "loopx.cli_commands.turn_registration" , "loopx.cli_commands.turn" ),
288288 (["turn" , "run-once" , "--help" ], "loopx.cli_commands.turn_registration" , "loopx.cli_commands.turn" ),
289+ * [( [command , "--help" ], "loopx.cli_commands.project_lifecycle" , "loopx.cli_commands.project_lifecycle" )
290+ for command in ("refresh-state" , "checkpoint-context" , "read-only-map" , "reward" , "operator-gate" )],
289291 ],
290292)
291293def test_common_command_help_loads_only_its_owner (
@@ -413,6 +415,12 @@ def test_quota_facade_lazy_exports_preserve_owner_identity() -> None:
413415
414416def test_selected_parser_matches_full_help_and_diagnostics () -> None :
415417 argv_cases = [
418+ * [[command , flag ] for command in
419+ ("refresh-state" , "checkpoint-context" , "read-only-map" , "reward" , "operator-gate" )
420+ for flag in ("--help" , "--unknown-option" )],
421+ ["refresh-state" , "--goal-id" , "goal" , "--delivery-outcome" , "invalid" ],
422+ ["checkpoint-context" , "--goal-id" , "goal" , "--agent-id" , "agent" , "--turn-instance-id" , "turn" ,
423+ "--todo-id" , "todo_work" , "--replan-obligation-id" , "replan" ],
416424 ["commands" , "--help" ],
417425 ["commands" , "--format" , "json" ],
418426 ["commands" , "--format" , "markdown" ],
@@ -487,6 +495,48 @@ def test_selected_manager_inbox_refusals_match_without_loading_full_cli(tmp_path
487495 assert json .loads (selected .stdout )["ok" ] is False
488496
489497
498+ @pytest .mark .parametrize ("arguments" , [
499+ ["refresh-state" , "--dry-run" ],
500+ ["checkpoint-context" , "--agent-id" , "perf-agent" , "--turn-instance-id" , "missing" , "--todo-id" , "todo_missing" ],
501+ ["read-only-map" ],
502+ ["reward" , "--decision" , "continue_route" , "--reward" , "positive" , "--reason-summary" , "Checked evidence" , "--dry-run" ],
503+ ["operator-gate" , "--decision" , "approve" , "--reason-summary" , "Checked evidence" , "--dry-run" ],
504+ ])
505+ def test_selected_lifecycle_refusals_match_without_full_cli (tmp_path , arguments ):
506+ registry , runtime = write_command_fixture (tmp_path )
507+ before = registry .read_bytes ()
508+ argv = ["--registry" , str (registry ), "--runtime-root" , str (runtime ), "--format" , "json" ,
509+ * arguments , "--goal-id" , "missing-goal" ]
510+ selected = run_cli_main ("loopx.entrypoint" , argv , forbidden_modules = ("loopx.cli" ,))
511+ full = run_cli_main ("loopx.cli" , argv )
512+ assert selected .returncode == full .returncode == 1
513+ assert selected .stdout == full .stdout
514+ assert selected .stderr == full .stderr
515+ assert json .loads (selected .stdout )["ok" ] is False
516+ assert registry .read_bytes () == before
517+
518+
519+ @pytest .mark .parametrize ("provider" , ["file" , "sqlite" ])
520+ def test_selected_refresh_preview_keeps_canonical_state_without_full_cli (tmp_path , monkeypatch , provider ):
521+ from tests .control_plane .canonical_authority_fixture import initialize_canonical_source_fixture , isolate_sqlite_runtime
522+ from loopx .control_plane .coordination .local_authority import read_canonical_todos_if_promoted
523+
524+ isolate_sqlite_runtime (tmp_path , monkeypatch )
525+ registry , runtime = write_command_fixture (tmp_path )
526+ state = registry .parent .parent / ".codex/goals/perf-goal/ACTIVE_GOAL_STATE.md"
527+ initialize_canonical_source_fixture (runtime , "perf-goal" , state_path = state , provider = provider )
528+ before = state .read_bytes (), read_canonical_todos_if_promoted (runtime_root = runtime , goal_id = "perf-goal" )
529+ argv = ["--registry" , str (registry ), "--runtime-root" , str (runtime ), "--format" , "json" ,
530+ "refresh-state" , "--goal-id" , "perf-goal" , "--agent-id" , "perf-agent" ,
531+ "--next-action" , "Continue bounded fixture work." , "--no-global-sync" , "--dry-run" ]
532+ for module in ("loopx.entrypoint" , "loopx.cli" ):
533+ result = run_cli_main (module , argv , forbidden_modules = ("loopx.cli" ,) if module == "loopx.entrypoint" else ())
534+ assert result .returncode == 0 , result .stderr
535+ payload = json .loads (result .stdout )
536+ assert payload ["ok" ] and payload ["dry_run" ]
537+ assert (state .read_bytes (), read_canonical_todos_if_promoted (runtime_root = runtime , goal_id = "perf-goal" )) == before
538+
539+
490540def test_selected_manager_result_matches_full_replay_without_loading_full_cli (tmp_path ):
491541 from test_collaboration_goal_instance import _create_source_registry , _manager_request
492542 from loopx .control_plane .collaboration .inbox import _root , acknowledge
0 commit comments