@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
@@ -4,10 +4,8 @@
4
4
  //! `swallow-batch4-cr-verdict.md` (workspace artifacts; BOTH points APPROVE'd,
5
5
  //! 8 constraints C1-C8 + 6 reverse cases — folded below).
6
6
  //!
7
- //! Point 1 (C1-C4): a corrupt provider-config JSON must FAIL EXPLICITLY — today
8
- //! profile_launch.rs:639-649 `read_json_object` turns any parse failure into an
9
- //! empty map and `write_json_object` then flattens the user's file (silent
10
- //! destructive rewrite; MUST-NOT-9 / MUST-NOT-13 violation).
7
+ //! Point 1 (C1-C4) covered the Claude compatible-API config dir that profile launch
8
+ //! maintained for legacy Claude workers; it left with that runtime.
11
9
  //! Point 2 (C5-C8): MCP scope validation must FAIL CLOSED when the runtime state is
12
10
  //! unreadable — today `load_runtime_state(..).unwrap_or(json!({}))`
13
11
  //! (mcp_server/tools.rs:574/:232) silently substitutes an empty state, so a
@@ -25,75 +23,9 @@ mod hermetic_guard;
25
23
  #[allow(dead_code)]
26
24
  fn _hermetic_boundary_marker(_: &hermetic_guard::HermeticTestEnv) {}
27
25
 
28
- use std::path::{Path, PathBuf};
29
- use std::sync::atomic::{AtomicU64, Ordering};
30
-
31
26
  use mcp_sim_harness::McpSimHarness;
32
27
  use serde_json::json;
33
28
  use serial_test::serial;
34
- use team_agent::lifecycle::launch_with_transport;
35
-
36
- /// C1-C4 + reverse cases `profile_invalid_json_returns_error_and_does_not_overwrite_file`
37
- /// / `..._includes_path_and_parse_detail_and_next_action`: launching a claude
38
- /// compatible_api profile over a CORRUPT `.claude.json` must return a structured error
39
- /// (path + parse detail + next action) and leave the corrupt file byte-identical —
40
- /// never rewrite it with a flattened empty object.
41
- #[test]
42
- #[serial(b4_mcp)]
43
- fn b4_profile_invalid_json_fails_explicit_and_never_flattens_the_file() {
44
- // Pin a neutral process ancestry so the launch path is deterministic regardless of
45
- // which provider flags this test process inherited (same guard as the #264 batch).
46
- std::env::set_var(
47
- "TEAM_AGENT_TEST_PROCESS_ANCESTRY_ARGV_JSON",
48
- "[\"/bin/zsh\"]",
49
- );
50
- let ws = tmp_ws("b4-profile");
51
- let team_dir = write_claude_compatible_team(&ws);
52
- let config_dir = ws.join(".team/runtime/provider-config/worker_a/claude");
53
- std::fs::create_dir_all(&config_dir).unwrap();
54
- let corrupt = b"{ this is the user's corrupt claude state".to_vec();
55
- std::fs::write(config_dir.join(".claude.json"), &corrupt).unwrap();
56
-
57
- let result = launch_with_transport(
58
- &team_dir.join("team.spec.yaml"),
59
- false,
60
- true,
61
- true,
62
- &offline_transport::RecordingTransport::new(),
63
- );
64
-
65
- let mut failures = Vec::new();
66
- match &result {
67
- Ok(report) => failures.push(format!(
68
- "C1/C2: a corrupt provider-config JSON must fail the launch with a \
69
- structured profile_invalid_json error, not silently continue; got Ok({report:?})"
70
- )),
71
- Err(error) => {
72
- let text = error.to_string();
73
- if !text.contains(".claude.json") {
74
- failures.push(format!(
75
- "C1/N38: the error must name the offending path; got {text}"
76
- ));
77
- }
78
- }
79
- }
80
- let after = std::fs::read(config_dir.join(".claude.json")).unwrap_or_default();
81
- if after != corrupt {
82
- failures.push(format!(
83
- "C3/C4: the user's corrupt file must stay byte-identical (framework never \
84
- flattens user files on load failure — MUST-NOT-9); before={} bytes, after={} bytes: {:?}",
85
- corrupt.len(),
86
- after.len(),
87
- String::from_utf8_lossy(&after)
88
- ));
89
- }
90
- std::env::remove_var("TEAM_AGENT_TEST_PROCESS_ANCESTRY_ARGV_JSON");
91
- assert!(
92
- failures.is_empty(),
93
- "batch4 point-1 profile fail-explicit contract failed:\n{}",
94
- failures.join("\n")
95
- );
96
- }
97
29
 
