@team-agent/installer 0.5.127 → 0.5.128

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 (145) hide show
  1. package/Cargo.lock +1 -1
  2. package/Cargo.toml +1 -1
  3. package/README.md +11 -0
  4. package/crates/team-agent/src/cli/adapters.rs +3 -13
  5. package/crates/team-agent/src/cli/arguments.rs +4 -0
  6. package/crates/team-agent/src/cli/diagnose.rs +68 -22
  7. package/crates/team-agent/src/cli/emit.rs +58 -26
  8. package/crates/team-agent/src/cli/intent/runtime.rs +32 -5
  9. package/crates/team-agent/src/cli/intent/runtime_tests.rs +102 -11
  10. package/crates/team-agent/src/cli/intent/tests.rs +10 -12
  11. package/crates/team-agent/src/cli/intent.rs +1 -1
  12. package/crates/team-agent/src/cli/mod.rs +25 -8
  13. package/crates/team-agent/src/cli/models.rs +764 -7
  14. package/crates/team-agent/src/cli/schedule.rs +175 -0
  15. package/crates/team-agent/src/cli/send/persist.rs +0 -36
  16. package/crates/team-agent/src/cli/send/presentation.rs +1 -1
  17. package/crates/team-agent/src/cli/send.rs +108 -110
  18. package/crates/team-agent/src/cli/spec.rs +6 -0
  19. package/crates/team-agent/src/cli/status_port/brief.rs +5 -67
  20. package/crates/team-agent/src/cli/tests/leader_watch.rs +12 -62
  21. package/crates/team-agent/src/cli/tests/mod.rs +1 -1
  22. package/crates/team-agent/src/cli/tests/named_address.rs +11 -10
  23. package/crates/team-agent/src/cli/tests/run_delegation.rs +9 -6
  24. package/crates/team-agent/src/cli/tests/status_send.rs +68 -271
  25. package/crates/team-agent/src/compiler/tests.rs +3 -18
  26. package/crates/team-agent/src/compiler.rs +205 -6
  27. package/crates/team-agent/src/contract_runtime/backend.rs +145 -11
  28. package/crates/team-agent/src/contract_runtime/commands.rs +7 -7
  29. package/crates/team-agent/src/contract_runtime/config.rs +26 -16
  30. package/crates/team-agent/src/contract_runtime/config_tests.rs +24 -4
  31. package/crates/team-agent/src/contract_runtime/discovery.rs +12 -1
  32. package/crates/team-agent/src/contract_runtime/fork.rs +3 -10
  33. package/crates/team-agent/src/contract_runtime/framework.rs +28 -11
  34. package/crates/team-agent/src/contract_runtime/mcp.rs +19 -24
  35. package/crates/team-agent/src/contract_runtime/prompt.rs +2 -2
  36. package/crates/team-agent/src/contract_runtime/registry.rs +56 -92
  37. package/crates/team-agent/src/coordinator/steps/abnormal.rs +11 -11
  38. package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +16 -54
  39. package/crates/team-agent/src/coordinator/tests/health_sync.rs +42 -0
  40. package/crates/team-agent/src/coordinator/tick.rs +1 -89
  41. package/crates/team-agent/src/db/message_store.rs +7 -65
  42. package/crates/team-agent/src/direct_delivery.rs +368 -0
  43. package/crates/team-agent/src/inbox_store.rs +169 -0
  44. package/crates/team-agent/src/leader/registry.rs +5 -0
  45. package/crates/team-agent/src/leader/start.rs +2 -1
  46. package/crates/team-agent/src/leader/tests/lease_api.rs +2 -2
  47. package/crates/team-agent/src/leader/tests/prompt_contract.rs +1 -0
  48. package/crates/team-agent/src/lib.rs +2 -0
  49. package/crates/team-agent/src/lifecycle/launch/add_agent.rs +33 -0
  50. package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +206 -1
  51. package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +28 -2
  52. package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +38 -13
  53. package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +87 -6
  54. package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +9 -1
  55. package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +351 -81
  56. package/crates/team-agent/src/lifecycle/launch/pi_mcp_extension.js +3 -4
  57. package/crates/team-agent/src/lifecycle/launch/quick_start.rs +24 -0
  58. package/crates/team-agent/src/lifecycle/launch/spawn.rs +36 -13
  59. package/crates/team-agent/src/lifecycle/launch.rs +24 -1
  60. package/crates/team-agent/src/lifecycle/profile_launch.rs +321 -11
  61. package/crates/team-agent/src/lifecycle/restart/agent.rs +1 -0
  62. package/crates/team-agent/src/lifecycle/restart/avatar.rs +1798 -0
  63. package/crates/team-agent/src/lifecycle/restart/claude_fork.rs +163 -0
  64. package/crates/team-agent/src/lifecycle/restart/common.rs +345 -35
  65. package/crates/team-agent/src/lifecycle/restart/selection.rs +5 -5
  66. package/crates/team-agent/src/lifecycle/restart.rs +4 -0
  67. package/crates/team-agent/src/lifecycle/role_config.rs +39 -14
  68. package/crates/team-agent/src/lifecycle/tests/claude_compatible_config_red.rs +325 -0
  69. package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +320 -8
  70. package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +236 -13
  71. package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +378 -4
  72. package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +5 -4
  73. package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +7 -11
  74. package/crates/team-agent/src/lifecycle/tests/core.rs +47 -18
  75. package/crates/team-agent/src/lifecycle/tests/fixtures/pi_native_mcp_host.mjs +2 -1
  76. package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +14 -14
  77. package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +60 -20
  78. package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +28 -26
  79. package/crates/team-agent/src/lifecycle/tests/mcp_tool_name_format_red.rs +6 -6
  80. package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +18 -6
  81. package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +70 -52
  82. package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +210 -0
  83. package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +157 -4
  84. package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +526 -10
  85. package/crates/team-agent/src/lifecycle/tests/pi_fork_session_inheritance_red.rs +1419 -0
  86. package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +68 -1
  87. package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +34 -12
  88. package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +94 -2
  89. package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +10 -11
  90. package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +2 -2
  91. package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +254 -2
  92. package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +4 -4
  93. package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +5 -6
  94. package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +16 -7
  95. package/crates/team-agent/src/lifecycle/tests.rs +3 -0
  96. package/crates/team-agent/src/lifecycle/types.rs +18 -2
  97. package/crates/team-agent/src/lifecycle/worker_command_context.rs +43 -50
  98. package/crates/team-agent/src/mcp_server/readiness.rs +130 -149
  99. package/crates/team-agent/src/mcp_server/readiness_tests.rs +98 -119
  100. package/crates/team-agent/src/mcp_server/tests/scoped.rs +21 -31
  101. package/crates/team-agent/src/mcp_server/tests/send.rs +72 -107
  102. package/crates/team-agent/src/mcp_server/tests/tools.rs +10 -12
  103. package/crates/team-agent/src/mcp_server/tools.rs +70 -196
  104. package/crates/team-agent/src/messaging/delivery.rs +160 -218
  105. package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +5 -5
  106. package/crates/team-agent/src/messaging/helpers.rs +1 -19
  107. package/crates/team-agent/src/messaging/mod.rs +1 -0
  108. package/crates/team-agent/src/messaging/reminders.rs +316 -0
  109. package/crates/team-agent/src/messaging/scheduler.rs +7 -1
  110. package/crates/team-agent/src/messaging/tests/dup_inject.rs +191 -85
  111. package/crates/team-agent/src/messaging/tests/runtime.rs +4 -110
  112. package/crates/team-agent/src/messaging/tests/spine.rs +40 -24
  113. package/crates/team-agent/src/messaging/types.rs +1 -0
  114. package/crates/team-agent/src/provider/adapter.rs +303 -51
  115. package/crates/team-agent/src/provider/adapters/claude.rs +78 -0
  116. package/crates/team-agent/src/provider/adapters/claude_fork.rs +131 -0
  117. package/crates/team-agent/src/provider/adapters/mod.rs +7 -5
  118. package/crates/team-agent/src/provider/adapters/pi.rs +106 -0
  119. package/crates/team-agent/src/provider/classify.rs +1 -66
  120. package/crates/team-agent/src/provider/model_catalog.rs +201 -13
  121. package/crates/team-agent/src/provider/session/capture.rs +106 -6
  122. package/crates/team-agent/src/provider/session/context_fork/claude.rs +123 -0
  123. package/crates/team-agent/src/provider/session/context_fork/outcome.rs +4 -0
  124. package/crates/team-agent/src/provider/session/context_fork.rs +150 -18
  125. package/crates/team-agent/src/provider/session_scan/claude.rs +523 -0
  126. package/crates/team-agent/src/provider/session_scan/common.rs +44 -8
  127. package/crates/team-agent/src/provider/session_scan/pi.rs +34 -1
  128. package/crates/team-agent/src/provider/session_scan.rs +16 -6
  129. package/crates/team-agent/src/provider/tests/adapter.rs +104 -17
  130. package/crates/team-agent/src/provider/tests/classify.rs +0 -53
  131. package/crates/team-agent/src/provider/tests/command_helpers.rs +12 -3
  132. package/crates/team-agent/src/provider/tests/idle.rs +37 -0
  133. package/crates/team-agent/src/provider/wire.rs +22 -34
  134. package/crates/team-agent/src/state/abnormal_watch/tests/mod.rs +1 -1
  135. package/crates/team-agent/src/state/persist.rs +6 -6
  136. package/crates/team-agent/src/state/projection.rs +1 -1
  137. package/crates/team-agent/src/state/repository/tests.rs +2 -2
  138. package/crates/team-agent/src/test_support/models_timeout_fixture.rs +144 -0
  139. package/crates/team-agent/src/tmux_backend/tests.rs +0 -151
  140. package/crates/team-agent/src/tmux_backend.rs +5 -40
  141. package/package.json +4 -4
  142. package/skills/team-agent/SKILL.md +5 -7
  143. package/skills/team-agent/command-coverage.json +1 -1
  144. package/skills/team-agent/docs/reference/team-agent-operator.md +3 -3
  145. package/skills/team-agent/references/team-agent-operator.md +3 -3
