@team-agent/installer 0.5.127 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -4
- package/README.zh.md +1 -1
- package/package.json +4 -8
- package/skills/team-agent/SKILL.md +41 -26
- package/skills/team-agent/command-coverage.json +170 -184
- package/skills/team-agent/docs/reference/team-agent-operator.md +66 -32
- package/skills/team-agent/references/recovery-runbook.md +1 -1
- package/skills/team-agent/references/team-agent-operator.md +66 -32
- package/templates/team_state.md +1 -1
- package/Cargo.lock +0 -1063
- package/Cargo.toml +0 -36
- package/crates/team-agent/Cargo.toml +0 -69
- package/crates/team-agent/src/app_server_test_support.rs +0 -258
- package/crates/team-agent/src/cli/adapters.rs +0 -1298
- package/crates/team-agent/src/cli/arguments.rs +0 -401
- package/crates/team-agent/src/cli/attach_app_server_leader.rs +0 -98
- package/crates/team-agent/src/cli/diagnose.rs +0 -1675
- package/crates/team-agent/src/cli/emit.rs +0 -2898
- package/crates/team-agent/src/cli/grok_slot.rs +0 -384
- package/crates/team-agent/src/cli/helpers.rs +0 -91
- package/crates/team-agent/src/cli/intent/runtime.rs +0 -1189
- package/crates/team-agent/src/cli/intent/runtime_tests.rs +0 -821
- package/crates/team-agent/src/cli/intent/tests.rs +0 -691
- package/crates/team-agent/src/cli/intent.rs +0 -664
- package/crates/team-agent/src/cli/leader.rs +0 -300
- package/crates/team-agent/src/cli/leader_prompt.rs +0 -261
- package/crates/team-agent/src/cli/leaders.rs +0 -418
- package/crates/team-agent/src/cli/mod.rs +0 -6528
- package/crates/team-agent/src/cli/models.rs +0 -449
- package/crates/team-agent/src/cli/named_address.rs +0 -1651
- package/crates/team-agent/src/cli/profile.rs +0 -342
- package/crates/team-agent/src/cli/route.rs +0 -212
- package/crates/team-agent/src/cli/send/coordinator.rs +0 -164
- package/crates/team-agent/src/cli/send/mailbox.rs +0 -145
- package/crates/team-agent/src/cli/send/persist.rs +0 -192
- package/crates/team-agent/src/cli/send/presentation.rs +0 -370
- package/crates/team-agent/src/cli/send/resolve.rs +0 -573
- package/crates/team-agent/src/cli/send.rs +0 -201
- package/crates/team-agent/src/cli/shutdown_socket.rs +0 -288
- package/crates/team-agent/src/cli/spec.rs +0 -159
- package/crates/team-agent/src/cli/status.rs +0 -280
- package/crates/team-agent/src/cli/status_port/agents.rs +0 -358
- package/crates/team-agent/src/cli/status_port/approvals.rs +0 -79
- package/crates/team-agent/src/cli/status_port/brief.rs +0 -2043
- package/crates/team-agent/src/cli/status_port/compact.rs +0 -240
- package/crates/team-agent/src/cli/status_port/format.rs +0 -146
- package/crates/team-agent/src/cli/status_port/inbox.rs +0 -62
- package/crates/team-agent/src/cli/status_port/runtime.rs +0 -197
- package/crates/team-agent/src/cli/status_port/snapshot.rs +0 -208
- package/crates/team-agent/src/cli/status_port/store.rs +0 -416
- package/crates/team-agent/src/cli/status_port/tests.rs +0 -90
- package/crates/team-agent/src/cli/status_port.rs +0 -92
- package/crates/team-agent/src/cli/tests/base.rs +0 -885
- package/crates/team-agent/src/cli/tests/divergence.rs +0 -518
- package/crates/team-agent/src/cli/tests/lane_c.rs +0 -453
- package/crates/team-agent/src/cli/tests/leader_watch.rs +0 -372
- package/crates/team-agent/src/cli/tests/main_preserved.rs +0 -430
- package/crates/team-agent/src/cli/tests/missing_subcommands.rs +0 -336
- package/crates/team-agent/src/cli/tests/mod.rs +0 -137
- package/crates/team-agent/src/cli/tests/named_address.rs +0 -760
- package/crates/team-agent/src/cli/tests/parser_safety.rs +0 -383
- package/crates/team-agent/src/cli/tests/run_delegation.rs +0 -481
- package/crates/team-agent/src/cli/tests/shutdown_kill_plan.rs +0 -2179
- package/crates/team-agent/src/cli/tests/status_brief.rs +0 -1514
- package/crates/team-agent/src/cli/tests/status_send.rs +0 -1091
- package/crates/team-agent/src/cli/tests/verb_install_skill.rs +0 -93
- package/crates/team-agent/src/cli/tests/verb_profile.rs +0 -392
- package/crates/team-agent/src/cli/triage.rs +0 -234
- package/crates/team-agent/src/cli/types.rs +0 -591
- package/crates/team-agent/src/codex_app_server.rs +0 -546
- package/crates/team-agent/src/communication_mode/mod.rs +0 -56
- package/crates/team-agent/src/compiler/tests.rs +0 -842
- package/crates/team-agent/src/compiler.rs +0 -691
- package/crates/team-agent/src/conpty/backend.rs +0 -829
- package/crates/team-agent/src/conpty/mod.rs +0 -33
- package/crates/team-agent/src/contract_runtime/backend.rs +0 -1610
- package/crates/team-agent/src/contract_runtime/commands.rs +0 -671
- package/crates/team-agent/src/contract_runtime/config.rs +0 -354
- package/crates/team-agent/src/contract_runtime/config_tests.rs +0 -56
- package/crates/team-agent/src/contract_runtime/discovery.rs +0 -438
- package/crates/team-agent/src/contract_runtime/fork.rs +0 -368
- package/crates/team-agent/src/contract_runtime/forward.rs +0 -288
- package/crates/team-agent/src/contract_runtime/framework.rs +0 -350
- package/crates/team-agent/src/contract_runtime/mcp.rs +0 -399
- package/crates/team-agent/src/contract_runtime/mod.rs +0 -17
- package/crates/team-agent/src/contract_runtime/prompt.rs +0 -216
- package/crates/team-agent/src/contract_runtime/pump.rs +0 -271
- package/crates/team-agent/src/contract_runtime/registry.rs +0 -589
- package/crates/team-agent/src/contract_runtime/workspace.rs +0 -228
- package/crates/team-agent/src/coordinator/backoff.rs +0 -741
- package/crates/team-agent/src/coordinator/conpty_shim.rs +0 -805
- package/crates/team-agent/src/coordinator/health.rs +0 -1185
- package/crates/team-agent/src/coordinator/mod.rs +0 -119
- package/crates/team-agent/src/coordinator/orphan.rs +0 -110
- package/crates/team-agent/src/coordinator/runtime_detectors.rs +0 -798
- package/crates/team-agent/src/coordinator/runtime_observation.rs +0 -84
- package/crates/team-agent/src/coordinator/steps/abnormal.rs +0 -2309
- package/crates/team-agent/src/coordinator/steps/delivery.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/health_sync.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/mod.rs +0 -126
- package/crates/team-agent/src/coordinator/steps/persist.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/runtime_prompts.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/session_gate.rs +0 -16
- package/crates/team-agent/src/coordinator/tests/a0_lostupdate.rs +0 -158
- package/crates/team-agent/src/coordinator/tests/abnormal.rs +0 -312
- package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +0 -338
- package/crates/team-agent/src/coordinator/tests/basics.rs +0 -211
- package/crates/team-agent/src/coordinator/tests/daemon.rs +0 -514
- package/crates/team-agent/src/coordinator/tests/energy.rs +0 -549
- package/crates/team-agent/src/coordinator/tests/health_sync.rs +0 -461
- package/crates/team-agent/src/coordinator/tests/main_preserved.rs +0 -186
- package/crates/team-agent/src/coordinator/tests/mod.rs +0 -295
- package/crates/team-agent/src/coordinator/tests/s3_bounded.rs +0 -207
- package/crates/team-agent/src/coordinator/tests/spine.rs +0 -308
- package/crates/team-agent/src/coordinator/tests/takeover.rs +0 -286
- package/crates/team-agent/src/coordinator/tests/tick_core.rs +0 -237
- package/crates/team-agent/src/coordinator/tick.rs +0 -3112
- package/crates/team-agent/src/coordinator/types.rs +0 -540
- package/crates/team-agent/src/db/agent_health_capture.rs +0 -126
- package/crates/team-agent/src/db/message_store.rs +0 -1585
- package/crates/team-agent/src/db/migration.rs +0 -984
- package/crates/team-agent/src/db/mod.rs +0 -26
- package/crates/team-agent/src/db/schema.rs +0 -663
- package/crates/team-agent/src/diagnose/comms.rs +0 -242
- package/crates/team-agent/src/diagnose/mod.rs +0 -44
- package/crates/team-agent/src/diagnose/orphans.rs +0 -889
- package/crates/team-agent/src/event_log.rs +0 -502
- package/crates/team-agent/src/fake_worker.rs +0 -303
- package/crates/team-agent/src/kill_audit.rs +0 -106
- package/crates/team-agent/src/layout/manager.rs +0 -248
- package/crates/team-agent/src/layout/mod.rs +0 -36
- package/crates/team-agent/src/layout/overlay.rs +0 -134
- package/crates/team-agent/src/layout/placement.rs +0 -52
- package/crates/team-agent/src/layout/recovery.rs +0 -106
- package/crates/team-agent/src/layout/runtime_sessions.rs +0 -317
- package/crates/team-agent/src/layout/sessions.rs +0 -294
- package/crates/team-agent/src/layout/tmux_endpoint.rs +0 -165
- package/crates/team-agent/src/layout/worker_env.rs +0 -721
- package/crates/team-agent/src/layout/worker_window_helpers.rs +0 -37
- package/crates/team-agent/src/leader/helpers.rs +0 -178
- package/crates/team-agent/src/leader/incident.rs +0 -6
- package/crates/team-agent/src/leader/lease.rs +0 -3356
- package/crates/team-agent/src/leader/mod.rs +0 -104
- package/crates/team-agent/src/leader/owner_bind.rs +0 -400
- package/crates/team-agent/src/leader/prompt.rs +0 -905
- package/crates/team-agent/src/leader/provider_attribution.rs +0 -247
- package/crates/team-agent/src/leader/rediscover/tests.rs +0 -689
- package/crates/team-agent/src/leader/rediscover.rs +0 -1192
- package/crates/team-agent/src/leader/registry.rs +0 -883
- package/crates/team-agent/src/leader/start.rs +0 -4500
- package/crates/team-agent/src/leader/takeover.rs +0 -65
- package/crates/team-agent/src/leader/tests/basics.rs +0 -337
- package/crates/team-agent/src/leader/tests/byte_findings.rs +0 -355
- package/crates/team-agent/src/leader/tests/claim_leader_mailbox_flush_contract.rs +0 -544
- package/crates/team-agent/src/leader/tests/historical_inventory_upgrade_gate_red.rs +0 -624
- package/crates/team-agent/src/leader/tests/identity.rs +0 -465
- package/crates/team-agent/src/leader/tests/identity_session_names.rs +0 -42
- package/crates/team-agent/src/leader/tests/idle.rs +0 -113
- package/crates/team-agent/src/leader/tests/lease_api.rs +0 -520
- package/crates/team-agent/src/leader/tests/lease_claim.rs +0 -629
- package/crates/team-agent/src/leader/tests/mod.rs +0 -106
- package/crates/team-agent/src/leader/tests/prompt_contract.rs +0 -267
- package/crates/team-agent/src/leader/tests/rediscover.rs +0 -403
- package/crates/team-agent/src/leader/tests/rehomed_env.rs +0 -83
- package/crates/team-agent/src/leader/tests/team_in_team_state_scope_red.rs +0 -1273
- package/crates/team-agent/src/leader/tests/terminal_and_replay_vs_rerender_invariants_red.rs +0 -417
- package/crates/team-agent/src/leader/tests/wake_start_owner.rs +0 -168
- package/crates/team-agent/src/leader/types.rs +0 -534
- package/crates/team-agent/src/lib.rs +0 -145
- package/crates/team-agent/src/lifecycle/helpers.rs +0 -212
- package/crates/team-agent/src/lifecycle/launch/add_agent.rs +0 -848
- package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +0 -393
- package/crates/team-agent/src/lifecycle/launch/agent_state.rs +0 -332
- package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +0 -178
- package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +0 -82
- package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +0 -63
- package/crates/team-agent/src/lifecycle/launch/identity.rs +0 -674
- package/crates/team-agent/src/lifecycle/launch/layout.rs +0 -350
- package/crates/team-agent/src/lifecycle/launch/leader_context.rs +0 -589
- package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +0 -152
- package/crates/team-agent/src/lifecycle/launch/ownership.rs +0 -105
- package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +0 -629
- package/crates/team-agent/src/lifecycle/launch/pi_mcp_extension.js +0 -226
- package/crates/team-agent/src/lifecycle/launch/plan.rs +0 -269
- package/crates/team-agent/src/lifecycle/launch/quick_start.rs +0 -5176
- package/crates/team-agent/src/lifecycle/launch/quick_start_transport.rs +0 -368
- package/crates/team-agent/src/lifecycle/launch/readiness.rs +0 -519
- package/crates/team-agent/src/lifecycle/launch/role_source.rs +0 -287
- package/crates/team-agent/src/lifecycle/launch/spawn.rs +0 -450
- package/crates/team-agent/src/lifecycle/launch/spec_state.rs +0 -801
- package/crates/team-agent/src/lifecycle/launch/state_projection.rs +0 -624
- package/crates/team-agent/src/lifecycle/launch/worker_env.rs +0 -558
- package/crates/team-agent/src/lifecycle/launch.rs +0 -534
- package/crates/team-agent/src/lifecycle/lock.rs +0 -350
- package/crates/team-agent/src/lifecycle/mod.rs +0 -79
- package/crates/team-agent/src/lifecycle/pane_input_lock.rs +0 -239
- package/crates/team-agent/src/lifecycle/profile_launch.rs +0 -757
- package/crates/team-agent/src/lifecycle/profile_smoke.rs +0 -557
- package/crates/team-agent/src/lifecycle/restart/agent.rs +0 -2198
- package/crates/team-agent/src/lifecycle/restart/common.rs +0 -2052
- package/crates/team-agent/src/lifecycle/restart/orchestrator.rs +0 -65
- package/crates/team-agent/src/lifecycle/restart/preflight.rs +0 -113
- package/crates/team-agent/src/lifecycle/restart/rebuild.rs +0 -5135
- package/crates/team-agent/src/lifecycle/restart/remove.rs +0 -1504
- package/crates/team-agent/src/lifecycle/restart/selection.rs +0 -559
- package/crates/team-agent/src/lifecycle/restart/team_state.rs +0 -329
- package/crates/team-agent/src/lifecycle/restart.rs +0 -223
- package/crates/team-agent/src/lifecycle/role_config.rs +0 -1205
- package/crates/team-agent/src/lifecycle/tests/acceptance_b_batch_red.rs +0 -1021
- package/crates/team-agent/src/lifecycle/tests/agent_ops.rs +0 -1205
- package/crates/team-agent/src/lifecycle/tests/b0_legacy_snapshot_nonauthority_contract.rs +0 -265
- package/crates/team-agent/src/lifecycle/tests/b0_reader_hideone_audit_contract.rs +0 -490
- package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +0 -656
- package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +0 -135
- package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +0 -1415
- package/crates/team-agent/src/lifecycle/tests/clone_agent_preserves_source_tools.rs +0 -427
- package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +0 -396
- package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +0 -418
- package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +0 -2039
- package/crates/team-agent/src/lifecycle/tests/core.rs +0 -1298
- package/crates/team-agent/src/lifecycle/tests/f032_startup_prompt_best_effort_red.rs +0 -315
- package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_g0.stdout.txt +0 -222
- package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_spaced_ids.stdout.txt +0 -9
- package/crates/team-agent/src/lifecycle/tests/fixtures/pi_native_mcp_host.mjs +0 -71
- package/crates/team-agent/src/lifecycle/tests/gate_fixtures.rs +0 -562
- package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +0 -110
- package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +0 -472
- package/crates/team-agent/src/lifecycle/tests/host_cotenant_death_p0_contract.rs +0 -921
- package/crates/team-agent/src/lifecycle/tests/issue238_codex_effort_contract.rs +0 -68
- package/crates/team-agent/src/lifecycle/tests/lane_ops.rs +0 -1851
- package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +0 -3981
- package/crates/team-agent/src/lifecycle/tests/lifecycle_lock.rs +0 -339
- package/crates/team-agent/src/lifecycle/tests/lifecycle_rollback_red.rs +0 -596
- package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +0 -513
- package/crates/team-agent/src/lifecycle/tests/mcp_tool_name_format_red.rs +0 -69
- package/crates/team-agent/src/lifecycle/tests/phase_b_contracts.rs +0 -824
- package/crates/team-agent/src/lifecycle/tests/phase_golden.rs +0 -723
- package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +0 -152
- package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +0 -182
- package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +0 -374
- package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +0 -546
- package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +0 -31
- package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +0 -528
- package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +0 -134
- package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +0 -333
- package/crates/team-agent/src/lifecycle/tests/realmachine_clusters_1_6_red.rs +0 -786
- package/crates/team-agent/src/lifecycle/tests/realmachine_residual_g1_g4_red.rs +0 -648
- package/crates/team-agent/src/lifecycle/tests/restart.rs +0 -185
- package/crates/team-agent/src/lifecycle/tests/restart_build_before_destroy_0540_contract.rs +0 -1053
- package/crates/team-agent/src/lifecycle/tests/restart_liveness_red.rs +0 -679
- package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +0 -1126
- package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +0 -153
- package/crates/team-agent/src/lifecycle/tests/resume_recover_red.rs +0 -427
- package/crates/team-agent/src/lifecycle/tests/stale_team_saveconflict_contract.rs +0 -431
- package/crates/team-agent/src/lifecycle/tests/startup_latency_contract.rs +0 -1066
- package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +0 -876
- package/crates/team-agent/src/lifecycle/tests/subprep_codex_trust_roundtrip_red.rs +0 -1026
- package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +0 -90
- package/crates/team-agent/src/lifecycle/tests/team_in_team_identity_scope_red.rs +0 -543
- package/crates/team-agent/src/lifecycle/tests/team_in_team_sibling_quick_start_red.rs +0 -1103
- package/crates/team-agent/src/lifecycle/tests/team_in_team_state_scope_red.rs +0 -1276
- package/crates/team-agent/src/lifecycle/tests/team_key_retirement_roster_red.rs +0 -145
- package/crates/team-agent/src/lifecycle/tests/team_key_retirement_txn_red.rs +0 -603
- package/crates/team-agent/src/lifecycle/tests/test_isolation_escape_contract.rs +0 -936
- package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +0 -970
- package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +0 -996
- package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +0 -827
- package/crates/team-agent/src/lifecycle/tests.rs +0 -102
- package/crates/team-agent/src/lifecycle/types.rs +0 -861
- package/crates/team-agent/src/lifecycle/worker_command_context.rs +0 -370
- package/crates/team-agent/src/main.rs +0 -52
- package/crates/team-agent/src/mcp_server/helpers.rs +0 -510
- package/crates/team-agent/src/mcp_server/lifecycle_tools/mod.rs +0 -6
- package/crates/team-agent/src/mcp_server/lifecycle_tools/state_status.rs +0 -43
- package/crates/team-agent/src/mcp_server/mod.rs +0 -119
- package/crates/team-agent/src/mcp_server/normalize.rs +0 -485
- package/crates/team-agent/src/mcp_server/readiness.rs +0 -546
- package/crates/team-agent/src/mcp_server/readiness_tests.rs +0 -369
- package/crates/team-agent/src/mcp_server/tests/golden.rs +0 -285
- package/crates/team-agent/src/mcp_server/tests/normalize.rs +0 -247
- package/crates/team-agent/src/mcp_server/tests/scoped.rs +0 -168
- package/crates/team-agent/src/mcp_server/tests/send.rs +0 -388
- package/crates/team-agent/src/mcp_server/tests/tools.rs +0 -343
- package/crates/team-agent/src/mcp_server/tests/wire.rs +0 -254
- package/crates/team-agent/src/mcp_server/tests.rs +0 -43
- package/crates/team-agent/src/mcp_server/tools.rs +0 -1015
- package/crates/team-agent/src/mcp_server/types.rs +0 -396
- package/crates/team-agent/src/mcp_server/wire.rs +0 -867
- package/crates/team-agent/src/messaging/activity.rs +0 -461
- package/crates/team-agent/src/messaging/address.rs +0 -87
- package/crates/team-agent/src/messaging/delivery.rs +0 -3785
- package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +0 -234
- package/crates/team-agent/src/messaging/enter_rescue.rs +0 -362
- package/crates/team-agent/src/messaging/enter_rescue_tests.rs +0 -633
- package/crates/team-agent/src/messaging/helpers.rs +0 -354
- package/crates/team-agent/src/messaging/leader_channel.rs +0 -287
- package/crates/team-agent/src/messaging/leader_receiver.rs +0 -786
- package/crates/team-agent/src/messaging/mod.rs +0 -166
- package/crates/team-agent/src/messaging/persist.rs +0 -377
- package/crates/team-agent/src/messaging/presentation.rs +0 -417
- package/crates/team-agent/src/messaging/results/collection_tests.rs +0 -719
- package/crates/team-agent/src/messaging/results.rs +0 -1415
- package/crates/team-agent/src/messaging/scheduler.rs +0 -217
- package/crates/team-agent/src/messaging/selftest.rs +0 -315
- package/crates/team-agent/src/messaging/send.rs +0 -981
- package/crates/team-agent/src/messaging/tests/basic.rs +0 -346
- package/crates/team-agent/src/messaging/tests/dup_inject.rs +0 -551
- package/crates/team-agent/src/messaging/tests/e23.rs +0 -49
- package/crates/team-agent/src/messaging/tests/leader_channel.rs +0 -169
- package/crates/team-agent/src/messaging/tests/leader_inject_acceptance.rs +0 -817
- package/crates/team-agent/src/messaging/tests/main_preserved.rs +0 -85
- package/crates/team-agent/src/messaging/tests/mod.rs +0 -306
- package/crates/team-agent/src/messaging/tests/runtime.rs +0 -3655
- package/crates/team-agent/src/messaging/tests/spine.rs +0 -837
- package/crates/team-agent/src/messaging/tests/wave2.rs +0 -381
- package/crates/team-agent/src/messaging/trust.rs +0 -215
- package/crates/team-agent/src/messaging/types.rs +0 -471
- package/crates/team-agent/src/messaging/wait.rs +0 -366
- package/crates/team-agent/src/messaging/watchers.rs +0 -916
- package/crates/team-agent/src/model/enums.rs +0 -356
- package/crates/team-agent/src/model/errors.rs +0 -18
- package/crates/team-agent/src/model/ids.rs +0 -165
- package/crates/team-agent/src/model/mod.rs +0 -29
- package/crates/team-agent/src/model/name_similarity.rs +0 -252
- package/crates/team-agent/src/model/pane_authority_refusal.rs +0 -359
- package/crates/team-agent/src/model/paths.rs +0 -257
- package/crates/team-agent/src/model/routing.rs +0 -387
- package/crates/team-agent/src/model/spec.rs +0 -1184
- package/crates/team-agent/src/model/task_graph.rs +0 -321
- package/crates/team-agent/src/model/testdata/fuzz.golden.yaml +0 -43
- package/crates/team-agent/src/model/testdata/fuzz.yaml +0 -43
- package/crates/team-agent/src/model/testdata/spec_invalid_a.yaml +0 -209
- package/crates/team-agent/src/model/testdata/team.spec.golden.yaml +0 -208
- package/crates/team-agent/src/model/testdata/team.spec.yaml +0 -208
- package/crates/team-agent/src/model/yaml/tests.rs +0 -188
- package/crates/team-agent/src/model/yaml.rs +0 -802
- package/crates/team-agent/src/os_probe.rs +0 -280
- package/crates/team-agent/src/packaging/install.rs +0 -219
- package/crates/team-agent/src/packaging/migrate.rs +0 -38
- package/crates/team-agent/src/packaging/mod.rs +0 -91
- package/crates/team-agent/src/packaging/repair.rs +0 -33
- package/crates/team-agent/src/packaging/tests.rs +0 -822
- package/crates/team-agent/src/packaging/types.rs +0 -417
- package/crates/team-agent/src/platform/argv.rs +0 -331
- package/crates/team-agent/src/platform/errors.rs +0 -104
- package/crates/team-agent/src/platform/file_lock.rs +0 -279
- package/crates/team-agent/src/platform/mod.rs +0 -5
- package/crates/team-agent/src/platform/process.rs +0 -545
- package/crates/team-agent/src/provider/adapter.rs +0 -898
- package/crates/team-agent/src/provider/adapters/copilot.rs +0 -75
- package/crates/team-agent/src/provider/adapters/copilot_fork.rs +0 -307
- package/crates/team-agent/src/provider/adapters/fake.rs +0 -18
- package/crates/team-agent/src/provider/adapters/mod.rs +0 -28
- package/crates/team-agent/src/provider/approvals/mod.rs +0 -3
- package/crates/team-agent/src/provider/approvals/parsing.rs +0 -586
- package/crates/team-agent/src/provider/approvals/runtime_prompts.rs +0 -205
- package/crates/team-agent/src/provider/argv_route.rs +0 -405
- package/crates/team-agent/src/provider/bypass_flags.rs +0 -116
- package/crates/team-agent/src/provider/classify.rs +0 -773
- package/crates/team-agent/src/provider/command_helpers.rs +0 -45
- package/crates/team-agent/src/provider/faults.rs +0 -165
- package/crates/team-agent/src/provider/helpers.rs +0 -52
- package/crates/team-agent/src/provider/mod.rs +0 -78
- package/crates/team-agent/src/provider/model_catalog.rs +0 -722
- package/crates/team-agent/src/provider/session/capture.rs +0 -2631
- package/crates/team-agent/src/provider/session/context_fork/outcome.rs +0 -168
- package/crates/team-agent/src/provider/session/context_fork.rs +0 -264
- package/crates/team-agent/src/provider/session/mod.rs +0 -36
- package/crates/team-agent/src/provider/session/resume.rs +0 -269
- package/crates/team-agent/src/provider/session_scan/common/tests.rs +0 -316
- package/crates/team-agent/src/provider/session_scan/common.rs +0 -618
- package/crates/team-agent/src/provider/session_scan/copilot.rs +0 -280
- package/crates/team-agent/src/provider/session_scan/pi.rs +0 -152
- package/crates/team-agent/src/provider/session_scan.rs +0 -61
- package/crates/team-agent/src/provider/startup_prompt.rs +0 -757
- package/crates/team-agent/src/provider/submit_now.rs +0 -71
- package/crates/team-agent/src/provider/testdata/copilot-ready-marker.txt +0 -5
- package/crates/team-agent/src/provider/testdata/copilot-trust-prompt.txt +0 -19
- package/crates/team-agent/src/provider/testdata/grok-models-authenticated.stdout +0 -9
- package/crates/team-agent/src/provider/testdata/grok-models-unauthenticated.stdout +0 -7
- package/crates/team-agent/src/provider/tests/adapter.rs +0 -354
- package/crates/team-agent/src/provider/tests/classify.rs +0 -201
- package/crates/team-agent/src/provider/tests/command_helpers.rs +0 -26
- package/crates/team-agent/src/provider/tests/copilot_fork.rs +0 -191
- package/crates/team-agent/src/provider/tests/faults.rs +0 -200
- package/crates/team-agent/src/provider/tests/idle.rs +0 -140
- package/crates/team-agent/src/provider/tests/wire.rs +0 -213
- package/crates/team-agent/src/provider/tests.rs +0 -32
- package/crates/team-agent/src/provider/types.rs +0 -529
- package/crates/team-agent/src/provider/wire.rs +0 -406
- package/crates/team-agent/src/redaction.rs +0 -259
- package/crates/team-agent/src/state/abnormal_watch/tests/mod.rs +0 -248
- package/crates/team-agent/src/state/abnormal_watch.rs +0 -144
- package/crates/team-agent/src/state/identity.rs +0 -914
- package/crates/team-agent/src/state/identity_keys.rs +0 -132
- package/crates/team-agent/src/state/mod.rs +0 -74
- package/crates/team-agent/src/state/owner_gate.rs +0 -482
- package/crates/team-agent/src/state/ownership.rs +0 -563
- package/crates/team-agent/src/state/paths.rs +0 -395
- package/crates/team-agent/src/state/persist.rs +0 -3811
- package/crates/team-agent/src/state/projection.rs +0 -1508
- package/crates/team-agent/src/state/repository/intent.rs +0 -14
- package/crates/team-agent/src/state/repository/tests.rs +0 -184
- package/crates/team-agent/src/state/repository.rs +0 -866
- package/crates/team-agent/src/state/selector.rs +0 -160
- package/crates/team-agent/src/state/testdata/state-rich.canonical.json +0 -133
- package/crates/team-agent/src/tmux_backend/enter_rescue.rs +0 -325
- package/crates/team-agent/src/tmux_backend/enter_rescue_tests.rs +0 -432
- package/crates/team-agent/src/tmux_backend/native_input.rs +0 -513
- package/crates/team-agent/src/tmux_backend/native_input_tests.rs +0 -742
- package/crates/team-agent/src/tmux_backend/tests.rs +0 -4254
- package/crates/team-agent/src/tmux_backend.rs +0 -4527
- package/crates/team-agent/src/topology.rs +0 -537
- package/crates/team-agent/src/transport/enter_rescue.rs +0 -166
- package/crates/team-agent/src/transport/native_input.rs +0 -491
- package/crates/team-agent/src/transport/test_support.rs +0 -743
- package/crates/team-agent/src/transport/tests/behavior.rs +0 -326
- package/crates/team-agent/src/transport/tests/mod.rs +0 -194
- package/crates/team-agent/src/transport/tests/wire.rs +0 -574
- package/crates/team-agent/src/transport.rs +0 -1655
- package/crates/team-agent/src/transport_factory.rs +0 -819
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
//!
|
|
2
|
-
//! step 11 · messaging — delivery / scheduler / results / collect / report_result /
|
|
3
|
-
//! watchers / leader-receiver / selftest 编排状态机 (ROUND-0 SKELETON).
|
|
4
|
-
//!
|
|
5
|
-
//! Card: `docs/phase0/subsystems/11-messaging.md` (type table §38-53, public API §60-75,
|
|
6
|
-
//! bug/trap §118-132, module map §134-149).
|
|
7
|
-
//! Truth source (READ-ONLY) `team-agent-public` @ v0.2.11 / `439bef8`:
|
|
8
|
-
//! - `messaging/send.py` · `delivery.py` · `internal_delivery.py` · `scheduler.py`
|
|
9
|
-
//! - `messaging/results.py` · `result_delivery.py` · `leader.py` · `leader_panes.py`
|
|
10
|
-
//! - `messaging/idle_alerts.py` · `activity_detector.py` · `trust_auto_answer.py`
|
|
11
|
-
//! - `messaging/session_drift.py` · `owner_bypass.py` · `routing.py`
|
|
12
|
-
//! - `diagnose/comms.py` (`run_comms_selftest` / `evaluate_idle_behavior`)
|
|
13
|
-
//!
|
|
14
|
-
//! SCOPE — this is the type/interface LAYER (so RED contracts can NAME these and
|
|
15
|
-
//! compile), NOT the implementation. It mirrors only the CONTRACT-NAMED public
|
|
16
|
-
//! surface; the 18 Python files' internal helpers are deferred (see
|
|
17
|
-
//! `cross_deps_or_placeholders`). Bodies are `unimplemented!("step11 port: …")`.
|
|
18
|
-
//!
|
|
19
|
-
//! REUSE (do NOT redefine): [`MessageStore`] + [`NotificationClaimParams`] (step 7);
|
|
20
|
-
//! [`Transport`] / [`Target`] / [`PaneId`] (step 9); [`Provider`] / [`MessageStatus`]
|
|
21
|
-
//! shadow (step 2 enums); [`worker_sender_bypasses_owner_gate`] (step 5 owner-gate);
|
|
22
|
-
//! [`RouteResult`] / [`route_task`] (step 2 routing); [`ProviderError`] / classifier
|
|
23
|
-
//! types (step 8); [`EventLog`] (step 4).
|
|
24
|
-
//!
|
|
25
|
-
//! 铁律 (card §118-132, Rust 绝不重蹈):
|
|
26
|
-
//! - **unknown ≠ idle** (bug-071/077/085): [`ActivityStatus`] 穷尽 match,`Uncertain`
|
|
27
|
-
//! 独立分支显式 block,**无 `_ => Idle` 兜底**。
|
|
28
|
-
//! - **dedup key 不含 leader_session_uuid** (Stage 12): 唯一去重原语 =
|
|
29
|
-
//! [`MessageStore::claim_leader_notification_delivery`] 的 `INSERT OR IGNORE`;
|
|
30
|
-
//! `peek` 只读快路径,非去重本身。`notified_message_id` requeue 必须存活 (Gap 32)。
|
|
31
|
-
//! - **trust 自动应答 fail-safe** (bug-064/082): pane 宽度查询失败时**绝不**返回默认
|
|
32
|
-
//! 宽度 ([`PaneWidthQuery::Failed`]),matcher 退回精确相等;trust 应答只对自己工作
|
|
33
|
-
//! 目录 realpath 全等。重试有界 ([`TRUST_RETRY_MAX_ATTEMPTS`]),终态显式。
|
|
34
|
-
//! - **scheduled kind 穷尽**: [`ScheduledKind`] 穷尽 match,漏 kind 编不过,无运行时 fallback。
|
|
35
|
-
//! - **busy → 延后不丢**: [`DeliveryStatus::Queued`] 不 mark failed,留队列等下次 tick。
|
|
36
|
-
//! - **selftest 零 provider SDK** (§84/MUST-NOT-13): [`run_comms_selftest`] 走 trait
|
|
37
|
-
//! mock,断言 `{anthropic,openai,httpx} == 0`,见 [`ProviderSdkCalls`]。
|
|
38
|
-
//!
|
|
39
|
-
//! §10:scheduler / result_delivery / leader_receiver / delivery 子路径被 coordinator
|
|
40
|
-
//! daemon (step 12) tick 直接调用 (bug-084 崩溃面) → 所有投递/调度/IO 返
|
|
41
|
-
//! `Result<_, MessagingError>` (thiserror)。`#![deny(unwrap/expect/panic)]` 由 leader
|
|
42
|
-
//! 集成时统一加,本 ROUND-0 skeleton 不加 (与 provider.rs/transport.rs 一致)。
|
|
43
|
-
|
|
44
|
-
// ROUND-0 skeleton:fn body 全 unimplemented!() → import/field/method 暂未被用;P2 porter 落实现时移除。
|
|
45
|
-
#![allow(dead_code, unused_imports)]
|
|
46
|
-
// §10:scheduler/result_delivery/leader_receiver/delivery 子路径被 coordinator daemon tick 直接调用
|
|
47
|
-
// (bug-084 崩溃面)→ 实现层禁 unwrap/expect/panic(unimplemented!() stub 不被拦);tests 各自 allow。
|
|
48
|
-
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
|
|
49
|
-
|
|
50
|
-
use thiserror::Error;
|
|
51
|
-
|
|
52
|
-
// ── REUSE: step 2 model ────────────────────────────────────────────────────
|
|
53
|
-
// 这些模块根级 `use` 保持子模块测试 `use super::*` 的名字解析不变 (TeamKey / PaneId / …)。
|
|
54
|
-
use crate::model::enums::Provider;
|
|
55
|
-
use crate::model::ids::{LeaderSessionUuid, OwnerEpoch, TaskId, TeamKey};
|
|
56
|
-
// route_task 已在 step 2 落地 (model::routing),send 子例程 REUSE,不重定义。
|
|
57
|
-
pub use crate::model::routing::{route_task, RouteResult};
|
|
58
|
-
|
|
59
|
-
// ── REUSE: step 4 event_log / step 7 message_store / step 9 transport ───────
|
|
60
|
-
use crate::event_log::EventLog;
|
|
61
|
-
use crate::message_store::MessageStore;
|
|
62
|
-
use crate::transport::{PaneId, Target, Transport};
|
|
63
|
-
|
|
64
|
-
pub mod activity;
|
|
65
|
-
pub mod address;
|
|
66
|
-
pub mod delivery;
|
|
67
|
-
pub(crate) mod enter_rescue;
|
|
68
|
-
pub mod helpers;
|
|
69
|
-
pub mod leader_channel;
|
|
70
|
-
pub mod leader_receiver;
|
|
71
|
-
pub mod persist;
|
|
72
|
-
pub mod presentation;
|
|
73
|
-
pub mod results;
|
|
74
|
-
pub mod scheduler;
|
|
75
|
-
pub mod selftest;
|
|
76
|
-
pub mod send;
|
|
77
|
-
pub mod trust;
|
|
78
|
-
pub mod types;
|
|
79
|
-
pub mod wait;
|
|
80
|
-
pub mod watchers;
|
|
81
|
-
|
|
82
|
-
// ── re-export: 保持 `crate::messaging::X` 与 test `super::X` 解析不变 ──────────
|
|
83
|
-
pub use activity::{classify_agent_activity, detect_cross_worker_deadlocks, detect_idle_fallbacks};
|
|
84
|
-
pub use address::{parse_logical_address, LogicalAddress, LogicalAddressTarget};
|
|
85
|
-
pub use delivery::{
|
|
86
|
-
deliver_pending_message, deliver_pending_messages, deliver_persisted_message,
|
|
87
|
-
deliver_stored_message, execute_trust_retry, handle_trust_retry_needed,
|
|
88
|
-
retry_injection_after_trust_auto_answer,
|
|
89
|
-
};
|
|
90
|
-
pub use leader_channel::{
|
|
91
|
-
resolve_live_leader_channel, DirectTmuxLeaderChannel, LeaderChannelResolution,
|
|
92
|
-
LeaderChannelUnbound, LiveLeaderChannel,
|
|
93
|
-
};
|
|
94
|
-
pub use leader_receiver::{
|
|
95
|
-
deliver_to_leader_fallback_pane, enqueue_leader_mailbox_until_attach,
|
|
96
|
-
mirror_peer_message_to_leader, send_to_leader_receiver,
|
|
97
|
-
send_to_leader_receiver_with_presentation,
|
|
98
|
-
};
|
|
99
|
-
pub use persist::{
|
|
100
|
-
persist_resolved_send, DeliveryBlocker, InitialDisposition, InternalSendKind,
|
|
101
|
-
LogicalRecipient, PersistResolution, PersistedSend, ResolvedSendIntent, SendOrigin,
|
|
102
|
-
};
|
|
103
|
-
pub use results::{
|
|
104
|
-
collect, collect_for_team, report_result, report_result_for_owner_team,
|
|
105
|
-
report_result_for_owner_team_with_primary_error,
|
|
106
|
-
};
|
|
107
|
-
pub use scheduler::{detect_stuck_agents, fire_due_scheduled_events};
|
|
108
|
-
pub use selftest::{run_comms_selftest, CommsSelftestDriver};
|
|
109
|
-
pub use send::{
|
|
110
|
-
apply_worker_sender_bypass, send_message, MessageTarget, SendOptions, TrustedSender,
|
|
111
|
-
};
|
|
112
|
-
pub use trust::{attempt_trust_auto_answer, TrustAnswerOutcome};
|
|
113
|
-
pub use types::{
|
|
114
|
-
ActivityStatus, AgentActivity, CheckEvidence, CheckKind, CheckStatus,
|
|
115
|
-
ContractSuiteCheck, DeliveryOutcome, DeliveryRefusal, DeliveryStage, DeliveryStatus,
|
|
116
|
-
IdleEvaluation, LeaderNotificationKey, LeaderReceiver, PaneWidthQuery,
|
|
117
|
-
ProviderSdkCalls, ReceiverMode, ScheduledKind, SelftestCheck, SelftestReport, SendEventPayload,
|
|
118
|
-
TrustRetryPayload, WatcherNotice, WorkerRuntimeState, RESULT_DELIVERY_MAX_ATTEMPTS,
|
|
119
|
-
SEND_RETRY_MAX_ATTEMPTS, TRUST_RETRY_BACKOFF_SECONDS, TRUST_RETRY_MAX_ATTEMPTS,
|
|
120
|
-
};
|
|
121
|
-
pub use wait::{wait_for_result, WaitResult};
|
|
122
|
-
pub use watchers::{
|
|
123
|
-
format_result_watcher_notification, requeue_after_claim_leader,
|
|
124
|
-
requeue_delivery_exhausted_watchers, result_id_from_text, retry_result_deliveries,
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
// `MessageStatusShadow` 是 [`DeliveryOutcome::message_status`] 的公有字段类型,原在模块根
|
|
128
|
-
// 可见 (`crate::messaging::MessageStatusShadow`),故 `pub` 再导出保持解析不变。
|
|
129
|
-
pub use helpers::MessageStatusShadow;
|
|
130
|
-
|
|
131
|
-
// ===========================================================================
|
|
132
|
-
// ERROR (thiserror, lib 边界;daemon tick 经此 Result 退避,§10/bug-084)
|
|
133
|
-
// ===========================================================================
|
|
134
|
-
|
|
135
|
-
/// messaging 子系统错误。投递/调度/IO 失败一律经此 `Result` 上抛,由 step 12 主循环
|
|
136
|
-
/// catch + 退避;**绝不**在调度/投递循环 panic (bug-084)。
|
|
137
|
-
#[derive(Debug, Error)]
|
|
138
|
-
pub enum MessagingError {
|
|
139
|
-
#[error("db: {0}")]
|
|
140
|
-
Db(#[from] crate::db::DbError),
|
|
141
|
-
#[error("sqlite: {0}")]
|
|
142
|
-
Sqlite(#[from] rusqlite::Error),
|
|
143
|
-
#[error("message store: {0}")]
|
|
144
|
-
Store(#[from] crate::message_store::MessageStoreError),
|
|
145
|
-
#[error("transport: {0}")]
|
|
146
|
-
Transport(#[from] crate::transport::TransportError),
|
|
147
|
-
#[error("state: {0}")]
|
|
148
|
-
State(#[from] crate::state::StateError),
|
|
149
|
-
#[error("event log: {0}")]
|
|
150
|
-
EventLog(#[from] crate::event_log::EventLogError),
|
|
151
|
-
#[error("provider: {0}")]
|
|
152
|
-
Provider(String),
|
|
153
|
-
/// envelope / 输入校验 (validate_result_envelope 等)。
|
|
154
|
-
#[error("validation: {0}")]
|
|
155
|
-
Validation(String),
|
|
156
|
-
/// team 解析 / 路由 / owner-gate 拒绝 (非 IO,语义性失败)。
|
|
157
|
-
#[error("routing: {0}")]
|
|
158
|
-
Routing(String),
|
|
159
|
-
#[error("io: {0}")]
|
|
160
|
-
Io(#[from] std::io::Error),
|
|
161
|
-
#[error("json: {0}")]
|
|
162
|
-
Json(#[from] serde_json::Error),
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
#[cfg(test)]
|
|
166
|
-
mod tests;
|
|
@@ -1,377 +0,0 @@
|
|
|
1
|
-
//!
|
|
2
|
-
//! Durable boundary between resolved logical addressing and delivery/recovery.
|
|
3
|
-
|
|
4
|
-
use std::path::{Path, PathBuf};
|
|
5
|
-
|
|
6
|
-
use crate::db::message_store::{MessageRowStatus, MessageStore, PersistMessageInput};
|
|
7
|
-
use crate::model::ids::{AgentId, TaskId, TeamKey};
|
|
8
|
-
|
|
9
|
-
use super::presentation::PresentationDecision;
|
|
10
|
-
use super::send::TrustedSender;
|
|
11
|
-
use super::MessagingError;
|
|
12
|
-
|
|
13
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
14
|
-
pub enum InternalSendKind {
|
|
15
|
-
Delivery,
|
|
16
|
-
LeaderNotification,
|
|
17
|
-
OfflineMailbox,
|
|
18
|
-
Selftest,
|
|
19
|
-
Watcher,
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
23
|
-
pub enum SendOrigin {
|
|
24
|
-
Cli,
|
|
25
|
-
Mcp,
|
|
26
|
-
Internal(InternalSendKind),
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
30
|
-
pub enum LogicalRecipient {
|
|
31
|
-
Worker(AgentId),
|
|
32
|
-
Leader,
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
impl LogicalRecipient {
|
|
36
|
-
pub fn from_resolved(value: impl Into<String>) -> Self {
|
|
37
|
-
let value = value.into();
|
|
38
|
-
if value == "leader" {
|
|
39
|
-
Self::Leader
|
|
40
|
-
} else {
|
|
41
|
-
Self::Worker(AgentId::new(value))
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
pub fn as_str(&self) -> &str {
|
|
46
|
-
match self {
|
|
47
|
-
Self::Worker(agent) => agent.as_str(),
|
|
48
|
-
Self::Leader => "leader",
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
54
|
-
pub enum DeliveryBlocker {
|
|
55
|
-
CoordinatorUnavailable,
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
impl DeliveryBlocker {
|
|
59
|
-
pub const fn as_str(self) -> &'static str {
|
|
60
|
-
match self {
|
|
61
|
-
Self::CoordinatorUnavailable => "coordinator_unavailable",
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
67
|
-
pub enum InitialDisposition {
|
|
68
|
-
Accepted,
|
|
69
|
-
StoredOnly,
|
|
70
|
-
QueuedUntilLeaderAttach,
|
|
71
|
-
Blocked(DeliveryBlocker),
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
impl InitialDisposition {
|
|
75
|
-
fn row_status(self) -> MessageRowStatus {
|
|
76
|
-
match self {
|
|
77
|
-
Self::Accepted => MessageRowStatus::Accepted,
|
|
78
|
-
Self::StoredOnly => MessageRowStatus::StoredOnly,
|
|
79
|
-
Self::QueuedUntilLeaderAttach => MessageRowStatus::QueuedUntilLeaderAttach,
|
|
80
|
-
Self::Blocked(DeliveryBlocker::CoordinatorUnavailable) => {
|
|
81
|
-
MessageRowStatus::QueuedCoordinatorUnavailable
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
fn error(self) -> Option<&'static str> {
|
|
87
|
-
match self {
|
|
88
|
-
Self::Blocked(blocker) => Some(blocker.as_str()),
|
|
89
|
-
Self::Accepted | Self::StoredOnly | Self::QueuedUntilLeaderAttach => None,
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
#[derive(Debug, Clone)]
|
|
95
|
-
pub struct ResolvedSendIntent {
|
|
96
|
-
pub origin: SendOrigin,
|
|
97
|
-
pub target_workspace: PathBuf,
|
|
98
|
-
pub owner_team_id: Option<TeamKey>,
|
|
99
|
-
pub recipient: LogicalRecipient,
|
|
100
|
-
pub sender: TrustedSender,
|
|
101
|
-
pub task_id: Option<TaskId>,
|
|
102
|
-
pub content: String,
|
|
103
|
-
pub reply_to: Option<String>,
|
|
104
|
-
pub requires_ack: bool,
|
|
105
|
-
pub requested_message_id: Option<String>,
|
|
106
|
-
pub initial_disposition: InitialDisposition,
|
|
107
|
-
pub presentation: PresentationDecision,
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
impl ResolvedSendIntent {
|
|
111
|
-
#[allow(clippy::too_many_arguments)]
|
|
112
|
-
pub fn accepted(
|
|
113
|
-
origin: SendOrigin,
|
|
114
|
-
workspace: &Path,
|
|
115
|
-
owner_team_id: Option<TeamKey>,
|
|
116
|
-
recipient: LogicalRecipient,
|
|
117
|
-
sender: TrustedSender,
|
|
118
|
-
task_id: Option<TaskId>,
|
|
119
|
-
content: impl Into<String>,
|
|
120
|
-
reply_to: Option<String>,
|
|
121
|
-
requires_ack: bool,
|
|
122
|
-
requested_message_id: Option<String>,
|
|
123
|
-
) -> Self {
|
|
124
|
-
Self {
|
|
125
|
-
origin,
|
|
126
|
-
target_workspace: workspace.to_path_buf(),
|
|
127
|
-
owner_team_id,
|
|
128
|
-
recipient,
|
|
129
|
-
sender,
|
|
130
|
-
task_id,
|
|
131
|
-
content: content.into(),
|
|
132
|
-
reply_to,
|
|
133
|
-
requires_ack,
|
|
134
|
-
requested_message_id,
|
|
135
|
-
initial_disposition: InitialDisposition::Accepted,
|
|
136
|
-
presentation: PresentationDecision::default(),
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
142
|
-
pub struct PersistedSend {
|
|
143
|
-
pub message_id: String,
|
|
144
|
-
pub owner_team_id: Option<TeamKey>,
|
|
145
|
-
pub recipient: LogicalRecipient,
|
|
146
|
-
pub row_status: MessageRowStatus,
|
|
147
|
-
pub blocker: Option<DeliveryBlocker>,
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
151
|
-
pub enum PersistResolution {
|
|
152
|
-
Persisted(PersistedSend),
|
|
153
|
-
Duplicate(String),
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
///
|
|
157
|
-
/// The only production entry point that creates a durable message row.
|
|
158
|
-
pub fn persist_resolved_send(
|
|
159
|
-
intent: &ResolvedSendIntent,
|
|
160
|
-
) -> Result<PersistResolution, MessagingError> {
|
|
161
|
-
let store = MessageStore::open(&intent.target_workspace)?;
|
|
162
|
-
if let Some(requested) = intent.requested_message_id.as_deref() {
|
|
163
|
-
if store.message_exists(requested)? {
|
|
164
|
-
return Ok(PersistResolution::Duplicate(requested.to_string()));
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
let status = intent.initial_disposition.row_status();
|
|
168
|
-
let presentation = serde_json::to_string(&intent.presentation)?;
|
|
169
|
-
let message_id = store.persist_message(PersistMessageInput {
|
|
170
|
-
message_id: intent.requested_message_id.as_deref(),
|
|
171
|
-
owner_team_id: intent.owner_team_id.as_ref().map(TeamKey::as_str),
|
|
172
|
-
task_id: intent.task_id.as_ref().map(TaskId::as_str),
|
|
173
|
-
sender: intent.sender.display_name(),
|
|
174
|
-
recipient: intent.recipient.as_str(),
|
|
175
|
-
reply_to: intent.reply_to.as_deref(),
|
|
176
|
-
requires_ack: intent.requires_ack,
|
|
177
|
-
status,
|
|
178
|
-
content: &intent.content,
|
|
179
|
-
presentation: &presentation,
|
|
180
|
-
error: intent.initial_disposition.error(),
|
|
181
|
-
})?;
|
|
182
|
-
Ok(PersistResolution::Persisted(PersistedSend {
|
|
183
|
-
message_id,
|
|
184
|
-
owner_team_id: intent.owner_team_id.clone(),
|
|
185
|
-
recipient: intent.recipient.clone(),
|
|
186
|
-
row_status: status,
|
|
187
|
-
blocker: match intent.initial_disposition {
|
|
188
|
-
InitialDisposition::Blocked(blocker) => Some(blocker),
|
|
189
|
-
InitialDisposition::Accepted
|
|
190
|
-
| InitialDisposition::StoredOnly
|
|
191
|
-
| InitialDisposition::QueuedUntilLeaderAttach => None,
|
|
192
|
-
},
|
|
193
|
-
}))
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
#[allow(clippy::too_many_arguments)]
|
|
197
|
-
pub(crate) fn persist_internal_send(
|
|
198
|
-
workspace: &Path,
|
|
199
|
-
kind: InternalSendKind,
|
|
200
|
-
owner_team_id: Option<&str>,
|
|
201
|
-
task_id: Option<&str>,
|
|
202
|
-
sender: &str,
|
|
203
|
-
recipient: &str,
|
|
204
|
-
content: &str,
|
|
205
|
-
reply_to: Option<&str>,
|
|
206
|
-
requires_ack: bool,
|
|
207
|
-
requested_message_id: Option<&str>,
|
|
208
|
-
initial_disposition: InitialDisposition,
|
|
209
|
-
presentation: Option<&PresentationDecision>,
|
|
210
|
-
) -> Result<PersistResolution, MessagingError> {
|
|
211
|
-
let mut intent = ResolvedSendIntent::accepted(
|
|
212
|
-
SendOrigin::Internal(kind),
|
|
213
|
-
workspace,
|
|
214
|
-
owner_team_id.map(TeamKey::new),
|
|
215
|
-
LogicalRecipient::from_resolved(recipient),
|
|
216
|
-
TrustedSender::from_runtime_identity(AgentId::new(sender)),
|
|
217
|
-
task_id.map(TaskId::new),
|
|
218
|
-
content,
|
|
219
|
-
reply_to.map(ToOwned::to_owned),
|
|
220
|
-
requires_ack,
|
|
221
|
-
requested_message_id.map(ToOwned::to_owned),
|
|
222
|
-
);
|
|
223
|
-
intent.initial_disposition = initial_disposition;
|
|
224
|
-
if let Some(presentation) = presentation {
|
|
225
|
-
intent.presentation = presentation.clone();
|
|
226
|
-
}
|
|
227
|
-
persist_resolved_send(&intent)
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
#[cfg(test)]
|
|
231
|
-
mod tests {
|
|
232
|
-
use super::*;
|
|
233
|
-
|
|
234
|
-
fn workspace(tag: &str) -> PathBuf {
|
|
235
|
-
let path =
|
|
236
|
-
std::env::temp_dir().join(format!("ta-send-persist-{tag}-{}", std::process::id()));
|
|
237
|
-
std::fs::create_dir_all(&path).unwrap();
|
|
238
|
-
path
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
#[test]
|
|
242
|
-
fn coordinator_blocker_is_durable_and_not_delivered() {
|
|
243
|
-
let workspace = workspace("coordinator-blocker");
|
|
244
|
-
let mut intent = ResolvedSendIntent::accepted(
|
|
245
|
-
SendOrigin::Cli,
|
|
246
|
-
&workspace,
|
|
247
|
-
Some(TeamKey::new("carc")),
|
|
248
|
-
LogicalRecipient::from_resolved("w1"),
|
|
249
|
-
TrustedSender::leader(),
|
|
250
|
-
None,
|
|
251
|
-
"probe",
|
|
252
|
-
None,
|
|
253
|
-
true,
|
|
254
|
-
None,
|
|
255
|
-
);
|
|
256
|
-
intent.initial_disposition =
|
|
257
|
-
InitialDisposition::Blocked(DeliveryBlocker::CoordinatorUnavailable);
|
|
258
|
-
let PersistResolution::Persisted(persisted) = persist_resolved_send(&intent).unwrap()
|
|
259
|
-
else {
|
|
260
|
-
panic!("fresh intent must persist")
|
|
261
|
-
};
|
|
262
|
-
assert_eq!(
|
|
263
|
-
persisted.row_status,
|
|
264
|
-
MessageRowStatus::QueuedCoordinatorUnavailable
|
|
265
|
-
);
|
|
266
|
-
assert_eq!(
|
|
267
|
-
persisted.blocker,
|
|
268
|
-
Some(DeliveryBlocker::CoordinatorUnavailable)
|
|
269
|
-
);
|
|
270
|
-
let store = MessageStore::open(&workspace).unwrap();
|
|
271
|
-
let connection = crate::db::schema::open_db(store.db_path()).unwrap();
|
|
272
|
-
let (status, delivered_at, error): (String, Option<String>, Option<String>) = connection
|
|
273
|
-
.query_row(
|
|
274
|
-
"select status, delivered_at, error from messages where message_id = ?1",
|
|
275
|
-
[&persisted.message_id],
|
|
276
|
-
|row| Ok((row.get(0)?, row.get(1)?, row.get(2)?)),
|
|
277
|
-
)
|
|
278
|
-
.unwrap();
|
|
279
|
-
assert_eq!(status, "queued_coordinator_unavailable");
|
|
280
|
-
assert_eq!(delivered_at, None);
|
|
281
|
-
assert_eq!(error.as_deref(), Some("coordinator_unavailable"));
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
#[test]
|
|
285
|
-
fn stored_only_persists_requested_presentation_without_delivery_eligibility() {
|
|
286
|
-
let workspace = workspace("stored-only");
|
|
287
|
-
let mut intent = ResolvedSendIntent::accepted(
|
|
288
|
-
SendOrigin::Mcp,
|
|
289
|
-
&workspace,
|
|
290
|
-
Some(TeamKey::new("team-a")),
|
|
291
|
-
LogicalRecipient::Leader,
|
|
292
|
-
TrustedSender::from_runtime_identity(AgentId::new("worker_a")),
|
|
293
|
-
None,
|
|
294
|
-
"stage evidence",
|
|
295
|
-
None,
|
|
296
|
-
false,
|
|
297
|
-
None,
|
|
298
|
-
);
|
|
299
|
-
intent.initial_disposition = InitialDisposition::StoredOnly;
|
|
300
|
-
intent.presentation = super::super::presentation::decide_presentation(
|
|
301
|
-
&super::super::presentation::PresentationRequest {
|
|
302
|
-
sink: super::super::presentation::PresentationSink::Casefile,
|
|
303
|
-
class: super::super::presentation::PresentationClass::StageResult,
|
|
304
|
-
case_id: Some("case-7".to_string()),
|
|
305
|
-
},
|
|
306
|
-
super::super::presentation::PresentationSource::Send,
|
|
307
|
-
);
|
|
308
|
-
let PersistResolution::Persisted(persisted) = persist_resolved_send(&intent).unwrap()
|
|
309
|
-
else {
|
|
310
|
-
panic!("fresh intent must persist")
|
|
311
|
-
};
|
|
312
|
-
assert_eq!(persisted.row_status, MessageRowStatus::StoredOnly);
|
|
313
|
-
let store = MessageStore::open(&workspace).unwrap();
|
|
314
|
-
let connection = crate::db::schema::open_db(store.db_path()).unwrap();
|
|
315
|
-
let (status, presentation): (String, String) = connection
|
|
316
|
-
.query_row(
|
|
317
|
-
"select status, presentation from messages where message_id = ?1",
|
|
318
|
-
[&persisted.message_id],
|
|
319
|
-
|row| Ok((row.get(0)?, row.get(1)?)),
|
|
320
|
-
)
|
|
321
|
-
.unwrap();
|
|
322
|
-
assert_eq!(status, "stored_only");
|
|
323
|
-
assert_eq!(
|
|
324
|
-
serde_json::from_str::<serde_json::Value>(&presentation).unwrap(),
|
|
325
|
-
serde_json::json!({
|
|
326
|
-
"sink": "casefile",
|
|
327
|
-
"class": "stage_result",
|
|
328
|
-
"case_id": "case-7",
|
|
329
|
-
"requested_sink": "casefile",
|
|
330
|
-
"effective_sink": "casefile",
|
|
331
|
-
"policy_reason": "requested_sink:casefile",
|
|
332
|
-
"policy_version": "team-presentation-v1"
|
|
333
|
-
})
|
|
334
|
-
);
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
#[test]
|
|
338
|
-
fn production_row_creation_is_owned_by_persisted_primitive() {
|
|
339
|
-
for (name, source) in [
|
|
340
|
-
("send", include_str!("send.rs")),
|
|
341
|
-
("leader_receiver", include_str!("leader_receiver.rs")),
|
|
342
|
-
("delivery", include_str!("delivery.rs")),
|
|
343
|
-
("watchers", include_str!("watchers.rs")),
|
|
344
|
-
("helpers", include_str!("helpers.rs")),
|
|
345
|
-
("selftest", include_str!("selftest.rs")),
|
|
346
|
-
] {
|
|
347
|
-
assert!(
|
|
348
|
-
!source.contains(".create_message(")
|
|
349
|
-
&& !source.contains(".create_message_with_id("),
|
|
350
|
-
"{name} still creates message rows outside persist_resolved_send"
|
|
351
|
-
);
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
#[test]
|
|
356
|
-
fn persisted_truth_and_workspace_identity_have_forward_consumers() {
|
|
357
|
-
for (name, source) in [
|
|
358
|
-
("send", include_str!("send.rs")),
|
|
359
|
-
("delivery", include_str!("delivery.rs")),
|
|
360
|
-
("leader_receiver", include_str!("leader_receiver.rs")),
|
|
361
|
-
] {
|
|
362
|
-
assert!(
|
|
363
|
-
source.contains("persisted.row_status"),
|
|
364
|
-
"{name} rebuilds wire truth instead of consuming PersistedSend"
|
|
365
|
-
);
|
|
366
|
-
}
|
|
367
|
-
let watchers = include_str!("watchers.rs");
|
|
368
|
-
assert!(
|
|
369
|
-
!watchers.contains(".and_then(std::path::Path::parent)"),
|
|
370
|
-
"watcher identity must not be derived from the team.db layout"
|
|
371
|
-
);
|
|
372
|
-
assert!(
|
|
373
|
-
watchers.contains("deliver_primary_watcher(\n workspace,"),
|
|
374
|
-
"watcher must forward the caller's canonical workspace"
|
|
375
|
-
);
|
|
376
|
-
}
|
|
377
|
-
}
|