@team-agent/installer 0.5.60 → 0.5.62

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 (265) hide show
  1. package/Cargo.lock +1 -1
  2. package/Cargo.toml +1 -1
  3. package/crates/team-agent/src/cli/adapters.rs +49 -3
  4. package/crates/team-agent/src/cli/attach_app_server_leader.rs +1 -0
  5. package/crates/team-agent/src/cli/diagnose.rs +184 -0
  6. package/crates/team-agent/src/cli/emit.rs +104 -21
  7. package/crates/team-agent/src/cli/helpers.rs +1 -0
  8. package/crates/team-agent/src/cli/leader.rs +14 -2
  9. package/crates/team-agent/src/cli/leaders.rs +2 -0
  10. package/crates/team-agent/src/cli/mod.rs +296 -8
  11. package/crates/team-agent/src/cli/named_address.rs +26 -2
  12. package/crates/team-agent/src/cli/profile.rs +2 -1
  13. package/crates/team-agent/src/cli/send/coordinator.rs +1 -0
  14. package/crates/team-agent/src/cli/send/mailbox.rs +3 -0
  15. package/crates/team-agent/src/cli/send/persist.rs +1 -0
  16. package/crates/team-agent/src/cli/send/presentation.rs +3 -0
  17. package/crates/team-agent/src/cli/send/resolve.rs +206 -1
  18. package/crates/team-agent/src/cli/send.rs +2 -1
  19. package/crates/team-agent/src/cli/spec.rs +5 -1
  20. package/crates/team-agent/src/cli/status.rs +2 -1
  21. package/crates/team-agent/src/cli/status_port/compact.rs +1 -0
  22. package/crates/team-agent/src/cli/status_port/format.rs +1 -0
  23. package/crates/team-agent/src/cli/status_port/inbox.rs +1 -0
  24. package/crates/team-agent/src/cli/status_port/store.rs +7 -3
  25. package/crates/team-agent/src/cli/tests/named_address.rs +65 -0
  26. package/crates/team-agent/src/cli/tests/verb_profile.rs +38 -0
  27. package/crates/team-agent/src/cli/types.rs +36 -2
  28. package/crates/team-agent/src/communication_mode/mod.rs +54 -0
  29. package/crates/team-agent/src/compiler/tests.rs +5 -5
  30. package/crates/team-agent/src/compiler.rs +54 -1
  31. package/crates/team-agent/src/conpty/backend.rs +1 -0
  32. package/crates/team-agent/src/conpty/mod.rs +1 -0
  33. package/crates/team-agent/src/coordinator/backoff.rs +5 -8
  34. package/crates/team-agent/src/coordinator/conpty_shim.rs +3 -2
  35. package/crates/team-agent/src/coordinator/health.rs +1 -0
  36. package/crates/team-agent/src/coordinator/mod.rs +2 -2
  37. package/crates/team-agent/src/coordinator/orphan.rs +4 -116
  38. package/crates/team-agent/src/coordinator/runtime_detectors.rs +1 -0
  39. package/crates/team-agent/src/coordinator/runtime_observation.rs +1 -0
  40. package/crates/team-agent/src/coordinator/steps/abnormal.rs +6 -5
  41. package/crates/team-agent/src/coordinator/steps/delivery.rs +1 -0
  42. package/crates/team-agent/src/coordinator/steps/health_sync.rs +1 -0
  43. package/crates/team-agent/src/coordinator/steps/mod.rs +2 -0
  44. package/crates/team-agent/src/coordinator/steps/persist.rs +1 -0
  45. package/crates/team-agent/src/coordinator/steps/runtime_prompts.rs +1 -0
  46. package/crates/team-agent/src/coordinator/steps/session_gate.rs +1 -0
  47. package/crates/team-agent/src/coordinator/tests/abnormal.rs +0 -174
  48. package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +0 -9
  49. package/crates/team-agent/src/coordinator/tests/basics.rs +0 -184
  50. package/crates/team-agent/src/coordinator/tests/mod.rs +2 -17
  51. package/crates/team-agent/src/coordinator/tests/tick_core.rs +0 -42
  52. package/crates/team-agent/src/coordinator/tick.rs +24 -28
  53. package/crates/team-agent/src/coordinator/types.rs +3 -176
  54. package/crates/team-agent/src/db/agent_health_capture.rs +1 -0
  55. package/crates/team-agent/src/db/message_store.rs +47 -2
  56. package/crates/team-agent/src/db/migration.rs +5 -4
  57. package/crates/team-agent/src/db/mod.rs +1 -0
  58. package/crates/team-agent/src/db/schema.rs +1 -0
  59. package/crates/team-agent/src/diagnose/comms.rs +2 -1
  60. package/crates/team-agent/src/diagnose/mod.rs +1 -0
  61. package/crates/team-agent/src/diagnose/orphans.rs +1 -0
  62. package/crates/team-agent/src/fake_worker.rs +21 -1
  63. package/crates/team-agent/src/layout/manager.rs +3 -7
  64. package/crates/team-agent/src/layout/mod.rs +2 -2
  65. package/crates/team-agent/src/layout/overlay.rs +6 -1
  66. package/crates/team-agent/src/layout/placement.rs +1 -0
  67. package/crates/team-agent/src/layout/recovery.rs +3 -0
  68. package/crates/team-agent/src/layout/runtime_sessions.rs +8 -3
  69. package/crates/team-agent/src/layout/sessions.rs +8 -1
  70. package/crates/team-agent/src/layout/tmux_endpoint.rs +3 -0
  71. package/crates/team-agent/src/layout/worker_env.rs +3 -0
  72. package/crates/team-agent/src/layout/worker_window_helpers.rs +2 -0
  73. package/crates/team-agent/src/leader/helpers.rs +1 -0
  74. package/crates/team-agent/src/leader/incident.rs +1 -0
  75. package/crates/team-agent/src/leader/lease.rs +27 -22
  76. package/crates/team-agent/src/leader/mod.rs +2 -3
  77. package/crates/team-agent/src/leader/owner_bind.rs +13 -3
  78. package/crates/team-agent/src/leader/provider_attribution.rs +1 -0
  79. package/crates/team-agent/src/leader/rediscover.rs +4 -17
  80. package/crates/team-agent/src/leader/registry.rs +3 -15
  81. package/crates/team-agent/src/leader/start.rs +1072 -186
  82. package/crates/team-agent/src/leader/takeover.rs +10 -232
  83. package/crates/team-agent/src/leader/tests/claim_leader_mailbox_flush_contract.rs +544 -0
  84. package/crates/team-agent/src/leader/tests/historical_inventory_upgrade_gate_red.rs +624 -0
  85. package/crates/team-agent/src/leader/tests/identity.rs +71 -59
  86. package/crates/team-agent/src/leader/tests/identity_session_names.rs +42 -0
  87. package/crates/team-agent/src/leader/tests/idle.rs +0 -193
  88. package/crates/team-agent/src/leader/tests/lease_api.rs +0 -45
  89. package/crates/team-agent/src/leader/tests/mod.rs +4 -41
  90. package/crates/team-agent/src/leader/tests/rehomed_env.rs +83 -0
  91. package/crates/team-agent/src/leader/tests/team_in_team_state_scope_red.rs +1273 -0
  92. package/crates/team-agent/src/leader/tests/terminal_and_replay_vs_rerender_invariants_red.rs +417 -0
  93. package/crates/team-agent/src/leader/tests/wake_start_owner.rs +22 -103
  94. package/crates/team-agent/src/leader/types.rs +1 -28
  95. package/crates/team-agent/src/lib.rs +7 -0
  96. package/crates/team-agent/src/lifecycle/display.rs +7 -1
  97. package/crates/team-agent/src/lifecycle/helpers.rs +3 -1
  98. package/crates/team-agent/src/lifecycle/launch/add_agent.rs +2 -2
  99. package/crates/team-agent/src/lifecycle/launch/fork_agent/completion.rs +1 -0
  100. package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +1 -1
  101. package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +1 -0
  102. package/crates/team-agent/src/lifecycle/launch/fork_finalize.rs +1 -0
  103. package/crates/team-agent/src/lifecycle/launch/plan.rs +2 -2
  104. package/crates/team-agent/src/lifecycle/launch/quick_start.rs +4 -26
  105. package/crates/team-agent/src/lifecycle/launch/readiness.rs +0 -27
  106. package/crates/team-agent/src/lifecycle/launch/spawn.rs +2 -28
  107. package/crates/team-agent/src/lifecycle/launch/spec_state.rs +4 -32
  108. package/crates/team-agent/src/lifecycle/launch/state_projection.rs +1 -0
  109. package/crates/team-agent/src/lifecycle/launch.rs +11 -12
  110. package/crates/team-agent/src/lifecycle/mod.rs +2 -1
  111. package/crates/team-agent/src/lifecycle/restart/agent.rs +4 -4
  112. package/crates/team-agent/src/lifecycle/restart/common.rs +1 -1
  113. package/crates/team-agent/src/lifecycle/restart/orchestrator.rs +2 -2
  114. package/crates/team-agent/src/lifecycle/restart/rebuild.rs +13 -5
  115. package/crates/team-agent/src/lifecycle/restart/remove.rs +1 -1
  116. package/crates/team-agent/src/lifecycle/restart/selection.rs +3 -3
  117. package/crates/team-agent/src/lifecycle/restart.rs +13 -11
  118. package/crates/team-agent/src/lifecycle/tests/acceptance_b_batch_red.rs +1007 -0
  119. package/crates/team-agent/src/lifecycle/tests/b0_legacy_snapshot_nonauthority_contract.rs +265 -0
  120. package/crates/team-agent/src/lifecycle/tests/b0_reader_hideone_audit_contract.rs +459 -0
  121. package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +849 -0
  122. package/crates/team-agent/src/lifecycle/tests/claude_compatible_config_red.rs +323 -0
  123. package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +423 -0
  124. package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +737 -0
  125. package/crates/team-agent/src/lifecycle/tests/codex_mcp_approval_inheritance_red.rs +1187 -0
  126. package/crates/team-agent/src/lifecycle/tests/codex_weak_window_attribution_red.rs +683 -0
  127. package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +394 -0
  128. package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +1856 -0
  129. package/crates/team-agent/src/lifecycle/tests/core_034_real_red.rs +917 -0
  130. package/crates/team-agent/src/lifecycle/tests/display_adaptive_red.rs +481 -0
  131. package/crates/team-agent/src/lifecycle/tests/f032_startup_prompt_best_effort_red.rs +301 -0
  132. package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +516 -0
  133. package/crates/team-agent/src/lifecycle/tests/host_cotenant_death_p0_contract.rs +986 -0
  134. package/crates/team-agent/src/lifecycle/tests/lifecycle_rollback_red.rs +651 -0
  135. package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +2 -0
  136. package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +332 -0
  137. package/crates/team-agent/src/lifecycle/tests/realmachine_clusters_1_6_red.rs +846 -0
  138. package/crates/team-agent/src/lifecycle/tests/realmachine_residual_g1_g4_red.rs +648 -0
  139. package/crates/team-agent/src/lifecycle/tests/restart_build_before_destroy_0540_contract.rs +910 -0
  140. package/crates/team-agent/src/lifecycle/tests/restart_liveness_red.rs +630 -0
  141. package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +1083 -0
  142. package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +1677 -0
  143. package/crates/team-agent/src/lifecycle/tests/resume_recover_red.rs +410 -0
  144. package/crates/team-agent/src/lifecycle/tests/stale_team_saveconflict_contract.rs +428 -0
  145. package/crates/team-agent/src/lifecycle/tests/startup_latency_contract.rs +1032 -0
  146. package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +869 -0
  147. package/crates/team-agent/src/lifecycle/tests/subprep_codex_trust_roundtrip_red.rs +1249 -0
  148. package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +342 -0
  149. package/crates/team-agent/src/lifecycle/tests/team_in_team_identity_scope_red.rs +542 -0
  150. package/crates/team-agent/src/lifecycle/tests/team_in_team_sibling_quick_start_red.rs +1103 -0
  151. package/crates/team-agent/src/lifecycle/tests/team_in_team_state_scope_red.rs +1276 -0
  152. package/crates/team-agent/src/lifecycle/tests/team_key_retirement_roster_red.rs +145 -0
  153. package/crates/team-agent/src/lifecycle/tests/team_key_retirement_txn_red.rs +603 -0
  154. package/crates/team-agent/src/lifecycle/tests/test_isolation_escape_contract.rs +837 -0
  155. package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +928 -0
  156. package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +951 -0
  157. package/crates/team-agent/src/lifecycle/tests/worker_dangerous_bypass_argv_red.rs +327 -0
  158. package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +760 -0
  159. package/crates/team-agent/src/lifecycle/tests.rs +59 -0
  160. package/crates/team-agent/src/lifecycle/types.rs +0 -9
  161. package/crates/team-agent/src/lifecycle/worker_command_context.rs +29 -11
  162. package/crates/team-agent/src/mcp_server/helpers.rs +1 -0
  163. package/crates/team-agent/src/mcp_server/lifecycle_tools/mod.rs +1 -0
  164. package/crates/team-agent/src/mcp_server/lifecycle_tools/state_status.rs +1 -0
  165. package/crates/team-agent/src/mcp_server/mod.rs +1 -0
  166. package/crates/team-agent/src/mcp_server/normalize.rs +5 -3
  167. package/crates/team-agent/src/mcp_server/tests/send.rs +26 -0
  168. package/crates/team-agent/src/mcp_server/tests/wire.rs +1 -1
  169. package/crates/team-agent/src/mcp_server/tools.rs +101 -66
  170. package/crates/team-agent/src/mcp_server/types.rs +6 -18
  171. package/crates/team-agent/src/mcp_server/wire.rs +32 -26
  172. package/crates/team-agent/src/messaging/activity.rs +1 -0
  173. package/crates/team-agent/src/messaging/address.rs +1 -0
  174. package/crates/team-agent/src/messaging/delivery.rs +109 -41
  175. package/crates/team-agent/src/messaging/helpers.rs +2 -1
  176. package/crates/team-agent/src/messaging/leader_channel.rs +34 -10
  177. package/crates/team-agent/src/messaging/leader_receiver.rs +42 -24
  178. package/crates/team-agent/src/messaging/mod.rs +10 -14
  179. package/crates/team-agent/src/messaging/peers.rs +2 -0
  180. package/crates/team-agent/src/messaging/persist.rs +3 -1
  181. package/crates/team-agent/src/messaging/presentation.rs +111 -1
  182. package/crates/team-agent/src/messaging/results.rs +166 -17
  183. package/crates/team-agent/src/messaging/scheduler.rs +1 -0
  184. package/crates/team-agent/src/messaging/selftest.rs +1 -1
  185. package/crates/team-agent/src/messaging/send.rs +135 -89
  186. package/crates/team-agent/src/messaging/tests/leader_channel.rs +6 -6
  187. package/crates/team-agent/src/messaging/tests/leader_inject_acceptance.rs +187 -0
  188. package/crates/team-agent/src/messaging/tests/mod.rs +5 -0
  189. package/crates/team-agent/src/messaging/tests/runtime.rs +13 -6
  190. package/crates/team-agent/src/messaging/types.rs +7 -2
  191. package/crates/team-agent/src/messaging/watchers.rs +24 -13
  192. package/crates/team-agent/src/model/enums.rs +1 -0
  193. package/crates/team-agent/src/model/errors.rs +1 -0
  194. package/crates/team-agent/src/model/ids.rs +1 -0
  195. package/crates/team-agent/src/model/mod.rs +2 -0
  196. package/crates/team-agent/src/model/name_similarity.rs +1 -0
  197. package/crates/team-agent/src/model/pane_authority_refusal.rs +359 -0
  198. package/crates/team-agent/src/model/paths.rs +1 -0
  199. package/crates/team-agent/src/model/permissions.rs +3 -2
  200. package/crates/team-agent/src/model/routing.rs +1 -0
  201. package/crates/team-agent/src/model/spec.rs +17 -0
  202. package/crates/team-agent/src/model/task_graph.rs +1 -0
  203. package/crates/team-agent/src/model/yaml/tests.rs +1 -0
  204. package/crates/team-agent/src/model/yaml.rs +1 -0
  205. package/crates/team-agent/src/packaging/install.rs +9 -147
  206. package/crates/team-agent/src/packaging/migrate.rs +2 -0
  207. package/crates/team-agent/src/packaging/mod.rs +1 -0
  208. package/crates/team-agent/src/packaging/repair.rs +2 -0
  209. package/crates/team-agent/src/packaging/tests.rs +29 -218
  210. package/crates/team-agent/src/packaging/types.rs +8 -15
  211. package/crates/team-agent/src/platform/argv.rs +4 -0
  212. package/crates/team-agent/src/platform/errors.rs +10 -1
  213. package/crates/team-agent/src/platform/file_lock.rs +4 -157
  214. package/crates/team-agent/src/platform/mod.rs +0 -61
  215. package/crates/team-agent/src/platform/process.rs +1 -0
  216. package/crates/team-agent/src/provider/adapter.rs +1 -0
  217. package/crates/team-agent/src/provider/adapters/claude.rs +1 -0
  218. package/crates/team-agent/src/provider/adapters/claude_fork.rs +1 -0
  219. package/crates/team-agent/src/provider/adapters/codex.rs +1 -0
  220. package/crates/team-agent/src/provider/adapters/copilot.rs +1 -0
  221. package/crates/team-agent/src/provider/adapters/copilot_fork.rs +1 -0
  222. package/crates/team-agent/src/provider/adapters/fake.rs +1 -0
  223. package/crates/team-agent/src/provider/adapters/mod.rs +1 -0
  224. package/crates/team-agent/src/provider/approvals/mod.rs +1 -0
  225. package/crates/team-agent/src/provider/approvals/parsing.rs +2 -5
  226. package/crates/team-agent/src/provider/approvals/runtime_prompts.rs +6 -5
  227. package/crates/team-agent/src/provider/classify.rs +1 -0
  228. package/crates/team-agent/src/provider/faults.rs +1 -26
  229. package/crates/team-agent/src/provider/helpers.rs +1 -0
  230. package/crates/team-agent/src/provider/mod.rs +1 -1
  231. package/crates/team-agent/src/provider/session/capture.rs +41 -22
  232. package/crates/team-agent/src/provider/session/context_fork/claude.rs +1 -0
  233. package/crates/team-agent/src/provider/session/context_fork/codex.rs +1 -0
  234. package/crates/team-agent/src/provider/session/context_fork/outcome.rs +1 -0
  235. package/crates/team-agent/src/provider/session/context_fork.rs +1 -0
  236. package/crates/team-agent/src/provider/session/mod.rs +2 -4
  237. package/crates/team-agent/src/provider/session/resume.rs +2 -209
  238. package/crates/team-agent/src/provider/session_scan/claude.rs +93 -3
  239. package/crates/team-agent/src/provider/session_scan/codex.rs +1 -0
  240. package/crates/team-agent/src/provider/session_scan/common.rs +24 -7
  241. package/crates/team-agent/src/provider/session_scan/copilot.rs +1 -0
  242. package/crates/team-agent/src/provider/session_scan.rs +6 -42
  243. package/crates/team-agent/src/provider/startup_prompt.rs +1 -0
  244. package/crates/team-agent/src/provider/types.rs +1 -0
  245. package/crates/team-agent/src/provider/wire.rs +1 -0
  246. package/crates/team-agent/src/state/identity.rs +16 -5
  247. package/crates/team-agent/src/state/identity_keys.rs +1 -0
  248. package/crates/team-agent/src/state/mod.rs +2 -0
  249. package/crates/team-agent/src/state/owner_gate.rs +5 -0
  250. package/crates/team-agent/src/state/ownership.rs +10 -4
  251. package/crates/team-agent/src/state/paths.rs +12 -0
  252. package/crates/team-agent/src/state/persist.rs +9 -3
  253. package/crates/team-agent/src/state/projection.rs +15 -2
  254. package/crates/team-agent/src/state/repository/intent.rs +1 -0
  255. package/crates/team-agent/src/state/repository/tests.rs +1 -0
  256. package/crates/team-agent/src/state/repository.rs +7 -0
  257. package/crates/team-agent/src/state/selector.rs +1 -0
  258. package/crates/team-agent/src/tmux_backend/tests.rs +39 -0
  259. package/crates/team-agent/src/tmux_backend.rs +63 -0
  260. package/crates/team-agent/src/topology.rs +3 -0
  261. package/crates/team-agent/src/transport.rs +15 -0
  262. package/package.json +4 -4
  263. package/skills/team-agent/command-coverage.json +379 -0
  264. package/crates/team-agent/src/leader/inject.rs +0 -33
  265. package/crates/team-agent/src/provider/command.rs +0 -80
