@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,770 +0,0 @@
|
|
|
1
|
-
//! agent-clone-fork · successor RED batch 4 (verifier) — R8 Copilot fork
|
|
2
|
-
//! (caps re-charter) + R7 permission-clamp GUARDRAIL.
|
|
3
|
-
//!
|
|
4
|
-
//! From locate.md §7 R7/R8 + §1.4 (Copilot 1.0.61 real-machine proof: directory
|
|
5
|
-
//! copy + SQLite transaction under COPILOT_HOME is feasible) + §3 surface
|
|
6
|
-
//! (`provider/adapter.rs` Copilot caps=false; `provider/session_scan/copilot.rs`
|
|
7
|
-
//! hard-reads `$HOME/.copilot`; `fork_agent.rs:173-288` provider/permission
|
|
8
|
-
//! inheritance) + MUST-16, NOT the §4 design. Baseline `9e6be51` (v0.5.52).
|
|
9
|
-
//!
|
|
10
|
-
//! - **R8 Copilot fork caps RE-CHARTER (RED + verifier signature)**: baseline
|
|
11
|
-
//! locks "Copilot fork MUST be refused (capability unsupported)"
|
|
12
|
-
//! (`copilot_provider_red.rs::copilot_fork_returns_structured_capability_unsupported`).
|
|
13
|
-
//! §1.4 proves Copilot CAN fork (directory copy + atomic SQLite transaction
|
|
14
|
-
//! under an isolated COPILOT_HOME). This batch RED asserts that a Copilot fork
|
|
15
|
-
//! is no longer rejected by a blanket capability gate. Baseline red: the fork
|
|
16
|
-
//! is refused with a copilot/fork capability-unsupported error. Retiring the old
|
|
17
|
-
//! "must refuse" contract is a re-charter that REQUIRES a verifier signature —
|
|
18
|
-
//! recorded in
|
|
19
|
-
//! `.team/artifacts/pipeline-runs/agent-clone-fork/verifier-r8-caps-recharter-signoff.md`.
|
|
20
|
-
//! (The SQLite foreign-key table integrity + exact-nonce recall are the GREEN
|
|
21
|
-
//! half / subscription-E2E per §1.4 — not asserted offline here.)
|
|
22
|
-
//!
|
|
23
|
-
//! - **R7 permission-clamp GUARDRAIL (naturally-green, not a RED, per L1 r2)**: a
|
|
24
|
-
//! fork's effective approval policy must be derived from the LEADER
|
|
25
|
-
//! (`source=leader_process`, `worker_capability_above_leader=false`), never a
|
|
26
|
-
//! raw clone of a source-declared capability above the leader (MUST-16).
|
|
27
|
-
//! Measured: baseline already derives approval from the leader and marks
|
|
28
|
-
//! `worker_capability_above_leader=false`, so there is no offline structural
|
|
29
|
-
//! red. Following the L1 r2 naturally-green-guardrail precedent, this pins the
|
|
30
|
-
//! clamp as a guardrail whose teeth engage after implement recompiles the role
|
|
31
|
-
//! via RoleSourceResolver (§4.2): any impl that raw-clones a compiled permission
|
|
32
|
-
//! above the leader trips it on the spot. R7's escalation scenario (a source
|
|
33
|
-
//! role declaring capability above the leader) cannot be constructed offline —
|
|
34
|
-
//! the role model forces `permission_mode=restricted` and inherits approval from
|
|
35
|
-
//! the leader — so the true escalation guard is a subscription/real-machine
|
|
36
|
-
//! concern; the guardrail defends the invariant that already holds.
|
|
37
|
-
//!
|
|
38
|
-
//! R9 clone-semantics is NOT frozen in this batch: offline, `clone-agent` does not
|
|
39
|
-
//! exist (already RED in batch1 R10), and its distinguishing semantics
|
|
40
|
-
//! (fresh-session-distinct-from-fork, carries no source nonce) are subscription
|
|
41
|
-
//! real-machine concerns (locate §4.5, §5 obs 6). It is recorded against R10 +
|
|
42
|
-
//! the E2E gate, not asserted offline here.
|
|
43
|
-
|
|
44
|
-
#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
|
|
45
|
-
|
|
46
|
-
use std::collections::BTreeMap;
|
|
47
|
-
use std::path::{Path, PathBuf};
|
|
48
|
-
use std::process::{Command, Output};
|
|
49
|
-
use std::sync::Mutex;
|
|
50
|
-
|
|
51
|
-
use serde_json::{json, Value};
|
|
52
|
-
use team_agent::lifecycle::launch::fork_agent_with_transport;
|
|
53
|
-
use team_agent::lifecycle::quick_start_with_transport_in_workspace;
|
|
54
|
-
use team_agent::model::ids::AgentId;
|
|
55
|
-
use team_agent::state::persist::{load_runtime_state, save_runtime_state};
|
|
56
|
-
use team_agent::transport::{
|
|
57
|
-
AttachOutcome, BackendKind, CaptureRange, CapturedText, InjectPayload, InjectReport,
|
|
58
|
-
InjectStage, InjectVerification, Key, PaneField, PaneId, PaneInfo, PaneLiveness, SessionName,
|
|
59
|
-
SetEnvOutcome, SpawnResult, SubmitVerification, Target, Transport, TransportError,
|
|
60
|
-
TurnVerification, WindowName,
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
#[path = "../../../tests/support/hermetic.rs"]
|
|
64
|
-
mod hermetic_guard;
|
|
65
|
-
use hermetic_guard::HermeticTestEnv;
|
|
66
|
-
|
|
67
|
-
const TEAM_NAME: &str = "cf-batch4";
|
|
68
|
-
const SOURCE: &str = "cp_worker";
|
|
69
|
-
const NEW: &str = "cp_fork";
|
|
70
|
-
const R7_CHILD: &str = "TEAM_AGENT_TEST_CF_R7_CHILD";
|
|
71
|
-
const R7B_CHILD: &str = "TEAM_AGENT_TEST_CF_R7B_CHILD";
|
|
72
|
-
const R8_CHILD: &str = "TEAM_AGENT_TEST_CF_R8_CHILD";
|
|
73
|
-
const ISOLATION_GUARD_CHILD: &str = "TEAM_AGENT_TEST_CF_ISOLATION_GUARD_CHILD";
|
|
74
|
-
const PARENT_PID_ENV: &str = "TEAM_AGENT_TEST_CF_PARENT_PID";
|
|
75
|
-
const R7_TEST: &str = concat!(
|
|
76
|
-
"lifecycle::tests::clone_fork_copilot_perms_red::",
|
|
77
|
-
"r7_fork_effective_permissions_are_clamped_to_leader_guardrail"
|
|
78
|
-
);
|
|
79
|
-
const R7B_TEST: &str = concat!(
|
|
80
|
-
"lifecycle::tests::clone_fork_copilot_perms_red::",
|
|
81
|
-
"r7b_fork_policy_under_restricted_leader_ancestry_is_disabled"
|
|
82
|
-
);
|
|
83
|
-
const R8_TEST: &str = concat!(
|
|
84
|
-
"lifecycle::tests::clone_fork_copilot_perms_red::",
|
|
85
|
-
"r8_copilot_fork_is_no_longer_capability_refused"
|
|
86
|
-
);
|
|
87
|
-
const ISOLATION_GUARD_TEST: &str = concat!(
|
|
88
|
-
"lifecycle::tests::clone_fork_copilot_perms_red::",
|
|
89
|
-
"copilot_clone_fork_env_fixtures_run_outside_parent_process"
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
/// These fixtures need process-global HOME and TEAM_AGENT_* overrides, while the
|
|
93
|
-
/// lib-test harness runs sibling tests in parallel. Execute each body as the sole
|
|
94
|
-
/// selected test in a child process so HermeticTestEnv never mutates the parent
|
|
95
|
-
/// test process. Fixture-caller tests still hold `serial(env)` while their child
|
|
96
|
-
/// runs: the child inherits the parent's PATH, and a sibling env test may have a
|
|
97
|
-
/// fake `tmux` on it that never creates the fixture caller socket.
|
|
98
|
-
fn run_process_isolated(marker: &str, test_name: &str, body: impl FnOnce()) {
|
|
99
|
-
if std::env::var_os(marker).is_some() {
|
|
100
|
-
body();
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
let output = Command::new(std::env::current_exe().expect("current lib-test executable"))
|
|
105
|
-
.args(["--exact", test_name, "--nocapture", "--test-threads=1"])
|
|
106
|
-
.env(marker, "1")
|
|
107
|
-
.env(PARENT_PID_ENV, std::process::id().to_string())
|
|
108
|
-
.output()
|
|
109
|
-
.expect("run fixture in isolated child test process");
|
|
110
|
-
assert!(
|
|
111
|
-
output.status.success(),
|
|
112
|
-
"isolated child test failed: test={test_name} status={:?}\nstdout:\n{}\nstderr:\n{}",
|
|
113
|
-
output.status.code(),
|
|
114
|
-
String::from_utf8_lossy(&output.stdout),
|
|
115
|
-
String::from_utf8_lossy(&output.stderr),
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
#[test]
|
|
120
|
-
fn copilot_clone_fork_env_fixtures_run_outside_parent_process() {
|
|
121
|
-
run_process_isolated(ISOLATION_GUARD_CHILD, ISOLATION_GUARD_TEST, || {
|
|
122
|
-
let parent_pid = std::env::var(PARENT_PID_ENV)
|
|
123
|
-
.expect("isolated child receives the parent test process id");
|
|
124
|
-
assert_ne!(
|
|
125
|
-
std::process::id().to_string(),
|
|
126
|
-
parent_pid,
|
|
127
|
-
"clone/fork env fixtures must never run in the parent lib-test process"
|
|
128
|
-
);
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/// Gate6 CI-hermeticity revision: the R7 fixture must pin the process-ancestry
|
|
133
|
-
/// seam explicitly (`TEAM_AGENT_TEST_PROCESS_ANCESTRY_ARGV_JSON`) instead of
|
|
134
|
-
/// depending on the REAL ancestry of the test-runner host. Unpinned, a local
|
|
135
|
-
/// runner descending from a dangerous-bypass leader yields
|
|
136
|
-
/// `source=leader_process` (historical local green) while a clean CI runner
|
|
137
|
-
/// correctly yields `source=disabled` — a non-hermetic assertion, not a product
|
|
138
|
-
/// regression. Precedent: `codex_mcp_approval_inheritance_red.rs` `MockAncestry`
|
|
139
|
-
/// (pins both bypass and restricted leader argv).
|
|
140
|
-
const ANCESTRY_ENV: &str = "TEAM_AGENT_TEST_PROCESS_ANCESTRY_ARGV_JSON";
|
|
141
|
-
const CODEX_BYPASS: &str = "--dangerously-bypass-approvals-and-sandbox";
|
|
142
|
-
const RESTRICTED_LEADER_ARGV: &[&str] = &[
|
|
143
|
-
"codex",
|
|
144
|
-
"--sandbox",
|
|
145
|
-
"read-only",
|
|
146
|
-
"--ask-for-approval",
|
|
147
|
-
"on-request",
|
|
148
|
-
];
|
|
149
|
-
|
|
150
|
-
struct Case {
|
|
151
|
-
env: HermeticTestEnv,
|
|
152
|
-
workspace: PathBuf,
|
|
153
|
-
shim_path: String,
|
|
154
|
-
ancestry_json: String,
|
|
155
|
-
socket: Option<PathBuf>,
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
impl Case {
|
|
159
|
-
/// R7 (permission-clamp guardrail) uses a claude source with a success-path
|
|
160
|
-
/// backing shim so the fork actually produces a NEW row whose permission clamp
|
|
161
|
-
/// can be inspected — without a real fork the guardrail would read no row and
|
|
162
|
-
/// pass vacuously. (R8 does not use Case: it exercises the library entry with
|
|
163
|
-
/// an in-process RecordingTransport — see `r8_...`.)
|
|
164
|
-
fn start(tag: &str) -> Self {
|
|
165
|
-
Self::start_with_ancestry(tag, &["codex", CODEX_BYPASS])
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/// Every CLI invocation of this Case pins `ancestry_argv` through the
|
|
169
|
-
/// product's existing test seam so the derived approval policy is a
|
|
170
|
-
/// function of the FIXTURE, never of the host process tree.
|
|
171
|
-
fn start_with_ancestry(tag: &str, ancestry_argv: &[&str]) -> Self {
|
|
172
|
-
let env = HermeticTestEnv::enter_with_leader(tag);
|
|
173
|
-
let workspace = env.workspace("ws");
|
|
174
|
-
write_team_docs(&workspace, "claude");
|
|
175
|
-
let shim_dir = write_claude_backing_shim(&workspace);
|
|
176
|
-
let shim_path = format!(
|
|
177
|
-
"{}:{}",
|
|
178
|
-
shim_dir.display(),
|
|
179
|
-
std::env::var("PATH").expect("PATH present")
|
|
180
|
-
);
|
|
181
|
-
let mut case = Self {
|
|
182
|
-
env,
|
|
183
|
-
workspace,
|
|
184
|
-
shim_path,
|
|
185
|
-
ancestry_json: serde_json::to_string(ancestry_argv).expect("ancestry argv json"),
|
|
186
|
-
socket: None,
|
|
187
|
-
};
|
|
188
|
-
case.quick_start();
|
|
189
|
-
case.seed_source_session_tuple();
|
|
190
|
-
case
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
fn ws(&self) -> &str {
|
|
194
|
-
self.workspace.to_str().expect("ws utf8")
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
fn state_path(&self) -> PathBuf {
|
|
198
|
-
self.workspace
|
|
199
|
-
.join(".team")
|
|
200
|
-
.join("runtime")
|
|
201
|
-
.join("state.json")
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
fn run(&self, args: &[&str]) -> Output {
|
|
205
|
-
self.env.run_cli_env(
|
|
206
|
-
&self.workspace,
|
|
207
|
-
args,
|
|
208
|
-
&[
|
|
209
|
-
("PATH", self.shim_path.as_str()),
|
|
210
|
-
(ANCESTRY_ENV, self.ancestry_json.as_str()),
|
|
211
|
-
],
|
|
212
|
-
)
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
fn quick_start(&mut self) {
|
|
216
|
-
let out = self.run(&[
|
|
217
|
-
"quick-start",
|
|
218
|
-
self.ws(),
|
|
219
|
-
"--workspace",
|
|
220
|
-
self.ws(),
|
|
221
|
-
"--name",
|
|
222
|
-
TEAM_NAME,
|
|
223
|
-
"--yes",
|
|
224
|
-
"--json",
|
|
225
|
-
]);
|
|
226
|
-
if let Ok(v) = serde_json::from_slice::<Value>(&out.stdout) {
|
|
227
|
-
if let Some(cmd) = v
|
|
228
|
-
.get("attach_commands")
|
|
229
|
-
.and_then(|a| a.as_array())
|
|
230
|
-
.and_then(|a| a.first())
|
|
231
|
-
.and_then(|c| c.as_str())
|
|
232
|
-
.or_else(|| v.get("leader_attach_command").and_then(|c| c.as_str()))
|
|
233
|
-
{
|
|
234
|
-
let toks: Vec<&str> = cmd.split_whitespace().collect();
|
|
235
|
-
if let Some(i) = toks.iter().position(|t| *t == "-S") {
|
|
236
|
-
if let Some(sock) = toks.get(i + 1) {
|
|
237
|
-
self.socket = Some(PathBuf::from(*sock));
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/// Seed the SOURCE session tuple so the fork reaches the capability gate
|
|
245
|
-
/// (not a missing-session gate) — mirrors the old refusal contract's
|
|
246
|
-
/// `seed_session_id`, which existed precisely so "the capability gate is what
|
|
247
|
-
/// fires".
|
|
248
|
-
fn seed_source_session_tuple(&self) {
|
|
249
|
-
// A real rollout file the source tuple points at.
|
|
250
|
-
let rollout_file = self.workspace.join("fixture-source-rollout.jsonl");
|
|
251
|
-
let _ = std::fs::write(&rollout_file, "{\"type\":\"fixture-source\"}\n");
|
|
252
|
-
let Ok(raw) = std::fs::read_to_string(self.state_path()) else {
|
|
253
|
-
return;
|
|
254
|
-
};
|
|
255
|
-
let Ok(mut state) = serde_json::from_str::<Value>(&raw) else {
|
|
256
|
-
return;
|
|
257
|
-
};
|
|
258
|
-
let tuple = json!({
|
|
259
|
-
"session_id": "sess-cf-batch4-source",
|
|
260
|
-
"rollout_path": rollout_file.to_string_lossy(),
|
|
261
|
-
"captured_at": "2026-07-21T00:00:00Z",
|
|
262
|
-
"captured_via": "contract-fixture"
|
|
263
|
-
});
|
|
264
|
-
let mut patch = |row: &mut Value| {
|
|
265
|
-
if let Some(obj) = row.as_object_mut() {
|
|
266
|
-
for (k, v) in tuple.as_object().unwrap() {
|
|
267
|
-
obj.insert(k.clone(), v.clone());
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
};
|
|
271
|
-
if let Some(row) = state.get_mut("agents").and_then(|a| a.get_mut(SOURCE)) {
|
|
272
|
-
patch(row);
|
|
273
|
-
}
|
|
274
|
-
if let Some(teams) = state.get_mut("teams").and_then(Value::as_object_mut) {
|
|
275
|
-
for team in teams.values_mut() {
|
|
276
|
-
if let Some(row) = team.get_mut("agents").and_then(|a| a.get_mut(SOURCE)) {
|
|
277
|
-
patch(row);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
let _ = std::fs::write(
|
|
282
|
-
self.state_path(),
|
|
283
|
-
serde_json::to_string_pretty(&state).unwrap(),
|
|
284
|
-
);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
fn fork(&self, as_name: &str) -> Value {
|
|
288
|
-
let out = self.run(&[
|
|
289
|
-
"fork-agent",
|
|
290
|
-
SOURCE,
|
|
291
|
-
"--as",
|
|
292
|
-
as_name,
|
|
293
|
-
"--workspace",
|
|
294
|
-
self.ws(),
|
|
295
|
-
"--team",
|
|
296
|
-
TEAM_NAME,
|
|
297
|
-
"--json",
|
|
298
|
-
]);
|
|
299
|
-
let stderr = String::from_utf8_lossy(&out.stderr).to_string();
|
|
300
|
-
serde_json::from_slice::<Value>(&out.stdout).unwrap_or_else(|_| {
|
|
301
|
-
json!({
|
|
302
|
-
"ok": out.status.success(),
|
|
303
|
-
"_exit": out.status.code(),
|
|
304
|
-
"_stderr": stderr,
|
|
305
|
-
})
|
|
306
|
-
})
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
fn team_agent_rows(&self) -> serde_json::Map<String, Value> {
|
|
310
|
-
let Ok(raw) = std::fs::read_to_string(self.state_path()) else {
|
|
311
|
-
return serde_json::Map::new();
|
|
312
|
-
};
|
|
313
|
-
let Ok(v) = serde_json::from_str::<Value>(&raw) else {
|
|
314
|
-
return serde_json::Map::new();
|
|
315
|
-
};
|
|
316
|
-
if let Some(teams) = v.get("teams").and_then(Value::as_object) {
|
|
317
|
-
for team in teams.values() {
|
|
318
|
-
if let Some(agents) = team.get("agents").and_then(Value::as_object) {
|
|
319
|
-
if agents.contains_key(SOURCE) {
|
|
320
|
-
return agents.clone();
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
serde_json::Map::new()
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
impl Drop for Case {
|
|
330
|
-
fn drop(&mut self) {
|
|
331
|
-
if let Some(sock) = &self.socket {
|
|
332
|
-
let _ = std::process::Command::new("tmux")
|
|
333
|
-
.args(["-S", sock.to_str().unwrap_or(""), "kill-server"])
|
|
334
|
-
.output();
|
|
335
|
-
}
|
|
336
|
-
let ws = self.workspace.to_string_lossy().to_string();
|
|
337
|
-
if let Ok(out) = std::process::Command::new("ps")
|
|
338
|
-
.args(["-axo", "pid=,command="])
|
|
339
|
-
.output()
|
|
340
|
-
{
|
|
341
|
-
for line in String::from_utf8_lossy(&out.stdout).lines() {
|
|
342
|
-
if line.contains(&ws) {
|
|
343
|
-
if let Some(pid) = line.split_whitespace().next() {
|
|
344
|
-
let _ = std::process::Command::new("kill")
|
|
345
|
-
.args(["-TERM", pid])
|
|
346
|
-
.output();
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
let _ = &self.env;
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
fn write_team_docs(workspace: &Path, provider: &str) {
|
|
356
|
-
std::fs::create_dir_all(workspace.join("agents")).expect("create agents dir");
|
|
357
|
-
std::fs::write(
|
|
358
|
-
workspace.join("TEAM.md"),
|
|
359
|
-
format!(
|
|
360
|
-
"---\nname: {TEAM_NAME}\nobjective: clone-fork batch4.\nprovider: {provider}\n---\n"
|
|
361
|
-
),
|
|
362
|
-
)
|
|
363
|
-
.expect("write TEAM.md");
|
|
364
|
-
std::fs::write(
|
|
365
|
-
workspace.join("agents").join(format!("{SOURCE}.md")),
|
|
366
|
-
format!(
|
|
367
|
-
"---\nname: {SOURCE}\nrole: {SOURCE}\nprovider: {provider}\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\n{SOURCE} body.\n"
|
|
368
|
-
),
|
|
369
|
-
)
|
|
370
|
-
.expect("write source role doc");
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
/// Copilot team docs for the library-entry R8 (a separate agents dir so the
|
|
374
|
-
/// OfflineTransport quick-start compiles a copilot source).
|
|
375
|
-
fn write_copilot_team_docs(workspace: &Path) -> PathBuf {
|
|
376
|
-
let team_dir = workspace.join("cf-r8-team");
|
|
377
|
-
std::fs::create_dir_all(team_dir.join("agents")).expect("create team agents dir");
|
|
378
|
-
std::fs::write(
|
|
379
|
-
team_dir.join("TEAM.md"),
|
|
380
|
-
format!("---\nname: {TEAM_NAME}\nobjective: clone-fork batch4 copilot recharter.\nprovider: copilot\n---\n\nTeam fixture.\n"),
|
|
381
|
-
)
|
|
382
|
-
.expect("write TEAM.md");
|
|
383
|
-
std::fs::write(
|
|
384
|
-
team_dir.join("agents").join(format!("{SOURCE}.md")),
|
|
385
|
-
format!(
|
|
386
|
-
"---\nname: {SOURCE}\nrole: Copilot Worker\nprovider: copilot\nmodel: gpt-5\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nCopilot source body.\n"
|
|
387
|
-
),
|
|
388
|
-
)
|
|
389
|
-
.expect("write source role doc");
|
|
390
|
-
team_dir
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
/// Seed the SOURCE's complete session tuple directly in runtime state (library
|
|
394
|
-
/// path) so the copilot fork reaches the capability gate, not a missing-session
|
|
395
|
-
/// gate. Mirrors the old refusal contract's `seed_session_id`.
|
|
396
|
-
fn seed_source_tuple_in_state(workspace: &Path, agent: &str) {
|
|
397
|
-
let mut state = load_runtime_state(workspace).expect("load runtime state");
|
|
398
|
-
// Per-test path under this workspace. Do not touch $HOME/.copilot —
|
|
399
|
-
// that races with sibling --lib fork tests that also mutate process HOME
|
|
400
|
-
// and CREATE TABLE sessions on a shared session-store.db.
|
|
401
|
-
// r8 only asserts the unverified refuse, which fires before any store I/O.
|
|
402
|
-
let source_session_id = format!(
|
|
403
|
-
"r8-{}-{}",
|
|
404
|
-
std::process::id(),
|
|
405
|
-
std::time::SystemTime::now()
|
|
406
|
-
.duration_since(std::time::UNIX_EPOCH)
|
|
407
|
-
.expect("clock")
|
|
408
|
-
.as_nanos()
|
|
409
|
-
);
|
|
410
|
-
let rollout = workspace
|
|
411
|
-
.join("copilot-fixture")
|
|
412
|
-
.join(&source_session_id)
|
|
413
|
-
.join("unused.db");
|
|
414
|
-
std::fs::create_dir_all(rollout.parent().expect("parent")).expect("create per-test copilot dir");
|
|
415
|
-
std::fs::write(&rollout, b"").expect("touch unused db placeholder");
|
|
416
|
-
let tuple = json!({
|
|
417
|
-
"status": "running",
|
|
418
|
-
"provider": "copilot",
|
|
419
|
-
"session_id": source_session_id,
|
|
420
|
-
"rollout_path": rollout.to_string_lossy(),
|
|
421
|
-
"captured_at": "2026-07-21T00:00:00Z",
|
|
422
|
-
"captured_via": "contract-fixture",
|
|
423
|
-
});
|
|
424
|
-
let apply = |obj: &mut serde_json::Map<String, Value>| {
|
|
425
|
-
for (k, v) in tuple.as_object().unwrap() {
|
|
426
|
-
obj.insert(k.clone(), v.clone());
|
|
427
|
-
}
|
|
428
|
-
};
|
|
429
|
-
if let Some(obj) = state
|
|
430
|
-
.pointer_mut(&format!("/agents/{agent}"))
|
|
431
|
-
.and_then(Value::as_object_mut)
|
|
432
|
-
{
|
|
433
|
-
apply(obj);
|
|
434
|
-
}
|
|
435
|
-
if let Some(teams) = state.get_mut("teams").and_then(Value::as_object_mut) {
|
|
436
|
-
for team in teams.values_mut() {
|
|
437
|
-
if let Some(obj) = team
|
|
438
|
-
.get_mut("agents")
|
|
439
|
-
.and_then(|a| a.get_mut(agent))
|
|
440
|
-
.and_then(Value::as_object_mut)
|
|
441
|
-
{
|
|
442
|
-
apply(obj);
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
save_runtime_state(workspace, &state).expect("save seeded state");
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
/// Claude success-path shim producing a NEW backing keyed to the predetermined
|
|
450
|
-
/// `--session-id` (same mechanism as batch3): the R7 fork must actually complete
|
|
451
|
-
/// so a NEW state row exists to inspect for the permission clamp — otherwise the
|
|
452
|
-
/// guardrail reads no row and passes vacuously (false-green-hole type 8).
|
|
453
|
-
fn write_claude_backing_shim(workspace: &Path) -> PathBuf {
|
|
454
|
-
let bin_dir = workspace.join("shim-bin");
|
|
455
|
-
std::fs::create_dir_all(&bin_dir).expect("create shim dir");
|
|
456
|
-
let shim = bin_dir.join("claude");
|
|
457
|
-
std::fs::write(
|
|
458
|
-
&shim,
|
|
459
|
-
r#"#!/bin/sh
|
|
460
|
-
sid=""
|
|
461
|
-
prev=""
|
|
462
|
-
for a in "$@"; do
|
|
463
|
-
if [ "$prev" = "--session-id" ]; then sid="$a"; fi
|
|
464
|
-
prev="$a"
|
|
465
|
-
done
|
|
466
|
-
if [ -n "$sid" ]; then
|
|
467
|
-
enc=$(printf '%s' "$PWD" | sed 's/[^a-zA-Z0-9]/-/g')
|
|
468
|
-
dir="$HOME/.claude/projects/$enc"
|
|
469
|
-
mkdir -p "$dir"
|
|
470
|
-
printf '{"sessionId":"%s","type":"fork-backing"}\n' "$sid" > "$dir/$sid.jsonl"
|
|
471
|
-
fi
|
|
472
|
-
echo 'claude shim ready'
|
|
473
|
-
exec sleep 3600
|
|
474
|
-
"#,
|
|
475
|
-
)
|
|
476
|
-
.expect("write claude shim");
|
|
477
|
-
#[cfg(unix)]
|
|
478
|
-
{
|
|
479
|
-
use std::os::unix::fs::PermissionsExt;
|
|
480
|
-
std::fs::set_permissions(&shim, std::fs::Permissions::from_mode(0o755))
|
|
481
|
-
.expect("chmod claude shim");
|
|
482
|
-
}
|
|
483
|
-
bin_dir
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
/// R8 Copilot fork caps RE-CHARTER — a Copilot fork must no longer be refused by a
|
|
487
|
-
/// blanket capability gate (§1.4 proves the directory-copy + SQLite-transaction
|
|
488
|
-
/// primitive is feasible under an isolated COPILOT_HOME). Baseline red: the fork
|
|
489
|
-
/// is refused with a copilot/fork capability-unsupported error.
|
|
490
|
-
///
|
|
491
|
-
/// Retiring the old "Copilot fork must be refused" contract is a re-charter
|
|
492
|
-
/// requiring a verifier signature — see
|
|
493
|
-
/// `verifier-r8-caps-recharter-signoff.md`. The SQLite FK-table integrity and
|
|
494
|
-
/// exact-nonce recall remain the GREEN half / subscription-E2E (§1.4).
|
|
495
|
-
#[test]
|
|
496
|
-
#[serial_test::serial(env)]
|
|
497
|
-
fn r8_copilot_fork_is_no_longer_capability_refused() {
|
|
498
|
-
run_process_isolated(R8_CHILD, R8_TEST, || {
|
|
499
|
-
// R8 uses the LIBRARY entry `fork_agent_with_transport` (the same entry the old
|
|
500
|
-
// refusal contract exercises), because the CLI `fork-agent` path reports
|
|
501
|
-
// ok:true for a copilot source (registration-only success) and never reaches
|
|
502
|
-
// the capability gate — a CLI-shaped R8 could never be RED. An in-process
|
|
503
|
-
// RecordingTransport stands the team up without a live copilot TUI (no
|
|
504
|
-
// ready-screen hang).
|
|
505
|
-
let env = HermeticTestEnv::enter_with_leader("cf-r8");
|
|
506
|
-
let workspace = env.workspace("ws");
|
|
507
|
-
super::launch_spawn::seed_healthy_coordinator(&workspace);
|
|
508
|
-
let team_dir = write_copilot_team_docs(&workspace);
|
|
509
|
-
// Session ABSENT at quick-start so it can create the team session; spawn_first
|
|
510
|
-
// flips session_present true, so the later fork sees a live session. (Starting
|
|
511
|
-
// with session_present=true causes a SessionConflict at quick-start.)
|
|
512
|
-
let transport = RecordingTransport::default();
|
|
513
|
-
quick_start_with_transport_in_workspace(
|
|
514
|
-
&workspace,
|
|
515
|
-
&team_dir,
|
|
516
|
-
Some(TEAM_NAME),
|
|
517
|
-
true,
|
|
518
|
-
Some("cfr8"),
|
|
519
|
-
&transport,
|
|
520
|
-
)
|
|
521
|
-
.expect("quick-start seeds the copilot team");
|
|
522
|
-
// Seed the source's complete session tuple so the fork reaches the capability
|
|
523
|
-
// gate (not a missing-session gate) — mirrors the old refusal contract's seed.
|
|
524
|
-
seed_source_tuple_in_state(&workspace, SOURCE);
|
|
525
|
-
|
|
526
|
-
// The team KEY is the quick-start team_id ("cfr8"), not the display name.
|
|
527
|
-
let result = fork_agent_with_transport(
|
|
528
|
-
&workspace,
|
|
529
|
-
&AgentId::new(SOURCE),
|
|
530
|
-
&AgentId::new(NEW),
|
|
531
|
-
None,
|
|
532
|
-
false,
|
|
533
|
-
Some("cfr8"),
|
|
534
|
-
&transport,
|
|
535
|
-
);
|
|
536
|
-
|
|
537
|
-
// Baseline: copilot fork is refused with a structured copilot/fork
|
|
538
|
-
// capability-unsupported error (copilot_provider_red.rs C-4-2/C-4-3). R8 pins
|
|
539
|
-
// that this blanket capability refusal is GONE post-recharter.
|
|
540
|
-
let text = format!("{result:?}").to_lowercase();
|
|
541
|
-
assert!(
|
|
542
|
-
result.is_err() && (text.contains("unverified") || text.contains("未验证")),
|
|
543
|
-
"Copilot in-window fork is unverified; result={result:?}"
|
|
544
|
-
);
|
|
545
|
-
});
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
/// R7 permission-clamp GUARDRAIL — a fork's effective approval policy is derived
|
|
549
|
-
/// from the LEADER and never escalates above it (MUST-16). 0.5.66 bypass 单源:
|
|
550
|
-
/// fork 的 approval policy 由源角色的 `dangerously_skip_permissions` 派生
|
|
551
|
-
/// (本 fixture = false → `source=disabled`),不再依赖 leader argv 继承。任何
|
|
552
|
-
/// fork 都不得出现 `source=leader_process`(旧模型已删)或 capability 高于源。
|
|
553
|
-
#[test]
|
|
554
|
-
#[serial_test::serial(env)]
|
|
555
|
-
fn r7_fork_effective_permissions_are_clamped_to_leader_guardrail() {
|
|
556
|
-
run_process_isolated(R7_CHILD, R7_TEST, || {
|
|
557
|
-
// Claude source + success-path backing shim so the fork COMPLETES and a NEW
|
|
558
|
-
// row exists to inspect — no vacuous pass on a refused fork. The source role
|
|
559
|
-
// declares `dangerously_skip_permissions: false`, so the fork's policy must
|
|
560
|
-
// resolve to `disabled` (fail-closed) — the new single-source model.
|
|
561
|
-
let case = Case::start("cf-r7");
|
|
562
|
-
let fork = case.fork(NEW);
|
|
563
|
-
assert_eq!(
|
|
564
|
-
fork.get("ok").and_then(Value::as_bool),
|
|
565
|
-
Some(true),
|
|
566
|
-
"R7 fixture precondition: the claude fork must complete so a NEW row exists to check the \
|
|
567
|
-
permission clamp (no vacuous guardrail). fork={fork}"
|
|
568
|
-
);
|
|
569
|
-
let policy = new_row_policy(&case);
|
|
570
|
-
let source = policy.get("source").and_then(Value::as_str);
|
|
571
|
-
assert_ne!(
|
|
572
|
-
source,
|
|
573
|
-
Some("leader_process"),
|
|
574
|
-
"0.5.66: fork policy must never be leader_process (old ancestry model removed); \
|
|
575
|
-
policy={policy}"
|
|
576
|
-
);
|
|
577
|
-
assert_eq!(
|
|
578
|
-
source,
|
|
579
|
-
Some("disabled"),
|
|
580
|
-
"guardrail: a fork's approval policy derives from the role's dangerously_skip_permissions \
|
|
581
|
-
(false → disabled), never raw-cloned escalation; MUST-16. policy={policy}"
|
|
582
|
-
);
|
|
583
|
-
assert_ne!(
|
|
584
|
-
policy.get("worker_capability_above_leader").and_then(Value::as_bool),
|
|
585
|
-
Some(true),
|
|
586
|
-
"guardrail: a fork must never carry a capability above the leader; MUST-16. policy={policy}"
|
|
587
|
-
);
|
|
588
|
-
});
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
/// R7b reverse positive control — same source role (dangerously_skip_permissions:
|
|
592
|
-
/// false) must also resolve to `source=disabled` under any ancestry seam. 0.5.66
|
|
593
|
-
/// 起 policy 与 leader argv 无关:source 恒 `disabled`,fork 恒不升级(MUST-16)。
|
|
594
|
-
#[test]
|
|
595
|
-
#[serial_test::serial(env)]
|
|
596
|
-
fn r7b_fork_policy_under_restricted_leader_ancestry_is_disabled() {
|
|
597
|
-
run_process_isolated(R7B_CHILD, R7B_TEST, || {
|
|
598
|
-
let case = Case::start_with_ancestry("cf-r7b", RESTRICTED_LEADER_ARGV);
|
|
599
|
-
let fork = case.fork(NEW);
|
|
600
|
-
assert_eq!(
|
|
601
|
-
fork.get("ok").and_then(Value::as_bool),
|
|
602
|
-
Some(true),
|
|
603
|
-
"R7b fixture precondition: the claude fork must complete so a NEW row exists to check the \
|
|
604
|
-
policy (no vacuous control). fork={fork}"
|
|
605
|
-
);
|
|
606
|
-
let policy = new_row_policy(&case);
|
|
607
|
-
assert_eq!(
|
|
608
|
-
policy.get("source").and_then(Value::as_str),
|
|
609
|
-
Some("disabled"),
|
|
610
|
-
"fail-closed: source role declares dangerously_skip_permissions=false → fork policy must \
|
|
611
|
-
be disabled; policy={policy}"
|
|
612
|
-
);
|
|
613
|
-
assert_ne!(
|
|
614
|
-
policy
|
|
615
|
-
.get("worker_capability_above_leader")
|
|
616
|
-
.and_then(Value::as_bool),
|
|
617
|
-
Some(true),
|
|
618
|
-
"a fork must never yield a capability above the source; MUST-16. policy={policy}"
|
|
619
|
-
);
|
|
620
|
-
});
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
fn new_row_policy(case: &Case) -> Value {
|
|
624
|
-
let rows = case.team_agent_rows();
|
|
625
|
-
let new_row = rows
|
|
626
|
-
.get(NEW)
|
|
627
|
-
.unwrap_or_else(|| panic!("NEW fork row must exist to inspect the policy; rows={rows:?}"));
|
|
628
|
-
new_row
|
|
629
|
-
.get("effective_approval_policy")
|
|
630
|
-
.cloned()
|
|
631
|
-
.unwrap_or_else(|| {
|
|
632
|
-
panic!("NEW fork row must carry an effective_approval_policy; row={new_row}")
|
|
633
|
-
})
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
// ---------------------------------------------------------------------------
|
|
637
|
-
// Minimal in-process Transport for the R8 library-entry test (mirrors the
|
|
638
|
-
// RecordingTransport the existing copilot refusal contract uses). Kept local so
|
|
639
|
-
// R8 exercises the real fork lifecycle capability gate without a live copilot TUI.
|
|
640
|
-
// ---------------------------------------------------------------------------
|
|
641
|
-
|
|
642
|
-
#[derive(Clone, Debug)]
|
|
643
|
-
struct RecordedSpawn {
|
|
644
|
-
argv: Vec<String>,
|
|
645
|
-
env: BTreeMap<String, String>,
|
|
646
|
-
window: String,
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
#[derive(Default)]
|
|
650
|
-
struct RecordingTransport {
|
|
651
|
-
spawns: Mutex<Vec<RecordedSpawn>>,
|
|
652
|
-
session_present: Mutex<bool>,
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
impl Transport for RecordingTransport {
|
|
656
|
-
fn kind(&self) -> BackendKind {
|
|
657
|
-
BackendKind::Tmux
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
fn spawn_first(
|
|
661
|
-
&self,
|
|
662
|
-
session: &SessionName,
|
|
663
|
-
window: &WindowName,
|
|
664
|
-
argv: &[String],
|
|
665
|
-
_cwd: &Path,
|
|
666
|
-
env: &BTreeMap<String, String>,
|
|
667
|
-
) -> Result<SpawnResult, TransportError> {
|
|
668
|
-
let mut spawns = self.spawns.lock().unwrap();
|
|
669
|
-
spawns.push(RecordedSpawn {
|
|
670
|
-
argv: argv.to_vec(),
|
|
671
|
-
env: env.clone(),
|
|
672
|
-
window: window.as_str().to_string(),
|
|
673
|
-
});
|
|
674
|
-
*self.session_present.lock().unwrap() = true;
|
|
675
|
-
Ok(SpawnResult {
|
|
676
|
-
pane_id: PaneId::new(format!("%{}", spawns.len())),
|
|
677
|
-
session: session.clone(),
|
|
678
|
-
window: window.clone(),
|
|
679
|
-
child_pid: Some(30_000 + spawns.len() as u32),
|
|
680
|
-
})
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
fn spawn_into(
|
|
684
|
-
&self,
|
|
685
|
-
session: &SessionName,
|
|
686
|
-
window: &WindowName,
|
|
687
|
-
argv: &[String],
|
|
688
|
-
cwd: &Path,
|
|
689
|
-
env: &BTreeMap<String, String>,
|
|
690
|
-
) -> Result<SpawnResult, TransportError> {
|
|
691
|
-
self.spawn_first(session, window, argv, cwd, env)
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
fn inject(
|
|
695
|
-
&self,
|
|
696
|
-
_target: &Target,
|
|
697
|
-
_payload: &InjectPayload,
|
|
698
|
-
_submit: Key,
|
|
699
|
-
_bracketed: bool,
|
|
700
|
-
) -> Result<InjectReport, TransportError> {
|
|
701
|
-
Ok(InjectReport {
|
|
702
|
-
stage_reached: InjectStage::Submit,
|
|
703
|
-
inject_verification: InjectVerification::CaptureContainsToken,
|
|
704
|
-
submit_verification: SubmitVerification::EnterSentWithoutPlaceholderCheck,
|
|
705
|
-
turn_verification: TurnVerification::NotYetObserved,
|
|
706
|
-
attempts: 1,
|
|
707
|
-
submit_diagnostics: None,
|
|
708
|
-
})
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
fn send_keys(&self, _target: &Target, _keys: &[Key]) -> Result<(), TransportError> {
|
|
712
|
-
Ok(())
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
fn capture(
|
|
716
|
-
&self,
|
|
717
|
-
_target: &Target,
|
|
718
|
-
range: CaptureRange,
|
|
719
|
-
) -> Result<CapturedText, TransportError> {
|
|
720
|
-
Ok(CapturedText {
|
|
721
|
-
text: "Claude Code\n> \nOpenAI Codex\ncodex>\nCopilot".to_string(),
|
|
722
|
-
range,
|
|
723
|
-
})
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
fn query(&self, _target: &Target, field: PaneField) -> Result<Option<String>, TransportError> {
|
|
727
|
-
match field {
|
|
728
|
-
PaneField::PaneWidth => Ok(Some("120".to_string())),
|
|
729
|
-
_ => Ok(None),
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
fn liveness(&self, _pane: &PaneId) -> Result<PaneLiveness, TransportError> {
|
|
734
|
-
Ok(PaneLiveness::Live)
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
fn list_targets(&self) -> Result<Vec<PaneInfo>, TransportError> {
|
|
738
|
-
Ok(Vec::new())
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
fn has_session(&self, _session: &SessionName) -> Result<bool, TransportError> {
|
|
742
|
-
Ok(*self.session_present.lock().unwrap())
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
fn list_windows(&self, _session: &SessionName) -> Result<Vec<WindowName>, TransportError> {
|
|
746
|
-
Ok(Vec::new())
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
fn set_session_env(
|
|
750
|
-
&self,
|
|
751
|
-
_session: &SessionName,
|
|
752
|
-
_key: &str,
|
|
753
|
-
_value: &str,
|
|
754
|
-
) -> Result<SetEnvOutcome, TransportError> {
|
|
755
|
-
Ok(SetEnvOutcome::Applied)
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
fn kill_session(&self, _session: &SessionName) -> Result<(), TransportError> {
|
|
759
|
-
*self.session_present.lock().unwrap() = false;
|
|
760
|
-
Ok(())
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
fn kill_window(&self, _target: &Target) -> Result<(), TransportError> {
|
|
764
|
-
Ok(())
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
fn attach_session(&self, _session: &SessionName) -> Result<AttachOutcome, TransportError> {
|
|
768
|
-
Ok(AttachOutcome::Attached)
|
|
769
|
-
}
|
|
770
|
-
}
|