@team-agent/installer 0.5.127 → 0.6.0
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/README.md +15 -4
- package/README.zh.md +1 -1
- package/package.json +4 -8
- package/skills/team-agent/SKILL.md +41 -26
- package/skills/team-agent/command-coverage.json +170 -184
- package/skills/team-agent/docs/reference/team-agent-operator.md +66 -32
- package/skills/team-agent/references/recovery-runbook.md +1 -1
- package/skills/team-agent/references/team-agent-operator.md +66 -32
- package/templates/team_state.md +1 -1
- package/Cargo.lock +0 -1063
- package/Cargo.toml +0 -36
- package/crates/team-agent/Cargo.toml +0 -69
- package/crates/team-agent/src/app_server_test_support.rs +0 -258
- package/crates/team-agent/src/cli/adapters.rs +0 -1298
- package/crates/team-agent/src/cli/arguments.rs +0 -401
- package/crates/team-agent/src/cli/attach_app_server_leader.rs +0 -98
- package/crates/team-agent/src/cli/diagnose.rs +0 -1675
- package/crates/team-agent/src/cli/emit.rs +0 -2898
- package/crates/team-agent/src/cli/grok_slot.rs +0 -384
- package/crates/team-agent/src/cli/helpers.rs +0 -91
- package/crates/team-agent/src/cli/intent/runtime.rs +0 -1189
- package/crates/team-agent/src/cli/intent/runtime_tests.rs +0 -821
- package/crates/team-agent/src/cli/intent/tests.rs +0 -691
- package/crates/team-agent/src/cli/intent.rs +0 -664
- package/crates/team-agent/src/cli/leader.rs +0 -300
- package/crates/team-agent/src/cli/leader_prompt.rs +0 -261
- package/crates/team-agent/src/cli/leaders.rs +0 -418
- package/crates/team-agent/src/cli/mod.rs +0 -6528
- package/crates/team-agent/src/cli/models.rs +0 -449
- package/crates/team-agent/src/cli/named_address.rs +0 -1651
- package/crates/team-agent/src/cli/profile.rs +0 -342
- package/crates/team-agent/src/cli/route.rs +0 -212
- package/crates/team-agent/src/cli/send/coordinator.rs +0 -164
- package/crates/team-agent/src/cli/send/mailbox.rs +0 -145
- package/crates/team-agent/src/cli/send/persist.rs +0 -192
- package/crates/team-agent/src/cli/send/presentation.rs +0 -370
- package/crates/team-agent/src/cli/send/resolve.rs +0 -573
- package/crates/team-agent/src/cli/send.rs +0 -201
- package/crates/team-agent/src/cli/shutdown_socket.rs +0 -288
- package/crates/team-agent/src/cli/spec.rs +0 -159
- package/crates/team-agent/src/cli/status.rs +0 -280
- package/crates/team-agent/src/cli/status_port/agents.rs +0 -358
- package/crates/team-agent/src/cli/status_port/approvals.rs +0 -79
- package/crates/team-agent/src/cli/status_port/brief.rs +0 -2043
- package/crates/team-agent/src/cli/status_port/compact.rs +0 -240
- package/crates/team-agent/src/cli/status_port/format.rs +0 -146
- package/crates/team-agent/src/cli/status_port/inbox.rs +0 -62
- package/crates/team-agent/src/cli/status_port/runtime.rs +0 -197
- package/crates/team-agent/src/cli/status_port/snapshot.rs +0 -208
- package/crates/team-agent/src/cli/status_port/store.rs +0 -416
- package/crates/team-agent/src/cli/status_port/tests.rs +0 -90
- package/crates/team-agent/src/cli/status_port.rs +0 -92
- package/crates/team-agent/src/cli/tests/base.rs +0 -885
- package/crates/team-agent/src/cli/tests/divergence.rs +0 -518
- package/crates/team-agent/src/cli/tests/lane_c.rs +0 -453
- package/crates/team-agent/src/cli/tests/leader_watch.rs +0 -372
- package/crates/team-agent/src/cli/tests/main_preserved.rs +0 -430
- package/crates/team-agent/src/cli/tests/missing_subcommands.rs +0 -336
- package/crates/team-agent/src/cli/tests/mod.rs +0 -137
- package/crates/team-agent/src/cli/tests/named_address.rs +0 -760
- package/crates/team-agent/src/cli/tests/parser_safety.rs +0 -383
- package/crates/team-agent/src/cli/tests/run_delegation.rs +0 -481
- package/crates/team-agent/src/cli/tests/shutdown_kill_plan.rs +0 -2179
- package/crates/team-agent/src/cli/tests/status_brief.rs +0 -1514
- package/crates/team-agent/src/cli/tests/status_send.rs +0 -1091
- package/crates/team-agent/src/cli/tests/verb_install_skill.rs +0 -93
- package/crates/team-agent/src/cli/tests/verb_profile.rs +0 -392
- package/crates/team-agent/src/cli/triage.rs +0 -234
- package/crates/team-agent/src/cli/types.rs +0 -591
- package/crates/team-agent/src/codex_app_server.rs +0 -546
- package/crates/team-agent/src/communication_mode/mod.rs +0 -56
- package/crates/team-agent/src/compiler/tests.rs +0 -842
- package/crates/team-agent/src/compiler.rs +0 -691
- package/crates/team-agent/src/conpty/backend.rs +0 -829
- package/crates/team-agent/src/conpty/mod.rs +0 -33
- package/crates/team-agent/src/contract_runtime/backend.rs +0 -1610
- package/crates/team-agent/src/contract_runtime/commands.rs +0 -671
- package/crates/team-agent/src/contract_runtime/config.rs +0 -354
- package/crates/team-agent/src/contract_runtime/config_tests.rs +0 -56
- package/crates/team-agent/src/contract_runtime/discovery.rs +0 -438
- package/crates/team-agent/src/contract_runtime/fork.rs +0 -368
- package/crates/team-agent/src/contract_runtime/forward.rs +0 -288
- package/crates/team-agent/src/contract_runtime/framework.rs +0 -350
- package/crates/team-agent/src/contract_runtime/mcp.rs +0 -399
- package/crates/team-agent/src/contract_runtime/mod.rs +0 -17
- package/crates/team-agent/src/contract_runtime/prompt.rs +0 -216
- package/crates/team-agent/src/contract_runtime/pump.rs +0 -271
- package/crates/team-agent/src/contract_runtime/registry.rs +0 -589
- package/crates/team-agent/src/contract_runtime/workspace.rs +0 -228
- package/crates/team-agent/src/coordinator/backoff.rs +0 -741
- package/crates/team-agent/src/coordinator/conpty_shim.rs +0 -805
- package/crates/team-agent/src/coordinator/health.rs +0 -1185
- package/crates/team-agent/src/coordinator/mod.rs +0 -119
- package/crates/team-agent/src/coordinator/orphan.rs +0 -110
- package/crates/team-agent/src/coordinator/runtime_detectors.rs +0 -798
- package/crates/team-agent/src/coordinator/runtime_observation.rs +0 -84
- package/crates/team-agent/src/coordinator/steps/abnormal.rs +0 -2309
- package/crates/team-agent/src/coordinator/steps/delivery.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/health_sync.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/mod.rs +0 -126
- package/crates/team-agent/src/coordinator/steps/persist.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/runtime_prompts.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/session_gate.rs +0 -16
- package/crates/team-agent/src/coordinator/tests/a0_lostupdate.rs +0 -158
- package/crates/team-agent/src/coordinator/tests/abnormal.rs +0 -312
- package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +0 -338
- package/crates/team-agent/src/coordinator/tests/basics.rs +0 -211
- package/crates/team-agent/src/coordinator/tests/daemon.rs +0 -514
- package/crates/team-agent/src/coordinator/tests/energy.rs +0 -549
- package/crates/team-agent/src/coordinator/tests/health_sync.rs +0 -461
- package/crates/team-agent/src/coordinator/tests/main_preserved.rs +0 -186
- package/crates/team-agent/src/coordinator/tests/mod.rs +0 -295
- package/crates/team-agent/src/coordinator/tests/s3_bounded.rs +0 -207
- package/crates/team-agent/src/coordinator/tests/spine.rs +0 -308
- package/crates/team-agent/src/coordinator/tests/takeover.rs +0 -286
- package/crates/team-agent/src/coordinator/tests/tick_core.rs +0 -237
- package/crates/team-agent/src/coordinator/tick.rs +0 -3112
- package/crates/team-agent/src/coordinator/types.rs +0 -540
- package/crates/team-agent/src/db/agent_health_capture.rs +0 -126
- package/crates/team-agent/src/db/message_store.rs +0 -1585
- package/crates/team-agent/src/db/migration.rs +0 -984
- package/crates/team-agent/src/db/mod.rs +0 -26
- package/crates/team-agent/src/db/schema.rs +0 -663
- package/crates/team-agent/src/diagnose/comms.rs +0 -242
- package/crates/team-agent/src/diagnose/mod.rs +0 -44
- package/crates/team-agent/src/diagnose/orphans.rs +0 -889
- package/crates/team-agent/src/event_log.rs +0 -502
- package/crates/team-agent/src/fake_worker.rs +0 -303
- package/crates/team-agent/src/kill_audit.rs +0 -106
- package/crates/team-agent/src/layout/manager.rs +0 -248
- package/crates/team-agent/src/layout/mod.rs +0 -36
- package/crates/team-agent/src/layout/overlay.rs +0 -134
- package/crates/team-agent/src/layout/placement.rs +0 -52
- package/crates/team-agent/src/layout/recovery.rs +0 -106
- package/crates/team-agent/src/layout/runtime_sessions.rs +0 -317
- package/crates/team-agent/src/layout/sessions.rs +0 -294
- package/crates/team-agent/src/layout/tmux_endpoint.rs +0 -165
- package/crates/team-agent/src/layout/worker_env.rs +0 -721
- package/crates/team-agent/src/layout/worker_window_helpers.rs +0 -37
- package/crates/team-agent/src/leader/helpers.rs +0 -178
- package/crates/team-agent/src/leader/incident.rs +0 -6
- package/crates/team-agent/src/leader/lease.rs +0 -3356
- package/crates/team-agent/src/leader/mod.rs +0 -104
- package/crates/team-agent/src/leader/owner_bind.rs +0 -400
- package/crates/team-agent/src/leader/prompt.rs +0 -905
- package/crates/team-agent/src/leader/provider_attribution.rs +0 -247
- package/crates/team-agent/src/leader/rediscover/tests.rs +0 -689
- package/crates/team-agent/src/leader/rediscover.rs +0 -1192
- package/crates/team-agent/src/leader/registry.rs +0 -883
- package/crates/team-agent/src/leader/start.rs +0 -4500
- package/crates/team-agent/src/leader/takeover.rs +0 -65
- package/crates/team-agent/src/leader/tests/basics.rs +0 -337
- package/crates/team-agent/src/leader/tests/byte_findings.rs +0 -355
- package/crates/team-agent/src/leader/tests/claim_leader_mailbox_flush_contract.rs +0 -544
- package/crates/team-agent/src/leader/tests/historical_inventory_upgrade_gate_red.rs +0 -624
- package/crates/team-agent/src/leader/tests/identity.rs +0 -465
- package/crates/team-agent/src/leader/tests/identity_session_names.rs +0 -42
- package/crates/team-agent/src/leader/tests/idle.rs +0 -113
- package/crates/team-agent/src/leader/tests/lease_api.rs +0 -520
- package/crates/team-agent/src/leader/tests/lease_claim.rs +0 -629
- package/crates/team-agent/src/leader/tests/mod.rs +0 -106
- package/crates/team-agent/src/leader/tests/prompt_contract.rs +0 -267
- package/crates/team-agent/src/leader/tests/rediscover.rs +0 -403
- package/crates/team-agent/src/leader/tests/rehomed_env.rs +0 -83
- package/crates/team-agent/src/leader/tests/team_in_team_state_scope_red.rs +0 -1273
- package/crates/team-agent/src/leader/tests/terminal_and_replay_vs_rerender_invariants_red.rs +0 -417
- package/crates/team-agent/src/leader/tests/wake_start_owner.rs +0 -168
- package/crates/team-agent/src/leader/types.rs +0 -534
- package/crates/team-agent/src/lib.rs +0 -145
- package/crates/team-agent/src/lifecycle/helpers.rs +0 -212
- package/crates/team-agent/src/lifecycle/launch/add_agent.rs +0 -848
- package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +0 -393
- package/crates/team-agent/src/lifecycle/launch/agent_state.rs +0 -332
- package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +0 -178
- package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +0 -82
- package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +0 -63
- package/crates/team-agent/src/lifecycle/launch/identity.rs +0 -674
- package/crates/team-agent/src/lifecycle/launch/layout.rs +0 -350
- package/crates/team-agent/src/lifecycle/launch/leader_context.rs +0 -589
- package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +0 -152
- package/crates/team-agent/src/lifecycle/launch/ownership.rs +0 -105
- package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +0 -629
- package/crates/team-agent/src/lifecycle/launch/pi_mcp_extension.js +0 -226
- package/crates/team-agent/src/lifecycle/launch/plan.rs +0 -269
- package/crates/team-agent/src/lifecycle/launch/quick_start.rs +0 -5176
- package/crates/team-agent/src/lifecycle/launch/quick_start_transport.rs +0 -368
- package/crates/team-agent/src/lifecycle/launch/readiness.rs +0 -519
- package/crates/team-agent/src/lifecycle/launch/role_source.rs +0 -287
- package/crates/team-agent/src/lifecycle/launch/spawn.rs +0 -450
- package/crates/team-agent/src/lifecycle/launch/spec_state.rs +0 -801
- package/crates/team-agent/src/lifecycle/launch/state_projection.rs +0 -624
- package/crates/team-agent/src/lifecycle/launch/worker_env.rs +0 -558
- package/crates/team-agent/src/lifecycle/launch.rs +0 -534
- package/crates/team-agent/src/lifecycle/lock.rs +0 -350
- package/crates/team-agent/src/lifecycle/mod.rs +0 -79
- package/crates/team-agent/src/lifecycle/pane_input_lock.rs +0 -239
- package/crates/team-agent/src/lifecycle/profile_launch.rs +0 -757
- package/crates/team-agent/src/lifecycle/profile_smoke.rs +0 -557
- package/crates/team-agent/src/lifecycle/restart/agent.rs +0 -2198
- package/crates/team-agent/src/lifecycle/restart/common.rs +0 -2052
- package/crates/team-agent/src/lifecycle/restart/orchestrator.rs +0 -65
- package/crates/team-agent/src/lifecycle/restart/preflight.rs +0 -113
- package/crates/team-agent/src/lifecycle/restart/rebuild.rs +0 -5135
- package/crates/team-agent/src/lifecycle/restart/remove.rs +0 -1504
- package/crates/team-agent/src/lifecycle/restart/selection.rs +0 -559
- package/crates/team-agent/src/lifecycle/restart/team_state.rs +0 -329
- package/crates/team-agent/src/lifecycle/restart.rs +0 -223
- package/crates/team-agent/src/lifecycle/role_config.rs +0 -1205
- package/crates/team-agent/src/lifecycle/tests/acceptance_b_batch_red.rs +0 -1021
- package/crates/team-agent/src/lifecycle/tests/agent_ops.rs +0 -1205
- package/crates/team-agent/src/lifecycle/tests/b0_legacy_snapshot_nonauthority_contract.rs +0 -265
- package/crates/team-agent/src/lifecycle/tests/b0_reader_hideone_audit_contract.rs +0 -490
- package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +0 -656
- package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +0 -135
- package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +0 -1415
- package/crates/team-agent/src/lifecycle/tests/clone_agent_preserves_source_tools.rs +0 -427
- package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +0 -396
- package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +0 -418
- package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +0 -2039
- package/crates/team-agent/src/lifecycle/tests/core.rs +0 -1298
- package/crates/team-agent/src/lifecycle/tests/f032_startup_prompt_best_effort_red.rs +0 -315
- package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_g0.stdout.txt +0 -222
- package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_spaced_ids.stdout.txt +0 -9
- package/crates/team-agent/src/lifecycle/tests/fixtures/pi_native_mcp_host.mjs +0 -71
- package/crates/team-agent/src/lifecycle/tests/gate_fixtures.rs +0 -562
- package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +0 -110
- package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +0 -472
- package/crates/team-agent/src/lifecycle/tests/host_cotenant_death_p0_contract.rs +0 -921
- package/crates/team-agent/src/lifecycle/tests/issue238_codex_effort_contract.rs +0 -68
- package/crates/team-agent/src/lifecycle/tests/lane_ops.rs +0 -1851
- package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +0 -3981
- package/crates/team-agent/src/lifecycle/tests/lifecycle_lock.rs +0 -339
- package/crates/team-agent/src/lifecycle/tests/lifecycle_rollback_red.rs +0 -596
- package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +0 -513
- package/crates/team-agent/src/lifecycle/tests/mcp_tool_name_format_red.rs +0 -69
- package/crates/team-agent/src/lifecycle/tests/phase_b_contracts.rs +0 -824
- package/crates/team-agent/src/lifecycle/tests/phase_golden.rs +0 -723
- package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +0 -152
- package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +0 -182
- package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +0 -374
- package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +0 -546
- package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +0 -31
- package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +0 -528
- package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +0 -134
- package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +0 -333
- package/crates/team-agent/src/lifecycle/tests/realmachine_clusters_1_6_red.rs +0 -786
- package/crates/team-agent/src/lifecycle/tests/realmachine_residual_g1_g4_red.rs +0 -648
- package/crates/team-agent/src/lifecycle/tests/restart.rs +0 -185
- package/crates/team-agent/src/lifecycle/tests/restart_build_before_destroy_0540_contract.rs +0 -1053
- package/crates/team-agent/src/lifecycle/tests/restart_liveness_red.rs +0 -679
- package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +0 -1126
- package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +0 -153
- package/crates/team-agent/src/lifecycle/tests/resume_recover_red.rs +0 -427
- package/crates/team-agent/src/lifecycle/tests/stale_team_saveconflict_contract.rs +0 -431
- package/crates/team-agent/src/lifecycle/tests/startup_latency_contract.rs +0 -1066
- package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +0 -876
- package/crates/team-agent/src/lifecycle/tests/subprep_codex_trust_roundtrip_red.rs +0 -1026
- package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +0 -90
- package/crates/team-agent/src/lifecycle/tests/team_in_team_identity_scope_red.rs +0 -543
- package/crates/team-agent/src/lifecycle/tests/team_in_team_sibling_quick_start_red.rs +0 -1103
- package/crates/team-agent/src/lifecycle/tests/team_in_team_state_scope_red.rs +0 -1276
- package/crates/team-agent/src/lifecycle/tests/team_key_retirement_roster_red.rs +0 -145
- package/crates/team-agent/src/lifecycle/tests/team_key_retirement_txn_red.rs +0 -603
- package/crates/team-agent/src/lifecycle/tests/test_isolation_escape_contract.rs +0 -936
- package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +0 -970
- package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +0 -996
- package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +0 -827
- package/crates/team-agent/src/lifecycle/tests.rs +0 -102
- package/crates/team-agent/src/lifecycle/types.rs +0 -861
- package/crates/team-agent/src/lifecycle/worker_command_context.rs +0 -370
- package/crates/team-agent/src/main.rs +0 -52
- package/crates/team-agent/src/mcp_server/helpers.rs +0 -510
- package/crates/team-agent/src/mcp_server/lifecycle_tools/mod.rs +0 -6
- package/crates/team-agent/src/mcp_server/lifecycle_tools/state_status.rs +0 -43
- package/crates/team-agent/src/mcp_server/mod.rs +0 -119
- package/crates/team-agent/src/mcp_server/normalize.rs +0 -485
- package/crates/team-agent/src/mcp_server/readiness.rs +0 -546
- package/crates/team-agent/src/mcp_server/readiness_tests.rs +0 -369
- package/crates/team-agent/src/mcp_server/tests/golden.rs +0 -285
- package/crates/team-agent/src/mcp_server/tests/normalize.rs +0 -247
- package/crates/team-agent/src/mcp_server/tests/scoped.rs +0 -168
- package/crates/team-agent/src/mcp_server/tests/send.rs +0 -388
- package/crates/team-agent/src/mcp_server/tests/tools.rs +0 -343
- package/crates/team-agent/src/mcp_server/tests/wire.rs +0 -254
- package/crates/team-agent/src/mcp_server/tests.rs +0 -43
- package/crates/team-agent/src/mcp_server/tools.rs +0 -1015
- package/crates/team-agent/src/mcp_server/types.rs +0 -396
- package/crates/team-agent/src/mcp_server/wire.rs +0 -867
- package/crates/team-agent/src/messaging/activity.rs +0 -461
- package/crates/team-agent/src/messaging/address.rs +0 -87
- package/crates/team-agent/src/messaging/delivery.rs +0 -3785
- package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +0 -234
- package/crates/team-agent/src/messaging/enter_rescue.rs +0 -362
- package/crates/team-agent/src/messaging/enter_rescue_tests.rs +0 -633
- package/crates/team-agent/src/messaging/helpers.rs +0 -354
- package/crates/team-agent/src/messaging/leader_channel.rs +0 -287
- package/crates/team-agent/src/messaging/leader_receiver.rs +0 -786
- package/crates/team-agent/src/messaging/mod.rs +0 -166
- package/crates/team-agent/src/messaging/persist.rs +0 -377
- package/crates/team-agent/src/messaging/presentation.rs +0 -417
- package/crates/team-agent/src/messaging/results/collection_tests.rs +0 -719
- package/crates/team-agent/src/messaging/results.rs +0 -1415
- package/crates/team-agent/src/messaging/scheduler.rs +0 -217
- package/crates/team-agent/src/messaging/selftest.rs +0 -315
- package/crates/team-agent/src/messaging/send.rs +0 -981
- package/crates/team-agent/src/messaging/tests/basic.rs +0 -346
- package/crates/team-agent/src/messaging/tests/dup_inject.rs +0 -551
- package/crates/team-agent/src/messaging/tests/e23.rs +0 -49
- package/crates/team-agent/src/messaging/tests/leader_channel.rs +0 -169
- package/crates/team-agent/src/messaging/tests/leader_inject_acceptance.rs +0 -817
- package/crates/team-agent/src/messaging/tests/main_preserved.rs +0 -85
- package/crates/team-agent/src/messaging/tests/mod.rs +0 -306
- package/crates/team-agent/src/messaging/tests/runtime.rs +0 -3655
- package/crates/team-agent/src/messaging/tests/spine.rs +0 -837
- package/crates/team-agent/src/messaging/tests/wave2.rs +0 -381
- package/crates/team-agent/src/messaging/trust.rs +0 -215
- package/crates/team-agent/src/messaging/types.rs +0 -471
- package/crates/team-agent/src/messaging/wait.rs +0 -366
- package/crates/team-agent/src/messaging/watchers.rs +0 -916
- package/crates/team-agent/src/model/enums.rs +0 -356
- package/crates/team-agent/src/model/errors.rs +0 -18
- package/crates/team-agent/src/model/ids.rs +0 -165
- package/crates/team-agent/src/model/mod.rs +0 -29
- package/crates/team-agent/src/model/name_similarity.rs +0 -252
- package/crates/team-agent/src/model/pane_authority_refusal.rs +0 -359
- package/crates/team-agent/src/model/paths.rs +0 -257
- package/crates/team-agent/src/model/routing.rs +0 -387
- package/crates/team-agent/src/model/spec.rs +0 -1184
- package/crates/team-agent/src/model/task_graph.rs +0 -321
- package/crates/team-agent/src/model/testdata/fuzz.golden.yaml +0 -43
- package/crates/team-agent/src/model/testdata/fuzz.yaml +0 -43
- package/crates/team-agent/src/model/testdata/spec_invalid_a.yaml +0 -209
- package/crates/team-agent/src/model/testdata/team.spec.golden.yaml +0 -208
- package/crates/team-agent/src/model/testdata/team.spec.yaml +0 -208
- package/crates/team-agent/src/model/yaml/tests.rs +0 -188
- package/crates/team-agent/src/model/yaml.rs +0 -802
- package/crates/team-agent/src/os_probe.rs +0 -280
- package/crates/team-agent/src/packaging/install.rs +0 -219
- package/crates/team-agent/src/packaging/migrate.rs +0 -38
- package/crates/team-agent/src/packaging/mod.rs +0 -91
- package/crates/team-agent/src/packaging/repair.rs +0 -33
- package/crates/team-agent/src/packaging/tests.rs +0 -822
- package/crates/team-agent/src/packaging/types.rs +0 -417
- package/crates/team-agent/src/platform/argv.rs +0 -331
- package/crates/team-agent/src/platform/errors.rs +0 -104
- package/crates/team-agent/src/platform/file_lock.rs +0 -279
- package/crates/team-agent/src/platform/mod.rs +0 -5
- package/crates/team-agent/src/platform/process.rs +0 -545
- package/crates/team-agent/src/provider/adapter.rs +0 -898
- package/crates/team-agent/src/provider/adapters/copilot.rs +0 -75
- package/crates/team-agent/src/provider/adapters/copilot_fork.rs +0 -307
- package/crates/team-agent/src/provider/adapters/fake.rs +0 -18
- package/crates/team-agent/src/provider/adapters/mod.rs +0 -28
- package/crates/team-agent/src/provider/approvals/mod.rs +0 -3
- package/crates/team-agent/src/provider/approvals/parsing.rs +0 -586
- package/crates/team-agent/src/provider/approvals/runtime_prompts.rs +0 -205
- package/crates/team-agent/src/provider/argv_route.rs +0 -405
- package/crates/team-agent/src/provider/bypass_flags.rs +0 -116
- package/crates/team-agent/src/provider/classify.rs +0 -773
- package/crates/team-agent/src/provider/command_helpers.rs +0 -45
- package/crates/team-agent/src/provider/faults.rs +0 -165
- package/crates/team-agent/src/provider/helpers.rs +0 -52
- package/crates/team-agent/src/provider/mod.rs +0 -78
- package/crates/team-agent/src/provider/model_catalog.rs +0 -722
- package/crates/team-agent/src/provider/session/capture.rs +0 -2631
- package/crates/team-agent/src/provider/session/context_fork/outcome.rs +0 -168
- package/crates/team-agent/src/provider/session/context_fork.rs +0 -264
- package/crates/team-agent/src/provider/session/mod.rs +0 -36
- package/crates/team-agent/src/provider/session/resume.rs +0 -269
- package/crates/team-agent/src/provider/session_scan/common/tests.rs +0 -316
- package/crates/team-agent/src/provider/session_scan/common.rs +0 -618
- package/crates/team-agent/src/provider/session_scan/copilot.rs +0 -280
- package/crates/team-agent/src/provider/session_scan/pi.rs +0 -152
- package/crates/team-agent/src/provider/session_scan.rs +0 -61
- package/crates/team-agent/src/provider/startup_prompt.rs +0 -757
- package/crates/team-agent/src/provider/submit_now.rs +0 -71
- package/crates/team-agent/src/provider/testdata/copilot-ready-marker.txt +0 -5
- package/crates/team-agent/src/provider/testdata/copilot-trust-prompt.txt +0 -19
- package/crates/team-agent/src/provider/testdata/grok-models-authenticated.stdout +0 -9
- package/crates/team-agent/src/provider/testdata/grok-models-unauthenticated.stdout +0 -7
- package/crates/team-agent/src/provider/tests/adapter.rs +0 -354
- package/crates/team-agent/src/provider/tests/classify.rs +0 -201
- package/crates/team-agent/src/provider/tests/command_helpers.rs +0 -26
- package/crates/team-agent/src/provider/tests/copilot_fork.rs +0 -191
- package/crates/team-agent/src/provider/tests/faults.rs +0 -200
- package/crates/team-agent/src/provider/tests/idle.rs +0 -140
- package/crates/team-agent/src/provider/tests/wire.rs +0 -213
- package/crates/team-agent/src/provider/tests.rs +0 -32
- package/crates/team-agent/src/provider/types.rs +0 -529
- package/crates/team-agent/src/provider/wire.rs +0 -406
- package/crates/team-agent/src/redaction.rs +0 -259
- package/crates/team-agent/src/state/abnormal_watch/tests/mod.rs +0 -248
- package/crates/team-agent/src/state/abnormal_watch.rs +0 -144
- package/crates/team-agent/src/state/identity.rs +0 -914
- package/crates/team-agent/src/state/identity_keys.rs +0 -132
- package/crates/team-agent/src/state/mod.rs +0 -74
- package/crates/team-agent/src/state/owner_gate.rs +0 -482
- package/crates/team-agent/src/state/ownership.rs +0 -563
- package/crates/team-agent/src/state/paths.rs +0 -395
- package/crates/team-agent/src/state/persist.rs +0 -3811
- package/crates/team-agent/src/state/projection.rs +0 -1508
- package/crates/team-agent/src/state/repository/intent.rs +0 -14
- package/crates/team-agent/src/state/repository/tests.rs +0 -184
- package/crates/team-agent/src/state/repository.rs +0 -866
- package/crates/team-agent/src/state/selector.rs +0 -160
- package/crates/team-agent/src/state/testdata/state-rich.canonical.json +0 -133
- package/crates/team-agent/src/tmux_backend/enter_rescue.rs +0 -325
- package/crates/team-agent/src/tmux_backend/enter_rescue_tests.rs +0 -432
- package/crates/team-agent/src/tmux_backend/native_input.rs +0 -513
- package/crates/team-agent/src/tmux_backend/native_input_tests.rs +0 -742
- package/crates/team-agent/src/tmux_backend/tests.rs +0 -4254
- package/crates/team-agent/src/tmux_backend.rs +0 -4527
- package/crates/team-agent/src/topology.rs +0 -537
- package/crates/team-agent/src/transport/enter_rescue.rs +0 -166
- package/crates/team-agent/src/transport/native_input.rs +0 -491
- package/crates/team-agent/src/transport/test_support.rs +0 -743
- package/crates/team-agent/src/transport/tests/behavior.rs +0 -326
- package/crates/team-agent/src/transport/tests/mod.rs +0 -194
- package/crates/team-agent/src/transport/tests/wire.rs +0 -574
- package/crates/team-agent/src/transport.rs +0 -1655
- package/crates/team-agent/src/transport_factory.rs +0 -819
|
@@ -1,1066 +0,0 @@
|
|
|
1
|
-
//! ---
|
|
2
|
-
//! purpose: restart spawn overlap and identity contracts
|
|
3
|
-
//! contract:
|
|
4
|
-
//! provides:
|
|
5
|
-
//! - name: restart_spawn_overlap_identity
|
|
6
|
-
//! what: controlled transport facts prove overlapping worker spawns and stable persisted identities
|
|
7
|
-
//! depends:
|
|
8
|
-
//! - crate::lifecycle::restart
|
|
9
|
-
//! - hermetic fake transport with spawn trace
|
|
10
|
-
//! boundary:
|
|
11
|
-
//! - overlap/max-in-flight facts replace scheduler-sensitive total-time thresholds
|
|
12
|
-
//! - no production scheduler, pool, or state-machine changes
|
|
13
|
-
//! maturity: wired
|
|
14
|
-
//! ---
|
|
15
|
-
//!
|
|
16
|
-
//! 0.5.38 RED contract: startup latency instrumentation and bounded worker spawn.
|
|
17
|
-
//!
|
|
18
|
-
//! References:
|
|
19
|
-
//! - `.team/artifacts/startup-latency-locate.md` §5 / §8.
|
|
20
|
-
//!
|
|
21
|
-
//! User-visible contract:
|
|
22
|
-
//! - Restart/launch expose structured phase timing before optimizing latency.
|
|
23
|
-
//! - Restart may spawn independent workers concurrently, but persisted topology
|
|
24
|
-
//! matches transport identity regardless of completion order, and failure
|
|
25
|
-
//! aggregation remains equivalent to serial.
|
|
26
|
-
//! - Readiness still waits on session, worker panes, and coordinator truth.
|
|
27
|
-
|
|
28
|
-
#![cfg(unix)]
|
|
29
|
-
#![allow(clippy::expect_used, clippy::panic, clippy::unwrap_used)]
|
|
30
|
-
|
|
31
|
-
#[path = "../../../tests/support/hermetic.rs"]
|
|
32
|
-
mod hermetic_guard;
|
|
33
|
-
#[allow(dead_code)]
|
|
34
|
-
fn _hermetic_boundary_marker(_: &hermetic_guard::HermeticTestEnv) {}
|
|
35
|
-
|
|
36
|
-
use std::collections::{BTreeMap, BTreeSet};
|
|
37
|
-
use std::fs;
|
|
38
|
-
use std::path::{Path, PathBuf};
|
|
39
|
-
use std::sync::{Arc, Mutex};
|
|
40
|
-
use std::time::{Duration, Instant};
|
|
41
|
-
|
|
42
|
-
use serde_json::{json, Value};
|
|
43
|
-
use serial_test::serial;
|
|
44
|
-
use team_agent::coordinator::{MetadataSource, Pid, WorkspacePath};
|
|
45
|
-
use team_agent::event_log::EventLog;
|
|
46
|
-
use team_agent::lifecycle::{
|
|
47
|
-
quick_start_with_transport_in_workspace, restart_with_transport_with_readiness_deadline,
|
|
48
|
-
QuickStartReport, RestartReport,
|
|
49
|
-
};
|
|
50
|
-
use team_agent::message_store::MessageStore;
|
|
51
|
-
use team_agent::model::paths::{runtime_dir, runtime_spec_path};
|
|
52
|
-
use team_agent::state::persist::{load_runtime_state, save_runtime_state};
|
|
53
|
-
use team_agent::transport::{
|
|
54
|
-
AttachOutcome, BackendKind, CaptureRange, CapturedText, InjectPayload, InjectReport,
|
|
55
|
-
InjectStage, InjectVerification, Key, PaneField, PaneId, PaneInfo, PaneLiveness, SessionName,
|
|
56
|
-
SetEnvOutcome, SpawnResult, SubmitVerification, Target, Transport, TransportError,
|
|
57
|
-
TurnVerification, WindowName,
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const TEAM: &str = "current";
|
|
61
|
-
const TEAM_SESSION: &str = "team-current";
|
|
62
|
-
const TMUX_ENDPOINT: &str = "/Volumes/nvme/tmp/ta-0538-startup-latency.sock";
|
|
63
|
-
const WRONG_INDEX_INJECTION: &str = "TEAM_AGENT_TEST_INJECT_WRONG_OUTCOME_INDEX";
|
|
64
|
-
const FAILURE_SNAPSHOT: &str = "TEAM_AGENT_STARTUP_FAILURE_SNAPSHOT";
|
|
65
|
-
|
|
66
|
-
#[test]
|
|
67
|
-
#[serial(env)]
|
|
68
|
-
fn restart_records_parallel_spawn_overlap_and_deterministic_state() {
|
|
69
|
-
let case = RestartLatencyCase::new("r1-parallel-state", 8);
|
|
70
|
-
let transport = StartupLatencyTransport::new().with_spawn_delay(Duration::from_millis(80));
|
|
71
|
-
|
|
72
|
-
let report = restart_with_transport_with_readiness_deadline(
|
|
73
|
-
&case.workspace,
|
|
74
|
-
true,
|
|
75
|
-
Some(TEAM),
|
|
76
|
-
&transport,
|
|
77
|
-
Some(2_000),
|
|
78
|
-
)
|
|
79
|
-
.expect("R1 setup: restart should complete against recording transport");
|
|
80
|
-
assert!(
|
|
81
|
-
matches!(report, RestartReport::Restarted { .. }),
|
|
82
|
-
"R1 setup: restart must reach Restarted before checking latency contract; report={report:?}"
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
let calls = transport.spawn_calls();
|
|
86
|
-
let new_windows = calls
|
|
87
|
-
.iter()
|
|
88
|
-
.filter(|call| call.kind == "spawn_into")
|
|
89
|
-
.collect::<Vec<_>>();
|
|
90
|
-
let mut state = case.read_state();
|
|
91
|
-
if std::env::var_os(WRONG_INDEX_INJECTION).is_some() {
|
|
92
|
-
inject_wrong_outcome_index(&mut state, "w1", "w2");
|
|
93
|
-
}
|
|
94
|
-
let panes = transport.pane_snapshot();
|
|
95
|
-
let mut violations = Vec::new();
|
|
96
|
-
if !has_overlap(&new_windows) {
|
|
97
|
-
violations.push(format!(
|
|
98
|
-
"expected at least two new-window spawns to overlap after the initial session creator; calls={calls:?}"
|
|
99
|
-
));
|
|
100
|
-
}
|
|
101
|
-
assert!(
|
|
102
|
-
transport.max_in_flight() >= 2,
|
|
103
|
-
"expected at least two concurrent spawn calls; calls={calls:?}"
|
|
104
|
-
);
|
|
105
|
-
let agent_keys = state
|
|
106
|
-
.pointer("/agents")
|
|
107
|
-
.and_then(Value::as_object)
|
|
108
|
-
.map(|agents| agents.keys().cloned().collect::<Vec<_>>())
|
|
109
|
-
.unwrap_or_default();
|
|
110
|
-
let expected_agents = worker_ids(8);
|
|
111
|
-
if agent_keys != expected_agents {
|
|
112
|
-
violations.push(format!(
|
|
113
|
-
"persisted agents must stay sorted/stable in plan order; got={agent_keys:?}"
|
|
114
|
-
));
|
|
115
|
-
}
|
|
116
|
-
for worker in &expected_agents {
|
|
117
|
-
let agent = state
|
|
118
|
-
.pointer(&format!("/agents/{worker}"))
|
|
119
|
-
.unwrap_or_else(|| panic!("R1 setup: missing {worker}; state={state}"));
|
|
120
|
-
if state.pointer("/session_name").and_then(Value::as_str) != Some(TEAM_SESSION) {
|
|
121
|
-
violations.push(format!("{worker}: root session_name not {TEAM_SESSION}"));
|
|
122
|
-
}
|
|
123
|
-
if agent.get("window").and_then(Value::as_str) != Some(worker.as_str()) {
|
|
124
|
-
violations.push(format!(
|
|
125
|
-
"{worker}: persisted window mismatch; agent={agent}"
|
|
126
|
-
));
|
|
127
|
-
}
|
|
128
|
-
if agent.get("spawn_epoch").and_then(Value::as_u64) != Some(1) {
|
|
129
|
-
violations.push(format!(
|
|
130
|
-
"{worker}: respawn must persist spawn_epoch=1, not leave the old/missing value; agent={agent}"
|
|
131
|
-
));
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
violations.extend(identity_tuple_violations(&state, &panes, &expected_agents));
|
|
135
|
-
let failure_snapshot =
|
|
136
|
-
(!violations.is_empty()).then(|| case.write_failure_snapshot(&state, &panes, &violations));
|
|
137
|
-
assert!(
|
|
138
|
-
violations.is_empty(),
|
|
139
|
-
"R1: parallel restart must overlap while preserving persisted↔transport identity tuples; failure_snapshot={}:\n{}",
|
|
140
|
-
failure_snapshot
|
|
141
|
-
.as_deref()
|
|
142
|
-
.map_or_else(|| "<none>".to_string(), |path| path.display().to_string()),
|
|
143
|
-
violations.join("\n")
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
#[test]
|
|
148
|
-
#[serial(env)]
|
|
149
|
-
fn restart_failure_aggregation_matches_serial_semantics_without_early_abort() {
|
|
150
|
-
let case = RestartLatencyCase::new("r2-failure-aggregation", 8);
|
|
151
|
-
let transport =
|
|
152
|
-
StartupLatencyTransport::new().with_spawn_failure("w3", "injected w3 spawn failure");
|
|
153
|
-
|
|
154
|
-
let report = restart_with_transport_with_readiness_deadline(
|
|
155
|
-
&case.workspace,
|
|
156
|
-
true,
|
|
157
|
-
Some(TEAM),
|
|
158
|
-
&transport,
|
|
159
|
-
Some(2_000),
|
|
160
|
-
)
|
|
161
|
-
.expect("R2 setup: restart should return a typed report");
|
|
162
|
-
let RestartReport::Partial {
|
|
163
|
-
agents,
|
|
164
|
-
failed_agents,
|
|
165
|
-
..
|
|
166
|
-
} = report
|
|
167
|
-
else {
|
|
168
|
-
panic!(
|
|
169
|
-
"R2: one worker spawn failure must produce Partial, not early abort; report={report:?}"
|
|
170
|
-
);
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
assert_eq!(
|
|
174
|
-
failed_agents
|
|
175
|
-
.iter()
|
|
176
|
-
.map(|agent| agent.agent_id.as_str())
|
|
177
|
-
.collect::<Vec<_>>(),
|
|
178
|
-
vec!["w3"],
|
|
179
|
-
"R2: only the injected worker should fail; failed_agents={failed_agents:?}"
|
|
180
|
-
);
|
|
181
|
-
assert_eq!(
|
|
182
|
-
agents
|
|
183
|
-
.iter()
|
|
184
|
-
.map(|agent| agent.agent_id.as_str().to_string())
|
|
185
|
-
.collect::<Vec<_>>(),
|
|
186
|
-
["w1", "w2", "w4", "w5", "w6", "w7", "w8"],
|
|
187
|
-
"R2: successful workers after w3 must still be spawned and reported"
|
|
188
|
-
);
|
|
189
|
-
let mut observed_spawn_windows = transport
|
|
190
|
-
.spawn_calls()
|
|
191
|
-
.into_iter()
|
|
192
|
-
.map(|call| call.window)
|
|
193
|
-
.collect::<Vec<_>>();
|
|
194
|
-
let mut expected_spawn_windows = worker_ids(8);
|
|
195
|
-
observed_spawn_windows.sort();
|
|
196
|
-
expected_spawn_windows.sort();
|
|
197
|
-
assert_eq!(
|
|
198
|
-
observed_spawn_windows,
|
|
199
|
-
expected_spawn_windows,
|
|
200
|
-
"R2: failure aggregation must attempt the full plan; no early return after w3"
|
|
201
|
-
);
|
|
202
|
-
|
|
203
|
-
let state = case.read_state();
|
|
204
|
-
assert_eq!(
|
|
205
|
-
state.pointer("/agents/w3/status").and_then(Value::as_str),
|
|
206
|
-
Some("failed"),
|
|
207
|
-
"R2: failed worker must be persisted as failed; state={state}"
|
|
208
|
-
);
|
|
209
|
-
for worker in ["w1", "w2", "w4", "w5", "w6", "w7", "w8"] {
|
|
210
|
-
assert_eq!(
|
|
211
|
-
state
|
|
212
|
-
.pointer(&format!("/agents/{worker}/status"))
|
|
213
|
-
.and_then(Value::as_str),
|
|
214
|
-
Some("running"),
|
|
215
|
-
"R2: successful worker {worker} must be persisted running; state={state}"
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
assert_phase_events(
|
|
219
|
-
&case.events(),
|
|
220
|
-
"restart.phase",
|
|
221
|
-
&[
|
|
222
|
-
"plan_classification",
|
|
223
|
-
"spawn_all",
|
|
224
|
-
"save_state",
|
|
225
|
-
"completed",
|
|
226
|
-
],
|
|
227
|
-
);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
#[test]
|
|
231
|
-
#[serial(env)]
|
|
232
|
-
fn restart_readiness_timeout_keeps_three_truth_booleans_and_no_false_restarted() {
|
|
233
|
-
let case = RestartLatencyCase::new("r3-readiness-timeout", 1);
|
|
234
|
-
let transport = StartupLatencyTransport::new().with_session_missing_for_readiness();
|
|
235
|
-
|
|
236
|
-
let result = restart_with_transport_with_readiness_deadline(
|
|
237
|
-
&case.workspace,
|
|
238
|
-
true,
|
|
239
|
-
Some(TEAM),
|
|
240
|
-
&transport,
|
|
241
|
-
Some(1),
|
|
242
|
-
);
|
|
243
|
-
assert!(
|
|
244
|
-
result.is_err(),
|
|
245
|
-
"R3: readiness timeout must return Err, not a false Restarted report; result={result:?}"
|
|
246
|
-
);
|
|
247
|
-
let err = result.unwrap_err().to_string();
|
|
248
|
-
assert!(
|
|
249
|
-
err.contains("restart not ready within") && err.contains("tmux session created"),
|
|
250
|
-
"R3: readiness error must name the missing truth gates; err={err}"
|
|
251
|
-
);
|
|
252
|
-
|
|
253
|
-
let events = case.events();
|
|
254
|
-
let timeout = events
|
|
255
|
-
.iter()
|
|
256
|
-
.find(|event| event_name(event) == Some("restart.readiness_timeout"))
|
|
257
|
-
.unwrap_or_else(|| {
|
|
258
|
-
panic!("R3: restart.readiness_timeout event missing; events={events:?}")
|
|
259
|
-
});
|
|
260
|
-
assert_eq!(
|
|
261
|
-
timeout.get("tmux_session_created").and_then(Value::as_bool),
|
|
262
|
-
Some(false),
|
|
263
|
-
"R3: timeout must expose tmux_session_created=false; event={timeout}"
|
|
264
|
-
);
|
|
265
|
-
assert_eq!(
|
|
266
|
-
timeout
|
|
267
|
-
.get("worker_pane_addressable")
|
|
268
|
-
.and_then(Value::as_bool),
|
|
269
|
-
Some(true),
|
|
270
|
-
"R3: timeout must expose worker_pane_addressable=true for the spawned pane; event={timeout}"
|
|
271
|
-
);
|
|
272
|
-
assert_eq!(
|
|
273
|
-
timeout.get("coordinator_alive").and_then(Value::as_bool),
|
|
274
|
-
Some(false),
|
|
275
|
-
"R3: coordinator_alive must be false when the team session is not live; event={timeout}"
|
|
276
|
-
);
|
|
277
|
-
assert!(
|
|
278
|
-
!events.iter().any(|event| {
|
|
279
|
-
event_name(event) == Some("restart.completed")
|
|
280
|
-
&& event.get("rc").and_then(Value::as_str) == Some("ok")
|
|
281
|
-
}),
|
|
282
|
-
"R3: readiness timeout must not emit a false ok restart.completed; events={events:?}"
|
|
283
|
-
);
|
|
284
|
-
assert_phase_events(&events, "restart.phase", &["readiness_wait"]);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
#[test]
|
|
288
|
-
#[serial(env)]
|
|
289
|
-
fn eight_worker_restart_with_100ms_spawn_delay_beats_serial_baseline() {
|
|
290
|
-
let case = RestartLatencyCase::new("r4-timing-smoke", 8);
|
|
291
|
-
let delay = Duration::from_millis(100);
|
|
292
|
-
let transport = StartupLatencyTransport::new().with_spawn_delay(delay);
|
|
293
|
-
|
|
294
|
-
let report = restart_with_transport_with_readiness_deadline(
|
|
295
|
-
&case.workspace,
|
|
296
|
-
true,
|
|
297
|
-
Some(TEAM),
|
|
298
|
-
&transport,
|
|
299
|
-
Some(2_000),
|
|
300
|
-
)
|
|
301
|
-
.expect("R4 setup: restart should complete against delayed transport");
|
|
302
|
-
assert!(
|
|
303
|
-
matches!(report, RestartReport::Restarted { .. }),
|
|
304
|
-
"R4 setup: restart must reach Restarted; report={report:?}"
|
|
305
|
-
);
|
|
306
|
-
|
|
307
|
-
let calls = transport.spawn_calls();
|
|
308
|
-
assert_eq!(
|
|
309
|
-
calls.len(),
|
|
310
|
-
8,
|
|
311
|
-
"R4 setup: timing smoke must exercise all 8 workers; calls={calls:?}"
|
|
312
|
-
);
|
|
313
|
-
assert!(
|
|
314
|
-
has_overlap(
|
|
315
|
-
&calls
|
|
316
|
-
.iter()
|
|
317
|
-
.filter(|call| call.kind == "spawn_into")
|
|
318
|
-
.collect::<Vec<_>>(),
|
|
319
|
-
),
|
|
320
|
-
"R4: bounded-concurrency restart must overlap spawn calls; calls={calls:?}"
|
|
321
|
-
);
|
|
322
|
-
assert!(
|
|
323
|
-
transport.max_in_flight() >= 2,
|
|
324
|
-
"R4: max in-flight spawn count must prove overlap; calls={calls:?}"
|
|
325
|
-
);
|
|
326
|
-
assert_phase_events(&case.events(), "restart.phase", &["spawn_all", "completed"]);
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
#[test]
|
|
330
|
-
#[serial(env)]
|
|
331
|
-
fn restart_and_launch_emit_structured_latency_events_without_fake_ready() {
|
|
332
|
-
let restart_case = RestartLatencyCase::new("events-restart", 2);
|
|
333
|
-
let restart_transport = StartupLatencyTransport::new();
|
|
334
|
-
let restart = restart_with_transport_with_readiness_deadline(
|
|
335
|
-
&restart_case.workspace,
|
|
336
|
-
true,
|
|
337
|
-
Some(TEAM),
|
|
338
|
-
&restart_transport,
|
|
339
|
-
Some(1_000),
|
|
340
|
-
)
|
|
341
|
-
.expect("event setup: restart should complete");
|
|
342
|
-
assert!(
|
|
343
|
-
matches!(restart, RestartReport::Restarted { .. }),
|
|
344
|
-
"event setup: restart failed unexpectedly; report={restart:?}"
|
|
345
|
-
);
|
|
346
|
-
let restart_events = restart_case.events();
|
|
347
|
-
assert_phase_events(
|
|
348
|
-
&restart_events,
|
|
349
|
-
"restart.phase",
|
|
350
|
-
&[
|
|
351
|
-
"resolve_context",
|
|
352
|
-
"compile_spec",
|
|
353
|
-
"plan_classification",
|
|
354
|
-
"teardown",
|
|
355
|
-
"spawn_all",
|
|
356
|
-
"save_state",
|
|
357
|
-
"coordinator_start",
|
|
358
|
-
"readiness_wait",
|
|
359
|
-
"completed",
|
|
360
|
-
],
|
|
361
|
-
);
|
|
362
|
-
assert_worker_spawn_timing_events(&restart_events, &worker_ids(2), "restart");
|
|
363
|
-
assert_no_fake_ready_events(&restart_events);
|
|
364
|
-
|
|
365
|
-
let launch_case = LaunchLatencyCase::new("events-launch", 2);
|
|
366
|
-
let launch_transport = StartupLatencyTransport::new();
|
|
367
|
-
let quick_start = quick_start_with_transport_in_workspace(
|
|
368
|
-
&launch_case.workspace,
|
|
369
|
-
&launch_case.team_dir,
|
|
370
|
-
None,
|
|
371
|
-
true,
|
|
372
|
-
Some(TEAM),
|
|
373
|
-
&launch_transport,
|
|
374
|
-
)
|
|
375
|
-
.expect("event setup: quick-start should complete");
|
|
376
|
-
assert!(
|
|
377
|
-
matches!(quick_start, QuickStartReport::Ready { .. }),
|
|
378
|
-
"event setup: quick-start failed unexpectedly; report={quick_start:?}"
|
|
379
|
-
);
|
|
380
|
-
let launch_events = launch_case.events();
|
|
381
|
-
assert_phase_events(
|
|
382
|
-
&launch_events,
|
|
383
|
-
"launch.phase",
|
|
384
|
-
&[
|
|
385
|
-
"compile_spec",
|
|
386
|
-
"spawn_all",
|
|
387
|
-
"coordinator_start",
|
|
388
|
-
"readiness_wait",
|
|
389
|
-
"completed",
|
|
390
|
-
],
|
|
391
|
-
);
|
|
392
|
-
assert_worker_spawn_timing_events(&launch_events, &worker_ids(2), "launch");
|
|
393
|
-
assert_no_fake_ready_events(&launch_events);
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
struct RestartLatencyCase {
|
|
397
|
-
_env: hermetic_guard::HermeticTestEnv,
|
|
398
|
-
workspace: PathBuf,
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
impl RestartLatencyCase {
|
|
402
|
-
fn new(tag: &str, workers: usize) -> Self {
|
|
403
|
-
let env = hermetic_guard::HermeticTestEnv::enter(tag);
|
|
404
|
-
env.scrub_tmux();
|
|
405
|
-
env.assert_no_real_tmux();
|
|
406
|
-
let workspace = env.workspace(tag);
|
|
407
|
-
write_team_docs(&workspace, workers);
|
|
408
|
-
write_runtime_spec(&workspace, &workspace);
|
|
409
|
-
seed_restart_state(&workspace, workers);
|
|
410
|
-
seed_healthy_coordinator(&workspace);
|
|
411
|
-
Self {
|
|
412
|
-
_env: env,
|
|
413
|
-
workspace,
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
fn read_state(&self) -> Value {
|
|
418
|
-
load_runtime_state(&self.workspace).expect("load runtime state")
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
fn events(&self) -> Vec<Value> {
|
|
422
|
-
EventLog::new(&self.workspace).tail(0).expect("read events")
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
fn write_failure_snapshot(
|
|
426
|
-
&self,
|
|
427
|
-
state: &Value,
|
|
428
|
-
panes: &[Value],
|
|
429
|
-
violations: &[String],
|
|
430
|
-
) -> PathBuf {
|
|
431
|
-
let path = std::env::var_os(FAILURE_SNAPSHOT)
|
|
432
|
-
.map(PathBuf::from)
|
|
433
|
-
.unwrap_or_else(|| {
|
|
434
|
-
self._env
|
|
435
|
-
.root()
|
|
436
|
-
.parent()
|
|
437
|
-
.expect("hermetic root parent")
|
|
438
|
-
.join(format!(
|
|
439
|
-
"startup-latency-r1-failure-{}.json",
|
|
440
|
-
std::process::id()
|
|
441
|
-
))
|
|
442
|
-
});
|
|
443
|
-
if let Some(parent) = path.parent() {
|
|
444
|
-
fs::create_dir_all(parent).expect("create R1 failure snapshot parent");
|
|
445
|
-
}
|
|
446
|
-
let snapshot = json!({
|
|
447
|
-
"wrong_index_injected": std::env::var_os(WRONG_INDEX_INJECTION).is_some(),
|
|
448
|
-
"workspace": self.workspace,
|
|
449
|
-
"persisted_session": state.get("session_name"),
|
|
450
|
-
"persisted_agents": state.get("agents"),
|
|
451
|
-
"transport_panes": panes,
|
|
452
|
-
"violations": violations,
|
|
453
|
-
});
|
|
454
|
-
fs::write(
|
|
455
|
-
&path,
|
|
456
|
-
serde_json::to_vec_pretty(&snapshot).expect("serialize R1 failure snapshot"),
|
|
457
|
-
)
|
|
458
|
-
.expect("write R1 failure snapshot before unwind");
|
|
459
|
-
path
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
struct LaunchLatencyCase {
|
|
464
|
-
_env: hermetic_guard::HermeticTestEnv,
|
|
465
|
-
workspace: PathBuf,
|
|
466
|
-
team_dir: PathBuf,
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
impl LaunchLatencyCase {
|
|
470
|
-
fn new(tag: &str, workers: usize) -> Self {
|
|
471
|
-
let env = hermetic_guard::HermeticTestEnv::enter_with_leader(tag);
|
|
472
|
-
let workspace = env.workspace(tag);
|
|
473
|
-
let team_dir = workspace.join("teamdir");
|
|
474
|
-
fs::create_dir_all(&team_dir).expect("create launch team dir");
|
|
475
|
-
write_team_docs(&team_dir, workers);
|
|
476
|
-
seed_healthy_coordinator(&workspace);
|
|
477
|
-
Self {
|
|
478
|
-
_env: env,
|
|
479
|
-
workspace,
|
|
480
|
-
team_dir,
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
fn events(&self) -> Vec<Value> {
|
|
485
|
-
EventLog::new(&self.workspace)
|
|
486
|
-
.tail(0)
|
|
487
|
-
.expect("read launch events")
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
fn write_team_docs(team_dir: &Path, workers: usize) {
|
|
492
|
-
fs::create_dir_all(team_dir.join("agents")).expect("create agents dir");
|
|
493
|
-
fs::write(
|
|
494
|
-
team_dir.join("TEAM.md"),
|
|
495
|
-
"---\nname: current\nobjective: Startup latency contract.\nprovider: fake\n---\n\nTeam.\n",
|
|
496
|
-
)
|
|
497
|
-
.expect("write TEAM.md");
|
|
498
|
-
for worker in worker_ids(workers) {
|
|
499
|
-
fs::write(
|
|
500
|
-
team_dir.join("agents").join(format!("{worker}.md")),
|
|
501
|
-
role_doc(&worker),
|
|
502
|
-
)
|
|
503
|
-
.expect("write role doc");
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
fn role_doc(worker: &str) -> String {
|
|
508
|
-
format!(
|
|
509
|
-
"---\nname: {worker}\nrole: Worker {worker}\nprovider: fake\nmodel: fake\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\n{worker}.\n"
|
|
510
|
-
)
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
fn write_runtime_spec(workspace: &Path, team_dir: &Path) {
|
|
514
|
-
let spec = team_agent::compiler::compile_team(team_dir).expect("compile team");
|
|
515
|
-
let spec_text = team_agent::model::yaml::dumps(&spec);
|
|
516
|
-
fs::write(team_dir.join("team.spec.yaml"), &spec_text).expect("write legacy spec");
|
|
517
|
-
let runtime_spec = runtime_spec_path(workspace, TEAM);
|
|
518
|
-
fs::create_dir_all(runtime_spec.parent().expect("runtime spec parent"))
|
|
519
|
-
.expect("create runtime spec dir");
|
|
520
|
-
fs::write(runtime_spec, spec_text).expect("write runtime spec");
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
fn seed_restart_state(workspace: &Path, workers: usize) {
|
|
524
|
-
let agents = worker_ids(workers)
|
|
525
|
-
.into_iter()
|
|
526
|
-
.map(|worker| {
|
|
527
|
-
(
|
|
528
|
-
worker.clone(),
|
|
529
|
-
json!({
|
|
530
|
-
"status": "running",
|
|
531
|
-
"provider": "fake",
|
|
532
|
-
"agent_id": worker,
|
|
533
|
-
"model": "fake",
|
|
534
|
-
"auth_mode": "subscription",
|
|
535
|
-
"window": worker,
|
|
536
|
-
"pane_id": format!("%old-{worker}"),
|
|
537
|
-
"spawn_epoch": 0,
|
|
538
|
-
"spawn_cwd": workspace.to_string_lossy(),
|
|
539
|
-
}),
|
|
540
|
-
)
|
|
541
|
-
})
|
|
542
|
-
.collect::<serde_json::Map<String, Value>>();
|
|
543
|
-
save_runtime_state(
|
|
544
|
-
workspace,
|
|
545
|
-
&json!({
|
|
546
|
-
"active_team_key": TEAM,
|
|
547
|
-
"team_key": TEAM,
|
|
548
|
-
"workspace": workspace.to_string_lossy(),
|
|
549
|
-
"team_dir": workspace.to_string_lossy(),
|
|
550
|
-
"spec_path": runtime_spec_path(workspace, TEAM).to_string_lossy(),
|
|
551
|
-
"session_name": TEAM_SESSION,
|
|
552
|
-
"tmux_endpoint": TMUX_ENDPOINT,
|
|
553
|
-
"tmux_socket": TMUX_ENDPOINT,
|
|
554
|
-
"agents": Value::Object(agents.clone()),
|
|
555
|
-
"teams": {
|
|
556
|
-
TEAM: {
|
|
557
|
-
"team_key": TEAM,
|
|
558
|
-
"workspace": workspace.to_string_lossy(),
|
|
559
|
-
"team_dir": workspace.to_string_lossy(),
|
|
560
|
-
"spec_path": runtime_spec_path(workspace, TEAM).to_string_lossy(),
|
|
561
|
-
"session_name": TEAM_SESSION,
|
|
562
|
-
"tmux_endpoint": TMUX_ENDPOINT,
|
|
563
|
-
"tmux_socket": TMUX_ENDPOINT,
|
|
564
|
-
"agents": Value::Object(agents),
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
}),
|
|
568
|
-
)
|
|
569
|
-
.expect("seed runtime state");
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
fn seed_healthy_coordinator(workspace: &Path) {
|
|
573
|
-
fs::create_dir_all(runtime_dir(workspace)).expect("create runtime dir");
|
|
574
|
-
let _store = MessageStore::open(workspace).expect("create message store schema");
|
|
575
|
-
let wp = WorkspacePath::new(workspace.to_path_buf());
|
|
576
|
-
let pid = Pid::new(std::process::id());
|
|
577
|
-
team_agent::coordinator::write_coordinator_metadata(&wp, pid, MetadataSource::Boot)
|
|
578
|
-
.expect("write coordinator metadata");
|
|
579
|
-
fs::write(
|
|
580
|
-
team_agent::coordinator::coordinator_pid_path(&wp),
|
|
581
|
-
pid.to_string(),
|
|
582
|
-
)
|
|
583
|
-
.expect("write coordinator pid");
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
fn worker_ids(workers: usize) -> Vec<String> {
|
|
587
|
-
(1..=workers).map(|i| format!("w{i}")).collect()
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
#[derive(Clone, Debug)]
|
|
591
|
-
struct SpawnCall {
|
|
592
|
-
kind: &'static str,
|
|
593
|
-
window: String,
|
|
594
|
-
start: Instant,
|
|
595
|
-
end: Instant,
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
#[derive(Default)]
|
|
599
|
-
struct TransportState {
|
|
600
|
-
session_present: bool,
|
|
601
|
-
calls: Vec<SpawnCall>,
|
|
602
|
-
panes: BTreeMap<String, PaneInfo>,
|
|
603
|
-
next_pane: usize,
|
|
604
|
-
in_flight: usize,
|
|
605
|
-
max_in_flight: usize,
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
#[derive(Clone)]
|
|
609
|
-
struct StartupLatencyTransport {
|
|
610
|
-
state: Arc<Mutex<TransportState>>,
|
|
611
|
-
spawn_delay: Duration,
|
|
612
|
-
fail_agent: Option<String>,
|
|
613
|
-
session_missing_for_readiness: bool,
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
impl StartupLatencyTransport {
|
|
617
|
-
fn new() -> Self {
|
|
618
|
-
Self {
|
|
619
|
-
state: Arc::new(Mutex::new(TransportState {
|
|
620
|
-
next_pane: 1,
|
|
621
|
-
..TransportState::default()
|
|
622
|
-
})),
|
|
623
|
-
spawn_delay: Duration::ZERO,
|
|
624
|
-
fail_agent: None,
|
|
625
|
-
session_missing_for_readiness: false,
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
fn with_spawn_delay(mut self, delay: Duration) -> Self {
|
|
630
|
-
self.spawn_delay = delay;
|
|
631
|
-
self
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
fn with_spawn_failure(mut self, agent: &str, message: &str) -> Self {
|
|
635
|
-
self.fail_agent = Some(format!("{agent}:{message}"));
|
|
636
|
-
self
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
fn with_session_missing_for_readiness(mut self) -> Self {
|
|
640
|
-
self.session_missing_for_readiness = true;
|
|
641
|
-
self
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
fn spawn_calls(&self) -> Vec<SpawnCall> {
|
|
645
|
-
self.state.lock().unwrap().calls.clone()
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
fn max_in_flight(&self) -> usize {
|
|
649
|
-
self.state.lock().unwrap().max_in_flight
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
fn pane_snapshot(&self) -> Vec<Value> {
|
|
653
|
-
self.state
|
|
654
|
-
.lock()
|
|
655
|
-
.unwrap()
|
|
656
|
-
.panes
|
|
657
|
-
.values()
|
|
658
|
-
.map(|pane| {
|
|
659
|
-
json!({
|
|
660
|
-
"pane_id": pane.pane_id.as_str(),
|
|
661
|
-
"session": pane.session.as_str(),
|
|
662
|
-
"window": pane.window_name.as_ref().map(WindowName::as_str),
|
|
663
|
-
})
|
|
664
|
-
})
|
|
665
|
-
.collect()
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
fn spawn(
|
|
669
|
-
&self,
|
|
670
|
-
kind: &'static str,
|
|
671
|
-
session: &SessionName,
|
|
672
|
-
window: &WindowName,
|
|
673
|
-
) -> Result<SpawnResult, TransportError> {
|
|
674
|
-
let start = Instant::now();
|
|
675
|
-
{
|
|
676
|
-
let mut state = self.state.lock().unwrap();
|
|
677
|
-
state.in_flight += 1;
|
|
678
|
-
state.max_in_flight = state.max_in_flight.max(state.in_flight);
|
|
679
|
-
}
|
|
680
|
-
if !self.spawn_delay.is_zero() {
|
|
681
|
-
std::thread::sleep(self.spawn_delay);
|
|
682
|
-
}
|
|
683
|
-
let end = Instant::now();
|
|
684
|
-
let mut state = self.state.lock().unwrap();
|
|
685
|
-
state.in_flight -= 1;
|
|
686
|
-
let pane_id = PaneId::new(format!("%{}", state.next_pane));
|
|
687
|
-
state.next_pane += 1;
|
|
688
|
-
state.calls.push(SpawnCall {
|
|
689
|
-
kind,
|
|
690
|
-
window: window.as_str().to_string(),
|
|
691
|
-
start,
|
|
692
|
-
end,
|
|
693
|
-
});
|
|
694
|
-
if let Some(failure) = self.fail_agent.as_deref() {
|
|
695
|
-
if failure.starts_with(&format!("{}:", window.as_str())) {
|
|
696
|
-
return Err(TransportError::Subprocess {
|
|
697
|
-
argv: vec!["tmux".to_string(), kind.to_string()],
|
|
698
|
-
code: Some(1),
|
|
699
|
-
stderr: failure.to_string(),
|
|
700
|
-
});
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
state.session_present = true;
|
|
704
|
-
let pane = PaneInfo {
|
|
705
|
-
pane_id: pane_id.clone(),
|
|
706
|
-
session: session.clone(),
|
|
707
|
-
window_index: None,
|
|
708
|
-
window_name: Some(window.clone()),
|
|
709
|
-
pane_index: None,
|
|
710
|
-
tty: None,
|
|
711
|
-
current_command: Some("team-agent-fake-worker".to_string()),
|
|
712
|
-
current_path: None,
|
|
713
|
-
active: true,
|
|
714
|
-
pane_pid: Some(10_000 + state.next_pane as u32),
|
|
715
|
-
leader_env: BTreeMap::new(),
|
|
716
|
-
};
|
|
717
|
-
state.panes.insert(pane_id.as_str().to_string(), pane);
|
|
718
|
-
Ok(SpawnResult {
|
|
719
|
-
pane_id,
|
|
720
|
-
session: session.clone(),
|
|
721
|
-
window: window.clone(),
|
|
722
|
-
child_pid: Some(10_000 + state.next_pane as u32),
|
|
723
|
-
})
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
impl Transport for StartupLatencyTransport {
|
|
728
|
-
fn kind(&self) -> BackendKind {
|
|
729
|
-
BackendKind::Tmux
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
fn tmux_endpoint(&self) -> Option<String> {
|
|
733
|
-
Some(TMUX_ENDPOINT.to_string())
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
fn spawn_first(
|
|
737
|
-
&self,
|
|
738
|
-
session: &SessionName,
|
|
739
|
-
window: &WindowName,
|
|
740
|
-
_argv: &[String],
|
|
741
|
-
_cwd: &Path,
|
|
742
|
-
_env: &BTreeMap<String, String>,
|
|
743
|
-
) -> Result<SpawnResult, TransportError> {
|
|
744
|
-
self.spawn("spawn_first", session, window)
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
fn spawn_into(
|
|
748
|
-
&self,
|
|
749
|
-
session: &SessionName,
|
|
750
|
-
window: &WindowName,
|
|
751
|
-
_argv: &[String],
|
|
752
|
-
_cwd: &Path,
|
|
753
|
-
_env: &BTreeMap<String, String>,
|
|
754
|
-
) -> Result<SpawnResult, TransportError> {
|
|
755
|
-
self.spawn("spawn_into", session, window)
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
fn inject(
|
|
759
|
-
&self,
|
|
760
|
-
_target: &Target,
|
|
761
|
-
_payload: &InjectPayload,
|
|
762
|
-
_submit: Key,
|
|
763
|
-
_bracketed: bool,
|
|
764
|
-
) -> Result<InjectReport, TransportError> {
|
|
765
|
-
Ok(InjectReport {
|
|
766
|
-
stage_reached: InjectStage::Submit,
|
|
767
|
-
inject_verification: InjectVerification::NoToken,
|
|
768
|
-
submit_verification: SubmitVerification::EnterSentWithoutPlaceholderCheck,
|
|
769
|
-
turn_verification: TurnVerification::NotRequired,
|
|
770
|
-
attempts: 1,
|
|
771
|
-
submit_diagnostics: None,
|
|
772
|
-
})
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
fn send_keys(&self, _target: &Target, _keys: &[Key]) -> Result<(), TransportError> {
|
|
776
|
-
Ok(())
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
fn capture(
|
|
780
|
-
&self,
|
|
781
|
-
_target: &Target,
|
|
782
|
-
range: CaptureRange,
|
|
783
|
-
) -> Result<CapturedText, TransportError> {
|
|
784
|
-
Ok(CapturedText {
|
|
785
|
-
text: String::new(),
|
|
786
|
-
range,
|
|
787
|
-
})
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
fn query(&self, _target: &Target, _field: PaneField) -> Result<Option<String>, TransportError> {
|
|
791
|
-
Ok(None)
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
fn liveness(&self, pane: &PaneId) -> Result<PaneLiveness, TransportError> {
|
|
795
|
-
if self.state.lock().unwrap().panes.contains_key(pane.as_str()) {
|
|
796
|
-
Ok(PaneLiveness::Live)
|
|
797
|
-
} else {
|
|
798
|
-
Ok(PaneLiveness::Dead)
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
|
|
802
|
-
fn has_pane(&self, pane: &PaneId) -> Result<Option<bool>, TransportError> {
|
|
803
|
-
Ok(Some(
|
|
804
|
-
self.state.lock().unwrap().panes.contains_key(pane.as_str()),
|
|
805
|
-
))
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
fn list_targets(&self) -> Result<Vec<PaneInfo>, TransportError> {
|
|
809
|
-
Ok(self.state.lock().unwrap().panes.values().cloned().collect())
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
fn has_session(&self, _session: &SessionName) -> Result<bool, TransportError> {
|
|
813
|
-
if self.session_missing_for_readiness {
|
|
814
|
-
return Ok(false);
|
|
815
|
-
}
|
|
816
|
-
Ok(self.state.lock().unwrap().session_present)
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
fn list_windows(&self, _session: &SessionName) -> Result<Vec<WindowName>, TransportError> {
|
|
820
|
-
let state = self.state.lock().unwrap();
|
|
821
|
-
if !state.session_present {
|
|
822
|
-
return Ok(Vec::new());
|
|
823
|
-
}
|
|
824
|
-
let mut windows = BTreeSet::new();
|
|
825
|
-
for pane in state.panes.values() {
|
|
826
|
-
if let Some(window) = pane.window_name.as_ref() {
|
|
827
|
-
windows.insert(window.clone());
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
Ok(windows.into_iter().collect())
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
fn set_session_env(
|
|
834
|
-
&self,
|
|
835
|
-
_session: &SessionName,
|
|
836
|
-
_key: &str,
|
|
837
|
-
_value: &str,
|
|
838
|
-
) -> Result<SetEnvOutcome, TransportError> {
|
|
839
|
-
Ok(SetEnvOutcome::Applied)
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
fn kill_session(&self, _session: &SessionName) -> Result<(), TransportError> {
|
|
843
|
-
let mut state = self.state.lock().unwrap();
|
|
844
|
-
state.session_present = false;
|
|
845
|
-
state.panes.clear();
|
|
846
|
-
Ok(())
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
fn kill_window(&self, target: &Target) -> Result<(), TransportError> {
|
|
850
|
-
if let Target::Pane(pane) = target {
|
|
851
|
-
self.state.lock().unwrap().panes.remove(pane.as_str());
|
|
852
|
-
}
|
|
853
|
-
Ok(())
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
-
fn attach_session(&self, _session: &SessionName) -> Result<AttachOutcome, TransportError> {
|
|
857
|
-
Ok(AttachOutcome::Attached)
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
fn has_overlap(calls: &[&SpawnCall]) -> bool {
|
|
862
|
-
calls.iter().enumerate().any(|(index, left)| {
|
|
863
|
-
calls
|
|
864
|
-
.iter()
|
|
865
|
-
.skip(index + 1)
|
|
866
|
-
.any(|right| left.start < right.end && right.start < left.end)
|
|
867
|
-
})
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
fn inject_wrong_outcome_index(state: &mut Value, left: &str, right: &str) {
|
|
871
|
-
swap_persisted_pane_ids(
|
|
872
|
-
state
|
|
873
|
-
.get_mut("agents")
|
|
874
|
-
.and_then(Value::as_object_mut)
|
|
875
|
-
.expect("wrong-index injection requires persisted agents"),
|
|
876
|
-
left,
|
|
877
|
-
right,
|
|
878
|
-
);
|
|
879
|
-
swap_persisted_pane_ids(
|
|
880
|
-
state
|
|
881
|
-
.pointer_mut(&format!("/teams/{TEAM}/agents"))
|
|
882
|
-
.and_then(Value::as_object_mut)
|
|
883
|
-
.expect("wrong-index injection requires team projection agents"),
|
|
884
|
-
left,
|
|
885
|
-
right,
|
|
886
|
-
);
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
fn swap_persisted_pane_ids(agents: &mut serde_json::Map<String, Value>, left: &str, right: &str) {
|
|
890
|
-
let left_pane = agents
|
|
891
|
-
.get(left)
|
|
892
|
-
.and_then(|agent| agent.get("pane_id"))
|
|
893
|
-
.cloned()
|
|
894
|
-
.expect("wrong-index injection left pane");
|
|
895
|
-
let right_pane = agents
|
|
896
|
-
.get(right)
|
|
897
|
-
.and_then(|agent| agent.get("pane_id"))
|
|
898
|
-
.cloned()
|
|
899
|
-
.expect("wrong-index injection right pane");
|
|
900
|
-
agents
|
|
901
|
-
.get_mut(left)
|
|
902
|
-
.and_then(Value::as_object_mut)
|
|
903
|
-
.expect("wrong-index injection left agent")
|
|
904
|
-
.insert("pane_id".to_string(), right_pane);
|
|
905
|
-
agents
|
|
906
|
-
.get_mut(right)
|
|
907
|
-
.and_then(Value::as_object_mut)
|
|
908
|
-
.expect("wrong-index injection right agent")
|
|
909
|
-
.insert("pane_id".to_string(), left_pane);
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
fn identity_tuple_violations(
|
|
913
|
-
state: &Value,
|
|
914
|
-
panes: &[Value],
|
|
915
|
-
expected_agents: &[String],
|
|
916
|
-
) -> Vec<String> {
|
|
917
|
-
let mut violations = Vec::new();
|
|
918
|
-
let persisted_session = state
|
|
919
|
-
.get("session_name")
|
|
920
|
-
.and_then(Value::as_str)
|
|
921
|
-
.unwrap_or("<missing-session>");
|
|
922
|
-
let persisted_tuples = expected_agents
|
|
923
|
-
.iter()
|
|
924
|
-
.filter_map(|worker| {
|
|
925
|
-
let agent = state.pointer(&format!("/agents/{worker}"))?;
|
|
926
|
-
Some((
|
|
927
|
-
worker.clone(),
|
|
928
|
-
agent
|
|
929
|
-
.get("pane_id")
|
|
930
|
-
.and_then(Value::as_str)
|
|
931
|
-
.unwrap_or("<missing-pane>")
|
|
932
|
-
.to_string(),
|
|
933
|
-
persisted_session.to_string(),
|
|
934
|
-
))
|
|
935
|
-
})
|
|
936
|
-
.collect::<BTreeSet<_>>();
|
|
937
|
-
let transport_tuples = panes
|
|
938
|
-
.iter()
|
|
939
|
-
.map(|pane| {
|
|
940
|
-
(
|
|
941
|
-
pane.get("window")
|
|
942
|
-
.and_then(Value::as_str)
|
|
943
|
-
.unwrap_or("<missing-window>")
|
|
944
|
-
.to_string(),
|
|
945
|
-
pane.get("pane_id")
|
|
946
|
-
.and_then(Value::as_str)
|
|
947
|
-
.unwrap_or("<missing-pane>")
|
|
948
|
-
.to_string(),
|
|
949
|
-
pane.get("session")
|
|
950
|
-
.and_then(Value::as_str)
|
|
951
|
-
.unwrap_or("<missing-session>")
|
|
952
|
-
.to_string(),
|
|
953
|
-
)
|
|
954
|
-
})
|
|
955
|
-
.collect::<BTreeSet<_>>();
|
|
956
|
-
let transport_windows = transport_tuples
|
|
957
|
-
.iter()
|
|
958
|
-
.map(|(window, _, _)| window.clone())
|
|
959
|
-
.collect::<BTreeSet<_>>();
|
|
960
|
-
let transport_pane_ids = transport_tuples
|
|
961
|
-
.iter()
|
|
962
|
-
.map(|(_, pane_id, _)| pane_id.clone())
|
|
963
|
-
.collect::<BTreeSet<_>>();
|
|
964
|
-
let expected_set = expected_agents.iter().cloned().collect::<BTreeSet<_>>();
|
|
965
|
-
|
|
966
|
-
if transport_windows != expected_set {
|
|
967
|
-
violations.push(format!(
|
|
968
|
-
"transport worker set incomplete or duplicated; expected={expected_set:?} got={transport_windows:?}"
|
|
969
|
-
));
|
|
970
|
-
}
|
|
971
|
-
if transport_pane_ids.len() != expected_agents.len() {
|
|
972
|
-
violations.push(format!(
|
|
973
|
-
"transport pane_id values must be globally unique; expected={} got={} panes={transport_pane_ids:?}",
|
|
974
|
-
expected_agents.len(),
|
|
975
|
-
transport_pane_ids.len()
|
|
976
|
-
));
|
|
977
|
-
}
|
|
978
|
-
if persisted_tuples != transport_tuples {
|
|
979
|
-
violations.push(format!(
|
|
980
|
-
"persisted↔transport identity tuple mismatch (worker/window, pane_id, session); persisted={persisted_tuples:?} transport={transport_tuples:?}"
|
|
981
|
-
));
|
|
982
|
-
}
|
|
983
|
-
violations
|
|
984
|
-
}
|
|
985
|
-
|
|
986
|
-
fn assert_phase_events(events: &[Value], event_kind: &str, expected_phases: &[&str]) {
|
|
987
|
-
let phases = events
|
|
988
|
-
.iter()
|
|
989
|
-
.filter(|event| event_name(event) == Some(event_kind))
|
|
990
|
-
.collect::<Vec<_>>();
|
|
991
|
-
for phase in expected_phases {
|
|
992
|
-
assert!(
|
|
993
|
-
phases
|
|
994
|
-
.iter()
|
|
995
|
-
.any(|event| event.get("phase").and_then(Value::as_str) == Some(*phase)),
|
|
996
|
-
"{event_kind} missing phase `{phase}`; events={events:?}"
|
|
997
|
-
);
|
|
998
|
-
}
|
|
999
|
-
let mut last = 0;
|
|
1000
|
-
for event in phases {
|
|
1001
|
-
let elapsed = event
|
|
1002
|
-
.get("elapsed_ms")
|
|
1003
|
-
.and_then(Value::as_u64)
|
|
1004
|
-
.unwrap_or_else(|| panic!("{event_kind} event missing numeric elapsed_ms: {event}"));
|
|
1005
|
-
assert!(
|
|
1006
|
-
elapsed >= last,
|
|
1007
|
-
"{event_kind} elapsed_ms must be monotonic; previous={last} event={event}"
|
|
1008
|
-
);
|
|
1009
|
-
last = elapsed;
|
|
1010
|
-
}
|
|
1011
|
-
}
|
|
1012
|
-
|
|
1013
|
-
fn assert_worker_spawn_timing_events(events: &[Value], workers: &[String], source: &str) {
|
|
1014
|
-
for worker in workers {
|
|
1015
|
-
let event = events
|
|
1016
|
-
.iter()
|
|
1017
|
-
.find(|event| {
|
|
1018
|
-
event_name(event) == Some("worker.spawn_timing")
|
|
1019
|
-
&& event.get("agent_id").and_then(Value::as_str) == Some(worker.as_str())
|
|
1020
|
-
&& event.get("source").and_then(Value::as_str) == Some(source)
|
|
1021
|
-
})
|
|
1022
|
-
.unwrap_or_else(|| {
|
|
1023
|
-
panic!("worker.spawn_timing missing for {source}:{worker}; events={events:?}")
|
|
1024
|
-
});
|
|
1025
|
-
for field in [
|
|
1026
|
-
"elapsed_ms",
|
|
1027
|
-
"command_plan_ms",
|
|
1028
|
-
"transport_spawn_ms",
|
|
1029
|
-
"pane_verify_ms",
|
|
1030
|
-
"startup_prompt_handler_ms",
|
|
1031
|
-
] {
|
|
1032
|
-
assert!(
|
|
1033
|
-
event.get(field).and_then(Value::as_u64).is_some(),
|
|
1034
|
-
"worker.spawn_timing {source}:{worker} missing numeric {field}; event={event}"
|
|
1035
|
-
);
|
|
1036
|
-
}
|
|
1037
|
-
assert!(
|
|
1038
|
-
event
|
|
1039
|
-
.get("tmux_start_mode")
|
|
1040
|
-
.and_then(Value::as_str)
|
|
1041
|
-
.is_some(),
|
|
1042
|
-
"worker.spawn_timing {source}:{worker} must carry tmux_start_mode; event={event}"
|
|
1043
|
-
);
|
|
1044
|
-
}
|
|
1045
|
-
}
|
|
1046
|
-
|
|
1047
|
-
fn assert_no_fake_ready_events(events: &[Value]) {
|
|
1048
|
-
let forbidden = events
|
|
1049
|
-
.iter()
|
|
1050
|
-
.filter_map(event_name)
|
|
1051
|
-
.filter(|name| {
|
|
1052
|
-
matches!(
|
|
1053
|
-
*name,
|
|
1054
|
-
"provider.ready" | "provider.prompt_ready" | "provider.fake_ready"
|
|
1055
|
-
)
|
|
1056
|
-
})
|
|
1057
|
-
.collect::<Vec<_>>();
|
|
1058
|
-
assert!(
|
|
1059
|
-
forbidden.is_empty(),
|
|
1060
|
-
"latency instrumentation must not invent provider ready/fake-ready events for recording transport; forbidden={forbidden:?} events={events:?}"
|
|
1061
|
-
);
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
fn event_name(event: &Value) -> Option<&str> {
|
|
1065
|
-
event.get("event").and_then(Value::as_str)
|
|
1066
|
-
}
|