@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
|
@@ -231,12 +231,11 @@ fn start_mode_serde_names_match_python_start_mode_strings() {
|
|
|
231
231
|
|
|
232
232
|
// ───────────────────────────────────────────────────────────────────────
|
|
233
233
|
// decide_start_mode — bug-085 四象限 + E20 #264 gap closure.
|
|
234
|
-
//
|
|
235
|
-
//
|
|
236
|
-
//
|
|
237
|
-
//
|
|
238
|
-
//
|
|
239
|
-
// copilot no-sess -> fresh
|
|
234
|
+
// claude/copilot sess backing-present any-fresh -> resumed
|
|
235
|
+
// claude/copilot sess backing-MISSING !allow_fresh -> noop/refuse (绝不静默 resume 死 session)
|
|
236
|
+
// claude/copilot sess backing-MISSING allow_fresh -> fresh_after_missing_rollout
|
|
237
|
+
// claude/copilot no-sess any -> fresh
|
|
238
|
+
// non-resumable (fake/gemini_cli/retired codex/grok rows) sess -> noop 或 fresh_after_missing_rollout
|
|
240
239
|
// 这是 bug-085 把 start_mode 分类从 start_agent 的 lock+spawn 全路径剥离出来的命门。
|
|
241
240
|
// ───────────────────────────────────────────────────────────────────────
|
|
242
241
|
|
|
@@ -248,16 +247,16 @@ fn rp(p: &str) -> RolloutPath {
|
|
|
248
247
|
}
|
|
249
248
|
|
|
250
249
|
#[test]
|
|
251
|
-
fn
|
|
252
|
-
// bug-085 唯一 FreshAfterMissingRollout 臂:
|
|
250
|
+
fn decide_start_mode_copilot_missing_rollout_with_allow_fresh_is_fresh_after_missing() {
|
|
251
|
+
// bug-085 唯一 FreshAfterMissingRollout 臂:copilot(唯一可 resume 的 legacy worker)+ 有 session_id + backing 缺 + allow_fresh。
|
|
253
252
|
assert_eq!(
|
|
254
|
-
decide_start_mode("
|
|
253
|
+
decide_start_mode("copilot", Some(&sid("s1")), None, false, true),
|
|
255
254
|
StartMode::FreshAfterMissingRollout
|
|
256
255
|
);
|
|
257
256
|
// rollout 路径存在但文件已不在,同样命中。
|
|
258
257
|
assert_eq!(
|
|
259
258
|
decide_start_mode(
|
|
260
|
-
"
|
|
259
|
+
"copilot",
|
|
261
260
|
Some(&sid("s1")),
|
|
262
261
|
Some(&rp("/gone.jsonl")),
|
|
263
262
|
false,
|
|
@@ -268,19 +267,19 @@ fn decide_start_mode_codex_missing_rollout_with_allow_fresh_is_fresh_after_missi
|
|
|
268
267
|
}
|
|
269
268
|
|
|
270
269
|
#[test]
|
|
271
|
-
fn
|
|
270
|
+
fn decide_start_mode_copilot_missing_rollout_without_allow_fresh_refuses() {
|
|
272
271
|
// E20 C①:backing 缺且 !allow_fresh → 诚实拒绝,绝不 resume 进死 session。
|
|
273
272
|
assert_eq!(
|
|
274
|
-
decide_start_mode("
|
|
273
|
+
decide_start_mode("copilot", Some(&sid("s1")), None, false, false),
|
|
275
274
|
StartMode::Noop
|
|
276
275
|
);
|
|
277
276
|
}
|
|
278
277
|
|
|
279
278
|
#[test]
|
|
280
|
-
fn
|
|
279
|
+
fn decide_start_mode_copilot_rollout_present_is_resumed_regardless_of_fresh() {
|
|
281
280
|
assert_eq!(
|
|
282
281
|
decide_start_mode(
|
|
283
|
-
"
|
|
282
|
+
"copilot",
|
|
284
283
|
Some(&sid("s1")),
|
|
285
284
|
Some(&rp("/r.jsonl")),
|
|
286
285
|
true,
|
|
@@ -289,7 +288,7 @@ fn decide_start_mode_codex_rollout_present_is_resumed_regardless_of_fresh() {
|
|
|
289
288
|
StartMode::Resumed
|
|
290
289
|
);
|
|
291
290
|
assert_eq!(
|
|
292
|
-
decide_start_mode("
|
|
291
|
+
decide_start_mode("copilot", Some(&sid("s1")), Some(&rp("/r.jsonl")), true, true),
|
|
293
292
|
StartMode::Resumed
|
|
294
293
|
);
|
|
295
294
|
}
|
|
@@ -297,18 +296,18 @@ fn decide_start_mode_codex_rollout_present_is_resumed_regardless_of_fresh() {
|
|
|
297
296
|
#[test]
|
|
298
297
|
fn decide_start_mode_no_session_is_fresh() {
|
|
299
298
|
assert_eq!(
|
|
300
|
-
decide_start_mode("
|
|
299
|
+
decide_start_mode("copilot", None, None, false, true),
|
|
301
300
|
StartMode::Fresh
|
|
302
301
|
);
|
|
303
302
|
assert_eq!(
|
|
304
|
-
decide_start_mode("
|
|
303
|
+
decide_start_mode("copilot", None, None, false, false),
|
|
305
304
|
StartMode::Fresh
|
|
306
305
|
);
|
|
307
306
|
}
|
|
308
307
|
|
|
309
308
|
#[test]
|
|
310
309
|
fn decide_start_mode_checks_backing_for_all_resumable_providers() {
|
|
311
|
-
for provider in ["
|
|
310
|
+
for provider in ["claude", "claude_code", "copilot"] {
|
|
312
311
|
assert_eq!(
|
|
313
312
|
decide_start_mode(provider, Some(&sid("s1")), None, false, true),
|
|
314
313
|
StartMode::FreshAfterMissingRollout,
|
|
@@ -326,15 +325,19 @@ fn decide_start_mode_checks_backing_for_all_resumable_providers() {
|
|
|
326
325
|
);
|
|
327
326
|
}
|
|
328
327
|
assert_eq!(
|
|
329
|
-
decide_start_mode("
|
|
328
|
+
decide_start_mode("claude", None, None, false, true),
|
|
329
|
+
StartMode::Fresh
|
|
330
|
+
);
|
|
331
|
+
assert_eq!(
|
|
332
|
+
decide_start_mode("copilot", None, None, false, false),
|
|
330
333
|
StartMode::Fresh
|
|
331
334
|
);
|
|
332
335
|
}
|
|
333
336
|
|
|
334
337
|
#[test]
|
|
335
338
|
fn decide_start_mode_refuses_session_id_for_nonresumable_providers() {
|
|
336
|
-
// A persisted legacy
|
|
337
|
-
for provider in ["fake", "gemini_cli", "
|
|
339
|
+
// A persisted legacy Codex / Grok worker row is no longer resumable.
|
|
340
|
+
for provider in ["fake", "gemini_cli", "codex", "grok"] {
|
|
338
341
|
assert_eq!(
|
|
339
342
|
decide_start_mode(provider, Some(&sid("s1")), None, true, false),
|
|
340
343
|
StartMode::Noop,
|
|
@@ -385,7 +388,7 @@ fn classify_restart_plan_interacted_unresumable_no_allow_fresh_yields_refuse() {
|
|
|
385
388
|
"session_name": "team-a",
|
|
386
389
|
"agents": {
|
|
387
390
|
"w1": {
|
|
388
|
-
"provider": "
|
|
391
|
+
"provider": "claude",
|
|
389
392
|
"first_send_at": "2026-05-27T10:00:00+00:00",
|
|
390
393
|
"session_id": null
|
|
391
394
|
}
|
|
@@ -438,7 +441,7 @@ fn classify_restart_plan_interacted_unresumable_with_allow_fresh_yields_fresh_st
|
|
|
438
441
|
let state = json!({
|
|
439
442
|
"agents": {
|
|
440
443
|
"w1": {
|
|
441
|
-
"provider": "
|
|
444
|
+
"provider": "claude",
|
|
442
445
|
"first_send_at": "2026-05-27T10:00:00+00:00",
|
|
443
446
|
"session_id": null
|
|
444
447
|
}
|
|
@@ -468,7 +471,7 @@ fn classify_restart_plan_never_captured_null_session_auto_fresh_partial_resume()
|
|
|
468
471
|
// not captured" bug state) — see the OTHER refuse-interacted test below
|
|
469
472
|
// and upgrade_restart_refuses_interacted_worker_without_session_id.
|
|
470
473
|
let state = json!({
|
|
471
|
-
"agents": { "w1": { "provider": "
|
|
474
|
+
"agents": { "w1": { "provider": "claude", "session_id": null } }
|
|
472
475
|
});
|
|
473
476
|
let plan = classify_restart_plan(&state, false).expect("纯验证不应 Err");
|
|
474
477
|
assert_eq!(plan.decisions.len(), 1);
|
|
@@ -494,7 +497,7 @@ fn restart_required_missing_skips_never_captured_workers() {
|
|
|
494
497
|
use crate::lifecycle::restart::restart_required_missing_session_agent_ids;
|
|
495
498
|
let state = json!({
|
|
496
499
|
"agents": {
|
|
497
|
-
"w1": { "provider": "
|
|
500
|
+
"w1": { "provider": "claude", "session_id": null, "status": "running" }
|
|
498
501
|
}
|
|
499
502
|
});
|
|
500
503
|
let missing = restart_required_missing_session_agent_ids(&state);
|
|
@@ -514,7 +517,7 @@ fn restart_required_missing_keeps_null_session_with_first_send_at() {
|
|
|
514
517
|
let state = json!({
|
|
515
518
|
"agents": {
|
|
516
519
|
"w1": {
|
|
517
|
-
"provider": "
|
|
520
|
+
"provider": "claude",
|
|
518
521
|
"session_id": null,
|
|
519
522
|
"status": "running",
|
|
520
523
|
"spawn_cwd": "/tmp/ws",
|
|
@@ -540,7 +543,7 @@ fn restart_required_missing_keeps_null_session_with_last_result_at() {
|
|
|
540
543
|
let state = json!({
|
|
541
544
|
"agents": {
|
|
542
545
|
"w1": {
|
|
543
|
-
"provider": "
|
|
546
|
+
"provider": "claude",
|
|
544
547
|
"session_id": null,
|
|
545
548
|
"status": "running",
|
|
546
549
|
"spawn_cwd": "/tmp/ws",
|
|
@@ -566,7 +569,7 @@ fn classify_restart_plan_null_session_with_last_result_at_refuses_without_allow_
|
|
|
566
569
|
let state = json!({
|
|
567
570
|
"agents": {
|
|
568
571
|
"w1": {
|
|
569
|
-
"provider": "
|
|
572
|
+
"provider": "claude",
|
|
570
573
|
"session_id": null,
|
|
571
574
|
"last_result_at": "2026-01-01T00:00:00+00:00",
|
|
572
575
|
}
|
|
@@ -587,7 +590,7 @@ fn classify_restart_plan_null_session_with_last_result_at_refuses_without_allow_
|
|
|
587
590
|
fn classify_restart_plan_never_interacted_null_session_with_allow_fresh_marks_forced_fresh() {
|
|
588
591
|
// E6 层2: 同上自启动 null-session worker,但显式 --allow-fresh → 用户主动认账丢上下文 → FreshStart。
|
|
589
592
|
let state = json!({
|
|
590
|
-
"agents": { "w1": { "provider": "
|
|
593
|
+
"agents": { "w1": { "provider": "claude", "session_id": null } }
|
|
591
594
|
});
|
|
592
595
|
let plan = classify_restart_plan(&state, true).expect("纯验证不应 Err");
|
|
593
596
|
assert_eq!(plan.decisions.len(), 1);
|
|
@@ -603,14 +606,14 @@ fn classify_restart_plan_never_interacted_null_session_with_allow_fresh_marks_fo
|
|
|
603
606
|
}
|
|
604
607
|
|
|
605
608
|
#[test]
|
|
606
|
-
fn
|
|
607
|
-
// E6 层2 回归锁(不误伤):
|
|
609
|
+
fn classify_restart_plan_copilot_with_session_still_resumes() {
|
|
610
|
+
// E6 层2 回归锁(不误伤): copilot worker first_send_at=null 但 session_id 已捕 →
|
|
608
611
|
// 仍走 Resume(分流轴是 session_id 有无,不是 interacted)。防层2 修法把 has_session 也误判。
|
|
609
612
|
let ws = temp_ws();
|
|
610
|
-
let rollout = ws.join("
|
|
613
|
+
let rollout = ws.join("copilot-rollout.jsonl");
|
|
611
614
|
std::fs::write(&rollout, "{}\n").unwrap();
|
|
612
615
|
let state = json!({
|
|
613
|
-
"agents": { "w1": { "provider": "
|
|
616
|
+
"agents": { "w1": { "provider": "copilot", "session_id": "sess-copilot-abc", "rollout_path": rollout.to_string_lossy() } }
|
|
614
617
|
});
|
|
615
618
|
let plan = classify_restart_plan(&state, false).expect("纯验证不应 Err");
|
|
616
619
|
assert_eq!(plan.decisions.len(), 1);
|
|
@@ -749,9 +752,9 @@ fn classify_restart_plan_produces_corrupt_entries_with_python_type_names() {
|
|
|
749
752
|
// ("str"/"int"/"list") —— 锁跨语言 type-name 映射,不是手设字段。
|
|
750
753
|
let state = json!({
|
|
751
754
|
"agents": {
|
|
752
|
-
"w_str": { "provider": "
|
|
753
|
-
"w_int": { "provider": "
|
|
754
|
-
"w_list": { "provider": "
|
|
755
|
+
"w_str": { "provider": "claude", "first_send_at": "" },
|
|
756
|
+
"w_int": { "provider": "claude", "first_send_at": 0 },
|
|
757
|
+
"w_list": { "provider": "claude", "first_send_at": [] }
|
|
755
758
|
}
|
|
756
759
|
});
|
|
757
760
|
// corrupt 非空 → restart 在 teardown 之前 hard refuse(决策前)。
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
//! Launch/restart may spawn a pane and then ask the provider adapter to handle startup prompts.
|
|
4
4
|
//! A provider-specific prompt handler panic must not unwind out of the user command and leave a
|
|
5
5
|
//! half-initialized runtime. The command should still complete once the pane has been spawned.
|
|
6
|
+
//! Copilot is the surviving legacy worker with a startup (folder-trust) prompt handler.
|
|
6
7
|
|
|
7
8
|
#[path = "../../../tests/support/hermetic.rs"]
|
|
8
9
|
mod hermetic_guard;
|
|
@@ -15,6 +16,7 @@ use std::sync::atomic::{AtomicU32, Ordering};
|
|
|
15
16
|
use std::sync::Mutex;
|
|
16
17
|
|
|
17
18
|
use serde_json::json;
|
|
19
|
+
use serial_test::serial;
|
|
18
20
|
use team_agent::lifecycle::{launch_with_transport, restart_with_transport, RestartReport};
|
|
19
21
|
use team_agent::transport::{
|
|
20
22
|
AttachOutcome, BackendKind, CaptureRange, CapturedText, InjectPayload, InjectReport,
|
|
@@ -27,10 +29,12 @@ static SEQ: AtomicU32 = AtomicU32::new(0);
|
|
|
27
29
|
|
|
28
30
|
const TEAM_MD: &str =
|
|
29
31
|
"---\nname: f032team\nobjective: F032 lifecycle prompt fault probe.\nprovider: codex\n---\n\nF032.\n";
|
|
30
|
-
const ROLE_MD: &str = "---\nname: implementer\nrole: Implementation Engineer\nprovider:
|
|
32
|
+
const ROLE_MD: &str = "---\nname: implementer\nrole: Implementation Engineer\nprovider: copilot\nmodel: gpt-5.5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nImplement.\n";
|
|
31
33
|
|
|
32
34
|
#[test]
|
|
35
|
+
#[serial(env)]
|
|
33
36
|
fn f032_launch_spawn_path_treats_startup_prompt_panic_as_best_effort() {
|
|
37
|
+
let _hermetic = hermetic_guard::HermeticTestEnv::enter("f032-launch");
|
|
34
38
|
let team = compiled_team_dir("launch");
|
|
35
39
|
let spec_path = team.join("team.spec.yaml");
|
|
36
40
|
let transport = PanicOnStartupPromptTransport::new();
|
|
@@ -52,8 +56,10 @@ fn f032_launch_spawn_path_treats_startup_prompt_panic_as_best_effort() {
|
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
#[test]
|
|
59
|
+
#[serial(env)]
|
|
55
60
|
fn f032_restart_spawn_path_treats_startup_prompt_panic_as_best_effort() {
|
|
56
|
-
let
|
|
61
|
+
let hermetic = hermetic_guard::HermeticTestEnv::enter("f032-restart");
|
|
62
|
+
let workspace = restart_workspace("restart", hermetic.home());
|
|
57
63
|
let transport = PanicOnStartupPromptTransport::new();
|
|
58
64
|
|
|
59
65
|
let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
|
|
@@ -101,10 +107,19 @@ fn compiled_team_dir(label: &str) -> PathBuf {
|
|
|
101
107
|
team
|
|
102
108
|
}
|
|
103
109
|
|
|
104
|
-
fn restart_workspace(label: &str) -> PathBuf {
|
|
110
|
+
fn restart_workspace(label: &str, home: &Path) -> PathBuf {
|
|
105
111
|
let ws = compiled_team_dir(label);
|
|
106
|
-
|
|
107
|
-
|
|
112
|
+
// Copilot resume backing is the session-store row under $HOME/.copilot.
|
|
113
|
+
let db = home.join(".copilot").join("session-store.db");
|
|
114
|
+
std::fs::create_dir_all(db.parent().expect("session store parent"))
|
|
115
|
+
.expect("create copilot home");
|
|
116
|
+
let conn = rusqlite::Connection::open(db).expect("open copilot session store");
|
|
117
|
+
conn.execute_batch(
|
|
118
|
+
"create table if not exists sessions (id text primary key, name text, created_at text);
|
|
119
|
+
insert or replace into sessions(id, name, created_at)
|
|
120
|
+
values ('f0320000-0000-4000-8000-000000000032', 'f032', '2026-05-27T10:00:00Z');",
|
|
121
|
+
)
|
|
122
|
+
.expect("seed copilot session store");
|
|
108
123
|
team_agent::state::persist::save_runtime_state(
|
|
109
124
|
&ws,
|
|
110
125
|
&json!({
|
|
@@ -112,9 +127,8 @@ fn restart_workspace(label: &str) -> PathBuf {
|
|
|
112
127
|
"agents": {
|
|
113
128
|
"implementer": {
|
|
114
129
|
"status": "running",
|
|
115
|
-
"provider": "
|
|
116
|
-
"session_id": "
|
|
117
|
-
"rollout_path": rollout.to_string_lossy(),
|
|
130
|
+
"provider": "copilot",
|
|
131
|
+
"session_id": "f0320000-0000-4000-8000-000000000032",
|
|
118
132
|
"first_send_at": "2026-05-27T10:00:00+00:00"
|
|
119
133
|
}
|
|
120
134
|
}
|
|
@@ -65,7 +65,8 @@ const beforeAgentStart = handlers.get("before_agent_start")?.[0];
|
|
|
65
65
|
if (typeof beforeAgentStart !== "function") throw new Error("generated wrapper omitted before_agent_start wire binding");
|
|
66
66
|
const binding = await beforeAgentStart({ systemPrompt: "N1 fixture" }, context);
|
|
67
67
|
const wirePrompt = binding?.systemPrompt;
|
|
68
|
-
|
|
68
|
+
const communicationTools = expectedTools.filter((name) => !name.endsWith("__report_result"));
|
|
69
|
+
if (typeof wirePrompt !== "string" || !communicationTools.every((name) => wirePrompt.includes(name)) || wirePrompt.includes("report_result")) {
|
|
69
70
|
throw new Error(`native Team tool wire binding is incomplete: ${wirePrompt}`);
|
|
70
71
|
}
|
|
71
72
|
await writeFile(receiptPath, `${JSON.stringify({ registrations, unregistrations, activeTools: pi.getActiveTools(), expectedTools, wirePrompt }, null, 2)}\n`, "utf8");
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
//! purpose:
|
|
2
|
-
//! contract: 缺 model 的
|
|
3
|
-
//!
|
|
4
|
-
//!
|
|
5
|
-
//!
|
|
6
|
-
//! 修之前判红(40e91fba):grok 角色缺 model 仍会成功启动(compiler 填
|
|
7
|
-
//! 内建默认 grok-4,argv 带 `--model grok-4`,看起来完全正常)。
|
|
1
|
+
//! purpose: claude 席位角色文件缺 model 时仍能正常启动
|
|
2
|
+
//! contract: 缺 model 的 claude 角色启动成功并真的 spawn worker
|
|
3
|
+
//! boundary: legacy Grok worker runtime 已移除(grok 角色现走 grok_build 合约叶),
|
|
4
|
+
//! 本文件只保留 claude 缺 model 的回归钉子
|
|
8
5
|
|
|
9
6
|
#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
|
|
10
7
|
|
|
@@ -24,93 +21,20 @@ use serial_test::serial;
|
|
|
24
21
|
use team_agent::lifecycle::quick_start_with_transport_in_workspace;
|
|
25
22
|
use team_agent::transport::test_support::OfflineTransport;
|
|
26
23
|
|
|
27
|
-
///
|
|
24
|
+
/// claude 角色缺 model ⇒ 行为不变(仍能启动)。
|
|
28
25
|
#[test]
|
|
29
26
|
#[serial(env)]
|
|
30
|
-
fn
|
|
31
|
-
let _hermetic = enter_hermetic("grok-
|
|
32
|
-
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");
|
|
33
30
|
super::launch_spawn::seed_healthy_coordinator(&ws);
|
|
34
|
-
let home = tmp_dir("grok-no-model-home");
|
|
35
|
-
seed_grok_home(&home, Some(&ws));
|
|
36
|
-
let _guard = HomeGuard::set(&home);
|
|
37
31
|
let team = write_role_team(
|
|
38
32
|
&ws,
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
33
|
+
"claudeteam",
|
|
34
|
+
"clauder",
|
|
35
|
+
"claude",
|
|
42
36
|
None,
|
|
43
|
-
"
|
|
44
|
-
);
|
|
45
|
-
let transport = OfflineTransport::new();
|
|
46
|
-
|
|
47
|
-
quick_start_with_transport_in_workspace(
|
|
48
|
-
&ws,
|
|
49
|
-
&team,
|
|
50
|
-
None,
|
|
51
|
-
true,
|
|
52
|
-
Some("grokteam"),
|
|
53
|
-
&transport,
|
|
54
|
-
)
|
|
55
|
-
.expect("Grok may use its provider-native model default");
|
|
56
|
-
let argv = first_spawn_argv(&transport);
|
|
57
|
-
assert!(
|
|
58
|
-
!argv.iter().any(|arg| arg == "--model"),
|
|
59
|
-
"an omitted model must not fabricate a --model argument: {argv:?}"
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/// 2. grok 角色写了 model ⇒ 正常启动,且该值真的进 argv(`--model <值>` 相邻)。
|
|
64
|
-
#[test]
|
|
65
|
-
#[serial(env)]
|
|
66
|
-
fn grok_role_explicit_model_reaches_argv() {
|
|
67
|
-
let _hermetic = enter_hermetic("grok-explicit-model");
|
|
68
|
-
let ws = tmp_dir("grok-with-model");
|
|
69
|
-
super::launch_spawn::seed_healthy_coordinator(&ws);
|
|
70
|
-
let home = tmp_dir("grok-with-model-home");
|
|
71
|
-
seed_grok_home(&home, Some(&ws));
|
|
72
|
-
let _guard = HomeGuard::set(&home);
|
|
73
|
-
let team = write_role_team(
|
|
74
|
-
&ws,
|
|
75
|
-
"grokteam",
|
|
76
|
-
"grok_writer",
|
|
77
|
-
"grok",
|
|
78
|
-
Some("grok-4.6"),
|
|
79
|
-
"Grok Writer",
|
|
80
|
-
);
|
|
81
|
-
let transport = OfflineTransport::new();
|
|
82
|
-
|
|
83
|
-
quick_start_with_transport_in_workspace(
|
|
84
|
-
&ws,
|
|
85
|
-
&team,
|
|
86
|
-
None,
|
|
87
|
-
true,
|
|
88
|
-
Some("grokteam"),
|
|
89
|
-
&transport,
|
|
90
|
-
)
|
|
91
|
-
.expect("grok role with explicit model must start");
|
|
92
|
-
|
|
93
|
-
let argv = first_spawn_argv(&transport);
|
|
94
|
-
assert!(
|
|
95
|
-
argv_contains_adjacent(&argv, &["--model", "grok-4.6"]),
|
|
96
|
-
"declared model must appear as adjacent `--model grok-4.6` in worker argv; argv={argv:?}"
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/// 3. copilot 角色缺 model ⇒ 行为不变(仍能启动,不被 grok 的硬性 model 要求误伤)。
|
|
101
|
-
#[test]
|
|
102
|
-
#[serial(env)]
|
|
103
|
-
fn copilot_role_missing_model_still_starts() {
|
|
104
|
-
let _hermetic = enter_hermetic("grok-copilot-missing-model");
|
|
105
|
-
let ws = tmp_dir("copilot-no-model");
|
|
106
|
-
super::launch_spawn::seed_healthy_coordinator(&ws);
|
|
107
|
-
let team = write_role_team(
|
|
108
|
-
&ws,
|
|
109
|
-
"copilotteam",
|
|
110
|
-
"copiloter",
|
|
111
|
-
"copilot",
|
|
112
|
-
None,
|
|
113
|
-
"Copilot Worker",
|
|
37
|
+
"Claude Worker",
|
|
114
38
|
);
|
|
115
39
|
let transport = OfflineTransport::new();
|
|
116
40
|
|
|
@@ -119,17 +43,17 @@ fn copilot_role_missing_model_still_starts() {
|
|
|
119
43
|
&team,
|
|
120
44
|
None,
|
|
121
45
|
true,
|
|
122
|
-
Some("
|
|
46
|
+
Some("claudeteam"),
|
|
123
47
|
&transport,
|
|
124
48
|
);
|
|
125
49
|
assert!(
|
|
126
50
|
result.is_ok(),
|
|
127
|
-
"
|
|
51
|
+
"claude role without model must keep starting; err={result:?}"
|
|
128
52
|
);
|
|
129
53
|
let argv = first_spawn_argv(&transport);
|
|
130
54
|
assert!(
|
|
131
55
|
!argv.is_empty(),
|
|
132
|
-
"
|
|
56
|
+
"claude seat must still spawn; argv={argv:?}"
|
|
133
57
|
);
|
|
134
58
|
}
|
|
135
59
|
|
|
@@ -142,14 +66,6 @@ fn first_spawn_argv(transport: &OfflineTransport) -> Vec<String> {
|
|
|
142
66
|
records[0].1.clone()
|
|
143
67
|
}
|
|
144
68
|
|
|
145
|
-
fn argv_contains_adjacent(hay: &[String], needle: &[&str]) -> bool {
|
|
146
|
-
if needle.is_empty() {
|
|
147
|
-
return true;
|
|
148
|
-
}
|
|
149
|
-
hay.windows(needle.len())
|
|
150
|
-
.any(|window| window.iter().map(String::as_str).eq(needle.iter().copied()))
|
|
151
|
-
}
|
|
152
|
-
|
|
153
69
|
fn write_role_team(
|
|
154
70
|
ws: &Path,
|
|
155
71
|
team_key: &str,
|
|
@@ -181,40 +97,6 @@ fn write_role_team(
|
|
|
181
97
|
team
|
|
182
98
|
}
|
|
183
99
|
|
|
184
|
-
fn seed_grok_home(home: &Path, trusted_cwd: Option<&Path>) {
|
|
185
|
-
let grok = home.join(".grok");
|
|
186
|
-
std::fs::create_dir_all(&grok).unwrap();
|
|
187
|
-
std::fs::write(grok.join("auth.json"), r#"{"test":"ok"}"#).unwrap();
|
|
188
|
-
if let Some(cwd) = trusted_cwd {
|
|
189
|
-
std::fs::write(
|
|
190
|
-
grok.join("trusted_folders.toml"),
|
|
191
|
-
format!("[folders.\"{}\"]\ntrusted = true\n", cwd.display()),
|
|
192
|
-
)
|
|
193
|
-
.unwrap();
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
struct HomeGuard {
|
|
198
|
-
prev: Option<String>,
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
impl HomeGuard {
|
|
202
|
-
fn set(home: &Path) -> Self {
|
|
203
|
-
let prev = std::env::var("HOME").ok();
|
|
204
|
-
std::env::set_var("HOME", home);
|
|
205
|
-
Self { prev }
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
impl Drop for HomeGuard {
|
|
210
|
-
fn drop(&mut self) {
|
|
211
|
-
match &self.prev {
|
|
212
|
-
Some(value) => std::env::set_var("HOME", value),
|
|
213
|
-
None => std::env::remove_var("HOME"),
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
100
|
fn tmp_dir(tag: &str) -> PathBuf {
|
|
219
101
|
static N: AtomicU64 = AtomicU64::new(0);
|
|
220
102
|
let dir = std::env::temp_dir().join(format!(
|
|
@@ -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 {
|