@@ -1,7 +1,7 @@
1
- //! purpose: copilot 席位角色文件缺 model 时仍能正常启动
2
- //! contract: 缺 model 的 copilot 角色启动成功并真的 spawn worker
1
+ //! purpose: claude 席位角色文件缺 model 时仍能正常启动
2
+ //! contract: 缺 model 的 claude 角色启动成功并真的 spawn worker
3
3
  //! boundary: legacy Grok worker runtime 已移除(grok 角色现走 grok_build 合约叶),
4
- //! 本文件只保留 copilot 缺 model 的回归钉子
4
+ //! 本文件只保留 claude 缺 model 的回归钉子
5
5
 
6
6
  #![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
7
7
 
@@ -21,20 +21,20 @@ use serial_test::serial;
21
21
  use team_agent::lifecycle::quick_start_with_transport_in_workspace;
22
22
  use team_agent::transport::test_support::OfflineTransport;
23
23
 
24
- /// copilot 角色缺 model ⇒ 行为不变(仍能启动)。
24
+ /// claude 角色缺 model ⇒ 行为不变(仍能启动)。
25
25
  #[test]
26
26
  #[serial(env)]
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");
27
+ fn claude_role_missing_model_still_starts() {
28
+ let _hermetic = enter_hermetic("grok-claude-missing-model");
29
+ let ws = tmp_dir("claude-no-model");
30
30
  super::launch_spawn::seed_healthy_coordinator(&ws);
31
31
  let team = write_role_team(
32
32
  &ws,
33
- "copilotteam",
34
- "copiloter",
35
- "copilot",
33
+ "claudeteam",
34
+ "clauder",
35
+ "claude",
36
36
  None,
37
- "Copilot Worker",
37
+ "Claude Worker",
38
38
  );
39
39
  let transport = OfflineTransport::new();
40
40
 
@@ -43,17 +43,17 @@ fn copilot_role_missing_model_still_starts() {
43
43
  &team,
44
44
  None,
45
45
  true,
46
- Some("copilotteam"),
46
+ Some("claudeteam"),
47
47
  &transport,
48
48
  );
49
49
  assert!(
50
50
  result.is_ok(),
51
- "copilot role without model must keep starting; err={result:?}"
51
+ "claude role without model must keep starting; err={result:?}"
52
52
  );
53
53
  let argv = first_spawn_argv(&transport);
54
54
  assert!(
55
55
  !argv.is_empty(),
56
- "copilot seat must still spawn; argv={argv:?}"
56
+ "claude seat must still spawn; argv={argv:?}"
57
57
  );
58
58
  }
