@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.
Files changed (436) hide show
  1. package/README.md +4 -4
  2. package/README.zh.md +1 -1
  3. package/package.json +4 -8
  4. package/skills/team-agent/SKILL.md +37 -20
  5. package/skills/team-agent/command-coverage.json +169 -183
  6. package/skills/team-agent/docs/reference/team-agent-operator.md +64 -30
  7. package/skills/team-agent/references/recovery-runbook.md +1 -1
  8. package/skills/team-agent/references/team-agent-operator.md +64 -30
  9. package/templates/team_state.md +1 -1
  10. package/Cargo.lock +0 -1063
  11. package/Cargo.toml +0 -36
  12. package/crates/team-agent/Cargo.toml +0 -69
  13. package/crates/team-agent/src/app_server_test_support.rs +0 -258
  14. package/crates/team-agent/src/cli/adapters.rs +0 -1288
  15. package/crates/team-agent/src/cli/arguments.rs +0 -405
  16. package/crates/team-agent/src/cli/attach_app_server_leader.rs +0 -98
  17. package/crates/team-agent/src/cli/diagnose.rs +0 -1721
  18. package/crates/team-agent/src/cli/emit.rs +0 -2930
  19. package/crates/team-agent/src/cli/grok_slot.rs +0 -384
  20. package/crates/team-agent/src/cli/helpers.rs +0 -91
  21. package/crates/team-agent/src/cli/intent/runtime.rs +0 -1216
  22. package/crates/team-agent/src/cli/intent/runtime_tests.rs +0 -912
  23. package/crates/team-agent/src/cli/intent/tests.rs +0 -689
  24. package/crates/team-agent/src/cli/intent.rs +0 -664
  25. package/crates/team-agent/src/cli/leader.rs +0 -300
  26. package/crates/team-agent/src/cli/leader_prompt.rs +0 -261
  27. package/crates/team-agent/src/cli/leaders.rs +0 -418
  28. package/crates/team-agent/src/cli/mod.rs +0 -6545
  29. package/crates/team-agent/src/cli/models.rs +0 -1206
  30. package/crates/team-agent/src/cli/named_address.rs +0 -1651
  31. package/crates/team-agent/src/cli/profile.rs +0 -342
  32. package/crates/team-agent/src/cli/route.rs +0 -212
  33. package/crates/team-agent/src/cli/schedule.rs +0 -175
  34. package/crates/team-agent/src/cli/send/coordinator.rs +0 -164
  35. package/crates/team-agent/src/cli/send/mailbox.rs +0 -145
  36. package/crates/team-agent/src/cli/send/persist.rs +0 -156
  37. package/crates/team-agent/src/cli/send/presentation.rs +0 -370
  38. package/crates/team-agent/src/cli/send/resolve.rs +0 -573
  39. package/crates/team-agent/src/cli/send.rs +0 -199
  40. package/crates/team-agent/src/cli/shutdown_socket.rs +0 -288
  41. package/crates/team-agent/src/cli/spec.rs +0 -165
  42. package/crates/team-agent/src/cli/status.rs +0 -280
  43. package/crates/team-agent/src/cli/status_port/agents.rs +0 -358
  44. package/crates/team-agent/src/cli/status_port/approvals.rs +0 -79
  45. package/crates/team-agent/src/cli/status_port/brief.rs +0 -1981
  46. package/crates/team-agent/src/cli/status_port/compact.rs +0 -240
  47. package/crates/team-agent/src/cli/status_port/format.rs +0 -146
  48. package/crates/team-agent/src/cli/status_port/inbox.rs +0 -62
  49. package/crates/team-agent/src/cli/status_port/runtime.rs +0 -197
  50. package/crates/team-agent/src/cli/status_port/snapshot.rs +0 -208
  51. package/crates/team-agent/src/cli/status_port/store.rs +0 -416
  52. package/crates/team-agent/src/cli/status_port/tests.rs +0 -90
  53. package/crates/team-agent/src/cli/status_port.rs +0 -92
  54. package/crates/team-agent/src/cli/tests/base.rs +0 -885
  55. package/crates/team-agent/src/cli/tests/divergence.rs +0 -518
  56. package/crates/team-agent/src/cli/tests/lane_c.rs +0 -453
  57. package/crates/team-agent/src/cli/tests/leader_watch.rs +0 -322
  58. package/crates/team-agent/src/cli/tests/main_preserved.rs +0 -430
  59. package/crates/team-agent/src/cli/tests/missing_subcommands.rs +0 -336
  60. package/crates/team-agent/src/cli/tests/mod.rs +0 -137
  61. package/crates/team-agent/src/cli/tests/named_address.rs +0 -761
  62. package/crates/team-agent/src/cli/tests/parser_safety.rs +0 -383
  63. package/crates/team-agent/src/cli/tests/run_delegation.rs +0 -484
  64. package/crates/team-agent/src/cli/tests/shutdown_kill_plan.rs +0 -2179
  65. package/crates/team-agent/src/cli/tests/status_brief.rs +0 -1514
  66. package/crates/team-agent/src/cli/tests/status_send.rs +0 -888
  67. package/crates/team-agent/src/cli/tests/verb_install_skill.rs +0 -93
  68. package/crates/team-agent/src/cli/tests/verb_profile.rs +0 -392
  69. package/crates/team-agent/src/cli/triage.rs +0 -234
  70. package/crates/team-agent/src/cli/types.rs +0 -591
  71. package/crates/team-agent/src/codex_app_server.rs +0 -546
  72. package/crates/team-agent/src/communication_mode/mod.rs +0 -56
  73. package/crates/team-agent/src/compiler/tests.rs +0 -827
  74. package/crates/team-agent/src/compiler.rs +0 -890
  75. package/crates/team-agent/src/conpty/backend.rs +0 -829
  76. package/crates/team-agent/src/conpty/mod.rs +0 -33
  77. package/crates/team-agent/src/contract_runtime/backend.rs +0 -1744
  78. package/crates/team-agent/src/contract_runtime/commands.rs +0 -671
  79. package/crates/team-agent/src/contract_runtime/config.rs +0 -364
  80. package/crates/team-agent/src/contract_runtime/config_tests.rs +0 -76
  81. package/crates/team-agent/src/contract_runtime/discovery.rs +0 -449
  82. package/crates/team-agent/src/contract_runtime/fork.rs +0 -361
  83. package/crates/team-agent/src/contract_runtime/forward.rs +0 -288
  84. package/crates/team-agent/src/contract_runtime/framework.rs +0 -367
  85. package/crates/team-agent/src/contract_runtime/mcp.rs +0 -394
  86. package/crates/team-agent/src/contract_runtime/mod.rs +0 -17
  87. package/crates/team-agent/src/contract_runtime/prompt.rs +0 -216
  88. package/crates/team-agent/src/contract_runtime/pump.rs +0 -271
  89. package/crates/team-agent/src/contract_runtime/registry.rs +0 -553
  90. package/crates/team-agent/src/contract_runtime/workspace.rs +0 -228
  91. package/crates/team-agent/src/coordinator/backoff.rs +0 -741
  92. package/crates/team-agent/src/coordinator/conpty_shim.rs +0 -805
  93. package/crates/team-agent/src/coordinator/health.rs +0 -1185
  94. package/crates/team-agent/src/coordinator/mod.rs +0 -119
  95. package/crates/team-agent/src/coordinator/orphan.rs +0 -110
  96. package/crates/team-agent/src/coordinator/runtime_detectors.rs +0 -798
  97. package/crates/team-agent/src/coordinator/runtime_observation.rs +0 -84
  98. package/crates/team-agent/src/coordinator/steps/abnormal.rs +0 -2309
  99. package/crates/team-agent/src/coordinator/steps/delivery.rs +0 -15
  100. package/crates/team-agent/src/coordinator/steps/health_sync.rs +0 -15
  101. package/crates/team-agent/src/coordinator/steps/mod.rs +0 -126
  102. package/crates/team-agent/src/coordinator/steps/persist.rs +0 -15
  103. package/crates/team-agent/src/coordinator/steps/runtime_prompts.rs +0 -15
  104. package/crates/team-agent/src/coordinator/steps/session_gate.rs +0 -16
  105. package/crates/team-agent/src/coordinator/tests/a0_lostupdate.rs +0 -158
  106. package/crates/team-agent/src/coordinator/tests/abnormal.rs +0 -312
  107. package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +0 -300
  108. package/crates/team-agent/src/coordinator/tests/basics.rs +0 -211
  109. package/crates/team-agent/src/coordinator/tests/daemon.rs +0 -514
  110. package/crates/team-agent/src/coordinator/tests/energy.rs +0 -549
  111. package/crates/team-agent/src/coordinator/tests/health_sync.rs +0 -503
  112. package/crates/team-agent/src/coordinator/tests/main_preserved.rs +0 -186
  113. package/crates/team-agent/src/coordinator/tests/mod.rs +0 -295
  114. package/crates/team-agent/src/coordinator/tests/s3_bounded.rs +0 -207
  115. package/crates/team-agent/src/coordinator/tests/spine.rs +0 -308
  116. package/crates/team-agent/src/coordinator/tests/takeover.rs +0 -286
  117. package/crates/team-agent/src/coordinator/tests/tick_core.rs +0 -237
  118. package/crates/team-agent/src/coordinator/tick.rs +0 -3024
  119. package/crates/team-agent/src/coordinator/types.rs +0 -540
  120. package/crates/team-agent/src/db/agent_health_capture.rs +0 -126
  121. package/crates/team-agent/src/db/message_store.rs +0 -1527
  122. package/crates/team-agent/src/db/migration.rs +0 -984
  123. package/crates/team-agent/src/db/mod.rs +0 -26
  124. package/crates/team-agent/src/db/schema.rs +0 -663
  125. package/crates/team-agent/src/diagnose/comms.rs +0 -242
  126. package/crates/team-agent/src/diagnose/mod.rs +0 -44
  127. package/crates/team-agent/src/diagnose/orphans.rs +0 -889
  128. package/crates/team-agent/src/direct_delivery.rs +0 -368
  129. package/crates/team-agent/src/event_log.rs +0 -502
  130. package/crates/team-agent/src/fake_worker.rs +0 -303
  131. package/crates/team-agent/src/inbox_store.rs +0 -169
  132. package/crates/team-agent/src/kill_audit.rs +0 -106
  133. package/crates/team-agent/src/layout/manager.rs +0 -248
  134. package/crates/team-agent/src/layout/mod.rs +0 -36
  135. package/crates/team-agent/src/layout/overlay.rs +0 -134
  136. package/crates/team-agent/src/layout/placement.rs +0 -52
  137. package/crates/team-agent/src/layout/recovery.rs +0 -106
  138. package/crates/team-agent/src/layout/runtime_sessions.rs +0 -317
  139. package/crates/team-agent/src/layout/sessions.rs +0 -294
  140. package/crates/team-agent/src/layout/tmux_endpoint.rs +0 -165
  141. package/crates/team-agent/src/layout/worker_env.rs +0 -721
  142. package/crates/team-agent/src/layout/worker_window_helpers.rs +0 -37
  143. package/crates/team-agent/src/leader/helpers.rs +0 -178
  144. package/crates/team-agent/src/leader/incident.rs +0 -6
  145. package/crates/team-agent/src/leader/lease.rs +0 -3356
  146. package/crates/team-agent/src/leader/mod.rs +0 -104
  147. package/crates/team-agent/src/leader/owner_bind.rs +0 -400
  148. package/crates/team-agent/src/leader/prompt.rs +0 -905
  149. package/crates/team-agent/src/leader/provider_attribution.rs +0 -247
  150. package/crates/team-agent/src/leader/rediscover/tests.rs +0 -689
  151. package/crates/team-agent/src/leader/rediscover.rs +0 -1192
  152. package/crates/team-agent/src/leader/registry.rs +0 -888
  153. package/crates/team-agent/src/leader/start.rs +0 -4501
  154. package/crates/team-agent/src/leader/takeover.rs +0 -65
  155. package/crates/team-agent/src/leader/tests/basics.rs +0 -337
  156. package/crates/team-agent/src/leader/tests/byte_findings.rs +0 -355
  157. package/crates/team-agent/src/leader/tests/claim_leader_mailbox_flush_contract.rs +0 -544
  158. package/crates/team-agent/src/leader/tests/historical_inventory_upgrade_gate_red.rs +0 -624
  159. package/crates/team-agent/src/leader/tests/identity.rs +0 -465
  160. package/crates/team-agent/src/leader/tests/identity_session_names.rs +0 -42
  161. package/crates/team-agent/src/leader/tests/idle.rs +0 -113
  162. package/crates/team-agent/src/leader/tests/lease_api.rs +0 -520
  163. package/crates/team-agent/src/leader/tests/lease_claim.rs +0 -629
  164. package/crates/team-agent/src/leader/tests/mod.rs +0 -106
  165. package/crates/team-agent/src/leader/tests/prompt_contract.rs +0 -268
  166. package/crates/team-agent/src/leader/tests/rediscover.rs +0 -403
  167. package/crates/team-agent/src/leader/tests/rehomed_env.rs +0 -83
  168. package/crates/team-agent/src/leader/tests/team_in_team_state_scope_red.rs +0 -1273
  169. package/crates/team-agent/src/leader/tests/terminal_and_replay_vs_rerender_invariants_red.rs +0 -417
  170. package/crates/team-agent/src/leader/tests/wake_start_owner.rs +0 -168
  171. package/crates/team-agent/src/leader/types.rs +0 -534
  172. package/crates/team-agent/src/lib.rs +0 -147
  173. package/crates/team-agent/src/lifecycle/helpers.rs +0 -212
  174. package/crates/team-agent/src/lifecycle/launch/add_agent.rs +0 -881
  175. package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +0 -598
  176. package/crates/team-agent/src/lifecycle/launch/agent_state.rs +0 -332
  177. package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +0 -204
  178. package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +0 -107
  179. package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +0 -144
  180. package/crates/team-agent/src/lifecycle/launch/identity.rs +0 -674
  181. package/crates/team-agent/src/lifecycle/launch/layout.rs +0 -350
  182. package/crates/team-agent/src/lifecycle/launch/leader_context.rs +0 -589
  183. package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +0 -160
  184. package/crates/team-agent/src/lifecycle/launch/ownership.rs +0 -105
  185. package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +0 -899
  186. package/crates/team-agent/src/lifecycle/launch/pi_mcp_extension.js +0 -225
  187. package/crates/team-agent/src/lifecycle/launch/plan.rs +0 -269
  188. package/crates/team-agent/src/lifecycle/launch/quick_start.rs +0 -5200
  189. package/crates/team-agent/src/lifecycle/launch/quick_start_transport.rs +0 -368
  190. package/crates/team-agent/src/lifecycle/launch/readiness.rs +0 -519
  191. package/crates/team-agent/src/lifecycle/launch/role_source.rs +0 -287
  192. package/crates/team-agent/src/lifecycle/launch/spawn.rs +0 -473
  193. package/crates/team-agent/src/lifecycle/launch/spec_state.rs +0 -801
  194. package/crates/team-agent/src/lifecycle/launch/state_projection.rs +0 -624
  195. package/crates/team-agent/src/lifecycle/launch/worker_env.rs +0 -558
  196. package/crates/team-agent/src/lifecycle/launch.rs +0 -557
  197. package/crates/team-agent/src/lifecycle/lock.rs +0 -350
  198. package/crates/team-agent/src/lifecycle/mod.rs +0 -79
  199. package/crates/team-agent/src/lifecycle/pane_input_lock.rs +0 -239
  200. package/crates/team-agent/src/lifecycle/profile_launch.rs +0 -1067
  201. package/crates/team-agent/src/lifecycle/profile_smoke.rs +0 -557
  202. package/crates/team-agent/src/lifecycle/restart/agent.rs +0 -2199
  203. package/crates/team-agent/src/lifecycle/restart/avatar.rs +0 -1798
  204. package/crates/team-agent/src/lifecycle/restart/claude_fork.rs +0 -163
  205. package/crates/team-agent/src/lifecycle/restart/common.rs +0 -2362
  206. package/crates/team-agent/src/lifecycle/restart/orchestrator.rs +0 -65
  207. package/crates/team-agent/src/lifecycle/restart/preflight.rs +0 -113
  208. package/crates/team-agent/src/lifecycle/restart/rebuild.rs +0 -5135
  209. package/crates/team-agent/src/lifecycle/restart/remove.rs +0 -1504
  210. package/crates/team-agent/src/lifecycle/restart/selection.rs +0 -559
  211. package/crates/team-agent/src/lifecycle/restart/team_state.rs +0 -329
  212. package/crates/team-agent/src/lifecycle/restart.rs +0 -227
  213. package/crates/team-agent/src/lifecycle/role_config.rs +0 -1230
  214. package/crates/team-agent/src/lifecycle/tests/acceptance_b_batch_red.rs +0 -1021
  215. package/crates/team-agent/src/lifecycle/tests/agent_ops.rs +0 -1205
  216. package/crates/team-agent/src/lifecycle/tests/b0_legacy_snapshot_nonauthority_contract.rs +0 -265
  217. package/crates/team-agent/src/lifecycle/tests/b0_reader_hideone_audit_contract.rs +0 -490
  218. package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +0 -656
  219. package/crates/team-agent/src/lifecycle/tests/claude_compatible_config_red.rs +0 -325
  220. package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +0 -447
  221. package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +0 -1638
  222. package/crates/team-agent/src/lifecycle/tests/clone_agent_preserves_source_tools.rs +0 -427
  223. package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +0 -770
  224. package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +0 -419
  225. package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +0 -2035
  226. package/crates/team-agent/src/lifecycle/tests/core.rs +0 -1327
  227. package/crates/team-agent/src/lifecycle/tests/f032_startup_prompt_best_effort_red.rs +0 -315
  228. package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_g0.stdout.txt +0 -222
  229. package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_spaced_ids.stdout.txt +0 -9
  230. package/crates/team-agent/src/lifecycle/tests/fixtures/pi_native_mcp_host.mjs +0 -72
  231. package/crates/team-agent/src/lifecycle/tests/gate_fixtures.rs +0 -562
  232. package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +0 -110
  233. package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +0 -512
  234. package/crates/team-agent/src/lifecycle/tests/host_cotenant_death_p0_contract.rs +0 -921
  235. package/crates/team-agent/src/lifecycle/tests/issue238_codex_effort_contract.rs +0 -68
  236. package/crates/team-agent/src/lifecycle/tests/lane_ops.rs +0 -1851
  237. package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +0 -3983
  238. package/crates/team-agent/src/lifecycle/tests/lifecycle_lock.rs +0 -339
  239. package/crates/team-agent/src/lifecycle/tests/lifecycle_rollback_red.rs +0 -596
  240. package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +0 -513
  241. package/crates/team-agent/src/lifecycle/tests/mcp_tool_name_format_red.rs +0 -69
  242. package/crates/team-agent/src/lifecycle/tests/phase_b_contracts.rs +0 -824
  243. package/crates/team-agent/src/lifecycle/tests/phase_golden.rs +0 -723
  244. package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +0 -164
  245. package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +0 -200
  246. package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +0 -210
  247. package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +0 -527
  248. package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +0 -1062
  249. package/crates/team-agent/src/lifecycle/tests/pi_fork_session_inheritance_red.rs +0 -1419
  250. package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +0 -98
  251. package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +0 -550
  252. package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +0 -226
  253. package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +0 -332
  254. package/crates/team-agent/src/lifecycle/tests/realmachine_clusters_1_6_red.rs +0 -786
  255. package/crates/team-agent/src/lifecycle/tests/realmachine_residual_g1_g4_red.rs +0 -648
  256. package/crates/team-agent/src/lifecycle/tests/restart.rs +0 -185
  257. package/crates/team-agent/src/lifecycle/tests/restart_build_before_destroy_0540_contract.rs +0 -1053
  258. package/crates/team-agent/src/lifecycle/tests/restart_liveness_red.rs +0 -679
  259. package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +0 -1126
  260. package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +0 -153
  261. package/crates/team-agent/src/lifecycle/tests/resume_recover_red.rs +0 -427
  262. package/crates/team-agent/src/lifecycle/tests/stale_team_saveconflict_contract.rs +0 -431
  263. package/crates/team-agent/src/lifecycle/tests/startup_latency_contract.rs +0 -1066
  264. package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +0 -876
  265. package/crates/team-agent/src/lifecycle/tests/subprep_codex_trust_roundtrip_red.rs +0 -1026
  266. package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +0 -342
  267. package/crates/team-agent/src/lifecycle/tests/team_in_team_identity_scope_red.rs +0 -543
  268. package/crates/team-agent/src/lifecycle/tests/team_in_team_sibling_quick_start_red.rs +0 -1103
  269. package/crates/team-agent/src/lifecycle/tests/team_in_team_state_scope_red.rs +0 -1276
  270. package/crates/team-agent/src/lifecycle/tests/team_key_retirement_roster_red.rs +0 -145
  271. package/crates/team-agent/src/lifecycle/tests/team_key_retirement_txn_red.rs +0 -603
  272. package/crates/team-agent/src/lifecycle/tests/test_isolation_escape_contract.rs +0 -936
  273. package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +0 -970
  274. package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +0 -995
  275. package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +0 -836
  276. package/crates/team-agent/src/lifecycle/tests.rs +0 -105
  277. package/crates/team-agent/src/lifecycle/types.rs +0 -877
  278. package/crates/team-agent/src/lifecycle/worker_command_context.rs +0 -363
  279. package/crates/team-agent/src/main.rs +0 -52
  280. package/crates/team-agent/src/mcp_server/helpers.rs +0 -510
  281. package/crates/team-agent/src/mcp_server/lifecycle_tools/mod.rs +0 -6
  282. package/crates/team-agent/src/mcp_server/lifecycle_tools/state_status.rs +0 -43
  283. package/crates/team-agent/src/mcp_server/mod.rs +0 -119
  284. package/crates/team-agent/src/mcp_server/normalize.rs +0 -485
  285. package/crates/team-agent/src/mcp_server/readiness.rs +0 -527
  286. package/crates/team-agent/src/mcp_server/readiness_tests.rs +0 -348
  287. package/crates/team-agent/src/mcp_server/tests/golden.rs +0 -285
  288. package/crates/team-agent/src/mcp_server/tests/normalize.rs +0 -247
  289. package/crates/team-agent/src/mcp_server/tests/scoped.rs +0 -158
  290. package/crates/team-agent/src/mcp_server/tests/send.rs +0 -353
  291. package/crates/team-agent/src/mcp_server/tests/tools.rs +0 -341
  292. package/crates/team-agent/src/mcp_server/tests/wire.rs +0 -254
  293. package/crates/team-agent/src/mcp_server/tests.rs +0 -43
  294. package/crates/team-agent/src/mcp_server/tools.rs +0 -889
  295. package/crates/team-agent/src/mcp_server/types.rs +0 -396
  296. package/crates/team-agent/src/mcp_server/wire.rs +0 -867
  297. package/crates/team-agent/src/messaging/activity.rs +0 -461
  298. package/crates/team-agent/src/messaging/address.rs +0 -87
  299. package/crates/team-agent/src/messaging/delivery.rs +0 -3727
  300. package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +0 -234
  301. package/crates/team-agent/src/messaging/enter_rescue.rs +0 -362
  302. package/crates/team-agent/src/messaging/enter_rescue_tests.rs +0 -633
  303. package/crates/team-agent/src/messaging/helpers.rs +0 -336
  304. package/crates/team-agent/src/messaging/leader_channel.rs +0 -287
  305. package/crates/team-agent/src/messaging/leader_receiver.rs +0 -786
  306. package/crates/team-agent/src/messaging/mod.rs +0 -167
  307. package/crates/team-agent/src/messaging/persist.rs +0 -377
  308. package/crates/team-agent/src/messaging/presentation.rs +0 -417
  309. package/crates/team-agent/src/messaging/reminders.rs +0 -316
  310. package/crates/team-agent/src/messaging/results/collection_tests.rs +0 -719
  311. package/crates/team-agent/src/messaging/results.rs +0 -1415
  312. package/crates/team-agent/src/messaging/scheduler.rs +0 -223
  313. package/crates/team-agent/src/messaging/selftest.rs +0 -315
  314. package/crates/team-agent/src/messaging/send.rs +0 -981
  315. package/crates/team-agent/src/messaging/tests/basic.rs +0 -346
  316. package/crates/team-agent/src/messaging/tests/dup_inject.rs +0 -657
  317. package/crates/team-agent/src/messaging/tests/e23.rs +0 -49
  318. package/crates/team-agent/src/messaging/tests/leader_channel.rs +0 -169
  319. package/crates/team-agent/src/messaging/tests/leader_inject_acceptance.rs +0 -817
  320. package/crates/team-agent/src/messaging/tests/main_preserved.rs +0 -85
  321. package/crates/team-agent/src/messaging/tests/mod.rs +0 -306
  322. package/crates/team-agent/src/messaging/tests/runtime.rs +0 -3549
  323. package/crates/team-agent/src/messaging/tests/spine.rs +0 -853
  324. package/crates/team-agent/src/messaging/tests/wave2.rs +0 -381
  325. package/crates/team-agent/src/messaging/trust.rs +0 -215
  326. package/crates/team-agent/src/messaging/types.rs +0 -472
  327. package/crates/team-agent/src/messaging/wait.rs +0 -366
  328. package/crates/team-agent/src/messaging/watchers.rs +0 -916
  329. package/crates/team-agent/src/model/enums.rs +0 -356
  330. package/crates/team-agent/src/model/errors.rs +0 -18
  331. package/crates/team-agent/src/model/ids.rs +0 -165
  332. package/crates/team-agent/src/model/mod.rs +0 -29
  333. package/crates/team-agent/src/model/name_similarity.rs +0 -252
  334. package/crates/team-agent/src/model/pane_authority_refusal.rs +0 -359
  335. package/crates/team-agent/src/model/paths.rs +0 -257
  336. package/crates/team-agent/src/model/routing.rs +0 -387
  337. package/crates/team-agent/src/model/spec.rs +0 -1184
  338. package/crates/team-agent/src/model/task_graph.rs +0 -321
  339. package/crates/team-agent/src/model/testdata/fuzz.golden.yaml +0 -43
  340. package/crates/team-agent/src/model/testdata/fuzz.yaml +0 -43
  341. package/crates/team-agent/src/model/testdata/spec_invalid_a.yaml +0 -209
  342. package/crates/team-agent/src/model/testdata/team.spec.golden.yaml +0 -208
  343. package/crates/team-agent/src/model/testdata/team.spec.yaml +0 -208
  344. package/crates/team-agent/src/model/yaml/tests.rs +0 -188
  345. package/crates/team-agent/src/model/yaml.rs +0 -802
  346. package/crates/team-agent/src/os_probe.rs +0 -280
  347. package/crates/team-agent/src/packaging/install.rs +0 -219
  348. package/crates/team-agent/src/packaging/migrate.rs +0 -38
  349. package/crates/team-agent/src/packaging/mod.rs +0 -91
  350. package/crates/team-agent/src/packaging/repair.rs +0 -33
  351. package/crates/team-agent/src/packaging/tests.rs +0 -822
  352. package/crates/team-agent/src/packaging/types.rs +0 -417
  353. package/crates/team-agent/src/platform/argv.rs +0 -331
  354. package/crates/team-agent/src/platform/errors.rs +0 -104
  355. package/crates/team-agent/src/platform/file_lock.rs +0 -279
  356. package/crates/team-agent/src/platform/mod.rs +0 -5
  357. package/crates/team-agent/src/platform/process.rs +0 -545
  358. package/crates/team-agent/src/provider/adapter.rs +0 -1150
  359. package/crates/team-agent/src/provider/adapters/claude.rs +0 -78
  360. package/crates/team-agent/src/provider/adapters/claude_fork.rs +0 -131
  361. package/crates/team-agent/src/provider/adapters/copilot.rs +0 -75
  362. package/crates/team-agent/src/provider/adapters/copilot_fork.rs +0 -307
  363. package/crates/team-agent/src/provider/adapters/fake.rs +0 -18
  364. package/crates/team-agent/src/provider/adapters/mod.rs +0 -30
  365. package/crates/team-agent/src/provider/adapters/pi.rs +0 -106
  366. package/crates/team-agent/src/provider/approvals/mod.rs +0 -3
  367. package/crates/team-agent/src/provider/approvals/parsing.rs +0 -586
  368. package/crates/team-agent/src/provider/approvals/runtime_prompts.rs +0 -205
  369. package/crates/team-agent/src/provider/argv_route.rs +0 -405
  370. package/crates/team-agent/src/provider/bypass_flags.rs +0 -116
  371. package/crates/team-agent/src/provider/classify.rs +0 -708
  372. package/crates/team-agent/src/provider/command_helpers.rs +0 -45
  373. package/crates/team-agent/src/provider/faults.rs +0 -165
  374. package/crates/team-agent/src/provider/helpers.rs +0 -52
  375. package/crates/team-agent/src/provider/mod.rs +0 -78
  376. package/crates/team-agent/src/provider/model_catalog.rs +0 -910
  377. package/crates/team-agent/src/provider/session/capture.rs +0 -2731
  378. package/crates/team-agent/src/provider/session/context_fork/claude.rs +0 -123
  379. package/crates/team-agent/src/provider/session/context_fork/outcome.rs +0 -172
  380. package/crates/team-agent/src/provider/session/context_fork.rs +0 -396
  381. package/crates/team-agent/src/provider/session/mod.rs +0 -36
  382. package/crates/team-agent/src/provider/session/resume.rs +0 -269
  383. package/crates/team-agent/src/provider/session_scan/claude.rs +0 -523
  384. package/crates/team-agent/src/provider/session_scan/common/tests.rs +0 -316
  385. package/crates/team-agent/src/provider/session_scan/common.rs +0 -654
  386. package/crates/team-agent/src/provider/session_scan/copilot.rs +0 -280
  387. package/crates/team-agent/src/provider/session_scan/pi.rs +0 -185
  388. package/crates/team-agent/src/provider/session_scan.rs +0 -71
  389. package/crates/team-agent/src/provider/startup_prompt.rs +0 -757
  390. package/crates/team-agent/src/provider/submit_now.rs +0 -71
  391. package/crates/team-agent/src/provider/testdata/copilot-ready-marker.txt +0 -5
  392. package/crates/team-agent/src/provider/testdata/copilot-trust-prompt.txt +0 -19
  393. package/crates/team-agent/src/provider/testdata/grok-models-authenticated.stdout +0 -9
  394. package/crates/team-agent/src/provider/testdata/grok-models-unauthenticated.stdout +0 -7
  395. package/crates/team-agent/src/provider/tests/adapter.rs +0 -441
  396. package/crates/team-agent/src/provider/tests/classify.rs +0 -148
  397. package/crates/team-agent/src/provider/tests/command_helpers.rs +0 -35
  398. package/crates/team-agent/src/provider/tests/copilot_fork.rs +0 -191
  399. package/crates/team-agent/src/provider/tests/faults.rs +0 -200
  400. package/crates/team-agent/src/provider/tests/idle.rs +0 -177
  401. package/crates/team-agent/src/provider/tests/wire.rs +0 -213
  402. package/crates/team-agent/src/provider/tests.rs +0 -32
  403. package/crates/team-agent/src/provider/types.rs +0 -529
  404. package/crates/team-agent/src/provider/wire.rs +0 -394
  405. package/crates/team-agent/src/redaction.rs +0 -259
  406. package/crates/team-agent/src/state/abnormal_watch/tests/mod.rs +0 -248
  407. package/crates/team-agent/src/state/abnormal_watch.rs +0 -144
  408. package/crates/team-agent/src/state/identity.rs +0 -914
  409. package/crates/team-agent/src/state/identity_keys.rs +0 -132
  410. package/crates/team-agent/src/state/mod.rs +0 -74
  411. package/crates/team-agent/src/state/owner_gate.rs +0 -482
  412. package/crates/team-agent/src/state/ownership.rs +0 -563
  413. package/crates/team-agent/src/state/paths.rs +0 -395
  414. package/crates/team-agent/src/state/persist.rs +0 -3811
  415. package/crates/team-agent/src/state/projection.rs +0 -1508
  416. package/crates/team-agent/src/state/repository/intent.rs +0 -14
  417. package/crates/team-agent/src/state/repository/tests.rs +0 -184
  418. package/crates/team-agent/src/state/repository.rs +0 -866
  419. package/crates/team-agent/src/state/selector.rs +0 -160
  420. package/crates/team-agent/src/state/testdata/state-rich.canonical.json +0 -133
  421. package/crates/team-agent/src/test_support/models_timeout_fixture.rs +0 -144
  422. package/crates/team-agent/src/tmux_backend/enter_rescue.rs +0 -325
  423. package/crates/team-agent/src/tmux_backend/enter_rescue_tests.rs +0 -432
  424. package/crates/team-agent/src/tmux_backend/native_input.rs +0 -513
  425. package/crates/team-agent/src/tmux_backend/native_input_tests.rs +0 -742
  426. package/crates/team-agent/src/tmux_backend/tests.rs +0 -4103
  427. package/crates/team-agent/src/tmux_backend.rs +0 -4492
  428. package/crates/team-agent/src/topology.rs +0 -537
  429. package/crates/team-agent/src/transport/enter_rescue.rs +0 -166
  430. package/crates/team-agent/src/transport/native_input.rs +0 -491
  431. package/crates/team-agent/src/transport/test_support.rs +0 -743
  432. package/crates/team-agent/src/transport/tests/behavior.rs +0 -326
  433. package/crates/team-agent/src/transport/tests/mod.rs +0 -194
  434. package/crates/team-agent/src/transport/tests/wire.rs +0 -574
  435. package/crates/team-agent/src/transport.rs +0 -1655
  436. package/crates/team-agent/src/transport_factory.rs +0 -819
