@team-agent/installer 0.5.125 → 0.5.127
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +1 -1
- package/Cargo.toml +1 -1
- package/crates/team-agent/src/cli/diagnose.rs +0 -137
- package/crates/team-agent/src/cli/emit.rs +13 -8
- package/crates/team-agent/src/cli/grok_slot.rs +88 -3
- package/crates/team-agent/src/cli/intent/runtime.rs +6 -4
- package/crates/team-agent/src/cli/intent/runtime_tests.rs +55 -10
- package/crates/team-agent/src/cli/mod.rs +35 -29
- package/crates/team-agent/src/cli/models.rs +33 -944
- package/crates/team-agent/src/cli/tests/leader_watch.rs +1 -1
- package/crates/team-agent/src/cli/tests/mod.rs +3 -3
- package/crates/team-agent/src/cli/tests/run_delegation.rs +8 -7
- package/crates/team-agent/src/cli/tests/status_send.rs +2 -2
- package/crates/team-agent/src/compiler/tests.rs +54 -12
- package/crates/team-agent/src/compiler.rs +7 -205
- package/crates/team-agent/src/contract_runtime/backend.rs +97 -38
- package/crates/team-agent/src/contract_runtime/commands.rs +335 -4
- package/crates/team-agent/src/contract_runtime/config.rs +12 -8
- package/crates/team-agent/src/contract_runtime/fork.rs +368 -0
- package/crates/team-agent/src/contract_runtime/framework.rs +8 -13
- package/crates/team-agent/src/contract_runtime/mod.rs +1 -0
- package/crates/team-agent/src/contract_runtime/registry.rs +100 -60
- package/crates/team-agent/src/coordinator/steps/abnormal.rs +45 -5
- package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +54 -16
- package/crates/team-agent/src/coordinator/tests/energy.rs +4 -4
- package/crates/team-agent/src/coordinator/tests/health_sync.rs +2 -44
- package/crates/team-agent/src/coordinator/tests/main_preserved.rs +2 -2
- package/crates/team-agent/src/coordinator/tests/spine.rs +1 -1
- package/crates/team-agent/src/coordinator/tests/takeover.rs +3 -3
- package/crates/team-agent/src/leader/start.rs +1 -1
- package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +2 -195
- package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +11 -27
- package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +22 -200
- package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +6 -87
- package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +5 -496
- package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +74 -244
- package/crates/team-agent/src/lifecycle/launch/quick_start.rs +2 -26
- package/crates/team-agent/src/lifecycle/launch/role_source.rs +5 -0
- package/crates/team-agent/src/lifecycle/launch/spawn.rs +26 -51
- package/crates/team-agent/src/lifecycle/launch.rs +3 -34
- package/crates/team-agent/src/lifecycle/profile_launch.rs +18 -373
- package/crates/team-agent/src/lifecycle/restart/common.rs +45 -463
- package/crates/team-agent/src/lifecycle/restart/remove.rs +129 -0
- package/crates/team-agent/src/lifecycle/restart/selection.rs +5 -5
- package/crates/team-agent/src/lifecycle/restart.rs +0 -2
- package/crates/team-agent/src/lifecycle/role_config.rs +40 -13
- package/crates/team-agent/src/lifecycle/tests/acceptance_b_batch_red.rs +1 -1
- package/crates/team-agent/src/lifecycle/tests/agent_ops.rs +8 -12
- package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +38 -236
- package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +8 -320
- package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +106 -186
- package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +4 -334
- package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +19 -15
- package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +2 -2
- package/crates/team-agent/src/lifecycle/tests/core.rs +33 -58
- package/crates/team-agent/src/lifecycle/tests/f032_startup_prompt_best_effort_red.rs +22 -8
- package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +15 -133
- package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +3 -51
- package/crates/team-agent/src/lifecycle/tests/host_cotenant_death_p0_contract.rs +30 -67
- package/crates/team-agent/src/lifecycle/tests/issue238_codex_effort_contract.rs +3 -31
- package/crates/team-agent/src/lifecycle/tests/lane_ops.rs +194 -169
- package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +162 -284
- package/crates/team-agent/src/lifecycle/tests/lifecycle_rollback_red.rs +15 -78
- package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +7 -7
- package/crates/team-agent/src/lifecycle/tests/phase_b_contracts.rs +75 -69
- package/crates/team-agent/src/lifecycle/tests/phase_golden.rs +2 -10
- package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +6 -18
- package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +52 -70
- package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +4 -157
- package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +10 -302
- package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +1 -68
- package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +1 -19
- package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +2 -100
- package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +15 -14
- package/crates/team-agent/src/lifecycle/tests/restart.rs +12 -153
- package/crates/team-agent/src/lifecycle/tests/restart_build_before_destroy_0540_contract.rs +27 -5
- package/crates/team-agent/src/lifecycle/tests/restart_liveness_red.rs +59 -10
- package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +47 -6
- package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +3 -1478
- package/crates/team-agent/src/lifecycle/tests/resume_recover_red.rs +27 -10
- package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +7 -7
- package/crates/team-agent/src/lifecycle/tests/subprep_codex_trust_roundtrip_red.rs +67 -313
- package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +2 -254
- package/crates/team-agent/src/lifecycle/tests/team_in_team_identity_scope_red.rs +2 -2
- package/crates/team-agent/src/lifecycle/tests/team_in_team_sibling_quick_start_red.rs +1 -1
- package/crates/team-agent/src/lifecycle/tests/team_in_team_state_scope_red.rs +2 -2
- package/crates/team-agent/src/lifecycle/tests/team_key_retirement_txn_red.rs +4 -4
- package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +74 -19
- package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +39 -38
- package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +42 -97
- package/crates/team-agent/src/lifecycle/tests.rs +0 -7
- package/crates/team-agent/src/lifecycle/types.rs +2 -21
- package/crates/team-agent/src/mcp_server/readiness_tests.rs +15 -17
- package/crates/team-agent/src/messaging/delivery.rs +14 -195
- package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +5 -5
- package/crates/team-agent/src/messaging/tests/dup_inject.rs +68 -69
- package/crates/team-agent/src/messaging/tests/main_preserved.rs +2 -2
- package/crates/team-agent/src/messaging/tests/runtime.rs +5 -5
- package/crates/team-agent/src/messaging/tests/spine.rs +30 -32
- package/crates/team-agent/src/messaging/tests/wave2.rs +13 -20
- package/crates/team-agent/src/provider/adapter.rs +71 -572
- package/crates/team-agent/src/provider/adapters/mod.rs +6 -8
- package/crates/team-agent/src/provider/model_catalog.rs +13 -201
- package/crates/team-agent/src/provider/session/capture.rs +11 -211
- package/crates/team-agent/src/provider/session/context_fork/outcome.rs +8 -24
- package/crates/team-agent/src/provider/session/context_fork.rs +29 -240
- package/crates/team-agent/src/provider/session/mod.rs +2 -3
- package/crates/team-agent/src/provider/session_scan/common.rs +27 -87
- package/crates/team-agent/src/provider/session_scan/pi.rs +1 -34
- package/crates/team-agent/src/provider/session_scan.rs +7 -23
- package/crates/team-agent/src/provider/tests/adapter.rs +66 -204
- package/crates/team-agent/src/provider/tests/command_helpers.rs +3 -29
- package/crates/team-agent/src/provider/tests/idle.rs +0 -68
- package/crates/team-agent/src/provider/types.rs +0 -4
- package/crates/team-agent/src/provider/wire.rs +77 -23
- package/crates/team-agent/src/state/abnormal_watch/tests/mod.rs +1 -1
- package/crates/team-agent/src/state/persist.rs +6 -6
- package/crates/team-agent/src/state/repository/tests.rs +2 -2
- package/crates/team-agent/src/tmux_backend.rs +4 -3
- package/package.json +4 -4
- package/skills/team-agent/SKILL.md +8 -5
- package/skills/team-agent/command-coverage.json +29 -1
- package/skills/team-agent/docs/reference/team-agent-operator.md +7 -3
- package/skills/team-agent/references/team-agent-operator.md +7 -3
- package/crates/team-agent/src/lifecycle/launch/grok_per_seat.rs +0 -260
- package/crates/team-agent/src/lifecycle/restart/avatar.rs +0 -1805
- package/crates/team-agent/src/lifecycle/tests/claude_compatible_config_red.rs +0 -325
- package/crates/team-agent/src/lifecycle/tests/codex_weak_window_attribution_red.rs +0 -683
- package/crates/team-agent/src/lifecycle/tests/grok_effort_argv_red.rs +0 -247
- package/crates/team-agent/src/lifecycle/tests/grok_mcp_overlay_red.rs +0 -507
- package/crates/team-agent/src/lifecycle/tests/grok_restart_resume_red.rs +0 -300
- package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +0 -210
- package/crates/team-agent/src/lifecycle/tests/pi_fork_session_inheritance_red.rs +0 -1409
- package/crates/team-agent/src/provider/adapters/claude.rs +0 -78
- package/crates/team-agent/src/provider/adapters/claude_fork.rs +0 -131
- package/crates/team-agent/src/provider/adapters/codex.rs +0 -101
- package/crates/team-agent/src/provider/adapters/grok.rs +0 -67
- package/crates/team-agent/src/provider/adapters/pi.rs +0 -100
- package/crates/team-agent/src/provider/session/context_fork/claude.rs +0 -123
- package/crates/team-agent/src/provider/session/context_fork/codex.rs +0 -514
- package/crates/team-agent/src/provider/session_scan/claude.rs +0 -523
- package/crates/team-agent/src/provider/session_scan/codex.rs +0 -326
- package/crates/team-agent/src/provider/session_scan/grok.rs +0 -288
- package/crates/team-agent/src/test_support/models_timeout_fixture.rs +0 -144
|
@@ -3,34 +3,29 @@ use super::*;
|
|
|
3
3
|
|
|
4
4
|
// ═════════════════════════════════════════════════════════════════════════
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// Fork sources run on `copilot`, the legacy provider whose adapter still claims native fork, so a
|
|
7
|
+
// refusal from the legacy fork entry cannot be explained by a missing capability.
|
|
8
|
+
pub(super) const COPILOT_ROLE_ALPHA: &str = "---\nname: alpha\nrole: Alpha Worker\nprovider: copilot\nmodel: gpt-5.5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nAlpha.\n";
|
|
9
|
+
const DELEG_ROLE_ALPHA_COMPAT: &str = "---\nname: alpha\nrole: Alpha Worker\nprovider: copilot\nmodel: gpt-5.5\nauth_mode: compatible_api\ndangerously_skip_permissions: false\nprofile: alpha-compat\ntools:\n - mcp_team\n---\n\nAlpha.\n";
|
|
10
|
+
|
|
11
|
+
/// The legacy fork entry never forks in-window and never substitutes a fresh replacement: a
|
|
12
|
+
/// non-retired legacy row is refused as unverified, naming its provider.
|
|
13
|
+
pub(super) fn assert_legacy_fork_unverified<T: std::fmt::Debug>(
|
|
14
|
+
result: &Result<T, LifecycleError>,
|
|
15
|
+
provider: &str,
|
|
16
|
+
) {
|
|
17
|
+
let expected = format!(
|
|
18
|
+
"{provider} native session fork is unverified (未验证); no legacy fork or fresh replacement was performed"
|
|
19
|
+
);
|
|
20
|
+
assert!(
|
|
21
|
+
matches!(result, Err(LifecycleError::Provider(message)) if *message == expected),
|
|
22
|
+
"the legacy fork entry must refuse a {provider} row as unverified; got {result:?}"
|
|
23
|
+
);
|
|
24
|
+
}
|
|
7
25
|
|
|
8
26
|
type LaneKills = std::sync::Arc<std::sync::Mutex<Vec<String>>>;
|
|
9
27
|
pub(super) type LaneSpawns = std::sync::Arc<std::sync::Mutex<Vec<(String, Vec<String>)>>>;
|
|
10
28
|
|
|
11
|
-
fn emit_codex_fork_backing(argv: &[String], cwd: &std::path::Path) {
|
|
12
|
-
if !argv.windows(2).any(|pair| pair == ["codex", "fork"]) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
static SESSION_SEQ: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);
|
|
16
|
-
let sequence = SESSION_SEQ.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
|
|
17
|
-
let session_id = format!("lane-fork-{}-{sequence}", std::process::id());
|
|
18
|
-
let root = std::env::var_os("HOME")
|
|
19
|
-
.map(std::path::PathBuf::from)
|
|
20
|
-
.unwrap_or_else(|| std::path::PathBuf::from("."))
|
|
21
|
-
.join(".codex/sessions/lane-fixture");
|
|
22
|
-
std::fs::create_dir_all(&root).unwrap();
|
|
23
|
-
std::fs::write(
|
|
24
|
-
root.join(format!("rollout-{session_id}.jsonl")),
|
|
25
|
-
format!(
|
|
26
|
-
"{{\"session_meta\":{{\"payload\":{{\"id\":\"{session_id}\",\"cwd\":\"{}\"}}}},\"created_at\":\"{}\"}}\n",
|
|
27
|
-
cwd.to_string_lossy(),
|
|
28
|
-
chrono::Utc::now().to_rfc3339()
|
|
29
|
-
),
|
|
30
|
-
)
|
|
31
|
-
.unwrap();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
29
|
pub(super) struct LaneHomeGuard {
|
|
35
30
|
previous: Option<std::ffi::OsString>,
|
|
36
31
|
root: PathBuf,
|
|
@@ -116,14 +111,13 @@ impl crate::transport::Transport for LaneTransport {
|
|
|
116
111
|
session: &crate::transport::SessionName,
|
|
117
112
|
window: &crate::transport::WindowName,
|
|
118
113
|
argv: &[String],
|
|
119
|
-
|
|
114
|
+
_c: &std::path::Path,
|
|
120
115
|
_e: &std::collections::BTreeMap<String, String>,
|
|
121
116
|
) -> Result<crate::transport::SpawnResult, crate::transport::TransportError> {
|
|
122
117
|
self.spawn_observed_at
|
|
123
118
|
.lock()
|
|
124
119
|
.unwrap()
|
|
125
120
|
.push(chrono::Utc::now().to_rfc3339());
|
|
126
|
-
emit_codex_fork_backing(argv, c);
|
|
127
121
|
self.spawns
|
|
128
122
|
.lock()
|
|
129
123
|
.unwrap()
|
|
@@ -152,14 +146,13 @@ impl crate::transport::Transport for LaneTransport {
|
|
|
152
146
|
session: &crate::transport::SessionName,
|
|
153
147
|
window: &crate::transport::WindowName,
|
|
154
148
|
argv: &[String],
|
|
155
|
-
|
|
149
|
+
_c: &std::path::Path,
|
|
156
150
|
_e: &std::collections::BTreeMap<String, String>,
|
|
157
151
|
) -> Result<crate::transport::SpawnResult, crate::transport::TransportError> {
|
|
158
152
|
self.spawn_observed_at
|
|
159
153
|
.lock()
|
|
160
154
|
.unwrap()
|
|
161
155
|
.push(chrono::Utc::now().to_rfc3339());
|
|
162
|
-
emit_codex_fork_backing(argv, c);
|
|
163
156
|
self.spawns
|
|
164
157
|
.lock()
|
|
165
158
|
.unwrap()
|
|
@@ -207,11 +200,12 @@ impl crate::transport::Transport for LaneTransport {
|
|
|
207
200
|
Ok(crate::transport::CapturedText {
|
|
208
201
|
// A fresh worker has reached the ready prompt by the time this
|
|
209
202
|
// deterministic lifecycle replay observes its pane. Returning
|
|
210
|
-
// the stable ready marker
|
|
203
|
+
// the stable Copilot ready marker (the remaining legacy provider
|
|
204
|
+
// with a startup-prompt handler) keeps the replay focused on the
|
|
211
205
|
// single-lock transaction instead of burning the provider's
|
|
212
206
|
// bounded startup-prompt polling interval on an unobservable
|
|
213
207
|
// empty screen.
|
|
214
|
-
text:
|
|
208
|
+
text: crate::provider::COPILOT_READY_MARKER.to_string(),
|
|
215
209
|
range: r,
|
|
216
210
|
})
|
|
217
211
|
}
|
|
@@ -423,7 +417,7 @@ fn lanea_one_agent_ws(alpha_status: &str) -> PathBuf {
|
|
|
423
417
|
std::fs::write(ws.join("agents").join("alpha.md"), DELEG_ROLE_ALPHA).unwrap();
|
|
424
418
|
let spec = crate::compiler::compile_team(&ws).expect("compile 1-agent team");
|
|
425
419
|
std::fs::write(ws.join("team.spec.yaml"), crate::model::yaml::dumps(&spec)).unwrap();
|
|
426
|
-
crate::state::persist::save_runtime_state(&ws, &json!({ "session_name": "team-laneateam", "agents": { "alpha": { "status": alpha_status, "provider": "
|
|
420
|
+
crate::state::persist::save_runtime_state(&ws, &json!({ "session_name": "team-laneateam", "agents": { "alpha": { "status": alpha_status, "provider": "fake", "window": "alpha" } } })).unwrap();
|
|
427
421
|
ws
|
|
428
422
|
}
|
|
429
423
|
|
|
@@ -484,8 +478,8 @@ fn remove_agent_from_fixture_state(ws: &std::path::Path, agent_id: &str) {
|
|
|
484
478
|
fn force_remove_reconciles_all_seat_quadrants_without_cross_team_same_name_kill() {
|
|
485
479
|
for quadrant in ["state-only", "spec-only", "physical-only", "mixed"] {
|
|
486
480
|
let ws = lanea_ws_agents(json!({
|
|
487
|
-
"alpha": { "status": "stopped", "provider": "
|
|
488
|
-
"bravo": { "status": "running", "provider": "
|
|
481
|
+
"alpha": { "status": "stopped", "provider": "fake", "window": "alpha" },
|
|
482
|
+
"bravo": { "status": "running", "provider": "fake", "window": "bravo" }
|
|
489
483
|
}));
|
|
490
484
|
let local_physical = matches!(quadrant, "physical-only");
|
|
491
485
|
let tx = LaneTransport::new(
|
|
@@ -555,8 +549,8 @@ fn force_remove_reconciles_all_seat_quadrants_without_cross_team_same_name_kill(
|
|
|
555
549
|
#[test]
|
|
556
550
|
fn remove_persists_retired_tombstone_and_explicit_readd_clears_it() {
|
|
557
551
|
let ws = lanea_ws_agents(json!({
|
|
558
|
-
"alpha": { "status": "stopped", "provider": "
|
|
559
|
-
"bravo": { "status": "running", "provider": "
|
|
552
|
+
"alpha": { "status": "stopped", "provider": "fake", "window": "alpha" },
|
|
553
|
+
"bravo": { "status": "running", "provider": "fake", "window": "bravo" }
|
|
560
554
|
}));
|
|
561
555
|
let mut seeded = crate::state::persist::load_runtime_state(&ws).unwrap();
|
|
562
556
|
seeded["team_key"] = json!("laneateam");
|
|
@@ -640,6 +634,96 @@ fn remove_persists_retired_tombstone_and_explicit_readd_clears_it() {
|
|
|
640
634
|
);
|
|
641
635
|
}
|
|
642
636
|
|
|
637
|
+
/// #391: remove-agent keeps the user's role file and leaves a retired
|
|
638
|
+
/// tombstone. `add-agent --force` without `--role-file` must re-adopt that
|
|
639
|
+
/// file instead of refusing "role file already exists" forever.
|
|
640
|
+
#[test]
|
|
641
|
+
#[serial_test::serial(env)]
|
|
642
|
+
fn issue391_force_readd_adopts_the_role_file_a_removed_seat_left_behind() {
|
|
643
|
+
let ws = lanea_ws_agents(json!({
|
|
644
|
+
"alpha": { "status": "stopped", "provider": "fake", "window": "alpha" },
|
|
645
|
+
"bravo": { "status": "running", "provider": "fake", "window": "bravo" }
|
|
646
|
+
}));
|
|
647
|
+
let mut seeded = crate::state::persist::load_runtime_state(&ws).unwrap();
|
|
648
|
+
seeded["team_key"] = json!("laneateam");
|
|
649
|
+
seeded["active_team_key"] = json!("laneateam");
|
|
650
|
+
let mut nested = crate::state::projection::compact_team_state(&seeded);
|
|
651
|
+
nested["status"] = json!("alive");
|
|
652
|
+
seeded["teams"] = json!({ "laneateam": nested });
|
|
653
|
+
crate::state::persist::save_runtime_state(&ws, &seeded).unwrap();
|
|
654
|
+
let tx = LaneTransport::new("team-laneateam", &[]);
|
|
655
|
+
let role = ws.join("agents").join("alpha.md");
|
|
656
|
+
let load = || crate::state::persist::load_runtime_state(&ws).unwrap();
|
|
657
|
+
let add = |patch: &crate::lifecycle::role_config::RoleConfigPatch, force: bool| {
|
|
658
|
+
crate::lifecycle::role_config::add_agent_from_role_with_transport(
|
|
659
|
+
&ws,
|
|
660
|
+
&aid("alpha"),
|
|
661
|
+
None,
|
|
662
|
+
patch,
|
|
663
|
+
force,
|
|
664
|
+
&tx,
|
|
665
|
+
)
|
|
666
|
+
};
|
|
667
|
+
let same = crate::lifecycle::role_config::RoleConfigPatch {
|
|
668
|
+
provider: Some("fake".into()),
|
|
669
|
+
bypass: Some(false),
|
|
670
|
+
..Default::default()
|
|
671
|
+
};
|
|
672
|
+
|
|
673
|
+
remove_agent_with_transport(&ws, &aid("alpha"), true, true, None, &tx).unwrap();
|
|
674
|
+
assert_eq!(std::fs::read_to_string(&role).unwrap(), DELEG_ROLE_ALPHA);
|
|
675
|
+
assert_eq!(
|
|
676
|
+
load()["teams"]["laneateam"]["agent_lifecycle"]["alpha"]["state"],
|
|
677
|
+
"retired"
|
|
678
|
+
);
|
|
679
|
+
|
|
680
|
+
let refused = add(&same, false).unwrap_err().to_string();
|
|
681
|
+
assert!(
|
|
682
|
+
refused.contains("role file already exists") && refused.contains("--force"),
|
|
683
|
+
"without --force the refusal names a real way out: {refused}"
|
|
684
|
+
);
|
|
685
|
+
assert!(load()["teams"]["laneateam"]["agents"]
|
|
686
|
+
.get("alpha")
|
|
687
|
+
.is_none());
|
|
688
|
+
|
|
689
|
+
add(&same, true).unwrap_or_else(|error| panic!("force re-add failed: {error}"));
|
|
690
|
+
let readded = load();
|
|
691
|
+
assert!(
|
|
692
|
+
readded["teams"]["laneateam"]["agent_lifecycle"]
|
|
693
|
+
.get("alpha")
|
|
694
|
+
.is_none(),
|
|
695
|
+
"force re-add consumes the retired tombstone"
|
|
696
|
+
);
|
|
697
|
+
assert!(readded["teams"]["laneateam"]["agents"]
|
|
698
|
+
.get("alpha")
|
|
699
|
+
.is_some());
|
|
700
|
+
assert_eq!(
|
|
701
|
+
std::fs::read_to_string(&role).unwrap(),
|
|
702
|
+
DELEG_ROLE_ALPHA,
|
|
703
|
+
"equal CLI values keep the adopted file byte-identical"
|
|
704
|
+
);
|
|
705
|
+
|
|
706
|
+
// A second removal, then --force with a different model: CLI values
|
|
707
|
+
// override the adopted frontmatter and the role body is kept.
|
|
708
|
+
remove_agent_with_transport(&ws, &aid("alpha"), true, true, None, &tx).unwrap();
|
|
709
|
+
let changed = crate::lifecycle::role_config::RoleConfigPatch {
|
|
710
|
+
model: Some("gpt-5.4".into()),
|
|
711
|
+
..same
|
|
712
|
+
};
|
|
713
|
+
add(&changed, true)
|
|
714
|
+
.unwrap_or_else(|error| panic!("force re-add with override failed: {error}"));
|
|
715
|
+
let (meta, _) = crate::compiler::read_front_matter(&role).unwrap();
|
|
716
|
+
assert_eq!(
|
|
717
|
+
meta.get("model")
|
|
718
|
+
.and_then(crate::model::yaml::Value::as_str),
|
|
719
|
+
Some("gpt-5.4")
|
|
720
|
+
);
|
|
721
|
+
assert!(std::fs::read_to_string(&role).unwrap().contains("Alpha."));
|
|
722
|
+
assert!(load()["teams"]["laneateam"]["agents"]
|
|
723
|
+
.get("alpha")
|
|
724
|
+
.is_some());
|
|
725
|
+
}
|
|
726
|
+
|
|
643
727
|
/// Cross-product RED (verifier, slice2b authority leak): the FAILURE dimension
|
|
644
728
|
/// (a stale writer whose incoming projection predates a sibling retirement) x the
|
|
645
729
|
/// BOUNDARY dimension (a sibling team carrying the SAME agent id). The tracked
|
|
@@ -655,8 +739,8 @@ fn remove_persists_retired_tombstone_and_explicit_readd_clears_it() {
|
|
|
655
739
|
fn add_agent_authority_must_not_cross_team_erase_sibling_same_id_retirement() {
|
|
656
740
|
// Disk latest: team A alive with alpha; team B alpha ABSENT + retired.
|
|
657
741
|
let ws = lanea_ws_agents(json!({
|
|
658
|
-
"alpha": { "status": "running", "provider": "
|
|
659
|
-
"bravo": { "status": "running", "provider": "
|
|
742
|
+
"alpha": { "status": "running", "provider": "fake", "window": "alpha" },
|
|
743
|
+
"bravo": { "status": "running", "provider": "fake", "window": "bravo" }
|
|
660
744
|
}));
|
|
661
745
|
let mut latest = crate::state::persist::load_runtime_state(&ws).unwrap();
|
|
662
746
|
latest["team_key"] = json!("laneateam");
|
|
@@ -687,7 +771,7 @@ fn add_agent_authority_must_not_cross_team_erase_sibling_same_id_retirement() {
|
|
|
687
771
|
incoming_stale["teams"]["sibling"] = json!({
|
|
688
772
|
"team_key": "sibling",
|
|
689
773
|
"status": "alive",
|
|
690
|
-
"agents": { "alpha": { "status": "running", "provider": "
|
|
774
|
+
"agents": { "alpha": { "status": "running", "provider": "fake", "window": "alpha" } },
|
|
691
775
|
"agent_lifecycle": {}
|
|
692
776
|
});
|
|
693
777
|
|
|
@@ -732,8 +816,8 @@ fn add_agent_authority_must_not_cross_team_erase_sibling_same_id_retirement() {
|
|
|
732
816
|
fn terminal_active_team_key_does_not_widen_topology_authority_to_bare_id() {
|
|
733
817
|
// Disk latest: laneateam alive with alpha; sibling alpha ABSENT + retired.
|
|
734
818
|
let ws = lanea_ws_agents(json!({
|
|
735
|
-
"alpha": { "status": "running", "provider": "
|
|
736
|
-
"bravo": { "status": "running", "provider": "
|
|
819
|
+
"alpha": { "status": "running", "provider": "fake", "window": "alpha" },
|
|
820
|
+
"bravo": { "status": "running", "provider": "fake", "window": "bravo" }
|
|
737
821
|
}));
|
|
738
822
|
let mut latest = crate::state::persist::load_runtime_state(&ws).unwrap();
|
|
739
823
|
latest["team_key"] = json!("laneateam");
|
|
@@ -760,7 +844,7 @@ fn terminal_active_team_key_does_not_widen_topology_authority_to_bare_id() {
|
|
|
760
844
|
incoming_stale["teams"]["sibling"] = json!({
|
|
761
845
|
"team_key": "sibling",
|
|
762
846
|
"status": "alive",
|
|
763
|
-
"agents": { "alpha": { "status": "running", "provider": "
|
|
847
|
+
"agents": { "alpha": { "status": "running", "provider": "fake", "window": "alpha" } },
|
|
764
848
|
"agent_lifecycle": {}
|
|
765
849
|
});
|
|
766
850
|
|
|
@@ -805,8 +889,8 @@ fn terminal_active_team_key_does_not_widen_topology_authority_to_bare_id() {
|
|
|
805
889
|
#[test]
|
|
806
890
|
fn current_alias_authority_does_not_leak_into_real_sibling_same_id_retirement() {
|
|
807
891
|
let ws = lanea_ws_agents(json!({
|
|
808
|
-
"alpha": { "status": "running", "provider": "
|
|
809
|
-
"bravo": { "status": "running", "provider": "
|
|
892
|
+
"alpha": { "status": "running", "provider": "fake", "window": "alpha" },
|
|
893
|
+
"bravo": { "status": "running", "provider": "fake", "window": "bravo" }
|
|
810
894
|
}));
|
|
811
895
|
let mut latest = crate::state::persist::load_runtime_state(&ws).unwrap();
|
|
812
896
|
latest["team_key"] = json!("laneateam");
|
|
@@ -833,7 +917,7 @@ fn current_alias_authority_does_not_leak_into_real_sibling_same_id_retirement()
|
|
|
833
917
|
incoming_stale["teams"]["sibling"] = json!({
|
|
834
918
|
"team_key": "sibling",
|
|
835
919
|
"status": "alive",
|
|
836
|
-
"agents": { "alpha": { "status": "running", "provider": "
|
|
920
|
+
"agents": { "alpha": { "status": "running", "provider": "fake", "window": "alpha" } },
|
|
837
921
|
"agent_lifecycle": {}
|
|
838
922
|
});
|
|
839
923
|
|
|
@@ -865,7 +949,7 @@ fn current_alias_authority_does_not_leak_into_real_sibling_same_id_retirement()
|
|
|
865
949
|
);
|
|
866
950
|
}
|
|
867
951
|
|
|
868
|
-
const CHARLIE_ROLE: &str = "---\nname: charlie\nrole: Charlie Worker\nprovider:
|
|
952
|
+
const CHARLIE_ROLE: &str = "---\nname: charlie\nrole: Charlie Worker\nprovider: fake\nmodel: fake\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nCharlie.\n";
|
|
869
953
|
|
|
870
954
|
struct HermeticTestEnv {
|
|
871
955
|
root: std::path::PathBuf,
|
|
@@ -938,8 +1022,8 @@ fn seed_charlie(ws: &std::path::Path, tx: &LaneTransport) -> std::path::PathBuf
|
|
|
938
1022
|
fn force_recreate_is_one_lock_transaction_for_all_seat_quadrants_and_rolls_back_failure() {
|
|
939
1023
|
for quadrant in ["state-only", "spec-only", "physical-only", "mixed"] {
|
|
940
1024
|
let ws = lanea_ws_agents(json!({
|
|
941
|
-
"alpha": { "status": "stopped", "provider": "
|
|
942
|
-
"bravo": { "status": "running", "provider": "
|
|
1025
|
+
"alpha": { "status": "stopped", "provider": "fake", "window": "alpha" },
|
|
1026
|
+
"bravo": { "status": "running", "provider": "fake", "window": "bravo" }
|
|
943
1027
|
}));
|
|
944
1028
|
let tx = LaneTransport::new("team-laneateam", &[]);
|
|
945
1029
|
seed_healthy_coordinator(&ws);
|
|
@@ -1016,8 +1100,8 @@ fn force_recreate_is_one_lock_transaction_for_all_seat_quadrants_and_rolls_back_
|
|
|
1016
1100
|
}
|
|
1017
1101
|
|
|
1018
1102
|
let ws = lanea_ws_agents(json!({
|
|
1019
|
-
"alpha": { "status": "stopped", "provider": "
|
|
1020
|
-
"bravo": { "status": "running", "provider": "
|
|
1103
|
+
"alpha": { "status": "stopped", "provider": "fake", "window": "alpha" },
|
|
1104
|
+
"bravo": { "status": "running", "provider": "fake", "window": "bravo" }
|
|
1021
1105
|
}));
|
|
1022
1106
|
let tx = LaneTransport::new("team-laneateam", &[]);
|
|
1023
1107
|
seed_healthy_coordinator(&ws);
|
|
@@ -1072,8 +1156,8 @@ fn force_recreate_post_consumption_failure_restores_before_tuple_and_health() {
|
|
|
1072
1156
|
let ws = lanea_ws_agents_at(
|
|
1073
1157
|
hermetic.workspace_root(),
|
|
1074
1158
|
json!({
|
|
1075
|
-
"alpha": { "status": "stopped", "provider": "
|
|
1076
|
-
"bravo": { "status": "running", "provider": "
|
|
1159
|
+
"alpha": { "status": "stopped", "provider": "fake", "window": "alpha" },
|
|
1160
|
+
"bravo": { "status": "running", "provider": "fake", "window": "bravo" }
|
|
1077
1161
|
}),
|
|
1078
1162
|
);
|
|
1079
1163
|
let tx = LaneTransport::new("team-laneateam", &[]);
|
|
@@ -1154,8 +1238,8 @@ fn force_remove_scopes_agent_health_to_canonical_team_key() {
|
|
|
1154
1238
|
let ws = lanea_ws_agents_at(
|
|
1155
1239
|
hermetic.workspace_root(),
|
|
1156
1240
|
json!({
|
|
1157
|
-
"alpha": { "status": "stopped", "provider": "
|
|
1158
|
-
"bravo": { "status": "running", "provider": "
|
|
1241
|
+
"alpha": { "status": "stopped", "provider": "fake", "window": "alpha" },
|
|
1242
|
+
"bravo": { "status": "running", "provider": "fake", "window": "bravo" }
|
|
1159
1243
|
}),
|
|
1160
1244
|
);
|
|
1161
1245
|
let tx = LaneTransport::new("team-laneateam", &[]);
|
|
@@ -1199,9 +1283,10 @@ fn set_context_state_file(ws: &std::path::Path, name: &str) {
|
|
|
1199
1283
|
std::fs::write(&p, replaced).unwrap();
|
|
1200
1284
|
}
|
|
1201
1285
|
|
|
1202
|
-
/// Fork workspace: source `alpha` (role doc = `alpha_role`) + `bravo`, alpha seeded
|
|
1203
|
-
///
|
|
1204
|
-
///
|
|
1286
|
+
/// Fork workspace: source `alpha` (role doc = `alpha_role`) + `bravo`, alpha seeded as a RUNNING
|
|
1287
|
+
/// Copilot seat with a captured `session_id` — a fork-capable legacy source — so every refusal comes
|
|
1288
|
+
/// from the legacy fork entry itself. Seeded-healthy coordinator (no real daemon).
|
|
1289
|
+
/// session_name = "team-laneateam".
|
|
1205
1290
|
pub(super) fn fork_ws(alpha_role: &str) -> PathBuf {
|
|
1206
1291
|
let ws = temp_ws().join("forkv2");
|
|
1207
1292
|
std::fs::create_dir_all(ws.join("agents")).unwrap();
|
|
@@ -1214,42 +1299,6 @@ pub(super) fn fork_ws(alpha_role: &str) -> PathBuf {
|
|
|
1214
1299
|
std::fs::write(ws.join("agents").join("bravo.md"), DELEG_ROLE_BRAVO).unwrap();
|
|
1215
1300
|
let spec = crate::compiler::compile_team(&ws).expect("compile fork team");
|
|
1216
1301
|
std::fs::write(ws.join("team.spec.yaml"), crate::model::yaml::dumps(&spec)).unwrap();
|
|
1217
|
-
// 0.4.6 tuple-atomic contract: fork now requires the complete source
|
|
1218
|
-
// tuple (session_id + rollout_path + captured_at + captured_via). These
|
|
1219
|
-
// fork-mechanics tests previously only seeded session_id; seed a real
|
|
1220
|
-
// rollout file + the rest of the tuple so the source backing guard
|
|
1221
|
-
// passes and the test exercises the fork mechanics being asserted.
|
|
1222
|
-
use std::sync::atomic::{AtomicU64, Ordering};
|
|
1223
|
-
static FORK_ROLLOUT_SEQ: AtomicU64 = AtomicU64::new(0);
|
|
1224
|
-
let n = FORK_ROLLOUT_SEQ.fetch_add(1, Ordering::Relaxed);
|
|
1225
|
-
let rollout = std::env::temp_dir().join(format!(
|
|
1226
|
-
"ta-fork-ws-rollout-{}-{}.jsonl",
|
|
1227
|
-
std::process::id(),
|
|
1228
|
-
n
|
|
1229
|
-
));
|
|
1230
|
-
std::fs::write(
|
|
1231
|
-
&rollout,
|
|
1232
|
-
format!(
|
|
1233
|
-
"{}\n{}\n",
|
|
1234
|
-
json!({
|
|
1235
|
-
"type": "session_meta",
|
|
1236
|
-
"payload": {
|
|
1237
|
-
"id": "sess-a",
|
|
1238
|
-
"cwd": ws,
|
|
1239
|
-
}
|
|
1240
|
-
}),
|
|
1241
|
-
json!({
|
|
1242
|
-
"type": "response_item",
|
|
1243
|
-
"payload": {
|
|
1244
|
-
"content": [{
|
|
1245
|
-
"type": "input_text",
|
|
1246
|
-
"text": "You are Team Agent worker `alpha` with role `fixture`."
|
|
1247
|
-
}]
|
|
1248
|
-
}
|
|
1249
|
-
})
|
|
1250
|
-
),
|
|
1251
|
-
)
|
|
1252
|
-
.expect("seed identity-complete fork source rollout");
|
|
1253
1302
|
crate::state::persist::save_runtime_state(
|
|
1254
1303
|
&ws,
|
|
1255
1304
|
&json!({
|
|
@@ -1257,14 +1306,13 @@ pub(super) fn fork_ws(alpha_role: &str) -> PathBuf {
|
|
|
1257
1306
|
"agents": {
|
|
1258
1307
|
"alpha": {
|
|
1259
1308
|
"status": "running",
|
|
1260
|
-
"provider": "
|
|
1309
|
+
"provider": "copilot",
|
|
1261
1310
|
"window": "alpha",
|
|
1262
1311
|
"session_id": "sess-a",
|
|
1263
|
-
"rollout_path": rollout.to_string_lossy(),
|
|
1264
1312
|
"captured_at": "2026-06-25T10:00:00+00:00",
|
|
1265
1313
|
"captured_via": "session.captured"
|
|
1266
1314
|
},
|
|
1267
|
-
"bravo": { "status": "running", "provider": "
|
|
1315
|
+
"bravo": { "status": "running", "provider": "fake", "window": "bravo" }
|
|
1268
1316
|
}
|
|
1269
1317
|
}),
|
|
1270
1318
|
)
|
|
@@ -1282,7 +1330,7 @@ pub(super) fn fork_ws(alpha_role: &str) -> PathBuf {
|
|
|
1282
1330
|
#[test]
|
|
1283
1331
|
fn lanea_stop_window_absent_returns_stopped_false_no_kill() {
|
|
1284
1332
|
let ws = lanea_ws_agents(
|
|
1285
|
-
json!({ "alpha": { "status": "running", "provider": "
|
|
1333
|
+
json!({ "alpha": { "status": "running", "provider": "fake", "window": "alpha" } }),
|
|
1286
1334
|
);
|
|
1287
1335
|
let tx = LaneTransport::new("team-laneateam", &[]); // alpha's window is ABSENT
|
|
1288
1336
|
let report = stop_agent_with_transport(&ws, &aid("alpha"), None, &tx)
|
|
@@ -1304,7 +1352,7 @@ fn lanea_stop_window_absent_returns_stopped_false_no_kill() {
|
|
|
1304
1352
|
#[test]
|
|
1305
1353
|
fn lanea_stop_window_present_kills_and_stopped_true() {
|
|
1306
1354
|
let ws = lanea_ws_agents(
|
|
1307
|
-
json!({ "alpha": { "status": "running", "provider": "
|
|
1355
|
+
json!({ "alpha": { "status": "running", "provider": "fake", "window": "alpha" } }),
|
|
1308
1356
|
);
|
|
1309
1357
|
let tx = LaneTransport::new("team-laneateam", &["alpha"]); // window present
|
|
1310
1358
|
let report =
|
|
@@ -1331,7 +1379,7 @@ fn lanea_stop_window_present_kills_and_stopped_true() {
|
|
|
1331
1379
|
#[test]
|
|
1332
1380
|
fn lanea_reset_paused_agent_returns_ok_not_err() {
|
|
1333
1381
|
let ws = lanea_ws_agents(json!({
|
|
1334
|
-
"alpha": { "status": "running", "provider": "
|
|
1382
|
+
"alpha": { "status": "running", "provider": "fake", "window": "alpha", "paused": true, "session_id": "sess-a" }
|
|
1335
1383
|
}));
|
|
1336
1384
|
let tx = LaneTransport::new("team-laneateam", &["alpha"]);
|
|
1337
1385
|
let result = reset_agent_with_transport(&ws, &aid("alpha"), true, false, None, &tx);
|
|
@@ -1355,8 +1403,8 @@ fn lanea_reset_paused_agent_returns_ok_not_err() {
|
|
|
1355
1403
|
#[test]
|
|
1356
1404
|
fn lanea_remove_dynamic_agent_removable_without_from_spec() {
|
|
1357
1405
|
let ws = lanea_ws_agents(json!({
|
|
1358
|
-
"alpha": { "status": "stopped", "provider": "
|
|
1359
|
-
"bravo": { "status": "stopped", "provider": "
|
|
1406
|
+
"alpha": { "status": "stopped", "provider": "fake", "window": "alpha", "dynamic_role_file": ".team/dynamic-role-files/alpha.md" },
|
|
1407
|
+
"bravo": { "status": "stopped", "provider": "fake", "window": "bravo" }
|
|
1360
1408
|
}));
|
|
1361
1409
|
// make the dynamic role file exist (so removal resolves+deletes it cleanly under either path policy).
|
|
1362
1410
|
let dyn_dir = ws.join(".team").join("dynamic-role-files");
|
|
@@ -1383,8 +1431,8 @@ fn lanea_remove_dynamic_agent_removable_without_from_spec() {
|
|
|
1383
1431
|
fn remove_preserves_external_role_source_for_both_flag_forms() {
|
|
1384
1432
|
for from_spec in [false, true] {
|
|
1385
1433
|
let ws = lanea_ws_agents(json!({
|
|
1386
|
-
"alpha": { "status": "stopped", "provider": "
|
|
1387
|
-
"bravo": { "status": "stopped", "provider": "
|
|
1434
|
+
"alpha": { "status": "stopped", "provider": "fake", "window": "alpha" },
|
|
1435
|
+
"bravo": { "status": "stopped", "provider": "fake", "window": "bravo" }
|
|
1388
1436
|
}));
|
|
1389
1437
|
let external_dir = ws.join("role-masters");
|
|
1390
1438
|
std::fs::create_dir_all(&external_dir).unwrap();
|
|
@@ -1423,11 +1471,11 @@ fn remove_agent_preserves_registered_role_markdown_by_default() {
|
|
|
1423
1471
|
let ws = lanea_ws_agents(json!({
|
|
1424
1472
|
"alpha": {
|
|
1425
1473
|
"status": "stopped",
|
|
1426
|
-
"provider": "
|
|
1474
|
+
"provider": "fake",
|
|
1427
1475
|
"window": "alpha",
|
|
1428
1476
|
"dynamic_role_file": ".team/dynamic-role-files/alpha.md"
|
|
1429
1477
|
},
|
|
1430
|
-
"bravo": { "status": "stopped", "provider": "
|
|
1478
|
+
"bravo": { "status": "stopped", "provider": "fake", "window": "bravo" }
|
|
1431
1479
|
}));
|
|
1432
1480
|
let role = ws.join(".team/dynamic-role-files/alpha.md");
|
|
1433
1481
|
std::fs::create_dir_all(role.parent().unwrap()).unwrap();
|
|
@@ -1458,8 +1506,8 @@ fn remove_preserves_managed_path_symlink_escape() {
|
|
|
1458
1506
|
use std::os::unix::fs::symlink;
|
|
1459
1507
|
|
|
1460
1508
|
let ws = lanea_ws_agents(json!({
|
|
1461
|
-
"alpha": { "status": "stopped", "provider": "
|
|
1462
|
-
"bravo": { "status": "stopped", "provider": "
|
|
1509
|
+
"alpha": { "status": "stopped", "provider": "fake", "window": "alpha", "dynamic_role_file": ".team/dynamic-role-files/alpha.md" },
|
|
1510
|
+
"bravo": { "status": "stopped", "provider": "fake", "window": "bravo" }
|
|
1463
1511
|
}));
|
|
1464
1512
|
let external = ws.join("role-masters").join("alpha.md");
|
|
1465
1513
|
std::fs::create_dir_all(external.parent().unwrap()).unwrap();
|
|
@@ -1487,8 +1535,8 @@ fn remove_preserves_managed_path_symlink_escape() {
|
|
|
1487
1535
|
#[test]
|
|
1488
1536
|
fn remove_agent_deletes_unrecorded_default_managed_role() {
|
|
1489
1537
|
let ws = lanea_ws_agents(json!({
|
|
1490
|
-
"alpha": { "status": "stopped", "provider": "
|
|
1491
|
-
"bravo": { "status": "stopped", "provider": "
|
|
1538
|
+
"alpha": { "status": "stopped", "provider": "fake", "window": "alpha" },
|
|
1539
|
+
"bravo": { "status": "stopped", "provider": "fake", "window": "bravo" }
|
|
1492
1540
|
}));
|
|
1493
1541
|
let role = ws.join(".team").join("dynamic-role-files").join("alpha.md");
|
|
1494
1542
|
std::fs::create_dir_all(role.parent().unwrap()).unwrap();
|
|
@@ -1512,8 +1560,8 @@ fn remove_agent_deletes_unrecorded_default_managed_role() {
|
|
|
1512
1560
|
#[test]
|
|
1513
1561
|
fn force_remove_state_only_seat_is_idempotent() {
|
|
1514
1562
|
let ws = lanea_ws_agents(json!({
|
|
1515
|
-
"alpha": { "status": "stopped", "provider": "
|
|
1516
|
-
"bravo": { "status": "stopped", "provider": "
|
|
1563
|
+
"alpha": { "status": "stopped", "provider": "fake", "window": "alpha" },
|
|
1564
|
+
"bravo": { "status": "stopped", "provider": "fake", "window": "bravo" }
|
|
1517
1565
|
}));
|
|
1518
1566
|
let spec_path = ws.join("team.spec.yaml");
|
|
1519
1567
|
let spec = crate::model::yaml::loads(&std::fs::read_to_string(&spec_path).unwrap()).unwrap();
|
|
@@ -1543,7 +1591,7 @@ fn force_remove_state_only_seat_is_idempotent() {
|
|
|
1543
1591
|
#[test]
|
|
1544
1592
|
fn lanea_remove_unknown_agent_precedes_from_spec_refusal() {
|
|
1545
1593
|
let ws = lanea_ws_agents(
|
|
1546
|
-
json!({ "alpha": { "status": "stopped", "provider": "
|
|
1594
|
+
json!({ "alpha": { "status": "stopped", "provider": "fake", "window": "alpha" } }),
|
|
1547
1595
|
);
|
|
1548
1596
|
let tx = LaneTransport::new("team-laneateam", &[]);
|
|
1549
1597
|
let text = format!(
|
|
@@ -1566,8 +1614,8 @@ fn lanea_remove_unknown_agent_precedes_from_spec_refusal() {
|
|
|
1566
1614
|
#[test]
|
|
1567
1615
|
fn lanea_remove_writes_markdown_team_state_not_json() {
|
|
1568
1616
|
let ws = lanea_ws_agents(json!({
|
|
1569
|
-
"alpha": { "status": "stopped", "provider": "
|
|
1570
|
-
"bravo": { "status": "running", "provider": "
|
|
1617
|
+
"alpha": { "status": "stopped", "provider": "fake", "window": "alpha" },
|
|
1618
|
+
"bravo": { "status": "running", "provider": "fake", "window": "bravo" }
|
|
1571
1619
|
}));
|
|
1572
1620
|
let tx = LaneTransport::new("team-laneateam", &[]);
|
|
1573
1621
|
let _ =
|
|
@@ -1587,7 +1635,7 @@ fn lanea_remove_writes_markdown_team_state_not_json() {
|
|
|
1587
1635
|
"golden has a '## Agents' section; got:\n{team_state}"
|
|
1588
1636
|
);
|
|
1589
1637
|
assert!(
|
|
1590
|
-
team_state.contains("bravo: Bravo Worker on
|
|
1638
|
+
team_state.contains("bravo: Bravo Worker on fake"),
|
|
1591
1639
|
"the '## Agents' section must list the remaining agent bravo (golden '- {{id}}: {{role}} on {{provider}} ({{status}})'); got:\n{team_state}"
|
|
1592
1640
|
);
|
|
1593
1641
|
assert!(
|
|
@@ -1605,8 +1653,8 @@ fn lanea_remove_writes_markdown_team_state_not_json() {
|
|
|
1605
1653
|
#[test]
|
|
1606
1654
|
fn lanea_remove_is_running_honors_tmux_window_fallback() {
|
|
1607
1655
|
let ws = lanea_ws_agents(json!({
|
|
1608
|
-
"alpha": { "status": "idle", "provider": "
|
|
1609
|
-
"bravo": { "status": "stopped", "provider": "
|
|
1656
|
+
"alpha": { "status": "idle", "provider": "fake", "window": "alpha" }, // stale status, but window is live
|
|
1657
|
+
"bravo": { "status": "stopped", "provider": "fake", "window": "bravo" }
|
|
1610
1658
|
}));
|
|
1611
1659
|
let tx = LaneTransport::new("team-laneateam", &["alpha"]); // alpha's tmux window EXISTS
|
|
1612
1660
|
let result = remove_agent_with_transport(&ws, &aid("alpha"), true, false, None, &tx); // force=FALSE
|
|
@@ -1659,8 +1707,8 @@ fn lanea_remove_rollback_restarts_force_stopped_worker() {
|
|
|
1659
1707
|
#[test]
|
|
1660
1708
|
fn lanea_remove_dynamic_role_file_missing_does_not_block_unregister() {
|
|
1661
1709
|
let ws = lanea_ws_agents(json!({
|
|
1662
|
-
"alpha": { "status": "stopped", "provider": "
|
|
1663
|
-
"bravo": { "status": "stopped", "provider": "
|
|
1710
|
+
"alpha": { "status": "stopped", "provider": "fake", "window": "alpha", "dynamic_role_file": ".team/dynamic-role-files/custom.md" }, // file NOT created
|
|
1711
|
+
"bravo": { "status": "stopped", "provider": "fake", "window": "bravo" }
|
|
1664
1712
|
}));
|
|
1665
1713
|
let tx = LaneTransport::new("team-laneateam", &[]);
|
|
1666
1714
|
let result = remove_agent_with_transport(&ws, &aid("alpha"), true, true, None, &tx);
|
|
@@ -1703,16 +1751,12 @@ fn lanea_remove_rollback_restores_via_spec_state_file_path() {
|
|
|
1703
1751
|
// fork proceeds against the leader id. RED: fork target == "leader" must be 'already exists'.
|
|
1704
1752
|
#[test]
|
|
1705
1753
|
fn lanea_fork_dup_target_leader_id_is_already_exists() {
|
|
1706
|
-
let ws = fork_ws(
|
|
1754
|
+
let ws = fork_ws(COPILOT_ROLE_ALPHA);
|
|
1707
1755
|
let tx = LaneTransport::new("team-laneateam", &[]);
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
fork_agent_with_transport(&ws, &aid("alpha"), &aid("leader"), None, false, None, &tx)
|
|
1711
|
-
);
|
|
1712
|
-
assert!(
|
|
1713
|
-
text.contains("unverified") || text.contains("未验证") || text.contains("refuses --as"),
|
|
1714
|
-
"codex in-window fork is unverified; leader-id duplicate is not reached. got {text}"
|
|
1715
|
-
);
|
|
1756
|
+
// The legacy fork entry refuses before any target check; the leader-id duplicate is not reached.
|
|
1757
|
+
let result =
|
|
1758
|
+
fork_agent_with_transport(&ws, &aid("alpha"), &aid("leader"), None, false, None, &tx);
|
|
1759
|
+
assert_legacy_fork_unverified(&result, "copilot");
|
|
1716
1760
|
}
|
|
1717
1761
|
|
|
1718
1762
|
// ── FORK (fork-missing-tmux-window-guard) [RED] — window-already-exists guard BEFORE spec mutation ────
|
|
@@ -1722,19 +1766,12 @@ fn lanea_fork_dup_target_leader_id_is_already_exists() {
|
|
|
1722
1766
|
// for the target must (a) raise that exact message and (b) leave the spec UNMUTATED (no fork agent).
|
|
1723
1767
|
#[test]
|
|
1724
1768
|
fn lanea_fork_window_already_exists_guard_before_spec_mutation() {
|
|
1725
|
-
let ws = fork_ws(
|
|
1769
|
+
let ws = fork_ws(COPILOT_ROLE_ALPHA);
|
|
1726
1770
|
let tx = LaneTransport::new("team-laneateam", &["newfork"]); // the target window already exists
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
fork_agent_with_transport(&ws, &aid("alpha"), &aid("newfork"), None, false, None, &tx)
|
|
1730
|
-
);
|
|
1731
|
-
assert!(
|
|
1732
|
-
text.contains("unverified")
|
|
1733
|
-
|| text.contains("未验证")
|
|
1734
|
-
|| text.contains("refuses --as")
|
|
1735
|
-
|| text.contains("tmux window already exists for fork target: team-laneateam:newfork"),
|
|
1736
|
-
"codex in-window fork is unverified; window-exists guard is not reached. got {text}"
|
|
1737
|
-
);
|
|
1771
|
+
// The legacy fork entry refuses before any target check; the window-exists guard is not reached.
|
|
1772
|
+
let result =
|
|
1773
|
+
fork_agent_with_transport(&ws, &aid("alpha"), &aid("newfork"), None, false, None, &tx);
|
|
1774
|
+
assert_legacy_fork_unverified(&result, "copilot");
|
|
1738
1775
|
let spec_text = std::fs::read_to_string(ws.join("team.spec.yaml")).unwrap();
|
|
1739
1776
|
assert!(
|
|
1740
1777
|
!spec_text.contains("newfork"),
|
|
@@ -1745,21 +1782,18 @@ fn lanea_fork_window_already_exists_guard_before_spec_mutation() {
|
|
|
1745
1782
|
// ── FORK (fork-gate-error-text) [RED] + (fork-incomplete-rollback, adapter arm) — golden gate text + spec rollback
|
|
1746
1783
|
// Golden operations.py:329-330 raises f"{provider} does not support native session fork" when the native
|
|
1747
1784
|
// fork gate fails (auth_mode==compatible_api). Rust relies on adapter.fork_plan() -> CapabilityUnsupported
|
|
1748
|
-
// ("
|
|
1785
|
+
// ("<provider>:fork") (adapter.rs:310) -> a different observable. AND golden wraps the post-spec-write steps
|
|
1749
1786
|
// in try/except restoring the spec on ANY failure (operations.py:384-394); Rust writes the spec
|
|
1750
1787
|
// (launch.rs:443) then errors at adapter.fork_plan (458-460) WITHOUT restoring it. RED on both: the message
|
|
1751
1788
|
// text AND the spec must be rolled back to not contain the fork agent.
|
|
1752
1789
|
#[test]
|
|
1753
1790
|
fn lanea_fork_gate_error_text_and_spec_rollback_on_adapter_arm() {
|
|
1754
|
-
let ws = fork_ws(DELEG_ROLE_ALPHA_COMPAT); // source alpha auth_mode=compatible_api
|
|
1791
|
+
let ws = fork_ws(DELEG_ROLE_ALPHA_COMPAT); // source alpha auth_mode=compatible_api
|
|
1755
1792
|
let tx = LaneTransport::new("team-laneateam", &[]);
|
|
1756
1793
|
let result =
|
|
1757
1794
|
fork_agent_with_transport(&ws, &aid("alpha"), &aid("newfork"), None, false, None, &tx);
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
text.contains("unverified") || text.contains("未验证"),
|
|
1761
|
-
"codex is unverified (any auth), not 'does not support'. got {text}"
|
|
1762
|
-
);
|
|
1795
|
+
// Unverified for any auth mode, never "does not support".
|
|
1796
|
+
assert_legacy_fork_unverified(&result, "copilot");
|
|
1763
1797
|
let spec_text = std::fs::read_to_string(ws.join("team.spec.yaml")).unwrap();
|
|
1764
1798
|
assert!(
|
|
1765
1799
|
!spec_text.contains("newfork"),
|
|
@@ -1768,34 +1802,25 @@ fn lanea_fork_gate_error_text_and_spec_rollback_on_adapter_arm() {
|
|
|
1768
1802
|
);
|
|
1769
1803
|
}
|
|
1770
1804
|
|
|
1771
|
-
//
|
|
1805
|
+
// A fork-capable, fully captured Copilot source gets no legacy fork and no fresh replacement: the
|
|
1806
|
+
// refusal performs no spawn and leaves the runtime state untouched.
|
|
1772
1807
|
#[test]
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
let
|
|
1776
|
-
let ws = fork_ws(DELEG_ROLE_ALPHA); // codex+subscription -> native fork supported -> full success path
|
|
1777
|
-
let mut state = crate::state::persist::load_runtime_state(&ws).unwrap();
|
|
1778
|
-
let source = PathBuf::from(state["agents"]["alpha"]["rollout_path"].as_str().unwrap());
|
|
1779
|
-
let codex_root = std::env::var_os("HOME")
|
|
1780
|
-
.map(PathBuf::from)
|
|
1781
|
-
.unwrap()
|
|
1782
|
-
.join(".codex/sessions/lane-fixture");
|
|
1783
|
-
std::fs::create_dir_all(&codex_root).unwrap();
|
|
1784
|
-
let discoverable_source = codex_root.join("rollout-sess-a.jsonl");
|
|
1785
|
-
std::fs::copy(source, &discoverable_source).unwrap();
|
|
1786
|
-
state["agents"]["alpha"]["rollout_path"] =
|
|
1787
|
-
json!(discoverable_source.to_string_lossy().to_string());
|
|
1788
|
-
crate::state::persist::save_runtime_state(&ws, &state).unwrap();
|
|
1808
|
+
fn lanea_fork_captured_copilot_source_spawns_nothing() {
|
|
1809
|
+
let ws = fork_ws(COPILOT_ROLE_ALPHA);
|
|
1810
|
+
let state_before = crate::state::persist::load_runtime_state(&ws).unwrap();
|
|
1789
1811
|
let tx = LaneTransport::new("team-laneateam", &[]);
|
|
1790
1812
|
let result =
|
|
1791
1813
|
fork_agent_with_transport(&ws, &aid("alpha"), &aid("newfork"), None, false, None, &tx);
|
|
1792
|
-
|
|
1793
|
-
Err(error) => error.to_string(),
|
|
1794
|
-
Ok(_) => panic!("codex in-window fork is unverified and must refuse"),
|
|
1795
|
-
};
|
|
1814
|
+
assert_legacy_fork_unverified(&result, "copilot");
|
|
1796
1815
|
assert!(
|
|
1797
|
-
|
|
1798
|
-
"
|
|
1816
|
+
tx.spawns().is_empty(),
|
|
1817
|
+
"the refused legacy fork must not spawn a pane; spawns={:?}",
|
|
1818
|
+
tx.spawns()
|
|
1819
|
+
);
|
|
1820
|
+
assert_eq!(
|
|
1821
|
+
crate::state::persist::load_runtime_state(&ws).unwrap(),
|
|
1822
|
+
state_before,
|
|
1823
|
+
"the refused legacy fork must not write runtime state"
|
|
1799
1824
|
);
|
|
1800
1825
|
}
|
|
1801
1826
|
|