@team-agent/installer 0.5.128 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (436) hide show
  1. package/README.md +4 -4
  2. package/README.zh.md +1 -1
  3. package/package.json +4 -8
  4. package/skills/team-agent/SKILL.md +37 -20
  5. package/skills/team-agent/command-coverage.json +169 -183
  6. package/skills/team-agent/docs/reference/team-agent-operator.md +64 -30
  7. package/skills/team-agent/references/recovery-runbook.md +1 -1
  8. package/skills/team-agent/references/team-agent-operator.md +64 -30
  9. package/templates/team_state.md +1 -1
  10. package/Cargo.lock +0 -1063
  11. package/Cargo.toml +0 -36
  12. package/crates/team-agent/Cargo.toml +0 -69
  13. package/crates/team-agent/src/app_server_test_support.rs +0 -258
  14. package/crates/team-agent/src/cli/adapters.rs +0 -1288
  15. package/crates/team-agent/src/cli/arguments.rs +0 -405
  16. package/crates/team-agent/src/cli/attach_app_server_leader.rs +0 -98
  17. package/crates/team-agent/src/cli/diagnose.rs +0 -1721
  18. package/crates/team-agent/src/cli/emit.rs +0 -2930
  19. package/crates/team-agent/src/cli/grok_slot.rs +0 -384
  20. package/crates/team-agent/src/cli/helpers.rs +0 -91
  21. package/crates/team-agent/src/cli/intent/runtime.rs +0 -1216
  22. package/crates/team-agent/src/cli/intent/runtime_tests.rs +0 -912
  23. package/crates/team-agent/src/cli/intent/tests.rs +0 -689
  24. package/crates/team-agent/src/cli/intent.rs +0 -664
  25. package/crates/team-agent/src/cli/leader.rs +0 -300
  26. package/crates/team-agent/src/cli/leader_prompt.rs +0 -261
  27. package/crates/team-agent/src/cli/leaders.rs +0 -418
  28. package/crates/team-agent/src/cli/mod.rs +0 -6545
  29. package/crates/team-agent/src/cli/models.rs +0 -1206
  30. package/crates/team-agent/src/cli/named_address.rs +0 -1651
  31. package/crates/team-agent/src/cli/profile.rs +0 -342
  32. package/crates/team-agent/src/cli/route.rs +0 -212
  33. package/crates/team-agent/src/cli/schedule.rs +0 -175
  34. package/crates/team-agent/src/cli/send/coordinator.rs +0 -164
  35. package/crates/team-agent/src/cli/send/mailbox.rs +0 -145
  36. package/crates/team-agent/src/cli/send/persist.rs +0 -156
  37. package/crates/team-agent/src/cli/send/presentation.rs +0 -370
  38. package/crates/team-agent/src/cli/send/resolve.rs +0 -573
  39. package/crates/team-agent/src/cli/send.rs +0 -199
  40. package/crates/team-agent/src/cli/shutdown_socket.rs +0 -288
  41. package/crates/team-agent/src/cli/spec.rs +0 -165
  42. package/crates/team-agent/src/cli/status.rs +0 -280
  43. package/crates/team-agent/src/cli/status_port/agents.rs +0 -358
  44. package/crates/team-agent/src/cli/status_port/approvals.rs +0 -79
  45. package/crates/team-agent/src/cli/status_port/brief.rs +0 -1981
  46. package/crates/team-agent/src/cli/status_port/compact.rs +0 -240
  47. package/crates/team-agent/src/cli/status_port/format.rs +0 -146
  48. package/crates/team-agent/src/cli/status_port/inbox.rs +0 -62
  49. package/crates/team-agent/src/cli/status_port/runtime.rs +0 -197
  50. package/crates/team-agent/src/cli/status_port/snapshot.rs +0 -208
  51. package/crates/team-agent/src/cli/status_port/store.rs +0 -416
  52. package/crates/team-agent/src/cli/status_port/tests.rs +0 -90
  53. package/crates/team-agent/src/cli/status_port.rs +0 -92
  54. package/crates/team-agent/src/cli/tests/base.rs +0 -885
  55. package/crates/team-agent/src/cli/tests/divergence.rs +0 -518
  56. package/crates/team-agent/src/cli/tests/lane_c.rs +0 -453
  57. package/crates/team-agent/src/cli/tests/leader_watch.rs +0 -322
  58. package/crates/team-agent/src/cli/tests/main_preserved.rs +0 -430
  59. package/crates/team-agent/src/cli/tests/missing_subcommands.rs +0 -336
  60. package/crates/team-agent/src/cli/tests/mod.rs +0 -137
  61. package/crates/team-agent/src/cli/tests/named_address.rs +0 -761
  62. package/crates/team-agent/src/cli/tests/parser_safety.rs +0 -383
  63. package/crates/team-agent/src/cli/tests/run_delegation.rs +0 -484
  64. package/crates/team-agent/src/cli/tests/shutdown_kill_plan.rs +0 -2179
  65. package/crates/team-agent/src/cli/tests/status_brief.rs +0 -1514
  66. package/crates/team-agent/src/cli/tests/status_send.rs +0 -888
  67. package/crates/team-agent/src/cli/tests/verb_install_skill.rs +0 -93
  68. package/crates/team-agent/src/cli/tests/verb_profile.rs +0 -392
  69. package/crates/team-agent/src/cli/triage.rs +0 -234
  70. package/crates/team-agent/src/cli/types.rs +0 -591
  71. package/crates/team-agent/src/codex_app_server.rs +0 -546
  72. package/crates/team-agent/src/communication_mode/mod.rs +0 -56
  73. package/crates/team-agent/src/compiler/tests.rs +0 -827
  74. package/crates/team-agent/src/compiler.rs +0 -890
  75. package/crates/team-agent/src/conpty/backend.rs +0 -829
  76. package/crates/team-agent/src/conpty/mod.rs +0 -33
  77. package/crates/team-agent/src/contract_runtime/backend.rs +0 -1744
  78. package/crates/team-agent/src/contract_runtime/commands.rs +0 -671
  79. package/crates/team-agent/src/contract_runtime/config.rs +0 -364
  80. package/crates/team-agent/src/contract_runtime/config_tests.rs +0 -76
  81. package/crates/team-agent/src/contract_runtime/discovery.rs +0 -449
  82. package/crates/team-agent/src/contract_runtime/fork.rs +0 -361
  83. package/crates/team-agent/src/contract_runtime/forward.rs +0 -288
  84. package/crates/team-agent/src/contract_runtime/framework.rs +0 -367
  85. package/crates/team-agent/src/contract_runtime/mcp.rs +0 -394
  86. package/crates/team-agent/src/contract_runtime/mod.rs +0 -17
  87. package/crates/team-agent/src/contract_runtime/prompt.rs +0 -216
  88. package/crates/team-agent/src/contract_runtime/pump.rs +0 -271
  89. package/crates/team-agent/src/contract_runtime/registry.rs +0 -553
  90. package/crates/team-agent/src/contract_runtime/workspace.rs +0 -228
  91. package/crates/team-agent/src/coordinator/backoff.rs +0 -741
  92. package/crates/team-agent/src/coordinator/conpty_shim.rs +0 -805
  93. package/crates/team-agent/src/coordinator/health.rs +0 -1185
  94. package/crates/team-agent/src/coordinator/mod.rs +0 -119
  95. package/crates/team-agent/src/coordinator/orphan.rs +0 -110
  96. package/crates/team-agent/src/coordinator/runtime_detectors.rs +0 -798
  97. package/crates/team-agent/src/coordinator/runtime_observation.rs +0 -84
  98. package/crates/team-agent/src/coordinator/steps/abnormal.rs +0 -2309
  99. package/crates/team-agent/src/coordinator/steps/delivery.rs +0 -15
  100. package/crates/team-agent/src/coordinator/steps/health_sync.rs +0 -15
  101. package/crates/team-agent/src/coordinator/steps/mod.rs +0 -126
  102. package/crates/team-agent/src/coordinator/steps/persist.rs +0 -15
  103. package/crates/team-agent/src/coordinator/steps/runtime_prompts.rs +0 -15
  104. package/crates/team-agent/src/coordinator/steps/session_gate.rs +0 -16
  105. package/crates/team-agent/src/coordinator/tests/a0_lostupdate.rs +0 -158
  106. package/crates/team-agent/src/coordinator/tests/abnormal.rs +0 -312
  107. package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +0 -300
  108. package/crates/team-agent/src/coordinator/tests/basics.rs +0 -211
  109. package/crates/team-agent/src/coordinator/tests/daemon.rs +0 -514
  110. package/crates/team-agent/src/coordinator/tests/energy.rs +0 -549
  111. package/crates/team-agent/src/coordinator/tests/health_sync.rs +0 -503
  112. package/crates/team-agent/src/coordinator/tests/main_preserved.rs +0 -186
  113. package/crates/team-agent/src/coordinator/tests/mod.rs +0 -295
  114. package/crates/team-agent/src/coordinator/tests/s3_bounded.rs +0 -207
  115. package/crates/team-agent/src/coordinator/tests/spine.rs +0 -308
  116. package/crates/team-agent/src/coordinator/tests/takeover.rs +0 -286
  117. package/crates/team-agent/src/coordinator/tests/tick_core.rs +0 -237
  118. package/crates/team-agent/src/coordinator/tick.rs +0 -3024
  119. package/crates/team-agent/src/coordinator/types.rs +0 -540
  120. package/crates/team-agent/src/db/agent_health_capture.rs +0 -126
  121. package/crates/team-agent/src/db/message_store.rs +0 -1527
  122. package/crates/team-agent/src/db/migration.rs +0 -984
  123. package/crates/team-agent/src/db/mod.rs +0 -26
  124. package/crates/team-agent/src/db/schema.rs +0 -663
  125. package/crates/team-agent/src/diagnose/comms.rs +0 -242
  126. package/crates/team-agent/src/diagnose/mod.rs +0 -44
  127. package/crates/team-agent/src/diagnose/orphans.rs +0 -889
  128. package/crates/team-agent/src/direct_delivery.rs +0 -368
  129. package/crates/team-agent/src/event_log.rs +0 -502
  130. package/crates/team-agent/src/fake_worker.rs +0 -303
  131. package/crates/team-agent/src/inbox_store.rs +0 -169
  132. package/crates/team-agent/src/kill_audit.rs +0 -106
  133. package/crates/team-agent/src/layout/manager.rs +0 -248
  134. package/crates/team-agent/src/layout/mod.rs +0 -36
  135. package/crates/team-agent/src/layout/overlay.rs +0 -134
  136. package/crates/team-agent/src/layout/placement.rs +0 -52
  137. package/crates/team-agent/src/layout/recovery.rs +0 -106
  138. package/crates/team-agent/src/layout/runtime_sessions.rs +0 -317
  139. package/crates/team-agent/src/layout/sessions.rs +0 -294
  140. package/crates/team-agent/src/layout/tmux_endpoint.rs +0 -165
  141. package/crates/team-agent/src/layout/worker_env.rs +0 -721
  142. package/crates/team-agent/src/layout/worker_window_helpers.rs +0 -37
  143. package/crates/team-agent/src/leader/helpers.rs +0 -178
  144. package/crates/team-agent/src/leader/incident.rs +0 -6
  145. package/crates/team-agent/src/leader/lease.rs +0 -3356
  146. package/crates/team-agent/src/leader/mod.rs +0 -104
  147. package/crates/team-agent/src/leader/owner_bind.rs +0 -400
  148. package/crates/team-agent/src/leader/prompt.rs +0 -905
  149. package/crates/team-agent/src/leader/provider_attribution.rs +0 -247
  150. package/crates/team-agent/src/leader/rediscover/tests.rs +0 -689
  151. package/crates/team-agent/src/leader/rediscover.rs +0 -1192
  152. package/crates/team-agent/src/leader/registry.rs +0 -888
  153. package/crates/team-agent/src/leader/start.rs +0 -4501
  154. package/crates/team-agent/src/leader/takeover.rs +0 -65
  155. package/crates/team-agent/src/leader/tests/basics.rs +0 -337
  156. package/crates/team-agent/src/leader/tests/byte_findings.rs +0 -355
  157. package/crates/team-agent/src/leader/tests/claim_leader_mailbox_flush_contract.rs +0 -544
  158. package/crates/team-agent/src/leader/tests/historical_inventory_upgrade_gate_red.rs +0 -624
  159. package/crates/team-agent/src/leader/tests/identity.rs +0 -465
  160. package/crates/team-agent/src/leader/tests/identity_session_names.rs +0 -42
  161. package/crates/team-agent/src/leader/tests/idle.rs +0 -113
  162. package/crates/team-agent/src/leader/tests/lease_api.rs +0 -520
  163. package/crates/team-agent/src/leader/tests/lease_claim.rs +0 -629
  164. package/crates/team-agent/src/leader/tests/mod.rs +0 -106
  165. package/crates/team-agent/src/leader/tests/prompt_contract.rs +0 -268
  166. package/crates/team-agent/src/leader/tests/rediscover.rs +0 -403
  167. package/crates/team-agent/src/leader/tests/rehomed_env.rs +0 -83
  168. package/crates/team-agent/src/leader/tests/team_in_team_state_scope_red.rs +0 -1273
  169. package/crates/team-agent/src/leader/tests/terminal_and_replay_vs_rerender_invariants_red.rs +0 -417
  170. package/crates/team-agent/src/leader/tests/wake_start_owner.rs +0 -168
  171. package/crates/team-agent/src/leader/types.rs +0 -534
  172. package/crates/team-agent/src/lib.rs +0 -147
  173. package/crates/team-agent/src/lifecycle/helpers.rs +0 -212
  174. package/crates/team-agent/src/lifecycle/launch/add_agent.rs +0 -881
  175. package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +0 -598
  176. package/crates/team-agent/src/lifecycle/launch/agent_state.rs +0 -332
  177. package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +0 -204
  178. package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +0 -107
  179. package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +0 -144
  180. package/crates/team-agent/src/lifecycle/launch/identity.rs +0 -674
  181. package/crates/team-agent/src/lifecycle/launch/layout.rs +0 -350
  182. package/crates/team-agent/src/lifecycle/launch/leader_context.rs +0 -589
  183. package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +0 -160
  184. package/crates/team-agent/src/lifecycle/launch/ownership.rs +0 -105
  185. package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +0 -899
  186. package/crates/team-agent/src/lifecycle/launch/pi_mcp_extension.js +0 -225
  187. package/crates/team-agent/src/lifecycle/launch/plan.rs +0 -269
  188. package/crates/team-agent/src/lifecycle/launch/quick_start.rs +0 -5200
  189. package/crates/team-agent/src/lifecycle/launch/quick_start_transport.rs +0 -368
  190. package/crates/team-agent/src/lifecycle/launch/readiness.rs +0 -519
  191. package/crates/team-agent/src/lifecycle/launch/role_source.rs +0 -287
  192. package/crates/team-agent/src/lifecycle/launch/spawn.rs +0 -473
  193. package/crates/team-agent/src/lifecycle/launch/spec_state.rs +0 -801
  194. package/crates/team-agent/src/lifecycle/launch/state_projection.rs +0 -624
  195. package/crates/team-agent/src/lifecycle/launch/worker_env.rs +0 -558
  196. package/crates/team-agent/src/lifecycle/launch.rs +0 -557
  197. package/crates/team-agent/src/lifecycle/lock.rs +0 -350
  198. package/crates/team-agent/src/lifecycle/mod.rs +0 -79
  199. package/crates/team-agent/src/lifecycle/pane_input_lock.rs +0 -239
  200. package/crates/team-agent/src/lifecycle/profile_launch.rs +0 -1067
  201. package/crates/team-agent/src/lifecycle/profile_smoke.rs +0 -557
  202. package/crates/team-agent/src/lifecycle/restart/agent.rs +0 -2199
  203. package/crates/team-agent/src/lifecycle/restart/avatar.rs +0 -1798
  204. package/crates/team-agent/src/lifecycle/restart/claude_fork.rs +0 -163
  205. package/crates/team-agent/src/lifecycle/restart/common.rs +0 -2362
  206. package/crates/team-agent/src/lifecycle/restart/orchestrator.rs +0 -65
  207. package/crates/team-agent/src/lifecycle/restart/preflight.rs +0 -113
  208. package/crates/team-agent/src/lifecycle/restart/rebuild.rs +0 -5135
  209. package/crates/team-agent/src/lifecycle/restart/remove.rs +0 -1504
  210. package/crates/team-agent/src/lifecycle/restart/selection.rs +0 -559
  211. package/crates/team-agent/src/lifecycle/restart/team_state.rs +0 -329
  212. package/crates/team-agent/src/lifecycle/restart.rs +0 -227
  213. package/crates/team-agent/src/lifecycle/role_config.rs +0 -1230
  214. package/crates/team-agent/src/lifecycle/tests/acceptance_b_batch_red.rs +0 -1021
  215. package/crates/team-agent/src/lifecycle/tests/agent_ops.rs +0 -1205
  216. package/crates/team-agent/src/lifecycle/tests/b0_legacy_snapshot_nonauthority_contract.rs +0 -265
  217. package/crates/team-agent/src/lifecycle/tests/b0_reader_hideone_audit_contract.rs +0 -490
  218. package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +0 -656
  219. package/crates/team-agent/src/lifecycle/tests/claude_compatible_config_red.rs +0 -325
  220. package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +0 -447
  221. package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +0 -1638
  222. package/crates/team-agent/src/lifecycle/tests/clone_agent_preserves_source_tools.rs +0 -427
  223. package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +0 -770
  224. package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +0 -419
  225. package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +0 -2035
  226. package/crates/team-agent/src/lifecycle/tests/core.rs +0 -1327
  227. package/crates/team-agent/src/lifecycle/tests/f032_startup_prompt_best_effort_red.rs +0 -315
  228. package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_g0.stdout.txt +0 -222
  229. package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_spaced_ids.stdout.txt +0 -9
  230. package/crates/team-agent/src/lifecycle/tests/fixtures/pi_native_mcp_host.mjs +0 -72
  231. package/crates/team-agent/src/lifecycle/tests/gate_fixtures.rs +0 -562
  232. package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +0 -110
  233. package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +0 -512
  234. package/crates/team-agent/src/lifecycle/tests/host_cotenant_death_p0_contract.rs +0 -921
  235. package/crates/team-agent/src/lifecycle/tests/issue238_codex_effort_contract.rs +0 -68
  236. package/crates/team-agent/src/lifecycle/tests/lane_ops.rs +0 -1851
  237. package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +0 -3983
  238. package/crates/team-agent/src/lifecycle/tests/lifecycle_lock.rs +0 -339
  239. package/crates/team-agent/src/lifecycle/tests/lifecycle_rollback_red.rs +0 -596
  240. package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +0 -513
  241. package/crates/team-agent/src/lifecycle/tests/mcp_tool_name_format_red.rs +0 -69
  242. package/crates/team-agent/src/lifecycle/tests/phase_b_contracts.rs +0 -824
  243. package/crates/team-agent/src/lifecycle/tests/phase_golden.rs +0 -723
  244. package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +0 -164
  245. package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +0 -200
  246. package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +0 -210
  247. package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +0 -527
  248. package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +0 -1062
  249. package/crates/team-agent/src/lifecycle/tests/pi_fork_session_inheritance_red.rs +0 -1419
  250. package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +0 -98
  251. package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +0 -550
  252. package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +0 -226
  253. package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +0 -332
  254. package/crates/team-agent/src/lifecycle/tests/realmachine_clusters_1_6_red.rs +0 -786
  255. package/crates/team-agent/src/lifecycle/tests/realmachine_residual_g1_g4_red.rs +0 -648
  256. package/crates/team-agent/src/lifecycle/tests/restart.rs +0 -185
  257. package/crates/team-agent/src/lifecycle/tests/restart_build_before_destroy_0540_contract.rs +0 -1053
  258. package/crates/team-agent/src/lifecycle/tests/restart_liveness_red.rs +0 -679
  259. package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +0 -1126
  260. package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +0 -153
  261. package/crates/team-agent/src/lifecycle/tests/resume_recover_red.rs +0 -427
  262. package/crates/team-agent/src/lifecycle/tests/stale_team_saveconflict_contract.rs +0 -431
  263. package/crates/team-agent/src/lifecycle/tests/startup_latency_contract.rs +0 -1066
  264. package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +0 -876
  265. package/crates/team-agent/src/lifecycle/tests/subprep_codex_trust_roundtrip_red.rs +0 -1026
  266. package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +0 -342
  267. package/crates/team-agent/src/lifecycle/tests/team_in_team_identity_scope_red.rs +0 -543
  268. package/crates/team-agent/src/lifecycle/tests/team_in_team_sibling_quick_start_red.rs +0 -1103
  269. package/crates/team-agent/src/lifecycle/tests/team_in_team_state_scope_red.rs +0 -1276
  270. package/crates/team-agent/src/lifecycle/tests/team_key_retirement_roster_red.rs +0 -145
  271. package/crates/team-agent/src/lifecycle/tests/team_key_retirement_txn_red.rs +0 -603
  272. package/crates/team-agent/src/lifecycle/tests/test_isolation_escape_contract.rs +0 -936
  273. package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +0 -970
  274. package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +0 -995
  275. package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +0 -836
  276. package/crates/team-agent/src/lifecycle/tests.rs +0 -105
  277. package/crates/team-agent/src/lifecycle/types.rs +0 -877
  278. package/crates/team-agent/src/lifecycle/worker_command_context.rs +0 -363
  279. package/crates/team-agent/src/main.rs +0 -52
  280. package/crates/team-agent/src/mcp_server/helpers.rs +0 -510
  281. package/crates/team-agent/src/mcp_server/lifecycle_tools/mod.rs +0 -6
  282. package/crates/team-agent/src/mcp_server/lifecycle_tools/state_status.rs +0 -43
  283. package/crates/team-agent/src/mcp_server/mod.rs +0 -119
  284. package/crates/team-agent/src/mcp_server/normalize.rs +0 -485
  285. package/crates/team-agent/src/mcp_server/readiness.rs +0 -527
  286. package/crates/team-agent/src/mcp_server/readiness_tests.rs +0 -348
  287. package/crates/team-agent/src/mcp_server/tests/golden.rs +0 -285
  288. package/crates/team-agent/src/mcp_server/tests/normalize.rs +0 -247
  289. package/crates/team-agent/src/mcp_server/tests/scoped.rs +0 -158
  290. package/crates/team-agent/src/mcp_server/tests/send.rs +0 -353
  291. package/crates/team-agent/src/mcp_server/tests/tools.rs +0 -341
  292. package/crates/team-agent/src/mcp_server/tests/wire.rs +0 -254
  293. package/crates/team-agent/src/mcp_server/tests.rs +0 -43
  294. package/crates/team-agent/src/mcp_server/tools.rs +0 -889
  295. package/crates/team-agent/src/mcp_server/types.rs +0 -396
  296. package/crates/team-agent/src/mcp_server/wire.rs +0 -867
  297. package/crates/team-agent/src/messaging/activity.rs +0 -461
  298. package/crates/team-agent/src/messaging/address.rs +0 -87
  299. package/crates/team-agent/src/messaging/delivery.rs +0 -3727
  300. package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +0 -234
  301. package/crates/team-agent/src/messaging/enter_rescue.rs +0 -362
  302. package/crates/team-agent/src/messaging/enter_rescue_tests.rs +0 -633
  303. package/crates/team-agent/src/messaging/helpers.rs +0 -336
  304. package/crates/team-agent/src/messaging/leader_channel.rs +0 -287
  305. package/crates/team-agent/src/messaging/leader_receiver.rs +0 -786
  306. package/crates/team-agent/src/messaging/mod.rs +0 -167
  307. package/crates/team-agent/src/messaging/persist.rs +0 -377
  308. package/crates/team-agent/src/messaging/presentation.rs +0 -417
  309. package/crates/team-agent/src/messaging/reminders.rs +0 -316
  310. package/crates/team-agent/src/messaging/results/collection_tests.rs +0 -719
  311. package/crates/team-agent/src/messaging/results.rs +0 -1415
  312. package/crates/team-agent/src/messaging/scheduler.rs +0 -223
  313. package/crates/team-agent/src/messaging/selftest.rs +0 -315
  314. package/crates/team-agent/src/messaging/send.rs +0 -981
  315. package/crates/team-agent/src/messaging/tests/basic.rs +0 -346
  316. package/crates/team-agent/src/messaging/tests/dup_inject.rs +0 -657
  317. package/crates/team-agent/src/messaging/tests/e23.rs +0 -49
  318. package/crates/team-agent/src/messaging/tests/leader_channel.rs +0 -169
  319. package/crates/team-agent/src/messaging/tests/leader_inject_acceptance.rs +0 -817
  320. package/crates/team-agent/src/messaging/tests/main_preserved.rs +0 -85
  321. package/crates/team-agent/src/messaging/tests/mod.rs +0 -306
  322. package/crates/team-agent/src/messaging/tests/runtime.rs +0 -3549
  323. package/crates/team-agent/src/messaging/tests/spine.rs +0 -853
  324. package/crates/team-agent/src/messaging/tests/wave2.rs +0 -381
  325. package/crates/team-agent/src/messaging/trust.rs +0 -215
  326. package/crates/team-agent/src/messaging/types.rs +0 -472
  327. package/crates/team-agent/src/messaging/wait.rs +0 -366
  328. package/crates/team-agent/src/messaging/watchers.rs +0 -916
  329. package/crates/team-agent/src/model/enums.rs +0 -356
  330. package/crates/team-agent/src/model/errors.rs +0 -18
  331. package/crates/team-agent/src/model/ids.rs +0 -165
  332. package/crates/team-agent/src/model/mod.rs +0 -29
  333. package/crates/team-agent/src/model/name_similarity.rs +0 -252
  334. package/crates/team-agent/src/model/pane_authority_refusal.rs +0 -359
  335. package/crates/team-agent/src/model/paths.rs +0 -257
  336. package/crates/team-agent/src/model/routing.rs +0 -387
  337. package/crates/team-agent/src/model/spec.rs +0 -1184
  338. package/crates/team-agent/src/model/task_graph.rs +0 -321
  339. package/crates/team-agent/src/model/testdata/fuzz.golden.yaml +0 -43
  340. package/crates/team-agent/src/model/testdata/fuzz.yaml +0 -43
  341. package/crates/team-agent/src/model/testdata/spec_invalid_a.yaml +0 -209
  342. package/crates/team-agent/src/model/testdata/team.spec.golden.yaml +0 -208
  343. package/crates/team-agent/src/model/testdata/team.spec.yaml +0 -208
  344. package/crates/team-agent/src/model/yaml/tests.rs +0 -188
  345. package/crates/team-agent/src/model/yaml.rs +0 -802
  346. package/crates/team-agent/src/os_probe.rs +0 -280
  347. package/crates/team-agent/src/packaging/install.rs +0 -219
  348. package/crates/team-agent/src/packaging/migrate.rs +0 -38
  349. package/crates/team-agent/src/packaging/mod.rs +0 -91
  350. package/crates/team-agent/src/packaging/repair.rs +0 -33
  351. package/crates/team-agent/src/packaging/tests.rs +0 -822
  352. package/crates/team-agent/src/packaging/types.rs +0 -417
  353. package/crates/team-agent/src/platform/argv.rs +0 -331
  354. package/crates/team-agent/src/platform/errors.rs +0 -104
  355. package/crates/team-agent/src/platform/file_lock.rs +0 -279
  356. package/crates/team-agent/src/platform/mod.rs +0 -5
  357. package/crates/team-agent/src/platform/process.rs +0 -545
  358. package/crates/team-agent/src/provider/adapter.rs +0 -1150
  359. package/crates/team-agent/src/provider/adapters/claude.rs +0 -78
  360. package/crates/team-agent/src/provider/adapters/claude_fork.rs +0 -131
  361. package/crates/team-agent/src/provider/adapters/copilot.rs +0 -75
  362. package/crates/team-agent/src/provider/adapters/copilot_fork.rs +0 -307
  363. package/crates/team-agent/src/provider/adapters/fake.rs +0 -18
  364. package/crates/team-agent/src/provider/adapters/mod.rs +0 -30
  365. package/crates/team-agent/src/provider/adapters/pi.rs +0 -106
  366. package/crates/team-agent/src/provider/approvals/mod.rs +0 -3
  367. package/crates/team-agent/src/provider/approvals/parsing.rs +0 -586
  368. package/crates/team-agent/src/provider/approvals/runtime_prompts.rs +0 -205
  369. package/crates/team-agent/src/provider/argv_route.rs +0 -405
  370. package/crates/team-agent/src/provider/bypass_flags.rs +0 -116
  371. package/crates/team-agent/src/provider/classify.rs +0 -708
  372. package/crates/team-agent/src/provider/command_helpers.rs +0 -45
  373. package/crates/team-agent/src/provider/faults.rs +0 -165
  374. package/crates/team-agent/src/provider/helpers.rs +0 -52
  375. package/crates/team-agent/src/provider/mod.rs +0 -78
  376. package/crates/team-agent/src/provider/model_catalog.rs +0 -910
  377. package/crates/team-agent/src/provider/session/capture.rs +0 -2731
  378. package/crates/team-agent/src/provider/session/context_fork/claude.rs +0 -123
  379. package/crates/team-agent/src/provider/session/context_fork/outcome.rs +0 -172
  380. package/crates/team-agent/src/provider/session/context_fork.rs +0 -396
  381. package/crates/team-agent/src/provider/session/mod.rs +0 -36
  382. package/crates/team-agent/src/provider/session/resume.rs +0 -269
  383. package/crates/team-agent/src/provider/session_scan/claude.rs +0 -523
  384. package/crates/team-agent/src/provider/session_scan/common/tests.rs +0 -316
  385. package/crates/team-agent/src/provider/session_scan/common.rs +0 -654
  386. package/crates/team-agent/src/provider/session_scan/copilot.rs +0 -280
  387. package/crates/team-agent/src/provider/session_scan/pi.rs +0 -185
  388. package/crates/team-agent/src/provider/session_scan.rs +0 -71
  389. package/crates/team-agent/src/provider/startup_prompt.rs +0 -757
  390. package/crates/team-agent/src/provider/submit_now.rs +0 -71
  391. package/crates/team-agent/src/provider/testdata/copilot-ready-marker.txt +0 -5
  392. package/crates/team-agent/src/provider/testdata/copilot-trust-prompt.txt +0 -19
  393. package/crates/team-agent/src/provider/testdata/grok-models-authenticated.stdout +0 -9
  394. package/crates/team-agent/src/provider/testdata/grok-models-unauthenticated.stdout +0 -7
  395. package/crates/team-agent/src/provider/tests/adapter.rs +0 -441
  396. package/crates/team-agent/src/provider/tests/classify.rs +0 -148
  397. package/crates/team-agent/src/provider/tests/command_helpers.rs +0 -35
  398. package/crates/team-agent/src/provider/tests/copilot_fork.rs +0 -191
  399. package/crates/team-agent/src/provider/tests/faults.rs +0 -200
  400. package/crates/team-agent/src/provider/tests/idle.rs +0 -177
  401. package/crates/team-agent/src/provider/tests/wire.rs +0 -213
  402. package/crates/team-agent/src/provider/tests.rs +0 -32
  403. package/crates/team-agent/src/provider/types.rs +0 -529
  404. package/crates/team-agent/src/provider/wire.rs +0 -394
  405. package/crates/team-agent/src/redaction.rs +0 -259
  406. package/crates/team-agent/src/state/abnormal_watch/tests/mod.rs +0 -248
  407. package/crates/team-agent/src/state/abnormal_watch.rs +0 -144
  408. package/crates/team-agent/src/state/identity.rs +0 -914
  409. package/crates/team-agent/src/state/identity_keys.rs +0 -132
  410. package/crates/team-agent/src/state/mod.rs +0 -74
  411. package/crates/team-agent/src/state/owner_gate.rs +0 -482
  412. package/crates/team-agent/src/state/ownership.rs +0 -563
  413. package/crates/team-agent/src/state/paths.rs +0 -395
  414. package/crates/team-agent/src/state/persist.rs +0 -3811
  415. package/crates/team-agent/src/state/projection.rs +0 -1508
  416. package/crates/team-agent/src/state/repository/intent.rs +0 -14
  417. package/crates/team-agent/src/state/repository/tests.rs +0 -184
  418. package/crates/team-agent/src/state/repository.rs +0 -866
  419. package/crates/team-agent/src/state/selector.rs +0 -160
  420. package/crates/team-agent/src/state/testdata/state-rich.canonical.json +0 -133
  421. package/crates/team-agent/src/test_support/models_timeout_fixture.rs +0 -144
  422. package/crates/team-agent/src/tmux_backend/enter_rescue.rs +0 -325
  423. package/crates/team-agent/src/tmux_backend/enter_rescue_tests.rs +0 -432
  424. package/crates/team-agent/src/tmux_backend/native_input.rs +0 -513
  425. package/crates/team-agent/src/tmux_backend/native_input_tests.rs +0 -742
  426. package/crates/team-agent/src/tmux_backend/tests.rs +0 -4103
  427. package/crates/team-agent/src/tmux_backend.rs +0 -4492
  428. package/crates/team-agent/src/topology.rs +0 -537
  429. package/crates/team-agent/src/transport/enter_rescue.rs +0 -166
  430. package/crates/team-agent/src/transport/native_input.rs +0 -491
  431. package/crates/team-agent/src/transport/test_support.rs +0 -743
  432. package/crates/team-agent/src/transport/tests/behavior.rs +0 -326
  433. package/crates/team-agent/src/transport/tests/mod.rs +0 -194
  434. package/crates/team-agent/src/transport/tests/wire.rs +0 -574
  435. package/crates/team-agent/src/transport.rs +0 -1655
  436. package/crates/team-agent/src/transport_factory.rs +0 -819
