@team-agent/installer 0.5.61 → 0.5.62
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/crates/team-agent/src/cli/adapters.rs +5 -2
- package/crates/team-agent/src/cli/attach_app_server_leader.rs +1 -0
- package/crates/team-agent/src/cli/diagnose.rs +1 -0
- package/crates/team-agent/src/cli/emit.rs +41 -7
- package/crates/team-agent/src/cli/helpers.rs +1 -0
- package/crates/team-agent/src/cli/leader.rs +6 -1
- package/crates/team-agent/src/cli/leaders.rs +2 -0
- package/crates/team-agent/src/cli/mod.rs +33 -3
- package/crates/team-agent/src/cli/named_address.rs +8 -1
- package/crates/team-agent/src/cli/profile.rs +2 -1
- package/crates/team-agent/src/cli/send/coordinator.rs +1 -0
- package/crates/team-agent/src/cli/send/mailbox.rs +3 -0
- package/crates/team-agent/src/cli/send/persist.rs +1 -0
- package/crates/team-agent/src/cli/send/presentation.rs +1 -0
- package/crates/team-agent/src/cli/send/resolve.rs +206 -1
- package/crates/team-agent/src/cli/send.rs +2 -1
- package/crates/team-agent/src/cli/spec.rs +1 -0
- package/crates/team-agent/src/cli/status.rs +2 -1
- package/crates/team-agent/src/cli/status_port/compact.rs +1 -0
- package/crates/team-agent/src/cli/status_port/format.rs +1 -0
- package/crates/team-agent/src/cli/status_port/inbox.rs +1 -0
- package/crates/team-agent/src/cli/tests/verb_profile.rs +38 -0
- package/crates/team-agent/src/cli/types.rs +3 -2
- package/crates/team-agent/src/communication_mode/mod.rs +1 -0
- package/crates/team-agent/src/compiler.rs +1 -0
- package/crates/team-agent/src/conpty/backend.rs +1 -0
- package/crates/team-agent/src/conpty/mod.rs +1 -0
- package/crates/team-agent/src/coordinator/backoff.rs +5 -8
- package/crates/team-agent/src/coordinator/conpty_shim.rs +3 -2
- package/crates/team-agent/src/coordinator/health.rs +1 -0
- package/crates/team-agent/src/coordinator/mod.rs +2 -2
- package/crates/team-agent/src/coordinator/orphan.rs +4 -116
- package/crates/team-agent/src/coordinator/runtime_detectors.rs +1 -0
- package/crates/team-agent/src/coordinator/runtime_observation.rs +1 -0
- package/crates/team-agent/src/coordinator/steps/abnormal.rs +6 -5
- package/crates/team-agent/src/coordinator/steps/delivery.rs +1 -0
- package/crates/team-agent/src/coordinator/steps/health_sync.rs +1 -0
- package/crates/team-agent/src/coordinator/steps/mod.rs +2 -0
- package/crates/team-agent/src/coordinator/steps/persist.rs +1 -0
- package/crates/team-agent/src/coordinator/steps/runtime_prompts.rs +1 -0
- package/crates/team-agent/src/coordinator/steps/session_gate.rs +1 -0
- package/crates/team-agent/src/coordinator/tests/abnormal.rs +0 -174
- package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +0 -9
- package/crates/team-agent/src/coordinator/tests/basics.rs +0 -184
- package/crates/team-agent/src/coordinator/tests/mod.rs +2 -17
- package/crates/team-agent/src/coordinator/tests/tick_core.rs +0 -42
- package/crates/team-agent/src/coordinator/tick.rs +24 -28
- package/crates/team-agent/src/coordinator/types.rs +3 -176
- package/crates/team-agent/src/db/agent_health_capture.rs +1 -0
- package/crates/team-agent/src/db/message_store.rs +2 -1
- package/crates/team-agent/src/db/migration.rs +5 -4
- package/crates/team-agent/src/db/mod.rs +1 -0
- package/crates/team-agent/src/db/schema.rs +1 -0
- package/crates/team-agent/src/diagnose/comms.rs +2 -1
- package/crates/team-agent/src/diagnose/mod.rs +1 -0
- package/crates/team-agent/src/diagnose/orphans.rs +1 -0
- package/crates/team-agent/src/layout/manager.rs +3 -7
- package/crates/team-agent/src/layout/mod.rs +2 -2
- package/crates/team-agent/src/layout/overlay.rs +6 -1
- package/crates/team-agent/src/layout/placement.rs +1 -0
- package/crates/team-agent/src/layout/recovery.rs +3 -0
- package/crates/team-agent/src/layout/runtime_sessions.rs +8 -3
- package/crates/team-agent/src/layout/sessions.rs +8 -1
- package/crates/team-agent/src/layout/tmux_endpoint.rs +3 -0
- package/crates/team-agent/src/layout/worker_env.rs +3 -0
- package/crates/team-agent/src/layout/worker_window_helpers.rs +2 -0
- package/crates/team-agent/src/leader/helpers.rs +1 -0
- package/crates/team-agent/src/leader/incident.rs +1 -0
- package/crates/team-agent/src/leader/lease.rs +27 -22
- package/crates/team-agent/src/leader/mod.rs +2 -3
- package/crates/team-agent/src/leader/owner_bind.rs +13 -3
- package/crates/team-agent/src/leader/provider_attribution.rs +1 -0
- package/crates/team-agent/src/leader/rediscover.rs +4 -17
- package/crates/team-agent/src/leader/registry.rs +3 -15
- package/crates/team-agent/src/leader/start.rs +373 -125
- package/crates/team-agent/src/leader/takeover.rs +10 -232
- package/crates/team-agent/src/leader/tests/claim_leader_mailbox_flush_contract.rs +544 -0
- package/crates/team-agent/src/leader/tests/historical_inventory_upgrade_gate_red.rs +624 -0
- package/crates/team-agent/src/leader/tests/identity.rs +7 -2
- package/crates/team-agent/src/leader/tests/idle.rs +0 -193
- package/crates/team-agent/src/leader/tests/lease_api.rs +0 -45
- package/crates/team-agent/src/leader/tests/mod.rs +4 -41
- package/crates/team-agent/src/leader/tests/rehomed_env.rs +83 -0
- package/crates/team-agent/src/leader/tests/team_in_team_state_scope_red.rs +1273 -0
- package/crates/team-agent/src/leader/tests/terminal_and_replay_vs_rerender_invariants_red.rs +417 -0
- package/crates/team-agent/src/leader/tests/wake_start_owner.rs +22 -103
- package/crates/team-agent/src/leader/types.rs +1 -28
- package/crates/team-agent/src/lib.rs +3 -0
- package/crates/team-agent/src/lifecycle/display.rs +7 -1
- package/crates/team-agent/src/lifecycle/helpers.rs +3 -1
- package/crates/team-agent/src/lifecycle/launch/add_agent.rs +2 -2
- package/crates/team-agent/src/lifecycle/launch/fork_agent/completion.rs +1 -0
- package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +1 -0
- package/crates/team-agent/src/lifecycle/launch/fork_finalize.rs +1 -0
- package/crates/team-agent/src/lifecycle/launch/plan.rs +2 -2
- package/crates/team-agent/src/lifecycle/launch/quick_start.rs +4 -26
- package/crates/team-agent/src/lifecycle/launch/readiness.rs +0 -27
- package/crates/team-agent/src/lifecycle/launch/spawn.rs +1 -27
- package/crates/team-agent/src/lifecycle/launch/spec_state.rs +4 -32
- package/crates/team-agent/src/lifecycle/launch/state_projection.rs +1 -0
- package/crates/team-agent/src/lifecycle/launch.rs +11 -12
- package/crates/team-agent/src/lifecycle/mod.rs +2 -1
- package/crates/team-agent/src/lifecycle/restart/agent.rs +3 -3
- package/crates/team-agent/src/lifecycle/restart/orchestrator.rs +2 -2
- package/crates/team-agent/src/lifecycle/restart/rebuild.rs +13 -5
- package/crates/team-agent/src/lifecycle/restart/remove.rs +1 -1
- package/crates/team-agent/src/lifecycle/restart/selection.rs +3 -3
- package/crates/team-agent/src/lifecycle/restart.rs +13 -11
- package/crates/team-agent/src/lifecycle/tests/acceptance_b_batch_red.rs +1007 -0
- package/crates/team-agent/src/lifecycle/tests/b0_legacy_snapshot_nonauthority_contract.rs +265 -0
- package/crates/team-agent/src/lifecycle/tests/b0_reader_hideone_audit_contract.rs +459 -0
- package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +849 -0
- package/crates/team-agent/src/lifecycle/tests/claude_compatible_config_red.rs +323 -0
- package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +423 -0
- package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +737 -0
- package/crates/team-agent/src/lifecycle/tests/codex_mcp_approval_inheritance_red.rs +1187 -0
- package/crates/team-agent/src/lifecycle/tests/codex_weak_window_attribution_red.rs +683 -0
- package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +394 -0
- package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +1856 -0
- package/crates/team-agent/src/lifecycle/tests/core_034_real_red.rs +917 -0
- package/crates/team-agent/src/lifecycle/tests/display_adaptive_red.rs +481 -0
- package/crates/team-agent/src/lifecycle/tests/f032_startup_prompt_best_effort_red.rs +301 -0
- package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +516 -0
- package/crates/team-agent/src/lifecycle/tests/host_cotenant_death_p0_contract.rs +986 -0
- package/crates/team-agent/src/lifecycle/tests/lifecycle_rollback_red.rs +651 -0
- package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +2 -0
- package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +332 -0
- package/crates/team-agent/src/lifecycle/tests/realmachine_clusters_1_6_red.rs +846 -0
- package/crates/team-agent/src/lifecycle/tests/realmachine_residual_g1_g4_red.rs +648 -0
- package/crates/team-agent/src/lifecycle/tests/restart_build_before_destroy_0540_contract.rs +910 -0
- package/crates/team-agent/src/lifecycle/tests/restart_liveness_red.rs +630 -0
- package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +1083 -0
- package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +1677 -0
- package/crates/team-agent/src/lifecycle/tests/resume_recover_red.rs +410 -0
- package/crates/team-agent/src/lifecycle/tests/stale_team_saveconflict_contract.rs +428 -0
- package/crates/team-agent/src/lifecycle/tests/startup_latency_contract.rs +1032 -0
- package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +869 -0
- package/crates/team-agent/src/lifecycle/tests/subprep_codex_trust_roundtrip_red.rs +1249 -0
- package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +342 -0
- package/crates/team-agent/src/lifecycle/tests/team_in_team_identity_scope_red.rs +542 -0
- package/crates/team-agent/src/lifecycle/tests/team_in_team_sibling_quick_start_red.rs +1103 -0
- package/crates/team-agent/src/lifecycle/tests/team_in_team_state_scope_red.rs +1276 -0
- package/crates/team-agent/src/lifecycle/tests/team_key_retirement_roster_red.rs +145 -0
- package/crates/team-agent/src/lifecycle/tests/team_key_retirement_txn_red.rs +603 -0
- package/crates/team-agent/src/lifecycle/tests/test_isolation_escape_contract.rs +837 -0
- package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +928 -0
- package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +951 -0
- package/crates/team-agent/src/lifecycle/tests/worker_dangerous_bypass_argv_red.rs +327 -0
- package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +760 -0
- package/crates/team-agent/src/lifecycle/tests.rs +59 -0
- package/crates/team-agent/src/lifecycle/types.rs +0 -9
- package/crates/team-agent/src/mcp_server/helpers.rs +1 -0
- package/crates/team-agent/src/mcp_server/lifecycle_tools/mod.rs +1 -0
- package/crates/team-agent/src/mcp_server/lifecycle_tools/state_status.rs +1 -0
- package/crates/team-agent/src/mcp_server/mod.rs +1 -0
- package/crates/team-agent/src/mcp_server/normalize.rs +4 -3
- package/crates/team-agent/src/mcp_server/tools.rs +1 -0
- package/crates/team-agent/src/mcp_server/types.rs +1 -18
- package/crates/team-agent/src/mcp_server/wire.rs +5 -5
- package/crates/team-agent/src/messaging/activity.rs +1 -0
- package/crates/team-agent/src/messaging/address.rs +1 -0
- package/crates/team-agent/src/messaging/delivery.rs +4 -3
- package/crates/team-agent/src/messaging/helpers.rs +2 -1
- package/crates/team-agent/src/messaging/leader_channel.rs +1 -0
- package/crates/team-agent/src/messaging/leader_receiver.rs +2 -1
- package/crates/team-agent/src/messaging/mod.rs +10 -14
- package/crates/team-agent/src/messaging/peers.rs +2 -0
- package/crates/team-agent/src/messaging/persist.rs +3 -1
- package/crates/team-agent/src/messaging/presentation.rs +2 -1
- package/crates/team-agent/src/messaging/results.rs +1 -0
- package/crates/team-agent/src/messaging/scheduler.rs +1 -0
- package/crates/team-agent/src/messaging/selftest.rs +1 -1
- package/crates/team-agent/src/messaging/send.rs +41 -8
- package/crates/team-agent/src/messaging/tests/mod.rs +5 -0
- package/crates/team-agent/src/messaging/types.rs +2 -2
- package/crates/team-agent/src/messaging/watchers.rs +19 -13
- package/crates/team-agent/src/model/enums.rs +1 -0
- package/crates/team-agent/src/model/errors.rs +1 -0
- package/crates/team-agent/src/model/ids.rs +1 -0
- package/crates/team-agent/src/model/mod.rs +1 -0
- package/crates/team-agent/src/model/name_similarity.rs +1 -0
- package/crates/team-agent/src/model/pane_authority_refusal.rs +1 -0
- package/crates/team-agent/src/model/paths.rs +1 -0
- package/crates/team-agent/src/model/permissions.rs +3 -2
- package/crates/team-agent/src/model/routing.rs +1 -0
- package/crates/team-agent/src/model/spec.rs +1 -0
- package/crates/team-agent/src/model/task_graph.rs +1 -0
- package/crates/team-agent/src/model/yaml/tests.rs +1 -0
- package/crates/team-agent/src/model/yaml.rs +1 -0
- package/crates/team-agent/src/packaging/install.rs +9 -147
- package/crates/team-agent/src/packaging/migrate.rs +2 -0
- package/crates/team-agent/src/packaging/mod.rs +1 -0
- package/crates/team-agent/src/packaging/repair.rs +2 -0
- package/crates/team-agent/src/packaging/tests.rs +29 -218
- package/crates/team-agent/src/packaging/types.rs +8 -15
- package/crates/team-agent/src/platform/argv.rs +4 -0
- package/crates/team-agent/src/platform/errors.rs +10 -1
- package/crates/team-agent/src/platform/file_lock.rs +4 -157
- package/crates/team-agent/src/platform/mod.rs +0 -61
- package/crates/team-agent/src/platform/process.rs +1 -0
- package/crates/team-agent/src/provider/adapter.rs +1 -0
- package/crates/team-agent/src/provider/adapters/claude.rs +1 -0
- package/crates/team-agent/src/provider/adapters/claude_fork.rs +1 -0
- package/crates/team-agent/src/provider/adapters/codex.rs +1 -0
- package/crates/team-agent/src/provider/adapters/copilot.rs +1 -0
- package/crates/team-agent/src/provider/adapters/copilot_fork.rs +1 -0
- package/crates/team-agent/src/provider/adapters/fake.rs +1 -0
- package/crates/team-agent/src/provider/adapters/mod.rs +1 -0
- package/crates/team-agent/src/provider/approvals/mod.rs +1 -0
- package/crates/team-agent/src/provider/approvals/parsing.rs +2 -5
- package/crates/team-agent/src/provider/approvals/runtime_prompts.rs +6 -5
- package/crates/team-agent/src/provider/classify.rs +1 -0
- package/crates/team-agent/src/provider/faults.rs +1 -26
- package/crates/team-agent/src/provider/helpers.rs +1 -0
- package/crates/team-agent/src/provider/mod.rs +1 -1
- package/crates/team-agent/src/provider/session/capture.rs +1 -4
- package/crates/team-agent/src/provider/session/context_fork/claude.rs +1 -0
- package/crates/team-agent/src/provider/session/context_fork/codex.rs +1 -0
- package/crates/team-agent/src/provider/session/context_fork/outcome.rs +1 -0
- package/crates/team-agent/src/provider/session/context_fork.rs +1 -0
- package/crates/team-agent/src/provider/session/mod.rs +2 -4
- package/crates/team-agent/src/provider/session/resume.rs +2 -209
- package/crates/team-agent/src/provider/session_scan/claude.rs +1 -0
- package/crates/team-agent/src/provider/session_scan/codex.rs +1 -0
- package/crates/team-agent/src/provider/session_scan/common.rs +1 -0
- package/crates/team-agent/src/provider/session_scan/copilot.rs +1 -0
- package/crates/team-agent/src/provider/session_scan.rs +1 -42
- package/crates/team-agent/src/provider/startup_prompt.rs +1 -0
- package/crates/team-agent/src/provider/types.rs +1 -0
- package/crates/team-agent/src/provider/wire.rs +1 -0
- package/crates/team-agent/src/state/identity.rs +16 -5
- package/crates/team-agent/src/state/identity_keys.rs +1 -0
- package/crates/team-agent/src/state/mod.rs +2 -0
- package/crates/team-agent/src/state/owner_gate.rs +5 -0
- package/crates/team-agent/src/state/ownership.rs +10 -4
- package/crates/team-agent/src/state/paths.rs +12 -0
- package/crates/team-agent/src/state/persist.rs +9 -3
- package/crates/team-agent/src/state/projection.rs +15 -2
- package/crates/team-agent/src/state/repository/intent.rs +1 -0
- package/crates/team-agent/src/state/repository/tests.rs +1 -0
- package/crates/team-agent/src/state/repository.rs +7 -0
- package/crates/team-agent/src/state/selector.rs +1 -0
- package/crates/team-agent/src/tmux_backend/tests.rs +39 -0
- package/crates/team-agent/src/tmux_backend.rs +63 -0
- package/crates/team-agent/src/transport.rs +15 -0
- package/package.json +4 -4
- package/crates/team-agent/src/leader/inject.rs +0 -33
- package/crates/team-agent/src/provider/command.rs +0 -80
|
@@ -0,0 +1,459 @@
|
|
|
1
|
+
//! Foundation-0 F0-3 RED contract: B0 legacy snapshot reader/path hide-one audit.
|
|
2
|
+
//!
|
|
3
|
+
//! References:
|
|
4
|
+
//! - `.team/artifacts/foundation-0-slice-design.md` §5 F0-3.
|
|
5
|
+
//! - F0-2 boundary: retained legacy snapshots are diagnostic only via
|
|
6
|
+
//! `_not_authoritative`, `_canonical_state_path`, `_derived_from`,
|
|
7
|
+
//! `_generated_at`, and `B0_DIAGNOSTIC_LEGACY_SNAPSHOT_READ` allowlisted reads.
|
|
8
|
+
//!
|
|
9
|
+
//! User story: when a legacy per-session snapshot disagrees with the current
|
|
10
|
+
//! root/projection state, every runtime reader keeps routing, restart, delivery,
|
|
11
|
+
//! status, and diagnose decisions on the current authority. The snapshot may be
|
|
12
|
+
//! shown only as a labeled diagnostic, never as hidden truth.
|
|
13
|
+
|
|
14
|
+
#![allow(clippy::expect_used, clippy::panic, clippy::unwrap_used)]
|
|
15
|
+
|
|
16
|
+
#[path = "../../../tests/support/hermetic.rs"]
|
|
17
|
+
mod hermetic_guard;
|
|
18
|
+
|
|
19
|
+
#[path = "../../../tests/support/composite_source.rs"]
|
|
20
|
+
mod composite_source;
|
|
21
|
+
use std::path::{Path, PathBuf};
|
|
22
|
+
|
|
23
|
+
use serde_json::{json, Value};
|
|
24
|
+
use serial_test::serial;
|
|
25
|
+
use team_agent::state::persist::{runtime_state_path, save_runtime_state};
|
|
26
|
+
|
|
27
|
+
const TEAM: &str = "team-a";
|
|
28
|
+
const SESSION: &str = "team-b0-hideone";
|
|
29
|
+
const WORKER: &str = "worker";
|
|
30
|
+
const NEW_ENDPOINT: &str = "/private/tmp/tmux-501/ta-b0-new";
|
|
31
|
+
const OLD_ENDPOINT: &str = "/private/tmp/tmux-501/ta-b0-old";
|
|
32
|
+
const READ_MARKER: &str = "B0_DIAGNOSTIC_LEGACY_SNAPSHOT_READ";
|
|
33
|
+
|
|
34
|
+
#[test]
|
|
35
|
+
#[serial(env)]
|
|
36
|
+
fn stale_snapshot_endpoint_does_not_reach_restart_preflight_spawn_attach_or_events() {
|
|
37
|
+
let case = B0HideOneCase::new("restart-endpoint-hide-one");
|
|
38
|
+
case.seed_current_root_and_stale_snapshot();
|
|
39
|
+
|
|
40
|
+
let selected = team_agent::state::projection::select_runtime_state(&case.workspace, Some(TEAM))
|
|
41
|
+
.expect("select runtime state from current authority");
|
|
42
|
+
assert_eq!(
|
|
43
|
+
selected.get("tmux_endpoint").and_then(Value::as_str),
|
|
44
|
+
Some(NEW_ENDPOINT),
|
|
45
|
+
"F0-3 RED1: restart selection must read current root/projection endpoint, not stale legacy snapshot endpoint; selected={selected}"
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
let candidate = team_agent::lifecycle::select_restart_state(&case.workspace, Some(TEAM))
|
|
49
|
+
.expect("restart preflight should select the current team");
|
|
50
|
+
assert_eq!(
|
|
51
|
+
candidate.state_path,
|
|
52
|
+
runtime_state_path(&case.workspace),
|
|
53
|
+
"F0-3 RED1: restart preflight must be rooted at the canonical runtime state file, not a legacy per-session snapshot; candidate={candidate:?}"
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
let offenders = source_lines_under("src/lifecycle/restart")
|
|
57
|
+
.into_iter()
|
|
58
|
+
.filter(|(rel, line_no, line)| legacy_snapshot_authority_read(rel, *line_no, line))
|
|
59
|
+
.collect::<Vec<_>>();
|
|
60
|
+
assert!(
|
|
61
|
+
offenders.is_empty(),
|
|
62
|
+
"F0-3 RED1: lifecycle/restart preflight, spawn metadata, attach_commands, and restart events must not read legacy snapshot paths. Offenders (file:line): {offenders:#?}"
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
#[test]
|
|
67
|
+
#[serial(env)]
|
|
68
|
+
fn stale_snapshot_pane_does_not_reach_delivery_target_resolution() {
|
|
69
|
+
let case = B0HideOneCase::new("delivery-pane-hide-one");
|
|
70
|
+
case.seed_current_root_and_stale_snapshot();
|
|
71
|
+
|
|
72
|
+
let selected = team_agent::state::projection::select_runtime_state(&case.workspace, Some(TEAM))
|
|
73
|
+
.expect("select runtime state from current authority");
|
|
74
|
+
assert_eq!(
|
|
75
|
+
selected.pointer("/agents/worker/pane_id").and_then(Value::as_str),
|
|
76
|
+
Some("%new"),
|
|
77
|
+
"F0-3 RED2: delivery target selection must see the current root/projection worker pane, not stale legacy snapshot pane; selected={selected}"
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
let offenders = source_lines_for(&[
|
|
81
|
+
"src/messaging",
|
|
82
|
+
"src/cli/send.rs",
|
|
83
|
+
"src/cli/named_address.rs",
|
|
84
|
+
])
|
|
85
|
+
.into_iter()
|
|
86
|
+
.filter(|(rel, line_no, line)| legacy_snapshot_authority_read(rel, *line_no, line))
|
|
87
|
+
.collect::<Vec<_>>();
|
|
88
|
+
assert!(
|
|
89
|
+
offenders.is_empty(),
|
|
90
|
+
"F0-3 RED2: delivery and named-send target resolution must not read legacy snapshot paths, so stale snapshot panes cannot be selected. Offenders (file:line): {offenders:#?}"
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
#[test]
|
|
95
|
+
#[serial(env)]
|
|
96
|
+
fn stale_snapshot_cannot_flip_status_or_diagnose_ok_readiness() {
|
|
97
|
+
let case = B0HideOneCase::new("status-diagnose-hide-one");
|
|
98
|
+
let root = case.current_state();
|
|
99
|
+
save_runtime_state(&case.workspace, &root).expect("seed current root state");
|
|
100
|
+
|
|
101
|
+
let status_before = case.run_json(&[
|
|
102
|
+
"status",
|
|
103
|
+
"--workspace",
|
|
104
|
+
case.workspace_str(),
|
|
105
|
+
"--team",
|
|
106
|
+
TEAM,
|
|
107
|
+
"--detail",
|
|
108
|
+
"--json",
|
|
109
|
+
]);
|
|
110
|
+
let diagnose_before = case.run_json(&[
|
|
111
|
+
"diagnose",
|
|
112
|
+
"--workspace",
|
|
113
|
+
case.workspace_str(),
|
|
114
|
+
"--team",
|
|
115
|
+
TEAM,
|
|
116
|
+
"--json",
|
|
117
|
+
]);
|
|
118
|
+
|
|
119
|
+
case.write_stale_snapshot();
|
|
120
|
+
|
|
121
|
+
let status_after = case.run_json(&[
|
|
122
|
+
"status",
|
|
123
|
+
"--workspace",
|
|
124
|
+
case.workspace_str(),
|
|
125
|
+
"--team",
|
|
126
|
+
TEAM,
|
|
127
|
+
"--detail",
|
|
128
|
+
"--json",
|
|
129
|
+
]);
|
|
130
|
+
let diagnose_after = case.run_json(&[
|
|
131
|
+
"diagnose",
|
|
132
|
+
"--workspace",
|
|
133
|
+
case.workspace_str(),
|
|
134
|
+
"--team",
|
|
135
|
+
TEAM,
|
|
136
|
+
"--json",
|
|
137
|
+
]);
|
|
138
|
+
|
|
139
|
+
assert_eq!(
|
|
140
|
+
status_after.pointer("/agents/worker/pane_id").and_then(Value::as_str),
|
|
141
|
+
Some("%new"),
|
|
142
|
+
"F0-3 RED3: status must not display the stale snapshot pane as the worker authority; before={status_before} after={status_after}"
|
|
143
|
+
);
|
|
144
|
+
assert_eq!(
|
|
145
|
+
worker_status_tuple(&status_before),
|
|
146
|
+
worker_status_tuple(&status_after),
|
|
147
|
+
"F0-3 RED3: stale legacy snapshot must not flip status/readiness fields except for a labeled diagnostic; before={status_before} after={status_after}"
|
|
148
|
+
);
|
|
149
|
+
assert_eq!(
|
|
150
|
+
diagnose_before.get("ok"),
|
|
151
|
+
diagnose_after.get("ok"),
|
|
152
|
+
"F0-3 RED3: stale legacy snapshot must not flip diagnose ok; before={diagnose_before} after={diagnose_after}"
|
|
153
|
+
);
|
|
154
|
+
let before_issues = issue_ids(&diagnose_before);
|
|
155
|
+
let after_issues = issue_ids(&diagnose_after);
|
|
156
|
+
let new_issues = after_issues
|
|
157
|
+
.iter()
|
|
158
|
+
.filter(|issue| !before_issues.contains(*issue))
|
|
159
|
+
.cloned()
|
|
160
|
+
.collect::<Vec<_>>();
|
|
161
|
+
let bad = new_issues
|
|
162
|
+
.iter()
|
|
163
|
+
.filter(|issue| issue.as_str() != "legacy_snapshot_stale")
|
|
164
|
+
.collect::<Vec<_>>();
|
|
165
|
+
assert!(
|
|
166
|
+
bad.is_empty(),
|
|
167
|
+
"F0-3 RED3: status/diagnose may surface only labeled `legacy_snapshot_stale` for a divergent snapshot; new_issues={new_issues:?} before={diagnose_before} after={diagnose_after}"
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
#[test]
|
|
172
|
+
fn product_authority_paths_do_not_read_legacy_snapshot_without_diagnostic_marker() {
|
|
173
|
+
let offenders = source_lines_under("src")
|
|
174
|
+
.into_iter()
|
|
175
|
+
.filter(|(rel, line_no, line)| legacy_snapshot_authority_read(rel, *line_no, line))
|
|
176
|
+
.collect::<Vec<_>>();
|
|
177
|
+
|
|
178
|
+
assert!(
|
|
179
|
+
offenders.is_empty(),
|
|
180
|
+
"F0-3 RED4: product authority paths must not read legacy per-session snapshots. Only migration/diagnostic/test code, or lines explicitly marked `{READ_MARKER}`, may touch `.team/runtime/teams/<session_name>/state.json`. Offenders (file:line): {offenders:#?}"
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
#[test]
|
|
185
|
+
fn team_runtime_state_path_uses_b3_team_key_layout_not_legacy_runtime_root_layout() {
|
|
186
|
+
let paths = team_agent::state::paths::TeamRuntimePaths::new(PathBuf::from("/ws/proj"), "alpha");
|
|
187
|
+
|
|
188
|
+
assert_eq!(
|
|
189
|
+
paths.state_path(),
|
|
190
|
+
PathBuf::from("/ws/proj/.team/runtime/teams/alpha/state.json"),
|
|
191
|
+
"F0-3 RED5: state/paths.rs must pre-announce the B3 canonical team state path as `.team/runtime/teams/<team_key>/state.json`; `.team/runtime/<team_key>/state.json` collides with runtime spec/coordinator sidecar layout and keeps the old hide-two ambiguity alive"
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
struct B0HideOneCase {
|
|
196
|
+
env: hermetic_guard::HermeticTestEnv,
|
|
197
|
+
workspace: PathBuf,
|
|
198
|
+
workspace_str: String,
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
impl B0HideOneCase {
|
|
202
|
+
fn new(tag: &str) -> Self {
|
|
203
|
+
let env = hermetic_guard::HermeticTestEnv::enter(tag);
|
|
204
|
+
let workspace = env.workspace(tag);
|
|
205
|
+
let workspace_str = workspace.to_string_lossy().to_string();
|
|
206
|
+
Self {
|
|
207
|
+
env,
|
|
208
|
+
workspace,
|
|
209
|
+
workspace_str,
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
fn workspace_str(&self) -> &str {
|
|
214
|
+
&self.workspace_str
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
fn seed_current_root_and_stale_snapshot(&self) {
|
|
218
|
+
save_runtime_state(&self.workspace, &self.current_state())
|
|
219
|
+
.expect("seed current root state");
|
|
220
|
+
self.write_stale_snapshot();
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
fn current_state(&self) -> Value {
|
|
224
|
+
self.state("%new", 24001, 3, NEW_ENDPOINT)
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
fn stale_snapshot_state(&self) -> Value {
|
|
228
|
+
let mut state = self.state("%old", 12001, 1, OLD_ENDPOINT);
|
|
229
|
+
let canonical = runtime_state_path(&self.workspace);
|
|
230
|
+
let obj = state.as_object_mut().expect("state object");
|
|
231
|
+
obj.insert("_not_authoritative".to_string(), json!(true));
|
|
232
|
+
obj.insert(
|
|
233
|
+
"_canonical_state_path".to_string(),
|
|
234
|
+
json!(canonical.to_string_lossy().to_string()),
|
|
235
|
+
);
|
|
236
|
+
obj.insert(
|
|
237
|
+
"_derived_from".to_string(),
|
|
238
|
+
json!("f0-3-test-stale-legacy-snapshot"),
|
|
239
|
+
);
|
|
240
|
+
obj.insert("_generated_at".to_string(), json!("2026-07-11T00:00:00Z"));
|
|
241
|
+
state
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
fn state(&self, pane_id: &str, pane_pid: i64, spawn_epoch: u64, endpoint: &str) -> Value {
|
|
245
|
+
let worker = json!({
|
|
246
|
+
"id": WORKER,
|
|
247
|
+
"agent_id": WORKER,
|
|
248
|
+
"provider": "fake",
|
|
249
|
+
"model": "fake",
|
|
250
|
+
"pane_id": pane_id,
|
|
251
|
+
"pane_pid": pane_pid,
|
|
252
|
+
"tmux_session": SESSION,
|
|
253
|
+
"window": WORKER,
|
|
254
|
+
"last_window": WORKER,
|
|
255
|
+
"spawn_epoch": spawn_epoch,
|
|
256
|
+
"status": "running",
|
|
257
|
+
"auth_mode": "subscription"
|
|
258
|
+
});
|
|
259
|
+
let team = json!({
|
|
260
|
+
"team_key": TEAM,
|
|
261
|
+
"active_team_key": TEAM,
|
|
262
|
+
"session_name": SESSION,
|
|
263
|
+
"team_dir": self.workspace_str,
|
|
264
|
+
"workspace": self.workspace_str,
|
|
265
|
+
"status": "alive",
|
|
266
|
+
"tmux_endpoint": endpoint,
|
|
267
|
+
"tmux_socket": endpoint,
|
|
268
|
+
"tmux_socket_source": "test",
|
|
269
|
+
"transport": {"kind": "tmux", "source": "test"},
|
|
270
|
+
"agents": {
|
|
271
|
+
WORKER: worker.clone()
|
|
272
|
+
},
|
|
273
|
+
"leader_receiver": {
|
|
274
|
+
"status": "attached",
|
|
275
|
+
"pane_id": "%leader-new",
|
|
276
|
+
"provider": "fake",
|
|
277
|
+
"tmux_socket": endpoint,
|
|
278
|
+
"owner_epoch": 3
|
|
279
|
+
},
|
|
280
|
+
"team_owner": {
|
|
281
|
+
"pane_id": "%leader-new",
|
|
282
|
+
"provider": "fake",
|
|
283
|
+
"owner_epoch": 3,
|
|
284
|
+
"leader_session_uuid": "leader-new"
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
json!({
|
|
288
|
+
"schema_version": 1,
|
|
289
|
+
"active_team_key": TEAM,
|
|
290
|
+
"team_key": TEAM,
|
|
291
|
+
"session_name": SESSION,
|
|
292
|
+
"team_dir": self.workspace_str,
|
|
293
|
+
"workspace": self.workspace_str,
|
|
294
|
+
"status": "alive",
|
|
295
|
+
"tmux_endpoint": endpoint,
|
|
296
|
+
"tmux_socket": endpoint,
|
|
297
|
+
"tmux_socket_source": "test",
|
|
298
|
+
"transport": {"kind": "tmux", "source": "test"},
|
|
299
|
+
"agents": {
|
|
300
|
+
WORKER: worker
|
|
301
|
+
},
|
|
302
|
+
"leader_receiver": {
|
|
303
|
+
"status": "attached",
|
|
304
|
+
"pane_id": "%leader-new",
|
|
305
|
+
"provider": "fake",
|
|
306
|
+
"tmux_socket": endpoint,
|
|
307
|
+
"owner_epoch": 3
|
|
308
|
+
},
|
|
309
|
+
"team_owner": {
|
|
310
|
+
"pane_id": "%leader-new",
|
|
311
|
+
"provider": "fake",
|
|
312
|
+
"owner_epoch": 3,
|
|
313
|
+
"leader_session_uuid": "leader-new"
|
|
314
|
+
},
|
|
315
|
+
"teams": {
|
|
316
|
+
TEAM: team
|
|
317
|
+
}
|
|
318
|
+
})
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
fn write_stale_snapshot(&self) {
|
|
322
|
+
let path = team_agent::lifecycle::helpers::team_snapshot_path(&self.workspace, SESSION);
|
|
323
|
+
write_json(&path, &self.stale_snapshot_state());
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
fn run_json(&self, args: &[&str]) -> Value {
|
|
327
|
+
let output = self.env.run_cli(&self.workspace, args);
|
|
328
|
+
let stdout = String::from_utf8_lossy(&output.stdout);
|
|
329
|
+
let stderr = String::from_utf8_lossy(&output.stderr);
|
|
330
|
+
parse_json_object(&format!("{stdout}\n{stderr}")).unwrap_or_else(|| {
|
|
331
|
+
panic!("command did not emit JSON: args={args:?} stdout={stdout} stderr={stderr}")
|
|
332
|
+
})
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
fn worker_status_tuple(status: &Value) -> Value {
|
|
337
|
+
let worker = status
|
|
338
|
+
.get("agents")
|
|
339
|
+
.and_then(Value::as_object)
|
|
340
|
+
.and_then(|agents| agents.get(WORKER))
|
|
341
|
+
.cloned()
|
|
342
|
+
.unwrap_or(Value::Null);
|
|
343
|
+
json!({
|
|
344
|
+
"ok": status.get("ok").cloned().unwrap_or(Value::Null),
|
|
345
|
+
"pane_id": worker.get("pane_id").cloned().unwrap_or(Value::Null),
|
|
346
|
+
"status": worker.get("status").cloned().unwrap_or(Value::Null),
|
|
347
|
+
"readiness": status.get("readiness").cloned().unwrap_or(Value::Null),
|
|
348
|
+
})
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
fn issue_ids(value: &Value) -> Vec<String> {
|
|
352
|
+
value
|
|
353
|
+
.get("issues")
|
|
354
|
+
.and_then(Value::as_array)
|
|
355
|
+
.into_iter()
|
|
356
|
+
.flatten()
|
|
357
|
+
.filter_map(|issue| {
|
|
358
|
+
issue.as_str().map(str::to_string).or_else(|| {
|
|
359
|
+
issue
|
|
360
|
+
.get("id")
|
|
361
|
+
.or_else(|| issue.get("code"))
|
|
362
|
+
.and_then(Value::as_str)
|
|
363
|
+
.map(str::to_string)
|
|
364
|
+
})
|
|
365
|
+
})
|
|
366
|
+
.collect()
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
fn write_json(path: &Path, value: &Value) {
|
|
370
|
+
std::fs::create_dir_all(path.parent().expect("json parent")).expect("create json parent");
|
|
371
|
+
std::fs::write(
|
|
372
|
+
path,
|
|
373
|
+
serde_json::to_vec_pretty(value).expect("serialize json"),
|
|
374
|
+
)
|
|
375
|
+
.unwrap_or_else(|error| panic!("write {}: {error}", path.display()));
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
fn parse_json_object(text: &str) -> Option<Value> {
|
|
379
|
+
let start = text.find('{')?;
|
|
380
|
+
let end = text.rfind('}')?;
|
|
381
|
+
serde_json::from_str(&text[start..=end]).ok()
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
fn legacy_snapshot_authority_read(rel: &str, _line_no: usize, line: &str) -> bool {
|
|
385
|
+
let trimmed = line.trim_start();
|
|
386
|
+
if trimmed.starts_with("//") || trimmed.starts_with("///") || trimmed.starts_with("//!") {
|
|
387
|
+
return false;
|
|
388
|
+
}
|
|
389
|
+
if allowed_test_source(rel) || allowed_diagnostic_or_migration_source(rel, line) {
|
|
390
|
+
return false;
|
|
391
|
+
}
|
|
392
|
+
if rel == "src/lifecycle/helpers.rs" {
|
|
393
|
+
return false;
|
|
394
|
+
}
|
|
395
|
+
line.contains("team_snapshot_path(")
|
|
396
|
+
|| line.contains("readable_team_snapshot_path(")
|
|
397
|
+
|| line.contains("detect_dual_state_divergence(")
|
|
398
|
+
|| line.contains("\".team/runtime/teams\"")
|
|
399
|
+
|| line.contains("runtime/teams")
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
fn allowed_test_source(rel: &str) -> bool {
|
|
403
|
+
rel.contains("/tests/") || rel.ends_with("/tests.rs")
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
fn allowed_diagnostic_or_migration_source(rel: &str, line: &str) -> bool {
|
|
407
|
+
rel.contains("/migration")
|
|
408
|
+
|| rel.contains("/diagnose")
|
|
409
|
+
|| rel.contains("diagnose")
|
|
410
|
+
|| line.contains(READ_MARKER)
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
fn source_lines_for(paths: &[&str]) -> Vec<(String, usize, String)> {
|
|
414
|
+
paths
|
|
415
|
+
.iter()
|
|
416
|
+
.flat_map(|rel| source_lines_under(rel))
|
|
417
|
+
.collect()
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
fn source_lines_under(rel: &str) -> Vec<(String, usize, String)> {
|
|
421
|
+
let mut out = Vec::new();
|
|
422
|
+
if rel.ends_with(".rs") {
|
|
423
|
+
for (part_rel, text) in composite_source::composite_files(rel) {
|
|
424
|
+
for (index, line) in text.lines().enumerate() {
|
|
425
|
+
out.push((part_rel.clone(), index + 1, line.to_string()));
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
return out;
|
|
429
|
+
}
|
|
430
|
+
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join(rel);
|
|
431
|
+
append_source_lines(&root, Path::new(env!("CARGO_MANIFEST_DIR")), &mut out);
|
|
432
|
+
out
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
fn append_source_lines(path: &Path, base: &Path, out: &mut Vec<(String, usize, String)>) {
|
|
436
|
+
if path.is_dir() {
|
|
437
|
+
let mut entries = std::fs::read_dir(path)
|
|
438
|
+
.expect("read source dir")
|
|
439
|
+
.map(|entry| entry.expect("read source entry").path())
|
|
440
|
+
.collect::<Vec<PathBuf>>();
|
|
441
|
+
entries.sort();
|
|
442
|
+
for entry in entries {
|
|
443
|
+
append_source_lines(&entry, base, out);
|
|
444
|
+
}
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
if path.extension().and_then(|v| v.to_str()) != Some("rs") {
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
let rel = path
|
|
451
|
+
.strip_prefix(base)
|
|
452
|
+
.unwrap_or(path)
|
|
453
|
+
.to_string_lossy()
|
|
454
|
+
.to_string();
|
|
455
|
+
let text = std::fs::read_to_string(path).expect("read source file");
|
|
456
|
+
for (idx, line) in text.lines().enumerate() {
|
|
457
|
+
out.push((rel.clone(), idx + 1, line.trim().to_string()));
|
|
458
|
+
}
|
|
459
|
+
}
|