@team-agent/installer 0.5.125 → 0.5.127

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 (144) hide show
  1. package/Cargo.lock +1 -1
  2. package/Cargo.toml +1 -1
  3. package/crates/team-agent/src/cli/diagnose.rs +0 -137
  4. package/crates/team-agent/src/cli/emit.rs +13 -8
  5. package/crates/team-agent/src/cli/grok_slot.rs +88 -3
  6. package/crates/team-agent/src/cli/intent/runtime.rs +6 -4
  7. package/crates/team-agent/src/cli/intent/runtime_tests.rs +55 -10
  8. package/crates/team-agent/src/cli/mod.rs +35 -29
  9. package/crates/team-agent/src/cli/models.rs +33 -944
  10. package/crates/team-agent/src/cli/tests/leader_watch.rs +1 -1
  11. package/crates/team-agent/src/cli/tests/mod.rs +3 -3
  12. package/crates/team-agent/src/cli/tests/run_delegation.rs +8 -7
  13. package/crates/team-agent/src/cli/tests/status_send.rs +2 -2
  14. package/crates/team-agent/src/compiler/tests.rs +54 -12
  15. package/crates/team-agent/src/compiler.rs +7 -205
  16. package/crates/team-agent/src/contract_runtime/backend.rs +97 -38
  17. package/crates/team-agent/src/contract_runtime/commands.rs +335 -4
  18. package/crates/team-agent/src/contract_runtime/config.rs +12 -8
  19. package/crates/team-agent/src/contract_runtime/fork.rs +368 -0
  20. package/crates/team-agent/src/contract_runtime/framework.rs +8 -13
  21. package/crates/team-agent/src/contract_runtime/mod.rs +1 -0
  22. package/crates/team-agent/src/contract_runtime/registry.rs +100 -60
  23. package/crates/team-agent/src/coordinator/steps/abnormal.rs +45 -5
  24. package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +54 -16
  25. package/crates/team-agent/src/coordinator/tests/energy.rs +4 -4
  26. package/crates/team-agent/src/coordinator/tests/health_sync.rs +2 -44
  27. package/crates/team-agent/src/coordinator/tests/main_preserved.rs +2 -2
  28. package/crates/team-agent/src/coordinator/tests/spine.rs +1 -1
  29. package/crates/team-agent/src/coordinator/tests/takeover.rs +3 -3
  30. package/crates/team-agent/src/leader/start.rs +1 -1
  31. package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +2 -195
  32. package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +11 -27
  33. package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +22 -200
  34. package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +6 -87
  35. package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +5 -496
  36. package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +74 -244
  37. package/crates/team-agent/src/lifecycle/launch/quick_start.rs +2 -26
  38. package/crates/team-agent/src/lifecycle/launch/role_source.rs +5 -0
  39. package/crates/team-agent/src/lifecycle/launch/spawn.rs +26 -51
  40. package/crates/team-agent/src/lifecycle/launch.rs +3 -34
  41. package/crates/team-agent/src/lifecycle/profile_launch.rs +18 -373
  42. package/crates/team-agent/src/lifecycle/restart/common.rs +45 -463
  43. package/crates/team-agent/src/lifecycle/restart/remove.rs +129 -0
  44. package/crates/team-agent/src/lifecycle/restart/selection.rs +5 -5
  45. package/crates/team-agent/src/lifecycle/restart.rs +0 -2
  46. package/crates/team-agent/src/lifecycle/role_config.rs +40 -13
  47. package/crates/team-agent/src/lifecycle/tests/acceptance_b_batch_red.rs +1 -1
  48. package/crates/team-agent/src/lifecycle/tests/agent_ops.rs +8 -12
  49. package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +38 -236
  50. package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +8 -320
  51. package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +106 -186
  52. package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +4 -334
  53. package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +19 -15
  54. package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +2 -2
  55. package/crates/team-agent/src/lifecycle/tests/core.rs +33 -58
  56. package/crates/team-agent/src/lifecycle/tests/f032_startup_prompt_best_effort_red.rs +22 -8
  57. package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +15 -133
  58. package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +3 -51
  59. package/crates/team-agent/src/lifecycle/tests/host_cotenant_death_p0_contract.rs +30 -67
  60. package/crates/team-agent/src/lifecycle/tests/issue238_codex_effort_contract.rs +3 -31
  61. package/crates/team-agent/src/lifecycle/tests/lane_ops.rs +194 -169
  62. package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +162 -284
  63. package/crates/team-agent/src/lifecycle/tests/lifecycle_rollback_red.rs +15 -78
  64. package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +7 -7
  65. package/crates/team-agent/src/lifecycle/tests/phase_b_contracts.rs +75 -69
  66. package/crates/team-agent/src/lifecycle/tests/phase_golden.rs +2 -10
  67. package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +6 -18
  68. package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +52 -70
  69. package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +4 -157
  70. package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +10 -302
  71. package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +1 -68
  72. package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +1 -19
  73. package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +2 -100
  74. package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +15 -14
  75. package/crates/team-agent/src/lifecycle/tests/restart.rs +12 -153
  76. package/crates/team-agent/src/lifecycle/tests/restart_build_before_destroy_0540_contract.rs +27 -5
  77. package/crates/team-agent/src/lifecycle/tests/restart_liveness_red.rs +59 -10
  78. package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +47 -6
  79. package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +3 -1478
  80. package/crates/team-agent/src/lifecycle/tests/resume_recover_red.rs +27 -10
  81. package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +7 -7
  82. package/crates/team-agent/src/lifecycle/tests/subprep_codex_trust_roundtrip_red.rs +67 -313
  83. package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +2 -254
  84. package/crates/team-agent/src/lifecycle/tests/team_in_team_identity_scope_red.rs +2 -2
  85. package/crates/team-agent/src/lifecycle/tests/team_in_team_sibling_quick_start_red.rs +1 -1
  86. package/crates/team-agent/src/lifecycle/tests/team_in_team_state_scope_red.rs +2 -2
  87. package/crates/team-agent/src/lifecycle/tests/team_key_retirement_txn_red.rs +4 -4
  88. package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +74 -19
  89. package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +39 -38
  90. package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +42 -97
  91. package/crates/team-agent/src/lifecycle/tests.rs +0 -7
  92. package/crates/team-agent/src/lifecycle/types.rs +2 -21
  93. package/crates/team-agent/src/mcp_server/readiness_tests.rs +15 -17
  94. package/crates/team-agent/src/messaging/delivery.rs +14 -195
  95. package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +5 -5
  96. package/crates/team-agent/src/messaging/tests/dup_inject.rs +68 -69
  97. package/crates/team-agent/src/messaging/tests/main_preserved.rs +2 -2
  98. package/crates/team-agent/src/messaging/tests/runtime.rs +5 -5
  99. package/crates/team-agent/src/messaging/tests/spine.rs +30 -32
  100. package/crates/team-agent/src/messaging/tests/wave2.rs +13 -20
  101. package/crates/team-agent/src/provider/adapter.rs +71 -572
  102. package/crates/team-agent/src/provider/adapters/mod.rs +6 -8
  103. package/crates/team-agent/src/provider/model_catalog.rs +13 -201
  104. package/crates/team-agent/src/provider/session/capture.rs +11 -211
  105. package/crates/team-agent/src/provider/session/context_fork/outcome.rs +8 -24
  106. package/crates/team-agent/src/provider/session/context_fork.rs +29 -240
  107. package/crates/team-agent/src/provider/session/mod.rs +2 -3
  108. package/crates/team-agent/src/provider/session_scan/common.rs +27 -87
  109. package/crates/team-agent/src/provider/session_scan/pi.rs +1 -34
  110. package/crates/team-agent/src/provider/session_scan.rs +7 -23
  111. package/crates/team-agent/src/provider/tests/adapter.rs +66 -204
  112. package/crates/team-agent/src/provider/tests/command_helpers.rs +3 -29
  113. package/crates/team-agent/src/provider/tests/idle.rs +0 -68
  114. package/crates/team-agent/src/provider/types.rs +0 -4
  115. package/crates/team-agent/src/provider/wire.rs +77 -23
  116. package/crates/team-agent/src/state/abnormal_watch/tests/mod.rs +1 -1
  117. package/crates/team-agent/src/state/persist.rs +6 -6
  118. package/crates/team-agent/src/state/repository/tests.rs +2 -2
  119. package/crates/team-agent/src/tmux_backend.rs +4 -3
  120. package/package.json +4 -4
  121. package/skills/team-agent/SKILL.md +8 -5
  122. package/skills/team-agent/command-coverage.json +29 -1
  123. package/skills/team-agent/docs/reference/team-agent-operator.md +7 -3
  124. package/skills/team-agent/references/team-agent-operator.md +7 -3
  125. package/crates/team-agent/src/lifecycle/launch/grok_per_seat.rs +0 -260
  126. package/crates/team-agent/src/lifecycle/restart/avatar.rs +0 -1805
  127. package/crates/team-agent/src/lifecycle/tests/claude_compatible_config_red.rs +0 -325
  128. package/crates/team-agent/src/lifecycle/tests/codex_weak_window_attribution_red.rs +0 -683
  129. package/crates/team-agent/src/lifecycle/tests/grok_effort_argv_red.rs +0 -247
  130. package/crates/team-agent/src/lifecycle/tests/grok_mcp_overlay_red.rs +0 -507
  131. package/crates/team-agent/src/lifecycle/tests/grok_restart_resume_red.rs +0 -300
  132. package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +0 -210
  133. package/crates/team-agent/src/lifecycle/tests/pi_fork_session_inheritance_red.rs +0 -1409
  134. package/crates/team-agent/src/provider/adapters/claude.rs +0 -78
  135. package/crates/team-agent/src/provider/adapters/claude_fork.rs +0 -131
  136. package/crates/team-agent/src/provider/adapters/codex.rs +0 -101
  137. package/crates/team-agent/src/provider/adapters/grok.rs +0 -67
  138. package/crates/team-agent/src/provider/adapters/pi.rs +0 -100
  139. package/crates/team-agent/src/provider/session/context_fork/claude.rs +0 -123
  140. package/crates/team-agent/src/provider/session/context_fork/codex.rs +0 -514
  141. package/crates/team-agent/src/provider/session_scan/claude.rs +0 -523
  142. package/crates/team-agent/src/provider/session_scan/codex.rs +0 -326
  143. package/crates/team-agent/src/provider/session_scan/grok.rs +0 -288
  144. package/crates/team-agent/src/test_support/models_timeout_fixture.rs +0 -144
