@team-agent/installer 0.5.128 → 0.6.1
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,350 +0,0 @@
|
|
|
1
|
-
//! ---
|
|
2
|
-
//! purpose: workspace 级 agent-lifecycle 互斥锁,让同一 workspace 的席位增删起停串行
|
|
3
|
-
//! contract:
|
|
4
|
-
//! provides:
|
|
5
|
-
//! - name: acquire_agent_lifecycle_lock
|
|
6
|
-
//! what: 轮询抢锁,成功返回持有到 Drop 的 guard,超时返回 LifecycleLockTimeout
|
|
7
|
-
//! - name: agent_lifecycle_lock_path
|
|
8
|
-
//! what: 给出该 workspace 的锁文件路径
|
|
9
|
-
//! depends:
|
|
10
|
-
//! - crate::platform::file_lock
|
|
11
|
-
//! - crate::event_log::EventLog
|
|
12
|
-
//! - crate::model::paths
|
|
13
|
-
//! boundary:
|
|
14
|
-
//! - 不锁 pane 输入通道,那是 pane_input_lock
|
|
15
|
-
//! - 不做跨 workspace 互斥,锁作用域就是一个 workspace
|
|
16
|
-
//! - 拿不到锁只超时报错,不强抢也不清理他人锁文件
|
|
17
|
-
//! - 锁文件内容只作观测用,不作为持有权判据
|
|
18
|
-
//! maturity: wired
|
|
19
|
-
//! ---
|
|
20
|
-
use std::io::{Seek, Write};
|
|
21
|
-
use std::path::{Path, PathBuf};
|
|
22
|
-
use std::time::{Duration, Instant};
|
|
23
|
-
|
|
24
|
-
use crate::lifecycle::types::LifecycleError;
|
|
25
|
-
use crate::model::ids::AgentId;
|
|
26
|
-
|
|
27
|
-
pub(crate) const AGENT_LIFECYCLE_LOCK_NAME: &str = "agent-lifecycle";
|
|
28
|
-
pub(crate) const LIFECYCLE_LOCK_TIMEOUT: Duration = Duration::from_secs(30);
|
|
29
|
-
pub(crate) const LIFECYCLE_LOCK_HELD_LONG: Duration = Duration::from_secs(5);
|
|
30
|
-
|
|
31
|
-
pub(crate) struct LifecycleLockRequest<'a> {
|
|
32
|
-
pub workspace: &'a Path,
|
|
33
|
-
pub operation: &'static str,
|
|
34
|
-
pub team: Option<&'a str>,
|
|
35
|
-
pub agent_id: Option<&'a AgentId>,
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
pub(crate) struct LifecycleLockGuard {
|
|
39
|
-
file: std::fs::File,
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/// ---
|
|
43
|
-
/// purpose: 抢 workspace 级 agent-lifecycle 锁,默认 30 秒超时、5 秒起写 lock_held_long 事件
|
|
44
|
-
/// params:
|
|
45
|
-
/// request: 携带 workspace、操作名与可选 team/agent,仅用于锁元数据与事件
|
|
46
|
-
/// returns: 持有锁的 guard,Drop 时解锁
|
|
47
|
-
/// errors: 建目录或打开锁文件失败返回 StatePersist,等待超时返回 LifecycleLockTimeout
|
|
48
|
-
/// ---
|
|
49
|
-
pub(crate) fn acquire_agent_lifecycle_lock(
|
|
50
|
-
request: LifecycleLockRequest<'_>,
|
|
51
|
-
) -> Result<LifecycleLockGuard, LifecycleError> {
|
|
52
|
-
#[cfg(test)]
|
|
53
|
-
if let Some((timeout, held_long)) = test_lifecycle_lock_deadline_override() {
|
|
54
|
-
return acquire_agent_lifecycle_lock_with_deadlines(request, timeout, held_long);
|
|
55
|
-
}
|
|
56
|
-
acquire_agent_lifecycle_lock_with_deadlines(
|
|
57
|
-
request,
|
|
58
|
-
LIFECYCLE_LOCK_TIMEOUT,
|
|
59
|
-
LIFECYCLE_LOCK_HELD_LONG,
|
|
60
|
-
)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/// ---
|
|
64
|
-
/// purpose: 以显式超时与告警阈值抢同一把锁,仅测试构建可见
|
|
65
|
-
/// params:
|
|
66
|
-
/// timeout: 放弃等待的上限
|
|
67
|
-
/// held_long: 超过它写一次 lock_held_long 事件
|
|
68
|
-
/// returns: 持有锁的 guard
|
|
69
|
-
/// errors: 同 acquire_agent_lifecycle_lock
|
|
70
|
-
/// ---
|
|
71
|
-
#[cfg(test)]
|
|
72
|
-
pub(crate) fn acquire_agent_lifecycle_lock_for_test(
|
|
73
|
-
request: LifecycleLockRequest<'_>,
|
|
74
|
-
timeout: Duration,
|
|
75
|
-
held_long: Duration,
|
|
76
|
-
) -> Result<LifecycleLockGuard, LifecycleError> {
|
|
77
|
-
acquire_agent_lifecycle_lock_with_deadlines(request, timeout, held_long)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
#[cfg(test)]
|
|
81
|
-
thread_local! {
|
|
82
|
-
static TEST_DEADLINE_OVERRIDE: std::cell::Cell<Option<(Duration, Duration)>> =
|
|
83
|
-
const { std::cell::Cell::new(None) };
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
#[cfg(test)]
|
|
87
|
-
pub(crate) struct LifecycleLockDeadlineOverrideGuard {
|
|
88
|
-
previous: Option<(Duration, Duration)>,
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/// ---
|
|
92
|
-
/// purpose: 线程内改写默认锁超时与告警阈值,仅测试构建可见
|
|
93
|
-
/// returns: guard,Drop 时恢复上一次的取值
|
|
94
|
-
/// ---
|
|
95
|
-
#[cfg(test)]
|
|
96
|
-
pub(crate) fn override_agent_lifecycle_lock_deadlines_for_test(
|
|
97
|
-
timeout: Duration,
|
|
98
|
-
held_long: Duration,
|
|
99
|
-
) -> LifecycleLockDeadlineOverrideGuard {
|
|
100
|
-
let previous = TEST_DEADLINE_OVERRIDE.with(|override_cell| {
|
|
101
|
-
let previous = override_cell.get();
|
|
102
|
-
override_cell.set(Some((timeout, held_long)));
|
|
103
|
-
previous
|
|
104
|
-
});
|
|
105
|
-
LifecycleLockDeadlineOverrideGuard { previous }
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
#[cfg(test)]
|
|
109
|
-
fn test_lifecycle_lock_deadline_override() -> Option<(Duration, Duration)> {
|
|
110
|
-
TEST_DEADLINE_OVERRIDE.with(std::cell::Cell::get)
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
#[cfg(test)]
|
|
114
|
-
impl Drop for LifecycleLockDeadlineOverrideGuard {
|
|
115
|
-
fn drop(&mut self) {
|
|
116
|
-
TEST_DEADLINE_OVERRIDE.with(|override_cell| override_cell.set(self.previous));
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
fn acquire_agent_lifecycle_lock_with_deadlines(
|
|
121
|
-
request: LifecycleLockRequest<'_>,
|
|
122
|
-
timeout: Duration,
|
|
123
|
-
held_long: Duration,
|
|
124
|
-
) -> Result<LifecycleLockGuard, LifecycleError> {
|
|
125
|
-
// 0.5.x Windows portability Batch 2: migrated to
|
|
126
|
-
// `crate::platform::file_lock::{try_lock_once_nonblocking, unlock}`
|
|
127
|
-
// so the same polling loop + waiter file + 5s `lock_held_long`
|
|
128
|
-
// event + 30s N38 timeout error shape works on both Unix (`flock`)
|
|
129
|
-
// and Windows (`LockFileEx`). The Batch 0 non-Unix stub that
|
|
130
|
-
// returned `lock_timeout_error` unconditionally is now gone —
|
|
131
|
-
// Windows callers get real lock behavior. Byte-preserving on Unix:
|
|
132
|
-
// the polling cadence, waiter file writes, `lock_held_long_event`
|
|
133
|
-
// emission, and error shape are all unchanged relative to the
|
|
134
|
-
// pre-Batch-2 unix branch.
|
|
135
|
-
let lock_path = agent_lifecycle_lock_path(request.workspace);
|
|
136
|
-
if let Some(parent) = lock_path.parent() {
|
|
137
|
-
std::fs::create_dir_all(parent)
|
|
138
|
-
.map_err(|e| LifecycleError::StatePersist(format!("create lifecycle lock dir: {e}")))?;
|
|
139
|
-
}
|
|
140
|
-
let mut file = std::fs::OpenOptions::new()
|
|
141
|
-
.create(true)
|
|
142
|
-
.read(true)
|
|
143
|
-
.write(true)
|
|
144
|
-
.truncate(false)
|
|
145
|
-
.open(&lock_path)
|
|
146
|
-
.map_err(|e| LifecycleError::StatePersist(format!("open lifecycle lock: {e}")))?;
|
|
147
|
-
let started = Instant::now();
|
|
148
|
-
let mut long_event_written = false;
|
|
149
|
-
let mut waiter = None;
|
|
150
|
-
loop {
|
|
151
|
-
match crate::platform::file_lock::try_lock_once_nonblocking(&file) {
|
|
152
|
-
Ok(true) => {
|
|
153
|
-
write_lock_metadata(&mut file, &request, &lock_path)?;
|
|
154
|
-
return Ok(LifecycleLockGuard { file });
|
|
155
|
-
}
|
|
156
|
-
Ok(false) => {}
|
|
157
|
-
Err(e) => {
|
|
158
|
-
return Err(LifecycleError::StatePersist(format!(
|
|
159
|
-
"lifecycle lock acquire io error at {}: {e}",
|
|
160
|
-
lock_path.display()
|
|
161
|
-
)));
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
let elapsed = started.elapsed();
|
|
165
|
-
if waiter.is_none() {
|
|
166
|
-
waiter = WaiterFile::create(&request, &lock_path).ok();
|
|
167
|
-
}
|
|
168
|
-
if let Some(waiter) = waiter.as_ref() {
|
|
169
|
-
let _ = waiter.write(&request, elapsed);
|
|
170
|
-
}
|
|
171
|
-
if !long_event_written && elapsed >= held_long {
|
|
172
|
-
let _ = write_lock_held_long_event(&request, &lock_path, elapsed, held_long, timeout);
|
|
173
|
-
long_event_written = true;
|
|
174
|
-
}
|
|
175
|
-
if elapsed >= timeout {
|
|
176
|
-
return Err(lock_timeout_error(&request, &lock_path, elapsed));
|
|
177
|
-
}
|
|
178
|
-
std::thread::sleep(std::cmp::min(
|
|
179
|
-
Duration::from_millis(50),
|
|
180
|
-
timeout.saturating_sub(elapsed),
|
|
181
|
-
));
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/// ---
|
|
186
|
-
/// purpose: 给出该 workspace 的 agent-lifecycle 锁文件路径
|
|
187
|
-
/// returns: runtime 目录下的 agent-lifecycle.lock
|
|
188
|
-
/// ---
|
|
189
|
-
pub(crate) fn agent_lifecycle_lock_path(workspace: &Path) -> PathBuf {
|
|
190
|
-
crate::model::paths::runtime_dir(workspace).join(format!("{AGENT_LIFECYCLE_LOCK_NAME}.lock"))
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
fn write_lock_metadata(
|
|
194
|
-
file: &mut std::fs::File,
|
|
195
|
-
request: &LifecycleLockRequest<'_>,
|
|
196
|
-
lock_path: &Path,
|
|
197
|
-
) -> Result<(), LifecycleError> {
|
|
198
|
-
let metadata = serde_json::json!({
|
|
199
|
-
"lock_name": AGENT_LIFECYCLE_LOCK_NAME,
|
|
200
|
-
"pid": std::process::id(),
|
|
201
|
-
"operation": request.operation,
|
|
202
|
-
"team": request.team,
|
|
203
|
-
"agent_id": request.agent_id.map(AgentId::as_str),
|
|
204
|
-
"workspace": request.workspace.display().to_string(),
|
|
205
|
-
"lock_path": lock_path.display().to_string(),
|
|
206
|
-
"acquired_at": chrono::Utc::now().to_rfc3339(),
|
|
207
|
-
});
|
|
208
|
-
let mut bytes = serde_json::to_vec(&metadata).map_err(|e| {
|
|
209
|
-
LifecycleError::StatePersist(format!("encode lifecycle lock metadata: {e}"))
|
|
210
|
-
})?;
|
|
211
|
-
bytes.push(b'\n');
|
|
212
|
-
file.set_len(0)
|
|
213
|
-
.map_err(|e| LifecycleError::StatePersist(format!("truncate lifecycle lock: {e}")))?;
|
|
214
|
-
file.seek(std::io::SeekFrom::Start(0))
|
|
215
|
-
.map_err(|e| LifecycleError::StatePersist(format!("seek lifecycle lock: {e}")))?;
|
|
216
|
-
file.write_all(&bytes)
|
|
217
|
-
.map_err(|e| LifecycleError::StatePersist(format!("write lifecycle lock metadata: {e}")))?;
|
|
218
|
-
Ok(())
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
fn lock_timeout_error(
|
|
222
|
-
request: &LifecycleLockRequest<'_>,
|
|
223
|
-
lock_path: &Path,
|
|
224
|
-
elapsed: Duration,
|
|
225
|
-
) -> LifecycleError {
|
|
226
|
-
LifecycleError::LifecycleLockTimeout {
|
|
227
|
-
lock_path: lock_path.to_path_buf(),
|
|
228
|
-
log_path: crate::model::paths::logs_dir(request.workspace).join("events.jsonl"),
|
|
229
|
-
operation: request.operation.to_string(),
|
|
230
|
-
waited_ms: elapsed.as_millis(),
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
fn write_lock_held_long_event(
|
|
235
|
-
request: &LifecycleLockRequest<'_>,
|
|
236
|
-
lock_path: &Path,
|
|
237
|
-
elapsed: Duration,
|
|
238
|
-
held_long: Duration,
|
|
239
|
-
timeout: Duration,
|
|
240
|
-
) -> Result<(), crate::event_log::EventLogError> {
|
|
241
|
-
let holder = read_holder(lock_path);
|
|
242
|
-
let holder_duration_ms = holder_duration_ms(holder.as_ref());
|
|
243
|
-
crate::event_log::EventLog::new(request.workspace).write(
|
|
244
|
-
"lifecycle.lock_held_long",
|
|
245
|
-
serde_json::json!({
|
|
246
|
-
"lock_name": AGENT_LIFECYCLE_LOCK_NAME,
|
|
247
|
-
"lock_path": lock_path.display().to_string(),
|
|
248
|
-
"workspace": request.workspace.display().to_string(),
|
|
249
|
-
"operation": request.operation,
|
|
250
|
-
"team": request.team,
|
|
251
|
-
"agent_id": request.agent_id.map(AgentId::as_str),
|
|
252
|
-
"waited_ms": elapsed.as_millis(),
|
|
253
|
-
"threshold_ms": held_long.as_millis(),
|
|
254
|
-
"timeout_ms": timeout.as_millis(),
|
|
255
|
-
"holder": holder,
|
|
256
|
-
"holder_duration_ms": holder_duration_ms,
|
|
257
|
-
"blocked_queue_len": blocked_queue_len(request.workspace),
|
|
258
|
-
}),
|
|
259
|
-
)?;
|
|
260
|
-
Ok(())
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
fn read_holder(lock_path: &Path) -> Option<serde_json::Value> {
|
|
264
|
-
let text = std::fs::read_to_string(lock_path).ok()?;
|
|
265
|
-
let value = serde_json::from_str::<serde_json::Value>(&text).ok()?;
|
|
266
|
-
Some(serde_json::json!({
|
|
267
|
-
"pid": value.get("pid").cloned().unwrap_or(serde_json::Value::Null),
|
|
268
|
-
"operation": value.get("operation").cloned().unwrap_or(serde_json::Value::Null),
|
|
269
|
-
"team": value.get("team").cloned().unwrap_or(serde_json::Value::Null),
|
|
270
|
-
"agent_id": value.get("agent_id").cloned().unwrap_or(serde_json::Value::Null),
|
|
271
|
-
"acquired_at": value.get("acquired_at").cloned().unwrap_or(serde_json::Value::Null),
|
|
272
|
-
}))
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
fn holder_duration_ms(holder: Option<&serde_json::Value>) -> Option<u128> {
|
|
276
|
-
let acquired_at = holder?
|
|
277
|
-
.get("acquired_at")
|
|
278
|
-
.and_then(serde_json::Value::as_str)?;
|
|
279
|
-
let acquired_at = chrono::DateTime::parse_from_rfc3339(acquired_at).ok()?;
|
|
280
|
-
let elapsed = chrono::Utc::now().signed_duration_since(acquired_at.with_timezone(&chrono::Utc));
|
|
281
|
-
elapsed.to_std().ok().map(|d| d.as_millis())
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
fn waiter_dir(workspace: &Path) -> PathBuf {
|
|
285
|
-
crate::model::paths::runtime_dir(workspace).join(format!("{AGENT_LIFECYCLE_LOCK_NAME}.waiters"))
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
fn blocked_queue_len(workspace: &Path) -> Option<usize> {
|
|
289
|
-
std::fs::read_dir(waiter_dir(workspace))
|
|
290
|
-
.ok()
|
|
291
|
-
.map(|entries| entries.filter(|entry| entry.is_ok()).count())
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
struct WaiterFile {
|
|
295
|
-
path: PathBuf,
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
impl WaiterFile {
|
|
299
|
-
fn create(request: &LifecycleLockRequest<'_>, lock_path: &Path) -> std::io::Result<Self> {
|
|
300
|
-
let dir = waiter_dir(request.workspace);
|
|
301
|
-
std::fs::create_dir_all(&dir)?;
|
|
302
|
-
let path = dir.join(format!("{}.json", std::process::id()));
|
|
303
|
-
let file = Self { path };
|
|
304
|
-
file.write_with_lock(request, lock_path, Duration::from_millis(0))?;
|
|
305
|
-
Ok(file)
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
fn write(&self, request: &LifecycleLockRequest<'_>, elapsed: Duration) -> std::io::Result<()> {
|
|
309
|
-
self.write_with_lock(
|
|
310
|
-
request,
|
|
311
|
-
&agent_lifecycle_lock_path(request.workspace),
|
|
312
|
-
elapsed,
|
|
313
|
-
)
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
fn write_with_lock(
|
|
317
|
-
&self,
|
|
318
|
-
request: &LifecycleLockRequest<'_>,
|
|
319
|
-
lock_path: &Path,
|
|
320
|
-
elapsed: Duration,
|
|
321
|
-
) -> std::io::Result<()> {
|
|
322
|
-
let payload = serde_json::json!({
|
|
323
|
-
"pid": std::process::id(),
|
|
324
|
-
"operation": request.operation,
|
|
325
|
-
"team": request.team,
|
|
326
|
-
"agent_id": request.agent_id.map(AgentId::as_str),
|
|
327
|
-
"workspace": request.workspace.display().to_string(),
|
|
328
|
-
"lock_path": lock_path.display().to_string(),
|
|
329
|
-
"waited_ms": elapsed.as_millis(),
|
|
330
|
-
"updated_at": chrono::Utc::now().to_rfc3339(),
|
|
331
|
-
});
|
|
332
|
-
let bytes = serde_json::to_vec(&payload).map_err(std::io::Error::other)?;
|
|
333
|
-
std::fs::write(&self.path, bytes)
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
impl Drop for WaiterFile {
|
|
338
|
-
fn drop(&mut self) {
|
|
339
|
-
let _ = std::fs::remove_file(&self.path);
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
impl Drop for LifecycleLockGuard {
|
|
344
|
-
fn drop(&mut self) {
|
|
345
|
-
// Batch 2: unlock via platform primitive. Best-effort — OS
|
|
346
|
-
// releases when the file handle closes anyway. Uniform on
|
|
347
|
-
// both `flock(LOCK_UN)` (unix) and `UnlockFileEx` (windows).
|
|
348
|
-
let _ = crate::platform::file_lock::unlock(&self.file);
|
|
349
|
-
}
|
|
350
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
//! ---
|
|
2
|
-
//! purpose: team 进程级生命周期编排(起停加减 clone/fork)
|
|
3
|
-
//! contract:
|
|
4
|
-
//! provides:
|
|
5
|
-
//! - name: launch
|
|
6
|
-
//! what: 冷启与成员生命周期入口
|
|
7
|
-
//! boundary:
|
|
8
|
-
//! - 不拥有物理注入,只调用 transport
|
|
9
|
-
//! maturity: wired
|
|
10
|
-
//! ---
|
|
11
|
-
//!
|
|
12
|
-
//! step 13 · lifecycle — team 进程级生命周期编排器(ROUND-0.5 骨架)。
|
|
13
|
-
//!
|
|
14
|
-
//! 真相源 `team-agent-public` @ v0.2.11 (439bef8),只读。Card:
|
|
15
|
-
//! `docs/phase0/subsystems/13-lifecycle.md`。
|
|
16
|
-
//!
|
|
17
|
-
//! Python 源:
|
|
18
|
-
//! - `launch/core.py`(`launch`)、`launch/bootstrap.py`/`config.py`/`requirements.py`。
|
|
19
|
-
//! - `lifecycle/start.py`(`start_agent`)、`lifecycle/operations.py`
|
|
20
|
-
//! (`stop_agent`/`reset_agent`/`add_agent`/`fork_agent`)、`lifecycle/agents.py`
|
|
21
|
-
//! (`remove_agent` + `_RemoveRollback`)、`lifecycle/paste_buffer_hygiene.py`。
|
|
22
|
-
//! - `restart/orchestration.py`(`restart` Route B)、`restart/selection.py`、`restart/snapshot.py`。
|
|
23
|
-
//! - `orchestrator/__init__.py`/`plan.py`/`state.py`(plan 多 stage 状态机)。
|
|
24
|
-
//! - `diagnose/quick_start.py`(`quick_start`/`prepare_quick_start_team`/`wait_ready`)。
|
|
25
|
-
//!
|
|
26
|
-
//! 价值:把下层原语(transport step9 / provider step8 / leader step10 / messaging step11 /
|
|
27
|
-
//! state step5 / coordinator step12 / compiler step6)编排成**原子的、可回滚的、可审计的**
|
|
28
|
-
//! 用户级动作。本 module 不拥有底层原语,只**调用**它们。
|
|
29
|
-
//!
|
|
30
|
-
//! § 锁(机械化,leader 集成时上 `#![deny(unwrap/expect/panic)]`):本 module 调
|
|
31
|
-
//! `save_runtime_state`/`save_team_runtime_snapshot`/`save_plan_state`(`os.replace` 路径,
|
|
32
|
-
//! bug-084 高危)—— 所有写路径强制 `Result`,`EACCES/EPERM/EBUSY` 退避重试,绝不 unwrap。
|
|
33
|
-
//! § lifecycle **构造** provider 命令字符串经 step8 `ProviderAdapter` trait,**绝不**链接
|
|
34
|
-
//! provider client crate(anthropic/openai SDK)。
|
|
35
|
-
//!
|
|
36
|
-
//! ROUND-0.5:数据类型 + 行为入口 fn 签名齐备,body = `unimplemented!("step13 port: ...")`。
|
|
37
|
-
//! contracts blitz 可 NAME 这些类型并 CALL 这些 fn、断言其 rich return。
|
|
38
|
-
|
|
39
|
-
// ROUND-0 skeleton:fn body 全 unimplemented!() → import/field/param/大 Err 暂未落地;P2 porter 实现时移除。
|
|
40
|
-
#![allow(
|
|
41
|
-
dead_code,
|
|
42
|
-
unused_imports,
|
|
43
|
-
unused_variables,
|
|
44
|
-
clippy::result_large_err,
|
|
45
|
-
clippy::doc_overindented_list_items,
|
|
46
|
-
clippy::doc_lazy_continuation,
|
|
47
|
-
clippy::io_other_error
|
|
48
|
-
)]
|
|
49
|
-
// §10:lifecycle 写路径(save_runtime_state/snapshot/plan_state,bug-084 高危)实现层禁 unwrap/expect/panic
|
|
50
|
-
// (unimplemented!() stub 不被拦);tests 子模块各自 allow。
|
|
51
|
-
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
|
|
52
|
-
|
|
53
|
-
pub mod helpers;
|
|
54
|
-
pub mod launch;
|
|
55
|
-
pub(crate) mod lock;
|
|
56
|
-
pub(crate) mod pane_input_lock;
|
|
57
|
-
pub(crate) mod profile_launch;
|
|
58
|
-
pub(crate) mod profile_smoke;
|
|
59
|
-
pub mod restart;
|
|
60
|
-
pub mod role_config;
|
|
61
|
-
pub mod types;
|
|
62
|
-
pub(crate) mod worker_command_context;
|
|
63
|
-
|
|
64
|
-
use std::collections::BTreeMap;
|
|
65
|
-
use std::path::PathBuf;
|
|
66
|
-
|
|
67
|
-
use crate::model::ids::AgentId;
|
|
68
|
-
use crate::provider::{RolloutPath, SessionId};
|
|
69
|
-
use crate::transport::{PaneId, SessionName, WindowName};
|
|
70
|
-
|
|
71
|
-
pub use types::*;
|
|
72
|
-
pub use launch::*;
|
|
73
|
-
pub use restart::*;
|
|
74
|
-
|
|
75
|
-
pub(crate) use helpers::save_team_runtime_snapshot;
|
|
76
|
-
pub(crate) use helpers::{plan_lock_path, plan_state_path, read_plan_state, save_plan_state};
|
|
77
|
-
|
|
78
|
-
#[cfg(test)]
|
|
79
|
-
mod tests;
|
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
//! ---
|
|
2
|
-
//! purpose: pane 输入通道互斥锁,让同一 pane 上的写入串行化
|
|
3
|
-
//! contract:
|
|
4
|
-
//! provides:
|
|
5
|
-
//! - name: acquire_or_proceed
|
|
6
|
-
//! what: 取到锁则持有到 Drop;超时或锁不可用则告警后放行,不无限等待
|
|
7
|
-
//! depends:
|
|
8
|
-
//! - crate::platform::file_lock
|
|
9
|
-
//! - crate::event_log::EventLog
|
|
10
|
-
//! boundary:
|
|
11
|
-
//! - 不锁席位生命周期(那是 lock.rs)
|
|
12
|
-
//! - 不重粘文本、不加自动兜底重投;重试只重按回车由既有 inject 路径负责
|
|
13
|
-
//! - 不在投递层发明临时持有态
|
|
14
|
-
//! maturity: wired
|
|
15
|
-
//! ---
|
|
16
|
-
|
|
17
|
-
use std::path::{Path, PathBuf};
|
|
18
|
-
use std::time::{Duration, Instant};
|
|
19
|
-
|
|
20
|
-
use crate::event_log::EventLog;
|
|
21
|
-
use crate::model::paths::runtime_dir;
|
|
22
|
-
|
|
23
|
-
/// Hard upper bound for waiting on the pane input lock. Constant, not a magic number in a loop.
|
|
24
|
-
pub(crate) const PANE_INPUT_LOCK_TIMEOUT: Duration = Duration::from_millis(200);
|
|
25
|
-
|
|
26
|
-
pub(crate) const PANE_INPUT_LOCK_NAME: &str = "pane-input";
|
|
27
|
-
|
|
28
|
-
/// Event / stderr token. A5 greps this exact string.
|
|
29
|
-
pub(crate) const PANE_INPUT_LOCK_TIMEOUT_EVENT: &str = "pane_input_lock.timeout";
|
|
30
|
-
|
|
31
|
-
pub(crate) struct PaneInputLockRequest<'a> {
|
|
32
|
-
pub workspace: Option<&'a Path>,
|
|
33
|
-
pub target_key: &'a str,
|
|
34
|
-
pub operation: &'static str,
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
pub(crate) struct PaneInputLockGuard {
|
|
38
|
-
file: Option<std::fs::File>,
|
|
39
|
-
guard_gate: Option<std::fs::File>,
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/// ---
|
|
43
|
-
/// purpose: 取 pane 输入锁;拿不到或超时则告警后放行,绝不无限等待
|
|
44
|
-
/// params:
|
|
45
|
-
/// request: 携带可选 workspace、目标 pane 键与操作名
|
|
46
|
-
/// returns: Some 表示已持锁,None 表示无 workspace 可锁或已超时放行
|
|
47
|
-
/// ---
|
|
48
|
-
/// Acquire the pane lock or proceed after the hard timeout.
|
|
49
|
-
///
|
|
50
|
-
/// On timeout / lock I/O failure: emit [`PANE_INPUT_LOCK_TIMEOUT_EVENT`] (stderr + events.jsonl)
|
|
51
|
-
/// and return `None` so the caller still writes. Relief messages must not wait forever.
|
|
52
|
-
pub(crate) fn acquire_or_proceed(request: PaneInputLockRequest<'_>) -> Option<PaneInputLockGuard> {
|
|
53
|
-
let timeout = PANE_INPUT_LOCK_TIMEOUT;
|
|
54
|
-
let Some(workspace) = request.workspace else {
|
|
55
|
-
// No workspace (some unit backends): nothing to lock against. Not an alarm.
|
|
56
|
-
return None;
|
|
57
|
-
};
|
|
58
|
-
acquire_file_lock(workspace, &request, timeout, "proceed")
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/// Every legacy writer holds shared admission through its whole operation,
|
|
62
|
-
/// even when its ordinary 200ms lock times out. Required guards hold exclusive
|
|
63
|
-
/// admission, so neither can enter while the other is already writing.
|
|
64
|
-
pub(crate) fn acquire_for_write(request: PaneInputLockRequest<'_>) -> Result<Option<PaneInputLockGuard>, ()> {
|
|
65
|
-
if request.workspace.is_none() { return Ok(None); }
|
|
66
|
-
let gate = acquire_guard_gate(&request, false)?;
|
|
67
|
-
let mut guard = acquire_or_proceed(request).unwrap_or(PaneInputLockGuard { file: None, guard_gate: None });
|
|
68
|
-
guard.guard_gate = Some(gate);
|
|
69
|
-
Ok(Some(guard))
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
fn acquire_guard_gate(request: &PaneInputLockRequest<'_>, exclusive: bool) -> Result<std::fs::File, ()> {
|
|
73
|
-
let opened = (|| -> std::io::Result<std::fs::File> {
|
|
74
|
-
let workspace = request.workspace.ok_or_else(|| std::io::Error::other("workspace missing"))?;
|
|
75
|
-
let path = pane_input_lock_path(workspace, request.target_key).with_extension("guard");
|
|
76
|
-
if let Some(parent) = path.parent() { std::fs::create_dir_all(parent)?; }
|
|
77
|
-
let file = std::fs::OpenOptions::new().create(true).read(true).write(true).truncate(false).open(path)?;
|
|
78
|
-
let result = if exclusive { file.try_lock() } else { file.try_lock_shared() };
|
|
79
|
-
result.map_err(|error| match error {
|
|
80
|
-
std::fs::TryLockError::WouldBlock => std::io::Error::from(std::io::ErrorKind::WouldBlock),
|
|
81
|
-
std::fs::TryLockError::Error(error) => error,
|
|
82
|
-
})?;
|
|
83
|
-
Ok(file)
|
|
84
|
-
})();
|
|
85
|
-
opened.map_err(|_| emit_timeout_alarm(request, PANE_INPUT_LOCK_TIMEOUT, Duration::ZERO, "guard_gate", "refuse"))
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/// Guarded native input must never treat a missing/contended lock as permission.
|
|
89
|
-
pub(crate) fn acquire_required(request: PaneInputLockRequest<'_>) -> Option<PaneInputLockGuard> {
|
|
90
|
-
let Some(workspace) = request.workspace else {
|
|
91
|
-
emit_timeout_alarm(&request, PANE_INPUT_LOCK_TIMEOUT, Duration::ZERO, "workspace_missing", "refuse");
|
|
92
|
-
return None;
|
|
93
|
-
};
|
|
94
|
-
let gate = acquire_guard_gate(&request, true).ok()?;
|
|
95
|
-
let mut guard = acquire_file_lock(workspace, &request, PANE_INPUT_LOCK_TIMEOUT, "refuse")?;
|
|
96
|
-
guard.guard_gate = Some(gate);
|
|
97
|
-
Some(guard)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
fn acquire_file_lock(
|
|
101
|
-
workspace: &Path,
|
|
102
|
-
request: &PaneInputLockRequest<'_>,
|
|
103
|
-
timeout: Duration,
|
|
104
|
-
disposition: &str,
|
|
105
|
-
) -> Option<PaneInputLockGuard> {
|
|
106
|
-
let path = pane_input_lock_path(workspace, request.target_key);
|
|
107
|
-
if let Some(parent) = path.parent() {
|
|
108
|
-
if std::fs::create_dir_all(parent).is_err() {
|
|
109
|
-
emit_timeout_alarm(request, timeout, Duration::ZERO, "lock_dir", disposition);
|
|
110
|
-
return None;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
let file = match std::fs::OpenOptions::new()
|
|
114
|
-
.create(true)
|
|
115
|
-
.read(true)
|
|
116
|
-
.write(true)
|
|
117
|
-
.truncate(false)
|
|
118
|
-
.open(&path)
|
|
119
|
-
{
|
|
120
|
-
Ok(file) => file,
|
|
121
|
-
Err(_) => {
|
|
122
|
-
emit_timeout_alarm(request, timeout, Duration::ZERO, "lock_open", disposition);
|
|
123
|
-
return None;
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
let started = Instant::now();
|
|
127
|
-
loop {
|
|
128
|
-
match crate::platform::file_lock::try_lock_once_nonblocking(&file) {
|
|
129
|
-
Ok(true) => {
|
|
130
|
-
return Some(PaneInputLockGuard { file: Some(file), guard_gate: None });
|
|
131
|
-
}
|
|
132
|
-
Ok(false) => {}
|
|
133
|
-
Err(_) => {
|
|
134
|
-
emit_timeout_alarm(request, timeout, started.elapsed(), "lock_io", disposition);
|
|
135
|
-
return None;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
let elapsed = started.elapsed();
|
|
139
|
-
if elapsed >= timeout {
|
|
140
|
-
emit_timeout_alarm(request, timeout, elapsed, "timeout", disposition);
|
|
141
|
-
return None;
|
|
142
|
-
}
|
|
143
|
-
std::thread::sleep(std::cmp::min(
|
|
144
|
-
Duration::from_millis(10),
|
|
145
|
-
timeout.saturating_sub(elapsed),
|
|
146
|
-
));
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
fn pane_input_lock_path(workspace: &Path, target_key: &str) -> PathBuf {
|
|
151
|
-
let safe: String = target_key
|
|
152
|
-
.chars()
|
|
153
|
-
.map(|c| {
|
|
154
|
-
if c.is_ascii_alphanumeric() {
|
|
155
|
-
c
|
|
156
|
-
} else {
|
|
157
|
-
'_'
|
|
158
|
-
}
|
|
159
|
-
})
|
|
160
|
-
.collect();
|
|
161
|
-
runtime_dir(workspace)
|
|
162
|
-
.join(PANE_INPUT_LOCK_NAME)
|
|
163
|
-
.join(format!("{safe}.lock"))
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
fn emit_timeout_alarm(
|
|
167
|
-
request: &PaneInputLockRequest<'_>,
|
|
168
|
-
timeout: Duration,
|
|
169
|
-
waited: Duration,
|
|
170
|
-
reason: &str,
|
|
171
|
-
disposition: &str,
|
|
172
|
-
) {
|
|
173
|
-
// A5 watches this exact token on stderr. Commenting this line must turn A5 red.
|
|
174
|
-
eprintln!(
|
|
175
|
-
"{PANE_INPUT_LOCK_TIMEOUT_EVENT} target={} operation={} waited_ms={} timeout_ms={} reason={reason} disposition={disposition}",
|
|
176
|
-
request.target_key,
|
|
177
|
-
request.operation,
|
|
178
|
-
waited.as_millis(),
|
|
179
|
-
timeout.as_millis()
|
|
180
|
-
);
|
|
181
|
-
if let Some(workspace) = request.workspace {
|
|
182
|
-
let _ = EventLog::new(workspace).write(
|
|
183
|
-
PANE_INPUT_LOCK_TIMEOUT_EVENT,
|
|
184
|
-
serde_json::json!({
|
|
185
|
-
"lock_name": PANE_INPUT_LOCK_NAME,
|
|
186
|
-
"target": request.target_key,
|
|
187
|
-
"operation": request.operation,
|
|
188
|
-
"waited_ms": waited.as_millis() as u64,
|
|
189
|
-
"timeout_ms": timeout.as_millis() as u64,
|
|
190
|
-
"reason": reason,
|
|
191
|
-
"disposition": disposition,
|
|
192
|
-
}),
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
impl Drop for PaneInputLockGuard {
|
|
198
|
-
fn drop(&mut self) {
|
|
199
|
-
if let Some(file) = self.file.take() {
|
|
200
|
-
let _ = crate::platform::file_lock::unlock(&file);
|
|
201
|
-
}
|
|
202
|
-
if let Some(gate) = self.guard_gate.take() { let _ = gate.unlock(); }
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
#[cfg(test)]
|
|
207
|
-
mod required_tests {
|
|
208
|
-
#![allow(clippy::unwrap_used)]
|
|
209
|
-
use super::*;
|
|
210
|
-
|
|
211
|
-
#[test]
|
|
212
|
-
fn required_pane_input_lock_missing_workspace_refuses() {
|
|
213
|
-
assert!(acquire_required(PaneInputLockRequest { workspace: None, target_key: "%1", operation: "fixture" }).is_none());
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
#[test]
|
|
217
|
-
fn required_pane_input_lock_contention_refuses_and_drop_releases_same_key() {
|
|
218
|
-
let workspace = std::env::temp_dir().join(format!("ta-required-pane-lock-{}", std::process::id()));
|
|
219
|
-
std::fs::create_dir(&workspace).unwrap();
|
|
220
|
-
let request = || PaneInputLockRequest { workspace: Some(workspace.as_path()), target_key: "%1", operation: "fixture" };
|
|
221
|
-
let held = acquire_required(request()).unwrap();
|
|
222
|
-
assert!(acquire_required(request()).is_none());
|
|
223
|
-
let events = std::fs::read_to_string(workspace.join(".team/logs/events.jsonl")).unwrap();
|
|
224
|
-
assert!(events.lines().filter_map(|line| serde_json::from_str::<serde_json::Value>(line).ok())
|
|
225
|
-
.any(|row| row.to_string().contains("\"disposition\":\"refuse\"")));
|
|
226
|
-
drop(held);
|
|
227
|
-
drop(acquire_required(request()).unwrap());
|
|
228
|
-
// Preserve the old timeout/proceed policy, but hold reader admission
|
|
229
|
-
// through that unheld-main-lock writer so no required guard crosses it.
|
|
230
|
-
let first_writer = acquire_for_write(request()).unwrap().unwrap();
|
|
231
|
-
let timed_out_writer = acquire_for_write(request()).unwrap().unwrap();
|
|
232
|
-
assert!(timed_out_writer.file.is_none());
|
|
233
|
-
drop(first_writer);
|
|
234
|
-
assert!(acquire_required(request()).is_none());
|
|
235
|
-
drop(timed_out_writer);
|
|
236
|
-
drop(acquire_required(request()).unwrap());
|
|
237
|
-
std::fs::remove_dir_all(workspace).unwrap();
|
|
238
|
-
}
|
|
239
|
-
}
|