59
59
 
@@ -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; schema_diagnosis
14
- //! missing db -> ok:true; tmux fabricated
13
+ //! MUST-NOT-13): normalize_result_status unrecognized -> Success; claude_auth_hint
14
+ //! parse failure -> Present; schema_diagnosis 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::PathBuf;
26
+ use std::path::{Path, PathBuf};
27
27
  use std::sync::atomic::{AtomicU64, Ordering};
28
28
 
29
29
  use mcp_sim_harness::McpSimHarness;
@@ -246,23 +246,15 @@ fn t3_unknown_business_status_is_preserved_without_normalized_event() {
246
246
  "T3-1 ingress: an opaque business status must be accepted; body={} raw={}",
247
247
  call.body, call.raw
248
248
  );
249
- let result_id = call.body["result_id"]
250
- .as_str()
251
- .expect("T3-1 ingress must return the durable result_id");
252
- let row = harness
253
- .result_row(result_id)
254
- .unwrap_or_else(|| panic!("T3-1 ingress missing durable result {result_id}"));
255
- let envelope: serde_json::Value =
256
- serde_json::from_str(&row.envelope).expect("T3-1 durable envelope JSON");
257
- assert_eq!(
258
- row.status, "collected",
259
- "T3-1 ingress: report_result auto-finalization must mark the durable row collected"
260
- );
261
- assert_eq!(
262
- envelope["status"],
263
- serde_json::json!(status),
264
- "T3-1 ingress: canonical envelope status must preserve the same value"
265
- );
249
+ let message_id = call.body["message_id"].as_str().expect("durable inbound receipt id");
250
+ let inbox = crate::inbox_store::read(harness.workspace_path(), "leader", 10, Some("teamA")).unwrap();
251
+ let record = inbox["messages"].as_array().unwrap().iter()
252
+ .find(|record| record["message_id"] == message_id).expect("durable inbox record");
253
+ let envelope = &record["envelope"];
254
+ assert_eq!(record["content"], "did a thing");
255
+ assert_eq!(record["kind"], "result");
256
+ assert_eq!(envelope["status"], status, "opaque business status must not be normalized");
257
+ assert!(harness.result_row(message_id).is_none(), "no coordinator result row");
266
258
  let events = harness.events_text();
