From 4f38a7e0116f7df820884189cec19385b600064a Mon Sep 17 00:00:00 2001 From: bit9992 <84845600+bit9992@users.noreply.github.com> Date: Thu, 12 Nov 2026 10:08:46 +0300 Subject: [PATCH] Preserve verified WebRTC object cache across gclient synchronization --- .gitea/prepare-android-dependency-cache.py | 48 ++++++++++++++++++++++ .gitea/workflows/android.yml | 5 ++- CHANGELOG.md | 2 + README.md | 3 ++ docs/mobile-port-progress.md | 4 ++ 5 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 .gitea/prepare-android-dependency-cache.py diff --git a/.gitea/prepare-android-dependency-cache.py b/.gitea/prepare-android-dependency-cache.py new file mode 100644 index 0000000..c5d0e2a --- /dev/null +++ b/.gitea/prepare-android-dependency-cache.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python3 +"""Undo only receipt-matched source patches before gclient reuses a CI checkpoint.""" +import json +import pathlib +import subprocess + + +def unpatch(checkout, diffs): + checkout = checkout.resolve(strict=True) + pending = [] + for relative, expected in diffs.items(): + parts = pathlib.PurePosixPath(relative) + if parts.is_absolute() or '..' in parts.parts or not parts.parts or parts.parts[0] != 'src': + raise ValueError('Unconfined dependency receipt path') + directory = checkout.joinpath(*parts.parts).resolve(strict=True) + if not directory.is_relative_to(checkout): + raise ValueError('Dependency checkout escapes cache') + actual = subprocess.check_output(['git', '-C', str(directory), 'diff', '--binary', 'HEAD', '--']) + encoded = expected.encode('utf-8') + if actual != encoded: + raise ValueError(f'Cached changes differ from verified receipt: {relative}; refusing to reset') + if actual: + subprocess.run(['git', '-C', str(directory), 'apply', '--reverse', '--check', '-'], input=actual, check=True) + pending.append((directory, actual)) + # Validate every repository before making any mutation. Untracked outputs are not touched. + for directory, patch in pending: + subprocess.run(['git', '-C', str(directory), 'apply', '--reverse', '-'], input=patch, check=True) + print(f'Removed {len(pending)} receipt-matched source patches; build objects retained', flush=True) + + +def main(): + base = pathlib.Path('target/native-deps/aarch64-linux-android') + receipt_path = base / 'provenance.json' + if not receipt_path.exists(): + print('No restored dependency receipt; fresh provisioning') + return + receipt = json.loads(receipt_path.read_text(encoding='utf-8')) + lock = json.loads(pathlib.Path('native/native-deps.lock.json').read_text(encoding='utf-8')) + if receipt['target'] != 'aarch64-linux-android': + raise ValueError('Wrong cached target') + for receipt_key, lock_key in [('webrtc_revision', 'webrtc'), ('sdk_revision', 'sdk'), ('depot_tools_revision', 'depot_tools')]: + if receipt[receipt_key] != lock[lock_key]['revision']: + raise ValueError('Cached source revision no longer matches policy') + unpatch(base / 'checkout', receipt['applied_source_diffs']) + + +if __name__ == '__main__': + main() diff --git a/.gitea/workflows/android.yml b/.gitea/workflows/android.yml index 7a39634..ccfc746 100644 --- a/.gitea/workflows/android.yml +++ b/.gitea/workflows/android.yml @@ -140,7 +140,10 @@ jobs: - name: Build pinned WebRTC dependencies with bounded CI parallelism if: ${{ github.event.inputs.mode != 'inventory' }} id: dependencies - run: cargo run --locked -p xtask -- deps --target "$TARGET" --llvm-dir "$LLVM_HOME" --jobs "$CARGO_BUILD_JOBS" + run: | + set -euo pipefail + python3 .gitea/prepare-android-dependency-cache.py + cargo run --locked -p xtask -- deps --target "$TARGET" --llvm-dir "$LLVM_HOME" --jobs "$CARGO_BUILD_JOBS" - name: Checkpoint verified WebRTC before application build if: ${{ success() && github.event.inputs.mode != 'inventory' && steps.webrtc-cache.outputs.cache-hit != 'true' }} diff --git a/CHANGELOG.md b/CHANGELOG.md index f053ec2..48a2ef1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ Added checksum-pinned SDK/NDK/Rust/Skia/Gradle provisioning, early disk/RAM gates, four-job CI compilation, dependency checkpoints before native build, memory evidence and SHA-labelled test APK artifacts; no automatic releases, production signing or device actions. Local Windows limits remain separate. +- Fixed restored Android WebRTC checkpoints: validate and reverse receipt-matched source patches + before gclient synchronization, then reapply pinned patches without deleting compiled objects. - Android onboarding is now a full-screen page with a one-line 48dp nickname field, visible theme choices, errors and Create/Cancel buttons; keyboard insets are handled before profile creation. diff --git a/README.md b/README.md index 1c3ac16..146f930 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,9 @@ checkouts and Ninja objects. Its key excludes completed build receipts but inclu tool pins and dependency drivers; there is no cross-policy fallback. Every cache hit still runs `xtask deps`: checkouts, patches, GN inputs and artifacts are checked and current provenance is regenerated before use. The repository lock is never overwritten by a cached copy. +Before gclient sync, CI reverses only source diffs byte-identical to the restored provenance receipt; +unexpected modifications fail closed. Pinned patches are then reapplied by xtask. No reset/clean of +cached source or object outputs is used. These potentially large checkpoints require runner cache storage/capacity; cache misses remain valid cold builds. Before/after cgroup counters and `/usr/bin/time -v` data are retained as a separate `android-build-resources-` artifact even when native compilation fails, to diagnose SIGKILL diff --git a/docs/mobile-port-progress.md b/docs/mobile-port-progress.md index b257b89..efe412e 100644 --- a/docs/mobile-port-progress.md +++ b/docs/mobile-port-progress.md @@ -81,6 +81,10 @@ Updated **2026-11-11**. Windows baseline remains `05e8d34bcf0e24a44f76e65220293c overrides into CI. SSH/admin connection is not configured; no host change via mounted Docker socket attempted. Resume with the same4-job configuration and caches on owner's instruction; no memory expansion, optimization override or new infrastructure investigation is required by these pauses. +- Run4855 (`e676f2a`) restored both caches but gclient refused pre-existing pinned libunwind changes + in src/buildtools. Added CI-only pre-sync receipt-bound reversal of exact applied_source_diffs; + unexpected modifications abort, object files retained, xtask reapplies pinned patches afterward. + Real temporary Git fixture passed reversal/output-retention and mismatch-rejection checks. ## First Android APK build