@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,6 +1,32 @@
|
|
|
1
|
-
use std::path::Path;
|
|
1
|
+
use std::path::{Path, PathBuf};
|
|
2
2
|
|
|
3
|
+
use crate::cli::diagnose::{pi_doctor_facts, PiBackingStatus, PiDoctorInput, PiMcpStatus};
|
|
3
4
|
use crate::lifecycle::launch::pi_mcp::{pi_cleanup_plan, pi_seat_paths, PiCleanupAction};
|
|
5
|
+
use crate::provider::{AuthHintStatus, ClassifySource, TurnState};
|
|
6
|
+
|
|
7
|
+
fn doctor_input() -> PiDoctorInput {
|
|
8
|
+
PiDoctorInput {
|
|
9
|
+
executable_chain_verified: true,
|
|
10
|
+
pi_version: Some("0.84.3".to_string()),
|
|
11
|
+
adapter_version: Some("2.30.0".to_string()),
|
|
12
|
+
catalog_sha256: Some(
|
|
13
|
+
"726cedb6c3f6fe80a0d7b98918d8ed5063695e01f510a48f46c4bad5daab49fe".to_string(),
|
|
14
|
+
),
|
|
15
|
+
selected_model: Some("team-agent/qwen3.8-27b".to_string()),
|
|
16
|
+
candidate_executable: Some(PathBuf::from("/candidate/team-agent")),
|
|
17
|
+
wrapper: Some(PathBuf::from(
|
|
18
|
+
"/workspace/.team/runtime/pi/team-a/worker-a/team-mcp.ts",
|
|
19
|
+
)),
|
|
20
|
+
mcp_roundtrip_at: None,
|
|
21
|
+
backing: PiBackingStatus::Pending,
|
|
22
|
+
activity: TurnState::Unknown,
|
|
23
|
+
activity_source: ClassifySource::SessionFile,
|
|
24
|
+
env_key_names: vec![
|
|
25
|
+
"TEAM_AGENT_ID".to_string(),
|
|
26
|
+
"TEAM_AGENT_OWNER_TEAM_ID".to_string(),
|
|
27
|
+
],
|
|
28
|
+
}
|
|
29
|
+
}
|
|
4
30
|
|
|
5
31
|
#[test]
|
|
6
32
|
fn pi_stop_retains_backing_and_never_scans_by_process_name() {
|
|
@@ -29,3 +55,44 @@ fn pi_stop_retains_backing_and_never_scans_by_process_name() {
|
|
|
29
55
|
"remove may delete only exact Team-owned seat paths"
|
|
30
56
|
);
|
|
31
57
|
}
|
|
58
|
+
|
|
59
|
+
#[test]
|
|
60
|
+
fn pi_doctor_separates_configured_roundtrip_backing_and_activity_unknown() {
|
|
61
|
+
let facts = pi_doctor_facts(doctor_input());
|
|
62
|
+
|
|
63
|
+
assert_eq!(facts.mcp, PiMcpStatus::ConfiguredLazy);
|
|
64
|
+
assert!(
|
|
65
|
+
!facts.mcp_connected,
|
|
66
|
+
"wrapper existence is not an MCP roundtrip"
|
|
67
|
+
);
|
|
68
|
+
assert_eq!(facts.backing, PiBackingStatus::Pending);
|
|
69
|
+
assert_eq!(facts.activity, TurnState::Unknown);
|
|
70
|
+
assert_eq!(facts.activity_source, ClassifySource::SessionFile);
|
|
71
|
+
assert_eq!(facts.auth_hint, AuthHintStatus::Unknown);
|
|
72
|
+
|
|
73
|
+
let serialized = serde_json::to_string(&facts).expect("serialize doctor facts");
|
|
74
|
+
assert!(serialized.contains("configured_lazy"));
|
|
75
|
+
assert!(serialized.contains("unknown"));
|
|
76
|
+
for secret_surface in [
|
|
77
|
+
"api_key",
|
|
78
|
+
"access_token",
|
|
79
|
+
"refresh_token",
|
|
80
|
+
"cookie",
|
|
81
|
+
"authorization",
|
|
82
|
+
] {
|
|
83
|
+
assert!(
|
|
84
|
+
!serialized.to_ascii_lowercase().contains(secret_surface),
|
|
85
|
+
"doctor must expose identity/digest/key names, never credential values"
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
let connected = pi_doctor_facts(PiDoctorInput {
|
|
90
|
+
mcp_roundtrip_at: Some("2026-08-29T10:02:00+00:00".to_string()),
|
|
91
|
+
backing: PiBackingStatus::Captured,
|
|
92
|
+
..doctor_input()
|
|
93
|
+
});
|
|
94
|
+
assert_eq!(connected.mcp, PiMcpStatus::RoundtripVerified);
|
|
95
|
+
assert!(connected.mcp_connected);
|
|
96
|
+
assert_eq!(connected.backing, PiBackingStatus::Captured);
|
|
97
|
+
assert_eq!(connected.activity, TurnState::Unknown);
|
|
98
|
+
}
|
|
@@ -18,8 +18,9 @@ use std::time::{Duration, Instant};
|
|
|
18
18
|
|
|
19
19
|
use crate::event_log::EventLog;
|
|
20
20
|
use crate::lifecycle::launch::pi_mcp::{
|
|
21
|
-
materialize_pi_plan, pi_seat_paths, PiMaterializeRequest, PiSessionScope,
|
|
21
|
+
materialize_pi_plan, pi_model_candidates, pi_seat_paths, PiMaterializeRequest, PiSessionScope,
|
|
22
22
|
};
|
|
23
|
+
use crate::lifecycle::launch::run_pi_catalog_preflight;
|
|
23
24
|
use crate::lifecycle::tests::test_binary_path;
|
|
24
25
|
use crate::message_store::MessageStore;
|
|
25
26
|
use crate::provider::McpConfig;
|
|
@@ -90,6 +91,23 @@ esac
|
|
|
90
91
|
call_log.to_str().expect("call log path must be UTF-8"),
|
|
91
92
|
);
|
|
92
93
|
|
|
94
|
+
let roles = hermetic.workspace("roles");
|
|
95
|
+
let agents = roles.join("agents");
|
|
96
|
+
std::fs::create_dir_all(&agents).expect("create Pi role directory");
|
|
97
|
+
std::fs::write(
|
|
98
|
+
agents.join("n1.md"),
|
|
99
|
+
"---\nprovider: pi\nmodel: team-agent/qwen3.8-27b\n---\nN1 native Pi fixture\n",
|
|
100
|
+
)
|
|
101
|
+
.expect("write exact-model Pi role");
|
|
102
|
+
assert_eq!(
|
|
103
|
+
pi_model_candidates("qwen3.8-27b").expect("fake Pi model catalog"),
|
|
104
|
+
["team-agent/qwen3.8-27b"],
|
|
105
|
+
"catalog discovery must succeed without consulting the package list"
|
|
106
|
+
);
|
|
107
|
+
let mut discover = |requested: &str| pi_model_candidates(requested).map_err(|_| ());
|
|
108
|
+
run_pi_catalog_preflight(&roles, &mut discover)
|
|
109
|
+
.expect("exact-model catalog preflight must pass on native-only Pi");
|
|
110
|
+
|
|
93
111
|
let harness = sim::McpSimHarness::new();
|
|
94
112
|
harness.bind_leader_receiver_to_team("teamA");
|
|
95
113
|
let workspace = harness.workspace_path();
|
|
@@ -131,6 +149,7 @@ esac
|
|
|
131
149
|
team_mcp_tools: &REQUIRED_TOOLS,
|
|
132
150
|
mcp_config: &config,
|
|
133
151
|
session_scope: PiSessionScope::Isolated,
|
|
152
|
+
session_dir: None,
|
|
134
153
|
});
|
|
135
154
|
let pi_calls = std::fs::read_to_string(&call_log).unwrap_or_default();
|
|
136
155
|
assert!(
|
|
@@ -216,7 +235,11 @@ esac
|
|
|
216
235
|
let wire_prompt = native_receipt["wirePrompt"]
|
|
217
236
|
.as_str()
|
|
218
237
|
.expect("Pi wrapper installs an actual tool wire binding");
|
|
219
|
-
assert!(
|
|
238
|
+
assert!(["send_message", "get_team_status"]
|
|
239
|
+
.iter()
|
|
240
|
+
.all(|tool| wire_prompt.contains(tool)));
|
|
241
|
+
assert!(wire_prompt.contains("Use send_message exclusively for communication"));
|
|
242
|
+
assert!(!wire_prompt.contains("report_result"));
|
|
220
243
|
let registration = ®istrations[0];
|
|
221
244
|
let alias = registration["name"]
|
|
222
245
|
.as_str()
|
|
@@ -315,16 +338,15 @@ esac
|
|
|
315
338
|
"report_result stdio call: {}",
|
|
316
339
|
report.body
|
|
317
340
|
);
|
|
318
|
-
let
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
assert_eq!(
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
harness.drive_delivery_twice();
|
|
341
|
+
let message_id = report.body["message_id"].as_str().expect("durable inbound receipt id");
|
|
342
|
+
let inbox = crate::inbox_store::read(harness.workspace_path(), "leader", 10, Some("teamA")).unwrap();
|
|
343
|
+
let record = inbox["messages"].as_array().unwrap().iter()
|
|
344
|
+
.find(|record| record["message_id"] == message_id).expect("report persisted in the inbox");
|
|
345
|
+
assert_eq!(record["team"], "teamA");
|
|
346
|
+
assert_eq!(record["sender"], "worker_a");
|
|
347
|
+
assert_eq!(record["envelope"]["task_id"], "task_mcp");
|
|
348
|
+
assert!(harness.result_row(message_id).is_none(), "no result-ledger coupling");
|
|
349
|
+
assert!(harness.message_rows_containing(&result_marker).is_empty(), "no coordinator outbox");
|
|
328
350
|
assert!(harness.pane_text("leader").contains(&marker));
|
|
329
351
|
assert!(harness.pane_text("leader").contains(&result_marker));
|
|
330
352
|
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
use std::path::{Path, PathBuf};
|
|
2
2
|
use std::sync::atomic::{AtomicU32, Ordering};
|
|
3
3
|
|
|
4
|
-
use crate::
|
|
4
|
+
use crate::lifecycle::launch::pi_mcp::pi_seat_paths;
|
|
5
|
+
use crate::messaging::delivery::{
|
|
6
|
+
recipient_allows_explicit_queue_flush, recipient_requires_single_enter,
|
|
7
|
+
};
|
|
8
|
+
use crate::model::enums::{Provider, ProviderEffort};
|
|
9
|
+
use crate::provider::adapters::pi::{build_pi_command_argv, PiCommandRequest, PiSessionSelector};
|
|
5
10
|
use crate::provider::session_scan::{scan_session_candidates_once, CaptureSessionContext};
|
|
6
|
-
use crate::provider::SessionId;
|
|
11
|
+
use crate::provider::{get_adapter, AuthMode, ProviderError, SessionId};
|
|
7
12
|
|
|
8
13
|
static NEXT_ROOT: AtomicU32 = AtomicU32::new(0);
|
|
9
14
|
|
|
@@ -45,6 +50,20 @@ fn scan_context(cwd: &Path, root: &Path, id: &str, generation: &str) -> CaptureS
|
|
|
45
50
|
}
|
|
46
51
|
}
|
|
47
52
|
|
|
53
|
+
fn resume_argv(path: &Path) -> Result<Vec<String>, ProviderError> {
|
|
54
|
+
build_pi_command_argv(PiCommandRequest {
|
|
55
|
+
extension: Path::new("/workspace/.team/runtime/pi/team-a/worker-a/team-mcp.ts"),
|
|
56
|
+
model: Some("team-agent/qwen3.8-27b"),
|
|
57
|
+
effort: Some(ProviderEffort::Medium),
|
|
58
|
+
system_prompt: "worker contract",
|
|
59
|
+
session_dir: Some(Path::new(
|
|
60
|
+
"/workspace/.team/runtime/pi/team-a/worker-a/sessions",
|
|
61
|
+
)),
|
|
62
|
+
session: PiSessionSelector::Resume { path },
|
|
63
|
+
agent_id: "worker-a",
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
|
|
48
67
|
#[test]
|
|
49
68
|
fn pi_session_capture_requires_header_id_cwd_generation_and_unique_claim() {
|
|
50
69
|
let root = temp_root("session-capture");
|
|
@@ -132,3 +151,76 @@ fn pi_fresh_capture_reads_the_header_id_pi_wrote() {
|
|
|
132
151
|
);
|
|
133
152
|
std::fs::remove_dir_all(root).expect("remove native header fixture");
|
|
134
153
|
}
|
|
154
|
+
|
|
155
|
+
#[test]
|
|
156
|
+
fn pi_restart_uses_exact_path_and_refuses_missing_backing() {
|
|
157
|
+
let root = temp_root("resume");
|
|
158
|
+
let cwd = root.join("workspace");
|
|
159
|
+
let sessions = root.join("seat/sessions");
|
|
160
|
+
std::fs::create_dir_all(&cwd).expect("create cwd");
|
|
161
|
+
let id = "cc09d133-878f-4241-920f-f7ebfefc2a9e";
|
|
162
|
+
let generation = "2026-08-29T10:00:00Z";
|
|
163
|
+
let exact = sessions.join("nested/exact.jsonl");
|
|
164
|
+
write_header(&exact, id, &cwd, "2026-08-29T10:00:01Z");
|
|
165
|
+
|
|
166
|
+
let candidates =
|
|
167
|
+
scan_session_candidates_once(Provider::Pi, &scan_context(&cwd, &sessions, id, generation))
|
|
168
|
+
.expect("resume preflight scan");
|
|
169
|
+
assert_eq!(
|
|
170
|
+
candidates.len(),
|
|
171
|
+
1,
|
|
172
|
+
"exact backing must revalidate before restart"
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
let argv = resume_argv(&exact).expect("resume exact path");
|
|
176
|
+
assert!(argv
|
|
177
|
+
.windows(2)
|
|
178
|
+
.any(|pair| { pair[0] == "--session" && pair[1] == exact.to_string_lossy().as_ref() }));
|
|
179
|
+
assert!(!argv.iter().any(|arg| {
|
|
180
|
+
matches!(
|
|
181
|
+
arg.as_str(),
|
|
182
|
+
"--session-id" | "-c" | "--continue" | "-r" | "--resume"
|
|
183
|
+
)
|
|
184
|
+
}));
|
|
185
|
+
|
|
186
|
+
std::fs::remove_file(&exact).expect("remove backing tooth");
|
|
187
|
+
let missing = resume_argv(&exact);
|
|
188
|
+
assert!(
|
|
189
|
+
matches!(missing, Err(ProviderError::ResumeUnavailable(_))),
|
|
190
|
+
"missing exact backing must refuse rather than create a new session: {missing:?}"
|
|
191
|
+
);
|
|
192
|
+
std::fs::remove_dir_all(root).expect("remove resume fixture");
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
#[test]
|
|
196
|
+
fn pi_delivery_submits_one_enter_and_never_flushes_or_retries() {
|
|
197
|
+
let idle = serde_json::json!({
|
|
198
|
+
"agents": {
|
|
199
|
+
"worker-a": {"provider": "pi", "status": "running"}
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
assert!(recipient_requires_single_enter(&idle, "worker-a"));
|
|
203
|
+
assert!(!recipient_allows_explicit_queue_flush(&idle, "worker-a"));
|
|
204
|
+
let busy = serde_json::json!({
|
|
205
|
+
"agents": {
|
|
206
|
+
"worker-a": {"provider": "pi", "status": "busy"}
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
// Working native CLIs queue the same single-Enter input; no idle admission.
|
|
210
|
+
assert!(recipient_requires_single_enter(&busy, "worker-a"));
|
|
211
|
+
assert!(!recipient_allows_explicit_queue_flush(&busy, "worker-a"));
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
#[test]
|
|
215
|
+
fn pi_clone_is_fresh_and_fork_is_not_clone() {
|
|
216
|
+
let workspace = Path::new("/workspace");
|
|
217
|
+
let source_paths = pi_seat_paths(workspace, "team-a", "source");
|
|
218
|
+
let clone_paths = pi_seat_paths(workspace, "team-a", "clone");
|
|
219
|
+
assert_ne!(source_paths.runtime_root, clone_paths.runtime_root);
|
|
220
|
+
assert_ne!(source_paths.wrapper, clone_paths.wrapper);
|
|
221
|
+
assert_eq!(source_paths.sessions, clone_paths.sessions);
|
|
222
|
+
|
|
223
|
+
let source_session = SessionId::new("652756ea-aaee-4437-a30f-40c5606826d5");
|
|
224
|
+
let fork = get_adapter(Provider::Pi).fork(Some(&source_session), AuthMode::Subscription, None);
|
|
225
|
+
assert!(matches!(fork, Err(ProviderError::CapabilityUnsupported(_))));
|
|
226
|
+
}
|
|
@@ -40,7 +40,7 @@ const TEAM_MD: &str =
|
|
|
40
40
|
|
|
41
41
|
const FAKE_ROLE: &str = "---\nname: faker\nrole: Fake Worker\nprovider: fake\nmodel: fake\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nFake worker.\n";
|
|
42
42
|
|
|
43
|
-
const
|
|
43
|
+
const CLAUDE_ROLE: &str = "---\nname: clauder\nrole: Claude Worker\nprovider: claude\nmodel: claude-sonnet-4-6\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nClaude worker.\n";
|
|
44
44
|
|
|
45
45
|
#[test]
|
|
46
46
|
#[ignore = "real-machine: quick-start worker readiness gate"]
|
|
@@ -51,10 +51,10 @@ fn t1_quick_start_must_not_emit_bare_ready_when_worker_tool_load_is_unverified()
|
|
|
51
51
|
let team = bug7_team_dir(&hermetic, "t1-pending");
|
|
52
52
|
// Both agents spawn successfully (recording transport reports both windows live)
|
|
53
53
|
// but the framework has no way to verify the worker MCP tool set actually
|
|
54
|
-
// loaded —
|
|
54
|
+
// loaded — claude can still reject schemas asynchronously. The report
|
|
55
55
|
// therefore must be PendingToolLoad, not bare Ready.
|
|
56
56
|
let transport = RecordingTransport::new()
|
|
57
|
-
.with_windows(vec![WindowName::new("faker"), WindowName::new("
|
|
57
|
+
.with_windows(vec![WindowName::new("faker"), WindowName::new("clauder")]);
|
|
58
58
|
let report = quick_start_with_transport(&team, None, true, None, &transport)
|
|
59
59
|
.expect("quick_start_with_transport should succeed for healthy spawn");
|
|
60
60
|
let QuickStartReport::Ready {
|
|
@@ -98,8 +98,8 @@ fn t2_quick_start_must_report_degraded_when_a_worker_spawn_yields_no_live_window
|
|
|
98
98
|
hermetic.assert_no_real_tmux();
|
|
99
99
|
let team = bug7_team_dir(&hermetic, "t2-degraded");
|
|
100
100
|
// Recording transport simulates the Mac mini final capture: only the fake
|
|
101
|
-
// worker window exists after launch; the
|
|
102
|
-
// `
|
|
101
|
+
// worker window exists after launch; the claude window never materialized (no
|
|
102
|
+
// `claude` binary on PATH, etc.). BUG-2 fix already marks `clauder` as
|
|
103
103
|
// spawn_failed in runtime state; BUG-7 must surface that as a Degraded
|
|
104
104
|
// verdict so quick-start cannot pretend the team is ready.
|
|
105
105
|
let transport = RecordingTransport::new().with_windows(vec![WindowName::new("faker")]);
|
|
@@ -117,9 +117,9 @@ fn t2_quick_start_must_report_degraded_when_a_worker_spawn_yields_no_live_window
|
|
|
117
117
|
);
|
|
118
118
|
};
|
|
119
119
|
assert!(
|
|
120
|
-
unhealthy_agents.iter().any(|id| id == "
|
|
120
|
+
unhealthy_agents.iter().any(|id| id == "clauder"),
|
|
121
121
|
"T2: Degraded verdict must list the agent whose window never materialized \
|
|
122
|
-
(
|
|
122
|
+
(clauder); got unhealthy_agents={unhealthy_agents:?}"
|
|
123
123
|
);
|
|
124
124
|
let rendered = render_quick_start_summary(&report);
|
|
125
125
|
assert!(
|
|
@@ -128,8 +128,8 @@ fn t2_quick_start_must_report_degraded_when_a_worker_spawn_yields_no_live_window
|
|
|
128
128
|
the report as ready; got {rendered:?}"
|
|
129
129
|
);
|
|
130
130
|
assert!(
|
|
131
|
-
rendered.contains("
|
|
132
|
-
"T2: CLI summary should mention the unhealthy agent id (
|
|
131
|
+
rendered.contains("clauder"),
|
|
132
|
+
"T2: CLI summary should mention the unhealthy agent id (clauder); got {rendered:?}"
|
|
133
133
|
);
|
|
134
134
|
}
|
|
135
135
|
|
|
@@ -145,8 +145,7 @@ fn bug7_team_dir(hermetic: &HermeticTestEnv, tag: &str) -> PathBuf {
|
|
|
145
145
|
std::fs::create_dir_all(team.join("agents")).expect("mkdir teamdir/agents");
|
|
146
146
|
std::fs::write(team.join("TEAM.md"), TEAM_MD).expect("write TEAM.md");
|
|
147
147
|
std::fs::write(team.join("agents").join("faker.md"), FAKE_ROLE).expect("write faker.md");
|
|
148
|
-
std::fs::write(team.join("agents").join("
|
|
149
|
-
.expect("write copiloter.md");
|
|
148
|
+
std::fs::write(team.join("agents").join("clauder.md"), CLAUDE_ROLE).expect("write clauder.md");
|
|
150
149
|
team
|
|
151
150
|
}
|
|
152
151
|
|
|
@@ -686,7 +686,7 @@ fn write_profile_fixture(root: &Path, base_url: &str, token: &str) -> PathBuf {
|
|
|
686
686
|
fs::write(
|
|
687
687
|
team.join("profiles/local.env"),
|
|
688
688
|
format!(
|
|
689
|
-
"
|
|
689
|
+
"ANTHROPIC_BASE_URL={base_url}\nANTHROPIC_AUTH_TOKEN={token}\nANTHROPIC_MODEL=mock-model\n"
|
|
690
690
|
),
|
|
691
691
|
)
|
|
692
692
|
.unwrap();
|
|
@@ -697,7 +697,7 @@ fn write_profile_fixture(root: &Path, base_url: &str, token: &str) -> PathBuf {
|
|
|
697
697
|
.unwrap();
|
|
698
698
|
fs::write(
|
|
699
699
|
team.join("agents/worker.md"),
|
|
700
|
-
"---\nname: worker\nrole: Worker\nprovider:
|
|
700
|
+
"---\nname: worker\nrole: Worker\nprovider: claude\nauth_mode: compatible_api\ndangerously_skip_permissions: false\nprofile: local\nmodel: null\ntools:\n - mcp_team\n---\n\nWorker.\n",
|
|
701
701
|
)
|
|
702
702
|
.unwrap();
|
|
703
703
|
team
|
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
//! `swallow-batch4-cr-verdict.md` (workspace artifacts; BOTH points APPROVE'd,
|
|
5
5
|
//! 8 constraints C1-C8 + 6 reverse cases — folded below).
|
|
6
6
|
//!
|
|
7
|
-
//! Point 1 (C1-C4)
|
|
8
|
-
//!
|
|
7
|
+
//! Point 1 (C1-C4): a corrupt provider-config JSON must FAIL EXPLICITLY — today
|
|
8
|
+
//! profile_launch.rs:639-649 `read_json_object` turns any parse failure into an
|
|
9
|
+
//! empty map and `write_json_object` then flattens the user's file (silent
|
|
10
|
+
//! destructive rewrite; MUST-NOT-9 / MUST-NOT-13 violation).
|
|
9
11
|
//! Point 2 (C5-C8): MCP scope validation must FAIL CLOSED when the runtime state is
|
|
10
12
|
//! unreadable — today `load_runtime_state(..).unwrap_or(json!({}))`
|
|
11
13
|
//! (mcp_server/tools.rs:574/:232) silently substitutes an empty state, so a
|
|
@@ -23,9 +25,75 @@ mod hermetic_guard;
|
|
|
23
25
|
#[allow(dead_code)]
|
|
24
26
|
fn _hermetic_boundary_marker(_: &hermetic_guard::HermeticTestEnv) {}
|
|
25
27
|
|
|
28
|
+
use std::path::{Path, PathBuf};
|
|
29
|
+
use std::sync::atomic::{AtomicU64, Ordering};
|
|
30
|
+
|
|
26
31
|
use mcp_sim_harness::McpSimHarness;
|
|
27
32
|
use serde_json::json;
|
|
28
33
|
use serial_test::serial;
|
|
34
|
+
use team_agent::lifecycle::launch_with_transport;
|
|
35
|
+
|
|
36
|
+
/// C1-C4 + reverse cases `profile_invalid_json_returns_error_and_does_not_overwrite_file`
|
|
37
|
+
/// / `..._includes_path_and_parse_detail_and_next_action`: launching a claude
|
|
38
|
+
/// compatible_api profile over a CORRUPT `.claude.json` must return a structured error
|
|
39
|
+
/// (path + parse detail + next action) and leave the corrupt file byte-identical —
|
|
40
|
+
/// never rewrite it with a flattened empty object.
|
|
41
|
+
#[test]
|
|
42
|
+
#[serial(b4_mcp)]
|
|
43
|
+
fn b4_profile_invalid_json_fails_explicit_and_never_flattens_the_file() {
|
|
44
|
+
// Pin a neutral process ancestry so the launch path is deterministic regardless of
|
|
45
|
+
// which provider flags this test process inherited (same guard as the #264 batch).
|
|
46
|
+
std::env::set_var(
|
|
47
|
+
"TEAM_AGENT_TEST_PROCESS_ANCESTRY_ARGV_JSON",
|
|
48
|
+
"[\"/bin/zsh\"]",
|
|
49
|
+
);
|
|
50
|
+
let ws = tmp_ws("b4-profile");
|
|
51
|
+
let team_dir = write_claude_compatible_team(&ws);
|
|
52
|
+
let config_dir = ws.join(".team/runtime/provider-config/worker_a/claude");
|
|
53
|
+
std::fs::create_dir_all(&config_dir).unwrap();
|
|
54
|
+
let corrupt = b"{ this is the user's corrupt claude state".to_vec();
|
|
55
|
+
std::fs::write(config_dir.join(".claude.json"), &corrupt).unwrap();
|
|
56
|
+
|
|
57
|
+
let result = launch_with_transport(
|
|
58
|
+
&team_dir.join("team.spec.yaml"),
|
|
59
|
+
false,
|
|
60
|
+
true,
|
|
61
|
+
true,
|
|
62
|
+
&offline_transport::RecordingTransport::new(),
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
let mut failures = Vec::new();
|
|
66
|
+
match &result {
|
|
67
|
+
Ok(report) => failures.push(format!(
|
|
68
|
+
"C1/C2: a corrupt provider-config JSON must fail the launch with a \
|
|
69
|
+
structured profile_invalid_json error, not silently continue; got Ok({report:?})"
|
|
70
|
+
)),
|
|
71
|
+
Err(error) => {
|
|
72
|
+
let text = error.to_string();
|
|
73
|
+
if !text.contains(".claude.json") {
|
|
74
|
+
failures.push(format!(
|
|
75
|
+
"C1/N38: the error must name the offending path; got {text}"
|
|
76
|
+
));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
let after = std::fs::read(config_dir.join(".claude.json")).unwrap_or_default();
|
|
81
|
+
if after != corrupt {
|
|
82
|
+
failures.push(format!(
|
|
83
|
+
"C3/C4: the user's corrupt file must stay byte-identical (framework never \
|
|
84
|
+
flattens user files on load failure — MUST-NOT-9); before={} bytes, after={} bytes: {:?}",
|
|
85
|
+
corrupt.len(),
|
|
86
|
+
after.len(),
|
|
87
|
+
String::from_utf8_lossy(&after)
|
|
88
|
+
));
|
|
89
|
+
}
|
|
90
|
+
std::env::remove_var("TEAM_AGENT_TEST_PROCESS_ANCESTRY_ARGV_JSON");
|
|
91
|
+
assert!(
|
|
92
|
+
failures.is_empty(),
|
|
93
|
+
"batch4 point-1 profile fail-explicit contract failed:\n{}",
|
|
94
|
+
failures.join("\n")
|
|
95
|
+
);
|
|
96
|
+
}
|
|
29
97
|
|
|
30
98
|
/// C5-C8 + reverse cases `scope_unverifiable_when_state_read_fails_returns_structured_refusal`
|
|
31
99
|
/// / `scope_unverifiable_state_recovers_retry_passes`: with the runtime state
|
|
@@ -88,3 +156,187 @@ gate (owner-required refusal), not some degraded path; body={}",
|
|
|
88
156
|
failures.join("\n")
|
|
89
157
|
);
|
|
90
158
|
}
|
|
159
|
+
|
|
160
|
+
// ───────────────────────────────────── fixtures ─────────────────────────────────────
|
|
161
|
+
|
|
162
|
+
/// Compiled claude compatible_api team with a profile (the path that maintains the
|
|
163
|
+
/// managed `.claude.json`). Mirrors the #264 profile fixture, claude flavor.
|
|
164
|
+
fn write_claude_compatible_team(ws: &Path) -> PathBuf {
|
|
165
|
+
let team = ws.join("teamdir");
|
|
166
|
+
std::fs::create_dir_all(team.join("agents")).unwrap();
|
|
167
|
+
std::fs::create_dir_all(team.join("profiles")).unwrap();
|
|
168
|
+
std::fs::write(
|
|
169
|
+
team.join("TEAM.md"),
|
|
170
|
+
"---\nname: b4team\nobjective: batch4 profile fixture.\nprovider: claude\n---\n\nTeam.\n",
|
|
171
|
+
)
|
|
172
|
+
.unwrap();
|
|
173
|
+
std::fs::write(
|
|
174
|
+
team.join("agents/worker_a.md"),
|
|
175
|
+
"---\nname: worker_a\nrole: Compat Worker\nprovider: claude\nmodel: claude-haiku\nauth_mode: compatible_api\ndangerously_skip_permissions: false\nprofile: relay\ntools:\n - mcp_team\n---\n\nCompat worker.\n",
|
|
176
|
+
)
|
|
177
|
+
.unwrap();
|
|
178
|
+
std::fs::write(
|
|
179
|
+
team.join("profiles/relay.env"),
|
|
180
|
+
"AUTH_MODE=compatible_api\nBASE_URL=https://relay.example/v1\nAPI_KEY=sk-relay-b4\nMODEL=claude-haiku\n",
|
|
181
|
+
)
|
|
182
|
+
.unwrap();
|
|
183
|
+
let spec = team_agent::compiler::compile_team(&team).expect("compile fixture team");
|
|
184
|
+
std::fs::write(
|
|
185
|
+
team.join("team.spec.yaml"),
|
|
186
|
+
team_agent::model::yaml::dumps(&spec),
|
|
187
|
+
)
|
|
188
|
+
.unwrap();
|
|
189
|
+
team
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
mod offline_transport {
|
|
193
|
+
use super::*;
|
|
194
|
+
use std::collections::BTreeMap;
|
|
195
|
+
use std::sync::Mutex;
|
|
196
|
+
use team_agent::transport::{
|
|
197
|
+
AttachOutcome, BackendKind, CaptureRange, CapturedText, InjectPayload, InjectReport,
|
|
198
|
+
InjectStage, InjectVerification, Key, PaneField, PaneId, PaneInfo, SessionName,
|
|
199
|
+
SetEnvOutcome, SpawnResult, SubmitVerification, Target, Transport, TransportError,
|
|
200
|
+
TurnVerification, WindowName,
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
#[derive(Default)]
|
|
204
|
+
pub struct RecordingTransport {
|
|
205
|
+
session_present: Mutex<bool>,
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
impl RecordingTransport {
|
|
209
|
+
pub fn new() -> Self {
|
|
210
|
+
Self::default()
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
impl Transport for RecordingTransport {
|
|
215
|
+
fn kind(&self) -> BackendKind {
|
|
216
|
+
BackendKind::Tmux
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
fn spawn_first(
|
|
220
|
+
&self,
|
|
221
|
+
session: &SessionName,
|
|
222
|
+
window: &WindowName,
|
|
223
|
+
_argv: &[String],
|
|
224
|
+
_cwd: &Path,
|
|
225
|
+
_env: &BTreeMap<String, String>,
|
|
226
|
+
) -> Result<SpawnResult, TransportError> {
|
|
227
|
+
*self.session_present.lock().unwrap() = true;
|
|
228
|
+
Ok(SpawnResult {
|
|
229
|
+
pane_id: PaneId::new("%1"),
|
|
230
|
+
session: session.clone(),
|
|
231
|
+
window: window.clone(),
|
|
232
|
+
child_pid: None,
|
|
233
|
+
})
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
fn spawn_into(
|
|
237
|
+
&self,
|
|
238
|
+
session: &SessionName,
|
|
239
|
+
window: &WindowName,
|
|
240
|
+
argv: &[String],
|
|
241
|
+
cwd: &Path,
|
|
242
|
+
env: &BTreeMap<String, String>,
|
|
243
|
+
) -> Result<SpawnResult, TransportError> {
|
|
244
|
+
self.spawn_first(session, window, argv, cwd, env)
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
fn inject(
|
|
248
|
+
&self,
|
|
249
|
+
_target: &Target,
|
|
250
|
+
_payload: &InjectPayload,
|
|
251
|
+
_submit: Key,
|
|
252
|
+
_bracketed: bool,
|
|
253
|
+
) -> Result<InjectReport, TransportError> {
|
|
254
|
+
Ok(InjectReport {
|
|
255
|
+
stage_reached: InjectStage::Submit,
|
|
256
|
+
inject_verification: InjectVerification::CaptureContainsToken,
|
|
257
|
+
submit_verification: SubmitVerification::EnterSentWithoutPlaceholderCheck,
|
|
258
|
+
turn_verification: TurnVerification::NotYetObserved,
|
|
259
|
+
attempts: 1,
|
|
260
|
+
submit_diagnostics: None,
|
|
261
|
+
})
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
fn send_keys(&self, _target: &Target, _keys: &[Key]) -> Result<(), TransportError> {
|
|
265
|
+
Ok(())
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
fn capture(
|
|
269
|
+
&self,
|
|
270
|
+
_target: &Target,
|
|
271
|
+
range: CaptureRange,
|
|
272
|
+
) -> Result<CapturedText, TransportError> {
|
|
273
|
+
Ok(CapturedText {
|
|
274
|
+
text: "Claude Code\n> ".to_string(),
|
|
275
|
+
range,
|
|
276
|
+
})
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
fn query(
|
|
280
|
+
&self,
|
|
281
|
+
_target: &Target,
|
|
282
|
+
field: PaneField,
|
|
283
|
+
) -> Result<Option<String>, TransportError> {
|
|
284
|
+
match field {
|
|
285
|
+
PaneField::PaneWidth => Ok(Some("120".to_string())),
|
|
286
|
+
_ => Ok(None),
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
fn liveness(
|
|
291
|
+
&self,
|
|
292
|
+
_pane: &PaneId,
|
|
293
|
+
) -> Result<team_agent::transport::PaneLiveness, TransportError> {
|
|
294
|
+
Ok(team_agent::transport::PaneLiveness::Live)
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
fn list_targets(&self) -> Result<Vec<PaneInfo>, TransportError> {
|
|
298
|
+
Ok(Vec::new())
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
fn has_session(&self, _session: &SessionName) -> Result<bool, TransportError> {
|
|
302
|
+
Ok(*self.session_present.lock().unwrap())
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
fn list_windows(&self, _session: &SessionName) -> Result<Vec<WindowName>, TransportError> {
|
|
306
|
+
Ok(Vec::new())
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
fn set_session_env(
|
|
310
|
+
&self,
|
|
311
|
+
_session: &SessionName,
|
|
312
|
+
_key: &str,
|
|
313
|
+
_value: &str,
|
|
314
|
+
) -> Result<SetEnvOutcome, TransportError> {
|
|
315
|
+
Ok(SetEnvOutcome::Applied)
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
fn kill_session(&self, _session: &SessionName) -> Result<(), TransportError> {
|
|
319
|
+
Ok(())
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
fn kill_window(&self, _target: &Target) -> Result<(), TransportError> {
|
|
323
|
+
Ok(())
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
fn attach_session(&self, _session: &SessionName) -> Result<AttachOutcome, TransportError> {
|
|
327
|
+
Ok(AttachOutcome::Attached)
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
fn tmp_ws(tag: &str) -> PathBuf {
|
|
333
|
+
static N: AtomicU64 = AtomicU64::new(0);
|
|
334
|
+
let dir = std::env::temp_dir().join(format!(
|
|
335
|
+
"ta-rs-swallow-{tag}-{}-{}",
|
|
336
|
+
std::process::id(),
|
|
337
|
+
N.fetch_add(1, Ordering::Relaxed)
|
|
338
|
+
));
|
|
339
|
+
let _ = std::fs::remove_dir_all(&dir);
|
|
340
|
+
std::fs::create_dir_all(&dir).unwrap();
|
|
341
|
+
std::fs::canonicalize(dir).unwrap()
|
|
342
|
+
}
|
|
@@ -276,7 +276,7 @@ fn restart_auto_fresh_never_captured_worker_without_allow_fresh() {
|
|
|
276
276
|
"agents": {
|
|
277
277
|
"never_captured": {
|
|
278
278
|
"status": "running",
|
|
279
|
-
"provider": "
|
|
279
|
+
"provider": "claude",
|
|
280
280
|
"session_id": null,
|
|
281
281
|
"first_send_at": null
|
|
282
282
|
}
|
|
@@ -302,15 +302,15 @@ fn restart_auto_fresh_never_captured_worker_without_allow_fresh() {
|
|
|
302
302
|
/// state — restart without --allow-fresh must STILL Refuse, never
|
|
303
303
|
/// silently fresh (architect rule: 绝不静默 fresh). This is what the
|
|
304
304
|
/// existing `upgrade_restart_refuses_interacted_worker_without_session_id`
|
|
305
|
-
/// test pins; this test pins the SAME guard for
|
|
305
|
+
/// test pins; this test pins the SAME guard for Claude (the partial-resume
|
|
306
306
|
/// change must not weaken it for any provider).
|
|
307
307
|
#[test]
|
|
308
|
-
fn
|
|
308
|
+
fn restart_refuses_interacted_claude_worker_without_session_id_partial_resume_preserves_guard() {
|
|
309
309
|
let state = json!({
|
|
310
310
|
"agents": {
|
|
311
311
|
"interacted_no_sid": {
|
|
312
312
|
"status": "running",
|
|
313
|
-
"provider": "
|
|
313
|
+
"provider": "claude",
|
|
314
314
|
"session_id": null,
|
|
315
315
|
"first_send_at": "2026-06-26T01:00:00+00:00"
|
|
316
316
|
}
|