@team-agent/installer 0.5.125 → 0.5.127

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 (144) hide show
  1. package/Cargo.lock +1 -1
  2. package/Cargo.toml +1 -1
  3. package/crates/team-agent/src/cli/diagnose.rs +0 -137
  4. package/crates/team-agent/src/cli/emit.rs +13 -8
  5. package/crates/team-agent/src/cli/grok_slot.rs +88 -3
  6. package/crates/team-agent/src/cli/intent/runtime.rs +6 -4
  7. package/crates/team-agent/src/cli/intent/runtime_tests.rs +55 -10
  8. package/crates/team-agent/src/cli/mod.rs +35 -29
  9. package/crates/team-agent/src/cli/models.rs +33 -944
  10. package/crates/team-agent/src/cli/tests/leader_watch.rs +1 -1
  11. package/crates/team-agent/src/cli/tests/mod.rs +3 -3
  12. package/crates/team-agent/src/cli/tests/run_delegation.rs +8 -7
  13. package/crates/team-agent/src/cli/tests/status_send.rs +2 -2
  14. package/crates/team-agent/src/compiler/tests.rs +54 -12
  15. package/crates/team-agent/src/compiler.rs +7 -205
  16. package/crates/team-agent/src/contract_runtime/backend.rs +97 -38
  17. package/crates/team-agent/src/contract_runtime/commands.rs +335 -4
  18. package/crates/team-agent/src/contract_runtime/config.rs +12 -8
  19. package/crates/team-agent/src/contract_runtime/fork.rs +368 -0
  20. package/crates/team-agent/src/contract_runtime/framework.rs +8 -13
  21. package/crates/team-agent/src/contract_runtime/mod.rs +1 -0
  22. package/crates/team-agent/src/contract_runtime/registry.rs +100 -60
  23. package/crates/team-agent/src/coordinator/steps/abnormal.rs +45 -5
  24. package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +54 -16
  25. package/crates/team-agent/src/coordinator/tests/energy.rs +4 -4
  26. package/crates/team-agent/src/coordinator/tests/health_sync.rs +2 -44
  27. package/crates/team-agent/src/coordinator/tests/main_preserved.rs +2 -2
  28. package/crates/team-agent/src/coordinator/tests/spine.rs +1 -1
  29. package/crates/team-agent/src/coordinator/tests/takeover.rs +3 -3
  30. package/crates/team-agent/src/leader/start.rs +1 -1
  31. package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +2 -195
  32. package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +11 -27
  33. package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +22 -200
  34. package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +6 -87
  35. package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +5 -496
  36. package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +74 -244
  37. package/crates/team-agent/src/lifecycle/launch/quick_start.rs +2 -26
  38. package/crates/team-agent/src/lifecycle/launch/role_source.rs +5 -0
  39. package/crates/team-agent/src/lifecycle/launch/spawn.rs +26 -51
  40. package/crates/team-agent/src/lifecycle/launch.rs +3 -34
  41. package/crates/team-agent/src/lifecycle/profile_launch.rs +18 -373
  42. package/crates/team-agent/src/lifecycle/restart/common.rs +45 -463
  43. package/crates/team-agent/src/lifecycle/restart/remove.rs +129 -0
  44. package/crates/team-agent/src/lifecycle/restart/selection.rs +5 -5
  45. package/crates/team-agent/src/lifecycle/restart.rs +0 -2
  46. package/crates/team-agent/src/lifecycle/role_config.rs +40 -13
  47. package/crates/team-agent/src/lifecycle/tests/acceptance_b_batch_red.rs +1 -1
  48. package/crates/team-agent/src/lifecycle/tests/agent_ops.rs +8 -12
  49. package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +38 -236
  50. package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +8 -320
  51. package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +106 -186
  52. package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +4 -334
  53. package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +19 -15
  54. package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +2 -2
  55. package/crates/team-agent/src/lifecycle/tests/core.rs +33 -58
  56. package/crates/team-agent/src/lifecycle/tests/f032_startup_prompt_best_effort_red.rs +22 -8
  57. package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +15 -133
  58. package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +3 -51
  59. package/crates/team-agent/src/lifecycle/tests/host_cotenant_death_p0_contract.rs +30 -67
  60. package/crates/team-agent/src/lifecycle/tests/issue238_codex_effort_contract.rs +3 -31
  61. package/crates/team-agent/src/lifecycle/tests/lane_ops.rs +194 -169
  62. package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +162 -284
  63. package/crates/team-agent/src/lifecycle/tests/lifecycle_rollback_red.rs +15 -78
  64. package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +7 -7
  65. package/crates/team-agent/src/lifecycle/tests/phase_b_contracts.rs +75 -69
  66. package/crates/team-agent/src/lifecycle/tests/phase_golden.rs +2 -10
  67. package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +6 -18
  68. package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +52 -70
  69. package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +4 -157
  70. package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +10 -302
  71. package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +1 -68
  72. package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +1 -19
  73. package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +2 -100
  74. package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +15 -14
  75. package/crates/team-agent/src/lifecycle/tests/restart.rs +12 -153
  76. package/crates/team-agent/src/lifecycle/tests/restart_build_before_destroy_0540_contract.rs +27 -5
  77. package/crates/team-agent/src/lifecycle/tests/restart_liveness_red.rs +59 -10
  78. package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +47 -6
  79. package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +3 -1478
  80. package/crates/team-agent/src/lifecycle/tests/resume_recover_red.rs +27 -10
  81. package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +7 -7
  82. package/crates/team-agent/src/lifecycle/tests/subprep_codex_trust_roundtrip_red.rs +67 -313
  83. package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +2 -254
  84. package/crates/team-agent/src/lifecycle/tests/team_in_team_identity_scope_red.rs +2 -2
  85. package/crates/team-agent/src/lifecycle/tests/team_in_team_sibling_quick_start_red.rs +1 -1
  86. package/crates/team-agent/src/lifecycle/tests/team_in_team_state_scope_red.rs +2 -2
  87. package/crates/team-agent/src/lifecycle/tests/team_key_retirement_txn_red.rs +4 -4
  88. package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +74 -19
  89. package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +39 -38
  90. package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +42 -97
  91. package/crates/team-agent/src/lifecycle/tests.rs +0 -7
  92. package/crates/team-agent/src/lifecycle/types.rs +2 -21
  93. package/crates/team-agent/src/mcp_server/readiness_tests.rs +15 -17
  94. package/crates/team-agent/src/messaging/delivery.rs +14 -195
  95. package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +5 -5
  96. package/crates/team-agent/src/messaging/tests/dup_inject.rs +68 -69
  97. package/crates/team-agent/src/messaging/tests/main_preserved.rs +2 -2
  98. package/crates/team-agent/src/messaging/tests/runtime.rs +5 -5
  99. package/crates/team-agent/src/messaging/tests/spine.rs +30 -32
  100. package/crates/team-agent/src/messaging/tests/wave2.rs +13 -20
  101. package/crates/team-agent/src/provider/adapter.rs +71 -572
  102. package/crates/team-agent/src/provider/adapters/mod.rs +6 -8
  103. package/crates/team-agent/src/provider/model_catalog.rs +13 -201
  104. package/crates/team-agent/src/provider/session/capture.rs +11 -211
  105. package/crates/team-agent/src/provider/session/context_fork/outcome.rs +8 -24
  106. package/crates/team-agent/src/provider/session/context_fork.rs +29 -240
  107. package/crates/team-agent/src/provider/session/mod.rs +2 -3
  108. package/crates/team-agent/src/provider/session_scan/common.rs +27 -87
  109. package/crates/team-agent/src/provider/session_scan/pi.rs +1 -34
  110. package/crates/team-agent/src/provider/session_scan.rs +7 -23
  111. package/crates/team-agent/src/provider/tests/adapter.rs +66 -204
  112. package/crates/team-agent/src/provider/tests/command_helpers.rs +3 -29
  113. package/crates/team-agent/src/provider/tests/idle.rs +0 -68
  114. package/crates/team-agent/src/provider/types.rs +0 -4
  115. package/crates/team-agent/src/provider/wire.rs +77 -23
  116. package/crates/team-agent/src/state/abnormal_watch/tests/mod.rs +1 -1
  117. package/crates/team-agent/src/state/persist.rs +6 -6
  118. package/crates/team-agent/src/state/repository/tests.rs +2 -2
  119. package/crates/team-agent/src/tmux_backend.rs +4 -3
  120. package/package.json +4 -4
  121. package/skills/team-agent/SKILL.md +8 -5
  122. package/skills/team-agent/command-coverage.json +29 -1
  123. package/skills/team-agent/docs/reference/team-agent-operator.md +7 -3
  124. package/skills/team-agent/references/team-agent-operator.md +7 -3
  125. package/crates/team-agent/src/lifecycle/launch/grok_per_seat.rs +0 -260
  126. package/crates/team-agent/src/lifecycle/restart/avatar.rs +0 -1805
  127. package/crates/team-agent/src/lifecycle/tests/claude_compatible_config_red.rs +0 -325
  128. package/crates/team-agent/src/lifecycle/tests/codex_weak_window_attribution_red.rs +0 -683
  129. package/crates/team-agent/src/lifecycle/tests/grok_effort_argv_red.rs +0 -247
  130. package/crates/team-agent/src/lifecycle/tests/grok_mcp_overlay_red.rs +0 -507
  131. package/crates/team-agent/src/lifecycle/tests/grok_restart_resume_red.rs +0 -300
  132. package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +0 -210
  133. package/crates/team-agent/src/lifecycle/tests/pi_fork_session_inheritance_red.rs +0 -1409
  134. package/crates/team-agent/src/provider/adapters/claude.rs +0 -78
  135. package/crates/team-agent/src/provider/adapters/claude_fork.rs +0 -131
  136. package/crates/team-agent/src/provider/adapters/codex.rs +0 -101
  137. package/crates/team-agent/src/provider/adapters/grok.rs +0 -67
  138. package/crates/team-agent/src/provider/adapters/pi.rs +0 -100
  139. package/crates/team-agent/src/provider/session/context_fork/claude.rs +0 -123
  140. package/crates/team-agent/src/provider/session/context_fork/codex.rs +0 -514
  141. package/crates/team-agent/src/provider/session_scan/claude.rs +0 -523
  142. package/crates/team-agent/src/provider/session_scan/codex.rs +0 -326
  143. package/crates/team-agent/src/provider/session_scan/grok.rs +0 -288
  144. package/crates/team-agent/src/test_support/models_timeout_fixture.rs +0 -144