98
30
  /// C5-C8 + reverse cases `scope_unverifiable_when_state_read_fails_returns_structured_refusal`
99
31
  /// / `scope_unverifiable_state_recovers_retry_passes`: with the runtime state
@@ -156,187 +88,3 @@ gate (owner-required refusal), not some degraded path; body={}",
156
88
  failures.join("\n")
157
89
  );
158
90
  }
159
-
160
- // ───────────────────────────────────── fixtures ─────────────────────────────────────
161
-
162
- /// Compiled claude compatible_api team with a profile (the path that maintains the
163
- /// managed `.claude.json`). Mirrors the #264 profile fixture, claude flavor.
164
- fn write_claude_compatible_team(ws: &Path) -> PathBuf {
165
- let team = ws.join("teamdir");
166
- std::fs::create_dir_all(team.join("agents")).unwrap();
167
- std::fs::create_dir_all(team.join("profiles")).unwrap();
168
- std::fs::write(
169
- team.join("TEAM.md"),
170
- "---\nname: b4team\nobjective: batch4 profile fixture.\nprovider: claude\n---\n\nTeam.\n",
171
- )
172
- .unwrap();
173
- std::fs::write(
174
- team.join("agents/worker_a.md"),
175
- "---\nname: worker_a\nrole: Compat Worker\nprovider: claude\nmodel: claude-haiku\nauth_mode: compatible_api\ndangerously_skip_permissions: false\nprofile: relay\ntools:\n - mcp_team\n---\n\nCompat worker.\n",
176
- )
177
- .unwrap();
178
- std::fs::write(
179
- team.join("profiles/relay.env"),
180
- "AUTH_MODE=compatible_api\nBASE_URL=https://relay.example/v1\nAPI_KEY=sk-relay-b4\nMODEL=claude-haiku\n",
181
- )
182
- .unwrap();
183
- let spec = team_agent::compiler::compile_team(&team).expect("compile fixture team");
184
- std::fs::write(
185
- team.join("team.spec.yaml"),
186
- team_agent::model::yaml::dumps(&spec),
187
- )
188
- .unwrap();
189
- team
190
- }
191
-
192
- mod offline_transport {
193
- use super::*;
194
- use std::collections::BTreeMap;
195
- use std::sync::Mutex;
196
- use team_agent::transport::{
197
- AttachOutcome, BackendKind, CaptureRange, CapturedText, InjectPayload, InjectReport,
198
- InjectStage, InjectVerification, Key, PaneField, PaneId, PaneInfo, SessionName,
199
- SetEnvOutcome, SpawnResult, SubmitVerification, Target, Transport, TransportError,
200
- TurnVerification, WindowName,
201
- };
202
-
203
- #[derive(Default)]
204
- pub struct RecordingTransport {
205
- session_present: Mutex<bool>,
206
- }
207
-
208
- impl RecordingTransport {
209
- pub fn new() -> Self {
210
- Self::default()
211
- }
212
- }
213
-
214
- impl Transport for RecordingTransport {
215
- fn kind(&self) -> BackendKind {
216
- BackendKind::Tmux
217
- }
218
-
219
- fn spawn_first(
220
- &self,
221
- session: &SessionName,
222
- window: &WindowName,
223
- _argv: &[String],
224
- _cwd: &Path,
225
- _env: &BTreeMap<String, String>,
226
- ) -> Result<SpawnResult, TransportError> {
227
- *self.session_present.lock().unwrap() = true;
228
- Ok(SpawnResult {
229
- pane_id: PaneId::new("%1"),
230
- session: session.clone(),
231
- window: window.clone(),
232
- child_pid: None,
233
- })
234
- }
235
-
236
- fn spawn_into(
237
- &self,
238
- session: &SessionName,
239
- window: &WindowName,
240
- argv: &[String],
241
- cwd: &Path,
242
- env: &BTreeMap<String, String>,
243
- ) -> Result<SpawnResult, TransportError> {
244
- self.spawn_first(session, window, argv, cwd, env)
245
- }
246
-
247
- fn inject(
248
- &self,
249
- _target: &Target,
250
- _payload: &InjectPayload,
251
- _submit: Key,
252
- _bracketed: bool,
253
- ) -> Result<InjectReport, TransportError> {
254
- Ok(InjectReport {
255
- stage_reached: InjectStage::Submit,
256
- inject_verification: InjectVerification::CaptureContainsToken,
257
- submit_verification: SubmitVerification::EnterSentWithoutPlaceholderCheck,
258
- turn_verification: TurnVerification::NotYetObserved,
259
- attempts: 1,
260
- submit_diagnostics: None,
261
- })
262
- }
263
-
264
- fn send_keys(&self, _target: &Target, _keys: &[Key]) -> Result<(), TransportError> {
265
- Ok(())
266
- }
267
-
268
- fn capture(
269
- &self,
270
- _target: &Target,
271
- range: CaptureRange,
272
- ) -> Result<CapturedText, TransportError> {
273
- Ok(CapturedText {
274
- text: "Claude Code\n> ".to_string(),
275
- range,
276
- })
277
- }
278
-
279
- fn query(
280
- &self,
281
- _target: &Target,
282
- field: PaneField,
283
- ) -> Result<Option<String>, TransportError> {
284
- match field {
285
- PaneField::PaneWidth => Ok(Some("120".to_string())),
286
- _ => Ok(None),
287
- }
288
- }
289
-
290
- fn liveness(
291
- &self,
292
- _pane: &PaneId,
293
- ) -> Result<team_agent::transport::PaneLiveness, TransportError> {
294
- Ok(team_agent::transport::PaneLiveness::Live)
295
- }
296
-
297
- fn list_targets(&self) -> Result<Vec<PaneInfo>, TransportError> {
298
- Ok(Vec::new())
299
- }
300
-
301
- fn has_session(&self, _session: &SessionName) -> Result<bool, TransportError> {
302
- Ok(*self.session_present.lock().unwrap())
303
- }
304
-
305
- fn list_windows(&self, _session: &SessionName) -> Result<Vec<WindowName>, TransportError> {
306
- Ok(Vec::new())
307
- }
308
-
309
- fn set_session_env(
310
- &self,
311
- _session: &SessionName,
312
- _key: &str,
313
- _value: &str,
314
- ) -> Result<SetEnvOutcome, TransportError> {
315
- Ok(SetEnvOutcome::Applied)
316
- }
317
-
318
- fn kill_session(&self, _session: &SessionName) -> Result<(), TransportError> {
319
- Ok(())
320
- }
321
-
322
- fn kill_window(&self, _target: &Target) -> Result<(), TransportError> {
323
- Ok(())
324
- }
325
-
326
- fn attach_session(&self, _session: &SessionName) -> Result<AttachOutcome, TransportError> {
327
- Ok(AttachOutcome::Attached)
328
- }
329
- }
330
- }
331
-
332
- fn tmp_ws(tag: &str) -> PathBuf {
333
- static N: AtomicU64 = AtomicU64::new(0);
334
- let dir = std::env::temp_dir().join(format!(
335
- "ta-rs-swallow-{tag}-{}-{}",
336
- std::process::id(),
337
- N.fetch_add(1, Ordering::Relaxed)
338
- ));
339
- let _ = std::fs::remove_dir_all(&dir);
340
- std::fs::create_dir_all(&dir).unwrap();
341
- std::fs::canonicalize(dir).unwrap()
342
- }
@@ -245,7 +245,7 @@ fn write_team_dir(root: &Path, dir_name: &str, agent: &str) -> PathBuf {
245
245
 
246
246
  fn role_doc(agent: &str) -> String {
247
247
  format!(
248
- "---\nname: {agent}\nrole: Worker\nprovider: codex\nmodel: gpt-5.5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nWorker.\n"
248
+ "---\nname: {agent}\nrole: Worker\nprovider: fake\nmodel: fake\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nWorker.\n"
249
249
  )
250
250
  }
251
251
 
@@ -288,7 +288,7 @@ fn agent_state(team: &str, agent: &str) -> Value {
288
288
  "agent_id": agent,
289
289
  "owner_team_id": team,
290
290
  "status": "running",
291
- "provider": "codex",
291
+ "provider": "fake",
292
292
  "role": "Worker",
293
293
  "window": agent
294
294
  })
