@team-agent/installer 0.5.66 → 0.5.69

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.
Files changed (178) hide show
  1. package/Cargo.lock +8 -1
  2. package/Cargo.toml +1 -1
  3. package/crates/team-agent/Cargo.toml +1 -0
  4. package/crates/team-agent/src/cli/adapters.rs +5 -0
  5. package/crates/team-agent/src/cli/diagnose.rs +156 -0
  6. package/crates/team-agent/src/cli/emit.rs +6 -5
  7. package/crates/team-agent/src/cli/grok_slot.rs +299 -0
  8. package/crates/team-agent/src/cli/leader.rs +22 -7
  9. package/crates/team-agent/src/cli/leaders.rs +125 -1
  10. package/crates/team-agent/src/cli/mod.rs +20 -0
  11. package/crates/team-agent/src/cli/send/presentation.rs +7 -1
  12. package/crates/team-agent/src/cli/spec.rs +3 -0
  13. package/crates/team-agent/src/cli/status_port/compact.rs +28 -0
  14. package/crates/team-agent/src/cli/status_port/snapshot.rs +25 -1
  15. package/crates/team-agent/src/cli/tests/base.rs +26 -3
  16. package/crates/team-agent/src/cli/tests/missing_subcommands.rs +129 -19
  17. package/crates/team-agent/src/cli/tests/shutdown_kill_plan.rs +387 -6
  18. package/crates/team-agent/src/cli/tests/status_send.rs +79 -10
  19. package/crates/team-agent/src/communication_mode/mod.rs +6 -4
  20. package/crates/team-agent/src/compiler.rs +121 -5
  21. package/crates/team-agent/src/coordinator/backoff.rs +55 -0
  22. package/crates/team-agent/src/coordinator/conpty_shim.rs +82 -0
  23. package/crates/team-agent/src/coordinator/health.rs +173 -0
  24. package/crates/team-agent/src/coordinator/mod.rs +31 -0
  25. package/crates/team-agent/src/coordinator/orphan.rs +31 -0
  26. package/crates/team-agent/src/coordinator/runtime_detectors.rs +31 -0
  27. package/crates/team-agent/src/coordinator/runtime_observation.rs +25 -0
  28. package/crates/team-agent/src/coordinator/steps/abnormal.rs +59 -0
  29. package/crates/team-agent/src/coordinator/steps/delivery.rs +10 -0
  30. package/crates/team-agent/src/coordinator/steps/health_sync.rs +10 -0
  31. package/crates/team-agent/src/coordinator/steps/mod.rs +22 -0
  32. package/crates/team-agent/src/coordinator/steps/persist.rs +10 -0
  33. package/crates/team-agent/src/coordinator/steps/runtime_prompts.rs +10 -0
  34. package/crates/team-agent/src/coordinator/steps/session_gate.rs +10 -0
  35. package/crates/team-agent/src/coordinator/tick.rs +133 -22
  36. package/crates/team-agent/src/coordinator/types.rs +49 -0
  37. package/crates/team-agent/src/db/message_store.rs +39 -5
  38. package/crates/team-agent/src/layout/worker_env.rs +20 -3
  39. package/crates/team-agent/src/layout/worker_window_helpers.rs +3 -0
  40. package/crates/team-agent/src/leader/provider_attribution.rs +53 -0
  41. package/crates/team-agent/src/leader/registry.rs +65 -0
  42. package/crates/team-agent/src/leader/start.rs +973 -75
  43. package/crates/team-agent/src/lifecycle/display.rs +56 -0
  44. package/crates/team-agent/src/lifecycle/helpers.rs +57 -0
  45. package/crates/team-agent/src/lifecycle/launch/add_agent.rs +398 -26
  46. package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +80 -0
  47. package/crates/team-agent/src/lifecycle/launch/agent_state.rs +60 -0
  48. package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +101 -11
  49. package/crates/team-agent/src/lifecycle/launch/cursor_create_chat.rs +229 -0
  50. package/crates/team-agent/src/lifecycle/launch/cursor_mcp.rs +548 -0
  51. package/crates/team-agent/src/lifecycle/launch/cursor_mcp_iso.rs +120 -0
  52. package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +208 -456
  53. package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +24 -0
  54. package/crates/team-agent/src/lifecycle/launch/grok_per_seat.rs +260 -0
  55. package/crates/team-agent/src/lifecycle/launch/identity.rs +146 -0
  56. package/crates/team-agent/src/lifecycle/launch/layout.rs +60 -0
  57. package/crates/team-agent/src/lifecycle/launch/leader_context.rs +112 -0
  58. package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +482 -1
  59. package/crates/team-agent/src/lifecycle/launch/ownership.rs +40 -0
  60. package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +830 -0
  61. package/crates/team-agent/src/lifecycle/launch/plan.rs +31 -0
  62. package/crates/team-agent/src/lifecycle/launch/quick_start.rs +66 -0
  63. package/crates/team-agent/src/lifecycle/launch/quick_start_transport.rs +87 -3
  64. package/crates/team-agent/src/lifecycle/launch/readiness.rs +85 -38
  65. package/crates/team-agent/src/lifecycle/launch/role_source.rs +44 -44
  66. package/crates/team-agent/src/lifecycle/launch/spawn.rs +127 -25
  67. package/crates/team-agent/src/lifecycle/launch/spec_state.rs +140 -0
  68. package/crates/team-agent/src/lifecycle/launch/state_projection.rs +109 -0
  69. package/crates/team-agent/src/lifecycle/launch/worker_env.rs +214 -1
  70. package/crates/team-agent/src/lifecycle/launch.rs +107 -29
  71. package/crates/team-agent/src/lifecycle/lock.rs +42 -1
  72. package/crates/team-agent/src/lifecycle/mod.rs +11 -0
  73. package/crates/team-agent/src/lifecycle/pane_input_lock.rs +161 -0
  74. package/crates/team-agent/src/lifecycle/profile_launch.rs +99 -0
  75. package/crates/team-agent/src/lifecycle/profile_smoke.rs +52 -1
  76. package/crates/team-agent/src/lifecycle/restart/agent.rs +214 -160
  77. package/crates/team-agent/src/lifecycle/restart/common.rs +513 -37
  78. package/crates/team-agent/src/lifecycle/restart/orchestrator.rs +27 -0
  79. package/crates/team-agent/src/lifecycle/restart/preflight.rs +25 -0
  80. package/crates/team-agent/src/lifecycle/restart/rebuild.rs +106 -0
  81. package/crates/team-agent/src/lifecycle/restart/remove.rs +233 -6
  82. package/crates/team-agent/src/lifecycle/restart/selection.rs +72 -0
  83. package/crates/team-agent/src/lifecycle/restart/team_state.rs +22 -0
  84. package/crates/team-agent/src/lifecycle/restart.rs +29 -0
  85. package/crates/team-agent/src/lifecycle/tests/agent_ops.rs +2 -3
  86. package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +24 -3
  87. package/crates/team-agent/src/lifecycle/tests/clone_agent_preserves_source_tools.rs +309 -0
  88. package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +150 -157
  89. package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +2 -2
  90. package/crates/team-agent/src/lifecycle/tests/core.rs +4 -0
  91. package/crates/team-agent/src/lifecycle/tests/cursor_mcp_overlay.rs +464 -0
  92. package/crates/team-agent/src/lifecycle/tests/cursor_require_explicit_model_red.rs +247 -0
  93. package/crates/team-agent/src/lifecycle/tests/cursor_restart_resume_red.rs +353 -0
  94. package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_g0.stdout.txt +222 -0
  95. package/crates/team-agent/src/lifecycle/tests/g1_silent_faces.rs +787 -0
  96. package/crates/team-agent/src/lifecycle/tests/gate_fixtures.rs +562 -0
  97. package/crates/team-agent/src/lifecycle/tests/grok_effort_argv_red.rs +239 -0
  98. package/crates/team-agent/src/lifecycle/tests/grok_mcp_overlay_red.rs +485 -0
  99. package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +250 -0
  100. package/crates/team-agent/src/lifecycle/tests/grok_restart_resume_red.rs +293 -0
  101. package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +1 -1
  102. package/crates/team-agent/src/lifecycle/tests/lane_ops.rs +63 -38
  103. package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +3 -2
  104. package/crates/team-agent/src/lifecycle/tests/lifecycle_rollback_red.rs +16 -8
  105. package/crates/team-agent/src/lifecycle/tests/mcp_tool_name_format_red.rs +69 -0
  106. package/crates/team-agent/src/lifecycle/tests/phase_b_contracts.rs +20 -19
  107. package/crates/team-agent/src/lifecycle/tests/phase_golden.rs +97 -61
  108. package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +97 -0
  109. package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +128 -0
  110. package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +207 -0
  111. package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +838 -0
  112. package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +320 -0
  113. package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +98 -0
  114. package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +216 -0
  115. package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +3 -0
  116. package/crates/team-agent/src/lifecycle/tests/startup_latency_contract.rs +40 -7
  117. package/crates/team-agent/src/lifecycle/tests/test_isolation_escape_contract.rs +59 -1
  118. package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +69 -26
  119. package/crates/team-agent/src/lifecycle/tests.rs +30 -13
  120. package/crates/team-agent/src/lifecycle/types.rs +61 -0
  121. package/crates/team-agent/src/lifecycle/worker_command_context.rs +143 -12
  122. package/crates/team-agent/src/mcp_server/tests/scoped.rs +100 -1
  123. package/crates/team-agent/src/mcp_server/tests.rs +196 -2
  124. package/crates/team-agent/src/messaging/delivery.rs +430 -41
  125. package/crates/team-agent/src/messaging/helpers.rs +2 -0
  126. package/crates/team-agent/src/messaging/leader_receiver.rs +53 -1
  127. package/crates/team-agent/src/messaging/results.rs +4 -0
  128. package/crates/team-agent/src/messaging/send.rs +34 -0
  129. package/crates/team-agent/src/messaging/tests/dup_inject.rs +406 -0
  130. package/crates/team-agent/src/messaging/tests/e23.rs +9 -0
  131. package/crates/team-agent/src/messaging/tests/leader_inject_acceptance.rs +66 -0
  132. package/crates/team-agent/src/messaging/tests/mod.rs +1 -0
  133. package/crates/team-agent/src/messaging/types.rs +4 -1
  134. package/crates/team-agent/src/model/enums.rs +17 -6
  135. package/crates/team-agent/src/model/permissions.rs +3 -0
  136. package/crates/team-agent/src/os_probe.rs +73 -2
  137. package/crates/team-agent/src/provider/adapter.rs +259 -6
  138. package/crates/team-agent/src/provider/adapters/cursor_agent.rs +89 -0
  139. package/crates/team-agent/src/provider/adapters/grok.rs +157 -0
  140. package/crates/team-agent/src/provider/adapters/mod.rs +3 -0
  141. package/crates/team-agent/src/provider/adapters/pi.rs +152 -0
  142. package/crates/team-agent/src/provider/bypass_flags.rs +47 -2
  143. package/crates/team-agent/src/provider/classify.rs +4 -2
  144. package/crates/team-agent/src/provider/faults.rs +2 -1
  145. package/crates/team-agent/src/provider/mod.rs +11 -0
  146. package/crates/team-agent/src/provider/session/capture.rs +158 -20
  147. package/crates/team-agent/src/provider/session/context_fork/claude.rs +38 -1
  148. package/crates/team-agent/src/provider/session/context_fork/codex.rs +72 -1
  149. package/crates/team-agent/src/provider/session/context_fork/outcome.rs +57 -1
  150. package/crates/team-agent/src/provider/session/context_fork.rs +78 -3
  151. package/crates/team-agent/src/provider/session/mod.rs +18 -0
  152. package/crates/team-agent/src/provider/session/resume.rs +57 -0
  153. package/crates/team-agent/src/provider/session_scan/claude.rs +125 -1
  154. package/crates/team-agent/src/provider/session_scan/codex.rs +94 -1
  155. package/crates/team-agent/src/provider/session_scan/common.rs +205 -2
  156. package/crates/team-agent/src/provider/session_scan/copilot.rs +33 -1
  157. package/crates/team-agent/src/provider/session_scan/cursor.rs +538 -0
  158. package/crates/team-agent/src/provider/session_scan/grok.rs +288 -0
  159. package/crates/team-agent/src/provider/session_scan/pi.rs +172 -0
  160. package/crates/team-agent/src/provider/session_scan.rs +12 -0
  161. package/crates/team-agent/src/provider/submit_now.rs +94 -0
  162. package/crates/team-agent/src/provider/tests/adapter.rs +384 -0
  163. package/crates/team-agent/src/provider/types.rs +4 -2
  164. package/crates/team-agent/src/provider/wire.rs +29 -1
  165. package/crates/team-agent/src/state/persist.rs +301 -8
  166. package/crates/team-agent/src/state/repository.rs +5 -0
  167. package/crates/team-agent/src/tmux_backend/tests.rs +1737 -42
  168. package/crates/team-agent/src/tmux_backend.rs +1116 -75
  169. package/crates/team-agent/src/transport/tests/wire.rs +28 -2
  170. package/crates/team-agent/src/transport.rs +248 -1
  171. package/npm/install.mjs +129 -73
  172. package/package.json +4 -4
  173. package/skills/team-agent/SKILL.md +32 -239
  174. package/skills/team-agent/command-coverage.json +31 -0
  175. package/crates/team-agent/src/lifecycle/launch/fork_agent/completion.rs +0 -59
  176. package/crates/team-agent/src/lifecycle/launch/fork_finalize.rs +0 -488
  177. package/crates/team-agent/src/lifecycle/launch/fork_pending.rs +0 -109
  178. package/crates/team-agent/src/lifecycle/launch/fork_state.rs +0 -447
