@team-agent/installer 0.5.128 → 0.6.1

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,1327 +0,0 @@
1
- use super::*;
2
- use crate::transport::PaneLiveness;
3
-
4
- // ───────────────────────────────────────────────────────────────────────
5
- // classify_first_send_at — _classify_first_send_at (orchestration.py:404)
6
- // 严格分类,绝不靠 truthiness。golden 实跑(见任务记录):
7
- // None -> absent ; "" / 0 / False / "null" / "not-a-date" / 123 / [] / {} -> corrupt
8
- // "2026-05-27T10:00:00+00:00" / "2026-05-27T10:00:00" -> valid
9
- // 这是 Route B resume-atomicity 的命门:garbage 必须在 teardown 之前 hard-refuse。
10
- // ───────────────────────────────────────────────────────────────────────
11
-
12
- #[test]
13
- fn classify_first_send_at_none_is_absent_not_corrupt() {
14
- // None / 缺失 = 从未交互,可丢弃 fresh —— 不能误判成 corrupt。
15
- assert_eq!(
16
- classify_first_send_at(&json!(null)),
17
- FirstSendAtState::Absent
18
- );
19
- }
20
-
21
- #[test]
22
- fn classify_first_send_at_empty_string_is_corrupt_not_absent() {
23
- // 陷阱核心:Python truthiness 会把 "" 当 falsey/absent;契约要求 corrupt。
24
- assert_eq!(
25
- classify_first_send_at(&json!("")),
26
- FirstSendAtState::Corrupt
27
- );
28
- }
29
-
30
- #[test]
31
- fn classify_first_send_at_zero_and_false_are_corrupt() {
32
- // 0 / False 非 str → corrupt(绝不靠 bool/int truthiness 当 absent)。
33
- assert_eq!(classify_first_send_at(&json!(0)), FirstSendAtState::Corrupt);
34
- assert_eq!(
35
- classify_first_send_at(&json!(false)),
36
- FirstSendAtState::Corrupt
37
- );
38
- assert_eq!(
39
- classify_first_send_at(&json!(123)),
40
- FirstSendAtState::Corrupt
41
- );
42
- }
43
-
44
- #[test]
45
- fn classify_first_send_at_literal_null_string_is_corrupt() {
46
- // 字面量字符串 "null"(非 ISO)→ corrupt,而 JSON null → absent(上面已测)。
47
- assert_eq!(
48
- classify_first_send_at(&json!("null")),
49
- FirstSendAtState::Corrupt
50
- );
51
- assert_eq!(
52
- classify_first_send_at(&json!("not-a-date")),
53
- FirstSendAtState::Corrupt
54
- );
55
- }
56
-
57
- #[test]
58
- fn classify_first_send_at_non_string_containers_are_corrupt() {
59
- assert_eq!(
60
- classify_first_send_at(&json!([])),
61
- FirstSendAtState::Corrupt
62
- );
63
- assert_eq!(
64
- classify_first_send_at(&json!({})),
65
- FirstSendAtState::Corrupt
66
- );
67
- }
68
-
69
- #[test]
70
- fn classify_first_send_at_valid_iso_with_and_without_tz() {
71
- // datetime.fromisoformat 接受带 / 不带时区的 ISO-8601。
72
- assert_eq!(
73
- classify_first_send_at(&json!("2026-05-27T10:00:00+00:00")),
74
- FirstSendAtState::Valid
75
- );
76
- assert_eq!(
77
- classify_first_send_at(&json!("2026-05-27T10:00:00")),
78
- FirstSendAtState::Valid
79
- );
80
- }
81
-
82
- // ───────────────────────────────────────────────────────────────────────
83
- // PlanId::parse — sanitize_plan_id (orchestrator/state.py:18)
84
- // _PLAN_ID_RE = ^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$ (首字符必字母数字;总长 1..=64)
85
- // golden 实跑:
86
- // "abc"/"a.b-c_1"/"A"/"1plan"/64×"x" -> OK
87
- // "_bad"/".dot"/"../etc"/"a/b"/"a b"/""/None/65×"x" -> InvalidPlanId
88
- // newtype 防路径穿越:无 "/"、无空格。
89
- // ───────────────────────────────────────────────────────────────────────
90
-
91
- #[test]
92
- fn plan_id_accepts_alnum_and_inner_dot_dash_underscore() {
93
- assert_eq!(PlanId::parse("abc").unwrap().as_str(), "abc");
94
- assert_eq!(PlanId::parse("a.b-c_1").unwrap().as_str(), "a.b-c_1");
95
- assert_eq!(PlanId::parse("A").unwrap().as_str(), "A");
96
- assert_eq!(PlanId::parse("1plan").unwrap().as_str(), "1plan");
97
- }
98
-
99
- #[test]
100
- fn plan_id_rejects_leading_underscore_or_dot() {
101
- // 首字符必须 [A-Za-z0-9] —— "_bad" / ".dot" 被拒(防 ".." 穿越家族)。
102
- assert!(matches!(
103
- PlanId::parse("_bad"),
104
- Err(LifecycleError::InvalidPlanId(_))
105
- ));
106
- assert!(matches!(
107
- PlanId::parse(".dot"),
108
- Err(LifecycleError::InvalidPlanId(_))
109
- ));
110
- }
111
-
112
- #[test]
113
- fn plan_id_rejects_path_traversal_and_separators() {
114
- for bad in ["../etc", "a/b", "a b", ""] {
115
- assert!(
116
- matches!(PlanId::parse(bad), Err(LifecycleError::InvalidPlanId(_))),
117
- "expected InvalidPlanId for {bad:?}"
118
- );
119
- }
120
- }
121
-
122
- #[test]
123
- fn plan_id_length_boundary_64_ok_65_rejected() {
124
- // {0,63} 量词 + 1 首字符 = 最长 64;65 越界。
125
- let ok = "x".repeat(64);
126
- let bad = "x".repeat(65);
127
- assert_eq!(PlanId::parse(&ok).unwrap().as_str(), ok);
128
- assert!(matches!(
129
- PlanId::parse(&bad),
130
- Err(LifecycleError::InvalidPlanId(_))
131
- ));
132
- }
133
-
134
- #[test]
135
- fn plan_id_error_message_names_the_offending_value_and_grammar() {
136
- // exact message 契约:含 repr 后的非法值 + 文法 + "no slashes ... path-traversal"。
137
- let err = PlanId::parse("a/b").unwrap_err();
138
- let msg = err.to_string();
139
- assert!(msg.contains("invalid plan id"), "got: {msg}");
140
- assert!(msg.contains("a/b"), "must name offending value, got: {msg}");
141
- assert!(
142
- msg.contains("no slashes") || msg.contains("path-traversal"),
143
- "must explain why, got: {msg}"
144
- );
145
- }
146
-
147
- // ───────────────────────────────────────────────────────────────────────
148
- // PlanCondition::parse — _CONDITION_RE / _is_supported_condition (plan.py:9)
149
- // _CONDITION_RE = ^\s*report_result\.(\w+)\s*==\s*['"]([^'"]+)['"]\s*$
150
- // golden 实跑(_is_supported_condition):
151
- // "any"/"ANY"/" any " -> True (Any)
152
- // "report_result.foo == 'bar'" -> True (FieldEq foo bar)
153
- // "report_result.foo=='bar'"(无空格) -> True
154
- // 'report_result.s == "dq"'(双引号) -> True
155
- // "report_result. == 'y'"(空 field)/"foo == 'bar'"/""/"report_result.s == bar"(裸值) -> False
156
- // 封闭文法,越界 → InvalidPlan(不做自由表达式)。
157
- // ───────────────────────────────────────────────────────────────────────
158
-
159
- #[test]
160
- fn plan_condition_any_case_insensitive_and_trimmed() {
161
- assert_eq!(PlanCondition::parse("any").unwrap(), PlanCondition::Any);
162
- assert_eq!(PlanCondition::parse("ANY").unwrap(), PlanCondition::Any);
163
- assert_eq!(PlanCondition::parse(" any ").unwrap(), PlanCondition::Any);
164
- }
165
-
166
- #[test]
167
- fn plan_condition_field_eq_extracts_field_and_value() {
168
- assert_eq!(
169
- PlanCondition::parse("report_result.foo == 'bar'").unwrap(),
170
- PlanCondition::FieldEq {
171
- field: "foo".to_string(),
172
- value: "bar".to_string()
173
- }
174
- );
175
- }
176
-
177
- #[test]
178
- fn plan_condition_field_eq_tolerates_no_spaces_and_double_quotes() {
179
- assert_eq!(
180
- PlanCondition::parse("report_result.foo=='bar'").unwrap(),
181
- PlanCondition::FieldEq {
182
- field: "foo".to_string(),
183
- value: "bar".to_string()
184
- }
185
- );
186
- assert_eq!(
187
- PlanCondition::parse("report_result.s == \"dq\"").unwrap(),
188
- PlanCondition::FieldEq {
189
- field: "s".to_string(),
190
- value: "dq".to_string()
191
- }
192
- );
193
- }
194
-
195
- #[test]
196
- fn plan_condition_rejects_out_of_grammar() {
197
- // 空 field / 缺 report_result 前缀 / 裸值(无引号) / 空串 → InvalidPlan。
198
- for bad in [
199
- "report_result. == 'y'",
200
- "foo == 'bar'",
201
- "",
202
- "report_result.s == bar",
203
- ] {
204
- assert!(
205
- matches!(
206
- PlanCondition::parse(bad),
207
- Err(LifecycleError::InvalidPlan(_))
208
- ),
209
- "expected InvalidPlan for {bad:?}"
210
- );
211
- }
212
- }
213
-
214
- #[test]
215
- fn start_mode_serde_names_match_python_start_mode_strings() {
216
- // 低价值 wire-format 守卫:start_mode ∈ {"resumed","fresh","fresh_after_missing_rollout","noop"}。
217
- assert_eq!(
218
- serde_json::to_string(&StartMode::Resumed).unwrap(),
219
- "\"resumed\""
220
- );
221
- assert_eq!(
222
- serde_json::to_string(&StartMode::Fresh).unwrap(),
223
- "\"fresh\""
224
- );
225
- assert_eq!(
226
- serde_json::to_string(&StartMode::FreshAfterMissingRollout).unwrap(),
227
- "\"fresh_after_missing_rollout\""
228
- );
229
- assert_eq!(serde_json::to_string(&StartMode::Noop).unwrap(), "\"noop\"");
230
- }
231
-
232
- // ───────────────────────────────────────────────────────────────────────
233
- // decide_start_mode — bug-085 四象限 + E20 #264 gap closure.
234
- // claude/copilot sess backing-present any-fresh -> resumed
235
- // claude/copilot sess backing-MISSING !allow_fresh -> noop/refuse (绝不静默 resume 死 session)
236
- // claude/copilot sess backing-MISSING allow_fresh -> fresh_after_missing_rollout
237
- // claude/copilot no-sess any -> fresh
238
- // non-resumable (fake/gemini_cli/retired codex/grok rows) sess -> noop 或 fresh_after_missing_rollout
239
- // 这是 bug-085 把 start_mode 分类从 start_agent 的 lock+spawn 全路径剥离出来的命门。
240
- // ───────────────────────────────────────────────────────────────────────
241
-
242
- fn sid(s: &str) -> SessionId {
243
- SessionId::new(s)
244
- }
245
- fn rp(p: &str) -> RolloutPath {
246
- RolloutPath::new(p)
247
- }
248
-
249
- #[test]
250
- fn decide_start_mode_copilot_missing_rollout_with_allow_fresh_is_fresh_after_missing() {
251
- // bug-085 唯一 FreshAfterMissingRollout 臂:copilot(唯一可 resume 的 legacy worker)+ 有 session_id + backing 缺 + allow_fresh。
252
- assert_eq!(
253
- decide_start_mode("copilot", Some(&sid("s1")), None, false, true),
254
- StartMode::FreshAfterMissingRollout
255
- );
256
- // rollout 路径存在但文件已不在,同样命中。
257
- assert_eq!(
258
- decide_start_mode(
259
- "copilot",
260
- Some(&sid("s1")),
261
- Some(&rp("/gone.jsonl")),
262
- false,
263
- true
264
- ),
265
- StartMode::FreshAfterMissingRollout
266
- );
267
- }
268
-
269
- #[test]
270
- fn decide_start_mode_copilot_missing_rollout_without_allow_fresh_refuses() {
271
- // E20 C①:backing 缺且 !allow_fresh → 诚实拒绝,绝不 resume 进死 session。
272
- assert_eq!(
273
- decide_start_mode("copilot", Some(&sid("s1")), None, false, false),
274
- StartMode::Noop
275
- );
276
- }
277
-
278
- #[test]
279
- fn decide_start_mode_copilot_rollout_present_is_resumed_regardless_of_fresh() {
280
- assert_eq!(
281
- decide_start_mode(
282
- "copilot",
283
- Some(&sid("s1")),
284
- Some(&rp("/r.jsonl")),
285
- true,
286
- false
287
- ),
288
- StartMode::Resumed
289
- );
290
- assert_eq!(
291
- decide_start_mode("copilot", Some(&sid("s1")), Some(&rp("/r.jsonl")), true, true),
292
- StartMode::Resumed
293
- );
294
- }
295
-
296
- #[test]
297
- fn decide_start_mode_no_session_is_fresh() {
298
- assert_eq!(
299
- decide_start_mode("copilot", None, None, false, true),
300
- StartMode::Fresh
301
- );
302
- assert_eq!(
303
- decide_start_mode("copilot", None, None, false, false),
304
- StartMode::Fresh
305
- );
306
- }
307
-
308
- #[test]
309
- fn decide_start_mode_checks_backing_for_all_resumable_providers() {
310
- for provider in ["claude", "claude_code", "copilot"] {
311
- assert_eq!(
312
- decide_start_mode(provider, Some(&sid("s1")), None, false, true),
313
- StartMode::FreshAfterMissingRollout,
314
- "{provider} missing backing + allow_fresh must not resume"
315
- );
316
- assert_eq!(
317
- decide_start_mode(provider, Some(&sid("s1")), None, false, false),
318
- StartMode::Noop,
319
- "{provider} missing backing + !allow_fresh must refuse"
320
- );
321
- assert_eq!(
322
- decide_start_mode(provider, Some(&sid("s1")), Some(&rp("/r")), true, false),
323
- StartMode::Resumed,
324
- "{provider} existing backing remains resumable"
325
- );
326
- }
327
- assert_eq!(
328
- decide_start_mode("claude", None, None, false, true),
329
- StartMode::Fresh
330
- );
331
- assert_eq!(
332
- decide_start_mode("copilot", None, None, false, false),
333
- StartMode::Fresh
334
- );
335
- }
336
-
337
- #[test]
338
- fn decide_start_mode_refuses_session_id_for_nonresumable_providers() {
339
- // A persisted legacy Codex / Grok worker row is no longer resumable.
340
- for provider in ["fake", "gemini_cli", "codex", "grok"] {
341
- assert_eq!(
342
- decide_start_mode(provider, Some(&sid("s1")), None, true, false),
343
- StartMode::Noop,
344
- "{provider} has a persisted session id but caps.resume=false, so it must not resume"
345
- );
346
- assert_eq!(
347
- decide_start_mode(provider, Some(&sid("s1")), None, true, true),
348
- StartMode::FreshAfterMissingRollout,
349
- "{provider} may only fresh-start a persisted session id under explicit allow_fresh"
350
- );
351
- }
352
- }
353
-
354
- #[test]
355
- fn resume_decision_serde_names_match_python() {
356
- // 低价值 wire-format 守卫:_emit_resume_decisions: "resume"|"fresh_start"|"refuse"。
357
- assert_eq!(
358
- serde_json::to_string(&ResumeDecision::Resume).unwrap(),
359
- "\"resume\""
360
- );
361
- assert_eq!(
362
- serde_json::to_string(&ResumeDecision::FreshStart).unwrap(),
363
- "\"fresh_start\""
364
- );
365
- assert_eq!(
366
- serde_json::to_string(&ResumeDecision::Refuse).unwrap(),
367
- "\"refuse\""
368
- );
369
- }
370
-
371
- // ───────────────────────────────────────────────────────────────────────
372
- // classify_restart_plan — Route B 全量验证 (orchestration.py:430/467/498-538)
373
- // golden 决策矩阵(_emit_resume_decisions):
374
- // resumable -> Resume
375
- // !resumable && !interacted(first_send_at absent) -> FreshStart
376
- // !resumable && interacted && allow_fresh -> FreshStart
377
- // !resumable && interacted && !allow_fresh -> Refuse
378
- // Refuse 的 worker reason: 无 session_id -> "no_persisted_session_id" ; 有但不可 resume -> "session_unresumable"
379
- // 这是把 "每非 paused worker 发一条 resume_decision + Refuse 是唯一 atomic_refusal 触发"
380
- // 从 restart() 整条 teardown 路径剥离出来的纯验证面(gate gap)。
381
- // ───────────────────────────────────────────────────────────────────────
382
-
383
- #[test]
384
- fn classify_restart_plan_interacted_unresumable_no_allow_fresh_yields_refuse() {
385
- // 种子 state:worker w1 有 first_send_at(已交互)但无可 resume 的 session_id。
386
- // !allow_fresh → decision=Refuse,且进 unresumable,reason=no_persisted_session_id。
387
- let state = json!({
388
- "session_name": "team-a",
389
- "agents": {
390
- "w1": {
391
- "provider": "claude",
392
- "first_send_at": "2026-05-27T10:00:00+00:00",
393
- "session_id": null
394
- }
395
- }
396
- });
397
- let plan = classify_restart_plan(&state, false)
398
- .expect("纯验证不应 Err(资源型失败才走 LifecycleError)");
399
- assert!(plan.corrupt_entries.is_empty(), "valid ISO 不应判 corrupt");
400
- // 恰一条决策(每非 paused worker 一条),且为 Refuse。
401
- assert_eq!(
402
- plan.decisions.len(),
403
- 1,
404
- "每非 paused worker 恰一条 resume_decision"
405
- );
406
- assert_eq!(plan.decisions[0].agent_id, aid("w1"));
407
- assert_eq!(plan.decisions[0].decision, ResumeDecision::Refuse);
408
- // unresumable 收口该 worker,reason 精确。
409
- assert_eq!(plan.unresumable.len(), 1);
410
- assert_eq!(plan.unresumable[0].agent_id, aid("w1"));
411
- assert_eq!(plan.unresumable[0].reason, "no_persisted_session_id");
412
- }
413
-
414
- #[test]
415
- fn classify_restart_plan_fake_stale_session_refuses_without_allow_fresh() {
416
- let state = json!({
417
- "session_name": "team-a",
418
- "agents": {
419
- "w1": {
420
- "provider": "fake",
421
- "first_send_at": "2026-05-27T10:00:00+00:00",
422
- "session_id": "stale-fake-session"
423
- }
424
- }
425
- });
426
- let plan = classify_restart_plan(&state, false).expect("pure validation should not Err");
427
- assert_eq!(plan.decisions.len(), 1);
428
- assert_eq!(plan.decisions[0].decision, ResumeDecision::Refuse);
429
- assert_eq!(plan.decisions[0].restart_mode, StartMode::Noop);
430
- assert_eq!(plan.unresumable.len(), 1);
431
- assert_eq!(plan.unresumable[0].reason, "session_unresumable");
432
- assert_eq!(
433
- plan.unresumable[0].session_id.as_ref().map(|s| s.as_str()),
434
- Some("stale-fake-session")
435
- );
436
- }
437
-
438
- #[test]
439
- fn classify_restart_plan_interacted_unresumable_with_allow_fresh_yields_fresh_start_not_refuse() {
440
- // 同一 worker,allow_fresh=true → FreshStart(可丢 context),unresumable 为空(无 atomic refusal)。
441
- let state = json!({
442
- "agents": {
443
- "w1": {
444
- "provider": "claude",
445
- "first_send_at": "2026-05-27T10:00:00+00:00",
446
- "session_id": null
447
- }
448
- }
449
- });
450
- let plan = classify_restart_plan(&state, true).expect("纯验证不应 Err");
451
- assert_eq!(plan.decisions.len(), 1);
452
- assert_eq!(plan.decisions[0].decision, ResumeDecision::FreshStart);
453
- assert!(
454
- plan.unresumable.is_empty(),
455
- "allow_fresh 下 interacted-unresumable 不触发 atomic_refusal"
456
- );
457
- }
458
-
459
- #[test]
460
- fn classify_restart_plan_never_captured_null_session_auto_fresh_partial_resume() {
461
- // 0.4.7 partial-resume (inverts pre-0.4.7 E6 layer-2 policy for the
462
- // never-captured-AND-never-interacted case ONLY): when a worker has BOTH
463
- // session_id=null AND first_send_at=null, it has NEVER been bound to a
464
- // provider session AND the leader has NEVER sent a message to it — there
465
- // is literally no context to lose. Auto-fresh without --allow-fresh is
466
- // safe and PREVENTS one never-captured role from blocking restart of
467
- // other resumable roles (1-blocks-N regression in 0.4.6).
468
- //
469
- // The "never silently fresh" guard is preserved for the dangerous case
470
- // (session_id=null + first_send_at=Valid = "received message but session
471
- // not captured" bug state) — see the OTHER refuse-interacted test below
472
- // and upgrade_restart_refuses_interacted_worker_without_session_id.
473
- let state = json!({
474
- "agents": { "w1": { "provider": "claude", "session_id": null } }
475
- });
476
- let plan = classify_restart_plan(&state, false).expect("纯验证不应 Err");
477
- assert_eq!(plan.decisions.len(), 1);
478
- assert_eq!(
479
- plan.decisions[0].decision,
480
- ResumeDecision::FreshStart,
481
- "0.4.7: never-captured + never-interacted → auto-fresh without --allow-fresh"
482
- );
483
- assert!(
484
- plan.unresumable.is_empty(),
485
- "0.4.7: never-captured worker is structurally non-resumable (no context); \
486
- must NOT enter unresumable (which would block sibling restart)"
487
- );
488
- }
489
-
490
- #[test]
491
- fn restart_required_missing_skips_never_captured_workers() {
492
- // RESTART-RESUME-001 (0.4.8): the pre-selection convergence missing-set
493
- // predicate must skip never-captured workers (null session_id, no
494
- // first_send_at/last_result_at/task_prompt_delivered) so a single
495
- // never-captured role doesn't burn the capture deadline and trigger
496
- // resume_not_ready when the selection stage would auto-fresh it anyway.
497
- use crate::lifecycle::restart::restart_required_missing_session_agent_ids;
498
- let state = json!({
499
- "agents": {
500
- "w1": { "provider": "claude", "session_id": null, "status": "running" }
501
- }
502
- });
503
- let missing = restart_required_missing_session_agent_ids(&state);
504
- assert!(
505
- missing.is_empty(),
506
- "never-captured null-session worker must NOT appear in required-missing; \
507
- got {missing:?}"
508
- );
509
- }
510
-
511
- #[test]
512
- fn restart_required_missing_keeps_null_session_with_first_send_at() {
513
- // RESTART-RESUME-001: null session_id + valid first_send_at means the
514
- // leader DID send a message; that context must be preserved → still
515
- // missing → restart refuses without --allow-fresh.
516
- use crate::lifecycle::restart::restart_required_missing_session_agent_ids;
517
- let state = json!({
518
- "agents": {
519
- "w1": {
520
- "provider": "claude",
521
- "session_id": null,
522
- "status": "running",
523
- "spawn_cwd": "/tmp/ws",
524
- "first_send_at": "2026-01-01T00:00:00+00:00",
525
- }
526
- }
527
- });
528
- let missing = restart_required_missing_session_agent_ids(&state);
529
- assert_eq!(
530
- missing,
531
- vec!["w1".to_string()],
532
- "null-session + valid first_send_at (context bearing) must remain in \
533
- required-missing; got {missing:?}"
534
- );
535
- }
536
-
537
- #[test]
538
- fn restart_required_missing_keeps_null_session_with_last_result_at() {
539
- // RESTART-RESUME-001: MCP / report_result paths may not have
540
- // first_send_at, but a non-empty last_result_at means the worker DID
541
- // produce a result; that context must be preserved.
542
- use crate::lifecycle::restart::restart_required_missing_session_agent_ids;
543
- let state = json!({
544
- "agents": {
545
- "w1": {
546
- "provider": "claude",
547
- "session_id": null,
548
- "status": "running",
549
- "spawn_cwd": "/tmp/ws",
550
- "last_result_at": "2026-01-01T00:00:00+00:00",
551
- }
552
- }
553
- });
554
- let missing = restart_required_missing_session_agent_ids(&state);
555
- assert_eq!(
556
- missing,
557
- vec!["w1".to_string()],
558
- "null-session + last_result_at must remain in required-missing; \
559
- got {missing:?}"
560
- );
561
- }
562
-
563
- #[test]
564
- fn classify_restart_plan_null_session_with_last_result_at_refuses_without_allow_fresh() {
565
- // RESTART-RESUME-001: selection stage must also refuse null-session +
566
- // last_result_at (no first_send_at) without --allow-fresh. Otherwise the
567
- // pre-selection convergence and selection-stage refuse semantics drift
568
- // and the gate fails for MCP-only report paths.
569
- let state = json!({
570
- "agents": {
571
- "w1": {
572
- "provider": "claude",
573
- "session_id": null,
574
- "last_result_at": "2026-01-01T00:00:00+00:00",
575
- }
576
- }
577
- });
578
- let plan = classify_restart_plan(&state, false).expect("纯验证不应 Err");
579
- assert_eq!(plan.decisions.len(), 1);
580
- assert_eq!(
581
- plan.decisions[0].decision,
582
- ResumeDecision::Refuse,
583
- "null-session + last_result_at must Refuse without --allow-fresh \
584
- (context to preserve); got {:?}",
585
- plan.decisions[0].decision
586
- );
587
- }
588
-
589
- #[test]
590
- fn classify_restart_plan_never_interacted_null_session_with_allow_fresh_marks_forced_fresh() {
591
- // E6 层2: 同上自启动 null-session worker,但显式 --allow-fresh → 用户主动认账丢上下文 → FreshStart。
592
- let state = json!({
593
- "agents": { "w1": { "provider": "claude", "session_id": null } }
594
- });
595
- let plan = classify_restart_plan(&state, true).expect("纯验证不应 Err");
596
- assert_eq!(plan.decisions.len(), 1);
597
- assert_eq!(
598
- plan.decisions[0].decision,
599
- ResumeDecision::FreshStart,
600
- "显式 --allow-fresh 才允许 null-session worker fresh"
601
- );
602
- assert!(
603
- plan.unresumable.is_empty(),
604
- "allow_fresh 下不触发 unresumable refusal"
605
- );
606
- }
607
-
608
- #[test]
609
- fn classify_restart_plan_copilot_with_session_still_resumes() {
610
- // E6 层2 回归锁(不误伤): copilot worker first_send_at=null 但 session_id 已捕 →
611
- // 仍走 Resume(分流轴是 session_id 有无,不是 interacted)。防层2 修法把 has_session 也误判。
612
- let ws = temp_ws();
613
- let rollout = ws.join("copilot-rollout.jsonl");
614
- std::fs::write(&rollout, "{}\n").unwrap();
615
- let state = json!({
616
- "agents": { "w1": { "provider": "copilot", "session_id": "sess-copilot-abc", "rollout_path": rollout.to_string_lossy() } }
617
- });
618
- let plan = classify_restart_plan(&state, false).expect("纯验证不应 Err");
619
- assert_eq!(plan.decisions.len(), 1);
620
- assert_eq!(
621
- plan.decisions[0].decision,
622
- ResumeDecision::Resume,
623
- "有 session_id 必 Resume,与 first_send_at/interacted 无关"
624
- );
625
- assert!(plan.unresumable.is_empty());
626
- }
627
-
628
- // ───────────────────────────────────────────────────────────────────────
629
- // reset_agent — operations.py:102/104
630
- // 未传 discard_session=true → Refused{ DiscardSessionRequired }
631
- // (Python: {"ok":False,"status":"refused","reason":"discard_session_required"})
632
- // 这是不丢上下文的误用保护,且在 owner-gate / 重起之前(纯输入门)。
633
- // ───────────────────────────────────────────────────────────────────────
634
-
635
- #[test]
636
- fn reset_agent_without_discard_session_is_refused() {
637
- let ws = temp_ws();
638
- let got = reset_agent(&ws, &aid("w1"), false, false, None)
639
- .expect("discard_session=false 是 typed Refused,不是 Err");
640
- assert_eq!(
641
- got,
642
- ResetAgentOutcome::Refused {
643
- reason: ResetRefusal::DiscardSessionRequired
644
- }
645
- );
646
- }
647
-
648
- // ───────────────────────────────────────────────────────────────────────
649
- // owner-gate first-door — 每个单 worker 动作的第一道门(check_team_owner)
650
- // 空 / 无主 workspace:无 owner 记录 → foreign-owner gate 应 refuse 成 OwnerRefused,
651
- // 或在更上游因缺 state 而 typed-refuse。本测试锁:start_agent/stop_agent 在没有
652
- // 合法 owner 的 workspace 上 NOT 返回 Ok(Running/Stopped) —— 即门确实存在。
653
- // (RED:现 unimplemented!() panic;porter 实现后须命中此分支。)
654
- // ───────────────────────────────────────────────────────────────────────
655
-
656
- #[test]
657
- fn start_agent_on_unowned_workspace_does_not_silently_run() {
658
- let ws = temp_ws(); // 空 workspace,无 state/spec/owner
659
- match start_agent(&ws, &aid("w1"), false, false, false, None) {
660
- // 允许:owner 门拒 / 缺 spec 等 requirement 门 / team 选择失败。
661
- Err(LifecycleError::OwnerRefused(_))
662
- | Err(LifecycleError::RequirementUnmet(_))
663
- | Err(LifecycleError::TeamSelect(_))
664
- | Err(LifecycleError::Compile(_)) => {}
665
- // 绝不允许:在没有合法 owner 的空 workspace 上声称 Running。
666
- Ok(StartAgentOutcome::Running { .. }) => {
667
- panic!("start_agent 在无主空 workspace 上不得 Running —— owner-gate 漏门")
668
- }
669
- other => panic!("意外结果(porter 实现后应命中门):{other:?}"),
670
- }
671
- }
672
-
673
- #[test]
674
- fn stop_agent_on_unowned_workspace_does_not_silently_stop() {
675
- let ws = temp_ws();
676
- match stop_agent(&ws, &aid("w1"), None) {
677
- Err(LifecycleError::OwnerRefused(_))
678
- | Err(LifecycleError::RequirementUnmet(_))
679
- | Err(LifecycleError::TeamSelect(_))
680
- | Err(LifecycleError::Transport(_)) => {}
681
- Ok(rep) => panic!("stop_agent 在无主空 workspace 上不得成功:{rep:?}"),
682
- other => panic!("意外结果:{other:?}"),
683
- }
684
- }
685
-
686
- // ───────────────────────────────────────────────────────────────────────
687
- // remove_agent — agents.py:54/56
688
- // 未传 from_spec 确认 → RefusedFromSpecConfirm;运行中未传 force → RefusedForceRequired。
689
- // (typed refusal,不是 Err。) _RemoveRollback 字节级回滚见 Removed.agent_health_deleted。
690
- // ───────────────────────────────────────────────────────────────────────
691
-
692
- #[test]
693
- fn remove_agent_without_from_spec_is_refused_confirm() {
694
- let ws = temp_ws();
695
- // from_spec=false:Python agents.py:54 拒绝(需显式确认从 spec 摘除)。
696
- match remove_agent(&ws, &aid("w1"), false, false, None) {
697
- Ok(RemoveAgentOutcome::RefusedFromSpecConfirm { agent_id }) => {
698
- assert_eq!(agent_id, aid("w1"));
699
- }
700
- // 若先撞 owner / 缺 state / runtime-missing 门也可接受(门在 confirm 之前)。
701
- Err(LifecycleError::OwnerRefused(_))
702
- | Err(LifecycleError::RequirementUnmet(_))
703
- | Err(LifecycleError::TeamSelect(_)) => {}
704
- other => panic!("from_spec=false 应 RefusedFromSpecConfirm 或更上游门:{other:?}"),
705
- }
706
- }
707
-
708
- // ───────────────────────────────────────────────────────────────────────
709
- // restart — orchestration.py (Route B resume-atomicity)
710
- // corrupt first_send_at → RefusedInvalidFirstSendAt,且在任何破坏性 teardown 之前
711
- // (hard refuse BEFORE teardown)。无主空 workspace 至少不得 Restarted。
712
- // CorruptFirstSendAt payload 必带 raw + python type name(orchestration.py:443)。
713
- // ───────────────────────────────────────────────────────────────────────
714
-
715
- #[test]
716
- fn restart_on_unowned_workspace_does_not_restart() {
717
- let ws = temp_ws();
718
- match restart(&ws, false, None) {
719
- Err(LifecycleError::OwnerRefused(_))
720
- | Err(LifecycleError::TeamSelect(_))
721
- | Err(LifecycleError::SessionConflict(_)) => {}
722
- Ok(RestartReport::Restarted { .. }) => {
723
- panic!("restart 在无主空 workspace 上不得 Restarted")
724
- }
725
- // 校验阶段的 typed refusal 也可接受(refuse 早于 teardown,nothing created)。
726
- Ok(RestartReport::RefusedResumeAtomicity { .. })
727
- | Ok(RestartReport::RefusedInvalidFirstSendAt { .. }) => {}
728
- other => panic!("意外结果:{other:?}"),
729
- }
730
- }
731
-
732
- #[test]
733
- fn python_type_name_maps_to_python_names_not_serde_names() {
734
- // orchestration.py:446 — type(raw).__name__。golden 实跑(/tmp/x.py):
735
- // null->NoneType, ""/"null"/"x"->str, 0/123->int, false->bool, []->list, {}->dict, 1.5->float
736
- // 必须是 Python 名,绝不是 serde 的 null/string/number/boolean/array/object。
737
- assert_eq!(python_type_name(&json!(null)), "NoneType");
738
- assert_eq!(python_type_name(&json!("")), "str");
739
- assert_eq!(python_type_name(&json!("null")), "str");
740
- assert_eq!(python_type_name(&json!(0)), "int");
741
- assert_eq!(python_type_name(&json!(123)), "int");
742
- assert_eq!(python_type_name(&json!(false)), "bool");
743
- assert_eq!(python_type_name(&json!([])), "list");
744
- assert_eq!(python_type_name(&json!({})), "dict");
745
- assert_eq!(python_type_name(&json!(1.5)), "float");
746
- }
747
-
748
- #[test]
749
- fn classify_restart_plan_produces_corrupt_entries_with_python_type_names() {
750
- // 真驱动:种子 state 含 3 个 corrupt first_send_at(""/0/[]),classify_restart_plan
751
- // 必发对应 CorruptFirstSendAt,raw 原值保留,type 为 python type().__name__
752
- // ("str"/"int"/"list") —— 锁跨语言 type-name 映射,不是手设字段。
753
- let state = json!({
754
- "agents": {
755
- "w_str": { "provider": "claude", "first_send_at": "" },
756
- "w_int": { "provider": "claude", "first_send_at": 0 },
757
- "w_list": { "provider": "claude", "first_send_at": [] }
758
- }
759
- });
760
- // corrupt 非空 → restart 在 teardown 之前 hard refuse(决策前)。
761
- let plan = classify_restart_plan(&state, false).expect("纯验证不应 Err");
762
- let by_id: BTreeMap<String, &CorruptFirstSendAt> = plan
763
- .corrupt_entries
764
- .iter()
765
- .map(|e| (e.worker_id.as_str().to_string(), e))
766
- .collect();
767
- assert_eq!(by_id.len(), 3, "3 个 corrupt worker 各一条 entry");
768
- let s = by_id.get("w_str").expect("w_str corrupt entry");
769
- assert_eq!(s.raw_first_send_at, json!(""));
770
- assert_eq!(s.raw_first_send_at_type, "str");
771
- let i = by_id.get("w_int").expect("w_int corrupt entry");
772
- assert_eq!(i.raw_first_send_at, json!(0));
773
- assert_eq!(i.raw_first_send_at_type, "int");
774
- let l = by_id.get("w_list").expect("w_list corrupt entry");
775
- assert_eq!(l.raw_first_send_at, json!([]));
776
- assert_eq!(l.raw_first_send_at_type, "list");
777
- // 自洽:每个 raw 经 classify 必判 Corrupt(hard refuse 前提)。
778
- for e in &plan.corrupt_entries {
779
- assert_eq!(
780
- classify_first_send_at(&e.raw_first_send_at),
781
- FirstSendAtState::Corrupt
782
- );
783
- }
784
- }
785
-
786
- // ───────────────────────────────────────────────────────────────────────
787
- // select_restart_state — selection.py:49
788
- // 空 workspace:无候选 → 回退 load_runtime_state(空态)或 TeamSelect not-found;
789
- // 显式 team 未找到 → TeamSelect。锁:歧义/未找到走 TeamSelect 而非 panic。
790
- // ───────────────────────────────────────────────────────────────────────
791
-
792
- #[test]
793
- fn select_restart_state_unknown_team_is_team_select_error() {
794
- let ws = temp_ws();
795
- match select_restart_state(&ws, Some("ghost-team")) {
796
- Err(LifecycleError::TeamSelect(msg)) => {
797
- // Python: "restart team 'ghost-team' not found. ..."
798
- assert!(
799
- msg.contains("ghost-team") || msg.contains("not found"),
800
- "TeamSelect 文案应指名缺失 team:{msg}"
801
- );
802
- }
803
- other => panic!("未知 team 应 TeamSelect:{other:?}"),
804
- }
805
- }
806
-
807
- #[test]
808
- fn restart_candidates_empty_workspace_is_empty_list() {
809
- // selection.py:12 — 无 snapshot 无 active state → 空 vec(不是 Err)。
810
- let ws = temp_ws();
811
- let got = restart_candidates(&ws).expect("空 workspace 应 Ok(空 vec)");
812
- assert!(got.is_empty(), "空 workspace 不应有候选:{got:?}");
813
- }
814
-
815
- // ───────────────────────────────────────────────────────────────────────
816
- // save_team_runtime_snapshot — snapshot.py:17 (bug-084)
817
- // session_name 缺失 → Python 返回 None;Rust 入口签名为 Result<PathBuf,_>。
818
- // 锁:有 session_name 的 state 原子写出 .../runtime/teams/<safe>/state.json。
819
- // safe_snapshot_name: 非 [A-Za-z0-9_.-] → "_",再 strip "._-"。
820
- // ───────────────────────────────────────────────────────────────────────
821
-
822
- #[test]
823
- fn save_snapshot_writes_atomic_state_json_under_teams_dir() {
824
- let ws = temp_ws();
825
- let state = json!({"session_name": "team-alpha", "agents": {}});
826
- let path =
827
- save_team_runtime_snapshot(&ws, &state).expect("bug-084:写路径返 Result,正常态须 Ok");
828
- // 末段必为 state.json,且落在 runtime/teams/<safe session> 下。
829
- assert_eq!(
830
- path.file_name().and_then(|s| s.to_str()),
831
- Some("state.json")
832
- );
833
- let s = path.to_string_lossy();
834
- assert!(
835
- s.contains("teams") && s.contains("team-alpha"),
836
- "快照应落在 runtime/teams/<session>/:{s}"
837
- );
838
- assert!(path.exists(), "os.replace 后目标文件应存在");
839
- }
840
-
841
- // ───────────────────────────────────────────────────────────────────────
842
- // quick_start — diagnose/quick_start.py:18
843
- // 空 agents_dir + fresh=false:无 runtime → 走 launch(可能 PreflightBlocked);
844
- // 锁:返回 QuickStartReport(typed outcome,不 panic),且 Ready 时 next_actions 非空。
845
- // ───────────────────────────────────────────────────────────────────────
846
-
847
- #[test]
848
- fn quick_start_empty_dir_returns_typed_report_not_error_path_only() {
849
- let ws = temp_ws();
850
- // 空目录无可编译 team:应是 typed 阻塞 / 编译错,绝不 Ready。
851
- match quick_start(&ws, None, false, None) {
852
- Ok(QuickStartReport::Ready { .. }) => {
853
- panic!("空 agents_dir 不应 Ready —— 无 team 可编译")
854
- }
855
- Ok(QuickStartReport::PreflightBlocked { blockers, .. }) => {
856
- assert!(!blockers.is_empty(), "PreflightBlocked 必列 blockers");
857
- }
858
- Ok(QuickStartReport::ExistingRuntime { .. }) => {}
859
- Err(LifecycleError::Compile(_)) | Err(LifecycleError::RequirementUnmet(_)) => {}
860
- other => panic!("意外结果:{other:?}"),
861
- }
862
- }
863
-
864
- #[test]
865
- #[serial_test::serial(env)]
866
- fn leader_pane_env_absent_pane_fails_fast() {
867
- let _leader_pane = EnvVarGuard::set("TEAM_AGENT_LEADER_PANE_ID", "%9999");
868
- let transport =
869
- crate::transport::test_support::OfflineTransport::new().with_pane_presence("%9999", false);
870
- let err = validate_active_leader_pane_env(&transport).expect_err("absent pane must fail");
871
- let msg = err.to_string();
872
- assert!(msg.contains("TEAM_AGENT_LEADER_PANE_ID"), "got: {msg}");
873
- assert!(msg.contains("absent"), "got: {msg}");
874
- assert!(msg.contains("%9999"), "got: {msg}");
875
- }
876
-
877
- #[test]
878
- #[serial_test::serial(env)]
879
- fn leader_pane_env_dead_pane_fails_fast() {
880
- let _leader_pane = EnvVarGuard::set("TEAM_AGENT_LEADER_PANE_ID", "%404");
881
- let transport = crate::transport::test_support::OfflineTransport::new()
882
- .with_liveness("%404", PaneLiveness::Dead);
883
- let err = validate_active_leader_pane_env(&transport).expect_err("dead pane must fail");
884
- let msg = err.to_string();
885
- assert!(msg.contains("TEAM_AGENT_LEADER_PANE_ID"), "got: {msg}");
886
- assert!(msg.contains("dead"), "got: {msg}");
887
- assert!(msg.contains("%404"), "got: {msg}");
888
- }
889
-
890
- #[test]
891
- #[serial_test::serial(env)]
892
- fn leader_pane_env_unset_passes_without_probe() {
893
- let _leader_pane = EnvVarGuard::remove("TEAM_AGENT_LEADER_PANE_ID");
894
- let transport = crate::transport::test_support::OfflineTransport::new();
895
- validate_active_leader_pane_env(&transport).expect("unset env must pass");
896
- assert!(
897
- transport.calls().is_empty(),
898
- "unset env must not probe transport: {:?}",
899
- transport.calls()
900
- );
901
- }
902
-
903
- #[test]
904
- #[serial_test::serial(env)]
905
- fn leader_pane_env_unknown_when_unprovable_does_not_fail_fast() {
906
- let _leader_pane = EnvVarGuard::set("TEAM_AGENT_LEADER_PANE_ID", "%8888");
907
- let transport = crate::transport::test_support::OfflineTransport::new()
908
- .with_default_liveness(PaneLiveness::Unknown);
909
- validate_active_leader_pane_env(&transport).expect("unknown/unprovable pane must not fail");
910
- }
911
-
912
- #[test]
913
- #[serial_test::serial(env)]
914
- fn leader_pane_env_non_numeric_pane_id_is_unknown_not_absent() {
915
- let _leader_pane = EnvVarGuard::set("TEAM_AGENT_LEADER_PANE_ID", "abc-notapane");
916
- let transport = crate::transport::test_support::OfflineTransport::new()
917
- .with_pane_presence("abc-notapane", false)
918
- .with_liveness("abc-notapane", PaneLiveness::Dead);
919
- validate_active_leader_pane_env(&transport)
920
- .expect("non `%<digits>` env values are unprovable, not absent");
921
- assert!(
922
- transport.calls().is_empty(),
923
- "invalid pane id format must not hit tmux probe: {:?}",
924
- transport.calls()
925
- );
926
- }
927
-
928
- #[test]
929
- #[serial_test::serial(env)]
930
- fn leader_pane_env_invalid_format_writes_warning_event() {
931
- let ws = temp_ws();
932
- let _leader_pane = EnvVarGuard::set("TEAM_AGENT_LEADER_PANE_ID", "abc-notapane");
933
- let transport = crate::transport::test_support::OfflineTransport::new()
934
- .with_pane_presence("abc-notapane", false);
935
-
936
- validate_active_leader_pane_env_with_workspace(&transport, Some(&ws))
937
- .expect("invalid format is warning-only");
938
-
939
- let events = crate::event_log::EventLog::new(&ws)
940
- .tail(0)
941
- .expect("events");
942
- let event = events
943
- .iter()
944
- .find(|event| {
945
- event.get("event").and_then(serde_json::Value::as_str)
946
- == Some("leader_pane_env.validation_warning")
947
- })
948
- .expect("warning event");
949
- assert_eq!(
950
- event.get("value").and_then(serde_json::Value::as_str),
951
- Some("abc-notapane")
952
- );
953
- assert_eq!(
954
- event.get("warning").and_then(serde_json::Value::as_str),
955
- Some("invalid pane id format, skipping validation")
956
- );
957
- }
958
-
959
- #[test]
960
- #[serial_test::serial(env)]
961
- fn leader_pane_env_invalid_format_writes_warning_to_all_candidate_workspaces() {
962
- let cli_ws = temp_ws();
963
- let team_ws = temp_ws();
964
- let _leader_pane = EnvVarGuard::set("TEAM_AGENT_LEADER_PANE_ID", "abc-notapane");
965
- let transport = crate::transport::test_support::OfflineTransport::new();
966
-
967
- validate_active_leader_pane_env_with_workspaces(&transport, &[&cli_ws, &team_ws])
968
- .expect("invalid format is warning-only");
969
-
970
- for ws in [&cli_ws, &team_ws] {
971
- let events = crate::event_log::EventLog::new(ws).tail(0).expect("events");
972
- assert!(
973
- events.iter().any(|event| {
974
- event.get("event").and_then(serde_json::Value::as_str)
975
- == Some("leader_pane_env.validation_warning")
976
- && event.get("value").and_then(serde_json::Value::as_str)
977
- == Some("abc-notapane")
978
- }),
979
- "warning event missing in {}: {events:?}",
980
- ws.display()
981
- );
982
- }
983
- }
984
-
985
- #[test]
986
- fn leader_pane_env_cross_socket_live_wins() {
987
- let pane = crate::transport::PaneId::new("%7");
988
- let absent =
989
- crate::transport::test_support::OfflineTransport::new().with_pane_presence("%7", false);
990
- let live =
991
- crate::transport::test_support::OfflineTransport::new().with_pane_presence("%7", true);
992
-
993
- let state = active_leader_pane_state_across_transports(
994
- [&absent as &dyn crate::transport::Transport, &live],
995
- &pane,
996
- );
997
-
998
- assert_eq!(state, LeaderPaneEnvState::Live);
999
- }
1000
-
1001
- #[test]
1002
- fn leader_pane_env_cross_socket_dead_rejects_without_live() {
1003
- let pane = crate::transport::PaneId::new("%404");
1004
- let absent =
1005
- crate::transport::test_support::OfflineTransport::new().with_pane_presence("%404", false);
1006
- let dead = crate::transport::test_support::OfflineTransport::new()
1007
- .with_liveness("%404", PaneLiveness::Dead);
1008
-
1009
- let state = active_leader_pane_state_across_transports(
1010
- [&absent as &dyn crate::transport::Transport, &dead],
1011
- &pane,
1012
- );
1013
-
1014
- assert_eq!(state, LeaderPaneEnvState::Dead);
1015
- }
1016
-
1017
- #[test]
1018
- fn leader_pane_env_cross_socket_absent_when_reachable_servers_confirm_missing() {
1019
- let pane = crate::transport::PaneId::new("%9999");
1020
- let absent =
1021
- crate::transport::test_support::OfflineTransport::new().with_pane_presence("%9999", false);
1022
- let unknown = crate::transport::test_support::OfflineTransport::new()
1023
- .with_default_liveness(PaneLiveness::Unknown);
1024
-
1025
- let state = active_leader_pane_state_across_transports(
1026
- [&absent as &dyn crate::transport::Transport, &unknown],
1027
- &pane,
1028
- );
1029
-
1030
- assert_eq!(state, LeaderPaneEnvState::Absent);
1031
- }
1032
-
1033
- #[test]
1034
- fn leader_pane_env_cross_socket_all_probe_errors_stays_unknown() {
1035
- let pane = crate::transport::PaneId::new("%maybe");
1036
- let unknown_a = crate::transport::test_support::OfflineTransport::new()
1037
- .with_default_liveness(PaneLiveness::Unknown);
1038
- let unknown_b = crate::transport::test_support::OfflineTransport::new()
1039
- .with_default_liveness(PaneLiveness::Unknown);
1040
-
1041
- let state = active_leader_pane_state_across_transports(
1042
- [&unknown_a as &dyn crate::transport::Transport, &unknown_b],
1043
- &pane,
1044
- );
1045
-
1046
- assert_eq!(state, LeaderPaneEnvState::Unknown);
1047
- }
1048
-
1049
- #[test]
1050
- fn mcp_auto_approval_env_marks_leader_bypass_namespace_only() {
1051
- let mut env = std::collections::BTreeMap::new();
1052
- let safety = DangerousApproval {
1053
- enabled: true,
1054
- source: DangerousApprovalSource::LeaderProcess,
1055
- inherited: true,
1056
- provider: Some("codex".to_string()),
1057
- flag: Some("--dangerously-bypass-approvals-and-sandbox".to_string()),
1058
- worker_capability_above_leader: false,
1059
- ancestry_binary_name: Some("codex".to_string()),
1060
- unexpected_binary: false,
1061
- };
1062
-
1063
- apply_mcp_auto_approval_env(&mut env, &safety);
1064
-
1065
- assert_eq!(
1066
- env.get("TEAM_AGENT_LEADER_BYPASS").map(String::as_str),
1067
- Some("1")
1068
- );
1069
- assert_eq!(
1070
- env.get("TEAM_AGENT_MCP_AUTO_APPROVE").map(String::as_str),
1071
- Some("team_orchestrator")
1072
- );
1073
- assert_eq!(
1074
- env.get("TEAM_AGENT_MCP_AUTO_APPROVE_SOURCE")
1075
- .map(String::as_str),
1076
- Some("leader_bypass")
1077
- );
1078
- assert_eq!(
1079
- env.get("TEAM_AGENT_LEADER_BYPASS_FLAG").map(String::as_str),
1080
- Some("--dangerously-bypass-approvals-and-sandbox")
1081
- );
1082
- }
1083
-
1084
- #[test]
1085
- fn mcp_auto_approval_env_clears_when_leader_is_restricted() {
1086
- let mut env = std::collections::BTreeMap::from([
1087
- (
1088
- "TEAM_AGENT_MCP_AUTO_APPROVE".to_string(),
1089
- "team_orchestrator".to_string(),
1090
- ),
1091
- (
1092
- "TEAM_AGENT_MCP_AUTO_APPROVE_SOURCE".to_string(),
1093
- "leader_bypass".to_string(),
1094
- ),
1095
- ]);
1096
- let safety = DangerousApproval {
1097
- enabled: false,
1098
- source: DangerousApprovalSource::Disabled,
1099
- inherited: false,
1100
- provider: None,
1101
- flag: None,
1102
- worker_capability_above_leader: false,
1103
- ancestry_binary_name: None,
1104
- unexpected_binary: false,
1105
- };
1106
-
1107
- apply_mcp_auto_approval_env(&mut env, &safety);
1108
-
1109
- assert_eq!(
1110
- env.get("TEAM_AGENT_LEADER_BYPASS").map(String::as_str),
1111
- Some("0")
1112
- );
1113
- assert!(
1114
- !env.contains_key("TEAM_AGENT_MCP_AUTO_APPROVE"),
1115
- "restricted leader must not leave MCP auto-approval env behind: {env:?}"
1116
- );
1117
- }
1118
-
1119
- struct EnvVarGuard {
1120
- key: &'static str,
1121
- previous: Option<String>,
1122
- }
1123
-
1124
- impl EnvVarGuard {
1125
- fn set(key: &'static str, value: &str) -> Self {
1126
- let previous = std::env::var(key).ok();
1127
- unsafe {
1128
- std::env::set_var(key, value);
1129
- }
1130
- Self { key, previous }
1131
- }
1132
-
1133
- fn remove(key: &'static str) -> Self {
1134
- let previous = std::env::var(key).ok();
1135
- unsafe {
1136
- std::env::remove_var(key);
1137
- }
1138
- Self { key, previous }
1139
- }
1140
- }
1141
-
1142
- impl Drop for EnvVarGuard {
1143
- fn drop(&mut self) {
1144
- unsafe {
1145
- if let Some(value) = self.previous.take() {
1146
- std::env::set_var(self.key, value);
1147
- } else {
1148
- std::env::remove_var(self.key);
1149
- }
1150
- }
1151
- }
1152
- }
1153
-
1154
- // ───────────────────────────────────────────────────────────────────────
1155
- // fork_agent — operations.py:284 (native session fork eligibility)
1156
- // 资格门(adapter.supports_session_fork = auth_mode != "compatible_api"):
1157
- // - compatible_api 的 agent → 不支持 fork → RuntimeError("<provider> does not support
1158
- // native session fork") → Rust Provider error。
1159
- // - 源 session_id 缺失 → RuntimeError("cannot fork <id>: source session_id is missing")。
1160
- // 空无主 workspace:owner-gate / 缺 spec 门优先。失败臂须 adapter.cleanup_mcp + 回滚 spec。
1161
- // ───────────────────────────────────────────────────────────────────────
1162
-
1163
- #[test]
1164
- fn fork_agent_on_unowned_workspace_does_not_silently_fork() {
1165
- let ws = temp_ws();
1166
- match fork_agent(&ws, &aid("src"), &aid("dst"), None, false, None) {
1167
- // 允许:owner 门 / team 选择 / 缺 spec(provider 命令构造前的上游门)。
1168
- Err(LifecycleError::OwnerRefused(_))
1169
- | Err(LifecycleError::TeamSelect(_))
1170
- | Err(LifecycleError::Compile(_))
1171
- | Err(LifecycleError::RequirementUnmet(_))
1172
- // 资格 / 源 session 缺失 → Provider error(native fork 不可用)。
1173
- | Err(LifecycleError::Provider(_)) => {}
1174
- Ok(rep) => panic!("无主空 workspace 不得成功 fork:{rep:?}"),
1175
- other => panic!("意外结果(porter 实现后应命中门):{other:?}"),
1176
- }
1177
- }
1178
-
1179
- // ───────────────────────────────────────────────────────────────────────
1180
- // add_agent — operations.py:143 (字节级回滚 ORDER, Gap 15.11)
1181
- // 前向 step 顺序(_step_done 发 lifecycle.add_step_completed):
1182
- // role_file -> compile_role_doc -> spec_yaml -> team_state_md -> start_agent -> workspace_state
1183
- // 回滚顺序(失败时,发 lifecycle.add_step_rolled_back,operations.py:223-259):
1184
- // spec_yaml -> workspace_state -> team_state_md -> role_file
1185
- // 事件名常量已在 event_names 锁定。无主空 workspace:owner/缺 spec 门优先于任何写。
1186
- // ───────────────────────────────────────────────────────────────────────
1187
-
1188
- #[test]
1189
- fn add_agent_event_name_constants_match_python_lifecycle_strings() {
1190
- // 锁死发射事件名(顺序被 porter 实现后的事件流锁死;此处锁名)。
1191
- assert_eq!(
1192
- event_names::ADD_STEP_COMPLETED,
1193
- "lifecycle.add_step_completed"
1194
- );
1195
- assert_eq!(
1196
- event_names::ADD_STEP_ROLLED_BACK,
1197
- "lifecycle.add_step_rolled_back"
1198
- );
1199
- assert_eq!(event_names::ADD_FAILED, "lifecycle.add_failed");
1200
- }
1201
-
1202
- #[test]
1203
- fn add_agent_on_unowned_workspace_does_not_silently_add() {
1204
- let ws = temp_ws();
1205
- // 缺 role file / 缺 owner / 缺 spec → 上游门拒,绝不返回 Ok(env running)。
1206
- match add_agent(&ws, &aid("w1"), &ws.join("role.md"), false, None) {
1207
- Err(LifecycleError::OwnerRefused(_))
1208
- | Err(LifecycleError::TeamSelect(_))
1209
- | Err(LifecycleError::Compile(_))
1210
- | Err(LifecycleError::RequirementUnmet(_))
1211
- | Err(LifecycleError::RollbackFailed { .. }) => {}
1212
- Ok(rep) => panic!("无主空 workspace 不得成功 add:{rep:?}"),
1213
- other => panic!("意外结果:{other:?}"),
1214
- }
1215
- }
1216
-
1217
- // ───────────────────────────────────────────────────────────────────────
1218
- // start_plan / handle_report_result / halt_plan / plan_status
1219
- // (orchestrator/__init__.py:26/79/152/177)
1220
- // golden:
1221
- // start_plan 无 stage / 空 plan 路径 -> {"ok":False,"error":"plan has no stages"} 或 InvalidPlan
1222
- // handle_report_result 无匹配 stage -> {"ok":True,"status":"no_match","matched":False} -> NoMatch
1223
- // stage advance_on 命中 -> current_stage += 1;> len -> Completed
1224
- // halt_plan 未找到 -> {"ok":False,"error":"plan not found"} ; 非 running -> already_terminal 幂等
1225
- // plan_status 未找到 -> {"ok":False,"error":"plan not found"} -> Err / typed
1226
- // current_stage 1-based。
1227
- // ───────────────────────────────────────────────────────────────────────
1228
-
1229
- #[test]
1230
- fn start_plan_missing_file_is_invalid_plan_not_panic() {
1231
- let ws = temp_ws();
1232
- let missing = ws.join("nope.plan.yaml");
1233
- // 不存在 / 无 stage 的 plan → InvalidPlan(typed),不 panic 也不 Ok(Running)。
1234
- match start_plan(&ws, &missing, true) {
1235
- Err(LifecycleError::InvalidPlan(_)) | Err(LifecycleError::InvalidPlanId(_)) => {}
1236
- Ok(PlanProgress::Running { .. }) | Ok(PlanProgress::Completed { .. }) => {
1237
- panic!("缺失 / 无 stage 的 plan 不得 Running/Completed")
1238
- }
1239
- other => panic!("意外结果:{other:?}"),
1240
- }
1241
- }
1242
-
1243
- #[test]
1244
- fn handle_report_result_no_running_plan_is_no_match() {
1245
- let ws = temp_ws();
1246
- // 无任何 plan state → 任何 report_result 都不匹配 → NoMatch(no_match / matched:false)。
1247
- let envelope = json!({"report_result": {"status": "done"}});
1248
- let got = handle_report_result(&ws, &envelope).expect("no_match 是 typed outcome,不是 Err");
1249
- assert_eq!(got, PlanProgress::NoMatch);
1250
- }
1251
-
1252
- #[test]
1253
- fn halt_plan_unknown_id_is_not_found_error() {
1254
- let ws = temp_ws();
1255
- let pid = PlanId::parse("ghost-plan").expect("合法 plan id");
1256
- // 未持久化的 plan → "plan not found"(typed/Err),不幂等成 Halted。
1257
- match halt_plan(&ws, &pid, "user_requested") {
1258
- Err(LifecycleError::InvalidPlan(msg)) | Err(LifecycleError::TeamSelect(msg)) => {
1259
- assert!(
1260
- msg.contains("not found") || msg.contains("ghost-plan"),
1261
- "got: {msg}"
1262
- );
1263
- }
1264
- Ok(PlanProgress::Halted { .. }) => {
1265
- panic!("未找到的 plan 不得返回 Halted(应 not-found)")
1266
- }
1267
- other => panic!("意外结果:{other:?}"),
1268
- }
1269
- }
1270
-
1271
- #[test]
1272
- fn plan_status_unknown_id_is_not_found() {
1273
- let ws = temp_ws();
1274
- let pid = PlanId::parse("ghost-plan").expect("合法 plan id");
1275
- // 读未持久化 plan → not-found error(Rust 入口签名 Result<PlanState,_>)。
1276
- match plan_status(&ws, &pid) {
1277
- Err(LifecycleError::InvalidPlan(msg)) | Err(LifecycleError::TeamSelect(msg)) => {
1278
- assert!(
1279
- msg.contains("not found") || msg.contains("ghost-plan"),
1280
- "got: {msg}"
1281
- );
1282
- }
1283
- Ok(st) => panic!("未持久化 plan 不得返回 PlanState:{st:?}"),
1284
- other => panic!("意外结果:{other:?}"),
1285
- }
1286
- }
1287
-
1288
- // ═══════════════ P2 FIX-LOOP RED (复绿即对抗 cross-model finding) ═══════════════
1289
- // P1 — classify_first_send_at must accept the breadth of datetime.fromisoformat
1290
- // (restart/orchestration.py:404-426): space/'t'/'_' separators, date-only, fractional
1291
- // seconds, HH:MM, compact ±HHMM offset, basic YYYYMMDDTHHMMSS. The current dual-parser
1292
- // (rfc3339 OR "%Y-%m-%dT%H:%M:%S") marks these Corrupt, flipping restart() into a hard
1293
- // refuse where Python proceeds. Golden re-probed via /tmp/probe_p2b_iso.py (all → 'valid').
1294
- #[test]
1295
- fn p2_classify_first_send_at_accepts_broad_iso_like_python() {
1296
- for s in [
1297
- "2026-05-27 10:00:00", // space separator
1298
- "2026-05-27", // date-only
1299
- "2026-05-27T10:00:00.123456", // fractional seconds
1300
- "2026-05-27T10:00", // HH:MM
1301
- "2026-05-27T10:00:00+0000", // compact ±HHMM offset
1302
- "20260527T100000", // basic ISO
1303
- "2026-05-27t10:00:00", // lowercase 't' separator
1304
- "2026-05-27_10:00:00", // underscore separator
1305
- ] {
1306
- assert_eq!(
1307
- classify_first_send_at(&serde_json::json!(s)),
1308
- FirstSendAtState::Valid,
1309
- "Python datetime.fromisoformat accepts {s:?}",
1310
- );
1311
- }
1312
- }
1313
-
1314
- // ═════════════════════════════════════════════════════════════════════════
1315
- // LIFECYCLE ENTRY POINTS — RED integration: each user-facing action must drive its REAL
1316
- // in-process chain (crate::compiler spec-compile + crate::message_store db init +
1317
- // crate::state::persist seed) with only the OS edge (tmux spawn) mocked / asserted-as-plan.
1318
- // Today they are early-return STUBS — quick_start (launch.rs:36) returns a hardcoded
1319
- // PreflightBlocked{"no role docs found"}; launch / start_agent / restart / add_agent /
1320
- // fork_agent return a hardcoded Err — so these FAIL and green once the porter wires them.
1321
- // Golden: diagnose/quick_start.py, launch/core.py, lifecycle/start.py, restart/orchestration.py,
1322
- // lifecycle/operations.py (team-agent-public @ v0.2.11).
1323
- // ═════════════════════════════════════════════════════════════════════════
1324
-
1325
- // tests.rs 不在本单 write_paths 内;从本文件挂上夹具模块,cargo test 才能收录。
1326
- #[path = "gate_fixtures.rs"]
1327
- mod gate_fixtures;