@@ -881,7 +881,7 @@ fn team_dir_with_name(root: &Path, dir_name: &str, spec_name: &str, agent_id: &s
881
881
 
882
882
  fn role_doc(name: &str) -> String {
883
883
  format!(
884
- "---\nname: {name}\nrole: Worker\nprovider: codex\nmodel: gpt-5.5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nWorker.\n"
884
+ "---\nname: {name}\nrole: Worker\nprovider: fake\nmodel: fake\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nWorker.\n"
885
885
  )
886
886
  }
887
887
 
@@ -881,7 +881,7 @@ fn team_entry(
881
881
  json!({
882
882
  "agent_id": agent_id,
883
883
  "status": status,
884
- "provider": "codex",
884
+ "provider": "fake",
885
885
  "auth_mode": "subscription",
886
886
  "role": agent_id,
887
887
  "window": agent_id,
@@ -1057,7 +1057,7 @@ fn team_dir(root: &Path, name: &str, agents: &[(&str, &str)]) -> PathBuf {
1057
1057
 
1058
1058
  fn role_doc(name: &str, role: &str) -> String {
1059
1059
  format!(
1060
- "---\nname: {name}\nrole: {role}\nprovider: codex\nmodel: gpt-5.5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\n{role}.\n"
1060
+ "---\nname: {name}\nrole: {role}\nprovider: fake\nmodel: fake\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\n{role}.\n"
1061
1061
  )
1062
1062
  }
1063
1063
 
@@ -274,7 +274,7 @@ impl RollbackFixture {
274
274
  "agents": {
275
275
  "alpha": {
276
276
  "status": "stopped",
277
- "provider": "codex",
277
+ "provider": "fake",
278
278
  "auth_mode": "subscription",
279
279
  "window": "alpha",
280
280
  "session_id": "sess-alpha",
@@ -285,7 +285,7 @@ impl RollbackFixture {
285
285
  },
286
286
  "bravo": {
287
287
  "status": "running",
288
- "provider": "codex",
288
+ "provider": "fake",
289
289
  "auth_mode": "subscription",
290
290
  "window": "bravo",
291
291
  "session_id": "sess-bravo",
@@ -322,7 +322,7 @@ impl RollbackFixture {
322
322
  "agents": {
323
323
  "newfork": {
324
324
  "status": "running",
325
- "provider": "codex",
325
+ "provider": "fake",
326
326
  "pane_id": "%sibling-newfork",
327
327
  "owner_team_id": "sibling"
328
328
  }
@@ -390,7 +390,7 @@ impl RollbackFixture {
390
390
 
391
391
  fn agent_doc(name: &str, role: &str) -> String {
392
392
  format!(
393
- "---\nname: {name}\nrole: {role}\nprovider: codex\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\n{role}.\n"
393
+ "---\nname: {name}\nrole: {role}\nprovider: fake\nmodel: fake\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\n{role}.\n"
394
394
  )
395
395
  }
396
396
 
@@ -248,7 +248,7 @@ fn upgrade_restart_plan_uses_persisted_session_id() {
248
248
  "agents": {
249
249
  "w1": {
250
250
  "status": "running",
251
- "provider": "codex",
251
+ "provider": "copilot",
252
252
  "session_id": "sess-upgrade",
253
253
  "rollout_path": rollout.to_string_lossy(),
254
254
  "first_send_at": "2026-06-07T01:00:00+00:00"
@@ -276,7 +276,7 @@ fn restart_auto_fresh_never_captured_worker_without_allow_fresh() {
276
276
  "agents": {
277
277
  "never_captured": {
278
278
  "status": "running",
279
- "provider": "claude",
279
+ "provider": "copilot",
280
280
  "session_id": null,
281
281
  "first_send_at": null
282
282
  }
@@ -302,15 +302,15 @@ fn restart_auto_fresh_never_captured_worker_without_allow_fresh() {
302
302
  /// state — restart without --allow-fresh must STILL Refuse, never
303
303
  /// silently fresh (architect rule: 绝不静默 fresh). This is what the
304
304
  /// existing `upgrade_restart_refuses_interacted_worker_without_session_id`
305
- /// test pins; this test pins the SAME guard for Claude (the partial-resume
305
+ /// test pins; this test pins the SAME guard for Copilot (the partial-resume
306
306
  /// change must not weaken it for any provider).
307
307
  #[test]
308
- fn restart_refuses_interacted_claude_worker_without_session_id_partial_resume_preserves_guard() {
308
+ fn restart_refuses_interacted_copilot_worker_without_session_id_partial_resume_preserves_guard() {
309
309
  let state = json!({
310
310
  "agents": {
311
311
  "interacted_no_sid": {
312
312
  "status": "running",
313
- "provider": "claude",
313
+ "provider": "copilot",
314
314
  "session_id": null,
315
315
  "first_send_at": "2026-06-26T01:00:00+00:00"
316
316
  }
@@ -332,7 +332,7 @@ fn upgrade_restart_refuses_interacted_worker_without_session_id() {
332
332
  "agents": {
333
333
  "w1": {
334
334
  "status": "running",
335
- "provider": "codex",
335
+ "provider": "fake",
336
336
  "session_id": null,
337
337
  "first_send_at": "2026-06-07T01:00:00+00:00"
338
338
  }
@@ -358,6 +358,7 @@ fn upgrade_rust_mcp_config_uses_current_binary_and_runtime_key() {
358
358
  fixture.write_spec(TEAM_KEY, LEGACY_NAME);
359
359
  fixture.seed_restartable_state();
360
360
  fixture.seed_healthy_coordinator();
361
+ let _home = fixture.copilot_home_with_session("sess-upgrade");
361
362
  let transport = RecordingTransport::new().with_session_present(false);
362
363
 
363
364
  let report = restart_with_transport(&fixture.team_dir, false, Some(TEAM_KEY), &transport)
@@ -373,22 +374,37 @@ fn upgrade_rust_mcp_config_uses_current_binary_and_runtime_key() {
373
374
  format!("{report:?}").contains("Resumed"),
374
375
  "restart report must show resume path for persisted session_id; report={report:?}"
375
376
  );
377
+ // Copilot reads its MCP config from `--additional-mcp-config @<file>`.
378
+ let mcp_config_path = spawn
379
+ .argv
380
+ .windows(2)
381
+ .find(|pair| pair[0] == "--additional-mcp-config")
382
+ .and_then(|pair| pair[1].strip_prefix('@'))
383
+ .map(PathBuf::from)
384
+ .unwrap_or_else(|| {
385
+ panic!("restarted copilot worker must point --additional-mcp-config at its MCP file; command_line={command_line:?}")
386
+ });
387
+ let mcp_text = std::fs::read_to_string(&mcp_config_path).unwrap();
388
+ let mcp_config: Value = serde_json::from_str(&mcp_text).unwrap();
376
389
  assert!(
377
- command_line.contains(&current_exe),
378
- "restarted worker MCP command must use the current Rust candidate binary path; current_exe={current_exe} command_line={command_line:?}"
390
+ mcp_text.contains(&current_exe),
391
+ "restarted worker MCP command must use the current Rust candidate binary path; current_exe={current_exe} mcp_config={mcp_text}"
379
392
  );
380
393
  assert!(
381
394
  command_line.contains("TEAM_AGENT_OWNER_TEAM_ID=upgrade-key")
382
- && command_line.contains("TEAM_AGENT_OWNER_TEAM_ID=\"upgrade-key\""),
383
- "spawn env and MCP config must both use runtime team key upgrade-key; command_line={command_line:?}"
395
+ && mcp_config
396
+ .pointer("/mcpServers/team_orchestrator/env/TEAM_AGENT_OWNER_TEAM_ID")
397
+ .and_then(Value::as_str)
398
+ == Some("upgrade-key"),
399
+ "spawn env and MCP config must both use runtime team key upgrade-key; command_line={command_line:?} mcp_config={mcp_text}"
384
400
  );
385
401
  assert!(
386
- spawn
387
- .argv
388
- .windows(2)
389
- .any(|pair| pair[0] == "codex" && pair[1] == "resume")
390
- && spawn.argv.iter().any(|arg| arg == "sess-upgrade"),
391
- "restart must resume persisted provider session, not fresh start; command_line={command_line:?}"
402
+ spawn.argv.iter().any(|arg| arg == "copilot")
403
+ && spawn
404
+ .argv
405
+ .windows(2)
406
+ .any(|pair| pair[0] == "--resume" && pair[1] == "sess-upgrade"),
407
+ "restart must resume persisted provider session (`copilot ... --resume <sid>`), not fresh start; command_line={command_line:?}"
392
408
  );
393
409
  }
394
410
 
@@ -443,7 +459,7 @@ impl UpgradeFixture {
443
459
  std::fs::create_dir_all(self.team_dir.join("agents")).unwrap();
444
460
  std::fs::write(
445
461
  self.team_dir.join("agents").join("upgrade_worker.md"),
446
- "---\nname: upgrade_worker\nrole: Upgrade Worker\nprovider: codex\nmodel: gpt-5.5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nWorker.\n",
462
+ "---\nname: upgrade_worker\nrole: Upgrade Worker\nprovider: copilot\nmodel: gpt-5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nWorker.\n",
447
463
  )
448
464
  .unwrap();
449
465
  let spec = team_agent::compiler::compile_team(&self.team_dir).unwrap();
@@ -471,7 +487,7 @@ impl UpgradeFixture {
471
487
  "agents": {
472
488
  "upgrade_worker": {
473
489
  "status": "running",
474
- "provider": "codex",
490
+ "provider": "copilot",
475
491
  "role": "Upgrade Worker",
476
492
  "tools": ["mcp_team"],
477
493
  "window": "upgrade_worker",
@@ -492,7 +508,7 @@ impl UpgradeFixture {
492
508
  "agents": {
493
509
  "upgrade_worker": {
494
510
  "status": "running",
495
- "provider": "codex",
511
+ "provider": "copilot",
496
512
  "role": "Upgrade Worker",
497
513
  "tools": ["mcp_team"],
498
514
  "window": "upgrade_worker",
@@ -511,6 +527,26 @@ impl UpgradeFixture {
511
527
  .unwrap();
512
528
  }
513
529
 
530
+ /// Copilot resume backing is the `sessions` row in
531
+ /// `$HOME/.copilot/session-store.db`; seed it under a fixture HOME and point
532
+ /// HOME there for the guard's lifetime (callers are `serial(env)`).
533
+ fn copilot_home_with_session(&self, session_id: &str) -> HomeGuard {
534
+ let home = self.workspace.parent().unwrap().join("home");
535
+ let db = home.join(".copilot").join("session-store.db");
536
+ std::fs::create_dir_all(db.parent().unwrap()).unwrap();
537
+ let conn = rusqlite::Connection::open(db).unwrap();
538
+ conn.execute_batch(
539
+ "create table if not exists sessions (id text primary key, cwd text, created_at text);",
540
+ )
541
+ .unwrap();
542
+ conn.execute(
543
+ "insert or replace into sessions(id, cwd, created_at) values (?1, ?2, '2026-06-07T01:00:00Z')",
544
+ params![session_id, self.team_dir.to_string_lossy()],
545
+ )
546
+ .unwrap();
547
+ HomeGuard::set(&home)
548
+ }
549
+
514
550
  fn dual_team_state(&self, active: &str) -> Value {
515
551
  let upgrade = json!({
516
552
  "status": "alive",
@@ -657,6 +693,25 @@ impl UpgradeFixture {
657
693
  }
658
694
  }
659
695
 
696
+ struct HomeGuard(Option<std::ffi::OsString>);
697
+
698
+ impl HomeGuard {
699
+ fn set(home: &Path) -> Self {
700
+ let previous = std::env::var_os("HOME");
701
+ std::env::set_var("HOME", home);
702
+ Self(previous)
703
+ }
704
+ }
705
+
706
+ impl Drop for HomeGuard {
707
+ fn drop(&mut self) {
708
+ match self.0.take() {
709
+ Some(previous) => std::env::set_var("HOME", previous),
710
+ None => std::env::remove_var("HOME"),
711
+ }
712
+ }
713
+ }
714
+
660
715
  #[derive(Debug, Clone)]
661
716
  struct RecordedSpawn {
662
717
  argv: Vec<String>,