@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
|
@@ -89,7 +89,6 @@ struct RegisteredNode {
|
|
|
89
89
|
window: Option<String>,
|
|
90
90
|
pane: Option<String>,
|
|
91
91
|
lifecycle: Option<String>,
|
|
92
|
-
claude_registry: Option<(std::path::PathBuf, String)>,
|
|
93
92
|
}
|
|
94
93
|
|
|
95
94
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
@@ -535,7 +534,6 @@ fn registered_node(name: &str, value: &Value, state: &Value) -> RegisteredNode {
|
|
|
535
534
|
.or_else(|| first_string(display, &["pane_id"]))
|
|
536
535
|
.or_else(|| first_string(target, &["pane_id"])),
|
|
537
536
|
lifecycle: string_at(value, &["status"]).map(|status| status.to_ascii_lowercase()),
|
|
538
|
-
claude_registry: crate::provider::claude_registry_key(value),
|
|
539
537
|
}
|
|
540
538
|
}
|
|
541
539
|
|
|
@@ -1327,8 +1325,6 @@ fn project_node_with_attach(
|
|
|
1327
1325
|
let native_tmux = observed.evidence_method.as_deref() == Some("native_tmux");
|
|
1328
1326
|
let activity = if observed.provider.eq_ignore_ascii_case("pi") && !pi_channel && !native_tmux {
|
|
1329
1327
|
"unknown"
|
|
1330
|
-
} else if native_tmux && claude_node(node) {
|
|
1331
|
-
claude_registry_activity(node)
|
|
1332
1328
|
} else {
|
|
1333
1329
|
valid_activity(&observed.activity)
|
|
1334
1330
|
};
|
|
@@ -1399,24 +1395,6 @@ fn matches_registered(node: &RegisteredNode, observed: &ProbeNode) -> bool {
|
|
|
1399
1395
|
&& node.pane.as_deref() == Some(observed.pane.as_str())
|
|
1400
1396
|
}
|
|
1401
1397
|
|
|
1402
|
-
fn claude_node(node: &RegisteredNode) -> bool {
|
|
1403
|
-
crate::provider::wire::parse_provider(&node.provider)
|
|
1404
|
-
.is_some_and(crate::provider::wire::is_claude_family)
|
|
1405
|
-
}
|
|
1406
|
-
|
|
1407
|
-
/// #379: a live Claude pane always runs the Claude process, so its command
|
|
1408
|
-
/// name says nothing about the turn; Claude's own session registry does.
|
|
1409
|
-
fn claude_registry_activity(node: &RegisteredNode) -> &'static str {
|
|
1410
|
-
let state = node.claude_registry.as_ref().and_then(|(sessions, session_id)| {
|
|
1411
|
-
crate::provider::claude_registry_turn_state(sessions, session_id, node.pane.as_deref())
|
|
1412
|
-
});
|
|
1413
|
-
match state {
|
|
1414
|
-
Some(crate::provider::TurnState::Working) => "working",
|
|
1415
|
-
Some(crate::provider::TurnState::Idle) => "idle",
|
|
1416
|
-
_ => "unknown",
|
|
1417
|
-
}
|
|
1418
|
-
}
|
|
1419
|
-
|
|
1420
1398
|
fn valid_activity(value: &str) -> &str {
|
|
1421
1399
|
match value {
|
|
1422
1400
|
"working" | "idle" => value,
|
|
@@ -1528,7 +1506,6 @@ mod native_ps_batch_regressions {
|
|
|
1528
1506
|
window: Some("w".into()),
|
|
1529
1507
|
pane: Some(pane.into()),
|
|
1530
1508
|
lifecycle: None,
|
|
1531
|
-
claude_registry: None,
|
|
1532
1509
|
}
|
|
1533
1510
|
}
|
|
1534
1511
|
|
|
@@ -1616,7 +1593,11 @@ mod native_ps_batch_regressions {
|
|
|
1616
1593
|
#[test]
|
|
1617
1594
|
fn native_ps_partial_selection_preserves_a_live_pid() {
|
|
1618
1595
|
let pid = std::process::id();
|
|
1619
|
-
|
|
1596
|
+
// Darwin ps rejects i32::MAX as invalid syntax; use a real exited PID.
|
|
1597
|
+
let mut exited = Command::new("/bin/sh").args(["-c", "exit 0"]).spawn().unwrap();
|
|
1598
|
+
let dead_pid = exited.id();
|
|
1599
|
+
assert!(exited.wait().unwrap().success());
|
|
1600
|
+
let requested = BTreeSet::from([pid, dead_pid]);
|
|
1620
1601
|
let command = process_snapshot_command(&requested);
|
|
1621
1602
|
// Absolute ps avoids unrelated PATH-fixture mutation in parallel unit tests.
|
|
1622
1603
|
let output = Command::new("/bin/ps")
|
|
@@ -1793,7 +1774,6 @@ mod tests {
|
|
|
1793
1774
|
window: Some("win".to_string()),
|
|
1794
1775
|
pane: Some("%7".to_string()),
|
|
1795
1776
|
lifecycle: None,
|
|
1796
|
-
claude_registry: None,
|
|
1797
1777
|
}
|
|
1798
1778
|
}
|
|
1799
1779
|
|
|
@@ -1902,48 +1882,6 @@ mod tests {
|
|
|
1902
1882
|
);
|
|
1903
1883
|
}
|
|
1904
1884
|
|
|
1905
|
-
// #379: a live Claude pane always runs Claude; its registry names the turn.
|
|
1906
|
-
#[cfg(unix)]
|
|
1907
|
-
#[test]
|
|
1908
|
-
fn issue379_claude_activity_comes_from_its_session_registry_not_the_pane_command() {
|
|
1909
|
-
let config = std::env::temp_dir().join(format!("ta-379-brief-{}", std::process::id()));
|
|
1910
|
-
let _ = std::fs::remove_dir_all(&config);
|
|
1911
|
-
let sid = "33333333-4444-4555-8666-777777777777";
|
|
1912
|
-
let projects = config.join("projects").join("-owned-cwd");
|
|
1913
|
-
std::fs::create_dir_all(&projects).unwrap();
|
|
1914
|
-
std::fs::create_dir_all(config.join("sessions")).unwrap();
|
|
1915
|
-
let rollout = projects.join(format!("{sid}.jsonl"));
|
|
1916
|
-
std::fs::write(&rollout, "").unwrap();
|
|
1917
|
-
let record = config.join("sessions").join(format!("{}.json", std::process::id()));
|
|
1918
|
-
let mut node = registered();
|
|
1919
|
-
node.provider = "claude".to_string();
|
|
1920
|
-
node.claude_registry = crate::provider::claude_registry_key(&json!({"rollout_path": rollout}));
|
|
1921
|
-
let mut observed = probe("native_tmux");
|
|
1922
|
-
observed.provider = "claude".to_string();
|
|
1923
|
-
observed.activity = "working".to_string();
|
|
1924
|
-
let sample = Some(ProbeResult { nodes: vec![observed], ..Default::default() });
|
|
1925
|
-
for (status, expected) in [("busy", "working"), ("idle", "idle"), ("waiting", "unknown")] {
|
|
1926
|
-
let body = json!({"pid": std::process::id(), "sessionId": sid, "tmux": "sess:@1.%7", "status": status});
|
|
1927
|
-
std::fs::write(&record, body.to_string()).unwrap();
|
|
1928
|
-
assert_eq!(project_node(&node, Some(&sample)).activity, expected, "{status}");
|
|
1929
|
-
}
|
|
1930
|
-
// Cold start: the ready prompt before any transcript is captured.
|
|
1931
|
-
let body = json!({"pid": std::process::id(), "sessionId": sid, "tmux": "sess:@1.%7", "status": "idle"});
|
|
1932
|
-
std::fs::write(&record, body.to_string()).unwrap();
|
|
1933
|
-
let cold = registered_node(
|
|
1934
|
-
"worker",
|
|
1935
|
-
&json!({"provider": "claude", "_pending_session_id": sid, "claude_projects_root": config.join("projects")}),
|
|
1936
|
-
&json!({}),
|
|
1937
|
-
);
|
|
1938
|
-
node.claude_registry = cold.claude_registry;
|
|
1939
|
-
assert_eq!(project_node(&node, Some(&sample)).activity, "idle");
|
|
1940
|
-
std::fs::remove_file(&record).unwrap();
|
|
1941
|
-
let projected = project_node(&node, Some(&sample));
|
|
1942
|
-
assert_eq!(projected.activity, "unknown", "the process name is not a turn state");
|
|
1943
|
-
assert_eq!(projected.observation_reason, Some("activity_or_health_not_observed"));
|
|
1944
|
-
let _ = std::fs::remove_dir_all(&config);
|
|
1945
|
-
}
|
|
1946
|
-
|
|
1947
1885
|
#[test]
|
|
1948
1886
|
fn stopped_registration_is_retained_without_sample() {
|
|
1949
1887
|
let mut node = registered();
|
|
@@ -4,72 +4,22 @@ use super::*;
|
|
|
4
4
|
// (DELEGATION sweep, rt-host-a loop #2) — cmd_send persistence + shutdown teardown.
|
|
5
5
|
// =========================================================================
|
|
6
6
|
|
|
7
|
-
//
|
|
8
|
-
// and NEVER calls messaging::send_message, so NO `messages` row is persisted. RED: after cmd_send to
|
|
9
|
-
// a worker on a seeded ws (real MessageStore), assert a messages row was PERSISTED (query by
|
|
10
|
-
// recipient+content) — proving the real messaging::send_message -> MessageStore.create_message path.
|
|
11
|
-
// DB-persist is observable without a transport. (messaging::send_message is ALSO a stub today, so the
|
|
12
|
-
// porter wires BOTH cmd_send->send_message AND send_message->persist.)
|
|
13
|
-
//
|
|
14
|
-
// OLD seed: flat `{"agents": {"w1": ...}}` worked because send_message read agents
|
|
15
|
-
// directly off the raw runtime state.
|
|
16
|
-
// NEW seed (Bug 1/2 — team-in-team state scope, see tests/team_in_team_state_scope_red.rs):
|
|
17
|
-
// cmd_send → resolve_active_team yields a team_key, send_message projects the
|
|
18
|
-
// raw state through `project_top_level_view(team_key)` which reads agents off
|
|
19
|
-
// `teams[team_key].agents`. The seed therefore lives under `teams.current.agents`
|
|
20
|
-
// with `active_team_key=current`; the delegation + persistence behavior under test
|
|
21
|
-
// is unchanged — only the shape of "an in-team recipient" is now nested.
|
|
7
|
+
// Public mailbox delivery is durable in the inbound log, never the coordinator queue.
|
|
22
8
|
#[test]
|
|
23
|
-
fn
|
|
9
|
+
fn cli_send_mailbox_appends_an_inbox_record_without_a_delivery_row() {
|
|
24
10
|
let ws = deleg_uniq_dir("send");
|
|
25
|
-
let _ = crate::message_store::MessageStore::open(&ws).unwrap(); // real store at the workspace
|
|
26
|
-
// w1 must be a known team agent — golden send.py refuses non-team targets
|
|
27
|
-
// (target_not_in_team); an in-team recipient is the one that persists. Bug 1/2
|
|
28
|
-
// scopes agents under teams[<key>].agents (NEW shape).
|
|
29
|
-
crate::state::persist::save_runtime_state(
|
|
30
|
-
&ws,
|
|
31
|
-
&serde_json::json!({
|
|
32
|
-
"active_team_key": "current",
|
|
33
|
-
"teams": {"current": {"agents": {"w1": {"provider": "codex"}}}}
|
|
34
|
-
}),
|
|
35
|
-
)
|
|
36
|
-
.unwrap();
|
|
37
|
-
let args = SendArgs {
|
|
38
|
-
target: Some("w1".to_string()),
|
|
39
|
-
message: vec!["hello-real-delegation".to_string()],
|
|
40
|
-
targets: None,
|
|
41
|
-
workspace: ws.clone(),
|
|
42
|
-
team: None,
|
|
43
|
-
task: None,
|
|
44
|
-
sender: TrustedSender::leader(),
|
|
45
|
-
no_ack: false,
|
|
46
|
-
no_wait: true,
|
|
47
|
-
watch_result: false,
|
|
48
|
-
timeout: 0.0,
|
|
49
|
-
confirm_human: false,
|
|
50
|
-
json: true,
|
|
51
|
-
message_id: None,
|
|
52
|
-
presentation: crate::messaging::presentation::PresentationRequest::default(),
|
|
53
|
-
pane: None,
|
|
54
|
-
to_name: None,
|
|
55
|
-
to_leader: None,
|
|
56
|
-
};
|
|
57
|
-
let _ = cmd_send(&args);
|
|
58
|
-
|
|
59
11
|
let store = crate::message_store::MessageStore::open(&ws).unwrap();
|
|
12
|
+
crate::state::persist::save_runtime_state(&ws, &serde_json::json!({
|
|
13
|
+
"active_team_key": "current",
|
|
14
|
+
"teams": {"current": {"agents": {"w1": {"provider": "copilot"}}}}
|
|
15
|
+
})).unwrap();
|
|
16
|
+
let argv = ["send", "w1", "hello-real-delegation", "--mailbox", "--json"].map(str::to_string);
|
|
17
|
+
assert_eq!(run(&argv, &ws), ExitCode::Ok);
|
|
18
|
+
let inbox = crate::inbox_store::read(&ws, "w1", 3, None).unwrap();
|
|
19
|
+
assert_eq!(inbox["messages"][0]["content"], "hello-real-delegation");
|
|
60
20
|
let conn = crate::db::schema::open_db(store.db_path()).unwrap();
|
|
61
|
-
let count: i64 = conn
|
|
62
|
-
|
|
63
|
-
"select count(*) from messages where recipient = 'w1' and content = 'hello-real-delegation'",
|
|
64
|
-
[],
|
|
65
|
-
|r| r.get(0),
|
|
66
|
-
)
|
|
67
|
-
.unwrap();
|
|
68
|
-
assert!(
|
|
69
|
-
count >= 1,
|
|
70
|
-
"cmd_send must delegate to messaging::send_message and PERSIST a `messages` row (recipient=w1); \
|
|
71
|
-
the synthetic delivery_json writes NO DB row -> count={count}"
|
|
72
|
-
);
|
|
21
|
+
let count: i64 = conn.query_row("select count(*) from messages", [], |row| row.get(0)).unwrap();
|
|
22
|
+
assert_eq!(count, 0);
|
|
73
23
|
}
|
|
74
24
|
|
|
75
25
|
// 5 [P1, CONFIRMED PARTIAL] — shutdown stops the coordinator but NEVER kills the team tmux session
|
|
@@ -58,8 +58,8 @@ fn seed_send_workspace() -> std::path::PathBuf {
|
|
|
58
58
|
"teams": {
|
|
59
59
|
"teamA": {
|
|
60
60
|
"agents": {
|
|
61
|
-
"alice": {"provider": "
|
|
62
|
-
"drifted": {"provider": "
|
|
61
|
+
"alice": {"provider": "copilot"},
|
|
62
|
+
"drifted": {"provider": "copilot", "status": "session_drift"}
|
|
63
63
|
},
|
|
64
64
|
"tasks": [{"id": "t-1"}]
|
|
65
65
|
}
|
|
@@ -74,7 +74,7 @@ fn seed_send_workspace() -> std::path::PathBuf {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
const DELEG_VALID_ROLE: &str = "---\nname: implementer\nrole: Implementation Engineer\nprovider: fake\nmodel: fake\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nImplement bounded tasks.\n";
|
|
77
|
-
const DELEG_INVALID_ROLE: &str = "---\nname: broken\nrole: Broken Worker\
|
|
77
|
+
const DELEG_INVALID_ROLE: &str = "---\nname: broken\nrole: Broken Worker\nmodel: gpt-5.5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nNo provider field.\n";
|
|
78
78
|
const DELEG_TEAM_MD: &str =
|
|
79
79
|
"---\nname: clidelegteam\nobjective: Delegation probe.\nprovider: fake\n---\n\nteam.\n";
|
|
80
80
|
|
|
@@ -592,7 +592,7 @@ fn resolve_app_server_leader_name_fails_closed_on_transport_conflict() {
|
|
|
592
592
|
|
|
593
593
|
#[cfg(unix)]
|
|
594
594
|
#[test]
|
|
595
|
-
fn
|
|
595
|
+
fn send_to_name_app_server_leader_requires_explicit_mailbox_without_a_tmux_endpoint() {
|
|
596
596
|
let ws = named_ws("appserver-leader-send");
|
|
597
597
|
let fake = crate::app_server_test_support::FakeAppServer::start(
|
|
598
598
|
"named-send",
|
|
@@ -608,22 +608,23 @@ fn send_to_name_app_server_leader_persists_before_async_delivery() {
|
|
|
608
608
|
"alpha": app_server_leader_team(&ws, fake.endpoint(), "thread-live", "session-live")
|
|
609
609
|
})),
|
|
610
610
|
);
|
|
611
|
-
let args = named_send_args(&ws, Some("alpha/leader"), None, None, &["hello appserver"]);
|
|
612
|
-
|
|
613
|
-
|
|
611
|
+
let mut args = named_send_args(&ws, Some("alpha/leader"), None, None, &["hello appserver"]);
|
|
612
|
+
cmd_send(&args).expect_err("a direct send cannot pretend an app-server is a tmux pane");
|
|
613
|
+
assert!(!ws.join(".team/runtime/team.db").exists());
|
|
614
|
+
args.presentation.sink = crate::messaging::presentation::PresentationSink::Silent;
|
|
615
|
+
let result = cmd_send(&args).expect("explicit mailbox needs no physical endpoint");
|
|
614
616
|
let value = match result.output {
|
|
615
617
|
CmdOutput::Json(value) => value,
|
|
616
618
|
other => panic!("expected json output, got {other:?}"),
|
|
617
619
|
};
|
|
618
620
|
|
|
619
|
-
assert_eq!(value["
|
|
620
|
-
let
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
assert!(store.message_exists(message_id).unwrap());
|
|
621
|
+
assert_eq!(value["status"], json!("stored"));
|
|
622
|
+
let inbox = crate::inbox_store::read(&ws, "leader", 3, Some("alpha")).unwrap();
|
|
623
|
+
assert_eq!(inbox["messages"][0]["content"], "hello appserver");
|
|
624
|
+
assert!(!ws.join(".team/runtime/team.db").exists());
|
|
624
625
|
assert!(
|
|
625
626
|
fake.received_turns().is_empty(),
|
|
626
|
-
"
|
|
627
|
+
"mailbox is storage only and must not invoke any provider transport"
|
|
627
628
|
);
|
|
628
629
|
let _ = std::fs::remove_dir_all(&ws);
|
|
629
630
|
}
|
|
@@ -92,7 +92,9 @@ fn run_dispatches_status_to_handler_returns_ok() {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
#[test]
|
|
95
|
+
#[serial_test::serial(env)]
|
|
95
96
|
fn run_dispatches_send_to_handler_returns_ok() {
|
|
97
|
+
let _env = hermetic_guard::HermeticTestEnv::enter("send-dispatch");
|
|
96
98
|
// run([send w1 hello --workspace <seeded>]) -> cmd_send -> messaging::send_message
|
|
97
99
|
// -> ok (w1 is an in-team agent) -> ExitCode::Ok. w1 must be seeded: golden refuses non-team targets.
|
|
98
100
|
//
|
|
@@ -107,7 +109,7 @@ fn run_dispatches_send_to_handler_returns_ok() {
|
|
|
107
109
|
&ws,
|
|
108
110
|
&serde_json::json!({
|
|
109
111
|
"active_team_key": "current",
|
|
110
|
-
"teams": {"current": {"agents": {"w1": {"provider": "
|
|
112
|
+
"teams": {"current": {"agents": {"w1": {"provider": "fake"}}}}
|
|
111
113
|
}),
|
|
112
114
|
)
|
|
113
115
|
.unwrap();
|
|
@@ -115,14 +117,16 @@ fn run_dispatches_send_to_handler_returns_ok() {
|
|
|
115
117
|
"send".to_string(),
|
|
116
118
|
"w1".to_string(),
|
|
117
119
|
"hello".to_string(),
|
|
120
|
+
"--mailbox".to_string(),
|
|
118
121
|
"--workspace".to_string(),
|
|
119
122
|
ws.to_string_lossy().to_string(),
|
|
120
123
|
];
|
|
121
124
|
assert_eq!(
|
|
122
125
|
run(&argv, Path::new(".")),
|
|
123
126
|
ExitCode::Ok,
|
|
124
|
-
"run must dispatch
|
|
127
|
+
"run must dispatch an explicit mailbox send without a coordinator"
|
|
125
128
|
);
|
|
129
|
+
assert_eq!(crate::inbox_store::read(&ws, "w1", 3, None).unwrap()["messages"][0]["content"], "hello");
|
|
126
130
|
}
|
|
127
131
|
|
|
128
132
|
#[test]
|
|
@@ -185,7 +189,7 @@ fn run_dispatches_quick_start_compiles_spec() {
|
|
|
185
189
|
.unwrap();
|
|
186
190
|
std::fs::write(
|
|
187
191
|
dir.join("agents").join("implementer.md"),
|
|
188
|
-
"---\nname: implementer\nrole: Impl\nprovider:
|
|
192
|
+
"---\nname: implementer\nrole: Impl\nprovider: fake\nmodel: fake\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nImpl.\n",
|
|
189
193
|
)
|
|
190
194
|
.unwrap();
|
|
191
195
|
let argv = vec![
|
|
@@ -252,10 +256,9 @@ fn cli_quick_start_invokes_real_lifecycle_admission_before_runtime_effects() {
|
|
|
252
256
|
);
|
|
253
257
|
}
|
|
254
258
|
|
|
255
|
-
// 2 [P0] — cmd_quick_start over an INVALID role doc surfaces the REAL compiler error (
|
|
256
|
-
// `provider
|
|
257
|
-
//
|
|
258
|
-
// -> RED. OS-safe (compile fails early).
|
|
259
|
+
// 2 [P0] — cmd_quick_start over an INVALID role doc surfaces the REAL compiler error (missing
|
|
260
|
+
// `provider`), proving delegation to crate::lifecycle (compile fails before any spawn). The
|
|
261
|
+
// placeholder returns a canned {ok:true} with no error -> RED. OS-safe (compile fails early).
|
|
259
262
|
#[test]
|
|
260
263
|
fn cli_quick_start_invalid_spec_surfaces_real_compile_error() {
|
|
261
264
|
let team = deleg_uniq_dir("qsbad");
|
|
@@ -275,7 +278,7 @@ fn cli_quick_start_invalid_spec_surfaces_real_compile_error() {
|
|
|
275
278
|
let text = outcome_text(cmd_quick_start(&args));
|
|
276
279
|
assert!(
|
|
277
280
|
text.contains("provider"),
|
|
278
|
-
"cmd_quick_start must surface the REAL compiler error for a role doc
|
|
281
|
+
"cmd_quick_start must surface the REAL compiler error for a role doc missing `provider` \
|
|
279
282
|
(proving delegation to crate::lifecycle, not the placeholder's canned ok:true); got {text}"
|
|
280
283
|
);
|
|
281
284
|
}
|
|
@@ -320,7 +323,7 @@ fn cli_add_agent_duplicate_id_surfaces_real_error() {
|
|
|
320
323
|
&json!({
|
|
321
324
|
"session_name": "team-deleg-addagent",
|
|
322
325
|
"agents": {
|
|
323
|
-
"implementer": {"status": "running", "provider": "
|
|
326
|
+
"implementer": {"status": "running", "provider": "fake", "window": "implementer"}
|
|
324
327
|
}
|
|
325
328
|
}),
|
|
326
329
|
)
|