267
259
  assert!(
268
260
  !events.contains("provider.result.unknown_status_normalized"),
@@ -419,6 +411,45 @@ check behind it = false green); it must reflect an actual doctor result"
419
411
  );
420
412
  }
421
413
 
414
+ /// T3-2 (claude_auth_hint parse failure): when `claude auth status` output is
415
+ /// unparseable / unsuccessful, the hint must not default to Present (auth misreported
416
+ /// as available). PATH-shims a `claude` that prints garbage and exits non-zero.
417
+ /// Mutates the process-global PATH/HOME — must not race host_cotenant's ps/tmux
418
+ /// shims (P0 pid-probe isolation) or other env-mutating tests, hence
419
+ /// `#[serial(env, pid_probe)]`.
420
+ #[test]
421
+ #[serial(env, pid_probe)]
422
+ fn t3_claude_auth_hint_parse_failure_is_not_present() {
423
+ let home = tmp_ws("t3-auth-home");
424
+ let shim_dir = home.join("bin");
425
+ std::fs::create_dir_all(&shim_dir).unwrap();
426
+ // claude shim: garbage stdout + non-zero exit (auth status unparseable / failed).
427
+ write_shim(
428
+ &shim_dir.join("claude"),
429
+ "#!/bin/sh\nprintf 'not json at all\\n'\nexit 7\n",
430
+ );
431
+ let old_path = std::env::var("PATH").unwrap_or_default();
432
+ let old_home = std::env::var("HOME").ok();
433
+ std::env::set_var("HOME", &home);
434
+ std::env::set_var("PATH", format!("{}:{old_path}", shim_dir.to_string_lossy()));
435
+
436
+ let status = team_agent::provider::get_adapter(team_agent::provider::Provider::Claude)
437
+ .auth_hint(team_agent::provider::AuthMode::Subscription);
438
+
439
+ std::env::set_var("PATH", &old_path);
440
+ match old_home {
441
+ Some(home) => std::env::set_var("HOME", home),
442
+ None => std::env::remove_var("HOME"),
443
+ }
444
+
445
+ assert_ne!(
446
+ format!("{status:?}"),
447
+ "Present",
448
+ "T3-2: a `claude auth status` that prints unparseable output and exits non-zero \
449
+ must NOT report Present (auth misreported as available is a false green); got {status:?}"
450
+ );
451
+ }
452
+
422
453
  // ───────────────────────────────── T5 · thread leak ─────────────────────────────────
423
454
 
424
455
  /// T5 (A2 shutdown thread leak): stop_coordinator_bounded spawns a worker thread and
@@ -445,6 +476,15 @@ stop; body={body}"
445
476
 
446
477
  // ───────────────────────────────────── helpers ─────────────────────────────────────
447
478
 
479
+ fn write_shim(path: &Path, body: &str) {
480
+ std::fs::write(path, body).unwrap();
481
+ #[cfg(unix)]
482
+ {
483
+ use std::os::unix::fs::PermissionsExt;
484
+ std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o755)).unwrap();
485
+ }
486
+ }
487
+
448
488
  /// Crude single-function body extractor: from the `fn name` line to the next
449
489
  /// same-indent ` fn ` (good enough for grep-guard scoping).
