@team-agent/installer 0.5.128 → 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 +4 -4
- package/README.zh.md +1 -1
- package/package.json +4 -8
- package/skills/team-agent/SKILL.md +37 -20
- package/skills/team-agent/command-coverage.json +169 -183
- package/skills/team-agent/docs/reference/team-agent-operator.md +64 -30
- package/skills/team-agent/references/recovery-runbook.md +1 -1
- package/skills/team-agent/references/team-agent-operator.md +64 -30
- 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 -1288
- package/crates/team-agent/src/cli/arguments.rs +0 -405
- package/crates/team-agent/src/cli/attach_app_server_leader.rs +0 -98
- package/crates/team-agent/src/cli/diagnose.rs +0 -1721
- package/crates/team-agent/src/cli/emit.rs +0 -2930
- 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 -1216
- package/crates/team-agent/src/cli/intent/runtime_tests.rs +0 -912
- package/crates/team-agent/src/cli/intent/tests.rs +0 -689
- 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 -6545
- package/crates/team-agent/src/cli/models.rs +0 -1206
- 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/schedule.rs +0 -175
- 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 -156
- 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 -199
- package/crates/team-agent/src/cli/shutdown_socket.rs +0 -288
- package/crates/team-agent/src/cli/spec.rs +0 -165
- 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 -1981
- 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 -322
- 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 -761
- package/crates/team-agent/src/cli/tests/parser_safety.rs +0 -383
- package/crates/team-agent/src/cli/tests/run_delegation.rs +0 -484
- 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 -888
- 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 -827
- package/crates/team-agent/src/compiler.rs +0 -890
- 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 -1744
- package/crates/team-agent/src/contract_runtime/commands.rs +0 -671
- package/crates/team-agent/src/contract_runtime/config.rs +0 -364
- package/crates/team-agent/src/contract_runtime/config_tests.rs +0 -76
- package/crates/team-agent/src/contract_runtime/discovery.rs +0 -449
- package/crates/team-agent/src/contract_runtime/fork.rs +0 -361
- package/crates/team-agent/src/contract_runtime/forward.rs +0 -288
- package/crates/team-agent/src/contract_runtime/framework.rs +0 -367
- package/crates/team-agent/src/contract_runtime/mcp.rs +0 -394
- 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 -553
- 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 -300
- 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 -503
- 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 -3024
- 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 -1527
- 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/direct_delivery.rs +0 -368
- 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/inbox_store.rs +0 -169
- 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 -888
- package/crates/team-agent/src/leader/start.rs +0 -4501
- 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 -268
- 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 -147
- package/crates/team-agent/src/lifecycle/helpers.rs +0 -212
- package/crates/team-agent/src/lifecycle/launch/add_agent.rs +0 -881
- package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +0 -598
- package/crates/team-agent/src/lifecycle/launch/agent_state.rs +0 -332
- package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +0 -204
- package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +0 -107
- package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +0 -144
- 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 -160
- package/crates/team-agent/src/lifecycle/launch/ownership.rs +0 -105
- package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +0 -899
- package/crates/team-agent/src/lifecycle/launch/pi_mcp_extension.js +0 -225
- package/crates/team-agent/src/lifecycle/launch/plan.rs +0 -269
- package/crates/team-agent/src/lifecycle/launch/quick_start.rs +0 -5200
- 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 -473
- 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 -557
- 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 -1067
- package/crates/team-agent/src/lifecycle/profile_smoke.rs +0 -557
- package/crates/team-agent/src/lifecycle/restart/agent.rs +0 -2199
- package/crates/team-agent/src/lifecycle/restart/avatar.rs +0 -1798
- package/crates/team-agent/src/lifecycle/restart/claude_fork.rs +0 -163
- package/crates/team-agent/src/lifecycle/restart/common.rs +0 -2362
- 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 -227
- package/crates/team-agent/src/lifecycle/role_config.rs +0 -1230
- 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_compatible_config_red.rs +0 -325
- package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +0 -447
- package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +0 -1638
- 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 -770
- package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +0 -419
- package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +0 -2035
- package/crates/team-agent/src/lifecycle/tests/core.rs +0 -1327
- 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 -72
- 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 -512
- 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 -3983
- 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 -164
- package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +0 -200
- package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +0 -210
- package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +0 -527
- package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +0 -1062
- package/crates/team-agent/src/lifecycle/tests/pi_fork_session_inheritance_red.rs +0 -1419
- package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +0 -98
- package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +0 -550
- package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +0 -226
- package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +0 -332
- 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 -342
- 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 -995
- package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +0 -836
- package/crates/team-agent/src/lifecycle/tests.rs +0 -105
- package/crates/team-agent/src/lifecycle/types.rs +0 -877
- package/crates/team-agent/src/lifecycle/worker_command_context.rs +0 -363
- 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 -527
- package/crates/team-agent/src/mcp_server/readiness_tests.rs +0 -348
- 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 -158
- package/crates/team-agent/src/mcp_server/tests/send.rs +0 -353
- package/crates/team-agent/src/mcp_server/tests/tools.rs +0 -341
- 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 -889
- 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 -3727
- 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 -336
- 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 -167
- 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/reminders.rs +0 -316
- 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 -223
- 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 -657
- 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 -3549
- package/crates/team-agent/src/messaging/tests/spine.rs +0 -853
- 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 -472
- 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 -1150
- package/crates/team-agent/src/provider/adapters/claude.rs +0 -78
- package/crates/team-agent/src/provider/adapters/claude_fork.rs +0 -131
- 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 -30
- package/crates/team-agent/src/provider/adapters/pi.rs +0 -106
- 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 -708
- 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 -910
- package/crates/team-agent/src/provider/session/capture.rs +0 -2731
- package/crates/team-agent/src/provider/session/context_fork/claude.rs +0 -123
- package/crates/team-agent/src/provider/session/context_fork/outcome.rs +0 -172
- package/crates/team-agent/src/provider/session/context_fork.rs +0 -396
- 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/claude.rs +0 -523
- package/crates/team-agent/src/provider/session_scan/common/tests.rs +0 -316
- package/crates/team-agent/src/provider/session_scan/common.rs +0 -654
- package/crates/team-agent/src/provider/session_scan/copilot.rs +0 -280
- package/crates/team-agent/src/provider/session_scan/pi.rs +0 -185
- package/crates/team-agent/src/provider/session_scan.rs +0 -71
- 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 -441
- package/crates/team-agent/src/provider/tests/classify.rs +0 -148
- package/crates/team-agent/src/provider/tests/command_helpers.rs +0 -35
- 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 -177
- 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 -394
- 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/test_support/models_timeout_fixture.rs +0 -144
- 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 -4103
- package/crates/team-agent/src/tmux_backend.rs +0 -4492
- 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,1205 +0,0 @@
|
|
|
1
|
-
use super::lane_ops::assert_legacy_fork_unverified;
|
|
2
|
-
use super::launch_spawn::{
|
|
3
|
-
quick_start_team_dir, restart_ws_two_resumable_workers, seed_healthy_coordinator,
|
|
4
|
-
DELEG_ROLE_ALPHA, DELEG_ROLE_BRAVO, QS_VALID_ROLE,
|
|
5
|
-
};
|
|
6
|
-
use super::*;
|
|
7
|
-
use crate::transport::test_support::OfflineTransport;
|
|
8
|
-
|
|
9
|
-
/// A no-owner workspace (= self-contained team dir) with a compiled 2-agent spec (alpha, bravo) + state
|
|
10
|
-
/// listing both at `status`. ensure_owner_allowed passes (no team_owner); load_spec finds alpha/bravo.
|
|
11
|
-
pub(super) fn lanea_team_ws(status: &str) -> PathBuf {
|
|
12
|
-
let ws = temp_ws().join("laneateam");
|
|
13
|
-
std::fs::create_dir_all(ws.join("agents")).unwrap();
|
|
14
|
-
std::fs::write(
|
|
15
|
-
ws.join("TEAM.md"),
|
|
16
|
-
"---\nname: laneateam\nobjective: Lane A probe.\nprovider: codex\n---\n\nteam.\n",
|
|
17
|
-
)
|
|
18
|
-
.unwrap();
|
|
19
|
-
std::fs::write(ws.join("agents").join("alpha.md"), DELEG_ROLE_ALPHA).unwrap();
|
|
20
|
-
std::fs::write(ws.join("agents").join("bravo.md"), DELEG_ROLE_BRAVO).unwrap();
|
|
21
|
-
let spec = crate::compiler::compile_team(&ws).expect("compile lane-A team");
|
|
22
|
-
// Re-point routing/tasks at the STAYING agent `bravo` so removing `alpha` validates cleanly (golden
|
|
23
|
-
// remove_agent removes from agents+startup_order then validate_spec raises on dangling refs — a routed
|
|
24
|
-
// agent is not removable in golden; alpha here stands in for an unrouted/dynamic worker). See lanea_ws_agents.
|
|
25
|
-
let yaml = crate::model::yaml::dumps(&spec)
|
|
26
|
-
.replace("default_assignee: \"alpha\"", "default_assignee: \"bravo\"")
|
|
27
|
-
.replace("assign_to: \"alpha\"", "assign_to: \"bravo\"")
|
|
28
|
-
.replace("assignee: \"alpha\"", "assignee: \"bravo\"");
|
|
29
|
-
assert!(
|
|
30
|
-
!yaml.contains("default_assignee: \"alpha\""),
|
|
31
|
-
"fixture unroute: default_assignee still alpha"
|
|
32
|
-
);
|
|
33
|
-
assert!(
|
|
34
|
-
!yaml.contains("assign_to: \"alpha\""),
|
|
35
|
-
"fixture unroute: a routing rule still assign_to alpha"
|
|
36
|
-
);
|
|
37
|
-
assert!(
|
|
38
|
-
!yaml.contains("assignee: \"alpha\""),
|
|
39
|
-
"fixture unroute: task still assignee alpha"
|
|
40
|
-
);
|
|
41
|
-
std::fs::write(ws.join("team.spec.yaml"), yaml).unwrap();
|
|
42
|
-
crate::state::persist::save_runtime_state(
|
|
43
|
-
&ws,
|
|
44
|
-
&json!({
|
|
45
|
-
"session_name": "team-laneateam",
|
|
46
|
-
"agents": {
|
|
47
|
-
"alpha": {"status": status, "provider": "fake", "window": "alpha"},
|
|
48
|
-
"bravo": {"status": status, "provider": "fake", "window": "bravo"}
|
|
49
|
-
}
|
|
50
|
-
}),
|
|
51
|
-
)
|
|
52
|
-
.unwrap();
|
|
53
|
-
ws
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// A-31 RED: a stale pane must not be treated as a live seat merely because its
|
|
57
|
-
// old window name still exists. The assertion is on the physical spawn record,
|
|
58
|
-
// not on start-agent's success-shaped return value.
|
|
59
|
-
#[test]
|
|
60
|
-
fn start_agent_pane_dead_must_not_noop_on_live_window() {
|
|
61
|
-
let ws = restart_ws_two_resumable_workers();
|
|
62
|
-
let mut state = crate::state::persist::load_runtime_state(&ws).unwrap();
|
|
63
|
-
state["agents"]["alpha"]["pane_id"] = json!("%dead");
|
|
64
|
-
state["agents"]["alpha"]["stale"] = json!(true);
|
|
65
|
-
state["agents"]["alpha"]["stale_reason"] = json!("pane_dead");
|
|
66
|
-
crate::state::persist::save_runtime_state(&ws, &state).unwrap();
|
|
67
|
-
|
|
68
|
-
let transport = OfflineTransport::new()
|
|
69
|
-
.with_session_present(true)
|
|
70
|
-
.with_windows(vec![crate::transport::WindowName::new("alpha")])
|
|
71
|
-
.with_pane_presence("%dead", false)
|
|
72
|
-
.with_liveness("%dead", crate::transport::PaneLiveness::Dead);
|
|
73
|
-
let _ = start_agent_with_transport(
|
|
74
|
-
&ws,
|
|
75
|
-
&aid("alpha"),
|
|
76
|
-
false,
|
|
77
|
-
false,
|
|
78
|
-
false,
|
|
79
|
-
None,
|
|
80
|
-
&transport,
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
assert!(
|
|
84
|
-
!transport.spawn_records().is_empty(),
|
|
85
|
-
"A-31: pane_dead must trigger a physical respawn even when the stale window remains; asserting only the command's success-shaped return would miss the Noop bug"
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// A-31 RED: a live pane from another session is not this agent's live seat.
|
|
90
|
-
// The assertion is on the physical spawn record, not on start-agent's
|
|
91
|
-
// success-shaped return value.
|
|
92
|
-
#[test]
|
|
93
|
-
fn start_agent_foreign_live_pane_must_respawn_for_intended_window() {
|
|
94
|
-
let ws = restart_ws_two_resumable_workers();
|
|
95
|
-
let mut state = crate::state::persist::load_runtime_state(&ws).unwrap();
|
|
96
|
-
state["agents"]["alpha"]["pane_id"] = json!("%foreign");
|
|
97
|
-
crate::state::persist::save_runtime_state(&ws, &state).unwrap();
|
|
98
|
-
|
|
99
|
-
let foreign = crate::transport::PaneInfo {
|
|
100
|
-
pane_id: crate::transport::PaneId::new("%foreign"),
|
|
101
|
-
session: crate::transport::SessionName::new("foreign-session"),
|
|
102
|
-
window_index: None,
|
|
103
|
-
window_name: Some(crate::transport::WindowName::new("foreign-window")),
|
|
104
|
-
pane_index: None,
|
|
105
|
-
tty: None,
|
|
106
|
-
current_command: None,
|
|
107
|
-
current_path: None,
|
|
108
|
-
active: true,
|
|
109
|
-
pane_pid: None,
|
|
110
|
-
leader_env: std::collections::BTreeMap::new(),
|
|
111
|
-
};
|
|
112
|
-
let transport = OfflineTransport::new()
|
|
113
|
-
.with_session_present(true)
|
|
114
|
-
.with_windows(vec![crate::transport::WindowName::new("alpha")])
|
|
115
|
-
.with_targets(vec![foreign])
|
|
116
|
-
.with_pane_presence("%foreign", true)
|
|
117
|
-
.with_liveness("%foreign", crate::transport::PaneLiveness::Live);
|
|
118
|
-
let _ = start_agent_with_transport(
|
|
119
|
-
&ws,
|
|
120
|
-
&aid("alpha"),
|
|
121
|
-
false,
|
|
122
|
-
false,
|
|
123
|
-
false,
|
|
124
|
-
None,
|
|
125
|
-
&transport,
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
assert!(
|
|
129
|
-
!transport.spawn_records().is_empty(),
|
|
130
|
-
"A-31: a physically live pane owned by another session must trigger a physical respawn for alpha; start-agent must not Noop on foreign pane %foreign"
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// A-35 mirror RED: an ownership query failure is missing evidence, not proof
|
|
135
|
-
// that the cached live pane is foreign. start-agent must retain the base
|
|
136
|
-
// conservative Noop direction and leave retry authority to the operator.
|
|
137
|
-
#[test]
|
|
138
|
-
fn start_agent_transport_ownership_query_failure_must_not_respawn_live_pane() {
|
|
139
|
-
let ws = restart_ws_two_resumable_workers();
|
|
140
|
-
let mut state = crate::state::persist::load_runtime_state(&ws).unwrap();
|
|
141
|
-
state["agents"]["alpha"]["pane_id"] = json!("%transport-error");
|
|
142
|
-
state["agents"]["alpha"]["stale"] = json!(false);
|
|
143
|
-
state["agents"]["alpha"]["stale_reason"] = serde_json::Value::Null;
|
|
144
|
-
crate::state::persist::save_runtime_state(&ws, &state).unwrap();
|
|
145
|
-
|
|
146
|
-
let transport = OfflineTransport::new()
|
|
147
|
-
.with_session_present(true)
|
|
148
|
-
.with_windows(vec![crate::transport::WindowName::new("alpha")])
|
|
149
|
-
.with_pane_presence("%transport-error", true)
|
|
150
|
-
.with_liveness("%transport-error", crate::transport::PaneLiveness::Live)
|
|
151
|
-
.with_list_targets_error("simulated tmux snapshot failure");
|
|
152
|
-
let _ = start_agent_with_transport(
|
|
153
|
-
&ws,
|
|
154
|
-
&aid("alpha"),
|
|
155
|
-
false,
|
|
156
|
-
false,
|
|
157
|
-
false,
|
|
158
|
-
None,
|
|
159
|
-
&transport,
|
|
160
|
-
);
|
|
161
|
-
|
|
162
|
-
assert!(
|
|
163
|
-
transport.spawn_records().is_empty(),
|
|
164
|
-
"A-35 mirror: list_targets failure is missing ownership evidence, not proof of a foreign/dead pane; a physically live cached pane must not trigger a duplicate spawn"
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// A-31 guard RED: an explicit pane_dead reason remains positive death
|
|
169
|
-
// evidence even when the persisted pane tuple is absent.
|
|
170
|
-
#[test]
|
|
171
|
-
fn start_agent_pane_dead_reason_must_respawn_without_cached_pane_id() {
|
|
172
|
-
let ws = restart_ws_two_resumable_workers();
|
|
173
|
-
let mut state = crate::state::persist::load_runtime_state(&ws).unwrap();
|
|
174
|
-
let agent = state["agents"]["alpha"].as_object_mut().unwrap();
|
|
175
|
-
agent.remove("pane_id");
|
|
176
|
-
agent.insert("stale".to_string(), json!(true));
|
|
177
|
-
agent.insert("stale_reason".to_string(), json!("pane_dead"));
|
|
178
|
-
crate::state::persist::save_runtime_state(&ws, &state).unwrap();
|
|
179
|
-
|
|
180
|
-
let transport = OfflineTransport::new()
|
|
181
|
-
.with_session_present(true)
|
|
182
|
-
.with_windows(vec![crate::transport::WindowName::new("alpha")]);
|
|
183
|
-
let _ = start_agent_with_transport(
|
|
184
|
-
&ws,
|
|
185
|
-
&aid("alpha"),
|
|
186
|
-
false,
|
|
187
|
-
false,
|
|
188
|
-
false,
|
|
189
|
-
None,
|
|
190
|
-
&transport,
|
|
191
|
-
);
|
|
192
|
-
|
|
193
|
-
assert!(
|
|
194
|
-
!transport.spawn_records().is_empty(),
|
|
195
|
-
"A-31 guard: stale_reason=pane_dead is positive death evidence and must trigger a physical respawn even when no cached pane_id remains"
|
|
196
|
-
);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// remove_agent [P0] — from_spec + force on a NON-running agent atomically removes it from state.agents
|
|
200
|
-
// (golden agents.py: pop agents[agent_id] + save). Pure fs/state (non-running -> no stop/tmux). Today the
|
|
201
|
-
// stub returns OwnerRefused and removes nothing -> RED.
|
|
202
|
-
#[test]
|
|
203
|
-
fn lanea_remove_agent_from_spec_force_removes_from_state() {
|
|
204
|
-
let ws = lanea_team_ws("stopped"); // non-running -> the running+force stop branch is skipped (no tmux)
|
|
205
|
-
let _ = remove_agent(&ws, &aid("alpha"), true, true, None); // from_spec=true, force=true
|
|
206
|
-
let state = crate::state::persist::load_runtime_state(&ws).expect("load state");
|
|
207
|
-
let agents = state.get("agents").and_then(serde_json::Value::as_object);
|
|
208
|
-
assert!(
|
|
209
|
-
agents.is_some_and(|a| !a.contains_key("alpha")),
|
|
210
|
-
"remove_agent(from_spec, force) must atomically remove 'alpha' from state.agents (golden agents.py); \
|
|
211
|
-
the stub returns OwnerRefused and removes nothing; state.agents={agents:?}"
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
// remove_agent [P1] — a RUNNING agent removed without --force is RefusedForceRequired (golden
|
|
216
|
-
// agents.py:56; _is_running is status-based for status in {running,busy} -> no tmux). Today the stub
|
|
217
|
-
// returns OwnerRefused (a different, wrong refusal) -> RED.
|
|
218
|
-
#[test]
|
|
219
|
-
fn lanea_remove_agent_running_without_force_is_refused_force_required() {
|
|
220
|
-
let ws = lanea_team_ws("running"); // alpha is running (status-based _is_running -> true, no tmux)
|
|
221
|
-
match remove_agent(&ws, &aid("alpha"), true, false, None) {
|
|
222
|
-
Ok(RemoveAgentOutcome::RefusedForceRequired { agent_id }) => assert_eq!(agent_id, aid("alpha")),
|
|
223
|
-
other => panic!(
|
|
224
|
-
"a RUNNING agent removed without --force must be RefusedForceRequired (golden agents.py:56); \
|
|
225
|
-
the stub returns OwnerRefused; got {other:?}"
|
|
226
|
-
),
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
// stop_agent [P0] — an UNKNOWN agent id (past the owner gate) raises "unknown worker agent id: <id>"
|
|
231
|
-
// (golden operations.py:73), NOT OwnerRefused. The owner gate passes on a no-owner ws, then _find_agent
|
|
232
|
-
// fails. The check precedes any tmux. Today the stub returns OwnerRefused (never loads the spec) -> RED.
|
|
233
|
-
#[test]
|
|
234
|
-
fn lanea_stop_agent_unknown_agent_is_unknown_worker_not_owner_refused() {
|
|
235
|
-
let ws = lanea_team_ws("stopped");
|
|
236
|
-
let text = format!("{:?}", stop_agent(&ws, &aid("ghost"), None));
|
|
237
|
-
assert!(
|
|
238
|
-
text.contains("unknown worker"),
|
|
239
|
-
"stop_agent past the owner gate must raise 'unknown worker agent id: ghost' for an unknown agent \
|
|
240
|
-
(golden operations.py:73), not OwnerRefused; got {text}"
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
// fork_agent [P0] — precedence: an UNKNOWN source is rejected as "unknown worker agent id" BEFORE the
|
|
245
|
-
// source-session-id check (golden operations.py:284-25). Today the stub always returns "source session_id
|
|
246
|
-
// is missing" (never loads the spec) -> RED.
|
|
247
|
-
#[test]
|
|
248
|
-
fn lanea_fork_agent_unknown_source_is_unknown_worker_before_session_check() {
|
|
249
|
-
let ws = lanea_team_ws("stopped");
|
|
250
|
-
let text = format!(
|
|
251
|
-
"{:?}",
|
|
252
|
-
fork_agent(&ws, &aid("ghost"), &aid("newfork"), None, false, None)
|
|
253
|
-
);
|
|
254
|
-
assert!(
|
|
255
|
-
text.contains("unknown worker"),
|
|
256
|
-
"fork_agent must reject an UNKNOWN source as 'unknown worker agent id: ghost' BEFORE the session-id \
|
|
257
|
-
check (golden precedence); the stub returns 'source session_id is missing'; got {text}"
|
|
258
|
-
);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
// fork_agent [P0] — precedence: a DUPLICATE fork-target id is rejected as "agent id already exists" BEFORE
|
|
262
|
-
// the source-session-id check (golden operations.py:284-19, the FIRST guard). Today the stub returns
|
|
263
|
-
// "source session_id is missing" -> RED.
|
|
264
|
-
#[test]
|
|
265
|
-
fn lanea_fork_agent_duplicate_target_is_already_exists_before_session_check() {
|
|
266
|
-
let ws = lanea_team_ws("stopped");
|
|
267
|
-
// target 'bravo' already exists in the spec -> duplicate; source 'alpha' exists (its session_id is irrelevant).
|
|
268
|
-
// The legacy fork entry refuses the fake source as unverified; duplicate --as is not reached.
|
|
269
|
-
let result = fork_agent(&ws, &aid("alpha"), &aid("bravo"), None, false, None);
|
|
270
|
-
assert_legacy_fork_unverified(&result, "fake");
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
// SEAM-GATED real-machine boundary (note to porter): stop_agent / reset_agent / fork_agent must drive a
|
|
274
|
-
// transport (kill_window / re-spawn / native-fork spawn). The porter adds stop_agent_with_transport /
|
|
275
|
-
// reset_agent_with_transport / fork_agent_with_transport(.., &dyn Transport) (mirror restart_with_transport)
|
|
276
|
-
// so kill_window / spawn are assertable in-process via a recording transport. Until then the PUBLIC fns
|
|
277
|
-
// hit real tmux -> #[ignore]. This documents the stop_agent kill_window + mark-stopped observable.
|
|
278
|
-
#[test]
|
|
279
|
-
#[ignore = "real-machine: stop_agent kills the real tmux window. PORTER SEAM: stop_agent_with_transport(.., \
|
|
280
|
-
&dyn Transport) so kill_window(session:window) + agents[a].status='stopped' is assertable in-process."]
|
|
281
|
-
fn lanea_stop_agent_kills_window_and_marks_stopped() {
|
|
282
|
-
let ws = lanea_team_ws("running");
|
|
283
|
-
let _ = stop_agent(&ws, &aid("alpha"), None); // real machine: tmux kill-window team-laneateam:alpha
|
|
284
|
-
let state = crate::state::persist::load_runtime_state(&ws).expect("load state");
|
|
285
|
-
let status = state
|
|
286
|
-
.pointer("/agents/alpha/status")
|
|
287
|
-
.and_then(serde_json::Value::as_str);
|
|
288
|
-
assert_eq!(
|
|
289
|
-
status,
|
|
290
|
-
Some("stopped"),
|
|
291
|
-
"stop_agent must mark agents[alpha].status='stopped' after killing the window"
|
|
292
|
-
);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
// ═════════════════════════════════════════════════════════════════════════
|
|
296
|
-
// rt-host-a P1 — `add-agent w2` recompiles + spawns w2 but does NOT JOIN it to the LIVE team: (a) the
|
|
297
|
-
// running roster (state.agents at team_workspace) stays ['w1'] — add_agent upserts w2 into the team-DIR
|
|
298
|
-
// workspace, not the running workspace; (b) w2 is spawned detached / not spawn_into the existing team
|
|
299
|
-
// session. Coordinator can't deliver to w2 -> `send w2` never round-trips. Golden lifecycle/operations.py:
|
|
300
|
-
// add_agent -> start_agent(allow_fresh) spawns INTO the team session + the agent is in runtime state.
|
|
301
|
-
// ═════════════════════════════════════════════════════════════════════════
|
|
302
|
-
|
|
303
|
-
// RED — add_agent_with_transport over a seeded RUNNING team must JOIN w2: (1) the RUNNING roster
|
|
304
|
-
// (load_runtime_state(team_workspace)) gains "w2", AND (2) the transport records a spawn_INTO (not
|
|
305
|
-
// spawn_first) so w2 joins the existing team session. Today the roster stays ['w1'] (w2 written to the
|
|
306
|
-
// wrong workspace) and start_agent_with_transport is a stub (zero spawns) -> RED. OS-safe: recording
|
|
307
|
-
// transport (no real tmux) + seeded-healthy-coordinator (start_coordinator AlreadyRunning).
|
|
308
|
-
#[test]
|
|
309
|
-
fn add_agent_joins_w2_into_running_roster_and_existing_session() {
|
|
310
|
-
let team_dir = quick_start_team_dir(QS_VALID_ROLE); // <base>/teamdir (agents/implementer.md)
|
|
311
|
-
let workspace = team_dir
|
|
312
|
-
.parent()
|
|
313
|
-
.expect("team_workspace(team_dir) = parent"); // the RUNNING team's workspace
|
|
314
|
-
// a RUNNING team already in the session (roster = ['w1'], session_name set).
|
|
315
|
-
crate::state::persist::save_runtime_state(
|
|
316
|
-
workspace,
|
|
317
|
-
&json!({
|
|
318
|
-
"session_name": "team-implteam",
|
|
319
|
-
"agents": {"w1": {"status": "running", "provider": "fake", "window": "w1"}}
|
|
320
|
-
}),
|
|
321
|
-
)
|
|
322
|
-
.unwrap();
|
|
323
|
-
seed_healthy_coordinator(workspace); // start_coordinator -> AlreadyRunning (no real daemon)
|
|
324
|
-
// the new agent's role file, OUTSIDE agents/ so it's not a duplicate of an existing agent.
|
|
325
|
-
let role_file = team_dir.join("w2-role.md");
|
|
326
|
-
std::fs::write(
|
|
327
|
-
&role_file,
|
|
328
|
-
"---\nname: w2\nrole: Worker Two\nprovider: fake\nmodel: fake\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nWorker two.\n",
|
|
329
|
-
)
|
|
330
|
-
.unwrap();
|
|
331
|
-
let transport = OfflineTransport::new().with_session_present(true);
|
|
332
|
-
|
|
333
|
-
let _ = add_agent_with_transport(
|
|
334
|
-
team_dir.as_path(),
|
|
335
|
-
&aid("w2"),
|
|
336
|
-
&role_file,
|
|
337
|
-
false,
|
|
338
|
-
None,
|
|
339
|
-
&transport,
|
|
340
|
-
);
|
|
341
|
-
|
|
342
|
-
// (1) [load-bearing] the RUNNING roster (team_workspace) must now contain w2.
|
|
343
|
-
let state = crate::state::persist::load_runtime_state(workspace).expect("load running state");
|
|
344
|
-
assert!(
|
|
345
|
-
state.pointer("/agents/w2").is_some(),
|
|
346
|
-
"add-agent must JOIN w2 to the RUNNING roster (state.agents at team_workspace); today w2 is upserted \
|
|
347
|
-
into the team-DIR workspace, not the running workspace, so the roster stays ['w1'] and the \
|
|
348
|
-
coordinator can't deliver to w2; running agents={:?}",
|
|
349
|
-
state.get("agents")
|
|
350
|
-
);
|
|
351
|
-
// (2) w2 must spawn_INTO the existing team session (not a detached/new session via spawn_first).
|
|
352
|
-
let recorded = transport.spawn_records();
|
|
353
|
-
assert!(
|
|
354
|
-
recorded.iter().any(|(kind, _)| kind == "spawn_into"),
|
|
355
|
-
"add-agent must spawn w2 INTO the existing team session (spawn_into); today start_agent_with_transport \
|
|
356
|
-
is a stub -> ZERO spawns recorded; got {recorded:?}"
|
|
357
|
-
);
|
|
358
|
-
assert!(
|
|
359
|
-
!recorded.iter().any(|(kind, _)| kind == "spawn_first"),
|
|
360
|
-
"w2 must NOT create a NEW session (spawn_first) — that's the detached-spawn bug; got {recorded:?}"
|
|
361
|
-
);
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
#[derive(Clone)]
|
|
365
|
-
struct SocketRecordingRunner {
|
|
366
|
-
recorded: std::sync::Arc<std::sync::Mutex<Vec<Vec<String>>>>,
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
impl crate::tmux_backend::CommandRunner for SocketRecordingRunner {
|
|
370
|
-
fn run(&self, argv: &[String]) -> Result<crate::tmux_backend::CommandOutput, std::io::Error> {
|
|
371
|
-
self.recorded.lock().unwrap().push(argv.to_vec());
|
|
372
|
-
Ok(crate::tmux_backend::CommandOutput {
|
|
373
|
-
success: true,
|
|
374
|
-
code: Some(0),
|
|
375
|
-
stdout: String::new(),
|
|
376
|
-
stderr: String::new(),
|
|
377
|
-
})
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
fn socket_for_workspace(workspace: &std::path::Path) -> String {
|
|
382
|
-
use crate::transport::Transport as _;
|
|
383
|
-
let recorded = std::sync::Arc::new(std::sync::Mutex::new(Vec::new()));
|
|
384
|
-
let runner = SocketRecordingRunner {
|
|
385
|
-
recorded: std::sync::Arc::clone(&recorded),
|
|
386
|
-
};
|
|
387
|
-
let backend =
|
|
388
|
-
crate::tmux_backend::TmuxBackend::with_runner_for_workspace(Box::new(runner), workspace);
|
|
389
|
-
backend.has_session(&sess("team-implteam")).unwrap();
|
|
390
|
-
let socket = recorded.lock().unwrap()[0][2].clone();
|
|
391
|
-
socket
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
// BUG A / CP-1: public lifecycle handlers such as stop_agent receive either the run workspace or
|
|
395
|
-
// the team dir, but the daemon is bound to the run workspace socket. A team-dir raw for_workspace
|
|
396
|
-
// derives a different -L socket and makes stop_agent silently see no windows.
|
|
397
|
-
#[test]
|
|
398
|
-
fn bug_a_team_dir_lifecycle_socket_matches_daemon_run_workspace_socket() {
|
|
399
|
-
let run_ws = temp_ws();
|
|
400
|
-
std::fs::create_dir_all(crate::model::paths::runtime_dir(&run_ws)).unwrap();
|
|
401
|
-
let team_dir = run_ws.join("agents");
|
|
402
|
-
std::fs::create_dir_all(&team_dir).unwrap();
|
|
403
|
-
|
|
404
|
-
let daemon_socket = socket_for_workspace(&run_ws);
|
|
405
|
-
let lifecycle_ws = crate::lifecycle::restart::lifecycle_run_workspace(&team_dir).unwrap();
|
|
406
|
-
let stop_socket = socket_for_workspace(&lifecycle_ws);
|
|
407
|
-
assert_eq!(
|
|
408
|
-
stop_socket, daemon_socket,
|
|
409
|
-
"team-dir lifecycle ops must derive the same -L socket as the daemon run workspace"
|
|
410
|
-
);
|
|
411
|
-
assert_ne!(
|
|
412
|
-
socket_for_workspace(&team_dir),
|
|
413
|
-
daemon_socket,
|
|
414
|
-
"regression guard: raw team_dir for_workspace is the buggy socket"
|
|
415
|
-
);
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
#[test]
|
|
419
|
-
#[ignore = "real-machine: stop_agent with a team-dir input kills an existing worker window on the daemon -L socket"]
|
|
420
|
-
fn bug_a_stop_agent_team_dir_input_kills_existing_window_real_machine() {
|
|
421
|
-
let team_dir = quick_start_team_dir(QS_VALID_ROLE);
|
|
422
|
-
let report = stop_agent(&team_dir, &aid("w1"), None).expect("real stop-agent");
|
|
423
|
-
assert!(
|
|
424
|
-
report.stopped,
|
|
425
|
-
"existing worker window must be killed, not silently reported absent"
|
|
426
|
-
);
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
struct EnvVarGuard {
|
|
430
|
-
key: &'static str,
|
|
431
|
-
previous: Option<String>,
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
impl EnvVarGuard {
|
|
435
|
-
fn set(key: &'static str, value: &str) -> Self {
|
|
436
|
-
let previous = std::env::var(key).ok();
|
|
437
|
-
unsafe {
|
|
438
|
-
std::env::set_var(key, value);
|
|
439
|
-
}
|
|
440
|
-
Self { key, previous }
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
impl Drop for EnvVarGuard {
|
|
445
|
-
fn drop(&mut self) {
|
|
446
|
-
unsafe {
|
|
447
|
-
if let Some(value) = self.previous.take() {
|
|
448
|
-
std::env::set_var(self.key, value);
|
|
449
|
-
} else {
|
|
450
|
-
std::env::remove_var(self.key);
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
#[cfg(unix)]
|
|
457
|
-
struct TmuxShim {
|
|
458
|
-
log: std::path::PathBuf,
|
|
459
|
-
_path: EnvVarGuard,
|
|
460
|
-
_log: EnvVarGuard,
|
|
461
|
-
_endpoint: EnvVarGuard,
|
|
462
|
-
_session: EnvVarGuard,
|
|
463
|
-
_pane: EnvVarGuard,
|
|
464
|
-
_real_tmux: EnvVarGuard,
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
#[cfg(unix)]
|
|
468
|
-
fn install_e27_tmux_shim(expected_endpoint: &str, session_name: &str) -> TmuxShim {
|
|
469
|
-
use std::os::unix::fs::PermissionsExt;
|
|
470
|
-
|
|
471
|
-
let root = temp_ws().join("e27_tmux_shim");
|
|
472
|
-
let bin = root.join("bin");
|
|
473
|
-
std::fs::create_dir_all(&bin).unwrap();
|
|
474
|
-
let log = root.join("tmux-argv.log");
|
|
475
|
-
let tmux = bin.join("tmux");
|
|
476
|
-
let real_tmux = std::process::Command::new("sh")
|
|
477
|
-
.arg("-lc")
|
|
478
|
-
.arg("command -v tmux || true")
|
|
479
|
-
.output()
|
|
480
|
-
.ok()
|
|
481
|
-
.and_then(|out| String::from_utf8(out.stdout).ok())
|
|
482
|
-
.map(|s| s.trim().to_string())
|
|
483
|
-
.filter(|s| !s.is_empty())
|
|
484
|
-
.unwrap_or_default();
|
|
485
|
-
std::fs::write(
|
|
486
|
-
&tmux,
|
|
487
|
-
r#"#!/bin/sh
|
|
488
|
-
set -eu
|
|
489
|
-
log="${TEAM_AGENT_E27_TMUX_LOG}"
|
|
490
|
-
expected="${TEAM_AGENT_E27_EXPECTED_ENDPOINT}"
|
|
491
|
-
session="${TEAM_AGENT_E27_SESSION_NAME}"
|
|
492
|
-
pane="${TEAM_AGENT_E27_PANE_ID}"
|
|
493
|
-
killed_marker="${log}.killed"
|
|
494
|
-
spawned_marker="${log}.spawned"
|
|
495
|
-
anchor_marker="${log}.anchor"
|
|
496
|
-
track=0
|
|
497
|
-
case "$*" in
|
|
498
|
-
*"$expected"*|*"$session"*|*"$pane"*) track=1 ;;
|
|
499
|
-
esac
|
|
500
|
-
if [ "$track" != 1 ]; then
|
|
501
|
-
if [ -n "${TEAM_AGENT_E27_REAL_TMUX}" ]; then
|
|
502
|
-
exec "${TEAM_AGENT_E27_REAL_TMUX}" "$@"
|
|
503
|
-
fi
|
|
504
|
-
exit 127
|
|
505
|
-
fi
|
|
506
|
-
# 0.5.39 Slice 2: worker spawn now goes through the worker shell
|
|
507
|
-
# wrapper (tmux-server-death-locate §7 Slice 2), which embeds a
|
|
508
|
-
# printf format literal containing "\n" bytes so the pane retains an
|
|
509
|
-
# inert sh tail with an explicit exit marker instead of collapsing to
|
|
510
|
-
# `[exited]`. Those embedded newlines land inside the
|
|
511
|
-
# tmux argv payload, so a naive `printf '%s\n' "$*"` writes multiple
|
|
512
|
-
# lines per tmux invocation and downstream `raw.lines()` scans see
|
|
513
|
-
# fake "argv" lines that carry only the marker text. Escape newlines
|
|
514
|
-
# to a literal `\n` marker so one shim call = one log line = one
|
|
515
|
-
# assertion target.
|
|
516
|
-
printf '%s\n' "$*" | awk 'BEGIN{ORS=""} {print sep $0; sep="\\n"} END{print "\n"}' >> "$log"
|
|
517
|
-
case "$*" in
|
|
518
|
-
*"-S $expected"*) ;;
|
|
519
|
-
*)
|
|
520
|
-
echo "missing expected socket $expected: $*" >&2
|
|
521
|
-
exit 18
|
|
522
|
-
;;
|
|
523
|
-
esac
|
|
524
|
-
# 0.4.10+ reset-gate fix: track kill-pane so the next display-message
|
|
525
|
-
# probe reports the pane as gone. The reset hard gate calls has_pane
|
|
526
|
-
# after stop_agent_at_paths returns; a shim that always reports the
|
|
527
|
-
# original pane as live would trip the gate.
|
|
528
|
-
case "$*" in
|
|
529
|
-
*"kill-pane -t $pane"*)
|
|
530
|
-
: > "$killed_marker"
|
|
531
|
-
exit 0
|
|
532
|
-
;;
|
|
533
|
-
esac
|
|
534
|
-
case "$*" in
|
|
535
|
-
*"list-panes -s -t =$session -F"*)
|
|
536
|
-
if [ -f "$anchor_marker" ]; then
|
|
537
|
-
printf '%%9299\t[team-agent keepalive]\n'
|
|
538
|
-
fi
|
|
539
|
-
if [ ! -f "$killed_marker" ]; then
|
|
540
|
-
printf '%s\talpha\n' "$pane"
|
|
541
|
-
fi
|
|
542
|
-
if [ -f "$spawned_marker" ]; then
|
|
543
|
-
printf '%%9288\talpha\n'
|
|
544
|
-
fi
|
|
545
|
-
exit 0
|
|
546
|
-
;;
|
|
547
|
-
*"new-window "*"[team-agent keepalive]"*)
|
|
548
|
-
: > "$anchor_marker"
|
|
549
|
-
printf '%%9299\n'
|
|
550
|
-
exit 0
|
|
551
|
-
;;
|
|
552
|
-
*"new-window "*|*"new-session "*)
|
|
553
|
-
: > "$spawned_marker"
|
|
554
|
-
printf '%%9288\n'
|
|
555
|
-
exit 0
|
|
556
|
-
;;
|
|
557
|
-
*"display-message -p -t $pane #{pane_id}"*)
|
|
558
|
-
if [ -f "$killed_marker" ]; then
|
|
559
|
-
echo "can't find pane: $pane" >&2
|
|
560
|
-
exit 1
|
|
561
|
-
fi
|
|
562
|
-
printf '%s\n' "$pane"
|
|
563
|
-
exit 0
|
|
564
|
-
;;
|
|
565
|
-
*"list-windows -t $session -F #{window_name}"*)
|
|
566
|
-
exit 0
|
|
567
|
-
;;
|
|
568
|
-
*"list-panes -a -F"*)
|
|
569
|
-
if [ -f "$spawned_marker" ]; then
|
|
570
|
-
printf '%%9288\t%s\t0\talpha\t0\t/dev/ttys099\tnode\t1\t/tmp\t1\t0\t9288\n' "$session"
|
|
571
|
-
exit 0
|
|
572
|
-
fi
|
|
573
|
-
# Hard-gate post-stop snapshot: no residual same-role panes after kill.
|
|
574
|
-
if [ -f "$killed_marker" ]; then
|
|
575
|
-
exit 0
|
|
576
|
-
fi
|
|
577
|
-
exit 0
|
|
578
|
-
;;
|
|
579
|
-
*"has-session -t $session"*)
|
|
580
|
-
exit 0
|
|
581
|
-
;;
|
|
582
|
-
*)
|
|
583
|
-
exit 0
|
|
584
|
-
;;
|
|
585
|
-
esac
|
|
586
|
-
"#,
|
|
587
|
-
)
|
|
588
|
-
.unwrap();
|
|
589
|
-
let mut perms = std::fs::metadata(&tmux).unwrap().permissions();
|
|
590
|
-
perms.set_mode(0o755);
|
|
591
|
-
std::fs::set_permissions(&tmux, perms).unwrap();
|
|
592
|
-
let old_path = std::env::var("PATH").unwrap_or_default();
|
|
593
|
-
TmuxShim {
|
|
594
|
-
log: log.clone(),
|
|
595
|
-
_path: EnvVarGuard::set("PATH", &format!("{}:{old_path}", bin.display())),
|
|
596
|
-
_log: EnvVarGuard::set("TEAM_AGENT_E27_TMUX_LOG", &log.to_string_lossy()),
|
|
597
|
-
_endpoint: EnvVarGuard::set("TEAM_AGENT_E27_EXPECTED_ENDPOINT", expected_endpoint),
|
|
598
|
-
_session: EnvVarGuard::set("TEAM_AGENT_E27_SESSION_NAME", session_name),
|
|
599
|
-
_pane: EnvVarGuard::set("TEAM_AGENT_E27_PANE_ID", "%9277"),
|
|
600
|
-
_real_tmux: EnvVarGuard::set("TEAM_AGENT_E27_REAL_TMUX", &real_tmux),
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
fn seed_e27_attached_socket_state(ws: &std::path::Path, endpoint: &str, session_name: &str) {
|
|
605
|
-
let mut state = crate::state::persist::load_runtime_state(ws).unwrap();
|
|
606
|
-
let obj = state.as_object_mut().unwrap();
|
|
607
|
-
obj.insert("session_name".to_string(), json!(session_name));
|
|
608
|
-
obj.insert("tmux_endpoint".to_string(), json!(endpoint));
|
|
609
|
-
obj.insert("tmux_socket".to_string(), json!(endpoint));
|
|
610
|
-
let alpha = obj
|
|
611
|
-
.get_mut("agents")
|
|
612
|
-
.and_then(serde_json::Value::as_object_mut)
|
|
613
|
-
.and_then(|agents| agents.get_mut("alpha"))
|
|
614
|
-
.and_then(serde_json::Value::as_object_mut)
|
|
615
|
-
.unwrap();
|
|
616
|
-
alpha.insert("status".to_string(), json!("running"));
|
|
617
|
-
alpha.insert("provider".to_string(), json!("fake"));
|
|
618
|
-
alpha.insert("window".to_string(), json!("alpha"));
|
|
619
|
-
alpha.insert("pane_id".to_string(), json!("%9277"));
|
|
620
|
-
alpha.insert("session_id".to_string(), json!("old-session"));
|
|
621
|
-
crate::state::persist::save_runtime_state(ws, &state).unwrap();
|
|
622
|
-
seed_healthy_coordinator(ws);
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
fn assert_only_expected_socket_used(log: &std::path::Path, expected_endpoint: &str) {
|
|
626
|
-
let raw = std::fs::read_to_string(log).unwrap();
|
|
627
|
-
assert!(!raw.is_empty(), "tmux shim was not invoked");
|
|
628
|
-
assert!(
|
|
629
|
-
!raw.contains("-L ta-"),
|
|
630
|
-
"lifecycle worker operation must not use workspace-derived -L ta-* socket; argv log:\n{raw}"
|
|
631
|
-
);
|
|
632
|
-
for line in raw.lines() {
|
|
633
|
-
assert!(
|
|
634
|
-
line.contains(&format!("-S {expected_endpoint}")),
|
|
635
|
-
"tmux argv must use state endpoint {expected_endpoint}; got line {line:?}; full log:\n{raw}"
|
|
636
|
-
);
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
// 0.5.x Windows portability Batch 5: E27 tests use a shell-script
|
|
641
|
-
// tmux shim + Unix socket paths. Unix-only.
|
|
642
|
-
#[cfg(unix)]
|
|
643
|
-
#[test]
|
|
644
|
-
#[serial_test::serial(env)]
|
|
645
|
-
fn e27_stop_agent_uses_attached_explicit_state_socket() {
|
|
646
|
-
let endpoint = "/tmp/loop13-e27-explicit.sock";
|
|
647
|
-
let session_name = "team-e27-explicit-stop";
|
|
648
|
-
let ws = lanea_team_ws("running");
|
|
649
|
-
seed_e27_attached_socket_state(&ws, endpoint, session_name);
|
|
650
|
-
let shim = install_e27_tmux_shim(endpoint, session_name);
|
|
651
|
-
|
|
652
|
-
let report = stop_agent(&ws, &aid("alpha"), None).expect("stop-agent");
|
|
653
|
-
|
|
654
|
-
assert!(
|
|
655
|
-
report.stopped,
|
|
656
|
-
"attached explicit-socket worker should be stopped"
|
|
657
|
-
);
|
|
658
|
-
assert_only_expected_socket_used(&shim.log, endpoint);
|
|
659
|
-
let raw = std::fs::read_to_string(&shim.log).unwrap();
|
|
660
|
-
assert!(raw.contains(&format!("list-panes -s -t ={session_name}")));
|
|
661
|
-
assert!(raw.contains("set-window-option -t %9299 remain-on-exit on"));
|
|
662
|
-
assert!(raw.contains("respawn-pane -k -t %9299 exit 0"));
|
|
663
|
-
let state = crate::state::persist::load_runtime_state(&ws).unwrap();
|
|
664
|
-
assert_eq!(
|
|
665
|
-
state
|
|
666
|
-
.pointer("/agents/alpha/status")
|
|
667
|
-
.and_then(serde_json::Value::as_str),
|
|
668
|
-
Some("stopped")
|
|
669
|
-
);
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
#[cfg(unix)]
|
|
673
|
-
#[test]
|
|
674
|
-
#[serial_test::serial(env)]
|
|
675
|
-
fn e27_reset_agent_uses_attached_explicit_state_socket_for_stop_and_spawn() {
|
|
676
|
-
let endpoint = "/tmp/loop13-e27-explicit.sock";
|
|
677
|
-
let session_name = "team-e27-explicit-reset";
|
|
678
|
-
let ws = lanea_team_ws("running");
|
|
679
|
-
seed_e27_attached_socket_state(&ws, endpoint, session_name);
|
|
680
|
-
let shim = install_e27_tmux_shim(endpoint, session_name);
|
|
681
|
-
|
|
682
|
-
let outcome = reset_agent(&ws, &aid("alpha"), true, false, None).expect("reset-agent");
|
|
683
|
-
|
|
684
|
-
assert!(
|
|
685
|
-
matches!(outcome, ResetAgentOutcome::Reset { .. }),
|
|
686
|
-
"reset-agent should complete over attached explicit socket; got {outcome:?}"
|
|
687
|
-
);
|
|
688
|
-
assert_only_expected_socket_used(&shim.log, endpoint);
|
|
689
|
-
let raw = std::fs::read_to_string(&shim.log).unwrap();
|
|
690
|
-
assert!(
|
|
691
|
-
raw.contains("kill-pane"),
|
|
692
|
-
"reset must stop the old pane first; argv log:\n{raw}"
|
|
693
|
-
);
|
|
694
|
-
assert!(
|
|
695
|
-
raw.contains("new-window") || raw.contains("new-session"),
|
|
696
|
-
"reset must respawn the worker through the same endpoint; argv log:\n{raw}"
|
|
697
|
-
);
|
|
698
|
-
let state = crate::state::persist::load_runtime_state(&ws).unwrap();
|
|
699
|
-
assert_ne!(
|
|
700
|
-
state
|
|
701
|
-
.pointer("/agents/alpha/session_id")
|
|
702
|
-
.and_then(serde_json::Value::as_str),
|
|
703
|
-
Some("old-session"),
|
|
704
|
-
"discard-session must not preserve the old session id"
|
|
705
|
-
);
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
#[cfg(unix)]
|
|
709
|
-
#[test]
|
|
710
|
-
#[serial_test::serial(env)]
|
|
711
|
-
fn e27_stop_agent_expands_short_state_socket_name() {
|
|
712
|
-
let short = "ta-loop13-e27-short";
|
|
713
|
-
let session_name = "team-e27-short-stop";
|
|
714
|
-
let expected = crate::tmux_backend::socket_path_for_name(short)
|
|
715
|
-
.unwrap()
|
|
716
|
-
.to_string_lossy()
|
|
717
|
-
.to_string();
|
|
718
|
-
let ws = lanea_team_ws("running");
|
|
719
|
-
seed_e27_attached_socket_state(&ws, short, session_name);
|
|
720
|
-
let shim = install_e27_tmux_shim(&expected, session_name);
|
|
721
|
-
|
|
722
|
-
let report = stop_agent(&ws, &aid("alpha"), None).expect("stop-agent short endpoint");
|
|
723
|
-
|
|
724
|
-
assert!(report.stopped, "short endpoint worker should be stopped");
|
|
725
|
-
assert_only_expected_socket_used(&shim.log, &expected);
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
// ═════════════════════════════════════════════════════════════════════════
|
|
729
|
-
// WAVE-2 · LANE A v2 — DEEPENED byte-parity REDs (stop / reset / remove / fork).
|
|
730
|
-
//
|
|
731
|
-
// The shallow 5 lanea_ tests pass, but the port is NOT byte-parity. /tmp/lanea_blockers.json caught
|
|
732
|
-
// 15 CONFIRMED blockers + 2 warns. These lock the GOLDEN observable for each.
|
|
733
|
-
// Golden (truth source): lifecycle/operations.py (stop:62 / reset:102 / fork:284),
|
|
734
|
-
// lifecycle/agents.py (remove:22 + _RemoveRollback + _is_running + _find_worker),
|
|
735
|
-
// runtime.py:1023 _tmux_window_exists, display/close.py (close_ghostty_workspace_slot:51).
|
|
736
|
-
//
|
|
737
|
-
// Transport-driven via LaneTransport (records kill_window + spawns; list_windows/list_targets answer
|
|
738
|
-
// from a configurable window set = golden's _tmux_window_exists primitive). OS-safe (no real tmux;
|
|
739
|
-
// seeded-healthy coordinator where start_coordinator is reached). Rollback-internal bits that need a
|
|
740
|
-
// production failure-injection seam (agent_health re-upsert; fork post-spawn arms) are #[ignore]
|
|
741
|
-
|
|
742
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
743
|
-
// Wave3 EVENT PAYLOAD BYTE-LOCK — lifecycle verbs must write golden's events.jsonl payloads.
|
|
744
|
-
// events.jsonl = json.dumps({ts, event, **fields}, sort_keys=True) (event_log.rs:4 / golden events.py:35)
|
|
745
|
-
// → byte form has ALPHABETICALLY-sorted keys (NOT insertion order; that is state.json's rule). So the
|
|
746
|
-
// byte-lock = event name + field KEY SET + field VALUES (ts is a live timestamp → tolerated; order is
|
|
747
|
-
// sort_keys-deterministic given keys+values). Rust restart/remove.rs + restart/agent.rs write ZERO
|
|
748
|
-
// lifecycle events (crate-wide grep: the names exist in types.rs but are never emitted) -> RED.
|
|
749
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
750
|
-
|
|
751
|
-
// Read every events.jsonl the verb could write to (run-workspace resolves to either the team dir or its
|
|
752
|
-
// parent; read both so the lock is robust to that resolution).
|
|
753
|
-
fn lifecycle_events(ws: &std::path::Path) -> Vec<serde_json::Value> {
|
|
754
|
-
let mut out = crate::event_log::EventLog::new(ws)
|
|
755
|
-
.tail(0)
|
|
756
|
-
.unwrap_or_default();
|
|
757
|
-
if let Ok(parent) = crate::model::paths::team_workspace(ws) {
|
|
758
|
-
if parent != ws {
|
|
759
|
-
out.extend(
|
|
760
|
-
crate::event_log::EventLog::new(&parent)
|
|
761
|
-
.tail(0)
|
|
762
|
-
.unwrap_or_default(),
|
|
763
|
-
);
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
out
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
fn payload_keys(event: &serde_json::Value) -> std::collections::BTreeSet<String> {
|
|
770
|
-
event
|
|
771
|
-
.as_object()
|
|
772
|
-
.map(|o| {
|
|
773
|
-
o.keys()
|
|
774
|
-
.filter(|k| *k != "ts" && *k != "event")
|
|
775
|
-
.cloned()
|
|
776
|
-
.collect()
|
|
777
|
-
})
|
|
778
|
-
.unwrap_or_default()
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
fn find_event<'a>(events: &'a [serde_json::Value], name: &str) -> Option<&'a serde_json::Value> {
|
|
782
|
-
events
|
|
783
|
-
.iter()
|
|
784
|
-
.find(|e| e.get("event").and_then(|v| v.as_str()) == Some(name))
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
fn names(events: &[serde_json::Value]) -> Vec<String> {
|
|
788
|
-
events
|
|
789
|
-
.iter()
|
|
790
|
-
.filter_map(|e| {
|
|
791
|
-
e.get("event")
|
|
792
|
-
.and_then(|v| v.as_str())
|
|
793
|
-
.map(ToString::to_string)
|
|
794
|
-
})
|
|
795
|
-
.collect()
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
// remove-agent — golden agents.py:66-147 writes lifecycle.remove_step_completed (per step) +
|
|
799
|
-
// remove_agent.complete. (stopped agent + from_spec + force: no stop step, pure fs/state, no spawn.)
|
|
800
|
-
#[test]
|
|
801
|
-
fn remove_agent_emits_golden_lifecycle_event_payloads() {
|
|
802
|
-
let ws = lanea_team_ws("stopped");
|
|
803
|
-
let _ = remove_agent(&ws, &aid("alpha"), true, true, None); // from_spec=true, force=true
|
|
804
|
-
let events = lifecycle_events(&ws);
|
|
805
|
-
|
|
806
|
-
// remove_agent.complete (golden agents.py:140-147) — EXACT field key set + load-bearing values.
|
|
807
|
-
let complete = find_event(&events, "remove_agent.complete").unwrap_or_else(|| panic!(
|
|
808
|
-
"remove_agent must write `remove_agent.complete` (golden agents.py:140); Rust restart/remove.rs emits NO \
|
|
809
|
-
events. events seen: {:?}", names(&events)
|
|
810
|
-
));
|
|
811
|
-
let expected: std::collections::BTreeSet<String> = [
|
|
812
|
-
"agent_id",
|
|
813
|
-
"from_spec",
|
|
814
|
-
"force",
|
|
815
|
-
"stopped",
|
|
816
|
-
"role_file_removed",
|
|
817
|
-
"cleared_locations",
|
|
818
|
-
]
|
|
819
|
-
.iter()
|
|
820
|
-
.map(ToString::to_string)
|
|
821
|
-
.collect();
|
|
822
|
-
assert_eq!(
|
|
823
|
-
payload_keys(complete),
|
|
824
|
-
expected,
|
|
825
|
-
"remove_agent.complete payload key set must match golden agents.py:140-147; got {:?}",
|
|
826
|
-
payload_keys(complete)
|
|
827
|
-
);
|
|
828
|
-
assert_eq!(
|
|
829
|
-
complete.get("agent_id").and_then(|v| v.as_str()),
|
|
830
|
-
Some("alpha")
|
|
831
|
-
);
|
|
832
|
-
assert_eq!(
|
|
833
|
-
complete.get("from_spec").and_then(|v| v.as_bool()),
|
|
834
|
-
Some(true)
|
|
835
|
-
);
|
|
836
|
-
assert_eq!(complete.get("force").and_then(|v| v.as_bool()), Some(true));
|
|
837
|
-
|
|
838
|
-
// lifecycle.remove_step_completed (golden agents.py:66-72) — fired per step; key set {agent_id, step,
|
|
839
|
-
// resource}; the workspace_state + agent_health steps fire for a stopped from_spec remove.
|
|
840
|
-
let step_events: Vec<&serde_json::Value> = events
|
|
841
|
-
.iter()
|
|
842
|
-
.filter(|e| {
|
|
843
|
-
e.get("event").and_then(|v| v.as_str()) == Some("lifecycle.remove_step_completed")
|
|
844
|
-
})
|
|
845
|
-
.collect();
|
|
846
|
-
let steps: Vec<&str> = step_events
|
|
847
|
-
.iter()
|
|
848
|
-
.filter_map(|e| e.get("step").and_then(|v| v.as_str()))
|
|
849
|
-
.collect();
|
|
850
|
-
assert!(steps.contains(&"workspace_state") && steps.contains(&"agent_health"),
|
|
851
|
-
"remove_agent must write lifecycle.remove_step_completed for each step (golden agents.py:86,109); got steps {steps:?}");
|
|
852
|
-
let ws_step = step_events
|
|
853
|
-
.iter()
|
|
854
|
-
.find(|e| e.get("step").and_then(|v| v.as_str()) == Some("workspace_state"))
|
|
855
|
-
.expect("the workspace_state step event");
|
|
856
|
-
let expected_step: std::collections::BTreeSet<String> = ["agent_id", "step", "resource"]
|
|
857
|
-
.iter()
|
|
858
|
-
.map(ToString::to_string)
|
|
859
|
-
.collect();
|
|
860
|
-
assert_eq!(payload_keys(ws_step), expected_step,
|
|
861
|
-
"lifecycle.remove_step_completed (non-stop step) payload must be EXACTLY {{agent_id, step, resource}} (golden agents.py:68-70)");
|
|
862
|
-
assert_eq!(
|
|
863
|
-
ws_step.get("resource").and_then(|v| v.as_str()),
|
|
864
|
-
Some("state.json:agents"),
|
|
865
|
-
"workspace_state step resource == golden 'state.json:agents' (agents.py:82)"
|
|
866
|
-
);
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
// reset-agent — golden operations.py:123/132 writes discard.session_tombstone {agent_id,
|
|
870
|
-
// discarded_session_id} + reset_agent.complete {agent_id, stopped, started}. OfflineTransport (no spawn).
|
|
871
|
-
#[test]
|
|
872
|
-
fn reset_agent_emits_golden_lifecycle_event_payloads() {
|
|
873
|
-
let ws = lanea_team_ws("running");
|
|
874
|
-
// give alpha a stored session so discard.session_tombstone.discarded_session_id is meaningful (golden operations.py:118).
|
|
875
|
-
let mut state = crate::state::persist::load_runtime_state(&ws).unwrap();
|
|
876
|
-
state["agents"]["alpha"]["session_id"] = json!("S-alpha");
|
|
877
|
-
crate::state::persist::save_runtime_state(&ws, &state).unwrap();
|
|
878
|
-
|
|
879
|
-
let transport = OfflineTransport::new().with_session_present(true);
|
|
880
|
-
let _ = crate::lifecycle::reset_agent_with_transport(
|
|
881
|
-
&ws,
|
|
882
|
-
&aid("alpha"),
|
|
883
|
-
true,
|
|
884
|
-
false,
|
|
885
|
-
None,
|
|
886
|
-
&transport,
|
|
887
|
-
);
|
|
888
|
-
let events = lifecycle_events(&ws);
|
|
889
|
-
|
|
890
|
-
// discard.session_tombstone (golden operations.py:123) — EXACT key set + the discarded session id.
|
|
891
|
-
let tombstone = find_event(&events, "discard.session_tombstone").unwrap_or_else(|| panic!(
|
|
892
|
-
"reset_agent must write `discard.session_tombstone` (golden operations.py:123); Rust restart/agent.rs emits \
|
|
893
|
-
NO events. events seen: {:?}", names(&events)
|
|
894
|
-
));
|
|
895
|
-
let expected_tomb: std::collections::BTreeSet<String> = ["agent_id", "discarded_session_id"]
|
|
896
|
-
.iter()
|
|
897
|
-
.map(ToString::to_string)
|
|
898
|
-
.collect();
|
|
899
|
-
assert_eq!(payload_keys(tombstone), expected_tomb,
|
|
900
|
-
"discard.session_tombstone payload key set must be EXACTLY {{agent_id, discarded_session_id}} (golden operations.py:123)");
|
|
901
|
-
assert_eq!(
|
|
902
|
-
tombstone.get("agent_id").and_then(|v| v.as_str()),
|
|
903
|
-
Some("alpha")
|
|
904
|
-
);
|
|
905
|
-
assert_eq!(
|
|
906
|
-
tombstone
|
|
907
|
-
.get("discarded_session_id")
|
|
908
|
-
.and_then(|v| v.as_str()),
|
|
909
|
-
Some("S-alpha"),
|
|
910
|
-
"discarded_session_id == the agent's stored session_id (golden operations.py:118)"
|
|
911
|
-
);
|
|
912
|
-
|
|
913
|
-
// reset_agent.complete (golden operations.py:132) — EXACT key set {agent_id, stopped, started}.
|
|
914
|
-
let complete = find_event(&events, "reset_agent.complete").unwrap_or_else(|| panic!(
|
|
915
|
-
"reset_agent must write `reset_agent.complete` (golden operations.py:132); events seen: {:?}", names(&events)
|
|
916
|
-
));
|
|
917
|
-
let expected_complete: std::collections::BTreeSet<String> = ["agent_id", "stopped", "started"]
|
|
918
|
-
.iter()
|
|
919
|
-
.map(ToString::to_string)
|
|
920
|
-
.collect();
|
|
921
|
-
assert_eq!(payload_keys(complete), expected_complete,
|
|
922
|
-
"reset_agent.complete payload key set must be EXACTLY {{agent_id, stopped, started}} (golden operations.py:132)");
|
|
923
|
-
assert_eq!(
|
|
924
|
-
complete.get("agent_id").and_then(|v| v.as_str()),
|
|
925
|
-
Some("alpha")
|
|
926
|
-
);
|
|
927
|
-
}
|
|
928
|
-
|
|
929
|
-
// 0.4.10+ reset duplicate-window fix RED tests
|
|
930
|
-
// (plan §1-§3, CR C-1/C-2/C-5 acceptance).
|
|
931
|
-
|
|
932
|
-
/// Plan §2: stop must resolve a stale pane_id to live same-role panes
|
|
933
|
-
/// and kill them by pane_id. Pre-fix path returned stopped=false when
|
|
934
|
-
/// pane_id was stale even if a residue survived; this lets reset's
|
|
935
|
-
/// unconditional start spawn a duplicate window.
|
|
936
|
-
///
|
|
937
|
-
/// With the fix: stale pane_id + same-role residue → stop enumerates,
|
|
938
|
-
/// kills by pane_id, returns stopped=true. Reset proceeds normally.
|
|
939
|
-
#[test]
|
|
940
|
-
fn reset_agent_stale_pane_with_same_role_residue_kills_by_pane_id() {
|
|
941
|
-
use crate::transport::{PaneId as PaneIdT, PaneInfo, SessionName, WindowName};
|
|
942
|
-
let ws = lanea_team_ws("running");
|
|
943
|
-
let mut state = crate::state::persist::load_runtime_state(&ws).unwrap();
|
|
944
|
-
state["agents"]["alpha"]["pane_id"] = json!("%STALE");
|
|
945
|
-
state["agents"]["alpha"]["window"] = json!("alpha");
|
|
946
|
-
crate::state::persist::save_runtime_state(&ws, &state).unwrap();
|
|
947
|
-
|
|
948
|
-
// Transport: stale %STALE absent; same-role residual %RESIDUAL listed.
|
|
949
|
-
let residual = PaneInfo {
|
|
950
|
-
pane_id: PaneIdT::new("%RESIDUAL"),
|
|
951
|
-
session: SessionName::new("team-laneateam"),
|
|
952
|
-
window_index: Some(0),
|
|
953
|
-
window_name: Some(WindowName::new("alpha")),
|
|
954
|
-
pane_index: None,
|
|
955
|
-
tty: None,
|
|
956
|
-
current_command: None,
|
|
957
|
-
current_path: None,
|
|
958
|
-
active: true,
|
|
959
|
-
pane_pid: None,
|
|
960
|
-
leader_env: std::collections::BTreeMap::new(),
|
|
961
|
-
};
|
|
962
|
-
let transport = OfflineTransport::new()
|
|
963
|
-
.with_session_present(true)
|
|
964
|
-
.with_targets(vec![residual.clone()])
|
|
965
|
-
.with_pane_presence("%STALE", false);
|
|
966
|
-
|
|
967
|
-
// The stop sub-step must enumerate same-role panes and kill %RESIDUAL.
|
|
968
|
-
// The reset overall proceeds (stop.stopped=true → gate skipped).
|
|
969
|
-
let outcome = crate::lifecycle::reset_agent_with_transport(
|
|
970
|
-
&ws,
|
|
971
|
-
&aid("alpha"),
|
|
972
|
-
true,
|
|
973
|
-
false,
|
|
974
|
-
None,
|
|
975
|
-
&transport,
|
|
976
|
-
);
|
|
977
|
-
let outcome_dbg = format!("{outcome:?}");
|
|
978
|
-
// Outcome may be Ok or downstream Err from spawn, but it MUST NOT be
|
|
979
|
-
// the stop-not-proven RequirementUnmet (the gate did not need to fire
|
|
980
|
-
// because stop correctly killed the residue).
|
|
981
|
-
assert!(
|
|
982
|
-
!outcome_dbg.contains("old agent instance still live"),
|
|
983
|
-
"stop must kill stale-pane residue (no stop-not-proven gate \
|
|
984
|
-
trigger); got {outcome_dbg}"
|
|
985
|
-
);
|
|
986
|
-
// The stop_complete event must report stopped=true (residual was killed).
|
|
987
|
-
let events = lifecycle_events(&ws);
|
|
988
|
-
let stop_complete =
|
|
989
|
-
find_event(&events, "stop_agent.complete").expect("stop_agent.complete must be emitted");
|
|
990
|
-
assert_eq!(
|
|
991
|
-
stop_complete.get("stopped").and_then(|v| v.as_bool()),
|
|
992
|
-
Some(true),
|
|
993
|
-
"stop must report stopped=true when same-role residue was killed; \
|
|
994
|
-
got {stop_complete:?}"
|
|
995
|
-
);
|
|
996
|
-
}
|
|
997
|
-
|
|
998
|
-
/// Plan §3 hard gate: structural verification — the helpers exist and
|
|
999
|
-
/// are wired into reset_agent_at_paths. The full race-condition scenario
|
|
1000
|
-
/// (stop returns stopped=false BUT residue appears between stop and
|
|
1001
|
-
/// gate-time list_targets snapshot) requires concurrency the
|
|
1002
|
-
/// OfflineTransport cannot model — the live macmini batch reset
|
|
1003
|
-
/// evidence (.team/evidence/) is the truth source for that race. The
|
|
1004
|
-
/// unit test below verifies the gate code path is reachable + the
|
|
1005
|
-
/// event writer + N38 error text via a synthetic state with a still-live
|
|
1006
|
-
/// stored pane_id that stop's kill_pane targeted but the
|
|
1007
|
-
/// post-stop has_pane re-reads as live (a deterministic mock).
|
|
1008
|
-
#[test]
|
|
1009
|
-
fn reset_agent_stop_not_proven_grep_guard_hard_gate_wired() {
|
|
1010
|
-
let manifest = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
|
|
1011
|
-
let agent_rs = manifest
|
|
1012
|
-
.join("src")
|
|
1013
|
-
.join("lifecycle")
|
|
1014
|
-
.join("restart")
|
|
1015
|
-
.join("agent.rs");
|
|
1016
|
-
let contents = std::fs::read_to_string(&agent_rs).expect("read agent.rs");
|
|
1017
|
-
// Gate must exist with the N38 three-line text and stop_not_proven event.
|
|
1018
|
-
assert!(
|
|
1019
|
-
contents.contains("reset refused: old agent instance still live"),
|
|
1020
|
-
"reset_agent_at_paths must carry the N38 three-line error (CR C-1)"
|
|
1021
|
-
);
|
|
1022
|
-
assert!(
|
|
1023
|
-
contents.contains("write_reset_stop_not_proven_event"),
|
|
1024
|
-
"reset_agent_at_paths must emit reset_agent.stop_not_proven via the writer"
|
|
1025
|
-
);
|
|
1026
|
-
assert!(
|
|
1027
|
-
contents.contains("if !agent_is_paused {"),
|
|
1028
|
-
"gate must run after stop for every non-paused reset, including stop.stopped=true residue"
|
|
1029
|
-
);
|
|
1030
|
-
assert!(
|
|
1031
|
-
contents.contains("list_same_role_panes") && contents.contains("is_per_agent_window"),
|
|
1032
|
-
"stop_agent_at_paths must enumerate same-role panes via the new helpers"
|
|
1033
|
-
);
|
|
1034
|
-
}
|
|
1035
|
-
|
|
1036
|
-
/// Plan §3 hard gate: when no residue (clean stop), reset is allowed to
|
|
1037
|
-
/// proceed to start. Covers the legitimate `stopped=false` case (worker
|
|
1038
|
-
/// already absent — nothing to gate, nothing to refuse).
|
|
1039
|
-
#[test]
|
|
1040
|
-
fn reset_agent_already_absent_can_start() {
|
|
1041
|
-
let ws = lanea_team_ws("stopped");
|
|
1042
|
-
// No stale pane_id, no residual panes — gate is a no-op.
|
|
1043
|
-
let transport = OfflineTransport::new().with_session_present(true);
|
|
1044
|
-
let outcome = crate::lifecycle::reset_agent_with_transport(
|
|
1045
|
-
&ws,
|
|
1046
|
-
&aid("alpha"),
|
|
1047
|
-
true,
|
|
1048
|
-
false,
|
|
1049
|
-
None,
|
|
1050
|
-
&transport,
|
|
1051
|
-
);
|
|
1052
|
-
// The transport is offline so spawn may fail downstream; the contract
|
|
1053
|
-
// for THIS test is that the hard gate did NOT short-circuit to
|
|
1054
|
-
// RequirementUnmet with "old agent instance still live".
|
|
1055
|
-
let outcome_dbg = format!("{outcome:?}");
|
|
1056
|
-
assert!(
|
|
1057
|
-
!outcome_dbg.contains("old agent instance still live"),
|
|
1058
|
-
"reset with no residue must NOT trigger the stop-not-proven gate; \
|
|
1059
|
-
got {outcome_dbg}"
|
|
1060
|
-
);
|
|
1061
|
-
// The stop_not_proven event must NOT be present.
|
|
1062
|
-
let events = lifecycle_events(&ws);
|
|
1063
|
-
assert!(
|
|
1064
|
-
find_event(&events, "reset_agent.stop_not_proven").is_none(),
|
|
1065
|
-
"no reset_agent.stop_not_proven event when nothing to gate; \
|
|
1066
|
-
events seen: {:?}",
|
|
1067
|
-
names(&events)
|
|
1068
|
-
);
|
|
1069
|
-
}
|
|
1070
|
-
|
|
1071
|
-
/// Plan §2 + CR C-5: standalone stop-agent must keep "already absent is
|
|
1072
|
-
/// stopped=false, ok" behavior. The hard gate only runs in reset, not
|
|
1073
|
-
/// in stop-agent. This locks the boundary so the fix does not regress
|
|
1074
|
-
/// existing stop-agent contract.
|
|
1075
|
-
#[test]
|
|
1076
|
-
fn stop_agent_already_absent_still_returns_stopped_false() {
|
|
1077
|
-
let ws = lanea_team_ws("stopped");
|
|
1078
|
-
let transport = OfflineTransport::new().with_session_present(true);
|
|
1079
|
-
let result = crate::lifecycle::stop_agent_with_transport(&ws, &aid("alpha"), None, &transport);
|
|
1080
|
-
let report = result.expect("stop_agent must return Ok for absent agent");
|
|
1081
|
-
assert!(
|
|
1082
|
-
!report.stopped,
|
|
1083
|
-
"stop_agent on already-absent worker returns stopped=false (no \
|
|
1084
|
-
kill, contract preserved); got {report:?}"
|
|
1085
|
-
);
|
|
1086
|
-
}
|
|
1087
|
-
|
|
1088
|
-
// stop-agent — golden operations.py:98 writes stop_agent.complete {agent_id, target, stopped}
|
|
1089
|
-
// (+ stop_agent.window_stop_failed {agent_id, target, stderr} on kill failure). Rust emits none.
|
|
1090
|
-
#[test]
|
|
1091
|
-
fn stop_agent_emits_golden_complete_event_payload() {
|
|
1092
|
-
let ws = lanea_team_ws("running"); // alpha running (window "alpha")
|
|
1093
|
-
let transport = OfflineTransport::new().with_session_present(true);
|
|
1094
|
-
let _ = crate::lifecycle::stop_agent_with_transport(&ws, &aid("alpha"), None, &transport);
|
|
1095
|
-
let events = lifecycle_events(&ws);
|
|
1096
|
-
|
|
1097
|
-
let complete = find_event(&events, "stop_agent.complete").unwrap_or_else(|| panic!(
|
|
1098
|
-
"stop_agent must write `stop_agent.complete` (golden operations.py:98); Rust restart/agent.rs emits NO \
|
|
1099
|
-
events for stop. events seen: {:?}", names(&events)
|
|
1100
|
-
));
|
|
1101
|
-
let expected: std::collections::BTreeSet<String> = ["agent_id", "target", "stopped"]
|
|
1102
|
-
.iter()
|
|
1103
|
-
.map(ToString::to_string)
|
|
1104
|
-
.collect();
|
|
1105
|
-
assert_eq!(payload_keys(complete), expected,
|
|
1106
|
-
"stop_agent.complete payload key set must be EXACTLY {{agent_id, target, stopped}} (golden operations.py:98)");
|
|
1107
|
-
assert_eq!(
|
|
1108
|
-
complete.get("agent_id").and_then(|v| v.as_str()),
|
|
1109
|
-
Some("alpha")
|
|
1110
|
-
);
|
|
1111
|
-
}
|
|
1112
|
-
|
|
1113
|
-
// start-agent — golden start.py:225 writes start_agent.agent_start on the spawn path (9 keys). Rust emits
|
|
1114
|
-
// ONLY start_agent.noop (common.rs:315, for the already-running path); the fresh-spawn path emits nothing.
|
|
1115
|
-
#[test]
|
|
1116
|
-
fn start_agent_emits_golden_agent_start_event_payload() {
|
|
1117
|
-
let ws = lanea_team_ws("stopped"); // not running -> fresh spawn path (not noop)
|
|
1118
|
-
let transport = OfflineTransport::new();
|
|
1119
|
-
let _ = crate::lifecycle::start_agent_with_transport(
|
|
1120
|
-
&ws,
|
|
1121
|
-
&aid("alpha"),
|
|
1122
|
-
true,
|
|
1123
|
-
false,
|
|
1124
|
-
true,
|
|
1125
|
-
None,
|
|
1126
|
-
&transport,
|
|
1127
|
-
);
|
|
1128
|
-
let events = lifecycle_events(&ws);
|
|
1129
|
-
|
|
1130
|
-
let agent_start = find_event(&events, "start_agent.agent_start").unwrap_or_else(|| panic!(
|
|
1131
|
-
"start_agent (fresh-spawn) must write `start_agent.agent_start` (golden start.py:225); Rust emits only \
|
|
1132
|
-
start_agent.noop. events seen: {:?}", names(&events)
|
|
1133
|
-
));
|
|
1134
|
-
let expected: std::collections::BTreeSet<String> = [
|
|
1135
|
-
"agent_id",
|
|
1136
|
-
"provider",
|
|
1137
|
-
"start_mode",
|
|
1138
|
-
"session_id",
|
|
1139
|
-
"session",
|
|
1140
|
-
"window",
|
|
1141
|
-
"tmux_start_mode",
|
|
1142
|
-
"command",
|
|
1143
|
-
"mcp_config",
|
|
1144
|
-
]
|
|
1145
|
-
.iter()
|
|
1146
|
-
.map(ToString::to_string)
|
|
1147
|
-
.collect();
|
|
1148
|
-
assert_eq!(
|
|
1149
|
-
payload_keys(agent_start),
|
|
1150
|
-
expected,
|
|
1151
|
-
"start_agent.agent_start payload key set must match golden start.py:225-235 (9 keys)"
|
|
1152
|
-
);
|
|
1153
|
-
assert_eq!(
|
|
1154
|
-
agent_start.get("agent_id").and_then(|v| v.as_str()),
|
|
1155
|
-
Some("alpha")
|
|
1156
|
-
);
|
|
1157
|
-
assert_eq!(
|
|
1158
|
-
agent_start.get("window").and_then(|v| v.as_str()),
|
|
1159
|
-
Some("alpha"),
|
|
1160
|
-
"agent_start.window == agent_id (golden start.py:232)"
|
|
1161
|
-
);
|
|
1162
|
-
}
|
|
1163
|
-
|
|
1164
|
-
// restart — golden orchestration.py:507 writes ONE restart.resume_decision per non-paused worker
|
|
1165
|
-
// (7 keys, NOTE `worker_id` not `agent_id`). Rust emits no restart events.
|
|
1166
|
-
#[test]
|
|
1167
|
-
fn restart_emits_golden_resume_decision_event_payload() {
|
|
1168
|
-
let ws = lanea_team_ws("running"); // alpha + bravo present -> a resume_decision each
|
|
1169
|
-
let transport = OfflineTransport::new().with_session_present(true);
|
|
1170
|
-
let _ = crate::lifecycle::restart_with_transport(&ws, true, None, &transport);
|
|
1171
|
-
let events = lifecycle_events(&ws);
|
|
1172
|
-
|
|
1173
|
-
let decisions: Vec<&serde_json::Value> = events
|
|
1174
|
-
.iter()
|
|
1175
|
-
.filter(|e| e.get("event").and_then(|v| v.as_str()) == Some("restart.resume_decision"))
|
|
1176
|
-
.collect();
|
|
1177
|
-
assert!(
|
|
1178
|
-
!decisions.is_empty(),
|
|
1179
|
-
"restart must write one `restart.resume_decision` per non-paused worker \
|
|
1180
|
-
(golden orchestration.py:128/507); Rust emits NO restart events. events seen: {:?}",
|
|
1181
|
-
names(&events)
|
|
1182
|
-
);
|
|
1183
|
-
let expected: std::collections::BTreeSet<String> = [
|
|
1184
|
-
"worker_id",
|
|
1185
|
-
"has_first_send_at",
|
|
1186
|
-
"has_session_id",
|
|
1187
|
-
"allow_fresh",
|
|
1188
|
-
"decision",
|
|
1189
|
-
"first_send_at",
|
|
1190
|
-
"session_id",
|
|
1191
|
-
]
|
|
1192
|
-
.iter()
|
|
1193
|
-
.map(ToString::to_string)
|
|
1194
|
-
.collect();
|
|
1195
|
-
assert_eq!(payload_keys(decisions[0]), expected,
|
|
1196
|
-
"restart.resume_decision payload key set must match golden orchestration.py:507-514 (7 keys, `worker_id`)");
|
|
1197
|
-
let worker_ids: Vec<&str> = decisions
|
|
1198
|
-
.iter()
|
|
1199
|
-
.filter_map(|e| e.get("worker_id").and_then(|v| v.as_str()))
|
|
1200
|
-
.collect();
|
|
1201
|
-
assert!(
|
|
1202
|
-
worker_ids.contains(&"alpha") || worker_ids.contains(&"bravo"),
|
|
1203
|
-
"restart.resume_decision.worker_id must name a real worker (golden); got {worker_ids:?}"
|
|
1204
|
-
);
|
|
1205
|
-
}
|