@team-agent/installer 0.5.127 → 0.5.128
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/Cargo.lock +1 -1
- package/Cargo.toml +1 -1
- package/README.md +11 -0
- package/crates/team-agent/src/cli/adapters.rs +3 -13
- package/crates/team-agent/src/cli/arguments.rs +4 -0
- package/crates/team-agent/src/cli/diagnose.rs +68 -22
- package/crates/team-agent/src/cli/emit.rs +58 -26
- package/crates/team-agent/src/cli/intent/runtime.rs +32 -5
- package/crates/team-agent/src/cli/intent/runtime_tests.rs +102 -11
- package/crates/team-agent/src/cli/intent/tests.rs +10 -12
- package/crates/team-agent/src/cli/intent.rs +1 -1
- package/crates/team-agent/src/cli/mod.rs +25 -8
- package/crates/team-agent/src/cli/models.rs +764 -7
- package/crates/team-agent/src/cli/schedule.rs +175 -0
- package/crates/team-agent/src/cli/send/persist.rs +0 -36
- package/crates/team-agent/src/cli/send/presentation.rs +1 -1
- package/crates/team-agent/src/cli/send.rs +108 -110
- package/crates/team-agent/src/cli/spec.rs +6 -0
- package/crates/team-agent/src/cli/status_port/brief.rs +5 -67
- package/crates/team-agent/src/cli/tests/leader_watch.rs +12 -62
- package/crates/team-agent/src/cli/tests/mod.rs +1 -1
- package/crates/team-agent/src/cli/tests/named_address.rs +11 -10
- package/crates/team-agent/src/cli/tests/run_delegation.rs +9 -6
- package/crates/team-agent/src/cli/tests/status_send.rs +68 -271
- package/crates/team-agent/src/compiler/tests.rs +3 -18
- package/crates/team-agent/src/compiler.rs +205 -6
- package/crates/team-agent/src/contract_runtime/backend.rs +145 -11
- package/crates/team-agent/src/contract_runtime/commands.rs +7 -7
- package/crates/team-agent/src/contract_runtime/config.rs +26 -16
- package/crates/team-agent/src/contract_runtime/config_tests.rs +24 -4
- package/crates/team-agent/src/contract_runtime/discovery.rs +12 -1
- package/crates/team-agent/src/contract_runtime/fork.rs +3 -10
- package/crates/team-agent/src/contract_runtime/framework.rs +28 -11
- package/crates/team-agent/src/contract_runtime/mcp.rs +19 -24
- package/crates/team-agent/src/contract_runtime/prompt.rs +2 -2
- package/crates/team-agent/src/contract_runtime/registry.rs +56 -92
- package/crates/team-agent/src/coordinator/steps/abnormal.rs +11 -11
- package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +16 -54
- package/crates/team-agent/src/coordinator/tests/health_sync.rs +42 -0
- package/crates/team-agent/src/coordinator/tick.rs +1 -89
- package/crates/team-agent/src/db/message_store.rs +7 -65
- package/crates/team-agent/src/direct_delivery.rs +368 -0
- package/crates/team-agent/src/inbox_store.rs +169 -0
- package/crates/team-agent/src/leader/registry.rs +5 -0
- package/crates/team-agent/src/leader/start.rs +2 -1
- package/crates/team-agent/src/leader/tests/lease_api.rs +2 -2
- package/crates/team-agent/src/leader/tests/prompt_contract.rs +1 -0
- package/crates/team-agent/src/lib.rs +2 -0
- package/crates/team-agent/src/lifecycle/launch/add_agent.rs +33 -0
- package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +206 -1
- package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +28 -2
- package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +38 -13
- package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +87 -6
- package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +9 -1
- package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +351 -81
- package/crates/team-agent/src/lifecycle/launch/pi_mcp_extension.js +3 -4
- package/crates/team-agent/src/lifecycle/launch/quick_start.rs +24 -0
- package/crates/team-agent/src/lifecycle/launch/spawn.rs +36 -13
- package/crates/team-agent/src/lifecycle/launch.rs +24 -1
- package/crates/team-agent/src/lifecycle/profile_launch.rs +321 -11
- package/crates/team-agent/src/lifecycle/restart/agent.rs +1 -0
- package/crates/team-agent/src/lifecycle/restart/avatar.rs +1798 -0
- package/crates/team-agent/src/lifecycle/restart/claude_fork.rs +163 -0
- package/crates/team-agent/src/lifecycle/restart/common.rs +345 -35
- package/crates/team-agent/src/lifecycle/restart/selection.rs +5 -5
- package/crates/team-agent/src/lifecycle/restart.rs +4 -0
- package/crates/team-agent/src/lifecycle/role_config.rs +39 -14
- package/crates/team-agent/src/lifecycle/tests/claude_compatible_config_red.rs +325 -0
- package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +320 -8
- package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +236 -13
- package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +378 -4
- package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +5 -4
- package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +7 -11
- package/crates/team-agent/src/lifecycle/tests/core.rs +47 -18
- package/crates/team-agent/src/lifecycle/tests/fixtures/pi_native_mcp_host.mjs +2 -1
- package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +14 -14
- package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +60 -20
- package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +28 -26
- package/crates/team-agent/src/lifecycle/tests/mcp_tool_name_format_red.rs +6 -6
- package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +18 -6
- package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +70 -52
- package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +210 -0
- package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +157 -4
- package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +526 -10
- package/crates/team-agent/src/lifecycle/tests/pi_fork_session_inheritance_red.rs +1419 -0
- package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +68 -1
- package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +34 -12
- package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +94 -2
- package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +10 -11
- package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +2 -2
- package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +254 -2
- package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +4 -4
- package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +5 -6
- package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +16 -7
- package/crates/team-agent/src/lifecycle/tests.rs +3 -0
- package/crates/team-agent/src/lifecycle/types.rs +18 -2
- package/crates/team-agent/src/lifecycle/worker_command_context.rs +43 -50
- package/crates/team-agent/src/mcp_server/readiness.rs +130 -149
- package/crates/team-agent/src/mcp_server/readiness_tests.rs +98 -119
- package/crates/team-agent/src/mcp_server/tests/scoped.rs +21 -31
- package/crates/team-agent/src/mcp_server/tests/send.rs +72 -107
- package/crates/team-agent/src/mcp_server/tests/tools.rs +10 -12
- package/crates/team-agent/src/mcp_server/tools.rs +70 -196
- package/crates/team-agent/src/messaging/delivery.rs +160 -218
- package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +5 -5
- package/crates/team-agent/src/messaging/helpers.rs +1 -19
- package/crates/team-agent/src/messaging/mod.rs +1 -0
- package/crates/team-agent/src/messaging/reminders.rs +316 -0
- package/crates/team-agent/src/messaging/scheduler.rs +7 -1
- package/crates/team-agent/src/messaging/tests/dup_inject.rs +191 -85
- package/crates/team-agent/src/messaging/tests/runtime.rs +4 -110
- package/crates/team-agent/src/messaging/tests/spine.rs +40 -24
- package/crates/team-agent/src/messaging/types.rs +1 -0
- package/crates/team-agent/src/provider/adapter.rs +303 -51
- package/crates/team-agent/src/provider/adapters/claude.rs +78 -0
- package/crates/team-agent/src/provider/adapters/claude_fork.rs +131 -0
- package/crates/team-agent/src/provider/adapters/mod.rs +7 -5
- package/crates/team-agent/src/provider/adapters/pi.rs +106 -0
- package/crates/team-agent/src/provider/classify.rs +1 -66
- package/crates/team-agent/src/provider/model_catalog.rs +201 -13
- package/crates/team-agent/src/provider/session/capture.rs +106 -6
- package/crates/team-agent/src/provider/session/context_fork/claude.rs +123 -0
- package/crates/team-agent/src/provider/session/context_fork/outcome.rs +4 -0
- package/crates/team-agent/src/provider/session/context_fork.rs +150 -18
- package/crates/team-agent/src/provider/session_scan/claude.rs +523 -0
- package/crates/team-agent/src/provider/session_scan/common.rs +44 -8
- package/crates/team-agent/src/provider/session_scan/pi.rs +34 -1
- package/crates/team-agent/src/provider/session_scan.rs +16 -6
- package/crates/team-agent/src/provider/tests/adapter.rs +104 -17
- package/crates/team-agent/src/provider/tests/classify.rs +0 -53
- package/crates/team-agent/src/provider/tests/command_helpers.rs +12 -3
- package/crates/team-agent/src/provider/tests/idle.rs +37 -0
- package/crates/team-agent/src/provider/wire.rs +22 -34
- package/crates/team-agent/src/state/abnormal_watch/tests/mod.rs +1 -1
- package/crates/team-agent/src/state/persist.rs +6 -6
- package/crates/team-agent/src/state/projection.rs +1 -1
- package/crates/team-agent/src/state/repository/tests.rs +2 -2
- package/crates/team-agent/src/test_support/models_timeout_fixture.rs +144 -0
- package/crates/team-agent/src/tmux_backend/tests.rs +0 -151
- package/crates/team-agent/src/tmux_backend.rs +5 -40
- package/package.json +4 -4
- package/skills/team-agent/SKILL.md +5 -7
- package/skills/team-agent/command-coverage.json +1 -1
- package/skills/team-agent/docs/reference/team-agent-operator.md +3 -3
- package/skills/team-agent/references/team-agent-operator.md +3 -3
|
@@ -20,9 +20,7 @@
|
|
|
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 (
|
|
24
|
-
//! seat fork through a backing shim; that runtime is gone, so they left with it.
|
|
25
|
-
//! Original charter: a
|
|
23
|
+
//! - **R7 permission-clamp GUARDRAIL (naturally-green, not a RED, per L1 r2)**: a
|
|
26
24
|
//! fork's effective approval policy must be derived from the LEADER
|
|
27
25
|
//! (`source=leader_process`, `worker_capability_above_leader=false`), never a
|
|
28
26
|
//! raw clone of a source-declared capability above the leader (MUST-16).
|
|
@@ -47,7 +45,7 @@
|
|
|
47
45
|
|
|
48
46
|
use std::collections::BTreeMap;
|
|
49
47
|
use std::path::{Path, PathBuf};
|
|
50
|
-
use std::process::Command;
|
|
48
|
+
use std::process::{Command, Output};
|
|
51
49
|
use std::sync::Mutex;
|
|
52
50
|
|
|
53
51
|
use serde_json::{json, Value};
|
|
@@ -69,9 +67,19 @@ use hermetic_guard::HermeticTestEnv;
|
|
|
69
67
|
const TEAM_NAME: &str = "cf-batch4";
|
|
70
68
|
const SOURCE: &str = "cp_worker";
|
|
71
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
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
|
+
);
|
|
75
83
|
const R8_TEST: &str = concat!(
|
|
76
84
|
"lifecycle::tests::clone_fork_copilot_perms_red::",
|
|
77
85
|
"r8_copilot_fork_is_no_longer_capability_refused"
|
|
@@ -121,6 +129,247 @@ fn copilot_clone_fork_env_fixtures_run_outside_parent_process() {
|
|
|
121
129
|
});
|
|
122
130
|
}
|
|
123
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
|
+
|
|
124
373
|
/// Copilot team docs for the library-entry R8 (a separate agents dir so the
|
|
125
374
|
/// OfflineTransport quick-start compiles a copilot source).
|
|
126
375
|
fn write_copilot_team_docs(workspace: &Path) -> PathBuf {
|
|
@@ -197,6 +446,43 @@ fn seed_source_tuple_in_state(workspace: &Path, agent: &str) {
|
|
|
197
446
|
save_runtime_state(workspace, &state).expect("save seeded state");
|
|
198
447
|
}
|
|
199
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
|
+
|
|
200
486
|
/// R8 Copilot fork caps RE-CHARTER — a Copilot fork must no longer be refused by a
|
|
201
487
|
/// blanket capability gate (§1.4 proves the directory-copy + SQLite-transaction
|
|
202
488
|
/// primitive is feasible under an isolated COPILOT_HOME). Baseline red: the fork
|
|
@@ -259,6 +545,94 @@ fn r8_copilot_fork_is_no_longer_capability_refused() {
|
|
|
259
545
|
});
|
|
260
546
|
}
|
|
261
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
|
+
|
|
262
636
|
// ---------------------------------------------------------------------------
|
|
263
637
|
// Minimal in-process Transport for the R8 library-entry test (mirrors the
|
|
264
638
|
// RecordingTransport the existing copilot refusal contract uses). Kept local so
|
|
@@ -77,8 +77,9 @@ fn t06_each_official_mode_selects_one_runtime_contract_in_real_spawn_prompt() {
|
|
|
77
77
|
assert!(
|
|
78
78
|
prompt.contains(&format!("ROLE BODY SENTINEL {id}"))
|
|
79
79
|
&& prompt.contains("Team Agent Teammate Runtime Contract")
|
|
80
|
-
&& prompt.contains("
|
|
81
|
-
|
|
80
|
+
&& prompt.contains("send_message exclusively for findings")
|
|
81
|
+
&& !prompt.contains("report_result"),
|
|
82
|
+
"T06/{id}: mode selection must preserve persona body and the send_message-only communication contract"
|
|
82
83
|
);
|
|
83
84
|
}
|
|
84
85
|
}
|
|
@@ -167,11 +168,11 @@ fn t07_final_spawn_prompt_does_not_leak_leader_centric_obligations_into_orchestr
|
|
|
167
168
|
for required in [
|
|
168
169
|
"All communication must go through Team Agent MCP tools.",
|
|
169
170
|
"Do not reply to pure ACKs, greetings, or unchanged status notices",
|
|
170
|
-
"
|
|
171
|
+
"send_message exclusively for findings",
|
|
171
172
|
] {
|
|
172
173
|
assert!(
|
|
173
174
|
orchestrated.contains(required),
|
|
174
|
-
"T07/orchestrated positive control: removing unconditional duties must preserve common MCP,
|
|
175
|
+
"T07/orchestrated positive control: removing unconditional duties must preserve common MCP, silence, and send_message obligations; missing {required:?}; prompt={orchestrated:?}"
|
|
175
176
|
);
|
|
176
177
|
}
|
|
177
178
|
|
|
@@ -348,7 +348,7 @@ with the identity section FIRST; head={:?}",
|
|
|
348
348
|
for marker in [
|
|
349
349
|
"# Team Agent Teammate Runtime Contract",
|
|
350
350
|
"COPILOT ROLE BODY SENTINEL",
|
|
351
|
-
"
|
|
351
|
+
"exclusively for findings, progress, questions, and completion updates",
|
|
352
352
|
] {
|
|
353
353
|
if !agents_md.contains(marker) {
|
|
354
354
|
failures.push(format!(
|
|
@@ -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::
|
|
1104
|
+
let config = team_agent::provider::get_adapter(Provider::ClaudeCode)
|
|
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::
|
|
1111
|
+
Some(Provider::ClaudeCode),
|
|
1112
1112
|
)
|
|
1113
1113
|
.unwrap();
|
|
1114
1114
|
let written: serde_json::Value =
|
|
@@ -2028,12 +2028,8 @@ fn copilot_tmp_pid_from_name(name: &str) -> Option<u32> {
|
|
|
2028
2028
|
}
|
|
2029
2029
|
|
|
2030
2030
|
fn pid_is_live(pid: u32) -> bool {
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
.stderr(Stdio::null())
|
|
2036
|
-
.status()
|
|
2037
|
-
.map(|status| status.success())
|
|
2038
|
-
.unwrap_or(false)
|
|
2031
|
+
!matches!(
|
|
2032
|
+
crate::platform::process::pid_liveness(pid),
|
|
2033
|
+
Ok(crate::platform::process::ProcessLiveness::Dead)
|
|
2034
|
+
)
|
|
2039
2035
|
}
|
|
@@ -231,11 +231,11 @@ fn start_mode_serde_names_match_python_start_mode_strings() {
|
|
|
231
231
|
|
|
232
232
|
// ───────────────────────────────────────────────────────────────────────
|
|
233
233
|
// decide_start_mode — bug-085 四象限 + E20 #264 gap closure.
|
|
234
|
-
// copilot sess backing-present any-fresh -> resumed
|
|
235
|
-
// copilot sess backing-MISSING !allow_fresh -> noop/refuse (绝不静默 resume 死 session)
|
|
236
|
-
// copilot sess backing-MISSING allow_fresh -> fresh_after_missing_rollout
|
|
237
|
-
// copilot no-sess any -> fresh
|
|
238
|
-
// non-resumable (fake/gemini_cli/retired
|
|
234
|
+
// claude/copilot sess backing-present any-fresh -> resumed
|
|
235
|
+
// claude/copilot sess backing-MISSING !allow_fresh -> noop/refuse (绝不静默 resume 死 session)
|
|
236
|
+
// claude/copilot sess backing-MISSING allow_fresh -> fresh_after_missing_rollout
|
|
237
|
+
// claude/copilot no-sess any -> fresh
|
|
238
|
+
// non-resumable (fake/gemini_cli/retired codex/grok rows) sess -> noop 或 fresh_after_missing_rollout
|
|
239
239
|
// 这是 bug-085 把 start_mode 分类从 start_agent 的 lock+spawn 全路径剥离出来的命门。
|
|
240
240
|
// ───────────────────────────────────────────────────────────────────────
|
|
241
241
|
|
|
@@ -305,10 +305,39 @@ fn decide_start_mode_no_session_is_fresh() {
|
|
|
305
305
|
);
|
|
306
306
|
}
|
|
307
307
|
|
|
308
|
+
#[test]
|
|
309
|
+
fn decide_start_mode_checks_backing_for_all_resumable_providers() {
|
|
310
|
+
for provider in ["claude", "claude_code", "copilot"] {
|
|
311
|
+
assert_eq!(
|
|
312
|
+
decide_start_mode(provider, Some(&sid("s1")), None, false, true),
|
|
313
|
+
StartMode::FreshAfterMissingRollout,
|
|
314
|
+
"{provider} missing backing + allow_fresh must not resume"
|
|
315
|
+
);
|
|
316
|
+
assert_eq!(
|
|
317
|
+
decide_start_mode(provider, Some(&sid("s1")), None, false, false),
|
|
318
|
+
StartMode::Noop,
|
|
319
|
+
"{provider} missing backing + !allow_fresh must refuse"
|
|
320
|
+
);
|
|
321
|
+
assert_eq!(
|
|
322
|
+
decide_start_mode(provider, Some(&sid("s1")), Some(&rp("/r")), true, false),
|
|
323
|
+
StartMode::Resumed,
|
|
324
|
+
"{provider} existing backing remains resumable"
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
assert_eq!(
|
|
328
|
+
decide_start_mode("claude", None, None, false, true),
|
|
329
|
+
StartMode::Fresh
|
|
330
|
+
);
|
|
331
|
+
assert_eq!(
|
|
332
|
+
decide_start_mode("copilot", None, None, false, false),
|
|
333
|
+
StartMode::Fresh
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
|
|
308
337
|
#[test]
|
|
309
338
|
fn decide_start_mode_refuses_session_id_for_nonresumable_providers() {
|
|
310
|
-
// A persisted legacy
|
|
311
|
-
for provider in ["fake", "gemini_cli", "
|
|
339
|
+
// A persisted legacy Codex / Grok worker row is no longer resumable.
|
|
340
|
+
for provider in ["fake", "gemini_cli", "codex", "grok"] {
|
|
312
341
|
assert_eq!(
|
|
313
342
|
decide_start_mode(provider, Some(&sid("s1")), None, true, false),
|
|
314
343
|
StartMode::Noop,
|
|
@@ -359,7 +388,7 @@ fn classify_restart_plan_interacted_unresumable_no_allow_fresh_yields_refuse() {
|
|
|
359
388
|
"session_name": "team-a",
|
|
360
389
|
"agents": {
|
|
361
390
|
"w1": {
|
|
362
|
-
"provider": "
|
|
391
|
+
"provider": "claude",
|
|
363
392
|
"first_send_at": "2026-05-27T10:00:00+00:00",
|
|
364
393
|
"session_id": null
|
|
365
394
|
}
|
|
@@ -412,7 +441,7 @@ fn classify_restart_plan_interacted_unresumable_with_allow_fresh_yields_fresh_st
|
|
|
412
441
|
let state = json!({
|
|
413
442
|
"agents": {
|
|
414
443
|
"w1": {
|
|
415
|
-
"provider": "
|
|
444
|
+
"provider": "claude",
|
|
416
445
|
"first_send_at": "2026-05-27T10:00:00+00:00",
|
|
417
446
|
"session_id": null
|
|
418
447
|
}
|
|
@@ -442,7 +471,7 @@ fn classify_restart_plan_never_captured_null_session_auto_fresh_partial_resume()
|
|
|
442
471
|
// not captured" bug state) — see the OTHER refuse-interacted test below
|
|
443
472
|
// and upgrade_restart_refuses_interacted_worker_without_session_id.
|
|
444
473
|
let state = json!({
|
|
445
|
-
"agents": { "w1": { "provider": "
|
|
474
|
+
"agents": { "w1": { "provider": "claude", "session_id": null } }
|
|
446
475
|
});
|
|
447
476
|
let plan = classify_restart_plan(&state, false).expect("纯验证不应 Err");
|
|
448
477
|
assert_eq!(plan.decisions.len(), 1);
|
|
@@ -468,7 +497,7 @@ fn restart_required_missing_skips_never_captured_workers() {
|
|
|
468
497
|
use crate::lifecycle::restart::restart_required_missing_session_agent_ids;
|
|
469
498
|
let state = json!({
|
|
470
499
|
"agents": {
|
|
471
|
-
"w1": { "provider": "
|
|
500
|
+
"w1": { "provider": "claude", "session_id": null, "status": "running" }
|
|
472
501
|
}
|
|
473
502
|
});
|
|
474
503
|
let missing = restart_required_missing_session_agent_ids(&state);
|
|
@@ -488,7 +517,7 @@ fn restart_required_missing_keeps_null_session_with_first_send_at() {
|
|
|
488
517
|
let state = json!({
|
|
489
518
|
"agents": {
|
|
490
519
|
"w1": {
|
|
491
|
-
"provider": "
|
|
520
|
+
"provider": "claude",
|
|
492
521
|
"session_id": null,
|
|
493
522
|
"status": "running",
|
|
494
523
|
"spawn_cwd": "/tmp/ws",
|
|
@@ -514,7 +543,7 @@ fn restart_required_missing_keeps_null_session_with_last_result_at() {
|
|
|
514
543
|
let state = json!({
|
|
515
544
|
"agents": {
|
|
516
545
|
"w1": {
|
|
517
|
-
"provider": "
|
|
546
|
+
"provider": "claude",
|
|
518
547
|
"session_id": null,
|
|
519
548
|
"status": "running",
|
|
520
549
|
"spawn_cwd": "/tmp/ws",
|
|
@@ -540,7 +569,7 @@ fn classify_restart_plan_null_session_with_last_result_at_refuses_without_allow_
|
|
|
540
569
|
let state = json!({
|
|
541
570
|
"agents": {
|
|
542
571
|
"w1": {
|
|
543
|
-
"provider": "
|
|
572
|
+
"provider": "claude",
|
|
544
573
|
"session_id": null,
|
|
545
574
|
"last_result_at": "2026-01-01T00:00:00+00:00",
|
|
546
575
|
}
|
|
@@ -561,7 +590,7 @@ fn classify_restart_plan_null_session_with_last_result_at_refuses_without_allow_
|
|
|
561
590
|
fn classify_restart_plan_never_interacted_null_session_with_allow_fresh_marks_forced_fresh() {
|
|
562
591
|
// E6 层2: 同上自启动 null-session worker,但显式 --allow-fresh → 用户主动认账丢上下文 → FreshStart。
|
|
563
592
|
let state = json!({
|
|
564
|
-
"agents": { "w1": { "provider": "
|
|
593
|
+
"agents": { "w1": { "provider": "claude", "session_id": null } }
|
|
565
594
|
});
|
|
566
595
|
let plan = classify_restart_plan(&state, true).expect("纯验证不应 Err");
|
|
567
596
|
assert_eq!(plan.decisions.len(), 1);
|
|
@@ -723,9 +752,9 @@ fn classify_restart_plan_produces_corrupt_entries_with_python_type_names() {
|
|
|
723
752
|
// ("str"/"int"/"list") —— 锁跨语言 type-name 映射,不是手设字段。
|
|
724
753
|
let state = json!({
|
|
725
754
|
"agents": {
|
|
726
|
-
"w_str": { "provider": "
|
|
727
|
-
"w_int": { "provider": "
|
|
728
|
-
"w_list": { "provider": "
|
|
755
|
+
"w_str": { "provider": "claude", "first_send_at": "" },
|
|
756
|
+
"w_int": { "provider": "claude", "first_send_at": 0 },
|
|
757
|
+
"w_list": { "provider": "claude", "first_send_at": [] }
|
|
729
758
|
}
|
|
730
759
|
});
|
|
731
760
|
// corrupt 非空 → restart 在 teardown 之前 hard refuse(决策前)。
|
|
@@ -65,7 +65,8 @@ const beforeAgentStart = handlers.get("before_agent_start")?.[0];
|
|
|
65
65
|
if (typeof beforeAgentStart !== "function") throw new Error("generated wrapper omitted before_agent_start wire binding");
|
|
66
66
|
const binding = await beforeAgentStart({ systemPrompt: "N1 fixture" }, context);
|
|
67
67
|
const wirePrompt = binding?.systemPrompt;
|
|
68
|
-
|
|
68
|
+
const communicationTools = expectedTools.filter((name) => !name.endsWith("__report_result"));
|
|
69
|
+
if (typeof wirePrompt !== "string" || !communicationTools.every((name) => wirePrompt.includes(name)) || wirePrompt.includes("report_result")) {
|
|
69
70
|
throw new Error(`native Team tool wire binding is incomplete: ${wirePrompt}`);
|
|
70
71
|
}
|
|
71
72
|
await writeFile(receiptPath, `${JSON.stringify({ registrations, unregistrations, activeTools: pi.getActiveTools(), expectedTools, wirePrompt }, null, 2)}\n`, "utf8");
|