@team-agent/installer 0.5.126 → 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.
- package/Cargo.lock +1 -1
- package/Cargo.toml +1 -1
- package/crates/team-agent/src/cli/diagnose.rs +0 -69
- package/crates/team-agent/src/cli/emit.rs +10 -9
- package/crates/team-agent/src/cli/grok_slot.rs +88 -3
- package/crates/team-agent/src/cli/intent/runtime.rs +6 -4
- package/crates/team-agent/src/cli/intent/runtime_tests.rs +45 -0
- package/crates/team-agent/src/cli/mod.rs +13 -1
- package/crates/team-agent/src/cli/models.rs +27 -181
- package/crates/team-agent/src/cli/tests/leader_watch.rs +1 -1
- package/crates/team-agent/src/cli/tests/mod.rs +2 -2
- package/crates/team-agent/src/cli/tests/run_delegation.rs +3 -3
- package/crates/team-agent/src/cli/tests/status_send.rs +2 -2
- package/crates/team-agent/src/compiler/tests.rs +36 -9
- package/crates/team-agent/src/compiler.rs +3 -2
- package/crates/team-agent/src/contract_runtime/backend.rs +36 -0
- package/crates/team-agent/src/contract_runtime/commands.rs +335 -4
- package/crates/team-agent/src/contract_runtime/config.rs +6 -5
- package/crates/team-agent/src/contract_runtime/framework.rs +2 -5
- package/crates/team-agent/src/contract_runtime/registry.rs +66 -67
- package/crates/team-agent/src/coordinator/steps/abnormal.rs +45 -5
- package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +27 -10
- package/crates/team-agent/src/coordinator/tests/energy.rs +4 -4
- package/crates/team-agent/src/coordinator/tests/health_sync.rs +2 -2
- package/crates/team-agent/src/coordinator/tests/main_preserved.rs +2 -2
- package/crates/team-agent/src/coordinator/tests/spine.rs +1 -1
- package/crates/team-agent/src/coordinator/tests/takeover.rs +3 -3
- package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +17 -185
- package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +4 -487
- package/crates/team-agent/src/lifecycle/launch/quick_start.rs +2 -2
- package/crates/team-agent/src/lifecycle/launch/spawn.rs +8 -21
- package/crates/team-agent/src/lifecycle/launch.rs +3 -11
- package/crates/team-agent/src/lifecycle/profile_launch.rs +8 -64
- package/crates/team-agent/src/lifecycle/restart/common.rs +6 -151
- package/crates/team-agent/src/lifecycle/restart/remove.rs +129 -0
- package/crates/team-agent/src/lifecycle/role_config.rs +40 -13
- package/crates/team-agent/src/lifecycle/tests/acceptance_b_batch_red.rs +1 -1
- package/crates/team-agent/src/lifecycle/tests/agent_ops.rs +8 -12
- package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +37 -240
- package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +95 -59
- package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +20 -35
- package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +2 -2
- package/crates/team-agent/src/lifecycle/tests/core.rs +22 -48
- package/crates/team-agent/src/lifecycle/tests/f032_startup_prompt_best_effort_red.rs +22 -8
- package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +6 -124
- package/crates/team-agent/src/lifecycle/tests/host_cotenant_death_p0_contract.rs +30 -67
- package/crates/team-agent/src/lifecycle/tests/issue238_codex_effort_contract.rs +3 -31
- package/crates/team-agent/src/lifecycle/tests/lane_ops.rs +194 -169
- package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +136 -256
- package/crates/team-agent/src/lifecycle/tests/lifecycle_rollback_red.rs +15 -78
- package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +7 -7
- package/crates/team-agent/src/lifecycle/tests/phase_b_contracts.rs +75 -69
- package/crates/team-agent/src/lifecycle/tests/phase_golden.rs +2 -10
- package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +7 -7
- package/crates/team-agent/src/lifecycle/tests/restart.rs +12 -153
- package/crates/team-agent/src/lifecycle/tests/restart_build_before_destroy_0540_contract.rs +27 -5
- package/crates/team-agent/src/lifecycle/tests/restart_liveness_red.rs +59 -10
- package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +47 -6
- package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +3 -1374
- package/crates/team-agent/src/lifecycle/tests/resume_recover_red.rs +27 -10
- package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +5 -5
- package/crates/team-agent/src/lifecycle/tests/subprep_codex_trust_roundtrip_red.rs +67 -313
- package/crates/team-agent/src/lifecycle/tests/team_in_team_identity_scope_red.rs +2 -2
- package/crates/team-agent/src/lifecycle/tests/team_in_team_sibling_quick_start_red.rs +1 -1
- package/crates/team-agent/src/lifecycle/tests/team_in_team_state_scope_red.rs +2 -2
- package/crates/team-agent/src/lifecycle/tests/team_key_retirement_txn_red.rs +4 -4
- package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +70 -15
- package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +35 -35
- package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +36 -82
- package/crates/team-agent/src/lifecycle/tests.rs +0 -4
- package/crates/team-agent/src/lifecycle/types.rs +2 -5
- package/crates/team-agent/src/mcp_server/readiness_tests.rs +15 -17
- package/crates/team-agent/src/messaging/delivery.rs +9 -61
- package/crates/team-agent/src/messaging/tests/dup_inject.rs +67 -68
- package/crates/team-agent/src/messaging/tests/main_preserved.rs +2 -2
- package/crates/team-agent/src/messaging/tests/runtime.rs +5 -5
- package/crates/team-agent/src/messaging/tests/spine.rs +5 -1
- package/crates/team-agent/src/messaging/tests/wave2.rs +13 -20
- package/crates/team-agent/src/provider/adapter.rs +58 -356
- package/crates/team-agent/src/provider/adapters/mod.rs +5 -7
- package/crates/team-agent/src/provider/session/capture.rs +5 -105
- package/crates/team-agent/src/provider/session/context_fork/outcome.rs +8 -20
- package/crates/team-agent/src/provider/session/context_fork.rs +23 -142
- package/crates/team-agent/src/provider/session/mod.rs +2 -3
- package/crates/team-agent/src/provider/session_scan/common.rs +21 -57
- package/crates/team-agent/src/provider/session_scan.rs +6 -16
- package/crates/team-agent/src/provider/tests/adapter.rs +37 -118
- package/crates/team-agent/src/provider/tests/command_helpers.rs +1 -18
- package/crates/team-agent/src/provider/tests/idle.rs +0 -43
- package/crates/team-agent/src/provider/types.rs +0 -4
- package/crates/team-agent/src/provider/wire.rs +34 -8
- package/crates/team-agent/src/tmux_backend.rs +4 -3
- package/package.json +4 -4
- package/skills/team-agent/SKILL.md +3 -2
- package/skills/team-agent/command-coverage.json +14 -0
- package/skills/team-agent/docs/reference/team-agent-operator.md +3 -1
- package/skills/team-agent/references/team-agent-operator.md +3 -1
- package/crates/team-agent/src/lifecycle/launch/grok_per_seat.rs +0 -260
- package/crates/team-agent/src/lifecycle/tests/codex_weak_window_attribution_red.rs +0 -683
- package/crates/team-agent/src/lifecycle/tests/grok_effort_argv_red.rs +0 -247
- package/crates/team-agent/src/lifecycle/tests/grok_mcp_overlay_red.rs +0 -507
- package/crates/team-agent/src/lifecycle/tests/grok_restart_resume_red.rs +0 -300
- package/crates/team-agent/src/provider/adapters/codex.rs +0 -101
- package/crates/team-agent/src/provider/adapters/grok.rs +0 -67
- package/crates/team-agent/src/provider/session/context_fork/codex.rs +0 -514
- package/crates/team-agent/src/provider/session_scan/codex.rs +0 -326
- package/crates/team-agent/src/provider/session_scan/grok.rs +0 -288
|
@@ -20,9 +20,9 @@ use super::*;
|
|
|
20
20
|
use crate::lifecycle::restart::classify_restart_plan;
|
|
21
21
|
use crate::lifecycle::types::{ResumeDecision, StartMode};
|
|
22
22
|
|
|
23
|
-
fn
|
|
23
|
+
fn agent_copilot(session_id: Option<&str>, first_send_at: serde_json::Value) -> serde_json::Value {
|
|
24
24
|
let mut obj = serde_json::Map::new();
|
|
25
|
-
obj.insert("provider".to_string(), json!("
|
|
25
|
+
obj.insert("provider".to_string(), json!("copilot"));
|
|
26
26
|
obj.insert("status".to_string(), json!("running"));
|
|
27
27
|
obj.insert("first_send_at".to_string(), first_send_at);
|
|
28
28
|
if let Some(sid) = session_id {
|
|
@@ -35,7 +35,7 @@ fn agent_codex(session_id: Option<&str>, first_send_at: serde_json::Value) -> se
|
|
|
35
35
|
fn unit0_restart_missing_session_id_is_no_persisted_session_id() {
|
|
36
36
|
let state = json!({
|
|
37
37
|
"agents": {
|
|
38
|
-
"a":
|
|
38
|
+
"a": agent_copilot(None, json!("2026-01-01T00:00:00Z")),
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
41
|
let plan = classify_restart_plan(&state, false).unwrap();
|
|
@@ -53,7 +53,7 @@ fn unit0_restart_session_id_present_no_backing_is_session_unresumable() {
|
|
|
53
53
|
// — the opaque reason that unit-5 will replace with structured enum.
|
|
54
54
|
let state = json!({
|
|
55
55
|
"agents": {
|
|
56
|
-
"a":
|
|
56
|
+
"a": agent_copilot(Some("sess-unit0-missing"), json!("2026-01-01T00:00:00Z")),
|
|
57
57
|
}
|
|
58
58
|
});
|
|
59
59
|
let plan = classify_restart_plan(&state, false).unwrap();
|
|
@@ -67,8 +67,8 @@ fn unit0_restart_session_id_present_no_backing_is_session_unresumable() {
|
|
|
67
67
|
fn unit0_restart_allow_fresh_converts_refusals_into_fresh_decisions() {
|
|
68
68
|
let state = json!({
|
|
69
69
|
"agents": {
|
|
70
|
-
"a":
|
|
71
|
-
"b":
|
|
70
|
+
"a": agent_copilot(None, json!("2026-01-01T00:00:00Z")),
|
|
71
|
+
"b": agent_copilot(Some("sess-unit0-allow-fresh"), json!("2026-01-01T00:00:00Z")),
|
|
72
72
|
}
|
|
73
73
|
});
|
|
74
74
|
let plan = classify_restart_plan(&state, true).unwrap();
|
|
@@ -93,8 +93,9 @@ fn unit0_restart_allow_fresh_converts_refusals_into_fresh_decisions() {
|
|
|
93
93
|
#[test]
|
|
94
94
|
fn layer2_backing_missing_refusal_carries_checked_paths_and_recovery_hint() {
|
|
95
95
|
// Leader follow-up 2026-06-22: when classify_restart_plan_with_resume_validation
|
|
96
|
-
// runs with a real workspace, a
|
|
97
|
-
// but whose rollout_path does not exist on disk
|
|
96
|
+
// runs with a real workspace, a copilot worker whose session_id is set
|
|
97
|
+
// but whose rollout_path does not exist on disk (and whose id has no
|
|
98
|
+
// ~/.copilot/session-store.db row) should produce a
|
|
98
99
|
// refusal whose structured ResumeRefusalReason::SessionBackingStoreMissing
|
|
99
100
|
// carries the actual probed paths (the persisted rollout_path) AND a
|
|
100
101
|
// RecoveryHint with the agent_id as the picker name.
|
|
@@ -109,7 +110,7 @@ fn layer2_backing_missing_refusal_carries_checked_paths_and_recovery_hint() {
|
|
|
109
110
|
// Do NOT create the file. Probe must report it as not-existing AND
|
|
110
111
|
// include it in checked_paths.
|
|
111
112
|
let mut agent = serde_json::Map::new();
|
|
112
|
-
agent.insert("provider".to_string(), json!("
|
|
113
|
+
agent.insert("provider".to_string(), json!("copilot"));
|
|
113
114
|
agent.insert("status".to_string(), json!("running"));
|
|
114
115
|
agent.insert("session_id".to_string(), json!("sess-layer2-missing"));
|
|
115
116
|
agent.insert(
|
|
@@ -156,7 +157,7 @@ fn layer2_backing_missing_refusal_carries_checked_paths_and_recovery_hint() {
|
|
|
156
157
|
Some(ws.as_path()),
|
|
157
158
|
"spawn_cwd should round-trip through the hint"
|
|
158
159
|
);
|
|
159
|
-
assert_eq!(hint.provider, "
|
|
160
|
+
assert_eq!(hint.provider, "copilot");
|
|
160
161
|
}
|
|
161
162
|
other => panic!(
|
|
162
163
|
"expected SessionBackingStoreMissing with structured fields; got {:?}",
|
|
@@ -165,148 +166,6 @@ fn layer2_backing_missing_refusal_carries_checked_paths_and_recovery_hint() {
|
|
|
165
166
|
}
|
|
166
167
|
}
|
|
167
168
|
|
|
168
|
-
fn write_codex_identity_rollout(
|
|
169
|
-
workspace: &std::path::Path,
|
|
170
|
-
file_name: &str,
|
|
171
|
-
session_id: &str,
|
|
172
|
-
embedded_agent_id: &str,
|
|
173
|
-
) -> std::path::PathBuf {
|
|
174
|
-
let path = workspace.join(file_name);
|
|
175
|
-
let text = format!(
|
|
176
|
-
"{{\"session_meta\":{{\"payload\":{{\"id\":\"{session_id}\",\"cwd\":\"{}\"}}}}}}\n\
|
|
177
|
-
{{\"type\":\"turn_context\",\"payload\":{{}}}}\n\
|
|
178
|
-
{{\"type\":\"response_item\",\"payload\":{{\"content\":[{{\"type\":\"input_text\",\"text\":\"You are Team Agent worker `{embedded_agent_id}` with role `fixture`.\"}}]}}}}\n",
|
|
179
|
-
workspace.to_string_lossy()
|
|
180
|
-
);
|
|
181
|
-
std::fs::write(&path, text).unwrap();
|
|
182
|
-
path
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
#[test]
|
|
186
|
-
fn restart_refuses_codex_session_identity_mismatch_without_allow_fresh() {
|
|
187
|
-
let ws = temp_ws();
|
|
188
|
-
let rollout = write_codex_identity_rollout(
|
|
189
|
-
&ws,
|
|
190
|
-
"rollout-frontend-poison.jsonl",
|
|
191
|
-
"019f3327-c35a-7023-b3cd-1bea93a7a157",
|
|
192
|
-
"ios-dev",
|
|
193
|
-
);
|
|
194
|
-
let state = json!({
|
|
195
|
-
"agents": {
|
|
196
|
-
"frontend": {
|
|
197
|
-
"provider": "codex",
|
|
198
|
-
"status": "running",
|
|
199
|
-
"session_id": "019f3327-c35a-7023-b3cd-1bea93a7a157",
|
|
200
|
-
"rollout_path": rollout.to_string_lossy(),
|
|
201
|
-
"captured_at": "2026-07-05T17:04:04Z",
|
|
202
|
-
"captured_via": "fs_watch",
|
|
203
|
-
"spawn_cwd": ws.to_string_lossy(),
|
|
204
|
-
"first_send_at": "2026-07-05T17:10:00Z"
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
let plan = crate::lifecycle::restart::classify_restart_plan_with_resume_validation(
|
|
210
|
-
Some(&ws),
|
|
211
|
-
&state,
|
|
212
|
-
false,
|
|
213
|
-
)
|
|
214
|
-
.unwrap();
|
|
215
|
-
|
|
216
|
-
assert_eq!(plan.decisions.len(), 1);
|
|
217
|
-
assert_eq!(plan.decisions[0].decision, ResumeDecision::Refuse);
|
|
218
|
-
assert_eq!(plan.unresumable.len(), 1);
|
|
219
|
-
let entry = &plan.unresumable[0];
|
|
220
|
-
assert_eq!(entry.agent_id.as_str(), "frontend");
|
|
221
|
-
assert_eq!(entry.reason, "session_identity_mismatch");
|
|
222
|
-
assert_eq!(
|
|
223
|
-
entry
|
|
224
|
-
.refusal_reason
|
|
225
|
-
.as_ref()
|
|
226
|
-
.map(crate::provider::session::ResumeRefusalReason::wire),
|
|
227
|
-
Some("session_identity_mismatch")
|
|
228
|
-
);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
#[test]
|
|
232
|
-
fn restart_identity_probe_reports_real_frontend_ios_dev_mismatch_shape() {
|
|
233
|
-
let ws = temp_ws();
|
|
234
|
-
let rollout = write_codex_identity_rollout(
|
|
235
|
-
&ws,
|
|
236
|
-
"rollout-frontend-poison.jsonl",
|
|
237
|
-
"019f3327-c35a-7023-b3cd-1bea93a7a157",
|
|
238
|
-
"ios-dev",
|
|
239
|
-
);
|
|
240
|
-
let rollout_path = crate::provider::RolloutPath::new(rollout.clone());
|
|
241
|
-
let probe = crate::lifecycle::restart::session_identity_probe_for_agent(
|
|
242
|
-
&aid("frontend"),
|
|
243
|
-
crate::provider::Provider::Codex,
|
|
244
|
-
Some(&rollout_path),
|
|
245
|
-
);
|
|
246
|
-
assert_eq!(probe.identity_ok, Some(false));
|
|
247
|
-
assert_eq!(probe.embedded_agent_id.as_deref(), Some("ios-dev"));
|
|
248
|
-
assert_eq!(probe.rollout_path.as_deref(), Some(rollout.as_path()));
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
#[test]
|
|
252
|
-
fn restart_allow_fresh_only_fresh_starts_mismatched_codex_worker() {
|
|
253
|
-
let ws = temp_ws();
|
|
254
|
-
let frontend_rollout = write_codex_identity_rollout(
|
|
255
|
-
&ws,
|
|
256
|
-
"rollout-frontend-poison.jsonl",
|
|
257
|
-
"019f3327-c35a-7023-b3cd-1bea93a7a157",
|
|
258
|
-
"ios-dev",
|
|
259
|
-
);
|
|
260
|
-
let backend_rollout = write_codex_identity_rollout(
|
|
261
|
-
&ws,
|
|
262
|
-
"rollout-backend-valid.jsonl",
|
|
263
|
-
"019f3327-backend-valid",
|
|
264
|
-
"backend",
|
|
265
|
-
);
|
|
266
|
-
let state = json!({
|
|
267
|
-
"agents": {
|
|
268
|
-
"frontend": {
|
|
269
|
-
"provider": "codex",
|
|
270
|
-
"status": "running",
|
|
271
|
-
"session_id": "019f3327-c35a-7023-b3cd-1bea93a7a157",
|
|
272
|
-
"rollout_path": frontend_rollout.to_string_lossy(),
|
|
273
|
-
"captured_at": "2026-07-05T17:04:04Z",
|
|
274
|
-
"captured_via": "fs_watch",
|
|
275
|
-
"spawn_cwd": ws.to_string_lossy()
|
|
276
|
-
},
|
|
277
|
-
"backend": {
|
|
278
|
-
"provider": "codex",
|
|
279
|
-
"status": "running",
|
|
280
|
-
"session_id": "019f3327-backend-valid",
|
|
281
|
-
"rollout_path": backend_rollout.to_string_lossy(),
|
|
282
|
-
"captured_at": "2026-07-05T17:04:05Z",
|
|
283
|
-
"captured_via": "fs_watch",
|
|
284
|
-
"spawn_cwd": ws.to_string_lossy()
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
let plan = crate::lifecycle::restart::classify_restart_plan_with_resume_validation(
|
|
290
|
-
Some(&ws),
|
|
291
|
-
&state,
|
|
292
|
-
true,
|
|
293
|
-
)
|
|
294
|
-
.unwrap();
|
|
295
|
-
|
|
296
|
-
assert!(
|
|
297
|
-
plan.unresumable.is_empty(),
|
|
298
|
-
"allow_fresh should convert the poisoned worker to fresh without refusing; got {:?}",
|
|
299
|
-
plan.unresumable
|
|
300
|
-
);
|
|
301
|
-
let decisions = plan
|
|
302
|
-
.decisions
|
|
303
|
-
.iter()
|
|
304
|
-
.map(|decision| (decision.agent_id.as_str(), decision.decision))
|
|
305
|
-
.collect::<std::collections::BTreeMap<_, _>>();
|
|
306
|
-
assert_eq!(decisions.get("frontend"), Some(&ResumeDecision::FreshStart));
|
|
307
|
-
assert_eq!(decisions.get("backend"), Some(&ResumeDecision::Resume));
|
|
308
|
-
}
|
|
309
|
-
|
|
310
169
|
#[test]
|
|
311
170
|
fn unit0_restart_corrupt_first_send_at_blocks_before_resume_classification() {
|
|
312
171
|
// The corrupt-first_send_at branch is the hard-refuse gate that fires
|
|
@@ -315,7 +174,7 @@ fn unit0_restart_corrupt_first_send_at_blocks_before_resume_classification() {
|
|
|
315
174
|
// stays empty for the corrupt agent.
|
|
316
175
|
let state = json!({
|
|
317
176
|
"agents": {
|
|
318
|
-
"a":
|
|
177
|
+
"a": agent_copilot(Some("sess-unit0-corrupt"), json!(false)),
|
|
319
178
|
}
|
|
320
179
|
});
|
|
321
180
|
let plan = classify_restart_plan(&state, false).unwrap();
|
|
@@ -97,7 +97,7 @@ fn server_exited_during_replacement_spawn_does_not_cascade_session_disappeared_a
|
|
|
97
97
|
let case = RestartCase::new(
|
|
98
98
|
"case-b-no-second-cascade",
|
|
99
99
|
worker_ids(2),
|
|
100
|
-
ProviderShape::
|
|
100
|
+
ProviderShape::CopilotResumable,
|
|
101
101
|
);
|
|
102
102
|
let transport =
|
|
103
103
|
BuildBeforeDestroyTransport::recording(worker_ids(2)).with_server_exit_after_first_spawn();
|
|
@@ -257,6 +257,9 @@ impl RestartCase {
|
|
|
257
257
|
|
|
258
258
|
fn seed_state_with_panes(&self, provider: ProviderShape, panes: &BTreeMap<String, String>) {
|
|
259
259
|
seed_restart_state(&self.workspace, &self.workers, provider, panes);
|
|
260
|
+
if matches!(provider, ProviderShape::CopilotResumable) {
|
|
261
|
+
seed_copilot_session_store(self.env.home(), &self.workers);
|
|
262
|
+
}
|
|
260
263
|
seed_healthy_coordinator(&self.workspace);
|
|
261
264
|
}
|
|
262
265
|
|
|
@@ -278,21 +281,21 @@ impl RestartCase {
|
|
|
278
281
|
#[derive(Clone, Copy)]
|
|
279
282
|
enum ProviderShape {
|
|
280
283
|
Fake,
|
|
281
|
-
|
|
284
|
+
CopilotResumable,
|
|
282
285
|
}
|
|
283
286
|
|
|
284
287
|
impl ProviderShape {
|
|
285
288
|
fn provider(self) -> &'static str {
|
|
286
289
|
match self {
|
|
287
290
|
Self::Fake => "fake",
|
|
288
|
-
Self::
|
|
291
|
+
Self::CopilotResumable => "copilot",
|
|
289
292
|
}
|
|
290
293
|
}
|
|
291
294
|
|
|
292
295
|
fn model(self) -> &'static str {
|
|
293
296
|
match self {
|
|
294
297
|
Self::Fake => "fake",
|
|
295
|
-
Self::
|
|
298
|
+
Self::CopilotResumable => "gpt-5",
|
|
296
299
|
}
|
|
297
300
|
}
|
|
298
301
|
}
|
|
@@ -354,7 +357,7 @@ fn seed_restart_state(
|
|
|
354
357
|
"spawn_cwd": workspace.to_string_lossy(),
|
|
355
358
|
"spawned_at": "2026-07-14T00:00:00+00:00",
|
|
356
359
|
});
|
|
357
|
-
if matches!(provider, ProviderShape::
|
|
360
|
+
if matches!(provider, ProviderShape::CopilotResumable) {
|
|
358
361
|
let rollout = workspace.join(format!("{worker}.jsonl"));
|
|
359
362
|
fs::write(&rollout, "{}\n").expect("write rollout fixture");
|
|
360
363
|
let row_obj = row.as_object_mut().expect("agent row object");
|
|
@@ -401,6 +404,25 @@ fn seed_restart_state(
|
|
|
401
404
|
.expect("seed runtime state");
|
|
402
405
|
}
|
|
403
406
|
|
|
407
|
+
/// Copilot resume backing is the `sessions` row in the hermetic
|
|
408
|
+
/// `$HOME/.copilot/session-store.db`.
|
|
409
|
+
fn seed_copilot_session_store(home: &Path, workers: &[String]) {
|
|
410
|
+
let db = home.join(".copilot").join("session-store.db");
|
|
411
|
+
fs::create_dir_all(db.parent().expect("copilot store parent")).expect("create copilot dir");
|
|
412
|
+
let conn = rusqlite::Connection::open(db).expect("open copilot session store");
|
|
413
|
+
conn.execute_batch(
|
|
414
|
+
"create table if not exists sessions (id text primary key, cwd text, created_at text);",
|
|
415
|
+
)
|
|
416
|
+
.expect("create copilot sessions table");
|
|
417
|
+
for worker in workers {
|
|
418
|
+
conn.execute(
|
|
419
|
+
"insert or replace into sessions(id, cwd, created_at) values (?1, ?2, '2026-07-14T00:00:00Z')",
|
|
420
|
+
rusqlite::params![format!("session-{worker}"), home.to_string_lossy()],
|
|
421
|
+
)
|
|
422
|
+
.expect("seed copilot session row");
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
404
426
|
fn seed_healthy_coordinator(workspace: &Path) {
|
|
405
427
|
fs::create_dir_all(runtime_dir(workspace)).expect("create runtime dir");
|
|
406
428
|
let _store = MessageStore::open(workspace).expect("create message store schema");
|
|
@@ -12,7 +12,7 @@ use std::sync::atomic::{AtomicU64, Ordering};
|
|
|
12
12
|
use std::sync::{Arc, Mutex};
|
|
13
13
|
|
|
14
14
|
use serde_json::{json, Value};
|
|
15
|
-
use serial_test::file_serial;
|
|
15
|
+
use serial_test::{file_serial, serial};
|
|
16
16
|
use team_agent::lifecycle::{launch_with_transport, restart_with_transport};
|
|
17
17
|
use team_agent::state::persist::{load_runtime_state, save_runtime_state};
|
|
18
18
|
use team_agent::tmux_backend::TmuxBackend;
|
|
@@ -25,9 +25,11 @@ use team_agent::transport::{
|
|
|
25
25
|
|
|
26
26
|
#[test]
|
|
27
27
|
#[ignore = "real-machine: restart/session liveness lifecycle gate"]
|
|
28
|
+
#[serial(env)]
|
|
28
29
|
fn restart_rechecks_session_liveness_before_spawning_second_worker() {
|
|
29
30
|
let fixture = RestartFixture::new("restart-liveness-recording", &["alpha", "bravo"]);
|
|
30
31
|
fixture.seed_resumable_state_with_stale_receiver();
|
|
32
|
+
let _home = HomeGuard::set(&fixture.home());
|
|
31
33
|
let transport = RestartLivenessTransport::new();
|
|
32
34
|
|
|
33
35
|
let result = restart_with_transport(&fixture.team, false, None, &transport);
|
|
@@ -59,9 +61,11 @@ fn restart_rechecks_session_liveness_before_spawning_second_worker() {
|
|
|
59
61
|
|
|
60
62
|
#[test]
|
|
61
63
|
#[ignore = "real-machine: restart/session liveness lifecycle gate"]
|
|
64
|
+
#[serial(env)]
|
|
62
65
|
fn restart_partial_failure_clears_stale_receiver_and_does_not_claim_running_without_pane() {
|
|
63
66
|
let fixture = RestartFixture::new("restart-liveness-state", &["alpha", "bravo"]);
|
|
64
67
|
fixture.seed_resumable_state_with_stale_receiver();
|
|
68
|
+
let _home = HomeGuard::set(&fixture.home());
|
|
65
69
|
let transport = RestartLivenessTransport::new();
|
|
66
70
|
|
|
67
71
|
let _ = restart_with_transport(&fixture.team, false, None, &transport);
|
|
@@ -109,13 +113,13 @@ fn launch_persists_real_pane_id_even_when_pane_pid_is_unavailable() {
|
|
|
109
113
|
}
|
|
110
114
|
|
|
111
115
|
#[test]
|
|
112
|
-
#[ignore = "real-machine: needs real tmux/binary; fake
|
|
116
|
+
#[ignore = "real-machine: needs real tmux/binary; fake copilot exits first resumed worker to reproduce no-server restart"]
|
|
113
117
|
#[file_serial(tmux)]
|
|
114
118
|
fn real_tmux_restart_names_first_resume_agent_when_first_resume_exits_before_second_spawn() {
|
|
115
119
|
let fixture = RestartFixture::new("restart-liveness-real-tmux", &["alpha", "bravo"]);
|
|
116
120
|
fixture.seed_resumable_state_with_stale_receiver();
|
|
117
121
|
let _cleanup = TmuxCleanup::new(&fixture.team);
|
|
118
|
-
let fake_bin = fixture.
|
|
122
|
+
let fake_bin = fixture.install_fake_copilot_that_exits_alpha_resume();
|
|
119
123
|
|
|
120
124
|
let output = Command::new(crate::lifecycle::tests::test_binary_path())
|
|
121
125
|
.args([
|
|
@@ -132,7 +136,8 @@ fn real_tmux_restart_names_first_resume_agent_when_first_resume_exits_before_sec
|
|
|
132
136
|
std::env::var("PATH").unwrap_or_default()
|
|
133
137
|
),
|
|
134
138
|
)
|
|
135
|
-
.env("
|
|
139
|
+
.env("HOME", fixture.home())
|
|
140
|
+
.env("COPILOT_FAKE_LOG", fixture.root.join("fake-copilot.log"))
|
|
136
141
|
.output()
|
|
137
142
|
.expect("run team-agent restart");
|
|
138
143
|
let stdout = String::from_utf8_lossy(&output.stdout);
|
|
@@ -141,7 +146,7 @@ fn real_tmux_restart_names_first_resume_agent_when_first_resume_exits_before_sec
|
|
|
141
146
|
|
|
142
147
|
assert!(
|
|
143
148
|
!output.status.success(),
|
|
144
|
-
"fixture expects first resumed
|
|
149
|
+
"fixture expects first resumed copilot process to exit and restart to fail honestly; stdout={stdout} stderr={stderr}"
|
|
145
150
|
);
|
|
146
151
|
assert!(
|
|
147
152
|
combined.contains("alpha")
|
|
@@ -492,7 +497,7 @@ impl RestartFixture {
|
|
|
492
497
|
std::fs::write(
|
|
493
498
|
team.join("agents").join(format!("{agent}.md")),
|
|
494
499
|
format!(
|
|
495
|
-
"---\nname: {agent}\nrole: Worker {agent}\nprovider:
|
|
500
|
+
"---\nname: {agent}\nrole: Worker {agent}\nprovider: copilot\nmodel: gpt-5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nWorker.\n"
|
|
496
501
|
),
|
|
497
502
|
)
|
|
498
503
|
.unwrap();
|
|
@@ -519,7 +524,7 @@ impl RestartFixture {
|
|
|
519
524
|
agent.clone(),
|
|
520
525
|
json!({
|
|
521
526
|
"status": "running",
|
|
522
|
-
"provider": "
|
|
527
|
+
"provider": "copilot",
|
|
523
528
|
"role": format!("Worker {agent}"),
|
|
524
529
|
"tools": ["mcp_team"],
|
|
525
530
|
"window": agent,
|
|
@@ -554,18 +559,43 @@ impl RestartFixture {
|
|
|
554
559
|
}),
|
|
555
560
|
)
|
|
556
561
|
.unwrap();
|
|
562
|
+
self.seed_copilot_session_store();
|
|
557
563
|
seed_healthy_coordinator(&self.team);
|
|
558
564
|
}
|
|
559
565
|
|
|
560
|
-
|
|
566
|
+
/// Fixture HOME: copilot resume backing is the `sessions` row in
|
|
567
|
+
/// `$HOME/.copilot/session-store.db`.
|
|
568
|
+
fn home(&self) -> PathBuf {
|
|
569
|
+
self.root.join("home")
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
fn seed_copilot_session_store(&self) {
|
|
573
|
+
let db = self.home().join(".copilot").join("session-store.db");
|
|
574
|
+
std::fs::create_dir_all(db.parent().unwrap()).unwrap();
|
|
575
|
+
let conn = rusqlite::Connection::open(db).unwrap();
|
|
576
|
+
conn.execute_batch(
|
|
577
|
+
"create table if not exists sessions (id text primary key, cwd text, created_at text);",
|
|
578
|
+
)
|
|
579
|
+
.unwrap();
|
|
580
|
+
for agent in &self.agents {
|
|
581
|
+
conn.execute(
|
|
582
|
+
"insert or replace into sessions(id, cwd, created_at) values (?1, ?2, '2026-06-08T00:00:00Z')",
|
|
583
|
+
rusqlite::params![format!("session-{agent}"), self.team.to_string_lossy()],
|
|
584
|
+
)
|
|
585
|
+
.unwrap();
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
fn install_fake_copilot_that_exits_alpha_resume(&self) -> PathBuf {
|
|
561
590
|
let bin = self.root.join("fake-bin");
|
|
562
591
|
std::fs::create_dir_all(&bin).unwrap();
|
|
563
|
-
let script = bin.join("
|
|
592
|
+
let script = bin.join("copilot");
|
|
564
593
|
std::fs::write(
|
|
565
594
|
&script,
|
|
566
595
|
r#"#!/bin/sh
|
|
567
|
-
echo "$@" >> "${
|
|
596
|
+
echo "$@" >> "${COPILOT_FAKE_LOG:-/tmp/team-agent-fake-copilot.log}"
|
|
568
597
|
case "$*" in
|
|
598
|
+
"mcp list") exit 0 ;;
|
|
569
599
|
*session-alpha*) exit 0 ;;
|
|
570
600
|
*) sleep 30 ;;
|
|
571
601
|
esac
|
|
@@ -581,6 +611,25 @@ esac
|
|
|
581
611
|
}
|
|
582
612
|
}
|
|
583
613
|
|
|
614
|
+
struct HomeGuard(Option<std::ffi::OsString>);
|
|
615
|
+
|
|
616
|
+
impl HomeGuard {
|
|
617
|
+
fn set(home: &Path) -> Self {
|
|
618
|
+
let previous = std::env::var_os("HOME");
|
|
619
|
+
std::env::set_var("HOME", home);
|
|
620
|
+
Self(previous)
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
impl Drop for HomeGuard {
|
|
625
|
+
fn drop(&mut self) {
|
|
626
|
+
match self.0.take() {
|
|
627
|
+
Some(previous) => std::env::set_var("HOME", previous),
|
|
628
|
+
None => std::env::remove_var("HOME"),
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
|
|
584
633
|
struct TmuxCleanup {
|
|
585
634
|
workspace: PathBuf,
|
|
586
635
|
}
|
|
@@ -49,9 +49,10 @@ const SUB: &str = "sub";
|
|
|
49
49
|
#[serial(env)]
|
|
50
50
|
fn restart_resume_spawns_worker_with_team_dir_cwd_matching_launch() {
|
|
51
51
|
let case = HotfixCase::new("restart-cwd");
|
|
52
|
-
case.write_team(CURRENT, "greeter", Provider::
|
|
52
|
+
case.write_team(CURRENT, "greeter", Provider::Copilot);
|
|
53
53
|
case.seed_restart_state(CURRENT, "greeter", "sess-current", "handled");
|
|
54
54
|
case.seed_healthy_coordinator();
|
|
55
|
+
let _home = case.copilot_home_with_session("sess-current");
|
|
55
56
|
let transport = RecordingTransport::new().with_session_present(false);
|
|
56
57
|
|
|
57
58
|
restart_with_transport(&case.team_dir(CURRENT), false, Some(CURRENT), &transport)
|
|
@@ -62,8 +63,8 @@ fn restart_resume_spawns_worker_with_team_dir_cwd_matching_launch() {
|
|
|
62
63
|
spawn.cwd,
|
|
63
64
|
case.team_dir(CURRENT),
|
|
64
65
|
"RC0: restart/resume must spawn the worker in the same team directory cwd used by first launch. \
|
|
65
|
-
Passing the run workspace root makes
|
|
66
|
-
'Choose working directory to resume this session' prompt. spawn={spawn:?}"
|
|
66
|
+
Passing the run workspace root makes the resumed provider see cwd != session cwd \
|
|
67
|
+
(Codex showed a 'Choose working directory to resume this session' prompt). spawn={spawn:?}"
|
|
67
68
|
);
|
|
68
69
|
}
|
|
69
70
|
|
|
@@ -72,9 +73,10 @@ fn restart_resume_spawns_worker_with_team_dir_cwd_matching_launch() {
|
|
|
72
73
|
#[serial(env)]
|
|
73
74
|
fn restart_resets_startup_prompt_state_for_respawn() {
|
|
74
75
|
let case = HotfixCase::new("restart-startup-state");
|
|
75
|
-
case.write_team(CURRENT, "greeter", Provider::
|
|
76
|
+
case.write_team(CURRENT, "greeter", Provider::Copilot);
|
|
76
77
|
case.seed_restart_state(CURRENT, "greeter", "sess-current", "handled");
|
|
77
78
|
case.seed_healthy_coordinator();
|
|
79
|
+
let _home = case.copilot_home_with_session("sess-current");
|
|
78
80
|
let transport = RecordingTransport::new().with_session_present(false);
|
|
79
81
|
|
|
80
82
|
restart_with_transport(&case.team_dir(CURRENT), false, Some(CURRENT), &transport)
|
|
@@ -328,6 +330,26 @@ impl HotfixCase {
|
|
|
328
330
|
self.workspace.join(".team/runtime/team.db")
|
|
329
331
|
}
|
|
330
332
|
|
|
333
|
+
/// Copilot resume backing is the `sessions` row in
|
|
334
|
+
/// `$HOME/.copilot/session-store.db`; seed it under a fixture HOME and
|
|
335
|
+
/// point HOME there for the guard's lifetime (callers are `serial(env)`).
|
|
336
|
+
fn copilot_home_with_session(&self, session_id: &str) -> HomeGuard {
|
|
337
|
+
let home = self.workspace.parent().unwrap().join("home");
|
|
338
|
+
let db = home.join(".copilot").join("session-store.db");
|
|
339
|
+
std::fs::create_dir_all(db.parent().unwrap()).unwrap();
|
|
340
|
+
let conn = rusqlite::Connection::open(db).unwrap();
|
|
341
|
+
conn.execute_batch(
|
|
342
|
+
"create table if not exists sessions (id text primary key, cwd text, created_at text);",
|
|
343
|
+
)
|
|
344
|
+
.unwrap();
|
|
345
|
+
conn.execute(
|
|
346
|
+
"insert or replace into sessions(id, cwd, created_at) values (?1, ?2, '2026-06-07T01:00:00Z')",
|
|
347
|
+
rusqlite::params![session_id, self.workspace.to_string_lossy()],
|
|
348
|
+
)
|
|
349
|
+
.unwrap();
|
|
350
|
+
HomeGuard::set(&home)
|
|
351
|
+
}
|
|
352
|
+
|
|
331
353
|
fn write_team(&self, team: &str, agent_id: &str, provider: Provider) {
|
|
332
354
|
let dir = self.team_dir(team);
|
|
333
355
|
std::fs::create_dir_all(dir.join("agents")).unwrap();
|
|
@@ -498,7 +520,7 @@ fn restart_agent(
|
|
|
498
520
|
json!({
|
|
499
521
|
"status": "running",
|
|
500
522
|
"agent_id": agent_id,
|
|
501
|
-
"provider": "
|
|
523
|
+
"provider": "copilot",
|
|
502
524
|
"role": "Greeter",
|
|
503
525
|
"tools": ["mcp_team"],
|
|
504
526
|
"window": agent_id,
|
|
@@ -520,7 +542,7 @@ fn team_state(team: &str, agent_id: &str, team_dir: &Path, with_leader_receiver:
|
|
|
520
542
|
"agents": {
|
|
521
543
|
agent_id: {
|
|
522
544
|
"status": "running",
|
|
523
|
-
"provider": "
|
|
545
|
+
"provider": "copilot",
|
|
524
546
|
"window": agent_id,
|
|
525
547
|
"owner_team_id": team,
|
|
526
548
|
"spawn_cwd": team_dir.to_string_lossy(),
|
|
@@ -1016,6 +1038,25 @@ impl ProviderAdapter for StaticCaptureAdapter {
|
|
|
1016
1038
|
}
|
|
1017
1039
|
}
|
|
1018
1040
|
|
|
1041
|
+
struct HomeGuard(Option<std::ffi::OsString>);
|
|
1042
|
+
|
|
1043
|
+
impl HomeGuard {
|
|
1044
|
+
fn set(home: &Path) -> Self {
|
|
1045
|
+
let previous = std::env::var_os("HOME");
|
|
1046
|
+
std::env::set_var("HOME", home);
|
|
1047
|
+
Self(previous)
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
impl Drop for HomeGuard {
|
|
1052
|
+
fn drop(&mut self) {
|
|
1053
|
+
match self.0.take() {
|
|
1054
|
+
Some(previous) => std::env::set_var("HOME", previous),
|
|
1055
|
+
None => std::env::remove_var("HOME"),
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1019
1060
|
fn pane_info(pane_id: &str, session: &str, window: &str, pane_pid: Option<u32>) -> PaneInfo {
|
|
1020
1061
|
PaneInfo {
|
|
1021
1062
|
pane_id: PaneId::new(pane_id),
|