@@ -1,3 +1,4 @@
1
+ //!
1
2
  //! unit-9 (Stage 4) — tmux endpoint selection policy, separated from the
2
3
  //! concrete `TmuxBackend` execution layer.
3
4
  //!
@@ -55,6 +56,7 @@ pub struct TmuxEndpointSelection {
55
56
  pub source: TmuxEndpointSource,
56
57
  }
57
58
 
59
+ ///
58
60
  /// Pure policy: pick the tmux endpoint to use given a (maybe-present)
59
61
  /// `state.json` Value.
60
62
  ///
@@ -91,6 +93,7 @@ pub fn select_endpoint_from_state(state: Option<&Value>) -> Option<TmuxEndpointS
91
93
  None
92
94
  }
93
95
 
96
+ ///
94
97
  /// State-first endpoint selection with workspace fallback. Equivalent to
95
98
  /// what `tmux_backend_for_runtime_state_or_workspace` does internally,
96
99
  /// minus the backend construction.
@@ -1,3 +1,4 @@
1
+ //!
1
2
  //! 0.3.28 layout step 3 — worker spawn env (inherit-then-strip) + worker
2
3
  //! spawn cwd (YAML-only).
3
4
  //!
@@ -57,6 +58,7 @@ const WORKER_IDENTITY_EXACT: &[&str] = &["CLAUDECODE", "CLAUDE_EFFORT", "CODEX_T
57
58
 
58
59
  const WORKER_IDENTITY_PREFIXES: &[&str] = &["CLAUDE_CODE_"];
59
60
 
61
+ ///
60
62
  /// Build the worker spawn env per Python inherit-then-strip semantics.
61
63
  ///
62
64
  /// Inputs:
@@ -158,6 +160,7 @@ fn is_posix_shell_identifier(s: &str) -> bool {
158
160
  bytes.all(|b| b.is_ascii_alphanumeric() || b == b'_')
159
161
  }
160
162
 
163
+ ///
161
164
  /// Compute worker spawn cwd per Python semantics: YAML
162
165
  /// `agent.spawn_cwd` if set, else `workspace`. The persisted-state
163
166
  /// `agent.spawn_cwd` override (the pre-0.3.28 Rust extension that caused
@@ -1,3 +1,4 @@
1
+ //!
1
2
  //! 0.3.28 layout step 2 — small window grammar helper for layout-layer naming.
2
3
  //!
3
4
  //! Command/UI grammar, not provider identity parsing: leader window names
@@ -6,6 +7,7 @@
6
7
 
7
8
  use crate::model::enums::Provider;
8
9
 
10
+ ///
9
11
  /// Window name used inside the leader session. Mirrors
10
12
  /// Python's `leader_window_name = provider` (see
11
13
  /// `runtime/0.2.11/src/team_agent/leader/__init__.py:114-131`).
@@ -1,3 +1,4 @@
1
+ //!
1
2
  //! leader 内部 helper —— provider/turn-state wire 串、JSON path 取值、rollout 读、
2
3
  //! workspace 路径归一 / session 文件夹消毒、uuid 前缀、时间戳、sha1。
3
4
 
@@ -1,3 +1,4 @@
1
+ //!
1
2
  #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2
3
  pub enum LeaderIncident {
3
4
  LeaderAttached,
@@ -1,3 +1,4 @@
1
+ //!
1
2
  //! leader::lease — attach / claim / autobind 统一 CAS 路径 + claim_lease_no_incident
2
3
  //! + 双写 / 分叉检测。
3
4
 
@@ -19,8 +20,8 @@ use crate::transport::{PaneId, PaneInfo, Transport};
19
20
  use super::helpers::{get_path_str, get_path_u64, now_ts, parse_provider};
20
21
  use super::owner_bind::leader_identity_context;
21
22
  use super::{
22
- ClaimedVia, Discovery, LeaderError, LeaderReceiver, LeaseReason, LeaseResult, LeaseSource,
23
- LeaseStatus, OwnerEpoch, ReceiverMode, ReceiverStatus, TeamOwner,
23
+ ClaimedVia, Discovery, LeaderError, LeaderIncident, LeaderReceiver, LeaseReason, LeaseResult,
24
+ LeaseSource, LeaseStatus, OwnerEpoch, ReceiverMode, ReceiverStatus, TeamOwner,
24
25
  };
25
26
 
26
27
  // ── leader::lease — attach / claim / takeover / autobind / readopt 统一 CAS 路径 ──
@@ -427,7 +428,7 @@ pub(crate) fn requeued_exhausted_watchers_event_payload(
427
428
  /// (cwd+command 宽松匹配);否则严格 UUID 门 + `try_readopt_leader_pane` 收敛到 lease claim。
428
429
  /// 返回 `(receiver, validation)`。
429
430
  #[allow(clippy::too_many_arguments)]
430
- pub fn attach_leader_to_state(
431
+ pub(crate) fn attach_leader_to_state(
431
432
  workspace: &Path,
432
433
  state: &mut Value,
433
434
  pane: Option<&PaneId>,
@@ -470,6 +471,14 @@ pub fn attach_leader_to_state(
470
471
  super::LeaderEvent::ReceiverAttached.name(),
471
472
  json!({"pane_id": pane_id.as_str(), "owner_epoch": next_epoch.0}),
472
473
  )?;
474
+ let team_id = TeamKey::new(crate::state::projection::team_state_key(state));
475
+ crate::messaging::watchers::recover_watchers_for_incident(
476
+ workspace,
477
+ event_log,
478
+ &team_id,
479
+ &pane_id,
480
+ LeaderIncident::LeaderAttached,
481
+ )?;
473
482
  return Ok((receiver, json!({"ok": true})));
474
483
  }
475
484
  write_lease_dual_state(workspace, state)?;
@@ -477,24 +486,17 @@ pub fn attach_leader_to_state(
477
486
  super::LeaderEvent::ReceiverAttached.name(),
478
487
  json!({"pane_id": pane_id.as_str(), "owner_epoch": epoch.0}),
479
488
  )?;
489
+ let team_id = TeamKey::new(crate::state::projection::team_state_key(state));
490
+ crate::messaging::watchers::recover_watchers_for_incident(
491
+ workspace,
492
+ event_log,
493
+ &team_id,
494
+ &pane_id,
495
+ LeaderIncident::LeaderAttached,
496
+ )?;
480
497
  Ok((receiver, json!({"ok": true})))
481
498
  }
482
499
 
483
- /// `autobind_leader_receiver_from_env`(card §44;`__init__.py:880`)。进程启动/restart 时从
484
- /// `$TMUX_PANE` 自动绑定;`$TMUX_PANE` 缺 → `Ok(None)`;异常写 `autobind_skipped` 返 `Ok(None)`。
485
- /// 持 `LEADER_OWNERSHIP_LOCK`(lease mutation 不能与 takeover/claim/attach/send 交错)。
486
- pub fn autobind_leader_receiver_from_env(
487
- workspace: &Path,
488
- provider: Provider,
489
- source: LeaseSource,
490
- ) -> Result<Option<LeaderReceiver>, LeaderError> {
491
- let _ = (workspace, provider, source);
492
- if std::env::var_os("TMUX_PANE").is_none() {
493
- return Ok(None);
494
- }
495
- Ok(None)
496
- }
497
-
498
500
  /// `claim_leader`(card §45;`__init__.py:744`)。`team-agent claim-leader` 入口。
499
501
  /// 有 ambiguous incident → 多候选 broadcast-claim 流;否则 `claim_lease_no_incident` 直接 acquire/CAS。
500
502
  /// 持 `LEADER_OWNERSHIP_LOCK`。
@@ -605,9 +607,12 @@ pub fn claim_leader(
605
607
  )?;
606
608
  if result.ok {
607
609
  if let Some(pane) = result.bound_pane_id.as_ref() {
608
- let store = MessageStore::open(workspace)?;
609
- crate::messaging::watchers::requeue_after_claim_leader(
610
- workspace, &store, &event_log, &team_id, pane, None,
610
+ crate::messaging::watchers::recover_watchers_for_incident(
611
+ workspace,
612
+ &event_log,
613
+ &team_id,
614
+ pane,
615
+ LeaderIncident::LeaderClaimed,
611
616
  )?;
612
617
  }
613
618
  }
@@ -618,7 +623,7 @@ pub fn claim_leader(
618
623
  /// 直接 acquire/CAS against live evidence。precheck epoch + caller 资格门 + confirm 门 +
619
624
  /// **锁内 revalidate(TOCTOU C3/C15)** + 双写 + 审计。
620
625
  #[allow(clippy::too_many_arguments)]
621
- pub fn claim_lease_no_incident(
626
+ pub(crate) fn claim_lease_no_incident(
622
627
  workspace: &Path,
623
628
  state: &mut Value,
624
629
  team: Option<&str>,
@@ -1,3 +1,4 @@
1
+ //!
1
2
  //! step 10 · leader — ownership lease / leader-session binding / idle-takeover wiring
2
3
  //! (ROUND-0 SKELETON: types + fn/method SURFACE only, all bodies `unimplemented!()`).
3
4
  //!
@@ -10,7 +11,7 @@
10
11
  //! - `leader_binding.py` (183) — Family A positive-source owner binding
11
12
  //! (`bind_owner_from_caller_pane` / `derive_leader_session_uuid` / `emit_owner_bound_event`).
12
13
  //! - `idle_takeover.py` (facade re-export) / `idle_takeover_wiring.py`
13
- //! (`build_idle_nodes` / `push_idle_reminder`) / `wake.py`
14
+ //! (`build_idle_nodes`) / `wake.py`
14
15
  //! (`should_reread` / `on_file_changed` / `take_pending`).
15
16
  //! - `messaging/leader_panes.py` (`_leader_command_looks_usable` /
16
17
  //! provider attribution / `_target_leader_session_uuid`).
@@ -77,7 +78,6 @@ use crate::state::StateError;
77
78
  // ── submodules(by responsibility) ──────────────────────────────────────────
78
79
  mod helpers;
79
80
  pub mod incident;
80
- pub mod inject;
81
81
  pub mod lease;
82
82
  pub mod owner_bind;
83
83
  pub mod provider_attribution;
@@ -89,7 +89,6 @@ pub mod types;
89
89
 
90
90
  // ── RE-EXPORT INVARIANT:每个先前 root-visible 项原路径不变 ────────────────────
91
91
  pub use incident::*;
92
- pub use inject::*;
93
92
  pub use lease::*;
94
93
  pub use owner_bind::*;
95
94
  pub(crate) use provider_attribution::*;
@@ -1,5 +1,6 @@
1
- //! leader::owner_bind — Family A 正源 owner 绑定(bind_owner_from_caller_pane / emit_owner_bound_event)
2
- //! + leader 身份上下文派生(override / state / derive)。
1
+ //!
2
+ //! leader::owner_bind Family A 正源 owner 绑定 + leader 身份上下文派生
3
+ //! (override / state / derive)。
3
4
 
4
5
  use std::path::Path;
5
6
 
@@ -153,6 +154,7 @@ pub fn bind_owner_from_caller_pane(
153
154
  &machine_fingerprint,
154
155
  &os_user,
155
156
  )?;
157
+ let derived_leader_session_uuid = identity.leader_session_uuid.clone();
156
158
  let owner = TeamOwner {
157
159
  pane_id: PaneId::new(pane.clone()),
158
160
  provider,
@@ -163,6 +165,14 @@ pub fn bind_owner_from_caller_pane(
163
165
  claimed_via: ClaimedVia::ClaimLeader,
164
166
  os_user: Some(os_user),
165
167
  };
168
+ emit_owner_bound_event(
169
+ workspace,
170
+ &PaneId::new(pane.clone()),
171
+ &caller_current_command,
172
+ &derived_leader_session_uuid,
173
+ team_id,
174
+ None,
175
+ )?;
166
176
  Ok(OwnerBindResult {
167
177
  ok: true,
168
178
  owner: Some(owner),
@@ -176,7 +186,7 @@ pub fn bind_owner_from_caller_pane(
176
186
 
177
187
  /// `emit_owner_bound_event`(`leader_binding.py:162`)。成功绑定后的审计 hook
178
188
  /// (`owner.bound_from_caller_pane`;只写 uuid 短前缀,不泄全 uuid)。
179
- pub fn emit_owner_bound_event(
189
+ fn emit_owner_bound_event(
180
190
  workspace: &Path,
181
191
  caller_pane_id: &PaneId,
182
192
  caller_current_command: &str,
@@ -1,3 +1,4 @@
1
+ //!
1
2
  //! Positive provider attribution for leader panes.
2
3
 
3
4
  use std::collections::BTreeMap;
@@ -1,3 +1,4 @@
1
+ //!
1
2
  //! leader::rediscover — attach-leader readopt and leader receiver rediscovery.
2
3
 
3
4
  use std::collections::BTreeMap;
@@ -129,21 +130,7 @@ pub fn try_readopt_leader_pane(
129
130
  )))
130
131
  }
131
132
 
132
- /// `_rediscover_leader_receiver`: scan live targets and repair the receiver when
133
- /// exactly one usable pane matches the recorded owner identity.
134
- pub fn rediscover_leader_receiver(
135
- workspace: &Path,
136
- state: &mut Value,
137
- transport: &dyn Transport,
138
- event_log: &crate::event_log::EventLog,
139
- ) -> Result<Value, LeaderError> {
140
- let identity = OwnerIdentity::from_state(workspace, state)?;
141
- rediscover_leader_receiver_with_identity(
142
- workspace, state, transport, event_log, &identity, None,
143
- )
144
- }
145
-
146
- pub fn rediscover_leader_receiver_with_owner_identity(
133
+ fn rediscover_leader_receiver_with_owner_identity(
147
134
  workspace: &Path,
148
135
  state: &mut Value,
149
136
  transport: &dyn Transport,
@@ -204,7 +191,7 @@ fn rediscover_leader_receiver_with_identity(
204
191
  )
205
192
  }
206
193
 
207
- pub fn rediscover_leader_receiver_from_targets(
194
+ fn rediscover_leader_receiver_from_targets(
208
195
  workspace: &Path,
209
196
  state: &mut Value,
210
197
  targets: &[PaneInfo],
@@ -216,7 +203,7 @@ pub fn rediscover_leader_receiver_from_targets(
216
203
  )
217
204
  }
218
205
 
219
- pub fn rediscover_leader_receiver_from_targets_with_owner_identity(
206
+ pub(super) fn rediscover_leader_receiver_from_targets_with_owner_identity(
220
207
  workspace: &Path,
221
208
  state: &mut Value,
222
209
  targets: &[PaneInfo],
@@ -1,3 +1,4 @@
1
+ //!
1
2
  //! Phase-DX E7 (0.5.9 host-leader-registry-design): file-per-leader discovery index.
2
3
  //!
3
4
  //! Location: `~/.team-agent/leaders/<workspace_hash>__<team_key>.json`.
@@ -147,7 +148,7 @@ pub fn workspace_hash(workspace: &Path) -> String {
147
148
  /// Compute the discovery-visible short label for a workspace path —
148
149
  /// basename by default, "workspace" when the path has no name component.
149
150
  #[must_use]
150
- pub fn workspace_short(workspace: &Path) -> String {
151
+ fn workspace_short(workspace: &Path) -> String {
151
152
  workspace
152
153
  .file_name()
153
154
  .and_then(|s| s.to_str())
@@ -338,7 +339,7 @@ pub fn unregister_entry(workspace: &Path, team_key: &str) -> Option<PathBuf> {
338
339
  /// registry is a derived discovery index and unreadable files are the
339
340
  /// "STALE / UNREADABLE" dirty class rather than an error.
340
341
  #[must_use]
341
- pub fn read_all_entries() -> Vec<(PathBuf, LeaderRegistryEntry)> {
342
+ fn read_all_entries() -> Vec<(PathBuf, LeaderRegistryEntry)> {
342
343
  let Some(dir) = registry_dir() else {
343
344
  return Vec::new();
344
345
  };
@@ -440,19 +441,6 @@ fn tmux_pane_live(socket: &str, pane_id: &str) -> bool {
440
441
  }
441
442
  }
442
443
 
443
- /// Return the canonical state's `leader_receiver` value for the entry's
444
- /// team, if one exists. Send/leaders paths use this so they never route
445
- /// through a stale registry channel — canonical state is the truth.
446
- #[must_use]
447
- pub fn canonical_receiver(entry: &LeaderRegistryEntry) -> Option<serde_json::Value> {
448
- let state = crate::state::persist::load_runtime_state(&entry.workspace).ok()?;
449
- let team = state
450
- .get("teams")
451
- .and_then(|v| v.as_object())
452
- .and_then(|teams| teams.get(&entry.team_key))?;
453
- team.get("leader_receiver").cloned()
454
- }
455
-
456
444
  /// Read all entries, classify each, and prune terminal-stale entries
457
445
  /// (`workspace_no_state`, `team_key_not_found`). Live entries are never
458
446
  /// touched. Returns the surviving (LIVE + STALE-not-yet-pruned) entries