@team-agent/installer 0.5.126 → 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 -91
- package/crates/team-agent/src/cli/emit.rs +61 -28
- package/crates/team-agent/src/cli/grok_slot.rs +88 -3
- package/crates/team-agent/src/cli/intent/runtime.rs +38 -9
- package/crates/team-agent/src/cli/intent/runtime_tests.rs +147 -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 +38 -9
- package/crates/team-agent/src/cli/models.rs +789 -186
- 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 +3 -3
- package/crates/team-agent/src/cli/tests/named_address.rs +11 -10
- package/crates/team-agent/src/cli/tests/run_delegation.rs +12 -9
- package/crates/team-agent/src/cli/tests/status_send.rs +70 -273
- package/crates/team-agent/src/compiler/tests.rs +39 -27
- package/crates/team-agent/src/compiler.rs +206 -6
- package/crates/team-agent/src/contract_runtime/backend.rs +181 -11
- package/crates/team-agent/src/contract_runtime/commands.rs +338 -7
- package/crates/team-agent/src/contract_runtime/config.rs +30 -19
- 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 -14
- 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 +93 -130
- package/crates/team-agent/src/coordinator/steps/abnormal.rs +45 -5
- package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +8 -29
- package/crates/team-agent/src/coordinator/tests/energy.rs +4 -4
- package/crates/team-agent/src/coordinator/tests/health_sync.rs +44 -2
- 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/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 +36 -179
- package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +87 -6
- package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +13 -488
- 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 +26 -2
- package/crates/team-agent/src/lifecycle/launch/spawn.rs +41 -31
- package/crates/team-agent/src/lifecycle/launch.rs +27 -12
- package/crates/team-agent/src/lifecycle/profile_launch.rs +318 -64
- 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 +298 -133
- 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 +4 -0
- package/crates/team-agent/src/lifecycle/role_config.rs +79 -27
- 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 +37 -240
- 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 +329 -70
- 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 +25 -39
- package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +7 -11
- package/crates/team-agent/src/lifecycle/tests/core.rs +39 -36
- package/crates/team-agent/src/lifecycle/tests/f032_startup_prompt_best_effort_red.rs +22 -8
- 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 +15 -133
- package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +60 -20
- 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 +164 -282
- 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/mcp_tool_name_format_red.rs +6 -6
- 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 +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 +14 -15
- 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 -1374
- 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 +254 -2
- 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 +38 -39
- package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +51 -88
- package/crates/team-agent/src/lifecycle/tests.rs +3 -4
- package/crates/team-agent/src/lifecycle/types.rs +18 -5
- 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 +86 -109
- 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 +143 -253
- 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 +255 -150
- package/crates/team-agent/src/messaging/tests/main_preserved.rs +2 -2
- package/crates/team-agent/src/messaging/tests/runtime.rs +9 -115
- package/crates/team-agent/src/messaging/tests/spine.rs +44 -24
- package/crates/team-agent/src/messaging/tests/wave2.rs +13 -20
- package/crates/team-agent/src/messaging/types.rs +1 -0
- package/crates/team-agent/src/provider/adapter.rs +208 -254
- 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 -7
- 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 +111 -111
- package/crates/team-agent/src/provider/session/context_fork/claude.rs +123 -0
- package/crates/team-agent/src/provider/session/context_fork/outcome.rs +10 -18
- package/crates/team-agent/src/provider/session/context_fork.rs +87 -74
- package/crates/team-agent/src/provider/session/mod.rs +2 -3
- package/crates/team-agent/src/provider/session_scan/claude.rs +523 -0
- package/crates/team-agent/src/provider/session_scan/common.rs +47 -47
- package/crates/team-agent/src/provider/session_scan/pi.rs +34 -1
- package/crates/team-agent/src/provider/session_scan.rs +13 -13
- package/crates/team-agent/src/provider/tests/adapter.rs +127 -121
- package/crates/team-agent/src/provider/tests/classify.rs +0 -53
- package/crates/team-agent/src/provider/tests/command_helpers.rs +11 -19
- package/crates/team-agent/src/provider/tests/idle.rs +13 -19
- package/crates/team-agent/src/provider/types.rs +0 -4
- package/crates/team-agent/src/provider/wire.rs +34 -20
- 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 +9 -43
- package/package.json +4 -4
- package/skills/team-agent/SKILL.md +7 -8
- 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/launch/grok_per_seat.rs +0 -260
- 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/provider/adapters/codex.rs +0 -101
- package/crates/team-agent/src/provider/adapters/grok.rs +0 -67
- package/crates/team-agent/src/provider/session/context_fork/codex.rs +0 -514
- package/crates/team-agent/src/provider/session_scan/codex.rs +0 -326
- package/crates/team-agent/src/provider/session_scan/grok.rs +0 -288
|
@@ -1,6 +1,32 @@
|
|
|
1
|
-
use std::path::Path;
|
|
1
|
+
use std::path::{Path, PathBuf};
|
|
2
2
|
|
|
3
|
+
use crate::cli::diagnose::{pi_doctor_facts, PiBackingStatus, PiDoctorInput, PiMcpStatus};
|
|
3
4
|
use crate::lifecycle::launch::pi_mcp::{pi_cleanup_plan, pi_seat_paths, PiCleanupAction};
|
|
5
|
+
use crate::provider::{AuthHintStatus, ClassifySource, TurnState};
|
|
6
|
+
|
|
7
|
+
fn doctor_input() -> PiDoctorInput {
|
|
8
|
+
PiDoctorInput {
|
|
9
|
+
executable_chain_verified: true,
|
|
10
|
+
pi_version: Some("0.84.3".to_string()),
|
|
11
|
+
adapter_version: Some("2.30.0".to_string()),
|
|
12
|
+
catalog_sha256: Some(
|
|
13
|
+
"726cedb6c3f6fe80a0d7b98918d8ed5063695e01f510a48f46c4bad5daab49fe".to_string(),
|
|
14
|
+
),
|
|
15
|
+
selected_model: Some("team-agent/qwen3.8-27b".to_string()),
|
|
16
|
+
candidate_executable: Some(PathBuf::from("/candidate/team-agent")),
|
|
17
|
+
wrapper: Some(PathBuf::from(
|
|
18
|
+
"/workspace/.team/runtime/pi/team-a/worker-a/team-mcp.ts",
|
|
19
|
+
)),
|
|
20
|
+
mcp_roundtrip_at: None,
|
|
21
|
+
backing: PiBackingStatus::Pending,
|
|
22
|
+
activity: TurnState::Unknown,
|
|
23
|
+
activity_source: ClassifySource::SessionFile,
|
|
24
|
+
env_key_names: vec![
|
|
25
|
+
"TEAM_AGENT_ID".to_string(),
|
|
26
|
+
"TEAM_AGENT_OWNER_TEAM_ID".to_string(),
|
|
27
|
+
],
|
|
28
|
+
}
|
|
29
|
+
}
|
|
4
30
|
|
|
5
31
|
#[test]
|
|
6
32
|
fn pi_stop_retains_backing_and_never_scans_by_process_name() {
|
|
@@ -29,3 +55,44 @@ fn pi_stop_retains_backing_and_never_scans_by_process_name() {
|
|
|
29
55
|
"remove may delete only exact Team-owned seat paths"
|
|
30
56
|
);
|
|
31
57
|
}
|
|
58
|
+
|
|
59
|
+
#[test]
|
|
60
|
+
fn pi_doctor_separates_configured_roundtrip_backing_and_activity_unknown() {
|
|
61
|
+
let facts = pi_doctor_facts(doctor_input());
|
|
62
|
+
|
|
63
|
+
assert_eq!(facts.mcp, PiMcpStatus::ConfiguredLazy);
|
|
64
|
+
assert!(
|
|
65
|
+
!facts.mcp_connected,
|
|
66
|
+
"wrapper existence is not an MCP roundtrip"
|
|
67
|
+
);
|
|
68
|
+
assert_eq!(facts.backing, PiBackingStatus::Pending);
|
|
69
|
+
assert_eq!(facts.activity, TurnState::Unknown);
|
|
70
|
+
assert_eq!(facts.activity_source, ClassifySource::SessionFile);
|
|
71
|
+
assert_eq!(facts.auth_hint, AuthHintStatus::Unknown);
|
|
72
|
+
|
|
73
|
+
let serialized = serde_json::to_string(&facts).expect("serialize doctor facts");
|
|
74
|
+
assert!(serialized.contains("configured_lazy"));
|
|
75
|
+
assert!(serialized.contains("unknown"));
|
|
76
|
+
for secret_surface in [
|
|
77
|
+
"api_key",
|
|
78
|
+
"access_token",
|
|
79
|
+
"refresh_token",
|
|
80
|
+
"cookie",
|
|
81
|
+
"authorization",
|
|
82
|
+
] {
|
|
83
|
+
assert!(
|
|
84
|
+
!serialized.to_ascii_lowercase().contains(secret_surface),
|
|
85
|
+
"doctor must expose identity/digest/key names, never credential values"
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
let connected = pi_doctor_facts(PiDoctorInput {
|
|
90
|
+
mcp_roundtrip_at: Some("2026-08-29T10:02:00+00:00".to_string()),
|
|
91
|
+
backing: PiBackingStatus::Captured,
|
|
92
|
+
..doctor_input()
|
|
93
|
+
});
|
|
94
|
+
assert_eq!(connected.mcp, PiMcpStatus::RoundtripVerified);
|
|
95
|
+
assert!(connected.mcp_connected);
|
|
96
|
+
assert_eq!(connected.backing, PiBackingStatus::Captured);
|
|
97
|
+
assert_eq!(connected.activity, TurnState::Unknown);
|
|
98
|
+
}
|
|
@@ -18,8 +18,9 @@ use std::time::{Duration, Instant};
|
|
|
18
18
|
|
|
19
19
|
use crate::event_log::EventLog;
|
|
20
20
|
use crate::lifecycle::launch::pi_mcp::{
|
|
21
|
-
materialize_pi_plan, pi_seat_paths, PiMaterializeRequest, PiSessionScope,
|
|
21
|
+
materialize_pi_plan, pi_model_candidates, pi_seat_paths, PiMaterializeRequest, PiSessionScope,
|
|
22
22
|
};
|
|
23
|
+
use crate::lifecycle::launch::run_pi_catalog_preflight;
|
|
23
24
|
use crate::lifecycle::tests::test_binary_path;
|
|
24
25
|
use crate::message_store::MessageStore;
|
|
25
26
|
use crate::provider::McpConfig;
|
|
@@ -90,6 +91,23 @@ esac
|
|
|
90
91
|
call_log.to_str().expect("call log path must be UTF-8"),
|
|
91
92
|
);
|
|
92
93
|
|
|
94
|
+
let roles = hermetic.workspace("roles");
|
|
95
|
+
let agents = roles.join("agents");
|
|
96
|
+
std::fs::create_dir_all(&agents).expect("create Pi role directory");
|
|
97
|
+
std::fs::write(
|
|
98
|
+
agents.join("n1.md"),
|
|
99
|
+
"---\nprovider: pi\nmodel: team-agent/qwen3.8-27b\n---\nN1 native Pi fixture\n",
|
|
100
|
+
)
|
|
101
|
+
.expect("write exact-model Pi role");
|
|
102
|
+
assert_eq!(
|
|
103
|
+
pi_model_candidates("qwen3.8-27b").expect("fake Pi model catalog"),
|
|
104
|
+
["team-agent/qwen3.8-27b"],
|
|
105
|
+
"catalog discovery must succeed without consulting the package list"
|
|
106
|
+
);
|
|
107
|
+
let mut discover = |requested: &str| pi_model_candidates(requested).map_err(|_| ());
|
|
108
|
+
run_pi_catalog_preflight(&roles, &mut discover)
|
|
109
|
+
.expect("exact-model catalog preflight must pass on native-only Pi");
|
|
110
|
+
|
|
93
111
|
let harness = sim::McpSimHarness::new();
|
|
94
112
|
harness.bind_leader_receiver_to_team("teamA");
|
|
95
113
|
let workspace = harness.workspace_path();
|
|
@@ -131,6 +149,7 @@ esac
|
|
|
131
149
|
team_mcp_tools: &REQUIRED_TOOLS,
|
|
132
150
|
mcp_config: &config,
|
|
133
151
|
session_scope: PiSessionScope::Isolated,
|
|
152
|
+
session_dir: None,
|
|
134
153
|
});
|
|
135
154
|
let pi_calls = std::fs::read_to_string(&call_log).unwrap_or_default();
|
|
136
155
|
assert!(
|
|
@@ -216,7 +235,11 @@ esac
|
|
|
216
235
|
let wire_prompt = native_receipt["wirePrompt"]
|
|
217
236
|
.as_str()
|
|
218
237
|
.expect("Pi wrapper installs an actual tool wire binding");
|
|
219
|
-
assert!(
|
|
238
|
+
assert!(["send_message", "get_team_status"]
|
|
239
|
+
.iter()
|
|
240
|
+
.all(|tool| wire_prompt.contains(tool)));
|
|
241
|
+
assert!(wire_prompt.contains("Use send_message exclusively for communication"));
|
|
242
|
+
assert!(!wire_prompt.contains("report_result"));
|
|
220
243
|
let registration = ®istrations[0];
|
|
221
244
|
let alias = registration["name"]
|
|
222
245
|
.as_str()
|
|
@@ -315,16 +338,15 @@ esac
|
|
|
315
338
|
"report_result stdio call: {}",
|
|
316
339
|
report.body
|
|
317
340
|
);
|
|
318
|
-
let
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
assert_eq!(
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
harness.drive_delivery_twice();
|
|
341
|
+
let message_id = report.body["message_id"].as_str().expect("durable inbound receipt id");
|
|
342
|
+
let inbox = crate::inbox_store::read(harness.workspace_path(), "leader", 10, Some("teamA")).unwrap();
|
|
343
|
+
let record = inbox["messages"].as_array().unwrap().iter()
|
|
344
|
+
.find(|record| record["message_id"] == message_id).expect("report persisted in the inbox");
|
|
345
|
+
assert_eq!(record["team"], "teamA");
|
|
346
|
+
assert_eq!(record["sender"], "worker_a");
|
|
347
|
+
assert_eq!(record["envelope"]["task_id"], "task_mcp");
|
|
348
|
+
assert!(harness.result_row(message_id).is_none(), "no result-ledger coupling");
|
|
349
|
+
assert!(harness.message_rows_containing(&result_marker).is_empty(), "no coordinator outbox");
|
|
328
350
|
assert!(harness.pane_text("leader").contains(&marker));
|
|
329
351
|
assert!(harness.pane_text("leader").contains(&result_marker));
|
|
330
352
|
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
use std::path::{Path, PathBuf};
|
|
2
2
|
use std::sync::atomic::{AtomicU32, Ordering};
|
|
3
3
|
|
|
4
|
-
use crate::
|
|
4
|
+
use crate::lifecycle::launch::pi_mcp::pi_seat_paths;
|
|
5
|
+
use crate::messaging::delivery::{
|
|
6
|
+
recipient_allows_explicit_queue_flush, recipient_requires_single_enter,
|
|
7
|
+
};
|
|
8
|
+
use crate::model::enums::{Provider, ProviderEffort};
|
|
9
|
+
use crate::provider::adapters::pi::{build_pi_command_argv, PiCommandRequest, PiSessionSelector};
|
|
5
10
|
use crate::provider::session_scan::{scan_session_candidates_once, CaptureSessionContext};
|
|
6
|
-
use crate::provider::SessionId;
|
|
11
|
+
use crate::provider::{get_adapter, AuthMode, ProviderError, SessionId};
|
|
7
12
|
|
|
8
13
|
static NEXT_ROOT: AtomicU32 = AtomicU32::new(0);
|
|
9
14
|
|
|
@@ -45,6 +50,20 @@ fn scan_context(cwd: &Path, root: &Path, id: &str, generation: &str) -> CaptureS
|
|
|
45
50
|
}
|
|
46
51
|
}
|
|
47
52
|
|
|
53
|
+
fn resume_argv(path: &Path) -> Result<Vec<String>, ProviderError> {
|
|
54
|
+
build_pi_command_argv(PiCommandRequest {
|
|
55
|
+
extension: Path::new("/workspace/.team/runtime/pi/team-a/worker-a/team-mcp.ts"),
|
|
56
|
+
model: Some("team-agent/qwen3.8-27b"),
|
|
57
|
+
effort: Some(ProviderEffort::Medium),
|
|
58
|
+
system_prompt: "worker contract",
|
|
59
|
+
session_dir: Some(Path::new(
|
|
60
|
+
"/workspace/.team/runtime/pi/team-a/worker-a/sessions",
|
|
61
|
+
)),
|
|
62
|
+
session: PiSessionSelector::Resume { path },
|
|
63
|
+
agent_id: "worker-a",
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
|
|
48
67
|
#[test]
|
|
49
68
|
fn pi_session_capture_requires_header_id_cwd_generation_and_unique_claim() {
|
|
50
69
|
let root = temp_root("session-capture");
|
|
@@ -132,3 +151,76 @@ fn pi_fresh_capture_reads_the_header_id_pi_wrote() {
|
|
|
132
151
|
);
|
|
133
152
|
std::fs::remove_dir_all(root).expect("remove native header fixture");
|
|
134
153
|
}
|
|
154
|
+
|
|
155
|
+
#[test]
|
|
156
|
+
fn pi_restart_uses_exact_path_and_refuses_missing_backing() {
|
|
157
|
+
let root = temp_root("resume");
|
|
158
|
+
let cwd = root.join("workspace");
|
|
159
|
+
let sessions = root.join("seat/sessions");
|
|
160
|
+
std::fs::create_dir_all(&cwd).expect("create cwd");
|
|
161
|
+
let id = "cc09d133-878f-4241-920f-f7ebfefc2a9e";
|
|
162
|
+
let generation = "2026-08-29T10:00:00Z";
|
|
163
|
+
let exact = sessions.join("nested/exact.jsonl");
|
|
164
|
+
write_header(&exact, id, &cwd, "2026-08-29T10:00:01Z");
|
|
165
|
+
|
|
166
|
+
let candidates =
|
|
167
|
+
scan_session_candidates_once(Provider::Pi, &scan_context(&cwd, &sessions, id, generation))
|
|
168
|
+
.expect("resume preflight scan");
|
|
169
|
+
assert_eq!(
|
|
170
|
+
candidates.len(),
|
|
171
|
+
1,
|
|
172
|
+
"exact backing must revalidate before restart"
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
let argv = resume_argv(&exact).expect("resume exact path");
|
|
176
|
+
assert!(argv
|
|
177
|
+
.windows(2)
|
|
178
|
+
.any(|pair| { pair[0] == "--session" && pair[1] == exact.to_string_lossy().as_ref() }));
|
|
179
|
+
assert!(!argv.iter().any(|arg| {
|
|
180
|
+
matches!(
|
|
181
|
+
arg.as_str(),
|
|
182
|
+
"--session-id" | "-c" | "--continue" | "-r" | "--resume"
|
|
183
|
+
)
|
|
184
|
+
}));
|
|
185
|
+
|
|
186
|
+
std::fs::remove_file(&exact).expect("remove backing tooth");
|
|
187
|
+
let missing = resume_argv(&exact);
|
|
188
|
+
assert!(
|
|
189
|
+
matches!(missing, Err(ProviderError::ResumeUnavailable(_))),
|
|
190
|
+
"missing exact backing must refuse rather than create a new session: {missing:?}"
|
|
191
|
+
);
|
|
192
|
+
std::fs::remove_dir_all(root).expect("remove resume fixture");
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
#[test]
|
|
196
|
+
fn pi_delivery_submits_one_enter_and_never_flushes_or_retries() {
|
|
197
|
+
let idle = serde_json::json!({
|
|
198
|
+
"agents": {
|
|
199
|
+
"worker-a": {"provider": "pi", "status": "running"}
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
assert!(recipient_requires_single_enter(&idle, "worker-a"));
|
|
203
|
+
assert!(!recipient_allows_explicit_queue_flush(&idle, "worker-a"));
|
|
204
|
+
let busy = serde_json::json!({
|
|
205
|
+
"agents": {
|
|
206
|
+
"worker-a": {"provider": "pi", "status": "busy"}
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
// Working native CLIs queue the same single-Enter input; no idle admission.
|
|
210
|
+
assert!(recipient_requires_single_enter(&busy, "worker-a"));
|
|
211
|
+
assert!(!recipient_allows_explicit_queue_flush(&busy, "worker-a"));
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
#[test]
|
|
215
|
+
fn pi_clone_is_fresh_and_fork_is_not_clone() {
|
|
216
|
+
let workspace = Path::new("/workspace");
|
|
217
|
+
let source_paths = pi_seat_paths(workspace, "team-a", "source");
|
|
218
|
+
let clone_paths = pi_seat_paths(workspace, "team-a", "clone");
|
|
219
|
+
assert_ne!(source_paths.runtime_root, clone_paths.runtime_root);
|
|
220
|
+
assert_ne!(source_paths.wrapper, clone_paths.wrapper);
|
|
221
|
+
assert_eq!(source_paths.sessions, clone_paths.sessions);
|
|
222
|
+
|
|
223
|
+
let source_session = SessionId::new("652756ea-aaee-4437-a30f-40c5606826d5");
|
|
224
|
+
let fork = get_adapter(Provider::Pi).fork(Some(&source_session), AuthMode::Subscription, None);
|
|
225
|
+
assert!(matches!(fork, Err(ProviderError::CapabilityUnsupported(_))));
|
|
226
|
+
}
|
|
@@ -38,9 +38,9 @@ use hermetic::HermeticTestEnv;
|
|
|
38
38
|
const TEAM_MD: &str =
|
|
39
39
|
"---\nname: bug7\nobjective: BUG-7 worker readiness honesty contract.\nprovider: codex\n---\n\nTeam.\n";
|
|
40
40
|
|
|
41
|
-
const
|
|
41
|
+
const FAKE_ROLE: &str = "---\nname: faker\nrole: Fake Worker\nprovider: fake\nmodel: fake\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nFake worker.\n";
|
|
42
42
|
|
|
43
|
-
const
|
|
43
|
+
const CLAUDE_ROLE: &str = "---\nname: clauder\nrole: Claude Worker\nprovider: claude\nmodel: claude-sonnet-4-6\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nClaude worker.\n";
|
|
44
44
|
|
|
45
45
|
#[test]
|
|
46
46
|
#[ignore = "real-machine: quick-start worker readiness gate"]
|
|
@@ -51,10 +51,10 @@ fn t1_quick_start_must_not_emit_bare_ready_when_worker_tool_load_is_unverified()
|
|
|
51
51
|
let team = bug7_team_dir(&hermetic, "t1-pending");
|
|
52
52
|
// Both agents spawn successfully (recording transport reports both windows live)
|
|
53
53
|
// but the framework has no way to verify the worker MCP tool set actually
|
|
54
|
-
// loaded —
|
|
54
|
+
// loaded — claude can still reject schemas asynchronously. The report
|
|
55
55
|
// therefore must be PendingToolLoad, not bare Ready.
|
|
56
56
|
let transport = RecordingTransport::new()
|
|
57
|
-
.with_windows(vec![WindowName::new("
|
|
57
|
+
.with_windows(vec![WindowName::new("faker"), WindowName::new("clauder")]);
|
|
58
58
|
let report = quick_start_with_transport(&team, None, true, None, &transport)
|
|
59
59
|
.expect("quick_start_with_transport should succeed for healthy spawn");
|
|
60
60
|
let QuickStartReport::Ready {
|
|
@@ -97,12 +97,12 @@ fn t2_quick_start_must_report_degraded_when_a_worker_spawn_yields_no_live_window
|
|
|
97
97
|
hermetic.scrub_tmux();
|
|
98
98
|
hermetic.assert_no_real_tmux();
|
|
99
99
|
let team = bug7_team_dir(&hermetic, "t2-degraded");
|
|
100
|
-
// Recording transport simulates the Mac mini final capture: only the
|
|
101
|
-
// window exists after launch; the
|
|
102
|
-
// `
|
|
100
|
+
// Recording transport simulates the Mac mini final capture: only the fake
|
|
101
|
+
// worker window exists after launch; the claude window never materialized (no
|
|
102
|
+
// `claude` binary on PATH, etc.). BUG-2 fix already marks `clauder` as
|
|
103
103
|
// spawn_failed in runtime state; BUG-7 must surface that as a Degraded
|
|
104
104
|
// verdict so quick-start cannot pretend the team is ready.
|
|
105
|
-
let transport = RecordingTransport::new().with_windows(vec![WindowName::new("
|
|
105
|
+
let transport = RecordingTransport::new().with_windows(vec![WindowName::new("faker")]);
|
|
106
106
|
let report = quick_start_with_transport(&team, None, true, None, &transport)
|
|
107
107
|
.expect("quick_start_with_transport should reach the spawn/state path even when an agent fails to spawn");
|
|
108
108
|
let QuickStartReport::Ready {
|
|
@@ -117,9 +117,9 @@ fn t2_quick_start_must_report_degraded_when_a_worker_spawn_yields_no_live_window
|
|
|
117
117
|
);
|
|
118
118
|
};
|
|
119
119
|
assert!(
|
|
120
|
-
unhealthy_agents.iter().any(|id| id == "
|
|
120
|
+
unhealthy_agents.iter().any(|id| id == "clauder"),
|
|
121
121
|
"T2: Degraded verdict must list the agent whose window never materialized \
|
|
122
|
-
(
|
|
122
|
+
(clauder); got unhealthy_agents={unhealthy_agents:?}"
|
|
123
123
|
);
|
|
124
124
|
let rendered = render_quick_start_summary(&report);
|
|
125
125
|
assert!(
|
|
@@ -128,8 +128,8 @@ fn t2_quick_start_must_report_degraded_when_a_worker_spawn_yields_no_live_window
|
|
|
128
128
|
the report as ready; got {rendered:?}"
|
|
129
129
|
);
|
|
130
130
|
assert!(
|
|
131
|
-
rendered.contains("
|
|
132
|
-
"T2: CLI summary should mention the unhealthy agent id (
|
|
131
|
+
rendered.contains("clauder"),
|
|
132
|
+
"T2: CLI summary should mention the unhealthy agent id (clauder); got {rendered:?}"
|
|
133
133
|
);
|
|
134
134
|
}
|
|
135
135
|
|
|
@@ -144,9 +144,8 @@ fn bug7_team_dir(hermetic: &HermeticTestEnv, tag: &str) -> PathBuf {
|
|
|
144
144
|
let team = base.join("teamdir");
|
|
145
145
|
std::fs::create_dir_all(team.join("agents")).expect("mkdir teamdir/agents");
|
|
146
146
|
std::fs::write(team.join("TEAM.md"), TEAM_MD).expect("write TEAM.md");
|
|
147
|
-
std::fs::write(team.join("agents").join("
|
|
148
|
-
std::fs::write(team.join("agents").join("
|
|
149
|
-
.expect("write copiloter.md");
|
|
147
|
+
std::fs::write(team.join("agents").join("faker.md"), FAKE_ROLE).expect("write faker.md");
|
|
148
|
+
std::fs::write(team.join("agents").join("clauder.md"), CLAUDE_ROLE).expect("write clauder.md");
|
|
150
149
|
team
|
|
151
150
|
}
|
|
152
151
|
|
|
@@ -20,9 +20,9 @@ use super::*;
|
|
|
20
20
|
use crate::lifecycle::restart::classify_restart_plan;
|
|
21
21
|
use crate::lifecycle::types::{ResumeDecision, StartMode};
|
|
22
22
|
|
|
23
|
-
fn
|
|
23
|
+
fn agent_copilot(session_id: Option<&str>, first_send_at: serde_json::Value) -> serde_json::Value {
|
|
24
24
|
let mut obj = serde_json::Map::new();
|
|
25
|
-
obj.insert("provider".to_string(), json!("
|
|
25
|
+
obj.insert("provider".to_string(), json!("copilot"));
|
|
26
26
|
obj.insert("status".to_string(), json!("running"));
|
|
27
27
|
obj.insert("first_send_at".to_string(), first_send_at);
|
|
28
28
|
if let Some(sid) = session_id {
|
|
@@ -35,7 +35,7 @@ fn agent_codex(session_id: Option<&str>, first_send_at: serde_json::Value) -> se
|
|
|
35
35
|
fn unit0_restart_missing_session_id_is_no_persisted_session_id() {
|
|
36
36
|
let state = json!({
|
|
37
37
|
"agents": {
|
|
38
|
-
"a":
|
|
38
|
+
"a": agent_copilot(None, json!("2026-01-01T00:00:00Z")),
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
41
|
let plan = classify_restart_plan(&state, false).unwrap();
|
|
@@ -53,7 +53,7 @@ fn unit0_restart_session_id_present_no_backing_is_session_unresumable() {
|
|
|
53
53
|
// — the opaque reason that unit-5 will replace with structured enum.
|
|
54
54
|
let state = json!({
|
|
55
55
|
"agents": {
|
|
56
|
-
"a":
|
|
56
|
+
"a": agent_copilot(Some("sess-unit0-missing"), json!("2026-01-01T00:00:00Z")),
|
|
57
57
|
}
|
|
58
58
|
});
|
|
59
59
|
let plan = classify_restart_plan(&state, false).unwrap();
|
|
@@ -67,8 +67,8 @@ fn unit0_restart_session_id_present_no_backing_is_session_unresumable() {
|
|
|
67
67
|
fn unit0_restart_allow_fresh_converts_refusals_into_fresh_decisions() {
|
|
68
68
|
let state = json!({
|
|
69
69
|
"agents": {
|
|
70
|
-
"a":
|
|
71
|
-
"b":
|
|
70
|
+
"a": agent_copilot(None, json!("2026-01-01T00:00:00Z")),
|
|
71
|
+
"b": agent_copilot(Some("sess-unit0-allow-fresh"), json!("2026-01-01T00:00:00Z")),
|
|
72
72
|
}
|
|
73
73
|
});
|
|
74
74
|
let plan = classify_restart_plan(&state, true).unwrap();
|
|
@@ -93,8 +93,9 @@ fn unit0_restart_allow_fresh_converts_refusals_into_fresh_decisions() {
|
|
|
93
93
|
#[test]
|
|
94
94
|
fn layer2_backing_missing_refusal_carries_checked_paths_and_recovery_hint() {
|
|
95
95
|
// Leader follow-up 2026-06-22: when classify_restart_plan_with_resume_validation
|
|
96
|
-
// runs with a real workspace, a
|
|
97
|
-
// but whose rollout_path does not exist on disk
|
|
96
|
+
// runs with a real workspace, a copilot worker whose session_id is set
|
|
97
|
+
// but whose rollout_path does not exist on disk (and whose id has no
|
|
98
|
+
// ~/.copilot/session-store.db row) should produce a
|
|
98
99
|
// refusal whose structured ResumeRefusalReason::SessionBackingStoreMissing
|
|
99
100
|
// carries the actual probed paths (the persisted rollout_path) AND a
|
|
100
101
|
// RecoveryHint with the agent_id as the picker name.
|
|
@@ -109,7 +110,7 @@ fn layer2_backing_missing_refusal_carries_checked_paths_and_recovery_hint() {
|
|
|
109
110
|
// Do NOT create the file. Probe must report it as not-existing AND
|
|
110
111
|
// include it in checked_paths.
|
|
111
112
|
let mut agent = serde_json::Map::new();
|
|
112
|
-
agent.insert("provider".to_string(), json!("
|
|
113
|
+
agent.insert("provider".to_string(), json!("copilot"));
|
|
113
114
|
agent.insert("status".to_string(), json!("running"));
|
|
114
115
|
agent.insert("session_id".to_string(), json!("sess-layer2-missing"));
|
|
115
116
|
agent.insert(
|
|
@@ -156,7 +157,7 @@ fn layer2_backing_missing_refusal_carries_checked_paths_and_recovery_hint() {
|
|
|
156
157
|
Some(ws.as_path()),
|
|
157
158
|
"spawn_cwd should round-trip through the hint"
|
|
158
159
|
);
|
|
159
|
-
assert_eq!(hint.provider, "
|
|
160
|
+
assert_eq!(hint.provider, "copilot");
|
|
160
161
|
}
|
|
161
162
|
other => panic!(
|
|
162
163
|
"expected SessionBackingStoreMissing with structured fields; got {:?}",
|
|
@@ -165,148 +166,6 @@ fn layer2_backing_missing_refusal_carries_checked_paths_and_recovery_hint() {
|
|
|
165
166
|
}
|
|
166
167
|
}
|
|
167
168
|
|
|
168
|
-
fn write_codex_identity_rollout(
|
|
169
|
-
workspace: &std::path::Path,
|
|
170
|
-
file_name: &str,
|
|
171
|
-
session_id: &str,
|
|
172
|
-
embedded_agent_id: &str,
|
|
173
|
-
) -> std::path::PathBuf {
|
|
174
|
-
let path = workspace.join(file_name);
|
|
175
|
-
let text = format!(
|
|
176
|
-
"{{\"session_meta\":{{\"payload\":{{\"id\":\"{session_id}\",\"cwd\":\"{}\"}}}}}}\n\
|
|
177
|
-
{{\"type\":\"turn_context\",\"payload\":{{}}}}\n\
|
|
178
|
-
{{\"type\":\"response_item\",\"payload\":{{\"content\":[{{\"type\":\"input_text\",\"text\":\"You are Team Agent worker `{embedded_agent_id}` with role `fixture`.\"}}]}}}}\n",
|
|
179
|
-
workspace.to_string_lossy()
|
|
180
|
-
);
|
|
181
|
-
std::fs::write(&path, text).unwrap();
|
|
182
|
-
path
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
#[test]
|
|
186
|
-
fn restart_refuses_codex_session_identity_mismatch_without_allow_fresh() {
|
|
187
|
-
let ws = temp_ws();
|
|
188
|
-
let rollout = write_codex_identity_rollout(
|
|
189
|
-
&ws,
|
|
190
|
-
"rollout-frontend-poison.jsonl",
|
|
191
|
-
"019f3327-c35a-7023-b3cd-1bea93a7a157",
|
|
192
|
-
"ios-dev",
|
|
193
|
-
);
|
|
194
|
-
let state = json!({
|
|
195
|
-
"agents": {
|
|
196
|
-
"frontend": {
|
|
197
|
-
"provider": "codex",
|
|
198
|
-
"status": "running",
|
|
199
|
-
"session_id": "019f3327-c35a-7023-b3cd-1bea93a7a157",
|
|
200
|
-
"rollout_path": rollout.to_string_lossy(),
|
|
201
|
-
"captured_at": "2026-07-05T17:04:04Z",
|
|
202
|
-
"captured_via": "fs_watch",
|
|
203
|
-
"spawn_cwd": ws.to_string_lossy(),
|
|
204
|
-
"first_send_at": "2026-07-05T17:10:00Z"
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
let plan = crate::lifecycle::restart::classify_restart_plan_with_resume_validation(
|
|
210
|
-
Some(&ws),
|
|
211
|
-
&state,
|
|
212
|
-
false,
|
|
213
|
-
)
|
|
214
|
-
.unwrap();
|
|
215
|
-
|
|
216
|
-
assert_eq!(plan.decisions.len(), 1);
|
|
217
|
-
assert_eq!(plan.decisions[0].decision, ResumeDecision::Refuse);
|
|
218
|
-
assert_eq!(plan.unresumable.len(), 1);
|
|
219
|
-
let entry = &plan.unresumable[0];
|
|
220
|
-
assert_eq!(entry.agent_id.as_str(), "frontend");
|
|
221
|
-
assert_eq!(entry.reason, "session_identity_mismatch");
|
|
222
|
-
assert_eq!(
|
|
223
|
-
entry
|
|
224
|
-
.refusal_reason
|
|
225
|
-
.as_ref()
|
|
226
|
-
.map(crate::provider::session::ResumeRefusalReason::wire),
|
|
227
|
-
Some("session_identity_mismatch")
|
|
228
|
-
);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
#[test]
|
|
232
|
-
fn restart_identity_probe_reports_real_frontend_ios_dev_mismatch_shape() {
|
|
233
|
-
let ws = temp_ws();
|
|
234
|
-
let rollout = write_codex_identity_rollout(
|
|
235
|
-
&ws,
|
|
236
|
-
"rollout-frontend-poison.jsonl",
|
|
237
|
-
"019f3327-c35a-7023-b3cd-1bea93a7a157",
|
|
238
|
-
"ios-dev",
|
|
239
|
-
);
|
|
240
|
-
let rollout_path = crate::provider::RolloutPath::new(rollout.clone());
|
|
241
|
-
let probe = crate::lifecycle::restart::session_identity_probe_for_agent(
|
|
242
|
-
&aid("frontend"),
|
|
243
|
-
crate::provider::Provider::Codex,
|
|
244
|
-
Some(&rollout_path),
|
|
245
|
-
);
|
|
246
|
-
assert_eq!(probe.identity_ok, Some(false));
|
|
247
|
-
assert_eq!(probe.embedded_agent_id.as_deref(), Some("ios-dev"));
|
|
248
|
-
assert_eq!(probe.rollout_path.as_deref(), Some(rollout.as_path()));
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
#[test]
|
|
252
|
-
fn restart_allow_fresh_only_fresh_starts_mismatched_codex_worker() {
|
|
253
|
-
let ws = temp_ws();
|
|
254
|
-
let frontend_rollout = write_codex_identity_rollout(
|
|
255
|
-
&ws,
|
|
256
|
-
"rollout-frontend-poison.jsonl",
|
|
257
|
-
"019f3327-c35a-7023-b3cd-1bea93a7a157",
|
|
258
|
-
"ios-dev",
|
|
259
|
-
);
|
|
260
|
-
let backend_rollout = write_codex_identity_rollout(
|
|
261
|
-
&ws,
|
|
262
|
-
"rollout-backend-valid.jsonl",
|
|
263
|
-
"019f3327-backend-valid",
|
|
264
|
-
"backend",
|
|
265
|
-
);
|
|
266
|
-
let state = json!({
|
|
267
|
-
"agents": {
|
|
268
|
-
"frontend": {
|
|
269
|
-
"provider": "codex",
|
|
270
|
-
"status": "running",
|
|
271
|
-
"session_id": "019f3327-c35a-7023-b3cd-1bea93a7a157",
|
|
272
|
-
"rollout_path": frontend_rollout.to_string_lossy(),
|
|
273
|
-
"captured_at": "2026-07-05T17:04:04Z",
|
|
274
|
-
"captured_via": "fs_watch",
|
|
275
|
-
"spawn_cwd": ws.to_string_lossy()
|
|
276
|
-
},
|
|
277
|
-
"backend": {
|
|
278
|
-
"provider": "codex",
|
|
279
|
-
"status": "running",
|
|
280
|
-
"session_id": "019f3327-backend-valid",
|
|
281
|
-
"rollout_path": backend_rollout.to_string_lossy(),
|
|
282
|
-
"captured_at": "2026-07-05T17:04:05Z",
|
|
283
|
-
"captured_via": "fs_watch",
|
|
284
|
-
"spawn_cwd": ws.to_string_lossy()
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
let plan = crate::lifecycle::restart::classify_restart_plan_with_resume_validation(
|
|
290
|
-
Some(&ws),
|
|
291
|
-
&state,
|
|
292
|
-
true,
|
|
293
|
-
)
|
|
294
|
-
.unwrap();
|
|
295
|
-
|
|
296
|
-
assert!(
|
|
297
|
-
plan.unresumable.is_empty(),
|
|
298
|
-
"allow_fresh should convert the poisoned worker to fresh without refusing; got {:?}",
|
|
299
|
-
plan.unresumable
|
|
300
|
-
);
|
|
301
|
-
let decisions = plan
|
|
302
|
-
.decisions
|
|
303
|
-
.iter()
|
|
304
|
-
.map(|decision| (decision.agent_id.as_str(), decision.decision))
|
|
305
|
-
.collect::<std::collections::BTreeMap<_, _>>();
|
|
306
|
-
assert_eq!(decisions.get("frontend"), Some(&ResumeDecision::FreshStart));
|
|
307
|
-
assert_eq!(decisions.get("backend"), Some(&ResumeDecision::Resume));
|
|
308
|
-
}
|
|
309
|
-
|
|
310
169
|
#[test]
|
|
311
170
|
fn unit0_restart_corrupt_first_send_at_blocks_before_resume_classification() {
|
|
312
171
|
// The corrupt-first_send_at branch is the hard-refuse gate that fires
|
|
@@ -315,7 +174,7 @@ fn unit0_restart_corrupt_first_send_at_blocks_before_resume_classification() {
|
|
|
315
174
|
// stays empty for the corrupt agent.
|
|
316
175
|
let state = json!({
|
|
317
176
|
"agents": {
|
|
318
|
-
"a":
|
|
177
|
+
"a": agent_copilot(Some("sess-unit0-corrupt"), json!(false)),
|
|
319
178
|
}
|
|
320
179
|
});
|
|
321
180
|
let plan = classify_restart_plan(&state, false).unwrap();
|
|
@@ -97,7 +97,7 @@ fn server_exited_during_replacement_spawn_does_not_cascade_session_disappeared_a
|
|
|
97
97
|
let case = RestartCase::new(
|
|
98
98
|
"case-b-no-second-cascade",
|
|
99
99
|
worker_ids(2),
|
|
100
|
-
ProviderShape::
|
|
100
|
+
ProviderShape::CopilotResumable,
|
|
101
101
|
);
|
|
102
102
|
let transport =
|
|
103
103
|
BuildBeforeDestroyTransport::recording(worker_ids(2)).with_server_exit_after_first_spawn();
|
|
@@ -257,6 +257,9 @@ impl RestartCase {
|
|
|
257
257
|
|
|
258
258
|
fn seed_state_with_panes(&self, provider: ProviderShape, panes: &BTreeMap<String, String>) {
|
|
259
259
|
seed_restart_state(&self.workspace, &self.workers, provider, panes);
|
|
260
|
+
if matches!(provider, ProviderShape::CopilotResumable) {
|
|
261
|
+
seed_copilot_session_store(self.env.home(), &self.workers);
|
|
262
|
+
}
|
|
260
263
|
seed_healthy_coordinator(&self.workspace);
|
|
261
264
|
}
|
|
262
265
|
|
|
@@ -278,21 +281,21 @@ impl RestartCase {
|
|
|
278
281
|
#[derive(Clone, Copy)]
|
|
279
282
|
enum ProviderShape {
|
|
280
283
|
Fake,
|
|
281
|
-
|
|
284
|
+
CopilotResumable,
|
|
282
285
|
}
|
|
283
286
|
|
|
284
287
|
impl ProviderShape {
|
|
285
288
|
fn provider(self) -> &'static str {
|
|
286
289
|
match self {
|
|
287
290
|
Self::Fake => "fake",
|
|
288
|
-
Self::
|
|
291
|
+
Self::CopilotResumable => "copilot",
|
|
289
292
|
}
|
|
290
293
|
}
|
|
291
294
|
|
|
292
295
|
fn model(self) -> &'static str {
|
|
293
296
|
match self {
|
|
294
297
|
Self::Fake => "fake",
|
|
295
|
-
Self::
|
|
298
|
+
Self::CopilotResumable => "gpt-5",
|
|
296
299
|
}
|
|
297
300
|
}
|
|
298
301
|
}
|
|
@@ -354,7 +357,7 @@ fn seed_restart_state(
|
|
|
354
357
|
"spawn_cwd": workspace.to_string_lossy(),
|
|
355
358
|
"spawned_at": "2026-07-14T00:00:00+00:00",
|
|
356
359
|
});
|
|
357
|
-
if matches!(provider, ProviderShape::
|
|
360
|
+
if matches!(provider, ProviderShape::CopilotResumable) {
|
|
358
361
|
let rollout = workspace.join(format!("{worker}.jsonl"));
|
|
359
362
|
fs::write(&rollout, "{}\n").expect("write rollout fixture");
|
|
360
363
|
let row_obj = row.as_object_mut().expect("agent row object");
|
|
@@ -401,6 +404,25 @@ fn seed_restart_state(
|
|
|
401
404
|
.expect("seed runtime state");
|
|
402
405
|
}
|
|
403
406
|
|
|
407
|
+
/// Copilot resume backing is the `sessions` row in the hermetic
|
|
408
|
+
/// `$HOME/.copilot/session-store.db`.
|
|
409
|
+
fn seed_copilot_session_store(home: &Path, workers: &[String]) {
|
|
410
|
+
let db = home.join(".copilot").join("session-store.db");
|
|
411
|
+
fs::create_dir_all(db.parent().expect("copilot store parent")).expect("create copilot dir");
|
|
412
|
+
let conn = rusqlite::Connection::open(db).expect("open copilot session store");
|
|
413
|
+
conn.execute_batch(
|
|
414
|
+
"create table if not exists sessions (id text primary key, cwd text, created_at text);",
|
|
415
|
+
)
|
|
416
|
+
.expect("create copilot sessions table");
|
|
417
|
+
for worker in workers {
|
|
418
|
+
conn.execute(
|
|
419
|
+
"insert or replace into sessions(id, cwd, created_at) values (?1, ?2, '2026-07-14T00:00:00Z')",
|
|
420
|
+
rusqlite::params![format!("session-{worker}"), home.to_string_lossy()],
|
|
421
|
+
)
|
|
422
|
+
.expect("seed copilot session row");
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
404
426
|
fn seed_healthy_coordinator(workspace: &Path) {
|
|
405
427
|
fs::create_dir_all(runtime_dir(workspace)).expect("create runtime dir");
|
|
406
428
|
let _store = MessageStore::open(workspace).expect("create message store schema");
|