@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,970 +0,0 @@
1
- //! #249 Python 0.2.11 -> Rust 0.3.x local upgrade compatibility contracts.
2
- //!
3
- //! These are T0/T1 fixture-driven checks only: no provider subscription, no live
4
- //! upgrade. They pin the state key, DB, delivery, restart, and MCP config seams
5
- //! that must survive a Python 0.2.11 runtime handoff.
6
-
7
- #![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
8
-
9
- #[path = "../../../tests/support/hermetic.rs"]
10
- mod hermetic_guard;
11
- #[allow(dead_code)]
12
- fn _hermetic_boundary_marker(_: &hermetic_guard::HermeticTestEnv) {}
13
-
14
- use std::collections::BTreeMap;
15
- use std::path::{Path, PathBuf};
16
- use std::sync::atomic::{AtomicU64, Ordering};
17
- use std::sync::Mutex;
18
-
19
- use rusqlite::params;
20
- use serde_json::{json, Value};
21
- use serial_test::serial;
22
- use team_agent::cli::{cmd_status_for_team, CmdOutput, StatusArgs};
23
- use team_agent::db::schema::{initialize_schema, open_db, table_layout, SCHEMA_VERSION};
24
- use team_agent::event_log::EventLog;
25
- use team_agent::lifecycle::restart::classify_restart_plan;
26
- use team_agent::lifecycle::{restart_with_transport, ResumeDecision, StartMode};
27
- use team_agent::message_store::MessageStore;
28
- use team_agent::messaging::delivery::deliver_pending_message;
29
- use team_agent::state::persist::save_runtime_state;
30
- use team_agent::state::selector::{resolve_active_team, SelectorMode};
31
- use team_agent::transport::{
32
- AttachOutcome, BackendKind, CaptureRange, CapturedText, InjectPayload, InjectReport,
33
- InjectStage, InjectVerification, Key, PaneField, PaneId, PaneInfo, PaneLiveness, SessionName,
34
- SetEnvOutcome, SpawnResult, SubmitVerification, Target, Transport, TransportError,
35
- TurnVerification, WindowName,
36
- };
37
-
38
- const TEAM_KEY: &str = "upgrade-key";
39
- const LEGACY_NAME: &str = "legacy-name";
40
- const SIBLING_KEY: &str = "sibling-key";
41
-
42
- #[test]
43
- #[serial(env)]
44
- fn upgrade_0211_state_team_key_runtime_key_not_spec_name() {
45
- let fixture = UpgradeFixture::new("state-key");
46
- fixture.write_spec(TEAM_KEY, LEGACY_NAME);
47
- fixture.seed_dual_team_state(TEAM_KEY);
48
-
49
- let selected = resolve_active_team(
50
- &fixture.workspace,
51
- Some(TEAM_KEY),
52
- SelectorMode::RuntimeOnly,
53
- )
54
- .expect("selector must accept the runtime team key");
55
- assert_eq!(
56
- selected.team_key, TEAM_KEY,
57
- "runtime team key comes from team_dir/spec_path state key, not spec.name"
58
- );
59
- assert_eq!(selected.state["active_team_key"], json!(TEAM_KEY));
60
- assert!(selected.state["agents"].get("upgrade_worker").is_some());
61
-
62
- let status = json_output(cmd_status_for_team(
63
- &StatusArgs {
64
- agent: None,
65
- workspace: fixture.workspace.clone(),
66
- detail: true,
67
- summary: false,
68
- json: true,
69
- team: None,
70
- },
71
- Some(TEAM_KEY),
72
- ));
73
- let node_names = status
74
- .get("nodes")
75
- .and_then(Value::as_array)
76
- .expect("status brief must expose nodes")
77
- .iter()
78
- .filter_map(|node| node.get("name").and_then(Value::as_str))
79
- .collect::<Vec<_>>();
80
- assert!(
81
- node_names.contains(&"upgrade_worker"),
82
- "status --team upgrade-key must project the runtime-key team; status={status}"
83
- );
84
- assert!(
85
- !node_names.contains(&"sibling_worker"),
86
- "status --team upgrade-key must not collapse to sibling/spec-name state; status={status}"
87
- );
88
- }
89
-
90
- #[test]
91
- #[serial(env)]
92
- fn upgrade_0211_db_schema_v3_reads_and_preserves_rows() {
93
- let fixture = UpgradeFixture::new("db-v3");
94
- fixture.seed_python_v3_db();
95
- let before = fixture.table_counts(&["messages", "results", "agent_health"]);
96
-
97
- let store = MessageStore::open(&fixture.workspace).expect("Rust must open Python schema v3 DB");
98
- let after = fixture.table_counts(&["messages", "results", "agent_health"]);
99
-
100
- assert_eq!(before, after, "opening Python schema v3 must not drop rows");
101
- assert_eq!(
102
- pragma_user_version(store.db_path()),
103
- SCHEMA_VERSION,
104
- "schema version must remain readable as v3"
105
- );
106
- }
107
-
108
- #[test]
109
- #[serial(env)]
110
- fn upgrade_legacy_owner_team_id_delivery_projects_state_team() {
111
- let fixture = UpgradeFixture::new("delivery-runtime-key");
112
- fixture.seed_dual_team_state(SIBLING_KEY);
113
- let store = MessageStore::open(&fixture.workspace).unwrap();
114
- let message_id = store
115
- .create_message(None, "leader", "w1", "ping", None, false, Some(TEAM_KEY))
116
- .unwrap();
117
- let transport = RecordingTransport::new();
118
- let state = team_agent::state::persist::load_runtime_state(&fixture.workspace).unwrap();
119
-
120
- let outcome = deliver_pending_message(
121
- &fixture.workspace,
122
- &store,
123
- &transport,
124
- &message_id,
125
- &EventLog::new(&fixture.workspace),
126
- &state,
127
- )
128
- .expect("delivery should run");
129
-
130
- assert!(
131
- outcome.ok,
132
- "runtime-key owner row should deliver; outcome={outcome:?}"
133
- );
134
- assert_eq!(
135
- transport.injected_windows(),
136
- vec![(format!("team-{TEAM_KEY}"), "upgrade-window".to_string())],
137
- "owner_team_id=upgrade-key must project state.teams[upgrade-key], not active sibling"
138
- );
139
- }
140
-
141
- #[test]
142
- #[serial(env)]
143
- fn upgrade_spec_name_owner_team_id_projects_without_read_side_migration() {
144
- let fixture = UpgradeFixture::new("delivery-legacy-name");
145
- fixture.seed_dual_team_state(SIBLING_KEY);
146
- let store = MessageStore::open(&fixture.workspace).unwrap();
147
- let message_id = store
148
- .create_message(None, "leader", "w1", "ping", None, false, Some(LEGACY_NAME))
149
- .unwrap();
150
- let transport = RecordingTransport::new();
151
- let state = team_agent::state::persist::load_runtime_state(&fixture.workspace).unwrap();
152
-
153
- let outcome = deliver_pending_message(
154
- &fixture.workspace,
155
- &store,
156
- &transport,
157
- &message_id,
158
- &EventLog::new(&fixture.workspace),
159
- &state,
160
- )
161
- .expect("delivery should return an explicit outcome");
162
- let owner_after = owner_team_id_for_message(&fixture.workspace, &message_id);
163
- let status_after = message_status(&fixture.workspace, &message_id);
164
-
165
- assert!(
166
- outcome.ok,
167
- "legacy alias must still project to canonical state; outcome={outcome:?}"
168
- );
169
- assert_eq!(
170
- owner_after.as_deref(),
171
- Some(LEGACY_NAME),
172
- "U0-B: read-side compatibility must not UPDATE owner_team_id rows; owner_after={owner_after:?}"
173
- );
174
- assert_eq!(
175
- status_after.as_deref(),
176
- Some("delivered"),
177
- "legacy alias delivery should be explicit, not silently dropped; status_after={status_after:?}"
178
- );
179
- assert_eq!(
180
- transport.injected_windows(),
181
- vec![(format!("team-{TEAM_KEY}"), "upgrade-window".to_string())],
182
- "owner_team_id=legacy-name must project to upgrade-key without mutating the DB row"
183
- );
184
- assert!(
185
- events_text(&fixture.workspace).contains("owner_team_id.compatibility_alias_detected"),
186
- "legacy alias projection must leave a read-only audit event; events={}",
187
- events_text(&fixture.workspace)
188
- );
189
- }
190
-
191
- #[test]
192
- #[serial(env)]
193
- fn upgrade_status_collect_scope_by_selected_team_key() {
194
- let fixture = UpgradeFixture::new("status-collect-scope");
195
- fixture.write_spec(TEAM_KEY, LEGACY_NAME);
196
- fixture.seed_dual_team_state(TEAM_KEY);
197
- fixture.seed_python_v3_db();
198
- fixture.seed_result(
199
- "res-upgrade",
200
- TEAM_KEY,
201
- "task-upgrade",
202
- "upgrade_worker",
203
- "success",
204
- );
205
- fixture.seed_result(
206
- "res-sibling",
207
- SIBLING_KEY,
208
- "task-sibling",
209
- "sibling_worker",
210
- "success",
211
- );
212
-
213
- let status = json_output(cmd_status_for_team(
214
- &StatusArgs {
215
- agent: None,
216
- workspace: fixture.workspace.clone(),
217
- detail: true,
218
- summary: false,
219
- json: true,
220
- team: None,
221
- },
222
- Some(TEAM_KEY),
223
- ));
224
- let node_names = status
225
- .get("nodes")
226
- .and_then(Value::as_array)
227
- .expect("status brief must expose nodes")
228
- .iter()
229
- .filter_map(|node| node.get("name").and_then(Value::as_str))
230
- .collect::<Vec<_>>();
231
- assert!(
232
- node_names.contains(&"upgrade_worker"),
233
- "status --team upgrade-key must retain the selected runtime-key node; status={status}"
234
- );
235
- assert!(
236
- !node_names.contains(&"sibling_worker"),
237
- "status --team upgrade-key must not expose sibling rows; status={status}"
238
- );
239
-
240
- }
241
-
242
- #[test]
243
- fn upgrade_restart_plan_uses_persisted_session_id() {
244
- let dir = tmp_dir("restart-plan-rollout");
245
- let rollout = dir.join("rollout.jsonl");
246
- std::fs::write(&rollout, "{}\n").unwrap();
247
- let state = json!({
248
- "agents": {
249
- "w1": {
250
- "status": "running",
251
- "provider": "copilot",
252
- "session_id": "sess-upgrade",
253
- "rollout_path": rollout.to_string_lossy(),
254
- "first_send_at": "2026-06-07T01:00:00+00:00"
255
- }
256
- }
257
- });
258
-
259
- let plan = classify_restart_plan(&state, false).expect("restart plan");
260
- assert_eq!(plan.decisions[0].decision, ResumeDecision::Resume);
261
- assert_eq!(plan.decisions[0].restart_mode, StartMode::Resumed);
262
- assert_eq!(
263
- plan.decisions[0].session_id.as_ref().map(|s| s.as_str()),
264
- Some("sess-upgrade")
265
- );
266
- }
267
-
268
- /// 0.4.7 partial-resume: a worker that has NEVER been captured
269
- /// (no session_id AND first_send_at is Absent) is structurally non-resumable.
270
- /// restart without --allow-fresh must auto-fresh it (no context to lose),
271
- /// instead of refusing and blocking the other roles. This prevents 1
272
- /// never-captured role from connecting 6 other resumable roles.
273
- #[test]
274
- fn restart_auto_fresh_never_captured_worker_without_allow_fresh() {
275
- let state = json!({
276
- "agents": {
277
- "never_captured": {
278
- "status": "running",
279
- "provider": "copilot",
280
- "session_id": null,
281
- "first_send_at": null
282
- }
283
- }
284
- });
285
-
286
- let plan = classify_restart_plan(&state, false).expect("restart plan");
287
- assert_eq!(
288
- plan.decisions[0].decision,
289
- ResumeDecision::FreshStart,
290
- "0.4.7: never-captured worker (no session_id + no first_send_at) \
291
- must auto-fresh without --allow-fresh; no context to lose"
292
- );
293
- assert_eq!(plan.decisions[0].restart_mode, StartMode::Fresh);
294
- assert!(
295
- plan.unresumable.is_empty(),
296
- "0.4.7: never-captured worker is not unresumable (no context to fail)"
297
- );
298
- }
299
-
300
- /// 0.4.7 partial-resume guard: a worker that HAS first_send_at but no
301
- /// session_id is the "received message but session not captured" bug
302
- /// state — restart without --allow-fresh must STILL Refuse, never
303
- /// silently fresh (architect rule: 绝不静默 fresh). This is what the
304
- /// existing `upgrade_restart_refuses_interacted_worker_without_session_id`
305
- /// test pins; this test pins the SAME guard for Copilot (the partial-resume
306
- /// change must not weaken it for any provider).
307
- #[test]
308
- fn restart_refuses_interacted_copilot_worker_without_session_id_partial_resume_preserves_guard() {
309
- let state = json!({
310
- "agents": {
311
- "interacted_no_sid": {
312
- "status": "running",
313
- "provider": "copilot",
314
- "session_id": null,
315
- "first_send_at": "2026-06-26T01:00:00+00:00"
316
- }
317
- }
318
- });
319
-
320
- let plan = classify_restart_plan(&state, false).expect("restart plan");
321
- assert_eq!(
322
- plan.decisions[0].decision,
323
- ResumeDecision::Refuse,
324
- "0.4.7: interacted worker with no session_id must STILL refuse \
325
- without --allow-fresh (architect rule: never silently drop context)"
326
- );
327
- }
328
-
329
- #[test]
330
- fn upgrade_restart_refuses_interacted_worker_without_session_id() {
331
- let state = json!({
332
- "agents": {
333
- "w1": {
334
- "status": "running",
335
- "provider": "fake",
336
- "session_id": null,
337
- "first_send_at": "2026-06-07T01:00:00+00:00"
338
- }
339
- }
340
- });
341
-
342
- let refused = classify_restart_plan(&state, false).expect("restart plan");
343
- assert_eq!(refused.decisions[0].decision, ResumeDecision::Refuse);
344
- assert_eq!(refused.unresumable[0].reason, "no_persisted_session_id");
345
-
346
- let allowed = classify_restart_plan(&state, true).expect("restart plan with allow_fresh");
347
- assert_eq!(allowed.decisions[0].decision, ResumeDecision::FreshStart);
348
- assert!(
349
- allowed.unresumable.is_empty(),
350
- "allow_fresh is the explicit opt-in to fresh restart for interacted workers"
351
- );
352
- }
353
-
354
- #[test]
355
- #[serial(env)]
356
- fn upgrade_rust_mcp_config_uses_current_binary_and_runtime_key() {
357
- let fixture = UpgradeFixture::new("restart-mcp");
358
- fixture.write_spec(TEAM_KEY, LEGACY_NAME);
359
- fixture.seed_restartable_state();
360
- fixture.seed_healthy_coordinator();
361
- let _home = fixture.copilot_home_with_session("sess-upgrade");
362
- let transport = RecordingTransport::new().with_session_present(false);
363
-
364
- let report = restart_with_transport(&fixture.team_dir, false, Some(TEAM_KEY), &transport)
365
- .expect("restart should spawn resumable worker");
366
- let spawn = transport.single_spawn();
367
- let command_line = spawn.command_line();
368
- let current_exe = std::env::current_exe()
369
- .unwrap()
370
- .to_string_lossy()
371
- .to_string();
372
-
373
- assert!(
374
- format!("{report:?}").contains("Resumed"),
375
- "restart report must show resume path for persisted session_id; report={report:?}"
376
- );
377
- // Copilot reads its MCP config from `--additional-mcp-config @<file>`.
378
- let mcp_config_path = spawn
379
- .argv
380
- .windows(2)
381
- .find(|pair| pair[0] == "--additional-mcp-config")
382
- .and_then(|pair| pair[1].strip_prefix('@'))
383
- .map(PathBuf::from)
384
- .unwrap_or_else(|| {
385
- panic!("restarted copilot worker must point --additional-mcp-config at its MCP file; command_line={command_line:?}")
386
- });
387
- let mcp_text = std::fs::read_to_string(&mcp_config_path).unwrap();
388
- let mcp_config: Value = serde_json::from_str(&mcp_text).unwrap();
389
- assert!(
390
- mcp_text.contains(&current_exe),
391
- "restarted worker MCP command must use the current Rust candidate binary path; current_exe={current_exe} mcp_config={mcp_text}"
392
- );
393
- assert!(
394
- command_line.contains("TEAM_AGENT_OWNER_TEAM_ID=upgrade-key")
395
- && mcp_config
396
- .pointer("/mcpServers/team_orchestrator/env/TEAM_AGENT_OWNER_TEAM_ID")
397
- .and_then(Value::as_str)
398
- == Some("upgrade-key"),
399
- "spawn env and MCP config must both use runtime team key upgrade-key; command_line={command_line:?} mcp_config={mcp_text}"
400
- );
401
- assert!(
402
- spawn.argv.iter().any(|arg| arg == "copilot")
403
- && spawn
404
- .argv
405
- .windows(2)
406
- .any(|pair| pair[0] == "--resume" && pair[1] == "sess-upgrade"),
407
- "restart must resume persisted provider session (`copilot ... --resume <sid>`), not fresh start; command_line={command_line:?}"
408
- );
409
- }
410
-
411
- #[test]
412
- #[serial(env)]
413
- fn upgrade_db_layout_rebuild_preserves_owner_team_id() {
414
- let fixture = UpgradeFixture::new("db-rebuild-owner");
415
- fixture.seed_legacy_drift_db_owner_last();
416
-
417
- let before = distinct_owner_ids(&fixture.db_path(), "messages");
418
- let store = MessageStore::open(&fixture.workspace).expect("open drifted legacy DB");
419
- let after = distinct_owner_ids(store.db_path(), "messages");
420
-
421
- assert_eq!(before, vec![TEAM_KEY.to_string()]);
422
- assert_eq!(
423
- after, before,
424
- "layout rebuild must preserve owner_team_id values"
425
- );
426
- assert_eq!(
427
- table_layout(&open_db(store.db_path()).unwrap(), "messages").unwrap()[..2],
428
- ["message_id".to_string(), "owner_team_id".to_string()],
429
- "messages layout must rebuild to canonical owner_team_id position"
430
- );
431
- }
432
-
433
- struct UpgradeFixture {
434
- workspace: PathBuf,
435
- team_dir: PathBuf,
436
- }
437
-
438
- impl UpgradeFixture {
439
- fn new(tag: &str) -> Self {
440
- let root = tmp_dir(tag);
441
- let workspace = root.join("ws");
442
- let team_dir = workspace.join(TEAM_KEY);
443
- std::fs::create_dir_all(&team_dir).unwrap();
444
- std::fs::create_dir_all(team_agent::model::paths::runtime_dir(&workspace)).unwrap();
445
- Self {
446
- workspace,
447
- team_dir,
448
- }
449
- }
450
-
451
- fn write_spec(&self, team_key: &str, spec_name: &str) {
452
- std::fs::write(
453
- self.team_dir.join("TEAM.md"),
454
- format!(
455
- "---\nname: {spec_name}\nobjective: upgrade compat\nprovider: codex\n---\n\nTeam.\n"
456
- ),
457
- )
458
- .unwrap();
459
- std::fs::create_dir_all(self.team_dir.join("agents")).unwrap();
460
- std::fs::write(
461
- self.team_dir.join("agents").join("upgrade_worker.md"),
462
- "---\nname: upgrade_worker\nrole: Upgrade Worker\nprovider: copilot\nmodel: gpt-5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nWorker.\n",
463
- )
464
- .unwrap();
465
- let spec = team_agent::compiler::compile_team(&self.team_dir).unwrap();
466
- assert_eq!(team_key, TEAM_KEY, "fixture uses constant runtime key");
467
- std::fs::write(
468
- self.team_dir.join("team.spec.yaml"),
469
- team_agent::model::yaml::dumps(&spec),
470
- )
471
- .unwrap();
472
- }
473
-
474
- fn seed_dual_team_state(&self, active: &str) {
475
- save_runtime_state(&self.workspace, &self.dual_team_state(active)).unwrap();
476
- }
477
-
478
- fn seed_restartable_state(&self) {
479
- std::fs::write(self.workspace.join("rollout.jsonl"), "{}\n").unwrap();
480
- save_runtime_state(
481
- &self.workspace,
482
- &json!({
483
- "active_team_key": TEAM_KEY,
484
- "team_dir": self.team_dir.to_string_lossy(),
485
- "spec_path": self.team_dir.join("team.spec.yaml").to_string_lossy(),
486
- "session_name": format!("team-{TEAM_KEY}"),
487
- "agents": {
488
- "upgrade_worker": {
489
- "status": "running",
490
- "provider": "copilot",
491
- "role": "Upgrade Worker",
492
- "tools": ["mcp_team"],
493
- "window": "upgrade_worker",
494
- "owner_team_id": TEAM_KEY,
495
- "session_id": "sess-upgrade",
496
- "first_send_at": "2026-06-07T01:00:00+00:00",
497
- "rollout_path": self.workspace.join("rollout.jsonl").to_string_lossy(),
498
- "spawn_cwd": self.team_dir.to_string_lossy()
499
- }
500
- },
501
- "tasks": [],
502
- "teams": {
503
- TEAM_KEY: {
504
- "status": "alive",
505
- "team_dir": self.team_dir.to_string_lossy(),
506
- "spec_path": self.team_dir.join("team.spec.yaml").to_string_lossy(),
507
- "session_name": format!("team-{TEAM_KEY}"),
508
- "agents": {
509
- "upgrade_worker": {
510
- "status": "running",
511
- "provider": "copilot",
512
- "role": "Upgrade Worker",
513
- "tools": ["mcp_team"],
514
- "window": "upgrade_worker",
515
- "owner_team_id": TEAM_KEY,
516
- "session_id": "sess-upgrade",
517
- "first_send_at": "2026-06-07T01:00:00+00:00",
518
- "rollout_path": self.workspace.join("rollout.jsonl").to_string_lossy(),
519
- "spawn_cwd": self.team_dir.to_string_lossy()
520
- }
521
- },
522
- "tasks": []
523
- }
524
- }
525
- }),
526
- )
527
- .unwrap();
528
- }
529
-
530
- /// Copilot resume backing is the `sessions` row in
531
- /// `$HOME/.copilot/session-store.db`; seed it under a fixture HOME and point
532
- /// HOME there for the guard's lifetime (callers are `serial(env)`).
533
- fn copilot_home_with_session(&self, session_id: &str) -> HomeGuard {
534
- let home = self.workspace.parent().unwrap().join("home");
535
- let db = home.join(".copilot").join("session-store.db");
536
- std::fs::create_dir_all(db.parent().unwrap()).unwrap();
537
- let conn = rusqlite::Connection::open(db).unwrap();
538
- conn.execute_batch(
539
- "create table if not exists sessions (id text primary key, cwd text, created_at text);",
540
- )
541
- .unwrap();
542
- conn.execute(
543
- "insert or replace into sessions(id, cwd, created_at) values (?1, ?2, '2026-06-07T01:00:00Z')",
544
- params![session_id, self.team_dir.to_string_lossy()],
545
- )
546
- .unwrap();
547
- HomeGuard::set(&home)
548
- }
549
-
550
- fn dual_team_state(&self, active: &str) -> Value {
551
- let upgrade = json!({
552
- "status": "alive",
553
- "team_dir": self.team_dir.to_string_lossy(),
554
- "spec_path": self.team_dir.join("team.spec.yaml").to_string_lossy(),
555
- "session_name": format!("team-{TEAM_KEY}"),
556
- "team": {"name": LEGACY_NAME},
557
- "agents": {
558
- "upgrade_worker": {"status": "running", "provider": "fake", "window": "upgrade-window", "owner_team_id": TEAM_KEY},
559
- "w1": {"status": "running", "provider": "fake", "window": "upgrade-window", "owner_team_id": TEAM_KEY}
560
- },
561
- "tasks": [{"id": "task-upgrade", "assignee": "upgrade_worker", "status": "pending"}]
562
- });
563
- let sibling = json!({
564
- "status": "alive",
565
- "team_dir": self.workspace.join(SIBLING_KEY).to_string_lossy(),
566
- "spec_path": self.workspace.join(SIBLING_KEY).join("team.spec.yaml").to_string_lossy(),
567
- "session_name": format!("team-{SIBLING_KEY}"),
568
- "agents": {
569
- "sibling_worker": {"status": "running", "provider": "fake", "window": "sibling-window", "owner_team_id": SIBLING_KEY},
570
- "w1": {"status": "running", "provider": "fake", "window": "sibling-window", "owner_team_id": SIBLING_KEY}
571
- },
572
- "tasks": [{"id": "task-sibling", "assignee": "sibling_worker", "status": "pending"}]
573
- });
574
- let active_state = if active == TEAM_KEY {
575
- upgrade.clone()
576
- } else {
577
- sibling.clone()
578
- };
579
- let mut state = active_state;
580
- let obj = state.as_object_mut().unwrap();
581
- obj.insert("active_team_key".to_string(), json!(active));
582
- obj.insert(
583
- "teams".to_string(),
584
- json!({TEAM_KEY: upgrade, SIBLING_KEY: sibling}),
585
- );
586
- state
587
- }
588
-
589
- fn db_path(&self) -> PathBuf {
590
- self.workspace.join(".team").join("runtime").join("team.db")
591
- }
592
-
593
- fn seed_python_v3_db(&self) {
594
- std::fs::create_dir_all(self.db_path().parent().unwrap()).unwrap();
595
- let conn = open_db(&self.db_path()).unwrap();
596
- initialize_schema(&conn, Some(&self.db_path())).unwrap();
597
- conn.execute_batch(&format!("pragma user_version = {SCHEMA_VERSION};"))
598
- .unwrap();
599
- conn.execute(
600
- "insert into messages(message_id, owner_team_id, sender, recipient, requires_ack, status, content, artifact_refs, created_at, updated_at, delivery_attempts)
601
- values ('msg-upgrade', ?1, 'leader', 'upgrade_worker', 0, 'accepted', 'hello', '[]', '2026-06-07T00:00:00+00:00', '2026-06-07T00:00:00+00:00', 0),
602
- ('msg-sibling', ?2, 'leader', 'sibling_worker', 0, 'accepted', 'hello', '[]', '2026-06-07T00:00:01+00:00', '2026-06-07T00:00:01+00:00', 0)",
603
- params![TEAM_KEY, SIBLING_KEY],
604
- )
605
- .unwrap();
606
- self.seed_result(
607
- "res-existing-upgrade",
608
- TEAM_KEY,
609
- "task-upgrade",
610
- "upgrade_worker",
611
- "success",
612
- );
613
- conn.execute(
614
- "insert or replace into agent_health(owner_team_id, agent_id, status, updated_at)
615
- values (?1, 'upgrade_worker', 'running', '2026-06-07T00:00:00+00:00'),
616
- (?2, 'sibling_worker', 'running', '2026-06-07T00:00:00+00:00')",
617
- params![TEAM_KEY, SIBLING_KEY],
618
- )
619
- .unwrap();
620
- }
621
-
622
- fn seed_result(
623
- &self,
624
- result_id: &str,
625
- owner_team_id: &str,
626
- task_id: &str,
627
- agent_id: &str,
628
- status: &str,
629
- ) {
630
- let conn = open_db(&self.db_path()).unwrap();
631
- let envelope = json!({
632
- "schema_version": "result_envelope_v1",
633
- "result_id": result_id,
634
- "task_id": task_id,
635
- "agent_id": agent_id,
636
- "status": status,
637
- "summary": "done",
638
- "changes": [], "tests": [], "risks": [], "artifacts": [], "next_actions": []
639
- });
640
- conn.execute(
641
- "insert or replace into results(result_id, owner_team_id, task_id, agent_id, envelope, status, created_at)
642
- values (?1, ?2, ?3, ?4, ?5, ?6, '2026-06-07T00:00:00+00:00')",
643
- params![result_id, owner_team_id, task_id, agent_id, envelope.to_string(), status],
644
- )
645
- .unwrap();
646
- }
647
-
648
- fn seed_legacy_drift_db_owner_last(&self) {
649
- std::fs::create_dir_all(self.db_path().parent().unwrap()).unwrap();
650
- let conn = rusqlite::Connection::open(self.db_path()).unwrap();
651
- conn.execute_batch(
652
- "pragma user_version=1;
653
- create table messages (message_id text primary key, task_id text, sender text, recipient text, reply_to text, requires_ack integer, status text, content text, artifact_refs text, created_at text, updated_at text, delivered_at text, acknowledged_at text, error text, delivery_attempts integer not null default 0, owner_team_id text);
654
- create table results (result_id text primary key, task_id text not null, agent_id text not null, envelope text not null, status text not null, created_at text not null, owner_team_id text);
655
- insert into messages(message_id, status, owner_team_id) values ('msg-drift','accepted','upgrade-key');
656
- insert into results(result_id, task_id, agent_id, envelope, status, created_at, owner_team_id) values ('res-drift','task-upgrade','upgrade_worker','{}','success','2026-06-07T00:00:00+00:00','upgrade-key');",
657
- )
658
- .unwrap();
659
- }
660
-
661
- fn seed_healthy_coordinator(&self) {
662
- let workspace = team_agent::coordinator::WorkspacePath::new(self.workspace.clone());
663
- std::fs::create_dir_all(team_agent::model::paths::runtime_dir(workspace.as_path()))
664
- .unwrap();
665
- let _ = MessageStore::open(workspace.as_path()).unwrap();
666
- let pid = team_agent::coordinator::Pid::new(std::process::id());
667
- team_agent::coordinator::write_coordinator_metadata(
668
- &workspace,
669
- pid,
670
- team_agent::coordinator::MetadataSource::Boot,
671
- )
672
- .unwrap();
673
- std::fs::write(
674
- team_agent::coordinator::coordinator_pid_path(&workspace),
675
- pid.to_string(),
676
- )
677
- .unwrap();
678
- }
679
-
680
- fn table_counts(&self, tables: &[&str]) -> BTreeMap<String, i64> {
681
- let conn = open_db(&self.db_path()).unwrap();
682
- tables
683
- .iter()
684
- .map(|table| {
685
- let count = conn
686
- .query_row(&format!("select count(*) from {table}"), [], |row| {
687
- row.get(0)
688
- })
689
- .unwrap();
690
- ((*table).to_string(), count)
691
- })
692
- .collect()
693
- }
694
- }
695
-
696
- struct HomeGuard(Option<std::ffi::OsString>);
697
-
698
- impl HomeGuard {
699
- fn set(home: &Path) -> Self {
700
- let previous = std::env::var_os("HOME");
701
- std::env::set_var("HOME", home);
702
- Self(previous)
703
- }
704
- }
705
-
706
- impl Drop for HomeGuard {
707
- fn drop(&mut self) {
708
- match self.0.take() {
709
- Some(previous) => std::env::set_var("HOME", previous),
710
- None => std::env::remove_var("HOME"),
711
- }
712
- }
713
- }
714
-
715
- #[derive(Debug, Clone)]
716
- struct RecordedSpawn {
717
- argv: Vec<String>,
718
- env: BTreeMap<String, String>,
719
- }
720
-
721
- impl RecordedSpawn {
722
- fn command_line(&self) -> String {
723
- let mut parts = self
724
- .env
725
- .iter()
726
- .map(|(key, value)| format!("{key}={value}"))
727
- .collect::<Vec<_>>();
728
- parts.extend(self.argv.iter().cloned());
729
- parts.join(" ")
730
- }
731
- }
732
-
733
- #[derive(Debug, Default)]
734
- struct RecordingTransport {
735
- spawns: Mutex<Vec<RecordedSpawn>>,
736
- injected: Mutex<Vec<Target>>,
737
- session_present: bool,
738
- }
739
-
740
- impl RecordingTransport {
741
- fn new() -> Self {
742
- Self::default()
743
- }
744
-
745
- fn with_session_present(mut self, present: bool) -> Self {
746
- self.session_present = present;
747
- self
748
- }
749
-
750
- fn single_spawn(&self) -> RecordedSpawn {
751
- let spawns = self.spawns.lock().unwrap();
752
- assert_eq!(spawns.len(), 1, "expected one spawn; spawns={spawns:?}");
753
- spawns[0].clone()
754
- }
755
-
756
- fn injected_windows(&self) -> Vec<(String, String)> {
757
- self.injected
758
- .lock()
759
- .unwrap()
760
- .iter()
761
- .filter_map(|target| match target {
762
- Target::SessionWindow { session, window } => {
763
- Some((session.as_str().to_string(), window.as_str().to_string()))
764
- }
765
- Target::Pane(pane) => Some(("pane".to_string(), pane.as_str().to_string())),
766
- })
767
- .collect()
768
- }
769
-
770
- fn spawn_result(
771
- &self,
772
- session: &SessionName,
773
- window: &WindowName,
774
- argv: &[String],
775
- env: &BTreeMap<String, String>,
776
- ) -> SpawnResult {
777
- let mut spawns = self.spawns.lock().unwrap();
778
- spawns.push(RecordedSpawn {
779
- argv: argv.to_vec(),
780
- env: env.clone(),
781
- });
782
- SpawnResult {
783
- pane_id: PaneId::new(format!("%{}", spawns.len())),
784
- session: session.clone(),
785
- window: window.clone(),
786
- child_pid: None,
787
- }
788
- }
789
- }
790
-
791
- impl Transport for RecordingTransport {
792
- fn kind(&self) -> BackendKind {
793
- BackendKind::Tmux
794
- }
795
-
796
- fn spawn_first(
797
- &self,
798
- session: &SessionName,
799
- window: &WindowName,
800
- argv: &[String],
801
- _cwd: &Path,
802
- env: &BTreeMap<String, String>,
803
- ) -> Result<SpawnResult, TransportError> {
804
- Ok(self.spawn_result(session, window, argv, env))
805
- }
806
-
807
- fn spawn_into(
808
- &self,
809
- session: &SessionName,
810
- window: &WindowName,
811
- argv: &[String],
812
- _cwd: &Path,
813
- env: &BTreeMap<String, String>,
814
- ) -> Result<SpawnResult, TransportError> {
815
- Ok(self.spawn_result(session, window, argv, env))
816
- }
817
-
818
- fn inject(
819
- &self,
820
- target: &Target,
821
- _payload: &InjectPayload,
822
- _submit: Key,
823
- _bracketed: bool,
824
- ) -> Result<InjectReport, TransportError> {
825
- self.injected.lock().unwrap().push(target.clone());
826
- Ok(InjectReport {
827
- stage_reached: InjectStage::Submit,
828
- inject_verification: InjectVerification::CaptureContainsToken,
829
- submit_verification: SubmitVerification::EnterSentWithoutPlaceholderCheck,
830
- turn_verification: TurnVerification::NotYetObserved,
831
- attempts: 1,
832
- submit_diagnostics: None,
833
- })
834
- }
835
-
836
- fn send_keys(&self, _target: &Target, _keys: &[Key]) -> Result<(), TransportError> {
837
- Ok(())
838
- }
839
-
840
- fn capture(
841
- &self,
842
- _target: &Target,
843
- range: CaptureRange,
844
- ) -> Result<CapturedText, TransportError> {
845
- Ok(CapturedText {
846
- text: String::new(),
847
- range,
848
- })
849
- }
850
-
851
- fn query(&self, _target: &Target, field: PaneField) -> Result<Option<String>, TransportError> {
852
- match field {
853
- PaneField::PaneWidth => Ok(Some("120".to_string())),
854
- _ => Ok(None),
855
- }
856
- }
857
-
858
- fn liveness(&self, _pane: &PaneId) -> Result<PaneLiveness, TransportError> {
859
- Ok(PaneLiveness::Live)
860
- }
861
-
862
- fn has_pane(&self, pane: &PaneId) -> Result<Option<bool>, TransportError> {
863
- let spawns = self.spawns.lock().unwrap();
864
- Ok(Some(
865
- spawns
866
- .iter()
867
- .enumerate()
868
- .any(|(idx, _)| pane.as_str() == format!("%{}", idx + 1)),
869
- ))
870
- }
871
-
872
- fn list_targets(&self) -> Result<Vec<PaneInfo>, TransportError> {
873
- Ok(Vec::new())
874
- }
875
-
876
- fn has_session(&self, _session: &SessionName) -> Result<bool, TransportError> {
877
- Ok(self.session_present || !self.spawns.lock().unwrap().is_empty())
878
- }
879
-
880
- fn list_windows(&self, _session: &SessionName) -> Result<Vec<WindowName>, TransportError> {
881
- Ok(Vec::new())
882
- }
883
-
884
- fn set_session_env(
885
- &self,
886
- _session: &SessionName,
887
- _key: &str,
888
- _value: &str,
889
- ) -> Result<SetEnvOutcome, TransportError> {
890
- Ok(SetEnvOutcome::Applied)
891
- }
892
-
893
- fn kill_session(&self, _session: &SessionName) -> Result<(), TransportError> {
894
- Ok(())
895
- }
896
-
897
- fn kill_window(&self, _target: &Target) -> Result<(), TransportError> {
898
- Ok(())
899
- }
900
-
901
- fn attach_session(&self, _session: &SessionName) -> Result<AttachOutcome, TransportError> {
902
- Ok(AttachOutcome::Attached)
903
- }
904
- }
905
-
906
- fn json_output(result: Result<team_agent::cli::CmdResult, team_agent::cli::CliError>) -> Value {
907
- match result.expect("CLI command should return a result").output {
908
- CmdOutput::Json(value) => value,
909
- other => panic!("expected JSON output, got {other:?}"),
910
- }
911
- }
912
-
913
- fn owner_team_id_for_message(workspace: &Path, message_id: &str) -> Option<String> {
914
- let store = MessageStore::open(workspace).unwrap();
915
- let conn = open_db(store.db_path()).unwrap();
916
- conn.query_row(
917
- "select owner_team_id from messages where message_id=?1",
918
- params![message_id],
919
- |row| row.get(0),
920
- )
921
- .unwrap()
922
- }
923
-
924
- fn message_status(workspace: &Path, message_id: &str) -> Option<String> {
925
- let store = MessageStore::open(workspace).unwrap();
926
- let conn = open_db(store.db_path()).unwrap();
927
- conn.query_row(
928
- "select status from messages where message_id=?1",
929
- params![message_id],
930
- |row| row.get(0),
931
- )
932
- .unwrap()
933
- }
934
-
935
- fn events_text(workspace: &Path) -> String {
936
- std::fs::read_to_string(workspace.join(".team").join("logs").join("events.jsonl"))
937
- .unwrap_or_default()
938
- }
939
-
940
- fn distinct_owner_ids(db_path: &Path, table: &str) -> Vec<String> {
941
- let conn = open_db(db_path).unwrap();
942
- let mut stmt = conn
943
- .prepare(&format!(
944
- "select distinct owner_team_id from {table} where owner_team_id is not null order by owner_team_id"
945
- ))
946
- .unwrap();
947
- stmt.query_map([], |row| row.get::<_, String>(0))
948
- .unwrap()
949
- .collect::<Result<Vec<_>, _>>()
950
- .unwrap()
951
- }
952
-
953
- fn pragma_user_version(db_path: &Path) -> i64 {
954
- open_db(db_path)
955
- .unwrap()
956
- .query_row("pragma user_version", [], |row| row.get(0))
957
- .unwrap()
958
- }
959
-
960
- fn tmp_dir(tag: &str) -> PathBuf {
961
- static N: AtomicU64 = AtomicU64::new(0);
962
- let dir = std::env::temp_dir().join(format!(
963
- "ta-rs-upgrade-compat-{tag}-{}-{}",
964
- std::process::id(),
965
- N.fetch_add(1, Ordering::Relaxed)
966
- ));
967
- let _ = std::fs::remove_dir_all(&dir);
968
- std::fs::create_dir_all(&dir).unwrap();
969
- std::fs::canonicalize(dir).unwrap()
970
- }