@@ -1,1184 +0,0 @@
1
- //!
2
- //! spec / result-envelope 校验(`spec.py`)。
3
- //!
4
- //! 本 module **操作解析后的 Value**(非 typed struct)——与 Python 一样校验 dict,
5
- //! 产出**逐字节一致的有序错误消息列表**(测试对 Python 真相源取 golden 锁死)。
6
- //! serde_json `preserve_order` 保证 child 迭代序 == Python 插入序。
7
- //!
8
- //! 本文件先落地 `validate_result_envelope`(自包含,step 7/11 的门)。`validate_spec`
9
- //! 依赖 `find_dependency_cycle`(task_graph)+ yaml Value。
10
-
11
- use std::path::Path;
12
-
13
- use serde_json::Value;
14
-
15
- use crate::model::enums::TaskStatus;
16
- use crate::model::errors::ModelError;
17
- use crate::model::ids::TaskId;
18
- use crate::model::task_graph::{find_dependency_cycle, TaskNode};
19
- use crate::model::yaml;
20
- use crate::model::yaml::Value as Yaml;
21
- use crate::provider::wire::parse_canonical_provider;
22
-
23
- const LEGACY_DISPLAY_KEY: &str = concat!("display", "_backend");
24
-
25
- /// result_envelope_v1 顶层 required(= allowed)。
26
- const RESULT_REQUIRED: &[&str] = &[
27
- "schema_version",
28
- "task_id",
29
- "agent_id",
30
- "status",
31
- "summary",
32
- "changes",
33
- "tests",
34
- "risks",
35
- "artifacts",
36
- "next_actions",
37
- ];
38
-
39
- /// `RESULT_COLLECTION_SCHEMAS`(`spec.py:93-99`),有序:(field, required, allowed)。
40
- const RESULT_COLLECTIONS: &[(&str, &[&str], &[&str])] = &[
41
- (
42
- "changes",
43
- &["path", "kind", "description"],
44
- &["path", "kind", "description"],
45
- ),
46
- (
47
- "tests",
48
- &["command", "status"],
49
- &["command", "status", "detail"],
50
- ),
51
- (
52
- "risks",
53
- &["severity", "description"],
54
- &["severity", "description"],
55
- ),
56
- (
57
- "artifacts",
58
- &["path", "description"],
59
- &["path", "description"],
60
- ),
61
- ("next_actions", &["description"], &["description"]),
62
- ];
63
-
64
- /// `spec.validate_result_envelope`:校验 result_envelope_v1。失败 → `ModelError::Validation`,
65
- /// 消息体与 Python 字节一致(`result_envelope_v1 validation failed:\n- ...`)。
66
- pub fn validate_result_envelope(envelope: &Value) -> Result<(), ModelError> {
67
- let errors = result_schema_errors(envelope);
68
- if errors.is_empty() {
69
- return Ok(());
70
- }
71
- let joined = errors
72
- .iter()
73
- .map(|e| format!("- {e}"))
74
- .collect::<Vec<_>>()
75
- .join("\n");
76
- Err(ModelError::Validation(format!(
77
- "result_envelope_v1 validation failed:\n{joined}"
78
- )))
79
- }
80
-
81
- /// `spec._check_keys`:非 object → "must be an object";否则 missing(排序)+ unknown(排序)。
82
- fn check_keys(
83
- obj: &Value,
84
- path: &str,
85
- required: &[&str],
86
- allowed: &[&str],
87
- errors: &mut Vec<String>,
88
- ) {
89
- let Some(map) = obj.as_object() else {
90
- errors.push(format!("{path}: must be an object"));
91
- return;
92
- };
93
- let base = path.trim_end_matches('/');
94
- let mut missing: Vec<&str> = required
95
- .iter()
96
- .copied()
97
- .filter(|k| !map.contains_key(*k))
98
- .collect();
99
- missing.sort_unstable();
100
- for k in missing {
101
- errors.push(format!("{base}/{k}: missing required field"));
102
- }
103
- let mut unknown: Vec<&str> = map
104
- .keys()
105
- .map(String::as_str)
106
- .filter(|k| !allowed.contains(k))
107
- .collect();
108
- unknown.sort_unstable();
109
- for k in unknown {
110
- errors.push(format!("{base}/{k}: unknown field"));
111
- }
112
- }
113
-
114
- /// `spec._result_schema_errors`,逐行对齐(含错误产出顺序)。
115
- fn result_schema_errors(envelope: &Value) -> Vec<String> {
116
- let mut errors = Vec::new();
117
- check_keys(envelope, "/", RESULT_REQUIRED, RESULT_REQUIRED, &mut errors);
118
- let Some(map) = envelope.as_object() else {
119
- return errors;
120
- };
121
-
122
- if map.get("schema_version").and_then(Value::as_str) != Some("result_envelope_v1") {
123
- errors.push("/schema_version: must be result_envelope_v1".to_string());
124
- }
125
-
126
- for field in ["task_id", "agent_id", "summary"] {
127
- if let Some(v) = map.get(field) {
128
- if !v.is_string() {
129
- errors.push(format!("/{field}: must be a string"));
130
- } else if v.as_str() == Some("") {
131
- errors.push(format!("/{field}: must not be empty"));
132
- }
133
- }
134
- }
135
-
136
- if !matches!(
137
- map.get("status").and_then(Value::as_str),
138
- Some("success" | "blocked" | "failed" | "partial")
139
- ) {
140
- errors.push("/status: invalid result status".to_string());
141
- }
142
-
143
- if map.contains_key("schema") {
144
- errors.push("/schema: use schema_version, not schema".to_string());
145
- }
146
-
147
- for (field, item_required, item_allowed) in RESULT_COLLECTIONS {
148
- let Some(value) = map.get(*field) else {
149
- continue;
150
- };
151
- let Some(arr) = value.as_array() else {
152
- errors.push(format!("/{field}: must be a list"));
153
- continue;
154
- };
155
- for (idx, item) in arr.iter().enumerate() {
156
- let item_path = format!("/{field}/{idx}");
157
- check_keys(item, &item_path, item_required, item_allowed, &mut errors);
158
- let Some(item_map) = item.as_object() else {
159
- continue;
160
- };
161
- // 枚举字段校验(changes.kind / tests.status / risks.severity):值不在合法集 → 报错。
162
- let enum_field: Option<(&str, &[&str], &str)> = match *field {
163
- "changes" => Some((
164
- "kind",
165
- &["created", "modified", "deleted", "observed"],
166
- "invalid change kind",
167
- )),
168
- "tests" => Some((
169
- "status",
170
- &["passed", "failed", "not_run", "skipped"],
171
- "invalid test status",
172
- )),
173
- "risks" => Some((
174
- "severity",
175
- &["low", "medium", "high"],
176
- "invalid risk severity",
177
- )),
178
- _ => None,
179
- };
180
- if let Some((key, valid, msg)) = enum_field {
181
- let value_ok = item_map
182
- .get(key)
183
- .and_then(Value::as_str)
184
- .is_some_and(|s| valid.contains(&s));
185
- if !value_ok {
186
- errors.push(format!("{item_path}/{key}: {msg}"));
187
- }
188
- }
189
- // child string 校验:插入序(preserve_order)== Python item.items()。
190
- for (key, child) in item_map {
191
- if item_allowed.contains(&key.as_str()) && !child.is_string() {
192
- errors.push(format!("{item_path}/{key}: must be a string"));
193
- }
194
- }
195
- }
196
- }
197
- errors
198
- }
199
-
200
- // ===================== validate_spec(team.spec.yaml) =====================
201
- // 操作 yaml::Value(spec 走 simple_yaml)。basic_schema 全部先于 semantic;错误消息逐字节
202
- // 对齐 Python `spec.validate_spec`(golden 由真相源双跑锁死)。
203
-
204
- const ROOT_KEYS: &[&str] = &[
205
- "version",
206
- "team",
207
- "leader",
208
- "agents",
209
- "routing",
210
- "communication",
211
- "runtime",
212
- "context",
213
- "tasks",
214
- ];
215
- const AUTH_MODES: &[&str] = &["subscription", "official_api", "compatible_api"];
216
- const TASK_STATUS_STRS: &[&str] = &[
217
- "pending",
218
- "ready",
219
- "running",
220
- "blocked",
221
- "needs_retry",
222
- "done",
223
- "failed",
224
- "cancelled",
225
- ];
226
-
227
- /// `spec.validate_spec`:basic schema + semantic 校验。失败 → `ModelError::Validation`,
228
- /// 消息与 Python 字节一致(`team.spec.yaml validation failed:\n- ...`)。
229
- pub fn validate_spec(spec: &Yaml, base_dir: &Path) -> Result<(), ModelError> {
230
- let mut errors = basic_schema_errors(spec);
231
- errors.extend(semantic_errors(spec, base_dir));
232
- if errors.is_empty() {
233
- return Ok(());
234
- }
235
- let joined = errors
236
- .iter()
237
- .map(|m| format!("- {m}"))
238
- .collect::<Vec<_>>()
239
- .join("\n");
240
- Err(ModelError::Validation(format!(
241
- "team.spec.yaml validation failed:\n{joined}"
242
- )))
243
- }
244
-
245
- /// 便捷:YAML 文本 → load → 校验(对应 `load_spec` 的校验部分,不含 deprecation 发射)。
246
- pub fn load_and_validate_spec(text: &str, base_dir: &Path) -> Result<Yaml, ModelError> {
247
- let spec = yaml::loads(text)?;
248
- validate_spec(&spec, base_dir)?;
249
- Ok(spec)
250
- }
251
-
252
- fn is_map_some(v: Option<&Yaml>) -> bool {
253
- v.is_some_and(Yaml::is_map)
254
- }
255
-
256
- /// `spec._check_keys` 的 yaml::Value 版。
257
- fn check_keys_y(
258
- obj: Option<&Yaml>,
259
- path: &str,
260
- required: &[&str],
261
- allowed: &[&str],
262
- errors: &mut Vec<String>,
263
- ) {
264
- let Some(map) = obj.and_then(Yaml::as_map) else {
265
- errors.push(format!("{path}: must be an object"));
266
- return;
267
- };
268
- let base = path.trim_end_matches('/');
269
- let mut missing: Vec<&str> = required
270
- .iter()
271
- .copied()
272
- .filter(|k| !map.iter().any(|(mk, _)| mk == k))
273
- .collect();
274
- missing.sort_unstable();
275
- for k in missing {
276
- errors.push(format!("{base}/{k}: missing required field"));
277
- }
278
- let mut unknown: Vec<&str> = map
279
- .iter()
280
- .map(|(k, _)| k.as_str())
281
- .filter(|k| !allowed.contains(k))
282
- .collect();
283
- unknown.sort_unstable();
284
- for k in unknown {
285
- errors.push(format!("{base}/{k}: unknown field"));
286
- }
287
- }
288
-
289
- fn check_list_y(value: Option<&Yaml>, path: &str, errors: &mut Vec<String>) {
290
- if !matches!(value, Some(Yaml::List(_))) {
291
- errors.push(format!("{path}: must be a list"));
292
- }
293
- }
294
-
295
- fn basic_schema_errors(spec: &Yaml) -> Vec<String> {
296
- let mut e = Vec::new();
297
- check_keys_y(Some(spec), "/", ROOT_KEYS, ROOT_KEYS, &mut e);
298
- if !matches!(spec.get("version"), Some(Yaml::Int(1))) {
299
- e.push("/version: must equal 1".to_string());
300
- }
301
- // 0.4.x provider effort MVP step 3: provider_effort is allowed but not required.
302
- let team_required = &["name", "mode", "objective", "workspace"];
303
- let team_allowed = &["name", "mode", "objective", "workspace", "provider_effort"];
304
- check_keys_y(
305
- spec.get("team"),
306
- "/team",
307
- team_required,
308
- team_allowed,
309
- &mut e,
310
- );
311
- if let Some(team) = spec.get("team") {
312
- if let Some(raw) = team.get("provider_effort").and_then(Yaml::as_str) {
313
- if crate::model::enums::ProviderEffort::parse(raw).is_none() {
314
- e.push(format!(
315
- "/team/provider_effort: unknown effort '{raw}' (allowed: low|medium|high|xhigh|max|ultra)"
316
- ));
317
- }
318
- }
319
- }
320
- let mode = spec
321
- .get("team")
322
- .and_then(|t| t.get("mode"))
323
- .and_then(Yaml::as_str);
324
- if !matches!(mode, Some("supervisor_worker" | "swarm_limited")) {
325
- e.push("/team/mode: invalid mode".to_string());
326
- }
327
- let leader_keys = &["id", "role", "provider", "model", "context_policy"];
328
- let leader_allowed = &["id", "role", "provider", "model", "tools", "context_policy"];
329
- check_keys_y(
330
- spec.get("leader"),
331
- "/leader",
332
- leader_keys,
333
- leader_allowed,
334
- &mut e,
335
- );
336
- let cp_keys = &[
337
- "keep_user_thread",
338
- "receive_worker_outputs",
339
- "max_worker_result_tokens",
340
- ];
341
- check_keys_y(
342
- spec.get("leader").and_then(|l| l.get("context_policy")),
343
- "/leader/context_policy",
344
- cp_keys,
345
- cp_keys,
346
- &mut e,
347
- );
348
- match spec.get("agents") {
349
- Some(Yaml::List(agents)) if !agents.is_empty() => {
350
- // 0.5.66 bypass 单源:收集缺/错 `dangerously_skip_permissions` 的角色清单,
351
- // 循环后一次性报出,满足"缺字段错误消息含每个缺字段的角色 id 清单"硬要求。
352
- let mut missing_bypass: Vec<String> = Vec::new();
353
- let mut bad_type_bypass: Vec<String> = Vec::new();
354
- for (idx, agent) in agents.iter().enumerate() {
355
- check_agent(agent, &format!("/agents/{idx}"), &mut e);
356
- match agent.get("dangerously_skip_permissions") {
357
- None => missing_bypass.push(agent_label(agent, idx)),
358
- Some(value) if !matches!(value, Yaml::Bool(_)) => {
359
- bad_type_bypass.push(agent_label(agent, idx))
360
- }
361
- Some(_) => {}
362
- }
363
- }
364
- if !missing_bypass.is_empty() {
365
- e.push(format!(
366
- "/agents/dangerously_skip_permissions: missing required field (role id(s): {}). This field must be declared explicitly; it controls whether the agent launches with permission prompts bypassed.",
367
- missing_bypass.join(", ")
368
- ));
369
- }
370
- if !bad_type_bypass.is_empty() {
371
- e.push(format!(
372
- "/agents/dangerously_skip_permissions: must be a boolean (role id(s): {}). This field must be declared explicitly; it controls whether the agent launches with permission prompts bypassed.",
373
- bad_type_bypass.join(", ")
374
- ));
375
- }
376
- }
377
- _ => e.push("/agents: must be a non-empty list".to_string()),
378
- }
379
- check_routing(spec.get("routing"), &mut e);
380
- check_communication(spec.get("communication"), &mut e);
381
- check_runtime(spec.get("runtime"), &mut e);
382
- check_context(spec.get("context"), &mut e);
383
- match spec.get("tasks") {
384
- Some(Yaml::List(tasks)) => {
385
- for (idx, task) in tasks.iter().enumerate() {
386
- check_task(task, &format!("/tasks/{idx}"), &mut e);
387
- }
388
- }
389
- _ => e.push("/tasks: must be a list".to_string()),
390
- }
391
- e
392
- }
393
-
394
- fn check_agent(agent: &Yaml, path: &str, errors: &mut Vec<String>) {
395
- let req = &[
396
- "id",
397
- "role",
398
- "provider",
399
- "model",
400
- "working_directory",
401
- "system_prompt",
402
- "dangerously_skip_permissions",
403
- "preferred_for",
404
- "avoid_for",
405
- "output_contract",
406
- ];
407
- let allowed = &[
408
- "id",
409
- "label",
410
- "role",
411
- "provider",
412
- "model",
413
- "working_directory",
414
- "system_prompt",
415
- "tools",
416
- "dangerously_skip_permissions",
417
- "preferred_for",
418
- "avoid_for",
419
- "output_contract",
420
- "communication_mode",
421
- "paused",
422
- "auth_mode",
423
- "profile",
424
- "credential_ref",
425
- "forked_from",
426
- // 存量角色 md 的 `permission_mode` 是历史无效值(compiler 曾恒发 restricted)。
427
- // 0.5.66 起不再被 compiler 消费;保留在 allowed 以免存量文件 fail-loud
428
- // (§3.1 迁移时顺手删除,0.6.0 可收紧)。
429
- "permission_mode",
430
- // 0.4.x provider effort MVP step 3: per-agent effort override (resolved at compile).
431
- "effort",
432
- ];
433
- check_keys_y(Some(agent), path, req, allowed, errors);
434
- if !agent.is_map() {
435
- return;
436
- }
437
- if let Some(value) = agent.get("communication_mode") {
438
- match value.as_str() {
439
- Some(raw) if crate::communication_mode::CommunicationMode::parse(raw).is_none() => {
440
- errors.push(format!(
441
- "{path}/communication_mode: unknown communication_mode '{raw}'"
442
- ));
443
- }
444
- None => {
445
- errors.push(format!(
446
- "{path}/communication_mode: unknown communication_mode"
447
- ));
448
- }
449
- Some(_) => {}
450
- }
451
- }
452
- // 0.4.x provider effort MVP step 3: effort syntactic + semantic validation.
453
- if let Some(raw) = agent.get("effort").and_then(Yaml::as_str) {
454
- match crate::model::enums::ProviderEffort::parse(raw) {
455
- None => {
456
- errors.push(format!(
457
- "{path}/effort: unknown effort '{raw}' (allowed: low|medium|high|xhigh|max|ultra)"
458
- ));
459
- }
460
- Some(effort) => {
461
- let provider = agent.get("provider").and_then(Yaml::as_str).unwrap_or("");
462
- if let Some(provider_enum) = parse_canonical_provider(provider) {
463
- if let Err(reason) = effort.resolve_for_provider(provider_enum) {
464
- errors.push(format!(
465
- "{path}/effort: {reason} (effort: {raw}; provider: {provider})"
466
- ));
467
- }
468
- }
469
- }
470
- }
471
- }
472
- check_keys_y(
473
- agent.get("system_prompt"),
474
- &format!("{path}/system_prompt"),
475
- &["inline", "file"],
476
- &["inline", "file"],
477
- errors,
478
- );
479
- check_list_y(
480
- agent.get("preferred_for"),
481
- &format!("{path}/preferred_for"),
482
- errors,
483
- );
484
- check_list_y(agent.get("avoid_for"), &format!("{path}/avoid_for"), errors);
485
- check_keys_y(
486
- agent.get("output_contract"),
487
- &format!("{path}/output_contract"),
488
- &["format", "required_fields"],
489
- &["format", "required_fields"],
490
- errors,
491
- );
492
- if agent
493
- .get("output_contract")
494
- .and_then(|o| o.get("format"))
495
- .and_then(Yaml::as_str)
496
- != Some("result_envelope_v1")
497
- {
498
- errors.push(format!(
499
- "{path}/output_contract/format: must be result_envelope_v1"
500
- ));
501
- }
502
- }
503
-
504
- /// 汇总错误里引用 agent 的可读标签:`<id>` 优先,退回 `<index> (role: <role>)`。
505
- fn agent_label(agent: &Yaml, idx: usize) -> String {
506
- agent
507
- .get("id")
508
- .and_then(Yaml::as_str)
509
- .map(|id| format!("`{id}`"))
510
- .unwrap_or_else(|| format!("agents[{idx}]"))
511
- }
512
-
513
- fn check_routing(routing: Option<&Yaml>, errors: &mut Vec<String>) {
514
- check_keys_y(
515
- routing,
516
- "/routing",
517
- &["default_assignee", "rules"],
518
- &["default_assignee", "rules"],
519
- errors,
520
- );
521
- if !is_map_some(routing) {
522
- return;
523
- }
524
- let Some(Yaml::List(rules)) = routing.and_then(|r| r.get("rules")) else {
525
- errors.push("/routing/rules: must be a list".to_string());
526
- return;
527
- };
528
- for (idx, rule) in rules.iter().enumerate() {
529
- check_keys_y(
530
- Some(rule),
531
- &format!("/routing/rules/{idx}"),
532
- &["id", "assign_to", "priority"],
533
- &["id", "when", "match", "assign_to", "priority"],
534
- errors,
535
- );
536
- let has_clause = rule.get("when").is_some_and(Yaml::is_truthy)
537
- || rule.get("match").is_some_and(Yaml::is_truthy);
538
- if rule.is_map() && !has_clause {
539
- errors.push(format!("/routing/rules/{idx}: must include when or match"));
540
- }
541
- }
542
- }
543
-
544
- fn check_communication(comm: Option<&Yaml>, errors: &mut Vec<String>) {
545
- let req = &[
546
- "protocol",
547
- "topology",
548
- "worker_to_worker",
549
- "ack_timeout_sec",
550
- "result_format",
551
- "message_store",
552
- ];
553
- check_keys_y(comm, "/communication", req, req, errors);
554
- if !is_map_some(comm) {
555
- return;
556
- }
557
- if !matches!(
558
- comm.and_then(|c| c.get("protocol")).and_then(Yaml::as_str),
559
- Some("mcp_inbox" | "file_bus")
560
- ) {
561
- errors.push("/communication/protocol: invalid protocol".to_string());
562
- }
563
- if comm
564
- .and_then(|c| c.get("result_format"))
565
- .and_then(Yaml::as_str)
566
- != Some("result_envelope_v1")
567
- {
568
- errors.push("/communication/result_format: must be result_envelope_v1".to_string());
569
- }
570
- check_keys_y(
571
- comm.and_then(|c| c.get("message_store")),
572
- "/communication/message_store",
573
- &["sqlite", "mirror_files"],
574
- &["sqlite", "mirror_files"],
575
- errors,
576
- );
577
- }
578
-
579
- fn check_runtime(runtime: Option<&Yaml>, errors: &mut Vec<String>) {
580
- let req = &[
581
- "backend",
582
- "session_name",
583
- "auto_launch",
584
- "require_user_approval_before_launch",
585
- "max_active_agents",
586
- "startup_order",
587
- ];
588
- let allowed = &[
589
- "backend",
590
- "session_name",
591
- "auto_launch",
592
- "require_user_approval_before_launch",
593
- "max_active_agents",
594
- "startup_order",
595
- LEGACY_DISPLAY_KEY,
596
- "auto_attach_leader",
597
- "fast",
598
- "tick_interval_sec",
599
- "push_min_interval_sec",
600
- "stuck_timeout_sec",
601
- "auto_trust_own_workspace",
602
- ];
603
- check_keys_y(runtime, "/runtime", req, allowed, errors);
604
- if !is_map_some(runtime) {
605
- return;
606
- }
607
- let get = |k: &str| runtime.and_then(|r| r.get(k));
608
- if !matches!(get("backend").and_then(Yaml::as_str), Some("tmux" | "pty")) {
609
- errors.push("/runtime/backend: invalid backend".to_string());
610
- }
611
- if get("auto_trust_own_workspace").is_some_and(|v| !matches!(v, Yaml::Bool(_))) {
612
- errors.push("/runtime/auto_trust_own_workspace: must be a boolean".to_string());
613
- }
614
- check_list_y(get("startup_order"), "/runtime/startup_order", errors);
615
- }
616
-
617
- fn check_context(context: Option<&Yaml>, errors: &mut Vec<String>) {
618
- let req = &["state_file", "artifact_dir", "log_dir", "summarization"];
619
- check_keys_y(context, "/context", req, req, errors);
620
- if is_map_some(context) {
621
- check_keys_y(
622
- context.and_then(|c| c.get("summarization")),
623
- "/context/summarization",
624
- &["worker_full_logs", "state_update"],
625
- &["worker_full_logs", "state_update"],
626
- errors,
627
- );
628
- }
629
- }
630
-
631
- fn check_task(task: &Yaml, path: &str, errors: &mut Vec<String>) {
632
- let req = &[
633
- "id",
634
- "title",
635
- "type",
636
- "assignee",
637
- "deps",
638
- "acceptance",
639
- "status",
640
- ];
641
- let allowed = &[
642
- "id",
643
- "title",
644
- "type",
645
- "assignee",
646
- "deps",
647
- "acceptance",
648
- "status",
649
- "description",
650
- "requires_tools",
651
- "files",
652
- "risk",
653
- "retry_limit",
654
- "human_confirmation",
655
- ];
656
- check_keys_y(Some(task), path, req, allowed, errors);
657
- if !task.is_map() {
658
- return;
659
- }
660
- check_list_y(task.get("deps"), &format!("{path}/deps"), errors);
661
- check_list_y(
662
- task.get("acceptance"),
663
- &format!("{path}/acceptance"),
664
- errors,
665
- );
666
- if !task
667
- .get("status")
668
- .and_then(Yaml::as_str)
669
- .is_some_and(|s| TASK_STATUS_STRS.contains(&s))
670
- {
671
- errors.push(format!("{path}/status: invalid task status"));
672
- }
673
- }
674
-
675
- fn semantic_errors(spec: &Yaml, base_dir: &Path) -> Vec<String> {
676
- use std::collections::HashSet;
677
- let mut e = Vec::new();
678
- let leader = spec.get("leader");
679
- let agents: &[Yaml] = spec.get("agents").and_then(Yaml::as_list).unwrap_or(&[]);
680
- let map_agents: Vec<&Yaml> = agents.iter().filter(|a| a.is_map()).collect();
681
-
682
- // duplicate agent id(集合含 None 复刻 Python `{a.get("id") ...}`)。
683
- // SMOKE-1 N38 失败可解释性:不仅报"有重复",还点出**哪个 id 重复**(可能多个),
684
- // 给 operator 直接定位线索;locate.md §"Smallest likely code touch" item 3。
685
- let id_set: HashSet<Option<&str>> = map_agents
686
- .iter()
687
- .map(|a| a.get("id").and_then(Yaml::as_str))
688
- .collect();
689
- if id_set.len() != map_agents.len() {
690
- let mut seen: HashSet<&str> = HashSet::new();
691
- let mut duplicates: Vec<&str> = Vec::new();
692
- for agent in &map_agents {
693
- if let Some(id) = agent.get("id").and_then(Yaml::as_str) {
694
- if !seen.insert(id) && !duplicates.contains(&id) {
695
- duplicates.push(id);
696
- }
697
- }
698
- }
699
- if duplicates.is_empty() {
700
- e.push("/agents: duplicate agent id".to_string());
701
- } else {
702
- e.push(format!(
703
- "/agents: duplicate agent id: {}",
704
- duplicates
705
- .iter()
706
- .map(|id| format!("`{id}`"))
707
- .collect::<Vec<_>>()
708
- .join(", ")
709
- ));
710
- }
711
- }
712
- // all_ids:present 的 agent id + leader id(若 truthy)。
713
- let mut all_ids: HashSet<&str> = map_agents
714
- .iter()
715
- .filter_map(|a| a.get("id").and_then(Yaml::as_str))
716
- .collect();
717
- if let Some(lid) = leader.and_then(|l| l.get("id")).and_then(Yaml::as_str) {
718
- if !lid.is_empty() {
719
- all_ids.insert(lid);
720
- }
721
- }
722
-
723
- let leader_provider = leader.and_then(|l| l.get("provider"));
724
- if !leader_provider
725
- .and_then(Yaml::as_str)
726
- .is_some_and(|p| parse_canonical_provider(p).is_some())
727
- {
728
- e.push(format!(
729
- "/leader/provider: unknown provider {}",
730
- py_repr(leader_provider)
731
- ));
732
- }
733
-
734
- for (idx, agent) in agents.iter().enumerate() {
735
- let provider = agent.get("provider");
736
- if !provider.and_then(Yaml::as_str).is_some_and(|p| {
737
- #[cfg(unix)]
738
- if crate::contract_runtime::registry::descriptor(p).is_some() {
739
- return true;
740
- }
741
- parse_canonical_provider(p).is_some()
742
- }) {
743
- e.push(format!(
744
- "/agents/{idx}/provider: unknown provider {}",
745
- py_repr(provider)
746
- ));
747
- }
748
- if let Some(auth) = agent.get("auth_mode") {
749
- if !matches!(auth, Yaml::Null)
750
- && !auth.as_str().is_some_and(|a| AUTH_MODES.contains(&a))
751
- {
752
- e.push(format!(
753
- "/agents/{idx}/auth_mode: unknown auth_mode {}",
754
- py_repr(Some(auth))
755
- ));
756
- }
757
- }
758
- if let Some(f) = agent
759
- .get("system_prompt")
760
- .and_then(|sp| sp.get("file"))
761
- .filter(|p| p.is_truthy())
762
- .and_then(Yaml::as_str)
763
- {
764
- let candidate = Path::new(f);
765
- let full = if candidate.is_absolute() {
766
- candidate.to_path_buf()
767
- } else {
768
- base_dir.join(candidate)
769
- };
770
- if !full.exists() {
771
- e.push(format!(
772
- "/agents/{idx}/system_prompt/file: file not found: {}",
773
- full.display()
774
- ));
775
- }
776
- }
777
- }
778
-
779
- let routing = spec.get("routing");
780
- if let Some(da) = routing
781
- .and_then(|r| r.get("default_assignee"))
782
- .and_then(Yaml::as_str)
783
- {
784
- if !da.is_empty() && !all_ids.contains(da) {
785
- e.push(format!(
786
- "/routing/default_assignee: unknown agent {}",
787
- py_repr_str(da)
788
- ));
789
- }
790
- }
791
- let rules = routing
792
- .and_then(|r| r.get("rules"))
793
- .and_then(Yaml::as_list)
794
- .unwrap_or(&[]);
795
- for (idx, rule) in rules.iter().enumerate() {
796
- let target = rule.get("assign_to");
797
- if !target
798
- .and_then(Yaml::as_str)
799
- .is_some_and(|t| all_ids.contains(t))
800
- {
801
- e.push(format!(
802
- "/routing/rules/{idx}/assign_to: unknown agent {}",
803
- py_repr(target)
804
- ));
805
- }
806
- }
807
-
808
- let tasks: &[Yaml] = spec.get("tasks").and_then(Yaml::as_list).unwrap_or(&[]);
809
- let task_ids: HashSet<&str> = tasks
810
- .iter()
811
- .filter(|t| t.is_map())
812
- .filter_map(|t| t.get("id").and_then(Yaml::as_str))
813
- .collect();
814
- for (idx, task) in tasks.iter().enumerate() {
815
- if let Some(a) = task.get("assignee").and_then(Yaml::as_str) {
816
- if !a.is_empty() && !all_ids.contains(a) {
817
- e.push(format!(
818
- "/tasks/{idx}/assignee: unknown agent {}",
819
- py_repr_str(a)
820
- ));
821
- }
822
- }
823
- for dep in task.get("deps").and_then(Yaml::as_list).unwrap_or(&[]) {
824
- if !dep.as_str().is_some_and(|d| task_ids.contains(d)) {
825
- e.push(format!(
826
- "/tasks/{idx}/deps: unknown dependency {}",
827
- py_repr(Some(dep))
828
- ));
829
- }
830
- }
831
- }
832
-
833
- // dependency cycle(只含有非空 id 的 task,复刻 Python `if t.get("id")`)。
834
- let nodes: Vec<TaskNode> = tasks
835
- .iter()
836
- .filter_map(|t| {
837
- let id = t
838
- .get("id")
839
- .and_then(Yaml::as_str)
840
- .filter(|s| !s.is_empty())?;
841
- let deps: Vec<TaskId> = t
842
- .get("deps")
843
- .and_then(Yaml::as_list)
844
- .unwrap_or(&[])
845
- .iter()
846
- .filter_map(|d| d.as_str().map(TaskId::from))
847
- .collect();
848
- Some(TaskNode::new(TaskId::from(id), deps, TaskStatus::Pending))
849
- })
850
- .collect();
851
- let cycle = find_dependency_cycle(&nodes);
852
- if !cycle.is_empty() {
853
- let chain = cycle
854
- .iter()
855
- .map(TaskId::as_str)
856
- .collect::<Vec<_>>()
857
- .join(" -> ");
858
- e.push(format!("/tasks: dependency cycle detected: {chain}"));
859
- }
860
- e
861
- }
862
-
863
- /// Python `repr()` of a string(选引号 + 转义),用于 `unknown X 'name'`。
864
- fn py_repr_str(s: &str) -> String {
865
- let quote = if s.contains('\'') && !s.contains('"') {
866
- '"'
867
- } else {
868
- '\''
869
- };
870
- let mut out = String::new();
871
- out.push(quote);
872
- for c in s.chars() {
873
- match c {
874
- '\\' => out.push_str("\\\\"),
875
- c if c == quote => {
876
- out.push('\\');
877
- out.push(c);
878
- }
879
- '\n' => out.push_str("\\n"),
880
- '\r' => out.push_str("\\r"),
881
- '\t' => out.push_str("\\t"),
882
- c => out.push(c),
883
- }
884
- }
885
- out.push(quote);
886
- out
887
- }
888
-
889
- /// Python `repr()` of an optional yaml value(None/absent→"None",Str→repr,标量→字面)。
890
- fn py_repr(v: Option<&Yaml>) -> String {
891
- match v {
892
- None | Some(Yaml::Null) => "None".to_string(),
893
- Some(Yaml::Str(s)) => py_repr_str(s),
894
- Some(Yaml::Bool(true)) => "True".to_string(),
895
- Some(Yaml::Bool(false)) => "False".to_string(),
896
- Some(Yaml::Int(i)) => i.to_string(),
897
- Some(Yaml::Float(f)) => f.to_string(),
898
- // list/map 作 provider/dep 等极少见的退化输入;非 Python-exact,仅保证不 panic。
899
- Some(other) => format!("{other:?}"),
900
- }
901
- }
902
-
903
- #[cfg(test)]
904
- mod tests {
905
- #![allow(clippy::unwrap_used)]
906
- use super::*;
907
- use serde_json::json;
908
-
909
- // golden 错误列表由 Python 真相源 `spec._result_schema_errors` 算出(team-agent-public@439bef8)。
910
- // §4.2 行为 diff 双跑:Rust 必须产出逐字节一致的有序消息。
911
- #[test]
912
- fn valid_envelope_has_no_errors() {
913
- let v = json!({
914
- "schema_version":"result_envelope_v1","task_id":"t1","agent_id":"a1",
915
- "status":"success","summary":"done",
916
- "changes":[],"tests":[],"risks":[],"artifacts":[],"next_actions":[]
917
- });
918
- assert!(result_schema_errors(&v).is_empty());
919
- assert!(validate_result_envelope(&v).is_ok());
920
- }
921
-
922
- #[test]
923
- fn missing_unknown_status_schema_order_matches_python() {
924
- let v = json!({
925
- "schema_version":"v0","task_id":"","status":"weird","summary":"s","schema":"x",
926
- "changes":[],"tests":[],"risks":[],"artifacts":[],"next_actions":[]
927
- });
928
- assert_eq!(
929
- result_schema_errors(&v),
930
- vec![
931
- "/agent_id: missing required field",
932
- "/schema: unknown field",
933
- "/schema_version: must be result_envelope_v1",
934
- "/task_id: must not be empty",
935
- "/status: invalid result status",
936
- "/schema: use schema_version, not schema",
937
- ]
938
- );
939
- }
940
-
941
- #[test]
942
- fn non_object_envelope() {
943
- assert_eq!(
944
- result_schema_errors(&json!(["x"])),
945
- vec!["/: must be an object"]
946
- );
947
- }
948
-
949
- #[test]
950
- fn bad_collection_items_match_python() {
951
- let v = json!({
952
- "schema_version":"result_envelope_v1","task_id":"t","agent_id":"a",
953
- "status":"success","summary":"s",
954
- "changes":[{"path":"p","kind":"bogus","description":"d"}],
955
- "tests":[{"command":"c","status":"weird"}],
956
- "risks":[{"severity":"huge","description":"d"}],
957
- "artifacts":[],
958
- "next_actions":[{"description":123}]
959
- });
960
- assert_eq!(
961
- result_schema_errors(&v),
962
- vec![
963
- "/changes/0/kind: invalid change kind",
964
- "/tests/0/status: invalid test status",
965
- "/risks/0/severity: invalid risk severity",
966
- "/next_actions/0/description: must be a string",
967
- ]
968
- );
969
- }
970
-
971
- #[test]
972
- fn validate_returns_joined_message() {
973
- let v = json!(["x"]);
974
- let err = validate_result_envelope(&v).unwrap_err();
975
- assert_eq!(
976
- err.to_string(),
977
- "validation error: result_envelope_v1 validation failed:\n- /: must be an object"
978
- );
979
- }
980
-
981
- // --- validate_spec(对 Python `spec.validate_spec` 取 golden) ---
982
-
983
- const TD: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/src/model/testdata");
984
-
985
- fn all_spec_errors(spec: &Yaml) -> Vec<String> {
986
- let mut v = basic_schema_errors(spec);
987
- v.extend(semantic_errors(spec, Path::new(TD)));
988
- v
989
- }
990
-
991
- #[test]
992
- fn valid_team_spec_passes() {
993
- let spec = yaml::loads(include_str!("testdata/team.spec.yaml")).unwrap();
994
- let r = validate_spec(&spec, Path::new(TD));
995
- assert!(r.is_ok(), "expected valid, got: {r:?}");
996
- }
997
-
998
- #[test]
999
- fn tools_are_transparent_for_all_providers() {
1000
- let pi_text = include_str!("testdata/team.spec.yaml")
1001
- .lines()
1002
- .filter(|line| {
1003
- !line.contains("provider_builtin")
1004
- && !line.contains("git_diff")
1005
- && !line.contains("network")
1006
- })
1007
- .collect::<Vec<_>>()
1008
- .join("\n");
1009
- let pi_text = pi_text.replace("provider: codex", "provider: pi");
1010
- let pi_spec = yaml::loads(&pi_text).unwrap();
1011
- assert!(
1012
- validate_spec(&pi_spec, Path::new(TD)).is_ok(),
1013
- "Pi must accept the native Team Agent categories"
1014
- );
1015
-
1016
- let bad_agent_text = pi_text.replacen(
1017
- " - mcp_team\n",
1018
- " - mcp_team\n - provider_builtin\n",
1019
- 1,
1020
- );
1021
- let bad_agent = yaml::loads(&bad_agent_text).unwrap();
1022
- assert!(
1023
- validate_spec(&bad_agent, Path::new(TD)).is_ok(),
1024
- "Pi tools metadata must be ignored"
1025
- );
1026
-
1027
- let missing_tools = pi_text
1028
- .replacen(
1029
- " tools:\n - fs_read\n - fs_list\n - mcp_team\n",
1030
- "",
1031
- 1,
1032
- )
1033
- .replacen(
1034
- " tools:\n - fs_read\n - fs_write\n - fs_list\n - execute_bash\n - mcp_team\n",
1035
- "",
1036
- 1,
1037
- );
1038
- let missing_tools = yaml::loads(&missing_tools).unwrap();
1039
- assert!(
1040
- validate_spec(&missing_tools, Path::new(TD)).is_ok(),
1041
- "omitted tools metadata must be accepted"
1042
- );
1043
- }
1044
-
1045
- #[test]
1046
- fn invalid_spec_a_matches_python_golden() {
1047
- let spec = yaml::loads(include_str!("testdata/spec_invalid_a.yaml")).unwrap();
1048
- assert_eq!(
1049
- all_spec_errors(&spec),
1050
- vec![
1051
- "/version: must equal 1",
1052
- "/team/mode: invalid mode",
1053
- "/leader/provider: unknown provider 'badprov'",
1054
- ]
1055
- );
1056
- }
1057
-
1058
- // 0.5.66 bypass 单源 §4.1:缺 `dangerously_skip_permissions` 字段 → 错误消息
1059
- // 必须列出每个缺字段的角色 id + 用户可读的必填说明。
1060
- #[test]
1061
- fn test_missing_dangerously_field_reports_role_list() {
1062
- // 从 fixture 文本里删掉第一个 agent 的字段,模拟该角色缺字段。
1063
- let text = include_str!("testdata/team.spec.yaml");
1064
- let without_first = text.replacen(" dangerously_skip_permissions: false\n", "", 1);
1065
- assert_ne!(text, without_first, "fixture must contain the field");
1066
- let spec = yaml::loads(&without_first).unwrap();
1067
- let errors = all_spec_errors(&spec);
1068
- let missing: Vec<&String> = errors
1069
- .iter()
1070
- .filter(|m| m.starts_with("/agents/dangerously_skip_permissions: missing"))
1071
- .collect();
1072
- assert_eq!(
1073
- missing.len(),
1074
- 1,
1075
- "exactly one missing-field error, got: {errors:#?}"
1076
- );
1077
- assert!(
1078
- missing[0].contains("`codex_implementer`"),
1079
- "must name the role id, got: {}",
1080
- missing[0]
1081
- );
1082
- assert!(
1083
- missing[0].contains("This field must be declared explicitly; it controls whether the agent launches with permission prompts bypassed."),
1084
- "must carry the user-facing required-field message, got: {}",
1085
- missing[0]
1086
- );
1087
- }
1088
-
1089
- // 0.5.66 bypass 单源 §4.1:非 bool 值 → fail-loud 类型错,同样带角色清单 + 硬串。
1090
- #[test]
1091
- fn test_invalid_dangerously_type_rejected() {
1092
- let text = include_str!("testdata/team.spec.yaml");
1093
- let bad = text.replacen(
1094
- " dangerously_skip_permissions: false\n",
1095
- " dangerously_skip_permissions: \"yes\"\n",
1096
- 1,
1097
- );
1098
- assert_ne!(text, bad, "fixture must contain the field");
1099
- let spec = yaml::loads(&bad).unwrap();
1100
- let errors = all_spec_errors(&spec);
1101
- let type_errs: Vec<&String> = errors
1102
- .iter()
1103
- .filter(|m| m.starts_with("/agents/dangerously_skip_permissions: must be a boolean"))
1104
- .collect();
1105
- assert_eq!(
1106
- type_errs.len(),
1107
- 1,
1108
- "exactly one type error, got: {errors:#?}"
1109
- );
1110
- assert!(
1111
- type_errs[0].contains("`codex_implementer`"),
1112
- "must name the role id, got: {}",
1113
- type_errs[0]
1114
- );
1115
- assert!(
1116
- type_errs[0].contains("This field must be declared explicitly; it controls whether the agent launches with permission prompts bypassed."),
1117
- "must carry the user-facing required-field message, got: {}",
1118
- type_errs[0]
1119
- );
1120
- }
1121
-
1122
- #[test]
1123
- fn empty_spec_matches_python_golden() {
1124
- let spec = yaml::loads("{}").unwrap();
1125
- assert_eq!(
1126
- all_spec_errors(&spec),
1127
- vec![
1128
- "/agents: missing required field",
1129
- "/communication: missing required field",
1130
- "/context: missing required field",
1131
- "/leader: missing required field",
1132
- "/routing: missing required field",
1133
- "/runtime: missing required field",
1134
- "/tasks: missing required field",
1135
- "/team: missing required field",
1136
- "/version: missing required field",
1137
- "/version: must equal 1",
1138
- "/team: must be an object",
1139
- "/team/mode: invalid mode",
1140
- "/leader: must be an object",
1141
- "/leader/context_policy: must be an object",
1142
- "/agents: must be a non-empty list",
1143
- "/routing: must be an object",
1144
- "/communication: must be an object",
1145
- "/runtime: must be an object",
1146
- "/context: must be an object",
1147
- "/tasks: must be a list",
1148
- "/leader/provider: unknown provider None",
1149
- ]
1150
- );
1151
- }
1152
-
1153
- // 0.5.66 bypass 单源 §4.1:7 个生命周期入口共享编译后的 spec。
1154
- // 缺失 role frontmatter 值时编译为安全默认 false;此处锁定公共编译入口的结果。
1155
- #[test]
1156
- fn test_all_7_triggers_use_compiled_default_bypass() {
1157
- let team = std::env::temp_dir().join(format!("ta-spec-7trigger-{}", std::process::id()));
1158
- let _ = std::fs::remove_dir_all(&team);
1159
- std::fs::create_dir_all(team.join("agents")).unwrap();
1160
- std::fs::write(
1161
- team.join("TEAM.md"),
1162
- "---\nname: t7\nobjective: 7 trigger.\nprovider: codex\n---\n\nteam.\n",
1163
- )
1164
- .unwrap();
1165
- // 角色文档故意省略该字段;纯文本默认必须写入 compiled spec。
1166
- std::fs::write(
1167
- team.join("agents").join("w.md"),
1168
- "---\nname: w\nrole: Worker\nprovider: codex\ntools:\n - mcp_team\n---\n\nw.\n",
1169
- )
1170
- .unwrap();
1171
- let spec = crate::compiler::compile_team(&team)
1172
- .expect("compile_team must materialize the default bypass value");
1173
- let agent = spec
1174
- .get("agents")
1175
- .and_then(Yaml::as_list)
1176
- .and_then(|agents| agents.first())
1177
- .expect("compiled spec has a worker");
1178
- assert_eq!(
1179
- agent.get("dangerously_skip_permissions"),
1180
- Some(&Yaml::Bool(false))
1181
- );
1182
- let _ = std::fs::remove_dir_all(&team);
1183
- }
1184
- }