@@ -20,7 +20,9 @@
20
20
  //! (The SQLite foreign-key table integrity + exact-nonce recall are the GREEN
21
21
  //! half / subscription-E2E per §1.4 — not asserted offline here.)
22
22
  //!
23
- //! - **R7 permission-clamp GUARDRAIL (naturally-green, not a RED, per L1 r2)**: a
23
+ //! - **R7 permission-clamp GUARDRAIL (retired)**: R7/R7b drove a legacy Claude
24
+ //! seat fork through a backing shim; that runtime is gone, so they left with it.
25
+ //! Original charter: a
24
26
  //! fork's effective approval policy must be derived from the LEADER
25
27
  //! (`source=leader_process`, `worker_capability_above_leader=false`), never a
26
28
  //! raw clone of a source-declared capability above the leader (MUST-16).
@@ -45,7 +47,7 @@
45
47
 
46
48
  use std::collections::BTreeMap;
47
49
  use std::path::{Path, PathBuf};
48
- use std::process::{Command, Output};
50
+ use std::process::Command;
49
51
  use std::sync::Mutex;
50
52
 
51
53
  use serde_json::{json, Value};
@@ -67,19 +69,9 @@ use hermetic_guard::HermeticTestEnv;
67
69
  const TEAM_NAME: &str = "cf-batch4";
