@team-agent/installer 0.5.127 → 0.5.128
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/README.md +11 -0
- package/crates/team-agent/src/cli/adapters.rs +3 -13
- package/crates/team-agent/src/cli/arguments.rs +4 -0
- package/crates/team-agent/src/cli/diagnose.rs +68 -22
- package/crates/team-agent/src/cli/emit.rs +58 -26
- package/crates/team-agent/src/cli/intent/runtime.rs +32 -5
- package/crates/team-agent/src/cli/intent/runtime_tests.rs +102 -11
- package/crates/team-agent/src/cli/intent/tests.rs +10 -12
- package/crates/team-agent/src/cli/intent.rs +1 -1
- package/crates/team-agent/src/cli/mod.rs +25 -8
- package/crates/team-agent/src/cli/models.rs +764 -7
- package/crates/team-agent/src/cli/schedule.rs +175 -0
- package/crates/team-agent/src/cli/send/persist.rs +0 -36
- package/crates/team-agent/src/cli/send/presentation.rs +1 -1
- package/crates/team-agent/src/cli/send.rs +108 -110
- package/crates/team-agent/src/cli/spec.rs +6 -0
- package/crates/team-agent/src/cli/status_port/brief.rs +5 -67
- package/crates/team-agent/src/cli/tests/leader_watch.rs +12 -62
- package/crates/team-agent/src/cli/tests/mod.rs +1 -1
- package/crates/team-agent/src/cli/tests/named_address.rs +11 -10
- package/crates/team-agent/src/cli/tests/run_delegation.rs +9 -6
- package/crates/team-agent/src/cli/tests/status_send.rs +68 -271
- package/crates/team-agent/src/compiler/tests.rs +3 -18
- package/crates/team-agent/src/compiler.rs +205 -6
- package/crates/team-agent/src/contract_runtime/backend.rs +145 -11
- package/crates/team-agent/src/contract_runtime/commands.rs +7 -7
- package/crates/team-agent/src/contract_runtime/config.rs +26 -16
- package/crates/team-agent/src/contract_runtime/config_tests.rs +24 -4
- package/crates/team-agent/src/contract_runtime/discovery.rs +12 -1
- package/crates/team-agent/src/contract_runtime/fork.rs +3 -10
- package/crates/team-agent/src/contract_runtime/framework.rs +28 -11
- package/crates/team-agent/src/contract_runtime/mcp.rs +19 -24
- package/crates/team-agent/src/contract_runtime/prompt.rs +2 -2
- package/crates/team-agent/src/contract_runtime/registry.rs +56 -92
- package/crates/team-agent/src/coordinator/steps/abnormal.rs +11 -11
- package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +16 -54
- package/crates/team-agent/src/coordinator/tests/health_sync.rs +42 -0
- package/crates/team-agent/src/coordinator/tick.rs +1 -89
- package/crates/team-agent/src/db/message_store.rs +7 -65
- package/crates/team-agent/src/direct_delivery.rs +368 -0
- package/crates/team-agent/src/inbox_store.rs +169 -0
- package/crates/team-agent/src/leader/registry.rs +5 -0
- package/crates/team-agent/src/leader/start.rs +2 -1
- package/crates/team-agent/src/leader/tests/lease_api.rs +2 -2
- package/crates/team-agent/src/leader/tests/prompt_contract.rs +1 -0
- package/crates/team-agent/src/lib.rs +2 -0
- package/crates/team-agent/src/lifecycle/launch/add_agent.rs +33 -0
- package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +206 -1
- package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +28 -2
- package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +38 -13
- package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +87 -6
- package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +9 -1
- package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +351 -81
- package/crates/team-agent/src/lifecycle/launch/pi_mcp_extension.js +3 -4
- package/crates/team-agent/src/lifecycle/launch/quick_start.rs +24 -0
- package/crates/team-agent/src/lifecycle/launch/spawn.rs +36 -13
- package/crates/team-agent/src/lifecycle/launch.rs +24 -1
- package/crates/team-agent/src/lifecycle/profile_launch.rs +321 -11
- package/crates/team-agent/src/lifecycle/restart/agent.rs +1 -0
- package/crates/team-agent/src/lifecycle/restart/avatar.rs +1798 -0
- package/crates/team-agent/src/lifecycle/restart/claude_fork.rs +163 -0
- package/crates/team-agent/src/lifecycle/restart/common.rs +345 -35
- package/crates/team-agent/src/lifecycle/restart/selection.rs +5 -5
- package/crates/team-agent/src/lifecycle/restart.rs +4 -0
- package/crates/team-agent/src/lifecycle/role_config.rs +39 -14
- package/crates/team-agent/src/lifecycle/tests/claude_compatible_config_red.rs +325 -0
- package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +320 -8
- package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +236 -13
- package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +378 -4
- package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +5 -4
- package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +7 -11
- package/crates/team-agent/src/lifecycle/tests/core.rs +47 -18
- package/crates/team-agent/src/lifecycle/tests/fixtures/pi_native_mcp_host.mjs +2 -1
- package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +14 -14
- package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +60 -20
- package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +28 -26
- package/crates/team-agent/src/lifecycle/tests/mcp_tool_name_format_red.rs +6 -6
- package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +18 -6
- package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +70 -52
- package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +210 -0
- package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +157 -4
- package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +526 -10
- package/crates/team-agent/src/lifecycle/tests/pi_fork_session_inheritance_red.rs +1419 -0
- package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +68 -1
- package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +34 -12
- package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +94 -2
- package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +10 -11
- 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 +254 -2
- 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 +5 -6
- package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +16 -7
- package/crates/team-agent/src/lifecycle/tests.rs +3 -0
- package/crates/team-agent/src/lifecycle/types.rs +18 -2
- package/crates/team-agent/src/lifecycle/worker_command_context.rs +43 -50
- package/crates/team-agent/src/mcp_server/readiness.rs +130 -149
- package/crates/team-agent/src/mcp_server/readiness_tests.rs +98 -119
- package/crates/team-agent/src/mcp_server/tests/scoped.rs +21 -31
- package/crates/team-agent/src/mcp_server/tests/send.rs +72 -107
- package/crates/team-agent/src/mcp_server/tests/tools.rs +10 -12
- package/crates/team-agent/src/mcp_server/tools.rs +70 -196
- package/crates/team-agent/src/messaging/delivery.rs +160 -218
- package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +5 -5
- package/crates/team-agent/src/messaging/helpers.rs +1 -19
- package/crates/team-agent/src/messaging/mod.rs +1 -0
- package/crates/team-agent/src/messaging/reminders.rs +316 -0
- package/crates/team-agent/src/messaging/scheduler.rs +7 -1
- package/crates/team-agent/src/messaging/tests/dup_inject.rs +191 -85
- package/crates/team-agent/src/messaging/tests/runtime.rs +4 -110
- package/crates/team-agent/src/messaging/tests/spine.rs +40 -24
- package/crates/team-agent/src/messaging/types.rs +1 -0
- package/crates/team-agent/src/provider/adapter.rs +303 -51
- package/crates/team-agent/src/provider/adapters/claude.rs +78 -0
- package/crates/team-agent/src/provider/adapters/claude_fork.rs +131 -0
- package/crates/team-agent/src/provider/adapters/mod.rs +7 -5
- package/crates/team-agent/src/provider/adapters/pi.rs +106 -0
- package/crates/team-agent/src/provider/classify.rs +1 -66
- package/crates/team-agent/src/provider/model_catalog.rs +201 -13
- package/crates/team-agent/src/provider/session/capture.rs +106 -6
- package/crates/team-agent/src/provider/session/context_fork/claude.rs +123 -0
- package/crates/team-agent/src/provider/session/context_fork/outcome.rs +4 -0
- package/crates/team-agent/src/provider/session/context_fork.rs +150 -18
- package/crates/team-agent/src/provider/session_scan/claude.rs +523 -0
- package/crates/team-agent/src/provider/session_scan/common.rs +44 -8
- package/crates/team-agent/src/provider/session_scan/pi.rs +34 -1
- package/crates/team-agent/src/provider/session_scan.rs +16 -6
- package/crates/team-agent/src/provider/tests/adapter.rs +104 -17
- package/crates/team-agent/src/provider/tests/classify.rs +0 -53
- package/crates/team-agent/src/provider/tests/command_helpers.rs +12 -3
- package/crates/team-agent/src/provider/tests/idle.rs +37 -0
- package/crates/team-agent/src/provider/wire.rs +22 -34
- 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/projection.rs +1 -1
- package/crates/team-agent/src/state/repository/tests.rs +2 -2
- package/crates/team-agent/src/test_support/models_timeout_fixture.rs +144 -0
- package/crates/team-agent/src/tmux_backend/tests.rs +0 -151
- package/crates/team-agent/src/tmux_backend.rs +5 -40
- package/package.json +4 -4
- package/skills/team-agent/SKILL.md +5 -7
- package/skills/team-agent/command-coverage.json +1 -1
- package/skills/team-agent/docs/reference/team-agent-operator.md +3 -3
- package/skills/team-agent/references/team-agent-operator.md +3 -3
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
//!
|
|
1
|
+
//! Claude compatible-api profile launch contracts for Batch A Lane 2.
|
|
2
2
|
//!
|
|
3
|
-
//! The
|
|
4
|
-
//!
|
|
3
|
+
//! The entrypoints are lifecycle/CLI surfaces with a recording transport, plus the S0 public
|
|
4
|
+
//! `ProviderProfileLaunch` shape. Before S0 lands this file compile-reds on the shared type; after
|
|
5
|
+
//! S0 it behavior-reds on lifecycle/profile wiring.
|
|
5
6
|
|
|
6
7
|
#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
|
|
7
8
|
|
|
@@ -12,10 +13,117 @@ fn _hermetic_boundary_marker(_: &hermetic_guard::HermeticTestEnv) {}
|
|
|
12
13
|
|
|
13
14
|
#[path = "../../../tests/support/composite_source.rs"]
|
|
14
15
|
mod composite_source;
|
|
16
|
+
use std::collections::{BTreeMap, BTreeSet};
|
|
15
17
|
use std::path::{Path, PathBuf};
|
|
16
18
|
use std::process::Command;
|
|
19
|
+
use std::sync::atomic::{AtomicU64, Ordering};
|
|
20
|
+
use std::sync::Mutex;
|
|
17
21
|
|
|
18
22
|
use serde_json::{json, Value};
|
|
23
|
+
use serial_test::serial;
|
|
24
|
+
use team_agent::lifecycle::quick_start_with_transport_in_workspace;
|
|
25
|
+
use team_agent::provider::{ProviderCommandOverrides, ProviderProfileLaunch};
|
|
26
|
+
use team_agent::state::persist::load_runtime_state;
|
|
27
|
+
use team_agent::transport::{
|
|
28
|
+
AttachOutcome, BackendKind, CaptureRange, CapturedText, InjectPayload, InjectReport,
|
|
29
|
+
InjectStage, InjectVerification, Key, PaneField, PaneId, PaneInfo, SessionName, SetEnvOutcome,
|
|
30
|
+
SpawnResult, SubmitVerification, Target, Transport, TransportError, TurnVerification,
|
|
31
|
+
WindowName,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
#[test]
|
|
35
|
+
#[serial(env)]
|
|
36
|
+
fn compatible_api_profile_quick_start_spawns_claude_with_profile_env_and_state_metadata() {
|
|
37
|
+
let _hermetic = hermetic_guard::HermeticTestEnv::enter_with_leader("claude-profile-quick-start");
|
|
38
|
+
assert_s0_profile_launch_shape();
|
|
39
|
+
|
|
40
|
+
let ws = tmp_dir("profile-launch");
|
|
41
|
+
super::launch_spawn::seed_healthy_coordinator(&ws);
|
|
42
|
+
let team = write_claude_profile_team(&ws, "claudeprof", "clauder");
|
|
43
|
+
let transport = RecordingTransport::default();
|
|
44
|
+
|
|
45
|
+
quick_start_with_transport_in_workspace(&ws, &team, None, true, Some("claudeprof"), &transport)
|
|
46
|
+
.expect(
|
|
47
|
+
"quick-start through recording transport should reach the real lifecycle spawn path",
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
let spawn = transport.single_spawn();
|
|
51
|
+
for (key, expected) in [
|
|
52
|
+
("CLAUDE_CONFIG_DIR", None),
|
|
53
|
+
("ANTHROPIC_BASE_URL", Some("https://llm.local/v1")),
|
|
54
|
+
("ANTHROPIC_AUTH_TOKEN", Some("local-secret")),
|
|
55
|
+
("ANTHROPIC_MODEL", Some("profile-effective-haiku")),
|
|
56
|
+
] {
|
|
57
|
+
let got = spawn.env.get(key).map(String::as_str);
|
|
58
|
+
match expected {
|
|
59
|
+
Some(expected) => assert_eq!(
|
|
60
|
+
got,
|
|
61
|
+
Some(expected),
|
|
62
|
+
"Claude compatible_api profile launch must inject {key} from .team/current/profiles/local.env; env={:?}",
|
|
63
|
+
spawn.env
|
|
64
|
+
),
|
|
65
|
+
None => assert!(
|
|
66
|
+
got.is_some_and(|value| !value.is_empty()),
|
|
67
|
+
"Claude compatible_api profile launch must inject non-empty {key}; env={:?}",
|
|
68
|
+
spawn.env
|
|
69
|
+
),
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
assert!(
|
|
73
|
+
!spawn.env.contains_key("ANTHROPIC_API_KEY"),
|
|
74
|
+
"compatible_api must unset ANTHROPIC_API_KEY and use ANTHROPIC_AUTH_TOKEN instead; env={:?}",
|
|
75
|
+
spawn.env
|
|
76
|
+
);
|
|
77
|
+
assert!(
|
|
78
|
+
argv_contains_adjacent(&spawn.argv, &["--model", "profile-effective-haiku"]),
|
|
79
|
+
"profile model must become the effective Claude model when role model is null; argv={:?}",
|
|
80
|
+
spawn.argv
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
let state = load_runtime_state(&ws).unwrap();
|
|
84
|
+
let agent = &state["teams"]["claudeprof"]["agents"]["clauder"];
|
|
85
|
+
assert!(
|
|
86
|
+
agent["_pending_session_id"].as_str().is_some_and(|value| !value.is_empty()),
|
|
87
|
+
"lifecycle must persist CommandPlan.expected_session_id as agents[*]._pending_session_id; state={state}"
|
|
88
|
+
);
|
|
89
|
+
assert!(
|
|
90
|
+
agent["claude_projects_root"].as_str().is_some_and(|value| !value.is_empty()),
|
|
91
|
+
"lifecycle must persist CommandPlan.provider_projects_root/profile claude_projects_root for capture; state={state}"
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
#[ignore = "flaky under parallel suite, tracked"]
|
|
96
|
+
#[test]
|
|
97
|
+
#[serial(env)]
|
|
98
|
+
fn subscription_profile_keeps_default_claude_config_dir_for_logged_in_quota() {
|
|
99
|
+
let ws = tmp_dir("subscription-config");
|
|
100
|
+
let team = write_claude_subscription_profile_team(&ws, "subteam", "clauder");
|
|
101
|
+
let transport = RecordingTransport::default();
|
|
102
|
+
|
|
103
|
+
quick_start_with_transport_in_workspace(&ws, &team, None, true, Some("subteam"), &transport)
|
|
104
|
+
.expect("subscription profile should launch without managed config isolation");
|
|
105
|
+
|
|
106
|
+
let spawn = transport.single_spawn();
|
|
107
|
+
assert!(
|
|
108
|
+
!spawn.env.contains_key("CLAUDE_CONFIG_DIR"),
|
|
109
|
+
"subscription Claude workers must inherit the user's default ~/.claude login state; env={:?}",
|
|
110
|
+
spawn.env
|
|
111
|
+
);
|
|
112
|
+
assert!(
|
|
113
|
+
!spawn.env.contains_key("ANTHROPIC_API_KEY")
|
|
114
|
+
&& !spawn.env.contains_key("ANTHROPIC_AUTH_TOKEN"),
|
|
115
|
+
"subscription launch must not switch into API-token auth via profile env; env={:?}",
|
|
116
|
+
spawn.env
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
let state = load_runtime_state(&ws).unwrap();
|
|
120
|
+
let agent = &state["teams"]["subteam"]["agents"]["clauder"];
|
|
121
|
+
assert_eq!(
|
|
122
|
+
agent.get("claude_projects_root"),
|
|
123
|
+
None,
|
|
124
|
+
"without a supported fine-grained Claude projects-root env, subscription workers must not fake an isolated transcript root; state={state}"
|
|
125
|
+
);
|
|
126
|
+
}
|
|
19
127
|
|
|
20
128
|
#[test]
|
|
21
129
|
fn launch_restart_start_add_and_fork_all_delegate_to_the_profile_launch_resolver() {
|
|
@@ -63,7 +171,7 @@ fn launch_restart_start_add_and_fork_all_delegate_to_the_profile_launch_resolver
|
|
|
63
171
|
fn diagnose_missing_profile_is_rc1_ok_false_and_zero_token() {
|
|
64
172
|
let env = hermetic_guard::HermeticTestEnv::enter("diagnose-missing-profile");
|
|
65
173
|
let ws = env.workspace("missing-profile");
|
|
66
|
-
let team =
|
|
174
|
+
let team = write_claude_profile_team(&ws, "diagteam", "clauder");
|
|
67
175
|
std::fs::remove_file(
|
|
68
176
|
ws.join(".team")
|
|
69
177
|
.join("current")
|
|
@@ -104,26 +212,73 @@ fn diagnose_missing_profile_is_rc1_ok_false_and_zero_token() {
|
|
|
104
212
|
);
|
|
105
213
|
}
|
|
106
214
|
|
|
107
|
-
fn
|
|
215
|
+
fn assert_s0_profile_launch_shape() {
|
|
216
|
+
let profile = ProviderProfileLaunch {
|
|
217
|
+
env_overlay: BTreeMap::from([(
|
|
218
|
+
"ANTHROPIC_MODEL".to_string(),
|
|
219
|
+
"profile-effective-haiku".to_string(),
|
|
220
|
+
)]),
|
|
221
|
+
env_unset: BTreeSet::from(["ANTHROPIC_API_KEY".to_string()]),
|
|
222
|
+
command_overrides: ProviderCommandOverrides {
|
|
223
|
+
model: Some("profile-effective-haiku".to_string()),
|
|
224
|
+
..ProviderCommandOverrides::default()
|
|
225
|
+
},
|
|
226
|
+
claude_config_dir: Some(PathBuf::from("/tmp/claude-config")),
|
|
227
|
+
claude_projects_root: Some(PathBuf::from("/tmp/claude-config/projects")),
|
|
228
|
+
managed_mcp_config: true,
|
|
229
|
+
};
|
|
230
|
+
assert!(profile.managed_mcp_config);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
fn write_claude_profile_team(ws: &Path, team_key: &str, agent_id: &str) -> PathBuf {
|
|
108
234
|
let team = ws.join(team_key);
|
|
109
235
|
std::fs::create_dir_all(team.join("agents")).unwrap();
|
|
110
236
|
std::fs::create_dir_all(ws.join(".team").join("current").join("profiles")).unwrap();
|
|
111
237
|
std::fs::write(
|
|
112
238
|
ws.join(".team").join("current").join("profiles").join("local.env"),
|
|
113
|
-
"
|
|
239
|
+
"ANTHROPIC_BASE_URL=https://llm.local/v1\nANTHROPIC_AUTH_TOKEN=local-secret\nANTHROPIC_MODEL=profile-effective-haiku\nANTHROPIC_API_KEY=\n",
|
|
114
240
|
)
|
|
115
241
|
.unwrap();
|
|
116
242
|
std::fs::write(
|
|
117
243
|
team.join("TEAM.md"),
|
|
118
244
|
format!(
|
|
119
|
-
"---\nname: {team_key}\nobjective:
|
|
245
|
+
"---\nname: {team_key}\nobjective: Claude compatible profile launch contract.\nprovider: claude\nauth_mode: compatible_api\ndangerously_skip_permissions: false\n---\n\nTeam.\n"
|
|
120
246
|
),
|
|
121
247
|
)
|
|
122
248
|
.unwrap();
|
|
123
249
|
std::fs::write(
|
|
124
250
|
team.join("agents").join(format!("{agent_id}.md")),
|
|
125
251
|
format!(
|
|
126
|
-
"---\nname: {agent_id}\nrole:
|
|
252
|
+
"---\nname: {agent_id}\nrole: Claude Worker\nprovider: claude\nauth_mode: compatible_api\ndangerously_skip_permissions: false\nprofile: local\nmodel: null\ntools:\n - mcp_team\n---\n\nWorker.\n"
|
|
253
|
+
),
|
|
254
|
+
)
|
|
255
|
+
.unwrap();
|
|
256
|
+
team
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
fn write_claude_subscription_profile_team(ws: &Path, team_key: &str, agent_id: &str) -> PathBuf {
|
|
260
|
+
let team = ws.join(team_key);
|
|
261
|
+
std::fs::create_dir_all(team.join("agents")).unwrap();
|
|
262
|
+
std::fs::create_dir_all(ws.join(".team").join("current").join("profiles")).unwrap();
|
|
263
|
+
std::fs::write(
|
|
264
|
+
ws.join(".team")
|
|
265
|
+
.join("current")
|
|
266
|
+
.join("profiles")
|
|
267
|
+
.join("local.env"),
|
|
268
|
+
"AUTH_MODE=subscription\nMODEL=claude-sonnet-4-6\n",
|
|
269
|
+
)
|
|
270
|
+
.unwrap();
|
|
271
|
+
std::fs::write(
|
|
272
|
+
team.join("TEAM.md"),
|
|
273
|
+
format!(
|
|
274
|
+
"---\nname: {team_key}\nobjective: Claude subscription profile launch contract.\nprovider: claude\nauth_mode: subscription\ndangerously_skip_permissions: false\n---\n\nTeam.\n"
|
|
275
|
+
),
|
|
276
|
+
)
|
|
277
|
+
.unwrap();
|
|
278
|
+
std::fs::write(
|
|
279
|
+
team.join("agents").join(format!("{agent_id}.md")),
|
|
280
|
+
format!(
|
|
281
|
+
"---\nname: {agent_id}\nrole: Claude Worker\nprovider: claude\nauth_mode: subscription\ndangerously_skip_permissions: false\nprofile: local\nmodel: null\ntools:\n - mcp_team\n---\n\nWorker.\n"
|
|
127
282
|
),
|
|
128
283
|
)
|
|
129
284
|
.unwrap();
|
|
@@ -133,3 +288,160 @@ fn write_compatible_profile_team(ws: &Path, team_key: &str, agent_id: &str) -> P
|
|
|
133
288
|
fn source(path: &str) -> String {
|
|
134
289
|
composite_source::composite_source(path)
|
|
135
290
|
}
|
|
291
|
+
|
|
292
|
+
fn argv_contains_adjacent(hay: &[String], needle: &[&str]) -> bool {
|
|
293
|
+
hay.windows(needle.len())
|
|
294
|
+
.any(|window| window.iter().map(String::as_str).eq(needle.iter().copied()))
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
fn tmp_dir(tag: &str) -> PathBuf {
|
|
298
|
+
static N: AtomicU64 = AtomicU64::new(0);
|
|
299
|
+
let dir = std::env::temp_dir().join(format!(
|
|
300
|
+
"ta-rs-claude-profile-launch-{tag}-{}-{}",
|
|
301
|
+
std::process::id(),
|
|
302
|
+
N.fetch_add(1, Ordering::Relaxed)
|
|
303
|
+
));
|
|
304
|
+
let _ = std::fs::remove_dir_all(&dir);
|
|
305
|
+
std::fs::create_dir_all(&dir).unwrap();
|
|
306
|
+
std::fs::canonicalize(dir).unwrap()
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
#[derive(Debug, Clone)]
|
|
310
|
+
struct RecordedSpawn {
|
|
311
|
+
argv: Vec<String>,
|
|
312
|
+
env: BTreeMap<String, String>,
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
#[derive(Debug, Default)]
|
|
316
|
+
struct RecordingTransport {
|
|
317
|
+
spawns: Mutex<Vec<RecordedSpawn>>,
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
impl RecordingTransport {
|
|
321
|
+
fn single_spawn(&self) -> RecordedSpawn {
|
|
322
|
+
let spawns = self.spawns.lock().unwrap();
|
|
323
|
+
assert_eq!(
|
|
324
|
+
spawns.len(),
|
|
325
|
+
1,
|
|
326
|
+
"fixture should record one Claude worker spawn; spawns={spawns:?}"
|
|
327
|
+
);
|
|
328
|
+
spawns[0].clone()
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
impl Transport for RecordingTransport {
|
|
333
|
+
fn kind(&self) -> BackendKind {
|
|
334
|
+
BackendKind::Tmux
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
fn spawn_first(
|
|
338
|
+
&self,
|
|
339
|
+
session: &SessionName,
|
|
340
|
+
window: &WindowName,
|
|
341
|
+
argv: &[String],
|
|
342
|
+
_cwd: &Path,
|
|
343
|
+
env: &BTreeMap<String, String>,
|
|
344
|
+
) -> Result<SpawnResult, TransportError> {
|
|
345
|
+
self.spawn_into(session, window, argv, _cwd, env)
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
fn spawn_into(
|
|
349
|
+
&self,
|
|
350
|
+
session: &SessionName,
|
|
351
|
+
window: &WindowName,
|
|
352
|
+
argv: &[String],
|
|
353
|
+
_cwd: &Path,
|
|
354
|
+
env: &BTreeMap<String, String>,
|
|
355
|
+
) -> Result<SpawnResult, TransportError> {
|
|
356
|
+
let mut spawns = self.spawns.lock().unwrap();
|
|
357
|
+
spawns.push(RecordedSpawn {
|
|
358
|
+
argv: argv.to_vec(),
|
|
359
|
+
env: env.clone(),
|
|
360
|
+
});
|
|
361
|
+
Ok(SpawnResult {
|
|
362
|
+
pane_id: PaneId::new(format!("%{}", spawns.len())),
|
|
363
|
+
session: session.clone(),
|
|
364
|
+
window: window.clone(),
|
|
365
|
+
child_pid: Some(10_000 + spawns.len() as u32),
|
|
366
|
+
})
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
fn inject(
|
|
370
|
+
&self,
|
|
371
|
+
_target: &Target,
|
|
372
|
+
_payload: &InjectPayload,
|
|
373
|
+
_submit: Key,
|
|
374
|
+
_bracketed: bool,
|
|
375
|
+
) -> Result<InjectReport, TransportError> {
|
|
376
|
+
Ok(InjectReport {
|
|
377
|
+
stage_reached: InjectStage::Submit,
|
|
378
|
+
inject_verification: InjectVerification::CaptureContainsToken,
|
|
379
|
+
submit_verification: SubmitVerification::EnterSentWithoutPlaceholderCheck,
|
|
380
|
+
turn_verification: TurnVerification::NotYetObserved,
|
|
381
|
+
attempts: 1,
|
|
382
|
+
submit_diagnostics: None,
|
|
383
|
+
})
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
fn send_keys(&self, _target: &Target, _keys: &[Key]) -> Result<(), TransportError> {
|
|
387
|
+
Ok(())
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
fn capture(
|
|
391
|
+
&self,
|
|
392
|
+
_target: &Target,
|
|
393
|
+
range: CaptureRange,
|
|
394
|
+
) -> Result<CapturedText, TransportError> {
|
|
395
|
+
Ok(CapturedText {
|
|
396
|
+
text: String::new(),
|
|
397
|
+
range,
|
|
398
|
+
})
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
fn query(&self, _target: &Target, field: PaneField) -> Result<Option<String>, TransportError> {
|
|
402
|
+
match field {
|
|
403
|
+
PaneField::PaneWidth => Ok(Some("120".to_string())),
|
|
404
|
+
_ => Ok(None),
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
fn liveness(
|
|
409
|
+
&self,
|
|
410
|
+
_pane: &PaneId,
|
|
411
|
+
) -> Result<team_agent::transport::PaneLiveness, TransportError> {
|
|
412
|
+
Ok(team_agent::transport::PaneLiveness::Live)
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
fn list_targets(&self) -> Result<Vec<PaneInfo>, TransportError> {
|
|
416
|
+
Ok(Vec::new())
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
fn has_session(&self, _session: &SessionName) -> Result<bool, TransportError> {
|
|
420
|
+
Ok(false)
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
fn list_windows(&self, _session: &SessionName) -> Result<Vec<WindowName>, TransportError> {
|
|
424
|
+
Ok(Vec::new())
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
fn set_session_env(
|
|
428
|
+
&self,
|
|
429
|
+
_session: &SessionName,
|
|
430
|
+
_key: &str,
|
|
431
|
+
_value: &str,
|
|
432
|
+
) -> Result<SetEnvOutcome, TransportError> {
|
|
433
|
+
Ok(SetEnvOutcome::Applied)
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
fn kill_session(&self, _session: &SessionName) -> Result<(), TransportError> {
|
|
437
|
+
Ok(())
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
fn kill_window(&self, _target: &Target) -> Result<(), TransportError> {
|
|
441
|
+
Ok(())
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
fn attach_session(&self, _session: &SessionName) -> Result<AttachOutcome, TransportError> {
|
|
445
|
+
Ok(AttachOutcome::Attached)
|
|
446
|
+
}
|
|
447
|
+
}
|
|
@@ -210,7 +210,12 @@ fn executable(path: &Path, script: &str) {
|
|
|
210
210
|
fs::set_permissions(path, fs::Permissions::from_mode(0o755)).unwrap();
|
|
211
211
|
}
|
|
212
212
|
fn role(provider: &str, id: &str) -> String {
|
|
213
|
-
|
|
213
|
+
let model = if provider == "pi" {
|
|
214
|
+
"team-agent/qwen3.8-27b"
|
|
215
|
+
} else {
|
|
216
|
+
"gpt-5.5"
|
|
217
|
+
};
|
|
218
|
+
format!("---\nname: {id}\nrole: {id} Worker\nprovider: {provider}\nmodel: {model}\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nLiteral route worker.\n")
|
|
214
219
|
}
|
|
215
220
|
fn seed_coordinator(ws: &Path) {
|
|
216
221
|
let workspace = crate::coordinator::WorkspacePath::new(ws.to_path_buf());
|
|
@@ -556,7 +561,9 @@ fn provider_property(key: &str, provider: Provider) {
|
|
|
556
561
|
f.switch(None);
|
|
557
562
|
let actual = f.cold(wire);
|
|
558
563
|
f.seed(true, json!({"pi":["pi-must-not-leak"]}));
|
|
559
|
-
|
|
564
|
+
if provider != Provider::Pi {
|
|
565
|
+
assert_eq!(normalized(&f.cold(wire)), normalized(&base));
|
|
566
|
+
}
|
|
560
567
|
injected(&base, &[format!("route-only-{key}")], &actual);
|
|
561
568
|
assert_eq!(
|
|
562
569
|
actual
|
|
@@ -568,8 +575,11 @@ fn provider_property(key: &str, provider: Provider) {
|
|
|
568
575
|
}
|
|
569
576
|
macro_rules! provider_tests { ($($name:ident => $key:literal, $provider:ident;)*) => { $(#[test] #[serial(env)] fn $name() { provider_property($key, Provider::$provider); })* }; }
|
|
570
577
|
provider_tests! {
|
|
578
|
+
a06_claude => "claude", Claude;
|
|
579
|
+
a06_claude_code => "claude", ClaudeCode;
|
|
571
580
|
a06_copilot => "copilot", Copilot;
|
|
572
581
|
a06_gemini_cli => "gemini_cli", GeminiCli;
|
|
582
|
+
a06_pi => "pi", Pi;
|
|
573
583
|
}
|
|
574
584
|
|
|
575
585
|
#[test]
|
|
@@ -815,6 +825,79 @@ fn a09_start_fresh_missing_backing_reset_and_add_use_new_route_once() {
|
|
|
815
825
|
}
|
|
816
826
|
}
|
|
817
827
|
|
|
828
|
+
#[test]
|
|
829
|
+
#[serial(env)]
|
|
830
|
+
fn a09_resume_retains_session_metadata_while_routes_change() {
|
|
831
|
+
let f = Fixture::new("argv-resume");
|
|
832
|
+
f.start_team("pi", &["worker"]);
|
|
833
|
+
let selected = crate::state::projection::select_runtime_state(&f.ws, Some("argvteam")).unwrap();
|
|
834
|
+
// Native --session-id pins fresh seats in Pi\'s shared project session root.
|
|
835
|
+
assert!(selected["agents"]["worker"]["_pending_session_id"].as_str().is_some_and(|id| !id.is_empty()));
|
|
836
|
+
assert!(selected["agents"]["worker"]["session_id"].is_null(), "a pending native id is not a captured session");
|
|
837
|
+
let session_id = "8d6c1f2e-4a5b-4c7d-9e0f-a09000000001";
|
|
838
|
+
let session = crate::lifecycle::launch::pi_mcp::pi_seat_paths(&f.ws, "argvteam", "worker")
|
|
839
|
+
.sessions
|
|
840
|
+
.join("valid.jsonl");
|
|
841
|
+
fs::create_dir_all(session.parent().unwrap()).unwrap();
|
|
842
|
+
fs::write(&session, format!("{}\n{}\n", json!({"type":"session","version":3,"id":session_id,"cwd":f.ws,"timestamp":"2026-01-01T00:00:00Z"}), json!({"type":"message","id":"a","parentId":null,"timestamp":"2026-01-01T00:00:01Z","message":{"role":"user","content":[{"type":"text","text":"seed"}]}}))).unwrap();
|
|
843
|
+
f.mutate_agent("worker", |a| {
|
|
844
|
+
a["status"] = json!("stopped");
|
|
845
|
+
a["session_id"] = json!(session_id);
|
|
846
|
+
a["rollout_path"] = json!(session);
|
|
847
|
+
a["captured_at"] = json!("2026-01-01T00:00:01Z");
|
|
848
|
+
a["captured_via"] = json!("session_scan");
|
|
849
|
+
a["capture_state"] = json!("captured");
|
|
850
|
+
a["first_send_at"] = json!("2026-01-01T00:00:01Z");
|
|
851
|
+
});
|
|
852
|
+
f.seed(true, json!({"pi":["resume-route"]}));
|
|
853
|
+
f.switch(None);
|
|
854
|
+
let t = offline();
|
|
855
|
+
start_agent_with_transport(
|
|
856
|
+
&f.ws,
|
|
857
|
+
&AgentId::new("worker"),
|
|
858
|
+
false,
|
|
859
|
+
false,
|
|
860
|
+
false,
|
|
861
|
+
Some("argvteam"),
|
|
862
|
+
&t,
|
|
863
|
+
)
|
|
864
|
+
.unwrap();
|
|
865
|
+
assert_eq!(t.spawn_records().len(), 1);
|
|
866
|
+
let argv = t.spawn_records()[0].1.clone();
|
|
867
|
+
assert!(argv
|
|
868
|
+
.windows(2)
|
|
869
|
+
.any(|p| p[0] == "--session" && Path::new(&p[1]) == session));
|
|
870
|
+
assert!(!argv.iter().any(|v| v == "--session-id"));
|
|
871
|
+
let retained = offline().with_session_present(true);
|
|
872
|
+
let reset = reset_agent_with_transport(
|
|
873
|
+
&f.ws,
|
|
874
|
+
&AgentId::new("worker"),
|
|
875
|
+
false,
|
|
876
|
+
false,
|
|
877
|
+
Some("argvteam"),
|
|
878
|
+
&retained,
|
|
879
|
+
);
|
|
880
|
+
// Existing reset policy requires discard-session even with a valid tuple.
|
|
881
|
+
// Protect refusal; routing must not invent a retain-session reset branch.
|
|
882
|
+
assert!(matches!(
|
|
883
|
+
reset,
|
|
884
|
+
Ok(crate::lifecycle::ResetAgentOutcome::Refused { .. })
|
|
885
|
+
));
|
|
886
|
+
assert!(retained.spawn_records().is_empty());
|
|
887
|
+
let restarted = offline()
|
|
888
|
+
.with_session_present(true)
|
|
889
|
+
.with_default_liveness(crate::transport::PaneLiveness::Dead);
|
|
890
|
+
let report = restart_with_transport(&f.ws, false, Some("argvteam"), &restarted);
|
|
891
|
+
assert!(report.is_ok(), "in-session resume fixture: {report:?}");
|
|
892
|
+
assert_eq!(restarted.spawn_records().len(), 1);
|
|
893
|
+
let restart_argv = restarted.spawn_records()[0].1.clone();
|
|
894
|
+
assert!(restart_argv
|
|
895
|
+
.windows(2)
|
|
896
|
+
.any(|p| p[0] == "--session" && Path::new(&p[1]) == session));
|
|
897
|
+
assert_route(&argv, &["resume-route"]);
|
|
898
|
+
assert_route(&restart_argv, &["resume-route"]);
|
|
899
|
+
}
|
|
900
|
+
|
|
818
901
|
#[test]
|
|
819
902
|
#[serial(env)]
|
|
820
903
|
fn a09_remove_rollback_respawns_original_seat_with_route_once() {
|
|
@@ -855,6 +938,151 @@ fn a09_remove_rollback_respawns_original_seat_with_route_once() {
|
|
|
855
938
|
);
|
|
856
939
|
}
|
|
857
940
|
|
|
941
|
+
#[test]
|
|
942
|
+
#[serial(env)]
|
|
943
|
+
fn a09_pi_fork_inherits_session_and_routes_only_new_native_spawn() {
|
|
944
|
+
let f = Fixture::new("argv-fork");
|
|
945
|
+
f.start_team("pi", &["worker"]);
|
|
946
|
+
let session = crate::lifecycle::launch::pi_mcp::pi_seat_paths(&f.ws, "argvteam", "worker")
|
|
947
|
+
.sessions
|
|
948
|
+
.join("source.jsonl");
|
|
949
|
+
fs::create_dir_all(session.parent().unwrap()).unwrap();
|
|
950
|
+
let id = "fc317e54-bdbb-4ce5-8c1a-2b1bf33a9700";
|
|
951
|
+
fs::write(&session, format!("{}\n{}\n", json!({"type":"session","version":3,"id":id,"cwd":f.ws,"timestamp":"2026-01-01T00:00:00Z"}), json!({"type":"message","id":"seed01","parentId":null,"timestamp":"2026-01-01T00:00:01Z","message":{"role":"user","content":[{"type":"text","text":"fork seed"}]}}))).unwrap();
|
|
952
|
+
f.mutate_agent("worker", |a| {
|
|
953
|
+
a["session_id"] = json!(id);
|
|
954
|
+
a["rollout_path"] = json!(session);
|
|
955
|
+
a["captured_at"] = json!("2026-01-01T00:00:01Z");
|
|
956
|
+
a["captured_via"] = json!("session_scan");
|
|
957
|
+
a["capture_state"] = json!("captured");
|
|
958
|
+
});
|
|
959
|
+
let original = fs::read(&session).unwrap();
|
|
960
|
+
f.seed(true, json!({"pi":["fork-route"]}));
|
|
961
|
+
f.switch(None);
|
|
962
|
+
let t = offline().with_session_present(true);
|
|
963
|
+
let report = fork_agent_with_transport(
|
|
964
|
+
&f.ws,
|
|
965
|
+
&AgentId::new("worker"),
|
|
966
|
+
&AgentId::new("forked"),
|
|
967
|
+
None,
|
|
968
|
+
false,
|
|
969
|
+
Some("argvteam"),
|
|
970
|
+
&t,
|
|
971
|
+
);
|
|
972
|
+
assert!(
|
|
973
|
+
report.is_ok(),
|
|
974
|
+
"valid v3 Pi fork must reach native spawn: {report:?}"
|
|
975
|
+
);
|
|
976
|
+
assert_eq!(t.spawn_records().len(), 1);
|
|
977
|
+
assert_route(&t.spawn_records()[0].1, &["fork-route"]);
|
|
978
|
+
assert_eq!(fs::read(session).unwrap(), original);
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
#[test]
|
|
982
|
+
#[serial(env)]
|
|
983
|
+
fn a09_claude_fork_spawns_native_fork_seat_and_leaves_source_unchanged() {
|
|
984
|
+
let f = Fixture::new("argv-claude-fork");
|
|
985
|
+
f.start_team("claude", &["worker"]);
|
|
986
|
+
let parent = "11111111-2222-4333-8444-555555555555";
|
|
987
|
+
let transcript = f.ws.join("parent-transcript.jsonl");
|
|
988
|
+
fs::write(&transcript, "{\"type\":\"user\"}\n").unwrap();
|
|
989
|
+
f.mutate_agent("worker", |a| {
|
|
990
|
+
a["session_id"] = json!(parent);
|
|
991
|
+
a["rollout_path"] = json!(transcript);
|
|
992
|
+
a["captured_at"] = json!("2026-01-01T00:00:01Z");
|
|
993
|
+
a["captured_via"] = json!("session_scan");
|
|
994
|
+
a["capture_state"] = json!("captured");
|
|
995
|
+
});
|
|
996
|
+
let tuple = |state: &Value| {
|
|
997
|
+
["session_id", "rollout_path", "captured_at", "captured_via"]
|
|
998
|
+
.map(|key| state["agents"]["worker"][key].clone())
|
|
999
|
+
};
|
|
1000
|
+
let before =
|
|
1001
|
+
tuple(&crate::state::projection::select_runtime_state(&f.ws, Some("argvteam")).unwrap());
|
|
1002
|
+
|
|
1003
|
+
// No in-place branch: the same id is refused before any key or spawn.
|
|
1004
|
+
let same = offline().with_session_present(true);
|
|
1005
|
+
let refused = fork_agent_with_transport(
|
|
1006
|
+
&f.ws,
|
|
1007
|
+
&AgentId::new("worker"),
|
|
1008
|
+
&AgentId::new("worker"),
|
|
1009
|
+
None,
|
|
1010
|
+
false,
|
|
1011
|
+
Some("argvteam"),
|
|
1012
|
+
&same,
|
|
1013
|
+
);
|
|
1014
|
+
assert!(format!("{refused:?}").contains("new seat"), "{refused:?}");
|
|
1015
|
+
assert!(same.spawn_records().is_empty() && same.inject_payloads().is_empty());
|
|
1016
|
+
|
|
1017
|
+
let t = offline().with_session_present(true);
|
|
1018
|
+
let report = fork_agent_with_transport(
|
|
1019
|
+
&f.ws,
|
|
1020
|
+
&AgentId::new("worker"),
|
|
1021
|
+
&AgentId::new("forked"),
|
|
1022
|
+
None,
|
|
1023
|
+
false,
|
|
1024
|
+
Some("argvteam"),
|
|
1025
|
+
&t,
|
|
1026
|
+
)
|
|
1027
|
+
.expect("a legacy Claude seat forks into a new seat in one call");
|
|
1028
|
+
assert_eq!(report.new_agent_id.as_str(), "forked");
|
|
1029
|
+
// The shim never writes the child transcript: pending, never a fabricated id.
|
|
1030
|
+
assert_eq!(
|
|
1031
|
+
report.backing_state,
|
|
1032
|
+
crate::lifecycle::ForkBackingState::PendingContextFork
|
|
1033
|
+
);
|
|
1034
|
+
assert!(report.session_id.is_none());
|
|
1035
|
+
let spawns = t.spawn_records();
|
|
1036
|
+
assert_eq!(spawns.len(), 1);
|
|
1037
|
+
let argv = &spawns[0].1;
|
|
1038
|
+
let after = |flag: &str| {
|
|
1039
|
+
argv.iter()
|
|
1040
|
+
.position(|value| value == flag)
|
|
1041
|
+
.and_then(|index| argv.get(index + 1))
|
|
1042
|
+
.cloned()
|
|
1043
|
+
};
|
|
1044
|
+
assert_eq!(after("--resume").as_deref(), Some(parent), "{argv:?}");
|
|
1045
|
+
assert!(
|
|
1046
|
+
argv.iter().any(|value| value == "--fork-session"),
|
|
1047
|
+
"{argv:?}"
|
|
1048
|
+
);
|
|
1049
|
+
let child = after("--session-id").expect("preassigned child session");
|
|
1050
|
+
assert_ne!(child, parent);
|
|
1051
|
+
|
|
1052
|
+
let state = crate::state::projection::select_runtime_state(&f.ws, Some("argvteam")).unwrap();
|
|
1053
|
+
let row = &state["agents"]["forked"];
|
|
1054
|
+
assert_eq!(row["provider"], "claude", "{row}");
|
|
1055
|
+
assert_eq!(row["status"], "running", "{row}");
|
|
1056
|
+
assert_eq!(row["_pending_session_id"], json!(child), "{row}");
|
|
1057
|
+
assert!(
|
|
1058
|
+
row.get("_fork_parent_session_id").is_none(),
|
|
1059
|
+
"one-shot fork instruction: {row}"
|
|
1060
|
+
);
|
|
1061
|
+
assert!(
|
|
1062
|
+
row.get("forked_from").is_none(),
|
|
1063
|
+
"capture must own the new row: {row}"
|
|
1064
|
+
);
|
|
1065
|
+
assert_eq!(tuple(&state), before, "the parent tuple is only read");
|
|
1066
|
+
assert_eq!(
|
|
1067
|
+
fs::read_to_string(&transcript).unwrap(),
|
|
1068
|
+
"{\"type\":\"user\"}\n"
|
|
1069
|
+
);
|
|
1070
|
+
let events = crate::event_log::EventLog::new(&f.ws).tail(0).unwrap();
|
|
1071
|
+
let spawn = events
|
|
1072
|
+
.iter()
|
|
1073
|
+
.rev()
|
|
1074
|
+
.find(|event| {
|
|
1075
|
+
event["event"] == "provider.worker.spawn_argv" && event["agent_id"] == "forked"
|
|
1076
|
+
})
|
|
1077
|
+
.expect("fork spawn argv event");
|
|
1078
|
+
assert!(
|
|
1079
|
+
spawn["env_overlay_keys"].as_array().is_some_and(|keys| keys
|
|
1080
|
+
.iter()
|
|
1081
|
+
.any(|key| key == "CLAUDE_CODE_RESUME_THRESHOLD_MINUTES")),
|
|
1082
|
+
"a fork never stops on the stale-resume modal: {spawn}"
|
|
1083
|
+
);
|
|
1084
|
+
}
|
|
1085
|
+
|
|
858
1086
|
#[test]
|
|
859
1087
|
#[serial(env)]
|
|
860
1088
|
fn a09_public_clone_reaches_native_argv_without_inheriting_old_route() {
|
|
@@ -1073,14 +1301,8 @@ fn a13_materializer_version_catalog_and_nonagent_command_builders_are_not_routed
|
|
|
1073
1301
|
json!({"pi":["--mode","rpc"],"copilot":["must-not-pollute-probe"]}),
|
|
1074
1302
|
);
|
|
1075
1303
|
f.switch(None);
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
}
|
|
1079
|
-
// The Pi leader plan is the remaining Pi materializer (version + catalog probes).
|
|
1080
|
-
let plan = f.leader(Provider::Pi, true, false).unwrap();
|
|
1081
|
-
unsafe {
|
|
1082
|
-
std::env::remove_var("TMUX");
|
|
1083
|
-
}
|
|
1304
|
+
let base = f.cold("pi");
|
|
1305
|
+
let _ = crate::lifecycle::launch::pi_mcp::pi_model_candidates("team-agent/qwen3.8-27b");
|
|
1084
1306
|
let probes = fs::read_to_string(&f.probes).unwrap();
|
|
1085
1307
|
assert!(probes.contains("--version"));
|
|
1086
1308
|
assert!(probes.contains("--list-models"));
|
|
@@ -1091,7 +1313,7 @@ fn a13_materializer_version_catalog_and_nonagent_command_builders_are_not_routed
|
|
|
1091
1313
|
!f.native_file().exists(),
|
|
1092
1314
|
"plan/materializer must not execute native provider session"
|
|
1093
1315
|
);
|
|
1094
|
-
assert_route(&
|
|
1316
|
+
assert_route(&base, &["--mode", "rpc"]);
|
|
1095
1317
|
}
|
|
1096
1318
|
|
|
1097
1319
|
#[test]
|
|
@@ -1376,10 +1598,11 @@ fn a15_route_does_not_relax_running_start_reset_discard_or_unsupported_fork() {
|
|
|
1376
1598
|
fn a16_cold_spawn_refuses_retired_or_missing_worker_provider_before_any_pane() {
|
|
1377
1599
|
use crate::model::yaml::Value as Yaml;
|
|
1378
1600
|
// A pre-upgrade spec agent naming a retired legacy key, or naming no
|
|
1379
|
-
// provider at all, never falls back to a legacy engine.
|
|
1601
|
+
// provider at all, never falls back to a legacy engine. `grok` is a
|
|
1602
|
+
// runtime alias of grok_build, so it takes the native route instead.
|
|
1380
1603
|
for (tag, provider, expected) in [
|
|
1381
1604
|
("argv-retired-codex", Some("codex"), "legacy codex seat has no runtime in this release"),
|
|
1382
|
-
("argv-
|
|
1605
|
+
("argv-native-grok", Some("grok"), "no legacy fallback"),
|
|
1383
1606
|
("argv-missing-provider", None, "unknown worker provider \"\""),
|
|
1384
1607
|
] {
|
|
1385
1608
|
let f = Fixture::new(tag);
|