@team-agent/installer 0.5.127 → 0.5.128
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +1 -1
- package/Cargo.toml +1 -1
- package/README.md +11 -0
- package/crates/team-agent/src/cli/adapters.rs +3 -13
- package/crates/team-agent/src/cli/arguments.rs +4 -0
- package/crates/team-agent/src/cli/diagnose.rs +68 -22
- package/crates/team-agent/src/cli/emit.rs +58 -26
- package/crates/team-agent/src/cli/intent/runtime.rs +32 -5
- package/crates/team-agent/src/cli/intent/runtime_tests.rs +102 -11
- package/crates/team-agent/src/cli/intent/tests.rs +10 -12
- package/crates/team-agent/src/cli/intent.rs +1 -1
- package/crates/team-agent/src/cli/mod.rs +25 -8
- package/crates/team-agent/src/cli/models.rs +764 -7
- package/crates/team-agent/src/cli/schedule.rs +175 -0
- package/crates/team-agent/src/cli/send/persist.rs +0 -36
- package/crates/team-agent/src/cli/send/presentation.rs +1 -1
- package/crates/team-agent/src/cli/send.rs +108 -110
- package/crates/team-agent/src/cli/spec.rs +6 -0
- package/crates/team-agent/src/cli/status_port/brief.rs +5 -67
- package/crates/team-agent/src/cli/tests/leader_watch.rs +12 -62
- package/crates/team-agent/src/cli/tests/mod.rs +1 -1
- package/crates/team-agent/src/cli/tests/named_address.rs +11 -10
- package/crates/team-agent/src/cli/tests/run_delegation.rs +9 -6
- package/crates/team-agent/src/cli/tests/status_send.rs +68 -271
- package/crates/team-agent/src/compiler/tests.rs +3 -18
- package/crates/team-agent/src/compiler.rs +205 -6
- package/crates/team-agent/src/contract_runtime/backend.rs +145 -11
- package/crates/team-agent/src/contract_runtime/commands.rs +7 -7
- package/crates/team-agent/src/contract_runtime/config.rs +26 -16
- package/crates/team-agent/src/contract_runtime/config_tests.rs +24 -4
- package/crates/team-agent/src/contract_runtime/discovery.rs +12 -1
- package/crates/team-agent/src/contract_runtime/fork.rs +3 -10
- package/crates/team-agent/src/contract_runtime/framework.rs +28 -11
- package/crates/team-agent/src/contract_runtime/mcp.rs +19 -24
- package/crates/team-agent/src/contract_runtime/prompt.rs +2 -2
- package/crates/team-agent/src/contract_runtime/registry.rs +56 -92
- package/crates/team-agent/src/coordinator/steps/abnormal.rs +11 -11
- package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +16 -54
- package/crates/team-agent/src/coordinator/tests/health_sync.rs +42 -0
- package/crates/team-agent/src/coordinator/tick.rs +1 -89
- package/crates/team-agent/src/db/message_store.rs +7 -65
- package/crates/team-agent/src/direct_delivery.rs +368 -0
- package/crates/team-agent/src/inbox_store.rs +169 -0
- package/crates/team-agent/src/leader/registry.rs +5 -0
- package/crates/team-agent/src/leader/start.rs +2 -1
- package/crates/team-agent/src/leader/tests/lease_api.rs +2 -2
- package/crates/team-agent/src/leader/tests/prompt_contract.rs +1 -0
- package/crates/team-agent/src/lib.rs +2 -0
- package/crates/team-agent/src/lifecycle/launch/add_agent.rs +33 -0
- package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +206 -1
- package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +28 -2
- package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +38 -13
- package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +87 -6
- package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +9 -1
- package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +351 -81
- package/crates/team-agent/src/lifecycle/launch/pi_mcp_extension.js +3 -4
- package/crates/team-agent/src/lifecycle/launch/quick_start.rs +24 -0
- package/crates/team-agent/src/lifecycle/launch/spawn.rs +36 -13
- package/crates/team-agent/src/lifecycle/launch.rs +24 -1
- package/crates/team-agent/src/lifecycle/profile_launch.rs +321 -11
- package/crates/team-agent/src/lifecycle/restart/agent.rs +1 -0
- package/crates/team-agent/src/lifecycle/restart/avatar.rs +1798 -0
- package/crates/team-agent/src/lifecycle/restart/claude_fork.rs +163 -0
- package/crates/team-agent/src/lifecycle/restart/common.rs +345 -35
- package/crates/team-agent/src/lifecycle/restart/selection.rs +5 -5
- package/crates/team-agent/src/lifecycle/restart.rs +4 -0
- package/crates/team-agent/src/lifecycle/role_config.rs +39 -14
- package/crates/team-agent/src/lifecycle/tests/claude_compatible_config_red.rs +325 -0
- package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +320 -8
- package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +236 -13
- package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +378 -4
- package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +5 -4
- package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +7 -11
- package/crates/team-agent/src/lifecycle/tests/core.rs +47 -18
- package/crates/team-agent/src/lifecycle/tests/fixtures/pi_native_mcp_host.mjs +2 -1
- package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +14 -14
- package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +60 -20
- package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +28 -26
- package/crates/team-agent/src/lifecycle/tests/mcp_tool_name_format_red.rs +6 -6
- package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +18 -6
- package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +70 -52
- package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +210 -0
- package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +157 -4
- package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +526 -10
- package/crates/team-agent/src/lifecycle/tests/pi_fork_session_inheritance_red.rs +1419 -0
- package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +68 -1
- package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +34 -12
- package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +94 -2
- package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +10 -11
- package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +2 -2
- package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +254 -2
- package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +4 -4
- package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +5 -6
- package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +16 -7
- package/crates/team-agent/src/lifecycle/tests.rs +3 -0
- package/crates/team-agent/src/lifecycle/types.rs +18 -2
- package/crates/team-agent/src/lifecycle/worker_command_context.rs +43 -50
- package/crates/team-agent/src/mcp_server/readiness.rs +130 -149
- package/crates/team-agent/src/mcp_server/readiness_tests.rs +98 -119
- package/crates/team-agent/src/mcp_server/tests/scoped.rs +21 -31
- package/crates/team-agent/src/mcp_server/tests/send.rs +72 -107
- package/crates/team-agent/src/mcp_server/tests/tools.rs +10 -12
- package/crates/team-agent/src/mcp_server/tools.rs +70 -196
- package/crates/team-agent/src/messaging/delivery.rs +160 -218
- package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +5 -5
- package/crates/team-agent/src/messaging/helpers.rs +1 -19
- package/crates/team-agent/src/messaging/mod.rs +1 -0
- package/crates/team-agent/src/messaging/reminders.rs +316 -0
- package/crates/team-agent/src/messaging/scheduler.rs +7 -1
- package/crates/team-agent/src/messaging/tests/dup_inject.rs +191 -85
- package/crates/team-agent/src/messaging/tests/runtime.rs +4 -110
- package/crates/team-agent/src/messaging/tests/spine.rs +40 -24
- package/crates/team-agent/src/messaging/types.rs +1 -0
- package/crates/team-agent/src/provider/adapter.rs +303 -51
- package/crates/team-agent/src/provider/adapters/claude.rs +78 -0
- package/crates/team-agent/src/provider/adapters/claude_fork.rs +131 -0
- package/crates/team-agent/src/provider/adapters/mod.rs +7 -5
- package/crates/team-agent/src/provider/adapters/pi.rs +106 -0
- package/crates/team-agent/src/provider/classify.rs +1 -66
- package/crates/team-agent/src/provider/model_catalog.rs +201 -13
- package/crates/team-agent/src/provider/session/capture.rs +106 -6
- package/crates/team-agent/src/provider/session/context_fork/claude.rs +123 -0
- package/crates/team-agent/src/provider/session/context_fork/outcome.rs +4 -0
- package/crates/team-agent/src/provider/session/context_fork.rs +150 -18
- package/crates/team-agent/src/provider/session_scan/claude.rs +523 -0
- package/crates/team-agent/src/provider/session_scan/common.rs +44 -8
- package/crates/team-agent/src/provider/session_scan/pi.rs +34 -1
- package/crates/team-agent/src/provider/session_scan.rs +16 -6
- package/crates/team-agent/src/provider/tests/adapter.rs +104 -17
- package/crates/team-agent/src/provider/tests/classify.rs +0 -53
- package/crates/team-agent/src/provider/tests/command_helpers.rs +12 -3
- package/crates/team-agent/src/provider/tests/idle.rs +37 -0
- package/crates/team-agent/src/provider/wire.rs +22 -34
- package/crates/team-agent/src/state/abnormal_watch/tests/mod.rs +1 -1
- package/crates/team-agent/src/state/persist.rs +6 -6
- package/crates/team-agent/src/state/projection.rs +1 -1
- package/crates/team-agent/src/state/repository/tests.rs +2 -2
- package/crates/team-agent/src/test_support/models_timeout_fixture.rs +144 -0
- package/crates/team-agent/src/tmux_backend/tests.rs +0 -151
- package/crates/team-agent/src/tmux_backend.rs +5 -40
- package/package.json +4 -4
- package/skills/team-agent/SKILL.md +5 -7
- package/skills/team-agent/command-coverage.json +1 -1
- package/skills/team-agent/docs/reference/team-agent-operator.md +3 -3
- package/skills/team-agent/references/team-agent-operator.md +3 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
//! purpose:
|
|
2
|
-
//! contract: 缺 model 的
|
|
1
|
+
//! purpose: claude 席位角色文件缺 model 时仍能正常启动
|
|
2
|
+
//! contract: 缺 model 的 claude 角色启动成功并真的 spawn worker
|
|
3
3
|
//! boundary: legacy Grok worker runtime 已移除(grok 角色现走 grok_build 合约叶),
|
|
4
|
-
//! 本文件只保留
|
|
4
|
+
//! 本文件只保留 claude 缺 model 的回归钉子
|
|
5
5
|
|
|
6
6
|
#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
|
|
7
7
|
|
|
@@ -21,20 +21,20 @@ use serial_test::serial;
|
|
|
21
21
|
use team_agent::lifecycle::quick_start_with_transport_in_workspace;
|
|
22
22
|
use team_agent::transport::test_support::OfflineTransport;
|
|
23
23
|
|
|
24
|
-
///
|
|
24
|
+
/// claude 角色缺 model ⇒ 行为不变(仍能启动)。
|
|
25
25
|
#[test]
|
|
26
26
|
#[serial(env)]
|
|
27
|
-
fn
|
|
28
|
-
let _hermetic = enter_hermetic("grok-
|
|
29
|
-
let ws = tmp_dir("
|
|
27
|
+
fn claude_role_missing_model_still_starts() {
|
|
28
|
+
let _hermetic = enter_hermetic("grok-claude-missing-model");
|
|
29
|
+
let ws = tmp_dir("claude-no-model");
|
|
30
30
|
super::launch_spawn::seed_healthy_coordinator(&ws);
|
|
31
31
|
let team = write_role_team(
|
|
32
32
|
&ws,
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
33
|
+
"claudeteam",
|
|
34
|
+
"clauder",
|
|
35
|
+
"claude",
|
|
36
36
|
None,
|
|
37
|
-
"
|
|
37
|
+
"Claude Worker",
|
|
38
38
|
);
|
|
39
39
|
let transport = OfflineTransport::new();
|
|
40
40
|
|
|
@@ -43,17 +43,17 @@ fn copilot_role_missing_model_still_starts() {
|
|
|
43
43
|
&team,
|
|
44
44
|
None,
|
|
45
45
|
true,
|
|
46
|
-
Some("
|
|
46
|
+
Some("claudeteam"),
|
|
47
47
|
&transport,
|
|
48
48
|
);
|
|
49
49
|
assert!(
|
|
50
50
|
result.is_ok(),
|
|
51
|
-
"
|
|
51
|
+
"claude role without model must keep starting; err={result:?}"
|
|
52
52
|
);
|
|
53
53
|
let argv = first_spawn_argv(&transport);
|
|
54
54
|
assert!(
|
|
55
55
|
!argv.is_empty(),
|
|
56
|
-
"
|
|
56
|
+
"claude seat must still spawn; argv={argv:?}"
|
|
57
57
|
);
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
//! leave a stale .tmp on a failed replace. The contracts assert the original data
|
|
11
11
|
//! survives / no residue.
|
|
12
12
|
//! T3 (false green = unrecognized/failed input silently maps to a success value,
|
|
13
|
-
//! MUST-NOT-13): normalize_result_status unrecognized -> Success;
|
|
14
|
-
//! missing db -> ok:true; tmux fabricated
|
|
13
|
+
//! MUST-NOT-13): normalize_result_status unrecognized -> Success; claude_auth_hint
|
|
14
|
+
//! parse failure -> Present; schema_diagnosis missing db -> ok:true; tmux fabricated
|
|
15
15
|
//! `%0` pane id; packaging install/update constant DoctorStatus::Ok.
|
|
16
16
|
//! T5: stop_coordinator_bounded spawns a thread + recv_timeout and never joins it —
|
|
17
17
|
//! a timed-out stop leaves a detached thread. Source grep guard (the bounded-stop
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
#[allow(dead_code)]
|
|
24
24
|
mod mcp_sim_harness;
|
|
25
25
|
|
|
26
|
-
use std::path::PathBuf;
|
|
26
|
+
use std::path::{Path, PathBuf};
|
|
27
27
|
use std::sync::atomic::{AtomicU64, Ordering};
|
|
28
28
|
|
|
29
29
|
use mcp_sim_harness::McpSimHarness;
|
|
@@ -246,23 +246,15 @@ fn t3_unknown_business_status_is_preserved_without_normalized_event() {
|
|
|
246
246
|
"T3-1 ingress: an opaque business status must be accepted; body={} raw={}",
|
|
247
247
|
call.body, call.raw
|
|
248
248
|
);
|
|
249
|
-
let
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
row.status, "collected",
|
|
259
|
-
"T3-1 ingress: report_result auto-finalization must mark the durable row collected"
|
|
260
|
-
);
|
|
261
|
-
assert_eq!(
|
|
262
|
-
envelope["status"],
|
|
263
|
-
serde_json::json!(status),
|
|
264
|
-
"T3-1 ingress: canonical envelope status must preserve the same value"
|
|
265
|
-
);
|
|
249
|
+
let message_id = call.body["message_id"].as_str().expect("durable inbound receipt id");
|
|
250
|
+
let inbox = crate::inbox_store::read(harness.workspace_path(), "leader", 10, Some("teamA")).unwrap();
|
|
251
|
+
let record = inbox["messages"].as_array().unwrap().iter()
|
|
252
|
+
.find(|record| record["message_id"] == message_id).expect("durable inbox record");
|
|
253
|
+
let envelope = &record["envelope"];
|
|
254
|
+
assert_eq!(record["content"], "did a thing");
|
|
255
|
+
assert_eq!(record["kind"], "result");
|
|
256
|
+
assert_eq!(envelope["status"], status, "opaque business status must not be normalized");
|
|
257
|
+
assert!(harness.result_row(message_id).is_none(), "no coordinator result row");
|
|
266
258
|
let events = harness.events_text();
|
|
267
259
|
assert!(
|
|
268
260
|
!events.contains("provider.result.unknown_status_normalized"),
|
|
@@ -419,6 +411,45 @@ check behind it = false green); it must reflect an actual doctor result"
|
|
|
419
411
|
);
|
|
420
412
|
}
|
|
421
413
|
|
|
414
|
+
/// T3-2 (claude_auth_hint parse failure): when `claude auth status` output is
|
|
415
|
+
/// unparseable / unsuccessful, the hint must not default to Present (auth misreported
|
|
416
|
+
/// as available). PATH-shims a `claude` that prints garbage and exits non-zero.
|
|
417
|
+
/// Mutates the process-global PATH/HOME — must not race host_cotenant's ps/tmux
|
|
418
|
+
/// shims (P0 pid-probe isolation) or other env-mutating tests, hence
|
|
419
|
+
/// `#[serial(env, pid_probe)]`.
|
|
420
|
+
#[test]
|
|
421
|
+
#[serial(env, pid_probe)]
|
|
422
|
+
fn t3_claude_auth_hint_parse_failure_is_not_present() {
|
|
423
|
+
let home = tmp_ws("t3-auth-home");
|
|
424
|
+
let shim_dir = home.join("bin");
|
|
425
|
+
std::fs::create_dir_all(&shim_dir).unwrap();
|
|
426
|
+
// claude shim: garbage stdout + non-zero exit (auth status unparseable / failed).
|
|
427
|
+
write_shim(
|
|
428
|
+
&shim_dir.join("claude"),
|
|
429
|
+
"#!/bin/sh\nprintf 'not json at all\\n'\nexit 7\n",
|
|
430
|
+
);
|
|
431
|
+
let old_path = std::env::var("PATH").unwrap_or_default();
|
|
432
|
+
let old_home = std::env::var("HOME").ok();
|
|
433
|
+
std::env::set_var("HOME", &home);
|
|
434
|
+
std::env::set_var("PATH", format!("{}:{old_path}", shim_dir.to_string_lossy()));
|
|
435
|
+
|
|
436
|
+
let status = team_agent::provider::get_adapter(team_agent::provider::Provider::Claude)
|
|
437
|
+
.auth_hint(team_agent::provider::AuthMode::Subscription);
|
|
438
|
+
|
|
439
|
+
std::env::set_var("PATH", &old_path);
|
|
440
|
+
match old_home {
|
|
441
|
+
Some(home) => std::env::set_var("HOME", home),
|
|
442
|
+
None => std::env::remove_var("HOME"),
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
assert_ne!(
|
|
446
|
+
format!("{status:?}"),
|
|
447
|
+
"Present",
|
|
448
|
+
"T3-2: a `claude auth status` that prints unparseable output and exits non-zero \
|
|
449
|
+
must NOT report Present (auth misreported as available is a false green); got {status:?}"
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
|
|
422
453
|
// ───────────────────────────────── T5 · thread leak ─────────────────────────────────
|
|
423
454
|
|
|
424
455
|
/// T5 (A2 shutdown thread leak): stop_coordinator_bounded spawns a worker thread and
|
|
@@ -445,6 +476,15 @@ stop; body={body}"
|
|
|
445
476
|
|
|
446
477
|
// ───────────────────────────────────── helpers ─────────────────────────────────────
|
|
447
478
|
|
|
479
|
+
fn write_shim(path: &Path, body: &str) {
|
|
480
|
+
std::fs::write(path, body).unwrap();
|
|
481
|
+
#[cfg(unix)]
|
|
482
|
+
{
|
|
483
|
+
use std::os::unix::fs::PermissionsExt;
|
|
484
|
+
std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o755)).unwrap();
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
|
|
448
488
|
/// Crude single-function body extractor: from the `fn name` line to the next
|
|
449
489
|
/// same-indent ` fn ` (good enough for grep-guard scoping).
|
|
450
490
|
fn fn_body(src: &str, marker: &str) -> String {
|
|
@@ -41,6 +41,7 @@ fn launch_source() -> String {
|
|
|
41
41
|
const QS_TEAM_MD: &str =
|
|
42
42
|
"---\nname: quickteam\nobjective: Quick start.\nprovider: codex\n---\n\nQuick-start team.\n";
|
|
43
43
|
pub(super) const QS_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";
|
|
44
|
+
const QS_ROLE_NO_PROVIDER: &str = "---\nname: implementer\nrole: Implementation Engineer\nmodel: gpt-5.5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nImplement bounded tasks.\n";
|
|
44
45
|
|
|
45
46
|
/// A REAL team dir `<base>/teamdir/{TEAM.md, agents/implementer.md}` — already in team-dir
|
|
46
47
|
/// layout, so quick_start's prepare_quick_start_team returns it as-is and writes the compiled
|
|
@@ -458,23 +459,25 @@ fn quick_start_default_workspace_compiled_spec_uses_project_root() {
|
|
|
458
459
|
);
|
|
459
460
|
}
|
|
460
461
|
|
|
461
|
-
//
|
|
462
|
-
//
|
|
463
|
-
|
|
462
|
+
// P0 — quick_start over an INVALID role doc (missing `provider`) must surface the REAL compile
|
|
463
|
+
// error, distinct from the stub's hardcoded "no role docs found". Golden: compile_team raises
|
|
464
|
+
// "missing front matter field provider" (compiler.py:_validate_role_doc), before preflight.
|
|
464
465
|
#[test]
|
|
465
|
-
fn
|
|
466
|
-
let team = quick_start_team_dir(
|
|
467
|
-
|
|
466
|
+
fn quick_start_invalid_role_doc_surfaces_real_compile_error() {
|
|
467
|
+
let team = quick_start_team_dir(QS_ROLE_NO_PROVIDER);
|
|
468
|
+
let transport = OfflineTransport::new();
|
|
469
|
+
let result = quick_start_with_transport(&team, None, true, None, &transport);
|
|
470
|
+
|
|
471
|
+
let text = format!("{result:?}");
|
|
472
|
+
assert!(
|
|
473
|
+
text.contains("provider"),
|
|
474
|
+
"an invalid role doc (missing provider) must surface the real compile error mentioning \
|
|
475
|
+
'provider'; got {text}"
|
|
476
|
+
);
|
|
477
|
+
assert!(
|
|
478
|
+
!text.contains("no role docs found"),
|
|
479
|
+
"must NOT be the hardcoded stub blocker — real preflight/compile distinguishes the cause"
|
|
468
480
|
);
|
|
469
|
-
let spec = crate::compiler::compile_team(&team).expect("an omitted provider is the default pi");
|
|
470
|
-
let providers = spec
|
|
471
|
-
.get("agents")
|
|
472
|
-
.and_then(crate::model::yaml::Value::as_list)
|
|
473
|
-
.expect("compiled agents")
|
|
474
|
-
.iter()
|
|
475
|
-
.map(|agent| agent.get("provider").and_then(crate::model::yaml::Value::as_str))
|
|
476
|
-
.collect::<Vec<_>>();
|
|
477
|
-
assert_eq!(providers, vec![Some("pi_tui")]);
|
|
478
481
|
}
|
|
479
482
|
|
|
480
483
|
// P0 — launch (dry_run) over a real compiled spec must resolve the REAL route/permission plan
|
|
@@ -2581,22 +2584,21 @@ fn restart_allow_fresh_copilot_keeps_session_id_null_until_capture_confirms() {
|
|
|
2581
2584
|
let _ = plan; // shape verified above; details depend on classifier internals.
|
|
2582
2585
|
}
|
|
2583
2586
|
|
|
2584
|
-
/// 0.4.6 tuple-atomic contract (audit, line 268):
|
|
2585
|
-
///
|
|
2586
|
-
/// input row had a stale session_id.
|
|
2587
|
+
/// 0.4.6 tuple-atomic contract (audit, line 268): Claude fresh restart
|
|
2588
|
+
/// leaves session_id=null even when input row had a stale session_id.
|
|
2587
2589
|
/// The poisoned-row scenario (Bug 045 release-engineer state).
|
|
2588
2590
|
#[test]
|
|
2589
|
-
fn
|
|
2590
|
-
let ws = temp_ws().join("
|
|
2591
|
+
fn restart_allow_fresh_claude_clears_poisoned_session_id() {
|
|
2592
|
+
let ws = temp_ws().join("restartclaude046");
|
|
2591
2593
|
std::fs::create_dir_all(ws.join("agents")).unwrap();
|
|
2592
2594
|
std::fs::write(
|
|
2593
2595
|
ws.join("TEAM.md"),
|
|
2594
|
-
"---\nname:
|
|
2596
|
+
"---\nname: restartclaude046\nobjective: 0.4.6 contract.\nprovider: claude\n---\n\nteam.\n",
|
|
2595
2597
|
)
|
|
2596
2598
|
.unwrap();
|
|
2597
2599
|
std::fs::write(
|
|
2598
2600
|
ws.join("agents").join("alpha.md"),
|
|
2599
|
-
"---\nname: alpha\nrole: Alpha\nprovider:
|
|
2601
|
+
"---\nname: alpha\nrole: Alpha\nprovider: claude\nmodel: sonnet\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nAlpha.\n",
|
|
2600
2602
|
)
|
|
2601
2603
|
.unwrap();
|
|
2602
2604
|
let spec = crate::compiler::compile_team(&ws).expect("compile");
|
|
@@ -2605,11 +2607,11 @@ fn restart_allow_fresh_copilot_clears_poisoned_session_id() {
|
|
|
2605
2607
|
crate::state::persist::save_runtime_state(
|
|
2606
2608
|
&ws,
|
|
2607
2609
|
&json!({
|
|
2608
|
-
"session_name": "team-
|
|
2610
|
+
"session_name": "team-restartclaude046",
|
|
2609
2611
|
"agents": {
|
|
2610
2612
|
"alpha": {
|
|
2611
2613
|
"status": "running",
|
|
2612
|
-
"provider": "
|
|
2614
|
+
"provider": "claude",
|
|
2613
2615
|
"window": "alpha",
|
|
2614
2616
|
"first_send_at": "2026-06-23T10:00:00+00:00",
|
|
2615
2617
|
"session_id": stale_uuid,
|
|
@@ -2627,7 +2629,7 @@ fn restart_allow_fresh_copilot_clears_poisoned_session_id() {
|
|
|
2627
2629
|
let result = restart_with_transport(&ws, true, None, &transport);
|
|
2628
2630
|
assert!(
|
|
2629
2631
|
matches!(result, Ok(RestartReport::Restarted { .. })),
|
|
2630
|
-
"allow-fresh restart should fresh-spawn the
|
|
2632
|
+
"allow-fresh restart should fresh-spawn the claude worker; got {result:?}"
|
|
2631
2633
|
);
|
|
2632
2634
|
|
|
2633
2635
|
let state = crate::state::persist::load_runtime_state(&ws).expect("load state");
|
|
@@ -2635,7 +2637,7 @@ fn restart_allow_fresh_copilot_clears_poisoned_session_id() {
|
|
|
2635
2637
|
assert_eq!(
|
|
2636
2638
|
agent.get("session_id"),
|
|
2637
2639
|
Some(&serde_json::Value::Null),
|
|
2638
|
-
"0.4.6 contract: fresh restart must clear stale session_id; agent={agent}"
|
|
2640
|
+
"0.4.6 contract: Claude fresh restart must clear stale session_id; agent={agent}"
|
|
2639
2641
|
);
|
|
2640
2642
|
// C1 dual-projection: teams.<key>.agents.alpha.session_id must also be null.
|
|
2641
2643
|
if let Some(teams) = state.get("teams").and_then(serde_json::Value::as_object) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//! purpose: worker 契约里的 MCP 工具名必须按 provider 实测书写形式渲染
|
|
2
2
|
//! contract:
|
|
3
|
-
//! claude → mcp__team_orchestrator__send_message /
|
|
4
|
-
//! grok → team_orchestrator__send_message /
|
|
3
|
+
//! claude → mcp__team_orchestrator__send_message / mcp__team_orchestrator__get_team_status
|
|
4
|
+
//! grok → team_orchestrator__send_message / team_orchestrator__get_team_status
|
|
5
5
|
//! 已验证 provider 的渲染结果不得再含 `team_orchestrator.` 点号
|
|
6
6
|
//! boundary: 只钉 compile_worker_system_prompt 字面;未验证 provider 不在此猜形式
|
|
7
7
|
|
|
@@ -30,8 +30,8 @@ fn claude_runtime_contract_pins_mcp_double_underscore_literals() {
|
|
|
30
30
|
for provider in [Provider::Claude, Provider::ClaudeCode] {
|
|
31
31
|
let prompt = compiled_prompt(provider);
|
|
32
32
|
assert!(
|
|
33
|
-
prompt.contains("
|
|
34
|
-
"{provider:?} must render the claude transcript literal
|
|
33
|
+
prompt.contains("mcp__team_orchestrator__get_team_status"),
|
|
34
|
+
"{provider:?} must render the claude transcript literal mcp__team_orchestrator__get_team_status; prompt={prompt}"
|
|
35
35
|
);
|
|
36
36
|
assert!(
|
|
37
37
|
prompt.contains("mcp__team_orchestrator__send_message"),
|
|
@@ -44,8 +44,8 @@ fn claude_runtime_contract_pins_mcp_double_underscore_literals() {
|
|
|
44
44
|
fn grok_runtime_contract_pins_server_double_underscore_literals() {
|
|
45
45
|
let prompt = compiled_prompt(Provider::Grok);
|
|
46
46
|
assert!(
|
|
47
|
-
prompt.contains("
|
|
48
|
-
"grok must render
|
|
47
|
+
prompt.contains("team_orchestrator__get_team_status"),
|
|
48
|
+
"grok must render team_orchestrator__get_team_status; prompt={prompt}"
|
|
49
49
|
);
|
|
50
50
|
assert!(
|
|
51
51
|
prompt.contains("team_orchestrator__send_message"),
|
|
@@ -2,9 +2,10 @@ use std::collections::BTreeSet;
|
|
|
2
2
|
use std::path::Path;
|
|
3
3
|
|
|
4
4
|
use crate::lifecycle::launch::pi_mcp::{
|
|
5
|
-
|
|
5
|
+
parse_pi_list_models_table, select_exact_pi_model, verify_started_pi_model,
|
|
6
6
|
};
|
|
7
7
|
use crate::model::enums::ProviderEffort;
|
|
8
|
+
use crate::provider::adapters::pi::{build_pi_command_argv, PiCommandRequest, PiSessionSelector};
|
|
8
9
|
|
|
9
10
|
const CATALOG: &[u8] = include_bytes!("fixtures/pi_list_models_g0.stdout.txt");
|
|
10
11
|
// Public pi --list-models rows captured for issue #186, preserving column widths.
|
|
@@ -86,12 +87,13 @@ fn argv_has_pair(argv: &[String], flag: &str, value: &str) -> bool {
|
|
|
86
87
|
|
|
87
88
|
fn command_for_model(model: &str) -> Vec<String> {
|
|
88
89
|
build_pi_command_argv(PiCommandRequest {
|
|
89
|
-
extension: Path::new("/workspace/.team/runtime/pi/t1/
|
|
90
|
+
extension: Path::new("/workspace/.team/runtime/pi/t1/w1/team-mcp.ts"),
|
|
90
91
|
model: Some(model),
|
|
91
92
|
effort: Some(ProviderEffort::Medium),
|
|
92
|
-
system_prompt: "
|
|
93
|
-
session_dir: Some(Path::new("/workspace/.team/runtime/pi/t1/
|
|
94
|
-
|
|
93
|
+
system_prompt: "worker contract",
|
|
94
|
+
session_dir: Some(Path::new("/workspace/.team/runtime/pi/t1/w1/sessions")),
|
|
95
|
+
session: PiSessionSelector::Fresh,
|
|
96
|
+
agent_id: "w1",
|
|
95
97
|
})
|
|
96
98
|
.expect("catalog member must build a semantic Pi argv")
|
|
97
99
|
}
|
|
@@ -132,7 +134,7 @@ fn pi_catalog_discovers_all_exact_ids_and_rejects_invalid_or_ambiguous_selection
|
|
|
132
134
|
}
|
|
133
135
|
|
|
134
136
|
#[test]
|
|
135
|
-
fn
|
|
137
|
+
fn pi_exact_catalog_id_is_forwarded_and_started_identity_must_match() {
|
|
136
138
|
let models = parse_pi_list_models_table(CATALOG).expect("frozen unfiltered table must parse");
|
|
137
139
|
assert_eq!(models.len(), 221);
|
|
138
140
|
|
|
@@ -149,4 +151,14 @@ fn pi_exact_catalog_id_is_forwarded_byte_for_byte() {
|
|
|
149
151
|
"model selector must occur exactly once: {argv:?}"
|
|
150
152
|
);
|
|
151
153
|
}
|
|
154
|
+
|
|
155
|
+
assert!(verify_started_pi_model("team-agent/qwen3.8-27b", "team-agent/qwen3.8-27b").is_ok());
|
|
156
|
+
assert!(
|
|
157
|
+
verify_started_pi_model("team-agent/qwen3.8-27b", "xai/grok-4.6").is_err(),
|
|
158
|
+
"started identity mismatch must refuse rather than trust pane chrome"
|
|
159
|
+
);
|
|
160
|
+
assert!(
|
|
161
|
+
verify_started_pi_model("team-agent/qwen3.8-27b", "").is_err(),
|
|
162
|
+
"missing objective started-model evidence must not pass"
|
|
163
|
+
);
|
|
152
164
|
}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
use std::path::Path;
|
|
2
2
|
|
|
3
|
-
use crate::lifecycle::launch::pi_mcp::{
|
|
4
|
-
build_pi_command_argv, pi_leader_session_scope, PiCommandRequest, PiSessionScope,
|
|
5
|
-
};
|
|
3
|
+
use crate::lifecycle::launch::pi_mcp::{pi_leader_session_scope, PiSessionScope};
|
|
6
4
|
use crate::model::enums::ProviderEffort;
|
|
5
|
+
use crate::provider::adapters::pi::{build_pi_command_argv, PiCommandRequest, PiSessionSelector};
|
|
7
6
|
|
|
8
|
-
fn
|
|
7
|
+
fn request(session: PiSessionSelector<'static>) -> PiCommandRequest<'static> {
|
|
9
8
|
PiCommandRequest {
|
|
10
|
-
extension: Path::new("/workspace/.team/runtime/pi/team-a/
|
|
9
|
+
extension: Path::new("/workspace/.team/runtime/pi/team-a/worker-a/team-mcp.ts"),
|
|
11
10
|
model: Some("team-agent/qwen3.8-27b"),
|
|
12
11
|
effort: Some(ProviderEffort::High),
|
|
13
|
-
system_prompt: "frozen
|
|
12
|
+
system_prompt: "frozen worker prompt",
|
|
14
13
|
session_dir: Some(Path::new(
|
|
15
|
-
"/workspace/.team/runtime/pi/team-a/
|
|
14
|
+
"/workspace/.team/runtime/pi/team-a/worker-a/sessions",
|
|
16
15
|
)),
|
|
17
|
-
|
|
16
|
+
session,
|
|
17
|
+
agent_id: "worker-a",
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
#[test]
|
|
22
22
|
fn pi_command_omits_unset_model_and_thinking_flags() {
|
|
23
|
-
let mut request =
|
|
23
|
+
let mut request = request(PiSessionSelector::Fresh);
|
|
24
24
|
request.model = None;
|
|
25
25
|
request.effort = None;
|
|
26
26
|
let argv = build_pi_command_argv(request).expect("Pi provider defaults");
|
|
@@ -36,6 +36,7 @@ fn leader_request() -> PiCommandRequest<'static> {
|
|
|
36
36
|
effort: None,
|
|
37
37
|
system_prompt: "frozen leader prompt",
|
|
38
38
|
session_dir: None,
|
|
39
|
+
session: PiSessionSelector::Fresh,
|
|
39
40
|
agent_id: "leader",
|
|
40
41
|
}
|
|
41
42
|
}
|
|
@@ -91,67 +92,84 @@ fn pi_leader_session_scope_keeps_explicit_and_external_routes_isolated() {
|
|
|
91
92
|
|
|
92
93
|
#[test]
|
|
93
94
|
fn pi_command_preserves_direct_pi_defaults_with_only_team_runtime_additions() {
|
|
94
|
-
let fresh = build_pi_command_argv(
|
|
95
|
+
let fresh = build_pi_command_argv(request(PiSessionSelector::Fresh))
|
|
96
|
+
.expect("fresh Pi command");
|
|
95
97
|
assert_eq!(
|
|
96
98
|
fresh,
|
|
97
99
|
[
|
|
98
100
|
"pi",
|
|
99
101
|
"-e",
|
|
100
|
-
"/workspace/.team/runtime/pi/team-a/
|
|
102
|
+
"/workspace/.team/runtime/pi/team-a/worker-a/team-mcp.ts",
|
|
101
103
|
"--model",
|
|
102
104
|
"team-agent/qwen3.8-27b",
|
|
103
105
|
"--thinking",
|
|
104
106
|
"high",
|
|
105
107
|
"--append-system-prompt",
|
|
106
|
-
"frozen
|
|
108
|
+
"frozen worker prompt",
|
|
107
109
|
"--session-dir",
|
|
108
|
-
"/workspace/.team/runtime/pi/team-a/
|
|
110
|
+
"/workspace/.team/runtime/pi/team-a/worker-a/sessions",
|
|
109
111
|
"--name",
|
|
110
|
-
"
|
|
112
|
+
"worker-a",
|
|
111
113
|
]
|
|
112
114
|
.map(str::to_string)
|
|
113
115
|
);
|
|
114
116
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
"
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
"
|
|
148
|
-
|
|
117
|
+
let resume = build_pi_command_argv(request(PiSessionSelector::Resume {
|
|
118
|
+
path: Path::new(
|
|
119
|
+
"/workspace/.team/runtime/pi/team-a/worker-a/sessions/2026/08/session.jsonl",
|
|
120
|
+
),
|
|
121
|
+
}))
|
|
122
|
+
.expect("resume Pi command");
|
|
123
|
+
assert!(resume.windows(2).any(|pair| {
|
|
124
|
+
pair == [
|
|
125
|
+
"--session",
|
|
126
|
+
"/workspace/.team/runtime/pi/team-a/worker-a/sessions/2026/08/session.jsonl",
|
|
127
|
+
]
|
|
128
|
+
}));
|
|
129
|
+
assert!(!resume.iter().any(|arg| arg == "--session-id"));
|
|
130
|
+
|
|
131
|
+
for argv in [&fresh, &resume] {
|
|
132
|
+
assert_eq!(argv.first().map(String::as_str), Some("pi"));
|
|
133
|
+
for forbidden in [
|
|
134
|
+
"rpc",
|
|
135
|
+
"--mode",
|
|
136
|
+
"--print",
|
|
137
|
+
"-p",
|
|
138
|
+
"-r",
|
|
139
|
+
"--resume",
|
|
140
|
+
"-c",
|
|
141
|
+
"--continue",
|
|
142
|
+
"--mcp-config",
|
|
143
|
+
"--provider",
|
|
144
|
+
"--fork",
|
|
145
|
+
"--workspace",
|
|
146
|
+
"--cwd",
|
|
147
|
+
"--rules",
|
|
148
|
+
"--always-approve",
|
|
149
|
+
"--force",
|
|
150
|
+
"--trust",
|
|
151
|
+
"--sandbox",
|
|
152
|
+
"--no-extensions",
|
|
153
|
+
"--no-approve",
|
|
154
|
+
"--no-context-files",
|
|
155
|
+
"--no-skills",
|
|
156
|
+
"--no-prompt-templates",
|
|
157
|
+
"--tui-mode",
|
|
158
|
+
"--tools",
|
|
159
|
+
"--system-prompt",
|
|
160
|
+
] {
|
|
161
|
+
assert!(
|
|
162
|
+
!argv.iter().any(|arg| arg == forbidden),
|
|
163
|
+
"materializer-owned Pi argv must not inherit {forbidden}: {argv:?}"
|
|
164
|
+
);
|
|
165
|
+
}
|
|
149
166
|
}
|
|
150
167
|
}
|
|
151
168
|
|
|
152
169
|
#[test]
|
|
153
170
|
fn pi_command_keeps_direct_plugins_skills_context_auth_and_tools() {
|
|
154
|
-
let argv = build_pi_command_argv(
|
|
171
|
+
let argv = build_pi_command_argv(request(PiSessionSelector::Fresh))
|
|
172
|
+
.expect("fresh Pi command");
|
|
155
173
|
|
|
156
174
|
for forbidden in [
|
|
157
175
|
"--no-context-files",
|
|
@@ -166,17 +184,17 @@ fn pi_command_keeps_direct_plugins_skills_context_auth_and_tools() {
|
|
|
166
184
|
assert_eq!(
|
|
167
185
|
argv.iter().filter(|arg| arg.as_str() == forbidden).count(),
|
|
168
186
|
0,
|
|
169
|
-
"Pi
|
|
187
|
+
"TeamMate Pi must preserve the direct Pi default instead of adding {forbidden}; argv={argv:?}"
|
|
170
188
|
);
|
|
171
189
|
}
|
|
172
190
|
assert!(argv.windows(2).any(|pair| {
|
|
173
191
|
pair == [
|
|
174
192
|
"-e",
|
|
175
|
-
"/workspace/.team/runtime/pi/team-a/
|
|
193
|
+
"/workspace/.team/runtime/pi/team-a/worker-a/team-mcp.ts",
|
|
176
194
|
]
|
|
177
195
|
}));
|
|
178
196
|
assert_eq!(argv.iter().filter(|arg| arg.as_str() == "-e").count(), 1);
|
|
179
197
|
assert!(argv
|
|
180
198
|
.windows(2)
|
|
181
|
-
.any(|pair| pair == ["--append-system-prompt", "frozen
|
|
199
|
+
.any(|pair| pair == ["--append-system-prompt", "frozen worker prompt"]));
|
|
182
200
|
}
|