@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.
- package/Cargo.lock +1 -1
- package/Cargo.toml +1 -1
- package/crates/team-agent/src/cli/diagnose.rs +0 -137
- package/crates/team-agent/src/cli/emit.rs +13 -8
- 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 +55 -10
- package/crates/team-agent/src/cli/mod.rs +35 -29
- package/crates/team-agent/src/cli/models.rs +33 -944
- package/crates/team-agent/src/cli/tests/leader_watch.rs +1 -1
- package/crates/team-agent/src/cli/tests/mod.rs +3 -3
- package/crates/team-agent/src/cli/tests/run_delegation.rs +8 -7
- package/crates/team-agent/src/cli/tests/status_send.rs +2 -2
- package/crates/team-agent/src/compiler/tests.rs +54 -12
- package/crates/team-agent/src/compiler.rs +7 -205
- package/crates/team-agent/src/contract_runtime/backend.rs +97 -38
- package/crates/team-agent/src/contract_runtime/commands.rs +335 -4
- package/crates/team-agent/src/contract_runtime/config.rs +12 -8
- package/crates/team-agent/src/contract_runtime/fork.rs +368 -0
- package/crates/team-agent/src/contract_runtime/framework.rs +8 -13
- package/crates/team-agent/src/contract_runtime/mod.rs +1 -0
- package/crates/team-agent/src/contract_runtime/registry.rs +100 -60
- package/crates/team-agent/src/coordinator/steps/abnormal.rs +45 -5
- package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +54 -16
- package/crates/team-agent/src/coordinator/tests/energy.rs +4 -4
- package/crates/team-agent/src/coordinator/tests/health_sync.rs +2 -44
- 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/leader/start.rs +1 -1
- package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +2 -195
- package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +11 -27
- package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +22 -200
- package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +6 -87
- package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +5 -496
- package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +74 -244
- package/crates/team-agent/src/lifecycle/launch/quick_start.rs +2 -26
- package/crates/team-agent/src/lifecycle/launch/role_source.rs +5 -0
- package/crates/team-agent/src/lifecycle/launch/spawn.rs +26 -51
- package/crates/team-agent/src/lifecycle/launch.rs +3 -34
- package/crates/team-agent/src/lifecycle/profile_launch.rs +18 -373
- package/crates/team-agent/src/lifecycle/restart/common.rs +45 -463
- package/crates/team-agent/src/lifecycle/restart/remove.rs +129 -0
- package/crates/team-agent/src/lifecycle/restart/selection.rs +5 -5
- package/crates/team-agent/src/lifecycle/restart.rs +0 -2
- 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 +38 -236
- package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +8 -320
- package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +106 -186
- package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +4 -334
- package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +19 -15
- package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +2 -2
- package/crates/team-agent/src/lifecycle/tests/core.rs +33 -58
- 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 +15 -133
- package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +3 -51
- 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 +162 -284
- 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/pi_catalog_red.rs +6 -18
- package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +52 -70
- package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +4 -157
- package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +10 -302
- package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +1 -68
- package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +1 -19
- package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +2 -100
- package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +15 -14
- 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 -1478
- 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 +7 -7
- package/crates/team-agent/src/lifecycle/tests/subprep_codex_trust_roundtrip_red.rs +67 -313
- package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +2 -254
- 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 +74 -19
- package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +39 -38
- package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +42 -97
- package/crates/team-agent/src/lifecycle/tests.rs +0 -7
- package/crates/team-agent/src/lifecycle/types.rs +2 -21
- package/crates/team-agent/src/mcp_server/readiness_tests.rs +15 -17
- package/crates/team-agent/src/messaging/delivery.rs +14 -195
- package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +5 -5
- package/crates/team-agent/src/messaging/tests/dup_inject.rs +68 -69
- 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 +30 -32
- package/crates/team-agent/src/messaging/tests/wave2.rs +13 -20
- package/crates/team-agent/src/provider/adapter.rs +71 -572
- package/crates/team-agent/src/provider/adapters/mod.rs +6 -8
- package/crates/team-agent/src/provider/model_catalog.rs +13 -201
- package/crates/team-agent/src/provider/session/capture.rs +11 -211
- package/crates/team-agent/src/provider/session/context_fork/outcome.rs +8 -24
- package/crates/team-agent/src/provider/session/context_fork.rs +29 -240
- package/crates/team-agent/src/provider/session/mod.rs +2 -3
- package/crates/team-agent/src/provider/session_scan/common.rs +27 -87
- package/crates/team-agent/src/provider/session_scan/pi.rs +1 -34
- package/crates/team-agent/src/provider/session_scan.rs +7 -23
- package/crates/team-agent/src/provider/tests/adapter.rs +66 -204
- package/crates/team-agent/src/provider/tests/command_helpers.rs +3 -29
- package/crates/team-agent/src/provider/tests/idle.rs +0 -68
- package/crates/team-agent/src/provider/types.rs +0 -4
- package/crates/team-agent/src/provider/wire.rs +77 -23
- package/crates/team-agent/src/state/abnormal_watch/tests/mod.rs +1 -1
- package/crates/team-agent/src/state/persist.rs +6 -6
- package/crates/team-agent/src/state/repository/tests.rs +2 -2
- package/crates/team-agent/src/tmux_backend.rs +4 -3
- package/package.json +4 -4
- package/skills/team-agent/SKILL.md +8 -5
- package/skills/team-agent/command-coverage.json +29 -1
- package/skills/team-agent/docs/reference/team-agent-operator.md +7 -3
- package/skills/team-agent/references/team-agent-operator.md +7 -3
- package/crates/team-agent/src/lifecycle/launch/grok_per_seat.rs +0 -260
- package/crates/team-agent/src/lifecycle/restart/avatar.rs +0 -1805
- package/crates/team-agent/src/lifecycle/tests/claude_compatible_config_red.rs +0 -325
- 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/lifecycle/tests/pi_compiler_red.rs +0 -210
- package/crates/team-agent/src/lifecycle/tests/pi_fork_session_inheritance_red.rs +0 -1409
- package/crates/team-agent/src/provider/adapters/claude.rs +0 -78
- package/crates/team-agent/src/provider/adapters/claude_fork.rs +0 -131
- 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/adapters/pi.rs +0 -100
- package/crates/team-agent/src/provider/session/context_fork/claude.rs +0 -123
- package/crates/team-agent/src/provider/session/context_fork/codex.rs +0 -514
- package/crates/team-agent/src/provider/session_scan/claude.rs +0 -523
- package/crates/team-agent/src/provider/session_scan/codex.rs +0 -326
- package/crates/team-agent/src/provider/session_scan/grok.rs +0 -288
- package/crates/team-agent/src/test_support/models_timeout_fixture.rs +0 -144
|
@@ -4,9 +4,12 @@
|
|
|
4
4
|
//! - `.team/artifacts/rs-subprep-codex-trust-roundtrip-root-cause.md`
|
|
5
5
|
//! - `.team/artifacts/macmini-e2e/subprep-codex-probe5-20260605T071044Z/`
|
|
6
6
|
//!
|
|
7
|
-
//! Real
|
|
8
|
-
//! these cargo contracts lock the local recognizer, delivery state, command-shape
|
|
9
|
-
//!
|
|
7
|
+
//! Real provider subscription behavior still needs rt smoke for the provider pane/report_result
|
|
8
|
+
//! parts; these cargo contracts lock the local recognizer, delivery state, and command-shape
|
|
9
|
+
//! surfaces that caused the probe failures. The legacy Codex worker runtime (its rollout capture
|
|
10
|
+
//! and worker trust loop) is gone: the Codex recognizer/matcher checks stay (the `team-agent codex`
|
|
11
|
+
//! leader uses them), while delivery/roundtrip contracts run on a Copilot worker, the only legacy
|
|
12
|
+
//! worker the delivery trust gate peeks for.
|
|
10
13
|
|
|
11
14
|
#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
|
|
12
15
|
|
|
@@ -33,7 +36,7 @@ use team_agent::messaging::delivery::deliver_pending_message;
|
|
|
33
36
|
use team_agent::messaging::trust::attempt_trust_auto_answer;
|
|
34
37
|
use team_agent::messaging::PaneWidthQuery;
|
|
35
38
|
use team_agent::model::enums::{AuthMode, Provider};
|
|
36
|
-
use team_agent::provider::{
|
|
39
|
+
use team_agent::provider::{get_adapter, COPILOT_READY_MARKER, COPILOT_TRUST_PROMPT_MARKER};
|
|
37
40
|
use team_agent::transport::{
|
|
38
41
|
AttachOutcome, BackendKind, CaptureRange, CapturedText, InjectPayload, InjectReport,
|
|
39
42
|
InjectStage, InjectVerification, Key, PaneField, PaneId, PaneInfo, SessionName, SetEnvOutcome,
|
|
@@ -54,18 +57,6 @@ const PROBE5_TRUST_PANE: &str = r#"> You are in /private/tmp/ta-subprep-SUB-PROB
|
|
|
54
57
|
Press enter to continue
|
|
55
58
|
"#;
|
|
56
59
|
|
|
57
|
-
const PROBE5_READY_AFTER_TRUST_CONSUMED: &str = r#"> You are in /private/tmp/ta-subprep-SUB-PROBE-2-send-turn-idle.uxarHT/teamdir
|
|
58
|
-
|
|
59
|
-
╭─────────────────────────────────────────────╮
|
|
60
|
-
│ >_ OpenAI Codex (v0.136.0) │
|
|
61
|
-
│ │
|
|
62
|
-
│ model: gpt-5.5 xhigh /model to change │
|
|
63
|
-
│ directory: /private/tmp/…/teamdir │
|
|
64
|
-
╰─────────────────────────────────────────────╯
|
|
65
|
-
|
|
66
|
-
› Run /review on my current changes
|
|
67
|
-
"#;
|
|
68
|
-
|
|
69
60
|
const SUBROOT_FULL_TRUST_PANE_AFTER_QUICKSTART: &str = r#"> You are in /private/tmp/ta-subroot-SUB-PROBE-1-trust-startup.uL9Boc/teamdir
|
|
70
61
|
|
|
71
62
|
Do you trust the contents of this directory? Working with untrusted contents
|
|
@@ -174,181 +165,6 @@ fn contract_a_subroot_full_pane_trust_menu_still_actionable_despite_bottom_ready
|
|
|
174
165
|
);
|
|
175
166
|
}
|
|
176
167
|
|
|
177
|
-
#[test]
|
|
178
|
-
fn contract_a_subroot_tick_answers_full_pane_trust_and_persists_startup_handled() {
|
|
179
|
-
use team_agent::coordinator::{Coordinator, ProviderRegistry, WorkspacePath};
|
|
180
|
-
use team_agent::provider::ProviderAdapter;
|
|
181
|
-
|
|
182
|
-
struct RealAdapterRegistry;
|
|
183
|
-
|
|
184
|
-
impl ProviderRegistry for RealAdapterRegistry {
|
|
185
|
-
fn adapter_for(&self, provider: Provider) -> Box<dyn ProviderAdapter> {
|
|
186
|
-
team_agent::provider::get_adapter(provider)
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
let ws = tmp_dir("a-subroot-tick-full-pane");
|
|
191
|
-
let mcp_config = ws.join(".team").join("runtime").join("mcp").join("w1.json");
|
|
192
|
-
std::fs::create_dir_all(mcp_config.parent().unwrap()).unwrap();
|
|
193
|
-
std::fs::write(&mcp_config, "{}").unwrap();
|
|
194
|
-
team_agent::state::persist::save_runtime_state(
|
|
195
|
-
&ws,
|
|
196
|
-
&json!({
|
|
197
|
-
"session_name": "team-ta-subroot-SUB-PROBE-1-trust-startup",
|
|
198
|
-
"team_dir": ws.join("teamdir").to_string_lossy().to_string(),
|
|
199
|
-
"agents": {
|
|
200
|
-
"w1": {
|
|
201
|
-
"provider": "codex",
|
|
202
|
-
"status": "running",
|
|
203
|
-
"startup_prompts": "pending",
|
|
204
|
-
"startup_prompt_status": "pending",
|
|
205
|
-
"window": "w1",
|
|
206
|
-
"pane_id": "%7",
|
|
207
|
-
"mcp_config": mcp_config.to_string_lossy().to_string()
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
}),
|
|
211
|
-
)
|
|
212
|
-
.unwrap();
|
|
213
|
-
|
|
214
|
-
let transport = RecordingTransport::new(vec![
|
|
215
|
-
SUBROOT_FULL_TRUST_PANE_AFTER_QUICKSTART.to_string(),
|
|
216
|
-
SUBROOT_FULL_TRUST_PANE_AFTER_QUICKSTART.to_string(),
|
|
217
|
-
])
|
|
218
|
-
.with_session_present(true)
|
|
219
|
-
.with_windows(vec![WindowName::new("w1")]);
|
|
220
|
-
let coord = Coordinator::new(
|
|
221
|
-
WorkspacePath::new(ws.to_path_buf()),
|
|
222
|
-
Box::new(RealAdapterRegistry),
|
|
223
|
-
Box::new(transport.clone()),
|
|
224
|
-
);
|
|
225
|
-
|
|
226
|
-
let report = coord
|
|
227
|
-
.tick()
|
|
228
|
-
.expect("coordinator tick should stay typed/fallible");
|
|
229
|
-
let state = team_agent::state::persist::load_runtime_state(&ws).unwrap();
|
|
230
|
-
let agent = &state["agents"]["w1"];
|
|
231
|
-
let events = read_events(&ws);
|
|
232
|
-
|
|
233
|
-
assert!(
|
|
234
|
-
report.ok && !report.stop,
|
|
235
|
-
"Contract A driver: startup trust handling must not stop or degrade the tick; report={report:?}"
|
|
236
|
-
);
|
|
237
|
-
assert_eq!(
|
|
238
|
-
transport.send_keys_count(),
|
|
239
|
-
1,
|
|
240
|
-
"Contract A driver: full-pane own-workspace trust prompt must send exactly one Enter"
|
|
241
|
-
);
|
|
242
|
-
assert_eq!(
|
|
243
|
-
agent["startup_prompts"],
|
|
244
|
-
json!("handled"),
|
|
245
|
-
"Contract A driver: tick must persist startup_prompts=handled after answering trust; state={state}"
|
|
246
|
-
);
|
|
247
|
-
assert_eq!(
|
|
248
|
-
agent["startup_prompt_handled"][0]["prompt"],
|
|
249
|
-
json!("codex_workspace_trust"),
|
|
250
|
-
"Contract A driver: handled prompt must identify codex workspace trust; state={state}"
|
|
251
|
-
);
|
|
252
|
-
assert_eq!(
|
|
253
|
-
agent["startup_prompt_handled"][0]["action"],
|
|
254
|
-
json!("sent_enter"),
|
|
255
|
-
"Contract A driver: handled prompt action must be sent_enter; state={state}"
|
|
256
|
-
);
|
|
257
|
-
assert!(
|
|
258
|
-
events.contains("leader_panes.trust_auto_answered")
|
|
259
|
-
|| events.contains("startup_prompt_handled"),
|
|
260
|
-
"Contract A driver: trust answer must be visible in events as leader_panes.trust_auto_answered or startup_prompt_handled; events={events}"
|
|
261
|
-
);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
#[test]
|
|
265
|
-
fn contract_a_step1_trust_auto_answer_is_idempotent_across_repeated_ticks() {
|
|
266
|
-
use team_agent::coordinator::{Coordinator, ProviderRegistry, WorkspacePath};
|
|
267
|
-
use team_agent::provider::ProviderAdapter;
|
|
268
|
-
|
|
269
|
-
struct RealAdapterRegistry;
|
|
270
|
-
|
|
271
|
-
impl ProviderRegistry for RealAdapterRegistry {
|
|
272
|
-
fn adapter_for(&self, provider: Provider) -> Box<dyn ProviderAdapter> {
|
|
273
|
-
team_agent::provider::get_adapter(provider)
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
let ws = tmp_dir("a-subroot-tick-idempotent");
|
|
278
|
-
let mcp_config = ws.join(".team").join("runtime").join("mcp").join("w1.json");
|
|
279
|
-
std::fs::create_dir_all(mcp_config.parent().unwrap()).unwrap();
|
|
280
|
-
std::fs::write(&mcp_config, "{}").unwrap();
|
|
281
|
-
team_agent::state::persist::save_runtime_state(
|
|
282
|
-
&ws,
|
|
283
|
-
&json!({
|
|
284
|
-
"session_name": "team-ta-subroot-SUB-PROBE-1-trust-startup",
|
|
285
|
-
"team_dir": ws.join("teamdir").to_string_lossy().to_string(),
|
|
286
|
-
"agents": {
|
|
287
|
-
"w1": {
|
|
288
|
-
"provider": "codex",
|
|
289
|
-
"status": "running",
|
|
290
|
-
"startup_prompts": "pending",
|
|
291
|
-
"startup_prompt_status": "pending",
|
|
292
|
-
"window": "w1",
|
|
293
|
-
"pane_id": "%7",
|
|
294
|
-
"mcp_config": mcp_config.to_string_lossy().to_string()
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
}),
|
|
298
|
-
)
|
|
299
|
-
.unwrap();
|
|
300
|
-
|
|
301
|
-
let transport = RecordingTransport::new(vec![
|
|
302
|
-
SUBROOT_FULL_TRUST_PANE_AFTER_QUICKSTART.to_string(),
|
|
303
|
-
SUBROOT_FULL_TRUST_PANE_AFTER_QUICKSTART.to_string(),
|
|
304
|
-
SUBROOT_FULL_TRUST_PANE_AFTER_QUICKSTART.to_string(),
|
|
305
|
-
])
|
|
306
|
-
.with_session_present(true)
|
|
307
|
-
.with_windows(vec![WindowName::new("w1")]);
|
|
308
|
-
let coord = Coordinator::new(
|
|
309
|
-
WorkspacePath::new(ws.to_path_buf()),
|
|
310
|
-
Box::new(RealAdapterRegistry),
|
|
311
|
-
Box::new(transport.clone()),
|
|
312
|
-
);
|
|
313
|
-
|
|
314
|
-
coord
|
|
315
|
-
.tick()
|
|
316
|
-
.expect("first tick should answer the startup trust prompt");
|
|
317
|
-
coord
|
|
318
|
-
.tick()
|
|
319
|
-
.expect("second tick over the same pane must not answer trust again");
|
|
320
|
-
|
|
321
|
-
let state = team_agent::state::persist::load_runtime_state(&ws).unwrap();
|
|
322
|
-
let agent = &state["agents"]["w1"];
|
|
323
|
-
let events = read_events(&ws);
|
|
324
|
-
let handled_event_count = count_event(&events, "startup_prompt_handled");
|
|
325
|
-
let sent_enter_count = count_handled_action(&events, "sent_enter");
|
|
326
|
-
|
|
327
|
-
assert_eq!(
|
|
328
|
-
transport.send_keys_count(),
|
|
329
|
-
1,
|
|
330
|
-
"Contract A step1/idempotency: the same actionable trust prompt across repeated coordinator ticks must receive Enter exactly once"
|
|
331
|
-
);
|
|
332
|
-
assert_eq!(
|
|
333
|
-
handled_event_count, 1,
|
|
334
|
-
"Contract A step1/idempotency: startup_prompt_handled must be emitted exactly once after trust is answered; events={events}"
|
|
335
|
-
);
|
|
336
|
-
assert_eq!(
|
|
337
|
-
sent_enter_count, 1,
|
|
338
|
-
"Contract A step1/idempotency: sent_enter handling for codex_workspace_trust must be recorded exactly once; events={events}"
|
|
339
|
-
);
|
|
340
|
-
assert_eq!(
|
|
341
|
-
agent["startup_prompts"],
|
|
342
|
-
json!("handled"),
|
|
343
|
-
"Contract A step1/idempotency: answering trust must persist startup_prompts=handled/complete so later ticks skip re-answering; state={state}"
|
|
344
|
-
);
|
|
345
|
-
assert_eq!(
|
|
346
|
-
agent["startup_prompt_handled"].as_array().map(Vec::len),
|
|
347
|
-
Some(1),
|
|
348
|
-
"Contract A step1/idempotency: state must retain one handled prompt record, not append duplicates; state={state}"
|
|
349
|
-
);
|
|
350
|
-
}
|
|
351
|
-
|
|
352
168
|
#[test]
|
|
353
169
|
fn contract_a_own_workspace_trust_is_actionable_not_ready_and_foreign_is_pending() {
|
|
354
170
|
use team_agent::provider::{classify_codex_startup_screen, StartupScreenDecision};
|
|
@@ -415,12 +231,12 @@ fn contract_a_own_workspace_trust_is_actionable_not_ready_and_foreign_is_pending
|
|
|
415
231
|
|
|
416
232
|
#[test]
|
|
417
233
|
fn contract_a_runtime_readiness_is_false_while_actionable_trust_remains() {
|
|
418
|
-
use team_agent::provider::{
|
|
234
|
+
use team_agent::provider::{classify_copilot_startup_screen, StartupScreenDecision};
|
|
419
235
|
|
|
420
236
|
assert_eq!(
|
|
421
|
-
|
|
237
|
+
classify_copilot_startup_screen(COPILOT_TRUST_PROMPT_MARKER),
|
|
422
238
|
StartupScreenDecision::AnswerWorkspaceTrust,
|
|
423
|
-
"fixture sanity:
|
|
239
|
+
"fixture sanity: the Copilot folder-trust pane is an actionable own-workspace trust prompt"
|
|
424
240
|
);
|
|
425
241
|
|
|
426
242
|
let ws = tmp_dir("a-runtime-readiness-trust");
|
|
@@ -435,7 +251,7 @@ fn contract_a_runtime_readiness_is_false_while_actionable_trust_remains() {
|
|
|
435
251
|
"leader_receiver": {"status": "attached", "pane_id": "%9"},
|
|
436
252
|
"agents": {
|
|
437
253
|
"w1": {
|
|
438
|
-
"provider": "
|
|
254
|
+
"provider": "copilot",
|
|
439
255
|
"status": "awaiting_trust_prompt",
|
|
440
256
|
"startup_prompt_status": "awaiting_trust_prompt",
|
|
441
257
|
"startup_prompts": "awaiting_trust_prompt",
|
|
@@ -486,7 +302,7 @@ fn contract_b_delivery_does_not_mark_delivered_or_inject_task_while_trust_prompt
|
|
|
486
302
|
"session_name": "team-subprep",
|
|
487
303
|
"agents": {
|
|
488
304
|
"w1": {
|
|
489
|
-
"provider": "
|
|
305
|
+
"provider": "copilot",
|
|
490
306
|
"status": "running",
|
|
491
307
|
"pane_id": "%7",
|
|
492
308
|
"window": "w1"
|
|
@@ -494,7 +310,7 @@ fn contract_b_delivery_does_not_mark_delivered_or_inject_task_while_trust_prompt
|
|
|
494
310
|
}
|
|
495
311
|
});
|
|
496
312
|
team_agent::state::persist::save_runtime_state(&ws, &state).unwrap();
|
|
497
|
-
let transport = RecordingTransport::new(vec![
|
|
313
|
+
let transport = RecordingTransport::new(vec![COPILOT_TRUST_PROMPT_MARKER.to_string()]);
|
|
498
314
|
let event_log = EventLog::new(&ws);
|
|
499
315
|
|
|
500
316
|
let outcome =
|
|
@@ -541,7 +357,7 @@ fn contract_b_probe5_delivered_without_result_is_rejected_as_lost_task_evidence(
|
|
|
541
357
|
"session_name": "team-ta-subprep-SUB-PROBE-2-send-turn-idle",
|
|
542
358
|
"agents": {
|
|
543
359
|
"w1": {
|
|
544
|
-
"provider": "
|
|
360
|
+
"provider": "copilot",
|
|
545
361
|
"status": "running",
|
|
546
362
|
"pane_id": "%7",
|
|
547
363
|
"window": "w1"
|
|
@@ -549,7 +365,7 @@ fn contract_b_probe5_delivered_without_result_is_rejected_as_lost_task_evidence(
|
|
|
549
365
|
}
|
|
550
366
|
});
|
|
551
367
|
team_agent::state::persist::save_runtime_state(&ws, &state).unwrap();
|
|
552
|
-
let transport = RecordingTransport::new(vec![
|
|
368
|
+
let transport = RecordingTransport::new(vec![COPILOT_TRUST_PROMPT_MARKER.to_string()]);
|
|
553
369
|
let event_log = EventLog::new(&ws);
|
|
554
370
|
|
|
555
371
|
let outcome =
|
|
@@ -598,7 +414,7 @@ fn contract_b_delivery_gate_trusts_startup_handled_state_over_pane_scrollback()
|
|
|
598
414
|
"session_name": "team-ta-subroot-SUB-PROBE-2-send-turn-idle",
|
|
599
415
|
"agents": {
|
|
600
416
|
"w1": {
|
|
601
|
-
"provider": "
|
|
417
|
+
"provider": "copilot",
|
|
602
418
|
"status": "running",
|
|
603
419
|
"startup_prompts": "pending",
|
|
604
420
|
"startup_prompt_status": "pending",
|
|
@@ -609,7 +425,7 @@ fn contract_b_delivery_gate_trusts_startup_handled_state_over_pane_scrollback()
|
|
|
609
425
|
});
|
|
610
426
|
team_agent::state::persist::save_runtime_state(&pending_ws, &pending_state).unwrap();
|
|
611
427
|
let pending_transport =
|
|
612
|
-
RecordingTransport::new(vec![
|
|
428
|
+
RecordingTransport::new(vec![COPILOT_TRUST_PROMPT_MARKER.to_string()]);
|
|
613
429
|
let pending_log = EventLog::new(&pending_ws);
|
|
614
430
|
let pending = deliver_pending_message(
|
|
615
431
|
&pending_ws,
|
|
@@ -658,12 +474,12 @@ fn contract_b_delivery_gate_trusts_startup_handled_state_over_pane_scrollback()
|
|
|
658
474
|
"session_name": "team-ta-subroot-SUB-PROBE-2-send-turn-idle",
|
|
659
475
|
"agents": {
|
|
660
476
|
"w1": {
|
|
661
|
-
"provider": "
|
|
477
|
+
"provider": "copilot",
|
|
662
478
|
"status": "running",
|
|
663
479
|
"startup_prompts": "handled",
|
|
664
480
|
"startup_prompt_status": "handled",
|
|
665
481
|
"startup_prompt_handled": [
|
|
666
|
-
{"prompt": "
|
|
482
|
+
{"prompt": "copilot_workspace_trust", "action": "sent_enter_yes_session"}
|
|
667
483
|
],
|
|
668
484
|
"pane_id": "%7",
|
|
669
485
|
"window": "w1"
|
|
@@ -676,7 +492,7 @@ fn contract_b_delivery_gate_trusts_startup_handled_state_over_pane_scrollback()
|
|
|
676
492
|
);
|
|
677
493
|
team_agent::state::persist::save_runtime_state(&handled_ws, &handled_state).unwrap();
|
|
678
494
|
let handled_transport =
|
|
679
|
-
RecordingTransport::new(vec![
|
|
495
|
+
RecordingTransport::new(vec![COPILOT_TRUST_PROMPT_MARKER.to_string()]);
|
|
680
496
|
#[cfg(unix)]
|
|
681
497
|
{ handled_transport.state.lock().unwrap().carrier = pane.pane_pid; }
|
|
682
498
|
let handled_log = EventLog::new(&handled_ws);
|
|
@@ -692,7 +508,7 @@ fn contract_b_delivery_gate_trusts_startup_handled_state_over_pane_scrollback()
|
|
|
692
508
|
|
|
693
509
|
assert!(
|
|
694
510
|
matches!(handled.status, team_agent::messaging::DeliveryStatus::Delivered),
|
|
695
|
-
"Contract B step2/scrollback: startup_prompts=handled must trust state and deliver, even if
|
|
511
|
+
"Contract B step2/scrollback: startup_prompts=handled must trust state and deliver, even if the pane still contains the folder-trust menu (`Do you trust the files in this folder?` + `❯ 1. Yes`); outcome={handled:?}"
|
|
696
512
|
);
|
|
697
513
|
assert_eq!(
|
|
698
514
|
message_status(handled_store.db_path(), &handled_message_id),
|
|
@@ -736,7 +552,7 @@ fn contract_b_step2_retry_delivers_queued_message_after_startup_trust_is_handled
|
|
|
736
552
|
"team_dir": ws.join("teamdir").to_string_lossy().to_string(),
|
|
737
553
|
"agents": {
|
|
738
554
|
"w1": {
|
|
739
|
-
"provider": "
|
|
555
|
+
"provider": "copilot",
|
|
740
556
|
"status": "running",
|
|
741
557
|
"startup_prompts": "pending",
|
|
742
558
|
"startup_prompt_status": "pending",
|
|
@@ -777,10 +593,10 @@ fn contract_b_step2_retry_delivers_queued_message_after_startup_trust_is_handled
|
|
|
777
593
|
)
|
|
778
594
|
.unwrap();
|
|
779
595
|
let transport = RecordingTransport::new(vec![
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
596
|
+
COPILOT_TRUST_PROMPT_MARKER.to_string(),
|
|
597
|
+
COPILOT_TRUST_PROMPT_MARKER.to_string(),
|
|
598
|
+
COPILOT_READY_MARKER.to_string(),
|
|
599
|
+
COPILOT_READY_MARKER.to_string(),
|
|
784
600
|
])
|
|
785
601
|
.with_session_present(true)
|
|
786
602
|
.with_windows(vec![WindowName::new("w1")]);
|
|
@@ -871,37 +687,61 @@ fn contract_c_lifecycle_launch_command_carries_role_tools_and_real_mcp_context()
|
|
|
871
687
|
.unwrap();
|
|
872
688
|
std::fs::write(
|
|
873
689
|
teamdir.join("agents").join("w1.md"),
|
|
874
|
-
"---\nname: w1\nrole: Worker must call report_result exactly once.\nprovider:
|
|
690
|
+
"---\nname: w1\nrole: Worker must call report_result exactly once.\nprovider: copilot\nmodel: gpt-5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nAlways use report_result for completion.\n",
|
|
875
691
|
)
|
|
876
692
|
.unwrap();
|
|
877
693
|
let spec = team_agent::compiler::compile_team(&teamdir).unwrap();
|
|
878
694
|
let spec_path = teamdir.join("team.spec.yaml");
|
|
879
695
|
std::fs::write(&spec_path, team_agent::model::yaml::dumps(&spec)).unwrap();
|
|
880
696
|
|
|
881
|
-
let transport = RecordingTransport::new(vec![
|
|
697
|
+
let transport = RecordingTransport::new(vec![COPILOT_READY_MARKER.to_string()]);
|
|
882
698
|
let report = launch_with_transport(&spec_path, false, true, true, &transport)
|
|
883
699
|
.expect("launch should reach transport spawn");
|
|
884
700
|
assert_eq!(
|
|
885
701
|
report.started.len(),
|
|
886
702
|
1,
|
|
887
|
-
"fixture sanity: one
|
|
888
|
-
);
|
|
889
|
-
let
|
|
703
|
+
"fixture sanity: one Copilot worker starts"
|
|
704
|
+
);
|
|
705
|
+
let spawn_argv = transport.spawn_argv();
|
|
706
|
+
let argv = spawn_argv.join(" ");
|
|
707
|
+
let arg_after = |flag: &str| {
|
|
708
|
+
spawn_argv
|
|
709
|
+
.windows(2)
|
|
710
|
+
.find(|pair| pair[0] == flag)
|
|
711
|
+
.map(|pair| pair[1].clone())
|
|
712
|
+
.unwrap_or_else(|| panic!("copilot worker argv must carry {flag}; argv={argv:?}"))
|
|
713
|
+
};
|
|
714
|
+
// Copilot takes role instructions via COPILOT_CUSTOM_INSTRUCTIONS_DIRS
|
|
715
|
+
// (`<workspace>/.team/runtime/copilot-instructions/<agent>/AGENTS.md`), not argv.
|
|
716
|
+
let workspace = PathBuf::from(arg_after("-C"));
|
|
717
|
+
let instructions = std::fs::read_to_string(
|
|
718
|
+
workspace
|
|
719
|
+
.join(".team/runtime/copilot-instructions/w1/AGENTS.md"),
|
|
720
|
+
)
|
|
721
|
+
.unwrap_or_default();
|
|
722
|
+
let mcp_file = arg_after("--additional-mcp-config");
|
|
723
|
+
let mcp_text = mcp_file
|
|
724
|
+
.strip_prefix('@')
|
|
725
|
+
.and_then(|path| std::fs::read_to_string(path).ok())
|
|
726
|
+
.unwrap_or_default();
|
|
890
727
|
|
|
891
728
|
assert!(
|
|
892
|
-
|
|
893
|
-
"Contract C/F6.4: lifecycle must pass resolved role/developer instructions into
|
|
729
|
+
instructions.contains("report_result"),
|
|
730
|
+
"Contract C/F6.4: lifecycle must pass resolved role/developer instructions into the Copilot worker instructions; workspace={} instructions={instructions:?} argv={argv:?}",
|
|
731
|
+
workspace.display()
|
|
894
732
|
);
|
|
895
733
|
assert!(
|
|
896
|
-
|
|
897
|
-
"Contract C/MUST-8:
|
|
898
|
-
);
|
|
899
|
-
|
|
900
|
-
!
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
734
|
+
mcp_text.contains("team_orchestrator"),
|
|
735
|
+
"Contract C/MUST-8: Copilot worker command must include a real Team Agent tool/MCP capability mechanism, not prompt-only state metadata; mcp_config={mcp_file:?} text={mcp_text:?} argv={argv:?}"
|
|
736
|
+
);
|
|
737
|
+
for text in [&argv, &mcp_text] {
|
|
738
|
+
assert!(
|
|
739
|
+
!text.contains("/tmp/ta-provider-ws")
|
|
740
|
+
&& !text.contains("worker1")
|
|
741
|
+
&& !text.contains("teamA"),
|
|
742
|
+
"Contract C: provider command/config must not leak placeholder MCP context; text={text:?}"
|
|
743
|
+
);
|
|
744
|
+
}
|
|
905
745
|
}
|
|
906
746
|
|
|
907
747
|
#[test]
|
|
@@ -932,7 +772,7 @@ fn contract_c_lifecycle_sources_use_context_aware_provider_builders() {
|
|
|
932
772
|
|
|
933
773
|
#[test]
|
|
934
774
|
fn contract_c_provider_mcp_config_is_parameterized_not_placeholder() {
|
|
935
|
-
let adapter = get_adapter(Provider::
|
|
775
|
+
let adapter = get_adapter(Provider::Copilot);
|
|
936
776
|
let config = adapter.mcp_config(AuthMode::Subscription).unwrap();
|
|
937
777
|
let raw = config.raw.to_string();
|
|
938
778
|
let command = config.raw["team_orchestrator"]["command"]
|
|
@@ -959,75 +799,6 @@ fn contract_c_provider_mcp_config_is_parameterized_not_placeholder() {
|
|
|
959
799
|
);
|
|
960
800
|
}
|
|
961
801
|
|
|
962
|
-
#[test]
|
|
963
|
-
fn contract_d_codex_capture_rejects_team_agent_events_jsonl_as_rollout() {
|
|
964
|
-
let ws = tmp_dir("d-events-rollout");
|
|
965
|
-
let log_dir = ws.join(".team").join("logs");
|
|
966
|
-
std::fs::create_dir_all(&log_dir).unwrap();
|
|
967
|
-
let events_path = log_dir.join("events.jsonl");
|
|
968
|
-
std::fs::write(
|
|
969
|
-
&events_path,
|
|
970
|
-
r#"{"event":"coordinator.boot","workspace":"/tmp/ta-subprep"}"#,
|
|
971
|
-
)
|
|
972
|
-
.unwrap();
|
|
973
|
-
|
|
974
|
-
let adapter = get_adapter(Provider::Codex);
|
|
975
|
-
let captured = adapter.capture_session_id("w1", &ws, 0).unwrap();
|
|
976
|
-
|
|
977
|
-
assert!(
|
|
978
|
-
captured.is_none(),
|
|
979
|
-
"Contract D/F5/N11: Team Agent `.team/logs/events.jsonl` is not a Codex provider transcript and must not become rollout_path; captured={captured:?}"
|
|
980
|
-
);
|
|
981
|
-
}
|
|
982
|
-
|
|
983
|
-
#[test]
|
|
984
|
-
fn contract_d_codex_rollout_requires_provider_lifecycle_shape_or_stays_unknown() {
|
|
985
|
-
let team_agent_events = r#"{"event":"message.delivered","message_id":"msg_1"}"#;
|
|
986
|
-
let classified = classify(
|
|
987
|
-
Provider::Codex,
|
|
988
|
-
team_agent_events,
|
|
989
|
-
ProcessLiveness::Unverifiable,
|
|
990
|
-
0.0,
|
|
991
|
-
)
|
|
992
|
-
.unwrap();
|
|
993
|
-
assert_eq!(
|
|
994
|
-
classified.state,
|
|
995
|
-
TurnState::Unknown,
|
|
996
|
-
"Contract D: Team Agent event rows do not contain Codex lifecycle facts and must classify unknown"
|
|
997
|
-
);
|
|
998
|
-
assert!(
|
|
999
|
-
!classified.state.is_idle_for_takeover(),
|
|
1000
|
-
"Contract D/F5/N11: no valid Codex transcript means honest unknown, never fake idle"
|
|
1001
|
-
);
|
|
1002
|
-
|
|
1003
|
-
let ws = tmp_dir("d-valid-rollout");
|
|
1004
|
-
let valid = ws.join("codex-session.jsonl");
|
|
1005
|
-
let session_meta = serde_json::json!({
|
|
1006
|
-
"session_meta": {"payload": {
|
|
1007
|
-
"id": "codex-contract-d",
|
|
1008
|
-
"cwd": ws.to_string_lossy(),
|
|
1009
|
-
"created_at": chrono::Utc::now().to_rfc3339(),
|
|
1010
|
-
}}
|
|
1011
|
-
});
|
|
1012
|
-
std::fs::write(
|
|
1013
|
-
&valid,
|
|
1014
|
-
format!(
|
|
1015
|
-
"{session_meta}\n{}\n",
|
|
1016
|
-
r#"{"type":"event_msg","payload":{"type":"task_complete","turn_id":"ct1"}}"#
|
|
1017
|
-
),
|
|
1018
|
-
)
|
|
1019
|
-
.unwrap();
|
|
1020
|
-
let adapter = get_adapter(Provider::Codex);
|
|
1021
|
-
let captured = adapter.capture_session_id("w1", &ws, 0).unwrap();
|
|
1022
|
-
assert!(
|
|
1023
|
-
captured
|
|
1024
|
-
.as_ref()
|
|
1025
|
-
.and_then(|c| c.rollout_path.as_ref())
|
|
1026
|
-
.is_some_and(|p| p.as_path() == valid),
|
|
1027
|
-
"Contract D: valid Codex lifecycle-shaped transcript may be persisted as rollout_path; captured={captured:?}"
|
|
1028
|
-
);
|
|
1029
|
-
}
|
|
1030
|
-
|
|
1031
802
|
fn message_status(db_path: &Path, message_id: &str) -> String {
|
|
1032
803
|
let conn = team_agent::db::schema::open_db(db_path).unwrap();
|
|
1033
804
|
conn.query_row(
|
|
@@ -1061,23 +832,11 @@ fn count_event(events: &str, event_name: &str) -> usize {
|
|
|
1061
832
|
.count()
|
|
1062
833
|
}
|
|
1063
834
|
|
|
1064
|
-
fn count_handled_action(events: &str, action: &str) -> usize {
|
|
1065
|
-
events
|
|
1066
|
-
.lines()
|
|
1067
|
-
.filter_map(|line| serde_json::from_str::<serde_json::Value>(line).ok())
|
|
1068
|
-
.filter(|event| event["event"] == "startup_prompt_handled")
|
|
1069
|
-
.filter_map(|event| event["handled"].as_array().cloned())
|
|
1070
|
-
.flat_map(|handled| handled.into_iter())
|
|
1071
|
-
.filter(|handled| handled["action"] == action)
|
|
1072
|
-
.count()
|
|
1073
|
-
}
|
|
1074
|
-
|
|
1075
835
|
#[derive(Debug, Default)]
|
|
1076
836
|
struct TransportState {
|
|
1077
837
|
captures: Vec<String>,
|
|
1078
838
|
capture_idx: usize,
|
|
1079
839
|
inject_count: usize,
|
|
1080
|
-
send_keys_count: usize,
|
|
1081
840
|
session_present: bool,
|
|
1082
841
|
windows: Vec<WindowName>,
|
|
1083
842
|
spawn_argv: Vec<Vec<String>>,
|
|
@@ -1113,10 +872,6 @@ impl RecordingTransport {
|
|
|
1113
872
|
self.state.lock().unwrap().inject_count
|
|
1114
873
|
}
|
|
1115
874
|
|
|
1116
|
-
fn send_keys_count(&self) -> usize {
|
|
1117
|
-
self.state.lock().unwrap().send_keys_count
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1120
875
|
fn spawn_argv(&self) -> Vec<String> {
|
|
1121
876
|
self.state
|
|
1122
877
|
.lock()
|
|
@@ -1191,7 +946,6 @@ impl Transport for RecordingTransport {
|
|
|
1191
946
|
}
|
|
1192
947
|
|
|
1193
948
|
fn send_keys(&self, _target: &Target, _keys: &[Key]) -> Result<(), TransportError> {
|
|
1194
|
-
self.state.lock().unwrap().send_keys_count += 1;
|
|
1195
949
|
Ok(())
|
|
1196
950
|
}
|
|
1197
951
|
|