@team-agent/installer 0.5.128 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/README.zh.md +1 -1
- package/package.json +4 -8
- package/skills/team-agent/SKILL.md +37 -20
- package/skills/team-agent/command-coverage.json +169 -183
- package/skills/team-agent/docs/reference/team-agent-operator.md +64 -30
- package/skills/team-agent/references/recovery-runbook.md +1 -1
- package/skills/team-agent/references/team-agent-operator.md +64 -30
- package/templates/team_state.md +1 -1
- package/Cargo.lock +0 -1063
- package/Cargo.toml +0 -36
- package/crates/team-agent/Cargo.toml +0 -69
- package/crates/team-agent/src/app_server_test_support.rs +0 -258
- package/crates/team-agent/src/cli/adapters.rs +0 -1288
- package/crates/team-agent/src/cli/arguments.rs +0 -405
- package/crates/team-agent/src/cli/attach_app_server_leader.rs +0 -98
- package/crates/team-agent/src/cli/diagnose.rs +0 -1721
- package/crates/team-agent/src/cli/emit.rs +0 -2930
- package/crates/team-agent/src/cli/grok_slot.rs +0 -384
- package/crates/team-agent/src/cli/helpers.rs +0 -91
- package/crates/team-agent/src/cli/intent/runtime.rs +0 -1216
- package/crates/team-agent/src/cli/intent/runtime_tests.rs +0 -912
- package/crates/team-agent/src/cli/intent/tests.rs +0 -689
- package/crates/team-agent/src/cli/intent.rs +0 -664
- package/crates/team-agent/src/cli/leader.rs +0 -300
- package/crates/team-agent/src/cli/leader_prompt.rs +0 -261
- package/crates/team-agent/src/cli/leaders.rs +0 -418
- package/crates/team-agent/src/cli/mod.rs +0 -6545
- package/crates/team-agent/src/cli/models.rs +0 -1206
- package/crates/team-agent/src/cli/named_address.rs +0 -1651
- package/crates/team-agent/src/cli/profile.rs +0 -342
- package/crates/team-agent/src/cli/route.rs +0 -212
- package/crates/team-agent/src/cli/schedule.rs +0 -175
- package/crates/team-agent/src/cli/send/coordinator.rs +0 -164
- package/crates/team-agent/src/cli/send/mailbox.rs +0 -145
- package/crates/team-agent/src/cli/send/persist.rs +0 -156
- package/crates/team-agent/src/cli/send/presentation.rs +0 -370
- package/crates/team-agent/src/cli/send/resolve.rs +0 -573
- package/crates/team-agent/src/cli/send.rs +0 -199
- package/crates/team-agent/src/cli/shutdown_socket.rs +0 -288
- package/crates/team-agent/src/cli/spec.rs +0 -165
- package/crates/team-agent/src/cli/status.rs +0 -280
- package/crates/team-agent/src/cli/status_port/agents.rs +0 -358
- package/crates/team-agent/src/cli/status_port/approvals.rs +0 -79
- package/crates/team-agent/src/cli/status_port/brief.rs +0 -1981
- package/crates/team-agent/src/cli/status_port/compact.rs +0 -240
- package/crates/team-agent/src/cli/status_port/format.rs +0 -146
- package/crates/team-agent/src/cli/status_port/inbox.rs +0 -62
- package/crates/team-agent/src/cli/status_port/runtime.rs +0 -197
- package/crates/team-agent/src/cli/status_port/snapshot.rs +0 -208
- package/crates/team-agent/src/cli/status_port/store.rs +0 -416
- package/crates/team-agent/src/cli/status_port/tests.rs +0 -90
- package/crates/team-agent/src/cli/status_port.rs +0 -92
- package/crates/team-agent/src/cli/tests/base.rs +0 -885
- package/crates/team-agent/src/cli/tests/divergence.rs +0 -518
- package/crates/team-agent/src/cli/tests/lane_c.rs +0 -453
- package/crates/team-agent/src/cli/tests/leader_watch.rs +0 -322
- package/crates/team-agent/src/cli/tests/main_preserved.rs +0 -430
- package/crates/team-agent/src/cli/tests/missing_subcommands.rs +0 -336
- package/crates/team-agent/src/cli/tests/mod.rs +0 -137
- package/crates/team-agent/src/cli/tests/named_address.rs +0 -761
- package/crates/team-agent/src/cli/tests/parser_safety.rs +0 -383
- package/crates/team-agent/src/cli/tests/run_delegation.rs +0 -484
- package/crates/team-agent/src/cli/tests/shutdown_kill_plan.rs +0 -2179
- package/crates/team-agent/src/cli/tests/status_brief.rs +0 -1514
- package/crates/team-agent/src/cli/tests/status_send.rs +0 -888
- package/crates/team-agent/src/cli/tests/verb_install_skill.rs +0 -93
- package/crates/team-agent/src/cli/tests/verb_profile.rs +0 -392
- package/crates/team-agent/src/cli/triage.rs +0 -234
- package/crates/team-agent/src/cli/types.rs +0 -591
- package/crates/team-agent/src/codex_app_server.rs +0 -546
- package/crates/team-agent/src/communication_mode/mod.rs +0 -56
- package/crates/team-agent/src/compiler/tests.rs +0 -827
- package/crates/team-agent/src/compiler.rs +0 -890
- package/crates/team-agent/src/conpty/backend.rs +0 -829
- package/crates/team-agent/src/conpty/mod.rs +0 -33
- package/crates/team-agent/src/contract_runtime/backend.rs +0 -1744
- package/crates/team-agent/src/contract_runtime/commands.rs +0 -671
- package/crates/team-agent/src/contract_runtime/config.rs +0 -364
- package/crates/team-agent/src/contract_runtime/config_tests.rs +0 -76
- package/crates/team-agent/src/contract_runtime/discovery.rs +0 -449
- package/crates/team-agent/src/contract_runtime/fork.rs +0 -361
- package/crates/team-agent/src/contract_runtime/forward.rs +0 -288
- package/crates/team-agent/src/contract_runtime/framework.rs +0 -367
- package/crates/team-agent/src/contract_runtime/mcp.rs +0 -394
- package/crates/team-agent/src/contract_runtime/mod.rs +0 -17
- package/crates/team-agent/src/contract_runtime/prompt.rs +0 -216
- package/crates/team-agent/src/contract_runtime/pump.rs +0 -271
- package/crates/team-agent/src/contract_runtime/registry.rs +0 -553
- package/crates/team-agent/src/contract_runtime/workspace.rs +0 -228
- package/crates/team-agent/src/coordinator/backoff.rs +0 -741
- package/crates/team-agent/src/coordinator/conpty_shim.rs +0 -805
- package/crates/team-agent/src/coordinator/health.rs +0 -1185
- package/crates/team-agent/src/coordinator/mod.rs +0 -119
- package/crates/team-agent/src/coordinator/orphan.rs +0 -110
- package/crates/team-agent/src/coordinator/runtime_detectors.rs +0 -798
- package/crates/team-agent/src/coordinator/runtime_observation.rs +0 -84
- package/crates/team-agent/src/coordinator/steps/abnormal.rs +0 -2309
- package/crates/team-agent/src/coordinator/steps/delivery.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/health_sync.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/mod.rs +0 -126
- package/crates/team-agent/src/coordinator/steps/persist.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/runtime_prompts.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/session_gate.rs +0 -16
- package/crates/team-agent/src/coordinator/tests/a0_lostupdate.rs +0 -158
- package/crates/team-agent/src/coordinator/tests/abnormal.rs +0 -312
- package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +0 -300
- package/crates/team-agent/src/coordinator/tests/basics.rs +0 -211
- package/crates/team-agent/src/coordinator/tests/daemon.rs +0 -514
- package/crates/team-agent/src/coordinator/tests/energy.rs +0 -549
- package/crates/team-agent/src/coordinator/tests/health_sync.rs +0 -503
- package/crates/team-agent/src/coordinator/tests/main_preserved.rs +0 -186
- package/crates/team-agent/src/coordinator/tests/mod.rs +0 -295
- package/crates/team-agent/src/coordinator/tests/s3_bounded.rs +0 -207
- package/crates/team-agent/src/coordinator/tests/spine.rs +0 -308
- package/crates/team-agent/src/coordinator/tests/takeover.rs +0 -286
- package/crates/team-agent/src/coordinator/tests/tick_core.rs +0 -237
- package/crates/team-agent/src/coordinator/tick.rs +0 -3024
- package/crates/team-agent/src/coordinator/types.rs +0 -540
- package/crates/team-agent/src/db/agent_health_capture.rs +0 -126
- package/crates/team-agent/src/db/message_store.rs +0 -1527
- package/crates/team-agent/src/db/migration.rs +0 -984
- package/crates/team-agent/src/db/mod.rs +0 -26
- package/crates/team-agent/src/db/schema.rs +0 -663
- package/crates/team-agent/src/diagnose/comms.rs +0 -242
- package/crates/team-agent/src/diagnose/mod.rs +0 -44
- package/crates/team-agent/src/diagnose/orphans.rs +0 -889
- package/crates/team-agent/src/direct_delivery.rs +0 -368
- package/crates/team-agent/src/event_log.rs +0 -502
- package/crates/team-agent/src/fake_worker.rs +0 -303
- package/crates/team-agent/src/inbox_store.rs +0 -169
- package/crates/team-agent/src/kill_audit.rs +0 -106
- package/crates/team-agent/src/layout/manager.rs +0 -248
- package/crates/team-agent/src/layout/mod.rs +0 -36
- package/crates/team-agent/src/layout/overlay.rs +0 -134
- package/crates/team-agent/src/layout/placement.rs +0 -52
- package/crates/team-agent/src/layout/recovery.rs +0 -106
- package/crates/team-agent/src/layout/runtime_sessions.rs +0 -317
- package/crates/team-agent/src/layout/sessions.rs +0 -294
- package/crates/team-agent/src/layout/tmux_endpoint.rs +0 -165
- package/crates/team-agent/src/layout/worker_env.rs +0 -721
- package/crates/team-agent/src/layout/worker_window_helpers.rs +0 -37
- package/crates/team-agent/src/leader/helpers.rs +0 -178
- package/crates/team-agent/src/leader/incident.rs +0 -6
- package/crates/team-agent/src/leader/lease.rs +0 -3356
- package/crates/team-agent/src/leader/mod.rs +0 -104
- package/crates/team-agent/src/leader/owner_bind.rs +0 -400
- package/crates/team-agent/src/leader/prompt.rs +0 -905
- package/crates/team-agent/src/leader/provider_attribution.rs +0 -247
- package/crates/team-agent/src/leader/rediscover/tests.rs +0 -689
- package/crates/team-agent/src/leader/rediscover.rs +0 -1192
- package/crates/team-agent/src/leader/registry.rs +0 -888
- package/crates/team-agent/src/leader/start.rs +0 -4501
- package/crates/team-agent/src/leader/takeover.rs +0 -65
- package/crates/team-agent/src/leader/tests/basics.rs +0 -337
- package/crates/team-agent/src/leader/tests/byte_findings.rs +0 -355
- package/crates/team-agent/src/leader/tests/claim_leader_mailbox_flush_contract.rs +0 -544
- package/crates/team-agent/src/leader/tests/historical_inventory_upgrade_gate_red.rs +0 -624
- package/crates/team-agent/src/leader/tests/identity.rs +0 -465
- package/crates/team-agent/src/leader/tests/identity_session_names.rs +0 -42
- package/crates/team-agent/src/leader/tests/idle.rs +0 -113
- package/crates/team-agent/src/leader/tests/lease_api.rs +0 -520
- package/crates/team-agent/src/leader/tests/lease_claim.rs +0 -629
- package/crates/team-agent/src/leader/tests/mod.rs +0 -106
- package/crates/team-agent/src/leader/tests/prompt_contract.rs +0 -268
- package/crates/team-agent/src/leader/tests/rediscover.rs +0 -403
- package/crates/team-agent/src/leader/tests/rehomed_env.rs +0 -83
- package/crates/team-agent/src/leader/tests/team_in_team_state_scope_red.rs +0 -1273
- package/crates/team-agent/src/leader/tests/terminal_and_replay_vs_rerender_invariants_red.rs +0 -417
- package/crates/team-agent/src/leader/tests/wake_start_owner.rs +0 -168
- package/crates/team-agent/src/leader/types.rs +0 -534
- package/crates/team-agent/src/lib.rs +0 -147
- package/crates/team-agent/src/lifecycle/helpers.rs +0 -212
- package/crates/team-agent/src/lifecycle/launch/add_agent.rs +0 -881
- package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +0 -598
- package/crates/team-agent/src/lifecycle/launch/agent_state.rs +0 -332
- package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +0 -204
- package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +0 -107
- package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +0 -144
- package/crates/team-agent/src/lifecycle/launch/identity.rs +0 -674
- package/crates/team-agent/src/lifecycle/launch/layout.rs +0 -350
- package/crates/team-agent/src/lifecycle/launch/leader_context.rs +0 -589
- package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +0 -160
- package/crates/team-agent/src/lifecycle/launch/ownership.rs +0 -105
- package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +0 -899
- package/crates/team-agent/src/lifecycle/launch/pi_mcp_extension.js +0 -225
- package/crates/team-agent/src/lifecycle/launch/plan.rs +0 -269
- package/crates/team-agent/src/lifecycle/launch/quick_start.rs +0 -5200
- package/crates/team-agent/src/lifecycle/launch/quick_start_transport.rs +0 -368
- package/crates/team-agent/src/lifecycle/launch/readiness.rs +0 -519
- package/crates/team-agent/src/lifecycle/launch/role_source.rs +0 -287
- package/crates/team-agent/src/lifecycle/launch/spawn.rs +0 -473
- package/crates/team-agent/src/lifecycle/launch/spec_state.rs +0 -801
- package/crates/team-agent/src/lifecycle/launch/state_projection.rs +0 -624
- package/crates/team-agent/src/lifecycle/launch/worker_env.rs +0 -558
- package/crates/team-agent/src/lifecycle/launch.rs +0 -557
- package/crates/team-agent/src/lifecycle/lock.rs +0 -350
- package/crates/team-agent/src/lifecycle/mod.rs +0 -79
- package/crates/team-agent/src/lifecycle/pane_input_lock.rs +0 -239
- package/crates/team-agent/src/lifecycle/profile_launch.rs +0 -1067
- package/crates/team-agent/src/lifecycle/profile_smoke.rs +0 -557
- package/crates/team-agent/src/lifecycle/restart/agent.rs +0 -2199
- package/crates/team-agent/src/lifecycle/restart/avatar.rs +0 -1798
- package/crates/team-agent/src/lifecycle/restart/claude_fork.rs +0 -163
- package/crates/team-agent/src/lifecycle/restart/common.rs +0 -2362
- package/crates/team-agent/src/lifecycle/restart/orchestrator.rs +0 -65
- package/crates/team-agent/src/lifecycle/restart/preflight.rs +0 -113
- package/crates/team-agent/src/lifecycle/restart/rebuild.rs +0 -5135
- package/crates/team-agent/src/lifecycle/restart/remove.rs +0 -1504
- package/crates/team-agent/src/lifecycle/restart/selection.rs +0 -559
- package/crates/team-agent/src/lifecycle/restart/team_state.rs +0 -329
- package/crates/team-agent/src/lifecycle/restart.rs +0 -227
- package/crates/team-agent/src/lifecycle/role_config.rs +0 -1230
- package/crates/team-agent/src/lifecycle/tests/acceptance_b_batch_red.rs +0 -1021
- package/crates/team-agent/src/lifecycle/tests/agent_ops.rs +0 -1205
- package/crates/team-agent/src/lifecycle/tests/b0_legacy_snapshot_nonauthority_contract.rs +0 -265
- package/crates/team-agent/src/lifecycle/tests/b0_reader_hideone_audit_contract.rs +0 -490
- package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +0 -656
- package/crates/team-agent/src/lifecycle/tests/claude_compatible_config_red.rs +0 -325
- package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +0 -447
- package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +0 -1638
- package/crates/team-agent/src/lifecycle/tests/clone_agent_preserves_source_tools.rs +0 -427
- package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +0 -770
- package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +0 -419
- package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +0 -2035
- package/crates/team-agent/src/lifecycle/tests/core.rs +0 -1327
- package/crates/team-agent/src/lifecycle/tests/f032_startup_prompt_best_effort_red.rs +0 -315
- package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_g0.stdout.txt +0 -222
- package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_spaced_ids.stdout.txt +0 -9
- package/crates/team-agent/src/lifecycle/tests/fixtures/pi_native_mcp_host.mjs +0 -72
- package/crates/team-agent/src/lifecycle/tests/gate_fixtures.rs +0 -562
- package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +0 -110
- package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +0 -512
- package/crates/team-agent/src/lifecycle/tests/host_cotenant_death_p0_contract.rs +0 -921
- package/crates/team-agent/src/lifecycle/tests/issue238_codex_effort_contract.rs +0 -68
- package/crates/team-agent/src/lifecycle/tests/lane_ops.rs +0 -1851
- package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +0 -3983
- package/crates/team-agent/src/lifecycle/tests/lifecycle_lock.rs +0 -339
- package/crates/team-agent/src/lifecycle/tests/lifecycle_rollback_red.rs +0 -596
- package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +0 -513
- package/crates/team-agent/src/lifecycle/tests/mcp_tool_name_format_red.rs +0 -69
- package/crates/team-agent/src/lifecycle/tests/phase_b_contracts.rs +0 -824
- package/crates/team-agent/src/lifecycle/tests/phase_golden.rs +0 -723
- package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +0 -164
- package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +0 -200
- package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +0 -210
- package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +0 -527
- package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +0 -1062
- package/crates/team-agent/src/lifecycle/tests/pi_fork_session_inheritance_red.rs +0 -1419
- package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +0 -98
- package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +0 -550
- package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +0 -226
- package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +0 -332
- package/crates/team-agent/src/lifecycle/tests/realmachine_clusters_1_6_red.rs +0 -786
- package/crates/team-agent/src/lifecycle/tests/realmachine_residual_g1_g4_red.rs +0 -648
- package/crates/team-agent/src/lifecycle/tests/restart.rs +0 -185
- package/crates/team-agent/src/lifecycle/tests/restart_build_before_destroy_0540_contract.rs +0 -1053
- package/crates/team-agent/src/lifecycle/tests/restart_liveness_red.rs +0 -679
- package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +0 -1126
- package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +0 -153
- package/crates/team-agent/src/lifecycle/tests/resume_recover_red.rs +0 -427
- package/crates/team-agent/src/lifecycle/tests/stale_team_saveconflict_contract.rs +0 -431
- package/crates/team-agent/src/lifecycle/tests/startup_latency_contract.rs +0 -1066
- package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +0 -876
- package/crates/team-agent/src/lifecycle/tests/subprep_codex_trust_roundtrip_red.rs +0 -1026
- package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +0 -342
- package/crates/team-agent/src/lifecycle/tests/team_in_team_identity_scope_red.rs +0 -543
- package/crates/team-agent/src/lifecycle/tests/team_in_team_sibling_quick_start_red.rs +0 -1103
- package/crates/team-agent/src/lifecycle/tests/team_in_team_state_scope_red.rs +0 -1276
- package/crates/team-agent/src/lifecycle/tests/team_key_retirement_roster_red.rs +0 -145
- package/crates/team-agent/src/lifecycle/tests/team_key_retirement_txn_red.rs +0 -603
- package/crates/team-agent/src/lifecycle/tests/test_isolation_escape_contract.rs +0 -936
- package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +0 -970
- package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +0 -995
- package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +0 -836
- package/crates/team-agent/src/lifecycle/tests.rs +0 -105
- package/crates/team-agent/src/lifecycle/types.rs +0 -877
- package/crates/team-agent/src/lifecycle/worker_command_context.rs +0 -363
- package/crates/team-agent/src/main.rs +0 -52
- package/crates/team-agent/src/mcp_server/helpers.rs +0 -510
- package/crates/team-agent/src/mcp_server/lifecycle_tools/mod.rs +0 -6
- package/crates/team-agent/src/mcp_server/lifecycle_tools/state_status.rs +0 -43
- package/crates/team-agent/src/mcp_server/mod.rs +0 -119
- package/crates/team-agent/src/mcp_server/normalize.rs +0 -485
- package/crates/team-agent/src/mcp_server/readiness.rs +0 -527
- package/crates/team-agent/src/mcp_server/readiness_tests.rs +0 -348
- package/crates/team-agent/src/mcp_server/tests/golden.rs +0 -285
- package/crates/team-agent/src/mcp_server/tests/normalize.rs +0 -247
- package/crates/team-agent/src/mcp_server/tests/scoped.rs +0 -158
- package/crates/team-agent/src/mcp_server/tests/send.rs +0 -353
- package/crates/team-agent/src/mcp_server/tests/tools.rs +0 -341
- package/crates/team-agent/src/mcp_server/tests/wire.rs +0 -254
- package/crates/team-agent/src/mcp_server/tests.rs +0 -43
- package/crates/team-agent/src/mcp_server/tools.rs +0 -889
- package/crates/team-agent/src/mcp_server/types.rs +0 -396
- package/crates/team-agent/src/mcp_server/wire.rs +0 -867
- package/crates/team-agent/src/messaging/activity.rs +0 -461
- package/crates/team-agent/src/messaging/address.rs +0 -87
- package/crates/team-agent/src/messaging/delivery.rs +0 -3727
- package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +0 -234
- package/crates/team-agent/src/messaging/enter_rescue.rs +0 -362
- package/crates/team-agent/src/messaging/enter_rescue_tests.rs +0 -633
- package/crates/team-agent/src/messaging/helpers.rs +0 -336
- package/crates/team-agent/src/messaging/leader_channel.rs +0 -287
- package/crates/team-agent/src/messaging/leader_receiver.rs +0 -786
- package/crates/team-agent/src/messaging/mod.rs +0 -167
- package/crates/team-agent/src/messaging/persist.rs +0 -377
- package/crates/team-agent/src/messaging/presentation.rs +0 -417
- package/crates/team-agent/src/messaging/reminders.rs +0 -316
- package/crates/team-agent/src/messaging/results/collection_tests.rs +0 -719
- package/crates/team-agent/src/messaging/results.rs +0 -1415
- package/crates/team-agent/src/messaging/scheduler.rs +0 -223
- package/crates/team-agent/src/messaging/selftest.rs +0 -315
- package/crates/team-agent/src/messaging/send.rs +0 -981
- package/crates/team-agent/src/messaging/tests/basic.rs +0 -346
- package/crates/team-agent/src/messaging/tests/dup_inject.rs +0 -657
- package/crates/team-agent/src/messaging/tests/e23.rs +0 -49
- package/crates/team-agent/src/messaging/tests/leader_channel.rs +0 -169
- package/crates/team-agent/src/messaging/tests/leader_inject_acceptance.rs +0 -817
- package/crates/team-agent/src/messaging/tests/main_preserved.rs +0 -85
- package/crates/team-agent/src/messaging/tests/mod.rs +0 -306
- package/crates/team-agent/src/messaging/tests/runtime.rs +0 -3549
- package/crates/team-agent/src/messaging/tests/spine.rs +0 -853
- package/crates/team-agent/src/messaging/tests/wave2.rs +0 -381
- package/crates/team-agent/src/messaging/trust.rs +0 -215
- package/crates/team-agent/src/messaging/types.rs +0 -472
- package/crates/team-agent/src/messaging/wait.rs +0 -366
- package/crates/team-agent/src/messaging/watchers.rs +0 -916
- package/crates/team-agent/src/model/enums.rs +0 -356
- package/crates/team-agent/src/model/errors.rs +0 -18
- package/crates/team-agent/src/model/ids.rs +0 -165
- package/crates/team-agent/src/model/mod.rs +0 -29
- package/crates/team-agent/src/model/name_similarity.rs +0 -252
- package/crates/team-agent/src/model/pane_authority_refusal.rs +0 -359
- package/crates/team-agent/src/model/paths.rs +0 -257
- package/crates/team-agent/src/model/routing.rs +0 -387
- package/crates/team-agent/src/model/spec.rs +0 -1184
- package/crates/team-agent/src/model/task_graph.rs +0 -321
- package/crates/team-agent/src/model/testdata/fuzz.golden.yaml +0 -43
- package/crates/team-agent/src/model/testdata/fuzz.yaml +0 -43
- package/crates/team-agent/src/model/testdata/spec_invalid_a.yaml +0 -209
- package/crates/team-agent/src/model/testdata/team.spec.golden.yaml +0 -208
- package/crates/team-agent/src/model/testdata/team.spec.yaml +0 -208
- package/crates/team-agent/src/model/yaml/tests.rs +0 -188
- package/crates/team-agent/src/model/yaml.rs +0 -802
- package/crates/team-agent/src/os_probe.rs +0 -280
- package/crates/team-agent/src/packaging/install.rs +0 -219
- package/crates/team-agent/src/packaging/migrate.rs +0 -38
- package/crates/team-agent/src/packaging/mod.rs +0 -91
- package/crates/team-agent/src/packaging/repair.rs +0 -33
- package/crates/team-agent/src/packaging/tests.rs +0 -822
- package/crates/team-agent/src/packaging/types.rs +0 -417
- package/crates/team-agent/src/platform/argv.rs +0 -331
- package/crates/team-agent/src/platform/errors.rs +0 -104
- package/crates/team-agent/src/platform/file_lock.rs +0 -279
- package/crates/team-agent/src/platform/mod.rs +0 -5
- package/crates/team-agent/src/platform/process.rs +0 -545
- package/crates/team-agent/src/provider/adapter.rs +0 -1150
- package/crates/team-agent/src/provider/adapters/claude.rs +0 -78
- package/crates/team-agent/src/provider/adapters/claude_fork.rs +0 -131
- package/crates/team-agent/src/provider/adapters/copilot.rs +0 -75
- package/crates/team-agent/src/provider/adapters/copilot_fork.rs +0 -307
- package/crates/team-agent/src/provider/adapters/fake.rs +0 -18
- package/crates/team-agent/src/provider/adapters/mod.rs +0 -30
- package/crates/team-agent/src/provider/adapters/pi.rs +0 -106
- package/crates/team-agent/src/provider/approvals/mod.rs +0 -3
- package/crates/team-agent/src/provider/approvals/parsing.rs +0 -586
- package/crates/team-agent/src/provider/approvals/runtime_prompts.rs +0 -205
- package/crates/team-agent/src/provider/argv_route.rs +0 -405
- package/crates/team-agent/src/provider/bypass_flags.rs +0 -116
- package/crates/team-agent/src/provider/classify.rs +0 -708
- package/crates/team-agent/src/provider/command_helpers.rs +0 -45
- package/crates/team-agent/src/provider/faults.rs +0 -165
- package/crates/team-agent/src/provider/helpers.rs +0 -52
- package/crates/team-agent/src/provider/mod.rs +0 -78
- package/crates/team-agent/src/provider/model_catalog.rs +0 -910
- package/crates/team-agent/src/provider/session/capture.rs +0 -2731
- package/crates/team-agent/src/provider/session/context_fork/claude.rs +0 -123
- package/crates/team-agent/src/provider/session/context_fork/outcome.rs +0 -172
- package/crates/team-agent/src/provider/session/context_fork.rs +0 -396
- package/crates/team-agent/src/provider/session/mod.rs +0 -36
- package/crates/team-agent/src/provider/session/resume.rs +0 -269
- package/crates/team-agent/src/provider/session_scan/claude.rs +0 -523
- package/crates/team-agent/src/provider/session_scan/common/tests.rs +0 -316
- package/crates/team-agent/src/provider/session_scan/common.rs +0 -654
- package/crates/team-agent/src/provider/session_scan/copilot.rs +0 -280
- package/crates/team-agent/src/provider/session_scan/pi.rs +0 -185
- package/crates/team-agent/src/provider/session_scan.rs +0 -71
- package/crates/team-agent/src/provider/startup_prompt.rs +0 -757
- package/crates/team-agent/src/provider/submit_now.rs +0 -71
- package/crates/team-agent/src/provider/testdata/copilot-ready-marker.txt +0 -5
- package/crates/team-agent/src/provider/testdata/copilot-trust-prompt.txt +0 -19
- package/crates/team-agent/src/provider/testdata/grok-models-authenticated.stdout +0 -9
- package/crates/team-agent/src/provider/testdata/grok-models-unauthenticated.stdout +0 -7
- package/crates/team-agent/src/provider/tests/adapter.rs +0 -441
- package/crates/team-agent/src/provider/tests/classify.rs +0 -148
- package/crates/team-agent/src/provider/tests/command_helpers.rs +0 -35
- package/crates/team-agent/src/provider/tests/copilot_fork.rs +0 -191
- package/crates/team-agent/src/provider/tests/faults.rs +0 -200
- package/crates/team-agent/src/provider/tests/idle.rs +0 -177
- package/crates/team-agent/src/provider/tests/wire.rs +0 -213
- package/crates/team-agent/src/provider/tests.rs +0 -32
- package/crates/team-agent/src/provider/types.rs +0 -529
- package/crates/team-agent/src/provider/wire.rs +0 -394
- package/crates/team-agent/src/redaction.rs +0 -259
- package/crates/team-agent/src/state/abnormal_watch/tests/mod.rs +0 -248
- package/crates/team-agent/src/state/abnormal_watch.rs +0 -144
- package/crates/team-agent/src/state/identity.rs +0 -914
- package/crates/team-agent/src/state/identity_keys.rs +0 -132
- package/crates/team-agent/src/state/mod.rs +0 -74
- package/crates/team-agent/src/state/owner_gate.rs +0 -482
- package/crates/team-agent/src/state/ownership.rs +0 -563
- package/crates/team-agent/src/state/paths.rs +0 -395
- package/crates/team-agent/src/state/persist.rs +0 -3811
- package/crates/team-agent/src/state/projection.rs +0 -1508
- package/crates/team-agent/src/state/repository/intent.rs +0 -14
- package/crates/team-agent/src/state/repository/tests.rs +0 -184
- package/crates/team-agent/src/state/repository.rs +0 -866
- package/crates/team-agent/src/state/selector.rs +0 -160
- package/crates/team-agent/src/state/testdata/state-rich.canonical.json +0 -133
- package/crates/team-agent/src/test_support/models_timeout_fixture.rs +0 -144
- package/crates/team-agent/src/tmux_backend/enter_rescue.rs +0 -325
- package/crates/team-agent/src/tmux_backend/enter_rescue_tests.rs +0 -432
- package/crates/team-agent/src/tmux_backend/native_input.rs +0 -513
- package/crates/team-agent/src/tmux_backend/native_input_tests.rs +0 -742
- package/crates/team-agent/src/tmux_backend/tests.rs +0 -4103
- package/crates/team-agent/src/tmux_backend.rs +0 -4492
- package/crates/team-agent/src/topology.rs +0 -537
- package/crates/team-agent/src/transport/enter_rescue.rs +0 -166
- package/crates/team-agent/src/transport/native_input.rs +0 -491
- package/crates/team-agent/src/transport/test_support.rs +0 -743
- package/crates/team-agent/src/transport/tests/behavior.rs +0 -326
- package/crates/team-agent/src/transport/tests/mod.rs +0 -194
- package/crates/team-agent/src/transport/tests/wire.rs +0 -574
- package/crates/team-agent/src/transport.rs +0 -1655
- package/crates/team-agent/src/transport_factory.rs +0 -819
|
@@ -1,912 +0,0 @@
|
|
|
1
|
-
#![allow(clippy::unwrap_used, clippy::panic)]
|
|
2
|
-
use super::super::tests::Sandbox;
|
|
3
|
-
use super::*;
|
|
4
|
-
|
|
5
|
-
fn fixture(ids: &[&str]) -> (Sandbox, Intent) {
|
|
6
|
-
let root = Sandbox::new();
|
|
7
|
-
std::fs::create_dir(root.path().join("agents")).unwrap();
|
|
8
|
-
std::fs::write(
|
|
9
|
-
root.path().join("TEAM.md"),
|
|
10
|
-
"---\nname: fixture\nprovider: pi\n---\nFixture\n",
|
|
11
|
-
)
|
|
12
|
-
.unwrap();
|
|
13
|
-
for id in ids {
|
|
14
|
-
write_role(root.path(), id);
|
|
15
|
-
}
|
|
16
|
-
let mut intent = super::super::tests::intent(Verb::Start);
|
|
17
|
-
intent.workspace = root.path().to_owned();
|
|
18
|
-
intent.subject = Subject::Team { source: None };
|
|
19
|
-
intent.team = Some("fixture".into());
|
|
20
|
-
(root, intent)
|
|
21
|
-
}
|
|
22
|
-
fn write_role(root: &Path, id: &str) {
|
|
23
|
-
std::fs::write(root.join("agents").join(format!("{id}.md")),format!("---\nname: {id}\nprovider: pi\nmodel: openai-codex/gpt-6-luna\neffort: max\ndangerously_skip_permissions: true\n---\nFixture\n")).unwrap();
|
|
24
|
-
}
|
|
25
|
-
fn install(root: &Path, ids: &[(&str, &str, bool)]) {
|
|
26
|
-
let agents:serde_json::Map<String,Value>=ids.iter().map(|(id,status,explicit)|((*id).into(),json!({"provider":"pi","status":status,"explicit_stop":explicit,"pane_pid":std::process::id(),"pane_id":format!("%{id}"),"window":id}))).collect();
|
|
27
|
-
let entry = json!({"team_key":"fixture","team_dir":root,"status":"alive","session_name":"team-fixture","agents":agents,"tasks":{}});
|
|
28
|
-
let mut raw = entry.clone();
|
|
29
|
-
raw["active_team_key"] = json!("fixture");
|
|
30
|
-
raw["teams"] = json!({"fixture":entry});
|
|
31
|
-
let state = crate::state::persist::runtime_state_path(root);
|
|
32
|
-
std::fs::create_dir_all(state.parent().unwrap()).unwrap();
|
|
33
|
-
std::fs::write(state, serde_json::to_vec(&raw).unwrap()).unwrap();
|
|
34
|
-
let spec = crate::model::paths::runtime_spec_path(root, "fixture");
|
|
35
|
-
std::fs::create_dir_all(spec.parent().unwrap()).unwrap();
|
|
36
|
-
std::fs::write(
|
|
37
|
-
spec,
|
|
38
|
-
yaml::dumps(&crate::compiler::compile_team(root).unwrap()),
|
|
39
|
-
)
|
|
40
|
-
.unwrap();
|
|
41
|
-
}
|
|
42
|
-
fn actions(plan: &Plan) -> Vec<(&str, Option<&str>)> {
|
|
43
|
-
plan.steps.iter().map(|s| (s.name(), s.agent())).collect()
|
|
44
|
-
}
|
|
45
|
-
#[test]
|
|
46
|
-
fn owned_native_reconciliation_still_allows_the_original_fenced_stop() {
|
|
47
|
-
assert_eq!(seat_actions(Verb::Stop, Observation::NativeReconcile, false, false, false, false).unwrap(), ["stop"]);
|
|
48
|
-
assert!(seat_actions(Verb::Stop, Observation::Unknown, false, false, false, false).is_err());
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
#[test]
|
|
52
|
-
#[serial_test::serial(env)]
|
|
53
|
-
fn team_start_skips_bad_native_preflight_but_explicit_target_still_refuses() {
|
|
54
|
-
let (root, intent) = fixture(&["healthy", "invalid"]);
|
|
55
|
-
std::fs::write(root.path().join("agents/invalid.md"),
|
|
56
|
-
"---\nprovider: codex\nmodel: native-model\nprofile: codex-default\n---\nInvalid native profile\n").unwrap();
|
|
57
|
-
install(root.path(), &[("healthy", "stopped", true), ("invalid", "stopped", true)]);
|
|
58
|
-
let state = crate::state::persist::runtime_state_path(root.path());
|
|
59
|
-
let mut raw: Value = serde_json::from_slice(&std::fs::read(&state).unwrap()).unwrap();
|
|
60
|
-
raw["teams"]["fixture"]["agents"]["invalid"]["provider"] = json!("codex_tui");
|
|
61
|
-
std::fs::write(&state, serde_json::to_vec(&raw).unwrap()).unwrap();
|
|
62
|
-
let before = std::fs::read(&state).unwrap();
|
|
63
|
-
let plan = plan_with_observer(intent.clone(), |_, _, _| Ok(Observation::StoppedVerified)).unwrap();
|
|
64
|
-
assert_eq!(actions(&plan), [("start_agent", Some("healthy"))]);
|
|
65
|
-
assert!(plan.skipped.iter().any(|entry| entry["agent"] == "invalid" && entry["reason"] == "preflight_blocked"));
|
|
66
|
-
let mut single = intent;
|
|
67
|
-
single.subject = Subject::Agent("invalid".into());
|
|
68
|
-
assert!(plan_with_observer(single, |_, _, _| Ok(Observation::StoppedVerified)).is_err());
|
|
69
|
-
assert_eq!(std::fs::read(&state).unwrap(), before);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
#[test]
|
|
73
|
-
#[serial_test::serial(env)]
|
|
74
|
-
fn absent_source_is_one_original_create_not_restart_or_probe() {
|
|
75
|
-
let (root, intent) = fixture(&["one", "two"]);
|
|
76
|
-
let plan = plan_with_observer(intent, |_, _, _| panic!("fresh team probed")).unwrap();
|
|
77
|
-
assert_eq!(actions(&plan), [("quick_start", None)]);
|
|
78
|
-
assert!(!crate::state::persist::runtime_state_path(root.path()).exists());
|
|
79
|
-
}
|
|
80
|
-
#[test]
|
|
81
|
-
#[serial_test::serial(env)]
|
|
82
|
-
fn startup_spec_red_stopped_team_uses_start_without_restart_or_planning_writes() {
|
|
83
|
-
let (root, intent) = fixture(&["one", "two"]);
|
|
84
|
-
install(
|
|
85
|
-
root.path(),
|
|
86
|
-
&[("one", "stopped", true), ("two", "stopped", false)],
|
|
87
|
-
);
|
|
88
|
-
let spec = crate::model::paths::runtime_spec_path(root.path(), "fixture");
|
|
89
|
-
std::fs::remove_file(&spec).unwrap();
|
|
90
|
-
let state = crate::state::persist::runtime_state_path(root.path());
|
|
91
|
-
let before = std::fs::read(&state).unwrap();
|
|
92
|
-
let result = plan_with_observer(intent, |_, _, _| Ok(Observation::StoppedVerified));
|
|
93
|
-
assert_eq!(std::fs::read(&state).unwrap(), before);
|
|
94
|
-
assert!(
|
|
95
|
-
!spec.exists(),
|
|
96
|
-
"readonly planning must not rebuild the spec"
|
|
97
|
-
);
|
|
98
|
-
let plan = result.expect("complete roles must provide a noncircular start plan when only the derived spec is missing");
|
|
99
|
-
assert_eq!(
|
|
100
|
-
plan.steps
|
|
101
|
-
.iter()
|
|
102
|
-
.filter_map(|step| match step {
|
|
103
|
-
Step::StartAgent(args) => Some(args.agent.as_str()),
|
|
104
|
-
_ => None,
|
|
105
|
-
})
|
|
106
|
-
.collect::<Vec<_>>(),
|
|
107
|
-
["one", "two"]
|
|
108
|
-
);
|
|
109
|
-
assert!(!plan
|
|
110
|
-
.steps
|
|
111
|
-
.iter()
|
|
112
|
-
.any(|step| matches!(step, Step::RestartTeam(_) | Step::StopAgent(_))));
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
#[test]
|
|
116
|
-
#[serial_test::serial(env)]
|
|
117
|
-
fn startup_spec_red_live_team_recovers_metadata_without_process_restart() {
|
|
118
|
-
let (root, intent) = fixture(&["one"]);
|
|
119
|
-
install(root.path(), &[("one", "running", false)]);
|
|
120
|
-
let spec = crate::model::paths::runtime_spec_path(root.path(), "fixture");
|
|
121
|
-
std::fs::remove_file(&spec).unwrap();
|
|
122
|
-
let state = crate::state::persist::runtime_state_path(root.path());
|
|
123
|
-
let before = std::fs::read(&state).unwrap();
|
|
124
|
-
let result = plan_with_observer(intent, |_, _, _| Ok(Observation::Live));
|
|
125
|
-
assert_eq!(std::fs::read(&state).unwrap(), before);
|
|
126
|
-
assert!(!spec.exists());
|
|
127
|
-
let plan =
|
|
128
|
-
result.expect("missing derived metadata must not require restarting a verified live seat");
|
|
129
|
-
assert!(!plan.steps.iter().any(|step| matches!(
|
|
130
|
-
step,
|
|
131
|
-
Step::StartAgent(_) | Step::StopAgent(_) | Step::RestartTeam(_) | Step::CreateTeam(_)
|
|
132
|
-
)));
|
|
133
|
-
assert!(plan
|
|
134
|
-
.skipped
|
|
135
|
-
.iter()
|
|
136
|
-
.any(|entry| entry["reason"] == "already_running"));
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
#[test]
|
|
140
|
-
#[serial_test::serial(env)]
|
|
141
|
-
fn startup_spec_repair_executes_only_metadata_and_preserves_seat_identity() {
|
|
142
|
-
let (root, intent) = fixture(&["one"]);
|
|
143
|
-
install(root.path(), &[("one", "stopped", true)]);
|
|
144
|
-
let spec = crate::model::paths::runtime_spec_path(root.path(), "fixture");
|
|
145
|
-
std::fs::remove_file(&spec).unwrap();
|
|
146
|
-
let state = crate::state::persist::runtime_state_path(root.path());
|
|
147
|
-
let before: Value = serde_json::from_slice(&std::fs::read(&state).unwrap()).unwrap();
|
|
148
|
-
let plan = plan_with_observer(intent, |_, _, _| Ok(Observation::StoppedVerified)).unwrap();
|
|
149
|
-
let repair = plan
|
|
150
|
-
.steps
|
|
151
|
-
.iter()
|
|
152
|
-
.find(|step| matches!(step, Step::RestoreSpec { .. }))
|
|
153
|
-
.unwrap();
|
|
154
|
-
for _ in 0..2 {
|
|
155
|
-
recheck(&plan, repair, false).unwrap();
|
|
156
|
-
assert_eq!(repair.execute().unwrap().exit, ExitCode::Ok);
|
|
157
|
-
assert!(spec.is_file());
|
|
158
|
-
let after: Value = serde_json::from_slice(&std::fs::read(&state).unwrap()).unwrap();
|
|
159
|
-
assert_eq!(after["teams"]["fixture"]["spec_path"], json!(spec));
|
|
160
|
-
assert_eq!(
|
|
161
|
-
relevant(&after["teams"]["fixture"]["agents"]["one"]),
|
|
162
|
-
relevant(&before["teams"]["fixture"]["agents"]["one"])
|
|
163
|
-
);
|
|
164
|
-
assert_eq!(
|
|
165
|
-
after["teams"]["fixture"]["agents"]["one"]["explicit_stop"],
|
|
166
|
-
true
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
#[test]
|
|
172
|
-
#[serial_test::serial(env)]
|
|
173
|
-
fn startup_spec_repair_rechecks_source_under_lock_and_unknown_stays_blocked() {
|
|
174
|
-
let (root, intent) = fixture(&["one"]);
|
|
175
|
-
install(root.path(), &[("one", "stopped", true)]);
|
|
176
|
-
let spec = crate::model::paths::runtime_spec_path(root.path(), "fixture");
|
|
177
|
-
std::fs::remove_file(&spec).unwrap();
|
|
178
|
-
assert!(plan_with_observer(intent.clone(), |_, _, _| Ok(Observation::Unknown)).is_err());
|
|
179
|
-
assert!(!spec.exists());
|
|
180
|
-
let plan = plan_with_observer(intent, |_, _, _| Ok(Observation::StoppedVerified)).unwrap();
|
|
181
|
-
let repair = plan
|
|
182
|
-
.steps
|
|
183
|
-
.iter()
|
|
184
|
-
.find(|step| matches!(step, Step::RestoreSpec { .. }))
|
|
185
|
-
.unwrap();
|
|
186
|
-
let state = crate::state::persist::runtime_state_path(root.path());
|
|
187
|
-
let before = std::fs::read(&state).unwrap();
|
|
188
|
-
let role = root.path().join("agents/one.md");
|
|
189
|
-
let changed = std::fs::read_to_string(&role)
|
|
190
|
-
.unwrap()
|
|
191
|
-
.replace("Fixture", "Changed role body");
|
|
192
|
-
std::fs::write(role, changed).unwrap();
|
|
193
|
-
assert!(
|
|
194
|
-
repair.execute().is_err(),
|
|
195
|
-
"the executor must not rely only on the earlier planner recheck"
|
|
196
|
-
);
|
|
197
|
-
assert_eq!(std::fs::read(state).unwrap(), before);
|
|
198
|
-
assert!(!spec.exists());
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
#[test]
|
|
202
|
-
#[serial_test::serial(env)]
|
|
203
|
-
fn startup_spec_missing_restart_still_preserves_explicit_stop() {
|
|
204
|
-
let (root, mut intent) = fixture(&["one"]);
|
|
205
|
-
install(root.path(), &[("one", "stopped", true)]);
|
|
206
|
-
let spec = crate::model::paths::runtime_spec_path(root.path(), "fixture");
|
|
207
|
-
std::fs::remove_file(&spec).unwrap();
|
|
208
|
-
intent.verb = Verb::Restart;
|
|
209
|
-
let plan =
|
|
210
|
-
plan_with_observer(intent, |_, _, _| panic!("held seat must not be probed")).unwrap();
|
|
211
|
-
assert!(plan.steps.is_empty());
|
|
212
|
-
assert!(plan.no_eligible.is_some());
|
|
213
|
-
assert_eq!(plan.skipped[0]["reason"], "explicit_stop");
|
|
214
|
-
assert!(!spec.exists());
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
#[test]
|
|
218
|
-
#[serial_test::serial(env)]
|
|
219
|
-
fn stopped_team_starts_both_and_mixed_start_leaves_live_peer_untouched() {
|
|
220
|
-
let (root, intent) = fixture(&["one", "two"]);
|
|
221
|
-
install(
|
|
222
|
-
root.path(),
|
|
223
|
-
&[("one", "stopped", true), ("two", "stopped", false)],
|
|
224
|
-
);
|
|
225
|
-
let plan =
|
|
226
|
-
plan_with_observer(intent.clone(), |_, _, _| Ok(Observation::StoppedVerified)).unwrap();
|
|
227
|
-
assert_eq!(
|
|
228
|
-
actions(&plan),
|
|
229
|
-
[("start_agent", Some("one")), ("start_agent", Some("two"))]
|
|
230
|
-
);
|
|
231
|
-
assert_eq!(plan.scope.team.as_deref(), Some("fixture"));
|
|
232
|
-
install(
|
|
233
|
-
root.path(),
|
|
234
|
-
&[("one", "running", false), ("two", "stopped", false)],
|
|
235
|
-
);
|
|
236
|
-
let plan = plan_with_observer(intent, |_, id, _| {
|
|
237
|
-
Ok(if id == "one" {
|
|
238
|
-
Observation::Live
|
|
239
|
-
} else {
|
|
240
|
-
Observation::StoppedVerified
|
|
241
|
-
})
|
|
242
|
-
})
|
|
243
|
-
.unwrap();
|
|
244
|
-
assert_eq!(actions(&plan), [("start_agent", Some("two"))]);
|
|
245
|
-
assert_eq!(plan.skipped[0]["reason"], "already_running");
|
|
246
|
-
}
|
|
247
|
-
#[test]
|
|
248
|
-
#[serial_test::serial(env)]
|
|
249
|
-
fn verified_all_live_is_noop_but_known_drift_and_unknown_refuse() {
|
|
250
|
-
let (root, intent) = fixture(&["one"]);
|
|
251
|
-
install(root.path(), &[("one", "running", false)]);
|
|
252
|
-
assert!(
|
|
253
|
-
plan_with_observer(intent.clone(), |_, _, _| Ok(Observation::Live))
|
|
254
|
-
.unwrap()
|
|
255
|
-
.steps
|
|
256
|
-
.is_empty()
|
|
257
|
-
);
|
|
258
|
-
assert!(plan_with_observer(intent.clone(), |_, _, _| Ok(Observation::Unknown)).is_err());
|
|
259
|
-
let mut patched = intent.clone();
|
|
260
|
-
patched.subject = Subject::Agent(AgentId::new("one"));
|
|
261
|
-
patched.patch.model = Some("new-model".into());
|
|
262
|
-
assert!(plan_with_observer(patched, |_, _, _| Ok(Observation::Live)).is_err());
|
|
263
|
-
let state = crate::state::persist::runtime_state_path(root.path());
|
|
264
|
-
let mut raw: Value = serde_json::from_slice(&std::fs::read(&state).unwrap()).unwrap();
|
|
265
|
-
raw["teams"]["fixture"]["agents"]["one"]["as_launched_dangerously_skip_permissions"] =
|
|
266
|
-
json!(false);
|
|
267
|
-
std::fs::write(state, serde_json::to_vec(&raw).unwrap()).unwrap();
|
|
268
|
-
assert!(plan_with_observer(intent, |_, _, _| Ok(Observation::Live)).is_err());
|
|
269
|
-
}
|
|
270
|
-
#[test]
|
|
271
|
-
#[serial_test::serial(env)]
|
|
272
|
-
fn new_restart_preserves_held_seats_and_shutdown_branch_starts_only_eligible() {
|
|
273
|
-
let (root, mut intent) = fixture(&["one", "two"]);
|
|
274
|
-
install(
|
|
275
|
-
root.path(),
|
|
276
|
-
&[("one", "stopped", true), ("two", "stopped", false)],
|
|
277
|
-
);
|
|
278
|
-
intent.verb = Verb::Restart;
|
|
279
|
-
intent.session = SessionPolicy::Auto;
|
|
280
|
-
let state = crate::state::persist::runtime_state_path(root.path());
|
|
281
|
-
let mut raw: Value = serde_json::from_slice(&std::fs::read(&state).unwrap()).unwrap();
|
|
282
|
-
raw["teams"]["fixture"]["status"] = json!("shutdown");
|
|
283
|
-
std::fs::write(&state, serde_json::to_vec(&raw).unwrap()).unwrap();
|
|
284
|
-
let plan = plan_with_observer(intent.clone(), |_, id, _| {
|
|
285
|
-
assert_ne!(id, "one", "held seat was probed");
|
|
286
|
-
Ok(Observation::StoppedVerified)
|
|
287
|
-
})
|
|
288
|
-
.unwrap();
|
|
289
|
-
assert_eq!(actions(&plan), [("start_agent", Some("two"))]);
|
|
290
|
-
assert_eq!(plan.skipped[0]["reason"], "explicit_stop");
|
|
291
|
-
raw["teams"]["fixture"]["agents"]["two"]["status"] = json!("running");
|
|
292
|
-
std::fs::write(state, serde_json::to_vec(&raw).unwrap()).unwrap();
|
|
293
|
-
let plan = plan_with_observer(intent, |_, _, _| Ok(Observation::Live)).unwrap();
|
|
294
|
-
assert_eq!(actions(&plan), [("restart_team", None)]);
|
|
295
|
-
let Step::RestartTeam(args) = &plan.steps[0] else {
|
|
296
|
-
panic!()
|
|
297
|
-
};
|
|
298
|
-
assert!(args.allow_fresh);
|
|
299
|
-
}
|
|
300
|
-
#[test]
|
|
301
|
-
#[serial_test::serial(env)]
|
|
302
|
-
fn all_paused_no_eligible_and_single_restart_never_unpauses() {
|
|
303
|
-
let (root, mut intent) = fixture(&["one"]);
|
|
304
|
-
install(root.path(), &[("one", "paused", false)]);
|
|
305
|
-
let blocked = plan_with_observer(intent.clone(), |_, _, _| panic!("paused probe")).unwrap();
|
|
306
|
-
assert!(blocked.no_eligible.is_some());
|
|
307
|
-
assert!(blocked.steps.is_empty());
|
|
308
|
-
assert_eq!(blocked.skipped[0]["reason"], "paused");
|
|
309
|
-
intent.verb = Verb::Restart;
|
|
310
|
-
intent.subject = Subject::Agent(AgentId::new("one"));
|
|
311
|
-
assert!(plan_with_observer(intent, |_, _, _| panic!("paused probe")).is_err());
|
|
312
|
-
}
|
|
313
|
-
#[test]
|
|
314
|
-
#[serial_test::serial(env)]
|
|
315
|
-
fn no_eligible_restart_preserves_scoped_held_and_stopped_skip_reasons() {
|
|
316
|
-
for explicit in [false, true] {
|
|
317
|
-
let (root, mut intent) = fixture(&["one"]);
|
|
318
|
-
install(root.path(), &[("one", "stopped", explicit)]);
|
|
319
|
-
intent.verb = Verb::Restart;
|
|
320
|
-
let blocked =
|
|
321
|
-
plan_with_observer(intent, |_, _, _| Ok(Observation::StoppedVerified)).unwrap();
|
|
322
|
-
assert!(blocked.no_eligible.is_some());
|
|
323
|
-
assert!(blocked.steps.is_empty());
|
|
324
|
-
assert_eq!(blocked.scope.team.as_deref(), Some("fixture"));
|
|
325
|
-
assert_eq!(blocked.skipped[0]["agent"], "one");
|
|
326
|
-
assert_eq!(
|
|
327
|
-
blocked.skipped[0]["reason"],
|
|
328
|
-
if explicit {
|
|
329
|
-
"explicit_stop"
|
|
330
|
-
} else {
|
|
331
|
-
"stopped_preserved_by_original_restart"
|
|
332
|
-
}
|
|
333
|
-
);
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
#[test]
|
|
338
|
-
#[serial_test::serial(env)]
|
|
339
|
-
fn role_only_add_and_absent_creation_need_explicit_decisions() {
|
|
340
|
-
let (root, mut intent) = fixture(&["one"]);
|
|
341
|
-
install(root.path(), &[("one", "stopped", false)]);
|
|
342
|
-
write_role(root.path(), "two");
|
|
343
|
-
intent.subject = Subject::Agent(AgentId::new("two"));
|
|
344
|
-
let plan = plan_with_observer(intent.clone(), |_, _, _| panic!("unregistered probe")).unwrap();
|
|
345
|
-
assert_eq!(actions(&plan), [("add_agent", Some("two"))]);
|
|
346
|
-
let Step::AddAgent(args) = &plan.steps[0] else {
|
|
347
|
-
panic!()
|
|
348
|
-
};
|
|
349
|
-
assert_eq!(
|
|
350
|
-
Path::new(&args.role_file),
|
|
351
|
-
root.path().join("agents/two.md")
|
|
352
|
-
);
|
|
353
|
-
intent.subject = Subject::Agent(AgentId::new("typo"));
|
|
354
|
-
assert!(plan_with_observer(intent.clone(), |_, _, _| panic!()).is_err());
|
|
355
|
-
intent.patch.provider = Some("pi".into());
|
|
356
|
-
intent.patch.bypass = Some(true);
|
|
357
|
-
assert!(matches!(
|
|
358
|
-
plan_with_observer(intent, |_, _, _| panic!())
|
|
359
|
-
.unwrap()
|
|
360
|
-
.steps[0],
|
|
361
|
-
Step::AddAgent(_)
|
|
362
|
-
));
|
|
363
|
-
}
|
|
364
|
-
#[test]
|
|
365
|
-
#[serial_test::serial(env)]
|
|
366
|
-
fn issue391_start_readmits_a_removed_seat_from_its_left_behind_role_file() {
|
|
367
|
-
let (root, mut intent) = fixture(&["one"]);
|
|
368
|
-
install(root.path(), &[("one", "stopped", false)]);
|
|
369
|
-
// remove-agent keeps the user's role file and leaves a retired tombstone.
|
|
370
|
-
write_role(root.path(), "two");
|
|
371
|
-
let state = crate::state::persist::runtime_state_path(root.path());
|
|
372
|
-
let mut raw: Value = serde_json::from_slice(&std::fs::read(&state).unwrap()).unwrap();
|
|
373
|
-
let tombstone = json!({"two": {"state": "retired", "changed_at": "2026-10-27T15:25:48Z", "reason": "remove-agent"}});
|
|
374
|
-
raw["agent_lifecycle"] = tombstone.clone();
|
|
375
|
-
raw["teams"]["fixture"]["agent_lifecycle"] = tombstone;
|
|
376
|
-
std::fs::write(&state, serde_json::to_vec(&raw).unwrap()).unwrap();
|
|
377
|
-
intent.subject = Subject::Agent(AgentId::new("two"));
|
|
378
|
-
let plan = plan_with_observer(intent.clone(), |_, _, _| panic!("unregistered probe")).unwrap();
|
|
379
|
-
assert_eq!(actions(&plan), [("add_agent", Some("two"))]);
|
|
380
|
-
let Step::AddAgent(args) = &plan.steps[0] else {
|
|
381
|
-
panic!()
|
|
382
|
-
};
|
|
383
|
-
assert_eq!(
|
|
384
|
-
Path::new(&args.role_file),
|
|
385
|
-
root.path().join("agents/two.md"),
|
|
386
|
-
"the left-behind role file is the seat's definition"
|
|
387
|
-
);
|
|
388
|
-
// Team start still leaves a removed seat retired.
|
|
389
|
-
let mut team = intent.clone();
|
|
390
|
-
team.subject = Subject::Team { source: None };
|
|
391
|
-
let plan = plan_with_observer(team, |_, _, _| Ok(Observation::StoppedVerified)).unwrap();
|
|
392
|
-
assert_eq!(actions(&plan), [("start_agent", Some("one"))]);
|
|
393
|
-
assert!(plan
|
|
394
|
-
.skipped
|
|
395
|
-
.iter()
|
|
396
|
-
.any(|entry| entry["agent"] == "two" && entry["reason"] == "retired"));
|
|
397
|
-
// History the planner cannot classify is refused without naming a phantom command.
|
|
398
|
-
raw["agent_lifecycle"]["two"]["state"] = json!("quarantined");
|
|
399
|
-
raw["teams"]["fixture"]["agent_lifecycle"]["two"]["state"] = json!("quarantined");
|
|
400
|
-
std::fs::write(&state, serde_json::to_vec(&raw).unwrap()).unwrap();
|
|
401
|
-
let error = plan_with_observer(intent, |_, _, _| panic!())
|
|
402
|
-
.unwrap_err()
|
|
403
|
-
.to_string();
|
|
404
|
-
assert!(
|
|
405
|
-
error.contains("unrecognized lifecycle history") && !error.contains("recovery"),
|
|
406
|
-
"{error}"
|
|
407
|
-
);
|
|
408
|
-
}
|
|
409
|
-
#[test]
|
|
410
|
-
#[serial_test::serial(env)]
|
|
411
|
-
fn spec_only_state_only_and_missing_spec_do_not_fallback_to_creation() {
|
|
412
|
-
let (root, mut intent) = fixture(&["one", "two"]);
|
|
413
|
-
install(root.path(), &[("one", "stopped", false)]);
|
|
414
|
-
assert!(
|
|
415
|
-
plan_with_observer(intent.clone(), |_, _, _| Ok(Observation::StoppedVerified)).is_err()
|
|
416
|
-
);
|
|
417
|
-
let spec = crate::model::paths::runtime_spec_path(root.path(), "fixture");
|
|
418
|
-
std::fs::remove_file(&spec).unwrap();
|
|
419
|
-
assert!(
|
|
420
|
-
plan_with_observer(intent.clone(), |_, _, _| Ok(Observation::StoppedVerified)).is_err()
|
|
421
|
-
);
|
|
422
|
-
intent.verb = Verb::Restart;
|
|
423
|
-
let blocked = plan_with_observer(intent, |_, _, _| Ok(Observation::StoppedVerified)).unwrap();
|
|
424
|
-
assert!(blocked.no_eligible.is_some());
|
|
425
|
-
assert!(blocked.steps.is_empty());
|
|
426
|
-
assert_eq!(blocked.skipped[0]["agent"], "one");
|
|
427
|
-
}
|
|
428
|
-
#[test]
|
|
429
|
-
#[serial_test::serial(env)]
|
|
430
|
-
fn runtime_files_and_source_are_unchanged_by_dry_planning() {
|
|
431
|
-
let (root, intent) = fixture(&["one"]);
|
|
432
|
-
install(root.path(), &[("one", "stopped", true)]);
|
|
433
|
-
let state = crate::state::persist::runtime_state_path(root.path());
|
|
434
|
-
let before = std::fs::read(&state).unwrap();
|
|
435
|
-
let plan = plan_with_observer(intent, |_, _, _| Ok(Observation::StoppedVerified)).unwrap();
|
|
436
|
-
assert!(!plan.steps.is_empty());
|
|
437
|
-
assert_eq!(std::fs::read(state).unwrap(), before);
|
|
438
|
-
}
|
|
439
|
-
#[test]
|
|
440
|
-
fn discovery_never_prefers_current_over_two_distinct_sources() {
|
|
441
|
-
let root = Sandbox::new();
|
|
442
|
-
for name in ["one", "current"] {
|
|
443
|
-
let path = root.path().join(".team").join(name);
|
|
444
|
-
std::fs::create_dir_all(path.join("agents")).unwrap();
|
|
445
|
-
std::fs::write(path.join("TEAM.md"), "fixture").unwrap();
|
|
446
|
-
}
|
|
447
|
-
assert!(discover(root.path(), None, None).is_err());
|
|
448
|
-
}
|
|
449
|
-
#[test]
|
|
450
|
-
#[serial_test::serial(env)]
|
|
451
|
-
fn explicit_source_and_relative_role_file_are_resolved_from_caller_not_workspace() {
|
|
452
|
-
let (root, _) = fixture(&["one"]);
|
|
453
|
-
let workspace = root.path().join("other");
|
|
454
|
-
std::fs::create_dir(&workspace).unwrap();
|
|
455
|
-
let args = vec![
|
|
456
|
-
"--from".into(),
|
|
457
|
-
".".into(),
|
|
458
|
-
"--workspace".into(),
|
|
459
|
-
workspace.to_string_lossy().into_owned(),
|
|
460
|
-
"--dry-run".into(),
|
|
461
|
-
"--json".into(),
|
|
462
|
-
];
|
|
463
|
-
let result = super::super::run("start", &args, root.path())
|
|
464
|
-
.unwrap()
|
|
465
|
-
.unwrap();
|
|
466
|
-
let CmdOutput::Json(value) = result.output else {
|
|
467
|
-
panic!()
|
|
468
|
-
};
|
|
469
|
-
assert_eq!(
|
|
470
|
-
value["scope"]["workspace"],
|
|
471
|
-
workspace.to_string_lossy().as_ref()
|
|
472
|
-
);
|
|
473
|
-
assert!(!workspace.join(".team").exists());
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
#[test]
|
|
477
|
-
#[serial_test::serial(env)]
|
|
478
|
-
fn genuine_bootstrap_uses_original_predicate_but_history_is_not_fresh() {
|
|
479
|
-
let (root, intent) = fixture(&["one"]);
|
|
480
|
-
let state = crate::state::persist::runtime_state_path(root.path());
|
|
481
|
-
std::fs::create_dir_all(state.parent().unwrap()).unwrap();
|
|
482
|
-
let bootstrap = json!({"team_key":"fixture","agents":{},"tasks":[],"session_name":null,"team_owner":{"pane_id":"%0"},"leader_receiver":{"pane_id":"%0","status":"attached"}});
|
|
483
|
-
std::fs::write(&state, serde_json::to_vec(&bootstrap).unwrap()).unwrap();
|
|
484
|
-
assert_eq!(
|
|
485
|
-
actions(&plan_with_observer(intent.clone(), |_, _, _| panic!()).unwrap()),
|
|
486
|
-
[("quick_start", None)]
|
|
487
|
-
);
|
|
488
|
-
let mut history = bootstrap;
|
|
489
|
-
history["tasks"] = json!({"old":{}});
|
|
490
|
-
std::fs::write(&state, serde_json::to_vec(&history).unwrap()).unwrap();
|
|
491
|
-
assert!(plan_with_observer(intent, |_, _, _| panic!()).is_err());
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
#[test]
|
|
495
|
-
#[serial_test::serial(env)]
|
|
496
|
-
fn preserve_rejects_known_missing_backing_before_stop_auto_uses_existing_decision() {
|
|
497
|
-
let (root, _) = fixture(&["one"]);
|
|
498
|
-
install(root.path(), &[("one", "running", false)]);
|
|
499
|
-
let selected =
|
|
500
|
-
resolve_active_team_readonly(root.path(), Some("fixture"), SelectorMode::RuntimeOnly)
|
|
501
|
-
.unwrap();
|
|
502
|
-
let row = json!({"provider":"pi","session_id":"missing-session","rollout_path":root.path().join("missing.jsonl"),"spawn_cwd":root.path()});
|
|
503
|
-
assert!(preflight_start(&selected, "one", &row, SessionPolicy::Preserve).is_err());
|
|
504
|
-
assert!(preflight_start(&selected, "one", &row, SessionPolicy::Auto).is_ok());
|
|
505
|
-
assert!(
|
|
506
|
-
preflight_start(
|
|
507
|
-
&selected,
|
|
508
|
-
"one",
|
|
509
|
-
&json!({"provider":"pi"}),
|
|
510
|
-
SessionPolicy::Preserve
|
|
511
|
-
)
|
|
512
|
-
.is_ok(),
|
|
513
|
-
"first fresh has no captured context to discard"
|
|
514
|
-
);
|
|
515
|
-
for policy in [SessionPolicy::Auto, SessionPolicy::Preserve] {
|
|
516
|
-
assert!(
|
|
517
|
-
preflight_start(&selected, "one", &json!({"provider":"cursor"}), policy).is_err(),
|
|
518
|
-
"unadmitted native resume cannot fall back to legacy/fresh"
|
|
519
|
-
);
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
#[test]
|
|
524
|
-
#[serial_test::serial(env)]
|
|
525
|
-
fn changed_role_and_socket_refuse_in_the_real_readonly_recheck() {
|
|
526
|
-
let (root, intent) = fixture(&["one"]);
|
|
527
|
-
install(root.path(), &[("one", "stopped", false)]);
|
|
528
|
-
let plan = plan_with_observer(intent, |_, _, _| Ok(Observation::StoppedVerified)).unwrap();
|
|
529
|
-
let path = root.path().join("agents/one.md");
|
|
530
|
-
let original = std::fs::read(&path).unwrap();
|
|
531
|
-
std::fs::write(&path, b"changed role").unwrap();
|
|
532
|
-
assert!(recheck(&plan, &plan.steps[0], false).is_err());
|
|
533
|
-
std::fs::write(path, original).unwrap();
|
|
534
|
-
let state = crate::state::persist::runtime_state_path(root.path());
|
|
535
|
-
let mut raw: Value = serde_json::from_slice(&std::fs::read(&state).unwrap()).unwrap();
|
|
536
|
-
raw["teams"]["fixture"]["tmux_socket"] = json!("/different/endpoint");
|
|
537
|
-
std::fs::write(state, serde_json::to_vec(&raw).unwrap()).unwrap();
|
|
538
|
-
assert!(recheck(&plan, &plan.steps[0], false).is_err());
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
#[test]
|
|
542
|
-
#[serial_test::serial(env)]
|
|
543
|
-
fn creation_rejects_an_added_role_before_the_original_create_handler() {
|
|
544
|
-
let (root, intent) = fixture(&["one"]);
|
|
545
|
-
let plan = plan_with_observer(intent, |_, _, _| panic!()).unwrap();
|
|
546
|
-
write_role(root.path(), "two");
|
|
547
|
-
assert!(recheck(&plan, &plan.steps[0], false).is_err());
|
|
548
|
-
assert!(!crate::state::persist::runtime_state_path(root.path()).exists());
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
#[test]
|
|
552
|
-
#[serial_test::serial(env)]
|
|
553
|
-
fn stopped_text_without_physical_identity_is_unknown_and_standalone_source_keeps_its_workspace() {
|
|
554
|
-
let (root, _) = fixture(&["one"]);
|
|
555
|
-
install(root.path(), &[("one", "stopped", false)]);
|
|
556
|
-
let selected =
|
|
557
|
-
resolve_active_team_readonly(root.path(), Some("fixture"), SelectorMode::RuntimeOnly)
|
|
558
|
-
.unwrap();
|
|
559
|
-
assert_eq!(
|
|
560
|
-
observe(
|
|
561
|
-
&selected,
|
|
562
|
-
"one",
|
|
563
|
-
&json!({"status":"stopped","provider":"pi"})
|
|
564
|
-
)
|
|
565
|
-
.unwrap(),
|
|
566
|
-
Observation::Unknown
|
|
567
|
-
);
|
|
568
|
-
assert_eq!(
|
|
569
|
-
observe(
|
|
570
|
-
&selected,
|
|
571
|
-
"one",
|
|
572
|
-
&json!({"status":"stopped","provider":"pi","pane_pid":std::process::id()})
|
|
573
|
-
)
|
|
574
|
-
.unwrap(),
|
|
575
|
-
Observation::Unknown
|
|
576
|
-
);
|
|
577
|
-
let (root, _) = fixture(&["one"]);
|
|
578
|
-
let values = vec![
|
|
579
|
-
"--from".into(),
|
|
580
|
-
root.path().to_string_lossy().into_owned(),
|
|
581
|
-
"--dry-run".into(),
|
|
582
|
-
"--json".into(),
|
|
583
|
-
];
|
|
584
|
-
let result = super::super::run("start", &values, root.path())
|
|
585
|
-
.unwrap()
|
|
586
|
-
.unwrap();
|
|
587
|
-
let CmdOutput::Json(value) = result.output else {
|
|
588
|
-
panic!()
|
|
589
|
-
};
|
|
590
|
-
assert_eq!(
|
|
591
|
-
value["scope"]["workspace"],
|
|
592
|
-
root.path().to_string_lossy().as_ref()
|
|
593
|
-
);
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
#[test]
|
|
597
|
-
#[cfg(unix)]
|
|
598
|
-
#[serial_test::serial(env)]
|
|
599
|
-
fn shell_supervised_claude_is_live_for_both_team_start_spellings() {
|
|
600
|
-
use std::process::Command;
|
|
601
|
-
use std::time::{Duration, Instant};
|
|
602
|
-
let (root, _) = fixture(&["one"]);
|
|
603
|
-
std::fs::write(root.path().join("agents/one.md"),
|
|
604
|
-
"---\nprovider: claude\nmodel: claude-opus-4.6\n---\nFixture\n").unwrap();
|
|
605
|
-
install(root.path(), &[("one", "running", false)]);
|
|
606
|
-
let sleep = Command::new("which").arg("sleep").output().unwrap();
|
|
607
|
-
assert!(sleep.status.success());
|
|
608
|
-
std::os::unix::fs::symlink(String::from_utf8(sleep.stdout).unwrap().trim(), root.path().join("claude")).unwrap();
|
|
609
|
-
let socket = root.path().join("t.sock");
|
|
610
|
-
struct Server(std::path::PathBuf);
|
|
611
|
-
impl Drop for Server {
|
|
612
|
-
fn drop(&mut self) { let _ = Command::new("tmux").arg("-S").arg(&self.0).arg("kill-server").output(); }
|
|
613
|
-
}
|
|
614
|
-
let _server = Server(socket.clone());
|
|
615
|
-
let output = Command::new("tmux").arg("-S").arg(&socket)
|
|
616
|
-
.args(["new-session", "-d", "-P", "-F", "#{pane_id} #{pane_pid}", "-s", "team-fixture", "-n", "one"])
|
|
617
|
-
.arg(format!("sh -c '{} 60 & wait'", root.path().join("claude").display()))
|
|
618
|
-
.output().unwrap();
|
|
619
|
-
assert!(output.status.success(), "{}", String::from_utf8_lossy(&output.stderr));
|
|
620
|
-
let pane = String::from_utf8(output.stdout).unwrap();
|
|
621
|
-
let fields: Vec<_> = pane.split_whitespace().collect();
|
|
622
|
-
let pid: u32 = fields[1].parse().unwrap();
|
|
623
|
-
let deadline = Instant::now() + Duration::from_secs(5);
|
|
624
|
-
while !launched_as_provider(pid, crate::provider::Provider::Claude) {
|
|
625
|
-
assert!(Instant::now() < deadline, "controlled Claude child did not start");
|
|
626
|
-
std::thread::sleep(Duration::from_millis(20));
|
|
627
|
-
}
|
|
628
|
-
let state = crate::state::persist::runtime_state_path(root.path());
|
|
629
|
-
let mut raw: Value = serde_json::from_slice(&std::fs::read(&state).unwrap()).unwrap();
|
|
630
|
-
raw["tmux_socket"] = json!(socket);
|
|
631
|
-
raw["teams"]["fixture"]["tmux_socket"] = json!(socket);
|
|
632
|
-
raw["teams"]["fixture"]["generation"] = json!("fixture-generation");
|
|
633
|
-
raw["teams"]["fixture"]["agents"]["one"] = json!({
|
|
634
|
-
"provider":"claude", "status":"running", "pane_id":fields[0], "pane_pid":pid, "window":"one"
|
|
635
|
-
});
|
|
636
|
-
std::fs::write(&state, serde_json::to_vec(&raw).unwrap()).unwrap();
|
|
637
|
-
let before = std::fs::read(&state).unwrap();
|
|
638
|
-
let selected = resolve_active_team_readonly(root.path(), Some("fixture"), SelectorMode::RuntimeOnly).unwrap();
|
|
639
|
-
let backend = crate::lifecycle::restart::lifecycle_worker_tmux_backend_selection_for_state(
|
|
640
|
-
&selected.run_workspace, &selected.state).unwrap().backend;
|
|
641
|
-
backend.set_session_owner_with_generation(&crate::transport::SessionName::new("team-fixture"),
|
|
642
|
-
&selected.run_workspace, "fixture", "fixture-generation").unwrap();
|
|
643
|
-
let row = &selected.state["agents"]["one"];
|
|
644
|
-
assert_eq!(observe(&selected, "one", row).unwrap(), Observation::Live);
|
|
645
|
-
for (command, values) in [
|
|
646
|
-
("team", vec!["start".into(), root.path().to_string_lossy().into_owned(), "--dry-run".into(), "--json".into()]),
|
|
647
|
-
("start", vec!["--team".into(), "fixture".into(), "--dry-run".into(), "--json".into()]),
|
|
648
|
-
] {
|
|
649
|
-
let output = super::super::run(command, &values, root.path()).unwrap().unwrap();
|
|
650
|
-
let CmdOutput::Json(value) = output.output else { panic!() };
|
|
651
|
-
assert_eq!(value["ok"], true, "{value}");
|
|
652
|
-
assert!(value["skipped"].as_array().unwrap().iter().any(|row| row["reason"] == "already_running"), "{value}");
|
|
653
|
-
}
|
|
654
|
-
let mut wrong = row.clone();
|
|
655
|
-
wrong["provider"] = json!("copilot");
|
|
656
|
-
assert_eq!(observe(&selected, "one", &wrong).unwrap(), Observation::Unknown);
|
|
657
|
-
assert_eq!(std::fs::read(state).unwrap(), before);
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
#[test]
|
|
661
|
-
fn declared_provider_aliases_do_not_create_false_drift_or_absorb_native_routes() {
|
|
662
|
-
assert!(same_provider("claude-code", "claude_code"));
|
|
663
|
-
assert!(!same_provider("cursor", "cursor_agent"));
|
|
664
|
-
assert!(same_provider("grok_build", "grok"));
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
#[test]
|
|
668
|
-
#[cfg(unix)]
|
|
669
|
-
fn native_noop_compares_all_five_authoritative_launch_settings() {
|
|
670
|
-
use crate::contract_runtime::{config::RoleConfig, prompt::Prompt};
|
|
671
|
-
use team_agent_contract::contract::types::{Digest, ProviderId, SeatId};
|
|
672
|
-
let old = RoleConfig {
|
|
673
|
-
id: SeatId::new("one").unwrap(),
|
|
674
|
-
provider: ProviderId::new("cursor").unwrap(),
|
|
675
|
-
source: PathBuf::from("/fixture/one.md"),
|
|
676
|
-
role: "one".into(),
|
|
677
|
-
model: "original".into(),
|
|
678
|
-
effort: None,
|
|
679
|
-
bypass: true,
|
|
680
|
-
paused: false,
|
|
681
|
-
body: "body".into(),
|
|
682
|
-
prompt: Prompt {
|
|
683
|
-
text: String::new(),
|
|
684
|
-
sha256: Digest([0; 32]),
|
|
685
|
-
sources: vec![],
|
|
686
|
-
},
|
|
687
|
-
};
|
|
688
|
-
assert!(!native_settings_changed(&old, &old.clone()));
|
|
689
|
-
for field in ["provider", "model", "effort", "bypass", "paused"] {
|
|
690
|
-
let mut current = old.clone();
|
|
691
|
-
match field {
|
|
692
|
-
"provider" => current.provider = ProviderId::new("kiro").unwrap(),
|
|
693
|
-
"model" => current.model = "changed".into(),
|
|
694
|
-
"effort" => current.effort = Some("high".into()),
|
|
695
|
-
"bypass" => current.bypass = false,
|
|
696
|
-
_ => current.paused = true,
|
|
697
|
-
}
|
|
698
|
-
assert!(
|
|
699
|
-
native_settings_changed(&old, ¤t),
|
|
700
|
-
"unexamined launch drift: {field}"
|
|
701
|
-
);
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
#[test]
|
|
706
|
-
fn original_supervised_shell_needs_both_current_native_frame_and_live_child() {
|
|
707
|
-
for shell in ["sh", "bash", "zsh", "fish"] {
|
|
708
|
-
assert!(surface_liveness(shell, true, true));
|
|
709
|
-
assert!(
|
|
710
|
-
!surface_liveness(shell, true, false),
|
|
711
|
-
"stale native screen without child"
|
|
712
|
-
);
|
|
713
|
-
assert!(
|
|
714
|
-
!surface_liveness(shell, false, true),
|
|
715
|
-
"inert tail sleep is not a provider"
|
|
716
|
-
);
|
|
717
|
-
assert!(!surface_liveness(shell, false, false));
|
|
718
|
-
}
|
|
719
|
-
assert!(!surface_liveness("", true, true));
|
|
720
|
-
assert!(surface_liveness("node", true, false));
|
|
721
|
-
assert!(!surface_liveness("node", false, true));
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
#[test]
|
|
725
|
-
fn provider_argv0_is_exact_basename_not_substring() {
|
|
726
|
-
use crate::model::enums::Provider;
|
|
727
|
-
assert!(argv0_names("claude", Provider::Claude));
|
|
728
|
-
assert!(argv0_names("/Users/u/.local/bin/claude", Provider::Claude));
|
|
729
|
-
assert!(argv0_names("claude", Provider::ClaudeCode));
|
|
730
|
-
for argv0 in ["2.1.309", "claude-wrapper", "team-agent", "node", ""] {
|
|
731
|
-
assert!(!argv0_names(argv0, Provider::Claude), "{argv0}");
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
#[test]
|
|
736
|
-
#[cfg(unix)]
|
|
737
|
-
fn version_named_native_install_is_identified_by_launch_argv0() {
|
|
738
|
-
// Claude Code's native installer execs `versions/<semver>`; tmux then
|
|
739
|
-
// reports e.g. `2.1.309` as the pane command while argv[0] stays `claude`.
|
|
740
|
-
use crate::model::enums::Provider;
|
|
741
|
-
use std::os::unix::process::CommandExt;
|
|
742
|
-
let mut claude = std::process::Command::new("sleep")
|
|
743
|
-
.arg0("claude")
|
|
744
|
-
.arg("30")
|
|
745
|
-
.spawn()
|
|
746
|
-
.unwrap();
|
|
747
|
-
let mut other = std::process::Command::new("sleep")
|
|
748
|
-
.arg("30")
|
|
749
|
-
.spawn()
|
|
750
|
-
.unwrap();
|
|
751
|
-
let launched = launched_as_provider(claude.id(), Provider::Claude);
|
|
752
|
-
let _ = claude.kill();
|
|
753
|
-
let _ = claude.wait();
|
|
754
|
-
assert!(launched);
|
|
755
|
-
let launched = launched_as_provider(other.id(), Provider::Claude);
|
|
756
|
-
let _ = other.kill();
|
|
757
|
-
let _ = other.wait();
|
|
758
|
-
assert!(!launched);
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
#[test]
|
|
762
|
-
#[cfg(unix)]
|
|
763
|
-
fn supervised_carrier_child_launched_as_provider_is_identified() {
|
|
764
|
-
// Original restart supervises the provider as a child of a shell carrier.
|
|
765
|
-
use crate::model::enums::Provider;
|
|
766
|
-
use std::os::unix::process::CommandExt;
|
|
767
|
-
let mut carrier = std::process::Command::new("bash")
|
|
768
|
-
.args(["-c", "exec -a claude sleep 30 & wait"])
|
|
769
|
-
.process_group(0)
|
|
770
|
-
.spawn()
|
|
771
|
-
.unwrap();
|
|
772
|
-
let deadline = std::time::Instant::now() + std::time::Duration::from_secs(5);
|
|
773
|
-
let mut launched = false;
|
|
774
|
-
while !launched && std::time::Instant::now() < deadline {
|
|
775
|
-
launched = launched_as_provider(carrier.id(), Provider::Claude);
|
|
776
|
-
std::thread::sleep(std::time::Duration::from_millis(20));
|
|
777
|
-
}
|
|
778
|
-
unsafe { libc::kill(-(carrier.id() as i32), libc::SIGKILL) };
|
|
779
|
-
let _ = carrier.wait();
|
|
780
|
-
assert!(launched);
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
#[test]
|
|
784
|
-
fn unchanged_observation_port_rejects_native_screen_followed_by_exit_tail() {
|
|
785
|
-
use crate::model::enums::Provider;
|
|
786
|
-
use crate::transport::native_input::inspect_input;
|
|
787
|
-
let native = "────────────────────────\n\n────────────────────────\ngpt-6-luna · max · 0%/272k · 0% · $0.00\n";
|
|
788
|
-
assert!(inspect_input(Provider::Pi, native, 24).is_some());
|
|
789
|
-
for tail in ["[team-agent worker] pi exited with 1\n", "[team-agent] Provider exited; this pane no longer accepts input. Restart from another pane with the appropriate team-agent start command.\n", "$ "] {
|
|
790
|
-
assert!(inspect_input(Provider::Pi, &format!("{native}{tail}"), 24).is_none());
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
#[test]
|
|
795
|
-
#[cfg(unix)]
|
|
796
|
-
fn native_kernel_exit_can_recover_ready_but_mismatched_liveness_never_noops() {
|
|
797
|
-
use team_agent_contract::{
|
|
798
|
-
host::process::ProcessState as P, orchestration::store::SeatStatus as S,
|
|
799
|
-
};
|
|
800
|
-
for (status, process, root, expected) in [
|
|
801
|
-
(S::Ready, P::Alive, "running", Observation::Live),
|
|
802
|
-
(S::Ready, P::Exited, "running", Observation::StoppedVerified),
|
|
803
|
-
(
|
|
804
|
-
S::Stopped,
|
|
805
|
-
P::Exited,
|
|
806
|
-
"stopped",
|
|
807
|
-
Observation::StoppedVerified,
|
|
808
|
-
),
|
|
809
|
-
(S::Ready, P::Alive, "stopped", Observation::Unknown),
|
|
810
|
-
(S::Stopped, P::Alive, "running", Observation::Unknown),
|
|
811
|
-
(S::Stopped, P::Exited, "running", Observation::Unknown),
|
|
812
|
-
(S::Ready, P::Replaced, "running", Observation::Unknown),
|
|
813
|
-
(
|
|
814
|
-
S::Ready,
|
|
815
|
-
P::Unknown(team_agent_contract::host::HostError::new(
|
|
816
|
-
"fixture",
|
|
817
|
-
team_agent_contract::host::HostErrorKind::Unknown,
|
|
818
|
-
)),
|
|
819
|
-
"running",
|
|
820
|
-
Observation::Unknown,
|
|
821
|
-
),
|
|
822
|
-
] {
|
|
823
|
-
assert_eq!(native_observation(status, process, Some(root)), expected);
|
|
824
|
-
}
|
|
825
|
-
}
|
|
826
|
-
|
|
827
|
-
#[test]
|
|
828
|
-
#[serial_test::serial(env)]
|
|
829
|
-
fn preserve_context_preflight_and_corrupt_metadata_refuse_before_stop() {
|
|
830
|
-
let (root, _) = fixture(&["one"]);
|
|
831
|
-
install(root.path(), &[("one", "running", false)]);
|
|
832
|
-
let selected =
|
|
833
|
-
resolve_active_team_readonly(root.path(), Some("fixture"), SelectorMode::RuntimeOnly)
|
|
834
|
-
.unwrap();
|
|
835
|
-
for signal in [
|
|
836
|
-
json!({"first_send_at":"2026-10-19T00:00:00Z"}),
|
|
837
|
-
json!({"task_prompt_delivered":true}),
|
|
838
|
-
json!({"last_result_at":"2026-10-19T00:00:00Z"}),
|
|
839
|
-
] {
|
|
840
|
-
let mut row = json!({"provider":"pi"});
|
|
841
|
-
row.as_object_mut()
|
|
842
|
-
.unwrap()
|
|
843
|
-
.extend(signal.as_object().unwrap().clone());
|
|
844
|
-
assert!(preflight_start(&selected, "one", &row, SessionPolicy::Preserve).is_err());
|
|
845
|
-
assert!(preflight_start(&selected, "one", &row, SessionPolicy::Auto).is_ok());
|
|
846
|
-
}
|
|
847
|
-
for field in [
|
|
848
|
-
"session_id",
|
|
849
|
-
"rollout_path",
|
|
850
|
-
"last_result_at",
|
|
851
|
-
"spawn_cwd",
|
|
852
|
-
"first_send_at",
|
|
853
|
-
"task_prompt_delivered",
|
|
854
|
-
] {
|
|
855
|
-
let mut row = json!({"provider":"pi"});
|
|
856
|
-
row[field] = json!([]);
|
|
857
|
-
for policy in [SessionPolicy::Auto, SessionPolicy::Preserve] {
|
|
858
|
-
assert!(
|
|
859
|
-
preflight_start(&selected, "one", &row, policy).is_err(),
|
|
860
|
-
"corrupt {field}"
|
|
861
|
-
);
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
let outside = Sandbox::new();
|
|
865
|
-
assert!(preflight_start(
|
|
866
|
-
&selected,
|
|
867
|
-
"one",
|
|
868
|
-
&json!({"provider":"pi", "spawn_cwd":outside.path()}),
|
|
869
|
-
SessionPolicy::Auto
|
|
870
|
-
)
|
|
871
|
-
.is_err());
|
|
872
|
-
assert!(preflight_start(
|
|
873
|
-
&selected,
|
|
874
|
-
"one",
|
|
875
|
-
&json!({"provider":"pi", "session_id":"captured"}),
|
|
876
|
-
SessionPolicy::Auto
|
|
877
|
-
)
|
|
878
|
-
.is_err());
|
|
879
|
-
}
|
|
880
|
-
|
|
881
|
-
#[test]
|
|
882
|
-
#[serial_test::serial(env)]
|
|
883
|
-
fn pinned_child_scope_never_inherits_parent_runtime_and_spec_only_never_creates() {
|
|
884
|
-
let (parent, _) = fixture(&["one"]);
|
|
885
|
-
install(parent.path(), &[("one", "running", false)]);
|
|
886
|
-
let child = parent.path().join("child");
|
|
887
|
-
std::fs::create_dir(&child).unwrap();
|
|
888
|
-
std::fs::create_dir(child.join("agents")).unwrap();
|
|
889
|
-
std::fs::write(
|
|
890
|
-
child.join("TEAM.md"),
|
|
891
|
-
"---\nname: child\nprovider: pi\n---\n",
|
|
892
|
-
)
|
|
893
|
-
.unwrap();
|
|
894
|
-
write_role(&child, "two");
|
|
895
|
-
let mut intent = super::super::tests::intent(Verb::Start);
|
|
896
|
-
intent.workspace = child.clone();
|
|
897
|
-
intent.team = None;
|
|
898
|
-
intent.subject = Subject::Team {
|
|
899
|
-
source: Some(child.clone()),
|
|
900
|
-
};
|
|
901
|
-
let plan = plan_with_observer(intent.clone(), |_, _, _| {
|
|
902
|
-
panic!("parent must not be selected")
|
|
903
|
-
})
|
|
904
|
-
.unwrap();
|
|
905
|
-
assert_eq!(plan.scope.workspace, child);
|
|
906
|
-
assert_eq!(actions(&plan), [("quick_start", None)]);
|
|
907
|
-
let path = crate::model::paths::runtime_spec_path(&child, "orphan");
|
|
908
|
-
std::fs::create_dir_all(path.parent().unwrap()).unwrap();
|
|
909
|
-
std::fs::write(path, "agents: []\n").unwrap();
|
|
910
|
-
assert!(plan_with_observer(intent, |_, _, _| panic!()).is_err());
|
|
911
|
-
assert!(!crate::state::persist::runtime_state_path(&child).exists());
|
|
912
|
-
}
|