@@ -1,936 +0,0 @@
1
- //! purpose: contracts that tests touching product side effects stay inside one hermetic HOME/registry/socket/env boundary
2
- //! contract: R1-R6 source guards; R6 needles match as identifiers, not as substrings of longer names
3
- //! boundary: does not own HermeticTestEnv; does not drop or whitelist R6 needles
4
- //!
5
- //! task#8 RED contract: tests that exercise Team Agent product side effects
6
- //! must run inside one HOME/registry/socket/env hermetic boundary.
7
- //!
8
- //! References:
9
- //! - `.team/artifacts/test-isolation-escape-locate.md` §8 R1-R6.
10
- //! - Slice A: shared `HermeticTestEnv` is implementation-owned; this file keeps
11
- //! only the minimal hostile harness needed to express the RED contracts.
12
- //! - Slice B: restart `auto_attach_leader` is product behavior and must write
13
- //! the same derived host leader registry entry as explicit binding commands.
14
-
15
- #![cfg(unix)]
16
- #![allow(clippy::expect_used, clippy::panic, clippy::unwrap_used)]
17
-
18
- use std::collections::BTreeMap;
19
- use std::path::{Path, PathBuf};
20
- use std::process::{Command, Output};
21
- use std::sync::atomic::{AtomicU64, Ordering};
22
- use std::sync::{Arc, Mutex};
23
-
24
- use serde_json::{json, Value};
25
- use serial_test::serial;
26
- use team_agent::lifecycle::{restart_with_transport_with_readiness_deadline, RestartReport};
27
- use team_agent::state::persist::{load_runtime_state, save_runtime_state};
28
- use team_agent::transport::{
29
- AttachOutcome, BackendKind, CaptureRange, CapturedText, InjectPayload, InjectReport,
30
- InjectStage, InjectVerification, Key, PaneField, PaneId, PaneInfo, PaneLiveness, SessionName,
31
- SetEnvOutcome, SpawnResult, SubmitVerification, Target, Transport, TransportError,
32
- TurnVerification, WindowName,
33
- };
34
-
35
- const CALLER_PANE: &str = "%7";
36
- const TMUX_SOCKET: &str = "/private/tmp/tmux-501/ta-0515-auto-attach";
37
- const TEAM_KEY: &str = "ctxteam";
38
- const WORKER: &str = "alpha";
39
-
40
- #[test]
41
- fn r1_claim_takeover_contracts_must_enter_hermetic_home_boundary() {
42
- let source =
43
- read_repo_file("crates/team-agent/tests/explicit_claim_takeover_any_live_pane_red.rs");
44
- assert_contains_all(
45
- "R1",
46
- &source,
47
- &[
48
- "HermeticTestEnv",
49
- "assert_real_registry_unchanged",
50
- "registry_entries",
51
- "HOME",
52
- ],
53
- "ta-rs-bug3 claim/takeover contracts run real CARGO_BIN_EXE_team-agent and binding hooks; they must isolate HOME and prove real ~/.team-agent/leaders is unchanged while hermetic HOME gets the expected entries",
54
- );
55
- assert!(
56
- !source.contains("std::env::temp_dir()"),
57
- "R1: explicit_claim_takeover_any_live_pane_red.rs must allocate workspaces through HermeticTestEnv, not std::env::temp_dir()"
58
- );
59
- }
60
-
61
- #[test]
62
- fn r2_bug4_canary_contract_must_not_observe_hostile_workspace_or_real_tmux() {
63
- let source = read_repo_file(
64
- "crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs",
65
- );
66
- assert_contains_all(
67
- "R2",
68
- &source,
69
- &[
70
- "HermeticTestEnv",
71
- "TEAM_AGENT_WORKSPACE",
72
- "assert_store_under_root",
73
- "assert_path_under_root",
74
- "RecordingTransport",
75
- "BUG4 worker to leader canary",
76
- ],
77
- "BUG4 delivery contracts use MessageStore/send/deliver primitives; hostile TEAM_AGENT_* and TMUX inputs must be scrubbed, fixture DB rows must stay under the hermetic root, and delivery must use RecordingTransport only",
78
- );
79
- assert!(
80
- !source.contains("fn temp_ws("),
81
- "R2: verify_rs031_window_consistency_red.rs must not keep a standalone temp_ws helper; workspace allocation must come from HermeticTestEnv"
82
- );
83
- }
84
-
85
- #[test]
86
- fn r3_socket_escape_contract_requires_declared_offline_or_recording_transport() {
87
- let verify = read_repo_file(
88
- "crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs",
89
- );
90
- let quick = read_repo_file(
91
- "crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs",
92
- );
93
- let combined = format!("{verify}\n{quick}");
94
- assert_contains_all(
95
- "R3",
96
- &combined,
97
- &[
98
- "HermeticTestEnv",
99
- "scrub_tmux",
100
- "RecordingTransport",
101
- "assert_no_real_tmux",
102
- ],
103
- "non-real-machine contracts may set hostile TMUX/TMUX_PANE only through HermeticTestEnv and must prove they did not construct a real TmuxBackend/default transport",
104
- );
105
- }
106
-
107
- #[test]
108
- fn r4_phase_golden_full_order_must_enter_hermetic_before_workspace_creation() {
109
- let source = read_repo_file("crates/team-agent/src/lifecycle/tests/phase_golden.rs");
110
- let hermetic = source.find("HermeticTestEnv").unwrap_or_else(|| {
111
- panic!("R4: phase_golden must import/enter shared HermeticTestEnv before creating test workspaces")
112
- });
113
- let workspace = source.find("two_worker_team_dir").unwrap_or_else(|| {
114
- panic!("R4 setup: phase_golden still expected to create the two-worker fixture")
115
- });
116
- assert!(
117
- hermetic < workspace,
118
- "R4: phase_golden must enter HermeticTestEnv before two_worker_team_dir/workspace creation so full --lib order cannot inherit prior env/HOME/socket state"
119
- );
120
- assert!(
121
- !source.contains("const CALLER_IDENTITY_ENVS"),
122
- "R4: phase_golden must not keep a private caller-identity scrub list that can drift from HermeticTestEnv"
123
- );
124
- }
125
-
126
- #[test]
127
- #[serial(env)]
128
- fn r5_restart_auto_attach_registers_isolated_live_leader_entry() {
129
- let case = RestartAutoAttachCase::new("r5-auto-attach");
130
- let _process_env = case.enter_process_env();
131
- case.seed_restartable_workspace();
132
- seed_healthy_coordinator(&case.workspace);
133
-
134
- let live = crate::transport::test_support::OfflineTransport::default()
135
- .with_tmux_endpoint(TMUX_SOCKET)
136
- .with_targets(vec![PaneInfo {
137
- pane_id: PaneId::new(CALLER_PANE),
138
- session: SessionName::new("team-agent-leader-0515"),
139
- window_index: Some(0),
140
- window_name: Some(WindowName::new("leader")),
141
- pane_index: Some(0),
142
- tty: None,
143
- current_command: Some("codex".to_string()),
144
- current_path: Some(case.workspace.clone()),
145
- active: true,
146
- pane_pid: None,
147
- leader_env: Default::default(),
148
- }]);
149
- let report = crate::transport_factory::with_leader_endpoint_transport(
150
- TMUX_SOCKET,
151
- live,
152
- || {
153
- restart_with_transport_with_readiness_deadline(
154
- &case.workspace,
155
- true,
156
- Some(TEAM_KEY),
157
- &RestartAutoAttachTransport::new(),
158
- Some(1_000),
159
- )
160
- },
161
- )
162
- .expect("R5 setup: restart should complete against fake transport");
163
- match &report {
164
- RestartReport::Restarted {
165
- leader_bind_ok, ..
166
- } => {
167
- assert!(
168
- *leader_bind_ok,
169
- "R5: public restart bind must be ok; report={report:?}"
170
- );
171
- }
172
- other => panic!("R5 setup: restart must succeed before checking registry side effects; report={other:?}"),
173
- }
174
- let state = load_runtime_state(&case.workspace).expect("read state after restart");
175
- assert_eq!(
176
- canonical_leader_receiver(&state)
177
- .and_then(|receiver| receiver.get("status"))
178
- .and_then(Value::as_str),
179
- Some("attached"),
180
- "R5 setup: restart auto_attach must bind canonical leader_receiver before registry assertion; state={state}"
181
- );
182
-
183
- let entries = case.registry_entries();
184
- assert_eq!(
185
- entries.len(),
186
- 1,
187
- "R5: successful restart auto_attach_leader must write exactly one isolated HOME registry entry; canonical binding exists but entries={entries:?}"
188
- );
189
- let entry = &entries[0].1;
190
- assert_eq!(
191
- entry.get("source").and_then(Value::as_str),
192
- Some("restart-auto-attach"),
193
- "R5: restart auto_attach registry entry must identify source=restart-auto-attach; entry={entry}"
194
- );
195
- case.assert_no_tmp_registry_files();
196
-
197
- let leaders = case.run_cli(["leaders", "--json"]);
198
- let leaders_json = json_output(&leaders, "R5 leaders --json");
199
- assert!(
200
- leader_statuses(&leaders_json).iter().any(|(name, status)| {
201
- (name == TEAM_KEY || name.ends_with(&format!("/{TEAM_KEY}"))) && status == "LIVE"
202
- }),
203
- "R5: leaders --json under isolated HOME must list the restart auto-attached leader as LIVE; output={leaders_json} entry={entry}"
204
- );
205
- }
206
-
207
- #[test]
208
- fn r6_static_guard_rejects_dangerous_tests_without_hermetic_boundary() {
209
- let synthetic = r#"
210
- use team_agent::message_store::MessageStore;
211
- fn fixture() {
212
- let _ = env!("CARGO_BIN_EXE_team-agent");
213
- }
214
- "#;
215
- assert!(
216
- static_guard_offenders([(
217
- "synthetic_missing_hermetic.rs".to_string(),
218
- synthetic.to_string()
219
- )])
220
- .iter()
221
- .any(|offender| offender.path == "synthetic_missing_hermetic.rs"),
222
- "R6 setup: synthetic MessageStore/CARGO_BIN_EXE test without HermeticTestEnv must be rejected"
223
- );
224
- let manual_cli_isolation = r#"
225
- use std::process::Command;
226
- fn run_cli() {
227
- let mut command = Command::new(crate::lifecycle::tests::test_binary_path());
228
- command
229
- .env("HOME", "/tmp/hermetic-home")
230
- .current_dir("/tmp/hermetic-workspace");
231
- let _ = std::env::var_os("TEAM_AGENT_TEST_TMP");
232
- for key in [
233
- "TMUX",
234
- "TMUX_PANE",
235
- "TEAM_AGENT_LEADER_PANE_ID",
236
- "TEAM_AGENT_LEADER_SESSION_UUID",
237
- "TEAM_AGENT_LEADER_SESSION_UUID_OVERRIDE",
238
- "TEAM_AGENT_LEADER_PROVIDER",
239
- "TEAM_AGENT_MACHINE_FINGERPRINT",
240
- "TEAM_AGENT_WORKSPACE",
241
- "TEAM_AGENT_TEAM_ID",
242
- "TEAM_AGENT_OWNER_TEAM_ID",
243
- "TEAM_AGENT_ACTIVE_TEAM",
244
- "TEAM_AGENT_ID",
245
- ] {
246
- command.env_remove(key);
247
- }
248
- }
249
- "#;
250
- assert!(
251
- static_guard_offenders([(
252
- "synthetic_manual_cli_isolation.rs".to_string(),
253
- manual_cli_isolation.to_string()
254
- )])
255
- .is_empty(),
256
- "R6 setup: CLI contracts that manually isolate HOME/current_dir and scrub TMUX/TEAM_AGENT_* envs should satisfy the equivalent isolation marker"
257
- );
258
-
259
- let files = dangerous_test_files();
260
- let offenders = static_guard_offenders(files);
261
- assert!(
262
- offenders.is_empty(),
263
- "R6: any test importing MessageStore/CARGO_BIN_EXE/send/delivery/quick-start/launch/registry/binding CLI surfaces must enter HermeticTestEnv or declare an equivalent real-machine isolation marker. offenders(first 30)={:#?}",
264
- offenders.into_iter().take(30).collect::<Vec<_>>()
265
- );
266
- }
267
-
268
- #[test]
269
- fn r6_mcp_tool_name_literal_is_not_message_plane_send() {
270
- let source = r#"
271
- assert!(prompt.contains("mcp__team_orchestrator__send_message"));
272
- assert!(prompt.contains("team_orchestrator__send_message"));
273
- "#;
274
- assert!(
275
- static_guard_offenders([(
276
- "synthetic_mcp_tool_name_literal.rs".to_string(),
277
- source.to_string()
278
- )])
279
- .is_empty(),
280
- "MCP tool-name literals are not the send_message surface"
281
- );
282
- }
283
-
284
- #[test]
285
- fn r6_bare_send_message_identifier_without_hermetic_is_still_offender() {
286
- let source = r#"
287
- fn tap() {
288
- let _ = send_message("to", "body");
289
- }
290
- "#;
291
- let offenders = static_guard_offenders([(
292
- "synthetic_bare_send_message.rs".to_string(),
293
- source.to_string(),
294
- )]);
295
- assert!(
296
- offenders.iter().any(|offender| offender.path == "synthetic_bare_send_message.rs"
297
- && offender.signals.contains(&"send_message")),
298
- "bare send_message identifier without HermeticTestEnv must remain an offender; offenders={offenders:?}"
299
- );
300
- }
301
-
302
- fn assert_contains_all(label: &str, source: &str, needles: &[&str], message: &str) {
303
- let missing = needles
304
- .iter()
305
- .copied()
306
- .filter(|needle| !source.contains(needle))
307
- .collect::<Vec<_>>();
308
- assert!(
309
- missing.is_empty(),
310
- "{label}: {message}; missing markers={missing:?}"
311
- );
312
- }
313
-
314
- #[allow(dead_code)]
315
- #[derive(Debug)]
316
- struct StaticOffender {
317
- path: String,
318
- signals: Vec<&'static str>,
319
- }
320
-
321
- fn static_guard_offenders(
322
- files: impl IntoIterator<Item = (String, String)>,
323
- ) -> Vec<StaticOffender> {
324
- files
325
- .into_iter()
326
- .filter_map(|(path, source)| {
327
- let signals = dangerous_signals(&source);
328
- if signals.is_empty() {
329
- return None;
330
- }
331
- let has_hermetic = source.contains("HermeticTestEnv");
332
- let has_real_machine_isolation = source.contains("real-machine")
333
- && source.contains("HOME")
334
- && source.contains("TMUX")
335
- && source.contains("TEAM_AGENT_WORKSPACE");
336
- if has_hermetic || has_real_machine_isolation || has_manual_cli_env_isolation(&source) {
337
- None
338
- } else {
339
- Some(StaticOffender { path, signals })
340
- }
341
- })
342
- .collect()
343
- }
344
-
345
- fn has_manual_cli_env_isolation(source: &str) -> bool {
346
- [
347
- "CARGO_BIN_EXE_team-agent",
348
- "TEAM_AGENT_TEST_TMP",
349
- ".env(\"HOME\"",
350
- ".current_dir(",
351
- "command.env_remove(key)",
352
- "\"TMUX\"",
353
- "\"TMUX_PANE\"",
354
- "\"TEAM_AGENT_LEADER_PANE_ID\"",
355
- "\"TEAM_AGENT_LEADER_SESSION_UUID\"",
356
- "\"TEAM_AGENT_LEADER_SESSION_UUID_OVERRIDE\"",
357
- "\"TEAM_AGENT_LEADER_PROVIDER\"",
358
- "\"TEAM_AGENT_MACHINE_FINGERPRINT\"",
359
- "\"TEAM_AGENT_WORKSPACE\"",
360
- "\"TEAM_AGENT_TEAM_ID\"",
361
- "\"TEAM_AGENT_OWNER_TEAM_ID\"",
362
- "\"TEAM_AGENT_ACTIVE_TEAM\"",
363
- "\"TEAM_AGENT_ID\"",
364
- ]
365
- .into_iter()
366
- .all(|needle| source.contains(needle))
367
- }
368
-
369
- fn dangerous_signals(source: &str) -> Vec<&'static str> {
370
- [
371
- "MessageStore",
372
- "send_message",
373
- "deliver_pending_message",
374
- "deliver_pending_messages",
375
- "quick_start_with_transport",
376
- "launch_with_transport",
377
- "CARGO_BIN_EXE_team-agent",
378
- "leader::registry",
379
- "claim-leader",
380
- "takeover",
381
- "attach-leader",
382
- ]
383
- .into_iter()
384
- .filter(|needle| contains_identifier(source, needle))
385
- .collect()
386
- }
387
-
388
- fn contains_identifier(source: &str, ident: &str) -> bool {
389
- let bytes = source.as_bytes();
390
- let mut start = 0;
391
- while let Some(rel) = source[start..].find(ident) {
392
- let idx = start + rel;
393
- let before_ok = idx == 0 || !is_ident_char(bytes[idx - 1]);
394
- let after = idx + ident.len();
395
- let after_ok = after == bytes.len() || !is_ident_char(bytes[after]);
396
- if before_ok && after_ok {
397
- return true;
398
- }
399
- start = idx + 1;
400
- }
401
- false
402
- }
403
-
404
- fn is_ident_char(b: u8) -> bool {
405
- matches!(b, b'0'..=b'9' | b'A'..=b'Z' | b'a'..=b'z' | b'_')
406
- }
407
-
408
- fn dangerous_test_files() -> Vec<(String, String)> {
409
- let root = repo_root();
410
- let mut files = Vec::new();
411
- collect_rs_files(
412
- &root,
413
- "crates/team-agent/tests",
414
- |name| name.ends_with("_red.rs") || name.ends_with("_contract.rs"),
415
- &mut files,
416
- );
417
- collect_rs_files(
418
- &root,
419
- "crates/team-agent/src/lifecycle/tests",
420
- |name| name.ends_with(".rs"),
421
- &mut files,
422
- );
423
- files.sort_by(|a, b| a.0.cmp(&b.0));
424
- files
425
- }
426
-
427
- fn read_repo_file(path: &str) -> String {
428
- std::fs::read_to_string(repo_root().join(path))
429
- .unwrap_or_else(|error| panic!("read repo file {path}: {error}"))
430
- }
431
-
432
- fn repo_root() -> PathBuf {
433
- Path::new(env!("CARGO_MANIFEST_DIR")).join("../..")
434
- }
435
-
436
- fn collect_rs_files(
437
- root: &Path,
438
- relative_dir: &'static str,
439
- keep: impl Fn(&str) -> bool,
440
- out: &mut Vec<(String, String)>,
441
- ) {
442
- let dir = root.join(relative_dir);
443
- let read_dir = std::fs::read_dir(&dir)
444
- .unwrap_or_else(|error| panic!("read static guard dir {}: {error}", dir.display()));
445
- for entry in read_dir.filter_map(Result::ok) {
446
- let path = entry.path();
447
- let Some(name) = path.file_name().and_then(|name| name.to_str()) else {
448
- continue;
449
- };
450
- if !keep(name) {
451
- continue;
452
- }
453
- let relative = format!("{relative_dir}/{name}");
454
- let source = std::fs::read_to_string(&path)
455
- .unwrap_or_else(|error| panic!("read static guard file {relative}: {error}"));
456
- out.push((relative, source));
457
- }
458
- }
459
-
460
- struct RestartAutoAttachCase {
461
- root: PathBuf,
462
- workspace: PathBuf,
463
- home: PathBuf,
464
- fake_bin: PathBuf,
465
- }
466
-
467
- impl RestartAutoAttachCase {
468
- fn new(tag: &str) -> Self {
469
- let root = tmp_dir(tag);
470
- let workspace = root.join("teamdir");
471
- let home = root.join("home");
472
- std::fs::create_dir_all(&home).expect("create isolated HOME");
473
- std::fs::create_dir_all(workspace.join("agents")).expect("create agents dir");
474
- std::fs::write(
475
- workspace.join("TEAM.md"),
476
- "---\nname: ctxteam\nobjective: restart auto attach registry contract\nprovider: fake\n---\n\nTeam.\n",
477
- )
478
- .expect("write TEAM.md");
479
- std::fs::write(
480
- workspace.join("agents").join(format!("{WORKER}.md")),
481
- format!(
482
- "---\nname: {WORKER}\nrole: Worker {WORKER}\nprovider: fake\nmodel: fake\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nWorker.\n"
483
- ),
484
- )
485
- .expect("write worker role");
486
- let spec = team_agent::compiler::compile_team(&workspace).expect("compile team");
487
- std::fs::write(
488
- workspace.join("team.spec.yaml"),
489
- team_agent::model::yaml::dumps(&spec),
490
- )
491
- .expect("write team.spec.yaml");
492
- let fake_bin = fake_tmux_bin(&root, &workspace);
493
- Self {
494
- root,
495
- workspace,
496
- home,
497
- fake_bin,
498
- }
499
- }
500
-
501
- fn enter_process_env(&self) -> EnvGuard {
502
- EnvGuard::set([
503
- ("HOME", Some(self.home.to_string_lossy().to_string())),
504
- (
505
- "PATH",
506
- Some(format!(
507
- "{}:{}",
508
- self.fake_bin.display(),
509
- std::env::var("PATH").unwrap_or_default()
510
- )),
511
- ),
512
- ("TMUX", Some(format!("{TMUX_SOCKET},12345,0"))),
513
- ("TMUX_PANE", Some(CALLER_PANE.to_string())),
514
- ("TEAM_AGENT_LEADER_PROVIDER", Some("codex".to_string())),
515
- (
516
- "TEAM_AGENT_MACHINE_FINGERPRINT",
517
- Some("machine-0515-red".to_string()),
518
- ),
519
- ("TEAM_AGENT_LEADER_PANE_ID", None),
520
- ("TEAM_AGENT_LEADER_SESSION_UUID", None),
521
- ("TEAM_AGENT_WORKSPACE", None),
522
- ("TEAM_AGENT_TEAM_ID", None),
523
- ("TEAM_AGENT_OWNER_TEAM_ID", None),
524
- ("TEAM_AGENT_ACTIVE_TEAM", None),
525
- ("TEAM_AGENT_ID", None),
526
- ])
527
- }
528
-
529
- fn seed_restartable_workspace(&self) {
530
- let worker = json!({
531
- "status": "stopped",
532
- "provider": "fake",
533
- "role": format!("Worker {WORKER}"),
534
- "tools": ["mcp_team"],
535
- "window": WORKER,
536
- "spawn_cwd": self.workspace.to_string_lossy().to_string()
537
- });
538
- save_runtime_state(
539
- &self.workspace,
540
- &json!({
541
- "active_team_key": TEAM_KEY,
542
- "team_key": TEAM_KEY,
543
- "team_dir": self.workspace.to_string_lossy().to_string(),
544
- "spec_path": self.workspace.join("team.spec.yaml").to_string_lossy().to_string(),
545
- "session_name": "team-ctxteam",
546
- "tmux_endpoint": TMUX_SOCKET,
547
- "tmux_socket": TMUX_SOCKET,
548
- "agents": { WORKER: worker.clone() },
549
- "teams": {
550
- TEAM_KEY: {
551
- "active_team_key": TEAM_KEY,
552
- "team_key": TEAM_KEY,
553
- "team_dir": self.workspace.to_string_lossy().to_string(),
554
- "spec_path": self.workspace.join("team.spec.yaml").to_string_lossy().to_string(),
555
- "session_name": "team-ctxteam",
556
- "tmux_endpoint": TMUX_SOCKET,
557
- "tmux_socket": TMUX_SOCKET,
558
- "team_owner": {
559
- "pane_id": CALLER_PANE,
560
- "owner_epoch": 1,
561
- "provider": "codex"
562
- },
563
- "leader_receiver": {
564
- "mode": "direct_tmux",
565
- "status": "attached",
566
- "pane_id": CALLER_PANE,
567
- "owner_epoch": 1,
568
- "provider": "codex",
569
- "tmux_socket": TMUX_SOCKET
570
- },
571
- "agents": { WORKER: worker }
572
- }
573
- }
574
- }),
575
- )
576
- .expect("seed runtime state");
577
- }
578
-
579
- fn registry_entries(&self) -> Vec<(PathBuf, Value)> {
580
- registry_entries(&self.home)
581
- }
582
-
583
- fn assert_no_tmp_registry_files(&self) {
584
- let dir = self.home.join(".team-agent/leaders");
585
- let tmp = std::fs::read_dir(&dir)
586
- .ok()
587
- .into_iter()
588
- .flatten()
589
- .filter_map(Result::ok)
590
- .map(|entry| entry.path())
591
- .filter(|path| {
592
- path.file_name()
593
- .and_then(|name| name.to_str())
594
- .is_some_and(|name| name.contains(".tmp") || name.ends_with(".tmp"))
595
- })
596
- .collect::<Vec<_>>();
597
- assert!(
598
- tmp.is_empty(),
599
- "R5: registry temp files must not remain: {tmp:?}"
600
- );
601
- }
602
-
603
- fn run_cli<const N: usize>(&self, args: [&str; N]) -> Output {
604
- Command::new(crate::lifecycle::tests::test_binary_path())
605
- .args(args)
606
- .current_dir(&self.workspace)
607
- .env("HOME", &self.home)
608
- .env(
609
- "PATH",
610
- format!(
611
- "{}:{}",
612
- self.fake_bin.display(),
613
- std::env::var("PATH").unwrap_or_default()
614
- ),
615
- )
616
- .env("TMUX", format!("{TMUX_SOCKET},12345,0"))
617
- .env("TMUX_PANE", CALLER_PANE)
618
- .env_remove("TEAM_AGENT_LEADER_PANE_ID")
619
- .env_remove("TEAM_AGENT_LEADER_SESSION_UUID")
620
- .env_remove("TEAM_AGENT_WORKSPACE")
621
- .env_remove("TEAM_AGENT_TEAM_ID")
622
- .env_remove("TEAM_AGENT_OWNER_TEAM_ID")
623
- .env_remove("TEAM_AGENT_ACTIVE_TEAM")
624
- .env_remove("TEAM_AGENT_ID")
625
- .output()
626
- .expect("run team-agent CLI")
627
- }
628
- }
629
-
630
- impl Drop for RestartAutoAttachCase {
631
- fn drop(&mut self) {
632
- if std::env::var("TEAM_AGENT_KEEP_TEST_TMP").as_deref() != Ok("1") {
633
- let _ = std::fs::remove_dir_all(&self.root);
634
- }
635
- }
636
- }
637
-
638
- #[derive(Clone, Default)]
639
- struct RestartAutoAttachTransport {
640
- pane_seq: Arc<Mutex<u64>>,
641
- }
642
-
643
- impl RestartAutoAttachTransport {
644
- fn new() -> Self {
645
- Self::default()
646
- }
647
-
648
- fn spawn_result(&self, session: &SessionName, window: &WindowName) -> SpawnResult {
649
- let mut pane_seq = self.pane_seq.lock().unwrap();
650
- let pane = format!("%{}", *pane_seq);
651
- *pane_seq = pane_seq.saturating_add(1);
652
- SpawnResult {
653
- pane_id: PaneId::new(pane),
654
- session: session.clone(),
655
- window: window.clone(),
656
- child_pid: Some(4242),
657
- }
658
- }
659
- }
660
-
661
- impl Transport for RestartAutoAttachTransport {
662
- fn kind(&self) -> BackendKind {
663
- BackendKind::Tmux
664
- }
665
-
666
- fn spawn_first(
667
- &self,
668
- session: &SessionName,
669
- window: &WindowName,
670
- _argv: &[String],
671
- _cwd: &Path,
672
- _env: &BTreeMap<String, String>,
673
- ) -> Result<SpawnResult, TransportError> {
674
- Ok(self.spawn_result(session, window))
675
- }
676
-
677
- fn spawn_into(
678
- &self,
679
- session: &SessionName,
680
- window: &WindowName,
681
- _argv: &[String],
682
- _cwd: &Path,
683
- _env: &BTreeMap<String, String>,
684
- ) -> Result<SpawnResult, TransportError> {
685
- Ok(self.spawn_result(session, window))
686
- }
687
-
688
- fn inject(
689
- &self,
690
- _target: &Target,
691
- _payload: &InjectPayload,
692
- _submit: Key,
693
- _bracketed: bool,
694
- ) -> Result<InjectReport, TransportError> {
695
- Ok(inject_report())
696
- }
697
-
698
- fn send_keys(&self, _target: &Target, _keys: &[Key]) -> Result<(), TransportError> {
699
- Ok(())
700
- }
701
-
702
- fn capture(
703
- &self,
704
- _target: &Target,
705
- range: CaptureRange,
706
- ) -> Result<CapturedText, TransportError> {
707
- Ok(CapturedText {
708
- text: String::new(),
709
- range,
710
- })
711
- }
712
-
713
- fn query(&self, _target: &Target, _field: PaneField) -> Result<Option<String>, TransportError> {
714
- Ok(Some("fake".to_string()))
715
- }
716
-
717
- fn liveness(&self, _pane: &PaneId) -> Result<PaneLiveness, TransportError> {
718
- Ok(PaneLiveness::Live)
719
- }
720
-
721
- fn list_targets(&self) -> Result<Vec<PaneInfo>, TransportError> {
722
- Ok(vec![])
723
- }
724
-
725
- fn has_session(&self, _session: &SessionName) -> Result<bool, TransportError> {
726
- Ok(true)
727
- }
728
-
729
- fn list_windows(&self, _session: &SessionName) -> Result<Vec<WindowName>, TransportError> {
730
- Ok(vec![WindowName::new(WORKER)])
731
- }
732
-
733
- fn set_session_env(
734
- &self,
735
- _session: &SessionName,
736
- _key: &str,
737
- _value: &str,
738
- ) -> Result<SetEnvOutcome, TransportError> {
739
- Ok(SetEnvOutcome::Applied)
740
- }
741
-
742
- fn kill_session(&self, _session: &SessionName) -> Result<(), TransportError> {
743
- Ok(())
744
- }
745
-
746
- fn kill_window(&self, _target: &Target) -> Result<(), TransportError> {
747
- Ok(())
748
- }
749
-
750
- fn attach_session(&self, _session: &SessionName) -> Result<AttachOutcome, TransportError> {
751
- Ok(AttachOutcome::Attached)
752
- }
753
- }
754
-
755
- fn inject_report() -> InjectReport {
756
- InjectReport {
757
- stage_reached: InjectStage::Submit,
758
- inject_verification: InjectVerification::NoToken,
759
- submit_verification: SubmitVerification::EnterSentWithoutPlaceholderCheck,
760
- turn_verification: TurnVerification::NotRequired,
761
- attempts: 1,
762
- submit_diagnostics: None,
763
- }
764
- }
765
-
766
- fn fake_tmux_bin(root: &Path, cwd: &Path) -> PathBuf {
767
- let bin = root.join("fake-bin");
768
- std::fs::create_dir_all(&bin).expect("create fake bin dir");
769
- let tmux = bin.join("tmux");
770
- let line = format!(
771
- "{CALLER_PANE}\tteam-agent-leader-0515\t0\tleader\t0\t/dev/ttys0515\tcodex\t1\t{}\t1\t0\t{}\n",
772
- cwd.display(),
773
- std::process::id()
774
- );
775
- let script = format!(
776
- r#"#!/bin/sh
777
- case " $* " in
778
- *" list-panes "*) printf '%s' '{line}'; exit 0 ;;
779
- *" list-sessions "*) printf '%s\n' 'team-agent-leader-0515: 1 windows'; exit 0 ;;
780
- *" display-message "*) printf '%s\n' '{pid}'; exit 0 ;;
781
- *" has-session "*) exit 0 ;;
782
- *) exit 0 ;;
783
- esac
784
- "#,
785
- line = shell_single_quoted_payload(&line),
786
- pid = std::process::id()
787
- );
788
- std::fs::write(&tmux, script).expect("write fake tmux");
789
- #[cfg(unix)]
790
- {
791
- use std::os::unix::fs::PermissionsExt;
792
- std::fs::set_permissions(&tmux, std::fs::Permissions::from_mode(0o755))
793
- .expect("chmod fake tmux");
794
- }
795
- bin
796
- }
797
-
798
- fn registry_entries(home: &Path) -> Vec<(PathBuf, Value)> {
799
- let dir = home.join(".team-agent/leaders");
800
- let Ok(read_dir) = std::fs::read_dir(&dir) else {
801
- return Vec::new();
802
- };
803
- let mut entries = read_dir
804
- .filter_map(Result::ok)
805
- .map(|entry| entry.path())
806
- .filter(|path| path.extension().and_then(|ext| ext.to_str()) == Some("json"))
807
- .map(|path| {
808
- let value = serde_json::from_str::<Value>(
809
- &std::fs::read_to_string(&path).expect("read registry entry"),
810
- )
811
- .expect("parse registry json");
812
- (path, value)
813
- })
814
- .collect::<Vec<_>>();
815
- entries.sort_by(|a, b| a.0.cmp(&b.0));
816
- entries
817
- }
818
-
819
- fn leader_statuses(value: &Value) -> Vec<(String, String)> {
820
- value
821
- .get("leaders")
822
- .or_else(|| value.get("entries"))
823
- .and_then(Value::as_array)
824
- .into_iter()
825
- .flatten()
826
- .map(|entry| {
827
- let name = entry
828
- .get("name")
829
- .or_else(|| entry.get("qualified_name"))
830
- .or_else(|| entry.get("team_key"))
831
- .and_then(Value::as_str)
832
- .unwrap_or("")
833
- .to_string();
834
- let status = entry
835
- .get("status")
836
- .and_then(Value::as_str)
837
- .unwrap_or("")
838
- .to_string();
839
- (name, status)
840
- })
841
- .collect()
842
- }
843
-
844
- fn canonical_leader_receiver<'a>(state: &'a Value) -> Option<&'a Value> {
845
- state
846
- .pointer(&format!("/teams/{TEAM_KEY}/leader_receiver"))
847
- .or_else(|| state.get("leader_receiver"))
848
- }
849
-
850
- fn json_output(output: &Output, label: &str) -> Value {
851
- let stdout = String::from_utf8_lossy(&output.stdout);
852
- let stderr = String::from_utf8_lossy(&output.stderr);
853
- assert!(
854
- output.status.success(),
855
- "{label}: expected success; code={:?} stdout={stdout} stderr={stderr}",
856
- output.status.code()
857
- );
858
- serde_json::from_str(stdout.trim()).unwrap_or_else(|error| {
859
- panic!("{label}: parse JSON failed: {error}; stdout={stdout:?}; stderr={stderr:?}")
860
- })
861
- }
862
-
863
- fn seed_healthy_coordinator(workspace: &Path) {
864
- let workspace_path = team_agent::coordinator::WorkspacePath::new(workspace.to_path_buf());
865
- std::fs::create_dir_all(team_agent::model::paths::runtime_dir(workspace)).unwrap();
866
- let _ = team_agent::message_store::MessageStore::open(workspace).unwrap();
867
- let pid = team_agent::coordinator::Pid::new(std::process::id());
868
- team_agent::coordinator::write_coordinator_metadata(
869
- &workspace_path,
870
- pid,
871
- team_agent::coordinator::MetadataSource::Boot,
872
- )
873
- .unwrap();
874
- std::fs::write(
875
- team_agent::coordinator::coordinator_pid_path(&workspace_path),
876
- pid.to_string(),
877
- )
878
- .unwrap();
879
- }
880
-
881
- struct EnvGuard {
882
- previous: Vec<(&'static str, Option<String>)>,
883
- }
884
-
885
- impl EnvGuard {
886
- fn set<const N: usize>(values: [(&'static str, Option<String>); N]) -> Self {
887
- let previous = values
888
- .iter()
889
- .map(|(key, _)| (*key, std::env::var(key).ok()))
890
- .collect::<Vec<_>>();
891
- for (key, value) in values {
892
- unsafe {
893
- if let Some(value) = value {
894
- std::env::set_var(key, value);
895
- } else {
896
- std::env::remove_var(key);
897
- }
898
- }
899
- }
900
- Self { previous }
901
- }
902
- }
903
-
904
- impl Drop for EnvGuard {
905
- fn drop(&mut self) {
906
- for (key, value) in self.previous.drain(..).rev() {
907
- unsafe {
908
- if let Some(value) = value {
909
- std::env::set_var(key, value);
910
- } else {
911
- std::env::remove_var(key);
912
- }
913
- }
914
- }
915
- }
916
- }
917
-
918
- fn tmp_dir(tag: &str) -> PathBuf {
919
- static COUNTER: AtomicU64 = AtomicU64::new(0);
920
- let root = std::env::var_os("TEAM_AGENT_TEST_TMP")
921
- .map(PathBuf::from)
922
- .unwrap_or_else(std::env::temp_dir);
923
- std::fs::create_dir_all(&root).expect("create TEAM_AGENT_TEST_TMP root");
924
- let dir = root.join(format!(
925
- "ta-0515-{tag}-{}-{}",
926
- std::process::id(),
927
- COUNTER.fetch_add(1, Ordering::Relaxed)
928
- ));
929
- let _ = std::fs::remove_dir_all(&dir);
930
- std::fs::create_dir_all(&dir).expect("create temp dir");
931
- std::fs::canonicalize(dir).expect("canonicalize temp dir")
932
- }
933
-
934
- fn shell_single_quoted_payload(text: &str) -> String {
935
- text.replace('\'', "'\\''")
936
- }