From 3229cae3f3ba976ac0e0b9f53023675a5dc59591 Mon Sep 17 00:00:00 2001 From: ogt Date: Fri, 17 Jul 2026 00:00:18 +0800 Subject: [PATCH] fix(agent99): bind transport to Gitea source truth --- .../agent99-remote-atomic-deploy-receiver.ps1 | 5 ++-- .../deploy-agent99-via-windows99-ssh.sh | 18 ++++---------- ...remote_atomic_deploy_transport_contract.py | 24 +++++++++++++++---- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/scripts/reboot-recovery/agent99-remote-atomic-deploy-receiver.ps1 b/scripts/reboot-recovery/agent99-remote-atomic-deploy-receiver.ps1 index dadc5b584..e2eec3c7c 100644 --- a/scripts/reboot-recovery/agent99-remote-atomic-deploy-receiver.ps1 +++ b/scripts/reboot-recovery/agent99-remote-atomic-deploy-receiver.ps1 @@ -857,9 +857,10 @@ function Write-AgentResultAndExit { try { $envelope = $EnvelopeJson | ConvertFrom-Json if ([string]$envelope.schemaVersion -ne "agent99_remote_atomic_deploy_envelope_v1") { throw "invalid_envelope_schema" } - if ([string]$envelope.sourceHostAlias -ne "110") { throw "invalid_source_host_alias" } + if ([string]$envelope.sourceHostAlias -ne "gitea-main") { throw "invalid_source_host_alias" } if ([string]$envelope.targetHostAlias -ne "99") { throw "invalid_target_host_alias" } - if ([string]$envelope.transport -ne "110_to_99_ssh_publickey") { throw "invalid_transport" } + if ([string]$envelope.transport -ne "gitea_main_bound_controller_to_99_ssh_publickey") { throw "invalid_transport" } + if ([string]$envelope.sourceHostGateSupersededBy -ne "global_product_governance_v2") { throw "invalid_source_host_gate_sunset" } $mode = [string]$envelope.mode if ($mode -notin @("check", "apply")) { throw "invalid_mode" } $transportPayloadMode = [string]$envelope.transportPayloadMode diff --git a/scripts/reboot-recovery/deploy-agent99-via-windows99-ssh.sh b/scripts/reboot-recovery/deploy-agent99-via-windows99-ssh.sh index a217f4b6d..e85268269 100755 --- a/scripts/reboot-recovery/deploy-agent99-via-windows99-ssh.sh +++ b/scripts/reboot-recovery/deploy-agent99-via-windows99-ssh.sh @@ -4,7 +4,6 @@ set -euo pipefail readonly SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" readonly DEFAULT_SOURCE_ROOT="$(CDPATH= cd -- "${SCRIPT_DIR}/../.." && pwd)" readonly TARGET="Administrator@192.168.0.99" -readonly SOURCE_HOST_IPV4="192.168.0.110" readonly GITEA_ORIGIN_HTTPS="https://gitea.wooo.work/wooo/awoooi.git" readonly GITEA_ORIGIN_HTTP_INTERNAL="http://192.168.0.110:3000/wooo/awoooi.git" readonly GITEA_ORIGIN_SSH_INTERNAL="ssh://git@192.168.0.110:2222/wooo/awoooi.git" @@ -150,20 +149,10 @@ if [[ "${MODE}" == "apply" ]]; then REMOTE_EXECUTION_TIMEOUT_SECONDS="2400" fi -for dependency in git python3 ssh scp mktemp hostname timeout; do +for dependency in git python3 ssh scp mktemp timeout; do command -v "${dependency}" >/dev/null 2>&1 || fail "required_command_missing_${dependency}" done -SOURCE_HOST_VERIFIED=0 -read -r -a LOCAL_ADDRESSES <<<"$(hostname -I 2>/dev/null || true)" -for local_address in "${LOCAL_ADDRESSES[@]}"; do - if [[ "${local_address%%/*}" == "${SOURCE_HOST_IPV4}" ]]; then - SOURCE_HOST_VERIFIED=1 - break - fi -done -[[ "${SOURCE_HOST_VERIFIED}" == "1" ]] || fail "source_host_is_not_110" - [[ -d "${SOURCE_ROOT}" ]] || fail "source_root_missing" SOURCE_ROOT="$(CDPATH= cd -- "${SOURCE_ROOT}" && pwd)" ORIGIN_URL="$(git -C "${SOURCE_ROOT}" remote get-url origin 2>/dev/null)" || fail "origin_remote_missing" @@ -261,9 +250,10 @@ preflight_content = preflight_path.read_bytes() envelope = { "schemaVersion": "agent99_remote_atomic_deploy_envelope_v1", - "sourceHostAlias": "110", + "sourceHostAlias": "gitea-main", "targetHostAlias": "99", - "transport": "110_to_99_ssh_publickey", + "transport": "gitea_main_bound_controller_to_99_ssh_publickey", + "sourceHostGateSupersededBy": "global_product_governance_v2", "transportPayloadMode": ( "ephemeral_file_delete_before_receiver" if mode == "apply" diff --git a/scripts/reboot-recovery/tests/test_agent99_remote_atomic_deploy_transport_contract.py b/scripts/reboot-recovery/tests/test_agent99_remote_atomic_deploy_transport_contract.py index 966a4383a..e287f9222 100644 --- a/scripts/reboot-recovery/tests/test_agent99_remote_atomic_deploy_transport_contract.py +++ b/scripts/reboot-recovery/tests/test_agent99_remote_atomic_deploy_transport_contract.py @@ -92,14 +92,28 @@ def test_sender_and_receiver_allow_exactly_the_deployer_runtime_bundle() -> None assert "duplicate_runtime_file" in receiver -def test_sender_is_fixed_to_110_to_windows99_public_key_transport() -> None: +def test_sender_is_fixed_to_gitea_main_and_windows99_public_key_transport() -> None: source = SENDER.read_text(encoding="utf-8") + receiver = RECEIVER.read_text(encoding="utf-8") assert 'readonly TARGET="Administrator@192.168.0.99"' in source - assert 'readonly SOURCE_HOST_IPV4="192.168.0.110"' in source - assert "source_host_is_not_110" in source - assert '"sourceHostAlias": "110"' in source - assert '"transport": "110_to_99_ssh_publickey"' in source + assert "source_host_is_not_110" not in source + assert "hostname -I" not in source + assert '"sourceHostAlias": "gitea-main"' in source + assert ( + '"transport": "gitea_main_bound_controller_to_99_ssh_publickey"' + in source + ) + assert ( + '"sourceHostGateSupersededBy": "global_product_governance_v2"' + in source + ) + assert 'sourceHostAlias -ne "gitea-main"' in receiver + assert ( + 'transport -ne "gitea_main_bound_controller_to_99_ssh_publickey"' + in receiver + ) + assert 'sourceHostGateSupersededBy -ne "global_product_governance_v2"' in receiver assert '"ephemeral_file_delete_before_receiver"' in source assert '"transportPayloadContainsSecrets": False' in source assert 'scp "${SCP_OPTIONS[@]}"' in source