testsAndMisc/docs/superpowers/contracts/mtk-root-toolkit-2026-08-04.json
Krzysztof kuhy Rudnicki 1b43ba093c
Some checks are pending
Pre-commit checks / pre-commit (push) Waiting to run
Shell tests / shell-tests (push) Waiting to run
Shell tests / arch-tests (push) Waiting to run
mtk_root: build the rooting toolkit before the phone lands
Prep for a Ulefone Armor X12 Pro (MediaTek MT6765) that has not arrived,
validated read-only against the Pixel 6a that has.

Partition discovery never hardcodes boot vs init_boot. It reads
/dev/block/by-name/, derives the slot scheme from observed _a suffixes, and
picks the ramdisk carrier by preference order init_boot then boot over what is
actually present. The AOSP launch-version rule explains why that ordering is
right; the code consults the filesystem, not the API level. One path therefore
serves both a Pixel (no init_boot, falls to boot_a) and a 13-launch MediaTek
device (init_boot_a taken). Patching the wrong one yields a phone that will
not boot.

Classification refuses rather than guesses: ULEFONE needs a positive MediaTek
signal AND a vendor match, with no "not a Pixel therefore Ulefone" fallback.
Carrier lock is always reported UNDETERMINED, because sys.oem_unlock_allowed,
ro.oem_unlock_supported and settings global oem_unlock_allowed read identically
whether a device is carrier-locked or merely has the toggle off; asserting a
negative would wrongly rule out a path.

No flashing script, deliberately. Automating irreversible partition writes
defeats the confirmation steps that catch a wrong partition or missing slot
suffix.

Three bugs found by running the code rather than only linting it:
- SIGPIPE: `adb version | head -1` under pipefail exited 141 and killed
  00-preflight.sh mid-run
- 20-dump-stock.sh exited silently when no recon had run, because find on a
  nonexistent cache dir fails under set -e
- the read-only static scan had a hole: stripping all quoted strings to avoid
  false positives on printf text also hid `adb shell "reboot bootloader"`.
  Now only printf/echo/cat arguments are stripped, and a negative self-test
  asserts the scan fails on injected commands

Also narrowed a world-writable udev catch-all (idVendor=="*", MODE="0666")
that granted every local process read/write access to every USB device;
commented with a backup, adb connectivity re-verified afterwards.

Validated: 58/58 offline fixture tests; 00-preflight.sh HOST READY (12/12);
10-recon.sh read-only against the Pixel reports PIXEL, boot_a, A/B, no
init_boot, path C-or-D indeterminate, with the device unchanged afterwards.
Untested and labelled as such in READY.md: the init_boot branch on real
hardware, mtkclient over BROM, and the whole flash/verify sequence.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018ReVsw7qovYkkGbqcU9tn7
2026-08-04 20:38:44 +02:00

27 lines
2.8 KiB
JSON

{
"title": "mtk_root: pre-arrival Android rooting toolkit",
"objective": "Prepare host tooling and recon scripts before a Ulefone Armor X12 Pro (MediaTek MT6765) arrives, so that rooting on arrival day is one script plus a decision rather than an evening of setup. Validate everything possible read-only against an already-connected Pixel 6a, and label honestly what remains untested because it is MediaTek-specific. Success means 00-preflight.sh reports HOST READY, the fixture suite passes, and READY.md states per-capability which parts are device-validated versus fixture-tested only.",
"acceptance_criteria": [
"00-preflight.sh reports HOST READY (all checks pass) on this machine",
"tests/run_tests.sh passes with zero failures and touches no phone",
"Partition discovery selects init_boot over a co-present boot, and boot when init_boot is absent, without hardcoding either name",
"10-recon.sh classifies an unrecognised device as UNKNOWN and refuses to name a path, rather than assuming it is the Ulefone",
"20-dump-stock.sh refuses any device lacking a positive MediaTek platform signal",
"10-recon.sh performs no device-mutating operation, enforced by a static scan that is itself proven to fail on an injected mutating command",
"Carrier lock is reported as UNDETERMINED, never as a negative, since no readable property discriminates it",
"10-recon.sh run read-only against the Pixel 6a reports PIXEL, boot_a, A/B, no init_boot, and path C-or-D indeterminate",
"mtkclient is cloned fresh and its venv imports usb, usb.core and serial under the current Python",
"READY.md distinguishes device-validated, host-validated, fixture-tested-only and untested per capability"
],
"out_of_scope": [
"Any flashing or partition-write script: automating irreversible writes would defeat the confirmation steps that catch a wrong partition or missing slot suffix, so flashing stays manual",
"Any write, unlock, wipe, or bootloader reboot of the Pixel 6a, which is the user's daily driver: today is read-only recon only",
"Modifying linux_configuration/scripts/single_use/utils/root_bl9000.sh, which still serves a different device (Blackview MT6893)",
"Pre-fetching Ulefone firmware: the stock ramdisk is dumped off the device itself so it matches that exact unit and build",
"Downloading a Pixel factory image, since the toolkit does not act on the Pixel",
"Play Integrity / SafetyNet bypass, which needs Zygisk plus a hiding config",
"Committing binary artifacts: images, APKs and dumps stay in ~/.cache/mtk-root/ outside the repo"
],
"verifier": "./linux_configuration/scripts/mtk_root/tests/run_tests.sh (58 assertions, offline); ./linux_configuration/scripts/mtk_root/00-preflight.sh (host readiness); shellcheck via pre-commit run --files; and a read-only ./10-recon.sh run against the attached Pixel 6a"
}