68
70
  const SOURCE: &str = "cp_worker";
69
71
  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
72
  const R8_CHILD: &str = "TEAM_AGENT_TEST_CF_R8_CHILD";
73
73
  const ISOLATION_GUARD_CHILD: &str = "TEAM_AGENT_TEST_CF_ISOLATION_GUARD_CHILD";
74
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
75
  const R8_TEST: &str = concat!(
84
76
  "lifecycle::tests::clone_fork_copilot_perms_red::",
85
77
  "r8_copilot_fork_is_no_longer_capability_refused"
@@ -129,247 +121,6 @@ fn copilot_clone_fork_env_fixtures_run_outside_parent_process() {
129
121
  });
130
122
  }
131
123
 
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
124
  /// Copilot team docs for the library-entry R8 (a separate agents dir so the
374
125
  /// OfflineTransport quick-start compiles a copilot source).
375
126
  fn write_copilot_team_docs(workspace: &Path) -> PathBuf {
@@ -446,43 +197,6 @@ fn seed_source_tuple_in_state(workspace: &Path, agent: &str) {
446
197
  save_runtime_state(workspace, &state).expect("save seeded state");
447
198
  }
448
199
 
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
200
  /// R8 Copilot fork caps RE-CHARTER — a Copilot fork must no longer be refused by a
487
201
  /// blanket capability gate (§1.4 proves the directory-copy + SQLite-transaction
488
202
  /// primitive is feasible under an isolated COPILOT_HOME). Baseline red: the fork
@@ -545,50 +259,6 @@ fn r8_copilot_fork_is_no_longer_capability_refused() {
545
259
  });