@@ -231,12 +231,11 @@ fn start_mode_serde_names_match_python_start_mode_strings() {
231
231
 
232
232
  // ───────────────────────────────────────────────────────────────────────
233
233
  // decide_start_mode — bug-085 四象限 + E20 #264 gap closure.
234
- // codex sess rollout-present any-fresh -> resumed
235
- // codex sess backing-MISSING !allow_fresh -> noop/refuse (绝不静默 resume 死 session)
236
- // codex sess backing-MISSING allow_fresh -> fresh_after_missing_rollout
237
- // codex no-sess any -> fresh
238
- // claude/copilot sess backing-missing -> fresh_after_missing_rollout 或 noop/refuse
239
- // claude no-sess -> fresh
234
+ // copilot sess backing-present any-fresh -> resumed
235
+ // copilot sess backing-MISSING !allow_fresh -> noop/refuse (绝不静默 resume 死 session)
236
+ // copilot sess backing-MISSING allow_fresh -> fresh_after_missing_rollout
237
+ // copilot no-sess any -> fresh
238
+ // non-resumable (fake/gemini_cli/retired claude/pi/codex/grok rows) sess -> noop 或 fresh_after_missing_rollout
240
239
  // 这是 bug-085 把 start_mode 分类从 start_agent 的 lock+spawn 全路径剥离出来的命门。
241
240
  // ───────────────────────────────────────────────────────────────────────
242
241
 
@@ -248,16 +247,16 @@ fn rp(p: &str) -> RolloutPath {
248
247
  }
249
248
 
250
249
  #[test]
251
- fn decide_start_mode_codex_missing_rollout_with_allow_fresh_is_fresh_after_missing() {
252
- // bug-085 唯一 FreshAfterMissingRollout 臂:codex + 有 session_id + rollout 缺 + allow_fresh。
250
+ fn decide_start_mode_copilot_missing_rollout_with_allow_fresh_is_fresh_after_missing() {
251
+ // bug-085 唯一 FreshAfterMissingRollout 臂:copilot(唯一可 resume 的 legacy worker)+ 有 session_id + backing 缺 + allow_fresh。
253
252
  assert_eq!(
254
- decide_start_mode("codex", Some(&sid("s1")), None, false, true),
253
+ decide_start_mode("copilot", Some(&sid("s1")), None, false, true),
255
254
  StartMode::FreshAfterMissingRollout
256
255
  );
257
256
  // rollout 路径存在但文件已不在,同样命中。
258
257
  assert_eq!(
259
258
  decide_start_mode(
260
- "codex",
259
+ "copilot",
261
260
  Some(&sid("s1")),
262
261
  Some(&rp("/gone.jsonl")),
263
262
  false,
@@ -268,19 +267,19 @@ fn decide_start_mode_codex_missing_rollout_with_allow_fresh_is_fresh_after_missi
268
267
  }
269
268
 
270
269
  #[test]
271
- fn decide_start_mode_codex_missing_rollout_without_allow_fresh_refuses() {
270
+ fn decide_start_mode_copilot_missing_rollout_without_allow_fresh_refuses() {
272
271
  // E20 C①:backing 缺且 !allow_fresh → 诚实拒绝,绝不 resume 进死 session。
273
272
  assert_eq!(
274
- decide_start_mode("codex", Some(&sid("s1")), None, false, false),
273
+ decide_start_mode("copilot", Some(&sid("s1")), None, false, false),
275
274
  StartMode::Noop
276
275
  );
277
276
  }
278
277
 
279
278
  #[test]
280
- fn decide_start_mode_codex_rollout_present_is_resumed_regardless_of_fresh() {
279
+ fn decide_start_mode_copilot_rollout_present_is_resumed_regardless_of_fresh() {
281
280
  assert_eq!(
282
281
  decide_start_mode(
283
- "codex",
282
+ "copilot",
284
283
  Some(&sid("s1")),
285
284
  Some(&rp("/r.jsonl")),
286
285
  true,
@@ -289,7 +288,7 @@ fn decide_start_mode_codex_rollout_present_is_resumed_regardless_of_fresh() {
289
288
  StartMode::Resumed
290
289
  );
291
290
  assert_eq!(
292
- decide_start_mode("codex", Some(&sid("s1")), Some(&rp("/r.jsonl")), true, true),
291
+ decide_start_mode("copilot", Some(&sid("s1")), Some(&rp("/r.jsonl")), true, true),
293
292
  StartMode::Resumed
294
293
  );
295
294
  }
@@ -297,43 +296,19 @@ fn decide_start_mode_codex_rollout_present_is_resumed_regardless_of_fresh() {
297
296
  #[test]
298
297
  fn decide_start_mode_no_session_is_fresh() {
299
298
  assert_eq!(
300
- decide_start_mode("codex", None, None, false, true),
299
+ decide_start_mode("copilot", None, None, false, true),
301
300
  StartMode::Fresh
302
301
  );
303
302
  assert_eq!(
304
- decide_start_mode("codex", None, None, false, false),
305
- StartMode::Fresh
306
- );
307
- }
308
-
309
- #[test]
310
- fn decide_start_mode_checks_backing_for_all_resumable_providers() {
311
- for provider in ["claude", "claude_code", "copilot"] {
312
- assert_eq!(
313
- decide_start_mode(provider, Some(&sid("s1")), None, false, true),
314
- StartMode::FreshAfterMissingRollout,
315
- "{provider} missing backing + allow_fresh must not resume"
316
- );
317
- assert_eq!(
318
- decide_start_mode(provider, Some(&sid("s1")), None, false, false),
319
- StartMode::Noop,
320
- "{provider} missing backing + !allow_fresh must refuse"
321
- );
322
- assert_eq!(
323
- decide_start_mode(provider, Some(&sid("s1")), Some(&rp("/r")), true, false),
324
- StartMode::Resumed,
325
- "{provider} existing backing remains resumable"
326
- );
327
- }
328
- assert_eq!(
329
- decide_start_mode("claude", None, None, false, true),
303
+ decide_start_mode("copilot", None, None, false, false),
330
304
  StartMode::Fresh
331
305
  );
332
306
  }
333
307
 
334
308
  #[test]
335
309
  fn decide_start_mode_refuses_session_id_for_nonresumable_providers() {
336
- for provider in ["fake", "gemini_cli"] {
310
+ // A persisted legacy Claude Code / Pi / Codex / Grok worker row is no longer resumable.
311
+ for provider in ["fake", "gemini_cli", "claude", "claude_code", "pi", "codex", "grok"] {
337
312
  assert_eq!(
338
313
  decide_start_mode(provider, Some(&sid("s1")), None, true, false),
339
314
  StartMode::Noop,
@@ -384,7 +359,7 @@ fn classify_restart_plan_interacted_unresumable_no_allow_fresh_yields_refuse() {
384
359
  "session_name": "team-a",
385
360
  "agents": {
386
361
  "w1": {
387
- "provider": "claude",
362
+ "provider": "copilot",
388
363
  "first_send_at": "2026-05-27T10:00:00+00:00",
389
364
  "session_id": null
390
365
  }
@@ -437,7 +412,7 @@ fn classify_restart_plan_interacted_unresumable_with_allow_fresh_yields_fresh_st
437
412
  let state = json!({
438
413
  "agents": {
439
414
  "w1": {
440
- "provider": "claude",
415
+ "provider": "copilot",
441
416
  "first_send_at": "2026-05-27T10:00:00+00:00",
442
417
  "session_id": null
443
418
  }
@@ -467,7 +442,7 @@ fn classify_restart_plan_never_captured_null_session_auto_fresh_partial_resume()
467
442
  // not captured" bug state) — see the OTHER refuse-interacted test below
468
443
  // and upgrade_restart_refuses_interacted_worker_without_session_id.
469
444
  let state = json!({
470
- "agents": { "w1": { "provider": "claude", "session_id": null } }
445
+ "agents": { "w1": { "provider": "copilot", "session_id": null } }
471
446
  });
472
447
  let plan = classify_restart_plan(&state, false).expect("纯验证不应 Err");
473
448
  assert_eq!(plan.decisions.len(), 1);
@@ -493,7 +468,7 @@ fn restart_required_missing_skips_never_captured_workers() {
493
468
  use crate::lifecycle::restart::restart_required_missing_session_agent_ids;
494
469
  let state = json!({
495
470
  "agents": {
496
- "w1": { "provider": "claude", "session_id": null, "status": "running" }
471
+ "w1": { "provider": "copilot", "session_id": null, "status": "running" }
497
472
  }
498
473
  });
499
474
  let missing = restart_required_missing_session_agent_ids(&state);
@@ -513,7 +488,7 @@ fn restart_required_missing_keeps_null_session_with_first_send_at() {
513
488
  let state = json!({
514
489
  "agents": {
515
490
  "w1": {
516
- "provider": "claude",
491
+ "provider": "copilot",
517
492
  "session_id": null,
518
493
  "status": "running",
519
494
  "spawn_cwd": "/tmp/ws",
@@ -539,7 +514,7 @@ fn restart_required_missing_keeps_null_session_with_last_result_at() {
539
514
  let state = json!({
540
515
  "agents": {
541
516
  "w1": {
542
- "provider": "claude",
517
+ "provider": "copilot",
543
518
  "session_id": null,
544
519
  "status": "running",
545
520
  "spawn_cwd": "/tmp/ws",
@@ -565,7 +540,7 @@ fn classify_restart_plan_null_session_with_last_result_at_refuses_without_allow_
565
540
  let state = json!({
566
541
  "agents": {
567
542
  "w1": {
568
- "provider": "claude",
543
+ "provider": "copilot",
569
544
  "session_id": null,
570
545
  "last_result_at": "2026-01-01T00:00:00+00:00",
571
546
  }
@@ -586,7 +561,7 @@ fn classify_restart_plan_null_session_with_last_result_at_refuses_without_allow_
586
561
  fn classify_restart_plan_never_interacted_null_session_with_allow_fresh_marks_forced_fresh() {
587
562
  // E6 层2: 同上自启动 null-session worker,但显式 --allow-fresh → 用户主动认账丢上下文 → FreshStart。
588
563
  let state = json!({
589
- "agents": { "w1": { "provider": "claude", "session_id": null } }
564
+ "agents": { "w1": { "provider": "copilot", "session_id": null } }
590
565
  });
591
566
  let plan = classify_restart_plan(&state, true).expect("纯验证不应 Err");
592
567
  assert_eq!(plan.decisions.len(), 1);
@@ -602,14 +577,14 @@ fn classify_restart_plan_never_interacted_null_session_with_allow_fresh_marks_fo
602
577
  }
603
578
 
604
579
  #[test]
605
- fn classify_restart_plan_codex_with_session_still_resumes() {
606
- // E6 层2 回归锁(不误伤): codex worker first_send_at=null 但 session_id 已捕 →
580
+ fn classify_restart_plan_copilot_with_session_still_resumes() {
581
+ // E6 层2 回归锁(不误伤): copilot worker first_send_at=null 但 session_id 已捕 →
607
582
  // 仍走 Resume(分流轴是 session_id 有无,不是 interacted)。防层2 修法把 has_session 也误判。
608
583
  let ws = temp_ws();
609
- let rollout = ws.join("codex-rollout.jsonl");
584
+ let rollout = ws.join("copilot-rollout.jsonl");
610
585
  std::fs::write(&rollout, "{}\n").unwrap();
611
586
  let state = json!({
612
- "agents": { "w1": { "provider": "codex", "session_id": "sess-codex-abc", "rollout_path": rollout.to_string_lossy() } }
587
+ "agents": { "w1": { "provider": "copilot", "session_id": "sess-copilot-abc", "rollout_path": rollout.to_string_lossy() } }
613
588
  });
614
589
  let plan = classify_restart_plan(&state, false).expect("纯验证不应 Err");
615
590
  assert_eq!(plan.decisions.len(), 1);
@@ -748,9 +723,9 @@ fn classify_restart_plan_produces_corrupt_entries_with_python_type_names() {
748
723
  // ("str"/"int"/"list") —— 锁跨语言 type-name 映射,不是手设字段。
749
724
  let state = json!({
750
725
  "agents": {
751
- "w_str": { "provider": "claude", "first_send_at": "" },
752
- "w_int": { "provider": "claude", "first_send_at": 0 },
753
- "w_list": { "provider": "claude", "first_send_at": [] }
726
+ "w_str": { "provider": "copilot", "first_send_at": "" },
727
+ "w_int": { "provider": "copilot", "first_send_at": 0 },
728
+ "w_list": { "provider": "copilot", "first_send_at": [] }
754
729
  }
755
730
  });
756
731
  // corrupt 非空 → restart 在 teardown 之前 hard refuse(决策前)。
@@ -3,6 +3,7 @@
3
3
  //! Launch/restart may spawn a pane and then ask the provider adapter to handle startup prompts.
4
4
  //! A provider-specific prompt handler panic must not unwind out of the user command and leave a
5
5
  //! half-initialized runtime. The command should still complete once the pane has been spawned.
6
+ //! Copilot is the surviving legacy worker with a startup (folder-trust) prompt handler.
6
7
 
7
8
  #[path = "../../../tests/support/hermetic.rs"]
8
9
  mod hermetic_guard;
@@ -15,6 +16,7 @@ use std::sync::atomic::{AtomicU32, Ordering};
15
16
  use std::sync::Mutex;
16
17
 
17
18
  use serde_json::json;
19
+ use serial_test::serial;
18
20
  use team_agent::lifecycle::{launch_with_transport, restart_with_transport, RestartReport};
19
21
  use team_agent::transport::{
20
22
  AttachOutcome, BackendKind, CaptureRange, CapturedText, InjectPayload, InjectReport,
@@ -27,10 +29,12 @@ static SEQ: AtomicU32 = AtomicU32::new(0);
27
29
 
28
30
  const TEAM_MD: &str =
29
31
  "---\nname: f032team\nobjective: F032 lifecycle prompt fault probe.\nprovider: codex\n---\n\nF032.\n";
30
- const ROLE_MD: &str = "---\nname: implementer\nrole: Implementation Engineer\nprovider: codex\nmodel: gpt-5.5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nImplement.\n";
32
+ const ROLE_MD: &str = "---\nname: implementer\nrole: Implementation Engineer\nprovider: copilot\nmodel: gpt-5.5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nImplement.\n";
31
33
 
32
34
  #[test]
35
+ #[serial(env)]
33
36
  fn f032_launch_spawn_path_treats_startup_prompt_panic_as_best_effort() {
37
+ let _hermetic = hermetic_guard::HermeticTestEnv::enter("f032-launch");
34
38
  let team = compiled_team_dir("launch");
35
39
  let spec_path = team.join("team.spec.yaml");
36
40
  let transport = PanicOnStartupPromptTransport::new();
@@ -52,8 +56,10 @@ fn f032_launch_spawn_path_treats_startup_prompt_panic_as_best_effort() {
52
56
  }
53
57
 
54
58
  #[test]
59
+ #[serial(env)]
55
60
  fn f032_restart_spawn_path_treats_startup_prompt_panic_as_best_effort() {
56
- let workspace = restart_workspace("restart");
61
+ let hermetic = hermetic_guard::HermeticTestEnv::enter("f032-restart");
62
+ let workspace = restart_workspace("restart", hermetic.home());
57
63
  let transport = PanicOnStartupPromptTransport::new();
58
64
 
59
65
  let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
@@ -101,10 +107,19 @@ fn compiled_team_dir(label: &str) -> PathBuf {
101
107
  team
102
108
  }
103
109
 
104
- fn restart_workspace(label: &str) -> PathBuf {
110
+ fn restart_workspace(label: &str, home: &Path) -> PathBuf {
105
111
  let ws = compiled_team_dir(label);
106
- let rollout = ws.join("implementer-rollout.jsonl");
107
- std::fs::write(&rollout, "{}\n").expect("seed rollout backing");
112
+ // Copilot resume backing is the session-store row under $HOME/.copilot.
113
+ let db = home.join(".copilot").join("session-store.db");
114
+ std::fs::create_dir_all(db.parent().expect("session store parent"))
115
+ .expect("create copilot home");
116
+ let conn = rusqlite::Connection::open(db).expect("open copilot session store");
117
+ conn.execute_batch(
118
+ "create table if not exists sessions (id text primary key, name text, created_at text);
119
+ insert or replace into sessions(id, name, created_at)
120
+ values ('f0320000-0000-4000-8000-000000000032', 'f032', '2026-05-27T10:00:00Z');",
121
+ )
122
+ .expect("seed copilot session store");
108
123
  team_agent::state::persist::save_runtime_state(
109
124
  &ws,
110
125
  &json!({
@@ -112,9 +127,8 @@ fn restart_workspace(label: &str) -> PathBuf {
112
127
  "agents": {
113
128
  "implementer": {
114
129
  "status": "running",
115
- "provider": "codex",
116
- "session_id": "sess-impl",
117
- "rollout_path": rollout.to_string_lossy(),
130
+ "provider": "copilot",
131
+ "session_id": "f0320000-0000-4000-8000-000000000032",
118
132
  "first_send_at": "2026-05-27T10:00:00+00:00"
119
133
  }
120
134
  }
@@ -1,10 +1,7 @@
1
- //! purpose: grok 席位角色文件必须显式写 model,缺则拒绝启动
2
- //! contract: 缺 model 的 grok 角色启动失败(错误含 model 与原因);写了 model
3
- //! 则该值进入 worker argv 的 `--model <值>`;claude 缺 model 行为不变
4
- //! boundary: 只钉 Provider::Grok 的启动契约;不改 claude/codex/copilot 路径
5
- //!
6
- //! 修之前判红(40e91fba):grok 角色缺 model 仍会成功启动(compiler 填
7
- //! 内建默认 grok-4,argv 带 `--model grok-4`,看起来完全正常)。
1
+ //! purpose: copilot 席位角色文件缺 model 时仍能正常启动
2
+ //! contract: 缺 model 的 copilot 角色启动成功并真的 spawn worker
3
+ //! boundary: legacy Grok worker runtime 已移除(grok 角色现走 grok_build 合约叶),
4
+ //! 本文件只保留 copilot 缺 model 的回归钉子
8
5
 
9
6
  #![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
10
7
 
@@ -24,93 +21,20 @@ use serial_test::serial;
24
21
  use team_agent::lifecycle::quick_start_with_transport_in_workspace;
25
22
  use team_agent::transport::test_support::OfflineTransport;
26
23
 
27
- /// An omitted Grok role model preserves the provider-native default.
24
+ /// copilot 角色缺 model ⇒ 行为不变(仍能启动)。
28
25
  #[test]
29
26
  #[serial(env)]
30
- fn grok_role_missing_model_uses_provider_default() {
31
- let _hermetic = enter_hermetic("grok-no-model");
32
- let ws = tmp_dir("grok-no-model");
27
+ fn copilot_role_missing_model_still_starts() {
28
+ let _hermetic = enter_hermetic("grok-copilot-missing-model");
29
+ let ws = tmp_dir("copilot-no-model");
33
30
  super::launch_spawn::seed_healthy_coordinator(&ws);
34
- let home = tmp_dir("grok-no-model-home");
35
- seed_grok_home(&home, Some(&ws));
36
- let _guard = HomeGuard::set(&home);
37
31
  let team = write_role_team(
38
32
  &ws,
39
- "grokteam",
40
- "grok_writer",
41
- "grok",
33
+ "copilotteam",
34
+ "copiloter",
35
+ "copilot",
42
36
  None,
43
- "Grok Writer",
44
- );
45
- let transport = OfflineTransport::new();
46
-
47
- quick_start_with_transport_in_workspace(
48
- &ws,
49
- &team,
50
- None,
51
- true,
52
- Some("grokteam"),
53
- &transport,
54
- )
55
- .expect("Grok may use its provider-native model default");
56
- let argv = first_spawn_argv(&transport);
57
- assert!(
58
- !argv.iter().any(|arg| arg == "--model"),
59
- "an omitted model must not fabricate a --model argument: {argv:?}"
60
- );
61
- }
62
-
63
- /// 2. grok 角色写了 model ⇒ 正常启动,且该值真的进 argv(`--model <值>` 相邻)。
64
- #[test]
65
- #[serial(env)]
66
- fn grok_role_explicit_model_reaches_argv() {
67
- let _hermetic = enter_hermetic("grok-explicit-model");
68
- let ws = tmp_dir("grok-with-model");
69
- super::launch_spawn::seed_healthy_coordinator(&ws);
70
- let home = tmp_dir("grok-with-model-home");
71
- seed_grok_home(&home, Some(&ws));
72
- let _guard = HomeGuard::set(&home);
73
- let team = write_role_team(
74
- &ws,
75
- "grokteam",
76
- "grok_writer",
77
- "grok",
78
- Some("grok-4.6"),
79
- "Grok Writer",
80
- );
81
- let transport = OfflineTransport::new();
82
-
83
- quick_start_with_transport_in_workspace(
84
- &ws,
85
- &team,
86
- None,
87
- true,
88
- Some("grokteam"),
89
- &transport,
90
- )
91
- .expect("grok role with explicit model must start");
92
-
93
- let argv = first_spawn_argv(&transport);
94
- assert!(
95
- argv_contains_adjacent(&argv, &["--model", "grok-4.6"]),
96
- "declared model must appear as adjacent `--model grok-4.6` in worker argv; argv={argv:?}"
97
- );
98
- }
99
-
100
- /// 3. claude 角色缺 model ⇒ 行为不变(仍能启动,不被 grok 的硬性 model 要求误伤)。
101
- #[test]
102
- #[serial(env)]
103
- fn claude_role_missing_model_still_starts() {
104
- let _hermetic = enter_hermetic("grok-claude-missing-model");
105
- let ws = tmp_dir("claude-no-model");
106
- super::launch_spawn::seed_healthy_coordinator(&ws);
107
- let team = write_role_team(
108
- &ws,
109
- "claudeteam",
110
- "clauder",
111
- "claude",
112
- None,
113
- "Claude Worker",
37
+ "Copilot Worker",
114
38
  );
115
39
  let transport = OfflineTransport::new();
116
40
 
@@ -119,17 +43,17 @@ fn claude_role_missing_model_still_starts() {
119
43
  &team,
120
44
  None,
121
45
  true,
122
- Some("claudeteam"),
46
+ Some("copilotteam"),
123
47
  &transport,
124
48
  );
125
49
  assert!(
126
50
  result.is_ok(),
127
- "claude role without model must keep starting; grok-only requirement leaked; err={result:?}"
51
+ "copilot role without model must keep starting; err={result:?}"
128
52
  );
129
53
  let argv = first_spawn_argv(&transport);
130
54
  assert!(
131
55
  !argv.is_empty(),
132
- "claude seat must still spawn; argv={argv:?}"
56
+ "copilot seat must still spawn; argv={argv:?}"
133
57
  );
134
58
  }
135
59
 
@@ -142,14 +66,6 @@ fn first_spawn_argv(transport: &OfflineTransport) -> Vec<String> {
142
66
  records[0].1.clone()
143
67
  }
144
68
 
145
- fn argv_contains_adjacent(hay: &[String], needle: &[&str]) -> bool {
146
- if needle.is_empty() {
147
- return true;
148
- }
149
- hay.windows(needle.len())
150
- .any(|window| window.iter().map(String::as_str).eq(needle.iter().copied()))
151
- }
152
-
153
69
  fn write_role_team(
154
70
  ws: &Path,
155
71
  team_key: &str,
@@ -181,40 +97,6 @@ fn write_role_team(
181
97
  team
182
98
  }
183
99
 
184
- fn seed_grok_home(home: &Path, trusted_cwd: Option<&Path>) {
185
- let grok = home.join(".grok");
186
- std::fs::create_dir_all(&grok).unwrap();
187
- std::fs::write(grok.join("auth.json"), r#"{"test":"ok"}"#).unwrap();
188
- if let Some(cwd) = trusted_cwd {
189
- std::fs::write(
190
- grok.join("trusted_folders.toml"),
191
- format!("[folders.\"{}\"]\ntrusted = true\n", cwd.display()),
192
- )
193
- .unwrap();
194
- }
195
- }
196
-
197
- struct HomeGuard {
198
- prev: Option<String>,
199
- }
200
-
201
- impl HomeGuard {
202
- fn set(home: &Path) -> Self {
203
- let prev = std::env::var("HOME").ok();
204
- std::env::set_var("HOME", home);
205
- Self { prev }
206
- }
207
- }
208
-
209
- impl Drop for HomeGuard {
210
- fn drop(&mut self) {
211
- match &self.prev {
212
- Some(value) => std::env::set_var("HOME", value),
213
- None => std::env::remove_var("HOME"),
214
- }
215
- }
216
- }
217
-
218
100
  fn tmp_dir(tag: &str) -> PathBuf {
219
101
  static N: AtomicU64 = AtomicU64::new(0);
220
102
  let dir = std::env::temp_dir().join(format!(
@@ -10,8 +10,8 @@
10
10
  //! leave a stale .tmp on a failed replace. The contracts assert the original data
11
11
  //! survives / no residue.
12
12
  //! T3 (false green = unrecognized/failed input silently maps to a success value,
13
- //! MUST-NOT-13): normalize_result_status unrecognized -> Success; claude_auth_hint
14
- //! parse failure -> Present; schema_diagnosis missing db -> ok:true; tmux fabricated
13
+ //! MUST-NOT-13): normalize_result_status unrecognized -> Success; schema_diagnosis
14
+ //! missing db -> ok:true; tmux fabricated
15
15
  //! `%0` pane id; packaging install/update constant DoctorStatus::Ok.
16
16
  //! T5: stop_coordinator_bounded spawns a thread + recv_timeout and never joins it —
17
17
  //! a timed-out stop leaves a detached thread. Source grep guard (the bounded-stop
@@ -23,7 +23,7 @@
23
23
  #[allow(dead_code)]
24
24
  mod mcp_sim_harness;
25
25
 
26
- use std::path::{Path, PathBuf};
26
+ use std::path::PathBuf;
27
27
  use std::sync::atomic::{AtomicU64, Ordering};
28
28
 
29
29
  use mcp_sim_harness::McpSimHarness;
@@ -419,45 +419,6 @@ check behind it = false green); it must reflect an actual doctor result"
419
419
  );
420
420
  }
421
421
 
422
- /// T3-2 (claude_auth_hint parse failure): when `claude auth status` output is
423
- /// unparseable / unsuccessful, the hint must not default to Present (auth misreported
424
- /// as available). PATH-shims a `claude` that prints garbage and exits non-zero.
425
- /// Mutates the process-global PATH/HOME — must not race host_cotenant's ps/tmux
426
- /// shims (P0 pid-probe isolation) or other env-mutating tests, hence
427
- /// `#[serial(env, pid_probe)]`.
428
- #[test]
429
- #[serial(env, pid_probe)]
430
- fn t3_claude_auth_hint_parse_failure_is_not_present() {
431
- let home = tmp_ws("t3-auth-home");
432
- let shim_dir = home.join("bin");
433
- std::fs::create_dir_all(&shim_dir).unwrap();
434
- // claude shim: garbage stdout + non-zero exit (auth status unparseable / failed).
435
- write_shim(
436
- &shim_dir.join("claude"),
437
- "#!/bin/sh\nprintf 'not json at all\\n'\nexit 7\n",
438
- );
439
- let old_path = std::env::var("PATH").unwrap_or_default();
440
- let old_home = std::env::var("HOME").ok();
441
- std::env::set_var("HOME", &home);
442
- std::env::set_var("PATH", format!("{}:{old_path}", shim_dir.to_string_lossy()));
443
-
444
- let status = team_agent::provider::get_adapter(team_agent::provider::Provider::Claude)
445
- .auth_hint(team_agent::provider::AuthMode::Subscription);
446
-
447
- std::env::set_var("PATH", &old_path);
448
- match old_home {
449
- Some(home) => std::env::set_var("HOME", home),
450
- None => std::env::remove_var("HOME"),
451
- }
452
-
453
- assert_ne!(
454
- format!("{status:?}"),
455
- "Present",
456
- "T3-2: a `claude auth status` that prints unparseable output and exits non-zero \
457
- must NOT report Present (auth misreported as available is a false green); got {status:?}"
458
- );
459
- }
460
-
461
422
  // ───────────────────────────────── T5 · thread leak ─────────────────────────────────
462
423
 
463
424
  /// T5 (A2 shutdown thread leak): stop_coordinator_bounded spawns a worker thread and
@@ -484,15 +445,6 @@ stop; body={body}"
484
445
 
485
446
  // ───────────────────────────────────── helpers ─────────────────────────────────────
486
447
 
487
- fn write_shim(path: &Path, body: &str) {
488
- std::fs::write(path, body).unwrap();
489
- #[cfg(unix)]
490
- {
491
- use std::os::unix::fs::PermissionsExt;
492
- std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o755)).unwrap();
493
- }
494
- }
495
-
496
448
  /// Crude single-function body extractor: from the `fn name` line to the next
497
449
  /// same-indent ` fn ` (good enough for grep-guard scoping).
498
450
  fn fn_body(src: &str, marker: &str) -> String {