2f76e72efde8
wire the release manifest drift gate into the Kepr publish path
- time
- 2026-09-10 22:55 UTC · 2 months ago
- machine
- koh2
- agent
- deepseek/deepseek-v4-flash
- session
- secure sync reset migration
- parent
- 4ccb3c874e48
↓ peach-android-2f76e72e.tar.gzatlas at this save
files changed3 files
scripts/check-release-manifest.py+15 −5scripts/kepr-build-apk.sh+9 −0scripts/test-release-manifest.sh+67 −0scripts/check-release-manifest.py+15 −5
@@ -7,8 +7,8 @@77 88 ANDROID_NS = "{http://schemas.android.com/apk/res/android}"99 ROOT = Path(__file__).resolve().parents[1]10-INVENTORY = ROOT / "docs" / "android-release-manifest-inventory.txt"11-MERGED = ROOT / "app" / "build" / "intermediates" / "merged_manifest" / "release" / "processReleaseMainManifest" / "AndroidManifest.xml"10+DEFAULT_INVENTORY = ROOT / "docs" / "android-release-manifest-inventory.txt"11+DEFAULT_MERGED = ROOT / "app" / "build" / "intermediates" / "merged_manifest" / "release" / "processReleaseMainManifest" / "AndroidManifest.xml"1212 1313 1414 def inventory(path: Path) -> str:@@ -31,14 +31,24 @@3131 return "\n".join(lines) + "\n"3232 3333 34-if len(sys.argv) != 2:35- raise SystemExit(f"usage: {Path(sys.argv[0]).name} check|write")34+USAGE = f"usage: {Path(sys.argv[0]).name} check|write [merged-manifest] [inventory]"35+36+if len(sys.argv) not in (2, 3, 4):37+ raise SystemExit(USAGE)38+MERGED = Path(sys.argv[2]) if len(sys.argv) > 2 else DEFAULT_MERGED39+INVENTORY = Path(sys.argv[3]) if len(sys.argv) > 3 else DEFAULT_INVENTORY40+41+if not MERGED.is_file():42+ raise SystemExit(f"merged release manifest not found: {MERGED}")43+3644 if sys.argv[1] == "write":3745 INVENTORY.write_text(inventory(MERGED))3846 elif sys.argv[1] == "check":47+ if not INVENTORY.is_file():48+ raise SystemExit(f"checked-in inventory not found: {INVENTORY}")3949 actual = inventory(MERGED)4050 expected = INVENTORY.read_text()4151 if actual != expected:4252 raise SystemExit("merged release manifest differs from checked-in inventory")4353 else:44- raise SystemExit(f"unknown command: {sys.argv[1]}")54+ raise SystemExit(f"unknown command: {sys.argv[1]}\n{USAGE}")scripts/kepr-build-apk.sh+9 −0
@@ -47,6 +47,15 @@4747 4848 "$ROOT_DIR/gradlew" --no-configuration-cache :app:assembleRelease4949 50+# PB-26-113: the merged release manifest is the shipped permission and exported51+# component surface. Drift from the checked-in inventory refuses the publish52+# rather than reaching a store unnoticed.53+python3 "$ROOT_DIR/scripts/check-release-manifest.py" check ||54+ {55+ echo "refusing to publish: release manifest inventory drift" >&256+ exit 157+ }58+5059 case "${KEPR_TARGET:-}" in5160 android-arm64)5261 APK_NAME="app-arm64-v8a-release.apk"scripts/test-release-manifest.sh+67 −0
@@ -0,0 +1,67 @@1+#!/bin/sh2+# Hermetic negative-path tests for the release-manifest inventory drift gate3+# (PB-26-113). No Android SDK, Gradle project, or merged build output required.4+set -eu5+6+SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)7+CHECK="$SCRIPT_DIR/check-release-manifest.py"8+9+TEMP_ROOT=$(mktemp -d "${TMPDIR:-/tmp}/peach-release-manifest-tests.XXXXXX")10+trap 'trash "$TEMP_ROOT"' EXIT HUP INT TERM11+12+MERGED="$TEMP_ROOT/AndroidManifest.xml"13+INVENTORY="$TEMP_ROOT/inventory.txt"14+15+fail() {16+ printf 'FAIL: %s\n' "$1" >&217+ exit 118+}19+20+write_manifest() {21+ cat > "$MERGED" <<XML22+<?xml version="1.0" encoding="utf-8"?>23+<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.peachpasswords">24+ <uses-permission android:name="android.permission.INTERNET"/>25+ $126+ <application android:name=".App">27+ <activity android:name=".MainActivity" android:exported="true">28+ <intent-filter>29+ <action android:name="android.intent.action.MAIN"/>30+ <category android:name="android.intent.category.LAUNCHER"/>31+ </intent-filter>32+ </activity>33+ </application>34+</manifest>35+XML36+}37+38+write_manifest ""39+python3 "$CHECK" write "$MERGED" "$INVENTORY"40+[ -s "$INVENTORY" ] || fail "write produced no inventory"41+grep -q '^permission|android.permission.INTERNET$' "$INVENTORY" ||42+ fail "inventory is missing the declared permission"43+44+python3 "$CHECK" check "$MERGED" "$INVENTORY"45+python3 "$CHECK" write "$MERGED" "$INVENTORY"46+python3 "$CHECK" check "$MERGED" "$INVENTORY"47+48+# A permission added to the merged manifest after the inventory was recorded49+# must refuse, and must say so rather than crashing.50+write_manifest '<uses-permission android:name="android.permission.CAMERA"/>'51+if output=$(python3 "$CHECK" check "$MERGED" "$INVENTORY" 2>&1); then52+ fail "drifted merged manifest was accepted"53+fi54+case "$output" in55+ *"differs from checked-in inventory"*) ;;56+ *) fail "drift refusal did not report drift: $output" ;;57+esac58+59+# Missing inputs fail closed instead of reporting a clean comparison.60+if python3 "$CHECK" check "$TEMP_ROOT/absent.xml" "$INVENTORY" >/dev/null 2>&1; then61+ fail "a missing merged manifest was accepted"62+fi63+if python3 "$CHECK" check "$MERGED" "$TEMP_ROOT/absent.txt" >/dev/null 2>&1; then64+ fail "a missing inventory was accepted"65+fi66+67+printf 'PASS: release manifest inventory drift gate\n'