546
260
  }
547
261
 
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
- let err = fork.to_string();
564
- assert!(
565
- err.contains("refuses --as")
566
- || err.contains("in-place")
567
- || fork.get("ok") == Some(&json!(false)),
568
- "in-place fork refuses --as {NEW}; no NEW row to clamp. fork={fork}"
569
- );
570
- });
571
- }
572
-
573
- /// R7b reverse positive control — same source role (dangerously_skip_permissions:
574
- /// false) must also resolve to `source=disabled` under any ancestry seam. 0.5.66
575
- /// 起 policy 与 leader argv 无关:source 恒 `disabled`,fork 恒不升级(MUST-16)。
576
- #[test]
577
- #[serial_test::serial(env)]
578
- fn r7b_fork_policy_under_restricted_leader_ancestry_is_disabled() {
579
- run_process_isolated(R7B_CHILD, R7B_TEST, || {
580
- let case = Case::start_with_ancestry("cf-r7b", RESTRICTED_LEADER_ARGV);
581
- let fork = case.fork(NEW);
582
- let err = fork.to_string();
583
- assert!(
584
- err.contains("refuses --as")
585
- || err.contains("in-place")
586
- || fork.get("ok") == Some(&json!(false)),
587
- "in-place fork refuses --as {NEW}; no NEW row. fork={fork}"
588
- );
589
- });
590
- }
591
-
592
262
  // ---------------------------------------------------------------------------
593
263
  // Minimal in-process Transport for the R8 library-entry test (mirrors the
594
264
  // RecordingTransport the existing copilot refusal contract uses). Kept local so
@@ -57,7 +57,7 @@ fn t06_each_official_mode_selects_one_runtime_contract_in_real_spawn_prompt() {
57
57
  .iter()
58
58
  .find(|spawn| spawn.window.as_str().contains(id))
59
59
  .unwrap_or_else(|| panic!("T06/{id}: no spawn recorded for product-catalog mode"));
60
- let prompt = flag_value(&spawn.argv, "--append-system-prompt");
60
+ let prompt = spawn_prompt(spawn);
61
61
  let own_heading = format!("{CONTRACT_HEADING_PREFIX}{id}");
62
62
  assert!(
63
63
  prompt.contains(&own_heading),
@@ -106,7 +106,7 @@ fn t06_selected_templates_project_the_two_signed_communication_boundaries() {
106
106
  .iter()
107
107
  .find(|spawn| spawn.window.as_str().contains(id))
108
108
  .unwrap_or_else(|| panic!("T06/{id}: missing recorded spawn"));
109
- flag_value(&spawn.argv, "--append-system-prompt")
109
+ spawn_prompt(spawn)
110
110
  };
111
111
 
112
112
  let leader = prompt(CommunicationMode::LeaderCentric);
@@ -161,7 +161,7 @@ fn t07_final_spawn_prompt_does_not_leak_leader_centric_obligations_into_orchestr
161
161
  .as_str()
162
162
  .contains(CommunicationMode::Orchestrated.as_str())
163
163
  })
164
- .map(|spawn| flag_value(&spawn.argv, "--append-system-prompt"))
164
+ .map(spawn_prompt)
165
165
  .expect("T07/orchestrated: missing recorded spawn");
166
166
 
