@team-agent/installer 0.5.128 → 0.6.0
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/README.md +4 -4
- package/README.zh.md +1 -1
- package/package.json +4 -8
- package/skills/team-agent/SKILL.md +37 -20
- package/skills/team-agent/command-coverage.json +169 -183
- package/skills/team-agent/docs/reference/team-agent-operator.md +64 -30
- package/skills/team-agent/references/recovery-runbook.md +1 -1
- package/skills/team-agent/references/team-agent-operator.md +64 -30
- package/templates/team_state.md +1 -1
- package/Cargo.lock +0 -1063
- package/Cargo.toml +0 -36
- package/crates/team-agent/Cargo.toml +0 -69
- package/crates/team-agent/src/app_server_test_support.rs +0 -258
- package/crates/team-agent/src/cli/adapters.rs +0 -1288
- package/crates/team-agent/src/cli/arguments.rs +0 -405
- package/crates/team-agent/src/cli/attach_app_server_leader.rs +0 -98
- package/crates/team-agent/src/cli/diagnose.rs +0 -1721
- package/crates/team-agent/src/cli/emit.rs +0 -2930
- package/crates/team-agent/src/cli/grok_slot.rs +0 -384
- package/crates/team-agent/src/cli/helpers.rs +0 -91
- package/crates/team-agent/src/cli/intent/runtime.rs +0 -1216
- package/crates/team-agent/src/cli/intent/runtime_tests.rs +0 -912
- package/crates/team-agent/src/cli/intent/tests.rs +0 -689
- package/crates/team-agent/src/cli/intent.rs +0 -664
- package/crates/team-agent/src/cli/leader.rs +0 -300
- package/crates/team-agent/src/cli/leader_prompt.rs +0 -261
- package/crates/team-agent/src/cli/leaders.rs +0 -418
- package/crates/team-agent/src/cli/mod.rs +0 -6545
- package/crates/team-agent/src/cli/models.rs +0 -1206
- package/crates/team-agent/src/cli/named_address.rs +0 -1651
- package/crates/team-agent/src/cli/profile.rs +0 -342
- package/crates/team-agent/src/cli/route.rs +0 -212
- package/crates/team-agent/src/cli/schedule.rs +0 -175
- package/crates/team-agent/src/cli/send/coordinator.rs +0 -164
- package/crates/team-agent/src/cli/send/mailbox.rs +0 -145
- package/crates/team-agent/src/cli/send/persist.rs +0 -156
- package/crates/team-agent/src/cli/send/presentation.rs +0 -370
- package/crates/team-agent/src/cli/send/resolve.rs +0 -573
- package/crates/team-agent/src/cli/send.rs +0 -199
- package/crates/team-agent/src/cli/shutdown_socket.rs +0 -288
- package/crates/team-agent/src/cli/spec.rs +0 -165
- package/crates/team-agent/src/cli/status.rs +0 -280
- package/crates/team-agent/src/cli/status_port/agents.rs +0 -358
- package/crates/team-agent/src/cli/status_port/approvals.rs +0 -79
- package/crates/team-agent/src/cli/status_port/brief.rs +0 -1981
- package/crates/team-agent/src/cli/status_port/compact.rs +0 -240
- package/crates/team-agent/src/cli/status_port/format.rs +0 -146
- package/crates/team-agent/src/cli/status_port/inbox.rs +0 -62
- package/crates/team-agent/src/cli/status_port/runtime.rs +0 -197
- package/crates/team-agent/src/cli/status_port/snapshot.rs +0 -208
- package/crates/team-agent/src/cli/status_port/store.rs +0 -416
- package/crates/team-agent/src/cli/status_port/tests.rs +0 -90
- package/crates/team-agent/src/cli/status_port.rs +0 -92
- package/crates/team-agent/src/cli/tests/base.rs +0 -885
- package/crates/team-agent/src/cli/tests/divergence.rs +0 -518
- package/crates/team-agent/src/cli/tests/lane_c.rs +0 -453
- package/crates/team-agent/src/cli/tests/leader_watch.rs +0 -322
- package/crates/team-agent/src/cli/tests/main_preserved.rs +0 -430
- package/crates/team-agent/src/cli/tests/missing_subcommands.rs +0 -336
- package/crates/team-agent/src/cli/tests/mod.rs +0 -137
- package/crates/team-agent/src/cli/tests/named_address.rs +0 -761
- package/crates/team-agent/src/cli/tests/parser_safety.rs +0 -383
- package/crates/team-agent/src/cli/tests/run_delegation.rs +0 -484
- package/crates/team-agent/src/cli/tests/shutdown_kill_plan.rs +0 -2179
- package/crates/team-agent/src/cli/tests/status_brief.rs +0 -1514
- package/crates/team-agent/src/cli/tests/status_send.rs +0 -888
- package/crates/team-agent/src/cli/tests/verb_install_skill.rs +0 -93
- package/crates/team-agent/src/cli/tests/verb_profile.rs +0 -392
- package/crates/team-agent/src/cli/triage.rs +0 -234
- package/crates/team-agent/src/cli/types.rs +0 -591
- package/crates/team-agent/src/codex_app_server.rs +0 -546
- package/crates/team-agent/src/communication_mode/mod.rs +0 -56
- package/crates/team-agent/src/compiler/tests.rs +0 -827
- package/crates/team-agent/src/compiler.rs +0 -890
- package/crates/team-agent/src/conpty/backend.rs +0 -829
- package/crates/team-agent/src/conpty/mod.rs +0 -33
- package/crates/team-agent/src/contract_runtime/backend.rs +0 -1744
- package/crates/team-agent/src/contract_runtime/commands.rs +0 -671
- package/crates/team-agent/src/contract_runtime/config.rs +0 -364
- package/crates/team-agent/src/contract_runtime/config_tests.rs +0 -76
- package/crates/team-agent/src/contract_runtime/discovery.rs +0 -449
- package/crates/team-agent/src/contract_runtime/fork.rs +0 -361
- package/crates/team-agent/src/contract_runtime/forward.rs +0 -288
- package/crates/team-agent/src/contract_runtime/framework.rs +0 -367
- package/crates/team-agent/src/contract_runtime/mcp.rs +0 -394
- package/crates/team-agent/src/contract_runtime/mod.rs +0 -17
- package/crates/team-agent/src/contract_runtime/prompt.rs +0 -216
- package/crates/team-agent/src/contract_runtime/pump.rs +0 -271
- package/crates/team-agent/src/contract_runtime/registry.rs +0 -553
- package/crates/team-agent/src/contract_runtime/workspace.rs +0 -228
- package/crates/team-agent/src/coordinator/backoff.rs +0 -741
- package/crates/team-agent/src/coordinator/conpty_shim.rs +0 -805
- package/crates/team-agent/src/coordinator/health.rs +0 -1185
- package/crates/team-agent/src/coordinator/mod.rs +0 -119
- package/crates/team-agent/src/coordinator/orphan.rs +0 -110
- package/crates/team-agent/src/coordinator/runtime_detectors.rs +0 -798
- package/crates/team-agent/src/coordinator/runtime_observation.rs +0 -84
- package/crates/team-agent/src/coordinator/steps/abnormal.rs +0 -2309
- package/crates/team-agent/src/coordinator/steps/delivery.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/health_sync.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/mod.rs +0 -126
- package/crates/team-agent/src/coordinator/steps/persist.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/runtime_prompts.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/session_gate.rs +0 -16
- package/crates/team-agent/src/coordinator/tests/a0_lostupdate.rs +0 -158
- package/crates/team-agent/src/coordinator/tests/abnormal.rs +0 -312
- package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +0 -300
- package/crates/team-agent/src/coordinator/tests/basics.rs +0 -211
- package/crates/team-agent/src/coordinator/tests/daemon.rs +0 -514
- package/crates/team-agent/src/coordinator/tests/energy.rs +0 -549
- package/crates/team-agent/src/coordinator/tests/health_sync.rs +0 -503
- package/crates/team-agent/src/coordinator/tests/main_preserved.rs +0 -186
- package/crates/team-agent/src/coordinator/tests/mod.rs +0 -295
- package/crates/team-agent/src/coordinator/tests/s3_bounded.rs +0 -207
- package/crates/team-agent/src/coordinator/tests/spine.rs +0 -308
- package/crates/team-agent/src/coordinator/tests/takeover.rs +0 -286
- package/crates/team-agent/src/coordinator/tests/tick_core.rs +0 -237
- package/crates/team-agent/src/coordinator/tick.rs +0 -3024
- package/crates/team-agent/src/coordinator/types.rs +0 -540
- package/crates/team-agent/src/db/agent_health_capture.rs +0 -126
- package/crates/team-agent/src/db/message_store.rs +0 -1527
- package/crates/team-agent/src/db/migration.rs +0 -984
- package/crates/team-agent/src/db/mod.rs +0 -26
- package/crates/team-agent/src/db/schema.rs +0 -663
- package/crates/team-agent/src/diagnose/comms.rs +0 -242
- package/crates/team-agent/src/diagnose/mod.rs +0 -44
- package/crates/team-agent/src/diagnose/orphans.rs +0 -889
- package/crates/team-agent/src/direct_delivery.rs +0 -368
- package/crates/team-agent/src/event_log.rs +0 -502
- package/crates/team-agent/src/fake_worker.rs +0 -303
- package/crates/team-agent/src/inbox_store.rs +0 -169
- package/crates/team-agent/src/kill_audit.rs +0 -106
- package/crates/team-agent/src/layout/manager.rs +0 -248
- package/crates/team-agent/src/layout/mod.rs +0 -36
- package/crates/team-agent/src/layout/overlay.rs +0 -134
- package/crates/team-agent/src/layout/placement.rs +0 -52
- package/crates/team-agent/src/layout/recovery.rs +0 -106
- package/crates/team-agent/src/layout/runtime_sessions.rs +0 -317
- package/crates/team-agent/src/layout/sessions.rs +0 -294
- package/crates/team-agent/src/layout/tmux_endpoint.rs +0 -165
- package/crates/team-agent/src/layout/worker_env.rs +0 -721
- package/crates/team-agent/src/layout/worker_window_helpers.rs +0 -37
- package/crates/team-agent/src/leader/helpers.rs +0 -178
- package/crates/team-agent/src/leader/incident.rs +0 -6
- package/crates/team-agent/src/leader/lease.rs +0 -3356
- package/crates/team-agent/src/leader/mod.rs +0 -104
- package/crates/team-agent/src/leader/owner_bind.rs +0 -400
- package/crates/team-agent/src/leader/prompt.rs +0 -905
- package/crates/team-agent/src/leader/provider_attribution.rs +0 -247
- package/crates/team-agent/src/leader/rediscover/tests.rs +0 -689
- package/crates/team-agent/src/leader/rediscover.rs +0 -1192
- package/crates/team-agent/src/leader/registry.rs +0 -888
- package/crates/team-agent/src/leader/start.rs +0 -4501
- package/crates/team-agent/src/leader/takeover.rs +0 -65
- package/crates/team-agent/src/leader/tests/basics.rs +0 -337
- package/crates/team-agent/src/leader/tests/byte_findings.rs +0 -355
- package/crates/team-agent/src/leader/tests/claim_leader_mailbox_flush_contract.rs +0 -544
- package/crates/team-agent/src/leader/tests/historical_inventory_upgrade_gate_red.rs +0 -624
- package/crates/team-agent/src/leader/tests/identity.rs +0 -465
- package/crates/team-agent/src/leader/tests/identity_session_names.rs +0 -42
- package/crates/team-agent/src/leader/tests/idle.rs +0 -113
- package/crates/team-agent/src/leader/tests/lease_api.rs +0 -520
- package/crates/team-agent/src/leader/tests/lease_claim.rs +0 -629
- package/crates/team-agent/src/leader/tests/mod.rs +0 -106
- package/crates/team-agent/src/leader/tests/prompt_contract.rs +0 -268
- package/crates/team-agent/src/leader/tests/rediscover.rs +0 -403
- package/crates/team-agent/src/leader/tests/rehomed_env.rs +0 -83
- package/crates/team-agent/src/leader/tests/team_in_team_state_scope_red.rs +0 -1273
- package/crates/team-agent/src/leader/tests/terminal_and_replay_vs_rerender_invariants_red.rs +0 -417
- package/crates/team-agent/src/leader/tests/wake_start_owner.rs +0 -168
- package/crates/team-agent/src/leader/types.rs +0 -534
- package/crates/team-agent/src/lib.rs +0 -147
- package/crates/team-agent/src/lifecycle/helpers.rs +0 -212
- package/crates/team-agent/src/lifecycle/launch/add_agent.rs +0 -881
- package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +0 -598
- package/crates/team-agent/src/lifecycle/launch/agent_state.rs +0 -332
- package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +0 -204
- package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +0 -107
- package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +0 -144
- package/crates/team-agent/src/lifecycle/launch/identity.rs +0 -674
- package/crates/team-agent/src/lifecycle/launch/layout.rs +0 -350
- package/crates/team-agent/src/lifecycle/launch/leader_context.rs +0 -589
- package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +0 -160
- package/crates/team-agent/src/lifecycle/launch/ownership.rs +0 -105
- package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +0 -899
- package/crates/team-agent/src/lifecycle/launch/pi_mcp_extension.js +0 -225
- package/crates/team-agent/src/lifecycle/launch/plan.rs +0 -269
- package/crates/team-agent/src/lifecycle/launch/quick_start.rs +0 -5200
- package/crates/team-agent/src/lifecycle/launch/quick_start_transport.rs +0 -368
- package/crates/team-agent/src/lifecycle/launch/readiness.rs +0 -519
- package/crates/team-agent/src/lifecycle/launch/role_source.rs +0 -287
- package/crates/team-agent/src/lifecycle/launch/spawn.rs +0 -473
- package/crates/team-agent/src/lifecycle/launch/spec_state.rs +0 -801
- package/crates/team-agent/src/lifecycle/launch/state_projection.rs +0 -624
- package/crates/team-agent/src/lifecycle/launch/worker_env.rs +0 -558
- package/crates/team-agent/src/lifecycle/launch.rs +0 -557
- package/crates/team-agent/src/lifecycle/lock.rs +0 -350
- package/crates/team-agent/src/lifecycle/mod.rs +0 -79
- package/crates/team-agent/src/lifecycle/pane_input_lock.rs +0 -239
- package/crates/team-agent/src/lifecycle/profile_launch.rs +0 -1067
- package/crates/team-agent/src/lifecycle/profile_smoke.rs +0 -557
- package/crates/team-agent/src/lifecycle/restart/agent.rs +0 -2199
- package/crates/team-agent/src/lifecycle/restart/avatar.rs +0 -1798
- package/crates/team-agent/src/lifecycle/restart/claude_fork.rs +0 -163
- package/crates/team-agent/src/lifecycle/restart/common.rs +0 -2362
- package/crates/team-agent/src/lifecycle/restart/orchestrator.rs +0 -65
- package/crates/team-agent/src/lifecycle/restart/preflight.rs +0 -113
- package/crates/team-agent/src/lifecycle/restart/rebuild.rs +0 -5135
- package/crates/team-agent/src/lifecycle/restart/remove.rs +0 -1504
- package/crates/team-agent/src/lifecycle/restart/selection.rs +0 -559
- package/crates/team-agent/src/lifecycle/restart/team_state.rs +0 -329
- package/crates/team-agent/src/lifecycle/restart.rs +0 -227
- package/crates/team-agent/src/lifecycle/role_config.rs +0 -1230
- package/crates/team-agent/src/lifecycle/tests/acceptance_b_batch_red.rs +0 -1021
- package/crates/team-agent/src/lifecycle/tests/agent_ops.rs +0 -1205
- package/crates/team-agent/src/lifecycle/tests/b0_legacy_snapshot_nonauthority_contract.rs +0 -265
- package/crates/team-agent/src/lifecycle/tests/b0_reader_hideone_audit_contract.rs +0 -490
- package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +0 -656
- package/crates/team-agent/src/lifecycle/tests/claude_compatible_config_red.rs +0 -325
- package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +0 -447
- package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +0 -1638
- package/crates/team-agent/src/lifecycle/tests/clone_agent_preserves_source_tools.rs +0 -427
- package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +0 -770
- package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +0 -419
- package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +0 -2035
- package/crates/team-agent/src/lifecycle/tests/core.rs +0 -1327
- package/crates/team-agent/src/lifecycle/tests/f032_startup_prompt_best_effort_red.rs +0 -315
- package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_g0.stdout.txt +0 -222
- package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_spaced_ids.stdout.txt +0 -9
- package/crates/team-agent/src/lifecycle/tests/fixtures/pi_native_mcp_host.mjs +0 -72
- package/crates/team-agent/src/lifecycle/tests/gate_fixtures.rs +0 -562
- package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +0 -110
- package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +0 -512
- package/crates/team-agent/src/lifecycle/tests/host_cotenant_death_p0_contract.rs +0 -921
- package/crates/team-agent/src/lifecycle/tests/issue238_codex_effort_contract.rs +0 -68
- package/crates/team-agent/src/lifecycle/tests/lane_ops.rs +0 -1851
- package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +0 -3983
- package/crates/team-agent/src/lifecycle/tests/lifecycle_lock.rs +0 -339
- package/crates/team-agent/src/lifecycle/tests/lifecycle_rollback_red.rs +0 -596
- package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +0 -513
- package/crates/team-agent/src/lifecycle/tests/mcp_tool_name_format_red.rs +0 -69
- package/crates/team-agent/src/lifecycle/tests/phase_b_contracts.rs +0 -824
- package/crates/team-agent/src/lifecycle/tests/phase_golden.rs +0 -723
- package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +0 -164
- package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +0 -200
- package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +0 -210
- package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +0 -527
- package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +0 -1062
- package/crates/team-agent/src/lifecycle/tests/pi_fork_session_inheritance_red.rs +0 -1419
- package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +0 -98
- package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +0 -550
- package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +0 -226
- package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +0 -332
- package/crates/team-agent/src/lifecycle/tests/realmachine_clusters_1_6_red.rs +0 -786
- package/crates/team-agent/src/lifecycle/tests/realmachine_residual_g1_g4_red.rs +0 -648
- package/crates/team-agent/src/lifecycle/tests/restart.rs +0 -185
- package/crates/team-agent/src/lifecycle/tests/restart_build_before_destroy_0540_contract.rs +0 -1053
- package/crates/team-agent/src/lifecycle/tests/restart_liveness_red.rs +0 -679
- package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +0 -1126
- package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +0 -153
- package/crates/team-agent/src/lifecycle/tests/resume_recover_red.rs +0 -427
- package/crates/team-agent/src/lifecycle/tests/stale_team_saveconflict_contract.rs +0 -431
- package/crates/team-agent/src/lifecycle/tests/startup_latency_contract.rs +0 -1066
- package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +0 -876
- package/crates/team-agent/src/lifecycle/tests/subprep_codex_trust_roundtrip_red.rs +0 -1026
- package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +0 -342
- package/crates/team-agent/src/lifecycle/tests/team_in_team_identity_scope_red.rs +0 -543
- package/crates/team-agent/src/lifecycle/tests/team_in_team_sibling_quick_start_red.rs +0 -1103
- package/crates/team-agent/src/lifecycle/tests/team_in_team_state_scope_red.rs +0 -1276
- package/crates/team-agent/src/lifecycle/tests/team_key_retirement_roster_red.rs +0 -145
- package/crates/team-agent/src/lifecycle/tests/team_key_retirement_txn_red.rs +0 -603
- package/crates/team-agent/src/lifecycle/tests/test_isolation_escape_contract.rs +0 -936
- package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +0 -970
- package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +0 -995
- package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +0 -836
- package/crates/team-agent/src/lifecycle/tests.rs +0 -105
- package/crates/team-agent/src/lifecycle/types.rs +0 -877
- package/crates/team-agent/src/lifecycle/worker_command_context.rs +0 -363
- package/crates/team-agent/src/main.rs +0 -52
- package/crates/team-agent/src/mcp_server/helpers.rs +0 -510
- package/crates/team-agent/src/mcp_server/lifecycle_tools/mod.rs +0 -6
- package/crates/team-agent/src/mcp_server/lifecycle_tools/state_status.rs +0 -43
- package/crates/team-agent/src/mcp_server/mod.rs +0 -119
- package/crates/team-agent/src/mcp_server/normalize.rs +0 -485
- package/crates/team-agent/src/mcp_server/readiness.rs +0 -527
- package/crates/team-agent/src/mcp_server/readiness_tests.rs +0 -348
- package/crates/team-agent/src/mcp_server/tests/golden.rs +0 -285
- package/crates/team-agent/src/mcp_server/tests/normalize.rs +0 -247
- package/crates/team-agent/src/mcp_server/tests/scoped.rs +0 -158
- package/crates/team-agent/src/mcp_server/tests/send.rs +0 -353
- package/crates/team-agent/src/mcp_server/tests/tools.rs +0 -341
- package/crates/team-agent/src/mcp_server/tests/wire.rs +0 -254
- package/crates/team-agent/src/mcp_server/tests.rs +0 -43
- package/crates/team-agent/src/mcp_server/tools.rs +0 -889
- package/crates/team-agent/src/mcp_server/types.rs +0 -396
- package/crates/team-agent/src/mcp_server/wire.rs +0 -867
- package/crates/team-agent/src/messaging/activity.rs +0 -461
- package/crates/team-agent/src/messaging/address.rs +0 -87
- package/crates/team-agent/src/messaging/delivery.rs +0 -3727
- package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +0 -234
- package/crates/team-agent/src/messaging/enter_rescue.rs +0 -362
- package/crates/team-agent/src/messaging/enter_rescue_tests.rs +0 -633
- package/crates/team-agent/src/messaging/helpers.rs +0 -336
- package/crates/team-agent/src/messaging/leader_channel.rs +0 -287
- package/crates/team-agent/src/messaging/leader_receiver.rs +0 -786
- package/crates/team-agent/src/messaging/mod.rs +0 -167
- package/crates/team-agent/src/messaging/persist.rs +0 -377
- package/crates/team-agent/src/messaging/presentation.rs +0 -417
- package/crates/team-agent/src/messaging/reminders.rs +0 -316
- package/crates/team-agent/src/messaging/results/collection_tests.rs +0 -719
- package/crates/team-agent/src/messaging/results.rs +0 -1415
- package/crates/team-agent/src/messaging/scheduler.rs +0 -223
- package/crates/team-agent/src/messaging/selftest.rs +0 -315
- package/crates/team-agent/src/messaging/send.rs +0 -981
- package/crates/team-agent/src/messaging/tests/basic.rs +0 -346
- package/crates/team-agent/src/messaging/tests/dup_inject.rs +0 -657
- package/crates/team-agent/src/messaging/tests/e23.rs +0 -49
- package/crates/team-agent/src/messaging/tests/leader_channel.rs +0 -169
- package/crates/team-agent/src/messaging/tests/leader_inject_acceptance.rs +0 -817
- package/crates/team-agent/src/messaging/tests/main_preserved.rs +0 -85
- package/crates/team-agent/src/messaging/tests/mod.rs +0 -306
- package/crates/team-agent/src/messaging/tests/runtime.rs +0 -3549
- package/crates/team-agent/src/messaging/tests/spine.rs +0 -853
- package/crates/team-agent/src/messaging/tests/wave2.rs +0 -381
- package/crates/team-agent/src/messaging/trust.rs +0 -215
- package/crates/team-agent/src/messaging/types.rs +0 -472
- package/crates/team-agent/src/messaging/wait.rs +0 -366
- package/crates/team-agent/src/messaging/watchers.rs +0 -916
- package/crates/team-agent/src/model/enums.rs +0 -356
- package/crates/team-agent/src/model/errors.rs +0 -18
- package/crates/team-agent/src/model/ids.rs +0 -165
- package/crates/team-agent/src/model/mod.rs +0 -29
- package/crates/team-agent/src/model/name_similarity.rs +0 -252
- package/crates/team-agent/src/model/pane_authority_refusal.rs +0 -359
- package/crates/team-agent/src/model/paths.rs +0 -257
- package/crates/team-agent/src/model/routing.rs +0 -387
- package/crates/team-agent/src/model/spec.rs +0 -1184
- package/crates/team-agent/src/model/task_graph.rs +0 -321
- package/crates/team-agent/src/model/testdata/fuzz.golden.yaml +0 -43
- package/crates/team-agent/src/model/testdata/fuzz.yaml +0 -43
- package/crates/team-agent/src/model/testdata/spec_invalid_a.yaml +0 -209
- package/crates/team-agent/src/model/testdata/team.spec.golden.yaml +0 -208
- package/crates/team-agent/src/model/testdata/team.spec.yaml +0 -208
- package/crates/team-agent/src/model/yaml/tests.rs +0 -188
- package/crates/team-agent/src/model/yaml.rs +0 -802
- package/crates/team-agent/src/os_probe.rs +0 -280
- package/crates/team-agent/src/packaging/install.rs +0 -219
- package/crates/team-agent/src/packaging/migrate.rs +0 -38
- package/crates/team-agent/src/packaging/mod.rs +0 -91
- package/crates/team-agent/src/packaging/repair.rs +0 -33
- package/crates/team-agent/src/packaging/tests.rs +0 -822
- package/crates/team-agent/src/packaging/types.rs +0 -417
- package/crates/team-agent/src/platform/argv.rs +0 -331
- package/crates/team-agent/src/platform/errors.rs +0 -104
- package/crates/team-agent/src/platform/file_lock.rs +0 -279
- package/crates/team-agent/src/platform/mod.rs +0 -5
- package/crates/team-agent/src/platform/process.rs +0 -545
- package/crates/team-agent/src/provider/adapter.rs +0 -1150
- package/crates/team-agent/src/provider/adapters/claude.rs +0 -78
- package/crates/team-agent/src/provider/adapters/claude_fork.rs +0 -131
- package/crates/team-agent/src/provider/adapters/copilot.rs +0 -75
- package/crates/team-agent/src/provider/adapters/copilot_fork.rs +0 -307
- package/crates/team-agent/src/provider/adapters/fake.rs +0 -18
- package/crates/team-agent/src/provider/adapters/mod.rs +0 -30
- package/crates/team-agent/src/provider/adapters/pi.rs +0 -106
- package/crates/team-agent/src/provider/approvals/mod.rs +0 -3
- package/crates/team-agent/src/provider/approvals/parsing.rs +0 -586
- package/crates/team-agent/src/provider/approvals/runtime_prompts.rs +0 -205
- package/crates/team-agent/src/provider/argv_route.rs +0 -405
- package/crates/team-agent/src/provider/bypass_flags.rs +0 -116
- package/crates/team-agent/src/provider/classify.rs +0 -708
- package/crates/team-agent/src/provider/command_helpers.rs +0 -45
- package/crates/team-agent/src/provider/faults.rs +0 -165
- package/crates/team-agent/src/provider/helpers.rs +0 -52
- package/crates/team-agent/src/provider/mod.rs +0 -78
- package/crates/team-agent/src/provider/model_catalog.rs +0 -910
- package/crates/team-agent/src/provider/session/capture.rs +0 -2731
- package/crates/team-agent/src/provider/session/context_fork/claude.rs +0 -123
- package/crates/team-agent/src/provider/session/context_fork/outcome.rs +0 -172
- package/crates/team-agent/src/provider/session/context_fork.rs +0 -396
- package/crates/team-agent/src/provider/session/mod.rs +0 -36
- package/crates/team-agent/src/provider/session/resume.rs +0 -269
- package/crates/team-agent/src/provider/session_scan/claude.rs +0 -523
- package/crates/team-agent/src/provider/session_scan/common/tests.rs +0 -316
- package/crates/team-agent/src/provider/session_scan/common.rs +0 -654
- package/crates/team-agent/src/provider/session_scan/copilot.rs +0 -280
- package/crates/team-agent/src/provider/session_scan/pi.rs +0 -185
- package/crates/team-agent/src/provider/session_scan.rs +0 -71
- package/crates/team-agent/src/provider/startup_prompt.rs +0 -757
- package/crates/team-agent/src/provider/submit_now.rs +0 -71
- package/crates/team-agent/src/provider/testdata/copilot-ready-marker.txt +0 -5
- package/crates/team-agent/src/provider/testdata/copilot-trust-prompt.txt +0 -19
- package/crates/team-agent/src/provider/testdata/grok-models-authenticated.stdout +0 -9
- package/crates/team-agent/src/provider/testdata/grok-models-unauthenticated.stdout +0 -7
- package/crates/team-agent/src/provider/tests/adapter.rs +0 -441
- package/crates/team-agent/src/provider/tests/classify.rs +0 -148
- package/crates/team-agent/src/provider/tests/command_helpers.rs +0 -35
- package/crates/team-agent/src/provider/tests/copilot_fork.rs +0 -191
- package/crates/team-agent/src/provider/tests/faults.rs +0 -200
- package/crates/team-agent/src/provider/tests/idle.rs +0 -177
- package/crates/team-agent/src/provider/tests/wire.rs +0 -213
- package/crates/team-agent/src/provider/tests.rs +0 -32
- package/crates/team-agent/src/provider/types.rs +0 -529
- package/crates/team-agent/src/provider/wire.rs +0 -394
- package/crates/team-agent/src/redaction.rs +0 -259
- package/crates/team-agent/src/state/abnormal_watch/tests/mod.rs +0 -248
- package/crates/team-agent/src/state/abnormal_watch.rs +0 -144
- package/crates/team-agent/src/state/identity.rs +0 -914
- package/crates/team-agent/src/state/identity_keys.rs +0 -132
- package/crates/team-agent/src/state/mod.rs +0 -74
- package/crates/team-agent/src/state/owner_gate.rs +0 -482
- package/crates/team-agent/src/state/ownership.rs +0 -563
- package/crates/team-agent/src/state/paths.rs +0 -395
- package/crates/team-agent/src/state/persist.rs +0 -3811
- package/crates/team-agent/src/state/projection.rs +0 -1508
- package/crates/team-agent/src/state/repository/intent.rs +0 -14
- package/crates/team-agent/src/state/repository/tests.rs +0 -184
- package/crates/team-agent/src/state/repository.rs +0 -866
- package/crates/team-agent/src/state/selector.rs +0 -160
- package/crates/team-agent/src/state/testdata/state-rich.canonical.json +0 -133
- package/crates/team-agent/src/test_support/models_timeout_fixture.rs +0 -144
- package/crates/team-agent/src/tmux_backend/enter_rescue.rs +0 -325
- package/crates/team-agent/src/tmux_backend/enter_rescue_tests.rs +0 -432
- package/crates/team-agent/src/tmux_backend/native_input.rs +0 -513
- package/crates/team-agent/src/tmux_backend/native_input_tests.rs +0 -742
- package/crates/team-agent/src/tmux_backend/tests.rs +0 -4103
- package/crates/team-agent/src/tmux_backend.rs +0 -4492
- package/crates/team-agent/src/topology.rs +0 -537
- package/crates/team-agent/src/transport/enter_rescue.rs +0 -166
- package/crates/team-agent/src/transport/native_input.rs +0 -491
- package/crates/team-agent/src/transport/test_support.rs +0 -743
- package/crates/team-agent/src/transport/tests/behavior.rs +0 -326
- package/crates/team-agent/src/transport/tests/mod.rs +0 -194
- package/crates/team-agent/src/transport/tests/wire.rs +0 -574
- package/crates/team-agent/src/transport.rs +0 -1655
- package/crates/team-agent/src/transport_factory.rs +0 -819
|
@@ -1,876 +0,0 @@
|
|
|
1
|
-
//! P0 RED contract: external diagnostic projections never expose credential values.
|
|
2
|
-
//!
|
|
3
|
-
//! Source: `.team/artifacts/status-credential-redact-locate.md` §8 RED1-RED7.
|
|
4
|
-
|
|
5
|
-
#![allow(clippy::expect_used, clippy::panic, clippy::unwrap_used)]
|
|
6
|
-
|
|
7
|
-
#[path = "../../../tests/support/hermetic.rs"]
|
|
8
|
-
mod hermetic_guard;
|
|
9
|
-
|
|
10
|
-
#[path = "../../../tests/support/composite_source.rs"]
|
|
11
|
-
mod composite_source;
|
|
12
|
-
use std::fs;
|
|
13
|
-
use std::io::{Read, Write};
|
|
14
|
-
use std::net::TcpListener;
|
|
15
|
-
#[cfg(unix)]
|
|
16
|
-
use std::os::unix::fs::PermissionsExt;
|
|
17
|
-
use std::path::{Path, PathBuf};
|
|
18
|
-
use std::process::{Command, Stdio};
|
|
19
|
-
use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
|
|
20
|
-
use std::sync::Arc;
|
|
21
|
-
use std::thread;
|
|
22
|
-
use std::time::{Duration, Instant};
|
|
23
|
-
|
|
24
|
-
use serde_json::{json, Value};
|
|
25
|
-
use serial_test::serial;
|
|
26
|
-
use team_agent::cli::{cmd_doctor, emit, CmdOutput, DoctorArgs};
|
|
27
|
-
use team_agent::event_log::EventLog;
|
|
28
|
-
use team_agent::message_store::MessageStore;
|
|
29
|
-
use team_agent::state::persist::save_runtime_state;
|
|
30
|
-
#[cfg(unix)]
|
|
31
|
-
use team_agent::tmux_backend::TmuxBackend;
|
|
32
|
-
#[cfg(unix)]
|
|
33
|
-
use team_agent::transport::{InjectPayload, Key, PaneId, Target, Transport};
|
|
34
|
-
|
|
35
|
-
const REDACTED: &str = "[REDACTED]";
|
|
36
|
-
|
|
37
|
-
#[test]
|
|
38
|
-
#[serial(env)]
|
|
39
|
-
fn red1_external_redaction_has_one_shared_module_and_two_crate_entry_points() {
|
|
40
|
-
let root = Path::new(env!("CARGO_MANIFEST_DIR"));
|
|
41
|
-
let redaction = fs::read_to_string(root.join("src/redaction.rs")).unwrap_or_default();
|
|
42
|
-
let lib = fs::read_to_string(root.join("src/lib.rs")).unwrap();
|
|
43
|
-
let crate_entries = redaction
|
|
44
|
-
.lines()
|
|
45
|
-
.filter_map(|line| line.trim().strip_prefix("pub(crate) fn "))
|
|
46
|
-
.filter_map(|line| line.split('(').next())
|
|
47
|
-
.collect::<Vec<_>>();
|
|
48
|
-
let marker = synthetic_marker();
|
|
49
|
-
let env = hermetic_guard::HermeticTestEnv::enter("redact-red1");
|
|
50
|
-
env.scrub_tmux();
|
|
51
|
-
env.assert_no_real_tmux();
|
|
52
|
-
let log = EventLog::new(&env.workspace("red1"));
|
|
53
|
-
let written = log
|
|
54
|
-
.write("redaction.contract", mixed_sensitive_value(&marker))
|
|
55
|
-
.unwrap();
|
|
56
|
-
let tail = log.tail(0).unwrap();
|
|
57
|
-
let text = Value::Array(tail.clone()).to_string();
|
|
58
|
-
let idempotent = tail.first() == Some(&written);
|
|
59
|
-
|
|
60
|
-
assert!(
|
|
61
|
-
lib.lines().any(|line| line.trim() == "mod redaction;")
|
|
62
|
-
&& crate_entries == ["redact_external_value", "redact_external_text"]
|
|
63
|
-
&& !text.contains(&marker)
|
|
64
|
-
&& text.contains(REDACTED)
|
|
65
|
-
&& text.contains("https://[REDACTED]@proxy.invalid:8443/path")
|
|
66
|
-
&& idempotent,
|
|
67
|
-
"RED1: one internal module with exactly two crate entry points must recursively mask mixed values and remain idempotent; no third public crate scrubber is allowed"
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
#[test]
|
|
72
|
-
#[serial(env)]
|
|
73
|
-
fn red2_false_positive_guard_preserves_team_provider_and_model_truth() {
|
|
74
|
-
let marker = synthetic_marker();
|
|
75
|
-
let (env, workspace) = redaction_case("red2", &marker, "current");
|
|
76
|
-
let status = team_agent::cli::status_port::status(&workspace, false, true)
|
|
77
|
-
.expect("detail status must remain available");
|
|
78
|
-
let text = status.to_string();
|
|
79
|
-
let diagnostics = status
|
|
80
|
-
.pointer("/teams/current/diagnostics")
|
|
81
|
-
.expect("raw selected-team diagnostics remain present");
|
|
82
|
-
let structural_fields_preserved = [
|
|
83
|
-
("/team_key", json!("current")),
|
|
84
|
-
("/auth_mode", json!("subscription")),
|
|
85
|
-
("/provider", json!("copilot")),
|
|
86
|
-
("/model", json!("gpt-contract")),
|
|
87
|
-
("/provider_source", json!("role")),
|
|
88
|
-
("/model_source", json!("role")),
|
|
89
|
-
("/model_stale", json!(true)),
|
|
90
|
-
("/session_id", json!("session-contract")),
|
|
91
|
-
("/pane_id", json!("%contract")),
|
|
92
|
-
("/monkey", json!("banana")),
|
|
93
|
-
("/author", json!("operator")),
|
|
94
|
-
("/normal_url", json!("https://proxy.invalid/health")),
|
|
95
|
-
("/already_redacted", json!(REDACTED)),
|
|
96
|
-
]
|
|
97
|
-
.iter()
|
|
98
|
-
.all(|(pointer, expected)| diagnostics.pointer(pointer) == Some(expected));
|
|
99
|
-
let marker_absent = !text.contains(&marker);
|
|
100
|
-
let replacement_present = text.contains(REDACTED);
|
|
101
|
-
let url_structure_preserved = text.contains("https://[REDACTED]@proxy.invalid:8443/path");
|
|
102
|
-
assert!(
|
|
103
|
-
marker_absent
|
|
104
|
-
&& replacement_present
|
|
105
|
-
&& structural_fields_preserved
|
|
106
|
-
&& url_structure_preserved,
|
|
107
|
-
"RED2: recursive masking must remove the synthetic marker while preserving structural provider/model/identity fields and URL host/path; marker_absent={marker_absent} replacement_present={replacement_present} structural_fields_preserved={structural_fields_preserved} url_structure_preserved={url_structure_preserved}"
|
|
108
|
-
);
|
|
109
|
-
drop(env);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
#[test]
|
|
113
|
-
#[serial(env)]
|
|
114
|
-
fn red3_full_and_compact_status_never_expose_restart_credentials() {
|
|
115
|
-
let marker = synthetic_marker();
|
|
116
|
-
let (env, workspace) = redaction_case("red3", &marker, "current");
|
|
117
|
-
let full = team_agent::cli::status_port::status(&workspace, false, true)
|
|
118
|
-
.expect("full status must remain available");
|
|
119
|
-
let compact = team_agent::cli::status_port::status(&workspace, true, false)
|
|
120
|
-
.expect("compact status must remain available");
|
|
121
|
-
let full_text = full.to_string();
|
|
122
|
-
let compact_text = compact.to_string();
|
|
123
|
-
let full_safe = !full_text.contains(&marker) && full_text.contains(REDACTED);
|
|
124
|
-
let compact_safe = !compact_text.contains(&marker);
|
|
125
|
-
let diagnostics_preserved = [
|
|
126
|
-
"/agents/worker/restart_error",
|
|
127
|
-
"/teams/current/agents/worker/restart_error",
|
|
128
|
-
]
|
|
129
|
-
.iter()
|
|
130
|
-
.all(|pointer| {
|
|
131
|
-
full.pointer(pointer)
|
|
132
|
-
.and_then(Value::as_str)
|
|
133
|
-
.is_some_and(|error| {
|
|
134
|
-
error.contains("subprocess exited 37")
|
|
135
|
-
&& error.contains("HTTPS_PROXY")
|
|
136
|
-
&& error.contains("proxy.invalid:8443/path")
|
|
137
|
-
&& error.contains(REDACTED)
|
|
138
|
-
})
|
|
139
|
-
});
|
|
140
|
-
assert!(
|
|
141
|
-
full_safe && compact_safe && diagnostics_preserved,
|
|
142
|
-
"RED3: full/compact status must mask credentials and full detail must retain restart classification/key/host/path; full_safe={full_safe} compact_safe={compact_safe} diagnostics_preserved={diagnostics_preserved}"
|
|
143
|
-
);
|
|
144
|
-
drop(env);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
#[test]
|
|
148
|
-
#[serial(env)]
|
|
149
|
-
fn red4_jsonrpc_and_legacy_mcp_status_never_expose_raw_team_credentials() {
|
|
150
|
-
let marker = synthetic_marker();
|
|
151
|
-
let team_key = "redaction-contract";
|
|
152
|
-
let (env, workspace) = redaction_case("red4", &marker, team_key);
|
|
153
|
-
let frames = run_mcp_status_frames(&env, &workspace, team_key);
|
|
154
|
-
assert_eq!(
|
|
155
|
-
frames.len(),
|
|
156
|
-
2,
|
|
157
|
-
"RED4: real MCP stdio must answer JSON-RPC and legacy requests"
|
|
158
|
-
);
|
|
159
|
-
|
|
160
|
-
let outer = frames[0].to_string();
|
|
161
|
-
let content_text = frames[0]
|
|
162
|
-
.pointer("/result/content/0/text")
|
|
163
|
-
.and_then(Value::as_str)
|
|
164
|
-
.expect("JSON-RPC tools/call content text");
|
|
165
|
-
let body: Value = serde_json::from_str(content_text).expect("decoded MCP status body");
|
|
166
|
-
let outer_safe = !outer.contains(&marker);
|
|
167
|
-
let content_safe = !content_text.contains(&marker);
|
|
168
|
-
let body_preserved = body
|
|
169
|
-
.pointer(&format!("/teams/{team_key}/agents/worker/restart_error"))
|
|
170
|
-
.and_then(Value::as_str)
|
|
171
|
-
.is_some_and(|error| error.contains(REDACTED));
|
|
172
|
-
let legacy = frames[1].to_string();
|
|
173
|
-
let legacy_safe = !legacy.contains(&marker);
|
|
174
|
-
let legacy_preserved = frames[1]
|
|
175
|
-
.pointer(&format!("/teams/{team_key}/agents/worker/restart_error"))
|
|
176
|
-
.and_then(Value::as_str)
|
|
177
|
-
.is_some_and(|error| error.contains(REDACTED));
|
|
178
|
-
assert!(
|
|
179
|
-
outer_safe && content_safe && body_preserved && legacy_safe && legacy_preserved,
|
|
180
|
-
"RED4: JSON-RPC outer/text and legacy frames must all mask the synthetic marker while preserving selected raw-team diagnostics; outer_safe={outer_safe} content_safe={content_safe} body_preserved={body_preserved} legacy_safe={legacy_safe} legacy_preserved={legacy_preserved}"
|
|
181
|
-
);
|
|
182
|
-
drop(env);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
#[test]
|
|
186
|
-
#[serial(env)]
|
|
187
|
-
fn red5_event_write_and_legacy_tail_are_redacted_and_idempotent() {
|
|
188
|
-
let marker = synthetic_marker();
|
|
189
|
-
let env = hermetic_guard::HermeticTestEnv::enter("redact-red5");
|
|
190
|
-
env.scrub_tmux();
|
|
191
|
-
env.assert_no_real_tmux();
|
|
192
|
-
let workspace = env.workspace("red5");
|
|
193
|
-
let log = EventLog::new(&workspace);
|
|
194
|
-
let diagnostic = restart_diagnostic(&marker);
|
|
195
|
-
let written = [
|
|
196
|
-
log.write(
|
|
197
|
-
"provider.worker.spawn_argv",
|
|
198
|
-
json!({
|
|
199
|
-
"authorization_header": format!("Bearer {marker}"),
|
|
200
|
-
"credential_blob": marker.clone(),
|
|
201
|
-
"config": format!("mcp_servers.demo.env.OPENAI_API_KEY=\"{marker}\""),
|
|
202
|
-
"argv": ["provider", "--api-key", marker.clone()],
|
|
203
|
-
}),
|
|
204
|
-
)
|
|
205
|
-
.unwrap(),
|
|
206
|
-
log.write(
|
|
207
|
-
"provider.worker.spawn_argv",
|
|
208
|
-
json!({"argv": ["provider", diagnostic.clone()]}),
|
|
209
|
-
)
|
|
210
|
-
.unwrap(),
|
|
211
|
-
log.write(
|
|
212
|
-
"start_agent.agent_start",
|
|
213
|
-
json!({"command": ["provider", diagnostic.clone()]}),
|
|
214
|
-
)
|
|
215
|
-
.unwrap(),
|
|
216
|
-
log.write(
|
|
217
|
-
"restart.agent_failed",
|
|
218
|
-
json!({"agent_id": "worker", "error": diagnostic.clone()}),
|
|
219
|
-
)
|
|
220
|
-
.unwrap(),
|
|
221
|
-
log.write(
|
|
222
|
-
"restart.completed",
|
|
223
|
-
json!({"failed_agents": [{"agent_id": "worker", "error": diagnostic}]}),
|
|
224
|
-
)
|
|
225
|
-
.unwrap(),
|
|
226
|
-
];
|
|
227
|
-
let path = workspace.join(".team/logs/events.jsonl");
|
|
228
|
-
let new_bytes = fs::read_to_string(&path).unwrap();
|
|
229
|
-
let new_bytes_safe = !new_bytes.contains(&marker) && new_bytes.contains(REDACTED);
|
|
230
|
-
|
|
231
|
-
let mut file = fs::OpenOptions::new().append(true).open(&path).unwrap();
|
|
232
|
-
writeln!(
|
|
233
|
-
file,
|
|
234
|
-
"{}",
|
|
235
|
-
json!({"event": "legacy.restart", "error": restart_diagnostic(&marker)})
|
|
236
|
-
)
|
|
237
|
-
.unwrap();
|
|
238
|
-
writeln!(
|
|
239
|
-
file,
|
|
240
|
-
"{}",
|
|
241
|
-
json!({
|
|
242
|
-
"event": "provider.session.converging",
|
|
243
|
-
"required_missing": ["worker"],
|
|
244
|
-
"pending": ["worker"]
|
|
245
|
-
})
|
|
246
|
-
)
|
|
247
|
-
.unwrap();
|
|
248
|
-
writeln!(file, "legacy malformed {}", restart_diagnostic(&marker)).unwrap();
|
|
249
|
-
let tail = log.tail(0).unwrap();
|
|
250
|
-
let tail_text = Value::Array(tail.clone()).to_string();
|
|
251
|
-
let tail_safe = !tail_text.contains(&marker) && tail_text.contains(REDACTED);
|
|
252
|
-
let double_boundary_idempotent = tail.first() == written.first();
|
|
253
|
-
let legacy_aliases_readable = tail.iter().any(|event| {
|
|
254
|
-
event.get("event").and_then(Value::as_str) == Some("provider.session.converging")
|
|
255
|
-
&& event.get("required_missing") == Some(&json!(["worker"]))
|
|
256
|
-
&& event.get("pending") == Some(&json!(["worker"]))
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
assert!(
|
|
260
|
-
new_bytes_safe && tail_safe && double_boundary_idempotent && legacy_aliases_readable,
|
|
261
|
-
"RED5: EventLog write bytes and legacy/malformed tail output must be masked; applying redaction at write then tail must be idempotent"
|
|
262
|
-
);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
#[test]
|
|
266
|
-
fn eventlog_producers_share_the_central_writer_and_canonical_schema() {
|
|
267
|
-
let root = Path::new(env!("CARGO_MANIFEST_DIR"));
|
|
268
|
-
let launch = composite_source::composite_source("src/lifecycle/launch.rs");
|
|
269
|
-
let common = fs::read_to_string(root.join("src/lifecycle/restart/common.rs")).unwrap();
|
|
270
|
-
let rebuild = fs::read_to_string(root.join("src/lifecycle/restart/rebuild.rs")).unwrap();
|
|
271
|
-
let helper_calls = [&launch, &common, &rebuild]
|
|
272
|
-
.iter()
|
|
273
|
-
.map(|source| source.matches("provider_worker_spawn_argv_fields(").count())
|
|
274
|
-
.sum::<usize>();
|
|
275
|
-
let convergence_writer = source_section(
|
|
276
|
-
&common,
|
|
277
|
-
"fn write_session_convergence_progress_event(",
|
|
278
|
-
"pub(crate) fn restart_required_missing_session_agent_ids(",
|
|
279
|
-
);
|
|
280
|
-
let resume_end = ["pub(crate) fn restart_candidates(", "pub fn restart_candidates("]
|
|
281
|
-
.into_iter()
|
|
282
|
-
.find(|marker| rebuild.contains(marker))
|
|
283
|
-
.expect("restart_candidates source section end");
|
|
284
|
-
let resume_writer = source_section(
|
|
285
|
-
&rebuild,
|
|
286
|
-
"fn write_restart_resume_decision_event(",
|
|
287
|
-
resume_end,
|
|
288
|
-
);
|
|
289
|
-
|
|
290
|
-
assert_eq!(
|
|
291
|
-
helper_calls, 3,
|
|
292
|
-
"launch/restart/fake must share one spawn schema helper"
|
|
293
|
-
);
|
|
294
|
-
assert!(!common.contains("\"required_missing\": progress"));
|
|
295
|
-
assert!(!common.contains("\"pending\": pending_agent_ids"));
|
|
296
|
-
for writer in [convergence_writer, resume_writer] {
|
|
297
|
-
assert!(writer.contains("EventLog::new"));
|
|
298
|
-
assert!(!writer.contains("OpenOptions"));
|
|
299
|
-
assert!(!writer.contains("write_all"));
|
|
300
|
-
assert!(!writer.contains("events.jsonl"));
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
fn source_section<'a>(source: &'a str, start: &str, end: &str) -> &'a str {
|
|
305
|
-
let start = source.find(start).expect("source section start");
|
|
306
|
-
let rest = &source[start..];
|
|
307
|
-
&rest[..rest.find(end).expect("source section end")]
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
#[test]
|
|
311
|
-
#[serial(env)]
|
|
312
|
-
fn red6_cli_restart_reports_and_top_level_error_logs_are_redacted() {
|
|
313
|
-
let marker = synthetic_marker();
|
|
314
|
-
let diagnostic = restart_diagnostic(&marker);
|
|
315
|
-
let mut regular_reports_safe = true;
|
|
316
|
-
for status in ["partial", "failed"] {
|
|
317
|
-
let output = CmdOutput::Json(json!({
|
|
318
|
-
"ok": false,
|
|
319
|
-
"status": status,
|
|
320
|
-
"reason": "restart_failed",
|
|
321
|
-
"failed_agents": [{"agent_id": "worker", "error": diagnostic.clone()}],
|
|
322
|
-
"action": "inspect the failed spawn and retry"
|
|
323
|
-
}));
|
|
324
|
-
for as_json in [true, false] {
|
|
325
|
-
let rendered = emit(&output, as_json).expect("restart report renders");
|
|
326
|
-
regular_reports_safe &= !rendered.contains(&marker)
|
|
327
|
-
&& rendered.contains("restart_failed")
|
|
328
|
-
&& rendered.contains("worker")
|
|
329
|
-
&& rendered.contains(REDACTED);
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
let env = hermetic_guard::HermeticTestEnv::enter("redact-red6");
|
|
334
|
-
env.scrub_tmux();
|
|
335
|
-
env.assert_no_real_tmux();
|
|
336
|
-
let workspace = env.workspace("red6");
|
|
337
|
-
let mut combined = String::new();
|
|
338
|
-
for json_mode in [true, false] {
|
|
339
|
-
let mut command = Command::new(crate::lifecycle::tests::test_binary_path());
|
|
340
|
-
command.arg("profile").arg(credential_url(&marker)).arg("synthetic-profile");
|
|
341
|
-
if json_mode {
|
|
342
|
-
command.arg("--json");
|
|
343
|
-
}
|
|
344
|
-
let output = command
|
|
345
|
-
.current_dir(&workspace)
|
|
346
|
-
.env("HOME", env.home())
|
|
347
|
-
.env_remove("TMUX")
|
|
348
|
-
.env_remove("TMUX_PANE")
|
|
349
|
-
.output()
|
|
350
|
-
.expect("run top-level CLI error boundary");
|
|
351
|
-
assert!(
|
|
352
|
-
!output.status.success(),
|
|
353
|
-
"invalid profile subcommand must reach CLI error"
|
|
354
|
-
);
|
|
355
|
-
combined.push_str(&String::from_utf8_lossy(&output.stdout));
|
|
356
|
-
combined.push_str(&String::from_utf8_lossy(&output.stderr));
|
|
357
|
-
}
|
|
358
|
-
assert!(read_cli_error_logs(&workspace).is_empty(),
|
|
359
|
-
"invalid profile syntax must not create a runtime diagnostic log");
|
|
360
|
-
// Keep the original physical-log redaction assertion on the same actual
|
|
361
|
-
// runtime-error emitter, separately from the new zero-log Usage boundary.
|
|
362
|
-
assert_eq!(crate::cli::emit::__test_runtime_error_emitter(
|
|
363
|
-
"restart", &workspace, &crate::cli::CliError::Runtime(diagnostic.clone())
|
|
364
|
-
), crate::cli::ExitCode::Error);
|
|
365
|
-
let logs = read_cli_error_logs(&workspace);
|
|
366
|
-
let output_safe = !combined.contains(&marker) && combined.contains(REDACTED);
|
|
367
|
-
let logs_safe = !logs.contains(&marker) && logs.contains(REDACTED);
|
|
368
|
-
assert!(
|
|
369
|
-
regular_reports_safe && output_safe && logs_safe,
|
|
370
|
-
"RED6: regular JSON/human reports plus top-level stdout/stderr and physical error logs must mask before emission; regular_reports_safe={regular_reports_safe} output_safe={output_safe} logs_safe={logs_safe} output_had_marker={} logs_had_marker={}",
|
|
371
|
-
combined.contains(&marker),
|
|
372
|
-
logs.contains(&marker)
|
|
373
|
-
);
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
#[test]
|
|
377
|
-
#[serial(env, pid_probe)]
|
|
378
|
-
fn red7_pane_and_profile_scrubbers_converge_without_losing_existing_policy() {
|
|
379
|
-
let root = Path::new(env!("CARGO_MANIFEST_DIR"));
|
|
380
|
-
let tmux = fs::read_to_string(root.join("src/tmux_backend.rs")).unwrap();
|
|
381
|
-
let profile = fs::read_to_string(root.join("src/lifecycle/profile_smoke.rs")).unwrap();
|
|
382
|
-
let delegates_to_shared =
|
|
383
|
-
tmux.contains("redact_external_text") && profile.contains("redact_external_text");
|
|
384
|
-
|
|
385
|
-
let marker = synthetic_marker();
|
|
386
|
-
let profile_token = format!("synthetic-profile-token-{}", std::process::id());
|
|
387
|
-
let tail_sentinel = "synthetic-truncation-tail";
|
|
388
|
-
let body = json!({"error": {"message": format!(
|
|
389
|
-
"HTTPS_PROXY='{}' explicit={} {}{}",
|
|
390
|
-
credential_url(&marker),
|
|
391
|
-
profile_token,
|
|
392
|
-
"x".repeat(600),
|
|
393
|
-
tail_sentinel
|
|
394
|
-
)}})
|
|
395
|
-
.to_string();
|
|
396
|
-
let server = MockLlmServer::new(401, body);
|
|
397
|
-
let env = hermetic_guard::HermeticTestEnv::enter("redact-red7");
|
|
398
|
-
let pane_policy_preserved = pane_excerpt_uses_shared_redaction(&env, &marker);
|
|
399
|
-
let team = write_profile_fixture(env.root(), server.base_url(), &profile_token);
|
|
400
|
-
let result = cmd_doctor(&DoctorArgs {
|
|
401
|
-
spec: Some(team.join("TEAM.md")),
|
|
402
|
-
workspace: team,
|
|
403
|
-
gate: None,
|
|
404
|
-
comms: false,
|
|
405
|
-
team: None,
|
|
406
|
-
fix: false,
|
|
407
|
-
fix_schema: false,
|
|
408
|
-
cleanup_orphans: false,
|
|
409
|
-
confirm: false,
|
|
410
|
-
json: true,
|
|
411
|
-
})
|
|
412
|
-
.expect("profile smoke returns a diagnostic report");
|
|
413
|
-
let report = match result.output {
|
|
414
|
-
CmdOutput::Json(value) => value,
|
|
415
|
-
other => panic!("expected JSON doctor output, got {other:?}"),
|
|
416
|
-
};
|
|
417
|
-
let report_text = report.to_string();
|
|
418
|
-
let text = report
|
|
419
|
-
.get("profile_smoke")
|
|
420
|
-
.unwrap_or_else(|| panic!("doctor must expose profile_smoke; report={report}"))
|
|
421
|
-
.to_string();
|
|
422
|
-
let profile_policy_preserved = !report_text.contains(&marker)
|
|
423
|
-
&& !report_text.contains(&profile_token)
|
|
424
|
-
&& !text.contains(tail_sentinel)
|
|
425
|
-
&& text.contains(REDACTED)
|
|
426
|
-
&& text.contains("proxy.invalid:8443/path")
|
|
427
|
-
&& server.was_called();
|
|
428
|
-
|
|
429
|
-
assert!(
|
|
430
|
-
delegates_to_shared && pane_policy_preserved && profile_policy_preserved,
|
|
431
|
-
"RED7: pane/profile scrubbers must delegate generic env/URL masking to the shared module while retaining pane token/hex policy and profile explicit-token/truncation policy"
|
|
432
|
-
);
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
fn redaction_case(
|
|
436
|
-
tag: &str,
|
|
437
|
-
marker: &str,
|
|
438
|
-
team_key: &str,
|
|
439
|
-
) -> (hermetic_guard::HermeticTestEnv, PathBuf) {
|
|
440
|
-
let env = hermetic_guard::HermeticTestEnv::enter(tag);
|
|
441
|
-
env.scrub_tmux();
|
|
442
|
-
env.assert_no_real_tmux();
|
|
443
|
-
let workspace = env.workspace(tag);
|
|
444
|
-
seed_redaction_state(&workspace, marker, team_key);
|
|
445
|
-
(env, workspace)
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
fn seed_redaction_state(workspace: &Path, marker: &str, team_key: &str) {
|
|
449
|
-
let diagnostic = restart_diagnostic(marker);
|
|
450
|
-
let mixed = mixed_sensitive_value(marker);
|
|
451
|
-
let agent = json!({
|
|
452
|
-
"agent_id": "worker",
|
|
453
|
-
"provider": "copilot",
|
|
454
|
-
"model": "gpt-contract",
|
|
455
|
-
"provider_source": "role",
|
|
456
|
-
"model_source": "role",
|
|
457
|
-
"model_stale": true,
|
|
458
|
-
"auth_mode": "subscription",
|
|
459
|
-
"status": "failed",
|
|
460
|
-
"restart_error": diagnostic,
|
|
461
|
-
"session_id": "session-contract",
|
|
462
|
-
"pane_id": "%contract",
|
|
463
|
-
});
|
|
464
|
-
save_runtime_state(
|
|
465
|
-
workspace,
|
|
466
|
-
&json!({
|
|
467
|
-
"active_team_key": team_key,
|
|
468
|
-
"session_name": "team-redaction-contract",
|
|
469
|
-
"leader": {"id": "leader"},
|
|
470
|
-
"agents": {"worker": agent.clone()},
|
|
471
|
-
"teams": {
|
|
472
|
-
(team_key): {
|
|
473
|
-
"agents": {"worker": agent},
|
|
474
|
-
"diagnostics": mixed,
|
|
475
|
-
"tasks": []
|
|
476
|
-
}
|
|
477
|
-
},
|
|
478
|
-
"tasks": []
|
|
479
|
-
}),
|
|
480
|
-
)
|
|
481
|
-
.unwrap();
|
|
482
|
-
let _ = MessageStore::open(workspace).unwrap();
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
fn mixed_sensitive_value(marker: &str) -> Value {
|
|
486
|
-
let diagnostic = restart_diagnostic(marker);
|
|
487
|
-
json!({
|
|
488
|
-
"HTTPS_PROXY": marker,
|
|
489
|
-
"http_proxy": marker,
|
|
490
|
-
"Copilot_Github_Token": marker,
|
|
491
|
-
"OPENAI_API_KEY": marker,
|
|
492
|
-
"db_password": marker,
|
|
493
|
-
"client_auth": marker,
|
|
494
|
-
"client_secret": marker,
|
|
495
|
-
"service_credential": marker,
|
|
496
|
-
"ordinary_diagnostic": format!(
|
|
497
|
-
"HTTPS_PROXY='{}' http_proxy=\"{}\" OPENAI_API_KEY={} endpoint={}",
|
|
498
|
-
credential_url(marker), credential_url(marker), marker, credential_url(marker)
|
|
499
|
-
),
|
|
500
|
-
"nested": [{"values": [diagnostic.clone(), credential_url(marker)]}],
|
|
501
|
-
"team_key": "current",
|
|
502
|
-
"auth_mode": "subscription",
|
|
503
|
-
"provider": "copilot",
|
|
504
|
-
"model": "gpt-contract",
|
|
505
|
-
"provider_source": "role",
|
|
506
|
-
"model_source": "role",
|
|
507
|
-
"model_stale": true,
|
|
508
|
-
"session_id": "session-contract",
|
|
509
|
-
"pane_id": "%contract",
|
|
510
|
-
"monkey": "banana",
|
|
511
|
-
"author": "operator",
|
|
512
|
-
"normal_url": "https://proxy.invalid/health",
|
|
513
|
-
"already_redacted": REDACTED,
|
|
514
|
-
})
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
fn synthetic_marker() -> String {
|
|
518
|
-
static NEXT: AtomicU64 = AtomicU64::new(0);
|
|
519
|
-
format!(
|
|
520
|
-
"synthetic-redact-marker-{}-{}",
|
|
521
|
-
std::process::id(),
|
|
522
|
-
NEXT.fetch_add(1, Ordering::Relaxed)
|
|
523
|
-
)
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
fn credential_url(marker: &str) -> String {
|
|
527
|
-
format!("https://demo-user:{marker}@proxy.invalid:8443/path")
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
fn restart_diagnostic(marker: &str) -> String {
|
|
531
|
-
format!(
|
|
532
|
-
"subprocess exited 37: argv=[tmux, new-window, HTTPS_PROXY='{}']; endpoint={}; stderr=synthetic transport failure",
|
|
533
|
-
credential_url(marker),
|
|
534
|
-
credential_url(marker)
|
|
535
|
-
)
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
fn run_mcp_status_frames(
|
|
539
|
-
env: &hermetic_guard::HermeticTestEnv,
|
|
540
|
-
workspace: &Path,
|
|
541
|
-
team_key: &str,
|
|
542
|
-
) -> Vec<Value> {
|
|
543
|
-
let mut child = Command::new(crate::lifecycle::tests::test_binary_path())
|
|
544
|
-
.args(["mcp-server", "--workspace"])
|
|
545
|
-
.arg(workspace)
|
|
546
|
-
.current_dir(workspace)
|
|
547
|
-
.env("HOME", env.home())
|
|
548
|
-
.env("TEAM_AGENT_ID", "worker")
|
|
549
|
-
.env("TEAM_AGENT_OWNER_TEAM_ID", team_key)
|
|
550
|
-
.env_remove("TMUX")
|
|
551
|
-
.env_remove("TMUX_PANE")
|
|
552
|
-
.stdin(Stdio::piped())
|
|
553
|
-
.stdout(Stdio::piped())
|
|
554
|
-
.stderr(Stdio::null())
|
|
555
|
-
.spawn()
|
|
556
|
-
.expect("spawn real MCP stdio server");
|
|
557
|
-
let rpc = json!({
|
|
558
|
-
"jsonrpc": "2.0",
|
|
559
|
-
"id": 1,
|
|
560
|
-
"method": "tools/call",
|
|
561
|
-
"params": {"name": "get_team_status", "arguments": {}}
|
|
562
|
-
});
|
|
563
|
-
let legacy = json!({"tool": "get_team_status", "arguments": {}});
|
|
564
|
-
{
|
|
565
|
-
let stdin = child.stdin.as_mut().expect("MCP stdin");
|
|
566
|
-
writeln!(stdin, "{rpc}").unwrap();
|
|
567
|
-
writeln!(stdin, "{legacy}").unwrap();
|
|
568
|
-
}
|
|
569
|
-
drop(child.stdin.take());
|
|
570
|
-
let output = child.wait_with_output().expect("wait for MCP EOF");
|
|
571
|
-
assert!(output.status.success(), "MCP stdio exits cleanly at EOF");
|
|
572
|
-
String::from_utf8(output.stdout)
|
|
573
|
-
.unwrap()
|
|
574
|
-
.lines()
|
|
575
|
-
.map(|line| serde_json::from_str(line).expect("MCP response JSON"))
|
|
576
|
-
.collect()
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
fn read_cli_error_logs(workspace: &Path) -> String {
|
|
580
|
-
let dir = workspace.join(".team/logs");
|
|
581
|
-
fs::read_dir(dir)
|
|
582
|
-
.into_iter()
|
|
583
|
-
.flatten()
|
|
584
|
-
.filter_map(Result::ok)
|
|
585
|
-
.filter(|entry| {
|
|
586
|
-
entry
|
|
587
|
-
.file_name()
|
|
588
|
-
.to_string_lossy()
|
|
589
|
-
.starts_with("cli-error-")
|
|
590
|
-
})
|
|
591
|
-
.filter_map(|entry| fs::read_to_string(entry.path()).ok())
|
|
592
|
-
.collect::<Vec<_>>()
|
|
593
|
-
.join("\n")
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
#[cfg(unix)]
|
|
597
|
-
fn pane_excerpt_uses_shared_redaction(env: &hermetic_guard::HermeticTestEnv, marker: &str) -> bool {
|
|
598
|
-
let workspace = env.workspace("red7-pane");
|
|
599
|
-
let shim_dir = env.root().join("pane-bin");
|
|
600
|
-
fs::create_dir_all(&shim_dir).unwrap();
|
|
601
|
-
let shim = shim_dir.join("tmux");
|
|
602
|
-
let submitted = env.root().join("pane-submitted");
|
|
603
|
-
fs::write(
|
|
604
|
-
&shim,
|
|
605
|
-
r#"#!/bin/sh
|
|
606
|
-
case " $* " in
|
|
607
|
-
*" capture-pane "*)
|
|
608
|
-
if [ -f "$TEAM_AGENT_TEST_PANE_SUBMITTED" ]; then
|
|
609
|
-
printf '%s\n' "$TEAM_AGENT_TEST_PANE_AFTER"
|
|
610
|
-
else
|
|
611
|
-
printf '%s\n' "$TEAM_AGENT_TEST_PANE_BEFORE"
|
|
612
|
-
fi
|
|
613
|
-
exit 0
|
|
614
|
-
;;
|
|
615
|
-
*" send-keys "*)
|
|
616
|
-
: > "$TEAM_AGENT_TEST_PANE_SUBMITTED"
|
|
617
|
-
exit 0
|
|
618
|
-
;;
|
|
619
|
-
*) exit 0 ;;
|
|
620
|
-
esac
|
|
621
|
-
"#,
|
|
622
|
-
)
|
|
623
|
-
.unwrap();
|
|
624
|
-
let mut permissions = fs::metadata(&shim).unwrap().permissions();
|
|
625
|
-
permissions.set_mode(0o755);
|
|
626
|
-
fs::set_permissions(&shim, permissions).unwrap();
|
|
627
|
-
let real_path = std::env::var_os("PATH").unwrap_or_default();
|
|
628
|
-
let token = "[team-agent-token:synthetic-redact-pane]";
|
|
629
|
-
let diagnostic = restart_diagnostic(marker);
|
|
630
|
-
let before = format!("message {token}\n{diagnostic}");
|
|
631
|
-
let after = format!(
|
|
632
|
-
"{diagnostic}\n{}{}\n{}{}\nBearer {}.part\nhex {}\nplain pane diagnostic",
|
|
633
|
-
"sk-",
|
|
634
|
-
marker,
|
|
635
|
-
"ghp_",
|
|
636
|
-
marker,
|
|
637
|
-
marker,
|
|
638
|
-
"a".repeat(40)
|
|
639
|
-
);
|
|
640
|
-
let _guards = [
|
|
641
|
-
env.with_env(
|
|
642
|
-
"PATH",
|
|
643
|
-
&format!("{}:{}", shim_dir.display(), real_path.to_string_lossy()),
|
|
644
|
-
),
|
|
645
|
-
env.with_env(
|
|
646
|
-
"TEAM_AGENT_TEST_PANE_SUBMITTED",
|
|
647
|
-
submitted.to_str().unwrap(),
|
|
648
|
-
),
|
|
649
|
-
env.with_env("TEAM_AGENT_TEST_PANE_BEFORE", &before),
|
|
650
|
-
env.with_env("TEAM_AGENT_TEST_PANE_AFTER", &after),
|
|
651
|
-
];
|
|
652
|
-
let backend = TmuxBackend::for_workspace(&workspace);
|
|
653
|
-
let report = backend
|
|
654
|
-
.inject(
|
|
655
|
-
&Target::Pane(PaneId::new("%redact-contract")),
|
|
656
|
-
&InjectPayload::Text(format!("message {token}")),
|
|
657
|
-
Key::Enter,
|
|
658
|
-
false,
|
|
659
|
-
)
|
|
660
|
-
.expect("scripted pane injection reaches submit diagnostics");
|
|
661
|
-
let excerpts = report
|
|
662
|
-
.submit_diagnostics
|
|
663
|
-
.into_iter()
|
|
664
|
-
.flat_map(|diagnostics| diagnostics.attempts_detail)
|
|
665
|
-
.map(|observation| observation.pane_tail_excerpt)
|
|
666
|
-
.collect::<Vec<_>>()
|
|
667
|
-
.join("\n");
|
|
668
|
-
!excerpts.contains(marker)
|
|
669
|
-
&& excerpts.contains(REDACTED)
|
|
670
|
-
&& excerpts.contains("REDACTED_HEX")
|
|
671
|
-
&& excerpts.contains("plain pane diagnostic")
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
#[cfg(not(unix))]
|
|
675
|
-
fn pane_excerpt_uses_shared_redaction(
|
|
676
|
-
_env: &hermetic_guard::HermeticTestEnv,
|
|
677
|
-
_marker: &str,
|
|
678
|
-
) -> bool {
|
|
679
|
-
true
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
fn write_profile_fixture(root: &Path, base_url: &str, token: &str) -> PathBuf {
|
|
683
|
-
let team = root.join("profile-team");
|
|
684
|
-
fs::create_dir_all(team.join("agents")).unwrap();
|
|
685
|
-
fs::create_dir_all(team.join("profiles")).unwrap();
|
|
686
|
-
fs::write(
|
|
687
|
-
team.join("profiles/local.env"),
|
|
688
|
-
format!(
|
|
689
|
-
"ANTHROPIC_BASE_URL={base_url}\nANTHROPIC_AUTH_TOKEN={token}\nANTHROPIC_MODEL=mock-model\n"
|
|
690
|
-
),
|
|
691
|
-
)
|
|
692
|
-
.unwrap();
|
|
693
|
-
fs::write(
|
|
694
|
-
team.join("TEAM.md"),
|
|
695
|
-
"---\nname: redact-profile\nobjective: Synthetic redaction profile contract.\nprovider: claude\nauth_mode: compatible_api\ndangerously_skip_permissions: false\n---\n\nTeam.\n",
|
|
696
|
-
)
|
|
697
|
-
.unwrap();
|
|
698
|
-
fs::write(
|
|
699
|
-
team.join("agents/worker.md"),
|
|
700
|
-
"---\nname: worker\nrole: Worker\nprovider: claude\nauth_mode: compatible_api\ndangerously_skip_permissions: false\nprofile: local\nmodel: null\ntools:\n - mcp_team\n---\n\nWorker.\n",
|
|
701
|
-
)
|
|
702
|
-
.unwrap();
|
|
703
|
-
team
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
struct MockLlmServer {
|
|
707
|
-
url: String,
|
|
708
|
-
called: Arc<AtomicBool>,
|
|
709
|
-
handle: Option<thread::JoinHandle<()>>,
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
impl MockLlmServer {
|
|
713
|
-
fn new(status: u16, body: String) -> Self {
|
|
714
|
-
let listener = TcpListener::bind("127.0.0.1:0").unwrap();
|
|
715
|
-
listener.set_nonblocking(true).unwrap();
|
|
716
|
-
let addr = listener.local_addr().unwrap();
|
|
717
|
-
let called = Arc::new(AtomicBool::new(false));
|
|
718
|
-
let called_in_thread = called.clone();
|
|
719
|
-
let handle = thread::spawn(move || {
|
|
720
|
-
let deadline = Instant::now() + Duration::from_secs(2);
|
|
721
|
-
while Instant::now() < deadline {
|
|
722
|
-
match listener.accept() {
|
|
723
|
-
Ok((mut stream, _)) => {
|
|
724
|
-
called_in_thread.store(true, Ordering::SeqCst);
|
|
725
|
-
let mut buffer = [0_u8; 4096];
|
|
726
|
-
let _ = stream.read(&mut buffer);
|
|
727
|
-
let response = format!(
|
|
728
|
-
"HTTP/1.1 {status} test\r\nContent-Type: application/json\r\nContent-Length: {}\r\n\r\n{body}",
|
|
729
|
-
body.len()
|
|
730
|
-
);
|
|
731
|
-
let _ = stream.write_all(response.as_bytes());
|
|
732
|
-
return;
|
|
733
|
-
}
|
|
734
|
-
Err(error) if error.kind() == std::io::ErrorKind::WouldBlock => {
|
|
735
|
-
thread::sleep(Duration::from_millis(20));
|
|
736
|
-
}
|
|
737
|
-
Err(_) => return,
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
|
-
});
|
|
741
|
-
Self {
|
|
742
|
-
url: format!("http://{addr}/v1"),
|
|
743
|
-
called,
|
|
744
|
-
handle: Some(handle),
|
|
745
|
-
}
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
fn base_url(&self) -> &str {
|
|
749
|
-
&self.url
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
fn was_called(&self) -> bool {
|
|
753
|
-
self.called.load(Ordering::SeqCst)
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
impl Drop for MockLlmServer {
|
|
758
|
-
fn drop(&mut self) {
|
|
759
|
-
if let Some(handle) = self.handle.take() {
|
|
760
|
-
let _ = handle.join();
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
#[test]
|
|
766
|
-
#[serial(env)]
|
|
767
|
-
fn red8_bearer_token_inside_free_text_is_masked_without_over_redaction() {
|
|
768
|
-
let marker = synthetic_marker();
|
|
769
|
-
let env = hermetic_guard::HermeticTestEnv::enter("redact-red8");
|
|
770
|
-
env.scrub_tmux();
|
|
771
|
-
env.assert_no_real_tmux();
|
|
772
|
-
let workspace = env.workspace("red8");
|
|
773
|
-
let log = EventLog::new(&workspace);
|
|
774
|
-
// Attack-input shape (case.md section 2.4 / arch delta-smell6 probe): a
|
|
775
|
-
// user-controlled prompt travels as free text INSIDE an argv value
|
|
776
|
-
// (a codex seat's `-c developer_instructions=<prompt>` argv value
|
|
777
|
-
// -> spawn_argv event). The bearer token hides in prose - not
|
|
778
|
-
// under a sensitive key, assignment key, or flag-value pair - so the
|
|
779
|
-
// shape matrix must map the attack input, not the scrubber branches.
|
|
780
|
-
let written = log
|
|
781
|
-
.write(
|
|
782
|
-
"provider.worker.spawn_argv",
|
|
783
|
-
json!({
|
|
784
|
-
"argv": [
|
|
785
|
-
"codex",
|
|
786
|
-
"-c",
|
|
787
|
-
format!(
|
|
788
|
-
"developer_instructions=You are w1. Call the api with Bearer {marker} and report back."
|
|
789
|
-
),
|
|
790
|
-
],
|
|
791
|
-
}),
|
|
792
|
-
)
|
|
793
|
-
.unwrap();
|
|
794
|
-
let events_path = workspace.join(".team").join("logs").join("events.jsonl");
|
|
795
|
-
let bytes = std::fs::read_to_string(&events_path).unwrap();
|
|
796
|
-
let leak_free = !bytes.contains(&marker) && bytes.contains(REDACTED);
|
|
797
|
-
|
|
798
|
-
// Over-redaction anchor: prose where "Bearer" is ordinary language (the
|
|
799
|
-
// successor word is not token-shaped) must survive verbatim.
|
|
800
|
-
log.write(
|
|
801
|
-
"provider.worker.spawn_argv",
|
|
802
|
-
json!({
|
|
803
|
-
"argv": [
|
|
804
|
-
"codex",
|
|
805
|
-
"-c",
|
|
806
|
-
"developer_instructions=A bearer of good news, Bearer of the ring.",
|
|
807
|
-
],
|
|
808
|
-
}),
|
|
809
|
-
)
|
|
810
|
-
.unwrap();
|
|
811
|
-
let bytes = std::fs::read_to_string(&events_path).unwrap();
|
|
812
|
-
let benign_preserved = bytes.contains("Bearer of the ring");
|
|
813
|
-
|
|
814
|
-
// Idempotency at the tail boundary, same discipline as RED5.
|
|
815
|
-
let tail = log.tail(0).unwrap();
|
|
816
|
-
let idempotent = tail.first() == Some(&written);
|
|
817
|
-
|
|
818
|
-
assert!(
|
|
819
|
-
leak_free && benign_preserved && idempotent,
|
|
820
|
-
"RED8: a bearer token inside user-controlled free text must be masked at event write while ordinary Bearer prose survives and redaction stays idempotent; leak_free={leak_free} benign_preserved={benign_preserved} idempotent={idempotent}"
|
|
821
|
-
);
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
#[test]
|
|
825
|
-
#[serial(env)]
|
|
826
|
-
fn red8b_bearer_terminal_matrix_masks_every_rfc6750_tail_with_zero_remnant() {
|
|
827
|
-
let env = hermetic_guard::HermeticTestEnv::enter("redact-red8b");
|
|
828
|
-
env.scrub_tmux();
|
|
829
|
-
env.assert_no_real_tmux();
|
|
830
|
-
let workspace = env.workspace("red8b");
|
|
831
|
-
let log = EventLog::new(&workspace);
|
|
832
|
-
// Boundary-value matrix (leader final ruling via r10): the token tail may
|
|
833
|
-
// be ANY RFC6750 b64token character. Exactly-min-length tokens and long
|
|
834
|
-
// tokens must both be fully masked with ZERO token remnant - over-masking
|
|
835
|
-
// a sentence period is accepted, a surviving token fragment is not.
|
|
836
|
-
let tails = ['-', '.', '~', '+', '/', '='];
|
|
837
|
-
for (index, tail) in tails.iter().enumerate() {
|
|
838
|
-
let core = format!("bnd{index}fake{index}core");
|
|
839
|
-
let min_token = format!("ab{core}{tail}");
|
|
840
|
-
let long_token = format!("ab{core}x{core}{tail}");
|
|
841
|
-
for token in [min_token, long_token] {
|
|
842
|
-
log.write(
|
|
843
|
-
"provider.worker.spawn_argv",
|
|
844
|
-
json!({
|
|
845
|
-
"argv": [
|
|
846
|
-
"codex",
|
|
847
|
-
"-c",
|
|
848
|
-
format!("developer_instructions=call the api with Bearer {token} then stop."),
|
|
849
|
-
],
|
|
850
|
-
}),
|
|
851
|
-
)
|
|
852
|
-
.unwrap();
|
|
853
|
-
}
|
|
854
|
-
}
|
|
855
|
-
let events_path = workspace.join(".team").join("logs").join("events.jsonl");
|
|
856
|
-
let bytes = std::fs::read_to_string(&events_path).unwrap();
|
|
857
|
-
let mut failures = Vec::new();
|
|
858
|
-
for (index, tail) in tails.iter().enumerate() {
|
|
859
|
-
let core = format!("bnd{index}fake{index}core");
|
|
860
|
-
if bytes.contains(&core) {
|
|
861
|
-
failures.push(format!("token body leaked for tail {tail:?}: {core}"));
|
|
862
|
-
}
|
|
863
|
-
let remnant = format!("{REDACTED}{tail}");
|
|
864
|
-
if bytes.contains(&remnant) {
|
|
865
|
-
failures.push(format!("token tail remnant survived masking: {remnant}"));
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
if !bytes.contains(REDACTED) {
|
|
869
|
-
failures.push("no [REDACTED] marker written at all".to_string());
|
|
870
|
-
}
|
|
871
|
-
assert!(
|
|
872
|
-
failures.is_empty(),
|
|
873
|
-
"RED8B: every RFC6750 terminal character must be masked with zero token remnant at exact-min and long lengths.\n{}",
|
|
874
|
-
failures.join("\n")
|
|
875
|
-
);
|
|
876
|
-
}
|