@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,837 +0,0 @@
1
- use super::*;
2
- use crate::transport::test_support::OfflineTransport;
3
-
4
- // ═══════════════ P2 FIX-LOOP RED (复绿即对抗 cross-model findings) ═══════════════
5
- // Golden re-probed via /tmp/probe_p2b_msg.py vs team-agent-public @ 439bef8.
6
-
7
- // P0 — IRON LAW (bug-064/082): trust auto-answer must REFUSE a prompt whose path is a
8
- // SUBDIRECTORY or SIBLING of the workspace. The current substring `.contains()` answers
9
- // both (a subdir/sibling string contains the workspace as a substring). leader_panes.py
10
- // requires EXACT canonical equality.
11
- #[test]
12
- fn p2_trust_refuses_subdirectory_and_sibling_of_workspace() {
13
- let ws = tmp_ws("trustsubsib");
14
- let canonical = std::fs::canonicalize(&ws).unwrap();
15
- let log = EventLog::new(&ws);
16
- let t = NoopTransport;
17
- let pane = PaneId::new("%7");
18
- let canon = canonical.to_string_lossy().to_string();
19
-
20
- let subdir = format!("Allow Codex to write to {canon}/subproject ?");
21
- let s = attempt_trust_auto_answer(
22
- &canonical,
23
- &t,
24
- Some(&pane),
25
- &subdir,
26
- &PaneWidthQuery::Ok { pane_width: 200 },
27
- &log,
28
- )
29
- .unwrap();
30
- assert!(
31
- !s.answered,
32
- "a SUBDIRECTORY of the workspace must NOT auto-answer trust"
33
- );
34
- assert_eq!(s.reason, "workspace_dir_mismatch");
35
-
36
- let sibling = format!("Allow Codex to write to {canon}-backup ?");
37
- let sib = attempt_trust_auto_answer(
38
- &canonical,
39
- &t,
40
- Some(&pane),
41
- &sibling,
42
- &PaneWidthQuery::Ok { pane_width: 200 },
43
- &log,
44
- )
45
- .unwrap();
46
- assert!(
47
- !sib.answered,
48
- "a SIBLING (<ws>-backup) must NOT auto-answer trust"
49
- );
50
- assert_eq!(sib.reason, "workspace_dir_mismatch");
51
- }
52
-
53
- // P1 — owner-gate worker bypass: sender == custom leader_id (state.leader.id) or the
54
- // 'Leader' literal must NOT bypass (state.py worker_sender_bypasses_owner_gate).
55
- #[test]
56
- fn p2_owner_bypass_rejects_custom_leader_id_and_capital_leader() {
57
- let ws = tmp_ws("bypassid");
58
- let log = EventLog::new(&ws);
59
- let target = MessageTarget::Single("leader".to_string());
60
-
61
- let s1 = serde_json::json!({"leader":{"id":"boss"},"agents":{"boss":{}}});
62
- assert!(
63
- !apply_worker_sender_bypass(&s1, Some("boss"), &target, None, &log).unwrap(),
64
- "sender == custom leader id must not bypass the owner gate"
65
- );
66
- let s2 = serde_json::json!({"agents":{"Leader":{}}});
67
- assert!(
68
- !apply_worker_sender_bypass(&s2, Some("Leader"), &target, None, &log).unwrap(),
69
- "'Leader' literal must not bypass"
70
- );
71
- }
72
-
73
- // P1 — owner-gate bypass honors the TEAM_AGENT_ID env identity gate: set and != sender → deny.
74
- #[test]
75
- #[serial_test::serial(env)]
76
- fn p2_owner_bypass_denies_on_env_agent_id_mismatch() {
77
- let _g = ENV_LOCK_MSG.lock().unwrap_or_else(|p| p.into_inner());
78
- let _e = EnvGuardMsg::set("TEAM_AGENT_ID", Some("other"));
79
- let ws = tmp_ws("bypassenv");
80
- let log = EventLog::new(&ws);
81
- let target = MessageTarget::Single("leader".to_string());
82
- let s = serde_json::json!({"agents":{"w1":{}}});
83
- assert!(
84
- !apply_worker_sender_bypass(&s, Some("w1"), &target, None, &log).unwrap(),
85
- "TEAM_AGENT_ID set and != sender must deny the bypass"
86
- );
87
- }
88
-
89
- // P1 — classify_agent_activity must read current_command, stale last_output, multiline /
90
- // Codex idle prompts, and Thinking/codex-spinner working indicators
91
- // (activity_detector.py:90-146). **E47 amendment (0.3.24 P0)**: the
92
- // working-indicator probe is now bottom-active-region scoped (last 1-3
93
- // non-empty lines) and looks for STRUCTURAL spinner markers (codex
94
- // `• Working (`/`Thinking`/braille; claude `✶`/`✢`), not bare lowercase
95
- // `working` anywhere in the scrollback. Pre-fix rfind across the whole
96
- // Tail(40) buffer is the macmini假阳 root cause (historical Working tokens
97
- // out-positioning a live idle composer).
98
- #[test]
99
- fn p2_classify_activity_reads_command_stale_and_prompts() {
100
- let st = serde_json::json!({});
101
- // (1) non-provider current_command → uncertain 0.75 (current drops command → 0.5).
102
- let a = classify_agent_activity(&st, "", false, Some("vim"), None);
103
- assert_eq!((a.status, a.confidence), (ActivityStatus::Uncertain, 0.75));
104
- // (2) stale last_output (≥ stuck_timeout) → stuck 0.85.
105
- let stale = (chrono::Utc::now() - chrono::Duration::seconds(400)).to_rfc3339();
106
- let b = classify_agent_activity(&st, "", false, None, Some(&stale));
107
- assert_eq!((b.status, b.confidence), (ActivityStatus::Stuck, 0.85));
108
- // (3) embedded multiline idle prompt (Codex ❯ not on its own trimmed line) → idle 0.9.
109
- let c = classify_agent_activity(&st, "some line\n❯\nmore", false, None, None);
110
- assert_eq!((c.status, c.confidence), (ActivityStatus::Idle, 0.9));
111
- // (4) 'Thinking' working indicator in the bottom active region → working 0.9.
112
- let d = classify_agent_activity(&st, "Thinking about it", false, None, None);
113
- assert_eq!((d.status, d.confidence), (ActivityStatus::Working, 0.9));
114
- // (5) E47 amendment: bare lowercase 'working on it' is NOT a structural
115
- // spinner marker; the live codex spinner is `• Working (Ns · esc to
116
- // interrupt)`. Treat as no-decisive-signal → Uncertain. The pre-fix
117
- // expectation here is exactly the macmini假阳 shape — a stale 'working'
118
- // token (without the parenthesised seconds + esc-to-interrupt tail) is
119
- // either scrollback residue or unrelated text, not a live working
120
- // indicator. To assert the Working path use the structural codex shape.
121
- let e = classify_agent_activity(&st, "working on it", false, None, None);
122
- assert_eq!((e.status, e.confidence), (ActivityStatus::Uncertain, 0.5));
123
- // (5b) E47 structural Working: a real codex live spinner in the bottom
124
- // active region must still classify Working 0.9.
125
- let e_struct =
126
- classify_agent_activity(&st, "• Working (12s · esc to interrupt)", false, None, None);
127
- assert_eq!(
128
- (e_struct.status, e_struct.confidence),
129
- (ActivityStatus::Working, 0.9)
130
- );
131
- }
132
-
133
- // P1 — scheduler dispatch must be exhaustive: an unknown kind surfaces an error, not a
134
- // silent {ok:false} (scheduler.py: 'unknown scheduled event kind: <kind>').
135
- #[test]
136
- fn p2_scheduler_unknown_kind_surfaces_error() {
137
- let ws = tmp_ws("schedunknown");
138
- let store = store_for(&ws);
139
- let conn = crate::db::schema::open_db(store.db_path()).unwrap();
140
- conn.execute(
141
- "insert into scheduled_events(owner_team_id, due_at, target, kind, payload_json, status, created_at) \
142
- values (null, '2000-01-01T00:00:00+00:00', 't', 'bogus_kind', '{}', 'pending', '2000-01-01T00:00:00+00:00')",
143
- [],
144
- )
145
- .unwrap();
146
- let log = EventLog::new(&ws);
147
- // U1 #5: unknown kind is isolated to its own row (marked terminal 'failed' +
148
- // scheduler.event_failed), NOT propagated as a pass-level Err that would halt the
149
- // batch. Failure stays loud (evented) but does not take the whole scheduler down.
150
- let fired = fire_due_scheduled_events(&ws, &store, &NoopTransport, &log)
151
- .expect("an unknown scheduled event kind must be isolated to its row, not halt the pass");
152
- assert_eq!(fired.len(), 1);
153
- assert_eq!(scheduled_status_of(&store, fired[0]), "failed");
154
- let events = log.tail(0).unwrap();
155
- assert!(
156
- events.iter().any(|event| {
157
- event.get("event").and_then(serde_json::Value::as_str) == Some("scheduler.event_failed")
158
- && event.get("event_id").and_then(serde_json::Value::as_i64) == Some(fired[0])
159
- }),
160
- "unknown scheduled event kind must leave scheduler.event_failed; events={events:?}"
161
- );
162
- }
163
-
164
- // ═════════════════════════════════════════════════════════════════════════
165
- // SPINE-WIRING (③ review→fix) RED — deliver_pending_messages + scheduler divergences
166
- // vs golden v0.2.11 (messaging/delivery.py + scheduler.py + core.py). Probes in
167
- // /tmp/spine_divergences.md (#1,#2,#6).
168
- // ═════════════════════════════════════════════════════════════════════════
169
-
170
- /// A delivery transport whose `inject` RECORDS-and-succeeds (the real deliver loop legitimately
171
- /// injects; the §84-guard NoopTransport panics). Only `inject` is reached by deliver_pending_message.
172
- #[derive(Default)]
173
- struct DeliverOkTransport {
174
- targets: Vec<PaneInfo>,
175
- }
176
- impl Transport for DeliverOkTransport {
177
- fn kind(&self) -> BackendKind {
178
- BackendKind::Tmux
179
- }
180
- fn supports_owned_native_input(&self) -> bool {
181
- true
182
- }
183
- fn spawn_first(
184
- &self,
185
- _s: &SessionName,
186
- _w: &WindowName,
187
- _a: &[String],
188
- _c: &Path,
189
- _e: &BTreeMap<String, String>,
190
- ) -> Result<SpawnResult, TransportError> {
191
- unimplemented!("not reached in delivery")
192
- }
193
- fn spawn_into(
194
- &self,
195
- _s: &SessionName,
196
- _w: &WindowName,
197
- _a: &[String],
198
- _c: &Path,
199
- _e: &BTreeMap<String, String>,
200
- ) -> Result<SpawnResult, TransportError> {
201
- unimplemented!("not reached in delivery")
202
- }
203
- fn inject(
204
- &self,
205
- _t: &Target,
206
- _p: &InjectPayload,
207
- _s: Key,
208
- _b: bool,
209
- ) -> Result<InjectReport, TransportError> {
210
- assert!(crate::transport::native_input::current_request().is_none(),
211
- "ordinary sends must use v0.5.113 direct input, not pre-paste idle admission");
212
- Ok(InjectReport {
213
- stage_reached: crate::transport::InjectStage::Submit,
214
- inject_verification: crate::transport::InjectVerification::CaptureContainsToken,
215
- submit_verification:
216
- crate::transport::SubmitVerification::EnterSentWithoutPlaceholderCheck,
217
- turn_verification: crate::transport::TurnVerification::NotYetObserved,
218
- attempts: 1,
219
- submit_diagnostics: None,
220
- })
221
- }
222
- fn send_keys(&self, _t: &Target, _k: &[Key]) -> Result<(), TransportError> {
223
- Ok(())
224
- }
225
- fn capture(&self, _t: &Target, range: CaptureRange) -> Result<CapturedText, TransportError> {
226
- Ok(CapturedText {
227
- text: String::new(),
228
- range,
229
- })
230
- }
231
- fn query(&self, _t: &Target, _f: PaneField) -> Result<Option<String>, TransportError> {
232
- Ok(None)
233
- }
234
- fn liveness(&self, _p: &PaneId) -> Result<PaneLiveness, TransportError> {
235
- Ok(PaneLiveness::Unknown)
236
- }
237
- fn list_targets(&self) -> Result<Vec<PaneInfo>, TransportError> {
238
- Ok(self.targets.clone())
239
- }
240
- fn has_session(&self, _s: &SessionName) -> Result<bool, TransportError> {
241
- Ok(true)
242
- }
243
- fn list_windows(&self, _s: &SessionName) -> Result<Vec<WindowName>, TransportError> {
244
- Ok(Vec::new())
245
- }
246
- fn set_session_env(
247
- &self,
248
- _s: &SessionName,
249
- _k: &str,
250
- _v: &str,
251
- ) -> Result<SetEnvOutcome, TransportError> {
252
- Ok(SetEnvOutcome::Applied)
253
- }
254
- fn kill_session(&self, _s: &SessionName) -> Result<(), TransportError> {
255
- Ok(())
256
- }
257
- fn kill_window(&self, _t: &Target) -> Result<(), TransportError> {
258
- Ok(())
259
- }
260
- fn attach_session(&self, _s: &SessionName) -> Result<AttachOutcome, TransportError> {
261
- Ok(AttachOutcome::Attached)
262
- }
263
- }
264
-
265
- fn set_message_status(store: &MessageStore, message_id: &str, status: &str) {
266
- let conn = crate::db::schema::open_db(store.db_path()).unwrap();
267
- conn.execute(
268
- "update messages set status = ?2 where message_id = ?1",
269
- sql_params![message_id, status],
270
- )
271
- .unwrap();
272
- }
273
- fn message_status_of(store: &MessageStore, message_id: &str) -> String {
274
- let conn = crate::db::schema::open_db(store.db_path()).unwrap();
275
- conn.query_row(
276
- "select status from messages where message_id = ?1",
277
- sql_params![message_id],
278
- |r| r.get::<_, String>(0),
279
- )
280
- .unwrap()
281
- }
282
- fn scheduled_status_of(store: &MessageStore, id: i64) -> String {
283
- let conn = crate::db::schema::open_db(store.db_path()).unwrap();
284
- conn.query_row(
285
- "select status from scheduled_events where id = ?1",
286
- [id],
287
- |r| r.get::<_, String>(0),
288
- )
289
- .unwrap()
290
- }
291
- fn seed_agent_health(store: &MessageStore, agent_id: &str, status: &str) {
292
- let conn = crate::db::schema::open_db(store.db_path()).unwrap();
293
- conn.execute(
294
- "insert into agent_health(owner_team_id, agent_id, status, last_output_at, context_usage_pct, current_task_id, updated_at) \
295
- values (null, ?1, ?2, null, null, null, ?3)",
296
- sql_params![agent_id, status, chrono::Utc::now().to_rfc3339()],
297
- )
298
- .unwrap();
299
- }
300
- fn seed_event_due(store: &MessageStore, kind: &str, due_at: &str, payload: &str) -> i64 {
301
- let conn = crate::db::schema::open_db(store.db_path()).unwrap();
302
- conn.execute(
303
- "insert into scheduled_events(owner_team_id, due_at, target, kind, payload_json, status, created_at) \
304
- values (null, ?1, 't', ?2, ?3, 'pending', ?1)",
305
- sql_params![due_at, kind, payload],
306
- )
307
- .unwrap();
308
- conn.last_insert_rowid()
309
- }
310
- fn read_event_log(ws: &Path) -> Vec<serde_json::Value> {
311
- let path = crate::model::paths::logs_dir(ws).join("events.jsonl");
312
- match std::fs::read_to_string(&path) {
313
- Ok(text) => text
314
- .lines()
315
- .filter_map(|l| serde_json::from_str(l).ok())
316
- .collect(),
317
- Err(_) => Vec::new(),
318
- }
319
- }
320
-
321
- // #1 — deliver_pending_messages delivers ONLY {pending,accepted}; queued_* rows are scheduler-owned
322
- // and must be left untouched (golden delivery.py:484 `if row["status"] not in {"pending","accepted"}: continue`).
323
- #[test]
324
- fn spine_delivery_skips_queued_statuses() {
325
- let ws = tmp_ws("deliver-queued");
326
- let store = store_for(&ws);
327
- let log = EventLog::new(&ws);
328
- let _acc = store
329
- .create_message(Some("t"), "leader", "w1", "hi", None, true, None)
330
- .unwrap();
331
- let qidle = store
332
- .create_message(Some("t"), "leader", "w1", "hi", None, true, None)
333
- .unwrap();
334
- let qstart = store
335
- .create_message(Some("t"), "leader", "w1", "hi", None, true, None)
336
- .unwrap();
337
- set_message_status(&store, &qidle, "queued_until_idle");
338
- set_message_status(&store, &qstart, "queued_until_start");
339
- let state = serde_json::json!({"agents": {"w1": {"provider": "fake"}}});
340
-
341
- let _ = deliver_pending_messages(&ws, &state, &DeliverOkTransport::default(), &log).unwrap();
342
-
343
- assert_eq!(
344
- message_status_of(&store, &qidle),
345
- "queued_until_idle",
346
- "queued_until_idle must NOT be claimed/injected/marked by deliver_pending"
347
- );
348
- assert_eq!(
349
- message_status_of(&store, &qstart),
350
- "queued_until_start",
351
- "queued_until_start must NOT be touched by deliver_pending"
352
- );
353
- }
354
-
355
- // Input is unconditional: native CLIs queue messages while working. Activity
356
- // metadata must not prevent a pending message from reaching paste + Enter.
357
- #[test]
358
- fn spine_delivery_busy_recipient_is_injected_without_idle_deferral() {
359
- let ws = tmp_ws("deliver-busy");
360
- let store = store_for(&ws);
361
- let log = EventLog::new(&ws);
362
- let mid = store
363
- .create_message(Some("t"), "leader", "w1", "hi", None, true, None)
364
- .unwrap();
365
- let state = serde_json::json!({"agents": {"w1": {"provider": "fake", "status": "busy"}}});
366
-
367
- let delivered = deliver_pending_messages(&ws, &state, &DeliverOkTransport::default(), &log).unwrap();
368
-
369
- assert!(delivered.contains(&mid));
370
- assert_eq!(message_status_of(&store, &mid), "delivered");
371
- let events = read_event_log(&ws);
372
- let deferred: Vec<_> = events
373
- .iter()
374
- .filter(|e| e.get("event").and_then(|v| v.as_str()) == Some("send.deferred_busy"))
375
- .collect();
376
- assert!(deferred.is_empty());
377
- }
378
-
379
- #[test]
380
- fn spine_delivery_refuses_retired_legacy_rows_before_input() {
381
- for (provider, expected) in [
382
- ("pi", "legacy pi seat has no runtime in this release"),
383
- ("claude", "legacy claude seat has no runtime in this release"),
384
- ("claude_code", "legacy claude seat has no runtime in this release"),
385
- ("codex", "legacy codex seat has no runtime in this release"),
386
- ("codex_cli", "legacy codex seat has no runtime in this release"),
387
- ("codex-cli", "legacy codex seat has no runtime in this release"),
388
- ("grok", "legacy grok seat has no runtime in this release"),
389
- ] {
390
- let ws = tmp_ws(&format!("retired-{provider}"));
391
- let store = store_for(&ws);
392
- let log = EventLog::new(&ws);
393
- let mid = store
394
- .create_message(Some("t"), "leader", "w1", "hi", None, true, None)
395
- .unwrap();
396
- let state = serde_json::json!({"agents": {"w1": {"provider": provider, "status": "running"}}});
397
-
398
- // NoopTransport panics on any call: the refusal precedes every pane effect.
399
- let delivered = deliver_pending_messages(&ws, &state, &NoopTransport, &log).unwrap();
400
-
401
- assert!(delivered.is_empty(), "{provider}");
402
- assert_ne!(message_status_of(&store, &mid), "delivered", "{provider}");
403
- let blocked = read_event_log(&ws)
404
- .into_iter()
405
- .find(|e| e.get("event").and_then(|v| v.as_str()) == Some("delivery.item_blocked"));
406
- assert!(
407
- blocked
408
- .as_ref()
409
- .and_then(|e| e.get("error"))
410
- .and_then(|v| v.as_str())
411
- .is_some_and(|error| error.contains(expected)),
412
- "{provider}: {blocked:?}"
413
- );
414
- }
415
- }
416
-
417
- // CONTRACT (shared-root, real-machine-driven; golden = correct-behavior baseline): an ALIVE worker
418
- // (lifecycle status="running") must be DELIVERABLE even when its turn-level agent_health=WORKING.
419
- // golden's busy gate is state.agents[recipient].status=="busy" (delivery.py:491) and status is NEVER
420
- // "busy" for an alive worker (only running/stopped), so golden never defers an alive worker. Rust
421
- // recipient_is_busy (delivery.rs:291) reads `agent_health WHERE status='WORKING'` — turn-level
422
- // idle-detection state — and defers. This is the Stage-B / stop-reset deferred_busy regression root:
423
- // turn-level agent_health must NOT gate delivery; lifecycle status (alive) does.
424
- #[test]
425
- fn contract_alive_worker_with_working_health_is_deliverable_not_deferred() {
426
- let ws = tmp_ws("deliver-alive-working");
427
- let store = store_for(&ws);
428
- let log = EventLog::new(&ws);
429
- let mid = store
430
- .create_message(Some("t"), "leader", "w1", "hi", None, true, None)
431
- .unwrap();
432
- seed_agent_health(&store, "w1", "WORKING"); // turn-level state — must NOT gate delivery
433
- let state = serde_json::json!({"agents": {"w1": {"provider": "fake", "status": "running"}}}); // lifecycle: alive
434
-
435
- let delivered = deliver_pending_messages(&ws, &state, &DeliverOkTransport::default(), &log).unwrap();
436
-
437
- let events = read_event_log(&ws);
438
- let deferred: Vec<_> = events
439
- .iter()
440
- .filter(|e| e.get("event").and_then(|v| v.as_str()) == Some("send.deferred_busy"))
441
- .collect();
442
- assert!(
443
- deferred.is_empty(),
444
- "CONTRACT: an alive worker (lifecycle status=running) must NOT be deferred_busy on agent_health=WORKING; \
445
- golden busy gate is lifecycle status=='busy' (never set for alive workers). got {deferred:?}"
446
- );
447
- assert!(
448
- delivered.contains(&mid),
449
- "the message to an alive worker must be delivered (round-trip), not deferred. delivered={delivered:?}"
450
- );
451
- }
452
-
453
- // #6a — fire_due_scheduled_events marks 'done' if result.ok else 'failed' (scheduler.py:117).
454
- // An EXHAUSTED trust_retry (attempt>=max) → handle_trust_retry_needed returns ok:false → 'failed'.
455
- #[test]
456
- fn spine_scheduler_marks_failed_when_result_not_ok() {
457
- let ws = tmp_ws("sched-failed");
458
- let store = store_for(&ws);
459
- let log = EventLog::new(&ws);
460
- let payload = serde_json::json!({"message_id": "msg_x", "attempt": 5, "max_attempts": 5, "first_target": "%1"}).to_string();
461
- let id = seed_event_due(&store, "trust_retry", "2000-01-01T00:00:00+00:00", &payload);
462
-
463
- let _ = fire_due_scheduled_events(&ws, &store, &NoopTransport, &log).unwrap();
464
-
465
- assert_eq!(
466
- scheduled_status_of(&store, id),
467
- "failed",
468
- "a not-ok result (exhausted trust_retry) must mark the scheduled event 'failed', not unconditional 'done'"
469
- );
470
- }
471
-
472
- // U1 #5 (RED) — a single poison scheduled event (malformed payload_json that errors at
473
- // `serde_json::from_str?`) must NOT halt the whole pass: it must be marked terminal 'failed'
474
- // + emit `scheduler.event_failed`, and a healthy event seeded AFTER it must still fire.
475
- // Today the bare `?` aborts `fire_due_scheduled_events`, the healthy event never fires → RED.
476
- #[test]
477
- fn spine_scheduler_poison_event_does_not_halt_batch() {
478
- let ws = tmp_ws("sched-poison");
479
- let store = store_for(&ws);
480
- let log = EventLog::new(&ws);
481
- // earlier due_at → selected first; malformed JSON payload errors at from_str.
482
- let poison = seed_event_due(
483
- &store,
484
- "send",
485
- "2000-01-01T00:00:00+00:00",
486
- "{not valid json",
487
- );
488
- // later due_at → selected after poison; healthy.
489
- let healthy = seed_event_due(&store, "health_ping", "2000-01-02T00:00:00+00:00", "{}");
490
-
491
- let fired = fire_due_scheduled_events(&ws, &store, &NoopTransport, &log)
492
- .expect("a poison event must not propagate as a pass-level Err (must isolate + continue)");
493
-
494
- // poison marked terminal failed (not re-fired every tick).
495
- assert_eq!(
496
- scheduled_status_of(&store, poison),
497
- "failed",
498
- "U1 #5: a poison scheduled event must be marked terminal 'failed', not halt the pass"
499
- );
500
- // healthy event AFTER the poison still fired.
501
- assert!(
502
- fired.contains(&healthy),
503
- "U1 #5: a healthy event after a poison one must still fire (batch not halted); fired={fired:?}"
504
- );
505
- // failure is loud: scheduler.event_failed event emitted for the poison.
506
- let events = read_event_log(&ws);
507
- assert!(
508
- events
509
- .iter()
510
- .any(|e| e.get("event").and_then(|v| v.as_str()) == Some("scheduler.event_failed")),
511
- "U1 #5: a poison event must emit scheduler.event_failed (failure must be loud, not silent)"
512
- );
513
- }
514
-
515
- // #6b — due events fire in (due_at, id) order (core.py due_scheduled_events), not id order.
516
- #[test]
517
- fn spine_scheduler_orders_due_events_by_due_at_then_id() {
518
- let ws = tmp_ws("sched-order");
519
- let store = store_for(&ws);
520
- let log = EventLog::new(&ws);
521
- // smaller id is due LATER → due_at order must reverse the id order.
522
- let a_late = seed_event_due(&store, "health_ping", "2000-01-02T00:00:00+00:00", "{}");
523
- let b_early = seed_event_due(&store, "health_ping", "2000-01-01T00:00:00+00:00", "{}");
524
-
525
- let fired = fire_due_scheduled_events(&ws, &store, &NoopTransport, &log).unwrap();
526
-
527
- assert_eq!(
528
- fired,
529
- vec![b_early, a_late],
530
- "fire order must be by (due_at, id) — earlier-due fires first; current orders by id only. got {fired:?}"
531
- );
532
- }
533
-
534
- // ═════════════════════════════════════════════════════════════════════════
535
- // rt-host-a LOOP #3 — coordinator deliver tick injects to the AGENT ID treated as a bare PANE-ID.
536
- // delivery.rs:127 builds Target::Pane(PaneId::new(message.recipient)) where recipient is the agent id
537
- // ("w1"). A coordinator process with NO attached tmux client cannot resolve a bare name -> every tick
538
- // "can't find pane: w1" -> message stuck -> no delivery. The fix (porter/leader): resolve the recipient
539
- // to a SESSION-QUALIFIED target (SessionWindow{session: state.session_name, window: agent.window}) OR
540
- // the persisted state.agents[recipient].pane_id — mirroring coordinator/tick.rs::capture_target —
541
- // NEVER Target::Pane(agent_id). 793/0/21 missed it: the deliver tests use a non-asserting transport.
542
- // ═════════════════════════════════════════════════════════════════════════
543
-
544
- // RED — deliver_pending_messages must inject to a RESOLVABLE target (session-qualified or a real
545
- // pane-id), NOT the bare agent-id treated as a pane. Today delivery.rs:127 records
546
- // Target::Pane(PaneId("w1")) -> a non-attached coordinator can't resolve it -> RED at assert_ne!.
547
- #[test]
548
- fn spine_delivery_injects_resolvable_target_not_bare_agent_pane() {
549
- let ws = tmp_ws("deliver-target");
550
- let store = store_for(&ws);
551
- let log = EventLog::new(&ws);
552
- let _mid = store
553
- .create_message(Some("t"), "leader", "w1", "hi", None, true, None)
554
- .unwrap();
555
- // in-team, non-busy agent -> deliver proceeds; the session-qualified resolution uses session_name + window.
556
- let state = serde_json::json!({
557
- "session_name": "team-x",
558
- "agents": {"w1": {"provider": "fake", "status": "idle", "window": "w1"}}
559
- });
560
- let transport = OfflineTransport::new();
561
-
562
- let _ = deliver_pending_messages(&ws, &state, &transport, &log).unwrap();
563
-
564
- let recorded = transport.inject_targets();
565
- assert_eq!(
566
- recorded.len(),
567
- 1,
568
- "deliver must inject the one pending message exactly once; got {recorded:?}"
569
- );
570
- let target = recorded[0].clone();
571
- // THE BUG (rt-host-a #3): deliver builds Target::Pane(PaneId(message.recipient)) — the agent id as a
572
- // BARE pane, which a non-attached coordinator can't resolve ("can't find pane: w1").
573
- assert_ne!(
574
- target,
575
- Target::Pane(PaneId::new("w1")),
576
- "deliver must NOT inject to the bare agent-id as a pane-id (a non-attached coordinator can't \
577
- resolve it -> 'can't find pane: w1'); expected a SESSION-QUALIFIED target \
578
- (SessionWindow{{session: team-x, window: w1}}) or the persisted pane-id, got {target:?}"
579
- );
580
- // ...and it must be a genuinely resolvable target: session-qualified (session=team-x) or a real
581
- // pane-id (anything but the bare agent name).
582
- let resolvable = match &target {
583
- Target::SessionWindow { session, .. } => session.as_str() == "team-x",
584
- Target::Pane(pane) => pane.as_str() != "w1",
585
- };
586
- assert!(
587
- resolvable,
588
- "deliver must resolve recipient 'w1' to session=team-x (session-qualified) or a real pane-id; got {target:?}"
589
- );
590
- }
591
-
592
- // ═════════════════════════════════════════════════════════════════════════
593
- // rt-host-a LOOP #4 — coordinator injects the RAW message content, but the worker only builds a
594
- // result_envelope when it sees the RENDERED protocol block ending [team-agent-token:<message_id>]. So
595
- // workers go WORKING but never report -> results=0, no round-trip. delivery.rs:131 injects
596
- // InjectPayload::Text(message.content) (bare). The fix (leader): port render_message before inject —
597
- // GOLDEN (rust_core.py:60-73, captured live):
598
- // "Team Agent message from {sender}[ for {task_id}]:\n\n{content}\n\n[team-agent-token:{message_id}]"
599
- // ═════════════════════════════════════════════════════════════════════════
600
-
601
- // RED — deliver must inject the RENDERED protocol block (header + content + [team-agent-token:<id>]),
602
- // NOT the raw content. Today the payload is the bare "do the thing" (no header, no token) -> RED.
603
- #[test]
604
- fn spine_delivery_injects_rendered_protocol_block_not_raw_content() {
605
- let ws = tmp_ws("deliver-render");
606
- let store = store_for(&ws);
607
- let log = EventLog::new(&ws);
608
- let mid = store
609
- .create_message(Some("t1"), "leader", "w1", "do the thing", None, true, None)
610
- .unwrap();
611
- let state = serde_json::json!({
612
- "session_name": "team-x",
613
- "agents": {"w1": {"provider": "fake", "status": "idle", "window": "w1"}}
614
- });
615
- let transport = OfflineTransport::new();
616
-
617
- let _ = deliver_pending_messages(&ws, &state, &transport, &log).unwrap();
618
-
619
- let recorded = transport.inject_payloads();
620
- assert_eq!(
621
- recorded.len(),
622
- 1,
623
- "deliver must inject the one pending message exactly once; got {recorded:?}"
624
- );
625
- let payload = recorded[0].clone();
626
- // THE BUG (rt-host-a #4): deliver injects the RAW content -> the worker never reports (it only builds
627
- // a result_envelope on the rendered block with the token).
628
- assert_ne!(
629
- payload, "do the thing",
630
- "deliver must NOT inject the bare content; the worker only reports on the rendered protocol block \
631
- (with [team-agent-token:<id>]) — bare text -> WORKING but never reports -> results=0; got {payload:?}"
632
- );
633
- assert!(
634
- payload.contains("Team Agent message from leader for t1:"),
635
- "the injected payload must be the rendered protocol header (sender + task): 'Team Agent message \
636
- from leader for t1:'; got {payload:?}"
637
- );
638
- assert!(
639
- payload.contains("do the thing"),
640
- "the rendered block must carry the content; got {payload:?}"
641
- );
642
- let token_line = format!("[team-agent-token:{mid}]");
643
- assert!(
644
- payload.contains(&token_line),
645
- "the rendered block must end with the token line {token_line:?} (token == message_id) so the \
646
- worker builds a result_envelope; got {payload:?}"
647
- );
648
- }
649
-
650
- // ═════════════════════════════════════════════════════════════════════════════
651
- // E47 (0.3.24 P0, idle/busy 假阳) — TUI keyword grep is structurally bounded.
652
- //
653
- // Real-machine repro (macmini): a Tail(40) capture of an idle codex worker
654
- // still carries historical `• Working (514s · esc to interrupt)` plus a
655
- // `─ Worked for 8m 34s ─` summary plus a fresh `❯ Run /review` prompt. The
656
- // pre-fix `working_seconds` full-buffer find matched the 514s token and
657
- // returned ≥300 → Stuck. The pre-fix `latest_prompt_signal` rfind let the
658
- // historical spinner out-position the bottom `❯` → Working. E47 narrows
659
- // both probes to the bottom active region (last 1-3 non-empty lines).
660
- //
661
- // The authoritative provider JSONL classify is wired in coordinator/tick.rs
662
- // (jsonl_activity_for_agent); these unit tests pin the TUI fallback layer.
663
- // ═════════════════════════════════════════════════════════════════════════════
664
-
665
- #[test]
666
- fn e47_codex_idle_with_historical_working_in_scrollback_is_idle_not_stuck_or_working() {
667
- // Exact macmini repro shape from the architect locate (E47).
668
- let scrollback = "• Working (514s · esc to interrupt)\n\
669
- tool call 1\n\
670
- tool call 2\n\
671
- ─ Worked for 8m 34s ─\n\
672
- › Run /review\n\
673
- ❯ ";
674
- let st = serde_json::json!({});
675
- let a = classify_agent_activity(&st, scrollback, false, None, None);
676
- assert_eq!(
677
- a.status,
678
- ActivityStatus::Idle,
679
- "E47 (RED-1): codex idle worker whose scrollback still carries \
680
- historical `• Working (514s · esc to interrupt)` must classify IDLE \
681
- (bottom active region is `❯`+`› Run /review` = idle composer). \
682
- pre-fix: Stuck/Working via rfind-recency. Got {a:?}"
683
- );
684
- }
685
-
686
- #[test]
687
- fn e47_past_tense_worked_for_is_not_stale_working_indicator() {
688
- // RED-2: past-tense `Worked for` summary line must NOT trigger
689
- // working_seconds Stuck. The pre-fix scanned the whole buffer and would
690
- // match the embedded `8m 34s ─` against `working (` if formatted slightly
691
- // differently — but more importantly this test pins the "past-tense
692
- // summary is idle context" semantics.
693
- let scrollback = "─ Worked for 8m 34s ─\n❯ ";
694
- let st = serde_json::json!({});
695
- let a = classify_agent_activity(&st, scrollback, false, None, None);
696
- assert_ne!(
697
- a.status,
698
- ActivityStatus::Stuck,
699
- "E47 (RED-2): past-tense `Worked for 8m 34s` must NOT trigger \
700
- stale_working_indicator Stuck. Got {a:?}"
701
- );
702
- assert_eq!(
703
- a.status,
704
- ActivityStatus::Idle,
705
- "E47 (RED-2): bottom `❯` composer = idle. Got {a:?}"
706
- );
707
- }
708
-
709
- #[test]
710
- fn e47_claude_idle_with_historical_spinner_classifies_idle() {
711
- // RED-3: claude idle worker; historical spinner shape (`✶` per
712
- // adapter.rs:875-876) earlier in the buffer (>= 3 non-empty lines deep),
713
- // bottom composer is idle (`›` glyph variant or `> ` claude prompt).
714
- // The bottom active region (last 3 non-empty lines) has NO spinner.
715
- let scrollback = "✶ Working on plan\n\
716
- tool 1\n\
717
- tool 2\n\
718
- assistant reply text\n\
719
- summary line A\n\
720
- summary line B\n\
721
- › Continue?";
722
- let st = serde_json::json!({});
723
- let a = classify_agent_activity(&st, scrollback, false, None, None);
724
- assert_eq!(
725
- a.status,
726
- ActivityStatus::Idle,
727
- "E47 (RED-3): claude idle worker — historical ✶ above, idle `›` \
728
- below — must classify IDLE. Got {a:?}"
729
- );
730
- }
731
-
732
- #[test]
733
- fn e47_codex_live_spinner_in_bottom_active_region_classifies_working() {
734
- // RED-4 (defence vs over-tightening 假阴): a TRULY busy codex worker
735
- // whose bottom active region carries the live spinner must still be
736
- // Working. No idle composer present.
737
- let scrollback = "tool call x\nassistant response so far\n• Working (12s · esc to interrupt)";
738
- let st = serde_json::json!({});
739
- let a = classify_agent_activity(&st, scrollback, false, None, None);
740
- assert_eq!(
741
- a.status,
742
- ActivityStatus::Working,
743
- "E47 (RED-4): live codex spinner in bottom active region must \
744
- classify Working. Got {a:?}"
745
- );
746
- }
747
-
748
- #[test]
749
- fn e47_claude_live_working_in_bottom_active_region_classifies_working() {
750
- // RED-5: a TRULY busy claude worker showing `✶ Working` at the bottom
751
- // active region must be Working — even without the `(Ns)` codex shape.
752
- let scrollback = "earlier output\nmore output\n✶ Working through the request";
753
- let st = serde_json::json!({});
754
- let a = classify_agent_activity(&st, scrollback, false, None, None);
755
- assert_eq!(
756
- a.status,
757
- ActivityStatus::Working,
758
- "E47 (RED-5): claude ✶ Working in bottom active region → Working. \
759
- Got {a:?}"
760
- );
761
- }
762
-
763
- #[test]
764
- fn worker_state_claude_code_busy_signal_within_bottom_five_classifies_working() {
765
- let scrollback = "older output\n\
766
- ✻ Searching files\n\
767
- Reading src/lib.rs\n\
768
- tool progress\n\
769
- status line\n\
770
- › Continue?\n\
771
- ❯ ";
772
- let st = serde_json::json!({});
773
- let a = classify_agent_activity(&st, scrollback, false, Some("claude"), None);
774
- assert_eq!(
775
- a.status,
776
- ActivityStatus::Working,
777
- "Claude Code busy signal inside the bottom five active lines must \
778
- classify Working even when an idle prompt glyph is also visible. Got {a:?}"
779
- );
780
- }
781
-
782
- #[test]
783
- fn worker_state_historical_claude_code_busy_above_bottom_five_stays_idle() {
784
- let scrollback = "✻ Searching old result\n\
785
- historical tool output\n\
786
- line 1\n\
787
- line 2\n\
788
- line 3\n\
789
- line 4\n\
790
- › Continue?\n\
791
- ❯ ";
792
- let st = serde_json::json!({});
793
- let a = classify_agent_activity(&st, scrollback, false, Some("claude"), None);
794
- assert_eq!(
795
- a.status,
796
- ActivityStatus::Idle,
797
- "Claude Code busy signal above the bottom five active lines is \
798
- scrollback history and must not override the live idle prompt. Got {a:?}"
799
- );
800
- }
801
-
802
- #[test]
803
- fn e47_iron_law_no_signal_in_bottom_region_stays_uncertain_not_idle() {
804
- // Defence: IRON LAW (activity.rs:3 / bug-071/077/085). When the bottom
805
- // active region has no spinner AND no `❯`/`›` AND no other decisive
806
- // signal, classify_agent_activity falls through to no_decisive_signal →
807
- // Uncertain — NEVER silently to Idle.
808
- let scrollback = "some neutral text\nmore neutral text\nstill nothing decisive";
809
- let st = serde_json::json!({});
810
- let a = classify_agent_activity(&st, scrollback, false, None, None);
811
- assert_eq!(
812
- a.status,
813
- ActivityStatus::Uncertain,
814
- "E47 IRON LAW guard: bottom region carries no spinner and no idle \
815
- composer → Uncertain, never silently Idle. Got {a:?}"
816
- );
817
- }
818
-
819
- // #379: Claude Code's spinner row sits above its composer box (outside the
820
- // bottom five rows) while a finished turn's `✻ Worked for 3s` sits inside them.
821
- fn claude_379_scrollback(above: &str) -> String {
822
- let rule = "─".repeat(56);
823
- format!(
824
- "❯ do the task\n\n⏺ Working through the files.\n\n{above}\n ◐ medium · /effort\n{rule}\n❯ \n{rule}\n ⏵⏵ bypass permissions on (shift+tab to cycle)\n"
825
- )
826
- }
827
-
828
- #[test]
829
- fn issue379_claude_spinner_above_the_box_is_working_and_a_finished_turn_is_idle() {
830
- let st = serde_json::json!({});
831
- for spinner in ["· Waddling…", "✢ Boondoggling… (3s · thinking)"] {
832
- let a = classify_agent_activity(&st, &claude_379_scrollback(spinner), false, None, None);
833
- assert_eq!(a.status, ActivityStatus::Working, "{spinner}: {a:?}");
834
- }
835
- let a = classify_agent_activity(&st, &claude_379_scrollback("✻ Worked for 3s"), false, None, None);
836
- assert_eq!(a.status, ActivityStatus::Idle, "{a:?}");
837
- }