@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,223 +0,0 @@
|
|
|
1
|
-
//!
|
|
2
|
-
//! Scheduled-event dispatch and coordinator stuck detection (card §18/§68/§73).
|
|
3
|
-
|
|
4
|
-
use std::path::Path;
|
|
5
|
-
|
|
6
|
-
use rusqlite::params;
|
|
7
|
-
|
|
8
|
-
use crate::event_log::EventLog;
|
|
9
|
-
use crate::message_store::MessageStore;
|
|
10
|
-
use crate::transport::{PaneId, Transport};
|
|
11
|
-
|
|
12
|
-
use super::delivery::{deliver_stored_message, handle_trust_retry_needed};
|
|
13
|
-
use super::helpers::{parse_scheduled_kind, status_wire};
|
|
14
|
-
use super::{MessagingError, ScheduledKind, TrustRetryPayload, TRUST_RETRY_MAX_ATTEMPTS};
|
|
15
|
-
|
|
16
|
-
/// `_fire_due_scheduled_events` (`scheduler.py:41`):coordinator tick 的调度器心脏 —— 分派到期
|
|
17
|
-
/// `send`/`health_ping`/`trust_retry` ([`ScheduledKind`] 穷尽 match),send 失败有界重试。
|
|
18
|
-
/// 返回 fired 的 scheduled_event id 列表。**daemon-path** (step 12 调) → Result。
|
|
19
|
-
pub fn fire_due_scheduled_events(
|
|
20
|
-
workspace: &Path,
|
|
21
|
-
store: &MessageStore,
|
|
22
|
-
transport: &dyn Transport,
|
|
23
|
-
event_log: &EventLog,
|
|
24
|
-
) -> Result<Vec<i64>, MessagingError> {
|
|
25
|
-
let _ = transport;
|
|
26
|
-
let conn = crate::db::schema::open_db(store.db_path())?;
|
|
27
|
-
let due_events = {
|
|
28
|
-
let mut stmt = conn.prepare(
|
|
29
|
-
"select id, kind, target, payload_json from scheduled_events where status = 'pending' and due_at <= ?1 order by due_at, id",
|
|
30
|
-
)?;
|
|
31
|
-
let rows = stmt.query_map(params![chrono::Utc::now().to_rfc3339()], |row| {
|
|
32
|
-
Ok((
|
|
33
|
-
row.get::<_, i64>(0)?,
|
|
34
|
-
row.get::<_, String>(1)?,
|
|
35
|
-
row.get::<_, String>(2)?,
|
|
36
|
-
row.get::<_, String>(3)?,
|
|
37
|
-
))
|
|
38
|
-
})?;
|
|
39
|
-
rows.collect::<Result<Vec<_>, _>>()?
|
|
40
|
-
};
|
|
41
|
-
let mut fired = Vec::new();
|
|
42
|
-
for (id, kind, target, payload_json) in due_events {
|
|
43
|
-
if matches!(parse_scheduled_kind(&kind), Ok(ScheduledKind::EnterRescue)) {
|
|
44
|
-
// This kind owns its pre-effect CAS and terminal/no-effect transitions.
|
|
45
|
-
if super::enter_rescue::fire(workspace, store, transport, event_log, id, &payload_json)? {
|
|
46
|
-
fired.push(id);
|
|
47
|
-
}
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
// U1 #5: per-event isolation — one poison event (bad payload / fire error) must not
|
|
51
|
-
// halt the whole pass. The fire body is confined to a closure; on Err we emit
|
|
52
|
-
// `scheduler.event_failed`, mark the row terminal 'failed' (no re-fire), and continue.
|
|
53
|
-
let fire_one = || -> Result<serde_json::Value, MessagingError> {
|
|
54
|
-
let scheduled_kind = parse_scheduled_kind(&kind)?;
|
|
55
|
-
let result = match scheduled_kind {
|
|
56
|
-
ScheduledKind::Reminder => super::reminders::fire(workspace, id, event_log)?,
|
|
57
|
-
ScheduledKind::Send => {
|
|
58
|
-
let payload: serde_json::Value = serde_json::from_str(&payload_json)?;
|
|
59
|
-
let outcome = deliver_stored_message(
|
|
60
|
-
workspace,
|
|
61
|
-
Some(&target),
|
|
62
|
-
payload
|
|
63
|
-
.get("content")
|
|
64
|
-
.and_then(|v| v.as_str())
|
|
65
|
-
.unwrap_or(""),
|
|
66
|
-
None,
|
|
67
|
-
payload
|
|
68
|
-
.get("sender")
|
|
69
|
-
.and_then(|v| v.as_str())
|
|
70
|
-
.unwrap_or("leader"),
|
|
71
|
-
payload
|
|
72
|
-
.get("requires_ack")
|
|
73
|
-
.and_then(|v| v.as_bool())
|
|
74
|
-
.unwrap_or(false),
|
|
75
|
-
payload
|
|
76
|
-
.get("wait_visible")
|
|
77
|
-
.and_then(|v| v.as_bool())
|
|
78
|
-
.unwrap_or(false),
|
|
79
|
-
payload
|
|
80
|
-
.get("timeout")
|
|
81
|
-
.and_then(|v| v.as_f64())
|
|
82
|
-
.unwrap_or(30.0),
|
|
83
|
-
None,
|
|
84
|
-
)?;
|
|
85
|
-
serde_json::json!({
|
|
86
|
-
"ok": outcome.ok,
|
|
87
|
-
"status": status_wire(outcome.status),
|
|
88
|
-
"message_id": outcome.message_id,
|
|
89
|
-
})
|
|
90
|
-
}
|
|
91
|
-
ScheduledKind::EnterRescue => return Err(MessagingError::Validation("enter rescue requires atomic dispatcher".into())),
|
|
92
|
-
ScheduledKind::HealthPing => {
|
|
93
|
-
event_log.write(
|
|
94
|
-
"scheduled.health_ping",
|
|
95
|
-
serde_json::json!({"event_id": id, "target": target}),
|
|
96
|
-
)?;
|
|
97
|
-
serde_json::json!({"ok": true, "status": "logged"})
|
|
98
|
-
}
|
|
99
|
-
ScheduledKind::TrustRetry => {
|
|
100
|
-
let payload: serde_json::Value = serde_json::from_str(&payload_json)?;
|
|
101
|
-
let outcome = handle_trust_retry_needed(
|
|
102
|
-
store,
|
|
103
|
-
&TrustRetryPayload {
|
|
104
|
-
message_id: payload
|
|
105
|
-
.get("message_id")
|
|
106
|
-
.and_then(|v| v.as_str())
|
|
107
|
-
.unwrap_or_default()
|
|
108
|
-
.to_string(),
|
|
109
|
-
attempt: payload
|
|
110
|
-
.get("attempt")
|
|
111
|
-
.and_then(|v| v.as_u64())
|
|
112
|
-
.and_then(|v| u8::try_from(v).ok())
|
|
113
|
-
.unwrap_or(1),
|
|
114
|
-
max_attempts: payload
|
|
115
|
-
.get("max_attempts")
|
|
116
|
-
.and_then(|v| v.as_u64())
|
|
117
|
-
.and_then(|v| u8::try_from(v).ok())
|
|
118
|
-
.unwrap_or(TRUST_RETRY_MAX_ATTEMPTS),
|
|
119
|
-
first_target: PaneId::new(
|
|
120
|
-
payload
|
|
121
|
-
.get("first_target")
|
|
122
|
-
.and_then(|v| v.as_str())
|
|
123
|
-
.unwrap_or(""),
|
|
124
|
-
),
|
|
125
|
-
},
|
|
126
|
-
event_log,
|
|
127
|
-
)?;
|
|
128
|
-
serde_json::json!({"ok": outcome.ok, "status": status_wire(outcome.status)})
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
Ok(result)
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
let (status, result_json) = match fire_one() {
|
|
135
|
-
Ok(result) => {
|
|
136
|
-
// Reminder dispatch owns recurrence advancement and cancellation.
|
|
137
|
-
if kind == "reminder" {
|
|
138
|
-
fired.push(id);
|
|
139
|
-
continue;
|
|
140
|
-
}
|
|
141
|
-
let ok = result
|
|
142
|
-
.get("ok")
|
|
143
|
-
.and_then(serde_json::Value::as_bool)
|
|
144
|
-
.unwrap_or(false);
|
|
145
|
-
(if ok { "done" } else { "failed" }, result.to_string())
|
|
146
|
-
}
|
|
147
|
-
Err(error) => {
|
|
148
|
-
// Poison event: loud + terminal, never halts the pass or re-fires.
|
|
149
|
-
let _ = event_log.write(
|
|
150
|
-
"scheduler.event_failed",
|
|
151
|
-
serde_json::json!({
|
|
152
|
-
"event_id": id,
|
|
153
|
-
"kind": kind,
|
|
154
|
-
"error": error.to_string(),
|
|
155
|
-
}),
|
|
156
|
-
);
|
|
157
|
-
(
|
|
158
|
-
"failed",
|
|
159
|
-
serde_json::json!({"ok": false, "status": "failed", "error": error.to_string()})
|
|
160
|
-
.to_string(),
|
|
161
|
-
)
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
// The row-status write stays `?`: a DB write failure is a real store fault, not a
|
|
165
|
-
// per-event poison, and should surface (consistent with the rest of the fn).
|
|
166
|
-
conn.execute(
|
|
167
|
-
"update scheduled_events set status = ?2, fired_at = ?3, result_json = ?4 where id = ?1 and status = 'pending'",
|
|
168
|
-
params![id, status, chrono::Utc::now().to_rfc3339(), result_json],
|
|
169
|
-
)?;
|
|
170
|
-
fired.push(id);
|
|
171
|
-
}
|
|
172
|
-
Ok(fired)
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/// `_detect_stuck_agents` (`scheduler.py:146`):stuck 检测。**§84 守门**:`_agent_has_stuck_relevant_work`
|
|
176
|
-
/// 仅在有 active task / inbound message 时推送,无 pending obligation 时绝不注入探索性 prompt。
|
|
177
|
-
pub fn detect_stuck_agents(
|
|
178
|
-
workspace: &Path,
|
|
179
|
-
state: &serde_json::Value,
|
|
180
|
-
store: &MessageStore,
|
|
181
|
-
event_log: &EventLog,
|
|
182
|
-
) -> Result<Vec<String>, MessagingError> {
|
|
183
|
-
let _ = (workspace, event_log);
|
|
184
|
-
let team = crate::state::projection::team_state_key(state);
|
|
185
|
-
let conn = crate::db::schema::open_db(store.db_path())?;
|
|
186
|
-
let mut stmt = conn.prepare(
|
|
187
|
-
"select agent_id, last_output_at from agent_health
|
|
188
|
-
where upper(status) in ('RUNNING', 'WORKING')
|
|
189
|
-
and owner_team_id = ?1
|
|
190
|
-
and last_output_at is not null
|
|
191
|
-
and exists (
|
|
192
|
-
select 1 from messages
|
|
193
|
-
where recipient = agent_health.agent_id
|
|
194
|
-
and status in (
|
|
195
|
-
'pending', 'accepted', 'queued_until_idle', 'queued_until_start',
|
|
196
|
-
'queued_stopped', 'queued_pane_missing', 'target_resolved',
|
|
197
|
-
'injected', 'visible', 'submitted', 'submitted_unverified', 'delivered'
|
|
198
|
-
)
|
|
199
|
-
)
|
|
200
|
-
order by agent_id",
|
|
201
|
-
)?;
|
|
202
|
-
let rows = stmt.query_map(params![team], |row| {
|
|
203
|
-
Ok((row.get::<_, String>(0)?, row.get::<_, String>(1)?))
|
|
204
|
-
})?;
|
|
205
|
-
let mut stuck = Vec::new();
|
|
206
|
-
for row in rows {
|
|
207
|
-
let (agent_id, last_output_at) = row?;
|
|
208
|
-
if output_is_stale(&last_output_at, 300) {
|
|
209
|
-
stuck.push(agent_id);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
Ok(stuck)
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
fn output_is_stale(last_output_at: &str, timeout_seconds: i64) -> bool {
|
|
216
|
-
let Ok(ts) = chrono::DateTime::parse_from_rfc3339(last_output_at) else {
|
|
217
|
-
return false;
|
|
218
|
-
};
|
|
219
|
-
chrono::Utc::now()
|
|
220
|
-
.signed_duration_since(ts.with_timezone(&chrono::Utc))
|
|
221
|
-
.num_seconds()
|
|
222
|
-
>= timeout_seconds
|
|
223
|
-
}
|
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
//! diagnose/comms.py — comms selftest (零 token / 零 provider SDK;card §31/§75)。
|
|
2
|
-
|
|
3
|
-
use std::path::Path;
|
|
4
|
-
|
|
5
|
-
use crate::message_store::MessageStore;
|
|
6
|
-
use crate::model::ids::TeamKey;
|
|
7
|
-
|
|
8
|
-
use super::helpers::next_run_id;
|
|
9
|
-
use super::{
|
|
10
|
-
CheckEvidence, CheckKind, CheckStatus, ContractSuiteCheck, IdleEvaluation, MessagingError,
|
|
11
|
-
ProviderSdkCalls, SelftestCheck, SelftestReport,
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
/// selftest driver (`diagnose/comms.py` `CommsSelftestDriver`):**零 token / 零 provider SDK**
|
|
15
|
-
/// 注入面 (§84/MUST-NOT-13)。trait mock + 断言调用计数 = 0。
|
|
16
|
-
pub trait CommsSelftestDriver {
|
|
17
|
-
/// 此 run 的稳定 id (None → 随机 hex[:12])。
|
|
18
|
-
fn run_id(&self) -> Option<String>;
|
|
19
|
-
/// provider SDK 调用计数 (机械门:必须全 0)。
|
|
20
|
-
fn provider_sdk_calls(&self) -> ProviderSdkCalls;
|
|
21
|
-
/// receiver binding 一致性快照 (供 `_receiver_binding_check`)。
|
|
22
|
-
fn receiver_binding(&self, workspace: &Path, team: Option<&TeamKey>) -> serde_json::Value;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/// `run_comms_selftest` (`diagnose/comms.py:21`):binding 一致性 + **零 provider SDK 调用断言**。
|
|
26
|
-
/// §10/§84 机械门 selftest 落点 —— **零 token,零 provider SDK 调用**,走 [`CommsSelftestDriver`]
|
|
27
|
-
/// trait mock。CLI `selftest` + 诊断调。
|
|
28
|
-
pub fn run_comms_selftest(
|
|
29
|
-
workspace: &Path,
|
|
30
|
-
team: Option<&TeamKey>,
|
|
31
|
-
driver: &dyn CommsSelftestDriver,
|
|
32
|
-
) -> Result<SelftestReport, MessagingError> {
|
|
33
|
-
let run_id = driver.run_id().unwrap_or_else(next_run_id);
|
|
34
|
-
let binding = driver.receiver_binding(workspace, team);
|
|
35
|
-
let mismatches = binding
|
|
36
|
-
.get("mismatches")
|
|
37
|
-
.and_then(|v| v.as_array())
|
|
38
|
-
.map(|items| {
|
|
39
|
-
items
|
|
40
|
-
.iter()
|
|
41
|
-
.filter_map(|v| v.as_str().map(ToString::to_string))
|
|
42
|
-
.collect::<Vec<_>>()
|
|
43
|
-
})
|
|
44
|
-
.unwrap_or_default();
|
|
45
|
-
let receiver_status = if mismatches.is_empty() {
|
|
46
|
-
CheckStatus::Pass
|
|
47
|
-
} else {
|
|
48
|
-
CheckStatus::Fail
|
|
49
|
-
};
|
|
50
|
-
let calls = driver.provider_sdk_calls();
|
|
51
|
-
let provider_status = if calls.is_zero() {
|
|
52
|
-
CheckStatus::Pass
|
|
53
|
-
} else {
|
|
54
|
-
CheckStatus::Fail
|
|
55
|
-
};
|
|
56
|
-
let contract_checks = run_contract_suite(workspace, team, &run_id);
|
|
57
|
-
let contract_status = if contract_checks
|
|
58
|
-
.iter()
|
|
59
|
-
.all(|check| check.status == CheckStatus::Pass)
|
|
60
|
-
{
|
|
61
|
-
CheckStatus::Pass
|
|
62
|
-
} else {
|
|
63
|
-
CheckStatus::Fail
|
|
64
|
-
};
|
|
65
|
-
let receiver_binding = SelftestCheck {
|
|
66
|
-
status: receiver_status,
|
|
67
|
-
verifies: CheckKind::ReceiverBinding,
|
|
68
|
-
evidence: CheckEvidence::Binding {
|
|
69
|
-
mismatches,
|
|
70
|
-
details: binding,
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
let contract_suite = SelftestCheck {
|
|
74
|
-
status: contract_status,
|
|
75
|
-
verifies: CheckKind::ContractSuite,
|
|
76
|
-
evidence: CheckEvidence::ContractSuite {
|
|
77
|
-
checks: contract_checks,
|
|
78
|
-
},
|
|
79
|
-
};
|
|
80
|
-
let provider_sdk_calls = SelftestCheck {
|
|
81
|
-
status: provider_status,
|
|
82
|
-
verifies: CheckKind::NoProviderSdkCalls,
|
|
83
|
-
evidence: CheckEvidence::ProviderSdkCalls(calls),
|
|
84
|
-
};
|
|
85
|
-
let ok = receiver_binding.status == CheckStatus::Pass
|
|
86
|
-
&& contract_suite.status == CheckStatus::Pass
|
|
87
|
-
&& provider_sdk_calls.status == CheckStatus::Pass;
|
|
88
|
-
Ok(SelftestReport {
|
|
89
|
-
ok,
|
|
90
|
-
status: if ok {
|
|
91
|
-
CheckStatus::Pass
|
|
92
|
-
} else {
|
|
93
|
-
CheckStatus::Fail
|
|
94
|
-
},
|
|
95
|
-
run_id,
|
|
96
|
-
scope: "binding_consistency".to_string(),
|
|
97
|
-
boundary: "messaging".to_string(),
|
|
98
|
-
receiver_binding,
|
|
99
|
-
contract_suite,
|
|
100
|
-
provider_sdk_calls,
|
|
101
|
-
})
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
fn run_contract_suite(
|
|
105
|
-
workspace: &Path,
|
|
106
|
-
team: Option<&TeamKey>,
|
|
107
|
-
run_id: &str,
|
|
108
|
-
) -> Vec<ContractSuiteCheck> {
|
|
109
|
-
let scratch =
|
|
110
|
-
std::env::temp_dir().join(format!("ta-comms-contract-{run_id}-{}", std::process::id()));
|
|
111
|
-
let _ = std::fs::remove_dir_all(&scratch);
|
|
112
|
-
let mut checks = Vec::new();
|
|
113
|
-
let mut scratch_store = match MessageStore::open(&scratch) {
|
|
114
|
-
Ok(store) => {
|
|
115
|
-
checks.push(contract_check(
|
|
116
|
-
"message_store_schema",
|
|
117
|
-
CheckStatus::Pass,
|
|
118
|
-
None,
|
|
119
|
-
));
|
|
120
|
-
Some(store)
|
|
121
|
-
}
|
|
122
|
-
Err(error) => {
|
|
123
|
-
checks.push(contract_check(
|
|
124
|
-
"message_store_schema",
|
|
125
|
-
CheckStatus::Fail,
|
|
126
|
-
Some(error.to_string()),
|
|
127
|
-
));
|
|
128
|
-
None
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
match scratch_store.as_ref().and_then(|_| {
|
|
133
|
-
match super::persist::persist_internal_send(
|
|
134
|
-
&scratch,
|
|
135
|
-
super::InternalSendKind::Selftest,
|
|
136
|
-
Some("contract-team"),
|
|
137
|
-
None,
|
|
138
|
-
"doctor",
|
|
139
|
-
"worker",
|
|
140
|
-
"comms contract probe",
|
|
141
|
-
None,
|
|
142
|
-
false,
|
|
143
|
-
None,
|
|
144
|
-
super::InitialDisposition::Accepted,
|
|
145
|
-
None,
|
|
146
|
-
)
|
|
147
|
-
.ok()?
|
|
148
|
-
{
|
|
149
|
-
super::PersistResolution::Persisted(persisted) => Some(persisted.message_id),
|
|
150
|
-
super::PersistResolution::Duplicate(_) => None,
|
|
151
|
-
}
|
|
152
|
-
}) {
|
|
153
|
-
Some(message_id) if message_id.starts_with("msg_") && message_id.len() > 4 => {
|
|
154
|
-
let rendered = format!(
|
|
155
|
-
"Team Agent message from doctor:\n\ncomms contract probe\n\n[team-agent-token:{message_id}]"
|
|
156
|
-
);
|
|
157
|
-
let token = format!("[team-agent-token:{message_id}]");
|
|
158
|
-
checks.push(contract_check(
|
|
159
|
-
"message_token_shape",
|
|
160
|
-
if rendered.ends_with(&token) {
|
|
161
|
-
CheckStatus::Pass
|
|
162
|
-
} else {
|
|
163
|
-
CheckStatus::Fail
|
|
164
|
-
},
|
|
165
|
-
(!rendered.ends_with(&token)).then(|| "rendered token suffix missing".to_string()),
|
|
166
|
-
));
|
|
167
|
-
}
|
|
168
|
-
Some(_) => checks.push(contract_check(
|
|
169
|
-
"message_token_shape",
|
|
170
|
-
CheckStatus::Fail,
|
|
171
|
-
Some("message id did not use msg_ prefix".to_string()),
|
|
172
|
-
)),
|
|
173
|
-
None => checks.push(contract_check(
|
|
174
|
-
"message_token_shape",
|
|
175
|
-
CheckStatus::Fail,
|
|
176
|
-
Some("could not create scratch message".to_string()),
|
|
177
|
-
)),
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
let result_id = format!("res-comms-{run_id}");
|
|
181
|
-
let result_content = super::watchers::format_result_watcher_notification(&serde_json::json!({
|
|
182
|
-
"result_id": result_id,
|
|
183
|
-
"task_id": "comms-contract",
|
|
184
|
-
"agent_id": "doctor",
|
|
185
|
-
"status": "success",
|
|
186
|
-
"summary": "contract suite probe",
|
|
187
|
-
}));
|
|
188
|
-
let parsed_result_id = super::watchers::result_id_from_text(&result_content);
|
|
189
|
-
checks.push(contract_check(
|
|
190
|
-
"result_notification_render",
|
|
191
|
-
if parsed_result_id.as_deref() == Some(result_id.as_str()) {
|
|
192
|
-
CheckStatus::Pass
|
|
193
|
-
} else {
|
|
194
|
-
CheckStatus::Fail
|
|
195
|
-
},
|
|
196
|
-
(parsed_result_id.as_deref() != Some(result_id.as_str()))
|
|
197
|
-
.then(|| "result notification did not round-trip result_id".to_string()),
|
|
198
|
-
));
|
|
199
|
-
|
|
200
|
-
let selected = crate::state::selector::resolve_active_team(
|
|
201
|
-
workspace,
|
|
202
|
-
team.map(TeamKey::as_str),
|
|
203
|
-
crate::state::selector::SelectorMode::RuntimeOnly,
|
|
204
|
-
);
|
|
205
|
-
match (scratch_store.take(), selected) {
|
|
206
|
-
(Some(store), Ok(selected)) => {
|
|
207
|
-
let owner_team = selected.team_key;
|
|
208
|
-
let mut state = selected.state;
|
|
209
|
-
if !state.is_object() {
|
|
210
|
-
state = serde_json::json!({});
|
|
211
|
-
}
|
|
212
|
-
if let Some(obj) = state.as_object_mut() {
|
|
213
|
-
obj.insert(
|
|
214
|
-
"active_team_key".to_string(),
|
|
215
|
-
serde_json::json!(owner_team.clone()),
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
let event_log = crate::event_log::EventLog::new(&scratch);
|
|
219
|
-
let outcome = super::leader_receiver::send_to_leader_receiver(
|
|
220
|
-
&scratch,
|
|
221
|
-
&state,
|
|
222
|
-
"leader",
|
|
223
|
-
"comms contract leader projection",
|
|
224
|
-
None,
|
|
225
|
-
"doctor",
|
|
226
|
-
false,
|
|
227
|
-
Some("comms-contract-result"),
|
|
228
|
-
&event_log,
|
|
229
|
-
);
|
|
230
|
-
match outcome {
|
|
231
|
-
Ok(outcome) => {
|
|
232
|
-
let actual_owner = outcome.message_id.as_deref().and_then(|message_id| {
|
|
233
|
-
message_owner_team(store.db_path(), message_id)
|
|
234
|
-
.ok()
|
|
235
|
-
.flatten()
|
|
236
|
-
});
|
|
237
|
-
checks.push(contract_check(
|
|
238
|
-
"leader_projection_owner_team",
|
|
239
|
-
if actual_owner.as_deref() == Some(owner_team.as_str()) {
|
|
240
|
-
CheckStatus::Pass
|
|
241
|
-
} else {
|
|
242
|
-
CheckStatus::Fail
|
|
243
|
-
},
|
|
244
|
-
(actual_owner.as_deref() != Some(owner_team.as_str())).then(|| {
|
|
245
|
-
format!(
|
|
246
|
-
"leader-bound message owner_team_id={:?}, expected={owner_team}",
|
|
247
|
-
actual_owner
|
|
248
|
-
)
|
|
249
|
-
}),
|
|
250
|
-
));
|
|
251
|
-
}
|
|
252
|
-
Err(error) => checks.push(contract_check(
|
|
253
|
-
"leader_projection_owner_team",
|
|
254
|
-
CheckStatus::Fail,
|
|
255
|
-
Some(error.to_string()),
|
|
256
|
-
)),
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
(_, Err(error)) => checks.push(contract_check(
|
|
260
|
-
"leader_projection_owner_team",
|
|
261
|
-
CheckStatus::Fail,
|
|
262
|
-
Some(error.to_string()),
|
|
263
|
-
)),
|
|
264
|
-
(None, _) => checks.push(contract_check(
|
|
265
|
-
"leader_projection_owner_team",
|
|
266
|
-
CheckStatus::Fail,
|
|
267
|
-
Some("message store schema unavailable".to_string()),
|
|
268
|
-
)),
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
let _ = std::fs::remove_dir_all(&scratch);
|
|
272
|
-
checks
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
fn contract_check(name: &str, status: CheckStatus, reason: Option<String>) -> ContractSuiteCheck {
|
|
276
|
-
ContractSuiteCheck {
|
|
277
|
-
name: name.to_string(),
|
|
278
|
-
status,
|
|
279
|
-
reason,
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
fn message_owner_team(db_path: &Path, message_id: &str) -> Result<Option<String>, MessagingError> {
|
|
284
|
-
let conn = crate::db::schema::open_db(db_path)?;
|
|
285
|
-
let owner = conn.query_row(
|
|
286
|
-
"select owner_team_id from messages where message_id = ?1",
|
|
287
|
-
rusqlite::params![message_id],
|
|
288
|
-
|row| row.get::<_, Option<String>>(0),
|
|
289
|
-
)?;
|
|
290
|
-
Ok(owner)
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
/// `evaluate_idle_behavior` (`diagnose/comms.py:50`):idle 分类准确性评估。零 token,走 driver。
|
|
294
|
-
pub(crate) fn evaluate_idle_behavior(
|
|
295
|
-
workspace: &Path,
|
|
296
|
-
agent_id: &str,
|
|
297
|
-
claimed_status: &str,
|
|
298
|
-
token: Option<&str>,
|
|
299
|
-
driver: &dyn CommsSelftestDriver,
|
|
300
|
-
) -> Result<IdleEvaluation, MessagingError> {
|
|
301
|
-
let _ = (workspace, driver);
|
|
302
|
-
let normalized = claimed_status.to_ascii_lowercase();
|
|
303
|
-
let status = match normalized.as_str() {
|
|
304
|
-
"idle" | "working" | "running" => CheckStatus::NotChallenged,
|
|
305
|
-
_ => CheckStatus::Fail,
|
|
306
|
-
};
|
|
307
|
-
Ok(IdleEvaluation {
|
|
308
|
-
ok: status == CheckStatus::NotChallenged,
|
|
309
|
-
agent_id: agent_id.to_string(),
|
|
310
|
-
claimed_status: claimed_status.to_string(),
|
|
311
|
-
token: token.unwrap_or("").to_string(),
|
|
312
|
-
status,
|
|
313
|
-
execution_ack: "not_challenged".to_string(),
|
|
314
|
-
})
|
|
315
|
-
}
|