@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,317 +0,0 @@
|
|
|
1
|
-
//!
|
|
2
|
-
//! unit-1 (Stage 1) — typed runtime session identity.
|
|
3
|
-
//!
|
|
4
|
-
//! Provides two compile-time-distinct newtypes plus a `RuntimeSessions`
|
|
5
|
-
//! reader that pulls them out of `state.json` in one shot.
|
|
6
|
-
//!
|
|
7
|
-
//! Why: every place that reads `state.session_name` or
|
|
8
|
-
//! `leader_receiver.session_name` today does an ad-hoc `starts_with("team-
|
|
9
|
-
//! agent-leader-")` check (or, in the false-positive cases, doesn't). The
|
|
10
|
-
//! 0.3.39 leader-mis-kill class of bugs traces back to a string crossing
|
|
11
|
-
//! a boundary as the wrong identity.
|
|
12
|
-
//!
|
|
13
|
-
//! By going through `WorkerSession::new` / `LeaderLauncherSession::new`, a
|
|
14
|
-
//! leader-prefixed name can never be presented as a worker session by
|
|
15
|
-
//! construction. `LeaderLauncherSession::new` enforces the inverse — only
|
|
16
|
-
//! a leader-prefixed name passes.
|
|
17
|
-
//!
|
|
18
|
-
//! This unit is PURELY ADDITIVE: no existing call site is rewired yet.
|
|
19
|
-
//! unit-3 (restart preflight guard) and unit-4 (managed leader persistence
|
|
20
|
-
//! fix) are the adoption sites; they will route their state reads through
|
|
21
|
-
//! `RuntimeSessions::from_state`.
|
|
22
|
-
|
|
23
|
-
use crate::layout::sessions::{is_leader_session, LEADER_SESSION_PREFIX};
|
|
24
|
-
use crate::transport::SessionName;
|
|
25
|
-
use serde_json::Value;
|
|
26
|
-
|
|
27
|
-
/// A tmux session name that is guaranteed NOT to be a leader launcher
|
|
28
|
-
/// session (does not start with `team-agent-leader-`).
|
|
29
|
-
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
30
|
-
pub struct WorkerSession(SessionName);
|
|
31
|
-
|
|
32
|
-
/// A tmux session name that IS a leader launcher session (starts with
|
|
33
|
-
/// `team-agent-leader-`).
|
|
34
|
-
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
35
|
-
pub struct LeaderLauncherSession(SessionName);
|
|
36
|
-
|
|
37
|
-
/// Why `WorkerSession::new` rejected a name.
|
|
38
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
39
|
-
enum WorkerSessionError {
|
|
40
|
-
/// The name is empty.
|
|
41
|
-
Empty,
|
|
42
|
-
/// The name carries the leader launcher prefix — must not be a worker
|
|
43
|
-
/// session by construction.
|
|
44
|
-
LeaderPrefixed { name: String },
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/// Why `LeaderLauncherSession::new` rejected a name.
|
|
48
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
49
|
-
enum LeaderLauncherSessionError {
|
|
50
|
-
/// The name is empty.
|
|
51
|
-
Empty,
|
|
52
|
-
/// The name does not carry the required leader launcher prefix.
|
|
53
|
-
MissingLeaderPrefix { name: String },
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
impl WorkerSession {
|
|
57
|
-
pub fn new(name: impl Into<String>) -> Result<Self, WorkerSessionError> {
|
|
58
|
-
let raw: String = name.into();
|
|
59
|
-
if raw.is_empty() {
|
|
60
|
-
return Err(WorkerSessionError::Empty);
|
|
61
|
-
}
|
|
62
|
-
if raw.starts_with(LEADER_SESSION_PREFIX) {
|
|
63
|
-
return Err(WorkerSessionError::LeaderPrefixed { name: raw });
|
|
64
|
-
}
|
|
65
|
-
Ok(WorkerSession(SessionName::new(raw)))
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
pub fn as_str(&self) -> &str {
|
|
69
|
-
self.0.as_str()
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
pub fn into_session_name(self) -> SessionName {
|
|
73
|
-
self.0
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
pub fn session_name(&self) -> &SessionName {
|
|
77
|
-
&self.0
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
impl LeaderLauncherSession {
|
|
82
|
-
pub fn new(name: impl Into<String>) -> Result<Self, LeaderLauncherSessionError> {
|
|
83
|
-
let raw: String = name.into();
|
|
84
|
-
if raw.is_empty() {
|
|
85
|
-
return Err(LeaderLauncherSessionError::Empty);
|
|
86
|
-
}
|
|
87
|
-
if !raw.starts_with(LEADER_SESSION_PREFIX) {
|
|
88
|
-
return Err(LeaderLauncherSessionError::MissingLeaderPrefix { name: raw });
|
|
89
|
-
}
|
|
90
|
-
Ok(LeaderLauncherSession(SessionName::new(raw)))
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
pub fn as_str(&self) -> &str {
|
|
94
|
-
self.0.as_str()
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
pub fn into_session_name(self) -> SessionName {
|
|
98
|
-
self.0
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
pub fn session_name(&self) -> &SessionName {
|
|
102
|
-
&self.0
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/// What `RuntimeSessions::from_state` learned about the runtime topology.
|
|
107
|
-
///
|
|
108
|
-
/// Both fields are `Option` because state.json may be partial: a workspace
|
|
109
|
-
/// that has never seen a successful quick-start has no `session_name`, and
|
|
110
|
-
/// `leader_receiver` is absent until a leader binds.
|
|
111
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
112
|
-
pub struct RuntimeSessions {
|
|
113
|
-
/// The worker session derived from `state.session_name`, if present
|
|
114
|
-
/// AND well-formed (not leader-prefixed).
|
|
115
|
-
pub worker: Option<WorkerSession>,
|
|
116
|
-
/// The leader launcher session derived from
|
|
117
|
-
/// `state.leader_receiver.session_name`, if present AND leader-prefixed.
|
|
118
|
-
pub leader: Option<LeaderLauncherSession>,
|
|
119
|
-
/// State fields that exist but failed validation (e.g.
|
|
120
|
-
/// `state.session_name` is leader-prefixed = the 0.3.39 bug shape).
|
|
121
|
-
/// Callers (unit-3 preflight) use this to refuse cleanly rather than
|
|
122
|
-
/// proceed with a wrong-identity name.
|
|
123
|
-
pub anomalies: Vec<RuntimeSessionAnomaly>,
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
127
|
-
pub enum RuntimeSessionAnomaly {
|
|
128
|
-
/// `state.session_name` carried the leader launcher prefix — classic
|
|
129
|
-
/// 0.3.39 bug shape. cli/lifecycle MUST refuse before taking a kill
|
|
130
|
-
/// action against this string.
|
|
131
|
-
WorkerSessionNameIsLeaderPrefixed { value: String },
|
|
132
|
-
/// `leader_receiver.session_name` was present but not leader-prefixed.
|
|
133
|
-
LeaderReceiverSessionNameNotLeaderPrefixed { value: String },
|
|
134
|
-
/// `state.session_name == leader_receiver.session_name` — collision
|
|
135
|
-
/// that unit-4 explicitly fixes by stopping the persistence overwrite.
|
|
136
|
-
WorkerSessionEqualsLeaderSession { value: String },
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
impl RuntimeSessions {
|
|
140
|
-
///
|
|
141
|
-
/// Read state.json's session-identity fields and wrap them in typed
|
|
142
|
-
/// values. Never panics on bad state — anomalies are surfaced for
|
|
143
|
-
/// callers to act on.
|
|
144
|
-
pub fn from_state(state: &Value) -> Self {
|
|
145
|
-
let raw_worker = state
|
|
146
|
-
.get("session_name")
|
|
147
|
-
.and_then(Value::as_str)
|
|
148
|
-
.map(str::to_string);
|
|
149
|
-
let raw_leader = state
|
|
150
|
-
.get("leader_receiver")
|
|
151
|
-
.and_then(|r| r.get("session_name"))
|
|
152
|
-
.and_then(Value::as_str)
|
|
153
|
-
.map(str::to_string);
|
|
154
|
-
|
|
155
|
-
let mut anomalies = Vec::new();
|
|
156
|
-
|
|
157
|
-
let worker = match raw_worker.as_deref() {
|
|
158
|
-
None | Some("") => None,
|
|
159
|
-
Some(name) => match WorkerSession::new(name) {
|
|
160
|
-
Ok(w) => Some(w),
|
|
161
|
-
Err(WorkerSessionError::LeaderPrefixed { name }) => {
|
|
162
|
-
anomalies.push(RuntimeSessionAnomaly::WorkerSessionNameIsLeaderPrefixed {
|
|
163
|
-
value: name,
|
|
164
|
-
});
|
|
165
|
-
None
|
|
166
|
-
}
|
|
167
|
-
Err(WorkerSessionError::Empty) => None,
|
|
168
|
-
},
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
let leader = match raw_leader.as_deref() {
|
|
172
|
-
None | Some("") => None,
|
|
173
|
-
Some(name) => match LeaderLauncherSession::new(name) {
|
|
174
|
-
Ok(l) => Some(l),
|
|
175
|
-
Err(LeaderLauncherSessionError::MissingLeaderPrefix { name }) => {
|
|
176
|
-
anomalies.push(
|
|
177
|
-
RuntimeSessionAnomaly::LeaderReceiverSessionNameNotLeaderPrefixed {
|
|
178
|
-
value: name,
|
|
179
|
-
},
|
|
180
|
-
);
|
|
181
|
-
None
|
|
182
|
-
}
|
|
183
|
-
Err(LeaderLauncherSessionError::Empty) => None,
|
|
184
|
-
},
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
if let (Some(rw), Some(rl)) = (raw_worker.as_deref(), raw_leader.as_deref()) {
|
|
188
|
-
if !rw.is_empty() && rw == rl {
|
|
189
|
-
anomalies.push(RuntimeSessionAnomaly::WorkerSessionEqualsLeaderSession {
|
|
190
|
-
value: rw.to_string(),
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
Self {
|
|
196
|
-
worker,
|
|
197
|
-
leader,
|
|
198
|
-
anomalies,
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
///
|
|
203
|
-
/// True if any session-identity anomaly was detected in state.
|
|
204
|
-
pub fn has_anomalies(&self) -> bool {
|
|
205
|
-
!self.anomalies.is_empty()
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
///
|
|
209
|
-
/// True if a `state.session_name` looked like a leader launcher session
|
|
210
|
-
/// — the exact 0.3.39 shape unit-3 must refuse before any kill.
|
|
211
|
-
pub fn worker_session_name_is_leader_prefixed(&self) -> bool {
|
|
212
|
-
self.anomalies.iter().any(|a| {
|
|
213
|
-
matches!(
|
|
214
|
-
a,
|
|
215
|
-
RuntimeSessionAnomaly::WorkerSessionNameIsLeaderPrefixed { .. }
|
|
216
|
-
)
|
|
217
|
-
})
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
///
|
|
222
|
-
/// True when `name` is a leader launcher session (mirrors
|
|
223
|
-
/// `layout::sessions::is_leader_session` on a raw &str).
|
|
224
|
-
fn name_is_leader_launcher(name: &str) -> bool {
|
|
225
|
-
let session = SessionName::new(name);
|
|
226
|
-
is_leader_session(&session)
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
#[cfg(test)]
|
|
230
|
-
mod tests {
|
|
231
|
-
use super::*;
|
|
232
|
-
use serde_json::json;
|
|
233
|
-
|
|
234
|
-
#[test]
|
|
235
|
-
fn worker_session_new_rejects_leader_prefixed() {
|
|
236
|
-
let err = WorkerSession::new("team-agent-leader-claude-x").unwrap_err();
|
|
237
|
-
assert!(matches!(err, WorkerSessionError::LeaderPrefixed { .. }));
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
#[test]
|
|
241
|
-
fn worker_session_new_rejects_empty() {
|
|
242
|
-
assert!(matches!(
|
|
243
|
-
WorkerSession::new("").unwrap_err(),
|
|
244
|
-
WorkerSessionError::Empty
|
|
245
|
-
));
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
#[test]
|
|
249
|
-
fn worker_session_new_accepts_team_prefixed() {
|
|
250
|
-
let w = WorkerSession::new("team-foo").unwrap();
|
|
251
|
-
assert_eq!(w.as_str(), "team-foo");
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
#[test]
|
|
255
|
-
fn leader_launcher_session_new_requires_leader_prefix() {
|
|
256
|
-
assert!(matches!(
|
|
257
|
-
LeaderLauncherSession::new("team-foo").unwrap_err(),
|
|
258
|
-
LeaderLauncherSessionError::MissingLeaderPrefix { .. }
|
|
259
|
-
));
|
|
260
|
-
let l = LeaderLauncherSession::new("team-agent-leader-codex-abc").unwrap();
|
|
261
|
-
assert_eq!(l.as_str(), "team-agent-leader-codex-abc");
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
#[test]
|
|
265
|
-
fn runtime_sessions_from_state_clean() {
|
|
266
|
-
let state = json!({
|
|
267
|
-
"session_name": "team-foo",
|
|
268
|
-
"leader_receiver": { "session_name": "team-agent-leader-codex-abc" },
|
|
269
|
-
});
|
|
270
|
-
let r = RuntimeSessions::from_state(&state);
|
|
271
|
-
assert_eq!(r.worker.unwrap().as_str(), "team-foo");
|
|
272
|
-
assert_eq!(r.leader.unwrap().as_str(), "team-agent-leader-codex-abc");
|
|
273
|
-
assert!(r.anomalies.is_empty());
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
#[test]
|
|
277
|
-
fn runtime_sessions_from_state_flags_leader_prefixed_worker_name() {
|
|
278
|
-
// The 0.3.39 bug shape.
|
|
279
|
-
let state = json!({ "session_name": "team-agent-leader-bad" });
|
|
280
|
-
let r = RuntimeSessions::from_state(&state);
|
|
281
|
-
assert!(r.worker.is_none());
|
|
282
|
-
assert!(r.worker_session_name_is_leader_prefixed());
|
|
283
|
-
assert!(r.has_anomalies());
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
#[test]
|
|
287
|
-
fn runtime_sessions_from_state_flags_worker_equals_leader() {
|
|
288
|
-
let state = json!({
|
|
289
|
-
"session_name": "team-agent-leader-x",
|
|
290
|
-
"leader_receiver": { "session_name": "team-agent-leader-x" },
|
|
291
|
-
});
|
|
292
|
-
let r = RuntimeSessions::from_state(&state);
|
|
293
|
-
// Both anomalies fire: leader-prefixed worker + worker==leader.
|
|
294
|
-
assert!(r.anomalies.iter().any(|a| matches!(
|
|
295
|
-
a,
|
|
296
|
-
RuntimeSessionAnomaly::WorkerSessionNameIsLeaderPrefixed { .. }
|
|
297
|
-
)));
|
|
298
|
-
assert!(r.anomalies.iter().any(|a| matches!(
|
|
299
|
-
a,
|
|
300
|
-
RuntimeSessionAnomaly::WorkerSessionEqualsLeaderSession { .. }
|
|
301
|
-
)));
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
#[test]
|
|
305
|
-
fn runtime_sessions_from_state_empty_state_is_clean() {
|
|
306
|
-
let r = RuntimeSessions::from_state(&json!({}));
|
|
307
|
-
assert!(r.worker.is_none());
|
|
308
|
-
assert!(r.leader.is_none());
|
|
309
|
-
assert!(r.anomalies.is_empty());
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
#[test]
|
|
313
|
-
fn name_is_leader_launcher_matches_constant() {
|
|
314
|
-
assert!(name_is_leader_launcher("team-agent-leader-x"));
|
|
315
|
-
assert!(!name_is_leader_launcher("team-x"));
|
|
316
|
-
}
|
|
317
|
-
}
|
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
//!
|
|
2
|
-
//! 0.3.28 layout step 1 — session name constructors + topology invariant guard.
|
|
3
|
-
//!
|
|
4
|
-
//! Python 0.2.11 truth source (recap):
|
|
5
|
-
//! * Leader runs in a SEPARATE tmux session named
|
|
6
|
-
//! `team-agent-leader-<provider>-<folder>-<sha1[:8]>` (the existing
|
|
7
|
-
//! `crate::leader::start::leader_session_name`).
|
|
8
|
-
//! * Worker session is `runtime.session_name` or `team-<team.name>` (the
|
|
9
|
-
//! existing `lifecycle::launch::spec_session_name`).
|
|
10
|
-
//! * These two names MUST be disjoint by prefix
|
|
11
|
-
//! (`team-agent-leader-` vs `team-...`).
|
|
12
|
-
//!
|
|
13
|
-
//! This module re-exports those name constructors under a single namespace
|
|
14
|
-
//! and adds the topology invariant guard. No behaviour change in Step 1;
|
|
15
|
-
//! the guard runs as `tracing::warn!` so any drift is logged but not fatal.
|
|
16
|
-
|
|
17
|
-
use std::path::Path;
|
|
18
|
-
|
|
19
|
-
use crate::model::enums::Provider;
|
|
20
|
-
use crate::model::yaml::Value as YamlValue;
|
|
21
|
-
use crate::transport::SessionName;
|
|
22
|
-
use serde_json::Value as JsonValue;
|
|
23
|
-
|
|
24
|
-
/// `team-agent-leader-` — disjoint prefix for the leader session.
|
|
25
|
-
/// Re-exported from `leader::start::LEADER_SESSION_PREFIX` so layout-layer
|
|
26
|
-
/// code does not have to depend on the leader module's internals.
|
|
27
|
-
pub const LEADER_SESSION_PREFIX: &str = crate::leader::start::LEADER_SESSION_PREFIX;
|
|
28
|
-
|
|
29
|
-
///
|
|
30
|
-
/// Leader's dedicated tmux session name.
|
|
31
|
-
///
|
|
32
|
-
/// Format: `team-agent-leader-<provider_wire>-<folder>-<sha1(workspace)[:8]>`.
|
|
33
|
-
///
|
|
34
|
-
/// Re-exports `crate::leader::start::leader_session_name` so the rest of the
|
|
35
|
-
/// runtime can derive this name without touching the leader module. The
|
|
36
|
-
/// single underlying impl lives in `leader/start.rs` for now to minimise the
|
|
37
|
-
/// Step-1 diff; Step 2 will move it.
|
|
38
|
-
pub fn leader_session_name(provider: Provider, workspace: &Path) -> SessionName {
|
|
39
|
-
crate::leader::start::leader_session_name(provider, workspace)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
///
|
|
43
|
-
/// Worker tmux session name derived from the team spec.
|
|
44
|
-
///
|
|
45
|
-
/// Format: `spec.runtime.session_name` if set, else `team-<team.name>`
|
|
46
|
-
/// (default `team-agent`). This is a thin re-export of the existing
|
|
47
|
-
/// `lifecycle::launch::worker_session_name_pub` — exposed here so layout-
|
|
48
|
-
/// layer code has one place to ask. The spec is a `model::yaml::Value`
|
|
49
|
-
/// (the team spec parser's native type).
|
|
50
|
-
pub fn worker_session_name(spec: &YamlValue) -> SessionName {
|
|
51
|
-
crate::lifecycle::launch::worker_session_name_pub(spec)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
///
|
|
55
|
-
/// True when `name` starts with the leader session prefix.
|
|
56
|
-
pub fn is_leader_session(name: &SessionName) -> bool {
|
|
57
|
-
name.as_str().starts_with(LEADER_SESSION_PREFIX)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
///
|
|
61
|
-
/// True when `name` equals the worker session name derived from `spec`.
|
|
62
|
-
fn is_worker_session(name: &SessionName, spec: &YamlValue) -> bool {
|
|
63
|
-
worker_session_name(spec).as_str() == name.as_str()
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/// A detected topology invariant violation, surfaced as a warn-level log line
|
|
67
|
-
/// during the incremental migration (Steps 1–9). Hard error in Step 10.
|
|
68
|
-
#[derive(Debug, Clone)]
|
|
69
|
-
pub struct TopologyViolation {
|
|
70
|
-
pub kind: TopologyViolationKind,
|
|
71
|
-
pub detail: String,
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
75
|
-
pub enum TopologyViolationKind {
|
|
76
|
-
/// Worker session name shares the leader-session prefix.
|
|
77
|
-
WorkerSessionNamedAsLeader,
|
|
78
|
-
/// A worker window inside the worker session is named `leader`.
|
|
79
|
-
WorkerWindowNamedLeader,
|
|
80
|
-
/// Two agents share the same `pane_id` in state.
|
|
81
|
-
AgentPaneIdCollision,
|
|
82
|
-
/// `leader_receiver.pane_id` matches an active agent's `pane_id`.
|
|
83
|
-
LeaderPaneIdCollidesWithAgent,
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
///
|
|
87
|
-
/// Assert the runtime-state topology invariants (Step 1 — `warn!` only).
|
|
88
|
-
///
|
|
89
|
-
/// Checks:
|
|
90
|
-
/// 1. The worker session name does NOT start with the leader prefix.
|
|
91
|
-
/// 2. No agent window in worker session is literally named `leader`.
|
|
92
|
-
/// 3. No two agents share the same `pane_id`.
|
|
93
|
-
/// 4. `state.leader_receiver.pane_id` is not equal to any agent's
|
|
94
|
-
/// `pane_id` (E51 family — co-located lease corruption).
|
|
95
|
-
///
|
|
96
|
-
/// Returns the list of violations without panicking. Callers may choose to
|
|
97
|
-
/// emit `tracing::warn!` for each (the default in Steps 1–9) or escalate.
|
|
98
|
-
pub fn assert_topology_invariants(state: &JsonValue, spec: &YamlValue) -> Vec<TopologyViolation> {
|
|
99
|
-
let mut out = Vec::new();
|
|
100
|
-
let worker_session = worker_session_name(spec);
|
|
101
|
-
if worker_session.as_str().starts_with(LEADER_SESSION_PREFIX) {
|
|
102
|
-
out.push(TopologyViolation {
|
|
103
|
-
kind: TopologyViolationKind::WorkerSessionNamedAsLeader,
|
|
104
|
-
detail: format!(
|
|
105
|
-
"worker session name `{}` starts with leader prefix `{LEADER_SESSION_PREFIX}` — \
|
|
106
|
-
leader and worker sessions must be disjoint",
|
|
107
|
-
worker_session.as_str()
|
|
108
|
-
),
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
let agents = state.get("agents").and_then(JsonValue::as_object);
|
|
112
|
-
if let Some(agents) = agents {
|
|
113
|
-
for (agent_id, agent) in agents {
|
|
114
|
-
let window = agent
|
|
115
|
-
.get("window")
|
|
116
|
-
.and_then(JsonValue::as_str)
|
|
117
|
-
.unwrap_or("");
|
|
118
|
-
if window.eq_ignore_ascii_case("leader") {
|
|
119
|
-
out.push(TopologyViolation {
|
|
120
|
-
kind: TopologyViolationKind::WorkerWindowNamedLeader,
|
|
121
|
-
detail: format!(
|
|
122
|
-
"agent `{agent_id}` lives in window `leader` of worker session \
|
|
123
|
-
`{}` — workers must use `agent_id` window names",
|
|
124
|
-
worker_session.as_str()
|
|
125
|
-
),
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
// Pane-id collision among agents.
|
|
130
|
-
let mut by_pane: std::collections::HashMap<String, Vec<String>> =
|
|
131
|
-
std::collections::HashMap::new();
|
|
132
|
-
for (agent_id, agent) in agents {
|
|
133
|
-
if let Some(pane) = agent
|
|
134
|
-
.get("pane_id")
|
|
135
|
-
.and_then(JsonValue::as_str)
|
|
136
|
-
.filter(|s| !s.is_empty())
|
|
137
|
-
{
|
|
138
|
-
by_pane
|
|
139
|
-
.entry(pane.to_string())
|
|
140
|
-
.or_default()
|
|
141
|
-
.push(agent_id.to_string());
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
for (pane, ids) in by_pane.iter() {
|
|
145
|
-
if ids.len() > 1 {
|
|
146
|
-
out.push(TopologyViolation {
|
|
147
|
-
kind: TopologyViolationKind::AgentPaneIdCollision,
|
|
148
|
-
detail: format!(
|
|
149
|
-
"pane_id `{pane}` shared by agents {ids:?} — at most one agent may bind a pane_id"
|
|
150
|
-
),
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
// leader_receiver.pane_id ∉ any agent.pane_id.
|
|
155
|
-
let leader_pane = state
|
|
156
|
-
.get("leader_receiver")
|
|
157
|
-
.and_then(|lr| lr.get("pane_id"))
|
|
158
|
-
.and_then(JsonValue::as_str)
|
|
159
|
-
.filter(|s| !s.is_empty());
|
|
160
|
-
if let Some(leader_pane) = leader_pane {
|
|
161
|
-
for (agent_id, agent) in agents {
|
|
162
|
-
if agent
|
|
163
|
-
.get("pane_id")
|
|
164
|
-
.and_then(JsonValue::as_str)
|
|
165
|
-
.is_some_and(|p| p == leader_pane)
|
|
166
|
-
{
|
|
167
|
-
out.push(TopologyViolation {
|
|
168
|
-
kind: TopologyViolationKind::LeaderPaneIdCollidesWithAgent,
|
|
169
|
-
detail: format!(
|
|
170
|
-
"leader_receiver.pane_id `{leader_pane}` is also bound to \
|
|
171
|
-
agent `{agent_id}` — legacy bare-pane advisory only; validate \
|
|
172
|
-
endpoint/session/window/pane_pid tuple before using this as an \
|
|
173
|
-
identity blocker"
|
|
174
|
-
),
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
out
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
///
|
|
184
|
-
/// Logs each violation in `violations` to stderr under the
|
|
185
|
-
/// `team_agent::layout` tag. No-op when the list is empty. This is the
|
|
186
|
-
/// Step-1 surface — `eprintln!` matches the codebase's existing logging
|
|
187
|
-
/// convention (see `lifecycle::launch::eprintln!` calls). Hard error path
|
|
188
|
-
/// is deferred to Step 10.
|
|
189
|
-
pub fn log_topology_violations(violations: &[TopologyViolation]) {
|
|
190
|
-
for v in violations {
|
|
191
|
-
eprintln!(
|
|
192
|
-
"team_agent::layout topology_invariant_violation kind={:?} detail={}",
|
|
193
|
-
v.kind, v.detail
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
#[cfg(test)]
|
|
199
|
-
mod tests {
|
|
200
|
-
use super::*;
|
|
201
|
-
use serde_json::json;
|
|
202
|
-
|
|
203
|
-
fn spec_for(team: &str) -> YamlValue {
|
|
204
|
-
YamlValue::Map(vec![(
|
|
205
|
-
"team".to_string(),
|
|
206
|
-
YamlValue::Map(vec![("name".to_string(), YamlValue::Str(team.to_string()))]),
|
|
207
|
-
)])
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
#[test]
|
|
211
|
-
fn leader_and_worker_session_names_are_disjoint_by_prefix() {
|
|
212
|
-
let leader = leader_session_name(Provider::Claude, Path::new("/tmp/proj"));
|
|
213
|
-
let worker = worker_session_name(&spec_for("alpha"));
|
|
214
|
-
assert!(
|
|
215
|
-
leader.as_str().starts_with(LEADER_SESSION_PREFIX),
|
|
216
|
-
"leader name `{}` must start with `{LEADER_SESSION_PREFIX}`",
|
|
217
|
-
leader.as_str()
|
|
218
|
-
);
|
|
219
|
-
assert!(
|
|
220
|
-
!worker.as_str().starts_with(LEADER_SESSION_PREFIX),
|
|
221
|
-
"worker name `{}` must NOT start with `{LEADER_SESSION_PREFIX}`",
|
|
222
|
-
worker.as_str()
|
|
223
|
-
);
|
|
224
|
-
assert_ne!(leader.as_str(), worker.as_str());
|
|
225
|
-
assert!(is_leader_session(&leader));
|
|
226
|
-
assert!(!is_leader_session(&worker));
|
|
227
|
-
assert!(is_worker_session(&worker, &spec_for("alpha")));
|
|
228
|
-
assert!(!is_worker_session(&leader, &spec_for("alpha")));
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
#[test]
|
|
232
|
-
fn assert_topology_clean_state_returns_empty() {
|
|
233
|
-
let state = json!({
|
|
234
|
-
"agents": {
|
|
235
|
-
"developer": { "pane_id": "%1", "window": "developer" },
|
|
236
|
-
"tester": { "pane_id": "%2", "window": "tester" }
|
|
237
|
-
},
|
|
238
|
-
"leader_receiver": { "pane_id": "%0" }
|
|
239
|
-
});
|
|
240
|
-
let v = assert_topology_invariants(&state, &spec_for("alpha"));
|
|
241
|
-
assert!(
|
|
242
|
-
v.is_empty(),
|
|
243
|
-
"clean state should produce no violations; got {v:?}"
|
|
244
|
-
);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
#[test]
|
|
248
|
-
fn assert_topology_flags_pane_id_collision() {
|
|
249
|
-
let state = json!({
|
|
250
|
-
"agents": {
|
|
251
|
-
"developer": { "pane_id": "%1", "window": "developer" },
|
|
252
|
-
"tester": { "pane_id": "%1", "window": "tester" }
|
|
253
|
-
},
|
|
254
|
-
"leader_receiver": { "pane_id": "%0" }
|
|
255
|
-
});
|
|
256
|
-
let v = assert_topology_invariants(&state, &spec_for("alpha"));
|
|
257
|
-
assert!(
|
|
258
|
-
v.iter()
|
|
259
|
-
.any(|x| matches!(x.kind, TopologyViolationKind::AgentPaneIdCollision)),
|
|
260
|
-
"must flag AgentPaneIdCollision; got {v:?}"
|
|
261
|
-
);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
#[test]
|
|
265
|
-
fn assert_topology_flags_leader_pane_overlap_with_agent() {
|
|
266
|
-
let state = json!({
|
|
267
|
-
"agents": {
|
|
268
|
-
"developer": { "pane_id": "%0", "window": "developer" }
|
|
269
|
-
},
|
|
270
|
-
"leader_receiver": { "pane_id": "%0" }
|
|
271
|
-
});
|
|
272
|
-
let v = assert_topology_invariants(&state, &spec_for("alpha"));
|
|
273
|
-
assert!(
|
|
274
|
-
v.iter()
|
|
275
|
-
.any(|x| matches!(x.kind, TopologyViolationKind::LeaderPaneIdCollidesWithAgent)),
|
|
276
|
-
"must flag LeaderPaneIdCollidesWithAgent; got {v:?}"
|
|
277
|
-
);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
#[test]
|
|
281
|
-
fn assert_topology_flags_worker_window_named_leader() {
|
|
282
|
-
let state = json!({
|
|
283
|
-
"agents": {
|
|
284
|
-
"stray": { "pane_id": "%5", "window": "leader" }
|
|
285
|
-
}
|
|
286
|
-
});
|
|
287
|
-
let v = assert_topology_invariants(&state, &spec_for("alpha"));
|
|
288
|
-
assert!(
|
|
289
|
-
v.iter()
|
|
290
|
-
.any(|x| matches!(x.kind, TopologyViolationKind::WorkerWindowNamedLeader)),
|
|
291
|
-
"must flag WorkerWindowNamedLeader; got {v:?}"
|
|
292
|
-
);
|
|
293
|
-
}
|
|
294
|
-
}
|