From 5522d942b43fe6cc12a4fee8166bc1d83c9d87a7 Mon Sep 17 00:00:00 2001 From: harryisfish Date: Fri, 6 Nov 2026 15:29:53 +0800 Subject: [PATCH 01/34] docs(ci): clarify resource and provider acceptance --- packages/docs/releasing.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/docs/releasing.md b/packages/docs/releasing.md index 59dea61ae..a677c139f 100644 --- a/packages/docs/releasing.md +++ b/packages/docs/releasing.md @@ -65,11 +65,11 @@ cd vibeface-- ## CI 验证范围 -`crypto-web` 在固定版本的 wasm-bindgen 工具链生成一份浏览器密码学资源,运行 native Rust 与 WASM 的实际 Noise 互通和篡改、重放、身份错配负例。`web` 下载这份资源及其真实 TypeScript 声明,以锁定的 pnpm 依赖生成 TanStack Start 静态 SPA。被选中的检查和打包任务下载同一份密码学资源和 SPA。Core 从 `VIBEFACE_APP_DIR` 或发行包同级 `web/` 读取完整静态目录,不在编译时内嵌网页或 WASM。Core 可独立构建和运行,未提供 App 时网页返回 404;App 构建和完整发行包缺少资源时失败。 +`crypto-web` 在固定版本的 wasm-bindgen 工具链生成一份浏览器密码学资源,运行 native Rust 与 WASM 的实际 Noise 互通和篡改、重放、身份错配负例。`web` 下载这份资源及其真实 TypeScript 声明,以锁定的 pnpm 依赖生成 TanStack Start 静态 SPA。制品任务下载同一份密码学资源和 SPA;Rust 检查不依赖这些生成产物。Core 从 `VIBEFACE_APP_DIR` 或发行包同级 `web/` 读取完整静态目录,不在编译时内嵌网页或 WASM。Core 可独立构建和运行,未提供 App 时网页返回 404;App 构建和完整发行包缺少资源时失败。 质量检查按计划选择受影响的 crate,包含 Rust fmt、快慢测试、Clippy、声明的最低 Rust 版本编译检查、工作流和 shell 静态检查、JavaScript 语法、Web TypeScript 检查和静态构建,以及 Atlas 迁移文件校验。Atlas 不打开用户数据库。README 和项目指引不触发构建,`packages/docs/` 触发门户构建;`main` 的纯 App 改动只构建 Linux x64 包并验收网页资源,不运行 Core 库业务测试。`main` 保留相关快速测试、Clippy 和 Linux x64 制品。慢测试、最低 Rust 版本和三平台制品在扩展检查执行。`ci-gate` 要求本次计划中的任务全部成功。 -打包任务校验 SHA256、源码提交、版本、target、密码学资源和存储 epoch。扩展检查在 Linux x64 启动解包后的程序运行无账号网络验收;每个选中的平台独立启动网页进程,检查 SPA 路由、JavaScript、CSS、字体、每段内联脚本的 CSP hash、HEAD、缓存策略和未知资源的 404。Linux x64 还安装包内锁定的 SDK 依赖并导入模块,不开启模型会话。 +打包任务校验 SHA256、源码提交、版本、target、密码学资源和存储 epoch。扩展检查在 Linux x64 启动解包后的程序运行无账号网络验收;每个选中的平台独立启动网页进程,检查 SPA 路由、JavaScript、CSS、字体、每段内联脚本的 CSP hash、HEAD、缓存策略和未知资源的 404。三平台 npm 冒烟检查安装已验证的 CLI 包并实际启动 Node 和网页;Provider 进程专项使用受控协议夹具,不调用真实模型。 源码打包前先生成密码学资源,再构建网页。安装 Node.js 22.12+、pnpm 11.9.0、Rust 的 `wasm32-unknown-unknown` target 和 `wasm-bindgen-cli 0.2.129`,然后执行: From 1f72cb95c2d5fce730fcbd0c182d0d6fae034c41 Mon Sep 17 00:00:00 2001 From: harryisfish Date: Fri, 6 Nov 2026 16:14:47 +0800 Subject: [PATCH 02/34] perf(ci): reuse verified builds and parallelize acceptance --- .github/workflows/ci-native.yml | 41 +++ .github/workflows/ci-package.yml | 328 ++++++++++++++++++++++ .github/workflows/ci.yml | 450 ++++++++++--------------------- .github/workflows/mobile.yml | 101 ++++++- .github/workflows/release.yml | 10 +- packages/docs/ci.md | 24 +- packages/docs/e2e.md | 6 + packages/docs/releasing.md | 9 +- scripts/build-inputs.py | 317 +++++++++++++++++++++- scripts/ci.py | 210 +++++++++++++-- scripts/package-node.sh | 34 ++- scripts/verify-node.py | 11 +- 12 files changed, 1182 insertions(+), 359 deletions(-) create mode 100644 .github/workflows/ci-native.yml create mode 100644 .github/workflows/ci-package.yml diff --git a/.github/workflows/ci-native.yml b/.github/workflows/ci-native.yml new file mode 100644 index 000000000..a96a55b2a --- /dev/null +++ b/.github/workflows/ci-native.yml @@ -0,0 +1,41 @@ +name: ci-native +on: + workflow_call: + inputs: + runner: {type: string, required: true} + target: {type: string, required: true} + outputs: + artifact_id: + value: ${{ jobs.build.outputs.artifact_id }} + producer_attempt: + value: ${{ jobs.build.outputs.producer_attempt }} +permissions: + contents: read +jobs: + build: + runs-on: ${{ inputs.runner }} + outputs: + artifact_id: ${{ steps.upload.outputs.artifact-id }} + producer_attempt: ${{ github.run_attempt }} + env: + PACKAGE_TARGET: ${{ inputs.target }} + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 + with: + persist-credentials: false + - uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec + - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 + with: + key: package-${{ inputs.target }} + save-if: ${{ github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' }} + - name: Build and seal native release input without Web dependencies + run: | + [[ "$(rustc -vV | sed -n 's/^host: //p')" == "$PACKAGE_TARGET" ]] + bash scripts/package-node.sh --target "$PACKAGE_TARGET" --native-output .artifacts/native-input.tar.gz + - id: upload + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 + with: + name: native-${{ inputs.target }}-${{ github.sha }}-${{ github.run_attempt }} + path: .artifacts/native-input.tar.gz + if-no-files-found: error + retention-days: 14 diff --git a/.github/workflows/ci-package.yml b/.github/workflows/ci-package.yml new file mode 100644 index 000000000..dfcee7844 --- /dev/null +++ b/.github/workflows/ci-package.yml @@ -0,0 +1,328 @@ +name: ci-package +on: + workflow_call: + inputs: + runner: {type: string, required: true} + target: {type: string, required: true} + native_artifact_id: {type: string, required: true} + producer_attempt: {type: string, required: true} + crypto_artifact_id: {type: string, required: true} + web_artifact_id: {type: string, required: true} + package_mode: {type: string, required: true} + delivery: {type: boolean, required: true} + secrets: + MACOS_CERTIFICATE_P12_BASE64: {required: false} + MACOS_CERTIFICATE_PASSWORD: {required: false} + APPLE_API_KEY_P8_BASE64: {required: false} + APPLE_API_KEY_ID: {required: false} + APPLE_API_ISSUER_ID: {required: false} + outputs: + artifact_id: + value: ${{ jobs.assemble.outputs.artifact_id }} +permissions: + contents: read +jobs: + assemble: + runs-on: ${{ inputs.runner }} + outputs: + artifact_id: ${{ steps.upload.outputs.artifact-id }} + env: + PACKAGE_TARGET: ${{ inputs.target }} + VIBEFACE_INPUT_ATTEMPT: ${{ inputs.producer_attempt }} + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 + with: + persist-credentials: false + - name: Require explicit producer artifact IDs + env: + ARTIFACT_IDS: ${{ inputs.crypto_artifact_id }} + run: '[[ "$ARTIFACT_IDS" =~ ^[1-9][0-9]*(,[1-9][0-9]*)*$ ]]' + - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 + with: + artifact-ids: ${{ inputs.crypto_artifact_id }} + merge-multiple: true + path: apps/app/generated + - name: Require explicit producer artifact IDs + env: + ARTIFACT_IDS: ${{ inputs.web_artifact_id }} + run: '[[ "$ARTIFACT_IDS" =~ ^[1-9][0-9]*(,[1-9][0-9]*)*$ ]]' + - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 + with: + artifact-ids: ${{ inputs.web_artifact_id }} + merge-multiple: true + path: apps/app/dist/client + - name: Require explicit producer artifact IDs + env: + ARTIFACT_IDS: ${{ inputs.native_artifact_id }} + run: '[[ "$ARTIFACT_IDS" =~ ^[1-9][0-9]*(,[1-9][0-9]*)*$ ]]' + - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 + with: + artifact-ids: ${{ inputs.native_artifact_id }} + merge-multiple: true + path: .artifacts/native-download + - name: Restore verified same-run native input + run: python3 scripts/build-inputs.py restore native --input .artifacts/native-download/native-input.tar.gz --output .artifacts/native-input --target "$PACKAGE_TARGET" --producer-attempt "$VIBEFACE_INPUT_ATTEMPT" + - uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec + with: + components: rustfmt + - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 + with: + python-version: '3.12' + - uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 + if: inputs.target == 'x86_64-unknown-linux-gnu' + with: + version: 11.9.0 + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 + with: + node-version: '24' + cache: ${{ inputs.target == 'x86_64-unknown-linux-gnu' && 'pnpm' || '' }} + cache-dependency-path: pnpm-lock.yaml + - name: Import Developer ID signing identity + if: inputs.target == 'aarch64-apple-darwin' && github.event_name != 'merge_group' + env: + MACOS_CERTIFICATE_P12_BASE64: ${{ secrets.MACOS_CERTIFICATE_P12_BASE64 }} + MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }} + APPLE_API_KEY_P8_BASE64: ${{ secrets.APPLE_API_KEY_P8_BASE64 }} + APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }} + APPLE_API_ISSUER_ID: ${{ secrets.APPLE_API_ISSUER_ID }} + run: | + for name in MACOS_CERTIFICATE_P12_BASE64 MACOS_CERTIFICATE_PASSWORD APPLE_API_KEY_P8_BASE64 APPLE_API_KEY_ID APPLE_API_ISSUER_ID; do + [[ -n "${!name}" ]] || { echo "::error::Repository secret $name is required to sign and notarize macOS packages."; exit 1; } + done + echo "::add-mask::$APPLE_API_KEY_ID" + echo "::add-mask::$APPLE_API_ISSUER_ID" + keychain="$RUNNER_TEMP/vibeface-signing.keychain-db" + keychain_password="$(openssl rand -hex 32)" + echo "::add-mask::$keychain_password" + umask 077 + printf '%s' "$MACOS_CERTIFICATE_P12_BASE64" | base64 --decode > "$RUNNER_TEMP/vibeface-signing.p12" + printf '%s' "$APPLE_API_KEY_P8_BASE64" | base64 --decode > "$RUNNER_TEMP/vibeface-notary.p8" + security create-keychain -p "$keychain_password" "$keychain" + security set-keychain-settings -lut 21600 "$keychain" + security unlock-keychain -p "$keychain_password" "$keychain" + security import "$RUNNER_TEMP/vibeface-signing.p12" -k "$keychain" -P "$MACOS_CERTIFICATE_PASSWORD" -f pkcs12 -T /usr/bin/codesign + rm -f "$RUNNER_TEMP/vibeface-signing.p12" + security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$keychain_password" "$keychain" > /dev/null + existing=() + while IFS= read -r line; do + line="${line#"${line%%[![:space:]]*}"}" + existing+=("${line//\"/}") + done < <(security list-keychains -d user) + security list-keychains -d user -s "$keychain" "${existing[@]}" + identities="$(security find-identity -v -p codesigning "$keychain" | grep '"Developer ID Application: ' || true)" + [[ -n "$identities" && "$(wc -l <<< "$identities")" -eq 1 ]] || { echo '::error::Expected exactly one Developer ID Application identity in the certificate.'; exit 1; } + identity="$(awk '{print $2}' <<< "$identities")" + team="$(sed -n 's/.*(\([A-Z0-9]\{10\}\))"$/\1/p' <<< "$identities")" + [[ "$identity" =~ ^[0-9A-F]{40}$ && -n "$team" ]] || { echo '::error::Could not resolve the signing identity or team.'; exit 1; } + { + printf 'VIBEFACE_CODESIGN_IDENTITY=%s\n' "$identity" + printf 'VIBEFACE_CODESIGN_TEAM=%s\n' "$team" + printf 'VIBEFACE_NOTARY_KEY=%s\n' "$RUNNER_TEMP/vibeface-notary.p8" + printf 'VIBEFACE_NOTARY_KEY_ID=%s\n' "$APPLE_API_KEY_ID" + printf 'VIBEFACE_NOTARY_ISSUER=%s\n' "$APPLE_API_ISSUER_ID" + } >> "$GITHUB_ENV" + - name: Build native release package + run: | + [[ "$(rustc -vV | sed -n 's/^host: //p')" == "$PACKAGE_TARGET" ]] + bash scripts/package-node.sh --target "$PACKAGE_TARGET" --native-input "$PWD/.artifacts/native-input" + if [[ -n "${VIBEFACE_NOTARY_KEY:-}" ]]; then + security delete-keychain "$RUNNER_TEMP/vibeface-signing.keychain-db" + rm -f "$VIBEFACE_NOTARY_KEY" + fi + - name: Verify checksum and unpacked source identity + id: unpack + shell: bash + run: | + shopt -s nullglob + archives=(.artifacts/packages/*.tar.gz) + [[ "${#archives[@]}" == 1 ]] + archive="${archives[0]}" + name="$(basename "$archive" .tar.gz)" + (cd .artifacts/packages && shasum -a 256 -c "$name.tar.gz.sha256") + mkdir -p .artifacts/unpacked + tar -xzf "$archive" -C .artifacts/unpacked + package="$PWD/.artifacts/unpacked/$name" + python3 - "$package/BUILD-INFO.json" <<'PY' + import json, os, pathlib, re, subprocess, sys + info = json.load(open(sys.argv[1])) + config = pathlib.Path("crates/control/src/lib.rs").read_text() + protocol, epoch = (int(re.search(rf"^pub const {name}: u32 = (\d+);$", config, re.M)[1]) for name in ("UPDATE_PROTOCOL", "DATA_EPOCH")) + assert set(info) == {"version", "target", "source_commit", "update_protocol", "data_epoch", "core_version", "core_source_commit", "app_version", "app_source_commit"} + assert info["update_protocol"] == protocol and info["data_epoch"] == epoch + assert info["source_commit"] == os.environ["GITHUB_SHA"] + assert info["target"] == os.environ["PACKAGE_TARGET"] + binary = pathlib.Path(sys.argv[1]).parent / "vibeface" + web = binary.parent / "web" + assert (web / "_shell.html").stat().st_size > 0 + assert (web / "index.html").stat().st_size > 0 + assert (web / "_redirects").stat().st_size > 0 + assert (web / "_headers").stat().st_size > 0 + assert (web / ".vibeface-build.json").stat().st_size > 0 + assert (web / "vibeface_secure.js").stat().st_size > 0 + assert (web / "vibeface_secure_bg.wasm").read_bytes().startswith(b"\x00asm") + assert (binary.parent / "vibeface-core").stat().st_size > 0 + assert subprocess.check_output([str(binary), "--version"], text=True).strip() == f'vibeface {info["version"]}' + assert subprocess.check_output([str(binary.parent / "vibeface-core"), "--version"], text=True).strip() == f'vibeface-core {info["core_version"]}' + PY + "$package/vibeface" --help + "$package/vibeface-core" --help + printf 'package=%s\n' "$package" >> "$GITHUB_OUTPUT" + - name: Verify Developer ID signature + if: inputs.target == 'aarch64-apple-darwin' && github.event_name != 'merge_group' + env: + PACKAGE: ${{ steps.unpack.outputs.package }} + run: | + set -o pipefail + for binary in "$PACKAGE/vibeface" "$PACKAGE/vibeface-core"; do + codesign --verify --strict "$binary" + details="$(codesign -dvvv "$binary" 2>&1)" + printf '%s\n' "$details" + grep -qx 'Identifier=cn.leaperone.vibeface' <<< "$details" + grep -qx "TeamIdentifier=$VIBEFACE_CODESIGN_TEAM" <<< "$details" + grep -Eq '^CodeDirectory .*flags=0x[0-9a-f]+\([^)]*runtime' <<< "$details" + binary_sha="$(shasum -a 256 "$binary" | cut -d ' ' -f 1)" + delays=(15 30 60 120 120 120 120 120 120) + for attempt in $(seq 0 "${#delays[@]}"); do + assessment="$RUNNER_TEMP/gatekeeper-assessment-$(basename "$binary")-$attempt.txt" + if spctl -a -vvv --ignore-cache --no-cache -t open --context context:primary-signature "$binary" >"$assessment" 2>&1; then + assessment_status=0 + else + assessment_status=$? + fi + cat "$assessment" + printf 'Gatekeeper assessment %s exited %s\n' "$attempt" "$assessment_status" + test "$(shasum -a 256 "$binary" | cut -d ' ' -f 1)" = "$binary_sha" + if test "$assessment_status" -eq 0; then + grep -qx 'source=Notarized Developer ID' "$assessment" + break + fi + if test "$assessment_status" -ne 3 || ! grep -qx 'source=Unnotarized Developer ID' "$assessment" || test "$attempt" -eq "${#delays[@]}"; then + exit "$assessment_status" + fi + sleep "${delays[$attempt]}" + done + done + - name: Verify packaged Web assets and process + env: + PACKAGE: ${{ steps.unpack.outputs.package }} + run: python3 scripts/verify-node.py --binary "$PACKAGE/vibeface" --core-binary "$PACKAGE/vibeface-core" --crypto-module "$PACKAGE/web/vibeface_secure.js" --artifacts .artifacts/ci-web --web-only + - name: Verify packaged free discovery and charity delivery over real Node processes + if: inputs.delivery && inputs.target == 'x86_64-unknown-linux-gnu' + env: + PACKAGE: ${{ steps.unpack.outputs.package }} + VIBEFACE_PROBE_SOURCE_ROOT: ${{ github.workspace }} + CARGO_TARGET_DIR: ${{ github.workspace }}/.artifacts/delivery-probe/target + run: | + cargo fmt --manifest-path tests/fixtures/delivery-probe/Cargo.toml -- --check + cargo build --manifest-path tests/fixtures/delivery-probe/Cargo.toml --locked + python3 scripts/verify-node.py --delivery-charity --binary "$PACKAGE/vibeface" --core-binary "$PACKAGE/vibeface-core" --crypto-module "$PACKAGE/web/vibeface_secure.js" --artifacts "$PWD/.artifacts/ci-delivery" --delivery-probe "$CARGO_TARGET_DIR/debug/vibeface-delivery-probe" --delivery-source-root "$PWD" --delivery-profile "$PWD/crates/delivery/proof/profile.json" + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 + if: ${{ !cancelled() && inputs.delivery && inputs.target == 'x86_64-unknown-linux-gnu' }} + with: + name: delivery-charity-${{ github.sha }}-${{ github.run_attempt }} + path: .artifacts/ci-delivery/delivery-charity-*/report.json + if-no-files-found: warn + retention-days: 7 + - name: Use official Ubuntu package mirror + if: inputs.target == 'x86_64-unknown-linux-gnu' + run: printf 'https://archive.ubuntu.com/ubuntu/\n' | sudo tee /etc/apt/apt-mirrors.txt > /dev/null + - name: Cache Chromium binaries + if: inputs.target == 'x86_64-unknown-linux-gnu' + uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 + with: + path: .artifacts/e2e/browsers + key: ${{ inputs.runner }}-${{ runner.arch }}-chromium-${{ hashFiles('pnpm-lock.yaml') }} + - name: Verify packaged Web onboarding in Chromium + if: inputs.target == 'x86_64-unknown-linux-gnu' + env: + VIBEFACE_E2E_BINARY: ${{ steps.unpack.outputs.package }}/vibeface + PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/.artifacts/e2e/browsers + E2E_TELEMETRY_DISABLED: '1' + run: | + pnpm install --frozen-lockfile --filter . + pnpm test:e2e:check + pnpm exec e2e-web install chromium --with-deps + pnpm test:e2e + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 + if: ${{ !cancelled() && inputs.target == 'x86_64-unknown-linux-gnu' }} + with: + name: e2e-${{ github.sha }}-${{ github.run_attempt }} + path: | + tests/e2e/.artifacts/results + !tests/e2e/.artifacts/results/**/downloads/** + if-no-files-found: warn + retention-days: 7 + - name: Verify unpacked Node scheduling and signed log without model calls + if: inputs.package_mode == 'node' && inputs.target == 'x86_64-unknown-linux-gnu' + env: + PACKAGE: ${{ steps.unpack.outputs.package }} + run: python3 scripts/verify-node.py --binary "$PACKAGE/vibeface" --core-binary "$PACKAGE/vibeface-core" --crypto-module "$PACKAGE/web/vibeface_secure.js" --artifacts .artifacts/ci-node --phase1 + - name: Verify multi-Node sync, entrances and delivery over iroh + if: inputs.package_mode == 'node' && inputs.target == 'x86_64-unknown-linux-gnu' + env: + PACKAGE: ${{ steps.unpack.outputs.package }} + run: python3 scripts/verify-node.py --binary "$PACKAGE/vibeface" --core-binary "$PACKAGE/vibeface-core" --crypto-module "$PACKAGE/web/vibeface_secure.js" --artifacts .artifacts/ci-multi-node + - name: Verify cross-device coordination, owner moves and attachments + if: inputs.package_mode == 'node' && inputs.target == 'x86_64-unknown-linux-gnu' + env: + PACKAGE: ${{ steps.unpack.outputs.package }} + run: python3 scripts/verify-node.py --binary "$PACKAGE/vibeface" --core-binary "$PACKAGE/vibeface-core" --crypto-module "$PACKAGE/web/vibeface_secure.js" --artifacts .artifacts/ci-phase4 --phase4 + - name: Verify the public entry and its relay token + if: inputs.package_mode == 'node' && inputs.target == 'x86_64-unknown-linux-gnu' + env: + PACKAGE: ${{ steps.unpack.outputs.package }} + run: python3 scripts/verify-node.py --binary "$PACKAGE/vibeface" --core-binary "$PACKAGE/vibeface-core" --crypto-module "$PACKAGE/web/vibeface_secure.js" --artifacts .artifacts/ci-public-entry --public-entry + - name: Verify discovery-only assistance and headless Nodes + if: inputs.package_mode == 'node' && inputs.target == 'x86_64-unknown-linux-gnu' + env: + PACKAGE: ${{ steps.unpack.outputs.package }} + run: python3 scripts/verify-node.py --binary "$PACKAGE/vibeface" --core-binary "$PACKAGE/vibeface-core" --crypto-module "$PACKAGE/web/vibeface_secure.js" --artifacts .artifacts/ci-discovery --discovery + - name: Verify independent macOS process suites + if: inputs.package_mode == 'node' && inputs.target == 'aarch64-apple-darwin' + env: + PACKAGE: ${{ steps.unpack.outputs.package }} + run: python3 scripts/ci.py macos-process --package "$PACKAGE" --artifacts .artifacts/macos-process + - name: Upload verified package + id: upload + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 + with: + name: node-package-${{ inputs.target }}-${{ github.sha }}-${{ github.run_attempt }} + path: | + .artifacts/packages/*.tar.gz + .artifacts/packages/*.tar.gz.sha256 + include-hidden-files: true + if-no-files-found: error + retention-days: 14 + - name: Upload Node failure diagnostics + if: failure() + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 + with: + name: node-process-failure-${{ inputs.target }}-${{ github.run_attempt }} + path: | + .artifacts/macos-process/results.json + .artifacts/macos-process/*.log + .artifacts/ci-web/web-process-*/report.json + .artifacts/ci-web/web-process-*/WEB/process.log + .artifacts/ci-node/phase1-process-*/report.json + .artifacts/ci-node/phase1-process-*/A/process.log + .artifacts/ci-node/phase1-process-*/fixture-manager-*.stderr.log + .artifacts/macos-process/chat-agent/runs/chat-agent-process-*/report.json + .artifacts/macos-process/chat-agent/runs/chat-agent-process-*/A/process.log + .artifacts/macos-process/chat-agent/runs/chat-agent-process-*/fixture-manager-*.stderr.log + .artifacts/macos-process/chat-agent/runs/chat-agent-process-*/manager-tool-errors.jsonl + .artifacts/ci-phase4/phase4-*/report.json + .artifacts/ci-phase4/phase4-*/*/node.log + .artifacts/ci-discovery/discovery-*/report.json + .artifacts/ci-discovery/discovery-*/*/node.log + .artifacts/ci-public-entry/public-entry-*/report.json + .artifacts/ci-public-entry/public-entry-*/*/node.log + .artifacts/macos-process/phase5/runs/phase5-*/report.json + .artifacts/macos-process/phase5/runs/phase5-*/*/node.log + include-hidden-files: true + if-no-files-found: ignore + retention-days: 7 + - name: Remove signing keychain and notary key + if: always() && inputs.target == 'aarch64-apple-darwin' && github.event_name != 'merge_group' + run: | + security delete-keychain "$RUNNER_TEMP/vibeface-signing.keychain-db" 2> /dev/null || true + rm -f "$RUNNER_TEMP/vibeface-notary.p8" "$RUNNER_TEMP/vibeface-signing.p12" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f89f023ab..d440f7056 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,10 @@ on: - cron: '23 3 * * *' workflow_dispatch: inputs: + feedback: + description: 'Replace older ordinary feedback on this branch; keep the full acceptance scope' + type: boolean + default: false delivery_live: description: 'Run genuine local paid delivery proofs and settlement in the bounded Linux sandbox' type: boolean @@ -23,8 +27,8 @@ on: default: '' concurrency: - group: ${{ github.workflow }}-${{ github.event_name == 'workflow_dispatch' && inputs.delivery_small && 'delivery-small' || format('{0}-{1}-{2}', github.event_name, github.ref, (github.event_name == 'workflow_dispatch' || github.run_attempt > 1) && github.run_id || '') }} - cancel-in-progress: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && github.run_attempt == 1 }} + group: ${{ github.workflow }}-${{ github.event_name == 'workflow_dispatch' && inputs.delivery_small && 'delivery-small' || format('{0}-{1}-{2}', github.event_name, github.ref, github.event_name == 'workflow_dispatch' && inputs.feedback && !inputs.delivery_live && !inputs.delivery_small && inputs.delivery_small_resume_run == '' && github.run_attempt == 1 && 'feedback' || (github.event_name == 'workflow_dispatch' || github.run_attempt > 1) && github.run_id || '') }} + cancel-in-progress: ${{ github.run_attempt == 1 && (github.event_name == 'push' && github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' && inputs.feedback && !inputs.delivery_live && !inputs.delivery_small && inputs.delivery_small_resume_run == '') }} permissions: contents: read @@ -128,7 +132,7 @@ jobs: pnpm --filter vibeface-www run check:static - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 with: - name: www-${{ github.sha }} + name: www-${{ github.sha }}-${{ github.run_attempt }} path: apps/www/dist/client include-hidden-files: true if-no-files-found: error @@ -137,6 +141,8 @@ jobs: crypto-web: needs: plan if: needs.plan.outputs.web == 'true' + outputs: + artifact_id: ${{ steps.upload.outputs.artifact-id }} runs-on: ubuntu-24.04 steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 @@ -159,9 +165,10 @@ jobs: bash scripts/build-web-crypto.sh cargo build -p vibeface-secure --example secure-probe --locked node scripts/crypto-client.mjs --self-test --native-probe target/debug/examples/secure-probe - - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + - id: upload + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 with: - name: crypto-web-${{ github.sha }} + name: crypto-web-${{ github.sha }}-${{ github.run_attempt }} path: | apps/app/generated/vibeface_secure.js apps/app/generated/vibeface_secure_bg.wasm @@ -174,14 +181,21 @@ jobs: web: needs: [plan, crypto-web] if: needs.plan.outputs.web == 'true' + outputs: + artifact_id: ${{ steps.upload.outputs.artifact-id }} runs-on: ubuntu-24.04 steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: persist-credentials: false + - name: Require explicit producer artifact IDs + env: + ARTIFACT_IDS: ${{ needs.crypto-web.outputs.artifact_id }} + run: '[[ "$ARTIFACT_IDS" =~ ^[1-9][0-9]*(,[1-9][0-9]*)*$ ]]' - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 with: - name: crypto-web-${{ github.sha }} + artifact-ids: ${{ needs.crypto-web.outputs.artifact_id }} + merge-multiple: true path: apps/app/generated - uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4 with: @@ -193,9 +207,10 @@ jobs: cache-dependency-path: pnpm-lock.yaml - name: Build and typecheck the static web client run: bash scripts/build-web.sh - - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + - id: upload + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 with: - name: web-${{ github.sha }} + name: web-${{ github.sha }}-${{ github.run_attempt }} path: apps/app/dist/client include-hidden-files: true if-no-files-found: error @@ -312,7 +327,7 @@ jobs: - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 if: ${{ !cancelled() }} with: - name: delivery-${{ github.sha }} + name: delivery-${{ github.sha }}-${{ github.run_attempt }} path: | .artifacts/vdp/host-info.json .artifacts/vdp/proof-results.json @@ -321,298 +336,77 @@ jobs: if-no-files-found: warn retention-days: 7 - package: - needs: [plan, crypto-web, web] - if: needs.plan.outputs.package == 'true' - name: package (${{ matrix.target }}) - runs-on: ${{ matrix.runner }} - strategy: - fail-fast: false - matrix: ${{ fromJSON(needs.plan.outputs.package_matrix) }} - env: - PACKAGE_TARGET: ${{ matrix.target }} - steps: - - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - with: - persist-credentials: false - - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 - with: - name: crypto-web-${{ github.sha }} - path: apps/app/generated - - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 - with: - name: web-${{ github.sha }} - path: apps/app/dist/client - - uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable - with: - components: rustfmt - - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 - with: - key: package-${{ matrix.target }} - save-if: ${{ github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' }} - - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 - with: - python-version: '3.12' - - uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4 - if: matrix.target == 'x86_64-unknown-linux-gnu' - with: - version: 11.9.0 - - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 - with: - node-version: '24' - cache: ${{ matrix.target == 'x86_64-unknown-linux-gnu' && 'pnpm' || '' }} - cache-dependency-path: pnpm-lock.yaml - - name: Import Developer ID signing identity - if: matrix.target == 'aarch64-apple-darwin' && github.event_name != 'merge_group' - env: - MACOS_CERTIFICATE_P12_BASE64: ${{ secrets.MACOS_CERTIFICATE_P12_BASE64 }} - MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }} - APPLE_API_KEY_P8_BASE64: ${{ secrets.APPLE_API_KEY_P8_BASE64 }} - APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }} - APPLE_API_ISSUER_ID: ${{ secrets.APPLE_API_ISSUER_ID }} - run: | - for name in MACOS_CERTIFICATE_P12_BASE64 MACOS_CERTIFICATE_PASSWORD APPLE_API_KEY_P8_BASE64 APPLE_API_KEY_ID APPLE_API_ISSUER_ID; do - [[ -n "${!name}" ]] || { echo "::error::Repository secret $name is required to sign and notarize macOS packages."; exit 1; } - done - echo "::add-mask::$APPLE_API_KEY_ID" - echo "::add-mask::$APPLE_API_ISSUER_ID" - keychain="$RUNNER_TEMP/vibeface-signing.keychain-db" - keychain_password="$(openssl rand -hex 32)" - echo "::add-mask::$keychain_password" - umask 077 - printf '%s' "$MACOS_CERTIFICATE_P12_BASE64" | base64 --decode > "$RUNNER_TEMP/vibeface-signing.p12" - printf '%s' "$APPLE_API_KEY_P8_BASE64" | base64 --decode > "$RUNNER_TEMP/vibeface-notary.p8" - security create-keychain -p "$keychain_password" "$keychain" - security set-keychain-settings -lut 21600 "$keychain" - security unlock-keychain -p "$keychain_password" "$keychain" - security import "$RUNNER_TEMP/vibeface-signing.p12" -k "$keychain" -P "$MACOS_CERTIFICATE_PASSWORD" -f pkcs12 -T /usr/bin/codesign - rm -f "$RUNNER_TEMP/vibeface-signing.p12" - security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$keychain_password" "$keychain" > /dev/null - existing=() - while IFS= read -r line; do - line="${line#"${line%%[![:space:]]*}"}" - existing+=("${line//\"/}") - done < <(security list-keychains -d user) - security list-keychains -d user -s "$keychain" "${existing[@]}" - identities="$(security find-identity -v -p codesigning "$keychain" | grep '"Developer ID Application: ' || true)" - [[ -n "$identities" && "$(wc -l <<< "$identities")" -eq 1 ]] || { echo '::error::Expected exactly one Developer ID Application identity in the certificate.'; exit 1; } - identity="$(awk '{print $2}' <<< "$identities")" - team="$(sed -n 's/.*(\([A-Z0-9]\{10\}\))"$/\1/p' <<< "$identities")" - [[ "$identity" =~ ^[0-9A-F]{40}$ && -n "$team" ]] || { echo '::error::Could not resolve the signing identity or team.'; exit 1; } - { - printf 'VIBEFACE_CODESIGN_IDENTITY=%s\n' "$identity" - printf 'VIBEFACE_CODESIGN_TEAM=%s\n' "$team" - printf 'VIBEFACE_NOTARY_KEY=%s\n' "$RUNNER_TEMP/vibeface-notary.p8" - printf 'VIBEFACE_NOTARY_KEY_ID=%s\n' "$APPLE_API_KEY_ID" - printf 'VIBEFACE_NOTARY_ISSUER=%s\n' "$APPLE_API_ISSUER_ID" - } >> "$GITHUB_ENV" - - name: Build native release package - run: | - [[ "$(rustc -vV | sed -n 's/^host: //p')" == "$PACKAGE_TARGET" ]] - bash scripts/package-node.sh --target "$PACKAGE_TARGET" - if [[ -n "${VIBEFACE_NOTARY_KEY:-}" ]]; then - security delete-keychain "$RUNNER_TEMP/vibeface-signing.keychain-db" - rm -f "$VIBEFACE_NOTARY_KEY" - fi - - name: Verify checksum and unpacked source identity - id: unpack - shell: bash - run: | - shopt -s nullglob - archives=(.artifacts/packages/*.tar.gz) - [[ "${#archives[@]}" == 1 ]] - archive="${archives[0]}" - name="$(basename "$archive" .tar.gz)" - (cd .artifacts/packages && shasum -a 256 -c "$name.tar.gz.sha256") - mkdir -p .artifacts/unpacked - tar -xzf "$archive" -C .artifacts/unpacked - package="$PWD/.artifacts/unpacked/$name" - python3 - "$package/BUILD-INFO.json" <<'PY' - import json, os, pathlib, re, subprocess, sys - info = json.load(open(sys.argv[1])) - config = pathlib.Path("crates/control/src/lib.rs").read_text() - protocol, epoch = (int(re.search(rf"^pub const {name}: u32 = (\d+);$", config, re.M)[1]) for name in ("UPDATE_PROTOCOL", "DATA_EPOCH")) - assert set(info) == {"version", "target", "source_commit", "update_protocol", "data_epoch", "core_version", "core_source_commit", "app_version", "app_source_commit"} - assert info["update_protocol"] == protocol and info["data_epoch"] == epoch - assert info["source_commit"] == os.environ["GITHUB_SHA"] - assert info["target"] == os.environ["PACKAGE_TARGET"] - binary = pathlib.Path(sys.argv[1]).parent / "vibeface" - web = binary.parent / "web" - assert (web / "_shell.html").stat().st_size > 0 - assert (web / "index.html").stat().st_size > 0 - assert (web / "_redirects").stat().st_size > 0 - assert (web / "_headers").stat().st_size > 0 - assert (web / ".vibeface-build.json").stat().st_size > 0 - assert (web / "vibeface_secure.js").stat().st_size > 0 - assert (web / "vibeface_secure_bg.wasm").read_bytes().startswith(b"\x00asm") - assert (binary.parent / "vibeface-core").stat().st_size > 0 - assert subprocess.check_output([str(binary), "--version"], text=True).strip() == f'vibeface {info["version"]}' - assert subprocess.check_output([str(binary.parent / "vibeface-core"), "--version"], text=True).strip() == f'vibeface-core {info["core_version"]}' - PY - "$package/vibeface" --help - "$package/vibeface-core" --help - printf 'package=%s\n' "$package" >> "$GITHUB_OUTPUT" - - name: Verify Developer ID signature - if: matrix.target == 'aarch64-apple-darwin' && github.event_name != 'merge_group' - env: - PACKAGE: ${{ steps.unpack.outputs.package }} - run: | - set -o pipefail - for binary in "$PACKAGE/vibeface" "$PACKAGE/vibeface-core"; do - codesign --verify --strict "$binary" - details="$(codesign -dvvv "$binary" 2>&1)" - printf '%s\n' "$details" - grep -qx 'Identifier=cn.leaperone.vibeface' <<< "$details" - grep -qx "TeamIdentifier=$VIBEFACE_CODESIGN_TEAM" <<< "$details" - grep -Eq '^CodeDirectory .*flags=0x[0-9a-f]+\([^)]*runtime' <<< "$details" - binary_sha="$(shasum -a 256 "$binary" | cut -d ' ' -f 1)" - delays=(15 30 60 120 120 120 120 120 120) - for attempt in $(seq 0 "${#delays[@]}"); do - assessment="$RUNNER_TEMP/gatekeeper-assessment-$(basename "$binary")-$attempt.txt" - if spctl -a -vvv --ignore-cache --no-cache -t open --context context:primary-signature "$binary" >"$assessment" 2>&1; then - assessment_status=0 - else - assessment_status=$? - fi - cat "$assessment" - printf 'Gatekeeper assessment %s exited %s\n' "$attempt" "$assessment_status" - test "$(shasum -a 256 "$binary" | cut -d ' ' -f 1)" = "$binary_sha" - if test "$assessment_status" -eq 0; then - grep -qx 'source=Notarized Developer ID' "$assessment" - break - fi - if test "$assessment_status" -ne 3 || ! grep -qx 'source=Unnotarized Developer ID' "$assessment" || test "$attempt" -eq "${#delays[@]}"; then - exit "$assessment_status" - fi - sleep "${delays[$attempt]}" - done - done - - name: Verify packaged Web assets and process - env: - PACKAGE: ${{ steps.unpack.outputs.package }} - run: python3 scripts/verify-node.py --binary "$PACKAGE/vibeface" --core-binary "$PACKAGE/vibeface-core" --crypto-module "$PACKAGE/web/vibeface_secure.js" --artifacts .artifacts/ci-web --web-only - - name: Verify packaged free discovery and charity delivery over real Node processes - if: needs.plan.outputs.delivery == 'true' && matrix.target == 'x86_64-unknown-linux-gnu' - env: - PACKAGE: ${{ steps.unpack.outputs.package }} - VIBEFACE_PROBE_SOURCE_ROOT: ${{ github.workspace }} - CARGO_TARGET_DIR: ${{ github.workspace }}/.artifacts/delivery-probe/target - run: | - cargo fmt --manifest-path tests/fixtures/delivery-probe/Cargo.toml -- --check - cargo build --manifest-path tests/fixtures/delivery-probe/Cargo.toml --locked - python3 scripts/verify-node.py --delivery-charity --binary "$PACKAGE/vibeface" --core-binary "$PACKAGE/vibeface-core" --crypto-module "$PACKAGE/web/vibeface_secure.js" --artifacts "$PWD/.artifacts/ci-delivery" --delivery-probe "$CARGO_TARGET_DIR/debug/vibeface-delivery-probe" --delivery-source-root "$PWD" --delivery-profile "$PWD/crates/delivery/proof/profile.json" - - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 - if: ${{ !cancelled() && needs.plan.outputs.delivery == 'true' && matrix.target == 'x86_64-unknown-linux-gnu' }} - with: - name: delivery-charity-${{ github.sha }} - path: .artifacts/ci-delivery/delivery-charity-*/report.json - if-no-files-found: warn - retention-days: 7 - - name: Use official Ubuntu package mirror - if: matrix.target == 'x86_64-unknown-linux-gnu' - run: printf 'https://archive.ubuntu.com/ubuntu/\n' | sudo tee /etc/apt/apt-mirrors.txt > /dev/null - - name: Cache Chromium binaries - if: matrix.target == 'x86_64-unknown-linux-gnu' - uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 - with: - path: .artifacts/e2e/browsers - key: ${{ matrix.runner }}-${{ runner.arch }}-chromium-${{ hashFiles('pnpm-lock.yaml') }} - - name: Verify packaged Web onboarding in Chromium - if: matrix.target == 'x86_64-unknown-linux-gnu' - env: - VIBEFACE_E2E_BINARY: ${{ steps.unpack.outputs.package }}/vibeface - PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/.artifacts/e2e/browsers - E2E_TELEMETRY_DISABLED: '1' - run: | - pnpm install --frozen-lockfile --filter . - pnpm test:e2e:check - pnpm exec e2e-web install chromium --with-deps - pnpm test:e2e - - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 - if: ${{ !cancelled() && matrix.target == 'x86_64-unknown-linux-gnu' }} - with: - name: e2e-${{ github.sha }} - path: | - tests/e2e/.artifacts/results - !tests/e2e/.artifacts/results/**/downloads/** - if-no-files-found: warn - retention-days: 7 - - name: Verify unpacked Node scheduling and signed log without model calls - if: needs.plan.outputs.package_mode == 'node' && matrix.target == 'x86_64-unknown-linux-gnu' - env: - PACKAGE: ${{ steps.unpack.outputs.package }} - run: python3 scripts/verify-node.py --binary "$PACKAGE/vibeface" --core-binary "$PACKAGE/vibeface-core" --crypto-module "$PACKAGE/web/vibeface_secure.js" --artifacts .artifacts/ci-node --phase1 - - name: Verify multi-Node sync, entrances and delivery over iroh - if: needs.plan.outputs.package_mode == 'node' && matrix.target == 'x86_64-unknown-linux-gnu' - env: - PACKAGE: ${{ steps.unpack.outputs.package }} - run: python3 scripts/verify-node.py --binary "$PACKAGE/vibeface" --core-binary "$PACKAGE/vibeface-core" --crypto-module "$PACKAGE/web/vibeface_secure.js" --artifacts .artifacts/ci-multi-node - - name: Verify bot tools and startup event recovery - if: needs.plan.outputs.package_mode == 'node' && matrix.target == 'aarch64-apple-darwin' - env: - PACKAGE: ${{ steps.unpack.outputs.package }} - run: python3 scripts/verify-node.py --binary "$PACKAGE/vibeface" --core-binary "$PACKAGE/vibeface-core" --crypto-module "$PACKAGE/web/vibeface_secure.js" --artifacts .artifacts/ci-chat-agent --chat-agent - - name: Verify cross-device coordination, owner moves and attachments - if: needs.plan.outputs.package_mode == 'node' && matrix.target == 'x86_64-unknown-linux-gnu' - env: - PACKAGE: ${{ steps.unpack.outputs.package }} - run: python3 scripts/verify-node.py --binary "$PACKAGE/vibeface" --core-binary "$PACKAGE/vibeface-core" --crypto-module "$PACKAGE/web/vibeface_secure.js" --artifacts .artifacts/ci-phase4 --phase4 - - name: Verify the public entry and its relay token - if: needs.plan.outputs.package_mode == 'node' && matrix.target == 'x86_64-unknown-linux-gnu' - env: - PACKAGE: ${{ steps.unpack.outputs.package }} - run: python3 scripts/verify-node.py --binary "$PACKAGE/vibeface" --core-binary "$PACKAGE/vibeface-core" --crypto-module "$PACKAGE/web/vibeface_secure.js" --artifacts .artifacts/ci-public-entry --public-entry - - name: Verify discovery-only assistance and headless Nodes - if: needs.plan.outputs.package_mode == 'node' && matrix.target == 'x86_64-unknown-linux-gnu' - env: - PACKAGE: ${{ steps.unpack.outputs.package }} - run: python3 scripts/verify-node.py --binary "$PACKAGE/vibeface" --core-binary "$PACKAGE/vibeface-core" --crypto-module "$PACKAGE/web/vibeface_secure.js" --artifacts .artifacts/ci-discovery --discovery - - name: Verify write protection, status and diagnostics - if: needs.plan.outputs.package_mode == 'node' && matrix.target == 'aarch64-apple-darwin' - env: - PACKAGE: ${{ steps.unpack.outputs.package }} - run: python3 scripts/verify-node.py --binary "$PACKAGE/vibeface" --core-binary "$PACKAGE/vibeface-core" --crypto-module "$PACKAGE/web/vibeface_secure.js" --artifacts .artifacts/ci-phase5 --phase5 - - name: Upload verified package - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 - with: - name: node-package-${{ matrix.target }}-${{ github.sha }} - path: | - .artifacts/packages/*.tar.gz - .artifacts/packages/*.tar.gz.sha256 - include-hidden-files: true - if-no-files-found: error - retention-days: 14 - - name: Upload Node failure diagnostics - if: failure() - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 - with: - name: node-process-failure-${{ matrix.target }}-${{ github.run_attempt }} - path: | - .artifacts/ci-web/web-process-*/report.json - .artifacts/ci-web/web-process-*/WEB/process.log - .artifacts/ci-node/phase1-process-*/report.json - .artifacts/ci-node/phase1-process-*/A/process.log - .artifacts/ci-node/phase1-process-*/fixture-manager-*.stderr.log - .artifacts/ci-chat-agent/chat-agent-process-*/report.json - .artifacts/ci-chat-agent/chat-agent-process-*/A/process.log - .artifacts/ci-chat-agent/chat-agent-process-*/fixture-manager-*.stderr.log - .artifacts/ci-chat-agent/chat-agent-process-*/manager-tool-errors.jsonl - .artifacts/ci-phase4/phase4-*/report.json - .artifacts/ci-phase4/phase4-*/*/node.log - .artifacts/ci-discovery/discovery-*/report.json - .artifacts/ci-discovery/discovery-*/*/node.log - .artifacts/ci-public-entry/public-entry-*/report.json - .artifacts/ci-public-entry/public-entry-*/*/node.log - .artifacts/ci-phase5/phase5-*/report.json - .artifacts/ci-phase5/phase5-*/*/node.log - include-hidden-files: true - if-no-files-found: ignore - retention-days: 7 - - name: Remove signing keychain and notary key - if: always() && matrix.target == 'aarch64-apple-darwin' && github.event_name != 'merge_group' - run: | - security delete-keychain "$RUNNER_TEMP/vibeface-signing.keychain-db" 2> /dev/null || true - rm -f "$RUNNER_TEMP/vibeface-notary.p8" "$RUNNER_TEMP/vibeface-signing.p12" + native-linux: + needs: plan + if: contains(fromJSON(needs.plan.outputs.package_matrix).include.*.target, 'x86_64-unknown-linux-gnu') + uses: ./.github/workflows/ci-native.yml + with: + runner: ubuntu-24.04 + target: x86_64-unknown-linux-gnu + + package-linux: + needs: [plan, native-linux, crypto-web, web] + if: contains(fromJSON(needs.plan.outputs.package_matrix).include.*.target, 'x86_64-unknown-linux-gnu') + uses: ./.github/workflows/ci-package.yml + with: + runner: ubuntu-24.04 + target: x86_64-unknown-linux-gnu + native_artifact_id: ${{ needs.native-linux.outputs.artifact_id }} + producer_attempt: ${{ needs.native-linux.outputs.producer_attempt }} + crypto_artifact_id: ${{ needs.crypto-web.outputs.artifact_id }} + web_artifact_id: ${{ needs.web.outputs.artifact_id }} + package_mode: ${{ needs.plan.outputs.package_mode }} + delivery: ${{ needs.plan.outputs.delivery == 'true' }} + + native-linux-arm: + needs: plan + if: contains(fromJSON(needs.plan.outputs.package_matrix).include.*.target, 'aarch64-unknown-linux-gnu') + uses: ./.github/workflows/ci-native.yml + with: + runner: ubuntu-24.04-arm + target: aarch64-unknown-linux-gnu + + package-linux-arm: + needs: [plan, native-linux-arm, crypto-web, web] + if: contains(fromJSON(needs.plan.outputs.package_matrix).include.*.target, 'aarch64-unknown-linux-gnu') + uses: ./.github/workflows/ci-package.yml + with: + runner: ubuntu-24.04-arm + target: aarch64-unknown-linux-gnu + native_artifact_id: ${{ needs.native-linux-arm.outputs.artifact_id }} + producer_attempt: ${{ needs.native-linux-arm.outputs.producer_attempt }} + crypto_artifact_id: ${{ needs.crypto-web.outputs.artifact_id }} + web_artifact_id: ${{ needs.web.outputs.artifact_id }} + package_mode: ${{ needs.plan.outputs.package_mode }} + delivery: ${{ needs.plan.outputs.delivery == 'true' }} + + native-macos: + needs: plan + if: contains(fromJSON(needs.plan.outputs.package_matrix).include.*.target, 'aarch64-apple-darwin') + uses: ./.github/workflows/ci-native.yml + with: + runner: macos-15 + target: aarch64-apple-darwin + + package-macos: + needs: [plan, native-macos, crypto-web, web] + if: contains(fromJSON(needs.plan.outputs.package_matrix).include.*.target, 'aarch64-apple-darwin') + uses: ./.github/workflows/ci-package.yml + with: + runner: macos-15 + target: aarch64-apple-darwin + native_artifact_id: ${{ needs.native-macos.outputs.artifact_id }} + producer_attempt: ${{ needs.native-macos.outputs.producer_attempt }} + crypto_artifact_id: ${{ needs.crypto-web.outputs.artifact_id }} + web_artifact_id: ${{ needs.web.outputs.artifact_id }} + package_mode: ${{ needs.plan.outputs.package_mode }} + delivery: ${{ needs.plan.outputs.delivery == 'true' }} + secrets: + MACOS_CERTIFICATE_P12_BASE64: ${{ secrets.MACOS_CERTIFICATE_P12_BASE64 }} + MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }} + APPLE_API_KEY_P8_BASE64: ${{ secrets.APPLE_API_KEY_P8_BASE64 }} + APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }} + APPLE_API_ISSUER_ID: ${{ secrets.APPLE_API_ISSUER_ID }} delivery-small-prepare: if: github.event_name == 'workflow_dispatch' && inputs.delivery_small @@ -722,28 +516,48 @@ jobs: delivery-live: if: github.event_name == 'workflow_dispatch' && inputs.delivery_live && !inputs.delivery_small - needs: [plan, package, crypto-web, web, delivery-android] + needs: [plan, package-linux, crypto-web, web, delivery-android] runs-on: ubuntu-24.04 timeout-minutes: 360 steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: persist-credentials: false + - name: Require explicit producer artifact IDs + env: + ARTIFACT_IDS: ${{ needs.package-linux.outputs.artifact_id }} + run: '[[ "$ARTIFACT_IDS" =~ ^[1-9][0-9]*(,[1-9][0-9]*)*$ ]]' - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 with: - name: node-package-x86_64-unknown-linux-gnu-${{ github.sha }} + artifact-ids: ${{ needs.package-linux.outputs.artifact_id }} + merge-multiple: true path: .artifacts/vdp/live-package + - name: Require explicit producer artifact IDs + env: + ARTIFACT_IDS: ${{ needs.crypto-web.outputs.artifact_id }} + run: '[[ "$ARTIFACT_IDS" =~ ^[1-9][0-9]*(,[1-9][0-9]*)*$ ]]' - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 with: - name: crypto-web-${{ github.sha }} + artifact-ids: ${{ needs.crypto-web.outputs.artifact_id }} + merge-multiple: true path: apps/app/generated + - name: Require explicit producer artifact IDs + env: + ARTIFACT_IDS: ${{ needs.web.outputs.artifact_id }} + run: '[[ "$ARTIFACT_IDS" =~ ^[1-9][0-9]*(,[1-9][0-9]*)*$ ]]' - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 with: - name: web-${{ github.sha }} + artifact-ids: ${{ needs.web.outputs.artifact_id }} + merge-multiple: true path: apps/app/dist/client + - name: Require explicit producer artifact IDs + env: + ARTIFACT_IDS: ${{ needs.delivery-android.outputs.android_artifact_id }} + run: '[[ "$ARTIFACT_IDS" =~ ^[1-9][0-9]*(,[1-9][0-9]*)*$ ]]' - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 with: - name: vibeface-android-${{ github.sha }} + artifact-ids: ${{ needs.delivery-android.outputs.android_artifact_id }} + merge-multiple: true path: .artifacts/vdp/live-android - uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4 with: @@ -851,8 +665,10 @@ jobs: retention-days: 14 npm-package: - needs: [plan, package] + needs: [plan, package-linux, package-linux-arm, package-macos] if: needs.plan.outputs.npm == 'true' + outputs: + artifact_id: ${{ steps.upload.outputs.artifact-id }} runs-on: ubuntu-24.04 steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 @@ -861,18 +677,23 @@ jobs: - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: node-version: '24' + - name: Require explicit producer artifact IDs + env: + ARTIFACT_IDS: ${{ needs.package-linux.outputs.artifact_id }},${{ needs.package-linux-arm.outputs.artifact_id }},${{ needs.package-macos.outputs.artifact_id }} + run: '[[ "$ARTIFACT_IDS" =~ ^[1-9][0-9]*(,[1-9][0-9]*)*$ ]]' - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 with: - pattern: node-package-*-${{ github.sha }} + artifact-ids: ${{ needs.package-linux.outputs.artifact_id }},${{ needs.package-linux-arm.outputs.artifact_id }},${{ needs.package-macos.outputs.artifact_id }} path: .artifacts/npm-input merge-multiple: true - name: Package verified native releases for npm env: SOURCE_COMMIT: ${{ github.sha }} run: node scripts/package-npm.mjs --input .artifacts/npm-input --source-commit "$SOURCE_COMMIT" - - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + - id: upload + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 with: - name: npm-package-${{ github.sha }} + name: npm-package-${{ github.sha }}-${{ github.run_attempt }} path: .artifacts/npm/leaperone-vibeface-*.tgz* if-no-files-found: error retention-days: 14 @@ -894,9 +715,14 @@ jobs: - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 with: python-version: '3.12' + - name: Require explicit producer artifact IDs + env: + ARTIFACT_IDS: ${{ needs.npm-package.outputs.artifact_id }} + run: '[[ "$ARTIFACT_IDS" =~ ^[1-9][0-9]*(,[1-9][0-9]*)*$ ]]' - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 with: - name: npm-package-${{ github.sha }} + artifact-ids: ${{ needs.npm-package.outputs.artifact_id }} + merge-multiple: true path: .artifacts/npm - name: Install npm artifact without lifecycle scripts env: @@ -919,7 +745,7 @@ jobs: ci-gate: name: ci-gate if: ${{ always() && !(github.event_name == 'workflow_dispatch' && inputs.delivery_small) }} - needs: [plan, quick-check, crypto-web, web, www, rust-check, rust-fast, rust-slow, delivery, delivery-live, package, npm-package, npm-smoke] + needs: [plan, quick-check, crypto-web, web, www, rust-check, rust-fast, rust-slow, delivery, delivery-live, native-linux, native-linux-arm, native-macos, package-linux, package-linux-arm, package-macos, npm-package, npm-smoke] runs-on: ubuntu-24.04 steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 diff --git a/.github/workflows/mobile.yml b/.github/workflows/mobile.yml index 2948d1fdd..1c1e30df6 100644 --- a/.github/workflows/mobile.yml +++ b/.github/workflows/mobile.yml @@ -3,15 +3,23 @@ name: mobile # Extended platform build: run by hand or from the delivery proof workflow. on: workflow_dispatch: + inputs: + feedback: + description: 'Replace older ordinary mobile feedback on this branch' + type: boolean + default: false workflow_call: + outputs: + android_artifact_id: + value: ${{ jobs.android.outputs.artifact_id }} inputs: android_only: type: boolean default: false concurrency: - group: mobile-${{ github.ref }} - cancel-in-progress: true + group: mobile-${{ github.ref }}-${{ github.event_name == 'workflow_dispatch' && inputs.feedback && github.run_attempt == 1 && 'feedback' || github.run_id }} + cancel-in-progress: ${{ github.event_name == 'workflow_dispatch' && inputs.feedback && github.run_attempt == 1 }} permissions: contents: read @@ -21,6 +29,8 @@ env: jobs: android: + outputs: + artifact_id: ${{ steps.upload.outputs.artifact-id }} if: inputs.android_only || github.event_name == 'workflow_dispatch' runs-on: ubuntu-24.04 timeout-minutes: 60 @@ -61,13 +71,17 @@ jobs: env: SOURCE_COMMIT: ${{ github.sha }} run: python3 scripts/run-delivery-live.py --record-android-apk apps/mobile/android/app/build/outputs/apk/release --source-commit "$SOURCE_COMMIT" - - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + - id: upload + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 with: - name: vibeface-android-${{ github.sha }} + name: vibeface-android-${{ github.sha }}-${{ github.run_attempt }} path: .artifacts/mobile-android/ if-no-files-found: error - ios: + ios-build: + outputs: + artifact_id: ${{ steps.inputs.outputs.artifact-id }} + producer_attempt: ${{ github.run_attempt }} if: ${{ !inputs.android_only && github.event_name == 'workflow_dispatch' }} runs-on: macos-26 timeout-minutes: 60 @@ -80,6 +94,10 @@ jobs: targets: aarch64-apple-ios,aarch64-apple-ios-sim,wasm32-unknown-unknown - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2 with: + key: ios-host-target-v1 + workspaces: | + . -> target + . -> .artifacts/native/target cache-on-failure: true - uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4 with: @@ -105,7 +123,7 @@ jobs: zip -qry "$GITHUB_WORKSPACE/.artifacts/native/vibeface-ios-simulator.zip" Vibeface.app - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 with: - name: vibeface-ios-simulator-${{ github.sha }} + name: vibeface-ios-simulator-${{ github.sha }}-${{ github.run_attempt }} path: .artifacts/native/vibeface-ios-simulator.zip if-no-files-found: error - name: Build the same-source host Node and browser cryptography @@ -113,20 +131,62 @@ jobs: SOURCE_COMMIT: ${{ github.sha }} CARGO_TARGET_DIR: ${{ github.workspace }}/.artifacts/native/target run: | - umask 077 - mkdir -p .artifacts/native/private - chmod 700 .artifacts/native .artifacts/native/private - printf '%s\n' host-source > .artifacts/native/private/stage.txt test "$(git rev-parse HEAD)" = "$SOURCE_COMMIT" test -z "$(git status --porcelain --untracked-files=normal)" test "$(uname -m)" = arm64 - printf '%s\n' host-build > .artifacts/native/private/stage.txt cargo install wasm-bindgen-cli --version 0.2.129 --locked bash scripts/build-web-crypto.sh bash scripts/build-web.sh - CARGO_ENCODED_RUSTFLAGS="$(python3 scripts/release-rustflags.py)" cargo build --release -p vibeface -p vibeface-core --locked + bash scripts/package-node.sh --target aarch64-apple-darwin --native-output .artifacts/native/host.tar.gz + - name: Seal the complete public iOS acceptance input + run: python3 scripts/build-inputs.py seal ios --app .artifacts/native/vibeface-ios-simulator.zip --native .artifacts/native/host.tar.gz --output .artifacts/native/ios-input.tar.gz + - id: inputs + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 + with: + name: ios-input-${{ github.sha }}-${{ github.run_attempt }} + path: .artifacts/native/ios-input.tar.gz + if-no-files-found: error + retention-days: 7 + + ios-accept: + needs: ios-build + if: ${{ !inputs.android_only && github.event_name == 'workflow_dispatch' }} + runs-on: macos-26 + timeout-minutes: 30 + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 + with: + persist-credentials: false + - uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 + with: + version: 11.9.0 + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 + with: + node-version: '24' + cache: pnpm + cache-dependency-path: pnpm-lock.yaml + - run: pnpm install --frozen-lockfile --filter . + - name: Require explicit producer artifact IDs + env: + ARTIFACT_IDS: ${{ needs.ios-build.outputs.artifact_id }} + run: '[[ "$ARTIFACT_IDS" =~ ^[1-9][0-9]*(,[1-9][0-9]*)*$ ]]' + - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 + with: + artifact-ids: ${{ needs.ios-build.outputs.artifact_id }} + merge-multiple: true + path: .artifacts/native-download + - name: Restore and verify the successful producer input + env: + PRODUCER_ATTEMPT: ${{ needs.ios-build.outputs.producer_attempt }} + run: | + python3 scripts/build-inputs.py restore ios --input .artifacts/native-download/ios-input.tar.gz --output .artifacts/ios-input --producer-attempt "$PRODUCER_ATTEMPT" + app=.artifacts/native/ios-build/Build/Products/Release-iphonesimulator/Vibeface.app + codesign --verify --strict "$app" + otool -l "$app/Vibeface" | grep -q 'sectname __entitlements' .artifacts/native/target/release/vibeface --version .artifacts/native/target/release/vibeface-core --version + umask 077 + mkdir -p .artifacts/native/private - name: Create the dedicated iOS Provider simulator env: VIBEFACE_E2E_SOURCE_COMMIT: ${{ github.sha }} @@ -180,7 +240,7 @@ jobs: set -e echo "Native Provider e2e exit code: $result" exit "$result" - - name: Remove only this task simulator and private acceptance state + - name: Clean up this task and require final UI acceptance if: always() env: SOURCE_COMMIT: ${{ github.sha }} @@ -390,7 +450,7 @@ jobs: - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 if: ${{ always() && !cancelled() }} with: - name: native-provider-ios-${{ github.sha }} + name: native-provider-ios-${{ github.sha }}-${{ github.run_attempt }} path: | .artifacts/native/public/provider.json .artifacts/native/public/provider-probe.json @@ -401,3 +461,16 @@ jobs: .artifacts/native/public/terminology-device-kinds.png if-no-files-found: error retention-days: 7 + + mobile-gate: + if: always() + needs: [android, ios-build, ios-accept] + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 + with: + persist-credentials: false + - name: Require all selected mobile jobs + env: + MOBILE_NEEDS: ${{ toJSON(needs) }} + run: python3 scripts/ci.py mobile-gate --needs-env MOBILE_NEEDS ${{ inputs.android_only && '--android-only' || '' }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5e62f488a..f9d83112f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -48,8 +48,16 @@ jobs: - uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 with: {version: 11.9.0} - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 - with: {node-version: '24'} + with: + node-version: '24' + cache: pnpm + cache-dependency-path: pnpm-lock.yaml + - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 + if: needs.identity.outputs.app == 'app' + with: + key: release-static-app - run: pnpm install --frozen-lockfile + if: needs.identity.outputs.app == 'www' - name: Install App browser build tools if: needs.identity.outputs.app == 'app' run: | diff --git a/packages/docs/ci.md b/packages/docs/ci.md index eda5a92d4..c50fba9cc 100644 --- a/packages/docs/ci.md +++ b/packages/docs/ci.md @@ -40,7 +40,7 @@ description: 查看 Vibeface CI 如何按改动范围选择检查。 静态快检保留 Rust fmt、工作流与 shell 检查、JavaScript 语法、选择器和安装器自检。涉及 Rust 时校验 Atlas 迁移文件,不打开数据库。快速 Rust 测试保留权限、个人网络隔离、数据持久化、写操作去重与未知结果对账等已有回归,只跳过 `SLOW_TESTS` 明确列出的重型用例,目前是 10 万事件追加测试和超出待补依赖上限的 4 万事件追平测试。 -`www` 使用 Node.js 24 和冻结的 pnpm 依赖,依次运行 `typecheck`、`build`、`check:static`,上传 `apps/www/dist/client` 为 `www-` 制品。门户与独立 App 分别构建;根 `packages/docs/` 是门户文档正文的唯一来源,修改文档也会触发 `www`。 +`www` 使用 Node.js 24 和冻结的 pnpm 依赖,依次运行 `typecheck`、`build`、`check:static`,上传 `apps/www/dist/client` 为 `www--` 制品。门户与独立 App 分别构建;根 `packages/docs/` 是门户文档正文的唯一来源,修改文档也会触发 `www`。 改 `apps/core/migrations/` 或 `apps/core/src/delivery/schema.sql` 的 schema 必须同时提高共享控制 crate `crates/control/src/lib.rs` 的 `DATA_EPOCH`,并更新 `apps/core/src/config.rs` 中相邻的 `DATA_EPOCH_SCHEMA_SHA256`;否则 Node 快速测试 `schema_changes_bump_the_data_epoch` 失败。存储 epoch 不变时旧数据库能打开,运行中才因缺列出错,自更新也会误判可原地升级。`install.sh` 中写死的 epoch 一并修改,由 `ci.py --self-test` 核对。 @@ -52,6 +52,10 @@ Linux 制品核对 checksum、源码提交、版本、target、WASM 和存储 ep Linux 制品还使用 [e2e](e2e.md) 启动隔离 Node,在 Chromium 中验证建网页面以及建网、下载恢复文件、跳过 AI 设置、创建 Bot 和刷新后保留的流程。它不调用真实模型。CI 上传浏览器测试报告,排除下载的恢复文件和 Node 数据。 +原生编译由每个平台的 `native-*` 任务执行,与 crypto/Web 并行。对应 `package-*` 只等待本平台原生输入和共享 Web,不等待其他平台。两个窄 reusable workflow 共用构建与组包配方;Rust 检查不下载 Web。最终 gate 逐项要求计划选中的 native、package 及原有检查成功。 + +原生输入使用带来源清单的 tar 保存执行位,记录干净源码 commit/tree、target、workflow、run、producer job 与 attempt,以及完整文件集的大小、模式和 SHA-256。消费方从成功上游接收不可变 artifact ID,按同 run、同源码核对输入;失败重跑允许使用较早的成功 producer attempt。缺失输出、来源不符、额外文件或摘要不同均失败,不取分支 latest,也不静默重新编译。 + ## 可验证交付的核心检查 `delivery` 任务使用 Rust 1.98.1 构建独立的 `crates/delivery/proof` host。guest 编译器固定为 RISC Zero Rust `r0.1.97.0`,由 `scripts/install-delivery-toolchain.py` 校验官方归档 SHA-256 后安装到 `.artifacts/vdp/risc0/`。它不改全局 Rust 配置,Node 默认构建不依赖重型 proof host。 @@ -158,15 +162,29 @@ controller 在真实 key1 后、C0 快照前开放配对,成员随原节点数 | Rust 快、慢测试及 Clippy | 整个工作区;慢组为精确名称的 `SLOW_TESTS` | | 最低 Rust 版本 | 安装 Cargo 声明的 MSRV,检查整个工作区 | | 原生 release 制品 | Linux x64、Linux ARM64、macOS ARM64,分别校验身份并启动网页进程 | -| 单 Node 调度与事件日志验收 | Linux x64 一次,使用 `--phase1` | +| 调度与事件日志验收 | Linux x64 一次,使用 `--phase1` | | 多 Node 同步、入口与投递验收 | Linux x64 一次,不带模式参数,四台 Node 经 iroh 和成员 relay 互连 | -| 聊天 Agent 模拟协议验收 | macOS ARM64 一次,使用 `--chat-agent` | +| 聊天 Agent 模拟协议验收 | macOS ARM64 一次,两个隔离 Node,使用 `--chat-agent` | | 跨设备协作、换负责人与附件验收 | Linux x64 一次,使用 `--phase4` | | 公共入口与 relay 令牌验收 | Linux x64 一次,使用 `--public-entry` | | 仅发现、普通 relay 回退与无网页验收 | Linux x64 一次,使用 `--discovery` | | 写入保护、状态与诊断包验收 | macOS ARM64 一次,使用 `--phase5` | | Nightly npm 包 | 组装三个原生包,三个平台分别安装、检查版本并执行 `--web-only` 冒烟 | +macOS 的 `--chat-agent` 与 `--phase5` 在同一组包任务内并行。两者使用同一签名包的独立副本、数据目录与互不重叠的端口区间,分别保存退出码;任一失败则组包失败。保留原来的去重、真实定时、deadline 和重启观察,聊天内部仍顺序执行。 + +普通手动运行默认保留每次验收。开发期间可显式传入 `feedback=true`,让同分支的新反馈替换旧反馈,检查范围不减少。付费 live/small、带 resume 意图及显式重跑不进入该取消组,main push 的累计覆盖规则仍生效。 + +```sh +gh workflow run ci.yml --ref <分支> -f feedback=true +# 最终验收使用默认输入,保留此 run。 +gh workflow run ci.yml --ref <分支> +``` + +`mobile.yml` 的普通手动运行要求 Android、`ios-build` 和 `ios-accept` 全部成功。Android-only 调用只要求 APK 构建。iOS 构建上传完整公共输入,包含 App ZIP、host CLI/Core、Web/WASM 与各 receipt;验收任务恢复同一输入后创建新模拟器和私有 fixture,继续真实秘密输入、配对、Provider 操作与取消验收。UI 失败后使用 `gh run rerun --failed` 只重跑失败任务;成功 producer 的 artifact ID 和 attempt 必须保留,缺失即失败。`mobile` 同样提供默认关闭的 `feedback` 输入。 + +Rust 缓存同时覆盖 iOS FFI 的 `target` 和 host 的 `.artifacts/native/target`,仍由 Cargo 正常检查依赖失效。未缓存 Pods、DerivedData 或 driver 状态。锁定的 RN/Hermes 下载器在远端校验值缺失时允许跳过校验,因此未增加其共享下载缓存。 + 快、慢测试组均使用 `opt-level=1`,保留调试断言和整数溢出检查,调试信息使用 `line-tables-only` 保留回溯文件和行号,共享独立的 `test-opt1` Rust 缓存;Clippy 使用单独的 `check` 缓存。两组运行前校验每个慢测试名恰好匹配一个已有测试。慢组用 `--include-ignored` 运行列出的用例,其他 `ignored` 用例仍默认忽略。两组测试命令用 `/usr/bin/time -v` 记录 CPU 与 maxRSS;maxRSS 不能当作并发进程树的总峰值。 CI 不使用真实 AI Provider 或模型密钥。各模式都使用受控 SDK 和 App Server 夹具,`--phase5` 不启动 App Server。模拟协议通过不能证明真实模型理解需求或正确选择工具。 diff --git a/packages/docs/e2e.md b/packages/docs/e2e.md index bfc4ac583..b1eef59a1 100644 --- a/packages/docs/e2e.md +++ b/packages/docs/e2e.md @@ -138,6 +138,12 @@ python3 scripts/verify-node.py --delivery-ui-selfcheck \ --binary /usr/bin/true --artifacts .artifacts/paid-ui-selfcheck ``` +## 重跑 iOS Provider 验收 + +`mobile.yml` 将构建和验收分成 `ios-build`、`ios-accept`。前者只上传白名单中的 App ZIP、host CLI/Core、Web/WASM 与来源清单,邀请、Node 数据和 driver 状态在后者创建。恢复后核对摘要、执行位、签名、entitlements 和实际安装的 bundle 字节,再执行原来的真实配对与 Provider 测试。构建成功不代表 UI 通过。 + +UI 失败时可运行 `gh run rerun --failed`,复用该 run 已成功构建的不可变输入,不重新构建 App。清理步骤同时判定最终 UI 结果,清理成功不能掩盖测试失败。每次验收使用新的专属模拟器,并上传带 attempt 的公开诊断。 + ## 验证原生接收和本地文件 原生验收使用已有 e2e mobile 引擎,必须指定当前任务构建的 `.app`、Node、匹配 WASM,以及专用模拟器的 UUID。该入口会重新安装本任务应用并清除该专用模拟器的钥匙串。不要指定其他任务正在使用的模拟器。 diff --git a/packages/docs/releasing.md b/packages/docs/releasing.md index a677c139f..c70bea983 100644 --- a/packages/docs/releasing.md +++ b/packages/docs/releasing.md @@ -27,7 +27,7 @@ description: 了解 Vibeface 的 CI、制品和 Nightly 发布流程。 ## 可下载的包 -每个平台的 Actions artifact 包含 `vibeface--.tar.gz` 和同名 `.sha256`。`main` 的核心检查按需生成 Linux x64 包;扩展检查在三种架构的原生 runner 构建,解包后分别启动网页进程。多 Node、单 Node 调度、跨设备协作和公共入口的多进程验收只在 Linux x64 运行一次,聊天 Agent 与写入保护验收只在 macOS ARM64 运行一次,都不调用模型。 +每个平台的 Actions artifact 包含 `vibeface--.tar.gz` 和同名 `.sha256`。`main` 的核心检查按需生成 Linux x64 包;扩展检查在三种架构的原生 runner 构建,解包后分别启动网页进程。多 Node、调度、跨设备协作和公共入口的多进程验收只在 Linux x64 运行一次,聊天 Agent 与写入保护验收只在 macOS ARM64 运行一次,都不调用模型。macOS 两项独立进程验收并行执行,保留各自状态和完整观察。 | 平台 | Rust target | 构建和验收环境 | | --- | --- | --- | @@ -57,12 +57,14 @@ cd vibeface-- 包内有 Rust 程序、浏览器密码学 JS/WASM、文档、用户级服务安装脚本和 `BUILD-INFO.json`,不含身份、配置、数据库、Provider 程序或模型凭证。打包要求干净 Git 提交,记录版本、target、源码提交和各组件身份;存在未提交更改时拒绝生成发行包。 -发布构建脚本把本机源码、用户目录和工具缓存路径替换成通用路径;压缩包清除构建账号和扩展属性。打包拒绝过期生成物、额外文件和跳过原生构建。 +发布构建脚本把本机源码、用户目录和工具缓存路径替换成通用路径;压缩包清除构建账号和扩展属性。打包拒绝过期生成物和额外文件。默认重新编译原生程序;CI 可显式消费通过同 run、同源码、target 和完整摘要校验的原生输入,不接受任意二进制或无校验的跳过构建。 自定义 Rust 编译参数通过 `RUSTFLAGS` 或 `CARGO_ENCODED_RUSTFLAGS` 传入,后者优先。发布脚本保留这些参数并追加路径映射;按 Cargo 的优先级,此时不使用配置文件中的 `rustflags`。 运行任务前须另装并登录相应 Provider。Cursor 管理路径需另装 Cursor SDK Bridge 并配置凭证。初始化、配对、服务安装和公网 TLS 见 [Node 使用说明](node.md)。 +App 的 static 发布使用 pnpm 与 Rust 工具缓存。`build-web.sh` 自身执行冻结的按需依赖安装,因此发布入口不再提前安装整个 workspace;www 仍独立安装。工具版本和生成物来源校验照常执行。 + ## CI 验证范围 `crypto-web` 在固定版本的 wasm-bindgen 工具链生成一份浏览器密码学资源,运行 native Rust 与 WASM 的实际 Noise 互通和篡改、重放、身份错配负例。`web` 下载这份资源及其真实 TypeScript 声明,以锁定的 pnpm 依赖生成 TanStack Start 静态 SPA。制品任务下载同一份密码学资源和 SPA;Rust 检查不依赖这些生成产物。Core 从 `VIBEFACE_APP_DIR` 或发行包同级 `web/` 读取完整静态目录,不在编译时内嵌网页或 WASM。Core 可独立构建和运行,未提供 App 时网页返回 404;App 构建和完整发行包缺少资源时失败。 @@ -76,7 +78,6 @@ cd vibeface-- ```sh bash scripts/build-web-crypto.sh bash scripts/build-web.sh -cargo build --release -p vibeface -p vibeface-core --locked bash scripts/package-node.sh ``` @@ -164,7 +165,7 @@ npm 包名为 `@leaperone/vibeface`,Nightly 使用同名不可变版本和 `ni `scripts/package-npm.mjs` 接收三个平台的完整 `.tar.gz` 与同名 SHA256,要求三个平台的 CLI 版本、CLI 源码、锁定组件身份及包协议一致,平台字段分别匹配各自 target。它拒绝危险路径、链接、特殊文件、校验错配和缺失资源,把完整包放入 `vendor/`,再生成一个含全部平台的 `.tgz`。只有一个 npm 发布身份和一次发布操作,代价是下载包含其他平台的程序。没有 postinstall、运行期下载或新增 npm 依赖。 -定时、手动扩展 CI 和 CLI Nightly 发布生成 `npm-package-` artifact,包含 `.tgz` 和记录源码 SHA、SHA256、npm integrity 的 JSON。CI 在三个原生平台上以 `--ignore-scripts` 全局安装到隔离 prefix,然后验证版本,并以 `--web-only` 验证启动和随包网页,不重复完整多节点验收。Stable 和 rc 延续现有 GitHub 发布流程,不生成 npm 包。 +定时和手动扩展 CI 生成 `npm-package--` artifact,CLI Nightly 发布也生成 npm 分发制品,包含 `.tgz` 和记录源码 SHA、SHA256、npm integrity 的 JSON。CI 在三个原生平台上以 `--ignore-scripts` 全局安装到隔离 prefix,然后验证版本,并以 `--web-only` 验证启动和随包网页,不重复完整多节点验收。Stable 和 rc 延续现有 GitHub 发布流程,不生成 npm 包。 本地检查与打包命令如下。输入目录只能包含对应版本的三个包与三个 checksum,默认输出 `.artifacts/npm`,已有同名制品会被保留并报错: diff --git a/scripts/build-inputs.py b/scripts/build-inputs.py index cb3b8bb45..46fb58518 100644 --- a/scripts/build-inputs.py +++ b/scripts/build-inputs.py @@ -1,13 +1,18 @@ #!/usr/bin/env python3 -"""Bind generated Web/WASM files to their source inputs and exact output set.""" +"""Verify source-bound Web/WASM, native and iOS build inputs.""" import argparse import base64 import fnmatch import hashlib import json +import os +import re import shutil +import stat import subprocess +import tarfile import tempfile +import zipfile from pathlib import Path @@ -183,6 +188,192 @@ def check(repo, component): return receipt +def origin(repo): + commit = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=repo, text=True).strip() + tree = subprocess.check_output(["git", "rev-parse", "HEAD^{tree}"], cwd=repo, text=True).strip() + if subprocess.check_output(["git", "status", "--porcelain", "--untracked-files=normal"], cwd=repo): + raise ValueError("reusable binaries require a clean source checkout") + result = dict(source_commit=commit, source_tree=tree, repository="local", workflow="local", run_id=0, job="local", attempt=0) + if os.environ.get("GITHUB_ACTIONS") == "true": + repository = os.environ["GITHUB_REPOSITORY"] + workflow = os.environ["GITHUB_WORKFLOW_REF"].split("@", 1)[0] + if os.environ["GITHUB_SHA"] != commit or not workflow.startswith(repository + "/.github/workflows/"): + raise ValueError("build source differs from the workflow identity") + result.update(repository=repository, workflow=workflow[len(repository) + 1:], + run_id=int(os.environ["GITHUB_RUN_ID"]), job=os.environ["GITHUB_JOB"], + attempt=int(os.environ["GITHUB_RUN_ATTEMPT"])) + if result["run_id"] <= 0 or result["attempt"] <= 0: + raise ValueError("invalid Actions producer identity") + return result + + +def verify_origin(repo, recorded, component, producer_attempt): + expected = origin(repo) + if expected["repository"] != "local": + workflow = expected["workflow"] + if workflow not in {".github/workflows/ci.yml", ".github/workflows/mobile.yml"}: + raise ValueError("unsupported input workflow") + expected["job"] = "ios-build" if workflow.endswith("/mobile.yml") else "build" + if producer_attempt is None or not 1 <= producer_attempt <= expected["attempt"]: + raise ValueError("missing or invalid producer attempt") + expected["attempt"] = producer_attempt + if component == "ios" and workflow != ".github/workflows/mobile.yml": + raise ValueError("iOS inputs require the mobile workflow") + if recorded != expected: + raise ValueError("input source, workflow, run, job or producer attempt differs") + + +def input_files(directory): + result = {} + for path in sorted(directory.rglob("*")): + metadata = path.lstat() + if stat.S_ISDIR(metadata.st_mode): + continue + if not stat.S_ISREG(metadata.st_mode): + raise ValueError("build inputs must be regular files") + name = path.relative_to(directory).as_posix() + if name != "manifest.json": + result[name] = dict(sha256=digest(path.read_bytes()), size=metadata.st_size, mode=stat.S_IMODE(metadata.st_mode)) + return result + + +def write_input(directory, archive, component, target, source): + manifest = dict(version=1, component=component, target=target, origin=source, files=input_files(directory)) + (directory / "manifest.json").write_text(json.dumps(manifest, sort_keys=True) + "\n") + archive.parent.mkdir(parents=True, exist_ok=True) + with tarfile.open(archive, "w:gz", format=tarfile.USTAR_FORMAT) as output: + for path in sorted(directory.rglob("*")): + if path.is_file(): + info = output.gettarinfo(str(path), arcname=path.relative_to(directory).as_posix()) + info.uid = info.gid = info.mtime = 0 + info.uname = info.gname = "" + with path.open("rb") as data: + output.addfile(info, data) + + +def check_input(repo, directory, component, target, producer_attempt): + manifest_path = directory / "manifest.json" + if manifest_path.is_symlink() or not manifest_path.is_file(): + raise ValueError("missing regular input manifest") + manifest = json.loads(manifest_path.read_text()) + if (set(manifest) != {"version", "component", "target", "origin", "files"} + or manifest["version"] != 1 or manifest["component"] != component or manifest["target"] != target): + raise ValueError("input kind or target differs") + verify_origin(repo, manifest["origin"], component, producer_attempt) + actual = input_files(directory) + if actual != manifest["files"]: + raise ValueError("input files, modes or digests differ") + native = {"vibeface", "vibeface-core"} + if component == "native": + if set(actual) != native: + raise ValueError("native input requires exactly CLI and Core") + else: + required = {"app.zip", "host/vibeface", "host/vibeface-core", "host/manifest.json", "crypto/" + RECEIPT, "web/" + RECEIPT} + if not required <= set(actual) or any(name not in required and not name.startswith(("crypto/", "web/")) for name in actual): + raise ValueError("iOS input contains missing or private files") + check_input(repo, directory / "host", "native", "aarch64-apple-darwin", producer_attempt) + for component_name in OUTPUTS: + name = "crypto" if component_name == "crypto" else "web" + receipt = json.loads((directory / name / RECEIPT).read_text()) + if receipt.get("outputs") != files(directory / name): + raise ValueError("iOS generated files differ from their receipt") + for name in ("vibeface_secure.js", "vibeface_secure_bg.wasm"): + if (directory / "crypto" / name).read_bytes() != (directory / "web" / name).read_bytes(): + raise ValueError("iOS Web and crypto bytes differ") + native = {"host/" + name for name in native} + if any(actual[name]["size"] <= 0 or actual[name]["mode"] != 0o755 for name in native): + raise ValueError("native binaries must be nonempty and executable") + return manifest + + +def restore_input(repo, archive, output, component, target, producer_attempt): + output.parent.mkdir(parents=True, exist_ok=True) + if output.exists() or output.is_symlink(): + raise ValueError("input destination must be new") + with tempfile.TemporaryDirectory(prefix=".restore-", dir=output.parent) as temporary: + directory = Path(temporary) + with tarfile.open(archive, "r:gz") as packed: + members = packed.getmembers() + names = [member.name for member in members] + if len(members) > 16384 or sum(member.size for member in members) > 2 * 1024 ** 3 or len(names) != len(set(names)): + raise ValueError("input archive exceeds limits or has duplicate members") + for member in members: + parts = member.name.split("/") + if (not member.isfile() or any(part in {"", ".", ".."} for part in parts) + or "\\" in member.name or ":" in member.name or member.mode not in {0o644, 0o755}): + raise ValueError("unsafe input archive member") + for member in members: + path = directory / member.name + path.parent.mkdir(parents=True, exist_ok=True) + with packed.extractfile(member) as source, path.open("xb") as destination: + shutil.copyfileobj(source, destination) + path.chmod(member.mode) + check_input(repo, directory, component, target, producer_attempt) + directory.rename(output) + + +def seal_native(repo, source, target, output): + source_identity = origin(repo) + with tempfile.TemporaryDirectory(prefix=".native-", dir=output.parent) as temporary: + directory = Path(temporary) + for name in ("vibeface", "vibeface-core"): + path = source / name + if path.is_symlink() or not path.is_file() or not os.access(path, os.X_OK): + raise ValueError("native binary is missing or not executable") + shutil.copyfile(path, directory / name) + (directory / name).chmod(0o755) + write_input(directory, output, "native", target, source_identity) + + +def pack_ios(repo, app, native, output): + check_app_zip(app) + check(repo, "crypto") + check(repo, "web") + with tempfile.TemporaryDirectory(prefix=".ios-", dir=output.parent) as temporary: + directory = Path(temporary) + restore_input(repo, native, directory / "host", "native", "aarch64-apple-darwin", int(os.environ.get("GITHUB_RUN_ATTEMPT", "0"))) + shutil.copyfile(app, directory / "app.zip") + (directory / "app.zip").chmod(0o644) + for component, path in OUTPUTS.items(): + shutil.copytree(repo / path, directory / component) + for copied in (directory / component).rglob("*"): + copied.chmod(0o755 if copied.is_dir() else 0o644) + write_input(directory, output, "ios", "aarch64-apple-ios-sim", origin(repo)) + + +def check_app_zip(path): + if path.is_symlink() or not path.is_file(): + raise ValueError("simulator app must be a regular ZIP") + with zipfile.ZipFile(path) as archive: + members = archive.infolist() + names = [member.filename.rstrip("/") for member in members] + if len(names) != len(set(names)) or len(names) > 16384 or sum(member.file_size for member in members) > 1024 ** 3: + raise ValueError("invalid app ZIP size or duplicate members") + for member, name in zip(members, names): + parts = name.split("/") + mode = member.external_attr >> 16 + if (parts[0] != "Vibeface.app" or any(part in {"", ".", ".."} for part in parts) + or "\\" in name or ":" in name or stat.S_IFMT(mode) not in {0, stat.S_IFDIR, stat.S_IFREG}): + raise ValueError("unsafe simulator app ZIP member") + + +def install_ios(repo, source, producer_attempt): + check_input(repo, source, "ios", "aarch64-apple-ios-sim", producer_attempt) + app_dir = repo / ".artifacts/native/ios-build/Build/Products/Release-iphonesimulator" + app_dir.mkdir(parents=True, exist_ok=True) + check_app_zip(source / "app.zip") + subprocess.run(["unzip", "-q", str(source / "app.zip"), "-d", str(app_dir)], check=True) + for component, path in OUTPUTS.items(): + destination = repo / path + destination.parent.mkdir(parents=True, exist_ok=True) + shutil.copytree(source / component, destination) + check(repo, component) + host = repo / ".artifacts/native/target/release" + host.mkdir(parents=True, exist_ok=True) + for name in ("vibeface", "vibeface-core"): + shutil.copy2(source / "host" / name, host / name) + + def self_test(): scratch = ROOT / ".artifacts/build-inputs-test" scratch.mkdir(parents=True, exist_ok=True) @@ -263,20 +454,140 @@ def self_test(): pass else: raise AssertionError("mid-build source change was accepted") + input_self_test(scratch) print("Build input self-test passed") +def input_self_test(scratch): + from unittest.mock import patch + with tempfile.TemporaryDirectory(prefix="inputs-", dir=scratch) as temporary: + repo = Path(temporary) + subprocess.run(["git", "init", "-q", str(repo)], check=True) + (repo / ".gitignore").write_text(".artifacts/\napps/app/generated/\napps/app/dist/\n") + subprocess.run(["git", "add", "."], cwd=repo, check=True) + subprocess.run(["git", "-c", "user.name=Fixture", "-c", "user.email=fixture@example.invalid", "commit", "-qm", "fixture"], cwd=repo, check=True) + build = repo / ".artifacts/build" + build.mkdir(parents=True) + for name in ("vibeface", "vibeface-core"): + (build / name).write_bytes(b"fixture binary") + (build / name).chmod(0o755) + env = dict(GITHUB_ACTIONS="true", GITHUB_REPOSITORY="fixture/repo", GITHUB_WORKFLOW_REF="fixture/repo/.github/workflows/ci.yml@refs/heads/fixture", + GITHUB_RUN_ID="42", GITHUB_RUN_ATTEMPT="1", GITHUB_JOB="build", + GITHUB_SHA=subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=repo, text=True).strip()) + archive = build.parent / "native.tar.gz" + target = "aarch64-apple-darwin" + with patch.dict(os.environ, env): + seal_native(repo, build, target, archive) + os.environ["GITHUB_JOB"] = "assemble" + os.environ["GITHUB_RUN_ATTEMPT"] = "2" + restored = build.parent / "restored" + restore_input(repo, archive, restored, "native", target, 1) + assert (restored / "vibeface").read_bytes() == b"fixture binary" + assert (restored / "vibeface").stat().st_mode & 0o777 == 0o755 + + def rejected(action): + try: + action() + except (ValueError, OSError): + return + raise AssertionError("unsafe or mismatched build input was accepted") + + for attempt in (None, 0, 2, 3): + rejected(lambda: check_input(repo, restored, "native", target, attempt)) + rejected(lambda: check_input(repo, restored, "native", "x86_64-unknown-linux-gnu", 1)) + manifest = restored / "manifest.json" + original = manifest.read_text() + for key, value in (("source_commit", "0" * 40), ("source_tree", "0" * 40), ("workflow", ".github/workflows/release.yml"), ("repository", "other/repo"), ("run_id", 43), ("job", "wrong")): + data = json.loads(original) + data["origin"][key] = value + manifest.write_text(json.dumps(data)) + rejected(lambda: check_input(repo, restored, "native", target, 1)) + manifest.write_text(original) + binary = restored / "vibeface" + for mutation in (lambda: binary.write_bytes(b"changed"), lambda: binary.chmod(0o644), lambda: binary.unlink(), lambda: (restored / "private").write_text("private")): + mutation() + rejected(lambda: check_input(repo, restored, "native", target, 1)) + binary.write_bytes(b"fixture binary") + binary.chmod(0o755) + (restored / "private").unlink(missing_ok=True) + import io + for name, kind in (("../escape", tarfile.REGTYPE), ("/absolute", tarfile.REGTYPE), ("link", tarfile.SYMTYPE), ("hard", tarfile.LNKTYPE), ("device", tarfile.CHRTYPE), ("duplicate", tarfile.REGTYPE)): + bad = build.parent / "bad.tar.gz" + with tarfile.open(bad, "w:gz") as packed: + member = tarfile.TarInfo(name) + member.type, member.mode, member.size = kind, 0o644, 1 if kind == tarfile.REGTYPE else 0 + packed.addfile(member, io.BytesIO(b"x") if member.size else None) + if name == "duplicate": + packed.addfile(member, io.BytesIO(b"x")) + rejected(lambda: restore_input(repo, bad, build.parent / "bad-output", "native", target, 1)) + assert not (build.parent / "bad-output").exists() + os.environ.update(GITHUB_WORKFLOW_REF="fixture/repo/.github/workflows/mobile.yml@refs/heads/fixture", GITHUB_JOB="ios-build", GITHUB_RUN_ATTEMPT="1") + seal_native(repo, build, target, archive) + for component in OUTPUTS: + prepare(repo, component) + directory = repo / OUTPUTS[component] + for name in ("vibeface_secure.js", "vibeface_secure_bg.wasm"): + (directory / name).write_bytes(b"public fixture") + if component == "web": + (directory / "_shell.html").write_text("") + finish(repo, component) + app = build.parent / "app.zip" + with zipfile.ZipFile(app, "w") as packed: + packed.writestr("Vibeface.app/Vibeface", b"public app fixture") + ios = build.parent / "ios.tar.gz" + pack_ios(repo, app, archive, ios) + os.environ.update(GITHUB_JOB="ios-accept", GITHUB_RUN_ATTEMPT="2") + restored_ios = build.parent / "ios-restored" + restore_input(repo, ios, restored_ios, "ios", "aarch64-apple-ios-sim", 1) + for path in OUTPUTS.values(): + shutil.rmtree(repo / path) + install_ios(repo, restored_ios, 1) + assert (repo / ".artifacts/native/target/release/vibeface").stat().st_mode & 0o777 == 0o755 + assert (repo / ".artifacts/native/ios-build/Build/Products/Release-iphonesimulator/Vibeface.app/Vibeface").read_bytes() == b"public app fixture" + (restored_ios / "private").mkdir() + (restored_ios / "private/invitation.txt").write_text("must not enter inputs") + rejected(lambda: check_input(repo, restored_ios, "ios", "aarch64-apple-ios-sim", 1)) + + def main(): parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("action", choices=("prepare", "finish", "check", "self-test")) - parser.add_argument("component", choices=tuple(OUTPUTS), nargs="?") + parser.add_argument("action", choices=("prepare", "finish", "check", "self-test", "seal", "restore")) + parser.add_argument("component", choices=(*OUTPUTS, "native", "ios"), nargs="?") parser.add_argument("--cargo", action="store_true") + parser.add_argument("--input", type=Path) + parser.add_argument("--source", type=Path) + parser.add_argument("--app", type=Path) + parser.add_argument("--native", type=Path) + parser.add_argument("--output", type=Path) + parser.add_argument("--target") + parser.add_argument("--producer-attempt", type=int) args = parser.parse_args() if args.action == "self-test": self_test() return if not args.component: parser.error("component is required") + if args.component in {"native", "ios"}: + target = args.target if args.component == "native" else "aarch64-apple-ios-sim" + if not target or not re.fullmatch(r"[a-z0-9_-]+", target): + parser.error("a valid target is required") + if args.action == "check" and args.input: + check_input(ROOT, args.input, args.component, target, args.producer_attempt) + elif args.action == "restore" and args.input and args.output: + restore_input(ROOT, args.input, args.output, args.component, target, args.producer_attempt) + if args.component == "ios": + install_ios(ROOT, args.output, args.producer_attempt) + elif args.action == "seal" and args.output: + args.output.parent.mkdir(parents=True, exist_ok=True) + if args.component == "native" and args.source: + seal_native(ROOT, args.source, target, args.output) + elif args.component == "ios" and args.app and args.native: + pack_ios(ROOT, args.app, args.native, args.output) + else: + parser.error("seal needs native source or app and native archives") + else: + parser.error("input action needs its source and destination") + return if args.action == "check": receipt = check(ROOT, args.component) if args.cargo: diff --git a/scripts/ci.py b/scripts/ci.py index 2ac5af9ec..778e252d7 100644 --- a/scripts/ci.py +++ b/scripts/ci.py @@ -9,6 +9,8 @@ import os from pathlib import Path import re +import shutil +import signal import subprocess import tempfile import urllib.request @@ -56,11 +58,12 @@ "runtime::peers::tests::a_round_left_behind_pulls_again_without_waiting_for_hello", ) PLATFORMS = ( - {"runner": "ubuntu-24.04", "target": "x86_64-unknown-linux-gnu"}, - {"runner": "ubuntu-24.04-arm", "target": "aarch64-unknown-linux-gnu"}, - {"runner": "macos-15", "target": "aarch64-apple-darwin"}, + {"runner": "ubuntu-24.04", "target": "x86_64-unknown-linux-gnu", "key": "linux"}, + {"runner": "ubuntu-24.04-arm", "target": "aarch64-unknown-linux-gnu", "key": "linux-arm"}, + {"runner": "macos-15", "target": "aarch64-apple-darwin", "key": "macos"}, ) -JOBS = ("quick-check", "crypto-web", "web", "rust-check", "rust-fast", "rust-slow", "delivery", "package", "npm-package", "npm-smoke", "www") +PLATFORM_JOBS = tuple(f"{kind}-{platform['key']}" for kind in ("native", "package") for platform in PLATFORMS) +JOBS = ("quick-check", "crypto-web", "web", "rust-check", "rust-fast", "rust-slow", "delivery", *PLATFORM_JOBS, "npm-package", "npm-smoke", "www") LOCAL_PROCESS_RULES = ( ("memory-sync", ("apps/core/src/store/bot_settings.rs", "apps/core/src/store/reduce.rs", "apps/core/src/store/log.rs", "apps/core/src/store/sync.rs", "apps/core/src/agent_context.rs", "apps/core/src/identity*", "crates/secure/*")), ("auto-route", ("apps/core/src/identity*", "apps/core/src/crypto.rs", "apps/core/src/local_access.rs", "apps/core/src/net*", "crates/secure/*", "crates/control/*")), @@ -141,7 +144,8 @@ def scope_plan(scopes, event, ref_type, channel): } required = {"quick-check"} if web: - required.update(("crypto-web", "web", "package")) + required.update(("crypto-web", "web")) + required.update(f"{kind}-{platform['key']}" for platform in platforms for kind in ("native", "package")) if packages: required.update(("rust-check", "rust-fast")) if slow: @@ -274,7 +278,7 @@ def write_plan(plan, output=None): "rust": str(bool(plan["rust_packages"])).lower(), "slow": str("slow" in plan["test_tiers"]).lower(), "delivery": str(plan["delivery"]).lower(), - "package": str("package" in plan["required_jobs"]).lower(), + "package": str(plan["web"]).lower(), "package_matrix": json.dumps(plan["package_matrix"], separators=(",", ":")), "package_mode": plan["package_mode"], "npm": str(plan["npm"]).lower(), @@ -365,6 +369,14 @@ def gate(needs, plan=None, delivery_live=False): print(f"CI gate passed: {', '.join(required)}") +def mobile_gate(needs, android_only): + required = ["android"] if android_only else ["android", "ios-build", "ios-accept"] + if (any(needs.get(job, {}).get("result") != "success" for job in required) + or any(job.get("result") in {"failure", "cancelled"} for job in needs.values())): + raise ValueError("Selected mobile jobs did not all succeed") + print(f"Mobile gate passed: {', '.join(required)}") + + def package_args(packages): if not packages or len(set(packages)) != len(packages) or set(packages) - set(PACKAGES): raise ValueError("Expected unique workspace package names") @@ -409,11 +421,87 @@ def run_check(packages, msrv=None): subprocess.run(["cargo", f"+{msrv}", "check", "--locked", *selected], check=True) +def parallel_processes(commands, artifacts): + artifacts.mkdir(parents=True, exist_ok=True) + processes, logs, results = {}, [], {} + previous = {sig: signal.getsignal(sig) for sig in (signal.SIGINT, signal.SIGTERM)} + + def interrupted(*_): + raise KeyboardInterrupt + + try: + for sig in previous: + signal.signal(sig, interrupted) + for mode, (command, environment) in commands.items(): + log = (artifacts / (mode + ".log")).open("w") + logs.append(log) + processes[mode] = subprocess.Popen(command, env=environment, stdout=log, stderr=subprocess.STDOUT, start_new_session=True) + for mode, process in processes.items(): + results[mode] = process.wait() + finally: + for sig in previous: + signal.signal(sig, signal.SIG_IGN) + for process in processes.values(): + if process.poll() is None: + process.send_signal(signal.SIGINT) + for mode, process in processes.items(): + try: + results[mode] = process.wait(timeout=30) + except subprocess.TimeoutExpired: + try: + os.killpg(process.pid, signal.SIGKILL) + except ProcessLookupError: + pass + results[mode] = process.wait() + for log in logs: + log.close() + (artifacts / "results.json").write_text(json.dumps(results, sort_keys=True) + "\n") + for sig, handler in previous.items(): + signal.signal(sig, handler) + if any(result != 0 for result in results.values()) or len(results) != len(commands): + raise ValueError(f"Process acceptance failed: {results}") + + +def macos_process(package, artifacts): + import hashlib + package, artifacts = package.resolve(strict=True), artifacts.resolve() + commands, copies = {}, [] + for mode, base in (("chat-agent", 41000), ("phase5", 51000)): + copied = artifacts / mode / "package" + shutil.copytree(package, copied) + copies.append(copied) + commands[mode] = (["python3", str(Path(__file__).with_name("verify-node.py")), + "--binary", str(copied / "vibeface"), "--core-binary", str(copied / "vibeface-core"), + "--crypto-module", str(copied / "web/vibeface_secure.js"), + "--artifacts", str(artifacts / mode / "runs"), "--" + mode], + dict(os.environ, VIBEFACE_PORT_BASE=str(base), VIBEFACE_PORT_LIMIT=str(base + 1000))) + + def hashes(directory): + return {path.relative_to(directory).as_posix(): hashlib.sha256(path.read_bytes()).hexdigest() + for path in directory.rglob("*") if path.is_file()} + + expected = hashes(package) + if any(hashes(copied) != expected for copied in copies): + raise ValueError("macOS package copies differ") + try: + parallel_processes(commands, artifacts) + finally: + if hashes(package) != expected or any(hashes(copied) != expected for copied in copies): + raise ValueError("macOS process acceptance changed its input package") + + def self_test(): from unittest.mock import patch + mobile = {job: {"result": "success"} for job in ("android", "ios-build", "ios-accept")} + mobile_gate(mobile, False) + mobile_gate({"android": {"result": "success"}, "ios-build": {"result": "skipped"}, "ios-accept": {"result": "skipped"}}, True) + for job in mobile: + for result in ("failure", "cancelled", "skipped", "missing"): + expect_failure(lambda: mobile_gate(dict(mobile, **{job: {"result": result}}), False)) + expect_failure(lambda: mobile_gate({key: value for key, value in mobile.items() if key != job}, False)) web = make_plan(["apps/app/src/routes/index.tsx"]) assert web["rust_packages"] == [] and web["test_tiers"] == [] - assert web["required_jobs"] == ["quick-check", "crypto-web", "web", "package"] + assert web["required_jobs"] == ["quick-check", "crypto-web", "web", "native-linux", "package-linux"] assert web["package_mode"] == "web" and web["package_matrix"]["include"] == list(PLATFORMS[:1]) assert make_plan(["apps/app/src/content.md"])["web"] assert web["local_process_modes"] == [] @@ -475,7 +563,7 @@ def self_test(): assert selected["scopes"] == ["delivery"] and selected["delivery"] assert selected["rust_packages"] == expected["delivery"] and selected["web"] assert "delivery" in selected["required_jobs"] - assert "package" in selected["required_jobs"] and selected["package_matrix"]["include"][0]["target"] == "x86_64-unknown-linux-gnu" + assert "package-linux" in selected["required_jobs"] and selected["package_matrix"]["include"][0]["target"] == "x86_64-unknown-linux-gnu" assert not docs["delivery"] and not web["delivery"] for path in ("Cargo.toml", "Cargo.lock", "apps/core/Cargo.toml", "apps/cli/Cargo.toml", "crates/control/Cargo.toml", ".cargo/config.toml", "rust-toolchain.toml", ".github/workflows/ci.yml", "scripts/ci.py", "new-build-input"): assert make_plan([path])["rust_packages"] == list(PACKAGES) @@ -633,16 +721,46 @@ def self_test(): workflow = (root / ".github/workflows/ci.yml").read_text() concurrency = workflow.split("concurrency:\n", 1)[1].split("\npermissions:", 1)[0] assert "(github.event_name == 'workflow_dispatch' || github.run_attempt > 1) && github.run_id || ''" in concurrency - assert "cancel-in-progress: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && github.run_attempt == 1 }}" in concurrency + assert "github.run_attempt == 1 && (github.event_name == 'push' && github.ref == 'refs/heads/main'" in concurrency + for condition in ("inputs.feedback", "!inputs.delivery_live", "!inputs.delivery_small", "inputs.delivery_small_resume_run == ''"): + assert concurrency.count(condition) == 2 + assert "feedback:\n" in workflow and "default: false" in workflow.split("feedback:\n", 1)[1].split("delivery_live:", 1)[0] assert "fetch-depth: 0" in workflow.split("\n ci-gate:\n", 1)[1] for job in ("rust-check", "rust-fast", "rust-slow"): block = re.search(rf"(?ms)^ {job}:\n(.*?)(?=^ \w|\Z)", workflow)[1] dependency = "[plan, quick-check]" if job == "rust-check" else "plan" assert f" needs: {dependency}\n" in block assert "actions/download-artifact@" not in block - package = re.search(r"(?ms)^ package:\n(.*?)(?=^ \w|\Z)", workflow)[1] - assert " needs: [plan, crypto-web, web]\n" in package - assert "name: crypto-web-${{ github.sha }}" in package and "name: web-${{ github.sha }}" in package + for platform in PLATFORMS: + key, target, runner = (platform[field] for field in ("key", "target", "runner")) + for kind in ("native", "package"): + block = re.search(rf"(?ms)^ {kind}-{key}:\n(.*?)(?=^ [a-z]|\Z)", workflow)[1] + dependency = "plan" if kind == "native" else f"[plan, native-{key}, crypto-web, web]" + assert f" needs: {dependency}\n" in block + assert f"runner: {runner}" in block and f"target: {target}" in block + assert f"uses: ./.github/workflows/ci-{kind}.yml" in block + assert f".include.*.target, '{target}'" in block + assert f"native-{key}" in ready["required_jobs"] and f"package-{key}" in ready["required_jobs"] + native = (root / ".github/workflows/ci-native.yml").read_text() + package = (root / ".github/workflows/ci-package.yml").read_text() + assert "actions/download-artifact@" not in native and "--native-output" in native + assert "--native-input" in package and "--producer-attempt" in package + assert "artifact-ids: ${{ inputs.crypto_artifact_id }}" in package and "artifact-ids: ${{ inputs.web_artifact_id }}" in package + assert "macos-process" in package + mobile_workflow = (root / ".github/workflows/mobile.yml").read_text() + build = mobile_workflow.split(" ios-build:\n", 1)[1].split(" ios-accept:\n", 1)[0] + accept = mobile_workflow.split(" ios-accept:\n", 1)[1].split(" mobile-gate:\n", 1)[0] + assert "seal ios" in build and "restore ios" in accept + assert "workspaces: |\n . -> target\n . -> .artifacts/native/target" in build + assert "xcodebuild" not in accept and "cargo build" not in accept and "build-web.sh" not in accept + assert "nativeInvitation" not in build and "simctl\", \"create" not in build + assert "artifact-ids: ${{ needs.ios-build.outputs.artifact_id }}" in accept and "needs.ios-build.outputs.producer_attempt" in accept + for text in (workflow, package, mobile_workflow): + lines = text.splitlines() + for index, line in enumerate(lines): + if "artifact-ids:" in line: + assert "merge-multiple: true" in "\n".join(lines[index:index + 5]) + process_pair_test(root, scratch) subprocess.run(["python3", str(root / "scripts/build-inputs.py"), "self-test"], check=True) config = (root / "crates/control/src/lib.rs").read_text() protocol, epoch = (re.search(rf"^pub const {name}: u32 = (\d+);$", config, re.M)[1] for name in ("UPDATE_PROTOCOL", "DATA_EPOCH")) @@ -722,7 +840,7 @@ def gatekeeper_test(root, scratch): import sys import textwrap - workflow = (root / ".github/workflows/ci.yml").read_text() + workflow = (root / ".github/workflows/ci-package.yml").read_text() step = workflow.split(" - name: Verify Developer ID signature\n", 1)[1] script = textwrap.dedent(step.split(" run: |\n", 1)[1].split("\n - ", 1)[0]) accepted = (0, "Notarized Developer ID") @@ -851,7 +969,7 @@ def generated(): marker = repo / "cargo-called" environment.update(PATH=f"{fake_cargo.parent}{os.pathsep}{environment['PATH']}", CARGO_MARKER=str(marker)) subprocess.run(["bash", str(repo / "scripts/package-node.sh"), "--target", "x86_64-unknown-linux-gnu"], env=environment, check=True, stdout=subprocess.PIPE) - assert marker.exists(), "packaging must always rebuild the native binary" + assert marker.exists(), "default packaging must rebuild the native binary" archive_path, = (repo / ".artifacts/packages").glob("*.tar.gz") with tarfile.open(archive_path) as archive: for entry in archive.getmembers(): @@ -863,9 +981,21 @@ def generated(): assert not any(entry.name.endswith(("/.env", "/untracked-note.md")) for entry in archive.getmembers()) assert archive.getmember(f"{package}/vibeface").mode & 0o111 assert archive.getmember(f"{package}/vibeface-core").mode & 0o111 + marker.unlink() + native = repo / ".artifacts/native.tar.gz" + subprocess.run(["bash", str(repo / "scripts/package-node.sh"), "--target", "x86_64-unknown-linux-gnu", "--native-output", str(native)], env=environment, check=True, stdout=subprocess.PIPE) + assert marker.exists(), "native producer must compile" + restored = repo / ".artifacts/native-restored" + subprocess.run(["python3", str(repo / "scripts/build-inputs.py"), "restore", "native", "--target", "x86_64-unknown-linux-gnu", "--input", str(native), "--output", str(restored)], env=environment, check=True) + marker.unlink() + command = ["bash", str(repo / "scripts/package-node.sh"), "--target", "x86_64-unknown-linux-gnu", "--native-input", str(restored)] + subprocess.run(command, env=environment, check=True, stdout=subprocess.PIPE) + assert not marker.exists(), "verified native input must be reused without Cargo" + (restored / "vibeface").write_bytes(b"corrupt") + assert subprocess.run(command, env=environment, stdout=subprocess.PIPE, stderr=subprocess.PIPE).returncode != 0 + assert not marker.exists(), "invalid native input must fail without a silent rebuild" (repo / "scripts/release-rustflags.py").write_text('raise RuntimeError("fixture failure")') generated() - marker.unlink() assert subprocess.run(["bash", str(repo / "scripts/package-node.sh"), "--target", "x86_64-unknown-linux-gnu"], env=environment, stdout=subprocess.PIPE, stderr=subprocess.PIPE).returncode != 0 assert not marker.exists(), "a failed privacy setup must stop the build" print("Release privacy self-test passed: caller flags, source paths, archive owners and extended attributes") @@ -879,6 +1009,46 @@ def expect_failure(check): raise AssertionError("Expected rejection") +def process_pair_test(root, scratch): + from unittest.mock import patch + import runpy + import time + with tempfile.TemporaryDirectory(prefix="pair-", dir=scratch) as temporary: + directory = Path(temporary) + commands = {"good": (["python3", "-c", "raise SystemExit(0)"], None), + "bad": (["python3", "-c", "raise SystemExit(7)"], None)} + expect_failure(lambda: parallel_processes(commands, directory)) + assert json.loads((directory / "results.json").read_text()) == {"good": 0, "bad": 7} + child = "import pathlib,signal,time; signal.signal(signal.SIGINT,lambda *_: (_ for _ in ()).throw(KeyboardInterrupt())); " + child += "pathlib.Path({ready!r}).touch()\ntry: time.sleep(30)\nfinally: pathlib.Path({done!r}).touch()\n" + commands = {name: (["python3", "-c", child.format(ready=str(directory / (name + "-ready")), done=str(directory / (name + "-done")))], None) for name in ("a", "b")} + supervisor = "import runpy,pathlib; runpy.run_path({script!r})['parallel_processes']({commands!r},pathlib.Path({output!r}))" + process = subprocess.Popen(["python3", "-c", supervisor.format(script=str(root / "scripts/ci.py"), commands=commands, output=str(directory))], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + try: + deadline = time.monotonic() + 10 + while not all((directory / (name + "-ready")).exists() for name in commands): + if process.poll() is not None or time.monotonic() >= deadline: + raise AssertionError("both controlled workers must start") + time.sleep(0.02) + process.terminate() + assert process.wait(timeout=10) != 0 + assert all((directory / (name + "-done")).exists() for name in commands) + assert set(json.loads((directory / "results.json").read_text())) == {"a", "b"} + finally: + if process.poll() is None: + process.kill() + process.wait() + with patch.dict(os.environ, {"VIBEFACE_PORT_BASE": "41000", "VIBEFACE_PORT_LIMIT": "41001"}): + namespace = runpy.run_path(str(root / "scripts/verify-node.py")) + namespace["_port_base"][0] = 41001 + try: + namespace["available_port"]() + except AssertionError: + pass + else: + raise AssertionError("exhausted port range was accepted") + + def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--self-test", action="store_true") @@ -894,6 +1064,9 @@ def main(): needs = final_gate.add_mutually_exclusive_group(required=True) needs.add_argument("--needs", type=Path) needs.add_argument("--needs-env") + mobile = commands.add_parser("mobile-gate") + mobile.add_argument("--needs-env", required=True) + mobile.add_argument("--android-only", action="store_true") for name in ("test", "check"): command = commands.add_parser(name) selection = command.add_mutually_exclusive_group(required=True) @@ -903,16 +1076,23 @@ def main(): command.add_argument("--tier", choices=("fast", "slow"), required=True) else: command.add_argument("--msrv", help="also check the declared minimum Rust version") + macos = commands.add_parser("macos-process") + macos.add_argument("--package", type=Path, required=True) + macos.add_argument("--artifacts", type=Path, required=True) args = parser.parse_args() if args.self_test: from unittest.mock import patch with patch.dict(os.environ, {key: value for key, value in os.environ.items() if not key.startswith("GITHUB_") and key != "GH_TOKEN"}, clear=True): self_test() + elif args.command == "macos-process": + macos_process(args.package, args.artifacts) elif args.command == "plan": write_plan(event_plan(args), args.github_output) elif args.command == "gate": needs = json.loads(args.needs.read_text() if args.needs else os.environ[args.needs_env]) gate(needs, json.loads(args.plan.read_text()) if args.plan else None, delivery_live=args.delivery_live) + elif args.command == "mobile-gate": + mobile_gate(json.loads(os.environ[args.needs_env]), args.android_only) elif args.command in {"test", "check"}: packages = args.packages if args.packages else json.loads(os.environ[args.plan_env])["rust_packages"] if args.command == "test": diff --git a/scripts/package-node.sh b/scripts/package-node.sh index 21a087b3d..cdcccceaf 100755 --- a/scripts/package-node.sh +++ b/scripts/package-node.sh @@ -4,6 +4,8 @@ set -euo pipefail usage() { cat <<'USAGE' Usage: package-node.sh [--target RUST_TARGET] [--output DIRECTORY] + package-node.sh --target RUST_TARGET --native-output ARCHIVE + package-node.sh --target RUST_TARGET --native-input VERIFIED_DIRECTORY Builds and packages the CLI, Core binary, web client, docs, and user service installer. The default output is .artifacts/packages. Provider runtimes and credentials are not bundled. @@ -13,6 +15,8 @@ USAGE repo="$(cd "$(dirname "$0")/.." && pwd)" output="$repo/.artifacts/packages" target='' +native_output='' +native_input='' while (($#)); do case "$1" in --target|--output) @@ -20,10 +24,16 @@ while (($#)); do if [[ "$1" == '--target' ]]; then target="$2"; else output="$2"; fi shift 2 ;; + --native-output|--native-input) + (($# >= 2)) || { usage >&2; exit 2; } + if [[ "$1" == '--native-output' ]]; then native_output="$2"; else native_input="$2"; fi + shift 2 + ;; --help|-h) usage; exit 0 ;; *) usage >&2; exit 2 ;; esac done +[[ -z "$native_output" || -z "$native_input" ]] || { usage >&2; exit 2; } notary_vars=0 for var in VIBEFACE_NOTARY_KEY VIBEFACE_NOTARY_KEY_ID VIBEFACE_NOTARY_ISSUER; do @@ -39,8 +49,10 @@ if ((notary_vars == 3)) && [[ -z "${VIBEFACE_CODESIGN_IDENTITY:-}" ]]; then fi cd "$repo" -python3 "$repo/scripts/build-inputs.py" check crypto -python3 "$repo/scripts/build-inputs.py" check web +if [[ -z "$native_output" ]]; then + python3 "$repo/scripts/build-inputs.py" check crypto + python3 "$repo/scripts/build-inputs.py" check web +fi build_args=(build --release -p vibeface -p vibeface-core --locked) target_dir="${CARGO_TARGET_DIR:-$repo/target}" if [[ -n "$target" ]]; then @@ -52,6 +64,21 @@ else cli_binary="$target_dir/release/vibeface" core_binary="$target_dir/release/vibeface-core" fi +if [[ -n "$native_input" ]]; then + input_args=(check native --input "$native_input" --target "$target") + if [[ -n "${VIBEFACE_INPUT_ATTEMPT:-}" ]]; then input_args+=(--producer-attempt "$VIBEFACE_INPUT_ATTEMPT"); fi + python3 "$repo/scripts/build-inputs.py" "${input_args[@]}" + cli_binary="$native_input/vibeface" + core_binary="$native_input/vibeface-core" +else + release_rustflags="$(python3 "$repo/scripts/release-rustflags.py")" + CARGO_ENCODED_RUSTFLAGS="$release_rustflags" cargo "${build_args[@]}" +fi +[[ -x "$cli_binary" && -x "$core_binary" ]] || { printf 'Release binaries are missing: %s and %s\n' "$cli_binary" "$core_binary" >&2; exit 1; } +if [[ -n "$native_output" ]]; then + python3 "$repo/scripts/build-inputs.py" seal native --source "$(dirname "$cli_binary")" --target "$target" --output "$native_output" + exit 0 +fi web="$repo/apps/app/dist/client" [[ -s "$web/vibeface_secure.js" && -s "$web/vibeface_secure_bg.wasm" ]] || { echo 'Browser cryptography is missing from the static output. Run scripts/build-web-crypto.sh and scripts/build-web.sh before building a package.' >&2 @@ -61,9 +88,6 @@ web="$repo/apps/app/dist/client" echo 'Web client is missing. Run scripts/build-web.sh before building a package.' >&2 exit 1 } -release_rustflags="$(python3 "$repo/scripts/release-rustflags.py")" -CARGO_ENCODED_RUSTFLAGS="$release_rustflags" cargo "${build_args[@]}" -[[ -x "$cli_binary" && -x "$core_binary" ]] || { printf 'Release binaries are missing: %s and %s\n' "$cli_binary" "$core_binary" >&2; exit 1; } version="$(sed -n 's/^version = "\([^"]*\)"$/\1/p' "$repo/apps/cli/Cargo.toml" | head -n 1)" [[ -n "$version" && -n "$target" ]] || { echo 'Could not determine package version or target.' >&2; exit 1; } case "$version$target" in *[!a-zA-Z0-9._-]*) echo 'Invalid package version or target.' >&2; exit 1 ;; esac diff --git a/scripts/verify-node.py b/scripts/verify-node.py index 55d228d97..0e9cb9471 100755 --- a/scripts/verify-node.py +++ b/scripts/verify-node.py @@ -115,13 +115,15 @@ def maintenance(node, command): _port_base = [int(os.environ.get("VIBEFACE_PORT_BASE", "0"))] +_port_limit = int(os.environ.get("VIBEFACE_PORT_LIMIT", "65536")) +require(0 <= _port_base[0] < _port_limit <= 65536, "valid exclusive port range") _assigned_ports = set() def available_port(): - """A free TCP/UDP loopback port; VIBEFACE_PORT_BASE pins a known range.""" while True: port = _port_base[0] + require(port < _port_limit, "the assigned port range is not exhausted") if port: _port_base[0] += 1 with socket.socket() as stream, socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as datagram: @@ -2858,7 +2860,7 @@ def chat_agent_acceptance(options): helper.write_text(CLIENT_SOURCE.replace("MODULE_URL", module.as_uri())) nodes = [] report = {"status": "running", "source_binary": str(binary), "binary_sha256": file_sha256(binary), - "provider_calls": 0, "coverage": "one real Node; fixture SDK driving the real vibeface CLIs against a managed fixture App Server", + "provider_calls": 0, "coverage": "two isolated real Nodes; fixture SDK driving the real vibeface CLIs against a managed fixture App Server", "evidence": [], "not_checked": ["real provider model behavior", "rendered browser UI", "cross-device work (phase 2)", "OS sandboxing of SDK host tools"]} @@ -7888,6 +7890,11 @@ def revealed(): if "--fixture-codex" in sys.argv: fixture_codex(sys.argv[1:]) else: + def interrupt_acceptance(*_): + raise KeyboardInterrupt + + signal.signal(signal.SIGINT, interrupt_acceptance) + signal.signal(signal.SIGTERM, interrupt_acceptance) parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--binary", type=Path, required=True, help="the vibeface CLI binary used to create and run the isolated Nodes") From c35ba5362c2a5c5fb485019ddb519a0436923480 Mon Sep 17 00:00:00 2001 From: harryisfish Date: Fri, 6 Nov 2026 16:21:34 +0800 Subject: [PATCH 03/34] perf(ci): preserve native cache identity across job extraction --- .github/workflows/ci-native.yml | 2 +- scripts/ci.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-native.yml b/.github/workflows/ci-native.yml index a96a55b2a..5112abd2d 100644 --- a/.github/workflows/ci-native.yml +++ b/.github/workflows/ci-native.yml @@ -26,7 +26,7 @@ jobs: - uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 with: - key: package-${{ inputs.target }} + shared-key: package-${{ inputs.target }}-package save-if: ${{ github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' }} - name: Build and seal native release input without Web dependencies run: | diff --git a/scripts/ci.py b/scripts/ci.py index 88cb8040c..f6be5efb0 100644 --- a/scripts/ci.py +++ b/scripts/ci.py @@ -744,6 +744,7 @@ def self_test(): native = (root / ".github/workflows/ci-native.yml").read_text() package = (root / ".github/workflows/ci-package.yml").read_text() assert "actions/download-artifact@" not in native and "--native-output" in native + assert "shared-key: package-${{ inputs.target }}-package" in native assert "--native-input" in package and "--producer-attempt" in package assert "artifact-ids: ${{ inputs.crypto_artifact_id }}" in package and "artifact-ids: ${{ inputs.web_artifact_id }}" in package assert "macos-process" in package From a5550606d04f7c88a5009a718088cd5e7576e6fb Mon Sep 17 00:00:00 2001 From: harryisfish Date: Fri, 6 Nov 2026 18:25:05 +0800 Subject: [PATCH 04/34] fix(ci): await native deep-link confirmation before navigation --- .github/workflows/mobile.yml | 4 ++++ packages/docs/e2e.md | 2 ++ tests/e2e/native-transfers.e2e.ts | 17 ++++++++++------- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/workflows/mobile.yml b/.github/workflows/mobile.yml index 1c1e30df6..1bec549ec 100644 --- a/.github/workflows/mobile.yml +++ b/.github/workflows/mobile.yml @@ -259,6 +259,9 @@ jobs: stage = stage_path.read_text().strip() if stage_path.exists() else "not_started" stages = {"host-source", "host-build", "simulator-create", "typecheck", "selection", "ui-run"} diagnostics = {"stage": stage if stage in stages else "not_started", "report": "missing", "failures": []} + ui_log = root / "private/ui.log" + if ui_log.exists(): + diagnostics["runner_prepare_fallback_reported"] = "automation runner not prepared" in ui_log.read_text(errors="replace") navigation_path = public / "provider-navigation.json" if navigation_path.exists(): try: @@ -391,6 +394,7 @@ jobs: ("welcome", None, "连接你的网络"), ("ready", None, "已填入加入链接"), ("invitation", "textbox", "加入链接"), ("device_name", "textbox", "这台设备的名字"), ("join", "button", "加入"), ("invalid_link", None, "这不是有效的加入链接"), + ("add_device", None, "添加设备"), ("open_button", "button", "Open"), ("cancel_button", "button", "Cancel"), ("spent_link", None, "这条加入链接已用过或已过期。在已有设备上点“添加设备”重新生成。"), ): prefix = r"^\s*#\S+ " + (re.escape(role) + " " if role else r"(?:[a-z-]+ )?") diff --git a/packages/docs/e2e.md b/packages/docs/e2e.md index b2a972f2c..7caad7091 100644 --- a/packages/docs/e2e.md +++ b/packages/docs/e2e.md @@ -138,6 +138,8 @@ python3 scripts/verify-node.py --delivery-ui-selfcheck \ --binary /usr/bin/true --artifacts .artifacts/paid-ui-selfcheck ``` +深链接验收先等待系统确认或明确的目标界面;出现确认时只点击一次 Open,再要求目标界面可见。验收保留真实安装、配对和系统弹窗操作,不增加测试重试或固定延迟。公开失败诊断只增加预热回退布尔值,以及固定控件是否被报告的 true/null 标记,不上传原始 driver 日志。 + ## 重跑 iOS Provider 验收 `mobile.yml` 将构建和验收分成 `ios-build`、`ios-accept`。前者只上传白名单中的 App ZIP、host CLI/Core、Web/WASM 与来源清单,邀请、Node 数据和 driver 状态在后者创建。恢复后核对摘要、执行位、签名、entitlements 和实际安装的 bundle 字节,再执行原来的真实配对与 Provider 测试。构建成功不代表 UI 通过。 diff --git a/tests/e2e/native-transfers.e2e.ts b/tests/e2e/native-transfers.e2e.ts index 877e95793..2883fe9d9 100644 --- a/tests/e2e/native-transfers.e2e.ts +++ b/tests/e2e/native-transfers.e2e.ts @@ -9,7 +9,7 @@ import { createInterface } from 'node:readline'; import { promisify } from 'node:util'; import { execFile } from 'node:child_process'; import { test as base } from '@e2e-dev/mobile'; -import { expect, secrets } from 'e2e'; +import { expect, secrets, type Locator } from 'e2e'; const root = resolve(import.meta.dirname, '../..'); const execute = promisify(execFile); @@ -188,12 +188,14 @@ test('provider settings and queued cancellation work in the installed native app await expect(screen.getByLabel(`安全码 ${code.split('').join(' ')}`)).toBeVisible(); await network.call({ op: 'native_approve', peer: text(pairing.peer), code }); await expect(screen.getByRole('link', '设置', { exact: true })).toBeVisible({ timeout: 30000 }); - const openLink = async (url: string) => { + const openLink = async (url: string, destination: Locator) => { await device.openLink(url); - const consent = screen.getByRole('alert', /Open in.*Vibeface/); + const consent = screen.getByRole('alert', /Open in.*Vibeface/, { visible: true }); + await expect(consent.or(destination).first()).toBeVisible(); if (await consent.isVisible()) await consent.getByRole('button', 'Open', { exact: true }).click(); + await expect(destination).toBeVisible(); }; - await openLink('vibeface://add-device'); + await openLink('vibeface://add-device', screen.getByRole('button', '关闭', { exact: true, visible: true })); await expect(screen.getByText('添加设备', { exact: true }).first()).toBeVisible(); const clientKind = screen.getByRole('button', '客户端', { exact: true }); const nodeKind = screen.getByRole('button', '节点', { exact: true }); @@ -439,7 +441,8 @@ test('provider settings and queued cancellation work in the installed native app const queue = await network.call({ op: 'native_provider_queue' }); await assert.rejects(network.call({ op: 'native_provider_queue' })); const botId = text(queue.bot_id), runningTrigger = text(queue.running_trigger), queuedTrigger = text(queue.queued_trigger); - await openLink(`vibeface://b/${botId}`); + const composer = screen.getByRole('textbox', /^给 Bot 发消息(?:$|[\s,,])/, { visible: true }); + await openLink(`vibeface://b/${botId}`, composer); const cancel = screen.getByRole('button', '取消排队', { exact: true }); await screen.scrollUntilVisible(cancel, { direction: 'up', timeout: 30000 }); await cancel.click(); @@ -451,8 +454,8 @@ test('provider settings and queued cancellation work in the installed native app const after = await inspect(); expect(after.running_invocations).toBe(1); expect(after.queued_invocations).toBe(0); - await openLink('vibeface://settings'); - await openLink(`vibeface://b/${botId}`); + await openLink('vibeface://settings', screen.getByText('我的设备', { exact: true, visible: true })); + await openLink(`vibeface://b/${botId}`, composer); await expect(screen.getByRole('textbox', /^给 Bot 发消息(?:$|[\s,,])/)).toBeVisible(); const reopened = await inspect(); expect(reopened.jobs).toEqual(after.jobs); From e26936871b6fbaffbb319eed82cdb2b8330eb715 Mon Sep 17 00:00:00 2001 From: harryisfish Date: Fri, 6 Nov 2026 18:43:03 +0800 Subject: [PATCH 05/34] fix(ci): require complete ios cache and unique deep-link destination --- .github/workflows/mobile.yml | 1 - tests/e2e/native-transfers.e2e.ts | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/mobile.yml b/.github/workflows/mobile.yml index 1bec549ec..7f6b0cb55 100644 --- a/.github/workflows/mobile.yml +++ b/.github/workflows/mobile.yml @@ -98,7 +98,6 @@ jobs: workspaces: | . -> target . -> .artifacts/native/target - cache-on-failure: true - uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4 with: version: 11.9.0 diff --git a/tests/e2e/native-transfers.e2e.ts b/tests/e2e/native-transfers.e2e.ts index 2883fe9d9..367d3358f 100644 --- a/tests/e2e/native-transfers.e2e.ts +++ b/tests/e2e/native-transfers.e2e.ts @@ -195,7 +195,7 @@ test('provider settings and queued cancellation work in the installed native app if (await consent.isVisible()) await consent.getByRole('button', 'Open', { exact: true }).click(); await expect(destination).toBeVisible(); }; - await openLink('vibeface://add-device', screen.getByRole('button', '关闭', { exact: true, visible: true })); + await openLink('vibeface://add-device', screen.getByText('添加设备', { exact: true, visible: true }).first()); await expect(screen.getByText('添加设备', { exact: true }).first()).toBeVisible(); const clientKind = screen.getByRole('button', '客户端', { exact: true }); const nodeKind = screen.getByRole('button', '节点', { exact: true }); From 22e0857db6c9200d677c139d0d4132f229fb76ff Mon Sep 17 00:00:00 2001 From: harryisfish Date: Fri, 6 Nov 2026 19:48:28 +0800 Subject: [PATCH 06/34] fix(ci): allow cold ios build cache cleanup to finish --- .github/workflows/mobile.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mobile.yml b/.github/workflows/mobile.yml index 7f6b0cb55..c8f13c956 100644 --- a/.github/workflows/mobile.yml +++ b/.github/workflows/mobile.yml @@ -84,7 +84,7 @@ jobs: producer_attempt: ${{ github.run_attempt }} if: ${{ !inputs.android_only && github.event_name == 'workflow_dispatch' }} runs-on: macos-26 - timeout-minutes: 60 + timeout-minutes: 75 steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: From 48b969d749475cce73b58c2ce7d078d0e408f169 Mon Sep 17 00:00:00 2001 From: harryisfish Date: Fri, 6 Nov 2026 21:18:18 +0800 Subject: [PATCH 07/34] fix(ci): update native driver for hosted runner failures --- pnpm-lock.yaml | 10 +++++----- pnpm-workspace.yaml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ee31aa916..7b5a80cc1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,7 +5,7 @@ settings: excludeLinksFromLockfile: false overrides: - '@e2e-dev/mobile@0.12.4>agent-device': 0.21.32 + '@e2e-dev/mobile@0.12.4>agent-device': 0.21.36 importers: @@ -3029,8 +3029,8 @@ packages: engines: {node: '>=18.18'} hasBin: true - agent-device@0.21.32: - resolution: {integrity: sha512-gfpNs+qeCHKKLY3mqD/NpC7Et7wh5qxNvM9A2cPOhOpzX21e9UHSkO7zOMBpUK7NGtOOkbtz67jco5SVmZOPog==} + agent-device@0.21.36: + resolution: {integrity: sha512-aG88WlEHjFc/OEBQC7AJg+2LfNoVT/ogxnnzIUYUEgafdiTvBaA+X6uQ2wNmpp2ZrHLy8QIXoEOyc3NEZgJCpQ==} engines: {node: '>=22.12'} hasBin: true peerDependencies: @@ -7161,7 +7161,7 @@ snapshots: '@e2e-dev/mobile@0.12.4(ai@7.0.153(zod@4.6.7))(e2e@0.21.3(ai@7.0.153(zod@4.6.7)))': dependencies: - agent-device: 0.21.32(ai@7.0.153(zod@4.6.7)) + agent-device: 0.21.36(ai@7.0.153(zod@4.6.7)) e2e: 0.21.3(ai@7.0.153(zod@4.6.7)) pngjs: 7.0.0 zod: 4.6.1 @@ -10016,7 +10016,7 @@ snapshots: agent-cli-detector@0.1.7: {} - agent-device@0.21.32(ai@7.0.153(zod@4.6.7)): + agent-device@0.21.36(ai@7.0.153(zod@4.6.7)): optionalDependencies: ai: 7.0.153(zod@4.6.7) diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 615aebbe9..564aa8244 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -2,7 +2,7 @@ packages: - packages/* - apps/* overrides: - '@e2e-dev/mobile@0.12.4>agent-device': 0.21.32 + '@e2e-dev/mobile@0.12.4>agent-device': 0.21.36 allowBuilds: esbuild: true lightningcss: true From 4315bffde2e51bb79afaa856eebfb6713dffee5d Mon Sep 17 00:00:00 2001 From: harryisfish Date: Fri, 6 Nov 2026 22:39:49 +0800 Subject: [PATCH 08/34] fix(ci): retain safe native install diagnostics Project the known driver error fields before the e2e report drops its cause. Keep the original install error and the existing acceptance gate. --- packages/docs/e2e.md | 6 ++++-- tests/e2e/native-transfers.e2e.ts | 29 ++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/packages/docs/e2e.md b/packages/docs/e2e.md index 7caad7091..9af594d71 100644 --- a/packages/docs/e2e.md +++ b/packages/docs/e2e.md @@ -138,7 +138,7 @@ python3 scripts/verify-node.py --delivery-ui-selfcheck \ --binary /usr/bin/true --artifacts .artifacts/paid-ui-selfcheck ``` -深链接验收先等待系统确认或明确的目标界面;出现确认时只点击一次 Open,再要求目标界面可见。验收保留真实安装、配对和系统弹窗操作,不增加测试重试或固定延迟。公开失败诊断只增加预热回退布尔值,以及固定控件是否被报告的 true/null 标记,不上传原始 driver 日志。 +深链接验收先等待系统确认或明确的目标界面;出现确认时只点击一次 Open,再要求目标界面可见。验收保留真实安装、配对和系统弹窗操作,不增加测试重试或固定延迟。公开失败诊断限于预热回退、固定控件是否被报告的 true/null 标记和安装异常白名单,不上传原始 driver 日志。 ## 重跑 iOS Provider 验收 @@ -178,7 +178,7 @@ pnpm exec e2e run --config tests/e2e/e2e.native.config.ts --grep '^receives a ch ## 验证原生 Provider 设置和队列取消 -手动运行 `.github/workflows/mobile.yml` 时,现有 iOS job 在当前 checkout 构建 Simulator App、宿主 Node、Web 和 WASM,然后运行一个 Provider 原生用例。Android job 仍只构建 APK。iOS job 核对实际 arm64 宿主与 App,选择可用 iOS runtime,创建专属 iPhone 17 simulator 并等待它启动。缺少 runtime、启动失败或 driver 不可用都会使验收失败,构建成功不能代替 UI 结果。 +手动运行 `.github/workflows/mobile.yml` 时,`ios-build` 在当前 checkout 构建 Simulator App、宿主 Node、Web 和 WASM,`ios-accept` 恢复同源输入后运行一个 Provider 原生用例。Android job 仍只构建 APK。`ios-accept` 核对实际 arm64 宿主与 App,选择可用 iOS runtime,创建专属 iPhone 17 simulator 并等待它启动。缺少 runtime、启动失败或 driver 不可用都会使验收失败,构建成功不能代替 UI 结果。 宿主构建前还要求 HEAD 等于本次提交,且 `git status --porcelain --untracked-files=normal` 为空。DerivedData 和 Simulator zip 位于已忽略的 `.artifacts/native/`,不会干扰这个检查。Expo prebuild 改变源码时必须先解决,不能继续把脏源码产物记为当前提交。 @@ -204,6 +204,8 @@ native config 默认关闭 trace 和整段 video。原始日志、自动失败 失败收据与 stdout 保留固定阶段、报告是否可读,以及从实际 e2e report 提取的受限错误码、固定 `engine_reason` 和 `engine_timeout_kind`、已知 API 名和两个验收文件的行号。`completed_poll_samples` 只来自唯一合法的既有 expect 采样事件;零表示没有记录完成的采样,字段缺失不补零。错误 message、stack、locator label、值和原始报告不会导出。 +安装异常还会沿最多八层运行时 cause 记录 `driver_errors`。它只保留 `COMMAND_FAILED`、固定的 simctl 操作或 `unknown`、已知启动或传输原因,以及有界整数形式的超时预算、退出码和启动次数。命令、参数、路径和进程 stdout/stderr 不会导出。诊断写入失败也继续抛出原始安装异常,不增加安装或重试,不改变最终判定。 + 已有失败语义快照通过文件与元数据校验时,`failure_screen` 只记录欢迎、已填入链接、邀请输入、设备名输入、加入按钮及已知无效或失效提示是否被报告。`true` 是正向出现,`null` 是未知,不能当作控件不存在。快照采集为 best effort,可能缺失或裁剪;没有截断标记也不证明树完整,不能从语义文本恢复原生控件类型或输入读回值。该投影不新增 UI 读取,也不改变原 fill、用例或清理的成败。报告尚未生成时仍保留失败阶段,完整私有日志随后按原清理规则删除。 本地用例产生的 `ui_passed` 仅表示 UI 步骤已完成;本地操作者仍须关闭并删除本人创建的专属 simulator,并核对 fixture 清理结果。这个入口覆盖 iOS Simulator 与受控 Provider,不代表 Android UI、iPhone 真机、真实登录或真实模型已经验收。 diff --git a/tests/e2e/native-transfers.e2e.ts b/tests/e2e/native-transfers.e2e.ts index 367d3358f..fd3af6d9a 100644 --- a/tests/e2e/native-transfers.e2e.ts +++ b/tests/e2e/native-transfers.e2e.ts @@ -158,7 +158,34 @@ test('provider settings and queued cancellation work in the installed native app await assert.rejects(network.call({ op: 'native_provider_setup' })); await assert.rejects(network.call({ op: 'native_provider_stage', stage: 'invalid' })); await assert.rejects(network.call({ op: 'native_provider_stage', stage: 'ready', role: 'source' })); - await device.installApp(undefined, { reinstall: true }); + try { + await device.installApp(undefined, { reinstall: true }); + } catch (cause) { + const failures: Record[] = []; + for (let error: unknown = cause, depth = 0; error instanceof Error && depth < 8; error = error.cause, depth++) { + if (!('code' in error) || error.code !== 'COMMAND_FAILED' || !('details' in error) + || error.details === null || typeof error.details !== 'object' || Array.isArray(error.details)) continue; + const details = record(error.details); + const failure: Record = { code: 'COMMAND_FAILED', operation: 'unknown' }; + const args = details.args; + if (typeof details.cmd === 'string' && details.cmd.split('/').at(-1) === 'xcrun' && Array.isArray(args) && args[0] === 'simctl') { + if (args[1] === 'install' || args[1] === 'uninstall' || args[1] === 'bootstatus') failure.operation = `simctl-${args[1]}`; + else if (args[1] === 'list' && args[2] === 'devices') failure.operation = 'simctl-list-devices'; + } + if (details.kind === 'daemon_startup_failed') failure.kind = details.kind; + if (details.reason === 'startup-exited' || details.reason === 'startup-stalled' || details.reason === 'startup-ceiling' + || details.reason === 'daemon_transport_timeout') failure.reason = details.reason; + const limits: Record = { timeoutMs: [1, 1800000], startupTimeoutMs: [1, 1800000], exitCode: [0, 255], startupAttempts: [1, 2] }; + for (const [key, [minimum, maximum]] of Object.entries(limits)) { + const value = details[key]; + if (typeof value === 'number' && Number.isSafeInteger(value) && value >= minimum && value <= maximum) failure[key] = value; + } + failures.push(failure); + } + await writeFile(join(publicPath, 'provider.json'), `${JSON.stringify({ source_commit: source, status: 'failed', driver_errors: failures })}\n`, { mode: 0o600 }) + .catch(() => { process.stderr.write('Native driver failure diagnostic could not be recorded\n'); }); + throw cause; + } const installedPath = (await execute('xcrun', ['simctl', 'get_app_container', simulator, 'one.leaper.vibeface', 'app'])).stdout.trim(); assert(installedPath.startsWith('/') && installedPath.toLowerCase().includes(simulator.toLowerCase()), 'Inspect only the assigned simulator installed bundle'); expect(await bundleManifest(installedPath)).toEqual(built); From f89d98158fb5e1a356934aa62974eefcbb7affc7 Mon Sep 17 00:00:00 2001 From: harryisfish Date: Sat, 7 Nov 2026 00:08:13 +0800 Subject: [PATCH 09/34] fix(ci): normalize public archive permissions Record portable archive modes independently of the producer umask. Keep source files unchanged and retain strict restored-mode validation. --- scripts/build-inputs.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/scripts/build-inputs.py b/scripts/build-inputs.py index 46fb58518..b3002a96a 100644 --- a/scripts/build-inputs.py +++ b/scripts/build-inputs.py @@ -239,12 +239,16 @@ def input_files(directory): def write_input(directory, archive, component, target, source): manifest = dict(version=1, component=component, target=target, origin=source, files=input_files(directory)) + for metadata in manifest["files"].values(): + metadata["mode"] = 0o755 if metadata["mode"] & 0o111 else 0o644 (directory / "manifest.json").write_text(json.dumps(manifest, sort_keys=True) + "\n") archive.parent.mkdir(parents=True, exist_ok=True) with tarfile.open(archive, "w:gz", format=tarfile.USTAR_FORMAT) as output: for path in sorted(directory.rglob("*")): if path.is_file(): - info = output.gettarinfo(str(path), arcname=path.relative_to(directory).as_posix()) + name = path.relative_to(directory).as_posix() + info = output.gettarinfo(str(path), arcname=name) + info.mode = 0o644 if name == "manifest.json" else manifest["files"][name]["mode"] info.uid = info.gid = info.mtime = 0 info.uname = info.gname = "" with path.open("rb") as data: @@ -454,7 +458,12 @@ def self_test(): pass else: raise AssertionError("mid-build source change was accepted") - input_self_test(scratch) + for mask in (0o022, 0o077): + previous_mask = os.umask(mask) + try: + input_self_test(scratch) + finally: + os.umask(previous_mask) print("Build input self-test passed") @@ -535,10 +544,15 @@ def rejected(action): with zipfile.ZipFile(app, "w") as packed: packed.writestr("Vibeface.app/Vibeface", b"public app fixture") ios = build.parent / "ios.tar.gz" + source_files = {component: input_files(repo / path) for component, path in OUTPUTS.items()} pack_ios(repo, app, archive, ios) + assert source_files == {component: input_files(repo / path) for component, path in OUTPUTS.items()} os.environ.update(GITHUB_JOB="ios-accept", GITHUB_RUN_ATTEMPT="2") restored_ios = build.parent / "ios-restored" restore_input(repo, ios, restored_ios, "ios", "aarch64-apple-ios-sim", 1) + assert (restored_ios / "manifest.json").stat().st_mode & 0o777 == 0o644 + assert (restored_ios / "host/manifest.json").stat().st_mode & 0o777 == 0o644 + assert (restored_ios / "web/vibeface_secure.js").stat().st_mode & 0o777 == 0o644 for path in OUTPUTS.values(): shutil.rmtree(repo / path) install_ios(repo, restored_ios, 1) From da01dd2b479739c5372037adc023b9bbc085d513 Mon Sep 17 00:00:00 2001 From: harryisfish Date: Sat, 7 Nov 2026 02:27:22 +0800 Subject: [PATCH 10/34] chore(ci): isolate cold ios runner diagnostics Add a temporary manual mode that records bounded runner startup facts without rebuilding the product or accessing invitations. Keep the normal mobile jobs and acceptance gate unchanged. --- .github/workflows/mobile.yml | 349 ++++++++++++++++++++++++++++++++++- 1 file changed, 343 insertions(+), 6 deletions(-) diff --git a/.github/workflows/mobile.yml b/.github/workflows/mobile.yml index c8f13c956..ad6cacada 100644 --- a/.github/workflows/mobile.yml +++ b/.github/workflows/mobile.yml @@ -4,6 +4,10 @@ name: mobile on: workflow_dispatch: inputs: + runner_probe: + description: 'Run only the temporary iOS runner diagnosis' + type: boolean + default: false feedback: description: 'Replace older ordinary mobile feedback on this branch' type: boolean @@ -18,8 +22,8 @@ on: default: false concurrency: - group: mobile-${{ github.ref }}-${{ github.event_name == 'workflow_dispatch' && inputs.feedback && github.run_attempt == 1 && 'feedback' || github.run_id }} - cancel-in-progress: ${{ github.event_name == 'workflow_dispatch' && inputs.feedback && github.run_attempt == 1 }} + group: mobile-${{ github.ref }}-${{ github.event_name == 'workflow_dispatch' && !inputs.runner_probe && inputs.feedback && github.run_attempt == 1 && 'feedback' || github.run_id }} + cancel-in-progress: ${{ github.event_name == 'workflow_dispatch' && !inputs.runner_probe && inputs.feedback && github.run_attempt == 1 }} permissions: contents: read @@ -31,7 +35,7 @@ jobs: android: outputs: artifact_id: ${{ steps.upload.outputs.artifact-id }} - if: inputs.android_only || github.event_name == 'workflow_dispatch' + if: ${{ !(github.event_name == 'workflow_dispatch' && inputs.runner_probe) && (inputs.android_only || github.event_name == 'workflow_dispatch') }} runs-on: ubuntu-24.04 timeout-minutes: 60 steps: @@ -82,7 +86,7 @@ jobs: outputs: artifact_id: ${{ steps.inputs.outputs.artifact-id }} producer_attempt: ${{ github.run_attempt }} - if: ${{ !inputs.android_only && github.event_name == 'workflow_dispatch' }} + if: ${{ !inputs.android_only && github.event_name == 'workflow_dispatch' && !inputs.runner_probe }} runs-on: macos-26 timeout-minutes: 75 steps: @@ -149,7 +153,7 @@ jobs: ios-accept: needs: ios-build - if: ${{ !inputs.android_only && github.event_name == 'workflow_dispatch' }} + if: ${{ !inputs.android_only && github.event_name == 'workflow_dispatch' && !inputs.runner_probe }} runs-on: macos-26 timeout-minutes: 30 steps: @@ -466,7 +470,7 @@ jobs: retention-days: 7 mobile-gate: - if: always() + if: ${{ always() && !(github.event_name == 'workflow_dispatch' && inputs.runner_probe) }} needs: [android, ios-build, ios-accept] runs-on: ubuntu-24.04 steps: @@ -477,3 +481,336 @@ jobs: env: MOBILE_NEEDS: ${{ toJSON(needs) }} run: python3 scripts/ci.py mobile-gate --needs-env MOBILE_NEEDS ${{ inputs.android_only && '--android-only' || '' }} + + runner-probe: + if: ${{ github.event_name == 'workflow_dispatch' && inputs.runner_probe }} + runs-on: macos-26 + timeout-minutes: 20 + env: + AGENT_DEVICE_HOME: ${{ github.workspace }}/.artifacts/ios-runner-probe/private/agent-device + AGENT_DEVICE_STATE_DIR: ${{ github.workspace }}/.artifacts/ios-runner-probe/private/agent-device + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 + with: + persist-credentials: false + - uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 + with: + version: 11.9.0 + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 + with: + node-version: '24' + cache: pnpm + cache-dependency-path: pnpm-lock.yaml + - name: Prepare the private diagnostic collector + shell: bash + run: | + umask 077 + mkdir -p .artifacts/ios-runner-probe/private + cat > .artifacts/ios-runner-probe/private/probe.mjs <<'NODE' + import assert from 'node:assert/strict'; + import { spawnSync } from 'node:child_process'; + import { closeSync, existsSync, mkdirSync, openSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs'; + import { createRequire, findPackageJSON } from 'node:module'; + import { dirname, join, resolve } from 'node:path'; + import { pathToFileURL } from 'node:url'; + + process.umask(0o077); + const root = resolve('.artifacts/ios-runner-probe'); + const privateRoot = join(root, 'private'); + const state = join(privateRoot, 'agent-device'); + const home = state; + const reportPath = join(root, 'result.json'); + const simulatorPath = join(privateRoot, 'simulator.txt'); + const session = 'vdp-native-acceptance-0'; + const stages = ['setup', 'prepare', 'open', 'system_snapshot']; + const timingKeys = ['adopt_detached_runner', 'cleanup_stale_xcodebuild', 'ensure_booted', + 'verify_device_readiness', 'verify_host_dev_tools_security', 'cleanup_stale_bundles', + 'ensure_xctestrun', 'allocate_port', 'prepare_xctestrun_env', 'launch_xcodebuild', 'build_xctestrun']; + const codes = ['INVALID_ARGS', 'DEVICE_NOT_FOUND', 'DEVICE_IN_USE', 'TOOL_MISSING', + 'APP_NOT_INSTALLED', 'UNSUPPORTED_PLATFORM', 'UNSUPPORTED_OPERATION', 'NOT_IMPLEMENTED', + 'COMMAND_FAILED', 'SESSION_NOT_FOUND', 'UNAUTHORIZED', 'AMBIGUOUS_MATCH', 'REPLAY_DIVERGENCE', + 'REPAIR_SESSION_EXPIRED', 'REPAIR_COMMIT_FAILED', 'UNKNOWN', 'ERR_ASSERTION', 'PROBE_COMMAND_FAILED']; + const reasons = ['daemon_transport_timeout', 'daemon_request_timeout', 'request_canceled', + 'prepare_deadline_expired', 'runner_start_budget_exhausted', 'runner_launch_budget_exhausted', + 'runner_main_thread_timeout', 'runner_main_thread_wedged', 'runner_busy', 'runner_busy_refusal', + 'runner_reply_lost', 'runner_connect_refused', 'runner_endpoint_probe_exhausted', + 'runner_readiness_preflight_failed', 'runner_cache_uncertifiable', 'runner_process_dead', + 'runner_reported_failure', 'xcodebuild_exited_early', 'simulator_service_hub_unavailable', + 'simulator_set_destination_not_found', 'build_failed_unclassified', + 'startup-exited', 'startup-stalled', 'startup-ceiling']; + const enumValue = (value, allowed, fallback = 'unknown') => allowed.includes(value) ? value : fallback; + const ms = value => typeof value === 'number' && Number.isFinite(value) && value >= 0 && value <= 3600000 + ? Math.round(value) : null; + const numericFields = (value, keys) => Object.fromEntries(keys.map(key => [key, ms(value?.[key])])); + const safeError = (error, depth = 0) => ({ + code: enumValue(error?.code, codes), + reason: enumValue(error?.details?.reason, reasons), + cause_reason: enumValue(error?.details?.causeReason, reasons), + runner_error_code: enumValue(error?.details?.runnerErrorCode, + ['RUNNER_BUSY', 'MAIN_THREAD_TIMEOUT', 'RUNNER_WEDGED', 'COMMAND_ALREADY_FINISHED', 'IOS_AX_SNAPSHOT_FAILED']), + runner_connect_failure_reason: enumValue(error?.details?.runnerConnectFailureReason, reasons), + runner_phase: enumValue(error?.details?.phase, ['runner_session', 'runner_rebuild', 'runner_health']), + startup_kind: enumValue(error?.details?.kind, ['daemon_startup_failed']), + timeout_ms: ms(error?.details?.timeoutMs), + startup_timeout_ms: ms(error?.details?.startupTimeoutMs), + startup_attempts: Number.isInteger(error?.details?.startupAttempts) + && error.details.startupAttempts >= 0 && error.details.startupAttempts <= 2 ? error.details.startupAttempts : null, + cause: depth < 2 && error?.cause ? safeError(error.cause, depth + 1) : null, + }); + function safeEvent(value) { + const phase = value?.phase; + const data = value?.data; + if (phase === 'prepare_apple_runner') return { phase, + event: enumValue(data?.event, ['readiness_start', 'runner_start', 'settled']), + duration_ms: ms(value.durationMs), timeout_ms: ms(data?.timeoutMs), remaining_ms: ms(data?.remainingMs) }; + if (timingKeys.slice(0, -1).some(key => phase === `ios_runner_startup_${key}`)) { + return { phase, duration_ms: ms(value.durationMs) }; + } + if (phase === 'ios_runner_session_startup_timings') return { phase, + duration_ms: ms(value.durationMs), ready: typeof data?.ready === 'boolean' ? data.ready : null, + command: enumValue(data?.command, ['uptime', 'activate', 'snapshot']), + timings: numericFields(data?.timings, timingKeys) }; + if (phase === 'apple_runner_prepare') return { phase, + cache: enumValue(data?.cache, ['exact', 'miss', 'external']), + artifact: enumValue(data?.artifact, ['valid', 'rebuilt']), + duration_ms: ms(value.durationMs), + timings: numericFields(data, ['buildMs', 'connectMs', 'healthCheckMs']) }; + return null; + } + function diagnostics(stage) { + const path = join(state, 'sessions', session, 'requests', `probe-${stage}.ndjson`); + const result = { status: 'missing', malformed_lines: 0, capped: false, events: [] }; + if (!existsSync(path)) return result; + if (statSync(path).size > 8388608) return { ...result, status: 'size_limit', capped: true }; + result.status = 'read'; + const lines = readFileSync(path, 'utf8').split('\n'); + result.capped = lines.length > 10000; + for (const line of lines.slice(0, 10000)) { + if (!line) continue; + if (line.length > 131072) { result.malformed_lines++; continue; } + let event; + try { event = safeEvent(JSON.parse(line)); } + catch { result.malformed_lines++; continue; } + if (!event) continue; + if (result.events.length >= 128) { result.capped = true; break; } + result.events.push(event); + } + return result; + } + function safePrepare(value) { + return { action: enumValue(value?.action, ['ios-runner']), platform: enumValue(value?.platform, ['ios']), + kind: enumValue(value?.kind, ['simulator']), cache: enumValue(value?.cache, ['exact', 'miss', 'external']), + artifact: enumValue(value?.artifact, ['valid', 'rebuilt']), + timings: numericFields(value, ['durationMs', 'buildMs', 'connectMs', 'healthCheckMs']), + total_ms: ms(value?.timing?.totalMs), + additive_parts: numericFields(value?.timing?.additiveParts, ['buildMs', 'connectAfterBuildMs', 'healthCheckMs']) }; + } + function safeSnapshot(value) { + return { node_count: Array.isArray(value?.nodes) && value.nodes.length <= 1000000 ? value.nodes.length : null, + quality: enumValue(value?.snapshotQuality?.state, ['healthy', 'recovered', 'sparse'], + value?.snapshotQuality === undefined ? 'absent' : 'unknown'), + backend: enumValue(value?.snapshotQuality?.backend, ['tree', 'queries', 'private-ax', 'android-helper']), + reason_code: enumValue(value?.snapshotQuality?.reasonCode, ['ax-rejected', 'sparse-tree', 'budget', + 'no-nodes', 'capture-failed', 'presentation-failed', 'deferred', 'requested-backend']) }; + } + const blank = () => ({ status: 'not_run', duration_ms: null, error: null, result: null, diagnostics: null }); + const initial = () => ({ schema_version: 1, status: 'not_run', scope: 'sdk-availability-control', + source_sha: /^[a-f0-9]{40}$/.test(process.env.GITHUB_SHA ?? '') ? process.env.GITHUB_SHA : null, + sdk_version: '0.21.36', mobile_version: '0.12.4', + configuration: { runner: 'macos-26', device: 'iPhone 17', sdk_debug: true, + home_equals_state: true, session, mobile_wrapper_exercised: false, + state_environment: 'before-process-start', production_state_environment: 'after-mobile-static-import', + derived_override_set: false, prepare_timeout_override_set: false, snapshot_interactive_only: false }, + environment: { host_arch: enumValue(process.arch, ['arm64', 'x64']), xcode_version: null, + xcode_build: null, simulator_sdk_version: null, simulator_runtime_version: null }, + ...Object.fromEntries(stages.map(name => [name, blank()])), + cleanup: { daemon_stop: 'not_run', simulator_shutdown: 'not_run', simulator_delete: 'not_run', state_removed: false } }); + let report; + function save() { writeFileSync(reportPath, `${JSON.stringify(report, null, 2)}\n`, { mode: 0o600 }); } + function raw(command, args, quiet = false) { + const stdout = quiet ? openSync(join(privateRoot, 'commands.stdout'), 'a', 0o600) : 'pipe'; + try { + const result = spawnSync(command, args, { encoding: 'utf8', maxBuffer: 33554432, + stdio: ['ignore', stdout, 2] }); + if (result.error || result.status !== 0) throw { code: 'PROBE_COMMAND_FAILED' }; + return result.stdout ?? ''; + } finally { if (quiet) closeSync(stdout); } + } + function dependency() { + const mobile = createRequire(resolve('package.json')).resolve('@e2e-dev/mobile'); + const mobilePackage = JSON.parse(readFileSync(join(dirname(mobile), '..', 'package.json'), 'utf8')); + const path = findPackageJSON('agent-device', pathToFileURL(mobile)); + const manifest = JSON.parse(readFileSync(path, 'utf8')); + assert.equal(mobilePackage.version, '0.12.4'); + assert.equal(manifest.version, '0.21.36'); + return { entry: resolve(dirname(path), manifest.exports['.'].import), cli: resolve(dirname(path), manifest.bin['agent-device']) }; + } + function isolate() { + assert.equal(process.env.AGENT_DEVICE_HOME, home); + assert.equal(process.env.AGENT_DEVICE_STATE_DIR, state); + mkdirSync(state, { recursive: true, mode: 0o700 }); + } + async function stage(name, operation, project = () => null) { + const started = performance.now(); + report[name].status = 'running'; + save(); + try { + const value = await operation(); + report[name].result = project(value); + report[name].status = 'passed'; + return true; + } catch (error) { + report[name].status = 'failed'; + report[name].error = safeError(error); + return false; + } finally { + report[name].duration_ms = ms(performance.now() - started); + try { report[name].diagnostics = diagnostics(name); } + catch { report[name].diagnostics = { status: 'unreadable', malformed_lines: 0, capped: false, events: [] }; } + save(); + } + } + function selfCheck() { + const sentinel = 'PRIVATE_SENTINEL_/token/screen/argv'; + assert.equal(ms(Infinity), null); + assert.equal(ms(-1), null); + assert.equal(ms('42'), null); + assert.equal(ms(3600001), null); + assert.equal(safeEvent({ phase: sentinel }), null); + const event = safeEvent({ phase: 'prepare_apple_runner', durationMs: 4, message: sentinel, + data: { event: sentinel, timeoutMs: 240000, remainingMs: -1, error: sentinel, argv: [sentinel] } }); + assert.deepEqual(event, { phase: 'prepare_apple_runner', event: 'unknown', duration_ms: 4, + timeout_ms: 240000, remaining_ms: null }); + const error = safeError({ code: sentinel, message: sentinel, details: { reason: sentinel, + runnerErrorCode: sentinel, timeoutMs: 42, stderr: sentinel }, cause: { code: 'COMMAND_FAILED', + details: { reason: 'daemon_request_timeout' }, message: sentinel } }); + assert.equal(error.code, 'unknown'); + assert.equal(error.cause.reason, 'daemon_request_timeout'); + const prepared = safePrepare({ action: 'ios-runner', runner: { token: sentinel }, message: sentinel, + recoveryReason: sentinel, failureReason: sentinel, xctestrunPath: sentinel, durationMs: 8 }); + const snapshot = safeSnapshot({ nodes: [{ label: sentinel, text: sentinel }], + snapshotQuality: { state: 'healthy', backend: 'tree', reason: sentinel }, fallbackScreenshotPath: sentinel }); + assert.equal(snapshot.node_count, 1); + assert.equal(snapshot.quality, 'healthy'); + assert(!JSON.stringify({ event, error, prepared, snapshot }).includes(sentinel)); + } + const mode = process.argv[2]; + if (mode === 'self-check') { selfCheck(); process.exit(0); } + mkdirSync(privateRoot, { recursive: true, mode: 0o700 }); + if (mode === 'init') { report = initial(); save(); process.exit(0); } + report = JSON.parse(readFileSync(reportPath, 'utf8')); + isolate(); + if (mode === 'run') { + let client; + let simulator; + const setup = await stage('setup', async () => { + assert.equal(process.platform, 'darwin'); + assert.equal(process.arch, 'arm64'); + assert(!process.env.AGENT_DEVICE_IOS_RUNNER_DERIVED_PATH); + assert(!process.env.AGENT_DEVICE_IOS_CLEAN_DERIVED); + const xcode = raw('xcodebuild', ['-version']).trim().match(/^Xcode (\d{1,3}(?:\.\d{1,3}){1,2})\s+Build version ([0-9]{1,3}[A-Z][0-9]{1,6}[a-z]?)$/); + assert(xcode); + report.environment.xcode_version = xcode[1]; + report.environment.xcode_build = xcode[2]; + const sdk = raw('xcrun', ['--sdk', 'iphonesimulator', '--show-sdk-version']).trim(); + assert(/^\d{1,3}(?:\.\d{1,3}){1,2}$/.test(sdk)); + report.environment.simulator_sdk_version = sdk; + const runtimes = JSON.parse(raw('xcrun', ['simctl', 'list', 'runtimes', '--json'])).runtimes + .filter(row => row.isAvailable && row.identifier.includes('.SimRuntime.iOS-')); + assert(runtimes.length > 0); + assert(runtimes.every(row => /^\d{1,3}(?:\.\d{1,3}){1,2}$/.test(row.version))); + const order = (a, b) => { + const left = a.version.split('.').map(Number), right = b.version.split('.').map(Number); + for (let i = 0; i < 3; i++) if ((right[i] ?? 0) !== (left[i] ?? 0)) return (right[i] ?? 0) - (left[i] ?? 0); + return 0; + }; + const runtime = runtimes.sort(order)[0]; + report.environment.simulator_runtime_version = runtime.version; + const types = JSON.parse(raw('xcrun', ['simctl', 'list', 'devicetypes', '--json'])).devicetypes; + const type = types.find(row => row.name === 'iPhone 17' && row.productFamily === 'iPhone'); + assert(type); + const sdkPackage = dependency(); + const { createAgentDeviceClient } = await import(pathToFileURL(sdkPackage.entry).href); + client = createAgentDeviceClient({ session, debug: true }); + simulator = raw('xcrun', ['simctl', 'create', `ios-runner-probe-${process.pid}`, type.identifier, runtime.identifier]).trim(); + assert(/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(simulator)); + writeFileSync(simulatorPath, simulator, { mode: 0o600 }); + raw('xcrun', ['simctl', 'boot', simulator], true); + raw('xcrun', ['simctl', 'bootstatus', simulator, '-b'], true); + }); + const where = { platform: 'ios', udid: simulator }; + if (setup && await stage('prepare', () => client.command.prepare({ action: 'ios-runner', ...where, + requestId: 'probe-prepare' }), safePrepare)) { + if (await stage('open', () => client.apps.open({ app: 'com.apple.Preferences', relaunch: true, + ...where, requestId: 'probe-open' }))) { + await stage('system_snapshot', () => client.capture.snapshot({ interactiveOnly: false, + requestId: 'probe-system_snapshot' }), value => { + const result = safeSnapshot(value); + report.system_snapshot.result = result; + assert(result.node_count > 0 && result.quality !== 'sparse'); + return result; + }); + } + } + report.status = stages.every(name => report[name].status === 'passed') ? 'passed' : 'failed'; + save(); + process.exitCode = report.status === 'passed' ? 0 : 1; + } else if (mode === 'cleanup') { + if (existsSync(join(state, 'daemon.json'))) { + try { + raw(process.execPath, [dependency().cli, 'daemon', 'stop', '--clean'], true); + assert(!existsSync(join(state, 'daemon.json'))); + report.cleanup.daemon_stop = 'passed'; + } + catch { report.cleanup.daemon_stop = 'failed'; } + } else report.cleanup.daemon_stop = 'absent'; + if (existsSync(simulatorPath)) { + const simulator = readFileSync(simulatorPath, 'utf8').trim(); + assert(/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(simulator)); + for (const [command, key] of [['shutdown', 'simulator_shutdown'], ['delete', 'simulator_delete']]) { + try { raw('xcrun', ['simctl', command, simulator], true); report.cleanup[key] = 'passed'; } + catch { report.cleanup[key] = 'failed'; } + } + } else { + report.cleanup.simulator_shutdown = 'absent'; + report.cleanup.simulator_delete = 'absent'; + } + if (report.cleanup.daemon_stop !== 'failed' && report.cleanup.simulator_delete !== 'failed') { + rmSync(state, { recursive: true, force: true }); + report.cleanup.state_removed = !existsSync(state); + } + const clean = report.cleanup.daemon_stop !== 'failed' && report.cleanup.simulator_delete !== 'failed' + && report.cleanup.state_removed; + if (!clean || report.status !== 'passed') report.status = 'failed'; + save(); + process.exitCode = clean ? 0 : 1; + } else throw new Error('Unsupported probe operation'); + NODE + node .artifacts/ios-runner-probe/private/probe.mjs init > .artifacts/ios-runner-probe/private/init.stdout 2> .artifacts/ios-runner-probe/private/init.stderr + node .artifacts/ios-runner-probe/private/probe.mjs self-check > .artifacts/ios-runner-probe/private/self-check.stdout 2> .artifacts/ios-runner-probe/private/self-check.stderr + - name: Install the frozen root dependencies + shell: bash + run: | + umask 077 + pnpm install --frozen-lockfile --filter . > .artifacts/ios-runner-probe/private/install.stdout 2> .artifacts/ios-runner-probe/private/install.stderr + - name: Probe one cold runner and one Settings snapshot + shell: bash + run: | + umask 077 + node .artifacts/ios-runner-probe/private/probe.mjs run > .artifacts/ios-runner-probe/private/driver.stdout 2> .artifacts/ios-runner-probe/private/driver.stderr + - name: Clean up the probe resources + if: always() + shell: bash + run: | + umask 077 + if [ -f .artifacts/ios-runner-probe/private/probe.mjs ]; then + node .artifacts/ios-runner-probe/private/probe.mjs cleanup > .artifacts/ios-runner-probe/private/cleanup.stdout 2> .artifacts/ios-runner-probe/private/cleanup.stderr + fi + - name: Upload only the fixed diagnostic receipt + if: always() + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 + with: + name: ios-runner-probe-${{ github.sha }}-${{ github.run_attempt }} + path: .artifacts/ios-runner-probe/result.json + if-no-files-found: error + retention-days: 7 From 3a1490c7f38b0b359794836865b6cd962be34248 Mon Sep 17 00:00:00 2001 From: harryisfish Date: Sat, 7 Nov 2026 03:00:46 +0800 Subject: [PATCH 11/34] chore(ci): retain runner startup process diagnostics --- .github/workflows/mobile.yml | 114 ++++++++++++++++++++++++++++++++++- 1 file changed, 111 insertions(+), 3 deletions(-) diff --git a/.github/workflows/mobile.yml b/.github/workflows/mobile.yml index ad6cacada..c66eb06e6 100644 --- a/.github/workflows/mobile.yml +++ b/.github/workflows/mobile.yml @@ -537,8 +537,19 @@ jobs: 'runner_readiness_preflight_failed', 'runner_cache_uncertifiable', 'runner_process_dead', 'runner_reported_failure', 'xcodebuild_exited_early', 'simulator_service_hub_unavailable', 'simulator_set_destination_not_found', 'build_failed_unclassified', + 'IOS_RUNNER_CONNECT_TIMEOUT', 'IOS_RUNNER_DEVICE_NOT_PROVISIONED', 'BOOT_COMMAND_FAILED', 'startup-exited', 'startup-stalled', 'startup-ceiling']; + const execEvents = ['spawn_start', 'spawn', 'deadline', 'abort', 'error', 'exit', 'close', 'settled']; + const signals = ['SIGTERM', 'SIGKILL', 'SIGABRT', 'SIGSEGV', 'SIGBUS', 'SIGILL', + 'SIGTRAP', 'SIGHUP', 'SIGINT', 'SIGQUIT', 'SIGPIPE']; + const startupReasons = ['bundle_identifier_already_registered', 'signing_no_development_team', + 'signing_provisioning_profile_missing', 'signing_unspecified', 'devtools_security_developer_mode_disabled', + 'device_developer_mode_disabled', 'device_developer_disk_image_unavailable', 'build_failed_unclassified', + 'simulator_service_hub_unavailable', 'simulator_set_destination_not_found']; const enumValue = (value, allowed, fallback = 'unknown') => allowed.includes(value) ? value : fallback; + const exitCode = value => value === undefined ? 'missing' : value === null ? null + : Number.isInteger(value) && value >= 0 && value <= 255 ? value : 'unknown'; + const signal = value => value === undefined ? 'missing' : value === null ? null : enumValue(value, signals); const ms = value => typeof value === 'number' && Number.isFinite(value) && value >= 0 && value <= 3600000 ? Math.round(value) : null; const numericFields = (value, keys) => Object.fromEntries(keys.map(key => [key, ms(value?.[key])])); @@ -549,6 +560,7 @@ jobs: runner_error_code: enumValue(error?.details?.runnerErrorCode, ['RUNNER_BUSY', 'MAIN_THREAD_TIMEOUT', 'RUNNER_WEDGED', 'COMMAND_ALREADY_FINISHED', 'IOS_AX_SNAPSHOT_FAILED']), runner_connect_failure_reason: enumValue(error?.details?.runnerConnectFailureReason, reasons), + xcodebuild_exit_code: exitCode(error?.details?.xcodebuild?.exitCode), runner_phase: enumValue(error?.details?.phase, ['runner_session', 'runner_rebuild', 'runner_health']), startup_kind: enumValue(error?.details?.kind, ['daemon_startup_failed']), timeout_ms: ms(error?.details?.timeoutMs), @@ -557,9 +569,19 @@ jobs: && error.details.startupAttempts >= 0 && error.details.startupAttempts <= 2 ? error.details.startupAttempts : null, cause: depth < 2 && error?.cause ? safeError(error.cause, depth + 1) : null, }); - function safeEvent(value) { + function safeEvent(value, execIds) { const phase = value?.phase; const data = value?.data; + if (phase === 'exec_command' && data?.command === 'xcodebuild' && execEvents.includes(data.event)) { + const id = data.execId; + if (typeof id === 'string' && /^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(id) + && !execIds.has(id) && execIds.size < 128) execIds.set(id, execIds.size + 1); + return { phase, command: 'xcodebuild', event: data.event, exec_index: execIds.get(id) ?? null, + duration_ms: ms(value.durationMs), timeout_ms: ms(data.timeoutMs), + exit_code: exitCode(data.exitCode), signal: signal(data.signal), + settlement_reason: enumValue(data.reason, ['success', 'exit_failure', 'timeout', 'abort', 'spawn_error', 'stdin_error'], + data.reason === undefined ? 'missing' : 'unknown') }; + } if (phase === 'prepare_apple_runner') return { phase, event: enumValue(data?.event, ['readiness_start', 'runner_start', 'settled']), duration_ms: ms(value.durationMs), timeout_ms: ms(data?.timeoutMs), remaining_ms: ms(data?.remainingMs) }; @@ -584,12 +606,13 @@ jobs: if (statSync(path).size > 8388608) return { ...result, status: 'size_limit', capped: true }; result.status = 'read'; const lines = readFileSync(path, 'utf8').split('\n'); + const execIds = new Map(); result.capped = lines.length > 10000; for (const line of lines.slice(0, 10000)) { if (!line) continue; if (line.length > 131072) { result.malformed_lines++; continue; } let event; - try { event = safeEvent(JSON.parse(line)); } + try { event = safeEvent(JSON.parse(line), execIds); } catch { result.malformed_lines++; continue; } if (!event) continue; if (result.events.length >= 128) { result.capped = true; break; } @@ -650,6 +673,27 @@ jobs: assert.equal(process.env.AGENT_DEVICE_STATE_DIR, state); mkdirSync(state, { recursive: true, mode: 0o700 }); } + function startupProjection(error, AppError, classify) { + const stderr = error?.details?.xcodebuild?.stderr; + if (typeof stderr !== 'string') return { reason: 'unavailable', matched: null }; + const details = { stderr }; + for (const key of ['simulatorSetPath', 'simulatorUdid', 'xcodeVersion']) { + if (typeof error.details[key] === 'string') details[key] = error.details[key]; + } + const result = classify(new AppError('COMMAND_FAILED', 'Runner did not accept connection (xcodebuild exited early)', details)); + return { reason: enumValue(result?.reason, startupReasons), + matched: typeof result?.matched === 'boolean' ? result.matched : null }; + } + async function startupClassification(error) { + if (typeof error?.details?.xcodebuild?.stderr !== 'string') return { reason: 'unavailable', matched: null }; + try { + const sdk = dependency(); + const { AppError } = await import(pathToFileURL(sdk.entry).href); + const { r: classify } = await import(pathToFileURL(join(dirname(sdk.entry), 'runner-error-classification.js')).href); + assert.equal(typeof classify, 'function'); + return startupProjection(error, AppError, classify); + } catch { return { reason: 'unavailable', matched: null }; } + } async function stage(name, operation, project = () => null) { const started = performance.now(); report[name].status = 'running'; @@ -662,6 +706,7 @@ jobs: } catch (error) { report[name].status = 'failed'; report[name].error = safeError(error); + report[name].error.startup_classification = await startupClassification(error); return false; } finally { report[name].duration_ms = ms(performance.now() - started); @@ -692,7 +737,70 @@ jobs: snapshotQuality: { state: 'healthy', backend: 'tree', reason: sentinel }, fallbackScreenshotPath: sentinel }); assert.equal(snapshot.node_count, 1); assert.equal(snapshot.quality, 'healthy'); - assert(!JSON.stringify({ event, error, prepared, snapshot }).includes(sentinel)); + for (const reason of ['IOS_RUNNER_CONNECT_TIMEOUT', 'IOS_RUNNER_DEVICE_NOT_PROVISIONED', 'BOOT_COMMAND_FAILED']) { + assert.equal(safeError({ details: { reason } }).reason, reason); + } + for (const code of [0, 1, 65, 70, 255]) { + assert.equal(safeError({ details: { xcodebuild: { exitCode: code } } }).xcodebuild_exit_code, code); + } + for (const code of [-1, 256, 1.5, Infinity, NaN, '65', sentinel]) assert.equal(exitCode(code), 'unknown'); + assert.equal(exitCode(undefined), 'missing'); + assert.equal(exitCode(null), null); + assert.equal(signal(undefined), 'missing'); + assert.equal(signal(null), null); + assert.equal(signal(sentinel), 'unknown'); + for (const name of signals) assert.equal(signal(name), name); + const execIds = new Map(); + const fixtureExecId = index => `00000000-0000-4000-8000-${index.toString(16).padStart(12, '0')}`; + const id = fixtureExecId(1); + const exec = (event, data = {}) => safeEvent({ phase: 'exec_command', durationMs: 7, + data: { command: 'xcodebuild', execId: id, event, args: [sentinel], stderr: sentinel, ...data } }, execIds); + for (const name of execEvents) assert.equal(exec(name).event, name); + const started = exec('spawn_start'); + assert.equal(started.exec_index, 1); + assert(!JSON.stringify(started).includes(id)); + assert.equal(started.exit_code, 'missing'); + assert.equal(started.signal, 'missing'); + const killed = exec('exit', { exitCode: null, signal: 'SIGKILL' }); + const closed = exec('close', { exitCode: null, signal: 'SIGKILL' }); + assert.equal(killed.exit_code, null); + assert.equal(killed.signal, 'SIGKILL'); + assert.equal(closed.exec_index, killed.exec_index); + const finished = exec('settled', { exitCode: 1, signal: null, reason: 'success', + execId: fixtureExecId(2) }); + assert.equal(finished.exec_index, 2); + assert.equal(finished.exit_code, 1); + assert.equal(finished.signal, null); + assert.equal(finished.settlement_reason, 'success'); + assert.equal(exec('exit', { signal: sentinel }).signal, 'unknown'); + assert.equal(exec(sentinel), null); + assert.equal(exec('exit', { command: 'swift' }), null); + assert.equal(exec('exit', { command: '/usr/bin/xcodebuild' }), null); + assert.equal(exec('exit', { execId: sentinel }).exec_index, null); + const groups = new Map(); + for (let i = 1; i <= 129; i++) { + const projected = safeEvent({ phase: 'exec_command', data: { command: 'xcodebuild', event: 'spawn', + execId: fixtureExecId(i) } }, groups); + assert.equal(projected.exec_index, i <= 128 ? i : null); + } + assert.equal(groups.size, 128); + class FixtureError extends Error { + constructor(code, message, details) { super(message); this.code = code; this.details = details; } + } + let adapted; + const classified = startupProjection({ message: sentinel, details: { xcodebuild: { stderr: sentinel }, + simulatorUdid: 'fixture-udid', simulatorSetPath: null, xcodeVersion: 26 } }, FixtureError, value => { + adapted = value; + return { reason: 'signing_no_development_team', matched: true, hint: sentinel, messageSuffix: sentinel }; + }); + assert.deepEqual(classified, { reason: 'signing_no_development_team', matched: true }); + assert.equal(adapted.message, 'Runner did not accept connection (xcodebuild exited early)'); + assert.deepEqual(adapted.details, { stderr: sentinel, simulatorUdid: 'fixture-udid' }); + assert.deepEqual(startupProjection({}, FixtureError, () => { throw new Error(); }), + { reason: 'unavailable', matched: null }); + assert.deepEqual(startupProjection({ details: { xcodebuild: { stderr: '' } } }, FixtureError, + () => ({ reason: sentinel, matched: sentinel })), { reason: 'unknown', matched: null }); + assert(!JSON.stringify({ event, error, prepared, snapshot, started, killed, closed, finished, classified }).includes(sentinel)); } const mode = process.argv[2]; if (mode === 'self-check') { selfCheck(); process.exit(0); } From 493350e140e824ce6958407716b06db211e01500 Mon Sep 17 00:00:00 2001 From: harryisfish Date: Sat, 7 Nov 2026 03:32:52 +0800 Subject: [PATCH 12/34] chore(ci): capture encrypted runner startup evidence --- .github/workflows/mobile.yml | 83 +++++++++++++++++++++++++++++++++++- 1 file changed, 82 insertions(+), 1 deletion(-) diff --git a/.github/workflows/mobile.yml b/.github/workflows/mobile.yml index c66eb06e6..fb4e560d4 100644 --- a/.github/workflows/mobile.yml +++ b/.github/workflows/mobile.yml @@ -509,7 +509,8 @@ jobs: cat > .artifacts/ios-runner-probe/private/probe.mjs <<'NODE' import assert from 'node:assert/strict'; import { spawnSync } from 'node:child_process'; - import { closeSync, existsSync, mkdirSync, openSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs'; + import { constants as fsConstants, closeSync, existsSync, fstatSync, lstatSync, mkdirSync, openSync, readFileSync, readSync, realpathSync, rmSync, statSync, writeFileSync } from 'node:fs'; + import { constants as cryptoConstants, createCipheriv, createHash, createPublicKey, publicEncrypt, randomBytes } from 'node:crypto'; import { createRequire, findPackageJSON } from 'node:module'; import { dirname, join, resolve } from 'node:path'; import { pathToFileURL } from 'node:url'; @@ -546,6 +547,10 @@ jobs: 'signing_provisioning_profile_missing', 'signing_unspecified', 'devtools_security_developer_mode_disabled', 'device_developer_mode_disabled', 'device_developer_disk_image_unavailable', 'build_failed_unclassified', 'simulator_service_hub_unavailable', 'simulator_set_destination_not_found']; + const runnerLogScope = 'fresh-task-session-runner-log'; + const runnerLogAAD = 'vibeface-ci472-runner-log-v1'; + const runnerLogKeyId = 'beb7dc7bf91c12efe172c9b82e89758b630439162509345ca1fdb2f3b0decccc'; + const runnerLogPublicKey = "-----BEGIN PUBLIC KEY-----\nMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAjTrGa8sXLaT5MeAJhIkI\ngqEMu+QNunCFHLV/z5bx/q+V9981uJi/hjg59hhaef5anN+JRBhqgzdGBDkkmmI+\nn8RZMQPGozzI/1dlfBnbeYX6DK19WntVr8J8df9uGuPOwqZ8Mp0jVa1oW+fLpdwS\nIIpzrmFXY+6JKZ1R+oeDzasxATSciBCZkOJxCk+CEQAL6A77Qyp6VEmKCdWs3zZ9\ndKaFeU4ERMVTdeAfhL9bIieaTW6a1kkJaQGe4iK5PQhyV2yZ27VSoappspH4wvQA\nNBkavdtpasbJ45+Wuzv6XwWvQf03+Yhcon6PUGF/M5Z1bUhyleluBgIpDoAxcij3\nttKYv19h9QzjKR6lgPRUBjMUMvjoB2msOsQzNvyTjM4TVeLNETYsP66TNLfA0Ifz\nOSuoSBCijOU80rWjG/22uVccADNhUN+s1kqRXeTwmFpfyEH2z6DYAICMfHshmf1T\nTIdzu6zWTKdDKgroJwUW5hZFaWiPHdQjgUiLc0hoyapFAgMBAAE=\n-----END PUBLIC KEY-----\n"; const enumValue = (value, allowed, fallback = 'unknown') => allowed.includes(value) ? value : fallback; const exitCode = value => value === undefined ? 'missing' : value === null ? null : Number.isInteger(value) && value >= 0 && value <= 255 ? value : 'unknown'; @@ -694,6 +699,68 @@ jobs: return startupProjection(error, AppError, classify); } catch { return { reason: 'unavailable', matched: null }; } } + function sealRunnerLog(bytes, recipient) { + const key = randomBytes(32), iv = randomBytes(12); + try { + const cipher = createCipheriv('aes-256-gcm', key, iv, { authTagLength: 16 }); + cipher.setAAD(Buffer.from(runnerLogAAD)); + const ciphertext = Buffer.concat([cipher.update(bytes), cipher.final()]); + return { algorithm: 'RSA-OAEP-SHA256+A256GCM', + key_id: createHash('sha256').update(recipient.export({ type: 'spki', format: 'der' })).digest('hex'), + iv: iv.toString('base64'), tag: cipher.getAuthTag().toString('base64'), + wrapped_key: publicEncrypt({ key: recipient, padding: cryptoConstants.RSA_PKCS1_OAEP_PADDING, + oaepHash: 'sha256' }, key).toString('base64'), ciphertext: ciphertext.toString('base64') }; + } finally { key.fill(0); } + } + function captureRunnerLog(error) { + const result = { scope: runnerLogScope, status: 'unavailable', reason: 'path-mismatch', + source_bytes: null, captured_bytes: 0, offset: null, capped: null, source_changed: null }; + const expected = join(state, 'sessions', session, 'runner.log'); + if (error?.details?.logPath !== expected || expected.toLowerCase().includes('trash')) return result; + let fd, bytes; + try { + result.reason = 'ownership-unproven'; + const uid = process.getuid(); + for (const directory of [root, privateRoot, state, join(state, 'sessions'), dirname(expected)]) { + const entry = lstatSync(directory); + assert(entry.isDirectory() && !entry.isSymbolicLink() && entry.uid === uid); + } + const before = lstatSync(expected); + assert(before.isFile() && !before.isSymbolicLink() && before.uid === uid); + assert.equal(realpathSync(expected), join(realpathSync(state), 'sessions', session, 'runner.log')); + assert(Number.isInteger(fsConstants.O_NOFOLLOW)); + fd = openSync(expected, fsConstants.O_RDONLY | fsConstants.O_NOFOLLOW); + const opened = fstatSync(fd); + assert(opened.isFile() && opened.uid === uid && opened.dev === before.dev && opened.ino === before.ino); + assert(Number.isSafeInteger(opened.size) && opened.size >= 0); + result.source_bytes = opened.size; + result.offset = Math.max(0, opened.size - 262144); + result.capped = opened.size > 262144; + if (opened.size === 0) return { ...result, status: 'empty', reason: null, source_changed: false }; + result.reason = 'read-failed'; + bytes = Buffer.alloc(Math.min(opened.size, 262144)); + let count = 0; + while (count < bytes.length) { + const size = readSync(fd, bytes, count, bytes.length - count, result.offset + count); + if (size === 0) break; + count += size; + } + result.captured_bytes = count; + assert.equal(count, bytes.length); + result.source_changed = fstatSync(fd).size !== opened.size; + result.reason = 'encryption-failed'; + const recipient = createPublicKey(runnerLogPublicKey); + assert.equal(recipient.asymmetricKeyType, 'rsa'); + assert.equal(recipient.asymmetricKeyDetails.modulusLength, 3072); + const envelope = sealRunnerLog(bytes, recipient); + assert.equal(envelope.key_id, runnerLogKeyId); + return { ...result, ...envelope, status: 'encrypted', reason: null }; + } catch { return result; } + finally { + if (fd !== undefined) { try { closeSync(fd); } catch {} } + bytes?.fill(0); + } + } async function stage(name, operation, project = () => null) { const started = performance.now(); report[name].status = 'running'; @@ -707,6 +774,7 @@ jobs: report[name].status = 'failed'; report[name].error = safeError(error); report[name].error.startup_classification = await startupClassification(error); + if (name === 'prepare') report[name].error.encrypted_runner_log = captureRunnerLog(error); return false; } finally { report[name].duration_ms = ms(performance.now() - started); @@ -801,6 +869,19 @@ jobs: assert.deepEqual(startupProjection({ details: { xcodebuild: { stderr: '' } } }, FixtureError, () => ({ reason: sentinel, matched: sentinel })), { reason: 'unknown', matched: null }); assert(!JSON.stringify({ event, error, prepared, snapshot, started, killed, closed, finished, classified }).includes(sentinel)); + const recipient = createPublicKey(runnerLogPublicKey); + assert.equal(recipient.asymmetricKeyType, 'rsa'); + assert.equal(recipient.asymmetricKeyDetails.modulusLength, 3072); + const encrypted = sealRunnerLog(Buffer.from(sentinel), recipient); + assert.equal(encrypted.key_id, runnerLogKeyId); + assert.equal(Buffer.from(encrypted.iv, 'base64').length, 12); + assert.equal(Buffer.from(encrypted.tag, 'base64').length, 16); + assert.equal(Buffer.from(encrypted.wrapped_key, 'base64').length, 384); + assert.equal(Buffer.from(encrypted.ciphertext, 'base64').length, Buffer.byteLength(sentinel)); + assert(!JSON.stringify(encrypted).includes(sentinel)); + assert.deepEqual(captureRunnerLog({ details: { logPath: 'not-the-task-log' } }), + { scope: runnerLogScope, status: 'unavailable', reason: 'path-mismatch', + source_bytes: null, captured_bytes: 0, offset: null, capped: null, source_changed: null }); } const mode = process.argv[2]; if (mode === 'self-check') { selfCheck(); process.exit(0); } From 1d1800d2963ffba80d375b1782218f558c3710e3 Mon Sep 17 00:00:00 2001 From: harryisfish Date: Sat, 7 Nov 2026 03:48:34 +0800 Subject: [PATCH 13/34] chore(ci): capture owned runner evidence on prepare failures --- .github/workflows/mobile.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/mobile.yml b/.github/workflows/mobile.yml index fb4e560d4..9f5cf0c83 100644 --- a/.github/workflows/mobile.yml +++ b/.github/workflows/mobile.yml @@ -712,11 +712,11 @@ jobs: oaepHash: 'sha256' }, key).toString('base64'), ciphertext: ciphertext.toString('base64') }; } finally { key.fill(0); } } - function captureRunnerLog(error) { - const result = { scope: runnerLogScope, status: 'unavailable', reason: 'path-mismatch', + function captureRunnerLog() { + const result = { scope: runnerLogScope, status: 'unavailable', reason: 'ownership-unproven', source_bytes: null, captured_bytes: 0, offset: null, capped: null, source_changed: null }; const expected = join(state, 'sessions', session, 'runner.log'); - if (error?.details?.logPath !== expected || expected.toLowerCase().includes('trash')) return result; + if (expected.toLowerCase().includes('trash')) return result; let fd, bytes; try { result.reason = 'ownership-unproven'; @@ -774,7 +774,7 @@ jobs: report[name].status = 'failed'; report[name].error = safeError(error); report[name].error.startup_classification = await startupClassification(error); - if (name === 'prepare') report[name].error.encrypted_runner_log = captureRunnerLog(error); + if (name === 'prepare') report[name].error.encrypted_runner_log = captureRunnerLog(); return false; } finally { report[name].duration_ms = ms(performance.now() - started); @@ -879,9 +879,6 @@ jobs: assert.equal(Buffer.from(encrypted.wrapped_key, 'base64').length, 384); assert.equal(Buffer.from(encrypted.ciphertext, 'base64').length, Buffer.byteLength(sentinel)); assert(!JSON.stringify(encrypted).includes(sentinel)); - assert.deepEqual(captureRunnerLog({ details: { logPath: 'not-the-task-log' } }), - { scope: runnerLogScope, status: 'unavailable', reason: 'path-mismatch', - source_bytes: null, captured_bytes: 0, offset: null, capped: null, source_changed: null }); } const mode = process.argv[2]; if (mode === 'self-check') { selfCheck(); process.exit(0); } From b08778f6b43e2ac53a50cfcdb38da4359f72d87d Mon Sep 17 00:00:00 2001 From: harryisfish Date: Sat, 7 Nov 2026 13:57:24 +0800 Subject: [PATCH 14/34] chore(ci): isolate runner derived data for diagnosis --- .github/workflows/mobile.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mobile.yml b/.github/workflows/mobile.yml index 9f5cf0c83..a6360511e 100644 --- a/.github/workflows/mobile.yml +++ b/.github/workflows/mobile.yml @@ -489,6 +489,7 @@ jobs: env: AGENT_DEVICE_HOME: ${{ github.workspace }}/.artifacts/ios-runner-probe/private/agent-device AGENT_DEVICE_STATE_DIR: ${{ github.workspace }}/.artifacts/ios-runner-probe/private/agent-device + AGENT_DEVICE_IOS_RUNNER_DERIVED_PATH: ${{ github.workspace }}/.artifacts/ios-runner-probe/private/agent-device/.tmp/runner-derived steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 with: @@ -648,7 +649,7 @@ jobs: configuration: { runner: 'macos-26', device: 'iPhone 17', sdk_debug: true, home_equals_state: true, session, mobile_wrapper_exercised: false, state_environment: 'before-process-start', production_state_environment: 'after-mobile-static-import', - derived_override_set: false, prepare_timeout_override_set: false, snapshot_interactive_only: false }, + derived_override_set: true, prepare_timeout_override_set: false, snapshot_interactive_only: false }, environment: { host_arch: enumValue(process.arch, ['arm64', 'x64']), xcode_version: null, xcode_build: null, simulator_sdk_version: null, simulator_runtime_version: null }, ...Object.fromEntries(stages.map(name => [name, blank()])), @@ -892,7 +893,7 @@ jobs: const setup = await stage('setup', async () => { assert.equal(process.platform, 'darwin'); assert.equal(process.arch, 'arm64'); - assert(!process.env.AGENT_DEVICE_IOS_RUNNER_DERIVED_PATH); + assert.equal(process.env.AGENT_DEVICE_IOS_RUNNER_DERIVED_PATH, join(state, '.tmp', 'runner-derived')); assert(!process.env.AGENT_DEVICE_IOS_CLEAN_DERIVED); const xcode = raw('xcodebuild', ['-version']).trim().match(/^Xcode (\d{1,3}(?:\.\d{1,3}){1,2})\s+Build version ([0-9]{1,3}[A-Z][0-9]{1,6}[a-z]?)$/); assert(xcode); From 4c67d3d9ab3a0e4b12459102dc20a6462f82e216 Mon Sep 17 00:00:00 2001 From: harryisfish Date: Sat, 7 Nov 2026 14:38:33 +0800 Subject: [PATCH 15/34] chore(ci): capture encrypted runner context after prepare failures --- .github/workflows/mobile.yml | 187 +++++++++++++++++++++++++++++++++-- 1 file changed, 181 insertions(+), 6 deletions(-) diff --git a/.github/workflows/mobile.yml b/.github/workflows/mobile.yml index a6360511e..4875f2b76 100644 --- a/.github/workflows/mobile.yml +++ b/.github/workflows/mobile.yml @@ -510,10 +510,10 @@ jobs: cat > .artifacts/ios-runner-probe/private/probe.mjs <<'NODE' import assert from 'node:assert/strict'; import { spawnSync } from 'node:child_process'; - import { constants as fsConstants, closeSync, existsSync, fstatSync, lstatSync, mkdirSync, openSync, readFileSync, readSync, realpathSync, rmSync, statSync, writeFileSync } from 'node:fs'; + import { constants as fsConstants, closeSync, existsSync, fstatSync, lstatSync, mkdirSync, openSync, opendirSync, readFileSync, readSync, realpathSync, rmSync, statSync, writeFileSync } from 'node:fs'; import { constants as cryptoConstants, createCipheriv, createHash, createPublicKey, publicEncrypt, randomBytes } from 'node:crypto'; import { createRequire, findPackageJSON } from 'node:module'; - import { dirname, join, resolve } from 'node:path'; + import { basename, dirname, isAbsolute, join, relative, resolve } from 'node:path'; import { pathToFileURL } from 'node:url'; process.umask(0o077); @@ -550,6 +550,7 @@ jobs: 'simulator_service_hub_unavailable', 'simulator_set_destination_not_found']; const runnerLogScope = 'fresh-task-session-runner-log'; const runnerLogAAD = 'vibeface-ci472-runner-log-v1'; + const runnerContextAAD = 'vibeface-ci472-runner-context-v1'; const runnerLogKeyId = 'beb7dc7bf91c12efe172c9b82e89758b630439162509345ca1fdb2f3b0decccc'; const runnerLogPublicKey = "-----BEGIN PUBLIC KEY-----\nMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAjTrGa8sXLaT5MeAJhIkI\ngqEMu+QNunCFHLV/z5bx/q+V9981uJi/hjg59hhaef5anN+JRBhqgzdGBDkkmmI+\nn8RZMQPGozzI/1dlfBnbeYX6DK19WntVr8J8df9uGuPOwqZ8Mp0jVa1oW+fLpdwS\nIIpzrmFXY+6JKZ1R+oeDzasxATSciBCZkOJxCk+CEQAL6A77Qyp6VEmKCdWs3zZ9\ndKaFeU4ERMVTdeAfhL9bIieaTW6a1kkJaQGe4iK5PQhyV2yZ27VSoappspH4wvQA\nNBkavdtpasbJ45+Wuzv6XwWvQf03+Yhcon6PUGF/M5Z1bUhyleluBgIpDoAxcij3\nttKYv19h9QzjKR6lgPRUBjMUMvjoB2msOsQzNvyTjM4TVeLNETYsP66TNLfA0Ifz\nOSuoSBCijOU80rWjG/22uVccADNhUN+s1kqRXeTwmFpfyEH2z6DYAICMfHshmf1T\nTIdzu6zWTKdDKgroJwUW5hZFaWiPHdQjgUiLc0hoyapFAgMBAAE=\n-----END PUBLIC KEY-----\n"; const enumValue = (value, allowed, fallback = 'unknown') => allowed.includes(value) ? value : fallback; @@ -700,11 +701,11 @@ jobs: return startupProjection(error, AppError, classify); } catch { return { reason: 'unavailable', matched: null }; } } - function sealRunnerLog(bytes, recipient) { + function sealEvidence(bytes, recipient, aad) { const key = randomBytes(32), iv = randomBytes(12); try { const cipher = createCipheriv('aes-256-gcm', key, iv, { authTagLength: 16 }); - cipher.setAAD(Buffer.from(runnerLogAAD)); + cipher.setAAD(Buffer.from(aad)); const ciphertext = Buffer.concat([cipher.update(bytes), cipher.final()]); return { algorithm: 'RSA-OAEP-SHA256+A256GCM', key_id: createHash('sha256').update(recipient.export({ type: 'spki', format: 'der' })).digest('hex'), @@ -753,7 +754,7 @@ jobs: const recipient = createPublicKey(runnerLogPublicKey); assert.equal(recipient.asymmetricKeyType, 'rsa'); assert.equal(recipient.asymmetricKeyDetails.modulusLength, 3072); - const envelope = sealRunnerLog(bytes, recipient); + const envelope = sealEvidence(bytes, recipient, runnerLogAAD); assert.equal(envelope.key_id, runnerLogKeyId); return { ...result, ...envelope, status: 'encrypted', reason: null }; } catch { return result; } @@ -762,6 +763,167 @@ jobs: bytes?.fill(0); } } + function openContextEntry(path, anchor, directory) { + assert(!path.toLowerCase().includes('trash')); + const before = lstatSync(path); + assert(!before.isSymbolicLink() && before.uid === process.getuid()); + assert(directory ? before.isDirectory() : before.isFile()); + const location = realpathSync(path), base = realpathSync(anchor), inside = relative(base, location); + assert(inside === '' || (!inside.startsWith('..') && !isAbsolute(inside))); + const fd = openSync(path, fsConstants.O_RDONLY | fsConstants.O_NOFOLLOW); + try { + const opened = fstatSync(fd); + assert(opened.uid === before.uid && opened.dev === before.dev && opened.ino === before.ino); + assert(directory ? opened.isDirectory() : opened.isFile()); + return { fd, stat: opened, real: location }; + } catch (error) { closeSync(fd); throw error; } + } + function contextBytes(path, anchor, maximum) { + const opened = openContextEntry(path, anchor, false); + try { + assert(Number.isSafeInteger(opened.stat.size) && opened.stat.size >= 0 && opened.stat.size <= maximum); + const bytes = Buffer.alloc(opened.stat.size); + let count = 0; + while (count < bytes.length) { + const size = readSync(opened.fd, bytes, count, bytes.length - count, count); + assert(size > 0); count += size; + } + assert.equal(fstatSync(opened.fd).size, opened.stat.size); + return bytes; + } finally { closeSync(opened.fd); } + } + function contextDeviceView(kind, bytes, requested) { + if (typeof requested !== 'string') return null; + try { + let text = new TextDecoder('utf-8', { fatal: true }).decode(bytes); + const warning = 'WARNING: xcdevice is deprecated. Please use `devicectl list devices` instead.'; + if (kind === 'xcdevice' && text.startsWith(warning + '\r\n')) text = text.slice(warning.length + 2); + else if (kind === 'xcdevice' && text.startsWith(warning + '\n')) text = text.slice(warning.length + 1); + const parsed = JSON.parse(text), matches = [], counts = new Map(); + let total = 0; + const row = (value, id, platform, runtime) => { + assert(value && typeof value === 'object' && !Array.isArray(value) && typeof id === 'string'); + total++; + const name = typeof platform === 'string' && platform.length <= 128 && (counts.has(platform) || counts.size < 32) ? platform : 'other'; + counts.set(name, (counts.get(name) ?? 0) + 1); + if (id.toLowerCase() === requested.toLowerCase()) matches.push(runtime === undefined ? value : { runtime, device: value }); + }; + if (kind === 'simctl') { + assert(parsed && typeof parsed === 'object' && !Array.isArray(parsed) && parsed.devices && typeof parsed.devices === 'object' && !Array.isArray(parsed.devices)); + for (const [runtime, devices] of Object.entries(parsed.devices)) { + assert(Array.isArray(devices)); + const platform = runtime.includes('.SimRuntime.') ? runtime.split('.SimRuntime.')[1].split('-')[0] : 'other'; + for (const device of devices) row(device, device?.udid, platform, runtime); + } + } else { + assert(kind === 'xcdevice' && Array.isArray(parsed)); + for (const device of parsed) row(device, device?.identifier, device?.platform); + } + return { interpretation: 'tool-view-only', total_count: total, platform_counts: Object.fromEntries(counts), requested_match_count: matches.length, requested_rows: matches }; + } catch { return null; } + } + function captureRunnerContext(run = spawnSync, seal = sealEvidence) { + const started = performance.now(), limits = { entries: 512, files: 16, file_bytes: 65536, depth: 8, + payload_bytes: 262144, command_timeout_ms: 30000, command_max_buffer: 262144 }; + const result = { scope: 'fresh-task-session-runner-context', payload_format: runnerContextAAD, + status: 'unavailable', reason: 'collection-failed', partial: false, entry_count: 0, file_count: 0, + payload_bytes: 0, collection_duration_ms: null, limits }; + const derived = join(state, '.tmp', 'runner-derived'), products = join(derived, 'Build', 'Products'); + const context = { payload_format: runnerContextAAD, requested_udid: null, requested_udid_status: 'unavailable', + environment: {}, derived_path: derived, inventory: { status: 'unavailable', entries: [], files: [] }, commands: [] }; + const fits = () => Buffer.byteLength(JSON.stringify(context)) <= limits.payload_bytes - 1024; + const append = (array, value) => { array.push(value); if (fits()) return true; array.pop(); result.partial = true; return false; }; + const stream = (command, key, bytes) => { + const output = { source_bytes: bytes.length, captured_bytes: 0, capped: false, bytes_base64: '' }; + command[key] = output; + let low = 0, high = bytes.length; + while (low < high) { + const size = Math.ceil((low + high) / 2); output.bytes_base64 = bytes.subarray(0, size).toString('base64'); + if (fits()) low = size; else high = size - 1; + } + output.bytes_base64 = bytes.subarray(0, low).toString('base64'); output.captured_bytes = low; output.capped = low < bytes.length; + if (output.capped) result.partial = true; + }; + try { + for (const directory of [root, privateRoot, state]) { const opened = openContextEntry(directory, root, true); closeSync(opened.fd); } + try { + const bytes = contextBytes(simulatorPath, privateRoot, 128), value = bytes.toString('utf8').trim(); bytes.fill(0); + assert(/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(value)); + context.requested_udid = value; context.requested_udid_status = 'captured'; + } catch { result.partial = true; } + for (const key of ['HOME', 'CFFIXED_USER_HOME', 'SIMULATOR_DEVICE_SET_PATH', 'CORE_SIMULATOR_DEVICE_SET_PATH', 'DEVELOPER_DIR', 'SDKROOT', 'AGENT_DEVICE_IOS_RUNNER_DERIVED_PATH']) { + const value = process.env[key]; + context.environment[key] = typeof value === 'string' && Buffer.byteLength(value) <= 8192 ? value : null; + if (typeof value === 'string' && Buffer.byteLength(value) > 8192) result.partial = true; + if (!fits()) { context.environment[key] = null; result.partial = true; } + } + for (const [kind, args] of [['simctl', ['simctl', 'list', 'devices', '--json']], ['xcdevice', ['xcdevice', 'list', '--timeout=10']]]) { + const command = { kind, status: 'unknown', exit_code: 'missing', signal: 'missing', duration_ms: null, view_status: 'unknown', view: null, stdout: null, stderr: null }; + context.commands.push(command); const at = performance.now(); + try { + const completed = run('xcrun', args, { timeout: limits.command_timeout_ms, maxBuffer: limits.command_max_buffer, + killSignal: 'SIGKILL', encoding: null, stdio: ['ignore', 'pipe', 'pipe'] }); + command.exit_code = exitCode(completed.status); command.signal = signal(completed.signal); + command.status = completed.error ? enumValue(completed.error.code, ['ETIMEDOUT', 'ENOBUFS'], 'spawn-error') : Number.isInteger(completed.status) ? 'completed' : 'unknown'; + const stdout = Buffer.isBuffer(completed.stdout) ? completed.stdout : Buffer.from(typeof completed.stdout === 'string' ? completed.stdout : ''); + const stderr = Buffer.isBuffer(completed.stderr) ? completed.stderr : Buffer.from(typeof completed.stderr === 'string' ? completed.stderr : ''); + if (!completed.error && completed.status === 0) command.view = contextDeviceView(kind, stdout, context.requested_udid); + if (command.view && fits()) command.view_status = 'parsed'; + else { command.view = null; result.partial = true; stream(command, 'stdout', stdout); } + stream(command, 'stderr', stderr); + } catch { command.status = 'unavailable'; result.partial = true; } + command.duration_ms = ms(performance.now() - at); + } + try { + for (const directory of [join(state, '.tmp'), derived, join(derived, 'Build'), products]) { const opened = openContextEntry(directory, state, true); closeSync(opened.fd); } + context.inventory.status = 'complete'; const queue = [{ path: products, relative: '', depth: 0 }]; + while (queue.length) { + const current = queue.shift(), opened = openContextEntry(current.path, products, true); + let directory; + try { + directory = opendirSync(current.path); + for (let entry; (entry = directory.readSync()) !== null;) { + if (result.entry_count >= limits.entries) { result.partial = true; context.inventory.status = 'partial'; queue.length = 0; break; } + result.entry_count++; + const path = join(current.path, entry.name), name = current.relative ? current.relative + '/' + entry.name : entry.name; + if (path.toLowerCase().includes('trash')) { result.partial = true; context.inventory.status = 'partial'; continue; } + const metadata = lstatSync(path), type = metadata.isSymbolicLink() ? 'symlink' : metadata.isDirectory() ? 'directory' : metadata.isFile() ? 'file' : 'other'; + if (type === 'file' || type === 'directory') { const child = openContextEntry(path, products, type === 'directory'); closeSync(child.fd); } + if (!append(context.inventory.entries, { relative: name, type, size: metadata.size, mode: metadata.mode & 0o7777 })) { context.inventory.status = 'partial'; queue.length = 0; break; } + if (type !== 'file' && type !== 'directory') { result.partial = true; context.inventory.status = 'partial'; continue; } + if (type === 'directory') { + if (current.depth < limits.depth) queue.push({ path, relative: name, depth: current.depth + 1 }); else { result.partial = true; context.inventory.status = 'partial'; } + } else if (entry.name.endsWith('.xctestrun') || (entry.name === 'Info.plist' && /\.(app|xctest)$/i.test(basename(current.path)))) { + if (context.inventory.files.length >= limits.files) { result.partial = true; context.inventory.status = 'partial'; continue; } + const file = { relative: name, status: 'unavailable', size: metadata.size }; + try { + if (metadata.size > limits.file_bytes) file.status = 'size-limit'; + else { + const bytes = contextBytes(path, products, limits.file_bytes); assert.equal(bytes.length, metadata.size); + file.bytes_base64 = bytes.toString('base64'); bytes.fill(0); file.status = 'captured'; + if (!append(context.inventory.files, file)) { delete file.bytes_base64; file.status = 'payload-limit'; append(context.inventory.files, file); } + } + } catch { file.status = 'unavailable'; } + if (file.status !== 'captured') { result.partial = true; context.inventory.status = 'partial'; if (!context.inventory.files.includes(file)) append(context.inventory.files, file); } + } + } + const after = lstatSync(current.path); + assert(after.isDirectory() && !after.isSymbolicLink() && after.uid === process.getuid() && after.dev === opened.stat.dev && after.ino === opened.stat.ino); + assert.equal(realpathSync(current.path), opened.real); + } finally { try { if (directory) directory.closeSync(); } finally { closeSync(opened.fd); } } + if (result.entry_count >= limits.entries && queue.length) { result.partial = true; context.inventory.status = 'partial'; break; } + } + } catch { context.inventory.status = 'unavailable'; result.partial = true; } + result.file_count = context.inventory.files.filter(file => file.status === 'captured').length; + const bytes = Buffer.from(JSON.stringify(context)); result.payload_bytes = bytes.length; + try { + assert(bytes.length <= limits.payload_bytes); + const envelope = seal(bytes, createPublicKey(runnerLogPublicKey), runnerContextAAD); assert.equal(envelope.key_id, runnerLogKeyId); + Object.assign(result, envelope, { status: 'encrypted', reason: null }); + } finally { bytes.fill(0); } + } catch { result.partial = true; } + result.collection_duration_ms = ms(performance.now() - started); return result; + } async function stage(name, operation, project = () => null) { const started = performance.now(); report[name].status = 'running'; @@ -776,6 +938,7 @@ jobs: report[name].error = safeError(error); report[name].error.startup_classification = await startupClassification(error); if (name === 'prepare') report[name].error.encrypted_runner_log = captureRunnerLog(); + if (name === 'prepare') report[name].error.encrypted_runner_context = captureRunnerContext(); return false; } finally { report[name].duration_ms = ms(performance.now() - started); @@ -873,13 +1036,25 @@ jobs: const recipient = createPublicKey(runnerLogPublicKey); assert.equal(recipient.asymmetricKeyType, 'rsa'); assert.equal(recipient.asymmetricKeyDetails.modulusLength, 3072); - const encrypted = sealRunnerLog(Buffer.from(sentinel), recipient); + const encrypted = sealEvidence(Buffer.from(sentinel), recipient, runnerLogAAD); assert.equal(encrypted.key_id, runnerLogKeyId); assert.equal(Buffer.from(encrypted.iv, 'base64').length, 12); assert.equal(Buffer.from(encrypted.tag, 'base64').length, 16); assert.equal(Buffer.from(encrypted.wrapped_key, 'base64').length, 384); assert.equal(Buffer.from(encrypted.ciphertext, 'base64').length, Buffer.byteLength(sentinel)); assert(!JSON.stringify(encrypted).includes(sentinel)); + const simctl = contextDeviceView('simctl', Buffer.from(JSON.stringify({ devices: { + 'com.apple.CoreSimulator.SimRuntime.iOS-26-5': [{ udid: fixtureExecId(1) }, { udid: fixtureExecId(2) }] } })), fixtureExecId(1).toUpperCase()); + assert.equal(simctl.total_count, 2); assert.equal(simctl.requested_match_count, 1); + const warning = 'WARNING: xcdevice is deprecated. Please use `devicectl list devices` instead.'; + const devices = JSON.stringify([{ identifier: fixtureExecId(1), platform: 'com.apple.platform.iphonesimulator' }, + { identifier: fixtureExecId(2), platform: 'com.apple.platform.macosx' }]); + for (const prefix of ['', warning + '\n', warning + '\r\n']) { + const view = contextDeviceView('xcdevice', Buffer.from(prefix + devices), fixtureExecId(1)); + assert.equal(view.total_count, 2); assert.equal(view.requested_match_count, 1); + } + assert.equal(contextDeviceView('xcdevice', Buffer.from('unknown warning\n' + devices), fixtureExecId(1)), null); + assert.equal(contextDeviceView('xcdevice', Buffer.from('bad JSON'), fixtureExecId(1)), null); } const mode = process.argv[2]; if (mode === 'self-check') { selfCheck(); process.exit(0); } From fe213598b4b73426f26606e5c535ebe639a003a1 Mon Sep 17 00:00:00 2001 From: harryisfish Date: Sat, 7 Nov 2026 14:54:26 +0800 Subject: [PATCH 16/34] chore(ci): remove temporary runner diagnostics --- .github/workflows/mobile.yml | 711 +---------------------------------- packages/docs/e2e.md | 2 +- 2 files changed, 7 insertions(+), 706 deletions(-) diff --git a/.github/workflows/mobile.yml b/.github/workflows/mobile.yml index 4875f2b76..c8f13c956 100644 --- a/.github/workflows/mobile.yml +++ b/.github/workflows/mobile.yml @@ -4,10 +4,6 @@ name: mobile on: workflow_dispatch: inputs: - runner_probe: - description: 'Run only the temporary iOS runner diagnosis' - type: boolean - default: false feedback: description: 'Replace older ordinary mobile feedback on this branch' type: boolean @@ -22,8 +18,8 @@ on: default: false concurrency: - group: mobile-${{ github.ref }}-${{ github.event_name == 'workflow_dispatch' && !inputs.runner_probe && inputs.feedback && github.run_attempt == 1 && 'feedback' || github.run_id }} - cancel-in-progress: ${{ github.event_name == 'workflow_dispatch' && !inputs.runner_probe && inputs.feedback && github.run_attempt == 1 }} + group: mobile-${{ github.ref }}-${{ github.event_name == 'workflow_dispatch' && inputs.feedback && github.run_attempt == 1 && 'feedback' || github.run_id }} + cancel-in-progress: ${{ github.event_name == 'workflow_dispatch' && inputs.feedback && github.run_attempt == 1 }} permissions: contents: read @@ -35,7 +31,7 @@ jobs: android: outputs: artifact_id: ${{ steps.upload.outputs.artifact-id }} - if: ${{ !(github.event_name == 'workflow_dispatch' && inputs.runner_probe) && (inputs.android_only || github.event_name == 'workflow_dispatch') }} + if: inputs.android_only || github.event_name == 'workflow_dispatch' runs-on: ubuntu-24.04 timeout-minutes: 60 steps: @@ -86,7 +82,7 @@ jobs: outputs: artifact_id: ${{ steps.inputs.outputs.artifact-id }} producer_attempt: ${{ github.run_attempt }} - if: ${{ !inputs.android_only && github.event_name == 'workflow_dispatch' && !inputs.runner_probe }} + if: ${{ !inputs.android_only && github.event_name == 'workflow_dispatch' }} runs-on: macos-26 timeout-minutes: 75 steps: @@ -153,7 +149,7 @@ jobs: ios-accept: needs: ios-build - if: ${{ !inputs.android_only && github.event_name == 'workflow_dispatch' && !inputs.runner_probe }} + if: ${{ !inputs.android_only && github.event_name == 'workflow_dispatch' }} runs-on: macos-26 timeout-minutes: 30 steps: @@ -470,7 +466,7 @@ jobs: retention-days: 7 mobile-gate: - if: ${{ always() && !(github.event_name == 'workflow_dispatch' && inputs.runner_probe) }} + if: always() needs: [android, ios-build, ios-accept] runs-on: ubuntu-24.04 steps: @@ -481,698 +477,3 @@ jobs: env: MOBILE_NEEDS: ${{ toJSON(needs) }} run: python3 scripts/ci.py mobile-gate --needs-env MOBILE_NEEDS ${{ inputs.android_only && '--android-only' || '' }} - - runner-probe: - if: ${{ github.event_name == 'workflow_dispatch' && inputs.runner_probe }} - runs-on: macos-26 - timeout-minutes: 20 - env: - AGENT_DEVICE_HOME: ${{ github.workspace }}/.artifacts/ios-runner-probe/private/agent-device - AGENT_DEVICE_STATE_DIR: ${{ github.workspace }}/.artifacts/ios-runner-probe/private/agent-device - AGENT_DEVICE_IOS_RUNNER_DERIVED_PATH: ${{ github.workspace }}/.artifacts/ios-runner-probe/private/agent-device/.tmp/runner-derived - steps: - - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 - with: - persist-credentials: false - - uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 - with: - version: 11.9.0 - - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 - with: - node-version: '24' - cache: pnpm - cache-dependency-path: pnpm-lock.yaml - - name: Prepare the private diagnostic collector - shell: bash - run: | - umask 077 - mkdir -p .artifacts/ios-runner-probe/private - cat > .artifacts/ios-runner-probe/private/probe.mjs <<'NODE' - import assert from 'node:assert/strict'; - import { spawnSync } from 'node:child_process'; - import { constants as fsConstants, closeSync, existsSync, fstatSync, lstatSync, mkdirSync, openSync, opendirSync, readFileSync, readSync, realpathSync, rmSync, statSync, writeFileSync } from 'node:fs'; - import { constants as cryptoConstants, createCipheriv, createHash, createPublicKey, publicEncrypt, randomBytes } from 'node:crypto'; - import { createRequire, findPackageJSON } from 'node:module'; - import { basename, dirname, isAbsolute, join, relative, resolve } from 'node:path'; - import { pathToFileURL } from 'node:url'; - - process.umask(0o077); - const root = resolve('.artifacts/ios-runner-probe'); - const privateRoot = join(root, 'private'); - const state = join(privateRoot, 'agent-device'); - const home = state; - const reportPath = join(root, 'result.json'); - const simulatorPath = join(privateRoot, 'simulator.txt'); - const session = 'vdp-native-acceptance-0'; - const stages = ['setup', 'prepare', 'open', 'system_snapshot']; - const timingKeys = ['adopt_detached_runner', 'cleanup_stale_xcodebuild', 'ensure_booted', - 'verify_device_readiness', 'verify_host_dev_tools_security', 'cleanup_stale_bundles', - 'ensure_xctestrun', 'allocate_port', 'prepare_xctestrun_env', 'launch_xcodebuild', 'build_xctestrun']; - const codes = ['INVALID_ARGS', 'DEVICE_NOT_FOUND', 'DEVICE_IN_USE', 'TOOL_MISSING', - 'APP_NOT_INSTALLED', 'UNSUPPORTED_PLATFORM', 'UNSUPPORTED_OPERATION', 'NOT_IMPLEMENTED', - 'COMMAND_FAILED', 'SESSION_NOT_FOUND', 'UNAUTHORIZED', 'AMBIGUOUS_MATCH', 'REPLAY_DIVERGENCE', - 'REPAIR_SESSION_EXPIRED', 'REPAIR_COMMIT_FAILED', 'UNKNOWN', 'ERR_ASSERTION', 'PROBE_COMMAND_FAILED']; - const reasons = ['daemon_transport_timeout', 'daemon_request_timeout', 'request_canceled', - 'prepare_deadline_expired', 'runner_start_budget_exhausted', 'runner_launch_budget_exhausted', - 'runner_main_thread_timeout', 'runner_main_thread_wedged', 'runner_busy', 'runner_busy_refusal', - 'runner_reply_lost', 'runner_connect_refused', 'runner_endpoint_probe_exhausted', - 'runner_readiness_preflight_failed', 'runner_cache_uncertifiable', 'runner_process_dead', - 'runner_reported_failure', 'xcodebuild_exited_early', 'simulator_service_hub_unavailable', - 'simulator_set_destination_not_found', 'build_failed_unclassified', - 'IOS_RUNNER_CONNECT_TIMEOUT', 'IOS_RUNNER_DEVICE_NOT_PROVISIONED', 'BOOT_COMMAND_FAILED', - 'startup-exited', 'startup-stalled', 'startup-ceiling']; - const execEvents = ['spawn_start', 'spawn', 'deadline', 'abort', 'error', 'exit', 'close', 'settled']; - const signals = ['SIGTERM', 'SIGKILL', 'SIGABRT', 'SIGSEGV', 'SIGBUS', 'SIGILL', - 'SIGTRAP', 'SIGHUP', 'SIGINT', 'SIGQUIT', 'SIGPIPE']; - const startupReasons = ['bundle_identifier_already_registered', 'signing_no_development_team', - 'signing_provisioning_profile_missing', 'signing_unspecified', 'devtools_security_developer_mode_disabled', - 'device_developer_mode_disabled', 'device_developer_disk_image_unavailable', 'build_failed_unclassified', - 'simulator_service_hub_unavailable', 'simulator_set_destination_not_found']; - const runnerLogScope = 'fresh-task-session-runner-log'; - const runnerLogAAD = 'vibeface-ci472-runner-log-v1'; - const runnerContextAAD = 'vibeface-ci472-runner-context-v1'; - const runnerLogKeyId = 'beb7dc7bf91c12efe172c9b82e89758b630439162509345ca1fdb2f3b0decccc'; - const runnerLogPublicKey = "-----BEGIN PUBLIC KEY-----\nMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAjTrGa8sXLaT5MeAJhIkI\ngqEMu+QNunCFHLV/z5bx/q+V9981uJi/hjg59hhaef5anN+JRBhqgzdGBDkkmmI+\nn8RZMQPGozzI/1dlfBnbeYX6DK19WntVr8J8df9uGuPOwqZ8Mp0jVa1oW+fLpdwS\nIIpzrmFXY+6JKZ1R+oeDzasxATSciBCZkOJxCk+CEQAL6A77Qyp6VEmKCdWs3zZ9\ndKaFeU4ERMVTdeAfhL9bIieaTW6a1kkJaQGe4iK5PQhyV2yZ27VSoappspH4wvQA\nNBkavdtpasbJ45+Wuzv6XwWvQf03+Yhcon6PUGF/M5Z1bUhyleluBgIpDoAxcij3\nttKYv19h9QzjKR6lgPRUBjMUMvjoB2msOsQzNvyTjM4TVeLNETYsP66TNLfA0Ifz\nOSuoSBCijOU80rWjG/22uVccADNhUN+s1kqRXeTwmFpfyEH2z6DYAICMfHshmf1T\nTIdzu6zWTKdDKgroJwUW5hZFaWiPHdQjgUiLc0hoyapFAgMBAAE=\n-----END PUBLIC KEY-----\n"; - const enumValue = (value, allowed, fallback = 'unknown') => allowed.includes(value) ? value : fallback; - const exitCode = value => value === undefined ? 'missing' : value === null ? null - : Number.isInteger(value) && value >= 0 && value <= 255 ? value : 'unknown'; - const signal = value => value === undefined ? 'missing' : value === null ? null : enumValue(value, signals); - const ms = value => typeof value === 'number' && Number.isFinite(value) && value >= 0 && value <= 3600000 - ? Math.round(value) : null; - const numericFields = (value, keys) => Object.fromEntries(keys.map(key => [key, ms(value?.[key])])); - const safeError = (error, depth = 0) => ({ - code: enumValue(error?.code, codes), - reason: enumValue(error?.details?.reason, reasons), - cause_reason: enumValue(error?.details?.causeReason, reasons), - runner_error_code: enumValue(error?.details?.runnerErrorCode, - ['RUNNER_BUSY', 'MAIN_THREAD_TIMEOUT', 'RUNNER_WEDGED', 'COMMAND_ALREADY_FINISHED', 'IOS_AX_SNAPSHOT_FAILED']), - runner_connect_failure_reason: enumValue(error?.details?.runnerConnectFailureReason, reasons), - xcodebuild_exit_code: exitCode(error?.details?.xcodebuild?.exitCode), - runner_phase: enumValue(error?.details?.phase, ['runner_session', 'runner_rebuild', 'runner_health']), - startup_kind: enumValue(error?.details?.kind, ['daemon_startup_failed']), - timeout_ms: ms(error?.details?.timeoutMs), - startup_timeout_ms: ms(error?.details?.startupTimeoutMs), - startup_attempts: Number.isInteger(error?.details?.startupAttempts) - && error.details.startupAttempts >= 0 && error.details.startupAttempts <= 2 ? error.details.startupAttempts : null, - cause: depth < 2 && error?.cause ? safeError(error.cause, depth + 1) : null, - }); - function safeEvent(value, execIds) { - const phase = value?.phase; - const data = value?.data; - if (phase === 'exec_command' && data?.command === 'xcodebuild' && execEvents.includes(data.event)) { - const id = data.execId; - if (typeof id === 'string' && /^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(id) - && !execIds.has(id) && execIds.size < 128) execIds.set(id, execIds.size + 1); - return { phase, command: 'xcodebuild', event: data.event, exec_index: execIds.get(id) ?? null, - duration_ms: ms(value.durationMs), timeout_ms: ms(data.timeoutMs), - exit_code: exitCode(data.exitCode), signal: signal(data.signal), - settlement_reason: enumValue(data.reason, ['success', 'exit_failure', 'timeout', 'abort', 'spawn_error', 'stdin_error'], - data.reason === undefined ? 'missing' : 'unknown') }; - } - if (phase === 'prepare_apple_runner') return { phase, - event: enumValue(data?.event, ['readiness_start', 'runner_start', 'settled']), - duration_ms: ms(value.durationMs), timeout_ms: ms(data?.timeoutMs), remaining_ms: ms(data?.remainingMs) }; - if (timingKeys.slice(0, -1).some(key => phase === `ios_runner_startup_${key}`)) { - return { phase, duration_ms: ms(value.durationMs) }; - } - if (phase === 'ios_runner_session_startup_timings') return { phase, - duration_ms: ms(value.durationMs), ready: typeof data?.ready === 'boolean' ? data.ready : null, - command: enumValue(data?.command, ['uptime', 'activate', 'snapshot']), - timings: numericFields(data?.timings, timingKeys) }; - if (phase === 'apple_runner_prepare') return { phase, - cache: enumValue(data?.cache, ['exact', 'miss', 'external']), - artifact: enumValue(data?.artifact, ['valid', 'rebuilt']), - duration_ms: ms(value.durationMs), - timings: numericFields(data, ['buildMs', 'connectMs', 'healthCheckMs']) }; - return null; - } - function diagnostics(stage) { - const path = join(state, 'sessions', session, 'requests', `probe-${stage}.ndjson`); - const result = { status: 'missing', malformed_lines: 0, capped: false, events: [] }; - if (!existsSync(path)) return result; - if (statSync(path).size > 8388608) return { ...result, status: 'size_limit', capped: true }; - result.status = 'read'; - const lines = readFileSync(path, 'utf8').split('\n'); - const execIds = new Map(); - result.capped = lines.length > 10000; - for (const line of lines.slice(0, 10000)) { - if (!line) continue; - if (line.length > 131072) { result.malformed_lines++; continue; } - let event; - try { event = safeEvent(JSON.parse(line), execIds); } - catch { result.malformed_lines++; continue; } - if (!event) continue; - if (result.events.length >= 128) { result.capped = true; break; } - result.events.push(event); - } - return result; - } - function safePrepare(value) { - return { action: enumValue(value?.action, ['ios-runner']), platform: enumValue(value?.platform, ['ios']), - kind: enumValue(value?.kind, ['simulator']), cache: enumValue(value?.cache, ['exact', 'miss', 'external']), - artifact: enumValue(value?.artifact, ['valid', 'rebuilt']), - timings: numericFields(value, ['durationMs', 'buildMs', 'connectMs', 'healthCheckMs']), - total_ms: ms(value?.timing?.totalMs), - additive_parts: numericFields(value?.timing?.additiveParts, ['buildMs', 'connectAfterBuildMs', 'healthCheckMs']) }; - } - function safeSnapshot(value) { - return { node_count: Array.isArray(value?.nodes) && value.nodes.length <= 1000000 ? value.nodes.length : null, - quality: enumValue(value?.snapshotQuality?.state, ['healthy', 'recovered', 'sparse'], - value?.snapshotQuality === undefined ? 'absent' : 'unknown'), - backend: enumValue(value?.snapshotQuality?.backend, ['tree', 'queries', 'private-ax', 'android-helper']), - reason_code: enumValue(value?.snapshotQuality?.reasonCode, ['ax-rejected', 'sparse-tree', 'budget', - 'no-nodes', 'capture-failed', 'presentation-failed', 'deferred', 'requested-backend']) }; - } - const blank = () => ({ status: 'not_run', duration_ms: null, error: null, result: null, diagnostics: null }); - const initial = () => ({ schema_version: 1, status: 'not_run', scope: 'sdk-availability-control', - source_sha: /^[a-f0-9]{40}$/.test(process.env.GITHUB_SHA ?? '') ? process.env.GITHUB_SHA : null, - sdk_version: '0.21.36', mobile_version: '0.12.4', - configuration: { runner: 'macos-26', device: 'iPhone 17', sdk_debug: true, - home_equals_state: true, session, mobile_wrapper_exercised: false, - state_environment: 'before-process-start', production_state_environment: 'after-mobile-static-import', - derived_override_set: true, prepare_timeout_override_set: false, snapshot_interactive_only: false }, - environment: { host_arch: enumValue(process.arch, ['arm64', 'x64']), xcode_version: null, - xcode_build: null, simulator_sdk_version: null, simulator_runtime_version: null }, - ...Object.fromEntries(stages.map(name => [name, blank()])), - cleanup: { daemon_stop: 'not_run', simulator_shutdown: 'not_run', simulator_delete: 'not_run', state_removed: false } }); - let report; - function save() { writeFileSync(reportPath, `${JSON.stringify(report, null, 2)}\n`, { mode: 0o600 }); } - function raw(command, args, quiet = false) { - const stdout = quiet ? openSync(join(privateRoot, 'commands.stdout'), 'a', 0o600) : 'pipe'; - try { - const result = spawnSync(command, args, { encoding: 'utf8', maxBuffer: 33554432, - stdio: ['ignore', stdout, 2] }); - if (result.error || result.status !== 0) throw { code: 'PROBE_COMMAND_FAILED' }; - return result.stdout ?? ''; - } finally { if (quiet) closeSync(stdout); } - } - function dependency() { - const mobile = createRequire(resolve('package.json')).resolve('@e2e-dev/mobile'); - const mobilePackage = JSON.parse(readFileSync(join(dirname(mobile), '..', 'package.json'), 'utf8')); - const path = findPackageJSON('agent-device', pathToFileURL(mobile)); - const manifest = JSON.parse(readFileSync(path, 'utf8')); - assert.equal(mobilePackage.version, '0.12.4'); - assert.equal(manifest.version, '0.21.36'); - return { entry: resolve(dirname(path), manifest.exports['.'].import), cli: resolve(dirname(path), manifest.bin['agent-device']) }; - } - function isolate() { - assert.equal(process.env.AGENT_DEVICE_HOME, home); - assert.equal(process.env.AGENT_DEVICE_STATE_DIR, state); - mkdirSync(state, { recursive: true, mode: 0o700 }); - } - function startupProjection(error, AppError, classify) { - const stderr = error?.details?.xcodebuild?.stderr; - if (typeof stderr !== 'string') return { reason: 'unavailable', matched: null }; - const details = { stderr }; - for (const key of ['simulatorSetPath', 'simulatorUdid', 'xcodeVersion']) { - if (typeof error.details[key] === 'string') details[key] = error.details[key]; - } - const result = classify(new AppError('COMMAND_FAILED', 'Runner did not accept connection (xcodebuild exited early)', details)); - return { reason: enumValue(result?.reason, startupReasons), - matched: typeof result?.matched === 'boolean' ? result.matched : null }; - } - async function startupClassification(error) { - if (typeof error?.details?.xcodebuild?.stderr !== 'string') return { reason: 'unavailable', matched: null }; - try { - const sdk = dependency(); - const { AppError } = await import(pathToFileURL(sdk.entry).href); - const { r: classify } = await import(pathToFileURL(join(dirname(sdk.entry), 'runner-error-classification.js')).href); - assert.equal(typeof classify, 'function'); - return startupProjection(error, AppError, classify); - } catch { return { reason: 'unavailable', matched: null }; } - } - function sealEvidence(bytes, recipient, aad) { - const key = randomBytes(32), iv = randomBytes(12); - try { - const cipher = createCipheriv('aes-256-gcm', key, iv, { authTagLength: 16 }); - cipher.setAAD(Buffer.from(aad)); - const ciphertext = Buffer.concat([cipher.update(bytes), cipher.final()]); - return { algorithm: 'RSA-OAEP-SHA256+A256GCM', - key_id: createHash('sha256').update(recipient.export({ type: 'spki', format: 'der' })).digest('hex'), - iv: iv.toString('base64'), tag: cipher.getAuthTag().toString('base64'), - wrapped_key: publicEncrypt({ key: recipient, padding: cryptoConstants.RSA_PKCS1_OAEP_PADDING, - oaepHash: 'sha256' }, key).toString('base64'), ciphertext: ciphertext.toString('base64') }; - } finally { key.fill(0); } - } - function captureRunnerLog() { - const result = { scope: runnerLogScope, status: 'unavailable', reason: 'ownership-unproven', - source_bytes: null, captured_bytes: 0, offset: null, capped: null, source_changed: null }; - const expected = join(state, 'sessions', session, 'runner.log'); - if (expected.toLowerCase().includes('trash')) return result; - let fd, bytes; - try { - result.reason = 'ownership-unproven'; - const uid = process.getuid(); - for (const directory of [root, privateRoot, state, join(state, 'sessions'), dirname(expected)]) { - const entry = lstatSync(directory); - assert(entry.isDirectory() && !entry.isSymbolicLink() && entry.uid === uid); - } - const before = lstatSync(expected); - assert(before.isFile() && !before.isSymbolicLink() && before.uid === uid); - assert.equal(realpathSync(expected), join(realpathSync(state), 'sessions', session, 'runner.log')); - assert(Number.isInteger(fsConstants.O_NOFOLLOW)); - fd = openSync(expected, fsConstants.O_RDONLY | fsConstants.O_NOFOLLOW); - const opened = fstatSync(fd); - assert(opened.isFile() && opened.uid === uid && opened.dev === before.dev && opened.ino === before.ino); - assert(Number.isSafeInteger(opened.size) && opened.size >= 0); - result.source_bytes = opened.size; - result.offset = Math.max(0, opened.size - 262144); - result.capped = opened.size > 262144; - if (opened.size === 0) return { ...result, status: 'empty', reason: null, source_changed: false }; - result.reason = 'read-failed'; - bytes = Buffer.alloc(Math.min(opened.size, 262144)); - let count = 0; - while (count < bytes.length) { - const size = readSync(fd, bytes, count, bytes.length - count, result.offset + count); - if (size === 0) break; - count += size; - } - result.captured_bytes = count; - assert.equal(count, bytes.length); - result.source_changed = fstatSync(fd).size !== opened.size; - result.reason = 'encryption-failed'; - const recipient = createPublicKey(runnerLogPublicKey); - assert.equal(recipient.asymmetricKeyType, 'rsa'); - assert.equal(recipient.asymmetricKeyDetails.modulusLength, 3072); - const envelope = sealEvidence(bytes, recipient, runnerLogAAD); - assert.equal(envelope.key_id, runnerLogKeyId); - return { ...result, ...envelope, status: 'encrypted', reason: null }; - } catch { return result; } - finally { - if (fd !== undefined) { try { closeSync(fd); } catch {} } - bytes?.fill(0); - } - } - function openContextEntry(path, anchor, directory) { - assert(!path.toLowerCase().includes('trash')); - const before = lstatSync(path); - assert(!before.isSymbolicLink() && before.uid === process.getuid()); - assert(directory ? before.isDirectory() : before.isFile()); - const location = realpathSync(path), base = realpathSync(anchor), inside = relative(base, location); - assert(inside === '' || (!inside.startsWith('..') && !isAbsolute(inside))); - const fd = openSync(path, fsConstants.O_RDONLY | fsConstants.O_NOFOLLOW); - try { - const opened = fstatSync(fd); - assert(opened.uid === before.uid && opened.dev === before.dev && opened.ino === before.ino); - assert(directory ? opened.isDirectory() : opened.isFile()); - return { fd, stat: opened, real: location }; - } catch (error) { closeSync(fd); throw error; } - } - function contextBytes(path, anchor, maximum) { - const opened = openContextEntry(path, anchor, false); - try { - assert(Number.isSafeInteger(opened.stat.size) && opened.stat.size >= 0 && opened.stat.size <= maximum); - const bytes = Buffer.alloc(opened.stat.size); - let count = 0; - while (count < bytes.length) { - const size = readSync(opened.fd, bytes, count, bytes.length - count, count); - assert(size > 0); count += size; - } - assert.equal(fstatSync(opened.fd).size, opened.stat.size); - return bytes; - } finally { closeSync(opened.fd); } - } - function contextDeviceView(kind, bytes, requested) { - if (typeof requested !== 'string') return null; - try { - let text = new TextDecoder('utf-8', { fatal: true }).decode(bytes); - const warning = 'WARNING: xcdevice is deprecated. Please use `devicectl list devices` instead.'; - if (kind === 'xcdevice' && text.startsWith(warning + '\r\n')) text = text.slice(warning.length + 2); - else if (kind === 'xcdevice' && text.startsWith(warning + '\n')) text = text.slice(warning.length + 1); - const parsed = JSON.parse(text), matches = [], counts = new Map(); - let total = 0; - const row = (value, id, platform, runtime) => { - assert(value && typeof value === 'object' && !Array.isArray(value) && typeof id === 'string'); - total++; - const name = typeof platform === 'string' && platform.length <= 128 && (counts.has(platform) || counts.size < 32) ? platform : 'other'; - counts.set(name, (counts.get(name) ?? 0) + 1); - if (id.toLowerCase() === requested.toLowerCase()) matches.push(runtime === undefined ? value : { runtime, device: value }); - }; - if (kind === 'simctl') { - assert(parsed && typeof parsed === 'object' && !Array.isArray(parsed) && parsed.devices && typeof parsed.devices === 'object' && !Array.isArray(parsed.devices)); - for (const [runtime, devices] of Object.entries(parsed.devices)) { - assert(Array.isArray(devices)); - const platform = runtime.includes('.SimRuntime.') ? runtime.split('.SimRuntime.')[1].split('-')[0] : 'other'; - for (const device of devices) row(device, device?.udid, platform, runtime); - } - } else { - assert(kind === 'xcdevice' && Array.isArray(parsed)); - for (const device of parsed) row(device, device?.identifier, device?.platform); - } - return { interpretation: 'tool-view-only', total_count: total, platform_counts: Object.fromEntries(counts), requested_match_count: matches.length, requested_rows: matches }; - } catch { return null; } - } - function captureRunnerContext(run = spawnSync, seal = sealEvidence) { - const started = performance.now(), limits = { entries: 512, files: 16, file_bytes: 65536, depth: 8, - payload_bytes: 262144, command_timeout_ms: 30000, command_max_buffer: 262144 }; - const result = { scope: 'fresh-task-session-runner-context', payload_format: runnerContextAAD, - status: 'unavailable', reason: 'collection-failed', partial: false, entry_count: 0, file_count: 0, - payload_bytes: 0, collection_duration_ms: null, limits }; - const derived = join(state, '.tmp', 'runner-derived'), products = join(derived, 'Build', 'Products'); - const context = { payload_format: runnerContextAAD, requested_udid: null, requested_udid_status: 'unavailable', - environment: {}, derived_path: derived, inventory: { status: 'unavailable', entries: [], files: [] }, commands: [] }; - const fits = () => Buffer.byteLength(JSON.stringify(context)) <= limits.payload_bytes - 1024; - const append = (array, value) => { array.push(value); if (fits()) return true; array.pop(); result.partial = true; return false; }; - const stream = (command, key, bytes) => { - const output = { source_bytes: bytes.length, captured_bytes: 0, capped: false, bytes_base64: '' }; - command[key] = output; - let low = 0, high = bytes.length; - while (low < high) { - const size = Math.ceil((low + high) / 2); output.bytes_base64 = bytes.subarray(0, size).toString('base64'); - if (fits()) low = size; else high = size - 1; - } - output.bytes_base64 = bytes.subarray(0, low).toString('base64'); output.captured_bytes = low; output.capped = low < bytes.length; - if (output.capped) result.partial = true; - }; - try { - for (const directory of [root, privateRoot, state]) { const opened = openContextEntry(directory, root, true); closeSync(opened.fd); } - try { - const bytes = contextBytes(simulatorPath, privateRoot, 128), value = bytes.toString('utf8').trim(); bytes.fill(0); - assert(/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(value)); - context.requested_udid = value; context.requested_udid_status = 'captured'; - } catch { result.partial = true; } - for (const key of ['HOME', 'CFFIXED_USER_HOME', 'SIMULATOR_DEVICE_SET_PATH', 'CORE_SIMULATOR_DEVICE_SET_PATH', 'DEVELOPER_DIR', 'SDKROOT', 'AGENT_DEVICE_IOS_RUNNER_DERIVED_PATH']) { - const value = process.env[key]; - context.environment[key] = typeof value === 'string' && Buffer.byteLength(value) <= 8192 ? value : null; - if (typeof value === 'string' && Buffer.byteLength(value) > 8192) result.partial = true; - if (!fits()) { context.environment[key] = null; result.partial = true; } - } - for (const [kind, args] of [['simctl', ['simctl', 'list', 'devices', '--json']], ['xcdevice', ['xcdevice', 'list', '--timeout=10']]]) { - const command = { kind, status: 'unknown', exit_code: 'missing', signal: 'missing', duration_ms: null, view_status: 'unknown', view: null, stdout: null, stderr: null }; - context.commands.push(command); const at = performance.now(); - try { - const completed = run('xcrun', args, { timeout: limits.command_timeout_ms, maxBuffer: limits.command_max_buffer, - killSignal: 'SIGKILL', encoding: null, stdio: ['ignore', 'pipe', 'pipe'] }); - command.exit_code = exitCode(completed.status); command.signal = signal(completed.signal); - command.status = completed.error ? enumValue(completed.error.code, ['ETIMEDOUT', 'ENOBUFS'], 'spawn-error') : Number.isInteger(completed.status) ? 'completed' : 'unknown'; - const stdout = Buffer.isBuffer(completed.stdout) ? completed.stdout : Buffer.from(typeof completed.stdout === 'string' ? completed.stdout : ''); - const stderr = Buffer.isBuffer(completed.stderr) ? completed.stderr : Buffer.from(typeof completed.stderr === 'string' ? completed.stderr : ''); - if (!completed.error && completed.status === 0) command.view = contextDeviceView(kind, stdout, context.requested_udid); - if (command.view && fits()) command.view_status = 'parsed'; - else { command.view = null; result.partial = true; stream(command, 'stdout', stdout); } - stream(command, 'stderr', stderr); - } catch { command.status = 'unavailable'; result.partial = true; } - command.duration_ms = ms(performance.now() - at); - } - try { - for (const directory of [join(state, '.tmp'), derived, join(derived, 'Build'), products]) { const opened = openContextEntry(directory, state, true); closeSync(opened.fd); } - context.inventory.status = 'complete'; const queue = [{ path: products, relative: '', depth: 0 }]; - while (queue.length) { - const current = queue.shift(), opened = openContextEntry(current.path, products, true); - let directory; - try { - directory = opendirSync(current.path); - for (let entry; (entry = directory.readSync()) !== null;) { - if (result.entry_count >= limits.entries) { result.partial = true; context.inventory.status = 'partial'; queue.length = 0; break; } - result.entry_count++; - const path = join(current.path, entry.name), name = current.relative ? current.relative + '/' + entry.name : entry.name; - if (path.toLowerCase().includes('trash')) { result.partial = true; context.inventory.status = 'partial'; continue; } - const metadata = lstatSync(path), type = metadata.isSymbolicLink() ? 'symlink' : metadata.isDirectory() ? 'directory' : metadata.isFile() ? 'file' : 'other'; - if (type === 'file' || type === 'directory') { const child = openContextEntry(path, products, type === 'directory'); closeSync(child.fd); } - if (!append(context.inventory.entries, { relative: name, type, size: metadata.size, mode: metadata.mode & 0o7777 })) { context.inventory.status = 'partial'; queue.length = 0; break; } - if (type !== 'file' && type !== 'directory') { result.partial = true; context.inventory.status = 'partial'; continue; } - if (type === 'directory') { - if (current.depth < limits.depth) queue.push({ path, relative: name, depth: current.depth + 1 }); else { result.partial = true; context.inventory.status = 'partial'; } - } else if (entry.name.endsWith('.xctestrun') || (entry.name === 'Info.plist' && /\.(app|xctest)$/i.test(basename(current.path)))) { - if (context.inventory.files.length >= limits.files) { result.partial = true; context.inventory.status = 'partial'; continue; } - const file = { relative: name, status: 'unavailable', size: metadata.size }; - try { - if (metadata.size > limits.file_bytes) file.status = 'size-limit'; - else { - const bytes = contextBytes(path, products, limits.file_bytes); assert.equal(bytes.length, metadata.size); - file.bytes_base64 = bytes.toString('base64'); bytes.fill(0); file.status = 'captured'; - if (!append(context.inventory.files, file)) { delete file.bytes_base64; file.status = 'payload-limit'; append(context.inventory.files, file); } - } - } catch { file.status = 'unavailable'; } - if (file.status !== 'captured') { result.partial = true; context.inventory.status = 'partial'; if (!context.inventory.files.includes(file)) append(context.inventory.files, file); } - } - } - const after = lstatSync(current.path); - assert(after.isDirectory() && !after.isSymbolicLink() && after.uid === process.getuid() && after.dev === opened.stat.dev && after.ino === opened.stat.ino); - assert.equal(realpathSync(current.path), opened.real); - } finally { try { if (directory) directory.closeSync(); } finally { closeSync(opened.fd); } } - if (result.entry_count >= limits.entries && queue.length) { result.partial = true; context.inventory.status = 'partial'; break; } - } - } catch { context.inventory.status = 'unavailable'; result.partial = true; } - result.file_count = context.inventory.files.filter(file => file.status === 'captured').length; - const bytes = Buffer.from(JSON.stringify(context)); result.payload_bytes = bytes.length; - try { - assert(bytes.length <= limits.payload_bytes); - const envelope = seal(bytes, createPublicKey(runnerLogPublicKey), runnerContextAAD); assert.equal(envelope.key_id, runnerLogKeyId); - Object.assign(result, envelope, { status: 'encrypted', reason: null }); - } finally { bytes.fill(0); } - } catch { result.partial = true; } - result.collection_duration_ms = ms(performance.now() - started); return result; - } - async function stage(name, operation, project = () => null) { - const started = performance.now(); - report[name].status = 'running'; - save(); - try { - const value = await operation(); - report[name].result = project(value); - report[name].status = 'passed'; - return true; - } catch (error) { - report[name].status = 'failed'; - report[name].error = safeError(error); - report[name].error.startup_classification = await startupClassification(error); - if (name === 'prepare') report[name].error.encrypted_runner_log = captureRunnerLog(); - if (name === 'prepare') report[name].error.encrypted_runner_context = captureRunnerContext(); - return false; - } finally { - report[name].duration_ms = ms(performance.now() - started); - try { report[name].diagnostics = diagnostics(name); } - catch { report[name].diagnostics = { status: 'unreadable', malformed_lines: 0, capped: false, events: [] }; } - save(); - } - } - function selfCheck() { - const sentinel = 'PRIVATE_SENTINEL_/token/screen/argv'; - assert.equal(ms(Infinity), null); - assert.equal(ms(-1), null); - assert.equal(ms('42'), null); - assert.equal(ms(3600001), null); - assert.equal(safeEvent({ phase: sentinel }), null); - const event = safeEvent({ phase: 'prepare_apple_runner', durationMs: 4, message: sentinel, - data: { event: sentinel, timeoutMs: 240000, remainingMs: -1, error: sentinel, argv: [sentinel] } }); - assert.deepEqual(event, { phase: 'prepare_apple_runner', event: 'unknown', duration_ms: 4, - timeout_ms: 240000, remaining_ms: null }); - const error = safeError({ code: sentinel, message: sentinel, details: { reason: sentinel, - runnerErrorCode: sentinel, timeoutMs: 42, stderr: sentinel }, cause: { code: 'COMMAND_FAILED', - details: { reason: 'daemon_request_timeout' }, message: sentinel } }); - assert.equal(error.code, 'unknown'); - assert.equal(error.cause.reason, 'daemon_request_timeout'); - const prepared = safePrepare({ action: 'ios-runner', runner: { token: sentinel }, message: sentinel, - recoveryReason: sentinel, failureReason: sentinel, xctestrunPath: sentinel, durationMs: 8 }); - const snapshot = safeSnapshot({ nodes: [{ label: sentinel, text: sentinel }], - snapshotQuality: { state: 'healthy', backend: 'tree', reason: sentinel }, fallbackScreenshotPath: sentinel }); - assert.equal(snapshot.node_count, 1); - assert.equal(snapshot.quality, 'healthy'); - for (const reason of ['IOS_RUNNER_CONNECT_TIMEOUT', 'IOS_RUNNER_DEVICE_NOT_PROVISIONED', 'BOOT_COMMAND_FAILED']) { - assert.equal(safeError({ details: { reason } }).reason, reason); - } - for (const code of [0, 1, 65, 70, 255]) { - assert.equal(safeError({ details: { xcodebuild: { exitCode: code } } }).xcodebuild_exit_code, code); - } - for (const code of [-1, 256, 1.5, Infinity, NaN, '65', sentinel]) assert.equal(exitCode(code), 'unknown'); - assert.equal(exitCode(undefined), 'missing'); - assert.equal(exitCode(null), null); - assert.equal(signal(undefined), 'missing'); - assert.equal(signal(null), null); - assert.equal(signal(sentinel), 'unknown'); - for (const name of signals) assert.equal(signal(name), name); - const execIds = new Map(); - const fixtureExecId = index => `00000000-0000-4000-8000-${index.toString(16).padStart(12, '0')}`; - const id = fixtureExecId(1); - const exec = (event, data = {}) => safeEvent({ phase: 'exec_command', durationMs: 7, - data: { command: 'xcodebuild', execId: id, event, args: [sentinel], stderr: sentinel, ...data } }, execIds); - for (const name of execEvents) assert.equal(exec(name).event, name); - const started = exec('spawn_start'); - assert.equal(started.exec_index, 1); - assert(!JSON.stringify(started).includes(id)); - assert.equal(started.exit_code, 'missing'); - assert.equal(started.signal, 'missing'); - const killed = exec('exit', { exitCode: null, signal: 'SIGKILL' }); - const closed = exec('close', { exitCode: null, signal: 'SIGKILL' }); - assert.equal(killed.exit_code, null); - assert.equal(killed.signal, 'SIGKILL'); - assert.equal(closed.exec_index, killed.exec_index); - const finished = exec('settled', { exitCode: 1, signal: null, reason: 'success', - execId: fixtureExecId(2) }); - assert.equal(finished.exec_index, 2); - assert.equal(finished.exit_code, 1); - assert.equal(finished.signal, null); - assert.equal(finished.settlement_reason, 'success'); - assert.equal(exec('exit', { signal: sentinel }).signal, 'unknown'); - assert.equal(exec(sentinel), null); - assert.equal(exec('exit', { command: 'swift' }), null); - assert.equal(exec('exit', { command: '/usr/bin/xcodebuild' }), null); - assert.equal(exec('exit', { execId: sentinel }).exec_index, null); - const groups = new Map(); - for (let i = 1; i <= 129; i++) { - const projected = safeEvent({ phase: 'exec_command', data: { command: 'xcodebuild', event: 'spawn', - execId: fixtureExecId(i) } }, groups); - assert.equal(projected.exec_index, i <= 128 ? i : null); - } - assert.equal(groups.size, 128); - class FixtureError extends Error { - constructor(code, message, details) { super(message); this.code = code; this.details = details; } - } - let adapted; - const classified = startupProjection({ message: sentinel, details: { xcodebuild: { stderr: sentinel }, - simulatorUdid: 'fixture-udid', simulatorSetPath: null, xcodeVersion: 26 } }, FixtureError, value => { - adapted = value; - return { reason: 'signing_no_development_team', matched: true, hint: sentinel, messageSuffix: sentinel }; - }); - assert.deepEqual(classified, { reason: 'signing_no_development_team', matched: true }); - assert.equal(adapted.message, 'Runner did not accept connection (xcodebuild exited early)'); - assert.deepEqual(adapted.details, { stderr: sentinel, simulatorUdid: 'fixture-udid' }); - assert.deepEqual(startupProjection({}, FixtureError, () => { throw new Error(); }), - { reason: 'unavailable', matched: null }); - assert.deepEqual(startupProjection({ details: { xcodebuild: { stderr: '' } } }, FixtureError, - () => ({ reason: sentinel, matched: sentinel })), { reason: 'unknown', matched: null }); - assert(!JSON.stringify({ event, error, prepared, snapshot, started, killed, closed, finished, classified }).includes(sentinel)); - const recipient = createPublicKey(runnerLogPublicKey); - assert.equal(recipient.asymmetricKeyType, 'rsa'); - assert.equal(recipient.asymmetricKeyDetails.modulusLength, 3072); - const encrypted = sealEvidence(Buffer.from(sentinel), recipient, runnerLogAAD); - assert.equal(encrypted.key_id, runnerLogKeyId); - assert.equal(Buffer.from(encrypted.iv, 'base64').length, 12); - assert.equal(Buffer.from(encrypted.tag, 'base64').length, 16); - assert.equal(Buffer.from(encrypted.wrapped_key, 'base64').length, 384); - assert.equal(Buffer.from(encrypted.ciphertext, 'base64').length, Buffer.byteLength(sentinel)); - assert(!JSON.stringify(encrypted).includes(sentinel)); - const simctl = contextDeviceView('simctl', Buffer.from(JSON.stringify({ devices: { - 'com.apple.CoreSimulator.SimRuntime.iOS-26-5': [{ udid: fixtureExecId(1) }, { udid: fixtureExecId(2) }] } })), fixtureExecId(1).toUpperCase()); - assert.equal(simctl.total_count, 2); assert.equal(simctl.requested_match_count, 1); - const warning = 'WARNING: xcdevice is deprecated. Please use `devicectl list devices` instead.'; - const devices = JSON.stringify([{ identifier: fixtureExecId(1), platform: 'com.apple.platform.iphonesimulator' }, - { identifier: fixtureExecId(2), platform: 'com.apple.platform.macosx' }]); - for (const prefix of ['', warning + '\n', warning + '\r\n']) { - const view = contextDeviceView('xcdevice', Buffer.from(prefix + devices), fixtureExecId(1)); - assert.equal(view.total_count, 2); assert.equal(view.requested_match_count, 1); - } - assert.equal(contextDeviceView('xcdevice', Buffer.from('unknown warning\n' + devices), fixtureExecId(1)), null); - assert.equal(contextDeviceView('xcdevice', Buffer.from('bad JSON'), fixtureExecId(1)), null); - } - const mode = process.argv[2]; - if (mode === 'self-check') { selfCheck(); process.exit(0); } - mkdirSync(privateRoot, { recursive: true, mode: 0o700 }); - if (mode === 'init') { report = initial(); save(); process.exit(0); } - report = JSON.parse(readFileSync(reportPath, 'utf8')); - isolate(); - if (mode === 'run') { - let client; - let simulator; - const setup = await stage('setup', async () => { - assert.equal(process.platform, 'darwin'); - assert.equal(process.arch, 'arm64'); - assert.equal(process.env.AGENT_DEVICE_IOS_RUNNER_DERIVED_PATH, join(state, '.tmp', 'runner-derived')); - assert(!process.env.AGENT_DEVICE_IOS_CLEAN_DERIVED); - const xcode = raw('xcodebuild', ['-version']).trim().match(/^Xcode (\d{1,3}(?:\.\d{1,3}){1,2})\s+Build version ([0-9]{1,3}[A-Z][0-9]{1,6}[a-z]?)$/); - assert(xcode); - report.environment.xcode_version = xcode[1]; - report.environment.xcode_build = xcode[2]; - const sdk = raw('xcrun', ['--sdk', 'iphonesimulator', '--show-sdk-version']).trim(); - assert(/^\d{1,3}(?:\.\d{1,3}){1,2}$/.test(sdk)); - report.environment.simulator_sdk_version = sdk; - const runtimes = JSON.parse(raw('xcrun', ['simctl', 'list', 'runtimes', '--json'])).runtimes - .filter(row => row.isAvailable && row.identifier.includes('.SimRuntime.iOS-')); - assert(runtimes.length > 0); - assert(runtimes.every(row => /^\d{1,3}(?:\.\d{1,3}){1,2}$/.test(row.version))); - const order = (a, b) => { - const left = a.version.split('.').map(Number), right = b.version.split('.').map(Number); - for (let i = 0; i < 3; i++) if ((right[i] ?? 0) !== (left[i] ?? 0)) return (right[i] ?? 0) - (left[i] ?? 0); - return 0; - }; - const runtime = runtimes.sort(order)[0]; - report.environment.simulator_runtime_version = runtime.version; - const types = JSON.parse(raw('xcrun', ['simctl', 'list', 'devicetypes', '--json'])).devicetypes; - const type = types.find(row => row.name === 'iPhone 17' && row.productFamily === 'iPhone'); - assert(type); - const sdkPackage = dependency(); - const { createAgentDeviceClient } = await import(pathToFileURL(sdkPackage.entry).href); - client = createAgentDeviceClient({ session, debug: true }); - simulator = raw('xcrun', ['simctl', 'create', `ios-runner-probe-${process.pid}`, type.identifier, runtime.identifier]).trim(); - assert(/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(simulator)); - writeFileSync(simulatorPath, simulator, { mode: 0o600 }); - raw('xcrun', ['simctl', 'boot', simulator], true); - raw('xcrun', ['simctl', 'bootstatus', simulator, '-b'], true); - }); - const where = { platform: 'ios', udid: simulator }; - if (setup && await stage('prepare', () => client.command.prepare({ action: 'ios-runner', ...where, - requestId: 'probe-prepare' }), safePrepare)) { - if (await stage('open', () => client.apps.open({ app: 'com.apple.Preferences', relaunch: true, - ...where, requestId: 'probe-open' }))) { - await stage('system_snapshot', () => client.capture.snapshot({ interactiveOnly: false, - requestId: 'probe-system_snapshot' }), value => { - const result = safeSnapshot(value); - report.system_snapshot.result = result; - assert(result.node_count > 0 && result.quality !== 'sparse'); - return result; - }); - } - } - report.status = stages.every(name => report[name].status === 'passed') ? 'passed' : 'failed'; - save(); - process.exitCode = report.status === 'passed' ? 0 : 1; - } else if (mode === 'cleanup') { - if (existsSync(join(state, 'daemon.json'))) { - try { - raw(process.execPath, [dependency().cli, 'daemon', 'stop', '--clean'], true); - assert(!existsSync(join(state, 'daemon.json'))); - report.cleanup.daemon_stop = 'passed'; - } - catch { report.cleanup.daemon_stop = 'failed'; } - } else report.cleanup.daemon_stop = 'absent'; - if (existsSync(simulatorPath)) { - const simulator = readFileSync(simulatorPath, 'utf8').trim(); - assert(/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(simulator)); - for (const [command, key] of [['shutdown', 'simulator_shutdown'], ['delete', 'simulator_delete']]) { - try { raw('xcrun', ['simctl', command, simulator], true); report.cleanup[key] = 'passed'; } - catch { report.cleanup[key] = 'failed'; } - } - } else { - report.cleanup.simulator_shutdown = 'absent'; - report.cleanup.simulator_delete = 'absent'; - } - if (report.cleanup.daemon_stop !== 'failed' && report.cleanup.simulator_delete !== 'failed') { - rmSync(state, { recursive: true, force: true }); - report.cleanup.state_removed = !existsSync(state); - } - const clean = report.cleanup.daemon_stop !== 'failed' && report.cleanup.simulator_delete !== 'failed' - && report.cleanup.state_removed; - if (!clean || report.status !== 'passed') report.status = 'failed'; - save(); - process.exitCode = clean ? 0 : 1; - } else throw new Error('Unsupported probe operation'); - NODE - node .artifacts/ios-runner-probe/private/probe.mjs init > .artifacts/ios-runner-probe/private/init.stdout 2> .artifacts/ios-runner-probe/private/init.stderr - node .artifacts/ios-runner-probe/private/probe.mjs self-check > .artifacts/ios-runner-probe/private/self-check.stdout 2> .artifacts/ios-runner-probe/private/self-check.stderr - - name: Install the frozen root dependencies - shell: bash - run: | - umask 077 - pnpm install --frozen-lockfile --filter . > .artifacts/ios-runner-probe/private/install.stdout 2> .artifacts/ios-runner-probe/private/install.stderr - - name: Probe one cold runner and one Settings snapshot - shell: bash - run: | - umask 077 - node .artifacts/ios-runner-probe/private/probe.mjs run > .artifacts/ios-runner-probe/private/driver.stdout 2> .artifacts/ios-runner-probe/private/driver.stderr - - name: Clean up the probe resources - if: always() - shell: bash - run: | - umask 077 - if [ -f .artifacts/ios-runner-probe/private/probe.mjs ]; then - node .artifacts/ios-runner-probe/private/probe.mjs cleanup > .artifacts/ios-runner-probe/private/cleanup.stdout 2> .artifacts/ios-runner-probe/private/cleanup.stderr - fi - - name: Upload only the fixed diagnostic receipt - if: always() - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 - with: - name: ios-runner-probe-${{ github.sha }}-${{ github.run_attempt }} - path: .artifacts/ios-runner-probe/result.json - if-no-files-found: error - retention-days: 7 diff --git a/packages/docs/e2e.md b/packages/docs/e2e.md index 9af594d71..0b6fe4775 100644 --- a/packages/docs/e2e.md +++ b/packages/docs/e2e.md @@ -192,7 +192,7 @@ pnpm exec e2e run --config tests/e2e/e2e.native.config.ts --grep '^provider ' \ --trace off --video off --retries 0 > .artifacts/native/private/ui.log 2>&1 ``` -该用例重新安装当前 App,逐项核对已安装 bundle 与构建 bundle 的文件摘要,包括实际可执行文件、打包 JavaScript 和原生库。它用 e2e Secret 从任务私有文件读取邀请,填写原生“加入链接”表单,再核对双方安全码并授予管理权限。邀请不会作为普通深链接参数传入 UI driver。iOS 的 TextInput 可把 placeholder 或值附在可访问名称后面,因此输入定位使用 textbox 角色和以字段名称开头、带分隔边界的正则,仍要求唯一匹配。已填写值、保存回读和私有命令剪贴板均作精确核对。 +该用例重新安装当前 App,逐项核对已安装 bundle 与构建 bundle 的文件摘要,包括实际可执行文件、打包 JavaScript 和原生库。它用 e2e Secret 从任务私有文件读取邀请,填写原生“加入链接”表单,再核对双方安全码并授予管理权限。邀请不会作为普通深链接参数传入 UI driver。iOS 的 TextInput 可把 placeholder 或值附在可访问名称后面,因此输入定位使用 textbox 角色和以字段名称开头、带分隔边界的正则,仍要求唯一匹配。邀请填写后核对已解码的链接卡片,Secret fill 报错仍使验收失败;原输入可能已被卡片替换,不能保证每次逐字回读邀请。设备名、设置保存回读和私有命令剪贴板均作精确核对。 原生设备页的“Bot 与任务”进入真实 AI 设置页。fixture 只配置受控程序与连接模式,并关闭 Bot 和执行角色,真实返回 `manager=null`。用例先确认未启用的 Codex 尚未主动检查,再开启执行用途;依照 Node 的首次设置默认,这也开启 Bot,用例随后由原生界面关闭 Bot。启用和已有 manager 的 Node 启动都会主动检查,不能把这些结果称为未检查。用例在 execution-only 状态实际检查未登录提示,精确核对从界面复制的私有目录认证命令,由受限 fake CLI 完成一次合成登录,再主动检查并选择、手填和清空执行模型。之后开启 Bot,验证双角色草稿、独立保存、默认模型和 high。它还确认 Provider 控制强度时清除旧覆盖,包括带空白的手填已知模型,以及目录不可用时保留旧模型和强度。所有启用与保存均经已授权手机的正常接口执行。 From ef0ad3d38429bd46bda88244fe7435bbe9a3c852 Mon Sep 17 00:00:00 2001 From: harryisfish Date: Sat, 7 Nov 2026 16:01:01 +0800 Subject: [PATCH 17/34] fix(ci): install directly on verified fresh simulators --- packages/docs/e2e.md | 4 ++-- tests/e2e/native-transfers.e2e.ts | 22 +++++++++++++--------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/packages/docs/e2e.md b/packages/docs/e2e.md index 0b6fe4775..053ffbd97 100644 --- a/packages/docs/e2e.md +++ b/packages/docs/e2e.md @@ -192,7 +192,7 @@ pnpm exec e2e run --config tests/e2e/e2e.native.config.ts --grep '^provider ' \ --trace off --video off --retries 0 > .artifacts/native/private/ui.log 2>&1 ``` -该用例重新安装当前 App,逐项核对已安装 bundle 与构建 bundle 的文件摘要,包括实际可执行文件、打包 JavaScript 和原生库。它用 e2e Secret 从任务私有文件读取邀请,填写原生“加入链接”表单,再核对双方安全码并授予管理权限。邀请不会作为普通深链接参数传入 UI driver。iOS 的 TextInput 可把 placeholder 或值附在可访问名称后面,因此输入定位使用 textbox 角色和以字段名称开头、带分隔边界的正则,仍要求唯一匹配。邀请填写后核对已解码的链接卡片,Secret fill 报错仍使验收失败;原输入可能已被卡片替换,不能保证每次逐字回读邀请。设备名、设置保存回读和私有命令剪贴板均作精确核对。 +该用例仅在 `GITHUB_ACTIONS=true` 且安装前核对 run ID、attempt、simulator 文件、实际唯一 UUID、专属名称和 Booted 状态后,才在本次新建的 simulator 上普通安装当前 App,避免先卸载一个尚未安装的应用。本地仍重新安装;GitHub Actions 缺少元数据,或已有 run ID/attempt 不完整或模拟器身份不符,都会在安装前失败。安装后逐项核对已安装 bundle 与构建 bundle 的文件摘要,包括实际可执行文件、打包 JavaScript 和原生库。它用 e2e Secret 从任务私有文件读取邀请,填写原生“加入链接”表单,再核对双方安全码并授予管理权限。邀请不会作为普通深链接参数传入 UI driver。iOS 的 TextInput 可把 placeholder 或值附在可访问名称后面,因此输入定位使用 textbox 角色和以字段名称开头、带分隔边界的正则,仍要求唯一匹配。邀请填写后核对已解码的链接卡片,Secret fill 报错仍使验收失败;原输入可能已被卡片替换,不能保证每次逐字回读邀请。设备名、设置保存回读和私有命令剪贴板均作精确核对。 原生设备页的“Bot 与任务”进入真实 AI 设置页。fixture 只配置受控程序与连接模式,并关闭 Bot 和执行角色,真实返回 `manager=null`。用例先确认未启用的 Codex 尚未主动检查,再开启执行用途;依照 Node 的首次设置默认,这也开启 Bot,用例随后由原生界面关闭 Bot。启用和已有 manager 的 Node 启动都会主动检查,不能把这些结果称为未检查。用例在 execution-only 状态实际检查未登录提示,精确核对从界面复制的私有目录认证命令,由受限 fake CLI 完成一次合成登录,再主动检查并选择、手填和清空执行模型。之后开启 Bot,验证双角色草稿、独立保存、默认模型和 high。它还确认 Provider 控制强度时清除旧覆盖,包括带空白的手填已知模型,以及目录不可用时保留旧模型和强度。所有启用与保存均经已授权手机的正常接口执行。 @@ -200,7 +200,7 @@ pnpm exec e2e run --config tests/e2e/e2e.native.config.ts --grep '^provider ' \ native config 默认关闭 trace 和整段 video。原始日志、自动失败截图、e2e report、邀请、恢复文件、Node 数据与 driver 状态都属于私有材料,不能递归上传 `.artifacts/native/`。CI 只上传固定的 `provider.json`、`provider-probe.json`、`provider-initial.png`、`provider-selectable.png`、`provider-controlled.png`、`provider-typed.png` 和 `terminology-device-kinds.png`。`provider-probe.json` 只记录首轮检查的 `link`、`readiness`、`authentication`、`catalog` 和 `checked` 五个固定状态字段。 -`provider-initial.png` 是唯一的配对前诊断图。它只在本次 CI 新建的专属 simulator 上,重新安装、清除钥匙串并启动 App 后主动拍摄,且早于首次 `secrets.get` 和邀请输入。用例核对 simulator 文件、实际 UUID、Booted 状态以及包含当前 run ID 和 attempt 的专属名称。此时 App 尚未接收邀请、登录命令或凭证,也没有旧应用数据;初始图只用于查看路由、系统弹窗和空表单。`terminology-device-kinds.png` 在配对后的“添加设备”面板记录节点与客户端分类,其他三张图在配对后的设置页保存。诊断图不代表配对或表单验收通过。导航诊断仅记录固定阶段和已知界面的布尔状态,不输出界面文本、加入链接、命令或剪贴板内容。CI 按固定键与布尔类型校验后,将该诊断并入公开的 `provider.json`,不上传原始页面树或测试日志。最终收据只有在一个目标测试真实通过、fixture 退出、专属 simulator 删除和私有状态清理后才标为 `passed`。 +`provider-initial.png` 是唯一的配对前诊断图。它只在安装前完成身份核验的本次 CI 新建专属 simulator 上,安装、清除钥匙串并启动 App,确认欢迎页后主动拍摄,且早于首次 `secrets.get` 和邀请输入。此时 App 尚未接收邀请、登录命令或凭证,也没有旧应用数据;初始图只用于查看路由、系统弹窗和空表单。`terminology-device-kinds.png` 在配对后的“添加设备”面板记录节点与客户端分类,其他三张图在配对后的设置页保存。诊断图不代表配对或表单验收通过。导航诊断仅记录固定阶段和已知界面的布尔状态,不输出界面文本、加入链接、命令或剪贴板内容。CI 按固定键与布尔类型校验后,将该诊断并入公开的 `provider.json`,不上传原始页面树或测试日志。最终收据只有在一个目标测试真实通过、fixture 退出、专属 simulator 删除和私有状态清理后才标为 `passed`。 失败收据与 stdout 保留固定阶段、报告是否可读,以及从实际 e2e report 提取的受限错误码、固定 `engine_reason` 和 `engine_timeout_kind`、已知 API 名和两个验收文件的行号。`completed_poll_samples` 只来自唯一合法的既有 expect 采样事件;零表示没有记录完成的采样,字段缺失不补零。错误 message、stack、locator label、值和原始报告不会导出。 diff --git a/tests/e2e/native-transfers.e2e.ts b/tests/e2e/native-transfers.e2e.ts index fd3af6d9a..e53a7a0b1 100644 --- a/tests/e2e/native-transfers.e2e.ts +++ b/tests/e2e/native-transfers.e2e.ts @@ -158,8 +158,20 @@ test('provider settings and queued cancellation work in the installed native app await assert.rejects(network.call({ op: 'native_provider_setup' })); await assert.rejects(network.call({ op: 'native_provider_stage', stage: 'invalid' })); await assert.rejects(network.call({ op: 'native_provider_stage', stage: 'ready', role: 'source' })); + const ci = process.env.GITHUB_ACTIONS === 'true'; + const run = process.env.GITHUB_RUN_ID, attempt = process.env.GITHUB_RUN_ATTEMPT; + if (ci || run !== undefined || attempt !== undefined) { + assert(run && attempt && /^[0-9]+$/.test(run) && /^[0-9]+$/.test(attempt)); + assert.equal((await readFile(resolve(root, '.artifacts/native/simulator.txt'), 'utf8')).trim(), simulator); + const devices = record(record(JSON.parse((await execute('xcrun', ['simctl', 'list', 'devices', '--json'])).stdout)).devices); + const assigned = Object.values(devices).flatMap(rows => { assert(Array.isArray(rows)); return rows.map(record); }).filter(row => row.udid === simulator); + assert.equal(assigned.length, 1); + assert.equal(assigned[0].name, `vibeface-provider-${run}-${attempt}`); + assert.equal(assigned[0].state, 'Booted'); + } try { - await device.installApp(undefined, { reinstall: true }); + if (ci) await device.installApp(); + else await device.installApp(undefined, { reinstall: true }); } catch (cause) { const failures: Record[] = []; for (let error: unknown = cause, depth = 0; error instanceof Error && depth < 8; error = error.cause, depth++) { @@ -192,15 +204,7 @@ test('provider settings and queued cancellation work in the installed native app await device.clearKeychain(); await app.open(); await expect(screen.getByText('连接你的网络', { exact: true })).toBeVisible({ timeout: 30000 }); - const run = process.env.GITHUB_RUN_ID, attempt = process.env.GITHUB_RUN_ATTEMPT; if (run !== undefined || attempt !== undefined) { - assert(run && attempt && /^[0-9]+$/.test(run) && /^[0-9]+$/.test(attempt)); - assert.equal((await readFile(resolve(root, '.artifacts/native/simulator.txt'), 'utf8')).trim(), simulator); - const devices = record(record(JSON.parse((await execute('xcrun', ['simctl', 'list', 'devices', '--json'])).stdout)).devices); - const assigned = Object.values(devices).flatMap(rows => { assert(Array.isArray(rows)); return rows.map(record); }).filter(row => row.udid === simulator); - assert.equal(assigned.length, 1); - assert.equal(assigned[0].name, `vibeface-provider-${run}-${attempt}`); - assert.equal(assigned[0].state, 'Booted'); await copyFile(await app.screenshot('provider-initial'), join(publicPath, 'provider-initial.png')); } await screen.getByRole('textbox', /^加入链接(?:$|[\s,,])/).fill(secrets.get('nativeInvitation'), { timeout: 30000 }); From fae9f4071ad4acb9a75a9efc26b06c5f5bcffd20 Mon Sep 17 00:00:00 2001 From: harryisfish Date: Sun, 8 Nov 2026 02:36:24 +0800 Subject: [PATCH 18/34] fix(ci): align native acceptance with deferred inputs Verify native deferred input cancellation through the queue sheet and owner receipt before stopping active work. Preserve bounded startup errors when the runner cannot produce a report. --- .github/workflows/mobile.yml | 16 ++++- packages/docs/e2e.md | 4 +- scripts/verify-node.py | 66 ++++++++++++++++--- tests/e2e/native-transfers.e2e.ts | 101 ++++++++++++++++++++++++++---- 4 files changed, 162 insertions(+), 25 deletions(-) diff --git a/.github/workflows/mobile.yml b/.github/workflows/mobile.yml index c8f13c956..04cf69550 100644 --- a/.github/workflows/mobile.yml +++ b/.github/workflows/mobile.yml @@ -237,6 +237,7 @@ jobs: pnpm exec e2e run --config tests/e2e/e2e.native.config.ts --grep '^provider ' --action-timeout 240000 --trace off --video off --retries 0 > .artifacts/native/private/ui.log 2>&1 result=$? set -e + printf '%s\n' "$result" > .artifacts/native/private/ui-exit-code.txt echo "Native Provider e2e exit code: $result" exit "$result" - name: Clean up this task and require final UI acceptance @@ -278,7 +279,7 @@ jobs: code = error.get("code") result = {"code": code if isinstance(code, str) and re.fullmatch(r"[A-Z][A-Z0-9_]{0,63}", code) else "UNCLASSIFIED_ERROR"} message = error.get("message") - if code == "ENGINE_FAILURE" and isinstance(message, str): + if code in {"ENGINE_FAILURE", "ENVIRONMENT_UNAVAILABLE"} and isinstance(message, str): lowered = message.lower() result["engine_timeout_kind"] = next((kind for needle, kind in ( ("timed out while reading snapshot viewport on the xctest main thread", "snapshot-viewport"), @@ -330,6 +331,19 @@ jobs: runner_root = pathlib.Path("tests/e2e/.artifacts/native") report_path = runner_root / "e2e/report.json" + exit_path = root / "private/ui-exit-code.txt" + if exit_path.exists(): + value = exit_path.read_text().strip() + if re.fullmatch(r"[0-9]{1,3}", value) and int(value) <= 255: + diagnostics["runner_exit_code"] = int(value) + if not report_path.exists() and ui_log.exists(): + logged = ui_log.read_text(errors="replace") + for code in ("ENVIRONMENT_UNAVAILABLE", "ENGINE_FAILURE", "CONFIG_LOAD_FAILED", "INVALID_CONFIG", "SESSION_UNAVAILABLE", "SESSION_CONTRACT", "INTERNAL_ERROR"): + match = re.search(r"(?m)^" + code + r": ([^\n]*)", logged) + if match: + diagnostics["failures"].append(safe_error({"code": code, "message": match[1]})) + break + if report_path.exists(): try: run = json.loads(report_path.read_text())["run"] diff --git a/packages/docs/e2e.md b/packages/docs/e2e.md index 93af0a396..64dc33d76 100644 --- a/packages/docs/e2e.md +++ b/packages/docs/e2e.md @@ -207,6 +207,8 @@ pnpm exec e2e run --config tests/e2e/e2e.workspace.native.config.ts workspace.na 本地运行使用上节的四个明确产物与 simulator 环境变量,并补充当前源码身份。仅选择 Provider 用例,不运行公益文件用例。 +使用 simslim 做键盘验收时保留 `siri` 分组。它包含听写和语音服务,关闭后可能干扰输入及可访问性快照。 + ```sh umask 077 mkdir -p .artifacts/native/private @@ -219,7 +221,7 @@ pnpm exec e2e run --config tests/e2e/e2e.native.config.ts --grep '^provider ' \ 原生设备页的“Bot 与任务”进入真实 AI 设置页。fixture 只配置受控程序与连接模式,并关闭 Bot 和执行角色,真实返回 `manager=null`。用例先确认未启用的 Codex 尚未主动检查,再开启执行用途;依照 Node 的首次设置默认,这也开启 Bot,用例随后由原生界面关闭 Bot。启用和已有 manager 的 Node 启动都会主动检查,不能把这些结果称为未检查。用例在 execution-only 状态实际检查未登录提示,精确核对从界面复制的私有目录认证命令,由受限 fake CLI 完成一次合成登录,再主动检查并选择、手填和清空执行模型。之后开启 Bot,验证双角色草稿、独立保存、默认模型和 high。它还确认 Provider 控制强度时清除旧覆盖,包括带空白的手填已知模型,以及目录不可用时保留旧模型和强度。所有启用与保存均经已授权手机的正常接口执行。 -队列场景通过真实 Node API 准备一条运行中消息和一条排队消息。原生 UI 取消排队后,再通过原生“停止”结束运行中的消息并释放槽位。独立读取确认运行中的消息调用过一次,被取消的消息始终没有调用,离开再进入聊天后计数保持不变。受控 fixture 不调用真实模型,也不代替手机保存、取消或停止。 +队列场景通过真实 Node API 准备一条运行中消息和同一目标的一条 defer 输入。原生 UI 在“目标和队列”弹层取消稍后输入后,独立读取同一 message、target 的输入和 owner 回执,确认 cancelled=true、reason=cancelled_before_delivery,且运行中的消息仍在运行。随后通过原生“停止”结束运行中的消息。独立读取确认运行中的消息调用过一次,被取消的 defer 输入始终没有调用,离开再进入聊天后取消事实与计数保持不变。受控 fixture 不调用真实模型,也不代替手机保存设置、取消或停止。 native config 默认关闭 trace 和整段 video。原始日志、自动失败截图、e2e report、邀请、恢复文件、Node 数据与 driver 状态都属于私有材料,不能递归上传 `.artifacts/native/`。CI 只上传固定的 `provider.json`、`provider-probe.json`、`provider-initial.png`、`provider-selectable.png`、`provider-controlled.png`、`provider-typed.png` 和 `terminology-device-kinds.png`。`provider-probe.json` 只记录首轮检查的 `link`、`readiness`、`authentication`、`catalog` 和 `checked` 五个固定状态字段。 diff --git a/scripts/verify-node.py b/scripts/verify-node.py index ba54ac4f8..89c211bc1 100755 --- a/scripts/verify-node.py +++ b/scripts/verify-node.py @@ -8569,6 +8569,32 @@ def details(): for role, node in nodes.items() }, **({"gates": {name: str(path) for name, path in workspace_gates.items()}} if workspace_gates else {})} + def native_deferred_input(client): + if native_queue is None: + return None + rows = [row for row in client.rpc("workspace_state")["inputs"] + if row["input"]["message_id"] == native_queue["deferred_message_id"]] + require(len(rows) == 1, "the native deferred message has one real workspace input") + queued = rows[0] + saved = queued["input"] + require(queued["conversation_id"] == native_queue["conversation_id"] + and saved["target"] == native_queue["target"] and saved["intent"] == "defer", + "the native deferred input preserves its exact conversation, target and intent") + require(all(isinstance(queued[key], str) and re.fullmatch(r"[0-9a-f]{64}", queued[key]) + for key in ("source_event", "control_event")) + and type(queued["deferred"]) is bool and type(queued["cancelled"]) is bool, + "the native deferred input has exact control events and boolean state") + receipt = client.rpc("input_receipt", conversation_id=queued["conversation_id"], + message_id=saved["message_id"], target=saved["target"]) + require(receipt["message_id"] == saved["message_id"] and receipt["target"] == saved["target"] + and receipt["control_event"] == queued["control_event"], + "the owner receipt identifies the exact native deferred input and control event") + return {"message_id": saved["message_id"], "conversation_id": queued["conversation_id"], + "target": saved["target"], "intent": saved["intent"], + **{key: queued[key] for key in ("deferred", "cancelled", "source_event", "control_event")}, + "receipt": {key: receipt[key] for key in + ("message_id", "target", "control_event", "stage", "reason", "actual_turn_id", "retry_safe")}} + def stop(*_): raise SystemExit(0) @@ -8796,23 +8822,40 @@ def revealed(): require(manager is not None and manager["provider"] == "codex", "the native UI must enable the controlled manager before queue preparation") native_queue = {"bot_id": "native-provider", "conversation_id": "native-provider", - "running_trigger": "message:native-running", "queued_trigger": "message:native-queued"} + "target": {"kind": "bot_main", "bot_id": "native-provider"}, + "running_trigger": "message:native-running", "deferred_message_id": "native-deferred"} client.rpc("create_bot", bot_id=native_queue["bot_id"], conversation_id=native_queue["conversation_id"], name="Native Provider", instructions="Controlled native acceptance", project=None) - for label in ("native-running", "native-queued"): + for label in ("native-running", native_queue["deferred_message_id"]): directive = {"phase1": True, "label": label} if label == "native-running": directive["gate"] = str(run / "native-never-release") receipt = client.rpc("message", conversation_id=native_queue["conversation_id"], - message_id=label, text=json.dumps(directive), report_results=False) - require(receipt["trigger"] == "message:" + label, "native queue preserves the accepted trigger") - wait_for("native message reaches its actual queue state", lambda: - any(job["trigger"] == receipt["trigger"] and job["state"] == ("running" if label == "native-running" else "queued") - for job in client.rpc("conversation", conversation_id=native_queue["conversation_id"])["scheduler"]["jobs"])) + message_id=label, target=native_queue["target"], + intent="continue" if label == "native-running" else "defer", + text=json.dumps(directive), report_results=False) + require(receipt["accepted"] is True and receipt["message_id"] == label + and receipt["trigger"] == "message:" + label + and receipt["receipt"]["network_id"] == client.network_id + and receipt["receipt"]["conversation_id"] == native_queue["conversation_id"] + and receipt["receipt"]["trigger"] == receipt["trigger"] + and receipt["receipt"]["state"] == receipt["state"], + "native messages preserve their exact accepted admission identity") if label == "native-running": + wait_for("native message reaches its actual running state", lambda: + any(job["trigger"] == receipt["trigger"] and job["state"] == "running" + for job in client.rpc("conversation", conversation_id=native_queue["conversation_id"])["scheduler"]["jobs"])) wait_for("the native queue has one positive controlled invocation", lambda: len([row for row in fixture_records(run) if row["conversation_id"] == native_queue["conversation_id"] and row["trigger"] == native_queue["running_trigger"]]) == 1) + else: + require(receipt["state"] == "deferred", "the native second message is saved as a deferred input") + deferred = native_deferred_input(client) + require(deferred["deferred"] is True and deferred["cancelled"] is False + and deferred["source_event"] == deferred["control_event"] + and deferred["receipt"]["stage"] == "owner_accepted" and deferred["receipt"]["reason"] == "deferred" + and deferred["receipt"]["actual_turn_id"] is None and deferred["receipt"]["retry_safe"] is False, + "the real owner confirms its unsent native deferred input") result = native_queue elif op == "native_provider_inspect": require(set(request) == {"op"} and native_provider, "native inspection reads only its controlled receiver") @@ -8822,6 +8865,8 @@ def revealed(): manager = settings["settings"]["manager"] jobs = client.rpc("conversation", conversation_id=native_queue["conversation_id"])["scheduler"]["jobs"] if native_queue else [] calls = [row for row in fixture_records(run) if native_queue and row["conversation_id"] == native_queue["conversation_id"]] + running_trigger = native_queue["running_trigger"] if native_queue else None + deferred_trigger = "message:" + native_queue["deferred_message_id"] if native_queue else None result = {"manager": {key: manager[key] for key in ("provider", "model", "reasoning_effort")} if manager is not None else None, "roles": provider["roles"], "execution_model": provider["execution_model"], "setup": provider["setup"], "login_count": len(fixture_records(run, "native-provider-login.jsonl")), @@ -8830,9 +8875,10 @@ def revealed(): "authentication": provider["probe"]["authentication"], "checked_at_ms": provider["probe"]["checked_at_ms"], "jobs": [{"trigger": row["trigger"], "state": row["state"]} for row in jobs - if row["trigger"] in (native_queue["running_trigger"], native_queue["queued_trigger"])], - "running_invocations": sum(row["trigger"] == native_queue["running_trigger"] for row in calls), - "queued_invocations": sum(row["trigger"] == native_queue["queued_trigger"] for row in calls)} + if row["trigger"] in (running_trigger, deferred_trigger)], + "deferred_input": native_deferred_input(client), + "running_invocations": sum(row["trigger"] == running_trigger for row in calls), + "deferred_invocations": sum(row["trigger"] == deferred_trigger for row in calls)} elif op == "native_send": require(native_ready, "native delivery is scoped to the initialized fixture") intent = str(uuid.uuid4()) diff --git a/tests/e2e/native-transfers.e2e.ts b/tests/e2e/native-transfers.e2e.ts index e53a7a0b1..c8b0b47a8 100644 --- a/tests/e2e/native-transfers.e2e.ts +++ b/tests/e2e/native-transfers.e2e.ts @@ -106,7 +106,32 @@ async function bundleManifest(directory: string): Promise return files; } +function providerDeferredInput(value: unknown) { + if (value === null) return null; + const input = record(value), receipt = record(input.receipt); + assert.deepEqual(Object.keys(input).sort(), ['message_id', 'conversation_id', 'target', 'intent', 'deferred', 'cancelled', 'source_event', 'control_event', 'receipt'].sort()); + assert(input.message_id === 'native-deferred' && input.conversation_id === 'native-provider' && input.intent === 'defer'); + assert.deepEqual(input.target, { kind: 'bot_main', bot_id: 'native-provider' }); + assert(typeof input.deferred === 'boolean' && typeof input.cancelled === 'boolean'); + const sourceEvent = text(input.source_event), controlEvent = text(input.control_event); + assert(/^[0-9a-f]{64}$/.test(sourceEvent) && /^[0-9a-f]{64}$/.test(controlEvent)); + assert.deepEqual(Object.keys(receipt).sort(), ['message_id', 'target', 'control_event', 'stage', 'reason', 'actual_turn_id', 'retry_safe'].sort()); + assert(receipt.message_id === input.message_id && receipt.control_event === controlEvent); + assert.deepEqual(receipt.target, input.target); + const stage = text(receipt.stage); + assert(['entry_accepted', 'owner_accepted', 'submitting', 'provider_accepted', 'associated', 'refused', 'unknown'].includes(stage)); + assert(receipt.reason === null || typeof receipt.reason === 'string'); + assert(receipt.actual_turn_id === null || typeof receipt.actual_turn_id === 'string' && receipt.actual_turn_id.length > 0); + assert(typeof receipt.retry_safe === 'boolean' && (stage !== 'unknown' || receipt.retry_safe === false)); + return { message_id: input.message_id, conversation_id: input.conversation_id, + target: { kind: 'bot_main', bot_id: 'native-provider' }, intent: input.intent, + deferred: input.deferred, cancelled: input.cancelled, source_event: sourceEvent, control_event: controlEvent, + receipt: { message_id: receipt.message_id, target: { kind: 'bot_main', bot_id: 'native-provider' }, control_event: controlEvent, + stage, reason: receipt.reason, actual_turn_id: receipt.actual_turn_id, retry_safe: receipt.retry_safe } }; +} + function providerInspection(value: Record) { + assert.deepEqual(Object.keys(value).sort(), ['manager', 'roles', 'execution_model', 'setup', 'login_count', 'app_server_link_state', 'readiness', 'catalog', 'authentication', 'checked_at_ms', 'jobs', 'deferred_input', 'running_invocations', 'deferred_invocations'].sort()); let manager: { provider: string; model: string; reasoning_effort: string | null } | null = null; if (value.manager !== null) { const saved = record(value.manager); @@ -117,7 +142,7 @@ function providerInspection(value: Record) { assert(value.checked_at_ms === null || typeof value.checked_at_ms === 'number' && Number.isSafeInteger(value.checked_at_ms) && value.checked_at_ms >= 0); assert(Array.isArray(value.jobs)); assert(typeof value.running_invocations === 'number' && Number.isSafeInteger(value.running_invocations) && value.running_invocations >= 0); - assert(typeof value.queued_invocations === 'number' && Number.isSafeInteger(value.queued_invocations) && value.queued_invocations >= 0); + assert(typeof value.deferred_invocations === 'number' && Number.isSafeInteger(value.deferred_invocations) && value.deferred_invocations >= 0); assert(Array.isArray(value.roles) && value.roles.every(role => role === 'agent' || role === 'execution')); assert(typeof value.execution_model === 'string'); assert(typeof value.login_count === 'number' && Number.isSafeInteger(value.login_count) && value.login_count >= 0); @@ -129,10 +154,11 @@ function providerInspection(value: Record) { app_server_link_state: link, readiness: text(value.readiness), authentication: text(value.authentication), catalog: text(value.catalog), checked_at_ms: value.checked_at_ms, checked: value.checked_at_ms !== null, jobs: value.jobs.map((item: unknown) => { const job = record(item); return { trigger: text(job.trigger), state: text(job.state) }; }), - running_invocations: value.running_invocations, queued_invocations: value.queued_invocations }; + deferred_input: providerDeferredInput(value.deferred_input), + running_invocations: value.running_invocations, deferred_invocations: value.deferred_invocations }; } -test('provider settings and queued cancellation work in the installed native app', { platforms: ['ios'], timeout: 600000 }, async ({ app, device, network, screen }) => { +test('provider settings and deferred input cancellation work in the installed native app', { platforms: ['ios'], timeout: 600000 }, async ({ app, device, network, screen }) => { const simulator = process.env.VIBEFACE_E2E_SIMULATOR, appPath = process.env.VIBEFACE_E2E_IOS_APP; const source = process.env.VIBEFACE_E2E_SOURCE_COMMIT; const binary = process.env.VIBEFACE_E2E_BINARY, crypto = process.env.VIBEFACE_E2E_CRYPTO_MODULE; @@ -471,27 +497,76 @@ test('provider settings and queued cancellation work in the installed native app await save('native-selectable', 'high'); const queue = await network.call({ op: 'native_provider_queue' }); await assert.rejects(network.call({ op: 'native_provider_queue' })); - const botId = text(queue.bot_id), runningTrigger = text(queue.running_trigger), queuedTrigger = text(queue.queued_trigger); + assert.deepEqual(Object.keys(queue).sort(), ['bot_id', 'conversation_id', 'target', 'running_trigger', 'deferred_message_id'].sort()); + const botId = text(queue.bot_id), conversationId = text(queue.conversation_id); + const runningTrigger = text(queue.running_trigger), deferredMessageId = text(queue.deferred_message_id); + assert(botId === 'native-provider' && conversationId === 'native-provider' + && runningTrigger === 'message:native-running' && deferredMessageId === 'native-deferred'); + const target = { kind: 'bot_main', bot_id: botId }; + assert.deepEqual(queue.target, target); + const prepared = await inspect(), deferred = prepared.deferred_input; + assert(deferred, 'The fixture reads the real deferred input and its owner receipt'); + expect(prepared.jobs).toEqual([{ trigger: runningTrigger, state: 'running' }]); + expect(prepared.running_invocations).toBe(1); + expect(prepared.deferred_invocations).toBe(0); + expect(deferred).toEqual({ message_id: deferredMessageId, conversation_id: conversationId, target, intent: 'defer', + deferred: true, cancelled: false, source_event: deferred.source_event, control_event: deferred.source_event, + receipt: { message_id: deferredMessageId, target, control_event: deferred.source_event, + stage: 'owner_accepted', reason: 'deferred', actual_turn_id: null, retry_safe: false } }); const composer = screen.getByRole('textbox', /^给 Bot 发消息(?:$|[\s,,])/, { visible: true }); await openLink(`vibeface://b/${botId}`, composer); - const cancel = screen.getByRole('button', '取消排队', { exact: true }); - await screen.scrollUntilVisible(cancel, { direction: 'up', timeout: 30000 }); + const targetSheet = screen.getByTestId('input-options-sheet', { visible: true }); + await screen.getByRole('button', /^输入目标 Native Provider · 主聊天,/, { visible: true }).click(); + await expect(targetSheet).toHaveCount(1); + const queued = targetSheet.getByText('稍后处理 1 条', { exact: true }); + const cancel = targetSheet.getByRole('button', '取消稍后输入', { exact: true, visible: true }); + const queueScroll = device.locator('role=scroll-area').filter({ + has: screen.getByRole('button', '取消稍后输入', { exact: true }), + }); + await expect(queueScroll).toHaveCount(1); + await queueScroll.scrollUntilVisible(queued, { direction: 'down' }); + await expect(queued).toBeVisible(); + await queueScroll.scrollUntilVisible(cancel, { direction: 'down' }); + await expect(cancel).toHaveCount(1); + await expect(cancel).toBeEnabled(); + let previousCancelBounds = ''; + await expect.poll(async () => { + const bounds = await cancel.boundingBox(), pane = await queueScroll.boundingBox(); + assert(bounds && pane, 'Deferred input Cancel and its scroll pane expose bounds'); + const observed = JSON.stringify([bounds, pane]), stable = observed === previousCancelBounds; + previousCancelBounds = observed; + return stable && bounds.x >= pane.x && bounds.y >= pane.y && bounds.x + bounds.width <= pane.x + pane.width && bounds.y + bounds.height <= pane.y + pane.height; + }).toBe(true); await cancel.click(); - await expect.poll(async () => (await inspect()).jobs.find(job => job.trigger === queuedTrigger)?.state, { timeout: 15000 }).toBe('cancelled'); - expect((await inspect()).queued_invocations).toBe(0); + await expect.poll(async () => (await inspect()).deferred_input?.cancelled, { timeout: 15000 }).toBe(true); + const cancelled = await inspect(), cancelledInput = cancelled.deferred_input; + assert(cancelledInput); + expect(cancelledInput).toEqual({ ...deferred, cancelled: true, control_event: cancelledInput.control_event, + receipt: { ...deferred.receipt, control_event: cancelledInput.control_event, stage: 'refused', reason: 'cancelled_before_delivery' } }); + expect(cancelledInput.control_event).not.toBe(deferred.control_event); + expect(cancelled.jobs).toEqual(prepared.jobs); + expect(cancelled.running_invocations).toBe(1); + expect(cancelled.deferred_invocations).toBe(0); + await expect(queued).toHaveCount(0); + await expect(cancel).toHaveCount(0); + await expect(targetSheet).toHaveCount(1); + await targetSheet.getByRole('button', '关闭目标和队列', { exact: true }).click(); + await expect(targetSheet).toHaveCount(0); await screen.getByRole('button', '停止', { exact: true }).click(); await expect.poll(async () => (await inspect()).jobs.find(job => job.trigger === runningTrigger)?.state, { timeout: 30000 }).toBe('cancelled'); await expect(screen.getByRole('button', '停止', { exact: true })).toBeHidden(); const after = await inspect(); + expect(after.deferred_input).toEqual(cancelledInput); expect(after.running_invocations).toBe(1); - expect(after.queued_invocations).toBe(0); + expect(after.deferred_invocations).toBe(0); await openLink('vibeface://settings', screen.getByText('我的设备', { exact: true, visible: true })); await openLink(`vibeface://b/${botId}`, composer); await expect(screen.getByRole('textbox', /^给 Bot 发消息(?:$|[\s,,])/)).toBeVisible(); const reopened = await inspect(); expect(reopened.jobs).toEqual(after.jobs); + expect(reopened.deferred_input).toEqual(cancelledInput); expect(reopened.running_invocations).toBe(1); - expect(reopened.queued_invocations).toBe(0); + expect(reopened.deferred_invocations).toBe(0); expect(reopened.execution_model).toBe(''); expect(reopened.login_count).toBe(1); expect(await bundleManifest(installedPath)).toEqual(built); @@ -515,9 +590,9 @@ test('provider settings and queued cancellation work in the installed native app private_login_command_copied_exactly: true, controlled_bin_and_private_codex_home_verified: true, synthetic_login_count: reopened.login_count, native_authenticated_recheck: true, trimmed_controlled_cleared_effort: true, real_provider_model_calls: 0, not_checked: ['real Provider authentication', 'Claude-specific native login'], - running_trigger: runningTrigger, queued_trigger: queuedTrigger, jobs: reopened.jobs, - running_invocations: reopened.running_invocations, queued_invocations: reopened.queued_invocations, - native_cancelled_queue: true, native_stopped_running: true, reopened_without_execution: true }, null, 2)}\n`, { mode: 0o600 }); + running_trigger: runningTrigger, deferred_message_id: deferredMessageId, deferred_input: reopened.deferred_input, jobs: reopened.jobs, + running_invocations: reopened.running_invocations, deferred_invocations: reopened.deferred_invocations, + native_cancelled_deferred_input: true, native_stopped_running: true, reopened_without_execution: true }, null, 2)}\n`, { mode: 0o600 }); }); test('receives a charity file through a real native pairing and verifies the saved bytes', { platforms: ['ios'], timeout: 240000 }, async ({ app, device, network, screen }) => { From 9d489d04036b62a7e42fc69256d7412a489135ff Mon Sep 17 00:00:00 2001 From: harryisfish Date: Sun, 8 Nov 2026 02:51:25 +0800 Subject: [PATCH 19/34] fix(e2e): correct deferred input retry safety Expect a releasable deferred input before cancellation and an explicit unsafe-to-retry receipt after cancellation, matching the Core contract. --- scripts/verify-node.py | 2 +- tests/e2e/native-transfers.e2e.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/verify-node.py b/scripts/verify-node.py index 89c211bc1..41de7970a 100755 --- a/scripts/verify-node.py +++ b/scripts/verify-node.py @@ -8854,7 +8854,7 @@ def revealed(): require(deferred["deferred"] is True and deferred["cancelled"] is False and deferred["source_event"] == deferred["control_event"] and deferred["receipt"]["stage"] == "owner_accepted" and deferred["receipt"]["reason"] == "deferred" - and deferred["receipt"]["actual_turn_id"] is None and deferred["receipt"]["retry_safe"] is False, + and deferred["receipt"]["actual_turn_id"] is None and deferred["receipt"]["retry_safe"] is True, "the real owner confirms its unsent native deferred input") result = native_queue elif op == "native_provider_inspect": diff --git a/tests/e2e/native-transfers.e2e.ts b/tests/e2e/native-transfers.e2e.ts index c8b0b47a8..3635fdeed 100644 --- a/tests/e2e/native-transfers.e2e.ts +++ b/tests/e2e/native-transfers.e2e.ts @@ -512,7 +512,7 @@ test('provider settings and deferred input cancellation work in the installed na expect(deferred).toEqual({ message_id: deferredMessageId, conversation_id: conversationId, target, intent: 'defer', deferred: true, cancelled: false, source_event: deferred.source_event, control_event: deferred.source_event, receipt: { message_id: deferredMessageId, target, control_event: deferred.source_event, - stage: 'owner_accepted', reason: 'deferred', actual_turn_id: null, retry_safe: false } }); + stage: 'owner_accepted', reason: 'deferred', actual_turn_id: null, retry_safe: true } }); const composer = screen.getByRole('textbox', /^给 Bot 发消息(?:$|[\s,,])/, { visible: true }); await openLink(`vibeface://b/${botId}`, composer); const targetSheet = screen.getByTestId('input-options-sheet', { visible: true }); @@ -542,7 +542,7 @@ test('provider settings and deferred input cancellation work in the installed na const cancelled = await inspect(), cancelledInput = cancelled.deferred_input; assert(cancelledInput); expect(cancelledInput).toEqual({ ...deferred, cancelled: true, control_event: cancelledInput.control_event, - receipt: { ...deferred.receipt, control_event: cancelledInput.control_event, stage: 'refused', reason: 'cancelled_before_delivery' } }); + receipt: { ...deferred.receipt, control_event: cancelledInput.control_event, stage: 'refused', reason: 'cancelled_before_delivery', retry_safe: false } }); expect(cancelledInput.control_event).not.toBe(deferred.control_event); expect(cancelled.jobs).toEqual(prepared.jobs); expect(cancelled.running_invocations).toBe(1); From e9c602e528ec19f34d68b578ed2221fd7f00008c Mon Sep 17 00:00:00 2001 From: harryisfish Date: Sun, 8 Nov 2026 03:26:22 +0800 Subject: [PATCH 20/34] fix(ci): stabilize control fixtures and preserve mobile diagnostics Use immutable control test executables to avoid Linux ETXTBSY races. Capture structured iOS runner output for diagnosis while requiring the canonical report for acceptance. --- .github/workflows/mobile.yml | 11 +++++++---- crates/control/src/lib.rs | 18 ++++-------------- .../tests/fixtures/control-nonzero-response.sh | 4 ++++ .../tests/fixtures/control-oversized-output.sh | 2 ++ 4 files changed, 17 insertions(+), 18 deletions(-) create mode 100755 crates/control/tests/fixtures/control-nonzero-response.sh create mode 100755 crates/control/tests/fixtures/control-oversized-output.sh diff --git a/.github/workflows/mobile.yml b/.github/workflows/mobile.yml index 04cf69550..b31118dd0 100644 --- a/.github/workflows/mobile.yml +++ b/.github/workflows/mobile.yml @@ -234,7 +234,7 @@ jobs: PY printf '%s\n' ui-run > .artifacts/native/private/stage.txt set +e - pnpm exec e2e run --config tests/e2e/e2e.native.config.ts --grep '^provider ' --action-timeout 240000 --trace off --video off --retries 0 > .artifacts/native/private/ui.log 2>&1 + pnpm exec e2e run --config tests/e2e/e2e.native.config.ts --grep '^provider ' --action-timeout 240000 --trace off --video off --retries 0 --reporter json > .artifacts/native/private/ui.json 2> .artifacts/native/private/ui.log result=$? set -e printf '%s\n' "$result" > .artifacts/native/private/ui-exit-code.txt @@ -331,12 +331,13 @@ jobs: runner_root = pathlib.Path("tests/e2e/.artifacts/native") report_path = runner_root / "e2e/report.json" + canonical_report = report_path.exists() exit_path = root / "private/ui-exit-code.txt" if exit_path.exists(): value = exit_path.read_text().strip() if re.fullmatch(r"[0-9]{1,3}", value) and int(value) <= 255: diagnostics["runner_exit_code"] = int(value) - if not report_path.exists() and ui_log.exists(): + if not canonical_report and ui_log.exists(): logged = ui_log.read_text(errors="replace") for code in ("ENVIRONMENT_UNAVAILABLE", "ENGINE_FAILURE", "CONFIG_LOAD_FAILED", "INVALID_CONFIG", "SESSION_UNAVAILABLE", "SESSION_CONTRACT", "INTERNAL_ERROR"): match = re.search(r"(?m)^" + code + r": ([^\n]*)", logged) @@ -344,12 +345,14 @@ jobs: diagnostics["failures"].append(safe_error({"code": code, "message": match[1]})) break + if not canonical_report: + report_path = root / "private/ui.json" if report_path.exists(): try: run = json.loads(report_path.read_text())["run"] - diagnostics["report"] = "present" + diagnostics["report"] = "present" if canonical_report else "stdout_only" summary = run["summary"] - selected_passed = run["exitCode"] == 0 and not run["errors"] and summary["selected"] == summary["passed"] == 1 and all( + selected_passed = canonical_report and run["exitCode"] == 0 and not run["errors"] and summary["selected"] == summary["passed"] == 1 and all( summary[key] == 0 for key in ("failed", "skipped", "interrupted", "flaky")) failures = [safe_error(error) for error in run["errors"]] for result in run["results"]: diff --git a/crates/control/src/lib.rs b/crates/control/src/lib.rs index ee5b09850..bf1e4df40 100644 --- a/crates/control/src/lib.rs +++ b/crates/control/src/lib.rs @@ -235,14 +235,11 @@ pub mod maintenance; #[cfg(all(test, unix))] mod tests { use super::*; - use std::os::unix::fs::PermissionsExt; #[tokio::test] async fn control_client_bounds_child_output_before_waiting_for_exit() -> Result<()> { - let path = - std::env::temp_dir().join(format!("vibeface-control-output-{}", uuid::Uuid::new_v4())); - std::fs::write(&path, b"#!/bin/sh\nhead -c 1048577 /dev/zero\n")?; - std::fs::set_permissions(&path, std::fs::Permissions::from_mode(0o700))?; + let path = Path::new(env!("CARGO_MANIFEST_DIR")) + .join("tests/fixtures/control-oversized-output.sh"); let error = request( &path, &ControlRequest::Inspect { @@ -252,19 +249,13 @@ mod tests { .await .expect_err("oversized child output must be rejected"); assert!(error.to_string().contains("stdout exceeds"), "{error:#}"); - std::fs::remove_file(path)?; Ok(()) } #[tokio::test] async fn control_client_rejects_ok_response_from_nonzero_child() -> Result<()> { - let path = - std::env::temp_dir().join(format!("vibeface-control-status-{}", uuid::Uuid::new_v4())); - std::fs::write( - &path, - b"#!/bin/sh\ncat >/dev/null\nprintf '%s\\n' '{\"ok\":true,\"result\":{}}'\nexit 7\n", - )?; - std::fs::set_permissions(&path, std::fs::Permissions::from_mode(0o700))?; + let path = Path::new(env!("CARGO_MANIFEST_DIR")) + .join("tests/fixtures/control-nonzero-response.sh"); let error = request( &path, &ControlRequest::Inspect { @@ -277,7 +268,6 @@ mod tests { error.to_string().contains("core control process failed"), "{error:#}" ); - std::fs::remove_file(path)?; Ok(()) } diff --git a/crates/control/tests/fixtures/control-nonzero-response.sh b/crates/control/tests/fixtures/control-nonzero-response.sh new file mode 100755 index 000000000..967b71f81 --- /dev/null +++ b/crates/control/tests/fixtures/control-nonzero-response.sh @@ -0,0 +1,4 @@ +#!/bin/sh +cat >/dev/null +printf '%s\n' '{"ok":true,"result":{}}' +exit 7 diff --git a/crates/control/tests/fixtures/control-oversized-output.sh b/crates/control/tests/fixtures/control-oversized-output.sh new file mode 100755 index 000000000..d79e9a7be --- /dev/null +++ b/crates/control/tests/fixtures/control-oversized-output.sh @@ -0,0 +1,2 @@ +#!/bin/sh +head -c 1048577 /dev/zero From 1bb54307373bac5fcc6600b81ff2d3815471169f Mon Sep 17 00:00:00 2001 From: harryisfish Date: Sun, 8 Nov 2026 06:25:26 +0800 Subject: [PATCH 21/34] fix(mobile): wait for native input sheet dismissal Keep the input target unavailable until iOS confirms the sheet has closed. Wait for that state before the existing running-stop assertion. Preserve bounded failure diagnostics and the full native acceptance flow. --- .../src/features/workspace/workspace.tsx | 9 +- scripts/verify-node.py | 114 ++++++++++++- tests/e2e/native-transfers.e2e.ts | 154 +++++++++++++++++- 3 files changed, 266 insertions(+), 11 deletions(-) diff --git a/apps/mobile/src/features/workspace/workspace.tsx b/apps/mobile/src/features/workspace/workspace.tsx index 3c8ec9767..04d069717 100644 --- a/apps/mobile/src/features/workspace/workspace.tsx +++ b/apps/mobile/src/features/workspace/workspace.tsx @@ -3,7 +3,7 @@ import { Link, Stack, router, useFocusEffect } from 'expo-router' import { BrainCircuit, ChevronDown, ChevronRight, CircleQuestionMark, ListChecks, MessagesSquare, Plus, Reply, Settings, X } from 'lucide-react-native' import { useCallback, useEffect, useRef, useState } from 'react' import { useReducedMotion } from 'react-native-reanimated' -import { Modal, Pressable, ScrollView, View } from 'react-native' +import { Modal, Platform, Pressable, ScrollView, View } from 'react-native' import { KeyboardAvoidingView, KeyboardAwareScrollView, KeyboardController, KeyboardStickyView } from 'react-native-keyboard-controller' import { useSafeAreaInsets } from 'react-native-safe-area-context' import { messageOf } from '@vibeface/client/lib/node.ts' @@ -177,7 +177,8 @@ function InputQueue({ targets }: { targets: InputTarget[] }) { } export function InputOptions({ label, options, selected, onSelect, intent, onIntent, pending }: { label: string; options: TargetOption[]; selected: string; onSelect: (option: TargetOption) => void; intent: InputIntent; onIntent: (intent: InputIntent) => void; pending: PendingMessage[] }) { - const [open, setOpen] = useState(false) + const [phase, setPhase] = useState<'closed' | 'open' | 'closing'>('closed') + const close = () => setPhase(Platform.OS === 'ios' ? 'closing' : 'closed') const shared = useLive() const [scopeContext, setScopeContext] = useState(null) const [contextError, setContextError] = useState('') @@ -187,8 +188,8 @@ export function InputOptions({ label, options, selected, onSelect, intent, onInt const insets = useSafeAreaInsets() const reducedMotion = useReducedMotion() const intents: { value: InputIntent; label: string }[] = [{ value: 'continue', label: '补充当前工作' }, { value: 'new_task', label: '新任务' }, { value: 'defer', label: '稍后处理' }] - return <> item.value === intent)?.label},打开目标和队列`} onPress={() => setOpen(true)} className="min-h-11 flex-row items-center gap-2 rounded-xl bg-muted px-3 py-2">{label}{pending.length ? ` · ${pending.length} 条待确认` : ''} - setOpen(false)}> setOpen(false)} accessibilityRole="button" accessibilityLabel="关闭目标和队列" />目标和队列发送给{options.map((option) => )}发送方式{intents.map((item) => )}发送给{options.map((option) => )}发送方式{intents.map((item) => )}