@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,842 +0,0 @@
1
- #![allow(clippy::unwrap_used)]
2
- use super::*;
3
- use crate::model::spec;
4
- use std::fs;
5
- use std::path::PathBuf;
6
- use std::sync::atomic::{AtomicU32, Ordering};
7
-
8
- static COUNTER: AtomicU32 = AtomicU32::new(0);
9
-
10
- #[cfg(unix)]
11
- #[test]
12
- fn every_cursor_provider_name_compiles_to_the_contract_leaf() {
13
- for provider in ["cursor", "cursor_agent", "cursor-agent", "agent"] {
14
- let role = write_tmp(
15
- "cursor.md",
16
- &format!("---\nprovider: {provider}\nmodel: gpt-5.6-luna-xhigh\n---\nRole\n"),
17
- );
18
- let compiled = compile_role_agent(&role, &Value::Map(Vec::new()), "/workspace").unwrap();
19
- assert_eq!(
20
- compiled.agent.get("provider").and_then(Value::as_str),
21
- Some("cursor"),
22
- "{provider}"
23
- );
24
- fs::remove_dir_all(role.parent().unwrap()).unwrap();
25
- // The leaf's effort admission applies, not a legacy warning-and-ignore.
26
- let role = write_tmp(
27
- "cursor.md",
28
- &format!("---\nprovider: {provider}\nmodel: gpt-5.6-luna-xhigh\neffort: high\n---\nRole\n"),
29
- );
30
- let error = compile_role_agent(&role, &Value::Map(Vec::new()), "/workspace")
31
- .err()
32
- .expect("Cursor effort is a model ID, never a separate flag");
33
- assert!(error.to_string().contains("exact catalog model ID"), "{provider}: {error}");
34
- fs::remove_dir_all(role.parent().unwrap()).unwrap();
35
- }
36
- }
37
-
38
- #[cfg(unix)]
39
- #[test]
40
- fn every_codex_and_grok_provider_name_compiles_to_the_contract_leaf() {
41
- // No opt-in: each public name declares its leaf, and neither leaf inherits
42
- // the TEAM provider_effort default.
43
- let team_meta = Value::Map(vec![(
44
- "provider_effort".to_string(),
45
- Value::Str("high".to_string()),
46
- )]);
47
- for (provider, leaf) in [
48
- ("codex", "codex_tui"),
49
- ("codex_cli", "codex_tui"),
50
- ("codex-cli", "codex_tui"),
51
- ("grok", "grok_build"),
52
- ] {
53
- let role = write_tmp("leaf.md", &format!("---\nprovider: {provider}\n---\nRole\n"));
54
- let compiled = compile_role_agent(&role, &team_meta, "/workspace").unwrap();
55
- assert_eq!(
56
- compiled.agent.get("provider").and_then(Value::as_str),
57
- Some(leaf),
58
- "{provider}"
59
- );
60
- assert!(compiled.agent.get("effort").is_none(), "{provider}");
61
- fs::remove_dir_all(role.parent().unwrap()).unwrap();
62
- }
63
- }
64
-
65
- fn unique_base() -> PathBuf {
66
- let n = COUNTER.fetch_add(1, Ordering::Relaxed);
67
- std::env::temp_dir().join(format!("ta_rs_compile_{}_{}", std::process::id(), n))
68
- }
69
-
70
- /// Build `<tmp>/.team/current/{TEAM.md, agents/*, profiles/*}` and return the
71
- /// team dir. `team_workspace(team_dir)` → `<tmp>` (parent is `.team`).
72
- fn build_team(team_md: &str, roles: &[(&str, &str)], profiles: &[(&str, &str)]) -> PathBuf {
73
- let team = unique_base().join(".team").join("current");
74
- fs::create_dir_all(team.join("agents")).unwrap();
75
- fs::create_dir_all(team.join("profiles")).unwrap();
76
- fs::write(team.join("TEAM.md"), team_md).unwrap();
77
- for (name, text) in roles {
78
- fs::write(team.join("agents").join(name), text).unwrap();
79
- }
80
- for (name, text) in profiles {
81
- fs::write(team.join("profiles").join(name), text).unwrap();
82
- }
83
- team
84
- }
85
-
86
- fn write_tmp(name: &str, text: &str) -> PathBuf {
87
- let base = unique_base();
88
- fs::create_dir_all(&base).unwrap();
89
- let p = base.join(name);
90
- fs::write(&p, text).unwrap();
91
- p
92
- }
93
-
94
- /// `json.dumps(v, sort_keys=False, separators=(",",":"))` for a `yaml::Value`:
95
- /// preserves Map insertion order; string escaping matches Python json (ASCII
96
- /// content here). Locks both VALUE and KEY INSERTION ORDER of the spec dict.
97
- fn compact_json(v: &Value) -> String {
98
- match v {
99
- Value::Null => "null".to_string(),
100
- Value::Bool(b) => b.to_string(),
101
- Value::Int(i) => i.to_string(),
102
- Value::Float(f) => format!("{f}"),
103
- Value::Str(s) => serde_json::to_string(s).unwrap(),
104
- Value::List(items) => {
105
- let inner: Vec<String> = items.iter().map(compact_json).collect();
106
- format!("[{}]", inner.join(","))
107
- }
108
- Value::Map(pairs) => {
109
- let inner: Vec<String> = pairs
110
- .iter()
111
- .map(|(k, val)| {
112
- format!(
113
- "{}:{}",
114
- serde_json::to_string(k).unwrap(),
115
- compact_json(val)
116
- )
117
- })
118
- .collect();
119
- format!("{{{}}}", inner.join(","))
120
- }
121
- }
122
- }
123
-
124
- /// Render spec to compact JSON with the env-dependent workspace path templated
125
- /// to `__WS__` (appears as both `team.workspace` and each `working_directory`).
126
- fn templated_compact_json(spec: &Value) -> String {
127
- let ws = spec
128
- .get("team")
129
- .and_then(|t| t.get("workspace"))
130
- .and_then(Value::as_str)
131
- .expect("spec.team.workspace must be a string");
132
- compact_json(spec).replace(ws, "__WS__")
133
- }
134
-
135
- fn workspace_of(spec: &Value) -> String {
136
- spec.get("team")
137
- .and_then(|t| t.get("workspace"))
138
- .and_then(Value::as_str)
139
- .unwrap()
140
- .to_string()
141
- }
142
-
143
- // ───────────────────── fixtures (byte-identical to the Python probe) ─────────────────────
144
-
145
- const TEAM_BASE: &str = "\
146
- ---
147
- name: doc-team
148
- objective: Compile role docs.
149
- provider: codex
150
- model: gpt-5.5
151
- ---
152
-
153
- Document-driven team.
154
- ";
155
-
156
- const ROLE_NOPROFILE: &str = "\
157
- ---
158
- name: implementer
159
- role: Implementation Engineer
160
- provider: copilot
161
- model: gpt-5.5
162
- auth_mode: subscription
163
- dangerously_skip_permissions: false
164
- tools:
165
- - fs_read
166
- - fs_write
167
- - execute_bash
168
- - mcp_team
169
- ---
170
-
171
- Implement bounded tasks and report result_envelope_v1.
172
- ";
173
-
174
- // ───────────────────────────── read_front_matter ─────────────────────────────
175
-
176
- #[test]
177
- fn front_matter_cases() {
178
- struct Case {
179
- id: &'static str,
180
- file: &'static str,
181
- text: &'static str,
182
- meta: &'static [(&'static str, &'static str)],
183
- body: &'static str,
184
- }
185
- const CASES: &[Case] = &[
186
- // No leading "---\n" → ({}, text) verbatim (compiler.py:175-176).
187
- Case {
188
- id: "front_matter_no_marker_returns_empty_meta_and_full_text", file: "no_marker.md",
189
- text: "hello\nworld\n", meta: &[], body: "hello\nworld\n",
190
- },
191
- Case {
192
- id: "front_matter_basic_splits_meta_and_lstrips_body", file: "basic.md",
193
- text: "---\nname: x\nrole: R\n---\n\nbody line\n", meta: &[("name", "x"), ("role", "R")], body: "body line\n",
194
- },
195
- // Closing marker at the blank line → raw "" → {}; body "body\n".
196
- Case {
197
- id: "front_matter_empty_block_is_empty_map", file: "empty.md",
198
- text: "---\n\n---\nbody\n", meta: &[], body: "body\n",
199
- },
200
- // body.lstrip("\n") removes leading NEWLINES but keeps the 2-space indent.
201
- Case {
202
- id: "front_matter_body_lstrip_strips_only_newlines", file: "lstrip.md",
203
- text: "---\nname: x\n---\n\n\n indented body\n", meta: &[("name", "x")], body: " indented body\n",
204
- },
205
- Case {
206
- id: "front_matter_unterminated_falls_back_to_plain_text", file: "unterminated.md",
207
- text: "---\nname: x\n", meta: &[], body: "---\nname: x\n",
208
- },
209
- Case {
210
- id: "front_matter_non_object_falls_back_to_plain_text", file: "list.md",
211
- text: "---\n- a\n- b\n---\nbody\n", meta: &[], body: "---\n- a\n- b\n---\nbody\n",
212
- },
213
- ];
214
- for case in CASES {
215
- let p = write_tmp(case.file, case.text);
216
- let (meta, body) = read_front_matter(&p).unwrap_or_else(|err| panic!("{}: {err}", case.id));
217
- let expected_meta = Value::Map(case.meta.iter().map(|(key, value)| {
218
- ((*key).to_string(), Value::Str((*value).to_string()))
219
- }).collect());
220
- assert_eq!(meta, expected_meta, "{}: metadata", case.id);
221
- assert_eq!(body, case.body, "{}: body", case.id);
222
- }
223
- }
224
-
225
- // ───────────────────────────── compile_team: full dict parity ─────────────────────────────
226
-
227
- // Golden = Python `json.dumps(compile_team(team)["spec"], sort_keys=False,
228
- // separators=(",",":"))` with the workspace path templated to __WS__.
229
- // (team-agent-public v0.2.11, /tmp/probe_compiler.py.)
230
-
231
- const BASE_NOPROFILE_JSON: &str = r#"{"version":1,"team":{"name":"doc-team","mode":"supervisor_worker","objective":"Compile role docs.","workspace":"__WS__"},"leader":{"id":"leader","role":"leader","provider":"codex","model":"gpt-5.5","context_policy":{"keep_user_thread":true,"receive_worker_outputs":"business_messages_and_short_summaries","max_worker_result_tokens":2000}},"agents":[{"id":"implementer","role":"Implementation Engineer","provider":"copilot","model":"gpt-5.5","auth_mode":"subscription","working_directory":"__WS__","system_prompt":{"inline":"Implement bounded tasks and report result_envelope_v1.","file":null},"dangerously_skip_permissions":false,"communication_mode":"leader_centric","preferred_for":["implementer","Implementation Engineer"],"avoid_for":[],"output_contract":{"format":"result_envelope_v1","required_fields":["task_id","status","summary","artifacts"]}}],"routing":{"default_assignee":"implementer","rules":[{"id":"route-implementer","match":{"assignee":["implementer"]},"assign_to":"implementer","priority":10}]},"communication":{"protocol":"mcp_inbox","topology":"leader_centered","worker_to_worker":true,"ack_timeout_sec":60,"result_format":"result_envelope_v1","message_store":{"sqlite":".team/runtime/team.db","mirror_files":".team/messages"}},"runtime":{"backend":"tmux","session_name":"team-doc-team","auto_launch":true,"require_user_approval_before_launch":true,"max_active_agents":1,"startup_order":["implementer"],"fast":false,"tick_interval_sec":2,"push_min_interval_sec":60,"stuck_timeout_sec":300},"context":{"state_file":"team_state.md","artifact_dir":".team/artifacts","log_dir":".team/logs","summarization":{"worker_full_logs":"retain_outside_leader_context","state_update":"after_each_result"}},"tasks":[{"id":"task_initial","title":"Initial document-driven team task","type":"implementation","assignee":"implementer","deps":[],"acceptance":["Worker reports valid result_envelope_v1"],"status":"pending","requires_tools":["mcp_team"],"files":[],"risk":"low"}]}"#;
232
-
233
- #[test]
234
- fn compile_base_noprofile_matches_python_dict_order_and_values() {
235
- let team = build_team(TEAM_BASE, &[("implementer.md", ROLE_NOPROFILE)], &[]);
236
- let spec = compile_team(&team).unwrap();
237
- assert_eq!(templated_compact_json(&spec), BASE_NOPROFILE_JSON);
238
- }
239
-
240
- #[test]
241
- fn compile_base_returned_spec_passes_validate_spec() {
242
- // §6 contract: the compiled spec MUST pass model::spec::validate_spec.
243
- let team = build_team(TEAM_BASE, &[("implementer.md", ROLE_NOPROFILE)], &[]);
244
- let spec = compile_team(&team).unwrap();
245
- let ws = workspace_of(&spec);
246
- assert!(spec::validate_spec(&spec, Path::new(&ws)).is_ok());
247
- }
248
-
249
- #[test]
250
- fn compile_subscription_without_profile_is_thin_manifest() {
251
- // No profile field → agent has auth_mode=subscription and NO profile / credential_ref keys.
252
- let team = build_team(TEAM_BASE, &[("implementer.md", ROLE_NOPROFILE)], &[]);
253
- let spec = compile_team(&team).unwrap();
254
- let agent = &spec.get("agents").and_then(Value::as_list).unwrap()[0];
255
- assert_eq!(
256
- agent.get("auth_mode").and_then(Value::as_str),
257
- Some("subscription")
258
- );
259
- assert!(agent.get("profile").is_none(), "profile key must be absent");
260
- assert!(
261
- agent.get("credential_ref").is_none(),
262
- "credential_ref key must be absent"
263
- );
264
- }
265
-
266
- // Runtime front-matter defaults: TEAM.md runtime settings remain available,
267
- // but its default_model does not fill an omitted role model; leader.model is null.
268
- const RUNTIME_DEFAULTS_TEAM: &str = "\
269
- ---
270
- name: doc-team
271
- objective: Compile role docs.
272
- provider: codex
273
- default_model: gpt-5.4
274
- default_auth_mode: subscription
275
- dangerous_auto_approve: true
276
- fast: true
277
- tick_interval_sec: 1
278
- push_min_interval_sec: 3
279
- stuck_timeout_sec: 5
280
- worker_to_worker: true
281
- ---
282
-
283
- Document-driven team.
284
- ";
285
-
286
- const RUNTIME_DEFAULTS_ROLE: &str = "\
287
- ---
288
- name: implementer
289
- role: Implementation Engineer
290
- provider: copilot
291
- tools:
292
- - fs_read
293
- - mcp_team
294
- dangerously_skip_permissions: false
295
- ---
296
-
297
- Implement bounded tasks.
298
- ";
299
-
300
- const RUNTIME_DEFAULTS_JSON: &str = r#"{"version":1,"team":{"name":"doc-team","mode":"supervisor_worker","objective":"Compile role docs.","workspace":"__WS__"},"leader":{"id":"leader","role":"leader","provider":"codex","model":null,"context_policy":{"keep_user_thread":true,"receive_worker_outputs":"business_messages_and_short_summaries","max_worker_result_tokens":2000}},"agents":[{"id":"implementer","role":"Implementation Engineer","provider":"copilot","model":null,"auth_mode":"subscription","working_directory":"__WS__","system_prompt":{"inline":"Implement bounded tasks.","file":null},"dangerously_skip_permissions":false,"communication_mode":"leader_centric","preferred_for":["implementer","Implementation Engineer"],"avoid_for":[],"output_contract":{"format":"result_envelope_v1","required_fields":["task_id","status","summary","artifacts"]}}],"routing":{"default_assignee":"implementer","rules":[{"id":"route-implementer","match":{"assignee":["implementer"]},"assign_to":"implementer","priority":10}]},"communication":{"protocol":"mcp_inbox","topology":"leader_centered","worker_to_worker":true,"ack_timeout_sec":60,"result_format":"result_envelope_v1","message_store":{"sqlite":".team/runtime/team.db","mirror_files":".team/messages"}},"runtime":{"backend":"tmux","session_name":"team-doc-team","auto_launch":true,"require_user_approval_before_launch":true,"max_active_agents":1,"startup_order":["implementer"],"fast":true,"tick_interval_sec":1,"push_min_interval_sec":3,"stuck_timeout_sec":5},"context":{"state_file":"team_state.md","artifact_dir":".team/artifacts","log_dir":".team/logs","summarization":{"worker_full_logs":"retain_outside_leader_context","state_update":"after_each_result"}},"tasks":[{"id":"task_initial","title":"Initial document-driven team task","type":"implementation","assignee":"implementer","deps":[],"acceptance":["Worker reports valid result_envelope_v1"],"status":"pending","requires_tools":["mcp_team"],"files":[],"risk":"low"}]}"#;
301
-
302
- #[test]
303
- fn compile_runtime_front_matter_defaults_match_python() {
304
- let team = build_team(
305
- RUNTIME_DEFAULTS_TEAM,
306
- &[("implementer.md", RUNTIME_DEFAULTS_ROLE)],
307
- &[],
308
- );
309
- let spec = compile_team(&team).unwrap();
310
- assert_eq!(templated_compact_json(&spec), RUNTIME_DEFAULTS_JSON);
311
- }
312
-
313
- // TEAM provider_models do not fill a role whose model is omitted.
314
- const ALIAS_TEAM: &str = "\
315
- ---
316
- name: debate-team
317
- objective: Compile thin role docs.
318
- provider_models:
319
- claude: claude-sonnet-4-6
320
- default_auth_mode: subscription
321
- ---
322
-
323
- Team config.
324
- ";
325
-
326
- const ALIAS_ROLE: &str = "\
327
- ---
328
- name: editor
329
- role: Editor and Defender
330
- provider: claude_code
331
- tools:
332
- - mcp_team
333
- dangerously_skip_permissions: false
334
- ---
335
-
336
- Edit and defend the argument.
337
- ";
338
-
339
- const ALIAS_JSON: &str = r#"{"version":1,"team":{"name":"debate-team","mode":"supervisor_worker","objective":"Compile thin role docs.","workspace":"__WS__"},"leader":{"id":"leader","role":"leader","provider":"codex","model":null,"context_policy":{"keep_user_thread":true,"receive_worker_outputs":"business_messages_and_short_summaries","max_worker_result_tokens":2000}},"agents":[{"id":"editor","role":"Editor and Defender","provider":"claude_code","model":null,"auth_mode":"subscription","working_directory":"__WS__","system_prompt":{"inline":"Edit and defend the argument.","file":null},"dangerously_skip_permissions":false,"communication_mode":"leader_centric","preferred_for":["editor","Editor and Defender"],"avoid_for":[],"output_contract":{"format":"result_envelope_v1","required_fields":["task_id","status","summary","artifacts"]}}],"routing":{"default_assignee":"editor","rules":[{"id":"route-editor","match":{"assignee":["editor"]},"assign_to":"editor","priority":10}]},"communication":{"protocol":"mcp_inbox","topology":"leader_centered","worker_to_worker":true,"ack_timeout_sec":60,"result_format":"result_envelope_v1","message_store":{"sqlite":".team/runtime/team.db","mirror_files":".team/messages"}},"runtime":{"backend":"tmux","session_name":"team-debate-team","auto_launch":true,"require_user_approval_before_launch":true,"max_active_agents":1,"startup_order":["editor"],"fast":false,"tick_interval_sec":2,"push_min_interval_sec":60,"stuck_timeout_sec":300},"context":{"state_file":"team_state.md","artifact_dir":".team/artifacts","log_dir":".team/logs","summarization":{"worker_full_logs":"retain_outside_leader_context","state_update":"after_each_result"}},"tasks":[{"id":"task_initial","title":"Initial document-driven team task","type":"implementation","assignee":"editor","deps":[],"acceptance":["Worker reports valid result_envelope_v1"],"status":"pending","requires_tools":["mcp_team"],"files":[],"risk":"low"}]}"#;
340
-
341
- #[test]
342
- fn compile_provider_models_do_not_fill_claude_code_role_model() {
343
- let team = build_team(ALIAS_TEAM, &[("implementer.md", ALIAS_ROLE)], &[]);
344
- let spec = compile_team(&team).unwrap();
345
- // On unix a `claude_code` role compiles to the Claude Code contract leaf's id.
346
- let expected = if cfg!(unix) {
347
- ALIAS_JSON.replace(r#""provider":"claude_code""#, r#""provider":"claude_tui""#)
348
- } else {
349
- ALIAS_JSON.to_string()
350
- };
351
- assert_eq!(templated_compact_json(&spec), expected);
352
- }
353
-
354
- // Omitted role model remains null; the provider supplies its native default.
355
- const BUILTIN_TEAM: &str = "\
356
- ---
357
- name: default-model-team
358
- objective: Compile role docs without model fields.
359
- ---
360
-
361
- Team config.
362
- ";
363
-
364
- const BUILTIN_ROLE: &str = "\
365
- ---
366
- name: implementer
367
- role: Implementation Engineer
368
- provider: copilot
369
- auth_mode: subscription
370
- dangerously_skip_permissions: false
371
- tools:
372
- - mcp_team
373
- ---
374
-
375
- Implement bounded tasks.
376
- ";
377
-
378
- const BUILTIN_JSON: &str = r#"{"version":1,"team":{"name":"default-model-team","mode":"supervisor_worker","objective":"Compile role docs without model fields.","workspace":"__WS__"},"leader":{"id":"leader","role":"leader","provider":"codex","model":null,"context_policy":{"keep_user_thread":true,"receive_worker_outputs":"business_messages_and_short_summaries","max_worker_result_tokens":2000}},"agents":[{"id":"implementer","role":"Implementation Engineer","provider":"copilot","model":null,"auth_mode":"subscription","working_directory":"__WS__","system_prompt":{"inline":"Implement bounded tasks.","file":null},"dangerously_skip_permissions":false,"communication_mode":"leader_centric","preferred_for":["implementer","Implementation Engineer"],"avoid_for":[],"output_contract":{"format":"result_envelope_v1","required_fields":["task_id","status","summary","artifacts"]}}],"routing":{"default_assignee":"implementer","rules":[{"id":"route-implementer","match":{"assignee":["implementer"]},"assign_to":"implementer","priority":10}]},"communication":{"protocol":"mcp_inbox","topology":"leader_centered","worker_to_worker":true,"ack_timeout_sec":60,"result_format":"result_envelope_v1","message_store":{"sqlite":".team/runtime/team.db","mirror_files":".team/messages"}},"runtime":{"backend":"tmux","session_name":"team-default-model-team","auto_launch":true,"require_user_approval_before_launch":true,"max_active_agents":1,"startup_order":["implementer"],"fast":false,"tick_interval_sec":2,"push_min_interval_sec":60,"stuck_timeout_sec":300},"context":{"state_file":"team_state.md","artifact_dir":".team/artifacts","log_dir":".team/logs","summarization":{"worker_full_logs":"retain_outside_leader_context","state_update":"after_each_result"}},"tasks":[{"id":"task_initial","title":"Initial document-driven team task","type":"implementation","assignee":"implementer","deps":[],"acceptance":["Worker reports valid result_envelope_v1"],"status":"pending","requires_tools":["mcp_team"],"files":[],"risk":"low"}]}"#;
379
-
380
- #[test]
381
- fn compile_subscription_without_model_keeps_provider_native_default() {
382
- let team = build_team(BUILTIN_TEAM, &[("implementer.md", BUILTIN_ROLE)], &[]);
383
- let spec = compile_team(&team).unwrap();
384
- assert_eq!(templated_compact_json(&spec), BUILTIN_JSON);
385
- }
386
-
387
- // Two role docs sorted by FILENAME (01-alpha before 02-bravo though names alpha/bravo):
388
- // startup_order, routing rules (one per agent), default_assignee = first agent,
389
- // max_active_agents = min(len, 2).
390
- const TWO_ROLE_A: &str = "\
391
- ---
392
- name: alpha
393
- role: Alpha Worker
394
- provider: copilot
395
- model: gpt-5.5
396
- auth_mode: subscription
397
- dangerously_skip_permissions: false
398
- tools:
399
- - mcp_team
400
- ---
401
-
402
- Alpha body.
403
- ";
404
-
405
- const TWO_ROLE_B: &str = "\
406
- ---
407
- name: bravo
408
- role: Bravo Worker
409
- provider: copilot
410
- model: gpt-5.5
411
- auth_mode: subscription
412
- dangerously_skip_permissions: false
413
- tools:
414
- - mcp_team
415
- ---
416
-
417
- Bravo body.
418
- ";
419
-
420
- const TWO_AGENTS_JSON: &str = r#"{"version":1,"team":{"name":"doc-team","mode":"supervisor_worker","objective":"Compile role docs.","workspace":"__WS__"},"leader":{"id":"leader","role":"leader","provider":"codex","model":"gpt-5.5","context_policy":{"keep_user_thread":true,"receive_worker_outputs":"business_messages_and_short_summaries","max_worker_result_tokens":2000}},"agents":[{"id":"alpha","role":"Alpha Worker","provider":"copilot","model":"gpt-5.5","auth_mode":"subscription","working_directory":"__WS__","system_prompt":{"inline":"Alpha body.","file":null},"dangerously_skip_permissions":false,"communication_mode":"leader_centric","preferred_for":["alpha","Alpha Worker"],"avoid_for":[],"output_contract":{"format":"result_envelope_v1","required_fields":["task_id","status","summary","artifacts"]}},{"id":"bravo","role":"Bravo Worker","provider":"copilot","model":"gpt-5.5","auth_mode":"subscription","working_directory":"__WS__","system_prompt":{"inline":"Bravo body.","file":null},"dangerously_skip_permissions":false,"communication_mode":"leader_centric","preferred_for":["bravo","Bravo Worker"],"avoid_for":[],"output_contract":{"format":"result_envelope_v1","required_fields":["task_id","status","summary","artifacts"]}}],"routing":{"default_assignee":"alpha","rules":[{"id":"route-alpha","match":{"assignee":["alpha"]},"assign_to":"alpha","priority":10},{"id":"route-bravo","match":{"assignee":["bravo"]},"assign_to":"bravo","priority":10}]},"communication":{"protocol":"mcp_inbox","topology":"leader_centered","worker_to_worker":true,"ack_timeout_sec":60,"result_format":"result_envelope_v1","message_store":{"sqlite":".team/runtime/team.db","mirror_files":".team/messages"}},"runtime":{"backend":"tmux","session_name":"team-doc-team","auto_launch":true,"require_user_approval_before_launch":true,"max_active_agents":2,"startup_order":["alpha","bravo"],"fast":false,"tick_interval_sec":2,"push_min_interval_sec":60,"stuck_timeout_sec":300},"context":{"state_file":"team_state.md","artifact_dir":".team/artifacts","log_dir":".team/logs","summarization":{"worker_full_logs":"retain_outside_leader_context","state_update":"after_each_result"}},"tasks":[{"id":"task_initial","title":"Initial document-driven team task","type":"implementation","assignee":"alpha","deps":[],"acceptance":["Worker reports valid result_envelope_v1"],"status":"pending","requires_tools":["mcp_team"],"files":[],"risk":"low"}]}"#;
421
-
422
- #[test]
423
- fn compile_two_agents_sorted_by_filename_with_routing_and_startup_order() {
424
- // filenames intentionally out of name order to prove sorted(glob) is by filename.
425
- let team = build_team(
426
- TEAM_BASE,
427
- &[("02-bravo.md", TWO_ROLE_B), ("01-alpha.md", TWO_ROLE_A)],
428
- &[],
429
- );
430
- let spec = compile_team(&team).unwrap();
431
- assert_eq!(templated_compact_json(&spec), TWO_AGENTS_JSON);
432
- }
433
-
434
- // ───────────────────────────── compile_team: error paths ─────────────────────────────
435
-
436
- const ROLE_MISSING_PROVIDER: &str = "\
437
- ---
438
- name: implementer
439
- role: Implementation Engineer
440
- model: team-agent/qwen3.8-27b
441
- auth_mode: subscription
442
- dangerously_skip_permissions: false
443
- tools:
444
- - mcp_team
445
- ---
446
-
447
- Implement bounded tasks.
448
- ";
449
-
450
- #[test]
451
- fn compile_missing_provider_defaults_to_pi() {
452
- let team = build_team(TEAM_BASE, &[("implementer.md", ROLE_MISSING_PROVIDER)], &[]);
453
- let spec = compile_team(&team).expect("an omitted provider defaults to Pi");
454
- let agent = agent0(&spec);
455
- // On unix the default `pi` compiles to the Pi contract leaf's id.
456
- let expected = if cfg!(unix) { "pi_tui" } else { "pi" };
457
- assert_eq!(agent.get("provider"), Some(&Value::Str(expected.to_string())));
458
- assert_eq!(
459
- agent.get("model"),
460
- Some(&Value::Str("team-agent/qwen3.8-27b".to_string()))
461
- );
462
- }
463
-
464
- const ROLE_COMPATIBLE_NO_PROFILE: &str = "\
465
- ---
466
- name: implementer
467
- role: Implementation Engineer
468
- provider: codex
469
- model: gpt-5.5
470
- auth_mode: compatible_api
471
- dangerously_skip_permissions: false
472
- tools:
473
- - mcp_team
474
- ---
475
-
476
- Implement bounded tasks.
477
- ";
478
-
479
- #[test]
480
- fn compile_compatible_api_without_profile_errors() {
481
- let team = build_team(
482
- TEAM_BASE,
483
- &[("implementer.md", ROLE_COMPATIBLE_NO_PROFILE)],
484
- &[],
485
- );
486
- let err = compile_team(&team).unwrap_err();
487
- assert!(
488
- err.to_string().contains("profile is required"),
489
- "got: {err}"
490
- );
491
- }
492
-
493
- // ════════════════════════ FIX-LOOP (wave-1) RED tests ════════════════════════
494
- // The first-round fixtures under-specified the contract. These lock the CORRECT
495
- // Python v0.2.11 behavior; each FAILS against the current (too-narrow) impl.
496
- // Golden re-probed via /tmp/probe_fix.py against team-agent-public v0.2.11.
497
-
498
- const TM_CODEX: &str = "---\nname: T\nprovider: codex\n---\nx\n";
499
-
500
- fn role_nomodel(provider: &str) -> String {
501
- format!("---\nname: w\nrole: R\nprovider: {provider}\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nbody\n")
502
- }
503
-
504
- fn agent0(spec: &Value) -> &Value {
505
- match spec.get("agents") {
506
- Some(Value::List(items)) if !items.is_empty() => &items[0],
507
- _ => panic!("spec.agents missing/empty"),
508
- }
509
- }
510
-
511
- fn get_path<'a>(v: &'a Value, keys: &[&str]) -> Option<&'a Value> {
512
- let mut cur = v;
513
- for k in keys {
514
- cur = cur.get(k)?;
515
- }
516
- Some(cur)
517
- }
518
-
519
- fn str_path(spec: &Value, keys: &[&str]) -> String {
520
- get_path(spec, keys)
521
- .and_then(Value::as_str)
522
- .unwrap_or_else(|| panic!("missing string at {keys:?}"))
523
- .to_string()
524
- }
525
-
526
- enum AgentsDir<'a> {
527
- Missing,
528
- File,
529
- WithRole(&'a str),
530
- }
531
-
532
- /// Build `<base>/<parent>/<leaf>/` with optional TEAM.md and a controllable
533
- /// `agents` entry — lets tests pin `team_dir.parent.name` (A3) and the
534
- /// missing-TEAM.md / missing-agents / agents-is-a-file error paths (A11).
535
- fn build_layout(parent: &str, leaf: &str, team_md: Option<&str>, agents: AgentsDir<'_>) -> PathBuf {
536
- let team = unique_base().join(parent).join(leaf);
537
- fs::create_dir_all(&team).unwrap();
538
- if let Some(md) = team_md {
539
- fs::write(team.join("TEAM.md"), md).unwrap();
540
- }
541
- match agents {
542
- AgentsDir::Missing => {}
543
- AgentsDir::File => fs::write(team.join("agents"), "not a dir").unwrap(),
544
- AgentsDir::WithRole(role) => {
545
- fs::create_dir_all(team.join("agents")).unwrap();
546
- fs::write(team.join("agents").join("w.md"), role).unwrap();
547
- }
548
- }
549
- team
550
- }
551
-
552
- // ── A1 model resolution ──
553
-
554
- #[test]
555
- fn team_model_defaults_do_not_fill_role_model() {
556
- // TEAM default_model and provider_models are not implicit role settings.
557
- let tm = "---\nname: T\nprovider: codex\ndefault_model: team-y\nprovider_models:\n codex: pm-z\n---\nx\n";
558
- let team = build_team(tm, &[("w.md", &role_nomodel("codex"))], &[]);
559
- let spec = compile_team(&team).unwrap();
560
- assert_eq!(agent0(&spec).get("model"), Some(&Value::Null));
561
- }
562
-
563
- #[test]
564
- fn team_provider_model_aliases_do_not_fill_role_model() {
565
- // TEAM provider-model aliases do not affect an omitted role model.
566
- let tm = "---\nname: T\nprovider: codex\nprovider_models:\n claude_code: cc-v\n---\nx\n";
567
- let team = build_team(tm, &[("w.md", &role_nomodel("claude"))], &[]);
568
- let spec = compile_team(&team).unwrap();
569
- assert_eq!(agent0(&spec).get("model"), Some(&Value::Null));
570
- }
571
-
572
- #[test]
573
- fn claude_role_without_model_keeps_provider_native_default() {
574
- // A missing explicit model stays null for both Claude provider names, each
575
- // of which compiles to the Claude Code contract leaf on unix.
576
- for prov in ["claude", "claude_code"] {
577
- let team = build_team(TM_CODEX, &[("w.md", &role_nomodel(prov))], &[]);
578
- let spec = compile_team(&team).unwrap();
579
- assert_eq!(
580
- agent0(&spec).get("model"),
581
- Some(&Value::Null),
582
- "provider {prov}"
583
- );
584
- let expected = if cfg!(unix) { "claude_tui" } else { prov };
585
- assert_eq!(
586
- agent0(&spec).get("provider").and_then(Value::as_str),
587
- Some(expected),
588
- "provider {prov}"
589
- );
590
- }
591
- }
592
-
593
- #[test]
594
- fn fix_a1_model_null_when_provider_absent_from_table() {
595
- // gemini_cli / fake have NO builtin default → model MUST be emitted as null.
596
- for prov in ["gemini_cli", "fake"] {
597
- let team = build_team(TM_CODEX, &[("w.md", &role_nomodel(prov))], &[]);
598
- let spec = compile_team(&team).unwrap();
599
- assert_eq!(
600
- agent0(&spec).get("model"),
601
- Some(&Value::Null),
602
- "provider {prov} → null"
603
- );
604
- }
605
- }
606
-
607
- // ── A2 objective ──
608
-
609
- #[test]
610
- fn fix_a2_objective_falls_back_to_body() {
611
- let tm = "---\nname: T\nprovider: codex\n---\nThis is the body.\n";
612
- let team = build_team(tm, &[("w.md", &role_nomodel("codex"))], &[]);
613
- let spec = compile_team(&team).unwrap();
614
- assert_eq!(str_path(&spec, &["team", "objective"]), "This is the body.");
615
- }
616
-
617
- #[test]
618
- fn fix_a2_objective_default_when_no_objective_and_no_body() {
619
- let tm = "---\nname: T\nprovider: codex\n---\n";
620
- let team = build_team(tm, &[("w.md", &role_nomodel("codex"))], &[]);
621
- let spec = compile_team(&team).unwrap();
622
- assert_eq!(
623
- str_path(&spec, &["team", "objective"]),
624
- "Team Agent document-driven team."
625
- );
626
- }
627
-
628
- // ── A3 name ──
629
-
630
- #[test]
631
- fn fix_a3_name_falls_back_to_parent_dir_name() {
632
- // no `name` → team_dir.parent.name (NOT a hardcoded "team").
633
- let tm = "---\nprovider: codex\n---\nx\n";
634
- let team = build_layout(
635
- "my-parent-dir",
636
- "leafteam",
637
- Some(tm),
638
- AgentsDir::WithRole(&role_nomodel("codex")),
639
- );
640
- let spec = compile_team(&team).unwrap();
641
- assert_eq!(str_path(&spec, &["team", "name"]), "my-parent-dir");
642
- }
643
-
644
- // ── A4 leader.role ──
645
-
646
- #[test]
647
- fn fix_a4_leader_role_from_team_meta() {
648
- let tm = "---\nname: T\nprovider: codex\nleader_role: Captain\n---\nx\n";
649
- let team = build_team(tm, &[("w.md", &role_nomodel("codex"))], &[]);
650
- let spec = compile_team(&team).unwrap();
651
- assert_eq!(str_path(&spec, &["leader", "role"]), "Captain");
652
- }
653
-
654
- // ── A5 session_name + _slug ──
655
-
656
- #[test]
657
- fn fix_a5_session_name_slugifies_team_name() {
658
- // "My Team!" → _slug → "My-Team" → "team-My-Team".
659
- let tm = "---\nname: My Team!\nprovider: codex\n---\nx\n";
660
- let team = build_team(tm, &[("w.md", &role_nomodel("codex"))], &[]);
661
- let spec = compile_team(&team).unwrap();
662
- assert_eq!(
663
- str_path(&spec, &["runtime", "session_name"]),
664
- "team-My-Team"
665
- );
666
- }
667
-
668
- #[test]
669
- fn fix_a5_session_name_override_wins() {
670
- let tm = "---\nname: My Team!\nprovider: codex\nsession_name: custom-sess\n---\nx\n";
671
- let team = build_team(tm, &[("w.md", &role_nomodel("codex"))], &[]);
672
- let spec = compile_team(&team).unwrap();
673
- assert_eq!(str_path(&spec, &["runtime", "session_name"]), "custom-sess");
674
- }
675
-
676
- // ── A6 tools ──
677
-
678
- #[test]
679
- fn fix_a6_tools_are_transparent_compatibility_metadata() {
680
- let role = "---\nname: w\nrole: R\nprovider: codex\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - shell\n - provider_builtin\n---\nb\n";
681
- let team = build_team(TM_CODEX, &[("w.md", role)], &[]);
682
- let spec = compile_team(&team).expect("tools metadata must not gate compilation");
683
- assert!(agent0(&spec).get("tools").is_none());
684
- }
685
-
686
- #[test]
687
- fn fix_a6_missing_tools_is_allowed() {
688
- let role = "---\nname: w\nrole: R\nprovider: codex\nauth_mode: subscription\ndangerously_skip_permissions: false\n---\nb\n";
689
- let team = build_team(TM_CODEX, &[("w.md", role)], &[]);
690
- compile_team(&team).expect("omitted tools metadata must compile");
691
- }
692
-
693
- #[test]
694
- fn fix_a6_tools_non_list_is_transparent() {
695
- let role = "---\nname: w\nrole: R\nprovider: codex\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools: justastring\n---\nb\n";
696
- let team = build_team(TM_CODEX, &[("w.md", role)], &[]);
697
- compile_team(&team).expect("any YAML tools metadata must compile");
698
- }
699
-
700
- // ── A7 system_prompt inline ──
701
-
702
- #[test]
703
- fn fix_a7_empty_body_inline_falls_back_to_role() {
704
- let role = "---\nname: w\nrole: Reviewer Role\nprovider: codex\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n";
705
- let team = build_team(TM_CODEX, &[("w.md", role)], &[]);
706
- let spec = compile_team(&team).unwrap();
707
- assert_eq!(
708
- str_path(agent0(&spec), &["system_prompt", "inline"]),
709
- "Reviewer Role"
710
- );
711
- }
712
-
713
- // ── A8 auth_mode ──
714
-
715
- #[test]
716
- fn fix_a8_official_api_without_profile_errors() {
717
- // official_api (any non-subscription) without profile MUST NOT silently compile.
718
- let role = "---\nname: w\nrole: R\nprovider: codex\nauth_mode: official_api\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\nb\n";
719
- let team = build_team(TM_CODEX, &[("w.md", role)], &[]);
720
- let err = compile_team(&team).unwrap_err();
721
- assert!(
722
- err.to_string()
723
- .contains("profile is required when auth_mode is 'official_api'"),
724
- "got: {err}"
725
- );
726
- }
727
-
728
- #[test]
729
- fn fix_a8_compatible_api_error_names_the_auth_mode() {
730
- // Full message form (the old test only checked the "profile is required" prefix).
731
- let team = build_team(
732
- TEAM_BASE,
733
- &[("implementer.md", ROLE_COMPATIBLE_NO_PROFILE)],
734
- &[],
735
- );
736
- let err = compile_team(&team).unwrap_err();
737
- assert!(
738
- err.to_string()
739
- .contains("profile is required when auth_mode is 'compatible_api'"),
740
- "got: {err}"
741
- );
742
- }
743
-
744
- // ── A9 bool/int coercion (Python bool()/int() over the simple_yaml value) ──
745
-
746
- #[test]
747
- fn fix_a9_bool_coercion_yes_and_one_are_true() {
748
- for v in ["yes", "1"] {
749
- let tm = format!("---\nname: T\nprovider: codex\nworker_to_worker: {v}\n---\nx\n");
750
- let team = build_team(&tm, &[("w.md", &role_nomodel("codex"))], &[]);
751
- let spec = compile_team(&team).unwrap();
752
- assert_eq!(
753
- get_path(&spec, &["communication", "worker_to_worker"]),
754
- Some(&Value::Bool(true)),
755
- "value {v}"
756
- );
757
- }
758
- }
759
-
760
- #[test]
761
- fn fix_a9_bool_coercion_no_is_python_truthy() {
762
- // FLAG: Python bool("no") is TRUE (only 0/false/False are falsy). The contract
763
- // note said "no->false" but Python golden is no->true; we lock Python.
764
- let tm = "---\nname: T\nprovider: codex\nworker_to_worker: no\n---\nx\n";
765
- let team = build_team(tm, &[("w.md", &role_nomodel("codex"))], &[]);
766
- let spec = compile_team(&team).unwrap();
767
- assert_eq!(
768
- get_path(&spec, &["communication", "worker_to_worker"]),
769
- Some(&Value::Bool(true))
770
- );
771
- }
772
-
773
- #[test]
774
- fn fix_a9_int_coercion_of_quoted_string() {
775
- // tick_interval_sec: "5" (a YAML string) → int("5") = 5.
776
- let tm = "---\nname: T\nprovider: codex\ntick_interval_sec: \"5\"\n---\nx\n";
777
- let team = build_team(tm, &[("w.md", &role_nomodel("codex"))], &[]);
778
- let spec = compile_team(&team).unwrap();
779
- assert_eq!(
780
- get_path(&spec, &["runtime", "tick_interval_sec"]),
781
- Some(&Value::Int(5))
782
- );
783
- }
784
-
785
- // ── A10 CRLF normalization ──
786
-
787
- #[test]
788
- fn fix_a10_crlf_role_doc_front_matter_is_parsed() {
789
- // Windows-authored \r\n doc: read_text universal-newlines normalizes before
790
- // the "---\n" check, so the front matter parses (current keeps \r\n → no FM).
791
- let crlf_role = "---\r\nname: crlfworker\r\nrole: R\r\nprovider: codex\r\nauth_mode: subscription\r\ndangerously_skip_permissions: false\r\ntools:\r\n - mcp_team\r\n---\r\n\r\nbody\r\n";
792
- let team = build_team(TM_CODEX, &[("w.md", crlf_role)], &[]);
793
- let spec = compile_team(&team).expect("CRLF role doc must parse its front matter");
794
- assert_eq!(
795
- agent0(&spec).get("id").and_then(Value::as_str),
796
- Some("crlfworker")
797
- );
798
- assert_eq!(
799
- str_path(agent0(&spec), &["system_prompt", "inline"]),
800
- "body"
801
- );
802
- }
803
-
804
- // ── A11 error-message paths ──
805
-
806
- #[test]
807
- fn fix_a11_missing_team_md_message_includes_team_md_path() {
808
- let team = build_layout(
809
- "p",
810
- "teamdir",
811
- None,
812
- AgentsDir::WithRole(&role_nomodel("codex")),
813
- );
814
- let err = compile_team(&team).unwrap_err();
815
- assert!(
816
- err.to_string().contains("/TEAM.md: missing TEAM.md"),
817
- "got: {err}"
818
- );
819
- }
820
-
821
- #[test]
822
- fn fix_a11_missing_agents_dir_message_includes_agents_path() {
823
- let team = build_layout("p", "teamdir", Some(TM_CODEX), AgentsDir::Missing);
824
- let err = compile_team(&team).unwrap_err();
825
- assert!(
826
- err.to_string()
827
- .contains("/agents: missing agents directory"),
828
- "got: {err}"
829
- );
830
- }
831
-
832
- #[test]
833
- fn fix_a11_agents_is_a_file_reports_no_role_docs() {
834
- // Python uses exists() (not is_dir()): agents-as-a-file passes the existence
835
- // gate, then the empty glob → "no role docs found" (path = agents dir).
836
- let team = build_layout("p", "teamdir", Some(TM_CODEX), AgentsDir::File);
837
- let err = compile_team(&team).unwrap_err();
838
- assert!(
839
- err.to_string().contains("/agents: no role docs found"),
840
- "got: {err}"
841
- );
842
- }