@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,633 +0,0 @@
|
|
|
1
|
-
#![allow(clippy::unwrap_used, clippy::panic)]
|
|
2
|
-
use super::*;
|
|
3
|
-
use crate::model::enums::Provider;
|
|
4
|
-
use crate::transport::enter_rescue::{EnterRescueProof, EnterRescueTarget};
|
|
5
|
-
use std::cell::Cell;
|
|
6
|
-
use std::sync::atomic::{AtomicUsize, Ordering};
|
|
7
|
-
|
|
8
|
-
struct Fixture {
|
|
9
|
-
workspace: std::path::PathBuf,
|
|
10
|
-
store: MessageStore,
|
|
11
|
-
log: EventLog,
|
|
12
|
-
context: EnterRescueContext,
|
|
13
|
-
}
|
|
14
|
-
impl Fixture {
|
|
15
|
-
fn new() -> Self {
|
|
16
|
-
static NEXT: AtomicUsize = AtomicUsize::new(0);
|
|
17
|
-
let workspace = std::env::temp_dir().join(format!(
|
|
18
|
-
"ta-independent-rescue-{}-{}",
|
|
19
|
-
std::process::id(),
|
|
20
|
-
NEXT.fetch_add(1, Ordering::SeqCst)
|
|
21
|
-
));
|
|
22
|
-
std::fs::create_dir(&workspace).unwrap();
|
|
23
|
-
let store = MessageStore::open(&workspace).unwrap();
|
|
24
|
-
let log = EventLog::new(&workspace);
|
|
25
|
-
let context = EnterRescueContext {
|
|
26
|
-
message_id: "msg_one".into(),
|
|
27
|
-
owner_team_id: "team".into(),
|
|
28
|
-
recipient: "worker".into(),
|
|
29
|
-
payload_sha256: digest(&render_message("leader", None, "body", "msg_one")),
|
|
30
|
-
target: Some(EnterRescueTarget {
|
|
31
|
-
provider: Provider::Pi,
|
|
32
|
-
endpoint: "/tmp/owned.sock".into(),
|
|
33
|
-
pane_id: "%1".into(),
|
|
34
|
-
pane_pid: 2,
|
|
35
|
-
pane_height: 120,
|
|
36
|
-
carrier_birth: "original-birth".into(),
|
|
37
|
-
binding_nonce: "original-nonce".into(),
|
|
38
|
-
session: "session".into(),
|
|
39
|
-
window: "worker".into(),
|
|
40
|
-
}),
|
|
41
|
-
proof: Some(EnterRescueProof {
|
|
42
|
-
ui_identity: "pi-model".into(),
|
|
43
|
-
footer_sha256: digest("footer"),
|
|
44
|
-
visible_marker: true,
|
|
45
|
-
transcript_marker_absent: true,
|
|
46
|
-
owned_capsule: None,
|
|
47
|
-
}),
|
|
48
|
-
};
|
|
49
|
-
let fixture = Self {
|
|
50
|
-
workspace,
|
|
51
|
-
store,
|
|
52
|
-
log,
|
|
53
|
-
context,
|
|
54
|
-
};
|
|
55
|
-
fixture.conn().execute("insert into messages(message_id,owner_team_id,sender,recipient,content,status,created_at,updated_at,delivery_attempts) values('msg_one','team','leader','worker','body','submitted_unverified','old','old',1)",[]).unwrap();
|
|
56
|
-
fixture.state("running", false);
|
|
57
|
-
fixture
|
|
58
|
-
}
|
|
59
|
-
fn conn(&self) -> rusqlite::Connection {
|
|
60
|
-
crate::db::schema::open_db(self.store.db_path()).unwrap()
|
|
61
|
-
}
|
|
62
|
-
fn state(&self, status: &str, stopped: bool) {
|
|
63
|
-
let state = serde_json::json!({"team_key":"team","session_name":"session","agents":{"worker":{"status":status,"explicit_stop":stopped,"provider":"pi","pane_id":"%1","pane_pid":2,"window":"worker"}}});
|
|
64
|
-
std::fs::write(
|
|
65
|
-
crate::model::paths::runtime_dir(&self.workspace).join("state.json"),
|
|
66
|
-
state.to_string(),
|
|
67
|
-
)
|
|
68
|
-
.unwrap();
|
|
69
|
-
}
|
|
70
|
-
fn schedule(&self, age: i64, bound: bool) {
|
|
71
|
-
let mut conn = self.conn();
|
|
72
|
-
let tx = conn.transaction().unwrap();
|
|
73
|
-
schedule_in_tx(&tx, "msg_one", Utc::now() - Duration::seconds(age)).unwrap();
|
|
74
|
-
tx.commit().unwrap();
|
|
75
|
-
if bound {
|
|
76
|
-
assert!(bind_pending_context(&self.store, &self.context).unwrap());
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
fn job(&self) -> (i64, String, String) {
|
|
80
|
-
self.conn()
|
|
81
|
-
.query_row(
|
|
82
|
-
"select id,payload_json,status from scheduled_events",
|
|
83
|
-
[],
|
|
84
|
-
|r| Ok((r.get(0)?, r.get(1)?, r.get(2)?)),
|
|
85
|
-
)
|
|
86
|
-
.unwrap()
|
|
87
|
-
}
|
|
88
|
-
fn message_status(&self) -> String {
|
|
89
|
-
self.conn()
|
|
90
|
-
.query_row(
|
|
91
|
-
"select status from messages where message_id='msg_one'",
|
|
92
|
-
[],
|
|
93
|
-
|r| r.get(0),
|
|
94
|
-
)
|
|
95
|
-
.unwrap()
|
|
96
|
-
}
|
|
97
|
-
fn fire(&self, execute: &Executor<'_>) -> bool {
|
|
98
|
-
let (id, payload, _) = self.job();
|
|
99
|
-
fire_with(
|
|
100
|
-
&self.workspace,
|
|
101
|
-
&self.store,
|
|
102
|
-
&self.log,
|
|
103
|
-
id,
|
|
104
|
-
&payload,
|
|
105
|
-
execute,
|
|
106
|
-
)
|
|
107
|
-
.unwrap()
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
impl Drop for Fixture {
|
|
111
|
-
fn drop(&mut self) {
|
|
112
|
-
let _ = std::fs::remove_dir_all(&self.workspace);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
#[test]
|
|
117
|
-
fn enter_rescue_first_successful_key_arms_original_turn_before_acceptance_poll() {
|
|
118
|
-
let f = Fixture::new();
|
|
119
|
-
f.schedule(95, true);
|
|
120
|
-
super::super::delivery::with_rescue_submit_observer(
|
|
121
|
-
&f.workspace,
|
|
122
|
-
&f.store,
|
|
123
|
-
&f.context,
|
|
124
|
-
&f.log,
|
|
125
|
-
|observer| {
|
|
126
|
-
observer.after_physical_submit();
|
|
127
|
-
let state = crate::state::persist::load_runtime_state(&f.workspace).unwrap();
|
|
128
|
-
assert_eq!(
|
|
129
|
-
state["agents"]["worker"]["current_turn_message_id"],
|
|
130
|
-
"msg_one"
|
|
131
|
-
);
|
|
132
|
-
Ok(EnterRescueOutcome::Entered { accepted: false })
|
|
133
|
-
},
|
|
134
|
-
)
|
|
135
|
-
.unwrap();
|
|
136
|
-
assert_eq!(f.message_status(), "submitted_unverified");
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
#[test]
|
|
140
|
-
fn enter_rescue_post_key_owner_or_receiver_loss_is_unknown_without_cross_team_write() {
|
|
141
|
-
for change in [
|
|
142
|
-
"owner",
|
|
143
|
-
"receiver",
|
|
144
|
-
"pane",
|
|
145
|
-
"pane_pid",
|
|
146
|
-
"missing_pane_pid",
|
|
147
|
-
"session",
|
|
148
|
-
"stopped",
|
|
149
|
-
] {
|
|
150
|
-
let f = Fixture::new();
|
|
151
|
-
f.schedule(95, true);
|
|
152
|
-
let (id, payload, _) = f.job();
|
|
153
|
-
let effects = AtomicUsize::new(0);
|
|
154
|
-
let path = crate::model::paths::runtime_dir(&f.workspace).join("state.json");
|
|
155
|
-
let replacement = std::cell::RefCell::new(String::new());
|
|
156
|
-
// Controlled post-key mutation; this is not a native TUI reproduction.
|
|
157
|
-
fire_with(
|
|
158
|
-
&f.workspace,
|
|
159
|
-
&f.store,
|
|
160
|
-
&f.log,
|
|
161
|
-
id,
|
|
162
|
-
&payload,
|
|
163
|
-
&|context, _| {
|
|
164
|
-
super::super::delivery::with_rescue_submit_observer(
|
|
165
|
-
&f.workspace,
|
|
166
|
-
&f.store,
|
|
167
|
-
context,
|
|
168
|
-
&f.log,
|
|
169
|
-
|observer| {
|
|
170
|
-
effects.fetch_add(1, Ordering::SeqCst);
|
|
171
|
-
let mut state =
|
|
172
|
-
crate::state::persist::load_runtime_state(&f.workspace).unwrap();
|
|
173
|
-
match change {
|
|
174
|
-
"owner" => {
|
|
175
|
-
state["team_key"] = "other".into();
|
|
176
|
-
state["active_team_key"] = "other".into();
|
|
177
|
-
state.as_object_mut().unwrap().remove("teams");
|
|
178
|
-
}
|
|
179
|
-
"receiver" => {
|
|
180
|
-
state["agents"].as_object_mut().unwrap().remove("worker");
|
|
181
|
-
}
|
|
182
|
-
"pane" => state["agents"]["worker"]["pane_id"] = "%2".into(),
|
|
183
|
-
"pane_pid" => state["agents"]["worker"]["pane_pid"] = 3.into(),
|
|
184
|
-
"missing_pane_pid" => {
|
|
185
|
-
state["agents"]["worker"]
|
|
186
|
-
.as_object_mut()
|
|
187
|
-
.unwrap()
|
|
188
|
-
.remove("pane_pid");
|
|
189
|
-
}
|
|
190
|
-
"session" => state["session_name"] = "other-session".into(),
|
|
191
|
-
"stopped" => state["agents"]["worker"]["explicit_stop"] = true.into(),
|
|
192
|
-
_ => unreachable!(),
|
|
193
|
-
}
|
|
194
|
-
*replacement.borrow_mut() = state.to_string();
|
|
195
|
-
std::fs::write(&path, replacement.borrow().as_bytes()).unwrap();
|
|
196
|
-
observer.after_physical_submit();
|
|
197
|
-
Ok(EnterRescueOutcome::Entered { accepted: true })
|
|
198
|
-
},
|
|
199
|
-
)
|
|
200
|
-
},
|
|
201
|
-
)
|
|
202
|
-
.unwrap();
|
|
203
|
-
// A rejected post-key commit must preserve every byte of replacement state.
|
|
204
|
-
let expected = replacement.borrow().clone();
|
|
205
|
-
assert_eq!(std::fs::read_to_string(&path).unwrap(), expected);
|
|
206
|
-
assert_eq!(f.job().2, "unknown", "{change}");
|
|
207
|
-
assert_eq!(f.message_status(), "submitted_unverified");
|
|
208
|
-
let state: serde_json::Value = serde_json::from_str(&expected).unwrap();
|
|
209
|
-
assert!(
|
|
210
|
-
state["agents"]["worker"]["current_turn_message_id"].is_null(),
|
|
211
|
-
"{change}"
|
|
212
|
-
);
|
|
213
|
-
assert!(!fire_with(
|
|
214
|
-
&f.workspace,
|
|
215
|
-
&f.store,
|
|
216
|
-
&f.log,
|
|
217
|
-
id,
|
|
218
|
-
&payload,
|
|
219
|
-
&|_, _| panic!("post-key error replay")
|
|
220
|
-
)
|
|
221
|
-
.unwrap());
|
|
222
|
-
assert_eq!(std::fs::read_to_string(&path).unwrap(), expected);
|
|
223
|
-
assert_eq!(effects.load(Ordering::SeqCst), 1);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
#[test]
|
|
228
|
-
fn enter_rescue_owner_loss_at_state_save_hook_refuses_without_default_fallback() {
|
|
229
|
-
let f = Fixture::new();
|
|
230
|
-
f.schedule(95, true);
|
|
231
|
-
let path = crate::model::paths::runtime_dir(&f.workspace).join("state.json");
|
|
232
|
-
let replacement = serde_json::json!({"team_key":"other","active_team_key":"other","session_name":"session","agents":{"worker":{"provider":"pi","status":"running","pane_id":"%1","pane_pid":2,"window":"worker"}}}).to_string();
|
|
233
|
-
let hook_path = path.clone();
|
|
234
|
-
let hook_state = replacement.clone();
|
|
235
|
-
crate::state::repository::test_support::set_before_commit(move || {
|
|
236
|
-
std::fs::write(hook_path, hook_state).unwrap();
|
|
237
|
-
});
|
|
238
|
-
assert!(super::super::delivery::with_rescue_submit_observer(
|
|
239
|
-
&f.workspace,
|
|
240
|
-
&f.store,
|
|
241
|
-
&f.context,
|
|
242
|
-
&f.log,
|
|
243
|
-
|observer| {
|
|
244
|
-
observer.after_physical_submit();
|
|
245
|
-
Ok(EnterRescueOutcome::Entered { accepted: true })
|
|
246
|
-
},
|
|
247
|
-
)
|
|
248
|
-
.is_err());
|
|
249
|
-
assert_eq!(std::fs::read_to_string(path).unwrap(), replacement);
|
|
250
|
-
assert_eq!(f.message_status(), "submitted_unverified");
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
#[test]
|
|
254
|
-
fn enter_rescue_switched_top_projection_updates_only_retained_original_owner() {
|
|
255
|
-
let f = Fixture::new();
|
|
256
|
-
f.schedule(95, true);
|
|
257
|
-
super::super::delivery::with_rescue_submit_observer(
|
|
258
|
-
&f.workspace, &f.store, &f.context, &f.log, |observer| {
|
|
259
|
-
let original = crate::state::persist::load_runtime_state(&f.workspace).unwrap();
|
|
260
|
-
let mut other = original.clone();
|
|
261
|
-
other["team_key"] = "other".into();
|
|
262
|
-
other["active_team_key"] = "other".into();
|
|
263
|
-
other["session_name"] = "other-session".into();
|
|
264
|
-
other["agents"]["worker"]["pane_id"] = "%2".into();
|
|
265
|
-
other["agents"]["worker"]["pane_pid"] = 3.into();
|
|
266
|
-
let mut state = other.clone();
|
|
267
|
-
state["teams"] = serde_json::json!({"team": crate::state::projection::compact_team_state(&original), "other": crate::state::projection::compact_team_state(&other)});
|
|
268
|
-
std::fs::write(crate::model::paths::runtime_dir(&f.workspace).join("state.json"), state.to_string()).unwrap();
|
|
269
|
-
observer.after_physical_submit();
|
|
270
|
-
Ok(EnterRescueOutcome::Entered { accepted: false })
|
|
271
|
-
},
|
|
272
|
-
).unwrap();
|
|
273
|
-
let state = crate::state::persist::load_runtime_state(&f.workspace).unwrap();
|
|
274
|
-
assert_eq!(
|
|
275
|
-
state["teams"]["team"]["agents"]["worker"]["current_turn_message_id"],
|
|
276
|
-
"msg_one"
|
|
277
|
-
);
|
|
278
|
-
assert!(state["teams"]["other"]["agents"]["worker"]["current_turn_message_id"].is_null());
|
|
279
|
-
assert!(state["agents"]["worker"]["current_turn_message_id"].is_null());
|
|
280
|
-
assert_eq!(state["agents"]["worker"]["pane_id"], "%2");
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
#[test]
|
|
284
|
-
fn every_unverified_row_registers_independently_of_native_receipts() {
|
|
285
|
-
let f = Fixture::new();
|
|
286
|
-
f.schedule(0, false);
|
|
287
|
-
let (_, payload, status) = f.job();
|
|
288
|
-
let job: RescueJob = serde_json::from_str(&payload).unwrap();
|
|
289
|
-
assert_eq!(status, "pending");
|
|
290
|
-
assert!(job.context.target.is_none());
|
|
291
|
-
assert!(job.context.proof.is_none());
|
|
292
|
-
assert!(!payload.contains("evidence"));
|
|
293
|
-
assert!(!payload.contains("NativeInput"));
|
|
294
|
-
let due: String = f
|
|
295
|
-
.conn()
|
|
296
|
-
.query_row("select due_at from scheduled_events", [], |r| r.get(0))
|
|
297
|
-
.unwrap();
|
|
298
|
-
assert_eq!(
|
|
299
|
-
timestamp(&due).unwrap() - timestamp(&job.registered_at).unwrap(),
|
|
300
|
-
Duration::seconds(90)
|
|
301
|
-
);
|
|
302
|
-
assert_eq!(
|
|
303
|
-
timestamp(&job.expires_at).unwrap() - timestamp(&job.registered_at).unwrap(),
|
|
304
|
-
Duration::seconds(120)
|
|
305
|
-
);
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
#[test]
|
|
309
|
-
fn even_missing_owner_or_recipient_gets_a_job_then_refuses_without_keys() {
|
|
310
|
-
let f = Fixture::new();
|
|
311
|
-
f.conn()
|
|
312
|
-
.execute("update messages set owner_team_id=null,recipient=null", [])
|
|
313
|
-
.unwrap();
|
|
314
|
-
f.schedule(95, false);
|
|
315
|
-
assert_eq!(f.job().2, "pending");
|
|
316
|
-
assert!(f.fire(&|_, _| panic!("unowned registration is not key authority")));
|
|
317
|
-
assert_eq!(f.job().2, "refused");
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
#[test]
|
|
321
|
-
fn registration_is_durable_and_never_resets_a_claimed_or_unknown_attempt() {
|
|
322
|
-
for status in ["pending", "claimed", "unknown", "done", "refused"] {
|
|
323
|
-
let f = Fixture::new();
|
|
324
|
-
f.schedule(95, false);
|
|
325
|
-
f.conn()
|
|
326
|
-
.execute("update scheduled_events set status=?1", [status])
|
|
327
|
-
.unwrap();
|
|
328
|
-
let original = f.job();
|
|
329
|
-
f.schedule(0, false);
|
|
330
|
-
assert_eq!(f.job(), original);
|
|
331
|
-
let count: i64 = f
|
|
332
|
-
.conn()
|
|
333
|
-
.query_row("select count(*) from scheduled_events", [], |r| r.get(0))
|
|
334
|
-
.unwrap();
|
|
335
|
-
assert_eq!(count, 1);
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
#[test]
|
|
340
|
-
fn unbound_job_is_observed_then_refused_without_executor() {
|
|
341
|
-
let f = Fixture::new();
|
|
342
|
-
f.schedule(95, false);
|
|
343
|
-
assert!(f.fire(&|_, _| panic!("unbound job must not reach keys")));
|
|
344
|
-
assert_eq!(f.job().2, "refused");
|
|
345
|
-
assert_eq!(f.message_status(), "submitted_unverified");
|
|
346
|
-
let result: String = f
|
|
347
|
-
.conn()
|
|
348
|
-
.query_row("select result_json from scheduled_events", [], |r| r.get(0))
|
|
349
|
-
.unwrap();
|
|
350
|
-
assert!(result.contains("proof_missing"));
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
#[test]
|
|
354
|
-
fn supplement_cannot_change_original_clock_scope_digest_or_bound_carrier() {
|
|
355
|
-
let f = Fixture::new();
|
|
356
|
-
f.schedule(95, false);
|
|
357
|
-
let before: (String, String) = f
|
|
358
|
-
.conn()
|
|
359
|
-
.query_row("select due_at,created_at from scheduled_events", [], |r| {
|
|
360
|
-
Ok((r.get(0)?, r.get(1)?))
|
|
361
|
-
})
|
|
362
|
-
.unwrap();
|
|
363
|
-
assert!(bind_pending_context(&f.store, &f.context).unwrap());
|
|
364
|
-
let after: (String, String) = f
|
|
365
|
-
.conn()
|
|
366
|
-
.query_row("select due_at,created_at from scheduled_events", [], |r| {
|
|
367
|
-
Ok((r.get(0)?, r.get(1)?))
|
|
368
|
-
})
|
|
369
|
-
.unwrap();
|
|
370
|
-
assert_eq!(before, after);
|
|
371
|
-
for field in [
|
|
372
|
-
"owner",
|
|
373
|
-
"recipient",
|
|
374
|
-
"digest",
|
|
375
|
-
"pid",
|
|
376
|
-
"birth",
|
|
377
|
-
"nonce",
|
|
378
|
-
"endpoint",
|
|
379
|
-
] {
|
|
380
|
-
let mut other = f.context.clone();
|
|
381
|
-
match field {
|
|
382
|
-
"owner" => other.owner_team_id = "other".into(),
|
|
383
|
-
"recipient" => other.recipient = "other".into(),
|
|
384
|
-
"digest" => other.payload_sha256 = digest("different"),
|
|
385
|
-
"pid" => other.target.as_mut().unwrap().pane_pid = 3,
|
|
386
|
-
"birth" => other.target.as_mut().unwrap().carrier_birth = "reused".into(),
|
|
387
|
-
"nonce" => other.target.as_mut().unwrap().binding_nonce = "replacement".into(),
|
|
388
|
-
_ => other.target.as_mut().unwrap().endpoint = "/tmp/other.sock".into(),
|
|
389
|
-
}
|
|
390
|
-
assert!(!bind_pending_context(&f.store, &other).unwrap(), "{field}");
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
#[test]
|
|
395
|
-
fn early_expired_or_extended_jobs_have_no_effect() {
|
|
396
|
-
for (age, extend) in [(0, false), (121, false), (95, true)] {
|
|
397
|
-
let f = Fixture::new();
|
|
398
|
-
f.schedule(age, true);
|
|
399
|
-
let (id, payload, _) = f.job();
|
|
400
|
-
let payload = if extend {
|
|
401
|
-
let mut j: RescueJob = serde_json::from_str(&payload).unwrap();
|
|
402
|
-
j.expires_at = (Utc::now() + Duration::hours(1)).to_rfc3339();
|
|
403
|
-
let p = serde_json::to_string(&j).unwrap();
|
|
404
|
-
f.conn()
|
|
405
|
-
.execute("update scheduled_events set payload_json=?1", [&p])
|
|
406
|
-
.unwrap();
|
|
407
|
-
p
|
|
408
|
-
} else {
|
|
409
|
-
payload
|
|
410
|
-
};
|
|
411
|
-
f.conn()
|
|
412
|
-
.execute(
|
|
413
|
-
"update scheduled_events set due_at='1970-01-01T00:00:00+00:00'",
|
|
414
|
-
[],
|
|
415
|
-
)
|
|
416
|
-
.unwrap();
|
|
417
|
-
assert!(fire_with(
|
|
418
|
-
&f.workspace,
|
|
419
|
-
&f.store,
|
|
420
|
-
&f.log,
|
|
421
|
-
id,
|
|
422
|
-
&payload,
|
|
423
|
-
&|_, _| panic!("invalid clock")
|
|
424
|
-
)
|
|
425
|
-
.unwrap());
|
|
426
|
-
assert_eq!(f.job().2, "refused");
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
#[test]
|
|
431
|
-
fn current_canonical_message_and_original_owner_recipient_remain_required() {
|
|
432
|
-
for change in [
|
|
433
|
-
"ack",
|
|
434
|
-
"content",
|
|
435
|
-
"owner",
|
|
436
|
-
"recipient",
|
|
437
|
-
"stop",
|
|
438
|
-
"pid",
|
|
439
|
-
"provider",
|
|
440
|
-
"session",
|
|
441
|
-
"window",
|
|
442
|
-
"newer",
|
|
443
|
-
] {
|
|
444
|
-
let f = Fixture::new();
|
|
445
|
-
f.schedule(95, true);
|
|
446
|
-
match change {
|
|
447
|
-
"ack" => {
|
|
448
|
-
f.conn()
|
|
449
|
-
.execute("update messages set status='acknowledged'", [])
|
|
450
|
-
.unwrap();
|
|
451
|
-
}
|
|
452
|
-
"content" => {
|
|
453
|
-
f.conn()
|
|
454
|
-
.execute("update messages set content='edited'", [])
|
|
455
|
-
.unwrap();
|
|
456
|
-
}
|
|
457
|
-
"owner" => {
|
|
458
|
-
f.conn()
|
|
459
|
-
.execute("update messages set owner_team_id='other'", [])
|
|
460
|
-
.unwrap();
|
|
461
|
-
}
|
|
462
|
-
"recipient" => {
|
|
463
|
-
f.conn()
|
|
464
|
-
.execute("update messages set recipient='other'", [])
|
|
465
|
-
.unwrap();
|
|
466
|
-
}
|
|
467
|
-
"stop" => f.state("running", true),
|
|
468
|
-
"newer" => {
|
|
469
|
-
f.conn().execute("insert into messages(message_id,owner_team_id,recipient,created_at,delivery_attempts) values('msg_new','team','worker','z',1)",[]).unwrap();
|
|
470
|
-
}
|
|
471
|
-
field => {
|
|
472
|
-
let p = crate::model::paths::runtime_dir(&f.workspace).join("state.json");
|
|
473
|
-
let mut state: serde_json::Value =
|
|
474
|
-
serde_json::from_str(&std::fs::read_to_string(&p).unwrap()).unwrap();
|
|
475
|
-
match field {
|
|
476
|
-
"pid" => state["agents"]["worker"]["pane_pid"] = 3.into(),
|
|
477
|
-
"provider" => state["agents"]["worker"]["provider"] = "grok".into(),
|
|
478
|
-
"session" => state["session_name"] = "other".into(),
|
|
479
|
-
_ => state["agents"]["worker"]["window"] = "other".into(),
|
|
480
|
-
};
|
|
481
|
-
std::fs::write(p, state.to_string()).unwrap();
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
assert!(f.fire(&|_, _| panic!("canonical change {change}")));
|
|
485
|
-
assert_eq!(f.job().2, "refused", "{change}");
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
#[test]
|
|
490
|
-
fn one_cas_and_ambiguous_effect_or_error_never_replay() {
|
|
491
|
-
for error in [false, true] {
|
|
492
|
-
let f = Fixture::new();
|
|
493
|
-
f.schedule(95, true);
|
|
494
|
-
let calls = Cell::new(0);
|
|
495
|
-
assert!(f.fire(&|_, authorize| {
|
|
496
|
-
calls.set(calls.get() + 1);
|
|
497
|
-
assert!(authorize());
|
|
498
|
-
if error {
|
|
499
|
-
Err(MessagingError::Validation("may have sent".into()))
|
|
500
|
-
} else {
|
|
501
|
-
Ok(EnterRescueOutcome::Entered { accepted: false })
|
|
502
|
-
}
|
|
503
|
-
}));
|
|
504
|
-
assert_eq!(f.job().2, "unknown");
|
|
505
|
-
assert!(!f.fire(&|_, _| panic!("unknown replay")));
|
|
506
|
-
assert_eq!(calls.get(), 1);
|
|
507
|
-
assert_eq!(f.message_status(), "submitted_unverified");
|
|
508
|
-
}
|
|
509
|
-
let f = Fixture::new();
|
|
510
|
-
f.schedule(95, true);
|
|
511
|
-
f.conn()
|
|
512
|
-
.execute("update scheduled_events set status='claimed'", [])
|
|
513
|
-
.unwrap();
|
|
514
|
-
assert!(!f.fire(&|_, _| panic!("crash replay")));
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
#[test]
|
|
518
|
-
fn no_effect_busy_reobserves_within_original_window_only() {
|
|
519
|
-
let f = Fixture::new();
|
|
520
|
-
f.schedule(95, true);
|
|
521
|
-
assert!(f.fire(&|_, _| Ok(EnterRescueOutcome::NoEffect {
|
|
522
|
-
reason: "busy",
|
|
523
|
-
reobserve: true
|
|
524
|
-
})));
|
|
525
|
-
assert_eq!(f.job().2, "pending");
|
|
526
|
-
let due: String = f
|
|
527
|
-
.conn()
|
|
528
|
-
.query_row("select due_at from scheduled_events", [], |r| r.get(0))
|
|
529
|
-
.unwrap();
|
|
530
|
-
assert!(timestamp(&due).unwrap() > Utc::now());
|
|
531
|
-
let f = Fixture::new();
|
|
532
|
-
f.schedule(119, true);
|
|
533
|
-
assert!(f.fire(&|_, _| Ok(EnterRescueOutcome::NoEffect {
|
|
534
|
-
reason: "busy",
|
|
535
|
-
reobserve: true
|
|
536
|
-
})));
|
|
537
|
-
assert_eq!(f.job().2, "refused");
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
#[test]
|
|
541
|
-
fn consumed_or_single_accepted_enter_updates_only_original_unverified_row() {
|
|
542
|
-
for consumed in [false, true] {
|
|
543
|
-
let f = Fixture::new();
|
|
544
|
-
f.schedule(95, true);
|
|
545
|
-
assert!(f.fire(&|_, _| Ok(if consumed {
|
|
546
|
-
EnterRescueOutcome::Consumed
|
|
547
|
-
} else {
|
|
548
|
-
EnterRescueOutcome::Entered { accepted: true }
|
|
549
|
-
})));
|
|
550
|
-
assert_eq!(f.job().2, "done");
|
|
551
|
-
assert_eq!(f.message_status(), "delivered");
|
|
552
|
-
assert!(!f.fire(&|_, _| panic!("done replay")));
|
|
553
|
-
}
|
|
554
|
-
let f = Fixture::new();
|
|
555
|
-
f.schedule(95, true);
|
|
556
|
-
assert!(f.fire(&|_, _| {
|
|
557
|
-
f.conn()
|
|
558
|
-
.execute("update messages set status='acknowledged'", [])
|
|
559
|
-
.unwrap();
|
|
560
|
-
Ok(EnterRescueOutcome::Entered { accepted: true })
|
|
561
|
-
}));
|
|
562
|
-
assert_eq!(f.message_status(), "acknowledged");
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
#[test]
|
|
566
|
-
fn final_authorizer_detects_canonical_changes_during_transport_checks() {
|
|
567
|
-
let f = Fixture::new();
|
|
568
|
-
f.schedule(95, true);
|
|
569
|
-
assert!(f.fire(&|_, authorize| {
|
|
570
|
-
assert!(authorize());
|
|
571
|
-
f.state("stopped", true);
|
|
572
|
-
assert!(!authorize());
|
|
573
|
-
Ok(EnterRescueOutcome::NoEffect {
|
|
574
|
-
reason: "canonical_changed",
|
|
575
|
-
reobserve: false,
|
|
576
|
-
})
|
|
577
|
-
}));
|
|
578
|
-
assert_eq!(f.job().2, "refused");
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
#[test]
|
|
582
|
-
fn revoked_scheduler_claim_is_not_key_authority() {
|
|
583
|
-
let f = Fixture::new();
|
|
584
|
-
f.schedule(95, true);
|
|
585
|
-
assert!(f.fire(&|_, authorize| {
|
|
586
|
-
assert!(authorize());
|
|
587
|
-
f.conn()
|
|
588
|
-
.execute("update scheduled_events set status='refused'", [])
|
|
589
|
-
.unwrap();
|
|
590
|
-
assert!(!authorize());
|
|
591
|
-
Ok(EnterRescueOutcome::NoEffect {
|
|
592
|
-
reason: "claim_revoked",
|
|
593
|
-
reobserve: false,
|
|
594
|
-
})
|
|
595
|
-
}));
|
|
596
|
-
assert_eq!(f.job().2, "refused");
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
#[test]
|
|
600
|
-
fn tampered_event_scope_or_untrusted_proof_cannot_execute() {
|
|
601
|
-
for change in ["scope", "capsule", "capsule_scope", "missing"] {
|
|
602
|
-
let f = Fixture::new();
|
|
603
|
-
f.schedule(95, false);
|
|
604
|
-
let mut context = f.context.clone();
|
|
605
|
-
if change == "capsule" || change == "capsule_scope" {
|
|
606
|
-
let scope_sha256 = if change == "capsule_scope" {
|
|
607
|
-
digest("foreign receipt")
|
|
608
|
-
} else {
|
|
609
|
-
context.scope_sha256().unwrap()
|
|
610
|
-
};
|
|
611
|
-
let proof = context.proof.as_mut().unwrap();
|
|
612
|
-
proof.visible_marker = false;
|
|
613
|
-
proof.owned_capsule = Some(crate::transport::enter_rescue::OwnedCapsule {
|
|
614
|
-
scope_sha256,
|
|
615
|
-
label: "[paste #1 +30 lines]".into(),
|
|
616
|
-
baseline_sha256: digest("baseline"),
|
|
617
|
-
baseline_capsules: vec![],
|
|
618
|
-
observed_after_owned_paste: change == "capsule_scope",
|
|
619
|
-
});
|
|
620
|
-
}
|
|
621
|
-
if change == "missing" {
|
|
622
|
-
context.proof = None;
|
|
623
|
-
}
|
|
624
|
-
assert!(bind_pending_context(&f.store, &context).unwrap());
|
|
625
|
-
if change == "scope" {
|
|
626
|
-
f.conn()
|
|
627
|
-
.execute("update scheduled_events set owner_team_id='other'", [])
|
|
628
|
-
.unwrap();
|
|
629
|
-
}
|
|
630
|
-
assert!(f.fire(&|_, _| panic!("untrusted job")));
|
|
631
|
-
assert_eq!(f.job().2, "refused");
|
|
632
|
-
}
|
|
633
|
-
}
|