@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,559 +0,0 @@
|
|
|
1
|
-
//! ---
|
|
2
|
-
//! purpose: restart 与 start 的纯决策层,定启动模式、first_send_at 分类与整队 resume 计划
|
|
3
|
-
//! contract:
|
|
4
|
-
//! provides:
|
|
5
|
-
//! - name: decide_start_mode
|
|
6
|
-
//! what: 由 session_id 与 resume 依据决定 Resumed/Fresh/FreshAfterMissingRollout/Noop
|
|
7
|
-
//! - name: classify_first_send_at
|
|
8
|
-
//! what: 严格分类 first_send_at,绝不靠真值性
|
|
9
|
-
//! - name: restart_agent_has_context_to_preserve
|
|
10
|
-
//! what: 判断该席位是否有会被静默 fresh 丢掉的上下文
|
|
11
|
-
//! - name: classify_restart_plan
|
|
12
|
-
//! what: 纯计算出整队的 resume 决策、损坏条目与不可 resume 名单
|
|
13
|
-
//! - name: python_type_name
|
|
14
|
-
//! what: 给出与 Python 一致的类型名,用于审计载荷
|
|
15
|
-
//! depends:
|
|
16
|
-
//! - crate::provider::wire
|
|
17
|
-
//! boundary:
|
|
18
|
-
//! - 纯计算,不 spawn、不 kill、不写盘
|
|
19
|
-
//! - 拒绝结论必须先于任何 teardown 产出,本层不执行任何破坏性动作
|
|
20
|
-
//! - 类型名用 Python 命名而非 serde 命名,保持与真相源一致
|
|
21
|
-
//! maturity: wired
|
|
22
|
-
//! ---
|
|
23
|
-
use super::common::*;
|
|
24
|
-
use super::*;
|
|
25
|
-
use crate::provider::wire::{parse_canonical_provider, requires_resume_backing};
|
|
26
|
-
|
|
27
|
-
#[cfg(all(test, unix))]
|
|
28
|
-
mod contract_route_tests {
|
|
29
|
-
use super::*;
|
|
30
|
-
|
|
31
|
-
#[test]
|
|
32
|
-
fn contract_seats_never_enter_legacy_resume_or_fresh_classification() {
|
|
33
|
-
let state = serde_json::json!({"agents": {
|
|
34
|
-
"cursor": {"provider":"cursor","status":"running","session_id":"native-cursor"},
|
|
35
|
-
"kiro": {"provider":"kiro","status":"running","session_id":"native-kiro"},
|
|
36
|
-
}});
|
|
37
|
-
for allow_fresh in [false, true] {
|
|
38
|
-
let plan = classify_restart_plan(&state, allow_fresh).unwrap();
|
|
39
|
-
assert!(plan.decisions.is_empty());
|
|
40
|
-
assert!(plan.unresumable.is_empty());
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
#[test]
|
|
45
|
-
fn mixed_team_retains_legacy_classification_without_native_codex_fallback() {
|
|
46
|
-
let state = serde_json::json!({"agents": {
|
|
47
|
-
"native": {"provider":"cursor","status":"running","session_id":"native-id"},
|
|
48
|
-
"legacy": {"provider":"pi","status":"running"},
|
|
49
|
-
}});
|
|
50
|
-
let plan = classify_restart_plan(&state, false).unwrap();
|
|
51
|
-
assert_eq!(plan.decisions.len(), 1);
|
|
52
|
-
assert_eq!(plan.decisions[0].agent_id.as_str(), "legacy");
|
|
53
|
-
assert_eq!(plan.decisions[0].restart_mode, StartMode::Fresh);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
#[cfg(test)]
|
|
58
|
-
mod stopped_restart_tests {
|
|
59
|
-
use super::*;
|
|
60
|
-
|
|
61
|
-
#[test]
|
|
62
|
-
fn stopped_rows_never_enter_validation_or_fresh_spawn_even_with_allow_fresh() {
|
|
63
|
-
let state = serde_json::json!({"agents": {
|
|
64
|
-
"stopped": {"provider":"pi","status":"stopped","explicit_stop":true,
|
|
65
|
-
"session_id":"preserved","generation":7,"first_send_at":false},
|
|
66
|
-
"legacy_stopped": {"provider":"pi","status":"stopped"},
|
|
67
|
-
"marker": {"provider":"pi","status":"running","explicit_stop":true},
|
|
68
|
-
"active": {"provider":"pi","status":"running"}
|
|
69
|
-
}});
|
|
70
|
-
let before = state.clone();
|
|
71
|
-
for allow_fresh in [false, true] {
|
|
72
|
-
let plan = classify_restart_plan(&state, allow_fresh).unwrap();
|
|
73
|
-
assert_eq!(plan.decisions.len(), 1);
|
|
74
|
-
assert_eq!(plan.decisions[0].agent_id.as_str(), "active");
|
|
75
|
-
assert!(plan.corrupt_entries.is_empty());
|
|
76
|
-
assert!(plan.unresumable.is_empty());
|
|
77
|
-
assert_eq!(state, before);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/// ---
|
|
83
|
-
/// purpose: 定出该席位这次的启动模式
|
|
84
|
-
/// params:
|
|
85
|
-
/// provider: provider wire 名,不支持 resume 时视为无 resume 依据
|
|
86
|
-
/// session_id: 已记录的会话;为空直接 Fresh
|
|
87
|
-
/// _rollout_path: 未参与判定
|
|
88
|
-
/// rollout_exists: resume 依据是否存在
|
|
89
|
-
/// allow_fresh: 依据缺失时是否允许改跑全新会话
|
|
90
|
-
/// returns: 依据齐全为 Resumed;缺依据且允许时为 FreshAfterMissingRollout;缺依据且不允许时为 Noop
|
|
91
|
-
/// ---
|
|
92
|
-
/// bug-085 四象限 `start_mode` 决策(`start.py:179-188` + `_resume_rollout_missing` `start.py:66-69`),
|
|
93
|
-
/// **从 start_agent 的整条 lock+spawn 路径里分离出的纯函数**(gate gap:porter 需要单元级 RED
|
|
94
|
-
/// for `FreshAfterMissingRollout`,而 start_agent 全路径不可单测)。语义:
|
|
95
|
-
/// - resume backing 缺失时不可 resume:codex/claude 用 transcript/rollout 文件,
|
|
96
|
-
/// copilot 用 session-store 行存在性(由调用方折叠进 `rollout_exists`)。
|
|
97
|
-
/// - 初始 `start_mode = if session_id { Resumed } else { Fresh }`(`start.py:179`)。
|
|
98
|
-
/// - `missing && allow_fresh` 升级为 `FreshAfterMissingRollout` 并清空 session_id。
|
|
99
|
-
/// - `missing && !allow_fresh` 返回 `Noop`,调用方据此诚实拒绝并提示 `--allow-fresh`。
|
|
100
|
-
pub fn decide_start_mode(
|
|
101
|
-
provider: &str,
|
|
102
|
-
session_id: Option<&SessionId>,
|
|
103
|
-
_rollout_path: Option<&RolloutPath>,
|
|
104
|
-
rollout_exists: bool,
|
|
105
|
-
allow_fresh: bool,
|
|
106
|
-
) -> StartMode {
|
|
107
|
-
match session_id {
|
|
108
|
-
None => StartMode::Fresh,
|
|
109
|
-
Some(_) => {
|
|
110
|
-
let missing_resume_backing = !provider_wire_supports_resume(provider)
|
|
111
|
-
|| (resumable_provider_requires_backing(provider) && !rollout_exists);
|
|
112
|
-
match (missing_resume_backing, allow_fresh) {
|
|
113
|
-
(true, true) => StartMode::FreshAfterMissingRollout,
|
|
114
|
-
(true, false) => StartMode::Noop,
|
|
115
|
-
(false, _) => StartMode::Resumed,
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/// ---
|
|
122
|
-
/// purpose: 判断该 provider 的 resume 是否必须有落盘依据
|
|
123
|
-
/// returns: 能解析成规范 provider 且它要求依据时为 true
|
|
124
|
-
/// ---
|
|
125
|
-
pub(crate) fn resumable_provider_requires_backing(provider: &str) -> bool {
|
|
126
|
-
parse_canonical_provider(provider).is_some_and(requires_resume_backing)
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/// ---
|
|
130
|
-
/// purpose: 严格分类 first_send_at 取值
|
|
131
|
-
/// params:
|
|
132
|
-
/// raw: 原始 JSON 值
|
|
133
|
-
/// returns: 空值为 Absent,合法 ISO 时间串为 Valid,其余一切取值都是 Corrupt
|
|
134
|
-
/// ---
|
|
135
|
-
/// `first_send_at` 严格分类(`_classify_first_send_at`,`orchestration.py:399`)。
|
|
136
|
-
/// **绝不靠 truthiness**:`""`/`0`/`False`/`"null"`/非 ISO → `Corrupt`。
|
|
137
|
-
pub(crate) fn classify_first_send_at(raw: &serde_json::Value) -> FirstSendAtState {
|
|
138
|
-
match raw {
|
|
139
|
-
serde_json::Value::Null => FirstSendAtState::Absent,
|
|
140
|
-
serde_json::Value::String(s) => {
|
|
141
|
-
if is_python_fromisoformat_like(s) {
|
|
142
|
-
FirstSendAtState::Valid
|
|
143
|
-
} else {
|
|
144
|
-
FirstSendAtState::Corrupt
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
serde_json::Value::Bool(_)
|
|
148
|
-
| serde_json::Value::Number(_)
|
|
149
|
-
| serde_json::Value::Array(_)
|
|
150
|
-
| serde_json::Value::Object(_) => FirstSendAtState::Corrupt,
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/// ---
|
|
155
|
-
/// purpose: 判断该席位是否有一旦静默 fresh 就会丢掉的上下文
|
|
156
|
-
/// returns: first_send_at 合法、有 last_result_at 或标了已投递首任务,任一成立即 true
|
|
157
|
-
/// ---
|
|
158
|
-
/// RESTART-RESUME-001 (0.4.8): true if the agent has any signal of prior
|
|
159
|
-
/// interaction whose context would be lost by silent fresh-start. Checks
|
|
160
|
-
/// `first_send_at` (leader→worker delivery), `last_result_at` (worker
|
|
161
|
-
/// report_result), and `task_prompt_delivered` (MCP-only worker first task).
|
|
162
|
-
/// Used by both the selection-stage never-captured decision and the
|
|
163
|
-
/// pre-selection convergence missing-set predicate so the two layers share
|
|
164
|
-
/// a single "needs context preservation" semantic.
|
|
165
|
-
///
|
|
166
|
-
/// CR M2 callers (must stay in sync):
|
|
167
|
-
/// * lifecycle/restart/selection.rs (never_captured branch, classify_resume_decision)
|
|
168
|
-
/// * lifecycle/restart/common.rs::restart_required_missing_session_agent_ids
|
|
169
|
-
pub(crate) fn restart_agent_has_context_to_preserve(agent: &serde_json::Value) -> bool {
|
|
170
|
-
let has_valid_first_send_at = matches!(
|
|
171
|
-
classify_first_send_at(
|
|
172
|
-
agent
|
|
173
|
-
.get("first_send_at")
|
|
174
|
-
.unwrap_or(&serde_json::Value::Null)
|
|
175
|
-
),
|
|
176
|
-
FirstSendAtState::Valid
|
|
177
|
-
);
|
|
178
|
-
if has_valid_first_send_at {
|
|
179
|
-
return true;
|
|
180
|
-
}
|
|
181
|
-
let has_last_result_at = agent
|
|
182
|
-
.get("last_result_at")
|
|
183
|
-
.and_then(serde_json::Value::as_str)
|
|
184
|
-
.is_some_and(|s| !s.is_empty());
|
|
185
|
-
if has_last_result_at {
|
|
186
|
-
return true;
|
|
187
|
-
}
|
|
188
|
-
agent
|
|
189
|
-
.get("task_prompt_delivered")
|
|
190
|
-
.and_then(serde_json::Value::as_bool)
|
|
191
|
-
.unwrap_or(false)
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/// ---
|
|
195
|
-
/// purpose: 判断该席位从未被捕获过会话,因而可以安全地直接 fresh
|
|
196
|
-
/// params:
|
|
197
|
-
/// session_id: 外部已知的会话 id,与席位行里的一并检查
|
|
198
|
-
/// returns: 无会话且无待保留上下文时为 true
|
|
199
|
-
/// ---
|
|
200
|
-
/// RESTART-RESUME-001: an agent is "never-captured" when its session_id is
|
|
201
|
-
/// absent AND there is no context to preserve. Such an agent is safe to
|
|
202
|
-
/// auto-fresh without `--allow-fresh` and should NOT be required to capture
|
|
203
|
-
/// a transcript before restart proceeds.
|
|
204
|
-
pub(crate) fn restart_agent_never_captured(
|
|
205
|
-
agent: &serde_json::Value,
|
|
206
|
-
session_id: Option<&str>,
|
|
207
|
-
) -> bool {
|
|
208
|
-
let session_present = session_id.is_some_and(|s| !s.is_empty())
|
|
209
|
-
|| agent
|
|
210
|
-
.get("session_id")
|
|
211
|
-
.and_then(serde_json::Value::as_str)
|
|
212
|
-
.is_some_and(|s| !s.is_empty());
|
|
213
|
-
if session_present {
|
|
214
|
-
return false;
|
|
215
|
-
}
|
|
216
|
-
!restart_agent_has_context_to_preserve(agent)
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
fn is_python_fromisoformat_like(raw: &str) -> bool {
|
|
220
|
-
if raw.is_empty() {
|
|
221
|
-
return false;
|
|
222
|
-
}
|
|
223
|
-
if chrono::DateTime::parse_from_rfc3339(raw).is_ok()
|
|
224
|
-
|| chrono::DateTime::parse_from_str(raw, "%Y-%m-%dT%H:%M:%S%z").is_ok()
|
|
225
|
-
|| chrono::DateTime::parse_from_str(raw, "%Y-%m-%dT%H:%M:%S%.f%z").is_ok()
|
|
226
|
-
{
|
|
227
|
-
return true;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
let normalized = normalize_iso_separator(raw);
|
|
231
|
-
for pattern in [
|
|
232
|
-
"%Y-%m-%d",
|
|
233
|
-
"%Y%m%d",
|
|
234
|
-
"%Y-%m-%dT%H:%M",
|
|
235
|
-
"%Y-%m-%dT%H:%M:%S",
|
|
236
|
-
"%Y-%m-%dT%H:%M:%S%.f",
|
|
237
|
-
"%Y-%m-%dT%H:%M%z",
|
|
238
|
-
"%Y-%m-%dT%H:%M:%S%z",
|
|
239
|
-
"%Y-%m-%dT%H:%M:%S%.f%z",
|
|
240
|
-
"%Y%m%dT%H%M%S",
|
|
241
|
-
] {
|
|
242
|
-
if chrono::NaiveDate::parse_from_str(&normalized, pattern).is_ok()
|
|
243
|
-
|| chrono::NaiveDateTime::parse_from_str(&normalized, pattern).is_ok()
|
|
244
|
-
|| chrono::DateTime::parse_from_str(&normalized, pattern).is_ok()
|
|
245
|
-
{
|
|
246
|
-
return true;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
false
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
fn normalize_iso_separator(raw: &str) -> String {
|
|
253
|
-
let mut out = String::with_capacity(raw.len());
|
|
254
|
-
for (idx, ch) in raw.chars().enumerate() {
|
|
255
|
-
if idx == 10 && matches!(ch, ' ' | 't' | '_') {
|
|
256
|
-
out.push('T');
|
|
257
|
-
} else {
|
|
258
|
-
out.push(ch);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
out
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
/// ---
|
|
265
|
-
/// purpose: 给出与 Python 一致的类型名
|
|
266
|
-
/// returns: NoneType、str、bool、list、dict、int 或 float
|
|
267
|
-
/// ---
|
|
268
|
-
/// Python `type(value).__name__` 映射(`orchestration.py:446`):corrupt first_send_at
|
|
269
|
-
/// 条目的 `raw_first_send_at_type` golden。锁死跨语言一致:`null→"NoneType"`、`""/"x"→"str"`、
|
|
270
|
-
/// `0/123→"int"`、`false→"bool"`、`[]→"list"`、`{}→"dict"`、float→`"float"`。
|
|
271
|
-
/// **绝不**用 Rust 的 `"null"/"string"/"number"/"boolean"/"array"/"object"`(serde 名)—— 必须是
|
|
272
|
-
/// Python 名,否则 audit payload 与真相源不一致。
|
|
273
|
-
pub(crate) fn python_type_name(value: &serde_json::Value) -> &'static str {
|
|
274
|
-
match value {
|
|
275
|
-
serde_json::Value::Null => "NoneType",
|
|
276
|
-
serde_json::Value::String(_) => "str",
|
|
277
|
-
serde_json::Value::Bool(_) => "bool",
|
|
278
|
-
serde_json::Value::Array(_) => "list",
|
|
279
|
-
serde_json::Value::Object(_) => "dict",
|
|
280
|
-
serde_json::Value::Number(n) => {
|
|
281
|
-
if n.is_i64() || n.is_u64() {
|
|
282
|
-
"int"
|
|
283
|
-
} else {
|
|
284
|
-
"float"
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
/// ---
|
|
291
|
-
/// purpose: 纯计算出整队的 restart 计划
|
|
292
|
-
/// params:
|
|
293
|
-
/// allow_fresh: 允许无会话席位改跑全新会话
|
|
294
|
-
/// returns: 每个非 paused/非 stopped 席位的 resume 决策、损坏的 first_send_at 条目与不可 resume 名单
|
|
295
|
-
/// errors: 计算过程中的错误以 LifecycleError 返回
|
|
296
|
-
/// contract_id: lifecycle.selection.classify_restart_plan
|
|
297
|
-
/// ---
|
|
298
|
-
/// Route B 全量验证(纯计算,**无破坏性副作用**;`_emit_resume_decisions` +
|
|
299
|
-
/// `_collect_corrupt_first_send_at`,`orchestration.py:430/467`)。读 fixture state 的
|
|
300
|
-
/// `agents.<id>`,对每非 paused/非 stopped worker(explicit_stop 也跳过):
|
|
301
|
-
/// (1) corrupt first_send_at → 收进 `corrupt_entries`(carry python type-name);
|
|
302
|
-
/// (2) 算 resume 决策(`session_id→Resume` / `null session && allow_fresh→FreshStart` /
|
|
303
|
-
/// 否则 `Refuse`;E6 层2:null session 不再因 first_send_at=null 静默 fresh);
|
|
304
|
-
/// (3) `Refuse` 的 worker(reason=`no_persisted_session_id`(无 session)|`session_unresumable`)
|
|
305
|
-
/// 进 `unresumable`。
|
|
306
|
-
/// restart() **先**调它再 teardown;corrupt 非空 → `RefusedInvalidFirstSendAt`,unresumable
|
|
307
|
-
/// 非空且 !allow_fresh → `RefusedResumeAtomicity`。**refuse 早于一切 teardown,nothing created**。
|
|
308
|
-
pub(crate) fn classify_restart_plan(
|
|
309
|
-
state: &serde_json::Value,
|
|
310
|
-
allow_fresh: bool,
|
|
311
|
-
) -> Result<RestartPlan, LifecycleError> {
|
|
312
|
-
classify_restart_plan_with_resume_validation(None, state, allow_fresh)
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
/// ---
|
|
316
|
-
/// purpose: 同上,并可带 workspace 以校验 resume 依据是否真的在盘上
|
|
317
|
-
/// params:
|
|
318
|
-
/// workspace: 给出时才做落盘依据校验
|
|
319
|
-
/// returns: 同 classify_restart_plan
|
|
320
|
-
/// errors: 计算过程中的错误以 LifecycleError 返回
|
|
321
|
-
/// contract_id: lifecycle.selection.classify_restart_plan
|
|
322
|
-
/// ---
|
|
323
|
-
pub(crate) fn classify_restart_plan_with_resume_validation(
|
|
324
|
-
workspace: Option<&Path>,
|
|
325
|
-
state: &serde_json::Value,
|
|
326
|
-
allow_fresh: bool,
|
|
327
|
-
) -> Result<RestartPlan, LifecycleError> {
|
|
328
|
-
let mut decisions = Vec::new();
|
|
329
|
-
let mut corrupt_entries = Vec::new();
|
|
330
|
-
let mut unresumable = Vec::new();
|
|
331
|
-
|
|
332
|
-
let Some(agents) = state.get("agents").and_then(|v| v.as_object()) else {
|
|
333
|
-
return Ok(RestartPlan {
|
|
334
|
-
decisions,
|
|
335
|
-
corrupt_entries,
|
|
336
|
-
unresumable,
|
|
337
|
-
});
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
for (worker_id, agent) in agents {
|
|
341
|
-
// Contract resumes are admitted against their canonical native store,
|
|
342
|
-
// not this legacy enum's unknown-provider Codex default.
|
|
343
|
-
#[cfg(unix)]
|
|
344
|
-
if crate::contract_runtime::framework::is_contract(agent) { continue; }
|
|
345
|
-
if crate::state::projection::agent_stopped_for_restart(agent)
|
|
346
|
-
|| agent.get("status").and_then(|v| v.as_str()) == Some("paused")
|
|
347
|
-
{
|
|
348
|
-
continue;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
let first_send_at_raw = agent
|
|
352
|
-
.get("first_send_at")
|
|
353
|
-
.cloned()
|
|
354
|
-
.unwrap_or(serde_json::Value::Null);
|
|
355
|
-
let first_send_at_state = classify_first_send_at(&first_send_at_raw);
|
|
356
|
-
if matches!(first_send_at_state, FirstSendAtState::Corrupt) {
|
|
357
|
-
corrupt_entries.push(CorruptFirstSendAt {
|
|
358
|
-
worker_id: AgentId::new(worker_id.clone()),
|
|
359
|
-
raw_first_send_at_type: python_type_name(&first_send_at_raw).to_string(),
|
|
360
|
-
raw_first_send_at: first_send_at_raw,
|
|
361
|
-
});
|
|
362
|
-
continue;
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
let session_id = agent
|
|
366
|
-
.get("session_id")
|
|
367
|
-
.and_then(|v| v.as_str())
|
|
368
|
-
.filter(|s| !s.is_empty())
|
|
369
|
-
.map(SessionId::new);
|
|
370
|
-
let agent_id = AgentId::new(worker_id.clone());
|
|
371
|
-
// E6 层2 (C2, 用户裁定"绝不静默 fresh"): null session 只有显式 --allow-fresh 才 fresh,
|
|
372
|
-
// 否则 Refuse(→ resume_not_ready + 指引)。删 `!interacted` 短路 —— 自启动 worker
|
|
373
|
-
// (leader 从未发消息 → first_send_at=null → interacted=false)会被它静默 fresh 丢上下文。
|
|
374
|
-
let provider = agent_provider(agent);
|
|
375
|
-
let provider_wire = provider_wire(provider);
|
|
376
|
-
let provider_can_resume = provider_supports_resume(provider);
|
|
377
|
-
let rollout_path = agent_rollout_path(agent);
|
|
378
|
-
// Layer 2 self-healing (leader follow-up 2026-06-22): use the
|
|
379
|
-
// structured probe so we can carry the list of paths the runtime
|
|
380
|
-
// actually checked into the refusal — operators need to see WHICH
|
|
381
|
-
// places we looked, not just "missing".
|
|
382
|
-
let (resume_backing_exists, backing_checked_paths) =
|
|
383
|
-
match (workspace, session_id.as_ref(), provider_can_resume) {
|
|
384
|
-
(_, Some(_), false) => (false, Vec::new()),
|
|
385
|
-
(Some(workspace), Some(session), true) => {
|
|
386
|
-
let probe = resume_backing_probe_for_agent(
|
|
387
|
-
workspace,
|
|
388
|
-
&agent_id,
|
|
389
|
-
agent,
|
|
390
|
-
provider,
|
|
391
|
-
session,
|
|
392
|
-
rollout_path.as_ref(),
|
|
393
|
-
);
|
|
394
|
-
(probe.exists, probe.checked_paths)
|
|
395
|
-
}
|
|
396
|
-
(None, Some(_), true) if resumable_provider_requires_backing(provider_wire) => {
|
|
397
|
-
let exists = rollout_path
|
|
398
|
-
.as_ref()
|
|
399
|
-
.is_some_and(|path| path.as_path().exists());
|
|
400
|
-
let checked = rollout_path
|
|
401
|
-
.as_ref()
|
|
402
|
-
.map(|p| vec![p.as_path().to_path_buf()])
|
|
403
|
-
.unwrap_or_default();
|
|
404
|
-
(exists, checked)
|
|
405
|
-
}
|
|
406
|
-
_ => (true, Vec::new()),
|
|
407
|
-
};
|
|
408
|
-
let identity_probe = workspace
|
|
409
|
-
.map(|workspace| {
|
|
410
|
-
session_identity_probe_for_agent_with_fork_ancestry(
|
|
411
|
-
workspace,
|
|
412
|
-
state,
|
|
413
|
-
&agent_id,
|
|
414
|
-
agent,
|
|
415
|
-
provider,
|
|
416
|
-
rollout_path.as_ref(),
|
|
417
|
-
)
|
|
418
|
-
})
|
|
419
|
-
.unwrap_or_else(|| {
|
|
420
|
-
session_identity_probe_for_agent(&agent_id, provider, rollout_path.as_ref())
|
|
421
|
-
});
|
|
422
|
-
let session_identity_mismatch = session_id.is_some()
|
|
423
|
-
&& provider_can_resume
|
|
424
|
-
&& resume_backing_exists
|
|
425
|
-
&& identity_probe.identity_ok == Some(false);
|
|
426
|
-
// 0.4.7 partial-resume + RESTART-RESUME-001 (0.4.8): when a worker
|
|
427
|
-
// has NEVER been captured (no session_id AND no context-bearing
|
|
428
|
-
// signal at all), it is structurally non-resumable — there is no
|
|
429
|
-
// context to lose, so auto-fresh is safe even without --allow-fresh.
|
|
430
|
-
//
|
|
431
|
-
// The "never_captured" predicate is now the shared
|
|
432
|
-
// restart_agent_never_captured(): session_id absent AND none of
|
|
433
|
-
// first_send_at(Valid) / last_result_at / task_prompt_delivered.
|
|
434
|
-
// This matches the pre-selection convergence semantic in
|
|
435
|
-
// common.rs::restart_required_missing_session_agent_ids so both
|
|
436
|
-
// layers refuse / auto-fresh in unison.
|
|
437
|
-
//
|
|
438
|
-
// If session_id is None but ANY context signal exists, that's the
|
|
439
|
-
// "received message/result but session not captured" bug state —
|
|
440
|
-
// keep the Refuse so we never silently drop context (architect
|
|
441
|
-
// rule: "绝不静默 fresh").
|
|
442
|
-
let _ = first_send_at_state; // retained for the Corrupt branch above
|
|
443
|
-
let never_captured =
|
|
444
|
-
restart_agent_never_captured(agent, session_id.as_ref().map(|s| s.as_str()));
|
|
445
|
-
let decision = if session_id.is_some()
|
|
446
|
-
&& provider_can_resume
|
|
447
|
-
&& resume_backing_exists
|
|
448
|
-
&& !session_identity_mismatch
|
|
449
|
-
{
|
|
450
|
-
ResumeDecision::Resume
|
|
451
|
-
} else if session_id.is_some() && allow_fresh {
|
|
452
|
-
ResumeDecision::FreshStart
|
|
453
|
-
} else if session_id.is_some() {
|
|
454
|
-
ResumeDecision::Refuse
|
|
455
|
-
} else if allow_fresh {
|
|
456
|
-
ResumeDecision::FreshStart
|
|
457
|
-
} else if never_captured {
|
|
458
|
-
// No session_id + never captured → safe to auto-fresh without
|
|
459
|
-
// --allow-fresh. No context to lose.
|
|
460
|
-
ResumeDecision::FreshStart
|
|
461
|
-
} else {
|
|
462
|
-
ResumeDecision::Refuse
|
|
463
|
-
};
|
|
464
|
-
if matches!(decision, ResumeDecision::Refuse) {
|
|
465
|
-
// unit-5: surface structured ResumeRefusalReason alongside the
|
|
466
|
-
// legacy free-form string. The string wire is preserved exactly
|
|
467
|
-
// (round-tripped through ResumeRefusalReason::wire) so the
|
|
468
|
-
// CLI/JSON contract does not change.
|
|
469
|
-
let (reason_str, structured) = if session_id.is_some() {
|
|
470
|
-
if session_identity_mismatch {
|
|
471
|
-
let session = session_id
|
|
472
|
-
.as_ref()
|
|
473
|
-
.map(|session| session.as_str().to_string())
|
|
474
|
-
.unwrap_or_default();
|
|
475
|
-
(
|
|
476
|
-
"session_identity_mismatch".to_string(),
|
|
477
|
-
crate::provider::session::ResumeRefusalReason::SessionIdentityMismatch {
|
|
478
|
-
expected_agent_id: agent_id.as_str().to_string(),
|
|
479
|
-
embedded_agent_id: identity_probe
|
|
480
|
-
.embedded_agent_id
|
|
481
|
-
.clone()
|
|
482
|
-
.unwrap_or_default(),
|
|
483
|
-
session_id: session,
|
|
484
|
-
rollout_path: identity_probe.rollout_path.clone(),
|
|
485
|
-
},
|
|
486
|
-
)
|
|
487
|
-
} else if !provider_can_resume {
|
|
488
|
-
(
|
|
489
|
-
"session_unresumable".to_string(),
|
|
490
|
-
crate::provider::session::ResumeRefusalReason::ProviderResumeUnsupported {
|
|
491
|
-
provider: provider_wire.to_string(),
|
|
492
|
-
},
|
|
493
|
-
)
|
|
494
|
-
} else if !resume_backing_exists {
|
|
495
|
-
// Today the legacy wire collapses backing-missing under
|
|
496
|
-
// the catch-all `session_unresumable` — keep that wire,
|
|
497
|
-
// but record the structured reason so the new shape is
|
|
498
|
-
// available to callers that want it.
|
|
499
|
-
//
|
|
500
|
-
// Layer 2 self-healing (architect probe 2026-06-22): attach
|
|
501
|
-
// a recovery hint pointing at the agent_id (used as
|
|
502
|
-
// launch-time `--name`) and spawn_cwd. Operator-facing
|
|
503
|
-
// diagnostic only — no auto-resume off the hint.
|
|
504
|
-
let recovery_hint = Some(crate::provider::session::RecoveryHint {
|
|
505
|
-
provider_session_name_hint: Some(agent_id.as_str().to_string()),
|
|
506
|
-
spawn_cwd: agent
|
|
507
|
-
.get("spawn_cwd")
|
|
508
|
-
.and_then(|v| v.as_str())
|
|
509
|
-
.filter(|s| !s.is_empty())
|
|
510
|
-
.map(std::path::PathBuf::from),
|
|
511
|
-
provider: provider_wire.to_string(),
|
|
512
|
-
});
|
|
513
|
-
(
|
|
514
|
-
"session_unresumable".to_string(),
|
|
515
|
-
crate::provider::session::ResumeRefusalReason::SessionBackingStoreMissing {
|
|
516
|
-
checked_paths: backing_checked_paths.clone(),
|
|
517
|
-
recovery_hint,
|
|
518
|
-
},
|
|
519
|
-
)
|
|
520
|
-
} else {
|
|
521
|
-
(
|
|
522
|
-
"session_unresumable".to_string(),
|
|
523
|
-
crate::provider::session::ResumeRefusalReason::Other {
|
|
524
|
-
legacy_reason: "session_unresumable".to_string(),
|
|
525
|
-
},
|
|
526
|
-
)
|
|
527
|
-
}
|
|
528
|
-
} else {
|
|
529
|
-
(
|
|
530
|
-
"no_persisted_session_id".to_string(),
|
|
531
|
-
crate::provider::session::ResumeRefusalReason::NoSessionId,
|
|
532
|
-
)
|
|
533
|
-
};
|
|
534
|
-
unresumable.push(UnresumableWorker {
|
|
535
|
-
agent_id: agent_id.clone(),
|
|
536
|
-
reason: reason_str,
|
|
537
|
-
refusal_reason: Some(structured),
|
|
538
|
-
session_id: session_id.clone(),
|
|
539
|
-
first_send_at: first_send_at_raw.as_str().map(|s| s.to_string()),
|
|
540
|
-
});
|
|
541
|
-
}
|
|
542
|
-
decisions.push(RestartedAgent {
|
|
543
|
-
agent_id,
|
|
544
|
-
restart_mode: match decision {
|
|
545
|
-
ResumeDecision::Resume => StartMode::Resumed,
|
|
546
|
-
ResumeDecision::FreshStart => StartMode::Fresh,
|
|
547
|
-
ResumeDecision::Refuse => StartMode::Noop,
|
|
548
|
-
},
|
|
549
|
-
decision,
|
|
550
|
-
session_id,
|
|
551
|
-
});
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
Ok(RestartPlan {
|
|
555
|
-
decisions,
|
|
556
|
-
corrupt_entries,
|
|
557
|
-
unresumable,
|
|
558
|
-
})
|
|
559
|
-
}
|