@team-agent/installer 0.5.60 → 0.5.62
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/crates/team-agent/src/cli/adapters.rs +49 -3
- package/crates/team-agent/src/cli/attach_app_server_leader.rs +1 -0
- package/crates/team-agent/src/cli/diagnose.rs +184 -0
- package/crates/team-agent/src/cli/emit.rs +104 -21
- package/crates/team-agent/src/cli/helpers.rs +1 -0
- package/crates/team-agent/src/cli/leader.rs +14 -2
- package/crates/team-agent/src/cli/leaders.rs +2 -0
- package/crates/team-agent/src/cli/mod.rs +296 -8
- package/crates/team-agent/src/cli/named_address.rs +26 -2
- package/crates/team-agent/src/cli/profile.rs +2 -1
- package/crates/team-agent/src/cli/send/coordinator.rs +1 -0
- package/crates/team-agent/src/cli/send/mailbox.rs +3 -0
- package/crates/team-agent/src/cli/send/persist.rs +1 -0
- package/crates/team-agent/src/cli/send/presentation.rs +3 -0
- package/crates/team-agent/src/cli/send/resolve.rs +206 -1
- package/crates/team-agent/src/cli/send.rs +2 -1
- package/crates/team-agent/src/cli/spec.rs +5 -1
- package/crates/team-agent/src/cli/status.rs +2 -1
- package/crates/team-agent/src/cli/status_port/compact.rs +1 -0
- package/crates/team-agent/src/cli/status_port/format.rs +1 -0
- package/crates/team-agent/src/cli/status_port/inbox.rs +1 -0
- package/crates/team-agent/src/cli/status_port/store.rs +7 -3
- package/crates/team-agent/src/cli/tests/named_address.rs +65 -0
- package/crates/team-agent/src/cli/tests/verb_profile.rs +38 -0
- package/crates/team-agent/src/cli/types.rs +36 -2
- package/crates/team-agent/src/communication_mode/mod.rs +54 -0
- package/crates/team-agent/src/compiler/tests.rs +5 -5
- package/crates/team-agent/src/compiler.rs +54 -1
- package/crates/team-agent/src/conpty/backend.rs +1 -0
- package/crates/team-agent/src/conpty/mod.rs +1 -0
- package/crates/team-agent/src/coordinator/backoff.rs +5 -8
- package/crates/team-agent/src/coordinator/conpty_shim.rs +3 -2
- package/crates/team-agent/src/coordinator/health.rs +1 -0
- package/crates/team-agent/src/coordinator/mod.rs +2 -2
- package/crates/team-agent/src/coordinator/orphan.rs +4 -116
- package/crates/team-agent/src/coordinator/runtime_detectors.rs +1 -0
- package/crates/team-agent/src/coordinator/runtime_observation.rs +1 -0
- package/crates/team-agent/src/coordinator/steps/abnormal.rs +6 -5
- package/crates/team-agent/src/coordinator/steps/delivery.rs +1 -0
- package/crates/team-agent/src/coordinator/steps/health_sync.rs +1 -0
- package/crates/team-agent/src/coordinator/steps/mod.rs +2 -0
- package/crates/team-agent/src/coordinator/steps/persist.rs +1 -0
- package/crates/team-agent/src/coordinator/steps/runtime_prompts.rs +1 -0
- package/crates/team-agent/src/coordinator/steps/session_gate.rs +1 -0
- package/crates/team-agent/src/coordinator/tests/abnormal.rs +0 -174
- package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +0 -9
- package/crates/team-agent/src/coordinator/tests/basics.rs +0 -184
- package/crates/team-agent/src/coordinator/tests/mod.rs +2 -17
- package/crates/team-agent/src/coordinator/tests/tick_core.rs +0 -42
- package/crates/team-agent/src/coordinator/tick.rs +24 -28
- package/crates/team-agent/src/coordinator/types.rs +3 -176
- package/crates/team-agent/src/db/agent_health_capture.rs +1 -0
- package/crates/team-agent/src/db/message_store.rs +47 -2
- package/crates/team-agent/src/db/migration.rs +5 -4
- package/crates/team-agent/src/db/mod.rs +1 -0
- package/crates/team-agent/src/db/schema.rs +1 -0
- package/crates/team-agent/src/diagnose/comms.rs +2 -1
- package/crates/team-agent/src/diagnose/mod.rs +1 -0
- package/crates/team-agent/src/diagnose/orphans.rs +1 -0
- package/crates/team-agent/src/fake_worker.rs +21 -1
- package/crates/team-agent/src/layout/manager.rs +3 -7
- package/crates/team-agent/src/layout/mod.rs +2 -2
- package/crates/team-agent/src/layout/overlay.rs +6 -1
- package/crates/team-agent/src/layout/placement.rs +1 -0
- package/crates/team-agent/src/layout/recovery.rs +3 -0
- package/crates/team-agent/src/layout/runtime_sessions.rs +8 -3
- package/crates/team-agent/src/layout/sessions.rs +8 -1
- package/crates/team-agent/src/layout/tmux_endpoint.rs +3 -0
- package/crates/team-agent/src/layout/worker_env.rs +3 -0
- package/crates/team-agent/src/layout/worker_window_helpers.rs +2 -0
- package/crates/team-agent/src/leader/helpers.rs +1 -0
- package/crates/team-agent/src/leader/incident.rs +1 -0
- package/crates/team-agent/src/leader/lease.rs +27 -22
- package/crates/team-agent/src/leader/mod.rs +2 -3
- package/crates/team-agent/src/leader/owner_bind.rs +13 -3
- package/crates/team-agent/src/leader/provider_attribution.rs +1 -0
- package/crates/team-agent/src/leader/rediscover.rs +4 -17
- package/crates/team-agent/src/leader/registry.rs +3 -15
- package/crates/team-agent/src/leader/start.rs +1072 -186
- package/crates/team-agent/src/leader/takeover.rs +10 -232
- package/crates/team-agent/src/leader/tests/claim_leader_mailbox_flush_contract.rs +544 -0
- package/crates/team-agent/src/leader/tests/historical_inventory_upgrade_gate_red.rs +624 -0
- package/crates/team-agent/src/leader/tests/identity.rs +71 -59
- package/crates/team-agent/src/leader/tests/identity_session_names.rs +42 -0
- package/crates/team-agent/src/leader/tests/idle.rs +0 -193
- package/crates/team-agent/src/leader/tests/lease_api.rs +0 -45
- package/crates/team-agent/src/leader/tests/mod.rs +4 -41
- package/crates/team-agent/src/leader/tests/rehomed_env.rs +83 -0
- package/crates/team-agent/src/leader/tests/team_in_team_state_scope_red.rs +1273 -0
- package/crates/team-agent/src/leader/tests/terminal_and_replay_vs_rerender_invariants_red.rs +417 -0
- package/crates/team-agent/src/leader/tests/wake_start_owner.rs +22 -103
- package/crates/team-agent/src/leader/types.rs +1 -28
- package/crates/team-agent/src/lib.rs +7 -0
- package/crates/team-agent/src/lifecycle/display.rs +7 -1
- package/crates/team-agent/src/lifecycle/helpers.rs +3 -1
- package/crates/team-agent/src/lifecycle/launch/add_agent.rs +2 -2
- package/crates/team-agent/src/lifecycle/launch/fork_agent/completion.rs +1 -0
- package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +1 -1
- package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +1 -0
- package/crates/team-agent/src/lifecycle/launch/fork_finalize.rs +1 -0
- package/crates/team-agent/src/lifecycle/launch/plan.rs +2 -2
- package/crates/team-agent/src/lifecycle/launch/quick_start.rs +4 -26
- package/crates/team-agent/src/lifecycle/launch/readiness.rs +0 -27
- package/crates/team-agent/src/lifecycle/launch/spawn.rs +2 -28
- package/crates/team-agent/src/lifecycle/launch/spec_state.rs +4 -32
- package/crates/team-agent/src/lifecycle/launch/state_projection.rs +1 -0
- package/crates/team-agent/src/lifecycle/launch.rs +11 -12
- package/crates/team-agent/src/lifecycle/mod.rs +2 -1
- package/crates/team-agent/src/lifecycle/restart/agent.rs +4 -4
- package/crates/team-agent/src/lifecycle/restart/common.rs +1 -1
- package/crates/team-agent/src/lifecycle/restart/orchestrator.rs +2 -2
- package/crates/team-agent/src/lifecycle/restart/rebuild.rs +13 -5
- package/crates/team-agent/src/lifecycle/restart/remove.rs +1 -1
- package/crates/team-agent/src/lifecycle/restart/selection.rs +3 -3
- package/crates/team-agent/src/lifecycle/restart.rs +13 -11
- package/crates/team-agent/src/lifecycle/tests/acceptance_b_batch_red.rs +1007 -0
- package/crates/team-agent/src/lifecycle/tests/b0_legacy_snapshot_nonauthority_contract.rs +265 -0
- package/crates/team-agent/src/lifecycle/tests/b0_reader_hideone_audit_contract.rs +459 -0
- package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +849 -0
- package/crates/team-agent/src/lifecycle/tests/claude_compatible_config_red.rs +323 -0
- package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +423 -0
- package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +737 -0
- package/crates/team-agent/src/lifecycle/tests/codex_mcp_approval_inheritance_red.rs +1187 -0
- package/crates/team-agent/src/lifecycle/tests/codex_weak_window_attribution_red.rs +683 -0
- package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +394 -0
- package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +1856 -0
- package/crates/team-agent/src/lifecycle/tests/core_034_real_red.rs +917 -0
- package/crates/team-agent/src/lifecycle/tests/display_adaptive_red.rs +481 -0
- package/crates/team-agent/src/lifecycle/tests/f032_startup_prompt_best_effort_red.rs +301 -0
- package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +516 -0
- package/crates/team-agent/src/lifecycle/tests/host_cotenant_death_p0_contract.rs +986 -0
- package/crates/team-agent/src/lifecycle/tests/lifecycle_rollback_red.rs +651 -0
- package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +2 -0
- package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +332 -0
- package/crates/team-agent/src/lifecycle/tests/realmachine_clusters_1_6_red.rs +846 -0
- package/crates/team-agent/src/lifecycle/tests/realmachine_residual_g1_g4_red.rs +648 -0
- package/crates/team-agent/src/lifecycle/tests/restart_build_before_destroy_0540_contract.rs +910 -0
- package/crates/team-agent/src/lifecycle/tests/restart_liveness_red.rs +630 -0
- package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +1083 -0
- package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +1677 -0
- package/crates/team-agent/src/lifecycle/tests/resume_recover_red.rs +410 -0
- package/crates/team-agent/src/lifecycle/tests/stale_team_saveconflict_contract.rs +428 -0
- package/crates/team-agent/src/lifecycle/tests/startup_latency_contract.rs +1032 -0
- package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +869 -0
- package/crates/team-agent/src/lifecycle/tests/subprep_codex_trust_roundtrip_red.rs +1249 -0
- package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +342 -0
- package/crates/team-agent/src/lifecycle/tests/team_in_team_identity_scope_red.rs +542 -0
- package/crates/team-agent/src/lifecycle/tests/team_in_team_sibling_quick_start_red.rs +1103 -0
- package/crates/team-agent/src/lifecycle/tests/team_in_team_state_scope_red.rs +1276 -0
- package/crates/team-agent/src/lifecycle/tests/team_key_retirement_roster_red.rs +145 -0
- package/crates/team-agent/src/lifecycle/tests/team_key_retirement_txn_red.rs +603 -0
- package/crates/team-agent/src/lifecycle/tests/test_isolation_escape_contract.rs +837 -0
- package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +928 -0
- package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +951 -0
- package/crates/team-agent/src/lifecycle/tests/worker_dangerous_bypass_argv_red.rs +327 -0
- package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +760 -0
- package/crates/team-agent/src/lifecycle/tests.rs +59 -0
- package/crates/team-agent/src/lifecycle/types.rs +0 -9
- package/crates/team-agent/src/lifecycle/worker_command_context.rs +29 -11
- package/crates/team-agent/src/mcp_server/helpers.rs +1 -0
- package/crates/team-agent/src/mcp_server/lifecycle_tools/mod.rs +1 -0
- package/crates/team-agent/src/mcp_server/lifecycle_tools/state_status.rs +1 -0
- package/crates/team-agent/src/mcp_server/mod.rs +1 -0
- package/crates/team-agent/src/mcp_server/normalize.rs +5 -3
- package/crates/team-agent/src/mcp_server/tests/send.rs +26 -0
- package/crates/team-agent/src/mcp_server/tests/wire.rs +1 -1
- package/crates/team-agent/src/mcp_server/tools.rs +101 -66
- package/crates/team-agent/src/mcp_server/types.rs +6 -18
- package/crates/team-agent/src/mcp_server/wire.rs +32 -26
- package/crates/team-agent/src/messaging/activity.rs +1 -0
- package/crates/team-agent/src/messaging/address.rs +1 -0
- package/crates/team-agent/src/messaging/delivery.rs +109 -41
- package/crates/team-agent/src/messaging/helpers.rs +2 -1
- package/crates/team-agent/src/messaging/leader_channel.rs +34 -10
- package/crates/team-agent/src/messaging/leader_receiver.rs +42 -24
- package/crates/team-agent/src/messaging/mod.rs +10 -14
- package/crates/team-agent/src/messaging/peers.rs +2 -0
- package/crates/team-agent/src/messaging/persist.rs +3 -1
- package/crates/team-agent/src/messaging/presentation.rs +111 -1
- package/crates/team-agent/src/messaging/results.rs +166 -17
- package/crates/team-agent/src/messaging/scheduler.rs +1 -0
- package/crates/team-agent/src/messaging/selftest.rs +1 -1
- package/crates/team-agent/src/messaging/send.rs +135 -89
- package/crates/team-agent/src/messaging/tests/leader_channel.rs +6 -6
- package/crates/team-agent/src/messaging/tests/leader_inject_acceptance.rs +187 -0
- package/crates/team-agent/src/messaging/tests/mod.rs +5 -0
- package/crates/team-agent/src/messaging/tests/runtime.rs +13 -6
- package/crates/team-agent/src/messaging/types.rs +7 -2
- package/crates/team-agent/src/messaging/watchers.rs +24 -13
- package/crates/team-agent/src/model/enums.rs +1 -0
- package/crates/team-agent/src/model/errors.rs +1 -0
- package/crates/team-agent/src/model/ids.rs +1 -0
- package/crates/team-agent/src/model/mod.rs +2 -0
- package/crates/team-agent/src/model/name_similarity.rs +1 -0
- package/crates/team-agent/src/model/pane_authority_refusal.rs +359 -0
- package/crates/team-agent/src/model/paths.rs +1 -0
- package/crates/team-agent/src/model/permissions.rs +3 -2
- package/crates/team-agent/src/model/routing.rs +1 -0
- package/crates/team-agent/src/model/spec.rs +17 -0
- package/crates/team-agent/src/model/task_graph.rs +1 -0
- package/crates/team-agent/src/model/yaml/tests.rs +1 -0
- package/crates/team-agent/src/model/yaml.rs +1 -0
- package/crates/team-agent/src/packaging/install.rs +9 -147
- package/crates/team-agent/src/packaging/migrate.rs +2 -0
- package/crates/team-agent/src/packaging/mod.rs +1 -0
- package/crates/team-agent/src/packaging/repair.rs +2 -0
- package/crates/team-agent/src/packaging/tests.rs +29 -218
- package/crates/team-agent/src/packaging/types.rs +8 -15
- package/crates/team-agent/src/platform/argv.rs +4 -0
- package/crates/team-agent/src/platform/errors.rs +10 -1
- package/crates/team-agent/src/platform/file_lock.rs +4 -157
- package/crates/team-agent/src/platform/mod.rs +0 -61
- package/crates/team-agent/src/platform/process.rs +1 -0
- package/crates/team-agent/src/provider/adapter.rs +1 -0
- package/crates/team-agent/src/provider/adapters/claude.rs +1 -0
- package/crates/team-agent/src/provider/adapters/claude_fork.rs +1 -0
- package/crates/team-agent/src/provider/adapters/codex.rs +1 -0
- package/crates/team-agent/src/provider/adapters/copilot.rs +1 -0
- package/crates/team-agent/src/provider/adapters/copilot_fork.rs +1 -0
- package/crates/team-agent/src/provider/adapters/fake.rs +1 -0
- package/crates/team-agent/src/provider/adapters/mod.rs +1 -0
- package/crates/team-agent/src/provider/approvals/mod.rs +1 -0
- package/crates/team-agent/src/provider/approvals/parsing.rs +2 -5
- package/crates/team-agent/src/provider/approvals/runtime_prompts.rs +6 -5
- package/crates/team-agent/src/provider/classify.rs +1 -0
- package/crates/team-agent/src/provider/faults.rs +1 -26
- package/crates/team-agent/src/provider/helpers.rs +1 -0
- package/crates/team-agent/src/provider/mod.rs +1 -1
- package/crates/team-agent/src/provider/session/capture.rs +41 -22
- package/crates/team-agent/src/provider/session/context_fork/claude.rs +1 -0
- package/crates/team-agent/src/provider/session/context_fork/codex.rs +1 -0
- package/crates/team-agent/src/provider/session/context_fork/outcome.rs +1 -0
- package/crates/team-agent/src/provider/session/context_fork.rs +1 -0
- package/crates/team-agent/src/provider/session/mod.rs +2 -4
- package/crates/team-agent/src/provider/session/resume.rs +2 -209
- package/crates/team-agent/src/provider/session_scan/claude.rs +93 -3
- package/crates/team-agent/src/provider/session_scan/codex.rs +1 -0
- package/crates/team-agent/src/provider/session_scan/common.rs +24 -7
- package/crates/team-agent/src/provider/session_scan/copilot.rs +1 -0
- package/crates/team-agent/src/provider/session_scan.rs +6 -42
- package/crates/team-agent/src/provider/startup_prompt.rs +1 -0
- package/crates/team-agent/src/provider/types.rs +1 -0
- package/crates/team-agent/src/provider/wire.rs +1 -0
- package/crates/team-agent/src/state/identity.rs +16 -5
- package/crates/team-agent/src/state/identity_keys.rs +1 -0
- package/crates/team-agent/src/state/mod.rs +2 -0
- package/crates/team-agent/src/state/owner_gate.rs +5 -0
- package/crates/team-agent/src/state/ownership.rs +10 -4
- package/crates/team-agent/src/state/paths.rs +12 -0
- package/crates/team-agent/src/state/persist.rs +9 -3
- package/crates/team-agent/src/state/projection.rs +15 -2
- package/crates/team-agent/src/state/repository/intent.rs +1 -0
- package/crates/team-agent/src/state/repository/tests.rs +1 -0
- package/crates/team-agent/src/state/repository.rs +7 -0
- package/crates/team-agent/src/state/selector.rs +1 -0
- package/crates/team-agent/src/tmux_backend/tests.rs +39 -0
- package/crates/team-agent/src/tmux_backend.rs +63 -0
- package/crates/team-agent/src/topology.rs +3 -0
- package/crates/team-agent/src/transport.rs +15 -0
- package/package.json +4 -4
- package/skills/team-agent/command-coverage.json +379 -0
- package/crates/team-agent/src/leader/inject.rs +0 -33
- package/crates/team-agent/src/provider/command.rs +0 -80
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
//! F032 regression contract: startup prompt handling is best-effort at lifecycle boundaries.
|
|
2
|
+
//!
|
|
3
|
+
//! Launch/restart may spawn a pane and then ask the provider adapter to handle startup prompts.
|
|
4
|
+
//! A provider-specific prompt handler panic must not unwind out of the user command and leave a
|
|
5
|
+
//! half-initialized runtime. The command should still complete once the pane has been spawned.
|
|
6
|
+
|
|
7
|
+
#[path = "../../../tests/support/hermetic.rs"]
|
|
8
|
+
mod hermetic_guard;
|
|
9
|
+
#[allow(dead_code)]
|
|
10
|
+
fn _hermetic_boundary_marker(_: &hermetic_guard::HermeticTestEnv) {}
|
|
11
|
+
|
|
12
|
+
use std::collections::BTreeMap;
|
|
13
|
+
use std::path::{Path, PathBuf};
|
|
14
|
+
use std::sync::atomic::{AtomicU32, Ordering};
|
|
15
|
+
use std::sync::Mutex;
|
|
16
|
+
|
|
17
|
+
use serde_json::json;
|
|
18
|
+
use team_agent::lifecycle::{launch_with_transport, restart_with_transport, RestartReport};
|
|
19
|
+
use team_agent::transport::{
|
|
20
|
+
AttachOutcome, BackendKind, CaptureRange, CapturedText, InjectPayload, InjectReport,
|
|
21
|
+
InjectStage, InjectVerification, Key, PaneField, PaneId, PaneInfo, SessionName, SetEnvOutcome,
|
|
22
|
+
SpawnResult, SubmitVerification, Target, Transport, TransportError, TurnVerification,
|
|
23
|
+
WindowName,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
static SEQ: AtomicU32 = AtomicU32::new(0);
|
|
27
|
+
|
|
28
|
+
const TEAM_MD: &str =
|
|
29
|
+
"---\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: codex\nmodel: gpt-5.5\nauth_mode: subscription\ntools:\n - mcp_team\n---\n\nImplement.\n";
|
|
31
|
+
|
|
32
|
+
#[test]
|
|
33
|
+
fn f032_launch_spawn_path_treats_startup_prompt_panic_as_best_effort() {
|
|
34
|
+
let team = compiled_team_dir("launch");
|
|
35
|
+
let spec_path = team.join("team.spec.yaml");
|
|
36
|
+
let transport = PanicOnStartupPromptTransport::new();
|
|
37
|
+
|
|
38
|
+
let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
|
|
39
|
+
launch_with_transport(&spec_path, false, true, true, &transport)
|
|
40
|
+
}));
|
|
41
|
+
|
|
42
|
+
assert_eq!(
|
|
43
|
+
transport.spawn_count(),
|
|
44
|
+
1,
|
|
45
|
+
"test fixture must prove the pane was spawned before the startup prompt handler faulted"
|
|
46
|
+
);
|
|
47
|
+
let report = assert_lifecycle_result_ok(result, "launch");
|
|
48
|
+
assert!(
|
|
49
|
+
!report.started.is_empty(),
|
|
50
|
+
"launch must keep the spawned pane in LaunchReport.started even if startup prompt handling panics"
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
#[test]
|
|
55
|
+
fn f032_restart_spawn_path_treats_startup_prompt_panic_as_best_effort() {
|
|
56
|
+
let workspace = restart_workspace("restart");
|
|
57
|
+
let transport = PanicOnStartupPromptTransport::new();
|
|
58
|
+
|
|
59
|
+
let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
|
|
60
|
+
restart_with_transport(&workspace, false, None, &transport)
|
|
61
|
+
}));
|
|
62
|
+
|
|
63
|
+
assert_eq!(
|
|
64
|
+
transport.spawn_count(),
|
|
65
|
+
1,
|
|
66
|
+
"test fixture must prove restart spawned a pane before the startup prompt handler faulted"
|
|
67
|
+
);
|
|
68
|
+
let report = assert_lifecycle_result_ok(result, "restart");
|
|
69
|
+
assert!(
|
|
70
|
+
matches!(report, RestartReport::Restarted { .. }),
|
|
71
|
+
"restart must complete after degrading startup prompt handling best-effort; got {report:?}"
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
fn assert_lifecycle_result_ok<T>(
|
|
76
|
+
result: std::thread::Result<Result<T, team_agent::lifecycle::LifecycleError>>,
|
|
77
|
+
command: &str,
|
|
78
|
+
) -> T {
|
|
79
|
+
match result {
|
|
80
|
+
Ok(Ok(report)) => report,
|
|
81
|
+
Ok(Err(err)) => panic!(
|
|
82
|
+
"{command} must not fail because startup prompt handling is best-effort; got error {err:?}"
|
|
83
|
+
),
|
|
84
|
+
Err(_) => panic!(
|
|
85
|
+
"{command} must catch provider startup prompt panics at or below the lifecycle boundary"
|
|
86
|
+
),
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
fn compiled_team_dir(label: &str) -> PathBuf {
|
|
91
|
+
let team = temp_ws(label).join("teamdir");
|
|
92
|
+
std::fs::create_dir_all(team.join("agents")).expect("create agents dir");
|
|
93
|
+
std::fs::write(team.join("TEAM.md"), TEAM_MD).expect("write TEAM.md");
|
|
94
|
+
std::fs::write(team.join("agents").join("implementer.md"), ROLE_MD).expect("write role");
|
|
95
|
+
let spec = team_agent::compiler::compile_team(&team).expect("compile team");
|
|
96
|
+
std::fs::write(
|
|
97
|
+
team.join("team.spec.yaml"),
|
|
98
|
+
team_agent::model::yaml::dumps(&spec),
|
|
99
|
+
)
|
|
100
|
+
.expect("write compiled spec");
|
|
101
|
+
team
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
fn restart_workspace(label: &str) -> PathBuf {
|
|
105
|
+
let ws = compiled_team_dir(label);
|
|
106
|
+
let rollout = ws.join("implementer-rollout.jsonl");
|
|
107
|
+
std::fs::write(&rollout, "{}\n").expect("seed rollout backing");
|
|
108
|
+
team_agent::state::persist::save_runtime_state(
|
|
109
|
+
&ws,
|
|
110
|
+
&json!({
|
|
111
|
+
"session_name": "team-f032team",
|
|
112
|
+
"agents": {
|
|
113
|
+
"implementer": {
|
|
114
|
+
"status": "running",
|
|
115
|
+
"provider": "codex",
|
|
116
|
+
"session_id": "sess-impl",
|
|
117
|
+
"rollout_path": rollout.to_string_lossy(),
|
|
118
|
+
"first_send_at": "2026-05-27T10:00:00+00:00"
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}),
|
|
122
|
+
)
|
|
123
|
+
.expect("seed runtime state");
|
|
124
|
+
seed_healthy_coordinator(&ws);
|
|
125
|
+
ws
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
fn seed_healthy_coordinator(workspace: &Path) {
|
|
129
|
+
let workspace = team_agent::coordinator::WorkspacePath::new(workspace.to_path_buf());
|
|
130
|
+
std::fs::create_dir_all(team_agent::model::paths::runtime_dir(workspace.as_path()))
|
|
131
|
+
.expect("create runtime dir");
|
|
132
|
+
let _ = team_agent::message_store::MessageStore::open(workspace.as_path())
|
|
133
|
+
.expect("create message store schema");
|
|
134
|
+
let pid = team_agent::coordinator::Pid::new(std::process::id());
|
|
135
|
+
team_agent::coordinator::write_coordinator_metadata(
|
|
136
|
+
&workspace,
|
|
137
|
+
pid,
|
|
138
|
+
team_agent::coordinator::MetadataSource::Boot,
|
|
139
|
+
)
|
|
140
|
+
.expect("write coordinator metadata");
|
|
141
|
+
std::fs::write(
|
|
142
|
+
team_agent::coordinator::coordinator_pid_path(&workspace),
|
|
143
|
+
pid.to_string(),
|
|
144
|
+
)
|
|
145
|
+
.expect("write coordinator pid");
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
fn temp_ws(label: &str) -> PathBuf {
|
|
149
|
+
let n = SEQ.fetch_add(1, Ordering::Relaxed);
|
|
150
|
+
let ws = std::env::temp_dir().join(format!(
|
|
151
|
+
"ta_rs_f032_prompt_best_effort_{}_{}_{}",
|
|
152
|
+
std::process::id(),
|
|
153
|
+
label,
|
|
154
|
+
n
|
|
155
|
+
));
|
|
156
|
+
std::fs::create_dir_all(&ws).expect("create temp workspace");
|
|
157
|
+
ws
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
#[derive(Debug, Default)]
|
|
161
|
+
struct PanicOnStartupPromptTransport {
|
|
162
|
+
spawns: Mutex<Vec<String>>,
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
impl PanicOnStartupPromptTransport {
|
|
166
|
+
fn new() -> Self {
|
|
167
|
+
Self::default()
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
fn spawn_count(&self) -> usize {
|
|
171
|
+
self.spawns.lock().expect("spawns lock").len()
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
fn spawn_result(
|
|
175
|
+
&self,
|
|
176
|
+
kind: &'static str,
|
|
177
|
+
session: &SessionName,
|
|
178
|
+
window: &WindowName,
|
|
179
|
+
) -> SpawnResult {
|
|
180
|
+
let mut spawns = self.spawns.lock().expect("spawns lock");
|
|
181
|
+
let pane_index = spawns.len();
|
|
182
|
+
spawns.push(kind.to_string());
|
|
183
|
+
SpawnResult {
|
|
184
|
+
pane_id: PaneId::new(format!("%{pane_index}")),
|
|
185
|
+
session: session.clone(),
|
|
186
|
+
window: window.clone(),
|
|
187
|
+
child_pid: None,
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
impl Transport for PanicOnStartupPromptTransport {
|
|
193
|
+
fn kind(&self) -> BackendKind {
|
|
194
|
+
BackendKind::Tmux
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
fn spawn_first(
|
|
198
|
+
&self,
|
|
199
|
+
session: &SessionName,
|
|
200
|
+
window: &WindowName,
|
|
201
|
+
_argv: &[String],
|
|
202
|
+
_cwd: &Path,
|
|
203
|
+
_env: &BTreeMap<String, String>,
|
|
204
|
+
) -> Result<SpawnResult, TransportError> {
|
|
205
|
+
Ok(self.spawn_result("spawn_first", session, window))
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
fn spawn_into(
|
|
209
|
+
&self,
|
|
210
|
+
session: &SessionName,
|
|
211
|
+
window: &WindowName,
|
|
212
|
+
_argv: &[String],
|
|
213
|
+
_cwd: &Path,
|
|
214
|
+
_env: &BTreeMap<String, String>,
|
|
215
|
+
) -> Result<SpawnResult, TransportError> {
|
|
216
|
+
Ok(self.spawn_result("spawn_into", session, window))
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
fn inject(
|
|
220
|
+
&self,
|
|
221
|
+
_target: &Target,
|
|
222
|
+
_payload: &InjectPayload,
|
|
223
|
+
_submit: Key,
|
|
224
|
+
_bracketed: bool,
|
|
225
|
+
) -> Result<InjectReport, TransportError> {
|
|
226
|
+
Ok(InjectReport {
|
|
227
|
+
stage_reached: InjectStage::Submit,
|
|
228
|
+
inject_verification: InjectVerification::CaptureContainsToken,
|
|
229
|
+
submit_verification: SubmitVerification::EnterSentWithoutPlaceholderCheck,
|
|
230
|
+
turn_verification: TurnVerification::NotYetObserved,
|
|
231
|
+
attempts: 1,
|
|
232
|
+
submit_diagnostics: None,
|
|
233
|
+
})
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
fn send_keys(&self, _target: &Target, _keys: &[Key]) -> Result<(), TransportError> {
|
|
237
|
+
Ok(())
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
fn capture(
|
|
241
|
+
&self,
|
|
242
|
+
_target: &Target,
|
|
243
|
+
_range: CaptureRange,
|
|
244
|
+
) -> Result<CapturedText, TransportError> {
|
|
245
|
+
panic!("fault adapter: startup prompt capture panicked after spawn");
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
fn query(&self, _target: &Target, _field: PaneField) -> Result<Option<String>, TransportError> {
|
|
249
|
+
Ok(None)
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
fn liveness(
|
|
253
|
+
&self,
|
|
254
|
+
_pane: &PaneId,
|
|
255
|
+
) -> Result<team_agent::transport::PaneLiveness, TransportError> {
|
|
256
|
+
Ok(team_agent::transport::PaneLiveness::Live)
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
fn has_pane(&self, pane: &PaneId) -> Result<Option<bool>, TransportError> {
|
|
260
|
+
let spawns = self.spawns.lock().expect("spawns lock");
|
|
261
|
+
Ok(Some(
|
|
262
|
+
spawns
|
|
263
|
+
.iter()
|
|
264
|
+
.enumerate()
|
|
265
|
+
.any(|(idx, _)| pane.as_str() == format!("%{idx}")),
|
|
266
|
+
))
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
fn list_targets(&self) -> Result<Vec<PaneInfo>, TransportError> {
|
|
270
|
+
Ok(Vec::new())
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
fn has_session(&self, _session: &SessionName) -> Result<bool, TransportError> {
|
|
274
|
+
Ok(!self.spawns.lock().expect("spawns lock").is_empty())
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
fn list_windows(&self, _session: &SessionName) -> Result<Vec<WindowName>, TransportError> {
|
|
278
|
+
Ok(Vec::new())
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
fn set_session_env(
|
|
282
|
+
&self,
|
|
283
|
+
_session: &SessionName,
|
|
284
|
+
_key: &str,
|
|
285
|
+
_value: &str,
|
|
286
|
+
) -> Result<SetEnvOutcome, TransportError> {
|
|
287
|
+
Ok(SetEnvOutcome::Applied)
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
fn kill_session(&self, _session: &SessionName) -> Result<(), TransportError> {
|
|
291
|
+
Ok(())
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
fn kill_window(&self, _target: &Target) -> Result<(), TransportError> {
|
|
295
|
+
Ok(())
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
fn attach_session(&self, _session: &SessionName) -> Result<AttachOutcome, TransportError> {
|
|
299
|
+
Ok(AttachOutcome::Attached)
|
|
300
|
+
}
|
|
301
|
+
}
|