@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,540 +0,0 @@
|
|
|
1
|
-
//! ---
|
|
2
|
-
//! purpose: coordinator 的共享数据面——协议常量、Pid/WorkspacePath newtype、健康与启停的穷尽状态 enum、metadata/schema/report 结构、以及跨子系统注入用的 trait 占位
|
|
3
|
-
//! contract:
|
|
4
|
-
//! provides:
|
|
5
|
-
//! - name: as_str
|
|
6
|
-
//! what: 把 binary-identity relation 与 metadata mismatch reason 映射成稳定 wire 字符串
|
|
7
|
-
//! - name: as_path
|
|
8
|
-
//! what: 从 WorkspacePath newtype 取回底层路径
|
|
9
|
-
//! depends:
|
|
10
|
-
//! - crate::model::enums
|
|
11
|
-
//! - crate::model::ids
|
|
12
|
-
//! - crate::provider
|
|
13
|
-
//! - crate::message_store
|
|
14
|
-
//! - crate::event_log
|
|
15
|
-
//! boundary:
|
|
16
|
-
//! - 只定义形状,不含任何判定、I/O 或事件写入
|
|
17
|
-
//! - as_str 的返回值是对外稳定契约:已发布的字符串只可新增不可改写
|
|
18
|
-
//! - ProviderRegistry / MarkerStore 只是注入点,实现体不在本模块
|
|
19
|
-
//! maturity: wired
|
|
20
|
-
//! ---
|
|
21
|
-
//!
|
|
22
|
-
//! coordinator 共享数据面:常量 / newtype / 穷尽 enum / metadata / schema health /
|
|
23
|
-
//! report 结构 / abnormal-track 数据型 / cross-dep 占位。
|
|
24
|
-
|
|
25
|
-
use std::path::{Path, PathBuf};
|
|
26
|
-
|
|
27
|
-
use serde::{Deserialize, Serialize};
|
|
28
|
-
use serde_json::Value;
|
|
29
|
-
use thiserror::Error;
|
|
30
|
-
|
|
31
|
-
// ── REUSE — committed model types(不重定义)──────────────────────────────────
|
|
32
|
-
use crate::model::enums::Provider;
|
|
33
|
-
|
|
34
|
-
// ── REUSE — step 8 provider(经 trait,MUST-NOT-13:绝不依赖 provider client crate)──
|
|
35
|
-
use crate::provider::{ProviderAdapter, RolloutPath, TurnState};
|
|
36
|
-
|
|
37
|
-
// ===========================================================================
|
|
38
|
-
// CONSTANTS(metadata.py:13 / __main__.py:101)
|
|
39
|
-
// ===========================================================================
|
|
40
|
-
|
|
41
|
-
/// `COORDINATOR_PROTOCOL_VERSION = 2`(`metadata.py:13`)。bump 即触发
|
|
42
|
-
/// `coordinator.restart_incompatible`。健康判定的三元之一。
|
|
43
|
-
pub const PROTOCOL_VERSION: u32 = 2;
|
|
44
|
-
|
|
45
|
-
/// `DEFAULT_TICK_INTERVAL_SEC = 5.0`(`__main__.py:101`;Gap 36c 从 2.0 提到 5.0,2.5x 省 CPU)。
|
|
46
|
-
pub const DEFAULT_TICK_INTERVAL_SEC: f64 = 5.0;
|
|
47
|
-
|
|
48
|
-
/// 指数退避封顶(`__main__.py:65` `min(.., 60.0)`)。bug-084 崩溃循环防护。
|
|
49
|
-
pub const BACKOFF_MAX_SEC: f64 = 60.0;
|
|
50
|
-
|
|
51
|
-
// ===========================================================================
|
|
52
|
-
// NEWTYPES(§3:Pid / WorkspacePath 不与裸 int/PathBuf 混传)
|
|
53
|
-
// ===========================================================================
|
|
54
|
-
|
|
55
|
-
/// OS pid(`metadata.py` / `pid_is_running` / stop)。避免与其他 int id 混传。
|
|
56
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
|
|
57
|
-
#[serde(transparent)]
|
|
58
|
-
pub struct Pid(pub u32);
|
|
59
|
-
|
|
60
|
-
impl Pid {
|
|
61
|
-
/// ---
|
|
62
|
-
/// purpose: 把裸 OS pid 包成 newtype,杜绝与其他 int id 混传
|
|
63
|
-
/// params:
|
|
64
|
-
/// pid: OS 进程号,不做存活或有效性校验
|
|
65
|
-
/// returns: 承载该 pid 的 newtype
|
|
66
|
-
/// ---
|
|
67
|
-
pub fn new(pid: u32) -> Self {
|
|
68
|
-
Self(pid)
|
|
69
|
-
}
|
|
70
|
-
/// ---
|
|
71
|
-
/// purpose: 取回底层裸 pid,供需要 OS 接口的调用方使用
|
|
72
|
-
/// returns: 构造时传入的 pid 原值
|
|
73
|
-
/// ---
|
|
74
|
-
pub fn get(self) -> u32 {
|
|
75
|
-
self.0
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
impl std::fmt::Display for Pid {
|
|
80
|
-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
81
|
-
write!(f, "{}", self.0)
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/// resolve()'d workspace 路径(`Path(args.workspace).resolve()`,`__main__.py:31`)。
|
|
86
|
-
/// tick/health/start/stop 全以它为 key —— 不与裸 `PathBuf` 混。
|
|
87
|
-
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
|
88
|
-
pub struct WorkspacePath(pub PathBuf);
|
|
89
|
-
|
|
90
|
-
impl WorkspacePath {
|
|
91
|
-
/// ---
|
|
92
|
-
/// purpose: 把一个路径包成 workspace newtype,作为 tick/health/start/stop 的统一 key
|
|
93
|
-
/// params:
|
|
94
|
-
/// p: workspace 根路径。调用方负责先 resolve;本构造不做规范化也不校验存在性
|
|
95
|
-
/// returns: 承载该路径的 newtype
|
|
96
|
-
/// ---
|
|
97
|
-
pub fn new(p: impl Into<PathBuf>) -> Self {
|
|
98
|
-
Self(p.into())
|
|
99
|
-
}
|
|
100
|
-
/// ---
|
|
101
|
-
/// purpose: 借出底层路径,供文件系统与子进程参数使用
|
|
102
|
-
/// returns: 构造时传入的路径原值的借用
|
|
103
|
-
/// ---
|
|
104
|
-
pub fn as_path(&self) -> &Path {
|
|
105
|
-
&self.0
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// ===========================================================================
|
|
110
|
-
// §19 散字符串态 → 穷尽 enum
|
|
111
|
-
// ===========================================================================
|
|
112
|
-
|
|
113
|
-
/// metadata `source`(`__main__.py:34` boot / `lifecycle.py:119` start)。仅两调用点 → enum。
|
|
114
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
115
|
-
#[serde(rename_all = "snake_case")]
|
|
116
|
-
pub enum MetadataSource {
|
|
117
|
-
Boot,
|
|
118
|
-
Start,
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/// health dict `status`(`lifecycle.py:30,34,38-46`)。
|
|
122
|
-
/// **ADJUDICATION**:与 `crate::provider::HealthStatus`(agent health label,大写)**不同概念** ——
|
|
123
|
-
/// 那是 worker agent 健康标签,本 enum 是 *coordinator daemon* 进程健康态 → 命名 `CoordinatorHealthStatus` 避撞。
|
|
124
|
-
/// `ok` 由 `running ∧ metadata_ok ∧ schema_ok` 三者合取得出(`lifecycle.py:38`),不在此 enum 内。
|
|
125
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
126
|
-
#[serde(rename_all = "snake_case")]
|
|
127
|
-
pub enum CoordinatorHealthStatus {
|
|
128
|
-
/// pid 文件不存在(`lifecycle.py:30`)。
|
|
129
|
-
Missing,
|
|
130
|
-
/// pid 文件存在但非整数(`lifecycle.py:34`)。
|
|
131
|
-
InvalidPid,
|
|
132
|
-
/// pid 存活(`lifecycle.py:41`)。
|
|
133
|
-
Running,
|
|
134
|
-
/// pid 文件存在但进程已死(`lifecycle.py:41`)。
|
|
135
|
-
Stale,
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/// `start_coordinator` 结果 status(`lifecycle.py:54,73,89,121`)。
|
|
139
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
140
|
-
#[serde(rename_all = "snake_case")]
|
|
141
|
-
pub enum StartOutcome {
|
|
142
|
-
/// 已健康 → no-op(`lifecycle.py:54`)。
|
|
143
|
-
AlreadyRunning,
|
|
144
|
-
/// metadata 不兼容,先 stop 但 stop 失败(`lifecycle.py:73`)。
|
|
145
|
-
RestartIncompatibleStopFailed,
|
|
146
|
-
/// schema 不兼容,拒启并给修复 hint(`lifecycle.py:89`)。
|
|
147
|
-
SchemaIncompatible,
|
|
148
|
-
/// 正常 spawn(`lifecycle.py:121`)。
|
|
149
|
-
Started,
|
|
150
|
-
/// 当前 CLI 发现 live daemon 的 binary identity 过期,stop 后重新 spawn。
|
|
151
|
-
StartedAfterRotation,
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/// `stop_coordinator` 结果 status(`lifecycle.py:232,238,243,247`)。
|
|
155
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
156
|
-
#[serde(rename_all = "snake_case")]
|
|
157
|
-
pub enum StopOutcome {
|
|
158
|
-
/// pid 文件不存在(`lifecycle.py:232`)。
|
|
159
|
-
Missing,
|
|
160
|
-
/// pid 非整数 → 清文件返回(`lifecycle.py:238`)。
|
|
161
|
-
InvalidPidRemoved,
|
|
162
|
-
/// The pid file points to a live process owned by another workspace.
|
|
163
|
-
NotOwned,
|
|
164
|
-
/// SIGTERM 失败(`lifecycle.py:243`)。
|
|
165
|
-
KillFailed,
|
|
166
|
-
/// SIGTERM + 清 pid/meta 成功(`lifecycle.py:247`)。
|
|
167
|
-
Stopped,
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/// tick degraded/stop 的 `reason`(`lifecycle.py:279,357`)。§19 散字符串 → enum。
|
|
171
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
172
|
-
#[serde(rename_all = "snake_case")]
|
|
173
|
-
pub enum TickStopReason {
|
|
174
|
-
/// tmux session 不在 → `stop:true` 触发主循环退出(`lifecycle.py:279`)。
|
|
175
|
-
TmuxSessionMissing,
|
|
176
|
-
/// bug-084:tick-end save_runtime_state 失败,`stop:false`(`lifecycle.py:357`)。
|
|
177
|
-
PersistenceDegraded,
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/// 孤儿分类 reason(`orphan_cleanup.py:87-100`)。携带 hint 数据 → enum(非散字符串)。
|
|
181
|
-
/// **ADJUDICATION**:orphan_cleanup 的完整 SIGTERM/SIGKILL 升级逻辑归 step 14 诊断面;
|
|
182
|
-
/// 本 step 拥有 reason 分类 enum 是因为 daemon 自终止(Gap 37b)与诊断共享它(card §35)。
|
|
183
|
-
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
184
|
-
#[serde(tag = "reason", rename_all = "snake_case")]
|
|
185
|
-
pub enum OrphanReason {
|
|
186
|
-
/// workspace 目录已不存在(`orphan_cleanup.py`)。
|
|
187
|
-
WorkspacePathMissing,
|
|
188
|
-
/// 临时目录模式命中(携带 hint,如 `/var/folders/...team-agent-watcher-dedupe-*`)。
|
|
189
|
-
EphemeralTempdirPattern { hint: String },
|
|
190
|
-
/// workspace 仍在 → 不是孤儿。
|
|
191
|
-
WorkspaceAlive,
|
|
192
|
-
/// 无法解析 cmdline → 无法判定 workspace。
|
|
193
|
-
CmdlineUnparsed,
|
|
194
|
-
/// workspace 仍存在,但 coordinator metadata 不指向该 pid/schema。
|
|
195
|
-
MetadataMismatch,
|
|
196
|
-
/// ps 列表仍有命令残留,但 pid 已不再存活。
|
|
197
|
-
PidNotRunning,
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// ===========================================================================
|
|
201
|
-
// CoordinatorMetadata(metadata.py:50-57)
|
|
202
|
-
// ===========================================================================
|
|
203
|
-
|
|
204
|
-
/// `coordinator.json` 内容(`metadata.py:50-57`)。serde 字段名锁死稳定 JSON 契约。
|
|
205
|
-
/// 健康判定需三元全等:`pid == 实际 ∧ protocol_version == PROTOCOL_VERSION ∧
|
|
206
|
-
/// message_store_schema_version == SCHEMA_VERSION`(`metadata.py:37-43`)。
|
|
207
|
-
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
208
|
-
pub struct CoordinatorMetadata {
|
|
209
|
-
pub pid: Pid,
|
|
210
|
-
pub protocol_version: u32,
|
|
211
|
-
pub message_store_schema_version: i64,
|
|
212
|
-
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
213
|
-
pub binary_path: Option<String>,
|
|
214
|
-
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
215
|
-
pub binary_version: Option<String>,
|
|
216
|
-
pub source: MetadataSource,
|
|
217
|
-
/// ISO8601(`datetime.now(timezone.utc).isoformat()`,`metadata.py:56`)。
|
|
218
|
-
pub updated_at: String,
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
/// Current coordinator daemon binary identity. Version comes from the compiled
|
|
222
|
-
/// package; path comes from the currently executing CLI binary, not PATH.
|
|
223
|
-
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
224
|
-
pub struct CoordinatorBinaryIdentity {
|
|
225
|
-
pub binary_path: String,
|
|
226
|
-
pub binary_version: String,
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
/// Caller-relative daemon binary identity relation.
|
|
230
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
231
|
-
#[serde(rename_all = "snake_case")]
|
|
232
|
-
pub enum CoordinatorBinaryIdentityRelation {
|
|
233
|
-
Same,
|
|
234
|
-
CallerNewerThanDaemon,
|
|
235
|
-
DaemonNewerThanCaller,
|
|
236
|
-
SameVersionPathMismatch,
|
|
237
|
-
Unknown,
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
impl CoordinatorBinaryIdentityRelation {
|
|
241
|
-
/// ---
|
|
242
|
-
/// purpose: 把「调用方二进制相对 daemon 二进制」的关系映射成稳定 wire 字符串
|
|
243
|
-
/// returns: 五个稳定串之一(same / caller_newer_than_daemon / daemon_newer_than_caller / same_version_path_mismatch / unknown);这些值进事件与 status 输出,已发布的不可改写
|
|
244
|
-
/// ---
|
|
245
|
-
pub fn as_str(self) -> &'static str {
|
|
246
|
-
match self {
|
|
247
|
-
Self::Same => "same",
|
|
248
|
-
Self::CallerNewerThanDaemon => "caller_newer_than_daemon",
|
|
249
|
-
Self::DaemonNewerThanCaller => "daemon_newer_than_caller",
|
|
250
|
-
Self::SameVersionPathMismatch => "same_version_path_mismatch",
|
|
251
|
-
Self::Unknown => "unknown",
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
/// Stable machine-readable reason for coordinator metadata rejection.
|
|
257
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
258
|
-
#[serde(rename_all = "snake_case")]
|
|
259
|
-
pub enum CoordinatorMetadataMismatchReason {
|
|
260
|
-
MetadataMissing,
|
|
261
|
-
PidMismatch,
|
|
262
|
-
ProtocolVersionMismatch,
|
|
263
|
-
MessageStoreSchemaVersionMismatch,
|
|
264
|
-
BinaryIdentityMissing,
|
|
265
|
-
BinaryVersionMismatch,
|
|
266
|
-
BinaryPathMismatch,
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
impl CoordinatorMetadataMismatchReason {
|
|
270
|
-
/// ---
|
|
271
|
-
/// purpose: 把 coordinator metadata 被拒的原因映射成稳定 wire 字符串
|
|
272
|
-
/// returns: 七个稳定串之一(metadata_missing / pid_mismatch / protocol_version_mismatch / message_store_schema_version_mismatch / binary_identity_missing / binary_version_mismatch / binary_path_mismatch);进 HealthReport 与事件,已发布的不可改写
|
|
273
|
-
/// ---
|
|
274
|
-
pub fn as_str(self) -> &'static str {
|
|
275
|
-
match self {
|
|
276
|
-
Self::MetadataMissing => "metadata_missing",
|
|
277
|
-
Self::PidMismatch => "pid_mismatch",
|
|
278
|
-
Self::ProtocolVersionMismatch => "protocol_version_mismatch",
|
|
279
|
-
Self::MessageStoreSchemaVersionMismatch => "message_store_schema_version_mismatch",
|
|
280
|
-
Self::BinaryIdentityMissing => "binary_identity_missing",
|
|
281
|
-
Self::BinaryVersionMismatch => "binary_version_mismatch",
|
|
282
|
-
Self::BinaryPathMismatch => "binary_path_mismatch",
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
// ===========================================================================
|
|
288
|
-
// SchemaHealth(lifecycle.py:197-226)
|
|
289
|
-
// ===========================================================================
|
|
290
|
-
|
|
291
|
-
/// message-store schema 兼容门结果(`message_store_schema_health`,`lifecycle.py:197`)。
|
|
292
|
-
/// 用穷尽 enum 表 mismatch(card 表:`SchemaHealth { ok, error: Option<SchemaError> }`)。
|
|
293
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
294
|
-
pub struct SchemaHealth {
|
|
295
|
-
/// `schema_ok`(`lifecycle.py:222/201`)。
|
|
296
|
-
pub ok: bool,
|
|
297
|
-
/// 当前 `MessageStore::SCHEMA_VERSION`(`lifecycle.py:198`)。
|
|
298
|
-
pub schema_version: i64,
|
|
299
|
-
/// `None` ⇔ `ok == true`。
|
|
300
|
-
pub error: Option<SchemaError>,
|
|
301
|
-
/// 修复 hint(`_SCHEMA_ACTION_HINT`,`lifecycle.py:131-135`);仅 error 时填。
|
|
302
|
-
pub action: Option<String>,
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
/// schema mismatch 的穷尽分类(`_diagnose_schema_mismatch`,`lifecycle.py:164-194`)。
|
|
306
|
-
/// 区分「pre-init 必需列缺失」(拒启)vs「migratable 列缺失」(可迁移)——card §89 铁律。
|
|
307
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
308
|
-
pub enum SchemaError {
|
|
309
|
-
/// pragma table_info vs expected 列集不符(`lifecycle.py:185-191`)。携带定位字段。
|
|
310
|
-
SchemaMismatch {
|
|
311
|
-
table: String,
|
|
312
|
-
expected_columns: Vec<String>,
|
|
313
|
-
actual_columns: Vec<String>,
|
|
314
|
-
missing_columns: Vec<String>,
|
|
315
|
-
/// pre-init 必需列(true)vs migratable(false)——决定拒启 vs 可迁移(card §89)。
|
|
316
|
-
pre_init_required: bool,
|
|
317
|
-
},
|
|
318
|
-
/// `MessageStore(workspace)` 构造抛异常(`lifecycle.py:213`),携带原文。
|
|
319
|
-
InitFailed { message: String },
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
// ===========================================================================
|
|
323
|
-
// health / start / stop report 结构(lifecycle.py:39-247 typed 版)
|
|
324
|
-
// ===========================================================================
|
|
325
|
-
|
|
326
|
-
/// `start_coordinator` 错误(spawn 子进程 / ensure dirs 失败)。lib 边界 thiserror(§12)。
|
|
327
|
-
#[derive(Debug, Error)]
|
|
328
|
-
pub enum StartError {
|
|
329
|
-
#[error("io: {0}")]
|
|
330
|
-
Io(#[from] std::io::Error),
|
|
331
|
-
#[error("event log: {0}")]
|
|
332
|
-
EventLog(#[from] crate::event_log::EventLogError),
|
|
333
|
-
#[error("message store: {0}")]
|
|
334
|
-
MessageStore(#[from] crate::message_store::MessageStoreError),
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
/// `stop_coordinator` 错误。
|
|
338
|
-
#[derive(Debug, Error)]
|
|
339
|
-
pub enum StopError {
|
|
340
|
-
#[error("io: {0}")]
|
|
341
|
-
Io(#[from] std::io::Error),
|
|
342
|
-
#[error("event log: {0}")]
|
|
343
|
-
EventLog(#[from] crate::event_log::EventLogError),
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
/// `coordinator_health` 结果(`lifecycle.py:39-46` typed 版)。
|
|
347
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
348
|
-
pub struct HealthReport {
|
|
349
|
-
/// `running ∧ metadata_ok ∧ schema_ok`(`lifecycle.py:38`)。
|
|
350
|
-
pub ok: bool,
|
|
351
|
-
pub status: CoordinatorHealthStatus,
|
|
352
|
-
pub pid: Option<Pid>,
|
|
353
|
-
pub metadata: Option<CoordinatorMetadata>,
|
|
354
|
-
/// 三元全等(`coordinator_metadata_ok`,`metadata.py:37-43`)。
|
|
355
|
-
pub metadata_ok: bool,
|
|
356
|
-
pub process_running: bool,
|
|
357
|
-
/// pid/protocol/schema match; excludes daemon binary identity.
|
|
358
|
-
pub wire_metadata_ok: bool,
|
|
359
|
-
pub binary_identity_ok: bool,
|
|
360
|
-
pub binary_identity_relation: CoordinatorBinaryIdentityRelation,
|
|
361
|
-
/// A live daemon that can process this workspace's queue.
|
|
362
|
-
pub service_available: bool,
|
|
363
|
-
pub metadata_mismatch_reason: Option<String>,
|
|
364
|
-
pub current_binary_identity: CoordinatorBinaryIdentity,
|
|
365
|
-
pub schema: SchemaHealth,
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
/// `start_coordinator` 结果(`lifecycle.py:54/86/121` typed 版)。
|
|
369
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
370
|
-
pub struct StartReport {
|
|
371
|
-
pub ok: bool,
|
|
372
|
-
pub pid: Option<Pid>,
|
|
373
|
-
pub status: StartOutcome,
|
|
374
|
-
pub previous_pid: Option<Pid>,
|
|
375
|
-
pub binary_path: Option<String>,
|
|
376
|
-
pub binary_version: Option<String>,
|
|
377
|
-
pub rotation_reason: Option<String>,
|
|
378
|
-
/// 0.5.41 Slice 3 (fault-invisibility-locate.md §5/§9 RED3): typed
|
|
379
|
-
/// binary-identity relation between the caller and the daemon that
|
|
380
|
-
/// was observed. Populated on every path (unknown when the health
|
|
381
|
-
/// probe returned no metadata). Downstream `coordinator_start_
|
|
382
|
-
/// summary_value` exposes this so restart/start summaries no longer
|
|
383
|
-
/// flatten `daemon_newer_than_caller` into a plain `already_running`
|
|
384
|
-
/// (RED3: caller-older-than-daemon must remain distinguishable
|
|
385
|
-
/// from a same-binary fresh daemon).
|
|
386
|
-
pub binary_identity_relation: CoordinatorBinaryIdentityRelation,
|
|
387
|
-
/// coordinator.log 路径(成功路径,`lifecycle.py:54/121`)。
|
|
388
|
-
pub log: Option<PathBuf>,
|
|
389
|
-
/// schema_incompatible 时的修复 hint / 失败原因。
|
|
390
|
-
pub schema_error: Option<SchemaError>,
|
|
391
|
-
pub action: Option<String>,
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
/// `stop_coordinator` 结果(`lifecycle.py:232-247` typed 版)。
|
|
395
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
396
|
-
pub struct StopReport {
|
|
397
|
-
pub ok: bool,
|
|
398
|
-
pub status: StopOutcome,
|
|
399
|
-
pub pid: Option<Pid>,
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
// ===========================================================================
|
|
403
|
-
// 异常轨 abnormal_track(abnormal_track.py)—— provider-neutral 数据型
|
|
404
|
-
// ===========================================================================
|
|
405
|
-
|
|
406
|
-
/// `detect_whole_team_gone` 分类(`abnormal_track.py:130/132/143`)。
|
|
407
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
408
|
-
#[serde(rename_all = "snake_case")]
|
|
409
|
-
pub enum WholeTeamGoneClass {
|
|
410
|
-
Alive,
|
|
411
|
-
/// clean shutdown → 静默(`abnormal_track.py:130`)。
|
|
412
|
-
CleanShutdown,
|
|
413
|
-
/// restart 进行中 → 静默(`abnormal_track.py:132`)。
|
|
414
|
-
RestartInProgress,
|
|
415
|
-
/// 闪退 → durable marker + deferred escalation(`abnormal_track.py:143`)。
|
|
416
|
-
UnexpectedExit,
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
/// `detect_whole_team_gone` 返回(`abnormal_track.py:140-147` typed 版)。
|
|
420
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
421
|
-
pub struct WholeTeamGoneReport {
|
|
422
|
-
pub whole_team_gone: bool,
|
|
423
|
-
pub classification: WholeTeamGoneClass,
|
|
424
|
-
pub notify: bool,
|
|
425
|
-
/// 仅 unexpected exit 时 true(`abnormal_track.py:145`):延迟到下条 leader 命令再 escalate。
|
|
426
|
-
pub escalate_user_on_next_leader_command: bool,
|
|
427
|
-
pub marker_written: bool,
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
/// 整队存活快照(`detect_whole_team_gone` 的 snapshot 入参,`abnormal_track.py:105-116`)。
|
|
431
|
-
/// coordinator-independent:不依赖 coordinator 活着也能判。
|
|
432
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
433
|
-
pub struct TeamPresenceSnapshot {
|
|
434
|
-
pub coordinator_alive: bool,
|
|
435
|
-
pub leader_alive: bool,
|
|
436
|
-
/// 每 worker 进程存活(`provider_state` liveness;`ProcessLiveness::Alive` 才算活)。
|
|
437
|
-
pub provider_processes_alive: Vec<bool>,
|
|
438
|
-
pub tmux_sessions_present: bool,
|
|
439
|
-
pub clean_shutdown: bool,
|
|
440
|
-
pub restart_in_progress: bool,
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
// ===========================================================================
|
|
444
|
-
// CROSS-DEP placeholders(其他并行 lane 拥有真名;leader 集成时 reconcile)
|
|
445
|
-
// ===========================================================================
|
|
446
|
-
// 下列类型/trait 是 tick 编排与异常轨命名到的、由 OTHER 10-15 子系统(step 8 provider、
|
|
447
|
-
// step 11 messaging、step 5 state projection)拥有的面。本 lane 给最小本地占位让 coordinator
|
|
448
|
-
// 的签名编得过;leader 集成时把它们换成真名(见 cross_deps_or_placeholders 清单)。
|
|
449
|
-
|
|
450
|
-
/// agent id(step 2/5 拥有 newtype;tick stuck 列表 / idle node 用)。
|
|
451
|
-
/// **PLACEHOLDER**:与 `crate::model::ids::AgentId` 同名同义,但 ids.rs 已定义 —— 集成时直接
|
|
452
|
-
/// `use crate::model::ids::AgentId` 替换本地别名。此处用本地 type alias 避免重定义冲突。
|
|
453
|
-
pub use crate::model::ids::AgentId;
|
|
454
|
-
|
|
455
|
-
/// provider adapter 解析器(`get_provider_registry` / `ADAPTERS` map 的 trait 版,step 8 拥有真名)。
|
|
456
|
-
/// **PLACEHOLDER**:step 8 provider lane 会给真正的 registry 类型;本 trait 是 coordinator 注入点
|
|
457
|
-
/// (MUST-NOT-13:经 trait 调,绝不依赖 provider client crate)。
|
|
458
|
-
pub trait ProviderRegistry {
|
|
459
|
-
/// 拿某 provider 的 adapter(`providers.get_adapter`)。
|
|
460
|
-
fn adapter_for(&self, provider: Provider) -> Box<dyn ProviderAdapter>;
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
/// idle take-over 候选 node(`idle_takeover_wiring.build_idle_nodes`,step 8/11 拥有真名)。
|
|
464
|
-
/// **PLACEHOLDER**:bug-085 关键 —— `state` 是穷尽 `TurnState`,`rollout_path` 是 `Option`
|
|
465
|
-
/// (None 漏穿曾误判 unknown→idle)。
|
|
466
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
467
|
-
pub struct IdleNode {
|
|
468
|
-
pub node_id: AgentId,
|
|
469
|
-
pub state: TurnState,
|
|
470
|
-
pub provider: Option<Provider>,
|
|
471
|
-
pub rollout_path: Option<RolloutPath>,
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
/// idle take-over 提醒(`lifecycle.py:304-307`)。**PLACEHOLDER**(step 11 messaging 拥有 alert 形状)。
|
|
475
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
476
|
-
pub struct IdleAlert {
|
|
477
|
-
pub message: Option<String>,
|
|
478
|
-
pub reason: Option<String>,
|
|
479
|
-
pub interrupted: Vec<AgentId>,
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
/// `_deliver_pending_messages` 投递记录(`delivery.py:484`,step 11 拥有)。**PLACEHOLDER**。
|
|
483
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
484
|
-
pub struct DeliveredMessage {
|
|
485
|
-
pub message_id: String,
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
/// `_fire_due_scheduled_events` 触发记录(`scheduler.py:41`,step 11 拥有)。**PLACEHOLDER**。
|
|
489
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
490
|
-
pub struct FiredScheduledEvent {
|
|
491
|
-
pub id: i64,
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
/// `detect_cross_worker_deadlocks` 告警(`messaging/idle_alerts.py`,step 11 拥有)。**PLACEHOLDER**。
|
|
495
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
496
|
-
pub struct DeadlockAlert {
|
|
497
|
-
pub raw: Value,
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
/// `detect_compaction_degradation` 结果(`messaging/activity_detector.py`,step 11 拥有)。**PLACEHOLDER**。
|
|
501
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
502
|
-
pub struct CompactionResult {
|
|
503
|
-
pub agent_id: AgentId,
|
|
504
|
-
pub provider: Option<Provider>,
|
|
505
|
-
pub observed: bool,
|
|
506
|
-
pub reason: Option<String>,
|
|
507
|
-
pub recommendation: Option<String>,
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
/// `detect_session_drift` 结果(`messaging/session_drift.py`,step 11 拥有)。**PLACEHOLDER**。
|
|
511
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
512
|
-
pub struct SessionDriftResult {
|
|
513
|
-
pub agent_id: AgentId,
|
|
514
|
-
pub stored_session_id: Option<String>,
|
|
515
|
-
pub observed_session_id: Option<String>,
|
|
516
|
-
pub status: String,
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
/// `detect_leader_api_errors` 结果(`messaging/leader_api_errors.py`,step 11 拥有)。**PLACEHOLDER**。
|
|
520
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
521
|
-
pub struct LeaderApiError {
|
|
522
|
-
pub provider: Option<Provider>,
|
|
523
|
-
pub pane_id: Option<String>,
|
|
524
|
-
pub fingerprint: String,
|
|
525
|
-
pub message: String,
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
/// Result projection reported by a coordinator tick. Report results now finalize inline.
|
|
529
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
530
|
-
pub struct CollectedResult {
|
|
531
|
-
pub result_id: String,
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
/// durable marker store(`detect_whole_team_gone` 的 marker_store 入参,`abnormal_track.py:226-239`)。
|
|
535
|
-
/// **PLACEHOLDER**:step 5 state / step 7 message_store 可能拥有真正的 marker 存储面;
|
|
536
|
-
/// 本 trait 是 abnormal track 的注入点(写 `whole_team_gone` durable marker)。
|
|
537
|
-
pub trait MarkerStore {
|
|
538
|
-
/// 写一个命名 marker;返回是否落盘成功(`abnormal_track.py:232-238`)。
|
|
539
|
-
fn set_marker(&mut self, name: &str, value: Value) -> bool;
|
|
540
|
-
}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
//!
|
|
2
|
-
//! Phase-DX E2: `agent_health` row capture/restore for the remove-agent flow.
|
|
3
|
-
//!
|
|
4
|
-
//! Extracted from `lifecycle/restart/remove.rs` so the SQL column reference to
|
|
5
|
-
//! `current_task_id` sits in the persistence layer (whitelisted by the E2 grep
|
|
6
|
-
//! guard) rather than in lifecycle policy code. Semantics are the golden Python
|
|
7
|
-
//! `_capture_agent_health` / `_restore_agent_health` — a plain
|
|
8
|
-
//! backup-across-delete that never treats the stored column as authoritative
|
|
9
|
-
//! task state.
|
|
10
|
-
|
|
11
|
-
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
|
|
12
|
-
|
|
13
|
-
use std::path::Path;
|
|
14
|
-
|
|
15
|
-
use crate::model::ids::AgentId;
|
|
16
|
-
|
|
17
|
-
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
18
|
-
pub struct CapturedHealth {
|
|
19
|
-
pub owner_team_id: Option<String>,
|
|
20
|
-
pub status: Option<String>,
|
|
21
|
-
pub last_output_at: Option<String>,
|
|
22
|
-
pub context_usage_pct: Option<i64>,
|
|
23
|
-
pub current_task_id: Option<String>,
|
|
24
|
-
pub updated_at: String,
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/// golden agents.py:185 `copy.deepcopy(store.agent_health().get(agent_id))` — read the row BEFORE
|
|
28
|
-
/// delete so the rollback can re-upsert it. Returns the captured columns, or `None` if the row is
|
|
29
|
-
/// absent.
|
|
30
|
-
pub fn select_agent_health(
|
|
31
|
-
workspace: &Path,
|
|
32
|
-
owner_team_id: &str,
|
|
33
|
-
agent_id: &AgentId,
|
|
34
|
-
) -> Result<Option<CapturedHealth>, crate::db::DbError> {
|
|
35
|
-
let store = crate::message_store::MessageStore::open(workspace)
|
|
36
|
-
.map_err(|e| crate::db::DbError::Schema(e.to_string()))?;
|
|
37
|
-
let conn = crate::db::schema::open_db(store.db_path())?;
|
|
38
|
-
let row = conn
|
|
39
|
-
.query_row(
|
|
40
|
-
"select owner_team_id, status, last_output_at, context_usage_pct, current_task_id, updated_at \
|
|
41
|
-
from agent_health where owner_team_id = ?1 and agent_id = ?2",
|
|
42
|
-
rusqlite::params![owner_team_id, agent_id.as_str()],
|
|
43
|
-
|r| {
|
|
44
|
-
Ok(CapturedHealth {
|
|
45
|
-
owner_team_id: r.get::<_, Option<String>>(0)?,
|
|
46
|
-
status: r.get::<_, Option<String>>(1)?,
|
|
47
|
-
last_output_at: r.get::<_, Option<String>>(2)?,
|
|
48
|
-
context_usage_pct: r.get::<_, Option<i64>>(3)?,
|
|
49
|
-
current_task_id: r.get::<_, Option<String>>(4)?,
|
|
50
|
-
updated_at: r.get::<_, String>(5)?,
|
|
51
|
-
})
|
|
52
|
-
},
|
|
53
|
-
)
|
|
54
|
-
.ok();
|
|
55
|
-
Ok(row)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/// golden agents.py:268-278 `_restore_agent_health`: re-upsert the captured row (status||"IDLE"),
|
|
59
|
-
/// or delete the row when there was nothing to restore.
|
|
60
|
-
pub fn restore_agent_health(
|
|
61
|
-
workspace: &Path,
|
|
62
|
-
owner_team_id: &str,
|
|
63
|
-
agent_id: &AgentId,
|
|
64
|
-
row: &Option<CapturedHealth>,
|
|
65
|
-
) -> Result<(), crate::db::DbError> {
|
|
66
|
-
let Some(row) = row else {
|
|
67
|
-
return delete_agent_health(workspace, owner_team_id, agent_id);
|
|
68
|
-
};
|
|
69
|
-
let store = crate::message_store::MessageStore::open(workspace)
|
|
70
|
-
.map_err(|e| crate::db::DbError::Schema(e.to_string()))?;
|
|
71
|
-
let conn = crate::db::schema::open_db(store.db_path())?;
|
|
72
|
-
let status = row.status.clone().unwrap_or_else(|| "IDLE".to_string());
|
|
73
|
-
conn.execute(
|
|
74
|
-
"insert into agent_health (owner_team_id, agent_id, status, last_output_at, context_usage_pct, current_task_id, updated_at) \
|
|
75
|
-
values (?1, ?2, ?3, ?4, ?5, ?6, ?7)",
|
|
76
|
-
rusqlite::params![
|
|
77
|
-
owner_team_id,
|
|
78
|
-
agent_id.as_str(),
|
|
79
|
-
status,
|
|
80
|
-
row.last_output_at,
|
|
81
|
-
row.context_usage_pct,
|
|
82
|
-
row.current_task_id,
|
|
83
|
-
row.updated_at,
|
|
84
|
-
],
|
|
85
|
-
)?;
|
|
86
|
-
Ok(())
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
fn delete_agent_health(
|
|
90
|
-
workspace: &Path,
|
|
91
|
-
owner_team_id: &str,
|
|
92
|
-
agent_id: &AgentId,
|
|
93
|
-
) -> Result<(), crate::db::DbError> {
|
|
94
|
-
let store = crate::message_store::MessageStore::open(workspace)
|
|
95
|
-
.map_err(|e| crate::db::DbError::Schema(e.to_string()))?;
|
|
96
|
-
let conn = crate::db::schema::open_db(store.db_path())?;
|
|
97
|
-
conn.execute(
|
|
98
|
-
"delete from agent_health where owner_team_id = ?1 and agent_id = ?2",
|
|
99
|
-
rusqlite::params![owner_team_id, agent_id.as_str()],
|
|
100
|
-
)?;
|
|
101
|
-
Ok(())
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/// 0.5.32 (`.team/artifacts/restart-resumed-stale-activity-locate.md` §5):
|
|
105
|
-
/// clear the `(owner_team_id, agent_id)` health observation row on a new
|
|
106
|
-
/// worker process cohort boundary. Distinct from `delete_agent_health` (used
|
|
107
|
-
/// by remove-agent rollback): this narrow helper keyed on both owner_team_id
|
|
108
|
-
/// and agent_id so a sibling team with the same agent_id keeps its own row.
|
|
109
|
-
/// Silently no-ops when the row is absent.
|
|
110
|
-
pub fn clear_agent_health_observation(
|
|
111
|
-
workspace: &Path,
|
|
112
|
-
owner_team_id: &str,
|
|
113
|
-
agent_id: &AgentId,
|
|
114
|
-
) -> Result<(), crate::db::DbError> {
|
|
115
|
-
if owner_team_id.is_empty() {
|
|
116
|
-
return Ok(());
|
|
117
|
-
}
|
|
118
|
-
let store = crate::message_store::MessageStore::open(workspace)
|
|
119
|
-
.map_err(|e| crate::db::DbError::Schema(e.to_string()))?;
|
|
120
|
-
let conn = crate::db::schema::open_db(store.db_path())?;
|
|
121
|
-
conn.execute(
|
|
122
|
-
"delete from agent_health where owner_team_id = ?1 and agent_id = ?2",
|
|
123
|
-
rusqlite::params![owner_team_id, agent_id.as_str()],
|
|
124
|
-
)?;
|
|
125
|
-
Ok(())
|
|
126
|
-
}
|