@team-agent/installer 0.5.125 → 0.5.126
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 -68
- package/crates/team-agent/src/cli/emit.rs +6 -2
- package/crates/team-agent/src/cli/intent/runtime_tests.rs +10 -10
- package/crates/team-agent/src/cli/mod.rs +22 -28
- package/crates/team-agent/src/cli/models.rs +7 -764
- package/crates/team-agent/src/cli/tests/mod.rs +1 -1
- package/crates/team-agent/src/cli/tests/run_delegation.rs +5 -4
- package/crates/team-agent/src/compiler/tests.rs +18 -3
- package/crates/team-agent/src/compiler.rs +4 -203
- package/crates/team-agent/src/contract_runtime/backend.rs +61 -38
- package/crates/team-agent/src/contract_runtime/config.rs +7 -4
- package/crates/team-agent/src/contract_runtime/fork.rs +368 -0
- package/crates/team-agent/src/contract_runtime/framework.rs +8 -10
- package/crates/team-agent/src/contract_runtime/mod.rs +1 -0
- package/crates/team-agent/src/contract_runtime/registry.rs +60 -19
- package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +29 -8
- package/crates/team-agent/src/coordinator/tests/health_sync.rs +0 -42
- 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 +18 -28
- package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +6 -87
- package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +1 -9
- package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +74 -244
- package/crates/team-agent/src/lifecycle/launch/quick_start.rs +0 -24
- package/crates/team-agent/src/lifecycle/launch/role_source.rs +5 -0
- package/crates/team-agent/src/lifecycle/launch/spawn.rs +21 -33
- package/crates/team-agent/src/lifecycle/launch.rs +0 -23
- package/crates/team-agent/src/lifecycle/profile_launch.rs +18 -317
- package/crates/team-agent/src/lifecycle/restart/common.rs +42 -315
- 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/tests/behavioral_diff_264_red.rs +11 -6
- 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 +22 -138
- 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 +30 -11
- package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +2 -2
- package/crates/team-agent/src/lifecycle/tests/core.rs +17 -16
- package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +12 -12
- package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +3 -51
- package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +26 -28
- 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 +11 -10
- package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +2 -106
- package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +2 -2
- package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +2 -254
- package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +4 -4
- package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +6 -5
- package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +7 -16
- package/crates/team-agent/src/lifecycle/tests.rs +0 -3
- package/crates/team-agent/src/lifecycle/types.rs +2 -18
- package/crates/team-agent/src/mcp_server/readiness_tests.rs +1 -1
- package/crates/team-agent/src/messaging/delivery.rs +12 -141
- package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +5 -5
- package/crates/team-agent/src/messaging/tests/dup_inject.rs +3 -3
- package/crates/team-agent/src/messaging/tests/spine.rs +26 -32
- package/crates/team-agent/src/provider/adapter.rs +35 -238
- package/crates/team-agent/src/provider/adapters/mod.rs +4 -4
- package/crates/team-agent/src/provider/model_catalog.rs +13 -201
- package/crates/team-agent/src/provider/session/capture.rs +6 -106
- package/crates/team-agent/src/provider/session/context_fork/outcome.rs +0 -4
- package/crates/team-agent/src/provider/session/context_fork.rs +15 -107
- package/crates/team-agent/src/provider/session_scan/common.rs +10 -34
- package/crates/team-agent/src/provider/session_scan/pi.rs +1 -34
- package/crates/team-agent/src/provider/session_scan.rs +4 -10
- package/crates/team-agent/src/provider/tests/adapter.rs +34 -91
- package/crates/team-agent/src/provider/tests/command_helpers.rs +3 -12
- package/crates/team-agent/src/provider/tests/idle.rs +0 -25
- package/crates/team-agent/src/provider/wire.rs +51 -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/package.json +4 -4
- package/skills/team-agent/SKILL.md +6 -4
- package/skills/team-agent/command-coverage.json +15 -1
- package/skills/team-agent/docs/reference/team-agent-operator.md +5 -3
- package/skills/team-agent/references/team-agent-operator.md +5 -3
- 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/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/pi.rs +0 -100
- package/crates/team-agent/src/provider/session/context_fork/claude.rs +0 -123
- package/crates/team-agent/src/provider/session_scan/claude.rs +0 -523
- package/crates/team-agent/src/test_support/models_timeout_fixture.rs +0 -144
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
//! leave a stale .tmp on a failed replace. The contracts assert the original data
|
|
11
11
|
//! survives / no residue.
|
|
12
12
|
//! T3 (false green = unrecognized/failed input silently maps to a success value,
|
|
13
|
-
//! MUST-NOT-13): normalize_result_status unrecognized -> Success;
|
|
14
|
-
//!
|
|
13
|
+
//! MUST-NOT-13): normalize_result_status unrecognized -> Success; schema_diagnosis
|
|
14
|
+
//! missing db -> ok:true; tmux fabricated
|
|
15
15
|
//! `%0` pane id; packaging install/update constant DoctorStatus::Ok.
|
|
16
16
|
//! T5: stop_coordinator_bounded spawns a thread + recv_timeout and never joins it —
|
|
17
17
|
//! a timed-out stop leaves a detached thread. Source grep guard (the bounded-stop
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
#[allow(dead_code)]
|
|
24
24
|
mod mcp_sim_harness;
|
|
25
25
|
|
|
26
|
-
use std::path::
|
|
26
|
+
use std::path::PathBuf;
|
|
27
27
|
use std::sync::atomic::{AtomicU64, Ordering};
|
|
28
28
|
|
|
29
29
|
use mcp_sim_harness::McpSimHarness;
|
|
@@ -419,45 +419,6 @@ check behind it = false green); it must reflect an actual doctor result"
|
|
|
419
419
|
);
|
|
420
420
|
}
|
|
421
421
|
|
|
422
|
-
/// T3-2 (claude_auth_hint parse failure): when `claude auth status` output is
|
|
423
|
-
/// unparseable / unsuccessful, the hint must not default to Present (auth misreported
|
|
424
|
-
/// as available). PATH-shims a `claude` that prints garbage and exits non-zero.
|
|
425
|
-
/// Mutates the process-global PATH/HOME — must not race host_cotenant's ps/tmux
|
|
426
|
-
/// shims (P0 pid-probe isolation) or other env-mutating tests, hence
|
|
427
|
-
/// `#[serial(env, pid_probe)]`.
|
|
428
|
-
#[test]
|
|
429
|
-
#[serial(env, pid_probe)]
|
|
430
|
-
fn t3_claude_auth_hint_parse_failure_is_not_present() {
|
|
431
|
-
let home = tmp_ws("t3-auth-home");
|
|
432
|
-
let shim_dir = home.join("bin");
|
|
433
|
-
std::fs::create_dir_all(&shim_dir).unwrap();
|
|
434
|
-
// claude shim: garbage stdout + non-zero exit (auth status unparseable / failed).
|
|
435
|
-
write_shim(
|
|
436
|
-
&shim_dir.join("claude"),
|
|
437
|
-
"#!/bin/sh\nprintf 'not json at all\\n'\nexit 7\n",
|
|
438
|
-
);
|
|
439
|
-
let old_path = std::env::var("PATH").unwrap_or_default();
|
|
440
|
-
let old_home = std::env::var("HOME").ok();
|
|
441
|
-
std::env::set_var("HOME", &home);
|
|
442
|
-
std::env::set_var("PATH", format!("{}:{old_path}", shim_dir.to_string_lossy()));
|
|
443
|
-
|
|
444
|
-
let status = team_agent::provider::get_adapter(team_agent::provider::Provider::Claude)
|
|
445
|
-
.auth_hint(team_agent::provider::AuthMode::Subscription);
|
|
446
|
-
|
|
447
|
-
std::env::set_var("PATH", &old_path);
|
|
448
|
-
match old_home {
|
|
449
|
-
Some(home) => std::env::set_var("HOME", home),
|
|
450
|
-
None => std::env::remove_var("HOME"),
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
assert_ne!(
|
|
454
|
-
format!("{status:?}"),
|
|
455
|
-
"Present",
|
|
456
|
-
"T3-2: a `claude auth status` that prints unparseable output and exits non-zero \
|
|
457
|
-
must NOT report Present (auth misreported as available is a false green); got {status:?}"
|
|
458
|
-
);
|
|
459
|
-
}
|
|
460
|
-
|
|
461
422
|
// ───────────────────────────────── T5 · thread leak ─────────────────────────────────
|
|
462
423
|
|
|
463
424
|
/// T5 (A2 shutdown thread leak): stop_coordinator_bounded spawns a worker thread and
|
|
@@ -484,15 +445,6 @@ stop; body={body}"
|
|
|
484
445
|
|
|
485
446
|
// ───────────────────────────────────── helpers ─────────────────────────────────────
|
|
486
447
|
|
|
487
|
-
fn write_shim(path: &Path, body: &str) {
|
|
488
|
-
std::fs::write(path, body).unwrap();
|
|
489
|
-
#[cfg(unix)]
|
|
490
|
-
{
|
|
491
|
-
use std::os::unix::fs::PermissionsExt;
|
|
492
|
-
std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o755)).unwrap();
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
|
|
496
448
|
/// Crude single-function body extractor: from the `fn name` line to the next
|
|
497
449
|
/// same-indent ` fn ` (good enough for grep-guard scoping).
|
|
498
450
|
fn fn_body(src: &str, marker: &str) -> String {
|
|
@@ -41,7 +41,6 @@ fn launch_source() -> String {
|
|
|
41
41
|
const QS_TEAM_MD: &str =
|
|
42
42
|
"---\nname: quickteam\nobjective: Quick start.\nprovider: codex\n---\n\nQuick-start team.\n";
|
|
43
43
|
pub(super) const QS_VALID_ROLE: &str = "---\nname: implementer\nrole: Implementation Engineer\nprovider: codex\nmodel: gpt-5.5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nImplement bounded tasks.\n";
|
|
44
|
-
const QS_ROLE_NO_PROVIDER: &str = "---\nname: implementer\nrole: Implementation Engineer\nmodel: gpt-5.5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nImplement bounded tasks.\n";
|
|
45
44
|
|
|
46
45
|
/// A REAL team dir `<base>/teamdir/{TEAM.md, agents/implementer.md}` — already in team-dir
|
|
47
46
|
/// layout, so quick_start's prepare_quick_start_team returns it as-is and writes the compiled
|
|
@@ -476,25 +475,23 @@ fn quick_start_default_workspace_compiled_spec_uses_project_root() {
|
|
|
476
475
|
);
|
|
477
476
|
}
|
|
478
477
|
|
|
479
|
-
//
|
|
480
|
-
//
|
|
481
|
-
|
|
478
|
+
// An omitted role `provider` is the default `pi`, which declares the Pi contract leaf: the
|
|
479
|
+
// compiled spec carries the leaf id, so quick-start never produces a legacy `pi` worker row.
|
|
480
|
+
#[cfg(unix)]
|
|
482
481
|
#[test]
|
|
483
|
-
fn
|
|
484
|
-
let team = quick_start_team_dir(
|
|
485
|
-
|
|
486
|
-
let result = quick_start_with_transport(&team, None, true, None, &transport);
|
|
487
|
-
|
|
488
|
-
let text = format!("{result:?}");
|
|
489
|
-
assert!(
|
|
490
|
-
text.contains("provider"),
|
|
491
|
-
"an invalid role doc (missing provider) must surface the real compile error mentioning \
|
|
492
|
-
'provider'; got {text}"
|
|
493
|
-
);
|
|
494
|
-
assert!(
|
|
495
|
-
!text.contains("no role docs found"),
|
|
496
|
-
"must NOT be the hardcoded stub blocker — real preflight/compile distinguishes the cause"
|
|
482
|
+
fn quick_start_role_without_provider_compiles_to_the_pi_leaf() {
|
|
483
|
+
let team = quick_start_team_dir(
|
|
484
|
+
"---\nname: implementer\nrole: Implementation Engineer\nmodel: gpt-5.5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nImplement bounded tasks.\n",
|
|
497
485
|
);
|
|
486
|
+
let spec = crate::compiler::compile_team(&team).expect("an omitted provider is the default pi");
|
|
487
|
+
let providers = spec
|
|
488
|
+
.get("agents")
|
|
489
|
+
.and_then(crate::model::yaml::Value::as_list)
|
|
490
|
+
.expect("compiled agents")
|
|
491
|
+
.iter()
|
|
492
|
+
.map(|agent| agent.get("provider").and_then(crate::model::yaml::Value::as_str))
|
|
493
|
+
.collect::<Vec<_>>();
|
|
494
|
+
assert_eq!(providers, vec![Some("pi_tui")]);
|
|
498
495
|
}
|
|
499
496
|
|
|
500
497
|
// P0 — launch (dry_run) over a real compiled spec must resolve the REAL route/permission plan
|
|
@@ -2704,21 +2701,22 @@ fn restart_allow_fresh_copilot_keeps_session_id_null_until_capture_confirms() {
|
|
|
2704
2701
|
let _ = plan; // shape verified above; details depend on classifier internals.
|
|
2705
2702
|
}
|
|
2706
2703
|
|
|
2707
|
-
/// 0.4.6 tuple-atomic contract (audit, line 268):
|
|
2708
|
-
/// leaves session_id=null even when
|
|
2704
|
+
/// 0.4.6 tuple-atomic contract (audit, line 268): a fresh restart of a
|
|
2705
|
+
/// preassigned-session worker (Copilot) leaves session_id=null even when the
|
|
2706
|
+
/// input row had a stale session_id.
|
|
2709
2707
|
/// The poisoned-row scenario (Bug 045 release-engineer state).
|
|
2710
2708
|
#[test]
|
|
2711
|
-
fn
|
|
2712
|
-
let ws = temp_ws().join("
|
|
2709
|
+
fn restart_allow_fresh_copilot_clears_poisoned_session_id() {
|
|
2710
|
+
let ws = temp_ws().join("restartcopilot046");
|
|
2713
2711
|
std::fs::create_dir_all(ws.join("agents")).unwrap();
|
|
2714
2712
|
std::fs::write(
|
|
2715
2713
|
ws.join("TEAM.md"),
|
|
2716
|
-
"---\nname:
|
|
2714
|
+
"---\nname: restartcopilot046\nobjective: 0.4.6 contract.\nprovider: claude\n---\n\nteam.\n",
|
|
2717
2715
|
)
|
|
2718
2716
|
.unwrap();
|
|
2719
2717
|
std::fs::write(
|
|
2720
2718
|
ws.join("agents").join("alpha.md"),
|
|
2721
|
-
"---\nname: alpha\nrole: Alpha\nprovider:
|
|
2719
|
+
"---\nname: alpha\nrole: Alpha\nprovider: copilot\nmodel: gpt-5.5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nAlpha.\n",
|
|
2722
2720
|
)
|
|
2723
2721
|
.unwrap();
|
|
2724
2722
|
let spec = crate::compiler::compile_team(&ws).expect("compile");
|
|
@@ -2727,11 +2725,11 @@ fn restart_allow_fresh_claude_clears_poisoned_session_id() {
|
|
|
2727
2725
|
crate::state::persist::save_runtime_state(
|
|
2728
2726
|
&ws,
|
|
2729
2727
|
&json!({
|
|
2730
|
-
"session_name": "team-
|
|
2728
|
+
"session_name": "team-restartcopilot046",
|
|
2731
2729
|
"agents": {
|
|
2732
2730
|
"alpha": {
|
|
2733
2731
|
"status": "running",
|
|
2734
|
-
"provider": "
|
|
2732
|
+
"provider": "copilot",
|
|
2735
2733
|
"window": "alpha",
|
|
2736
2734
|
"first_send_at": "2026-06-23T10:00:00+00:00",
|
|
2737
2735
|
"session_id": stale_uuid,
|
|
@@ -2749,7 +2747,7 @@ fn restart_allow_fresh_claude_clears_poisoned_session_id() {
|
|
|
2749
2747
|
let result = restart_with_transport(&ws, true, None, &transport);
|
|
2750
2748
|
assert!(
|
|
2751
2749
|
matches!(result, Ok(RestartReport::Restarted { .. })),
|
|
2752
|
-
"allow-fresh restart should fresh-spawn the
|
|
2750
|
+
"allow-fresh restart should fresh-spawn the copilot worker; got {result:?}"
|
|
2753
2751
|
);
|
|
2754
2752
|
|
|
2755
2753
|
let state = crate::state::persist::load_runtime_state(&ws).expect("load state");
|
|
@@ -2757,7 +2755,7 @@ fn restart_allow_fresh_claude_clears_poisoned_session_id() {
|
|
|
2757
2755
|
assert_eq!(
|
|
2758
2756
|
agent.get("session_id"),
|
|
2759
2757
|
Some(&serde_json::Value::Null),
|
|
2760
|
-
"0.4.6 contract:
|
|
2758
|
+
"0.4.6 contract: fresh restart must clear stale session_id; agent={agent}"
|
|
2761
2759
|
);
|
|
2762
2760
|
// C1 dual-projection: teams.<key>.agents.alpha.session_id must also be null.
|
|
2763
2761
|
if let Some(teams) = state.get("teams").and_then(serde_json::Value::as_object) {
|
|
@@ -2,10 +2,9 @@ use std::collections::BTreeSet;
|
|
|
2
2
|
use std::path::Path;
|
|
3
3
|
|
|
4
4
|
use crate::lifecycle::launch::pi_mcp::{
|
|
5
|
-
parse_pi_list_models_table, select_exact_pi_model,
|
|
5
|
+
build_pi_command_argv, parse_pi_list_models_table, select_exact_pi_model, PiCommandRequest,
|
|
6
6
|
};
|
|
7
7
|
use crate::model::enums::ProviderEffort;
|
|
8
|
-
use crate::provider::adapters::pi::{build_pi_command_argv, PiCommandRequest, PiSessionSelector};
|
|
9
8
|
|
|
10
9
|
const CATALOG: &[u8] = include_bytes!("fixtures/pi_list_models_g0.stdout.txt");
|
|
11
10
|
// Public pi --list-models rows captured for issue #186, preserving column widths.
|
|
@@ -87,13 +86,12 @@ fn argv_has_pair(argv: &[String], flag: &str, value: &str) -> bool {
|
|
|
87
86
|
|
|
88
87
|
fn command_for_model(model: &str) -> Vec<String> {
|
|
89
88
|
build_pi_command_argv(PiCommandRequest {
|
|
90
|
-
extension: Path::new("/workspace/.team/runtime/pi/t1/
|
|
89
|
+
extension: Path::new("/workspace/.team/runtime/pi/t1/leader/team-mcp.ts"),
|
|
91
90
|
model: Some(model),
|
|
92
91
|
effort: Some(ProviderEffort::Medium),
|
|
93
|
-
system_prompt: "
|
|
94
|
-
session_dir: Some(Path::new("/workspace/.team/runtime/pi/t1/
|
|
95
|
-
|
|
96
|
-
agent_id: "w1",
|
|
92
|
+
system_prompt: "leader contract",
|
|
93
|
+
session_dir: Some(Path::new("/workspace/.team/runtime/pi/t1/leader/sessions")),
|
|
94
|
+
agent_id: "leader",
|
|
97
95
|
})
|
|
98
96
|
.expect("catalog member must build a semantic Pi argv")
|
|
99
97
|
}
|
|
@@ -134,7 +132,7 @@ fn pi_catalog_discovers_all_exact_ids_and_rejects_invalid_or_ambiguous_selection
|
|
|
134
132
|
}
|
|
135
133
|
|
|
136
134
|
#[test]
|
|
137
|
-
fn
|
|
135
|
+
fn pi_exact_catalog_id_is_forwarded_byte_for_byte() {
|
|
138
136
|
let models = parse_pi_list_models_table(CATALOG).expect("frozen unfiltered table must parse");
|
|
139
137
|
assert_eq!(models.len(), 221);
|
|
140
138
|
|
|
@@ -151,14 +149,4 @@ fn pi_exact_catalog_id_is_forwarded_and_started_identity_must_match() {
|
|
|
151
149
|
"model selector must occur exactly once: {argv:?}"
|
|
152
150
|
);
|
|
153
151
|
}
|
|
154
|
-
|
|
155
|
-
assert!(verify_started_pi_model("team-agent/qwen3.8-27b", "team-agent/qwen3.8-27b").is_ok());
|
|
156
|
-
assert!(
|
|
157
|
-
verify_started_pi_model("team-agent/qwen3.8-27b", "xai/grok-4.6").is_err(),
|
|
158
|
-
"started identity mismatch must refuse rather than trust pane chrome"
|
|
159
|
-
);
|
|
160
|
-
assert!(
|
|
161
|
-
verify_started_pi_model("team-agent/qwen3.8-27b", "").is_err(),
|
|
162
|
-
"missing objective started-model evidence must not pass"
|
|
163
|
-
);
|
|
164
152
|
}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
use std::path::Path;
|
|
2
2
|
|
|
3
|
-
use crate::lifecycle::launch::pi_mcp::{
|
|
3
|
+
use crate::lifecycle::launch::pi_mcp::{
|
|
4
|
+
build_pi_command_argv, pi_leader_session_scope, PiCommandRequest, PiSessionScope,
|
|
5
|
+
};
|
|
4
6
|
use crate::model::enums::ProviderEffort;
|
|
5
|
-
use crate::provider::adapters::pi::{build_pi_command_argv, PiCommandRequest, PiSessionSelector};
|
|
6
7
|
|
|
7
|
-
fn
|
|
8
|
+
fn isolated_leader_request() -> PiCommandRequest<'static> {
|
|
8
9
|
PiCommandRequest {
|
|
9
|
-
extension: Path::new("/workspace/.team/runtime/pi/team-a/
|
|
10
|
+
extension: Path::new("/workspace/.team/runtime/pi/team-a/leader/team-mcp.ts"),
|
|
10
11
|
model: Some("team-agent/qwen3.8-27b"),
|
|
11
12
|
effort: Some(ProviderEffort::High),
|
|
12
|
-
system_prompt: "frozen
|
|
13
|
+
system_prompt: "frozen leader prompt",
|
|
13
14
|
session_dir: Some(Path::new(
|
|
14
|
-
"/workspace/.team/runtime/pi/team-a/
|
|
15
|
+
"/workspace/.team/runtime/pi/team-a/leader/sessions",
|
|
15
16
|
)),
|
|
16
|
-
|
|
17
|
-
agent_id: "worker-a",
|
|
17
|
+
agent_id: "leader",
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
#[test]
|
|
22
22
|
fn pi_command_omits_unset_model_and_thinking_flags() {
|
|
23
|
-
let mut request =
|
|
23
|
+
let mut request = isolated_leader_request();
|
|
24
24
|
request.model = None;
|
|
25
25
|
request.effort = None;
|
|
26
26
|
let argv = build_pi_command_argv(request).expect("Pi provider defaults");
|
|
@@ -36,7 +36,6 @@ fn leader_request() -> PiCommandRequest<'static> {
|
|
|
36
36
|
effort: None,
|
|
37
37
|
system_prompt: "frozen leader prompt",
|
|
38
38
|
session_dir: None,
|
|
39
|
-
session: PiSessionSelector::Fresh,
|
|
40
39
|
agent_id: "leader",
|
|
41
40
|
}
|
|
42
41
|
}
|
|
@@ -92,84 +91,67 @@ fn pi_leader_session_scope_keeps_explicit_and_external_routes_isolated() {
|
|
|
92
91
|
|
|
93
92
|
#[test]
|
|
94
93
|
fn pi_command_preserves_direct_pi_defaults_with_only_team_runtime_additions() {
|
|
95
|
-
let fresh = build_pi_command_argv(
|
|
96
|
-
.expect("fresh Pi command");
|
|
94
|
+
let fresh = build_pi_command_argv(isolated_leader_request()).expect("fresh Pi command");
|
|
97
95
|
assert_eq!(
|
|
98
96
|
fresh,
|
|
99
97
|
[
|
|
100
98
|
"pi",
|
|
101
99
|
"-e",
|
|
102
|
-
"/workspace/.team/runtime/pi/team-a/
|
|
100
|
+
"/workspace/.team/runtime/pi/team-a/leader/team-mcp.ts",
|
|
103
101
|
"--model",
|
|
104
102
|
"team-agent/qwen3.8-27b",
|
|
105
103
|
"--thinking",
|
|
106
104
|
"high",
|
|
107
105
|
"--append-system-prompt",
|
|
108
|
-
"frozen
|
|
106
|
+
"frozen leader prompt",
|
|
109
107
|
"--session-dir",
|
|
110
|
-
"/workspace/.team/runtime/pi/team-a/
|
|
108
|
+
"/workspace/.team/runtime/pi/team-a/leader/sessions",
|
|
111
109
|
"--name",
|
|
112
|
-
"
|
|
110
|
+
"leader",
|
|
113
111
|
]
|
|
114
112
|
.map(str::to_string)
|
|
115
113
|
);
|
|
116
114
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
"
|
|
150
|
-
|
|
151
|
-
"--sandbox",
|
|
152
|
-
"--no-extensions",
|
|
153
|
-
"--no-approve",
|
|
154
|
-
"--no-context-files",
|
|
155
|
-
"--no-skills",
|
|
156
|
-
"--no-prompt-templates",
|
|
157
|
-
"--tui-mode",
|
|
158
|
-
"--tools",
|
|
159
|
-
"--system-prompt",
|
|
160
|
-
] {
|
|
161
|
-
assert!(
|
|
162
|
-
!argv.iter().any(|arg| arg == forbidden),
|
|
163
|
-
"materializer-owned Pi argv must not inherit {forbidden}: {argv:?}"
|
|
164
|
-
);
|
|
165
|
-
}
|
|
115
|
+
for forbidden in [
|
|
116
|
+
"rpc",
|
|
117
|
+
"--mode",
|
|
118
|
+
"--print",
|
|
119
|
+
"-p",
|
|
120
|
+
"-r",
|
|
121
|
+
"--resume",
|
|
122
|
+
"-c",
|
|
123
|
+
"--continue",
|
|
124
|
+
"--session",
|
|
125
|
+
"--session-id",
|
|
126
|
+
"--mcp-config",
|
|
127
|
+
"--provider",
|
|
128
|
+
"--fork",
|
|
129
|
+
"--workspace",
|
|
130
|
+
"--cwd",
|
|
131
|
+
"--rules",
|
|
132
|
+
"--always-approve",
|
|
133
|
+
"--force",
|
|
134
|
+
"--trust",
|
|
135
|
+
"--sandbox",
|
|
136
|
+
"--no-extensions",
|
|
137
|
+
"--no-approve",
|
|
138
|
+
"--no-context-files",
|
|
139
|
+
"--no-skills",
|
|
140
|
+
"--no-prompt-templates",
|
|
141
|
+
"--tui-mode",
|
|
142
|
+
"--tools",
|
|
143
|
+
"--system-prompt",
|
|
144
|
+
] {
|
|
145
|
+
assert!(
|
|
146
|
+
!fresh.iter().any(|arg| arg == forbidden),
|
|
147
|
+
"materializer-owned Pi argv must not inherit {forbidden}: {fresh:?}"
|
|
148
|
+
);
|
|
166
149
|
}
|
|
167
150
|
}
|
|
168
151
|
|
|
169
152
|
#[test]
|
|
170
153
|
fn pi_command_keeps_direct_plugins_skills_context_auth_and_tools() {
|
|
171
|
-
let argv = build_pi_command_argv(
|
|
172
|
-
.expect("fresh Pi command");
|
|
154
|
+
let argv = build_pi_command_argv(isolated_leader_request()).expect("fresh Pi command");
|
|
173
155
|
|
|
174
156
|
for forbidden in [
|
|
175
157
|
"--no-context-files",
|
|
@@ -184,17 +166,17 @@ fn pi_command_keeps_direct_plugins_skills_context_auth_and_tools() {
|
|
|
184
166
|
assert_eq!(
|
|
185
167
|
argv.iter().filter(|arg| arg.as_str() == forbidden).count(),
|
|
186
168
|
0,
|
|
187
|
-
"
|
|
169
|
+
"Pi leader must preserve the direct Pi default instead of adding {forbidden}; argv={argv:?}"
|
|
188
170
|
);
|
|
189
171
|
}
|
|
190
172
|
assert!(argv.windows(2).any(|pair| {
|
|
191
173
|
pair == [
|
|
192
174
|
"-e",
|
|
193
|
-
"/workspace/.team/runtime/pi/team-a/
|
|
175
|
+
"/workspace/.team/runtime/pi/team-a/leader/team-mcp.ts",
|
|
194
176
|
]
|
|
195
177
|
}));
|
|
196
178
|
assert_eq!(argv.iter().filter(|arg| arg.as_str() == "-e").count(), 1);
|
|
197
179
|
assert!(argv
|
|
198
180
|
.windows(2)
|
|
199
|
-
.any(|pair| pair == ["--append-system-prompt", "frozen
|
|
181
|
+
.any(|pair| pair == ["--append-system-prompt", "frozen leader prompt"]));
|
|
200
182
|
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
use crate::cli::spec::{CommandKind, COMMAND_SPECS};
|
|
2
|
-
use crate::compiler::compile_role_agent;
|
|
3
2
|
use crate::lifecycle::launch::pi_mcp::parse_pi_leader_args;
|
|
4
|
-
use crate::model::enums::{
|
|
3
|
+
use crate::model::enums::{Provider, ProviderEffort};
|
|
5
4
|
use crate::model::ids::AgentId;
|
|
6
|
-
use crate::model::yaml::Value;
|
|
7
|
-
use crate::provider::{get_adapter, ProviderCommandContext};
|
|
8
5
|
use crate::transport::test_support::OfflineTransport;
|
|
9
6
|
use crate::transport::{Transport, WindowName};
|
|
10
7
|
use serde_json::json;
|
|
@@ -83,36 +80,6 @@ fn dynamic_add_fixture(root: &Path, label: &str, role_doc: &str) -> (PathBuf, Pa
|
|
|
83
80
|
(team, role)
|
|
84
81
|
}
|
|
85
82
|
|
|
86
|
-
#[cfg(unix)]
|
|
87
|
-
struct EnvVarGuard {
|
|
88
|
-
key: &'static str,
|
|
89
|
-
previous: Option<std::ffi::OsString>,
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
#[cfg(unix)]
|
|
93
|
-
impl EnvVarGuard {
|
|
94
|
-
fn set(key: &'static str, value: impl AsRef<std::ffi::OsStr>) -> Self {
|
|
95
|
-
let previous = std::env::var_os(key);
|
|
96
|
-
unsafe {
|
|
97
|
-
std::env::set_var(key, value);
|
|
98
|
-
}
|
|
99
|
-
Self { key, previous }
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
#[cfg(unix)]
|
|
104
|
-
impl Drop for EnvVarGuard {
|
|
105
|
-
fn drop(&mut self) {
|
|
106
|
-
unsafe {
|
|
107
|
-
if let Some(previous) = self.previous.take() {
|
|
108
|
-
std::env::set_var(self.key, previous);
|
|
109
|
-
} else {
|
|
110
|
-
std::env::remove_var(self.key);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
83
|
#[test]
|
|
117
84
|
fn pi_leader_and_teammate_share_provider_plan_but_are_separately_launchable() {
|
|
118
85
|
run_process_isolated(PI_DUAL_ENTRY_CHILD, PI_DUAL_ENTRY_TEST, || {
|
|
@@ -201,51 +168,6 @@ fn pi_leader_and_teammate_body(hermetic: &HermeticTestEnv) {
|
|
|
201
168
|
);
|
|
202
169
|
}
|
|
203
170
|
|
|
204
|
-
let root = hermetic.workspace("core-dual");
|
|
205
|
-
let role = root.join("worker.md");
|
|
206
|
-
std::fs::write(
|
|
207
|
-
&role,
|
|
208
|
-
"---\nname: worker-a\nrole: developer\nprovider: pi\nmodel: team-agent/qwen3.8-27b\nauth_mode: subscription\neffort: max\ntools:\n - mcp_team\ndangerously_skip_permissions: true\n---\nworker contract\n",
|
|
209
|
-
)
|
|
210
|
-
.expect("write teammate role");
|
|
211
|
-
let teammate = compile_role_agent(&role, &Value::Map(Vec::new()), "/workspace")
|
|
212
|
-
.expect("provider: pi teammate must compile separately");
|
|
213
|
-
assert_eq!(
|
|
214
|
-
teammate.agent.get("provider").and_then(Value::as_str),
|
|
215
|
-
Some("pi")
|
|
216
|
-
);
|
|
217
|
-
|
|
218
|
-
std::fs::write(
|
|
219
|
-
&role,
|
|
220
|
-
"---\nname: worker-a\nrole: developer\nprovider: pi\nauth_mode: subscription\ntools:\n - mcp_team\n---\nworker contract\n",
|
|
221
|
-
)
|
|
222
|
-
.expect("write provider-default teammate role");
|
|
223
|
-
let defaults = compile_role_agent(&role, &Value::Map(Vec::new()), "/workspace")
|
|
224
|
-
.expect("provider: pi teammate may preserve provider-native defaults");
|
|
225
|
-
assert_eq!(defaults.agent.get("model"), Some(&Value::Null));
|
|
226
|
-
assert_eq!(defaults.agent.get("effort"), None);
|
|
227
|
-
assert_eq!(
|
|
228
|
-
defaults.agent.get("dangerously_skip_permissions"),
|
|
229
|
-
Some(&Value::Bool(false))
|
|
230
|
-
);
|
|
231
|
-
std::fs::remove_dir_all(root).expect("remove role fixture");
|
|
232
|
-
|
|
233
|
-
let adapter = get_adapter(Provider::Pi);
|
|
234
|
-
let raw_build = adapter.build_command_plan(ProviderCommandContext {
|
|
235
|
-
auth_mode: AuthMode::Subscription,
|
|
236
|
-
mcp_config: None,
|
|
237
|
-
system_prompt: None,
|
|
238
|
-
model: None,
|
|
239
|
-
dangerously_skip_permissions: false,
|
|
240
|
-
profile_launch: None,
|
|
241
|
-
agent_id_hint: None,
|
|
242
|
-
effort: None,
|
|
243
|
-
});
|
|
244
|
-
assert!(raw_build
|
|
245
|
-
.expect_err("Pi adapter must refuse callers that skip the shared materializer")
|
|
246
|
-
.to_string()
|
|
247
|
-
.contains("shared lifecycle materializer"));
|
|
248
|
-
|
|
249
171
|
let dynamic_root = hermetic.workspace("teammate-dual");
|
|
250
172
|
let fake_role = "---\nname: mate\nrole: Dynamic Worker\nprovider: fake\nmodel: fake\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\ndynamic\n";
|
|
251
173
|
|
|
@@ -364,69 +286,6 @@ fn pi_leader_and_teammate_body(hermetic: &HermeticTestEnv) {
|
|
|
364
286
|
"dynamic add must not create a second tmux session"
|
|
365
287
|
);
|
|
366
288
|
|
|
367
|
-
let pi_provider_root = hermetic.workspace("pi-add-provider");
|
|
368
|
-
let pi_bin = pi_provider_root.join("bin");
|
|
369
|
-
std::fs::create_dir_all(&pi_bin).expect("create Pi test bin");
|
|
370
|
-
let pi_real = pi_provider_root.join("pi-cli");
|
|
371
|
-
std::fs::write(
|
|
372
|
-
&pi_real,
|
|
373
|
-
"#!/bin/sh\ncase \"$1\" in\n --version) printf '0.84.4\\n' ;;\n --list-models) printf 'provider model\\nteam-agent qwen3.8-27b\\n' ;;\n list) exit 64 ;;\n *) exit 64 ;;\nesac\n",
|
|
374
|
-
)
|
|
375
|
-
.expect("write protocol-capable Pi test executable");
|
|
376
|
-
std::fs::set_permissions(
|
|
377
|
-
&pi_real,
|
|
378
|
-
std::os::unix::fs::PermissionsExt::from_mode(0o755),
|
|
379
|
-
)
|
|
380
|
-
.expect("make Pi test executable");
|
|
381
|
-
std::os::unix::fs::symlink(&pi_real, pi_bin.join("pi")).expect("link Pi test executable");
|
|
382
|
-
let _pi_path = EnvVarGuard::set("PATH", pi_bin.as_os_str());
|
|
383
|
-
let pi_success_role = "---\nname: mate\nrole: Pi Dynamic Worker\nprovider: pi\nmodel: team-agent/qwen3.8-27b\nauth_mode: subscription\neffort: max\ntools:\n - mcp_team\ndangerously_skip_permissions: true\n---\n\ndynamic pi\n";
|
|
384
|
-
let (pi_success_team, pi_success_role_path) =
|
|
385
|
-
dynamic_add_fixture(&dynamic_root, "dynamic-pi-success", pi_success_role);
|
|
386
|
-
let pi_success_transport = OfflineTransport::new().with_session_present(true);
|
|
387
|
-
crate::lifecycle::add_agent_with_transport(
|
|
388
|
-
&pi_success_team,
|
|
389
|
-
&AgentId::new("mate"),
|
|
390
|
-
&pi_success_role_path,
|
|
391
|
-
false,
|
|
392
|
-
None,
|
|
393
|
-
&pi_success_transport,
|
|
394
|
-
)
|
|
395
|
-
.expect("Pi dynamic add must commit after spawning its materialized plan");
|
|
396
|
-
let pi_spawn = pi_success_transport.spawn_records();
|
|
397
|
-
assert_eq!(pi_spawn.len(), 1, "Pi dynamic add must spawn exactly once");
|
|
398
|
-
let pi_state = crate::state::persist::load_runtime_state(&pi_success_team)
|
|
399
|
-
.expect("load successful Pi add state");
|
|
400
|
-
assert_eq!(
|
|
401
|
-
pi_state
|
|
402
|
-
.pointer("/agents/mate/status")
|
|
403
|
-
.and_then(serde_json::Value::as_str),
|
|
404
|
-
Some("running"),
|
|
405
|
-
"successful Pi add must commit the running seat"
|
|
406
|
-
);
|
|
407
|
-
let pi_events = crate::event_log::EventLog::new(&pi_success_team)
|
|
408
|
-
.tail(50)
|
|
409
|
-
.expect("read successful Pi add events");
|
|
410
|
-
let pi_start_event = pi_events
|
|
411
|
-
.iter()
|
|
412
|
-
.find(|event| {
|
|
413
|
-
event.get("event").and_then(serde_json::Value::as_str)
|
|
414
|
-
== Some("start_agent.agent_start")
|
|
415
|
-
})
|
|
416
|
-
.expect("successful Pi add must emit start event");
|
|
417
|
-
let pi_event_command = pi_start_event
|
|
418
|
-
.get("command")
|
|
419
|
-
.and_then(serde_json::Value::as_array)
|
|
420
|
-
.expect("successful Pi start event command")
|
|
421
|
-
.iter()
|
|
422
|
-
.map(|value| value.as_str().expect("Pi argv string").to_string())
|
|
423
|
-
.collect::<Vec<_>>();
|
|
424
|
-
assert_eq!(
|
|
425
|
-
pi_event_command, pi_spawn[0].1,
|
|
426
|
-
"Pi start event must record the exact materialized plan that was spawned"
|
|
427
|
-
);
|
|
428
|
-
drop(_pi_path);
|
|
429
|
-
|
|
430
289
|
let (rollback_team, rollback_role) =
|
|
431
290
|
dynamic_add_fixture(&dynamic_root, "dynamic-rollback", fake_role);
|
|
432
291
|
let events_path = rollback_team.join(".team/logs/events.jsonl");
|
|
@@ -452,8 +311,7 @@ fn pi_leader_and_teammate_body(hermetic: &HermeticTestEnv) {
|
|
|
452
311
|
"failed dynamic add must not retain the inserted seat"
|
|
453
312
|
);
|
|
454
313
|
|
|
455
|
-
let
|
|
456
|
-
let (noop_team, noop_role) = dynamic_add_fixture(&dynamic_root, "dynamic-noop", pi_role);
|
|
314
|
+
let (noop_team, noop_role) = dynamic_add_fixture(&dynamic_root, "dynamic-noop", fake_role);
|
|
457
315
|
let noop_transport = OfflineTransport::new()
|
|
458
316
|
.with_session_present(true)
|
|
459
317
|
.with_windows(vec![WindowName::new("mate")]);
|
|
@@ -465,7 +323,7 @@ fn pi_leader_and_teammate_body(hermetic: &HermeticTestEnv) {
|
|
|
465
323
|
None,
|
|
466
324
|
&noop_transport,
|
|
467
325
|
)
|
|
468
|
-
.expect_err("a newly added
|
|
326
|
+
.expect_err("a newly added seat cannot succeed through start_agent.noop");
|
|
469
327
|
assert!(noop.to_string().contains("start_agent.noop"));
|
|
470
328
|
assert!(noop_transport.spawn_records().is_empty());
|
|
471
329
|
let noop_state =
|
|
@@ -495,8 +353,6 @@ fn pi_leader_and_teammate_body(hermetic: &HermeticTestEnv) {
|
|
|
495
353
|
|
|
496
354
|
let shared_source = include_str!("../launch/pi_mcp.rs");
|
|
497
355
|
let leader_source = include_str!("../../leader/start.rs");
|
|
498
|
-
let teammate_source = include_str!("../launch/spawn.rs");
|
|
499
|
-
let restart_source = include_str!("../restart/common.rs");
|
|
500
356
|
let restart_agent_source = include_str!("../restart/agent.rs");
|
|
501
357
|
let add_source = include_str!("../launch/add_agent.rs");
|
|
502
358
|
assert!(
|
|
@@ -510,17 +366,8 @@ fn pi_leader_and_teammate_body(hermetic: &HermeticTestEnv) {
|
|
|
510
366
|
assert_eq!(
|
|
511
367
|
shared_source.matches("fn materialize_pi_plan(").count(),
|
|
512
368
|
1,
|
|
513
|
-
"
|
|
514
|
-
);
|
|
515
|
-
assert_eq!(
|
|
516
|
-
shared_source
|
|
517
|
-
.matches("fn materialize_pi_resume_plan(")
|
|
518
|
-
.count(),
|
|
519
|
-
1,
|
|
520
|
-
"resume must share the same Core materializer module"
|
|
369
|
+
"the Pi leader must depend on one Core materializer definition"
|
|
521
370
|
);
|
|
522
|
-
assert!(teammate_source.contains("materialize_pi_plan("));
|
|
523
|
-
assert!(restart_source.contains("materialize_pi_plan("));
|
|
524
371
|
assert!(add_source.contains("start_agent_at_paths("));
|
|
525
372
|
assert!(restart_agent_source.contains("&spawn.plan,"));
|
|
526
373
|
std::fs::remove_dir_all(dynamic_root).expect("remove dynamic fixtures");
|