@team-agent/installer 0.5.127 → 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 (421) hide show
  1. package/README.md +15 -4
  2. package/README.zh.md +1 -1
  3. package/package.json +4 -8
  4. package/skills/team-agent/SKILL.md +41 -26
  5. package/skills/team-agent/command-coverage.json +170 -184
  6. package/skills/team-agent/docs/reference/team-agent-operator.md +66 -32
  7. package/skills/team-agent/references/recovery-runbook.md +1 -1
  8. package/skills/team-agent/references/team-agent-operator.md +66 -32
  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 -1298
  15. package/crates/team-agent/src/cli/arguments.rs +0 -401
  16. package/crates/team-agent/src/cli/attach_app_server_leader.rs +0 -98
  17. package/crates/team-agent/src/cli/diagnose.rs +0 -1675
  18. package/crates/team-agent/src/cli/emit.rs +0 -2898
  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 -1189
  22. package/crates/team-agent/src/cli/intent/runtime_tests.rs +0 -821
  23. package/crates/team-agent/src/cli/intent/tests.rs +0 -691
  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 -6528
  29. package/crates/team-agent/src/cli/models.rs +0 -449
  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/send/coordinator.rs +0 -164
  34. package/crates/team-agent/src/cli/send/mailbox.rs +0 -145
  35. package/crates/team-agent/src/cli/send/persist.rs +0 -192
  36. package/crates/team-agent/src/cli/send/presentation.rs +0 -370
  37. package/crates/team-agent/src/cli/send/resolve.rs +0 -573
  38. package/crates/team-agent/src/cli/send.rs +0 -201
  39. package/crates/team-agent/src/cli/shutdown_socket.rs +0 -288
  40. package/crates/team-agent/src/cli/spec.rs +0 -159
  41. package/crates/team-agent/src/cli/status.rs +0 -280
  42. package/crates/team-agent/src/cli/status_port/agents.rs +0 -358
  43. package/crates/team-agent/src/cli/status_port/approvals.rs +0 -79
  44. package/crates/team-agent/src/cli/status_port/brief.rs +0 -2043
  45. package/crates/team-agent/src/cli/status_port/compact.rs +0 -240
  46. package/crates/team-agent/src/cli/status_port/format.rs +0 -146
  47. package/crates/team-agent/src/cli/status_port/inbox.rs +0 -62
  48. package/crates/team-agent/src/cli/status_port/runtime.rs +0 -197
  49. package/crates/team-agent/src/cli/status_port/snapshot.rs +0 -208
  50. package/crates/team-agent/src/cli/status_port/store.rs +0 -416
  51. package/crates/team-agent/src/cli/status_port/tests.rs +0 -90
  52. package/crates/team-agent/src/cli/status_port.rs +0 -92
  53. package/crates/team-agent/src/cli/tests/base.rs +0 -885
  54. package/crates/team-agent/src/cli/tests/divergence.rs +0 -518
  55. package/crates/team-agent/src/cli/tests/lane_c.rs +0 -453
  56. package/crates/team-agent/src/cli/tests/leader_watch.rs +0 -372
  57. package/crates/team-agent/src/cli/tests/main_preserved.rs +0 -430
  58. package/crates/team-agent/src/cli/tests/missing_subcommands.rs +0 -336
  59. package/crates/team-agent/src/cli/tests/mod.rs +0 -137
  60. package/crates/team-agent/src/cli/tests/named_address.rs +0 -760
  61. package/crates/team-agent/src/cli/tests/parser_safety.rs +0 -383
  62. package/crates/team-agent/src/cli/tests/run_delegation.rs +0 -481
  63. package/crates/team-agent/src/cli/tests/shutdown_kill_plan.rs +0 -2179
  64. package/crates/team-agent/src/cli/tests/status_brief.rs +0 -1514
  65. package/crates/team-agent/src/cli/tests/status_send.rs +0 -1091
  66. package/crates/team-agent/src/cli/tests/verb_install_skill.rs +0 -93
  67. package/crates/team-agent/src/cli/tests/verb_profile.rs +0 -392
  68. package/crates/team-agent/src/cli/triage.rs +0 -234
  69. package/crates/team-agent/src/cli/types.rs +0 -591
  70. package/crates/team-agent/src/codex_app_server.rs +0 -546
  71. package/crates/team-agent/src/communication_mode/mod.rs +0 -56
  72. package/crates/team-agent/src/compiler/tests.rs +0 -842
  73. package/crates/team-agent/src/compiler.rs +0 -691
  74. package/crates/team-agent/src/conpty/backend.rs +0 -829
  75. package/crates/team-agent/src/conpty/mod.rs +0 -33
  76. package/crates/team-agent/src/contract_runtime/backend.rs +0 -1610
  77. package/crates/team-agent/src/contract_runtime/commands.rs +0 -671
  78. package/crates/team-agent/src/contract_runtime/config.rs +0 -354
  79. package/crates/team-agent/src/contract_runtime/config_tests.rs +0 -56
  80. package/crates/team-agent/src/contract_runtime/discovery.rs +0 -438
  81. package/crates/team-agent/src/contract_runtime/fork.rs +0 -368
  82. package/crates/team-agent/src/contract_runtime/forward.rs +0 -288
  83. package/crates/team-agent/src/contract_runtime/framework.rs +0 -350
  84. package/crates/team-agent/src/contract_runtime/mcp.rs +0 -399
  85. package/crates/team-agent/src/contract_runtime/mod.rs +0 -17
  86. package/crates/team-agent/src/contract_runtime/prompt.rs +0 -216
  87. package/crates/team-agent/src/contract_runtime/pump.rs +0 -271
  88. package/crates/team-agent/src/contract_runtime/registry.rs +0 -589
  89. package/crates/team-agent/src/contract_runtime/workspace.rs +0 -228
  90. package/crates/team-agent/src/coordinator/backoff.rs +0 -741
  91. package/crates/team-agent/src/coordinator/conpty_shim.rs +0 -805
  92. package/crates/team-agent/src/coordinator/health.rs +0 -1185
  93. package/crates/team-agent/src/coordinator/mod.rs +0 -119
  94. package/crates/team-agent/src/coordinator/orphan.rs +0 -110
  95. package/crates/team-agent/src/coordinator/runtime_detectors.rs +0 -798
  96. package/crates/team-agent/src/coordinator/runtime_observation.rs +0 -84
  97. package/crates/team-agent/src/coordinator/steps/abnormal.rs +0 -2309
  98. package/crates/team-agent/src/coordinator/steps/delivery.rs +0 -15
  99. package/crates/team-agent/src/coordinator/steps/health_sync.rs +0 -15
  100. package/crates/team-agent/src/coordinator/steps/mod.rs +0 -126
  101. package/crates/team-agent/src/coordinator/steps/persist.rs +0 -15
  102. package/crates/team-agent/src/coordinator/steps/runtime_prompts.rs +0 -15
  103. package/crates/team-agent/src/coordinator/steps/session_gate.rs +0 -16
  104. package/crates/team-agent/src/coordinator/tests/a0_lostupdate.rs +0 -158
  105. package/crates/team-agent/src/coordinator/tests/abnormal.rs +0 -312
  106. package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +0 -338
  107. package/crates/team-agent/src/coordinator/tests/basics.rs +0 -211
  108. package/crates/team-agent/src/coordinator/tests/daemon.rs +0 -514
  109. package/crates/team-agent/src/coordinator/tests/energy.rs +0 -549
  110. package/crates/team-agent/src/coordinator/tests/health_sync.rs +0 -461
  111. package/crates/team-agent/src/coordinator/tests/main_preserved.rs +0 -186
  112. package/crates/team-agent/src/coordinator/tests/mod.rs +0 -295
  113. package/crates/team-agent/src/coordinator/tests/s3_bounded.rs +0 -207
  114. package/crates/team-agent/src/coordinator/tests/spine.rs +0 -308
  115. package/crates/team-agent/src/coordinator/tests/takeover.rs +0 -286
  116. package/crates/team-agent/src/coordinator/tests/tick_core.rs +0 -237
  117. package/crates/team-agent/src/coordinator/tick.rs +0 -3112
  118. package/crates/team-agent/src/coordinator/types.rs +0 -540
  119. package/crates/team-agent/src/db/agent_health_capture.rs +0 -126
  120. package/crates/team-agent/src/db/message_store.rs +0 -1585
  121. package/crates/team-agent/src/db/migration.rs +0 -984
  122. package/crates/team-agent/src/db/mod.rs +0 -26
  123. package/crates/team-agent/src/db/schema.rs +0 -663
  124. package/crates/team-agent/src/diagnose/comms.rs +0 -242
  125. package/crates/team-agent/src/diagnose/mod.rs +0 -44
  126. package/crates/team-agent/src/diagnose/orphans.rs +0 -889
  127. package/crates/team-agent/src/event_log.rs +0 -502
  128. package/crates/team-agent/src/fake_worker.rs +0 -303
  129. package/crates/team-agent/src/kill_audit.rs +0 -106
  130. package/crates/team-agent/src/layout/manager.rs +0 -248
  131. package/crates/team-agent/src/layout/mod.rs +0 -36
  132. package/crates/team-agent/src/layout/overlay.rs +0 -134
  133. package/crates/team-agent/src/layout/placement.rs +0 -52
  134. package/crates/team-agent/src/layout/recovery.rs +0 -106
  135. package/crates/team-agent/src/layout/runtime_sessions.rs +0 -317
  136. package/crates/team-agent/src/layout/sessions.rs +0 -294
  137. package/crates/team-agent/src/layout/tmux_endpoint.rs +0 -165
  138. package/crates/team-agent/src/layout/worker_env.rs +0 -721
  139. package/crates/team-agent/src/layout/worker_window_helpers.rs +0 -37
  140. package/crates/team-agent/src/leader/helpers.rs +0 -178
  141. package/crates/team-agent/src/leader/incident.rs +0 -6
  142. package/crates/team-agent/src/leader/lease.rs +0 -3356
  143. package/crates/team-agent/src/leader/mod.rs +0 -104
  144. package/crates/team-agent/src/leader/owner_bind.rs +0 -400
  145. package/crates/team-agent/src/leader/prompt.rs +0 -905
  146. package/crates/team-agent/src/leader/provider_attribution.rs +0 -247
  147. package/crates/team-agent/src/leader/rediscover/tests.rs +0 -689
  148. package/crates/team-agent/src/leader/rediscover.rs +0 -1192
  149. package/crates/team-agent/src/leader/registry.rs +0 -883
  150. package/crates/team-agent/src/leader/start.rs +0 -4500
  151. package/crates/team-agent/src/leader/takeover.rs +0 -65
  152. package/crates/team-agent/src/leader/tests/basics.rs +0 -337
  153. package/crates/team-agent/src/leader/tests/byte_findings.rs +0 -355
  154. package/crates/team-agent/src/leader/tests/claim_leader_mailbox_flush_contract.rs +0 -544
  155. package/crates/team-agent/src/leader/tests/historical_inventory_upgrade_gate_red.rs +0 -624
  156. package/crates/team-agent/src/leader/tests/identity.rs +0 -465
  157. package/crates/team-agent/src/leader/tests/identity_session_names.rs +0 -42
  158. package/crates/team-agent/src/leader/tests/idle.rs +0 -113
  159. package/crates/team-agent/src/leader/tests/lease_api.rs +0 -520
  160. package/crates/team-agent/src/leader/tests/lease_claim.rs +0 -629
  161. package/crates/team-agent/src/leader/tests/mod.rs +0 -106
  162. package/crates/team-agent/src/leader/tests/prompt_contract.rs +0 -267
  163. package/crates/team-agent/src/leader/tests/rediscover.rs +0 -403
  164. package/crates/team-agent/src/leader/tests/rehomed_env.rs +0 -83
  165. package/crates/team-agent/src/leader/tests/team_in_team_state_scope_red.rs +0 -1273
  166. package/crates/team-agent/src/leader/tests/terminal_and_replay_vs_rerender_invariants_red.rs +0 -417
  167. package/crates/team-agent/src/leader/tests/wake_start_owner.rs +0 -168
  168. package/crates/team-agent/src/leader/types.rs +0 -534
  169. package/crates/team-agent/src/lib.rs +0 -145
  170. package/crates/team-agent/src/lifecycle/helpers.rs +0 -212
  171. package/crates/team-agent/src/lifecycle/launch/add_agent.rs +0 -848
  172. package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +0 -393
  173. package/crates/team-agent/src/lifecycle/launch/agent_state.rs +0 -332
  174. package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +0 -178
  175. package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +0 -82
  176. package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +0 -63
  177. package/crates/team-agent/src/lifecycle/launch/identity.rs +0 -674
  178. package/crates/team-agent/src/lifecycle/launch/layout.rs +0 -350
  179. package/crates/team-agent/src/lifecycle/launch/leader_context.rs +0 -589
  180. package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +0 -152
  181. package/crates/team-agent/src/lifecycle/launch/ownership.rs +0 -105
  182. package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +0 -629
  183. package/crates/team-agent/src/lifecycle/launch/pi_mcp_extension.js +0 -226
  184. package/crates/team-agent/src/lifecycle/launch/plan.rs +0 -269
  185. package/crates/team-agent/src/lifecycle/launch/quick_start.rs +0 -5176
  186. package/crates/team-agent/src/lifecycle/launch/quick_start_transport.rs +0 -368
  187. package/crates/team-agent/src/lifecycle/launch/readiness.rs +0 -519
  188. package/crates/team-agent/src/lifecycle/launch/role_source.rs +0 -287
  189. package/crates/team-agent/src/lifecycle/launch/spawn.rs +0 -450
  190. package/crates/team-agent/src/lifecycle/launch/spec_state.rs +0 -801
  191. package/crates/team-agent/src/lifecycle/launch/state_projection.rs +0 -624
  192. package/crates/team-agent/src/lifecycle/launch/worker_env.rs +0 -558
  193. package/crates/team-agent/src/lifecycle/launch.rs +0 -534
  194. package/crates/team-agent/src/lifecycle/lock.rs +0 -350
  195. package/crates/team-agent/src/lifecycle/mod.rs +0 -79
  196. package/crates/team-agent/src/lifecycle/pane_input_lock.rs +0 -239
  197. package/crates/team-agent/src/lifecycle/profile_launch.rs +0 -757
  198. package/crates/team-agent/src/lifecycle/profile_smoke.rs +0 -557
  199. package/crates/team-agent/src/lifecycle/restart/agent.rs +0 -2198
  200. package/crates/team-agent/src/lifecycle/restart/common.rs +0 -2052
  201. package/crates/team-agent/src/lifecycle/restart/orchestrator.rs +0 -65
  202. package/crates/team-agent/src/lifecycle/restart/preflight.rs +0 -113
  203. package/crates/team-agent/src/lifecycle/restart/rebuild.rs +0 -5135
  204. package/crates/team-agent/src/lifecycle/restart/remove.rs +0 -1504
  205. package/crates/team-agent/src/lifecycle/restart/selection.rs +0 -559
  206. package/crates/team-agent/src/lifecycle/restart/team_state.rs +0 -329
  207. package/crates/team-agent/src/lifecycle/restart.rs +0 -223
  208. package/crates/team-agent/src/lifecycle/role_config.rs +0 -1205
  209. package/crates/team-agent/src/lifecycle/tests/acceptance_b_batch_red.rs +0 -1021
  210. package/crates/team-agent/src/lifecycle/tests/agent_ops.rs +0 -1205
  211. package/crates/team-agent/src/lifecycle/tests/b0_legacy_snapshot_nonauthority_contract.rs +0 -265
  212. package/crates/team-agent/src/lifecycle/tests/b0_reader_hideone_audit_contract.rs +0 -490
  213. package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +0 -656
  214. package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +0 -135
  215. package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +0 -1415
  216. package/crates/team-agent/src/lifecycle/tests/clone_agent_preserves_source_tools.rs +0 -427
  217. package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +0 -396
  218. package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +0 -418
  219. package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +0 -2039
  220. package/crates/team-agent/src/lifecycle/tests/core.rs +0 -1298
  221. package/crates/team-agent/src/lifecycle/tests/f032_startup_prompt_best_effort_red.rs +0 -315
  222. package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_g0.stdout.txt +0 -222
  223. package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_spaced_ids.stdout.txt +0 -9
  224. package/crates/team-agent/src/lifecycle/tests/fixtures/pi_native_mcp_host.mjs +0 -71
  225. package/crates/team-agent/src/lifecycle/tests/gate_fixtures.rs +0 -562
  226. package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +0 -110
  227. package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +0 -472
  228. package/crates/team-agent/src/lifecycle/tests/host_cotenant_death_p0_contract.rs +0 -921
  229. package/crates/team-agent/src/lifecycle/tests/issue238_codex_effort_contract.rs +0 -68
  230. package/crates/team-agent/src/lifecycle/tests/lane_ops.rs +0 -1851
  231. package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +0 -3981
  232. package/crates/team-agent/src/lifecycle/tests/lifecycle_lock.rs +0 -339
  233. package/crates/team-agent/src/lifecycle/tests/lifecycle_rollback_red.rs +0 -596
  234. package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +0 -513
  235. package/crates/team-agent/src/lifecycle/tests/mcp_tool_name_format_red.rs +0 -69
  236. package/crates/team-agent/src/lifecycle/tests/phase_b_contracts.rs +0 -824
  237. package/crates/team-agent/src/lifecycle/tests/phase_golden.rs +0 -723
  238. package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +0 -152
  239. package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +0 -182
  240. package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +0 -374
  241. package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +0 -546
  242. package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +0 -31
  243. package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +0 -528
  244. package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +0 -134
  245. package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +0 -333
  246. package/crates/team-agent/src/lifecycle/tests/realmachine_clusters_1_6_red.rs +0 -786
  247. package/crates/team-agent/src/lifecycle/tests/realmachine_residual_g1_g4_red.rs +0 -648
  248. package/crates/team-agent/src/lifecycle/tests/restart.rs +0 -185
  249. package/crates/team-agent/src/lifecycle/tests/restart_build_before_destroy_0540_contract.rs +0 -1053
  250. package/crates/team-agent/src/lifecycle/tests/restart_liveness_red.rs +0 -679
  251. package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +0 -1126
  252. package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +0 -153
  253. package/crates/team-agent/src/lifecycle/tests/resume_recover_red.rs +0 -427
  254. package/crates/team-agent/src/lifecycle/tests/stale_team_saveconflict_contract.rs +0 -431
  255. package/crates/team-agent/src/lifecycle/tests/startup_latency_contract.rs +0 -1066
  256. package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +0 -876
  257. package/crates/team-agent/src/lifecycle/tests/subprep_codex_trust_roundtrip_red.rs +0 -1026
  258. package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +0 -90
  259. package/crates/team-agent/src/lifecycle/tests/team_in_team_identity_scope_red.rs +0 -543
  260. package/crates/team-agent/src/lifecycle/tests/team_in_team_sibling_quick_start_red.rs +0 -1103
  261. package/crates/team-agent/src/lifecycle/tests/team_in_team_state_scope_red.rs +0 -1276
  262. package/crates/team-agent/src/lifecycle/tests/team_key_retirement_roster_red.rs +0 -145
  263. package/crates/team-agent/src/lifecycle/tests/team_key_retirement_txn_red.rs +0 -603
  264. package/crates/team-agent/src/lifecycle/tests/test_isolation_escape_contract.rs +0 -936
  265. package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +0 -970
  266. package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +0 -996
  267. package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +0 -827
  268. package/crates/team-agent/src/lifecycle/tests.rs +0 -102
  269. package/crates/team-agent/src/lifecycle/types.rs +0 -861
  270. package/crates/team-agent/src/lifecycle/worker_command_context.rs +0 -370
  271. package/crates/team-agent/src/main.rs +0 -52
  272. package/crates/team-agent/src/mcp_server/helpers.rs +0 -510
  273. package/crates/team-agent/src/mcp_server/lifecycle_tools/mod.rs +0 -6
  274. package/crates/team-agent/src/mcp_server/lifecycle_tools/state_status.rs +0 -43
  275. package/crates/team-agent/src/mcp_server/mod.rs +0 -119
  276. package/crates/team-agent/src/mcp_server/normalize.rs +0 -485
  277. package/crates/team-agent/src/mcp_server/readiness.rs +0 -546
  278. package/crates/team-agent/src/mcp_server/readiness_tests.rs +0 -369
  279. package/crates/team-agent/src/mcp_server/tests/golden.rs +0 -285
  280. package/crates/team-agent/src/mcp_server/tests/normalize.rs +0 -247
  281. package/crates/team-agent/src/mcp_server/tests/scoped.rs +0 -168
  282. package/crates/team-agent/src/mcp_server/tests/send.rs +0 -388
  283. package/crates/team-agent/src/mcp_server/tests/tools.rs +0 -343
  284. package/crates/team-agent/src/mcp_server/tests/wire.rs +0 -254
  285. package/crates/team-agent/src/mcp_server/tests.rs +0 -43
  286. package/crates/team-agent/src/mcp_server/tools.rs +0 -1015
  287. package/crates/team-agent/src/mcp_server/types.rs +0 -396
  288. package/crates/team-agent/src/mcp_server/wire.rs +0 -867
  289. package/crates/team-agent/src/messaging/activity.rs +0 -461
  290. package/crates/team-agent/src/messaging/address.rs +0 -87
  291. package/crates/team-agent/src/messaging/delivery.rs +0 -3785
  292. package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +0 -234
  293. package/crates/team-agent/src/messaging/enter_rescue.rs +0 -362
  294. package/crates/team-agent/src/messaging/enter_rescue_tests.rs +0 -633
  295. package/crates/team-agent/src/messaging/helpers.rs +0 -354
  296. package/crates/team-agent/src/messaging/leader_channel.rs +0 -287
  297. package/crates/team-agent/src/messaging/leader_receiver.rs +0 -786
  298. package/crates/team-agent/src/messaging/mod.rs +0 -166
  299. package/crates/team-agent/src/messaging/persist.rs +0 -377
  300. package/crates/team-agent/src/messaging/presentation.rs +0 -417
  301. package/crates/team-agent/src/messaging/results/collection_tests.rs +0 -719
  302. package/crates/team-agent/src/messaging/results.rs +0 -1415
  303. package/crates/team-agent/src/messaging/scheduler.rs +0 -217
  304. package/crates/team-agent/src/messaging/selftest.rs +0 -315
  305. package/crates/team-agent/src/messaging/send.rs +0 -981
  306. package/crates/team-agent/src/messaging/tests/basic.rs +0 -346
  307. package/crates/team-agent/src/messaging/tests/dup_inject.rs +0 -551
  308. package/crates/team-agent/src/messaging/tests/e23.rs +0 -49
  309. package/crates/team-agent/src/messaging/tests/leader_channel.rs +0 -169
  310. package/crates/team-agent/src/messaging/tests/leader_inject_acceptance.rs +0 -817
  311. package/crates/team-agent/src/messaging/tests/main_preserved.rs +0 -85
  312. package/crates/team-agent/src/messaging/tests/mod.rs +0 -306
  313. package/crates/team-agent/src/messaging/tests/runtime.rs +0 -3655
  314. package/crates/team-agent/src/messaging/tests/spine.rs +0 -837
  315. package/crates/team-agent/src/messaging/tests/wave2.rs +0 -381
  316. package/crates/team-agent/src/messaging/trust.rs +0 -215
  317. package/crates/team-agent/src/messaging/types.rs +0 -471
  318. package/crates/team-agent/src/messaging/wait.rs +0 -366
  319. package/crates/team-agent/src/messaging/watchers.rs +0 -916
  320. package/crates/team-agent/src/model/enums.rs +0 -356
  321. package/crates/team-agent/src/model/errors.rs +0 -18
  322. package/crates/team-agent/src/model/ids.rs +0 -165
  323. package/crates/team-agent/src/model/mod.rs +0 -29
  324. package/crates/team-agent/src/model/name_similarity.rs +0 -252
  325. package/crates/team-agent/src/model/pane_authority_refusal.rs +0 -359
  326. package/crates/team-agent/src/model/paths.rs +0 -257
  327. package/crates/team-agent/src/model/routing.rs +0 -387
  328. package/crates/team-agent/src/model/spec.rs +0 -1184
  329. package/crates/team-agent/src/model/task_graph.rs +0 -321
  330. package/crates/team-agent/src/model/testdata/fuzz.golden.yaml +0 -43
  331. package/crates/team-agent/src/model/testdata/fuzz.yaml +0 -43
  332. package/crates/team-agent/src/model/testdata/spec_invalid_a.yaml +0 -209
  333. package/crates/team-agent/src/model/testdata/team.spec.golden.yaml +0 -208
  334. package/crates/team-agent/src/model/testdata/team.spec.yaml +0 -208
  335. package/crates/team-agent/src/model/yaml/tests.rs +0 -188
  336. package/crates/team-agent/src/model/yaml.rs +0 -802
  337. package/crates/team-agent/src/os_probe.rs +0 -280
  338. package/crates/team-agent/src/packaging/install.rs +0 -219
  339. package/crates/team-agent/src/packaging/migrate.rs +0 -38
  340. package/crates/team-agent/src/packaging/mod.rs +0 -91
  341. package/crates/team-agent/src/packaging/repair.rs +0 -33
  342. package/crates/team-agent/src/packaging/tests.rs +0 -822
  343. package/crates/team-agent/src/packaging/types.rs +0 -417
  344. package/crates/team-agent/src/platform/argv.rs +0 -331
  345. package/crates/team-agent/src/platform/errors.rs +0 -104
  346. package/crates/team-agent/src/platform/file_lock.rs +0 -279
  347. package/crates/team-agent/src/platform/mod.rs +0 -5
  348. package/crates/team-agent/src/platform/process.rs +0 -545
  349. package/crates/team-agent/src/provider/adapter.rs +0 -898
  350. package/crates/team-agent/src/provider/adapters/copilot.rs +0 -75
  351. package/crates/team-agent/src/provider/adapters/copilot_fork.rs +0 -307
  352. package/crates/team-agent/src/provider/adapters/fake.rs +0 -18
  353. package/crates/team-agent/src/provider/adapters/mod.rs +0 -28
  354. package/crates/team-agent/src/provider/approvals/mod.rs +0 -3
  355. package/crates/team-agent/src/provider/approvals/parsing.rs +0 -586
  356. package/crates/team-agent/src/provider/approvals/runtime_prompts.rs +0 -205
  357. package/crates/team-agent/src/provider/argv_route.rs +0 -405
  358. package/crates/team-agent/src/provider/bypass_flags.rs +0 -116
  359. package/crates/team-agent/src/provider/classify.rs +0 -773
  360. package/crates/team-agent/src/provider/command_helpers.rs +0 -45
  361. package/crates/team-agent/src/provider/faults.rs +0 -165
  362. package/crates/team-agent/src/provider/helpers.rs +0 -52
  363. package/crates/team-agent/src/provider/mod.rs +0 -78
  364. package/crates/team-agent/src/provider/model_catalog.rs +0 -722
  365. package/crates/team-agent/src/provider/session/capture.rs +0 -2631
  366. package/crates/team-agent/src/provider/session/context_fork/outcome.rs +0 -168
  367. package/crates/team-agent/src/provider/session/context_fork.rs +0 -264
  368. package/crates/team-agent/src/provider/session/mod.rs +0 -36
  369. package/crates/team-agent/src/provider/session/resume.rs +0 -269
  370. package/crates/team-agent/src/provider/session_scan/common/tests.rs +0 -316
  371. package/crates/team-agent/src/provider/session_scan/common.rs +0 -618
  372. package/crates/team-agent/src/provider/session_scan/copilot.rs +0 -280
  373. package/crates/team-agent/src/provider/session_scan/pi.rs +0 -152
  374. package/crates/team-agent/src/provider/session_scan.rs +0 -61
  375. package/crates/team-agent/src/provider/startup_prompt.rs +0 -757
  376. package/crates/team-agent/src/provider/submit_now.rs +0 -71
  377. package/crates/team-agent/src/provider/testdata/copilot-ready-marker.txt +0 -5
  378. package/crates/team-agent/src/provider/testdata/copilot-trust-prompt.txt +0 -19
  379. package/crates/team-agent/src/provider/testdata/grok-models-authenticated.stdout +0 -9
  380. package/crates/team-agent/src/provider/testdata/grok-models-unauthenticated.stdout +0 -7
  381. package/crates/team-agent/src/provider/tests/adapter.rs +0 -354
  382. package/crates/team-agent/src/provider/tests/classify.rs +0 -201
  383. package/crates/team-agent/src/provider/tests/command_helpers.rs +0 -26
  384. package/crates/team-agent/src/provider/tests/copilot_fork.rs +0 -191
  385. package/crates/team-agent/src/provider/tests/faults.rs +0 -200
  386. package/crates/team-agent/src/provider/tests/idle.rs +0 -140
  387. package/crates/team-agent/src/provider/tests/wire.rs +0 -213
  388. package/crates/team-agent/src/provider/tests.rs +0 -32
  389. package/crates/team-agent/src/provider/types.rs +0 -529
  390. package/crates/team-agent/src/provider/wire.rs +0 -406
  391. package/crates/team-agent/src/redaction.rs +0 -259
  392. package/crates/team-agent/src/state/abnormal_watch/tests/mod.rs +0 -248
  393. package/crates/team-agent/src/state/abnormal_watch.rs +0 -144
  394. package/crates/team-agent/src/state/identity.rs +0 -914
  395. package/crates/team-agent/src/state/identity_keys.rs +0 -132
  396. package/crates/team-agent/src/state/mod.rs +0 -74
  397. package/crates/team-agent/src/state/owner_gate.rs +0 -482
  398. package/crates/team-agent/src/state/ownership.rs +0 -563
  399. package/crates/team-agent/src/state/paths.rs +0 -395
  400. package/crates/team-agent/src/state/persist.rs +0 -3811
  401. package/crates/team-agent/src/state/projection.rs +0 -1508
  402. package/crates/team-agent/src/state/repository/intent.rs +0 -14
  403. package/crates/team-agent/src/state/repository/tests.rs +0 -184
  404. package/crates/team-agent/src/state/repository.rs +0 -866
  405. package/crates/team-agent/src/state/selector.rs +0 -160
  406. package/crates/team-agent/src/state/testdata/state-rich.canonical.json +0 -133
  407. package/crates/team-agent/src/tmux_backend/enter_rescue.rs +0 -325
  408. package/crates/team-agent/src/tmux_backend/enter_rescue_tests.rs +0 -432
  409. package/crates/team-agent/src/tmux_backend/native_input.rs +0 -513
  410. package/crates/team-agent/src/tmux_backend/native_input_tests.rs +0 -742
  411. package/crates/team-agent/src/tmux_backend/tests.rs +0 -4254
  412. package/crates/team-agent/src/tmux_backend.rs +0 -4527
  413. package/crates/team-agent/src/topology.rs +0 -537
  414. package/crates/team-agent/src/transport/enter_rescue.rs +0 -166
  415. package/crates/team-agent/src/transport/native_input.rs +0 -491
  416. package/crates/team-agent/src/transport/test_support.rs +0 -743
  417. package/crates/team-agent/src/transport/tests/behavior.rs +0 -326
  418. package/crates/team-agent/src/transport/tests/mod.rs +0 -194
  419. package/crates/team-agent/src/transport/tests/wire.rs +0 -574
  420. package/crates/team-agent/src/transport.rs +0 -1655
  421. package/crates/team-agent/src/transport_factory.rs +0 -819
