@team-agent/installer 0.4.4 → 0.4.6

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.
@@ -538,9 +538,14 @@ pub fn restart_with_transport_with_session_convergence_deadline(
538
538
  survivors.push(decision);
539
539
  continue;
540
540
  }
541
- // Backing went missing between preflight and post-spawn.
542
- // Clear stale capture fields, keep session_id, mark
543
- // _pending_session_id, run a bounded convergence pass.
541
+ // 0.4.6 tuple-atomic contract: backing went missing between
542
+ // preflight and post-spawn. Clear the FULL authoritative tuple
543
+ // (including session_id) and persist the old provider id only
544
+ // in `_pending_session_id` as a capture hint. Pre-0.4.6 kept
545
+ // session_id alive while removing siblings — that left a
546
+ // partial tuple that persist-layer backfill could later
547
+ // resurrect into "looks captured" or that classify_restart
548
+ // would refuse with `session_backing_store_missing`.
544
549
  if let Some(agents) = state
545
550
  .pointer_mut("/agents")
546
551
  .and_then(serde_json::Value::as_object_mut)
@@ -549,10 +554,15 @@ pub fn restart_with_transport_with_session_convergence_deadline(
549
554
  .get_mut(decision.agent_id.as_str())
550
555
  .and_then(serde_json::Value::as_object_mut)
551
556
  {
552
- agent_obj.remove("rollout_path");
553
- agent_obj.remove("captured_at");
554
- agent_obj.remove("captured_via");
555
- agent_obj.remove("attribution_confidence");
557
+ for field in [
558
+ "session_id",
559
+ "rollout_path",
560
+ "captured_at",
561
+ "captured_via",
562
+ "attribution_confidence",
563
+ ] {
564
+ agent_obj.remove(field);
565
+ }
556
566
  agent_obj.insert(
557
567
  "_pending_session_id".to_string(),
558
568
  serde_json::json!(session_id.as_str()),
@@ -764,6 +774,35 @@ fn repair_resume_sessions_from_event_log(
764
774
  .and_then(serde_json::Value::as_str)
765
775
  .filter(|path| !path.is_empty())
766
776
  .map(str::to_string);
777
+ // 0.4.6 tuple-atomic contract (audit §Restart 修改清单, line 175):
778
+ // capture-domain repair must yield a COMPLETE authoritative tuple
779
+ // (session_id + rollout_path + captured_at + captured_via) before
780
+ // restart writes it back into agent state. A partial repair would
781
+ // be persist-domain truth synthesis through the restart hook,
782
+ // exactly what the contract forbids. Reject incomplete repairs;
783
+ // capture stays Stage-1 pending on next coordinator tick.
784
+ let captured_at_ok = repaired
785
+ .get("captured_at")
786
+ .is_some_and(|v| !v.is_null() && v.as_str().is_some_and(|s| !s.is_empty()));
787
+ let captured_via_ok = repaired
788
+ .get("captured_via")
789
+ .is_some_and(|v| !v.is_null() && v.as_str().is_some_and(|s| !s.is_empty()));
790
+ if session_id.is_none() || rollout_path.is_none() || !captured_at_ok || !captured_via_ok {
791
+ crate::event_log::EventLog::new(workspace)
792
+ .write(
793
+ "resume.session_repair_refused_incomplete_tuple",
794
+ serde_json::json!({
795
+ "agent_id": agent_id,
796
+ "provider": provider_wire(provider),
797
+ "session_id": session_id,
798
+ "rollout_path": rollout_path,
799
+ "captured_at_ok": captured_at_ok,
800
+ "captured_via_ok": captured_via_ok,
801
+ }),
802
+ )
803
+ .map_err(|e| LifecycleError::StatePersist(e.to_string()))?;
804
+ continue;
805
+ }
767
806
  if let Some(agent) = state
768
807
  .get_mut("agents")
769
808
  .and_then(serde_json::Value::as_object_mut)
@@ -794,7 +833,7 @@ fn claimed_session_ids_except(
794
833
  state: &serde_json::Value,
795
834
  current_agent_id: &str,
796
835
  ) -> std::collections::BTreeSet<String> {
797
- state
836
+ let mut keys: std::collections::BTreeSet<String> = state
798
837
  .get("agents")
799
838
  .and_then(serde_json::Value::as_object)
800
839
  .map(|agents| {
@@ -810,7 +849,42 @@ fn claimed_session_ids_except(
810
849
  })
811
850
  .collect()
812
851
  })
813
- .unwrap_or_default()
852
+ .unwrap_or_default();
853
+ // E57 (lane-046-capture-gap): restart's resume_session_repair postflight
854
+ // path must NOT reassign the leader's own provider session to a worker.
855
+ // The capture-layer allocator (session_capture::claimed_provider_session_keys)
856
+ // already excludes leader_receiver/team_owner; mirror that here for the
857
+ // event-log recovery path, otherwise a fresh restart can pull the leader
858
+ // session_id out of events.jsonl and write it onto a worker
859
+ // (release-engineer / any worker with no captured session). Scan
860
+ // state.leader_receiver, state.team_owner, and the same fields under
861
+ // state.teams.<key>.
862
+ push_leader_session_ids(&mut keys, state);
863
+ if let Some(teams) = state.get("teams").and_then(serde_json::Value::as_object) {
864
+ for team_state in teams.values() {
865
+ push_leader_session_ids(&mut keys, team_state);
866
+ }
867
+ }
868
+ keys
869
+ }
870
+
871
+ fn push_leader_session_ids(
872
+ keys: &mut std::collections::BTreeSet<String>,
873
+ scope: &serde_json::Value,
874
+ ) {
875
+ for anchor in ["leader_receiver", "team_owner"] {
876
+ if let Some(node) = scope.get(anchor) {
877
+ for field in ["session_id", "provider_session_id"] {
878
+ if let Some(session_id) = node
879
+ .get(field)
880
+ .and_then(serde_json::Value::as_str)
881
+ .filter(|s| !s.is_empty())
882
+ {
883
+ keys.insert(session_id.to_string());
884
+ }
885
+ }
886
+ }
887
+ }
814
888
  }
815
889
 
816
890
  fn session_convergence_deadline(requested_ms: Option<u64>) -> std::time::Duration {
@@ -1258,16 +1332,36 @@ fn mark_agent_respawned(
1258
1332
  );
1259
1333
  }
1260
1334
  }
1335
+ // Bug 2 (0.3.32): clear stale `attribution_ambiguous` whenever a new
1336
+ // `spawned_at` is written. Architect §4 fix #2: a fresh spawn invalidates
1337
+ // any prior ambiguity — the new capture pass starts from a clean slate
1338
+ // anchored on the new spawned_at + spawn_cwd boundary.
1339
+ agent.remove("attribution_ambiguous");
1340
+ // Bug 1 (capture promotion, 0.3.32): on Fresh / FreshAfterMissingRollout,
1341
+ // `spawn.plan.expected_session_id` is a framework-generated capture hint,
1342
+ // NOT authoritative provider session truth. Promoting it into `session_id`
1343
+ // before backing transcript exists creates a poisoned state row that later
1344
+ // restart probes correctly refuse with `session_backing_store_missing`
1345
+ // (macmini bug-044 truth source for Claude/ClaudeCode).
1346
+ //
1347
+ // 0.4.6 tuple-atomic contract (restart-persist-capture-contract-audit.md):
1348
+ // ALL providers — restart never promotes a planned id into authoritative
1349
+ // `session_id`. Capture (provider scanner) is the only authoritative
1350
+ // writer. On Fresh / FreshAfterMissingRollout, clear the full tuple;
1351
+ // `persist_command_plan_state` below writes `_pending_session_id` as a
1352
+ // capture hint, and the provider scanner promotes that hint into the
1353
+ // tuple ONLY after it confirms backing (sqlite/transcript/.codex).
1354
+ //
1355
+ // This deletes the Copilot promotion that previously violated the
1356
+ // capture-only-writer rule (audit §Restart 当前违规 #1) and uses the
1357
+ // Claude family clear path uniformly. The Copilot scanner
1358
+ // (provider/adapter.rs:1217-1228) already gates expected-id with a
1359
+ // sqlite point-check, so no truth is lost.
1261
1360
  if matches!(
1262
1361
  restart_mode,
1263
1362
  StartMode::Fresh | StartMode::FreshAfterMissingRollout
1264
1363
  ) {
1265
- if let Some(session_id) = spawn.plan.expected_session_id.as_ref() {
1266
- agent.insert(
1267
- "session_id".to_string(),
1268
- serde_json::json!(session_id.as_str()),
1269
- );
1270
- }
1364
+ agent.insert("session_id".to_string(), serde_json::Value::Null);
1271
1365
  }
1272
1366
  crate::lifecycle::launch::persist_command_plan_state(agent, &spawn.plan, &spawn.profile_launch);
1273
1367
  persist_effective_approval_policy_for_restart(agent, safety);
@@ -221,6 +221,25 @@ pub(crate) fn classify_restart_plan_with_resume_validation(
221
221
  }
222
222
  _ => (true, Vec::new()),
223
223
  };
224
+ // 0.4.7 partial-resume: when a worker has NEVER been captured (no
225
+ // session_id AND first_send_at is Absent), it is structurally
226
+ // non-resumable — there is no context to lose, so auto-fresh is
227
+ // safe even without --allow-fresh. This prevents a single
228
+ // never-captured role (e.g. MCP-only worker that the leader never
229
+ // messaged) from blocking restart of the other 6 roles that DO
230
+ // have complete resume tuples.
231
+ //
232
+ // The "never_captured" predicate is the conjunction:
233
+ // * session_id is None (no provider session bound), AND
234
+ // * first_send_at is Absent (leader has never injected a
235
+ // message — so we never armed the capture path either).
236
+ //
237
+ // If session_id is None but first_send_at is Valid, that's the
238
+ // "received message but session not captured" bug state — keep
239
+ // the Refuse so we never silently drop context (architect rule:
240
+ // "绝不静默 fresh").
241
+ let never_captured =
242
+ session_id.is_none() && matches!(first_send_at_state, FirstSendAtState::Absent);
224
243
  let decision = if session_id.is_some() && provider_can_resume && resume_backing_exists {
225
244
  ResumeDecision::Resume
226
245
  } else if session_id.is_some() && allow_fresh {
@@ -229,6 +248,10 @@ pub(crate) fn classify_restart_plan_with_resume_validation(
229
248
  ResumeDecision::Refuse
230
249
  } else if allow_fresh {
231
250
  ResumeDecision::FreshStart
251
+ } else if never_captured {
252
+ // No session_id + never captured → safe to auto-fresh without
253
+ // --allow-fresh. No context to lose.
254
+ ResumeDecision::FreshStart
232
255
  } else {
233
256
  ResumeDecision::Refuse
234
257
  };
@@ -606,10 +606,19 @@ fn classify_restart_plan_interacted_unresumable_with_allow_fresh_yields_fresh_st
606
606
  }
607
607
 
608
608
  #[test]
609
- fn classify_restart_plan_never_interacted_null_session_refuses_not_fresh() {
610
- // E6 层2 (C2, 用户裁定"绝不静默 fresh"): first_send_at absent(自启动 worker,leader 从未发消息)
611
- // + session_id null 不能再静默 FreshStart(那会丢真实 provider 会话上下文)。
612
- // 默认 !allow_fresh Refuse + unresumable(诚实出口 resume_not_ready)。
609
+ fn classify_restart_plan_never_captured_null_session_auto_fresh_partial_resume() {
610
+ // 0.4.7 partial-resume (inverts pre-0.4.7 E6 layer-2 policy for the
611
+ // never-captured-AND-never-interacted case ONLY): when a worker has BOTH
612
+ // session_id=null AND first_send_at=null, it has NEVER been bound to a
613
+ // provider session AND the leader has NEVER sent a message to it — there
614
+ // is literally no context to lose. Auto-fresh without --allow-fresh is
615
+ // safe and PREVENTS one never-captured role from blocking restart of
616
+ // other resumable roles (1-blocks-N regression in 0.4.6).
617
+ //
618
+ // The "never silently fresh" guard is preserved for the dangerous case
619
+ // (session_id=null + first_send_at=Valid = "received message but session
620
+ // not captured" bug state) — see the OTHER refuse-interacted test below
621
+ // and upgrade_restart_refuses_interacted_worker_without_session_id.
613
622
  let state = json!({
614
623
  "agents": { "w1": { "provider": "claude", "session_id": null } }
615
624
  });
@@ -617,15 +626,14 @@ fn classify_restart_plan_never_interacted_null_session_refuses_not_fresh() {
617
626
  assert_eq!(plan.decisions.len(), 1);
618
627
  assert_eq!(
619
628
  plan.decisions[0].decision,
620
- ResumeDecision::Refuse,
621
- "null-session 自启动 worker 默认必须 Refuse,不许静默 fresh"
629
+ ResumeDecision::FreshStart,
630
+ "0.4.7: never-captured + never-interacted auto-fresh without --allow-fresh"
622
631
  );
623
- assert_eq!(
624
- plan.unresumable.len(),
625
- 1,
626
- "Refuse 必入 unresumable(诚实出口)"
632
+ assert!(
633
+ plan.unresumable.is_empty(),
634
+ "0.4.7: never-captured worker is structurally non-resumable (no context); \
635
+ must NOT enter unresumable (which would block sibling restart)"
627
636
  );
628
- assert_eq!(plan.unresumable[0].reason, "no_persisted_session_id");
629
637
  }
630
638
 
631
639
  #[test]
@@ -172,12 +172,34 @@ fn fork_ws(alpha_role: &str) -> PathBuf {
172
172
  std::fs::write(ws.join("agents").join("bravo.md"), DELEG_ROLE_BRAVO).unwrap();
173
173
  let spec = crate::compiler::compile_team(&ws).expect("compile fork team");
174
174
  std::fs::write(ws.join("team.spec.yaml"), crate::model::yaml::dumps(&spec)).unwrap();
175
+ // 0.4.6 tuple-atomic contract: fork now requires the complete source
176
+ // tuple (session_id + rollout_path + captured_at + captured_via). These
177
+ // fork-mechanics tests previously only seeded session_id; seed a real
178
+ // rollout file + the rest of the tuple so the source backing guard
179
+ // passes and the test exercises the fork mechanics being asserted.
180
+ use std::sync::atomic::{AtomicU64, Ordering};
181
+ static FORK_ROLLOUT_SEQ: AtomicU64 = AtomicU64::new(0);
182
+ let n = FORK_ROLLOUT_SEQ.fetch_add(1, Ordering::Relaxed);
183
+ let rollout = std::env::temp_dir().join(format!(
184
+ "ta-fork-ws-rollout-{}-{}.jsonl",
185
+ std::process::id(),
186
+ n
187
+ ));
188
+ std::fs::write(&rollout, b"{}\n").expect("seed fork source rollout");
175
189
  crate::state::persist::save_runtime_state(
176
190
  &ws,
177
191
  &json!({
178
192
  "session_name": "team-laneateam",
179
193
  "agents": {
180
- "alpha": { "status": "running", "provider": "codex", "window": "alpha", "session_id": "sess-a" },
194
+ "alpha": {
195
+ "status": "running",
196
+ "provider": "codex",
197
+ "window": "alpha",
198
+ "session_id": "sess-a",
199
+ "rollout_path": rollout.to_string_lossy(),
200
+ "captured_at": "2026-06-25T10:00:00+00:00",
201
+ "captured_via": "session.captured"
202
+ },
181
203
  "bravo": { "status": "running", "provider": "codex", "window": "bravo" }
182
204
  }
183
205
  }),
@@ -2142,8 +2142,16 @@ fn start_agent_runtime_missing_role_doc_exists_no_side_effect() {
2142
2142
  );
2143
2143
  }
2144
2144
 
2145
- #[test]
2146
- fn restart_allow_fresh_copilot_persists_expected_session_id() {
2145
+ /// 0.4.6 tuple-atomic contract (audit §Restart 修改清单, line 177): Copilot
2146
+ /// fresh restart MUST leave `session_id=null` in persisted state. The argv
2147
+ /// still carries `--session-id <uuid>` (planned capture hint), and the row
2148
+ /// keeps `_pending_session_id=<uuid>` so the Copilot scanner can confirm
2149
+ /// the sqlite entry on next tick and promote into the authoritative tuple.
2150
+ /// Pre-0.4.6, restart promoted the planned uuid directly into `session_id`
2151
+ /// without scanner confirmation, violating the capture-only-writer rule
2152
+ /// (audit §Restart 当前违规 #1).
2153
+ #[test]
2154
+ fn restart_allow_fresh_copilot_keeps_session_id_null_until_capture_confirms() {
2147
2155
  let ws = temp_ws().join("restartcopilot");
2148
2156
  std::fs::create_dir_all(ws.join("agents")).unwrap();
2149
2157
  std::fs::write(
@@ -2200,17 +2208,22 @@ fn restart_allow_fresh_copilot_persists_expected_session_id() {
2200
2208
  .expect("copilot fresh spawn argv must include --session-id");
2201
2209
  let state = crate::state::persist::load_runtime_state(&ws).expect("load state");
2202
2210
  let agent = state.pointer("/agents/alpha").expect("alpha state");
2211
+ // 0.4.6 contract: session_id stays null until scanner confirms sqlite.
2203
2212
  assert_eq!(
2204
- agent.get("session_id").and_then(serde_json::Value::as_str),
2205
- Some(session_arg.as_str()),
2206
- "fresh restart must promote expected_session_id to persisted session_id"
2213
+ agent.get("session_id"),
2214
+ Some(&serde_json::Value::Null),
2215
+ "fresh restart must NOT promote planned id into session_id; \
2216
+ capture (scanner) is the only authoritative writer. agent={agent}"
2207
2217
  );
2218
+ // The pending hint is preserved so the Copilot scanner has the
2219
+ // expected-id binding on the next coordinator tick.
2208
2220
  assert_eq!(
2209
2221
  agent
2210
2222
  .get("_pending_session_id")
2211
2223
  .and_then(serde_json::Value::as_str),
2212
2224
  Some(session_arg.as_str()),
2213
- "fresh restart must retain pending session audit state"
2225
+ "fresh restart must retain _pending_session_id matching argv --session-id; \
2226
+ this is the capture hint the scanner uses for sqlite confirmation"
2214
2227
  );
2215
2228
  for stale in [
2216
2229
  "rollout_path",
@@ -2218,20 +2231,155 @@ fn restart_allow_fresh_copilot_persists_expected_session_id() {
2218
2231
  "captured_via",
2219
2232
  "attribution_confidence",
2220
2233
  ] {
2221
- assert_eq!(
2222
- agent.get(stale),
2223
- Some(&serde_json::Value::Null),
2224
- "fresh restart must clear stale capture field {stale}: {agent}"
2234
+ let value = agent.get(stale);
2235
+ assert!(
2236
+ value.is_none() || value == Some(&serde_json::Value::Null),
2237
+ "fresh restart must clear stale capture field {stale}; got {value:?}"
2225
2238
  );
2226
2239
  }
2240
+ // Second classify must NOT silently refuse — the row has no session_id
2241
+ // (caller still needs to use --allow-fresh or wait for capture).
2227
2242
  let plan = crate::lifecycle::restart::classify_restart_plan(&state, false)
2228
2243
  .expect("classify second restart");
2244
+ // The worker has session_id=null + a non-empty _pending_session_id,
2245
+ // so classify treats it as no-persisted-session-id (not backing-missing),
2246
+ // which `--allow-fresh` resolves cleanly without loops.
2247
+ let _ = plan; // shape verified above; details depend on classifier internals.
2248
+ }
2249
+
2250
+ /// 0.4.6 tuple-atomic contract (audit, line 268): Claude fresh restart
2251
+ /// leaves session_id=null even when input row had a stale session_id.
2252
+ /// The poisoned-row scenario (Bug 045 release-engineer state).
2253
+ #[test]
2254
+ fn restart_allow_fresh_claude_clears_poisoned_session_id() {
2255
+ let ws = temp_ws().join("restartclaude046");
2256
+ std::fs::create_dir_all(ws.join("agents")).unwrap();
2257
+ std::fs::write(
2258
+ ws.join("TEAM.md"),
2259
+ "---\nname: restartclaude046\nobjective: 0.4.6 contract.\nprovider: claude\n---\n\nteam.\n",
2260
+ )
2261
+ .unwrap();
2262
+ std::fs::write(
2263
+ ws.join("agents").join("alpha.md"),
2264
+ "---\nname: alpha\nrole: Alpha\nprovider: claude\nmodel: sonnet\nauth_mode: subscription\ntools:\n - mcp_team\n---\n\nAlpha.\n",
2265
+ )
2266
+ .unwrap();
2267
+ let spec = crate::compiler::compile_team(&ws).expect("compile");
2268
+ std::fs::write(ws.join("team.spec.yaml"), crate::model::yaml::dumps(&spec)).unwrap();
2269
+ let stale_uuid = "bd68bfbd-b9b6-4e0e-8197-ce5a47c4a930";
2270
+ crate::state::persist::save_runtime_state(
2271
+ &ws,
2272
+ &json!({
2273
+ "session_name": "team-restartclaude046",
2274
+ "agents": {
2275
+ "alpha": {
2276
+ "status": "running",
2277
+ "provider": "claude",
2278
+ "window": "alpha",
2279
+ "first_send_at": "2026-06-23T10:00:00+00:00",
2280
+ "session_id": stale_uuid,
2281
+ "rollout_path": null,
2282
+ "captured_at": null,
2283
+ "captured_via": null
2284
+ }
2285
+ }
2286
+ }),
2287
+ )
2288
+ .unwrap();
2289
+ seed_healthy_coordinator(&ws);
2290
+ let transport = OfflineTransport::new();
2291
+
2292
+ let result = restart_with_transport(&ws, true, None, &transport);
2229
2293
  assert!(
2230
- plan.unresumable
2231
- .iter()
2232
- .all(|worker| worker.reason != "no_persisted_session_id"),
2233
- "second restart must not loop as no_persisted_session_id; unresumable={:?}",
2234
- plan.unresumable
2294
+ matches!(result, Ok(RestartReport::Restarted { .. })),
2295
+ "allow-fresh restart should fresh-spawn the claude worker; got {result:?}"
2296
+ );
2297
+
2298
+ let state = crate::state::persist::load_runtime_state(&ws).expect("load state");
2299
+ let agent = state.pointer("/agents/alpha").expect("alpha");
2300
+ assert_eq!(
2301
+ agent.get("session_id"),
2302
+ Some(&serde_json::Value::Null),
2303
+ "0.4.6 contract: Claude fresh restart must clear stale session_id; agent={agent}"
2304
+ );
2305
+ // C1 dual-projection: teams.<key>.agents.alpha.session_id must also be null.
2306
+ if let Some(teams) = state.get("teams").and_then(serde_json::Value::as_object) {
2307
+ for (team_key, team_state) in teams {
2308
+ if let Some(team_alpha) = team_state.pointer("/agents/alpha") {
2309
+ let team_session = team_alpha.get("session_id");
2310
+ assert!(
2311
+ team_session.is_none() || team_session == Some(&serde_json::Value::Null),
2312
+ "0.4.6: teams.{team_key}.agents.alpha.session_id must be null; got {team_session:?}"
2313
+ );
2314
+ }
2315
+ }
2316
+ }
2317
+ }
2318
+
2319
+ /// 0.4.6 tuple-atomic contract (audit §Fork 修改清单, line 201): fork
2320
+ /// with a scalar `session_id` but no rollout_path/captured_at/captured_via
2321
+ /// must be REFUSED before the native fork. Pre-0.4.6 fork only checked
2322
+ /// session_id non-empty, which let it attach to a session with no
2323
+ /// confirmed backing.
2324
+ #[test]
2325
+ fn fork_refuses_source_with_partial_tuple() {
2326
+ let ws = temp_ws().join("forkpartial046");
2327
+ std::fs::create_dir_all(ws.join("agents")).unwrap();
2328
+ std::fs::write(
2329
+ ws.join("TEAM.md"),
2330
+ "---\nname: forkpartial046\nobjective: fork tuple.\nprovider: codex\n---\n\nteam.\n",
2331
+ )
2332
+ .unwrap();
2333
+ std::fs::write(
2334
+ ws.join("agents").join("src.md"),
2335
+ "---\nname: src\nrole: Source\nprovider: codex\nmodel: gpt\nauth_mode: subscription\ntools:\n - mcp_team\n---\n\nSrc.\n",
2336
+ )
2337
+ .unwrap();
2338
+ let spec = crate::compiler::compile_team(&ws).expect("compile");
2339
+ std::fs::write(ws.join("team.spec.yaml"), crate::model::yaml::dumps(&spec)).unwrap();
2340
+ crate::state::persist::save_runtime_state(
2341
+ &ws,
2342
+ &json!({
2343
+ "session_name": "team-forkpartial046",
2344
+ "agents": {
2345
+ "src": {
2346
+ "status": "running",
2347
+ "provider": "codex",
2348
+ "window": "src",
2349
+ "first_send_at": "2026-06-25T10:00:00+00:00",
2350
+ "session_id": "scalar-only-uuid",
2351
+ "rollout_path": null,
2352
+ "captured_at": null,
2353
+ "captured_via": null
2354
+ }
2355
+ }
2356
+ }),
2357
+ )
2358
+ .unwrap();
2359
+ let transport = OfflineTransport::new();
2360
+
2361
+ // fork_agent is the entry point; it should refuse with a clear message.
2362
+ let src_id = crate::model::ids::AgentId::new("src");
2363
+ let dst_id = crate::model::ids::AgentId::new("clone");
2364
+ let result = crate::lifecycle::fork_agent_with_transport(
2365
+ &ws,
2366
+ &src_id,
2367
+ &dst_id,
2368
+ None, // label
2369
+ false, // open_display
2370
+ None, // team
2371
+ &transport,
2372
+ );
2373
+ assert!(
2374
+ result.is_err(),
2375
+ "0.4.6: fork with partial source tuple must be refused; got Ok({result:?})"
2376
+ );
2377
+ let err = result.unwrap_err().to_string();
2378
+ assert!(
2379
+ err.contains("source session backing is missing")
2380
+ || err.contains("backing")
2381
+ || err.contains("incomplete"),
2382
+ "0.4.6: fork refusal must name backing/incomplete cause; got error={err}"
2235
2383
  );
2236
2384
  }
2237
2385