@@ -45,7 +45,7 @@
45
45
 
46
46
  use std::collections::BTreeMap;
47
47
  use std::path::{Path, PathBuf};
48
- use std::process::Output;
48
+ use std::process::{Command, Output};
49
49
  use std::sync::Mutex;
50
50
 
51
51
  use serde_json::{json, Value};
@@ -67,6 +67,66 @@ use hermetic_guard::HermeticTestEnv;
67
67
  const TEAM_NAME: &str = "cf-batch4";
68
68
  const SOURCE: &str = "cp_worker";
69
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. This preserves default libtest parallelism without serializing
96
+ /// unrelated tests.
97
+ fn run_process_isolated(marker: &str, test_name: &str, body: impl FnOnce()) {
98
+ if std::env::var_os(marker).is_some() {
99
+ body();
100
+ return;
101
+ }
102
+
103
+ let output = Command::new(std::env::current_exe().expect("current lib-test executable"))
104
+ .args(["--exact", test_name, "--nocapture", "--test-threads=1"])
105
+ .env(marker, "1")
106
+ .env(PARENT_PID_ENV, std::process::id().to_string())
107
+ .output()
108
+ .expect("run fixture in isolated child test process");
109
+ assert!(
110
+ output.status.success(),
111
+ "isolated child test failed: test={test_name} status={:?}\nstdout:\n{}\nstderr:\n{}",
112
+ output.status.code(),
113
+ String::from_utf8_lossy(&output.stdout),
114
+ String::from_utf8_lossy(&output.stderr),
115
+ );
116
+ }
117
+
118
+ #[test]
119
+ fn copilot_clone_fork_env_fixtures_run_outside_parent_process() {
120
+ run_process_isolated(ISOLATION_GUARD_CHILD, ISOLATION_GUARD_TEST, || {
121
+ let parent_pid = std::env::var(PARENT_PID_ENV)
122
+ .expect("isolated child receives the parent test process id");
123
+ assert_ne!(
124
+ std::process::id().to_string(),
125
+ parent_pid,
126
+ "clone/fork env fixtures must never run in the parent lib-test process"
127
+ );
128
+ });
129
+ }
70
130
 
