@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,921 +0,0 @@
|
|
|
1
|
-
//! P0 RED contract: host co-tenant death / worker cohort identity.
|
|
2
|
-
//!
|
|
3
|
-
//! Source: `.team/artifacts/host-cotenant-death-p0-architecture-locate.md` §8.
|
|
4
|
-
|
|
5
|
-
#![cfg(unix)]
|
|
6
|
-
#![allow(clippy::expect_used, clippy::panic, clippy::unwrap_used)]
|
|
7
|
-
|
|
8
|
-
#[path = "../../../tests/support/hermetic.rs"]
|
|
9
|
-
mod hermetic_guard;
|
|
10
|
-
#[allow(dead_code)]
|
|
11
|
-
fn _hermetic_boundary_marker(_: &hermetic_guard::HermeticTestEnv) {}
|
|
12
|
-
|
|
13
|
-
use std::collections::{BTreeMap, BTreeSet};
|
|
14
|
-
use std::fs;
|
|
15
|
-
use std::os::unix::fs::PermissionsExt;
|
|
16
|
-
use std::path::{Path, PathBuf};
|
|
17
|
-
use std::sync::{Arc, Mutex};
|
|
18
|
-
|
|
19
|
-
use serde_json::{json, Value};
|
|
20
|
-
use serial_test::serial;
|
|
21
|
-
use team_agent::coordinator::{
|
|
22
|
-
coordinator_pid_path, Coordinator, MetadataSource, Pid, ProviderRegistry, WorkspacePath,
|
|
23
|
-
};
|
|
24
|
-
use team_agent::lifecycle::{
|
|
25
|
-
reset_agent_with_transport, restart_with_transport_with_readiness_deadline,
|
|
26
|
-
start_agent_with_transport, LifecycleError, RestartReport,
|
|
27
|
-
};
|
|
28
|
-
use team_agent::message_store::MessageStore;
|
|
29
|
-
use team_agent::model::enums::{PaneLiveness, Provider};
|
|
30
|
-
use team_agent::model::ids::AgentId;
|
|
31
|
-
use team_agent::model::paths::{runtime_dir, runtime_spec_path};
|
|
32
|
-
use team_agent::provider::{get_adapter, ProviderAdapter};
|
|
33
|
-
use team_agent::state::persist::{load_runtime_state, save_runtime_state};
|
|
34
|
-
use team_agent::transport::{
|
|
35
|
-
AttachOutcome, BackendKind, CaptureRange, CapturedText, InjectPayload, InjectReport,
|
|
36
|
-
InjectStage, InjectVerification, Key, PaneField, PaneId, PaneInfo, SessionName,
|
|
37
|
-
SetEnvOutcome, SpawnResult, SubmitVerification, Target, Transport, TransportError,
|
|
38
|
-
TurnVerification, WindowName,
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const TEAM: &str = "current";
|
|
42
|
-
const SESSION: &str = "team-current";
|
|
43
|
-
const TMUX_ENDPOINT: &str = "/private/tmp/ta-p0-cohort.sock";
|
|
44
|
-
const POLLUTED_CALLER_AUTHORITY_ENVS: &[&str] = &[
|
|
45
|
-
"TEAM_AGENT_LEADER_PANE_ID",
|
|
46
|
-
"TEAM_AGENT_LEADER_SESSION_UUID",
|
|
47
|
-
"TEAM_AGENT_LEADER_SESSION_UUID_OVERRIDE",
|
|
48
|
-
"TEAM_AGENT_LEADER_SESSION_NAME",
|
|
49
|
-
"TEAM_AGENT_LEADER_PROVIDER",
|
|
50
|
-
"TEAM_AGENT_MACHINE_FINGERPRINT",
|
|
51
|
-
"TEAM_AGENT_WORKSPACE",
|
|
52
|
-
"TEAM_AGENT_TEAM_ID",
|
|
53
|
-
"TEAM_AGENT_OWNER_TEAM_ID",
|
|
54
|
-
"TEAM_AGENT_ACTIVE_TEAM",
|
|
55
|
-
"TEAM_AGENT_ID",
|
|
56
|
-
"TEAM_AGENT_AGENT_ID",
|
|
57
|
-
"TEAM_AGENT_AUTH_MODE",
|
|
58
|
-
"TEAM_AGENT_LEADER_BYPASS",
|
|
59
|
-
"TEAM_AGENT_LEADER_BYPASS_SOURCE",
|
|
60
|
-
"TEAM_AGENT_LEADER_BYPASS_PROVIDER",
|
|
61
|
-
"TEAM_AGENT_LEADER_BYPASS_FLAG",
|
|
62
|
-
"TEAM_AGENT_MCP_AUTO_APPROVE",
|
|
63
|
-
"TEAM_AGENT_MCP_AUTO_APPROVE_SOURCE",
|
|
64
|
-
];
|
|
65
|
-
|
|
66
|
-
#[test]
|
|
67
|
-
#[serial(env, pid_probe)]
|
|
68
|
-
fn polluted_caller_env_never_authorizes_teardown_to_kill_foreign_tmux() {
|
|
69
|
-
let env = hermetic_guard::HermeticTestEnv::enter("p0-caller-env-sentinel");
|
|
70
|
-
let shim_dir = env.root().join("bin");
|
|
71
|
-
fs::create_dir_all(&shim_dir).unwrap();
|
|
72
|
-
let recorder = hermetic_guard::short_tmux_socket("p0-caller-env-recorder")
|
|
73
|
-
.with_extension("log");
|
|
74
|
-
let _ = fs::remove_file(&recorder);
|
|
75
|
-
let sentinel = env.root().join("foreign-sentinel.sock");
|
|
76
|
-
let polluted_tmux = format!("{},4242,0", sentinel.display());
|
|
77
|
-
|
|
78
|
-
let real_path = std::env::var_os("PATH").unwrap_or_default();
|
|
79
|
-
let real_tmux = std::env::split_paths(&real_path)
|
|
80
|
-
.map(|dir| dir.join("tmux"))
|
|
81
|
-
.find(|path| path.is_file())
|
|
82
|
-
.expect("real tmux binary on PATH");
|
|
83
|
-
let shim = shim_dir.join("tmux");
|
|
84
|
-
fs::write(
|
|
85
|
-
&shim,
|
|
86
|
-
r#"#!/bin/sh
|
|
87
|
-
{
|
|
88
|
-
printf 'TMUX=%s' "${TMUX-}"
|
|
89
|
-
for arg in "$@"; do printf '\t%s' "$arg"; done
|
|
90
|
-
printf '\n'
|
|
91
|
-
} >> "$TEAM_AGENT_TEST_TMUX_RECORDER_LOG"
|
|
92
|
-
case " $* " in
|
|
93
|
-
*" kill-session "*|*" kill-server "*) exit 0 ;;
|
|
94
|
-
esac
|
|
95
|
-
exec "$TEAM_AGENT_TEST_REAL_TMUX" "$@"
|
|
96
|
-
"#,
|
|
97
|
-
)
|
|
98
|
-
.unwrap();
|
|
99
|
-
let mut permissions = fs::metadata(&shim).unwrap().permissions();
|
|
100
|
-
permissions.set_mode(0o755);
|
|
101
|
-
fs::set_permissions(&shim, permissions).unwrap();
|
|
102
|
-
|
|
103
|
-
let mut polluted_env = vec![
|
|
104
|
-
env.with_env(
|
|
105
|
-
"PATH",
|
|
106
|
-
&format!("{}:{}", shim_dir.display(), real_path.to_string_lossy()),
|
|
107
|
-
),
|
|
108
|
-
env.with_env(
|
|
109
|
-
"TEAM_AGENT_TEST_TMUX_RECORDER_LOG",
|
|
110
|
-
recorder.to_str().unwrap(),
|
|
111
|
-
),
|
|
112
|
-
env.with_env("TEAM_AGENT_TEST_REAL_TMUX", real_tmux.to_str().unwrap()),
|
|
113
|
-
env.with_env("TMUX", &polluted_tmux),
|
|
114
|
-
env.with_env("TMUX_PANE", "%foreign-sentinel"),
|
|
115
|
-
];
|
|
116
|
-
for key in POLLUTED_CALLER_AUTHORITY_ENVS {
|
|
117
|
-
polluted_env.push(env.with_env(key, "foreign-caller-authority"));
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
let missing_scrub_keys = POLLUTED_CALLER_AUTHORITY_ENVS
|
|
121
|
-
.iter()
|
|
122
|
-
.filter(|key| !hermetic_guard::CALLER_IDENTITY_ENVS.contains(key))
|
|
123
|
-
.copied()
|
|
124
|
-
.collect::<Vec<_>>();
|
|
125
|
-
|
|
126
|
-
let _registration = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
|
|
127
|
-
env.register_owned_tmux_socket(&sentinel);
|
|
128
|
-
}));
|
|
129
|
-
drop(env);
|
|
130
|
-
|
|
131
|
-
let recorded = fs::read_to_string(&recorder).unwrap_or_default();
|
|
132
|
-
let destructive_hits = recorded
|
|
133
|
-
.lines()
|
|
134
|
-
.filter(|line| line.contains("\tkill-session") || line.contains("\tkill-server"))
|
|
135
|
-
.filter(|line| {
|
|
136
|
-
let explicit_endpoint = line.contains("\t-S\t") || line.contains("\t-L\t");
|
|
137
|
-
let targets_sentinel = line.split('\t').any(|arg| arg == sentinel.to_str().unwrap());
|
|
138
|
-
let inherits_sentinel = line.starts_with(&format!("TMUX={polluted_tmux}\t"));
|
|
139
|
-
targets_sentinel || (inherits_sentinel && !explicit_endpoint)
|
|
140
|
-
})
|
|
141
|
-
.collect::<Vec<_>>();
|
|
142
|
-
let _ = fs::remove_file(&recorder);
|
|
143
|
-
|
|
144
|
-
assert!(
|
|
145
|
-
missing_scrub_keys.is_empty() && destructive_hits.is_empty(),
|
|
146
|
-
"P0 caller-env boundary: polluted caller identity must never become teardown authority; missing_scrub_keys={missing_scrub_keys:?}; destructive tmux argv targeting ambient sentinel={destructive_hits:?}; all recorded argv={recorded:?}"
|
|
147
|
-
);
|
|
148
|
-
drop(polluted_env);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
#[test]
|
|
152
|
-
#[serial(env, pid_probe)]
|
|
153
|
-
fn restart_allow_fresh_does_not_leave_same_role_host_cotenants() {
|
|
154
|
-
let mut failures = Vec::new();
|
|
155
|
-
let (env, workspace) = team_case("p0-restart", &["developer", "test-engineer", "arch-reviewer"]);
|
|
156
|
-
let shim_dir = env.root().join("bin");
|
|
157
|
-
fs::create_dir_all(&shim_dir).unwrap();
|
|
158
|
-
let recorder = env.root().join("ps-recorder.log");
|
|
159
|
-
let real_path = std::env::var_os("PATH").unwrap_or_default();
|
|
160
|
-
let real_ps = std::env::split_paths(&real_path)
|
|
161
|
-
.map(|dir| dir.join("ps"))
|
|
162
|
-
.find(|path| path.is_file())
|
|
163
|
-
.expect("real ps binary on PATH");
|
|
164
|
-
let shim = shim_dir.join("ps");
|
|
165
|
-
fs::write(
|
|
166
|
-
&shim,
|
|
167
|
-
r#"#!/bin/sh
|
|
168
|
-
{
|
|
169
|
-
first=1
|
|
170
|
-
for arg in "$@"; do
|
|
171
|
-
if [ "$first" -eq 0 ]; then printf '\t'; fi
|
|
172
|
-
printf '%s' "$arg"
|
|
173
|
-
first=0
|
|
174
|
-
done
|
|
175
|
-
printf '\n'
|
|
176
|
-
} >> "$TEAM_AGENT_TEST_PS_RECORDER_LOG"
|
|
177
|
-
if [ "$#" -eq 4 ] && [ "$1" = "-p" ] && [ "$2" = "$TEAM_AGENT_TEST_SELF_PID" ] && [ "$3" = "-o" ] && [ "$4" = "stat=" ]; then
|
|
178
|
-
printf 'S\n'
|
|
179
|
-
exit 0
|
|
180
|
-
fi
|
|
181
|
-
exec "$TEAM_AGENT_TEST_REAL_PS" "$@"
|
|
182
|
-
"#,
|
|
183
|
-
)
|
|
184
|
-
.unwrap();
|
|
185
|
-
let mut permissions = fs::metadata(&shim).unwrap().permissions();
|
|
186
|
-
permissions.set_mode(0o755);
|
|
187
|
-
fs::set_permissions(&shim, permissions).unwrap();
|
|
188
|
-
let self_pid = std::process::id().to_string();
|
|
189
|
-
let _ps_env = [
|
|
190
|
-
env.with_env(
|
|
191
|
-
"PATH",
|
|
192
|
-
&format!("{}:{}", shim_dir.display(), real_path.to_string_lossy()),
|
|
193
|
-
),
|
|
194
|
-
env.with_env(
|
|
195
|
-
"TEAM_AGENT_TEST_PS_RECORDER_LOG",
|
|
196
|
-
recorder.to_str().unwrap(),
|
|
197
|
-
),
|
|
198
|
-
env.with_env("TEAM_AGENT_TEST_REAL_PS", real_ps.to_str().unwrap()),
|
|
199
|
-
env.with_env("TEAM_AGENT_TEST_SELF_PID", &self_pid),
|
|
200
|
-
];
|
|
201
|
-
let transport = CohortTransport::with_old_panes(&["developer", "test-engineer", "arch-reviewer"]);
|
|
202
|
-
let before = load_runtime_state(&workspace).unwrap();
|
|
203
|
-
let restart = restart_with_transport_with_readiness_deadline(
|
|
204
|
-
&workspace,
|
|
205
|
-
true,
|
|
206
|
-
Some(TEAM),
|
|
207
|
-
&transport,
|
|
208
|
-
Some(1_000),
|
|
209
|
-
);
|
|
210
|
-
if !matches!(&restart, Ok(RestartReport::Restarted { .. })) {
|
|
211
|
-
failures.push(format!(
|
|
212
|
-
"restart --allow-fresh: report must be Restarted, never readiness timeout; report={restart:?}"
|
|
213
|
-
));
|
|
214
|
-
}
|
|
215
|
-
collect_lifecycle_cohort_result(
|
|
216
|
-
&mut failures,
|
|
217
|
-
"restart --allow-fresh",
|
|
218
|
-
restart.map(|_| ()),
|
|
219
|
-
&transport,
|
|
220
|
-
);
|
|
221
|
-
let restart_coordinator_pid = fs::read_to_string(coordinator_pid_path(&WorkspacePath::new(
|
|
222
|
-
workspace.clone(),
|
|
223
|
-
)))
|
|
224
|
-
.unwrap_or_default();
|
|
225
|
-
if restart_coordinator_pid.trim() != self_pid {
|
|
226
|
-
failures.push(format!(
|
|
227
|
-
"restart --allow-fresh: seeded coordinator pid must remain the integration-test self pid; expected={self_pid}; actual={restart_coordinator_pid:?}"
|
|
228
|
-
));
|
|
229
|
-
}
|
|
230
|
-
let after = load_runtime_state(&workspace).unwrap();
|
|
231
|
-
for worker in ["developer", "test-engineer", "arch-reviewer"] {
|
|
232
|
-
let live = transport.live_panes_for_window(worker);
|
|
233
|
-
if live.len() != 1 {
|
|
234
|
-
failures.push(format!(
|
|
235
|
-
"restart --allow-fresh: {worker} must have one live tuple before state comparison; live={live:?}"
|
|
236
|
-
));
|
|
237
|
-
continue;
|
|
238
|
-
}
|
|
239
|
-
let live = &live[0];
|
|
240
|
-
let saved = &after["agents"][worker];
|
|
241
|
-
let prior = &before["agents"][worker];
|
|
242
|
-
let saved_tuple = (
|
|
243
|
-
saved.get("window").and_then(Value::as_str),
|
|
244
|
-
saved.get("pane_id").and_then(Value::as_str),
|
|
245
|
-
saved.get("pane_pid").and_then(Value::as_u64),
|
|
246
|
-
);
|
|
247
|
-
let live_tuple = (
|
|
248
|
-
live.window_name.as_ref().map(WindowName::as_str),
|
|
249
|
-
Some(live.pane_id.as_str()),
|
|
250
|
-
live.pane_pid.map(u64::from),
|
|
251
|
-
);
|
|
252
|
-
if saved_tuple != live_tuple {
|
|
253
|
-
failures.push(format!(
|
|
254
|
-
"restart --allow-fresh: {worker} saved state tuple must equal its sole live tuple; saved={saved_tuple:?}; live={live_tuple:?}"
|
|
255
|
-
));
|
|
256
|
-
}
|
|
257
|
-
let prior_pane = prior.get("pane_id").and_then(Value::as_str);
|
|
258
|
-
if saved.get("pane_id").and_then(Value::as_str) == prior_pane {
|
|
259
|
-
failures.push(format!(
|
|
260
|
-
"restart --allow-fresh: {worker} state must not remain bound to retired pane {prior_pane:?}"
|
|
261
|
-
));
|
|
262
|
-
}
|
|
263
|
-
let prior_epoch = prior.get("spawn_epoch").and_then(Value::as_u64).unwrap_or(0);
|
|
264
|
-
let saved_epoch = saved.get("spawn_epoch").and_then(Value::as_u64).unwrap_or(0);
|
|
265
|
-
if saved_epoch <= prior_epoch {
|
|
266
|
-
failures.push(format!(
|
|
267
|
-
"restart --allow-fresh: {worker} spawn_epoch must increase monotonically; before={prior_epoch}; after={saved_epoch}"
|
|
268
|
-
));
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
let (_env2, workspace2) = team_case("p0-start-force", &["developer"]);
|
|
272
|
-
let mut before_force = load_runtime_state(&workspace2).unwrap();
|
|
273
|
-
before_force["agents"]["developer"]["provider"] = json!("fake");
|
|
274
|
-
save_runtime_state(&workspace2, &before_force).unwrap();
|
|
275
|
-
let transport2 = CohortTransport::with_old_panes(&["developer"]);
|
|
276
|
-
collect_lifecycle_cohort_result(
|
|
277
|
-
&mut failures,
|
|
278
|
-
"start-agent --force",
|
|
279
|
-
start_agent_with_transport(&workspace2, &AgentId::new("developer"), true, false, true, Some(TEAM), &transport2).map(|_| ()),
|
|
280
|
-
&transport2,
|
|
281
|
-
);
|
|
282
|
-
let force_spawned = transport2
|
|
283
|
-
.pane_summary()
|
|
284
|
-
.into_iter()
|
|
285
|
-
.filter(|pane| pane.contains(":%new-"))
|
|
286
|
-
.collect::<Vec<_>>();
|
|
287
|
-
let after_force = load_runtime_state(&workspace2).unwrap();
|
|
288
|
-
if !force_spawned.is_empty()
|
|
289
|
-
|| after_force["agents"]["developer"]["pane_id"]
|
|
290
|
-
!= before_force["agents"]["developer"]["pane_id"]
|
|
291
|
-
{
|
|
292
|
-
failures.push(format!(
|
|
293
|
-
"start-agent --force: fake provider must share the same zero-mutation pre-spawn cohort refusal; spawned={force_spawned:?}; before={}; after={}",
|
|
294
|
-
before_force["agents"]["developer"], after_force["agents"]["developer"]
|
|
295
|
-
));
|
|
296
|
-
}
|
|
297
|
-
let start_force_coordinator_pid = fs::read_to_string(coordinator_pid_path(
|
|
298
|
-
&WorkspacePath::new(workspace2.clone()),
|
|
299
|
-
))
|
|
300
|
-
.unwrap_or_default();
|
|
301
|
-
if start_force_coordinator_pid.trim() != self_pid {
|
|
302
|
-
failures.push(format!(
|
|
303
|
-
"start-agent --force: seeded coordinator pid must remain the integration-test self pid; expected={self_pid}; actual={start_force_coordinator_pid:?}"
|
|
304
|
-
));
|
|
305
|
-
}
|
|
306
|
-
let recorded_ps = fs::read_to_string(&recorder).unwrap_or_default();
|
|
307
|
-
let expected_probe = format!("-p\t{self_pid}\t-o\tstat=");
|
|
308
|
-
if !recorded_ps.lines().any(|line| line == expected_probe) {
|
|
309
|
-
failures.push(format!(
|
|
310
|
-
"fixture ps shim must observe the exact self-pid coordinator health probe {expected_probe:?}; recorded={recorded_ps:?}"
|
|
311
|
-
));
|
|
312
|
-
}
|
|
313
|
-
assert!(
|
|
314
|
-
failures.is_empty(),
|
|
315
|
-
"P0 fixture1: lifecycle fresh/force paths must retire/swap/refuse so each (team_key, agent_id) has exactly one live tuple:\n{}",
|
|
316
|
-
failures.join("\n")
|
|
317
|
-
);
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
#[test]
|
|
321
|
-
#[serial(env)]
|
|
322
|
-
fn restart_bad_spawn_identity_fails_closed_before_stale_binding_and_new_orphan() {
|
|
323
|
-
let (_env, workspace) = team_case("p0-bad-spawn-identity", &["developer"]);
|
|
324
|
-
let before = load_runtime_state(&workspace).unwrap();
|
|
325
|
-
let old_pane = before["agents"]["developer"]["pane_id"]
|
|
326
|
-
.as_str()
|
|
327
|
-
.unwrap()
|
|
328
|
-
.to_string();
|
|
329
|
-
let old_epoch = before["agents"]["developer"]["spawn_epoch"]
|
|
330
|
-
.as_u64()
|
|
331
|
-
.unwrap();
|
|
332
|
-
let transport = CohortTransport::with_old_panes(&["developer"]).with_bad_spawn_identity();
|
|
333
|
-
|
|
334
|
-
let result = restart_with_transport_with_readiness_deadline(
|
|
335
|
-
&workspace,
|
|
336
|
-
true,
|
|
337
|
-
Some(TEAM),
|
|
338
|
-
&transport,
|
|
339
|
-
Some(0),
|
|
340
|
-
);
|
|
341
|
-
let report = format!("{result:?}");
|
|
342
|
-
let report_lower = report.to_ascii_lowercase();
|
|
343
|
-
let refused = !matches!(
|
|
344
|
-
&result,
|
|
345
|
-
Ok(RestartReport::Restarted { .. } | RestartReport::Partial { .. })
|
|
346
|
-
);
|
|
347
|
-
let named_identity_mismatch = report_lower.contains("spawn")
|
|
348
|
-
&& (report_lower.contains("identity") || report_lower.contains("binding"))
|
|
349
|
-
&& report_lower.contains("mismatch");
|
|
350
|
-
let after = load_runtime_state(&workspace).unwrap();
|
|
351
|
-
let saved = &after["agents"]["developer"];
|
|
352
|
-
let saved_pane = saved.get("pane_id").and_then(Value::as_str);
|
|
353
|
-
let saved_epoch = saved.get("spawn_epoch").and_then(Value::as_u64).unwrap_or(0);
|
|
354
|
-
let old_live = transport
|
|
355
|
-
.has_pane(&PaneId::new(old_pane.as_str()))
|
|
356
|
-
.unwrap()
|
|
357
|
-
.unwrap_or(false);
|
|
358
|
-
let new_live = transport
|
|
359
|
-
.live_panes_for_window("developer")
|
|
360
|
-
.into_iter()
|
|
361
|
-
.filter(|pane| pane.pane_id.as_str().starts_with("%new-"))
|
|
362
|
-
.map(|pane| pane.pane_id.as_str().to_string())
|
|
363
|
-
.collect::<Vec<_>>();
|
|
364
|
-
let stale_third_state = !old_live && saved_pane == Some(old_pane.as_str()) && !new_live.is_empty();
|
|
365
|
-
let old_redeclared_as_new = saved_pane == Some(old_pane.as_str()) && saved_epoch > old_epoch;
|
|
366
|
-
|
|
367
|
-
assert!(
|
|
368
|
-
refused && named_identity_mismatch && !stale_third_state && !old_redeclared_as_new,
|
|
369
|
-
"P0 bad-spawn-identity must fail closed with a spawn identity/binding mismatch and must never reach retired-old + state-bound-old + live-new-orphan third state; report={report}; old_live={old_live}; saved_pane={saved_pane:?}; epochs={old_epoch}->{saved_epoch}; new_live={new_live:?}; panes={:?}",
|
|
370
|
-
transport.pane_summary()
|
|
371
|
-
);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
#[test]
|
|
375
|
-
#[serial(env)]
|
|
376
|
-
fn start_agent_spawn_verification_failure_rolls_back_new_pane() {
|
|
377
|
-
let (_env, workspace) = team_case("p0-start-spawn-rollback", &["developer"]);
|
|
378
|
-
let before = load_runtime_state(&workspace).unwrap();
|
|
379
|
-
let old_pane = before["agents"]["developer"]["pane_id"]
|
|
380
|
-
.as_str()
|
|
381
|
-
.unwrap()
|
|
382
|
-
.to_string();
|
|
383
|
-
let old_epoch = before["agents"]["developer"]["spawn_epoch"]
|
|
384
|
-
.as_u64()
|
|
385
|
-
.unwrap();
|
|
386
|
-
let transport = CohortTransport::with_old_panes(&["developer"]).with_hidden_new_panes();
|
|
387
|
-
transport
|
|
388
|
-
.kill_pane(&PaneId::new(old_pane.as_str()))
|
|
389
|
-
.unwrap();
|
|
390
|
-
|
|
391
|
-
let result = start_agent_with_transport(
|
|
392
|
-
&workspace,
|
|
393
|
-
&AgentId::new("developer"),
|
|
394
|
-
true,
|
|
395
|
-
false,
|
|
396
|
-
true,
|
|
397
|
-
Some(TEAM),
|
|
398
|
-
&transport,
|
|
399
|
-
);
|
|
400
|
-
let report = format!("{result:?}");
|
|
401
|
-
let after = load_runtime_state(&workspace).unwrap();
|
|
402
|
-
let live_new = transport
|
|
403
|
-
.live_panes_for_window("developer")
|
|
404
|
-
.into_iter()
|
|
405
|
-
.filter(|pane| pane.pane_id.as_str().starts_with("%new-"))
|
|
406
|
-
.map(|pane| pane.pane_id.as_str().to_string())
|
|
407
|
-
.collect::<Vec<_>>();
|
|
408
|
-
|
|
409
|
-
assert!(
|
|
410
|
-
result.is_err() && report.contains("spawned pane not addressable"),
|
|
411
|
-
"spawn verification must fail closed with identity evidence; report={report}"
|
|
412
|
-
);
|
|
413
|
-
assert!(
|
|
414
|
-
live_new.is_empty(),
|
|
415
|
-
"a failed start-agent must kill only the pane created by that attempt; live_new={live_new:?}; panes={:?}",
|
|
416
|
-
transport.pane_summary()
|
|
417
|
-
);
|
|
418
|
-
assert_eq!(after["agents"]["developer"]["pane_id"], old_pane);
|
|
419
|
-
assert_eq!(
|
|
420
|
-
after["agents"]["developer"]["spawn_epoch"], old_epoch,
|
|
421
|
-
"failed replacement must leave persisted state authoritative"
|
|
422
|
-
);
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
#[test]
|
|
426
|
-
#[serial(env)]
|
|
427
|
-
fn start_agent_list_targets_failure_refuses_before_spawn() {
|
|
428
|
-
let (_env, workspace) = team_case("p0-start-observation-failure", &["developer"]);
|
|
429
|
-
let before = load_runtime_state(&workspace).unwrap();
|
|
430
|
-
let transport = CohortTransport::with_old_panes(&["developer"]).with_list_targets_failure();
|
|
431
|
-
|
|
432
|
-
let result = start_agent_with_transport(
|
|
433
|
-
&workspace,
|
|
434
|
-
&AgentId::new("developer"),
|
|
435
|
-
true,
|
|
436
|
-
false,
|
|
437
|
-
true,
|
|
438
|
-
Some(TEAM),
|
|
439
|
-
&transport,
|
|
440
|
-
);
|
|
441
|
-
let after = load_runtime_state(&workspace).unwrap();
|
|
442
|
-
let report = format!("{result:?}");
|
|
443
|
-
|
|
444
|
-
assert!(
|
|
445
|
-
result.is_err() && report.contains("same-role cohort observation failed"),
|
|
446
|
-
"an unobservable cohort must refuse before spawn; report={report}"
|
|
447
|
-
);
|
|
448
|
-
assert_eq!(after["agents"]["developer"], before["agents"]["developer"]);
|
|
449
|
-
assert!(
|
|
450
|
-
transport
|
|
451
|
-
.pane_summary()
|
|
452
|
-
.iter()
|
|
453
|
-
.all(|pane| !pane.contains(":%new-")),
|
|
454
|
-
"observation failure must not spawn a pane; panes={:?}",
|
|
455
|
-
transport.pane_summary()
|
|
456
|
-
);
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
#[test]
|
|
460
|
-
fn session_capture_claim_keys_are_typed_not_bare_strings() {
|
|
461
|
-
let capture_src = include_str!(concat!(
|
|
462
|
-
env!("CARGO_MANIFEST_DIR"),
|
|
463
|
-
"/src/provider/session/capture.rs"
|
|
464
|
-
));
|
|
465
|
-
assert!(
|
|
466
|
-
capture_src.contains("SessionAttributionKey")
|
|
467
|
-
&& !capture_src.contains("format!(\"session:{}\"")
|
|
468
|
-
&& !capture_src.contains("format!(\"rollout:{}\""),
|
|
469
|
-
"P0 capture contract: claimed/captured keys must be typed by provider+team_key+agent_id(+session/rollout), not bare session:/rollout: strings"
|
|
470
|
-
);
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
#[test]
|
|
474
|
-
#[serial(env)]
|
|
475
|
-
fn reset_stopped_true_still_rechecks_same_role_residue_before_start() {
|
|
476
|
-
let (_env, workspace) = team_case("p0-reset", &["developer"]);
|
|
477
|
-
let transport = CohortTransport::with_old_panes(&["developer"]);
|
|
478
|
-
|
|
479
|
-
let result = reset_agent_with_transport(&workspace, &AgentId::new("developer"), true, false, Some(TEAM), &transport);
|
|
480
|
-
let error_text = result.as_ref().err().map(ToString::to_string).unwrap_or_default();
|
|
481
|
-
assert!(
|
|
482
|
-
error_text.contains("stop_not_proven")
|
|
483
|
-
|| error_text.contains("residue")
|
|
484
|
-
|| error_text.contains("same-role"),
|
|
485
|
-
"P0 reset: stop.stopped=true is not proof when the same-role pane remains visible; reset must return a named residue proof error (stop_not_proven/residue/same-role) before spawning; result={result:?} error={error_text:?} panes={:?}",
|
|
486
|
-
transport.pane_summary()
|
|
487
|
-
);
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
#[test]
|
|
491
|
-
#[serial(env)]
|
|
492
|
-
fn abnormal_shell_pane_with_live_delivery_is_not_dead_and_dedupe_ignores_size() {
|
|
493
|
-
let env = hermetic_guard::HermeticTestEnv::enter("p0-abnormal");
|
|
494
|
-
let workspace = env.workspace("abnormal");
|
|
495
|
-
let rollout = workspace.join("architect-rollout.jsonl");
|
|
496
|
-
fs::write(&rollout, "{\"type\":\"session_meta\",\"payload\":{\"id\":\"sess-arch\",\"cwd\":\"/tmp\"}}\n").unwrap();
|
|
497
|
-
seed_healthy_coordinator(&workspace);
|
|
498
|
-
save_runtime_state(
|
|
499
|
-
&workspace,
|
|
500
|
-
&json!({
|
|
501
|
-
"active_team_key": TEAM,
|
|
502
|
-
"session_name": SESSION,
|
|
503
|
-
"agents": {
|
|
504
|
-
"architect": {
|
|
505
|
-
"status": "running",
|
|
506
|
-
"provider": "copilot",
|
|
507
|
-
"agent_id": "architect",
|
|
508
|
-
"window": "architect",
|
|
509
|
-
"pane_id": "%old-architect",
|
|
510
|
-
"session_id": "sess-arch",
|
|
511
|
-
"rollout_path": rollout.to_string_lossy(),
|
|
512
|
-
"spawn_epoch": 7,
|
|
513
|
-
"spawn_cwd": workspace.to_string_lossy()
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
}),
|
|
517
|
-
)
|
|
518
|
-
.unwrap();
|
|
519
|
-
let transport = CohortTransport::with_old_panes(&["architect"]).with_current_command("bash");
|
|
520
|
-
transport
|
|
521
|
-
.inject(
|
|
522
|
-
&Target::Pane(PaneId::new("%old-architect")),
|
|
523
|
-
&InjectPayload::Text("ping live tuple".to_string()),
|
|
524
|
-
Key::Enter,
|
|
525
|
-
false,
|
|
526
|
-
)
|
|
527
|
-
.expect("fixture proves the same physical tuple can receive a message");
|
|
528
|
-
let coord = Coordinator::new(
|
|
529
|
-
WorkspacePath::new(workspace.clone()),
|
|
530
|
-
Box::new(RealAdapterRegistry),
|
|
531
|
-
Box::new(transport.clone()),
|
|
532
|
-
);
|
|
533
|
-
let tick = coord.tick();
|
|
534
|
-
|
|
535
|
-
let state = load_runtime_state(&workspace).unwrap();
|
|
536
|
-
let watch = state
|
|
537
|
-
.pointer("/coordinator/abnormal_exit_watch/architect")
|
|
538
|
-
.cloned()
|
|
539
|
-
.unwrap_or(Value::Null);
|
|
540
|
-
let src = include_str!(concat!(
|
|
541
|
-
env!("CARGO_MANIFEST_DIR"),
|
|
542
|
-
"/src/coordinator/steps/abnormal.rs"
|
|
543
|
-
));
|
|
544
|
-
let mut failures = Vec::new();
|
|
545
|
-
if let Err(error) = tick { failures.push(format!("coordinator tick failed before abnormal fixture could be evaluated: {error}")); }
|
|
546
|
-
if watch.is_null() { failures.push("coordinator tick did not write abnormal_exit_watch for the live shell fixture".to_string()); }
|
|
547
|
-
if watch.pointer("/last_liveness").and_then(Value::as_str) == Some("dead")
|
|
548
|
-
|| watch
|
|
549
|
-
.pointer("/last_liveness_detail")
|
|
550
|
-
.and_then(Value::as_str)
|
|
551
|
-
.is_some_and(|detail| detail.contains("provider_not_foreground:bash"))
|
|
552
|
-
{
|
|
553
|
-
failures.push(format!(
|
|
554
|
-
"live wrapper shell with no exit marker was classified dead; watch={watch}"
|
|
555
|
-
));
|
|
556
|
-
}
|
|
557
|
-
for needle in [
|
|
558
|
-
"fn abnormal_dedupe_key(\n agent: &AbnormalWatchAgent,\n fact: &crate::provider::FaultFact,\n size: u64",
|
|
559
|
-
"fn abnormal_suppression_key(\n agent: &AbnormalWatchAgent,\n liveness: &ProcessCheck,\n reason: &str,\n size: u64",
|
|
560
|
-
"fn abnormal_check_key(\n agent: &AbnormalWatchAgent,\n liveness: &ProcessCheck,\n fact: Option<&crate::provider::FaultFact>,\n error_recency: ErrorRecency,\n error_observation_key: Option<&str>,\n size: u64",
|
|
561
|
-
"unwrap_or_else(|| size.to_string())",
|
|
562
|
-
] {
|
|
563
|
-
if src.contains(needle) {
|
|
564
|
-
failures.push(format!("abnormal dedupe/check identity still includes mutable rollout size marker `{needle}`"));
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
assert!(
|
|
568
|
-
failures.is_empty(),
|
|
569
|
-
"P0 abnormal contract failed:\n{}",
|
|
570
|
-
failures.join("\n")
|
|
571
|
-
);
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
#[test]
|
|
575
|
-
#[serial(env)]
|
|
576
|
-
fn status_model_uses_effective_copilot_source_not_stale_claude_state() {
|
|
577
|
-
let (_env, workspace) = team_case_with_model("p0-status", &[("developer", "gpt-5.6-sol")]);
|
|
578
|
-
let mut state = load_runtime_state(&workspace).unwrap();
|
|
579
|
-
state["agents"]["developer"]["provider"] = json!("copilot");
|
|
580
|
-
state["agents"]["developer"]["model"] = json!("claude-opus-4-7");
|
|
581
|
-
save_runtime_state(&workspace, &state).unwrap();
|
|
582
|
-
|
|
583
|
-
let status = team_agent::cli::status_port::status(&workspace, false, true)
|
|
584
|
-
.expect("status --json --detail");
|
|
585
|
-
let agent = status.pointer("/agents/developer").unwrap_or(&Value::Null);
|
|
586
|
-
let model = agent.get("model").and_then(Value::as_str);
|
|
587
|
-
let model_stale = agent.get("model_stale").and_then(Value::as_bool) == Some(true);
|
|
588
|
-
let model_source = agent.get("model_source").and_then(Value::as_str);
|
|
589
|
-
assert!(
|
|
590
|
-
model == Some("gpt-5.6-sol") || model_stale || model_source == Some("role"),
|
|
591
|
-
"P0 provider/model projection: Copilot seat must not render stale Claude model as truth; agent={agent} status={status}"
|
|
592
|
-
);
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
fn team_case(tag: &str, workers: &[&str]) -> (hermetic_guard::HermeticTestEnv, PathBuf) {
|
|
596
|
-
let pairs = workers.iter().map(|worker| (*worker, "gpt-5")).collect::<Vec<_>>();
|
|
597
|
-
team_case_with_model(tag, &pairs)
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
fn team_case_with_model(
|
|
601
|
-
tag: &str,
|
|
602
|
-
workers: &[(&str, &str)],
|
|
603
|
-
) -> (hermetic_guard::HermeticTestEnv, PathBuf) {
|
|
604
|
-
let env = hermetic_guard::HermeticTestEnv::enter(tag);
|
|
605
|
-
env.scrub_tmux();
|
|
606
|
-
env.assert_no_real_tmux();
|
|
607
|
-
let workspace = env.workspace(tag);
|
|
608
|
-
write_team_docs(&workspace, workers);
|
|
609
|
-
write_runtime_spec(&workspace);
|
|
610
|
-
seed_state(&workspace, workers);
|
|
611
|
-
seed_copilot_session_store(env.home(), workers);
|
|
612
|
-
seed_healthy_coordinator(&workspace);
|
|
613
|
-
(env, workspace)
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
fn write_team_docs(workspace: &Path, workers: &[(&str, &str)]) {
|
|
617
|
-
fs::create_dir_all(workspace.join("agents")).unwrap();
|
|
618
|
-
fs::write(workspace.join("TEAM.md"), "---\nname: current\nobjective: P0 host co-tenant contract.\nprovider: codex\n---\n").unwrap();
|
|
619
|
-
for (worker, model) in workers {
|
|
620
|
-
let role = format!("---\nname: {worker}\nrole: {worker}\nprovider: copilot\nmodel: {model}\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\n{worker}.\n");
|
|
621
|
-
fs::write(workspace.join("agents").join(format!("{worker}.md")), role).unwrap();
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
fn write_runtime_spec(workspace: &Path) {
|
|
626
|
-
let spec = team_agent::compiler::compile_team(workspace).unwrap();
|
|
627
|
-
let spec_text = team_agent::model::yaml::dumps(&spec);
|
|
628
|
-
fs::write(workspace.join("team.spec.yaml"), &spec_text).unwrap();
|
|
629
|
-
let path = runtime_spec_path(workspace, TEAM);
|
|
630
|
-
fs::create_dir_all(path.parent().unwrap()).unwrap();
|
|
631
|
-
fs::write(path, spec_text).unwrap();
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
fn seed_state(workspace: &Path, workers: &[(&str, &str)]) {
|
|
635
|
-
let agents = workers
|
|
636
|
-
.iter()
|
|
637
|
-
.map(|(worker, model)| ((*worker).to_string(), json!({
|
|
638
|
-
"status": "running", "provider": "copilot", "agent_id": worker, "role": worker,
|
|
639
|
-
"model": model, "auth_mode": "subscription", "tools": ["mcp_team"],
|
|
640
|
-
"window": worker, "pane_id": format!("%old-{worker}"), "pane_pid": 10_000,
|
|
641
|
-
"owner_team_id": TEAM,
|
|
642
|
-
"session_id": format!("sess-{worker}"),
|
|
643
|
-
"rollout_path": workspace.join(format!("{worker}.jsonl")).to_string_lossy(),
|
|
644
|
-
"spawn_epoch": 1, "spawn_cwd": workspace.to_string_lossy()
|
|
645
|
-
})))
|
|
646
|
-
.collect::<serde_json::Map<_, _>>();
|
|
647
|
-
for (worker, _) in workers {
|
|
648
|
-
fs::write(workspace.join(format!("{worker}.jsonl")), "{}\n").unwrap();
|
|
649
|
-
}
|
|
650
|
-
save_runtime_state(workspace, &json!({
|
|
651
|
-
"active_team_key": TEAM, "team_dir": workspace.to_string_lossy(),
|
|
652
|
-
"spec_path": workspace.join("team.spec.yaml").to_string_lossy(),
|
|
653
|
-
"session_name": SESSION, "agents": agents
|
|
654
|
-
})).unwrap();
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
fn seed_healthy_coordinator(workspace: &Path) {
|
|
658
|
-
fs::create_dir_all(runtime_dir(workspace)).unwrap();
|
|
659
|
-
let _ = MessageStore::open(workspace).unwrap();
|
|
660
|
-
let workspace = WorkspacePath::new(workspace.to_path_buf());
|
|
661
|
-
let pid = Pid::new(std::process::id());
|
|
662
|
-
team_agent::coordinator::write_coordinator_metadata(&workspace, pid, MetadataSource::Boot)
|
|
663
|
-
.unwrap();
|
|
664
|
-
fs::write(coordinator_pid_path(&workspace), pid.to_string()).unwrap();
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
/// Copilot resume backing is the `sessions` row in the hermetic
|
|
668
|
-
/// `$HOME/.copilot/session-store.db`.
|
|
669
|
-
fn seed_copilot_session_store(home: &Path, workers: &[(&str, &str)]) {
|
|
670
|
-
let db = home.join(".copilot").join("session-store.db");
|
|
671
|
-
fs::create_dir_all(db.parent().unwrap()).unwrap();
|
|
672
|
-
let conn = rusqlite::Connection::open(db).unwrap();
|
|
673
|
-
conn.execute_batch(
|
|
674
|
-
"create table if not exists sessions (id text primary key, cwd text, created_at text);",
|
|
675
|
-
)
|
|
676
|
-
.unwrap();
|
|
677
|
-
for (worker, _) in workers {
|
|
678
|
-
conn.execute(
|
|
679
|
-
"insert or replace into sessions(id, cwd, created_at) values (?1, ?2, '2026-01-01T00:00:00Z')",
|
|
680
|
-
rusqlite::params![format!("sess-{worker}"), home.to_string_lossy()],
|
|
681
|
-
)
|
|
682
|
-
.unwrap();
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
#[derive(Clone)]
|
|
687
|
-
struct CohortTransport {
|
|
688
|
-
state: Arc<Mutex<TransportState>>,
|
|
689
|
-
bad_spawn_identity: bool,
|
|
690
|
-
hide_new_from_list_targets: bool,
|
|
691
|
-
fail_list_targets: bool,
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
struct TransportState {
|
|
695
|
-
panes: Vec<PaneInfo>,
|
|
696
|
-
killed: BTreeSet<String>,
|
|
697
|
-
next: usize,
|
|
698
|
-
current_command: String,
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
impl CohortTransport {
|
|
702
|
-
fn with_old_panes(workers: &[&str]) -> Self {
|
|
703
|
-
let panes = workers.iter().map(|w| pane_info(w, &format!("%old-{w}"), "team-agent-worker")).collect();
|
|
704
|
-
Self {
|
|
705
|
-
state: Arc::new(Mutex::new(TransportState { panes, killed: BTreeSet::new(), next: 1, current_command: "team-agent-worker".to_string() })),
|
|
706
|
-
bad_spawn_identity: false,
|
|
707
|
-
hide_new_from_list_targets: false,
|
|
708
|
-
fail_list_targets: false,
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
fn with_bad_spawn_identity(mut self) -> Self {
|
|
713
|
-
self.bad_spawn_identity = true;
|
|
714
|
-
self
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
fn with_hidden_new_panes(mut self) -> Self {
|
|
718
|
-
self.hide_new_from_list_targets = true;
|
|
719
|
-
self
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
fn with_list_targets_failure(mut self) -> Self {
|
|
723
|
-
self.fail_list_targets = true;
|
|
724
|
-
self
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
fn with_current_command(self, command: &str) -> Self {
|
|
728
|
-
let mut state = self.state.lock().unwrap();
|
|
729
|
-
state.current_command = command.to_string();
|
|
730
|
-
for pane in &mut state.panes { pane.current_command = Some(command.to_string()); }
|
|
731
|
-
drop(state);
|
|
732
|
-
self
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
fn spawn(&self, session: &SessionName, window: &WindowName) -> SpawnResult {
|
|
736
|
-
let mut state = self.state.lock().unwrap();
|
|
737
|
-
let old_identity = state.panes.iter().find(|pane| {
|
|
738
|
-
pane.window_name.as_ref().is_some_and(|name| name == window)
|
|
739
|
-
&& pane.pane_id.as_str().starts_with("%old-")
|
|
740
|
-
&& !state.killed.contains(pane.pane_id.as_str())
|
|
741
|
-
}).map(|pane| (pane.pane_id.clone(), pane.pane_pid));
|
|
742
|
-
let pane_id = PaneId::new(format!("%new-{}-{}", window.as_str(), state.next));
|
|
743
|
-
let pane_pid = 20_000 + u32::try_from(state.next).unwrap();
|
|
744
|
-
state.next += 1;
|
|
745
|
-
let current_command = state.current_command.clone();
|
|
746
|
-
state.panes.push(pane_info_with_pid(
|
|
747
|
-
window.as_str(),
|
|
748
|
-
pane_id.as_str(),
|
|
749
|
-
current_command.as_str(),
|
|
750
|
-
pane_pid,
|
|
751
|
-
));
|
|
752
|
-
if self.bad_spawn_identity {
|
|
753
|
-
let (old_pane, old_pid) = old_identity.expect("bad identity fixture needs old pane");
|
|
754
|
-
SpawnResult { pane_id: old_pane, session: session.clone(), window: window.clone(), child_pid: old_pid }
|
|
755
|
-
} else {
|
|
756
|
-
SpawnResult { pane_id, session: session.clone(), window: window.clone(), child_pid: Some(pane_pid) }
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
fn pane_summary(&self) -> Vec<String> {
|
|
761
|
-
self.state.lock().unwrap().panes.iter().map(|p| {
|
|
762
|
-
format!("{}:{}", p.window_name.as_ref().map(WindowName::as_str).unwrap_or("-"), p.pane_id.as_str())
|
|
763
|
-
}).collect()
|
|
764
|
-
}
|
|
765
|
-
|
|
766
|
-
fn window_counts(&self) -> BTreeMap<String, usize> {
|
|
767
|
-
let mut counts = BTreeMap::new();
|
|
768
|
-
let state = self.state.lock().unwrap();
|
|
769
|
-
for pane in state.panes.iter().filter(|pane| !state.killed.contains(pane.pane_id.as_str())) {
|
|
770
|
-
if let Some(window) = pane.window_name.as_ref() { *counts.entry(window.as_str().to_string()).or_insert(0) += 1; }
|
|
771
|
-
}
|
|
772
|
-
counts
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
fn live_panes_for_window(&self, window: &str) -> Vec<PaneInfo> {
|
|
776
|
-
let state = self.state.lock().unwrap();
|
|
777
|
-
state.panes.iter().filter(|pane| {
|
|
778
|
-
!state.killed.contains(pane.pane_id.as_str())
|
|
779
|
-
&& pane.window_name.as_ref().is_some_and(|name| name.as_str() == window)
|
|
780
|
-
}).cloned().collect()
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
fn collect_lifecycle_cohort_result(
|
|
785
|
-
failures: &mut Vec<String>,
|
|
786
|
-
label: &str,
|
|
787
|
-
result: Result<(), LifecycleError>,
|
|
788
|
-
transport: &CohortTransport,
|
|
789
|
-
) {
|
|
790
|
-
let spawned = transport.pane_summary().into_iter().filter(|pane| pane.contains(":%new-")).collect::<Vec<_>>();
|
|
791
|
-
if let Err(error) = result {
|
|
792
|
-
let text = error.to_string();
|
|
793
|
-
if spawned.is_empty()
|
|
794
|
-
&& (text.contains("cohort") || text.contains("same-role") || text.contains("duplicate"))
|
|
795
|
-
{
|
|
796
|
-
return;
|
|
797
|
-
}
|
|
798
|
-
failures.push(if spawned.is_empty() {
|
|
799
|
-
format!("{label}: refusal must name cohort/duplicate proof; error={text}")
|
|
800
|
-
} else {
|
|
801
|
-
format!("{label}: refusal happened after spawning {spawned:?}, so it is not a safe pre-spawn cohort/duplicate refusal; error={text}; panes={:?}", transport.pane_summary())
|
|
802
|
-
});
|
|
803
|
-
return;
|
|
804
|
-
}
|
|
805
|
-
let duplicates = transport.window_counts().into_iter().filter(|(_, count)| *count != 1).map(|(window, count)| format!("{window}={count}")).collect::<Vec<_>>();
|
|
806
|
-
if !duplicates.is_empty() {
|
|
807
|
-
failures.push(format!(
|
|
808
|
-
"{label}: duplicate live tuple(s) {duplicates:?}; panes={:?}",
|
|
809
|
-
transport.pane_summary()
|
|
810
|
-
));
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
impl Transport for CohortTransport {
|
|
815
|
-
fn kind(&self) -> BackendKind { BackendKind::Tmux }
|
|
816
|
-
|
|
817
|
-
fn tmux_endpoint(&self) -> Option<String> { Some(TMUX_ENDPOINT.to_string()) }
|
|
818
|
-
|
|
819
|
-
fn spawn_first(
|
|
820
|
-
&self,
|
|
821
|
-
session: &SessionName,
|
|
822
|
-
window: &WindowName,
|
|
823
|
-
_argv: &[String],
|
|
824
|
-
_cwd: &Path,
|
|
825
|
-
_env: &BTreeMap<String, String>,
|
|
826
|
-
) -> Result<SpawnResult, TransportError> {
|
|
827
|
-
Ok(self.spawn(session, window))
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
fn spawn_into(&self, session: &SessionName, window: &WindowName, argv: &[String], cwd: &Path, env: &BTreeMap<String, String>) -> Result<SpawnResult, TransportError> {
|
|
831
|
-
self.spawn_first(session, window, argv, cwd, env)
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
fn inject(&self, _target: &Target, _payload: &InjectPayload, _submit: Key, _bracketed: bool) -> Result<InjectReport, TransportError> {
|
|
835
|
-
Ok(InjectReport { stage_reached: InjectStage::Submit, inject_verification: InjectVerification::CaptureContainsToken, submit_verification: SubmitVerification::EnterSentWithoutPlaceholderCheck, turn_verification: TurnVerification::NotRequired, attempts: 1, submit_diagnostics: None })
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
fn send_keys(&self, _target: &Target, _keys: &[Key]) -> Result<(), TransportError> { Ok(()) }
|
|
839
|
-
|
|
840
|
-
fn capture(&self, _target: &Target, range: CaptureRange) -> Result<CapturedText, TransportError> {
|
|
841
|
-
Ok(CapturedText { text: "wrapper shell prompt without team-agent provider exit marker".to_string(), range })
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
fn query(&self, _target: &Target, field: PaneField) -> Result<Option<String>, TransportError> {
|
|
845
|
-
Ok(match field {
|
|
846
|
-
PaneField::PaneId => Some("%query".to_string()),
|
|
847
|
-
PaneField::SessionName => Some(SESSION.to_string()),
|
|
848
|
-
PaneField::PaneCurrentCommand => Some(self.state.lock().unwrap().current_command.clone()),
|
|
849
|
-
_ => None,
|
|
850
|
-
})
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
fn liveness(&self, pane: &PaneId) -> Result<PaneLiveness, TransportError> {
|
|
854
|
-
Ok(if self.has_pane(pane)? == Some(true) { PaneLiveness::Live } else { PaneLiveness::Dead })
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
fn has_pane(&self, pane: &PaneId) -> Result<Option<bool>, TransportError> {
|
|
858
|
-
let state = self.state.lock().unwrap();
|
|
859
|
-
Ok(Some(!state.killed.contains(pane.as_str()) && state.panes.iter().any(|item| item.pane_id == *pane)))
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
fn list_targets(&self) -> Result<Vec<PaneInfo>, TransportError> {
|
|
863
|
-
if self.fail_list_targets {
|
|
864
|
-
return Err(TransportError::MuxUnavailable {
|
|
865
|
-
backend: BackendKind::Tmux,
|
|
866
|
-
detail: "injected list-targets failure".to_string(),
|
|
867
|
-
});
|
|
868
|
-
}
|
|
869
|
-
let state = self.state.lock().unwrap();
|
|
870
|
-
Ok(state.panes.iter().filter(|pane| {
|
|
871
|
-
!self.hide_new_from_list_targets || !pane.pane_id.as_str().starts_with("%new-")
|
|
872
|
-
}).cloned().collect())
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
fn has_session(&self, _session: &SessionName) -> Result<bool, TransportError> { Ok(true) }
|
|
876
|
-
|
|
877
|
-
fn list_windows(&self, _session: &SessionName) -> Result<Vec<WindowName>, TransportError> {
|
|
878
|
-
Ok(self.state.lock().unwrap().panes.iter().filter_map(|pane| pane.window_name.clone()).collect::<BTreeSet<_>>().into_iter().collect())
|
|
879
|
-
}
|
|
880
|
-
|
|
881
|
-
fn set_session_env(&self, _session: &SessionName, _key: &str, _value: &str) -> Result<SetEnvOutcome, TransportError> { Ok(SetEnvOutcome::Applied) }
|
|
882
|
-
|
|
883
|
-
fn kill_session(&self, _session: &SessionName) -> Result<(), TransportError> { Ok(()) }
|
|
884
|
-
|
|
885
|
-
fn kill_window(&self, target: &Target) -> Result<(), TransportError> {
|
|
886
|
-
if let Target::Pane(pane) = target { self.kill_pane(pane)?; }
|
|
887
|
-
Ok(())
|
|
888
|
-
}
|
|
889
|
-
|
|
890
|
-
fn kill_pane(&self, pane: &PaneId) -> Result<(), TransportError> {
|
|
891
|
-
self.state.lock().unwrap().killed.insert(pane.as_str().to_string());
|
|
892
|
-
Ok(())
|
|
893
|
-
}
|
|
894
|
-
|
|
895
|
-
fn attach_session(&self, _session: &SessionName) -> Result<AttachOutcome, TransportError> { Ok(AttachOutcome::Attached) }
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
fn pane_info(window: &str, pane: &str, current_command: &str) -> PaneInfo {
|
|
899
|
-
pane_info_with_pid(window, pane, current_command, 10_000)
|
|
900
|
-
}
|
|
901
|
-
|
|
902
|
-
fn pane_info_with_pid(window: &str, pane: &str, current_command: &str, pane_pid: u32) -> PaneInfo {
|
|
903
|
-
PaneInfo {
|
|
904
|
-
pane_id: PaneId::new(pane),
|
|
905
|
-
session: SessionName::new(SESSION),
|
|
906
|
-
window_name: Some(WindowName::new(window)),
|
|
907
|
-
window_index: None,
|
|
908
|
-
pane_index: None, tty: None,
|
|
909
|
-
current_command: Some(current_command.to_string()),
|
|
910
|
-
current_path: None, active: true, pane_pid: Some(pane_pid),
|
|
911
|
-
leader_env: BTreeMap::new(),
|
|
912
|
-
}
|
|
913
|
-
}
|
|
914
|
-
|
|
915
|
-
struct RealAdapterRegistry;
|
|
916
|
-
|
|
917
|
-
impl ProviderRegistry for RealAdapterRegistry {
|
|
918
|
-
fn adapter_for(&self, provider: Provider) -> Box<dyn ProviderAdapter> {
|
|
919
|
-
get_adapter(provider)
|
|
920
|
-
}
|
|
921
|
-
}
|