450
490
  fn fn_body(src: &str, marker: &str) -> String {
@@ -41,6 +41,7 @@ fn launch_source() -> String {
41
41
  const QS_TEAM_MD: &str =
42
42
  "---\nname: quickteam\nobjective: Quick start.\nprovider: codex\n---\n\nQuick-start team.\n";
43
43
  pub(super) const QS_VALID_ROLE: &str = "---\nname: implementer\nrole: Implementation Engineer\nprovider: fake\nmodel: fake\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nImplement bounded tasks.\n";
44
+ const QS_ROLE_NO_PROVIDER: &str = "---\nname: implementer\nrole: Implementation Engineer\nmodel: gpt-5.5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nImplement bounded tasks.\n";
44
45
 
45
46
  /// A REAL team dir `<base>/teamdir/{TEAM.md, agents/implementer.md}` — already in team-dir
46
47
  /// layout, so quick_start's prepare_quick_start_team returns it as-is and writes the compiled
@@ -458,23 +459,25 @@ fn quick_start_default_workspace_compiled_spec_uses_project_root() {
458
459
  );
459
460
  }
460
461
 
461
- // An omitted role `provider` is the default `pi`, which declares the Pi contract leaf: the
462
- // compiled spec carries the leaf id, so quick-start never produces a legacy `pi` worker row.
463
- #[cfg(unix)]
462
+ // P0 — quick_start over an INVALID role doc (missing `provider`) must surface the REAL compile
463
+ // error, distinct from the stub's hardcoded "no role docs found". Golden: compile_team raises
464
+ // "missing front matter field provider" (compiler.py:_validate_role_doc), before preflight.
464
465
  #[test]
465
- fn quick_start_role_without_provider_compiles_to_the_pi_leaf() {
466
- let team = quick_start_team_dir(
467
- "---\nname: implementer\nrole: Implementation Engineer\nmodel: gpt-5.5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nImplement bounded tasks.\n",
466
+ fn quick_start_invalid_role_doc_surfaces_real_compile_error() {
467
+ let team = quick_start_team_dir(QS_ROLE_NO_PROVIDER);
468
+ let transport = OfflineTransport::new();
469
+ let result = quick_start_with_transport(&team, None, true, None, &transport);
470
+
471
+ let text = format!("{result:?}");
472
+ assert!(
473
+ text.contains("provider"),
474
+ "an invalid role doc (missing provider) must surface the real compile error mentioning \
475
+ 'provider'; got {text}"
476
+ );
477
+ assert!(
478
+ !text.contains("no role docs found"),
479
+ "must NOT be the hardcoded stub blocker — real preflight/compile distinguishes the cause"
468
480
  );
469
- let spec = crate::compiler::compile_team(&team).expect("an omitted provider is the default pi");
470
- let providers = spec
471
- .get("agents")
472
- .and_then(crate::model::yaml::Value::as_list)
473
- .expect("compiled agents")
474
- .iter()
475
- .map(|agent| agent.get("provider").and_then(crate::model::yaml::Value::as_str))
476
- .collect::<Vec<_>>();
477
- assert_eq!(providers, vec![Some("pi_tui")]);
478
481
  }
479
482
 
480
483
  // P0 — launch (dry_run) over a real compiled spec must resolve the REAL route/permission plan
@@ -2581,22 +2584,21 @@ fn restart_allow_fresh_copilot_keeps_session_id_null_until_capture_confirms() {
2581
2584
  let _ = plan; // shape verified above; details depend on classifier internals.
2582
2585
  }
2583
2586
 
2584
- /// 0.4.6 tuple-atomic contract (audit, line 268): a fresh restart of a
2585
- /// preassigned-session worker (Copilot) leaves session_id=null even when the
2586
- /// input row had a stale session_id.
2587
+ /// 0.4.6 tuple-atomic contract (audit, line 268): Claude fresh restart
2588
+ /// leaves session_id=null even when input row had a stale session_id.
2587
2589
  /// The poisoned-row scenario (Bug 045 release-engineer state).
2588
2590
  #[test]
2589
- fn restart_allow_fresh_copilot_clears_poisoned_session_id() {
2590
- let ws = temp_ws().join("restartcopilot046");
2591
+ fn restart_allow_fresh_claude_clears_poisoned_session_id() {
2592
+ let ws = temp_ws().join("restartclaude046");
2591
2593
  std::fs::create_dir_all(ws.join("agents")).unwrap();
2592
2594
  std::fs::write(
2593
2595
  ws.join("TEAM.md"),
2594
- "---\nname: restartcopilot046\nobjective: 0.4.6 contract.\nprovider: claude\n---\n\nteam.\n",
2596
+ "---\nname: restartclaude046\nobjective: 0.4.6 contract.\nprovider: claude\n---\n\nteam.\n",
2595
2597
  )
2596
2598
  .unwrap();
2597
2599
  std::fs::write(
2598
2600
  ws.join("agents").join("alpha.md"),
2599
- "---\nname: alpha\nrole: Alpha\nprovider: copilot\nmodel: gpt-5.5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nAlpha.\n",
2601
+ "---\nname: alpha\nrole: Alpha\nprovider: claude\nmodel: sonnet\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nAlpha.\n",
2600
2602
  )
2601
2603
  .unwrap();
2602
2604
  let spec = crate::compiler::compile_team(&ws).expect("compile");
@@ -2605,11 +2607,11 @@ fn restart_allow_fresh_copilot_clears_poisoned_session_id() {
2605
2607
  crate::state::persist::save_runtime_state(
2606
2608
  &ws,
2607
2609
  &json!({
2608
- "session_name": "team-restartcopilot046",
2610
+ "session_name": "team-restartclaude046",
2609
2611
  "agents": {
2610
2612
  "alpha": {
2611
2613
  "status": "running",
2612
- "provider": "copilot",
2614
+ "provider": "claude",
2613
2615
  "window": "alpha",
2614
2616
  "first_send_at": "2026-06-23T10:00:00+00:00",
2615
2617
  "session_id": stale_uuid,
@@ -2627,7 +2629,7 @@ fn restart_allow_fresh_copilot_clears_poisoned_session_id() {
2627
2629
  let result = restart_with_transport(&ws, true, None, &transport);
2628
2630
  assert!(
2629
2631
  matches!(result, Ok(RestartReport::Restarted { .. })),
2630
- "allow-fresh restart should fresh-spawn the copilot worker; got {result:?}"
2632
+ "allow-fresh restart should fresh-spawn the claude worker; got {result:?}"
2631
2633
  );
2632
2634
 
2633
2635
  let state = crate::state::persist::load_runtime_state(&ws).expect("load state");
@@ -2635,7 +2637,7 @@ fn restart_allow_fresh_copilot_clears_poisoned_session_id() {
2635
2637
  assert_eq!(
2636
2638
  agent.get("session_id"),
2637
2639
  Some(&serde_json::Value::Null),
2638
- "0.4.6 contract: fresh restart must clear stale session_id; agent={agent}"
2640
+ "0.4.6 contract: Claude fresh restart must clear stale session_id; agent={agent}"
2639
2641
  );
2640
2642
  // C1 dual-projection: teams.<key>.agents.alpha.session_id must also be null.
2641
2643
  if let Some(teams) = state.get("teams").and_then(serde_json::Value::as_object) {
@@ -1,7 +1,7 @@
1
1
  //! purpose: worker 契约里的 MCP 工具名必须按 provider 实测书写形式渲染
2
2
  //! contract:
3
- //! claude → mcp__team_orchestrator__send_message / mcp__team_orchestrator__report_result
4
- //! grok → team_orchestrator__send_message / team_orchestrator__report_result
3
+ //! claude → mcp__team_orchestrator__send_message / mcp__team_orchestrator__get_team_status
4
+ //! grok → team_orchestrator__send_message / team_orchestrator__get_team_status
5
5
  //! 已验证 provider 的渲染结果不得再含 `team_orchestrator.` 点号
6
6
  //! boundary: 只钉 compile_worker_system_prompt 字面;未验证 provider 不在此猜形式
7
7
 
@@ -30,8 +30,8 @@ fn claude_runtime_contract_pins_mcp_double_underscore_literals() {
30
30
  for provider in [Provider::Claude, Provider::ClaudeCode] {
31
31
  let prompt = compiled_prompt(provider);
32
32
  assert!(
33
- prompt.contains("mcp__team_orchestrator__report_result"),
34
- "{provider:?} must render the claude transcript literal mcp__team_orchestrator__report_result; prompt={prompt}"
33
+ prompt.contains("mcp__team_orchestrator__get_team_status"),
34
+ "{provider:?} must render the claude transcript literal mcp__team_orchestrator__get_team_status; prompt={prompt}"
35
35
  );
36
36
  assert!(
37
37
  prompt.contains("mcp__team_orchestrator__send_message"),
@@ -44,8 +44,8 @@ fn claude_runtime_contract_pins_mcp_double_underscore_literals() {
44
44
  fn grok_runtime_contract_pins_server_double_underscore_literals() {
45
45
  let prompt = compiled_prompt(Provider::Grok);
46
46
  assert!(
47
- prompt.contains("team_orchestrator__report_result"),
48
- "grok must render team_orchestrator__report_result; prompt={prompt}"
47
+ prompt.contains("team_orchestrator__get_team_status"),
48
+ "grok must render team_orchestrator__get_team_status; prompt={prompt}"
49
49
  );
50
50
  assert!(
51
51
  prompt.contains("team_orchestrator__send_message"),
@@ -2,9 +2,10 @@ use std::collections::BTreeSet;
2
2
  use std::path::Path;
3
3
 
4
4
  use crate::lifecycle::launch::pi_mcp::{
5
- build_pi_command_argv, parse_pi_list_models_table, select_exact_pi_model, PiCommandRequest,
5
+ parse_pi_list_models_table, select_exact_pi_model, verify_started_pi_model,
6
6
  };
7
7
  use crate::model::enums::ProviderEffort;
8
+ use crate::provider::adapters::pi::{build_pi_command_argv, PiCommandRequest, PiSessionSelector};
8
9
 
9
10
  const CATALOG: &[u8] = include_bytes!("fixtures/pi_list_models_g0.stdout.txt");
10
11
  // Public pi --list-models rows captured for issue #186, preserving column widths.
@@ -86,12 +87,13 @@ fn argv_has_pair(argv: &[String], flag: &str, value: &str) -> bool {
86
87
 
87
88
  fn command_for_model(model: &str) -> Vec<String> {
88
89
  build_pi_command_argv(PiCommandRequest {
89
- extension: Path::new("/workspace/.team/runtime/pi/t1/leader/team-mcp.ts"),
90
+ extension: Path::new("/workspace/.team/runtime/pi/t1/w1/team-mcp.ts"),
90
91
  model: Some(model),
91
92
  effort: Some(ProviderEffort::Medium),
92
- system_prompt: "leader contract",
93
- session_dir: Some(Path::new("/workspace/.team/runtime/pi/t1/leader/sessions")),
94
- agent_id: "leader",
93
+ system_prompt: "worker contract",
94
+ session_dir: Some(Path::new("/workspace/.team/runtime/pi/t1/w1/sessions")),
95
+ session: PiSessionSelector::Fresh,
96
+ agent_id: "w1",
95
97
  })
96
98
  .expect("catalog member must build a semantic Pi argv")
97
99
  }
@@ -132,7 +134,7 @@ fn pi_catalog_discovers_all_exact_ids_and_rejects_invalid_or_ambiguous_selection
132
134
  }
133
135
 
134
136
  #[test]
135
- fn pi_exact_catalog_id_is_forwarded_byte_for_byte() {
137
+ fn pi_exact_catalog_id_is_forwarded_and_started_identity_must_match() {
136
138
  let models = parse_pi_list_models_table(CATALOG).expect("frozen unfiltered table must parse");
137
139
  assert_eq!(models.len(), 221);
138
140
 
@@ -149,4 +151,14 @@ fn pi_exact_catalog_id_is_forwarded_byte_for_byte() {
149
151
  "model selector must occur exactly once: {argv:?}"
150
152
  );
151
153
  }
154
+
155
+ assert!(verify_started_pi_model("team-agent/qwen3.8-27b", "team-agent/qwen3.8-27b").is_ok());
156
+ assert!(
157
+ verify_started_pi_model("team-agent/qwen3.8-27b", "xai/grok-4.6").is_err(),
158
+ "started identity mismatch must refuse rather than trust pane chrome"
159
+ );
160
+ assert!(
161
+ verify_started_pi_model("team-agent/qwen3.8-27b", "").is_err(),
162
+ "missing objective started-model evidence must not pass"
163
+ );
152
164
  }
@@ -1,26 +1,26 @@
1
1
  use std::path::Path;
2
2
 
3
- use crate::lifecycle::launch::pi_mcp::{
4
- build_pi_command_argv, pi_leader_session_scope, PiCommandRequest, PiSessionScope,
5
- };
3
+ use crate::lifecycle::launch::pi_mcp::{pi_leader_session_scope, PiSessionScope};
6
4
  use crate::model::enums::ProviderEffort;
5
+ use crate::provider::adapters::pi::{build_pi_command_argv, PiCommandRequest, PiSessionSelector};
7
6
 
8
- fn isolated_leader_request() -> PiCommandRequest<'static> {
7
+ fn request(session: PiSessionSelector<'static>) -> PiCommandRequest<'static> {
9
8
  PiCommandRequest {
10
- extension: Path::new("/workspace/.team/runtime/pi/team-a/leader/team-mcp.ts"),
9
+ extension: Path::new("/workspace/.team/runtime/pi/team-a/worker-a/team-mcp.ts"),
11
10
  model: Some("team-agent/qwen3.8-27b"),
12
11
  effort: Some(ProviderEffort::High),
13
- system_prompt: "frozen leader prompt",
12
+ system_prompt: "frozen worker prompt",
14
13
  session_dir: Some(Path::new(
15
- "/workspace/.team/runtime/pi/team-a/leader/sessions",
14
+ "/workspace/.team/runtime/pi/team-a/worker-a/sessions",
16
15
  )),
17
- agent_id: "leader",
16
+ session,
17
+ agent_id: "worker-a",
18
18
  }
19
19
  }
20
20
 
21
21
  #[test]
22
22
  fn pi_command_omits_unset_model_and_thinking_flags() {
23
- let mut request = isolated_leader_request();
23
+ let mut request = request(PiSessionSelector::Fresh);
24
24
  request.model = None;
25
25
  request.effort = None;
26
26
  let argv = build_pi_command_argv(request).expect("Pi provider defaults");
@@ -36,6 +36,7 @@ fn leader_request() -> PiCommandRequest<'static> {
36
36
  effort: None,
37
37
  system_prompt: "frozen leader prompt",
38
38
  session_dir: None,
39
+ session: PiSessionSelector::Fresh,
39
40
  agent_id: "leader",
40
41
  }
41
42
  }
@@ -91,67 +92,84 @@ fn pi_leader_session_scope_keeps_explicit_and_external_routes_isolated() {
91
92
 
92
93
  #[test]
93
94
  fn pi_command_preserves_direct_pi_defaults_with_only_team_runtime_additions() {
94
- let fresh = build_pi_command_argv(isolated_leader_request()).expect("fresh Pi command");
95
+ let fresh = build_pi_command_argv(request(PiSessionSelector::Fresh))
96
+ .expect("fresh Pi command");
95
97
  assert_eq!(
96
98
  fresh,
97
99
  [
98
100
  "pi",
99
101
  "-e",
100
- "/workspace/.team/runtime/pi/team-a/leader/team-mcp.ts",
102
+ "/workspace/.team/runtime/pi/team-a/worker-a/team-mcp.ts",
101
103
  "--model",
102
104
  "team-agent/qwen3.8-27b",
103
105
  "--thinking",
104
106
  "high",
105
107
  "--append-system-prompt",
106
- "frozen leader prompt",
108
+ "frozen worker prompt",
107
109
  "--session-dir",
108
- "/workspace/.team/runtime/pi/team-a/leader/sessions",
110
+ "/workspace/.team/runtime/pi/team-a/worker-a/sessions",
109
111
  "--name",
110
- "leader",
112
+ "worker-a",
111
113
  ]
112
114
  .map(str::to_string)
113
115
  );
114
116
 
115
- for forbidden in [
116
- "rpc",
117
- "--mode",
118
- "--print",
119
- "-p",
120
- "-r",
121
- "--resume",
122
- "-c",
123
- "--continue",
124
- "--session",
125
- "--session-id",
126
- "--mcp-config",
127
- "--provider",
128
- "--fork",
129
- "--workspace",
130
- "--cwd",
131
- "--rules",
132
- "--always-approve",
133
- "--force",
134
- "--trust",
135
- "--sandbox",
136
- "--no-extensions",
137
- "--no-approve",
138
- "--no-context-files",
139
- "--no-skills",
140
- "--no-prompt-templates",
141
- "--tui-mode",
142
- "--tools",
143
- "--system-prompt",
144
- ] {
145
- assert!(
146
- !fresh.iter().any(|arg| arg == forbidden),
147
- "materializer-owned Pi argv must not inherit {forbidden}: {fresh:?}"
148
- );
117
+ let resume = build_pi_command_argv(request(PiSessionSelector::Resume {
118
+ path: Path::new(
119
+ "/workspace/.team/runtime/pi/team-a/worker-a/sessions/2026/08/session.jsonl",
120
+ ),
121
+ }))
122
+ .expect("resume Pi command");
123
+ assert!(resume.windows(2).any(|pair| {
124
+ pair == [
125
+ "--session",
126
+ "/workspace/.team/runtime/pi/team-a/worker-a/sessions/2026/08/session.jsonl",
127
+ ]
128
+ }));
129
+ assert!(!resume.iter().any(|arg| arg == "--session-id"));
130
+
131
+ for argv in [&fresh, &resume] {
132
+ assert_eq!(argv.first().map(String::as_str), Some("pi"));
133
+ for forbidden in [
134
+ "rpc",
135
+ "--mode",
136
+ "--print",
137
+ "-p",
138
+ "-r",
139
+ "--resume",
140
+ "-c",
141
+ "--continue",
142
+ "--mcp-config",
143
+ "--provider",
144
+ "--fork",
145
+ "--workspace",
146
+ "--cwd",
147
+ "--rules",
148
+ "--always-approve",
149
+ "--force",
150
+ "--trust",
151
+ "--sandbox",
152
+ "--no-extensions",
153
+ "--no-approve",
154
+ "--no-context-files",
155
+ "--no-skills",
156
+ "--no-prompt-templates",
157
+ "--tui-mode",
158
+ "--tools",
159
+ "--system-prompt",
160
+ ] {
161
+ assert!(
162
+ !argv.iter().any(|arg| arg == forbidden),
163
+ "materializer-owned Pi argv must not inherit {forbidden}: {argv:?}"
164
+ );
165
+ }
149
166
  }
150
167
  }
151
168
 
152
169
  #[test]
153
170
  fn pi_command_keeps_direct_plugins_skills_context_auth_and_tools() {
154
- let argv = build_pi_command_argv(isolated_leader_request()).expect("fresh Pi command");
171
+ let argv = build_pi_command_argv(request(PiSessionSelector::Fresh))
172
+ .expect("fresh Pi command");
155
173
 
156
174
  for forbidden in [
157
175
  "--no-context-files",
@@ -166,17 +184,17 @@ fn pi_command_keeps_direct_plugins_skills_context_auth_and_tools() {
166
184
  assert_eq!(
167
185
  argv.iter().filter(|arg| arg.as_str() == forbidden).count(),
168
186
  0,
169
- "Pi leader must preserve the direct Pi default instead of adding {forbidden}; argv={argv:?}"
187
+ "TeamMate Pi must preserve the direct Pi default instead of adding {forbidden}; argv={argv:?}"
170
188
  );
171
189
  }
172
190
  assert!(argv.windows(2).any(|pair| {
173
191
  pair == [
174
192
  "-e",
175
- "/workspace/.team/runtime/pi/team-a/leader/team-mcp.ts",
193
+ "/workspace/.team/runtime/pi/team-a/worker-a/team-mcp.ts",
176
194
  ]
177
195
  }));
178
196
  assert_eq!(argv.iter().filter(|arg| arg.as_str() == "-e").count(), 1);
179
197
  assert!(argv
180
198
  .windows(2)
181
- .any(|pair| pair == ["--append-system-prompt", "frozen leader prompt"]));
199
+ .any(|pair| pair == ["--append-system-prompt", "frozen worker prompt"]));
182
200
  }