167
167
  for required in [
@@ -189,7 +189,7 @@ fn t07_final_spawn_prompt_does_not_leak_leader_centric_obligations_into_orchestr
189
189
  let default_spawns = default_transport.spawns.lock().unwrap();
190
190
  let default_prompt = default_spawns
191
191
  .first()
192
- .map(|spawn| flag_value(&spawn.argv, "--append-system-prompt"))
192
+ .map(spawn_prompt)
193
193
  .expect("T07/leader_centric positive control: missing recorded default spawn");
194
194
  for required in [
195
195
  "Progress, blockers, questions:",
@@ -266,7 +266,7 @@ fn fixture(tag: &str, team_mode: Option<&str>) -> PathBuf {
266
266
  std::fs::write(
267
267
  root.join("agents").join(format!("worker_{id}.md")),
268
268
  format!(
269
- "---\nname: worker_{id}\nrole: Communication Worker\nprovider: claude\ndangerously_skip_permissions: false\ncommunication_mode: {id}\ntools:\n - mcp_team\n---\n\nROLE BODY SENTINEL {id}\n"
269
+ "---\nname: worker_{id}\nrole: Communication Worker\nprovider: copilot\nmodel: gpt-5.5\ndangerously_skip_permissions: false\ncommunication_mode: {id}\ntools:\n - mcp_team\n---\n\nROLE BODY SENTINEL {id}\n"
270
270
  ),
271
271
  )
272
272
  .unwrap();
@@ -285,23 +285,26 @@ fn default_fixture(tag: &str) -> PathBuf {
285
285
  }
286
286
  std::fs::write(
287
287
  root.join("agents").join("worker_default.md"),
288
- "---\nname: worker_default\nrole: Communication Worker\nprovider: claude\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nROLE BODY SENTINEL default\n",
288
+ "---\nname: worker_default\nrole: Communication Worker\nprovider: copilot\nmodel: gpt-5.5\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nROLE BODY SENTINEL default\n",
289
289
  )
290
290
  .unwrap();
291
291
  root
292
292
  }
293
293
 
294
- fn flag_value(argv: &[String], flag: &str) -> String {
295
- argv.windows(2)
296
- .find(|pair| pair[0] == flag)
297
- .map(|pair| pair[1].clone())
294
+ /// The Copilot worker carries the assembled prompt verbatim in the per-worker
295
+ /// AGENTS.md that its spawn env `COPILOT_CUSTOM_INSTRUCTIONS_DIRS` points at.
296
+ fn spawn_prompt(spawn: &RecordedSpawn) -> String {
297
+ spawn
298
+ .instructions_dir
299
+ .as_ref()
300
+ .and_then(|dir| std::fs::read_to_string(Path::new(dir).join("AGENTS.md")).ok())
298
301
  .unwrap_or_default()
299
302
  }
300
303
 
301
304
  #[derive(Debug, Clone)]
302
305
  struct RecordedSpawn {
303
306
  window: WindowName,
304
- argv: Vec<String>,
307
+ instructions_dir: Option<String>,
305
308
  }
306
309
 
307
310
  #[derive(Debug, Default)]
@@ -329,14 +332,14 @@ impl Transport for RecordingTransport {
329
332
  &self,
330
333
  session: &SessionName,
331
334
  window: &WindowName,
332
- argv: &[String],
335
+ _argv: &[String],
333
336
  _cwd: &Path,
334
- _env: &BTreeMap<String, String>,
337
+ env: &BTreeMap<String, String>,
335
338
  ) -> Result<SpawnResult, TransportError> {
336
339
  let mut spawns = self.spawns.lock().unwrap();
337
340
  spawns.push(RecordedSpawn {
338
341
  window: window.clone(),
339
- argv: argv.to_vec(),
342
+ instructions_dir: env.get("COPILOT_CUSTOM_INSTRUCTIONS_DIRS").cloned(),
340
343
  });
341
344
  Ok(SpawnResult {
342
345
  pane_id: PaneId::new(format!("%{}", spawns.len())),
@@ -371,8 +374,9 @@ impl Transport for RecordingTransport {
371
374
  _target: &Target,
372
375
  range: CaptureRange,
373
376
  ) -> Result<CapturedText, TransportError> {
377
+ // A ready Copilot screen ends the startup-trust poll immediately.
374
378
  Ok(CapturedText {
375
- text: String::new(),
379
+ text: team_agent::provider::COPILOT_READY_MARKER.to_string(),
376
380
  range,
377
381
  })
378
382
  }
@@ -1101,14 +1101,14 @@ fn rules_t02_inline_server_map_preserves_unknown_and_non_object_values() {
1101
1101
  fn rules_t02_non_copilot_writer_keeps_canonical_schema() {
1102
1102
  let hermetic = enter_hermetic("rules-t02-canonical");
1103
1103
  let ws = hermetic.workspace("canonical");
1104
- let config = team_agent::provider::get_adapter(Provider::ClaudeCode)
1104
+ let config = team_agent::provider::get_adapter(Provider::GeminiCli)
1105
1105
  .mcp_config(team_agent::provider::AuthMode::Subscription)
1106
1106
  .unwrap();
1107
1107
  let path = team_agent::lifecycle::launch::write_worker_mcp_config_for_provider(
1108
1108
  &ws,
1109
1109
  "synthetic",
1110
1110
  &config,
1111
- Some(Provider::ClaudeCode),
1111
+ Some(Provider::GeminiCli),
1112
1112
  )
1113
1113
  .unwrap();
1114
1114
  let written: serde_json::Value =