@@ -1,861 +0,0 @@
1
- //! ---
2
- //! purpose: lifecycle 的数据类型集中定义,newtype、枚举、报告结构、错误与事件名常量
3
- //! contract:
4
- //! provides:
5
- //! - name: PlanId
6
- //! what: 受正则约束的 plan 标识,构造时拒斜杠空格与路径穿越
7
- //! - name: PlanCondition
8
- //! what: plan 推进条件的封闭文法,只认 any 与 report_result 字段相等
9
- //! - name: LifecycleError
10
- //! what: 本模块所有对外错误的统一枚举
11
- //! - name: CoordinatorStartSummary
12
- //! what: coordinator 启动结果在 lifecycle 报告里的投影
13
- //! - name: event_names
14
- //! what: lifecycle/restart/display 稳定事件名常量集
15
- //! depends:
16
- //! - crate::model::ids
17
- //! - crate::provider
18
- //! - crate::transport
19
- //! - crate::coordinator
20
- //! boundary:
21
- //! - 只定义类型与解析,不做 IO、不 spawn、不落盘
22
- //! - 事件名只声明常量,实际写事件由各行为文件负责
23
- //! maturity: wired
24
- //! ---
25
- //! lifecycle 数据类型:newtype / enum / data struct / error / outcome-report 集中定义。
26
-
27
- use std::path::PathBuf;
28
-
29
- use serde::{Deserialize, Serialize};
30
- use thiserror::Error;
31
-
32
- use crate::model::ids::AgentId;
33
- use crate::provider::{RolloutPath, SessionId};
34
- use crate::transport::SessionName;
35
-
36
- // ===========================================================================
37
- // CROSS-LANE PLACEHOLDERS(13/14/15 兄弟 lane 尚未交付;leader 集成时 reconcile)
38
- // ===========================================================================
39
-
40
- /// `EventLog` 已在 step4 落地,但 lifecycle 发射的 typed `EventKind` 名集(`lifecycle.*`/
41
- /// `restart.*`/`display.*`)是 step4 owned 的稳定事件名(JSON 名与 Python 一致)。
42
- /// **PLACEHOLDER**:此处仅命名 lifecycle 关心的事件名常量集,leader 集成时映射到
43
- /// step4 `event_log::EventLog::write(name, fields)`。
44
- pub mod event_names {
45
- // lifecycle 步进事件(Gap 15/16:发射顺序被测试锁死)。
46
- pub const ADD_STEP_COMPLETED: &str = "lifecycle.add_step_completed";
47
- pub const ADD_STEP_ROLLED_BACK: &str = "lifecycle.add_step_rolled_back";
48
- pub const ADD_FAILED: &str = "lifecycle.add_failed";
49
- pub const REMOVE_STEP_COMPLETED: &str = "lifecycle.remove_step_completed";
50
- pub const REMOVE_ROLLED_BACK: &str = "lifecycle.remove_rolled_back";
51
- pub const CONTEXT_FORK: &str = "context_fork";
52
- // restart 决策事件(Route B audit 契约必发)。
53
- pub const RESTART_RESUME_DECISION: &str = "restart.resume_decision";
54
- pub const RESTART_ATOMIC_REFUSAL: &str = "restart.atomic_refusal";
55
- pub const RESTART_FIRST_SEND_AT_INVALID: &str = "restart.first_send_at_invalid";
56
- pub const RESTART_FRESH_SPAWN: &str = "restart.fresh_spawn";
57
- pub const RESTART_ROLLBACK_SESSION: &str = "restart.rollback_session";
58
- // display 事件(C15/C16:每次降级非静默)。
59
- pub const DISPLAY_BACKEND_RESOLVED: &str = "display.backend_resolved";
60
- pub const DISPLAY_ADAPTIVE_OPENED: &str = "display.adaptive_opened";
61
- pub const DISPLAY_ADAPTIVE_BLOCKED: &str = "display.adaptive_blocked";
62
- pub const DISPLAY_ADAPTIVE_REBUILT: &str = "display.adaptive_rebuilt";
63
- pub const DISPLAY_ADAPTIVE_CLOSED: &str = "display.adaptive_closed";
64
- }
65
-
66
- // ===========================================================================
67
- // NEWTYPES(card §3:散 str → newtype。`AgentId`/`SessionName` 复用既有;
68
- // 此处新增 plan id / 派生 session 名)
69
- // ===========================================================================
70
-
71
- /// `PlanId`(`_PLAN_ID_RE = ^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$`,`orchestrator/state.py:11`)。
72
- /// **必须 newtype**:防路径穿越(无 `/`、空格);`sanitize_plan_id` 拒绝则 `InvalidPlanId`。
73
- #[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
74
- #[serde(transparent)]
75
- pub struct PlanId(String);
76
-
77
- impl PlanId {
78
- /// ---
79
- /// purpose: 校验并构造 PlanId
80
- /// params:
81
- /// raw: 原始 plan 名,首字符须字母数字,其余只许字母数字与下划线点横线,长度不超过 64
82
- /// returns: 通过校验的 PlanId
83
- /// errors: 不满足上述形状时返回 InvalidPlanId
84
- /// contract_id: lifecycle.types.plan_id_parse
85
- /// ---
86
- /// `sanitize_plan_id`(`orchestrator/state.py:18`):正则校验,失败 → `Err`。
87
- pub fn parse(raw: &str) -> Result<Self, LifecycleError> {
88
- let mut chars = raw.chars();
89
- let first_ok = chars
90
- .next()
91
- .map(|c| c.is_ascii_alphanumeric())
92
- .unwrap_or(false);
93
- let rest_ok = chars.all(|c| c.is_ascii_alphanumeric() || matches!(c, '_' | '.' | '-'));
94
- if first_ok && rest_ok && raw.len() <= 64 {
95
- Ok(Self(raw.to_string()))
96
- } else {
97
- Err(LifecycleError::InvalidPlanId(format!(
98
- "{raw:?} does not match ^[A-Za-z0-9][A-Za-z0-9_.-]{{0,63}}$; no slashes, spaces, or path-traversal segments are allowed"
99
- )))
100
- }
101
- }
102
- /// ---
103
- /// purpose: 取 PlanId 的原始字符串
104
- /// returns: 构造时保存的原文
105
- /// ---
106
- pub fn as_str(&self) -> &str {
107
- &self.0
108
- }
109
- }
110
-
111
- #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
112
- pub struct CoordinatorStartSummary {
113
- pub ok: bool,
114
- pub status: String,
115
- pub pid: Option<u32>,
116
- pub binary_path: Option<String>,
117
- pub binary_version: Option<String>,
118
- pub rotation_reason: Option<String>,
119
- /// 0.5.41 Slice 3 (fault-invisibility-locate.md §5/§9 RED3): typed
120
- /// binary-identity relation between caller and daemon that was
121
- /// observed. Carried through from `StartReport` so restart/start
122
- /// summaries keep `daemon_newer_than_caller` distinguishable from
123
- /// a same-binary fresh daemon (both surface as `already_running`).
124
- pub binary_identity_relation: String,
125
- }
126
-
127
- impl CoordinatorStartSummary {
128
- /// ---
129
- /// purpose: 把 coordinator 的 StartReport 投影成 lifecycle 报告用的摘要
130
- /// params:
131
- /// report: coordinator 启动返回的原始报告
132
- /// returns: 摘要,status 已转成稳定 wire 字符串,binary_identity_relation 原样带出
133
- /// ---
134
- pub fn from_start_report(report: &crate::coordinator::StartReport) -> Self {
135
- Self {
136
- ok: report.ok,
137
- status: coordinator_start_status_wire(report.status).to_string(),
138
- pid: report.pid.map(|pid| pid.get()),
139
- binary_path: report.binary_path.clone(),
140
- binary_version: report.binary_version.clone(),
141
- rotation_reason: report.rotation_reason.clone(),
142
- binary_identity_relation: report.binary_identity_relation.as_str().to_string(),
143
- }
144
- }
145
- }
146
-
147
- fn coordinator_start_status_wire(status: crate::coordinator::StartOutcome) -> &'static str {
148
- match status {
149
- crate::coordinator::StartOutcome::AlreadyRunning => "already_running",
150
- crate::coordinator::StartOutcome::RestartIncompatibleStopFailed => {
151
- "restart_incompatible_stop_failed"
152
- }
153
- crate::coordinator::StartOutcome::SchemaIncompatible => "schema_incompatible",
154
- crate::coordinator::StartOutcome::Started => "started",
155
- crate::coordinator::StartOutcome::StartedAfterRotation => "started_after_rotation",
156
- }
157
- }
158
-
159
- /// ---
160
- /// purpose: 把 coordinator 启动摘要序列化成 JSON 对象
161
- /// returns: 含 ok、status、pid、binary 路径与版本、rotation_reason、binary_identity_relation 的 JSON
162
- /// ---
163
- pub fn coordinator_start_summary_value(summary: &CoordinatorStartSummary) -> serde_json::Value {
164
- serde_json::json!({
165
- "ok": summary.ok,
166
- "status": summary.status,
167
- "pid": summary.pid,
168
- "binary_path": summary.binary_path,
169
- "binary_version": summary.binary_version,
170
- "rotation_reason": summary.rotation_reason,
171
- "binary_identity_relation": summary.binary_identity_relation,
172
- })
173
- }
174
-
175
- impl std::fmt::Display for PlanId {
176
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
177
- f.write_str(&self.0)
178
- }
179
- }
180
-
181
- // ===========================================================================
182
- // ENUM(card §3/§11:散字符串 → 穷尽 enum)
183
- // ===========================================================================
184
-
185
- /// `start_mode` / `restart_mode`(`start.py:179`,`orchestration.py:208`)。
186
- /// **必须 enum**:start/restart 全程穷尽分支;`noop`(窗口已存在且非 force)只在
187
- /// `start_agent` 出现。
188
- #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
189
- #[serde(rename_all = "snake_case")]
190
- pub enum StartMode {
191
- Resumed,
192
- Fresh,
193
- FreshAfterMissingRollout,
194
- Noop,
195
- }
196
-
197
- /// Route B resume 决策(`orchestration.py:498-505`)。每非 paused worker 发一条
198
- /// `restart.resume_decision`;`Refuse` 是 atomic refusal 的唯一触发。
199
- #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
200
- #[serde(rename_all = "snake_case")]
201
- pub enum ResumeDecision {
202
- Resume,
203
- FreshStart,
204
- Refuse,
205
- }
206
-
207
- /// `first_send_at` 严格分类(`_classify_first_send_at`,`orchestration.py:399-426`)。
208
- /// **必须 enum + 严格解析**:显式拒空串 / `0` / `False` / `"null"` / 非 ISO;
209
- /// garbage **hard refuse**,绝不靠 truthiness 把 `""` 当 absent 漏过去(陷阱)。
210
- #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
211
- #[serde(rename_all = "snake_case")]
212
- pub enum FirstSendAtState {
213
- /// `null` / 缺失 —— worker 从未交互,可丢弃 fresh。
214
- Absent,
215
- /// 合法 ISO-8601 UTC 串。
216
- Valid,
217
- /// `""` / `0` / `False` / `"null"` / 非 ISO —— state.json 损坏,决策前 hard refuse。
218
- Corrupt,
219
- }
220
-
221
- /// plan `status`(`orchestrator/__init__.py`)。**应 enum**:`start_plan` 对已
222
- /// running/halted/completed 幂等返回。
223
- #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
224
- #[serde(rename_all = "snake_case")]
225
- pub enum PlanStatus {
226
- Running,
227
- Halted,
228
- Completed,
229
- }
230
-
231
- /// 危险审批继承来源(`config.py:16` `dangerous_auto_approve_source`)。**应 enum**:
232
- /// launch 在 `inherited=false` 且无 `--yes` 时 raise(`core.py:120`)。
233
- #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
234
- #[serde(rename_all = "snake_case")]
235
- pub enum DangerousApprovalSource {
236
- RuntimeConfig,
237
- LeaderProcess,
238
- Disabled,
239
- }
240
-
241
- // ===========================================================================
242
- // DATA STRUCT(restart 候选 / plan state / 危险审批)
243
- // ===========================================================================
244
-
245
- /// `RestartCandidate`(`restart/selection.py:27`)。`select_restart_state` 多 team 选择;
246
- /// `has_context` 是 resume 可行性粗判。
247
- #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
248
- pub struct RestartCandidate {
249
- pub session_name: SessionName,
250
- pub team_name: String,
251
- pub state_path: PathBuf,
252
- pub spec_path: PathBuf,
253
- pub agents: Vec<AgentId>,
254
- pub has_context: bool,
255
- }
256
-
257
- /// 危险审批继承态(`config.py:16` `dangerous_auto_approve{_source,_inherited,_provider,_flag}`)。
258
- #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
259
- pub struct DangerousApproval {
260
- pub enabled: bool,
261
- pub source: DangerousApprovalSource,
262
- pub inherited: bool,
263
- pub provider: Option<String>,
264
- pub flag: Option<String>,
265
- pub worker_capability_above_leader: bool,
266
- pub ancestry_binary_name: Option<String>,
267
- pub unexpected_binary: bool,
268
- }
269
-
270
- /// `PlanState`(`orchestrator/__init__.py:51`)。plan 多 stage 状态机持久态。
271
- #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
272
- pub struct PlanState {
273
- pub plan_id: PlanId,
274
- pub plan_path: PathBuf,
275
- pub team: Option<String>,
276
- pub current_stage: i64,
277
- pub started_at: String,
278
- pub completed_stages: Vec<String>,
279
- pub status: PlanStatus,
280
- pub halt_reason: Option<String>,
281
- pub halt_artifact: Option<PathBuf>,
282
- pub stages: Vec<PlanStage>,
283
- pub current_dispatch: Option<String>,
284
- }
285
-
286
- /// 单 stage(`orchestrator/plan.py` stage mapping)。
287
- #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
288
- pub struct PlanStage {
289
- pub id: String,
290
- pub assignee: Option<AgentId>,
291
- pub prompt: Option<String>,
292
- pub on_result: Option<PlanCondition>,
293
- pub status: Option<String>,
294
- }
295
-
296
- /// plan 推进条件(封闭文法 `_CONDITION_RE`,`orchestrator/plan.py:9`)。
297
- /// **必须 typed**:`any` | `report_result.<field> == '<value>'`;越界 → `InvalidPlan`。
298
- /// 不做成自由表达式。
299
- #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
300
- pub enum PlanCondition {
301
- /// 无条件推进。
302
- Any,
303
- /// `report_result.<field> == '<value>'`。
304
- FieldEq { field: String, value: String },
305
- }
306
-
307
- impl PlanCondition {
308
- /// ---
309
- /// purpose: 解析 plan 推进条件的封闭文法
310
- /// params:
311
- /// expr: any,或 report_result.<字段> == <值>,值须带单引号或双引号
312
- /// returns: Any 或 FieldEq
313
- /// errors: 前缀不对、缺等号、字段名非法或值未带引号时返回 InvalidPlan
314
- /// contract_id: lifecycle.types.plan_condition_parse
315
- /// ---
316
- /// 解析封闭条件文法。越界 raise `InvalidPlan`(`orchestrator/plan.py:_is_supported_condition`)。
317
- pub fn parse(expr: &str) -> Result<Self, LifecycleError> {
318
- let trimmed = expr.trim();
319
- if trimmed.eq_ignore_ascii_case("any") {
320
- return Ok(Self::Any);
321
- }
322
-
323
- let Some(rest) = trimmed.strip_prefix("report_result.") else {
324
- return Err(LifecycleError::InvalidPlan(format!(
325
- "unsupported condition: {expr}"
326
- )));
327
- };
328
- let Some((field, value_expr)) = rest.split_once("==") else {
329
- return Err(LifecycleError::InvalidPlan(format!(
330
- "unsupported condition: {expr}"
331
- )));
332
- };
333
- let field = field.trim();
334
- if field.is_empty() || !field.chars().all(|c| c.is_ascii_alphanumeric() || c == '_') {
335
- return Err(LifecycleError::InvalidPlan(format!(
336
- "unsupported condition: {expr}"
337
- )));
338
- }
339
- let value_expr = value_expr.trim();
340
- let value = if let Some(inner) = value_expr
341
- .strip_prefix('\'')
342
- .and_then(|v| v.strip_suffix('\''))
343
- {
344
- inner
345
- } else if let Some(inner) = value_expr
346
- .strip_prefix('"')
347
- .and_then(|v| v.strip_suffix('"'))
348
- {
349
- inner
350
- } else {
351
- return Err(LifecycleError::InvalidPlan(format!(
352
- "unsupported condition: {expr}"
353
- )));
354
- };
355
- Ok(Self::FieldEq {
356
- field: field.to_string(),
357
- value: value.to_string(),
358
- })
359
- }
360
- }
361
-
362
- // ===========================================================================
363
- // ERROR(card §10:fallible 边界;daemon/CLI 入口返 rich Result<Report, Error>)
364
- // ===========================================================================
365
-
366
- /// lifecycle 子系统错误。这里只装真失败:
367
- /// owner-gate 拒绝、session 冲突、state 写崩(bug-084)、provider/transport I/O、回滚失败。
368
- #[derive(Debug, Error)]
369
- pub enum LifecycleError {
370
- /// owner-gate 拒绝(foreign owner;`check_team_owner` 失败 —— lifecycle 第一道门)。
371
- #[error("owner gate refused: {0}")]
372
- OwnerRefused(String),
373
- /// 同名 tmux session 已存在 —— **拒绝而非 kill**(`core.py:127`,`orchestration.py:79`)。
374
- #[error("tmux session conflict: {0}")]
375
- SessionConflict(String),
376
- /// 危险自动审批未显式确认(`core.py:120`:inherited=false 且无 --yes)。
377
- #[error("dangerous auto-approve requires explicit --yes: {0}")]
378
- DangerousApprovalRequired(String),
379
- /// 启动前门失败(`ensure_agent_start_requirements`:provider/profile/model check)。
380
- #[error("agent start requirement unmet: {0}")]
381
- RequirementUnmet(String),
382
- /// state 持久化失败(bug-084:`os.replace` EACCES/EPERM/EBUSY 退避后仍败)。
383
- #[error("state persistence failed: {0}")]
384
- StatePersist(String),
385
- /// workspace lifecycle transaction lock acquisition timed out.
386
- #[error("error: lifecycle lock timeout after 30s\naction: retry or check for hung reset/start\nlog: {log_path}")]
387
- LifecycleLockTimeout {
388
- lock_path: PathBuf,
389
- log_path: PathBuf,
390
- operation: String,
391
- waited_ms: u128,
392
- },
393
- /// 编译 spec / role doc 失败(`compile_team`/`compile_role_doc_agent`)。
394
- #[error("spec compile failed: {0}")]
395
- Compile(String),
396
- /// provider 命令构造 / resume 不可用(`ResumeUnavailable`)。
397
- #[error("provider error: {0}")]
398
- Provider(String),
399
- /// transport I/O(tmux new-session / new-window / kill 等子进程失败)。
400
- #[error("transport error: {0}")]
401
- Transport(String),
402
- /// 原子动作中途失败且**回滚也失败**(字节级回滚写回失败 —— Gap 15/16 最坏臂)。
403
- #[error("rollback failed after {step}: {detail}")]
404
- RollbackFailed { step: String, detail: String },
405
- /// plan id 非法(`sanitize_plan_id` 拒绝;防路径穿越)。
406
- #[error("invalid plan id: {0}")]
407
- InvalidPlanId(String),
408
- /// plan YAML 校验失败(`InvalidPlanError`)。
409
- #[error("invalid plan: {0}")]
410
- InvalidPlan(String),
411
- /// 多 team 选择歧义 / 未找到(`select_restart_state`)。
412
- #[error("team select: {0}")]
413
- TeamSelect(String),
414
- }
415
-
416
- // ===========================================================================
417
- // OUTCOME / REPORT(rich return — 契约断言这些 carry 的值)
418
- // ===========================================================================
419
-
420
- /// `launch(...)` 报告(`launch/core.py:294` 的 typed dict)。dry-run 时 `agents` 空、
421
- /// `safety` 填充。
422
- #[derive(Debug, Clone, PartialEq, Eq)]
423
- pub struct LaunchReport {
424
- pub session_name: SessionName,
425
- /// Legacy transport starts; their targets belong to the team transport.
426
- pub started: Vec<StartedAgent>,
427
- /// Committed contract starts, without fabricating legacy pane/window targets.
428
- /// Empty on dry-run; populated only after the contract startup returns success.
429
- pub contract_started: Vec<AgentId>,
430
- /// 是否 dry-run(只解析路由/权限,不起进程)。
431
- pub dry_run: bool,
432
- /// Selected tmux endpoint for the team transport when known.
433
- pub tmux_endpoint: Option<String>,
434
- /// 路由决策(每 task 一条;`routing.decision` 事件)。
435
- pub routes: Vec<RoutingDecision>,
436
- /// leader receiver(attach 成功时;经 step10 leader::attach_leader_to_state)。
437
- pub leader_receiver_attached: bool,
438
- pub leader_bind_stage: Option<String>,
439
- pub leader_bind_reason: Option<String>,
440
- pub session_capture_incomplete_agents: Vec<String>,
441
- }
442
-
443
- /// 单个已起 worker(`launch` 的 `agents[]` / `started`)。
444
- #[derive(Debug, Clone, PartialEq, Eq)]
445
- pub struct StartedAgent {
446
- pub agent_id: AgentId,
447
- pub start_mode: StartMode,
448
- pub target: String,
449
- pub spawned_at: String,
450
- pub session_id: Option<SessionId>,
451
- pub rollout_path: Option<RolloutPath>,
452
- pub pending_session_id: Option<SessionId>,
453
- pub claude_config_dir: Option<PathBuf>,
454
- pub provider_projects_root: Option<PathBuf>,
455
- pub managed_mcp_config: bool,
456
- }
457
-
458
- /// 路由决策(`routing.decision` 事件 / launch `routes[]`)。
459
- #[derive(Debug, Clone, PartialEq, Eq)]
460
- pub struct RoutingDecision {
461
- pub task_id: Option<String>,
462
- pub selected_agent: AgentId,
463
- pub reason: String,
464
- pub manual_override: bool,
465
- }
466
-
467
- /// BUG-7 (0.3.1): quick-start cannot honestly report "ready" before the workers'
468
- /// MCP tool sets have actually loaded — provider-side schema rejections (codex
469
- /// invalid_function_parameters etc.) happen AFTER spawn and silently disable the
470
- /// worker. The report must therefore carry a readiness verdict so the CLI surface
471
- /// never emits bare "ready" while worker capability is unverified or already known
472
- /// to be degraded.
473
- #[derive(Debug, Clone, PartialEq, Eq)]
474
- pub enum QuickStartReadiness {
475
- /// At least one agent already failed to materialize a live tmux window (BUG-2
476
- /// observable). The team is *not* ready; user must inspect / restart.
477
- Degraded { unhealthy_agents: Vec<String> },
478
- /// All spawned agents have live windows but their MCP tool set load has NOT
479
- /// been verified yet — provider-side schema/auth failures could still leave
480
- /// the worker unable to call team_orchestrator tools. CLI must label this
481
- /// `pending` / `unverified`, NOT bare `ready`.
482
- PendingToolLoad,
483
- }
484
-
485
- /// `quick_start(...)` 报告(`diagnose/quick_start.py:103` typed 版)。`Refused` 区分
486
- /// existing-context(需 restart 或 --fresh)与 preflight 失败。
487
- #[derive(Debug, Clone, PartialEq, Eq)]
488
- pub enum QuickStartReport {
489
- /// 起队成功 + wait_ready 就绪。
490
- Ready {
491
- session_name: SessionName,
492
- launch: Box<LaunchReport>,
493
- next_actions: Vec<String>,
494
- attach_commands: Vec<String>,
495
- /// BUG-7: real readiness verdict. `Ready` ⇒ the wrapper completed AND the
496
- /// caller already verified tool-set availability; the framework itself
497
- /// never emits this without an external observable confirming worker
498
- /// tool calls succeeded. quick_start_with_transport always defaults to
499
- /// [`QuickStartReadiness::PendingToolLoad`] (or `Degraded` if any agent
500
- /// failed to spawn) so the CLI surface cannot lie about availability.
501
- worker_readiness: QuickStartReadiness,
502
- team: String,
503
- },
504
- /// Workers may exist, but post-spawn admission/coordinator completion failed.
505
- /// Preserve confirmed effects; never disguise this as a preflight refusal.
506
- Partial {
507
- workspace: PathBuf,
508
- session_name: SessionName,
509
- launch: Box<LaunchReport>,
510
- team: String,
511
- error: String,
512
- coordinator_state: String,
513
- },
514
- /// 已有 runtime state → quick-start 拒绝并引导用 restart。
515
- ExistingRuntime {
516
- team: Option<String>,
517
- session_name: Option<SessionName>,
518
- state_path: Option<PathBuf>,
519
- next_actions: Vec<String>,
520
- attach_commands: Vec<String>,
521
- agent_ids: Vec<String>,
522
- },
523
- /// preflight 阻塞(`quick_start.py:59`)。
524
- PreflightBlocked {
525
- summary: String,
526
- blockers: Vec<String>,
527
- next_actions: Vec<String>,
528
- attach_commands: Vec<String>,
529
- },
530
- }
531
-
532
- /// 单 worker 动作通用 envelope(`{ok, agent_id, status, ...}`,`operations.py`/`agents.py`/
533
- /// `start.py`)。status 的语义随动作不同,故各动作有专属 outcome enum 收口;此 struct
534
- /// 是它们共享的字段载体。
535
- #[derive(Debug, Clone, PartialEq, Eq)]
536
- pub struct AgentActionEnvelope {
537
- pub agent_id: AgentId,
538
- pub state_file: PathBuf,
539
- /// coordinator 起后的报告(launch/start/fork/restart 末尾起 coordinator)。
540
- pub coordinator_started: bool,
541
- }
542
-
543
- /// `start_agent(...)` 结果(`start.py:101/134/353`)。穷尽 start 路径。
544
- #[derive(Debug, Clone, PartialEq, Eq)]
545
- pub enum StartAgentOutcome {
546
- /// 起/复活成功,carry start_mode(resumed/fresh/fresh_after_missing_rollout)。
547
- Running {
548
- env: AgentActionEnvelope,
549
- start_mode: StartMode,
550
- target: String,
551
- session_id: Option<SessionId>,
552
- new_session_id: Option<SessionId>,
553
- rollout_path: Option<RolloutPath>,
554
- },
555
- /// 窗口已存在且非 force → noop(`start.py:134`)。
556
- Noop {
557
- env: AgentActionEnvelope,
558
- target: String,
559
- },
560
- /// agent paused → 不起(`start.py:101`,reason=agent_paused)。
561
- Paused { agent_id: AgentId },
562
- }
563
-
564
- /// `stop_agent(...)` 结果(`operations.py:99`)。同时关显示(`test_stop_agent_display`)。
565
- #[derive(Debug, Clone, PartialEq, Eq)]
566
- pub struct StopAgentReport {
567
- pub agent_id: AgentId,
568
- pub target: String,
569
- /// 实际 kill 了的 window(已停则 false)。
570
- pub stopped: bool,
571
- pub display_closed: bool,
572
- pub state_file: PathBuf,
573
- }
574
-
575
- /// `reset_agent(...)` 结果(`operations.py:104/133`)。**必须 `discard_session=true`**,
576
- /// 否则 `Refused{ DiscardSessionRequired }`(`test_reset_agent_discard`)。
577
- #[derive(Debug, Clone, PartialEq, Eq)]
578
- pub enum ResetAgentOutcome {
579
- /// discard + 重起成功。
580
- Reset {
581
- env: AgentActionEnvelope,
582
- start_mode: StartMode,
583
- discarded_session_id: Option<SessionId>,
584
- session_id: Option<SessionId>,
585
- new_session_id: Option<SessionId>,
586
- capture_state: String,
587
- reset_proof: String,
588
- weak_reset_warning: Option<String>,
589
- },
590
- /// 未传 discard_session → 拒绝(不丢上下文的误用保护)。
591
- Refused { reason: ResetRefusal },
592
- }
593
-
594
- #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
595
- #[serde(rename_all = "snake_case")]
596
- pub enum ResetRefusal {
597
- DiscardSessionRequired,
598
- }
599
-
600
- /// `add_agent(...)` 结果(`operations.py:272`)。动态 role doc 编译进 spec + 起 worker;
601
- /// 失败字节级回滚 spec_yaml / workspace_state / **team_state.md** / role_file(Gap 15.11)。
602
- #[derive(Debug, Clone, PartialEq, Eq)]
603
- pub struct AddAgentReport {
604
- pub env: AgentActionEnvelope,
605
- pub start_mode: StartMode,
606
- /// 写入的动态 role file 路径。
607
- pub role_file: PathBuf,
608
- }
609
-
610
- /// `fork_agent(...)` 结果。legacy 席位不再 fork;Claude Code / Codex / Grok /
611
- /// Pi 的新席位 fork 由 contract 管道直接给出回执,不经过这里。
612
- #[derive(Debug, Clone, PartialEq, Eq)]
613
- pub struct ForkAgentReport {
614
- pub source_agent_id: AgentId,
615
- pub new_agent_id: AgentId,
616
- pub env: AgentActionEnvelope,
617
- pub session_id: Option<SessionId>,
618
- pub backing_state: ForkBackingState,
619
- }
620
-
621
- #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
622
- #[serde(rename_all = "snake_case")]
623
- pub enum ForkBackingState {
624
- Verified,
625
- PendingContextFork,
626
- }
627
-
628
- #[derive(Debug, Clone, PartialEq, Eq)]
629
- pub struct CloneAgentReport {
630
- pub source_agent_id: AgentId,
631
- pub new_agent_id: AgentId,
632
- pub env: AgentActionEnvelope,
633
- pub session_id: Option<SessionId>,
634
- pub backing_path: Option<PathBuf>,
635
- pub backing_state: CloneBackingState,
636
- }
637
-
638
- #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
639
- #[serde(rename_all = "snake_case")]
640
- pub enum CloneBackingState {
641
- Verified,
642
- PendingFirstTurn,
643
- }
644
-
645
- /// Read-only remove-agent flag requirements for the target's current state.
646
- #[derive(Debug, Clone, PartialEq, Eq)]
647
- pub struct RemoveAgentFlagRequirements {
648
- pub agent_id: AgentId,
649
- pub from_spec_required: bool,
650
- pub force_required: bool,
651
- pub has_session: bool,
652
- }
653
-
654
- /// `remove_agent(...)` 结果(`agents.py:54/56/150`)。`_RemoveRollback` 快照
655
- /// spec/state/team_state/role_file/agent_health 字节级回滚(Gap 16)。
656
- #[derive(Debug, Clone, PartialEq, Eq)]
657
- pub enum RemoveAgentOutcome {
658
- /// 原子摘除成功(spec/state/team_state/role-file/agent_health 全删)。
659
- Removed {
660
- agent_id: AgentId,
661
- state_file: PathBuf,
662
- /// GC 掉的 agent_health 行(`test_remove_agent_health_gc`)。
663
- agent_health_deleted: bool,
664
- },
665
- /// 未传 from_spec 确认(`agents.py:54`)。
666
- RefusedFromSpecConfirm { agent_id: AgentId },
667
- /// 运行中未传 force(`agents.py:56`)。
668
- RefusedForceRequired { agent_id: AgentId },
669
- /// Multiple required destructive flags are absent; report them together.
670
- RefusedRequiredFlags {
671
- agent_id: AgentId,
672
- from_spec_required: bool,
673
- force_required: bool,
674
- },
675
- }
676
-
677
- /// `restart(...)` 结果(`orchestration.py:114/142/387`)。Route B:**先全量验证**
678
- /// (resume 决策 + first_send_at 校验)**再**破坏性 teardown。refuse 时 nothing created。
679
- #[derive(Debug, Clone, PartialEq, Eq)]
680
- pub enum RestartReport {
681
- /// 整队重建成功。每 worker 已发 `restart.resume_decision`。
682
- Restarted {
683
- session_name: SessionName,
684
- agents: Vec<RestartedAgent>,
685
- /// Compatibility field: true means the coordinator requirement is
686
- /// satisfied. The structured `coordinator` summary carries started vs
687
- /// already-running vs rotated detail.
688
- coordinator_started: bool,
689
- coordinator: CoordinatorStartSummary,
690
- next_actions: Vec<String>,
691
- attach_commands: Vec<String>,
692
- /// Debt returned by this restart's best-effort auto-attach, if any.
693
- attach_window_failures: Option<serde_json::Value>,
694
- leader_bind_ok: bool,
695
- leader_bind_reason: Option<String>,
696
- },
697
- /// At least one worker failed during live spawn, but other workers were isolated
698
- /// and restarted. The CLI reports `status=partial` and exits non-zero.
699
- Partial {
700
- session_name: SessionName,
701
- agents: Vec<RestartedAgent>,
702
- failed_agents: Vec<RestartFailedAgent>,
703
- /// Compatibility field: true means the coordinator requirement is
704
- /// satisfied. The structured `coordinator` summary carries started vs
705
- /// already-running vs rotated detail.
706
- coordinator_started: bool,
707
- coordinator: CoordinatorStartSummary,
708
- next_actions: Vec<String>,
709
- attach_commands: Vec<String>,
710
- /// Debt returned by this restart's best-effort auto-attach, if any.
711
- attach_window_failures: Option<serde_json::Value>,
712
- leader_bind_ok: bool,
713
- leader_bind_reason: Option<String>,
714
- },
715
- /// All workers failed during live spawn. No worker is reported as restarted.
716
- Failed {
717
- session_name: SessionName,
718
- failed_agents: Vec<RestartFailedAgent>,
719
- next_actions: Vec<String>,
720
- attach_commands: Vec<String>,
721
- },
722
- /// atomic refusal(`reason=resume_atomicity`):某 interacted worker 不可 resume
723
- /// 且非 allow_fresh。**nothing created yet**,无需回滚。
724
- RefusedResumeAtomicity {
725
- unresumable: Vec<UnresumableWorker>,
726
- allow_fresh: bool,
727
- error: String,
728
- },
729
- /// session capture did not converge before destructive restart. No teardown/spawn occurred.
730
- RefusedResumeNotReady {
731
- missing: Vec<AgentId>,
732
- allow_fresh: bool,
733
- deadline: std::time::Duration,
734
- elapsed: std::time::Duration,
735
- error: String,
736
- },
737
- /// first_send_at 损坏(`reason=invalid_first_send_at`):决策前 hard refuse。
738
- RefusedInvalidFirstSendAt {
739
- invalid: Vec<CorruptFirstSendAt>,
740
- allow_fresh: bool,
741
- error: String,
742
- },
743
- /// 0.5.40 Slice 3 (tmux-server-death-locate §7 Slice 3, first-version
744
- /// all-or-refuse): the previous worker session is still live AND state
745
- /// carries running agents with real pane_ids. Restart today can only
746
- /// proceed by killing the live session first — which loses provider
747
- /// session state in the worker panes and, worse, can cascade into
748
- /// server death under Case B. Until the build-before-destroy path
749
- /// (later car: temporary session + minimal-viability proof + swap)
750
- /// lands, restart refuses this shape *before* touching tmux or state.
751
- /// **nothing created or killed; state.agents rows are byte-identical
752
- /// to what was seeded before the call.**
753
- RefusedBuildBeforeDestroyRequired {
754
- /// Live worker session name from state that would need destructive
755
- /// rebuild.
756
- session_name: String,
757
- /// Snapshot of agent ids currently running with real pane_ids —
758
- /// this is the "authoritative old state" the refusal preserves.
759
- live_agents: Vec<String>,
760
- /// Human-readable error pointing the user at the canonical recovery
761
- /// path (bare shutdown then restart).
762
- error: String,
763
- },
764
- /// unit-3 (Stage 1): session-identity preflight refused — `state.session_name`
765
- /// is a leader launcher session (`team-agent-leader-*`). Proceeding would
766
- /// tear down the leader pane (E49 / 0.3.39). **nothing created or killed**.
767
- RefusedDirtyTopology {
768
- /// The session name that failed the preflight, verbatim from state.
769
- session_name: String,
770
- /// Stable machine-readable reason (currently
771
- /// `"worker_session_is_leader_session"`).
772
- reason: String,
773
- /// Human-readable error directing the user to a recovery action.
774
- error: String,
775
- /// Stable topology issue ids surfaced by CLI/diagnose.
776
- issue_ids: Vec<String>,
777
- },
778
- }
779
-
780
- /// 单个重建后的 worker(carry restart_mode)。
781
- #[derive(Debug, Clone, PartialEq, Eq)]
782
- pub struct RestartedAgent {
783
- pub agent_id: AgentId,
784
- pub restart_mode: StartMode,
785
- pub decision: ResumeDecision,
786
- pub session_id: Option<SessionId>,
787
- }
788
-
789
- /// Worker restart failure isolated from the rest of the restart pass.
790
- #[derive(Debug, Clone, PartialEq, Eq)]
791
- pub struct RestartFailedAgent {
792
- pub agent_id: AgentId,
793
- pub restart_mode: StartMode,
794
- pub decision: ResumeDecision,
795
- pub session_id: Option<SessionId>,
796
- pub phase: String,
797
- pub error: String,
798
- }
799
-
800
- /// atomic refusal 里的不可重建 worker(`orchestration.py:517`)。
801
- ///
802
- /// unit-5 (Stage 2): `reason` 是历史 free-form 字符串,JSON/CLI 直接吃它;新增
803
- /// `refusal_reason` 携带 unit-5 的 closed enum(`provider::session::ResumeRefusalReason`)
804
- /// 同源 wire 字符串。两者必须 round-trip 一致(see `ResumeRefusalReason::wire`)。
805
- /// 旧调用方读 `reason` 不变;新调用方走 enum 拿到结构化原因。
806
- #[derive(Debug, Clone, PartialEq, Eq)]
807
- pub struct UnresumableWorker {
808
- pub agent_id: AgentId,
809
- /// `no_persisted_session_id` | `session_unresumable` | `session_backing_store_missing` | …
810
- pub reason: String,
811
- /// unit-5 structured refusal (optional during migration; populated alongside `reason`).
812
- pub refusal_reason: Option<crate::provider::session::ResumeRefusalReason>,
813
- pub session_id: Option<SessionId>,
814
- pub first_send_at: Option<String>,
815
- }
816
-
817
- /// first_send_at 损坏条目(`restart.first_send_at_invalid` 事件 payload)。
818
- #[derive(Debug, Clone, PartialEq, Eq)]
819
- pub struct CorruptFirstSendAt {
820
- pub worker_id: AgentId,
821
- pub raw_first_send_at: serde_json::Value,
822
- pub raw_first_send_at_type: String,
823
- }
824
-
825
- /// Route B 全量验证产物(`_emit_resume_decisions` + `_collect_corrupt_first_send_at`,
826
- /// `orchestration.py:430/467`)。restart() **先**算它(纯计算,无副作用),corrupt 非空则
827
- /// hard-refuse;否则按 decisions/unresumable 决定 teardown。把"每非 paused worker 发一条
828
- /// `restart.resume_decision`" 与 "python type().__name__ 映射" 从 start_agent 的整条
829
- /// lock+spawn 路径里**分离出来**,使 Route B audit 契约可在 fixture state 上单元级断言
830
- /// (gate gap:restart() 只返回终态 RestartReport,缺隔离测试面)。
831
- #[derive(Debug, Clone, PartialEq, Eq)]
832
- pub struct RestartPlan {
833
- /// 每非 paused worker 一条决策(顺序 = restart_agents 顺序);Route B audit 契约必发。
834
- pub decisions: Vec<RestartedAgent>,
835
- /// first_send_at 损坏条目(决策前 hard-refuse 的依据;carry python type-name)。
836
- pub corrupt_entries: Vec<CorruptFirstSendAt>,
837
- /// allow_fresh=false 且 interacted-but-unresumable 的 worker(atomic_refusal 触发集)。
838
- pub unresumable: Vec<UnresumableWorker>,
839
- }
840
-
841
- /// plan 状态机推进结果(`orchestrator/__init__.py` start_plan / handle_report_result /
842
- /// halt_plan 的 typed 版)。
843
- #[derive(Debug, Clone, PartialEq, Eq)]
844
- pub enum PlanProgress {
845
- /// 仍运行,当前 stage。
846
- Running {
847
- plan_id: PlanId,
848
- current_stage: i64,
849
- state_path: PathBuf,
850
- },
851
- /// 全 stage 完成。
852
- Completed { plan_id: PlanId },
853
- /// halted(carry reason + artifact)。
854
- Halted {
855
- plan_id: PlanId,
856
- reason: String,
857
- artifact: Option<PathBuf>,
858
- },
859
- /// report_result 不匹配任何 stage 条件 → no-op(`__init__.py:96`)。
860
- NoMatch,
861
- }