@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
|
@@ -8,7 +8,7 @@ use crate::transport::test_support::OfflineTransport;
|
|
|
8
8
|
|
|
9
9
|
#[test]
|
|
10
10
|
fn abnormal_exit_is_reported_without_auto_recovery_intent_or_action() {
|
|
11
|
-
let case = RecoveryCase::new("reported-no-auto"
|
|
11
|
+
let case = RecoveryCase::new("reported-no-auto");
|
|
12
12
|
case.seed_agent("baseline-429");
|
|
13
13
|
let transport = OfflineTransport::new().with_session_present(true);
|
|
14
14
|
let coord = case.coord(transport.clone());
|
|
@@ -61,9 +61,7 @@ fn abnormal_exit_is_reported_without_auto_recovery_intent_or_action() {
|
|
|
61
61
|
|
|
62
62
|
#[test]
|
|
63
63
|
fn first_turn_death_cannot_enter_auto_respawn_loop_and_manual_start_still_recovers() {
|
|
64
|
-
|
|
65
|
-
// both an explicit failed-turn fact and a resumable manual start.
|
|
66
|
-
let case = RecoveryCase::new("first-turn-death-no-loop", "codex");
|
|
64
|
+
let case = RecoveryCase::new("first-turn-death-no-loop");
|
|
67
65
|
case.seed_agent("baseline-429");
|
|
68
66
|
let transport = OfflineTransport::new().with_session_present(true);
|
|
69
67
|
let coord = case.coord(transport.clone());
|
|
@@ -133,11 +131,10 @@ fn first_turn_death_cannot_enter_auto_respawn_loop_and_manual_start_still_recove
|
|
|
133
131
|
|
|
134
132
|
struct RecoveryCase {
|
|
135
133
|
root: std::path::PathBuf,
|
|
136
|
-
provider: &'static str,
|
|
137
134
|
}
|
|
138
135
|
|
|
139
136
|
impl RecoveryCase {
|
|
140
|
-
fn new(tag: &str
|
|
137
|
+
fn new(tag: &str) -> Self {
|
|
141
138
|
let base = std::env::var_os("TEAM_AGENT_TEST_TMP")
|
|
142
139
|
.map(std::path::PathBuf::from)
|
|
143
140
|
.unwrap_or_else(std::env::temp_dir);
|
|
@@ -151,7 +148,7 @@ impl RecoveryCase {
|
|
|
151
148
|
.as_nanos()
|
|
152
149
|
));
|
|
153
150
|
std::fs::create_dir_all(&root).unwrap();
|
|
154
|
-
Self { root
|
|
151
|
+
Self { root }
|
|
155
152
|
}
|
|
156
153
|
|
|
157
154
|
fn coord(&self, transport: OfflineTransport) -> Coordinator {
|
|
@@ -166,8 +163,7 @@ impl RecoveryCase {
|
|
|
166
163
|
|
|
167
164
|
fn seed_agent(&self, uuid: &str) {
|
|
168
165
|
let rollout = self.rollout();
|
|
169
|
-
std::fs::write(&rollout,
|
|
170
|
-
let model = if self.provider == "codex" { "gpt-5.5" } else { "sonnet" };
|
|
166
|
+
std::fs::write(&rollout, claude_api_error_line(uuid)).unwrap();
|
|
171
167
|
let state = serde_json::json!({
|
|
172
168
|
"active_team_key": "research",
|
|
173
169
|
"team_key": "research",
|
|
@@ -183,8 +179,8 @@ impl RecoveryCase {
|
|
|
183
179
|
"fe-admin": {
|
|
184
180
|
"agent_id": "fe-admin",
|
|
185
181
|
"id": "fe-admin",
|
|
186
|
-
"provider":
|
|
187
|
-
"model":
|
|
182
|
+
"provider": "claude_code",
|
|
183
|
+
"model": "sonnet",
|
|
188
184
|
"status": "running",
|
|
189
185
|
"window": "fe-admin",
|
|
190
186
|
"rollout_path": rollout,
|
|
@@ -240,17 +236,10 @@ impl RecoveryCase {
|
|
|
240
236
|
.append(true)
|
|
241
237
|
.open(self.rollout())
|
|
242
238
|
.unwrap();
|
|
243
|
-
file.write_all(
|
|
239
|
+
file.write_all(claude_api_error_line(uuid).as_bytes())
|
|
244
240
|
.unwrap();
|
|
245
241
|
}
|
|
246
242
|
|
|
247
|
-
fn error_line(&self, uuid: &str) -> String {
|
|
248
|
-
match self.provider {
|
|
249
|
-
"codex" => codex_failed_turn_line(uuid),
|
|
250
|
-
_ => claude_api_error_line(uuid),
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
243
|
fn rollout(&self) -> std::path::PathBuf {
|
|
255
244
|
self.root.join("rollout-fe-admin.jsonl")
|
|
256
245
|
}
|
|
@@ -303,16 +292,6 @@ fn claude_api_error_line(uuid: &str) -> String {
|
|
|
303
292
|
)
|
|
304
293
|
}
|
|
305
294
|
|
|
306
|
-
fn codex_failed_turn_line(turn_id: &str) -> String {
|
|
307
|
-
format!(
|
|
308
|
-
"{}\n",
|
|
309
|
-
serde_json::json!({
|
|
310
|
-
"method": "turn/completed",
|
|
311
|
-
"params": {"turn": {"id": turn_id, "status": "failed"}}
|
|
312
|
-
})
|
|
313
|
-
)
|
|
314
|
-
}
|
|
315
|
-
|
|
316
295
|
fn find_event<'a>(events: &'a [serde_json::Value], name: &str) -> Option<&'a serde_json::Value> {
|
|
317
296
|
events
|
|
318
297
|
.iter()
|
|
@@ -25,13 +25,13 @@ fn slice1_stopped_or_missing_agents_do_not_probe_or_emit_capture_failures() {
|
|
|
25
25
|
"session_name": "team-energy",
|
|
26
26
|
"agents": {
|
|
27
27
|
"stopped": {
|
|
28
|
-
"provider": "
|
|
28
|
+
"provider": "copilot",
|
|
29
29
|
"status": "stopped",
|
|
30
30
|
"window": "stopped",
|
|
31
31
|
"pane_id": "%stopped"
|
|
32
32
|
},
|
|
33
33
|
"missing": {
|
|
34
|
-
"provider": "
|
|
34
|
+
"provider": "copilot",
|
|
35
35
|
"status": "running",
|
|
36
36
|
"window": "missing",
|
|
37
37
|
"pane_id": "%missing"
|
|
@@ -306,7 +306,7 @@ fn coordinator(workspace: &Path, transport: EnergyTransport) -> Coordinator {
|
|
|
306
306
|
|
|
307
307
|
fn running_agent(extra: Value) -> Value {
|
|
308
308
|
let mut agent = json!({
|
|
309
|
-
"provider": "
|
|
309
|
+
"provider": "copilot",
|
|
310
310
|
"status": "running",
|
|
311
311
|
"window": "w1",
|
|
312
312
|
"pane_id": "%1",
|
|
@@ -337,7 +337,7 @@ fn pane(pane_id: &str, window: &str) -> PaneInfo {
|
|
|
337
337
|
window_name: Some(WindowName::new(window)),
|
|
338
338
|
pane_index: Some(0),
|
|
339
339
|
tty: None,
|
|
340
|
-
current_command: Some("
|
|
340
|
+
current_command: Some("copilot".to_string()),
|
|
341
341
|
current_path: None,
|
|
342
342
|
active: true,
|
|
343
343
|
pane_pid: Some(1001),
|
|
@@ -230,13 +230,55 @@ fn spine2_sync_health_records_last_output_at() {
|
|
|
230
230
|
);
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
+
// P1 — capture_missing: an agent with NO session_id but a discoverable transcript under spawn_cwd gets
|
|
234
|
+
// its session_id captured + persisted (real capture_session_id); an agent that already has one is
|
|
235
|
+
// untouched. Golden sessions/capture.py:capture_missing_sessions.
|
|
236
|
+
#[test]
|
|
237
|
+
fn spine2_capture_missing_captures_session_id_for_missing_agent() {
|
|
238
|
+
use std::sync::atomic::{AtomicU64, Ordering};
|
|
239
|
+
static N: AtomicU64 = AtomicU64::new(0);
|
|
240
|
+
let tdir = std::env::temp_dir().join(format!(
|
|
241
|
+
"ta-rs-health-tx-{}-{}",
|
|
242
|
+
std::process::id(),
|
|
243
|
+
N.fetch_add(1, Ordering::Relaxed)
|
|
244
|
+
));
|
|
245
|
+
std::fs::create_dir_all(&tdir).unwrap();
|
|
246
|
+
// lane-046-capture-gap: Claude no-expected_session_id capture now requires
|
|
247
|
+
// positive_agent_id_match (TEAM_AGENT_ID=<id>) OR agent_path_match. Without
|
|
248
|
+
// a worker-identity signal, weak candidates can be leader transcripts and
|
|
249
|
+
// must not be attributed to a worker. The seeded transcript includes the
|
|
250
|
+
// TEAM_AGENT_ID marker for w1.
|
|
251
|
+
std::fs::write(
|
|
252
|
+
tdir.join("session.jsonl"),
|
|
253
|
+
r#"{"type":"user","sessionId":"sess-found","cwd":"x","message":{"content":"TEAM_AGENT_ID=w1 hi"}}"#,
|
|
254
|
+
)
|
|
255
|
+
.unwrap();
|
|
256
|
+
let agents = serde_json::json!({
|
|
257
|
+
"w1": { "provider": "claude_code", "window": "w1", "spawn_cwd": tdir.to_string_lossy() },
|
|
258
|
+
"w2": { "provider": "claude_code", "window": "w2", "session_id": "existing-sess" },
|
|
259
|
+
});
|
|
260
|
+
let (coord, dir) = seeded_health_coord(agents, "");
|
|
261
|
+
coord.tick().expect("tick");
|
|
262
|
+
assert!(
|
|
263
|
+
agent_field(&dir, "w1", "session_id").and_then(|v| v.as_str().map(str::to_string)).is_some(),
|
|
264
|
+
"capture_missing must capture+persist a session_id for an agent with a discoverable transcript; today it's a probe"
|
|
265
|
+
);
|
|
266
|
+
assert_eq!(
|
|
267
|
+
agent_field(&dir, "w2", "session_id")
|
|
268
|
+
.and_then(|v| v.as_str().map(str::to_string))
|
|
269
|
+
.as_deref(),
|
|
270
|
+
Some("existing-sess"),
|
|
271
|
+
"an agent that already has a session_id must be untouched"
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
|
|
233
275
|
// CONTRACT — sync_health runs BEFORE deliver_pending, but turn-level WORKING state must not make an
|
|
234
276
|
// alive worker undeliverable. Busy delivery deferral is lifecycle-only (`state.agents[id].status=="busy"`);
|
|
235
277
|
// activity/agent_health WORKING remains diagnostic turn state.
|
|
236
278
|
#[test]
|
|
237
279
|
fn spine2_sync_health_working_status_delivers_same_tick() {
|
|
238
280
|
let (coord, dir) = seeded_health_coord_with_readiness(
|
|
239
|
-
one_agent("
|
|
281
|
+
one_agent("fake"), "Working (5s · esc to interrupt)", true,
|
|
240
282
|
);
|
|
241
283
|
let store = MessageStore::open(&dir).unwrap();
|
|
242
284
|
let mid = store
|
|
@@ -283,7 +325,7 @@ fn spine2_sync_health_working_status_delivers_same_tick() {
|
|
|
283
325
|
// must be reconciled to this contract.)
|
|
284
326
|
#[test]
|
|
285
327
|
fn contract_working_worker_stays_alive_and_deliverable_in_real_tick() {
|
|
286
|
-
let (coord, dir) = seeded_health_coord(one_agent("
|
|
328
|
+
let (coord, dir) = seeded_health_coord(one_agent("fake"), "Working (5s · esc to interrupt)");
|
|
287
329
|
let store = MessageStore::open(&dir).unwrap();
|
|
288
330
|
let _mid = store
|
|
289
331
|
.create_message(Some("t"), "leader", "w1", "hi", None, true, None)
|
|
@@ -128,8 +128,8 @@ fn tick_swallows_capture_failure_and_still_delivers_to_other_agent() {
|
|
|
128
128
|
&serde_json::json!({
|
|
129
129
|
"session_name": "team-spine",
|
|
130
130
|
"agents": {
|
|
131
|
-
"w1": { "provider": "
|
|
132
|
-
"w2": { "provider": "
|
|
131
|
+
"w1": { "provider": "fake", "status": "stopped", "window": "w1" },
|
|
132
|
+
"w2": { "provider": "fake", "status": "running", "window": "w2" }
|
|
133
133
|
}
|
|
134
134
|
}),
|
|
135
135
|
)
|
|
@@ -170,7 +170,7 @@ fn slice2b_detect_stuck_no_longer_synthesized_by_framework_n35() {
|
|
|
170
170
|
let stale = (chrono::Utc::now() - chrono::Duration::seconds(1000)).to_rfc3339();
|
|
171
171
|
let (coord, dir, _inj) = takeover_coord(serde_json::json!({
|
|
172
172
|
"session_name": "team-h",
|
|
173
|
-
"agents": { "w1": { "provider": "
|
|
173
|
+
"agents": { "w1": { "provider": "copilot" } },
|
|
174
174
|
}));
|
|
175
175
|
seed_agent_health(&dir, "w1", "RUNNING", &stale, Some("team-h"));
|
|
176
176
|
let store = MessageStore::open(&dir).unwrap();
|
|
@@ -197,7 +197,7 @@ fn slice2b_detect_deadlocks_no_longer_synthesized_by_framework_n35() {
|
|
|
197
197
|
let now = chrono::Utc::now().to_rfc3339();
|
|
198
198
|
let (coord, dir, _inj) = takeover_coord(serde_json::json!({
|
|
199
199
|
"session_name": "team-h",
|
|
200
|
-
"agents": { "w1": { "provider": "
|
|
200
|
+
"agents": { "w1": { "provider": "copilot" }, "w2": { "provider": "copilot" } },
|
|
201
201
|
}));
|
|
202
202
|
seed_agent_health(&dir, "w1", "IDLE", &now, Some("team-h"));
|
|
203
203
|
let store = MessageStore::open(&dir).unwrap();
|
|
@@ -274,7 +274,7 @@ fn slice2b_takeover_unarmed_idle_worker_is_never_pinged() {
|
|
|
274
274
|
fn slice2b_unknown_persistent_no_longer_emitted_at_threshold_tick_n35() {
|
|
275
275
|
let (coord, dir, _inj) = takeover_coord(serde_json::json!({
|
|
276
276
|
"session_name": "team-h",
|
|
277
|
-
"agents": { "w1": { "provider": "
|
|
277
|
+
"agents": { "w1": { "provider": "copilot" } },
|
|
278
278
|
"coordinator": { "unknown_ticks": { "w1": 59 } }
|
|
279
279
|
}));
|
|
280
280
|
coord.tick().expect("tick");
|
|
@@ -830,7 +830,7 @@ impl Coordinator {
|
|
|
830
830
|
// runs so the CapturedRuntimeFact map stays populated for
|
|
831
831
|
// downstream runtime detectors; only the activity classify
|
|
832
832
|
// happens once.
|
|
833
|
-
let jsonl_first =
|
|
833
|
+
let jsonl_first = jsonl_activity_for_agent(agent);
|
|
834
834
|
if let Some(activity) = jsonl_first.as_ref() {
|
|
835
835
|
remember_idle_capture_schedule(agent, activity);
|
|
836
836
|
write_activity(agent, activity, false);
|
|
@@ -2313,47 +2313,6 @@ fn jsonl_activity_for_agent(agent: &Value) -> Option<crate::messaging::AgentActi
|
|
|
2313
2313
|
activity
|
|
2314
2314
|
}
|
|
2315
2315
|
|
|
2316
|
-
/// #379: for Claude, its live session registry outranks the transcript tail,
|
|
2317
|
-
/// which still reads idle between a submitted prompt and the first assistant
|
|
2318
|
-
/// record. Busy and waiting are decisive; idle yields only to a background
|
|
2319
|
-
/// task the transcript still holds open.
|
|
2320
|
-
fn native_activity_for_agent(agent: &Value) -> Option<crate::messaging::AgentActivity> {
|
|
2321
|
-
use crate::messaging::{ActivityStatus, AgentActivity};
|
|
2322
|
-
let jsonl = jsonl_activity_for_agent(agent);
|
|
2323
|
-
let claude = agent
|
|
2324
|
-
.get("provider")
|
|
2325
|
-
.and_then(Value::as_str)
|
|
2326
|
-
.and_then(parse_provider)
|
|
2327
|
-
.is_some_and(crate::provider::wire::is_claude_family);
|
|
2328
|
-
let registry = crate::provider::claude_registry_key(agent)
|
|
2329
|
-
.filter(|_| claude)
|
|
2330
|
-
.and_then(|(sessions, session_id)| {
|
|
2331
|
-
crate::provider::claude_registry_turn_state(
|
|
2332
|
-
&sessions,
|
|
2333
|
-
&session_id,
|
|
2334
|
-
agent.get("pane_id").and_then(Value::as_str),
|
|
2335
|
-
)
|
|
2336
|
-
});
|
|
2337
|
-
let (status, state) = match registry {
|
|
2338
|
-
Some(TurnState::Working) => (ActivityStatus::Working, "busy"),
|
|
2339
|
-
Some(TurnState::BlockedOnHuman) => (ActivityStatus::Uncertain, "waiting"),
|
|
2340
|
-
Some(TurnState::Idle)
|
|
2341
|
-
if jsonl
|
|
2342
|
-
.as_ref()
|
|
2343
|
-
.is_some_and(|activity| activity.rationale == "provider_jsonl:background_task") =>
|
|
2344
|
-
{
|
|
2345
|
-
return jsonl;
|
|
2346
|
-
}
|
|
2347
|
-
Some(TurnState::Idle) => (ActivityStatus::Idle, "idle"),
|
|
2348
|
-
_ => return jsonl,
|
|
2349
|
-
};
|
|
2350
|
-
Some(AgentActivity {
|
|
2351
|
-
status,
|
|
2352
|
-
confidence: 0.95,
|
|
2353
|
-
rationale: format!("claude_session_registry:{state}"),
|
|
2354
|
-
})
|
|
2355
|
-
}
|
|
2356
|
-
|
|
2357
2316
|
fn runtime_approval_target(
|
|
2358
2317
|
agent: &Value,
|
|
2359
2318
|
session_name: Option<&str>,
|
|
@@ -2949,53 +2908,6 @@ mod u1_tests {
|
|
|
2949
2908
|
use super::*;
|
|
2950
2909
|
use std::io::Write as _;
|
|
2951
2910
|
|
|
2952
|
-
// #379: the registry beside the transcript decides Claude's live turn.
|
|
2953
|
-
#[cfg(unix)]
|
|
2954
|
-
#[test]
|
|
2955
|
-
fn issue379_claude_registry_outranks_an_idle_transcript_tail() {
|
|
2956
|
-
use crate::messaging::ActivityStatus;
|
|
2957
|
-
let config = std::env::temp_dir().join(format!("ta-379-native-activity-{}", std::process::id()));
|
|
2958
|
-
let _ = std::fs::remove_dir_all(&config);
|
|
2959
|
-
let sid = "22222222-3333-4444-8555-666666666666";
|
|
2960
|
-
let projects = config.join("projects").join("-owned-cwd");
|
|
2961
|
-
std::fs::create_dir_all(&projects).unwrap();
|
|
2962
|
-
std::fs::create_dir_all(config.join("sessions")).unwrap();
|
|
2963
|
-
let rollout = projects.join(format!("{sid}.jsonl"));
|
|
2964
|
-
let pid = std::process::id();
|
|
2965
|
-
let registry = |status: &str| {
|
|
2966
|
-
let record = serde_json::json!({"pid": pid, "sessionId": sid, "tmux": "team-x:@1.%7", "status": status});
|
|
2967
|
-
std::fs::write(config.join("sessions").join(format!("{pid}.json")), record.to_string()).unwrap();
|
|
2968
|
-
};
|
|
2969
|
-
let end_turn = r#"{"type":"assistant","requestId":"r1","message":{"stop_reason":"end_turn"}}"#;
|
|
2970
|
-
let agent = serde_json::json!({
|
|
2971
|
-
"provider": "claude", "pane_id": "%7", "rollout_path": rollout, "process_alive": true,
|
|
2972
|
-
});
|
|
2973
|
-
let observe = || native_activity_for_agent(&agent).map(|a| (a.status, a.rationale));
|
|
2974
|
-
|
|
2975
|
-
// A submitted prompt before its first assistant record: the tail still reads idle.
|
|
2976
|
-
std::fs::write(&rollout, format!("{end_turn}\n")).unwrap();
|
|
2977
|
-
registry("busy");
|
|
2978
|
-
assert_eq!(observe(), Some((ActivityStatus::Working, "claude_session_registry:busy".into())));
|
|
2979
|
-
registry("waiting");
|
|
2980
|
-
assert_eq!(observe(), Some((ActivityStatus::Uncertain, "claude_session_registry:waiting".into())));
|
|
2981
|
-
registry("idle");
|
|
2982
|
-
assert_eq!(observe(), Some((ActivityStatus::Idle, "claude_session_registry:idle".into())));
|
|
2983
|
-
// A background shell the transcript holds open keeps the worker busy.
|
|
2984
|
-
let background = r#"{"type":"user","message":{"content":[{"type":"tool_result","content":"Command running in background with ID: bg1"}]}}"#;
|
|
2985
|
-
std::fs::write(&rollout, format!("{background}\n{end_turn}\n")).unwrap();
|
|
2986
|
-
assert_eq!(observe(), Some((ActivityStatus::Working, "provider_jsonl:background_task".into())));
|
|
2987
|
-
// Cold start: no transcript captured yet, only the launch's session id and root.
|
|
2988
|
-
let cold = serde_json::json!({
|
|
2989
|
-
"provider": "claude", "pane_id": "%7", "_pending_session_id": sid,
|
|
2990
|
-
"claude_projects_root": config.join("projects"),
|
|
2991
|
-
});
|
|
2992
|
-
assert_eq!(
|
|
2993
|
-
native_activity_for_agent(&cold).map(|a| (a.status, a.rationale)),
|
|
2994
|
-
Some((ActivityStatus::Idle, "claude_session_registry:idle".into()))
|
|
2995
|
-
);
|
|
2996
|
-
let _ = std::fs::remove_dir_all(&config);
|
|
2997
|
-
}
|
|
2998
|
-
|
|
2999
2911
|
struct CaptureFailureRegistry;
|
|
3000
2912
|
|
|
3001
2913
|
impl ProviderRegistry for CaptureFailureRegistry {
|
|
@@ -87,7 +87,7 @@ pub struct NotificationClaimParams<'a> {
|
|
|
87
87
|
pub pane_id: Option<&'a str>,
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
///
|
|
90
|
+
/// Legacy #373 parked-row marker, retained only for upgrade recovery.
|
|
91
91
|
pub(crate) const MCP_HANDSHAKE_TIMEOUT: &str = "mcp_handshake_timeout";
|
|
92
92
|
|
|
93
93
|
/// Canonical initial message-row statuses shared by persistence, presentation,
|
|
@@ -612,46 +612,6 @@ impl MessageStore {
|
|
|
612
612
|
Ok(rows == 1)
|
|
613
613
|
}
|
|
614
614
|
|
|
615
|
-
/// Park an owned pre-input claim whose readiness wait reached its bound.
|
|
616
|
-
/// `queued_until_start` is claimable but never polled by `deliver_pending`;
|
|
617
|
-
/// only [`Self::requeue_parked_deliveries`] or a seat restart resumes it.
|
|
618
|
-
pub(crate) fn park_delivery_before_input(
|
|
619
|
-
&self,
|
|
620
|
-
message_id: &str,
|
|
621
|
-
attempt: u32,
|
|
622
|
-
) -> Result<bool, MessageStoreError> {
|
|
623
|
-
if attempt == 0 {
|
|
624
|
-
return Ok(false);
|
|
625
|
-
}
|
|
626
|
-
let conn = crate::db::schema::open_db(&self.path)?;
|
|
627
|
-
let rows = conn.execute(
|
|
628
|
-
"update messages
|
|
629
|
-
set status = 'queued_until_start',
|
|
630
|
-
delivery_attempts = delivery_attempts - 1,
|
|
631
|
-
error = ?3, updated_at = ?4
|
|
632
|
-
where message_id = ?1 and status = 'target_resolved'
|
|
633
|
-
and error is null and delivery_attempts = ?2",
|
|
634
|
-
params![message_id, attempt, MCP_HANDSHAKE_TIMEOUT, now_ts()],
|
|
635
|
-
)?;
|
|
636
|
-
Ok(rows == 1)
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
/// Return one seat's parked rows to the normal delivery queue.
|
|
640
|
-
pub(crate) fn requeue_parked_deliveries(
|
|
641
|
-
&self,
|
|
642
|
-
recipient: &str,
|
|
643
|
-
owner_team_id: &str,
|
|
644
|
-
) -> Result<usize, MessageStoreError> {
|
|
645
|
-
let conn = crate::db::schema::open_db(&self.path)?;
|
|
646
|
-
Ok(conn.execute(
|
|
647
|
-
"update messages
|
|
648
|
-
set status = 'accepted', error = null, updated_at = ?4
|
|
649
|
-
where recipient = ?1 and status = 'queued_until_start' and error = ?3
|
|
650
|
-
and (owner_team_id = ?2 or owner_team_id is null)",
|
|
651
|
-
params![recipient, owner_team_id, MCP_HANDSHAKE_TIMEOUT, now_ts()],
|
|
652
|
-
)?)
|
|
653
|
-
}
|
|
654
|
-
|
|
655
615
|
/// Read inbox rows through [`Self::inbox`]; recovery transitions below are
|
|
656
616
|
/// separate repository owners and are not claim eligibility.
|
|
657
617
|
pub fn requeue_blocked_leader_messages(
|
|
@@ -1278,34 +1238,16 @@ mod tests {
|
|
|
1278
1238
|
}
|
|
1279
1239
|
|
|
1280
1240
|
#[test]
|
|
1281
|
-
fn
|
|
1241
|
+
fn issue372_legacy_timeout_recovery_is_scoped_to_seat_and_owner() {
|
|
1282
1242
|
let s = store();
|
|
1283
1243
|
let mid = s.create_message(Some("t"), "s", "r", "c", None, true, Some("team-a")).unwrap();
|
|
1284
|
-
|
|
1285
|
-
assert!(s.
|
|
1286
|
-
assert!(
|
|
1287
|
-
assert!(s.park_delivery_before_input(&mid, 1).unwrap());
|
|
1288
|
-
assert!(!s.park_delivery_before_input(&mid, 1).unwrap(), "single winner");
|
|
1289
|
-
let c = read(&s);
|
|
1290
|
-
assert_eq!(status_of(&c, &mid), "queued_until_start");
|
|
1291
|
-
assert_eq!(col_str(&c, &mid, "error").as_deref(), Some(MCP_HANDSHAKE_TIMEOUT));
|
|
1292
|
-
assert_eq!(col_i64(&c, &mid, "delivery_attempts"), 0, "waiting spends no input attempt");
|
|
1293
|
-
assert_eq!(s.requeue_parked_deliveries("other", "team-a").unwrap(), 0);
|
|
1294
|
-
assert_eq!(s.requeue_parked_deliveries("r", "team-b").unwrap(), 0);
|
|
1295
|
-
assert_eq!(s.requeue_parked_deliveries("r", "team-a").unwrap(), 1);
|
|
1296
|
-
let c = read(&s);
|
|
1297
|
-
assert_eq!(status_of(&c, &mid), "accepted");
|
|
1298
|
-
assert_eq!(col_str(&c, &mid, "error"), None);
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
|
-
#[test]
|
|
1302
|
-
fn issue372_seat_restart_also_resumes_parked_handshake_rows() {
|
|
1303
|
-
let s = store();
|
|
1304
|
-
let mid = s.create_message(Some("t"), "s", "r", "c", None, true, Some("team-a")).unwrap();
|
|
1305
|
-
assert!(s.claim_for_delivery(&mid).unwrap());
|
|
1306
|
-
assert!(s.park_delivery_before_input(&mid, 1).unwrap());
|
|
1244
|
+
s.mark(&mid, "queued_until_start", Some(MCP_HANDSHAKE_TIMEOUT)).unwrap();
|
|
1245
|
+
assert!(s.recover_worker_pane_available("other", Some("team-a")).unwrap().is_empty());
|
|
1246
|
+
assert!(s.recover_worker_pane_available("r", Some("team-b")).unwrap().is_empty());
|
|
1307
1247
|
assert_eq!(s.recover_worker_pane_available("r", Some("team-a")).unwrap(), vec![mid.clone()]);
|
|
1308
1248
|
assert_eq!(status_of(&read(&s), &mid), "accepted");
|
|
1249
|
+
assert_eq!(col_str(&read(&s), &mid, "error"), None);
|
|
1250
|
+
assert!(s.recover_worker_pane_available("r", Some("team-a")).unwrap().is_empty());
|
|
1309
1251
|
}
|
|
1310
1252
|
|
|
1311
1253
|
#[test]
|