@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
|
@@ -621,35 +621,6 @@ fn provider_home_codex_rollout_from_foreign_workspace_is_not_captured() {
|
|
|
621
621
|
);
|
|
622
622
|
}
|
|
623
623
|
|
|
624
|
-
#[test]
|
|
625
|
-
#[ignore = "real-machine: provider session filesystem + restart/shutdown lifecycle convergence"]
|
|
626
|
-
#[serial(env)]
|
|
627
|
-
fn provider_home_claude_session_is_captured_for_restart_resume() {
|
|
628
|
-
let fixture = RestartFixture::new("claude-home-capture", "claude");
|
|
629
|
-
let _home = HomeGuard::with_home(fixture.root.join("home"));
|
|
630
|
-
let claude_session = "claude-sess-240";
|
|
631
|
-
seed_claude_home_session(&fixture.home(), &fixture.spawn_cwd, claude_session);
|
|
632
|
-
seed_running_state_without_session(&fixture.team, "claude", &fixture.spawn_cwd);
|
|
633
|
-
|
|
634
|
-
let adapter = get_adapter(Provider::Claude);
|
|
635
|
-
let captured = adapter
|
|
636
|
-
.capture_session_id("worker_a", &fixture.spawn_cwd, 0)
|
|
637
|
-
.expect("Claude provider-home capture should not error")
|
|
638
|
-
.expect("Claude session under HOME/.claude/sessions must be discoverable before restart");
|
|
639
|
-
|
|
640
|
-
assert_eq!(
|
|
641
|
-
captured.session_id.as_ref().map(|id| id.as_str()),
|
|
642
|
-
Some(claude_session),
|
|
643
|
-
"Claude capture must recover sessionId from provider-home session JSON"
|
|
644
|
-
);
|
|
645
|
-
assert!(
|
|
646
|
-
captured.rollout_path.as_ref().is_some_and(|path| path
|
|
647
|
-
.as_path()
|
|
648
|
-
.starts_with(fixture.home().join(".claude/sessions"))),
|
|
649
|
-
"Claude capture must scan provider home, not only spawn_cwd; captured={captured:?}"
|
|
650
|
-
);
|
|
651
|
-
}
|
|
652
|
-
|
|
653
624
|
#[test]
|
|
654
625
|
#[ignore = "real-machine: provider session filesystem + restart/shutdown lifecycle convergence"]
|
|
655
626
|
#[serial(env)]
|
|
@@ -679,30 +650,6 @@ fn restart_force_captures_real_codex_session_meta_before_teardown() {
|
|
|
679
650
|
);
|
|
680
651
|
}
|
|
681
652
|
|
|
682
|
-
#[test]
|
|
683
|
-
#[ignore = "real-machine: provider session filesystem + restart/shutdown lifecycle convergence"]
|
|
684
|
-
#[serial(env)]
|
|
685
|
-
fn restart_force_captures_claude_session_before_teardown() {
|
|
686
|
-
let fixture = RestartFixture::new("restart-claude-force-capture", "claude");
|
|
687
|
-
let _home = HomeGuard::with_home(fixture.root.join("home"));
|
|
688
|
-
let claude_session = "claude-sess-before-kill";
|
|
689
|
-
seed_claude_home_session(&fixture.home(), &fixture.spawn_cwd, claude_session);
|
|
690
|
-
seed_running_state_without_session(&fixture.team, "claude", &fixture.spawn_cwd);
|
|
691
|
-
let transport = RecordingTransport::new().with_session_present(true);
|
|
692
|
-
|
|
693
|
-
let report = restart_with_transport(&fixture.team, false, None, &transport)
|
|
694
|
-
.expect("restart should succeed after forced session capture");
|
|
695
|
-
|
|
696
|
-
assert_restarted_with_resume(&report, claude_session);
|
|
697
|
-
assert_spawn_contains_adjacent(
|
|
698
|
-
&transport.single_spawn_argv(),
|
|
699
|
-
&["--resume", claude_session],
|
|
700
|
-
"Claude restart must spawn `claude ... --resume <session_id>`",
|
|
701
|
-
);
|
|
702
|
-
assert_state_session_id(&fixture.team, claude_session);
|
|
703
|
-
assert_events_contain_resume_decision(&fixture.team, "resume", claude_session);
|
|
704
|
-
}
|
|
705
|
-
|
|
706
653
|
#[test]
|
|
707
654
|
#[ignore = "real-machine: provider session filesystem + restart/shutdown lifecycle convergence"]
|
|
708
655
|
#[serial(env)]
|
|
@@ -756,23 +703,6 @@ fn persisted_session_id_is_the_resume_authority_for_restart_plan_and_spawn_argv(
|
|
|
756
703
|
&["resume", "codex-known-session"],
|
|
757
704
|
"Codex restart must use the persisted session id",
|
|
758
705
|
);
|
|
759
|
-
|
|
760
|
-
let claude = RestartFixture::new("claude-resume-authority", "claude");
|
|
761
|
-
seed_running_state_with_session(
|
|
762
|
-
&claude.team,
|
|
763
|
-
"claude",
|
|
764
|
-
&claude.spawn_cwd,
|
|
765
|
-
"claude-known-session",
|
|
766
|
-
);
|
|
767
|
-
let claude_transport = RecordingTransport::new().with_session_present(true);
|
|
768
|
-
let claude_report = restart_with_transport(&claude.team, false, None, &claude_transport)
|
|
769
|
-
.expect("persisted Claude session_id must be resumable");
|
|
770
|
-
assert_restarted_with_resume(&claude_report, "claude-known-session");
|
|
771
|
-
assert_spawn_contains_adjacent(
|
|
772
|
-
&claude_transport.single_spawn_argv(),
|
|
773
|
-
&["--resume", "claude-known-session"],
|
|
774
|
-
"Claude restart must use the persisted session id",
|
|
775
|
-
);
|
|
776
706
|
}
|
|
777
707
|
|
|
778
708
|
fn assert_restarted_with_resume(report: &RestartReport, expected_session: &str) {
|
|
@@ -980,16 +910,6 @@ fn agent_session<'a>(state: &'a serde_json::Value, agent_id: &str) -> Option<&'a
|
|
|
980
910
|
.filter(|value| !value.is_empty())
|
|
981
911
|
}
|
|
982
912
|
|
|
983
|
-
fn assert_spawn_contains_adjacent(argv: &[String], expected: &[&str], message: &str) {
|
|
984
|
-
assert!(
|
|
985
|
-
argv.windows(expected.len()).any(|window| window
|
|
986
|
-
.iter()
|
|
987
|
-
.map(String::as_str)
|
|
988
|
-
.eq(expected.iter().copied())),
|
|
989
|
-
"{message}; argv={argv:?}"
|
|
990
|
-
);
|
|
991
|
-
}
|
|
992
|
-
|
|
993
913
|
fn assert_spawn_contains_ordered(argv: &[String], expected: &[&str], message: &str) {
|
|
994
914
|
let mut index = 0;
|
|
995
915
|
for arg in argv {
|
|
@@ -1100,20 +1020,6 @@ fn seed_codex_home_rollout_with_agent_hint(
|
|
|
1100
1020
|
.unwrap();
|
|
1101
1021
|
}
|
|
1102
1022
|
|
|
1103
|
-
fn seed_claude_home_session(home: &Path, spawn_cwd: &Path, session_id: &str) {
|
|
1104
|
-
let dir = home.join(".claude/sessions");
|
|
1105
|
-
std::fs::create_dir_all(&dir).unwrap();
|
|
1106
|
-
std::fs::write(
|
|
1107
|
-
dir.join("worker-a-session.json"),
|
|
1108
|
-
serde_json::to_string(&json!({
|
|
1109
|
-
"sessionId": session_id,
|
|
1110
|
-
"cwd": spawn_cwd.to_string_lossy().to_string()
|
|
1111
|
-
}))
|
|
1112
|
-
.unwrap(),
|
|
1113
|
-
)
|
|
1114
|
-
.unwrap();
|
|
1115
|
-
}
|
|
1116
|
-
|
|
1117
1023
|
fn seed_running_state_without_session(team: &Path, provider: &str, spawn_cwd: &Path) {
|
|
1118
1024
|
seed_running_state(team, provider, spawn_cwd, None);
|
|
1119
1025
|
seed_healthy_coordinator(team);
|
|
@@ -1322,12 +1228,7 @@ impl RestartFixture {
|
|
|
1322
1228
|
std::fs::write(
|
|
1323
1229
|
team.join("agents/worker_a.md"),
|
|
1324
1230
|
format!(
|
|
1325
|
-
"---\nname: worker_a\nrole: Worker\nprovider: {provider}\nmodel:
|
|
1326
|
-
if provider == "claude" {
|
|
1327
|
-
"claude-sonnet-4-6"
|
|
1328
|
-
} else {
|
|
1329
|
-
"gpt-5.5"
|
|
1330
|
-
}
|
|
1231
|
+
"---\nname: worker_a\nrole: Worker\nprovider: {provider}\nmodel: gpt-5.5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nWorker.\n"
|
|
1331
1232
|
),
|
|
1332
1233
|
)
|
|
1333
1234
|
.unwrap();
|
|
@@ -1360,12 +1261,7 @@ impl RestartFixture {
|
|
|
1360
1261
|
std::fs::write(
|
|
1361
1262
|
team.join("agents/worker_a.md"),
|
|
1362
1263
|
format!(
|
|
1363
|
-
"---\nname: worker_a\nrole: Worker\nprovider: {provider}\nmodel:
|
|
1364
|
-
if provider == "claude" {
|
|
1365
|
-
"claude-sonnet-4-6"
|
|
1366
|
-
} else {
|
|
1367
|
-
"gpt-5.5"
|
|
1368
|
-
}
|
|
1264
|
+
"---\nname: worker_a\nrole: Worker\nprovider: {provider}\nmodel: gpt-5.5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nWorker.\n"
|
|
1369
1265
|
),
|
|
1370
1266
|
)
|
|
1371
1267
|
.unwrap();
|
|
@@ -686,7 +686,7 @@ fn write_profile_fixture(root: &Path, base_url: &str, token: &str) -> PathBuf {
|
|
|
686
686
|
fs::write(
|
|
687
687
|
team.join("profiles/local.env"),
|
|
688
688
|
format!(
|
|
689
|
-
"
|
|
689
|
+
"OPENAI_BASE_URL={base_url}\nOPENAI_API_KEY={token}\nOPENAI_MODEL=mock-model\n"
|
|
690
690
|
),
|
|
691
691
|
)
|
|
692
692
|
.unwrap();
|
|
@@ -697,7 +697,7 @@ fn write_profile_fixture(root: &Path, base_url: &str, token: &str) -> PathBuf {
|
|
|
697
697
|
.unwrap();
|
|
698
698
|
fs::write(
|
|
699
699
|
team.join("agents/worker.md"),
|
|
700
|
-
"---\nname: worker\nrole: Worker\nprovider:
|
|
700
|
+
"---\nname: worker\nrole: Worker\nprovider: codex\nauth_mode: compatible_api\ndangerously_skip_permissions: false\nprofile: local\nmodel: null\ntools:\n - mcp_team\n---\n\nWorker.\n",
|
|
701
701
|
)
|
|
702
702
|
.unwrap();
|
|
703
703
|
team
|
|
@@ -4,10 +4,8 @@
|
|
|
4
4
|
//! `swallow-batch4-cr-verdict.md` (workspace artifacts; BOTH points APPROVE'd,
|
|
5
5
|
//! 8 constraints C1-C8 + 6 reverse cases — folded below).
|
|
6
6
|
//!
|
|
7
|
-
//! Point 1 (C1-C4)
|
|
8
|
-
//!
|
|
9
|
-
//! empty map and `write_json_object` then flattens the user's file (silent
|
|
10
|
-
//! destructive rewrite; MUST-NOT-9 / MUST-NOT-13 violation).
|
|
7
|
+
//! Point 1 (C1-C4) covered the Claude compatible-API config dir that profile launch
|
|
8
|
+
//! maintained for legacy Claude workers; it left with that runtime.
|
|
11
9
|
//! Point 2 (C5-C8): MCP scope validation must FAIL CLOSED when the runtime state is
|
|
12
10
|
//! unreadable — today `load_runtime_state(..).unwrap_or(json!({}))`
|
|
13
11
|
//! (mcp_server/tools.rs:574/:232) silently substitutes an empty state, so a
|
|
@@ -25,75 +23,9 @@ mod hermetic_guard;
|
|
|
25
23
|
#[allow(dead_code)]
|
|
26
24
|
fn _hermetic_boundary_marker(_: &hermetic_guard::HermeticTestEnv) {}
|
|
27
25
|
|
|
28
|
-
use std::path::{Path, PathBuf};
|
|
29
|
-
use std::sync::atomic::{AtomicU64, Ordering};
|
|
30
|
-
|
|
31
26
|
use mcp_sim_harness::McpSimHarness;
|
|
32
27
|
use serde_json::json;
|
|
33
28
|
use serial_test::serial;
|
|
34
|
-
use team_agent::lifecycle::launch_with_transport;
|
|
35
|
-
|
|
36
|
-
/// C1-C4 + reverse cases `profile_invalid_json_returns_error_and_does_not_overwrite_file`
|
|
37
|
-
/// / `..._includes_path_and_parse_detail_and_next_action`: launching a claude
|
|
38
|
-
/// compatible_api profile over a CORRUPT `.claude.json` must return a structured error
|
|
39
|
-
/// (path + parse detail + next action) and leave the corrupt file byte-identical —
|
|
40
|
-
/// never rewrite it with a flattened empty object.
|
|
41
|
-
#[test]
|
|
42
|
-
#[serial(b4_mcp)]
|
|
43
|
-
fn b4_profile_invalid_json_fails_explicit_and_never_flattens_the_file() {
|
|
44
|
-
// Pin a neutral process ancestry so the launch path is deterministic regardless of
|
|
45
|
-
// which provider flags this test process inherited (same guard as the #264 batch).
|
|
46
|
-
std::env::set_var(
|
|
47
|
-
"TEAM_AGENT_TEST_PROCESS_ANCESTRY_ARGV_JSON",
|
|
48
|
-
"[\"/bin/zsh\"]",
|
|
49
|
-
);
|
|
50
|
-
let ws = tmp_ws("b4-profile");
|
|
51
|
-
let team_dir = write_claude_compatible_team(&ws);
|
|
52
|
-
let config_dir = ws.join(".team/runtime/provider-config/worker_a/claude");
|
|
53
|
-
std::fs::create_dir_all(&config_dir).unwrap();
|
|
54
|
-
let corrupt = b"{ this is the user's corrupt claude state".to_vec();
|
|
55
|
-
std::fs::write(config_dir.join(".claude.json"), &corrupt).unwrap();
|
|
56
|
-
|
|
57
|
-
let result = launch_with_transport(
|
|
58
|
-
&team_dir.join("team.spec.yaml"),
|
|
59
|
-
false,
|
|
60
|
-
true,
|
|
61
|
-
true,
|
|
62
|
-
&offline_transport::RecordingTransport::new(),
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
let mut failures = Vec::new();
|
|
66
|
-
match &result {
|
|
67
|
-
Ok(report) => failures.push(format!(
|
|
68
|
-
"C1/C2: a corrupt provider-config JSON must fail the launch with a \
|
|
69
|
-
structured profile_invalid_json error, not silently continue; got Ok({report:?})"
|
|
70
|
-
)),
|
|
71
|
-
Err(error) => {
|
|
72
|
-
let text = error.to_string();
|
|
73
|
-
if !text.contains(".claude.json") {
|
|
74
|
-
failures.push(format!(
|
|
75
|
-
"C1/N38: the error must name the offending path; got {text}"
|
|
76
|
-
));
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
let after = std::fs::read(config_dir.join(".claude.json")).unwrap_or_default();
|
|
81
|
-
if after != corrupt {
|
|
82
|
-
failures.push(format!(
|
|
83
|
-
"C3/C4: the user's corrupt file must stay byte-identical (framework never \
|
|
84
|
-
flattens user files on load failure — MUST-NOT-9); before={} bytes, after={} bytes: {:?}",
|
|
85
|
-
corrupt.len(),
|
|
86
|
-
after.len(),
|
|
87
|
-
String::from_utf8_lossy(&after)
|
|
88
|
-
));
|
|
89
|
-
}
|
|
90
|
-
std::env::remove_var("TEAM_AGENT_TEST_PROCESS_ANCESTRY_ARGV_JSON");
|
|
91
|
-
assert!(
|
|
92
|
-
failures.is_empty(),
|
|
93
|
-
"batch4 point-1 profile fail-explicit contract failed:\n{}",
|
|
94
|
-
failures.join("\n")
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
29
|
|
|
98
30
|
/// C5-C8 + reverse cases `scope_unverifiable_when_state_read_fails_returns_structured_refusal`
|
|
99
31
|
/// / `scope_unverifiable_state_recovers_retry_passes`: with the runtime state
|
|
@@ -156,187 +88,3 @@ gate (owner-required refusal), not some degraded path; body={}",
|
|
|
156
88
|
failures.join("\n")
|
|
157
89
|
);
|
|
158
90
|
}
|
|
159
|
-
|
|
160
|
-
// ───────────────────────────────────── fixtures ─────────────────────────────────────
|
|
161
|
-
|
|
162
|
-
/// Compiled claude compatible_api team with a profile (the path that maintains the
|
|
163
|
-
/// managed `.claude.json`). Mirrors the #264 profile fixture, claude flavor.
|
|
164
|
-
fn write_claude_compatible_team(ws: &Path) -> PathBuf {
|
|
165
|
-
let team = ws.join("teamdir");
|
|
166
|
-
std::fs::create_dir_all(team.join("agents")).unwrap();
|
|
167
|
-
std::fs::create_dir_all(team.join("profiles")).unwrap();
|
|
168
|
-
std::fs::write(
|
|
169
|
-
team.join("TEAM.md"),
|
|
170
|
-
"---\nname: b4team\nobjective: batch4 profile fixture.\nprovider: claude\n---\n\nTeam.\n",
|
|
171
|
-
)
|
|
172
|
-
.unwrap();
|
|
173
|
-
std::fs::write(
|
|
174
|
-
team.join("agents/worker_a.md"),
|
|
175
|
-
"---\nname: worker_a\nrole: Compat Worker\nprovider: claude\nmodel: claude-haiku\nauth_mode: compatible_api\ndangerously_skip_permissions: false\nprofile: relay\ntools:\n - mcp_team\n---\n\nCompat worker.\n",
|
|
176
|
-
)
|
|
177
|
-
.unwrap();
|
|
178
|
-
std::fs::write(
|
|
179
|
-
team.join("profiles/relay.env"),
|
|
180
|
-
"AUTH_MODE=compatible_api\nBASE_URL=https://relay.example/v1\nAPI_KEY=sk-relay-b4\nMODEL=claude-haiku\n",
|
|
181
|
-
)
|
|
182
|
-
.unwrap();
|
|
183
|
-
let spec = team_agent::compiler::compile_team(&team).expect("compile fixture team");
|
|
184
|
-
std::fs::write(
|
|
185
|
-
team.join("team.spec.yaml"),
|
|
186
|
-
team_agent::model::yaml::dumps(&spec),
|
|
187
|
-
)
|
|
188
|
-
.unwrap();
|
|
189
|
-
team
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
mod offline_transport {
|
|
193
|
-
use super::*;
|
|
194
|
-
use std::collections::BTreeMap;
|
|
195
|
-
use std::sync::Mutex;
|
|
196
|
-
use team_agent::transport::{
|
|
197
|
-
AttachOutcome, BackendKind, CaptureRange, CapturedText, InjectPayload, InjectReport,
|
|
198
|
-
InjectStage, InjectVerification, Key, PaneField, PaneId, PaneInfo, SessionName,
|
|
199
|
-
SetEnvOutcome, SpawnResult, SubmitVerification, Target, Transport, TransportError,
|
|
200
|
-
TurnVerification, WindowName,
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
#[derive(Default)]
|
|
204
|
-
pub struct RecordingTransport {
|
|
205
|
-
session_present: Mutex<bool>,
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
impl RecordingTransport {
|
|
209
|
-
pub fn new() -> Self {
|
|
210
|
-
Self::default()
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
impl Transport for RecordingTransport {
|
|
215
|
-
fn kind(&self) -> BackendKind {
|
|
216
|
-
BackendKind::Tmux
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
fn spawn_first(
|
|
220
|
-
&self,
|
|
221
|
-
session: &SessionName,
|
|
222
|
-
window: &WindowName,
|
|
223
|
-
_argv: &[String],
|
|
224
|
-
_cwd: &Path,
|
|
225
|
-
_env: &BTreeMap<String, String>,
|
|
226
|
-
) -> Result<SpawnResult, TransportError> {
|
|
227
|
-
*self.session_present.lock().unwrap() = true;
|
|
228
|
-
Ok(SpawnResult {
|
|
229
|
-
pane_id: PaneId::new("%1"),
|
|
230
|
-
session: session.clone(),
|
|
231
|
-
window: window.clone(),
|
|
232
|
-
child_pid: None,
|
|
233
|
-
})
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
fn spawn_into(
|
|
237
|
-
&self,
|
|
238
|
-
session: &SessionName,
|
|
239
|
-
window: &WindowName,
|
|
240
|
-
argv: &[String],
|
|
241
|
-
cwd: &Path,
|
|
242
|
-
env: &BTreeMap<String, String>,
|
|
243
|
-
) -> Result<SpawnResult, TransportError> {
|
|
244
|
-
self.spawn_first(session, window, argv, cwd, env)
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
fn inject(
|
|
248
|
-
&self,
|
|
249
|
-
_target: &Target,
|
|
250
|
-
_payload: &InjectPayload,
|
|
251
|
-
_submit: Key,
|
|
252
|
-
_bracketed: bool,
|
|
253
|
-
) -> Result<InjectReport, TransportError> {
|
|
254
|
-
Ok(InjectReport {
|
|
255
|
-
stage_reached: InjectStage::Submit,
|
|
256
|
-
inject_verification: InjectVerification::CaptureContainsToken,
|
|
257
|
-
submit_verification: SubmitVerification::EnterSentWithoutPlaceholderCheck,
|
|
258
|
-
turn_verification: TurnVerification::NotYetObserved,
|
|
259
|
-
attempts: 1,
|
|
260
|
-
submit_diagnostics: None,
|
|
261
|
-
})
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
fn send_keys(&self, _target: &Target, _keys: &[Key]) -> Result<(), TransportError> {
|
|
265
|
-
Ok(())
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
fn capture(
|
|
269
|
-
&self,
|
|
270
|
-
_target: &Target,
|
|
271
|
-
range: CaptureRange,
|
|
272
|
-
) -> Result<CapturedText, TransportError> {
|
|
273
|
-
Ok(CapturedText {
|
|
274
|
-
text: "Claude Code\n> ".to_string(),
|
|
275
|
-
range,
|
|
276
|
-
})
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
fn query(
|
|
280
|
-
&self,
|
|
281
|
-
_target: &Target,
|
|
282
|
-
field: PaneField,
|
|
283
|
-
) -> Result<Option<String>, TransportError> {
|
|
284
|
-
match field {
|
|
285
|
-
PaneField::PaneWidth => Ok(Some("120".to_string())),
|
|
286
|
-
_ => Ok(None),
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
fn liveness(
|
|
291
|
-
&self,
|
|
292
|
-
_pane: &PaneId,
|
|
293
|
-
) -> Result<team_agent::transport::PaneLiveness, TransportError> {
|
|
294
|
-
Ok(team_agent::transport::PaneLiveness::Live)
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
fn list_targets(&self) -> Result<Vec<PaneInfo>, TransportError> {
|
|
298
|
-
Ok(Vec::new())
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
fn has_session(&self, _session: &SessionName) -> Result<bool, TransportError> {
|
|
302
|
-
Ok(*self.session_present.lock().unwrap())
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
fn list_windows(&self, _session: &SessionName) -> Result<Vec<WindowName>, TransportError> {
|
|
306
|
-
Ok(Vec::new())
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
fn set_session_env(
|
|
310
|
-
&self,
|
|
311
|
-
_session: &SessionName,
|
|
312
|
-
_key: &str,
|
|
313
|
-
_value: &str,
|
|
314
|
-
) -> Result<SetEnvOutcome, TransportError> {
|
|
315
|
-
Ok(SetEnvOutcome::Applied)
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
fn kill_session(&self, _session: &SessionName) -> Result<(), TransportError> {
|
|
319
|
-
Ok(())
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
fn kill_window(&self, _target: &Target) -> Result<(), TransportError> {
|
|
323
|
-
Ok(())
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
fn attach_session(&self, _session: &SessionName) -> Result<AttachOutcome, TransportError> {
|
|
327
|
-
Ok(AttachOutcome::Attached)
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
fn tmp_ws(tag: &str) -> PathBuf {
|
|
333
|
-
static N: AtomicU64 = AtomicU64::new(0);
|
|
334
|
-
let dir = std::env::temp_dir().join(format!(
|
|
335
|
-
"ta-rs-swallow-{tag}-{}-{}",
|
|
336
|
-
std::process::id(),
|
|
337
|
-
N.fetch_add(1, Ordering::Relaxed)
|
|
338
|
-
));
|
|
339
|
-
let _ = std::fs::remove_dir_all(&dir);
|
|
340
|
-
std::fs::create_dir_all(&dir).unwrap();
|
|
341
|
-
std::fs::canonicalize(dir).unwrap()
|
|
342
|
-
}
|
|
@@ -276,7 +276,7 @@ fn restart_auto_fresh_never_captured_worker_without_allow_fresh() {
|
|
|
276
276
|
"agents": {
|
|
277
277
|
"never_captured": {
|
|
278
278
|
"status": "running",
|
|
279
|
-
"provider": "
|
|
279
|
+
"provider": "copilot",
|
|
280
280
|
"session_id": null,
|
|
281
281
|
"first_send_at": null
|
|
282
282
|
}
|
|
@@ -302,15 +302,15 @@ fn restart_auto_fresh_never_captured_worker_without_allow_fresh() {
|
|
|
302
302
|
/// state — restart without --allow-fresh must STILL Refuse, never
|
|
303
303
|
/// silently fresh (architect rule: 绝不静默 fresh). This is what the
|
|
304
304
|
/// existing `upgrade_restart_refuses_interacted_worker_without_session_id`
|
|
305
|
-
/// test pins; this test pins the SAME guard for
|
|
305
|
+
/// test pins; this test pins the SAME guard for Copilot (the partial-resume
|
|
306
306
|
/// change must not weaken it for any provider).
|
|
307
307
|
#[test]
|
|
308
|
-
fn
|
|
308
|
+
fn restart_refuses_interacted_copilot_worker_without_session_id_partial_resume_preserves_guard() {
|
|
309
309
|
let state = json!({
|
|
310
310
|
"agents": {
|
|
311
311
|
"interacted_no_sid": {
|
|
312
312
|
"status": "running",
|
|
313
|
-
"provider": "
|
|
313
|
+
"provider": "copilot",
|
|
314
314
|
"session_id": null,
|
|
315
315
|
"first_send_at": "2026-06-26T01:00:00+00:00"
|
|
316
316
|
}
|
|
@@ -41,7 +41,7 @@ const TEAM_MD: &str =
|
|
|
41
41
|
|
|
42
42
|
const CODEX_ROLE: &str = "---\nname: codexer\nrole: Codex Worker\nprovider: codex\nmodel: gpt-5.5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nCodex worker.\n";
|
|
43
43
|
|
|
44
|
-
const
|
|
44
|
+
const COPILOT_ROLE: &str = "---\nname: copiloter\nrole: Copilot Worker\nprovider: copilot\nmodel: gpt-5.5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nCopilot worker.\n";
|
|
45
45
|
|
|
46
46
|
#[test]
|
|
47
47
|
#[serial(env)]
|
|
@@ -50,7 +50,7 @@ fn worker_mcp_owner_team_scope_must_match_runtime_team_key_not_spec_name() {
|
|
|
50
50
|
let team = mixed_provider_team_dir(&hermetic, "mcp-owner-scope");
|
|
51
51
|
super::launch_spawn::seed_healthy_coordinator(team.parent().unwrap());
|
|
52
52
|
let transport = RecordingTransport::new()
|
|
53
|
-
.with_windows(vec![WindowName::new("
|
|
53
|
+
.with_windows(vec![WindowName::new("copiloter"), WindowName::new("codexer")]);
|
|
54
54
|
let launch = ready_launch(
|
|
55
55
|
quick_start_with_transport(&team, None, true, None, &transport)
|
|
56
56
|
.expect("quick-start should reach worker spawn path"),
|
|
@@ -194,7 +194,8 @@ fn running_worker_state_must_only_be_written_for_windows_that_exist_after_launch
|
|
|
194
194
|
let spec_path = team.join("team.spec.yaml");
|
|
195
195
|
std::fs::write(&spec_path, team_agent::model::yaml::dumps(&spec)).expect("write spec");
|
|
196
196
|
|
|
197
|
-
// Simulates the Mac mini final capture: the codex window exists, the
|
|
197
|
+
// Simulates the Mac mini final capture: the codex window exists, the other worker's
|
|
198
|
+
// (originally Claude, here Copilot) window does not.
|
|
198
199
|
// launch_with_transport currently never verifies the post-spawn window set before persisting
|
|
199
200
|
// `status=running`, so this fixture pins the state/physical invariant directly.
|
|
200
201
|
let transport = RecordingTransport::new().with_windows(vec![WindowName::new("codexer")]);
|
|
@@ -742,8 +743,8 @@ fn mixed_provider_team_dir(hermetic: &HermeticTestEnv, tag: &str) -> PathBuf {
|
|
|
742
743
|
let team = hermetic.workspace(tag).join("teamdir");
|
|
743
744
|
std::fs::create_dir_all(team.join("agents")).expect("create agents dir");
|
|
744
745
|
std::fs::write(team.join("TEAM.md"), TEAM_MD).expect("write TEAM.md");
|
|
745
|
-
std::fs::write(team.join("agents").join("
|
|
746
|
-
.expect("write
|
|
746
|
+
std::fs::write(team.join("agents").join("copiloter.md"), COPILOT_ROLE)
|
|
747
|
+
.expect("write copiloter role");
|
|
747
748
|
std::fs::write(team.join("agents").join("codexer.md"), CODEX_ROLE).expect("write codexer role");
|
|
748
749
|
team
|
|
749
750
|
}
|
|
@@ -167,8 +167,8 @@ fn worker_spawn_scrubs_cross_provider_process_identity_but_keeps_config_env() {
|
|
|
167
167
|
("NODE_EXTRA_CA_CERTS", "/canary/ca.pem"),
|
|
168
168
|
]);
|
|
169
169
|
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
// The identity scrub is provider-agnostic; a Codex worker exercises every spawn surface.
|
|
171
|
+
let launch_team = compiled_team_dir("cross-launch", &[("worker_a", "Launch Worker")]);
|
|
172
172
|
let launch_transport = RecordingTransport::new().with_session_present(false);
|
|
173
173
|
launch_with_transport(
|
|
174
174
|
&launch_team.join("team.spec.yaml"),
|
|
@@ -179,25 +179,16 @@ fn worker_spawn_scrubs_cross_provider_process_identity_but_keeps_config_env() {
|
|
|
179
179
|
)
|
|
180
180
|
.expect("launch fixture should spawn worker");
|
|
181
181
|
|
|
182
|
-
let restart_team =
|
|
183
|
-
|
|
184
|
-
&[("worker_a", "Restart Worker")],
|
|
185
|
-
"claude",
|
|
186
|
-
);
|
|
187
|
-
seed_restart_state_as(&restart_team, "worker_a", "claude");
|
|
182
|
+
let restart_team = compiled_team_dir("cross-restart", &[("worker_a", "Restart Worker")]);
|
|
183
|
+
seed_restart_state(&restart_team, "worker_a");
|
|
188
184
|
let restart_transport = RecordingTransport::new().with_session_present(false);
|
|
189
185
|
restart_with_transport(&restart_team, true, None, &restart_transport)
|
|
190
186
|
.expect("restart fixture should spawn worker");
|
|
191
187
|
|
|
192
|
-
let add_team =
|
|
193
|
-
|
|
194
|
-
seed_running_add_agent_state_as(&add_team, "worker_a", "claude");
|
|
188
|
+
let add_team = compiled_team_dir("cross-add", &[("worker_a", "Existing Worker")]);
|
|
189
|
+
seed_running_add_agent_state(&add_team, "worker_a");
|
|
195
190
|
let role_file = add_team.parent().unwrap().join("worker_b.md");
|
|
196
|
-
std::fs::write(
|
|
197
|
-
&role_file,
|
|
198
|
-
role_doc_for_provider("worker_b", "Added Worker", "claude"),
|
|
199
|
-
)
|
|
200
|
-
.unwrap();
|
|
191
|
+
std::fs::write(&role_file, role_doc("worker_b", "Added Worker")).unwrap();
|
|
201
192
|
let add_transport = RecordingTransport::new().with_session_present(true);
|
|
202
193
|
add_agent_with_transport(
|
|
203
194
|
&add_team,
|
|
@@ -50,7 +50,6 @@ mod agent_ops;
|
|
|
50
50
|
mod b0_legacy_snapshot_nonauthority_contract;
|
|
51
51
|
mod b0_reader_hideone_audit_contract;
|
|
52
52
|
mod behavioral_diff_264_red;
|
|
53
|
-
mod claude_compatible_config_red;
|
|
54
53
|
mod claude_profile_launch_red;
|
|
55
54
|
mod cli_argv_routing_red;
|
|
56
55
|
mod clone_agent_preserves_source_tools;
|
|
@@ -77,10 +76,8 @@ mod phase_b_contracts;
|
|
|
77
76
|
mod phase_golden;
|
|
78
77
|
mod pi_catalog_red;
|
|
79
78
|
mod pi_command_red;
|
|
80
|
-
mod pi_compiler_red;
|
|
81
79
|
mod pi_dual_entry_red;
|
|
82
80
|
mod pi_executable_mcp_red;
|
|
83
|
-
mod pi_fork_session_inheritance_red;
|
|
84
81
|
mod pi_lifecycle_doctor_red;
|
|
85
82
|
mod pi_native_mcp_capability_red;
|
|
86
83
|
mod pi_session_delivery_red;
|
|
@@ -396,14 +396,6 @@ pub enum LifecycleError {
|
|
|
396
396
|
/// 编译 spec / role doc 失败(`compile_team`/`compile_role_doc_agent`)。
|
|
397
397
|
#[error("spec compile failed: {0}")]
|
|
398
398
|
Compile(String),
|
|
399
|
-
/// Pi model/schema admission failed before lifecycle reservation or writes.
|
|
400
|
-
#[error("pi model preflight failed: {requested}")]
|
|
401
|
-
PiModelPreflight {
|
|
402
|
-
requested: String,
|
|
403
|
-
candidates: Vec<String>,
|
|
404
|
-
action: String,
|
|
405
|
-
not_ready: bool,
|
|
406
|
-
},
|
|
407
399
|
/// provider 命令构造 / resume 不可用(`ResumeUnavailable`)。
|
|
408
400
|
#[error("provider error: {0}")]
|
|
409
401
|
Provider(String),
|
|
@@ -618,8 +610,8 @@ pub struct AddAgentReport {
|
|
|
618
610
|
pub role_file: PathBuf,
|
|
619
611
|
}
|
|
620
612
|
|
|
621
|
-
/// `fork_agent(...)`
|
|
622
|
-
///
|
|
613
|
+
/// `fork_agent(...)` 结果(legacy 窗口内分身)。Claude Code / Pi 的新席位 fork
|
|
614
|
+
/// 由 contract 管道直接给出回执,不经过这里。
|
|
623
615
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
624
616
|
pub struct ForkAgentReport {
|
|
625
617
|
pub source_agent_id: AgentId,
|
|
@@ -627,14 +619,6 @@ pub struct ForkAgentReport {
|
|
|
627
619
|
pub env: AgentActionEnvelope,
|
|
628
620
|
pub session_id: Option<SessionId>,
|
|
629
621
|
pub backing_state: ForkBackingState,
|
|
630
|
-
pub pi_fork: Option<PiForkDetails>,
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
634
|
-
pub struct PiForkDetails {
|
|
635
|
-
pub source_session_id: SessionId,
|
|
636
|
-
pub session_id: SessionId,
|
|
637
|
-
pub backing_path: RolloutPath,
|
|
638
622
|
}
|
|
639
623
|
|
|
640
624
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
|
@@ -114,7 +114,7 @@ impl Drop for Case {
|
|
|
114
114
|
|
|
115
115
|
#[test]
|
|
116
116
|
fn issue345_missing_mcp_config_does_not_disable_eager_admission() {
|
|
117
|
-
for provider in ["grok", "codex", "
|
|
117
|
+
for provider in ["grok", "codex", "copilot"] {
|
|
118
118
|
let mut case = Case::new();
|
|
119
119
|
case.state["agents"]["worker"]["provider"] = json!(provider);
|
|
120
120
|
case.state["agents"]["worker"]
|