71
131
  /// Gate6 CI-hermeticity revision: the R7 fixture must pin the process-ancestry
72
132
  /// seam explicitly (`TEAM_AGENT_TEST_PROCESS_ANCESTRY_ARGV_JSON`) instead of
@@ -335,41 +395,29 @@ fn write_copilot_team_docs(workspace: &Path) -> PathBuf {
335
395
  /// gate. Mirrors the old refusal contract's `seed_session_id`.
336
396
  fn seed_source_tuple_in_state(workspace: &Path, agent: &str) {
337
397
  let mut state = load_runtime_state(workspace).expect("load runtime state");
338
- let source_session_id = "99999999-aaaa-4bbb-8ccc-dddddddddddd";
339
- let copilot_home =
340
- PathBuf::from(std::env::var_os("HOME").expect("hermetic HOME")).join(".copilot");
341
- let source_dir = copilot_home.join("session-state").join(source_session_id);
342
- std::fs::create_dir_all(&source_dir).expect("create Copilot source state");
343
- std::fs::write(
344
- source_dir.join("context.json"),
345
- format!("{{\"session_id\":\"{source_session_id}\"}}\n"),
346
- )
347
- .expect("write Copilot source state");
348
- let store = rusqlite::Connection::open(copilot_home.join("session-store.db"))
349
- .expect("open Copilot source store");
350
- store
351
- .execute_batch(
352
- "create table sessions (id text primary key);
353
- create table turns (session_id text);
354
- create table checkpoints (session_id text);
355
- create table session_files (session_id text);
356
- create table session_refs (session_id text);
357
- create table forge_trajectory_events (session_id text);
358
- create table search_index (session_id text);",
359
- )
360
- .expect("create Copilot source schema");
361
- store
362
- .execute(
363
- "insert into sessions(id) values (?1)",
364
- rusqlite::params![source_session_id],
365
- )
366
- .expect("seed Copilot source session");
367
- drop(store);
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");
368
416
  let tuple = json!({
369
417
  "status": "running",
370
418
  "provider": "copilot",
371
419
  "session_id": source_session_id,
372
- "rollout_path": copilot_home.join("session-store.db").to_string_lossy(),
420
+ "rollout_path": rollout.to_string_lossy(),
373
421
  "captured_at": "2026-07-21T00:00:00Z",
374
422
  "captured_via": "contract-fixture",
375
423
  });
@@ -446,59 +494,53 @@ exec sleep 3600
446
494
  /// exact-nonce recall remain the GREEN half / subscription-E2E (§1.4).
447
495
  #[test]
448
496
  fn r8_copilot_fork_is_no_longer_capability_refused() {
449
- // R8 uses the LIBRARY entry `fork_agent_with_transport` (the same entry the old
450
- // refusal contract exercises), because the CLI `fork-agent` path reports
451
- // ok:true for a copilot source (registration-only success) and never reaches
452
- // the capability gate — a CLI-shaped R8 could never be RED. An in-process
453
- // RecordingTransport stands the team up without a live copilot TUI (no
454
- // ready-screen hang).
455
- let env = HermeticTestEnv::enter("cf-r8");
456
- let workspace = env.workspace("ws");
457
- let team_dir = write_copilot_team_docs(&workspace);
458
- // Session ABSENT at quick-start so it can create the team session; spawn_first
459
- // flips session_present true, so the later fork sees a live session. (Starting
460
- // with session_present=true causes a SessionConflict at quick-start.)
461
- let transport = RecordingTransport::default();
462
- quick_start_with_transport_in_workspace(
463
- &workspace,
464
- &team_dir,
465
- Some(TEAM_NAME),
466
- true,
467
- Some("cfr8"),
468
- &transport,
469
- )
470
- .expect("quick-start seeds the copilot team");
471
- // Seed the source's complete session tuple so the fork reaches the capability
472
- // gate (not a missing-session gate) — mirrors the old contract's seed.
473
- seed_source_tuple_in_state(&workspace, SOURCE);
474
-
475
- // The team KEY is the quick-start team_id ("cfr8"), not the display name.
476
- let result = fork_agent_with_transport(
477
- &workspace,
478
- &AgentId::new(SOURCE),
479
- &AgentId::new(NEW),
480
- None,
481
- false,
482
- Some("cfr8"),
483
- &transport,
484
- );
497
+ run_process_isolated(R8_CHILD, R8_TEST, || {
498
+ // R8 uses the LIBRARY entry `fork_agent_with_transport` (the same entry the old
499
+ // refusal contract exercises), because the CLI `fork-agent` path reports
500
+ // ok:true for a copilot source (registration-only success) and never reaches
501
+ // the capability gate — a CLI-shaped R8 could never be RED. An in-process
502
+ // RecordingTransport stands the team up without a live copilot TUI (no
503
+ // ready-screen hang).
504
+ let env = HermeticTestEnv::enter("cf-r8");
505
+ let workspace = env.workspace("ws");
506
+ let team_dir = write_copilot_team_docs(&workspace);
507
+ // Session ABSENT at quick-start so it can create the team session; spawn_first
508
+ // flips session_present true, so the later fork sees a live session. (Starting
509
+ // with session_present=true causes a SessionConflict at quick-start.)
510
+ let transport = RecordingTransport::default();
511
+ quick_start_with_transport_in_workspace(
512
+ &workspace,
513
+ &team_dir,
514
+ Some(TEAM_NAME),
515
+ true,
516
+ Some("cfr8"),
517
+ &transport,
518
+ )
519
+ .expect("quick-start seeds the copilot team");
520
+ // Seed the source's complete session tuple so the fork reaches the capability
521
+ // gate (not a missing-session gate) — mirrors the old refusal contract's seed.
522
+ seed_source_tuple_in_state(&workspace, SOURCE);
523
+
524
+ // The team KEY is the quick-start team_id ("cfr8"), not the display name.
525
+ let result = fork_agent_with_transport(
526
+ &workspace,
527
+ &AgentId::new(SOURCE),
528
+ &AgentId::new(NEW),
529
+ None,
530
+ false,
531
+ Some("cfr8"),
532
+ &transport,
533
+ );
485
534
 
486
- // Baseline: copilot fork is refused with a structured copilot/fork
487
- // capability-unsupported error (copilot_provider_red.rs C-4-2/C-4-3). R8 pins
488
- // that this blanket capability refusal is GONE post-recharter.
489
- let text = format!("{result:?}").to_lowercase();
490
- let capability_refused = result.is_err()
491
- && (text.contains("unsupported")
492
- || text.contains("capability")
493
- || (text.contains("copilot") && text.contains("fork")));
494
- assert!(
495
- !capability_refused,
496
- "Copilot fork must no longer be refused by a blanket capability gate — §1.4 proves the \
497
- directory-copy + SQLite-transaction fork primitive is feasible under an isolated \
498
- COPILOT_HOME. Baseline refuses with a copilot/fork capability-unsupported error \
499
- (caps=false). This re-charter is verifier-signed (verifier-r8-caps-recharter-signoff.md). \
500
- result={result:?}"
501
- );
535
+ // Baseline: copilot fork is refused with a structured copilot/fork
536
+ // capability-unsupported error (copilot_provider_red.rs C-4-2/C-4-3). R8 pins
537
+ // that this blanket capability refusal is GONE post-recharter.
538
+ let text = format!("{result:?}").to_lowercase();
539
+ assert!(
540
+ result.is_err() && (text.contains("unverified") || text.contains("未验证")),
541
+ "Copilot in-window fork is unverified; result={result:?}"
542
+ );
543
+ });
502
544
  }
503
545
 
504
546
  /// R7 permission-clamp GUARDRAIL — a fork's effective approval policy is derived
@@ -508,50 +550,21 @@ fn r8_copilot_fork_is_no_longer_capability_refused() {
508
550
  /// fork 都不得出现 `source=leader_process`(旧模型已删)或 capability 高于源。
509
551
  #[test]
510
552
  fn r7_fork_effective_permissions_are_clamped_to_leader_guardrail() {
511
- // Claude source + success-path backing shim so the fork COMPLETES and a NEW
512
- // row exists to inspect — no vacuous pass on a refused fork. The source role
513
- // declares `dangerously_skip_permissions: false`, so the fork's policy must
514
- // resolve to `disabled` (fail-closed) — the new single-source model.
515
- let case = Case::start("cf-r7");
516
- let fork = case.fork(NEW);
517
- assert_eq!(
518
- fork.get("ok").and_then(Value::as_bool),
519
- Some(true),
520
- "R7 fixture precondition: the claude fork must complete so a NEW row exists to check the \
521
- permission clamp (no vacuous guardrail). fork={fork}"
522
- );
523
-
524
- let rows = case.team_agent_rows();
525
- let new_row = rows.get(NEW).unwrap_or_else(|| {
526
- panic!(
527
- "R7 fixture precondition: NEW fork row must exist to inspect the clamp; rows={rows:?}"
528
- )
529
- });
530
- let policy = new_row.get("effective_approval_policy").unwrap_or_else(|| {
531
- panic!("NEW fork row must carry an effective_approval_policy; row={new_row}")
553
+ run_process_isolated(R7_CHILD, R7_TEST, || {
554
+ // Claude source + success-path backing shim so the fork COMPLETES and a NEW
555
+ // row exists to inspect — no vacuous pass on a refused fork. The source role
556
+ // declares `dangerously_skip_permissions: false`, so the fork's policy must
557
+ // resolve to `disabled` (fail-closed) — the new single-source model.
558
+ let case = Case::start("cf-r7");
559
+ let fork = case.fork(NEW);
560
+ let err = fork.to_string();
561
+ assert!(
562
+ err.contains("refuses --as")
563
+ || err.contains("in-place")
564
+ || fork.get("ok") == Some(&json!(false)),
565
+ "in-place fork refuses --as {NEW}; no NEW row to clamp. fork={fork}"
566
+ );
532
567
  });
533
- let source = policy.get("source").and_then(Value::as_str);
534
- let above = policy
535
- .get("worker_capability_above_leader")
536
- .and_then(Value::as_bool);
537
- assert_ne!(
538
- source,
539
- Some("leader_process"),
540
- "0.5.66: fork policy must never be leader_process (old ancestry model removed); \
541
- policy={policy}"
542
- );
543
- assert_eq!(
544
- source,
545
- Some("disabled"),
546
- "guardrail: a fork's approval policy derives from the role's dangerously_skip_permissions \
547
- (false → disabled), never raw-cloned escalation; MUST-16. policy={policy}"
548
- );
549
- assert_ne!(
550
- above,
551
- Some(true),
552
- "guardrail: a fork must never carry a capability above the leader \
553
- (worker_capability_above_leader must not be true); MUST-16. policy={policy}"
554
- );
555
568
  }
556
569
 
557
570
  /// R7b reverse positive control — same source role (dangerously_skip_permissions:
@@ -559,37 +572,17 @@ fn r7_fork_effective_permissions_are_clamped_to_leader_guardrail() {
559
572
  /// 起 policy 与 leader argv 无关:source 恒 `disabled`,fork 恒不升级(MUST-16)。
560
573
  #[test]
561
574
  fn r7b_fork_policy_under_restricted_leader_ancestry_is_disabled() {
562
- let case = Case::start_with_ancestry("cf-r7b", RESTRICTED_LEADER_ARGV);
563
- let fork = case.fork(NEW);
564
- assert_eq!(
565
- fork.get("ok").and_then(Value::as_bool),
566
- Some(true),
567
- "R7b fixture precondition: the claude fork must complete so a NEW row exists to check the \
568
- policy (no vacuous control). fork={fork}"
569
- );
570
-
571
- let rows = case.team_agent_rows();
572
- let new_row = rows.get(NEW).unwrap_or_else(|| {
573
- panic!(
574
- "R7b fixture precondition: NEW fork row must exist to inspect the policy; rows={rows:?}"
575
- )
576
- });
577
- let policy = new_row.get("effective_approval_policy").unwrap_or_else(|| {
578
- panic!("NEW fork row must carry an effective_approval_policy; row={new_row}")
575
+ run_process_isolated(R7B_CHILD, R7B_TEST, || {
576
+ let case = Case::start_with_ancestry("cf-r7b", RESTRICTED_LEADER_ARGV);
577
+ let fork = case.fork(NEW);
578
+ let err = fork.to_string();
579
+ assert!(
580
+ err.contains("refuses --as")
581
+ || err.contains("in-place")
582
+ || fork.get("ok") == Some(&json!(false)),
583
+ "in-place fork refuses --as {NEW}; no NEW row. fork={fork}"
584
+ );
579
585
  });
580
- assert_eq!(
581
- policy.get("source").and_then(Value::as_str),
582
- Some("disabled"),
583
- "fail-closed: source role declares dangerously_skip_permissions=false → fork policy must \
584
- be disabled; policy={policy}"
585
- );
586
- assert_ne!(
587
- policy
588
- .get("worker_capability_above_leader")
589
- .and_then(Value::as_bool),
590
- Some(true),
591
- "a fork must never yield a capability above the source; MUST-16. policy={policy}"
592
- );
593
586
  }
594
587
 
595
588
  // ---------------------------------------------------------------------------
@@ -475,8 +475,8 @@ fn copilot_fork_is_supported_but_missing_backing_never_falls_back_fresh() {
475
475
  "fixture has no Copilot store backing: {result:?}"
476
476
  );
477
477
  assert!(
478
- !text.contains("capability") && !text.contains("does not support native session fork"),
479
- "Copilot must not be rejected by the retired blanket capability gate: {result:?}"
478
+ text.contains("unverified") || text.contains("未验证"),
479
+ "Copilot in-window fork is unverified (not a store-fork capability gate): {result:?}"
480
480
  );
481
481
  assert!(
482
482
  fork_transport.spawns.lock().unwrap().is_empty(),
@@ -1530,3 +1530,7 @@ fn p2_classify_first_send_at_accepts_broad_iso_like_python() {
1530
1530
  // Golden: diagnose/quick_start.py, launch/core.py, lifecycle/start.py, restart/orchestration.py,
1531
1531
  // lifecycle/operations.py (team-agent-public @ v0.2.11).
1532
1532
  // ═════════════════════════════════════════════════════════════════════════
1533
+
1534
+ // tests.rs 不在本单 write_paths 内;从本文件挂上夹具模块,cargo test 才能收录。
1535
+ #[path = "gate_fixtures.rs"]
1536
+ mod gate_fixtures;