fix(android): refuse helpers newer than the daemon's own

IM
4h ago
+612-276

Summary

Fixes #5185. Helpers with a higher versionCode than the daemon's counted as current, so an older daemon drove helpers whose protocol it lacks. Inspection now classifies them newer, and both ensure paths, for bundled or provider artifacts and every install policy, fail with one typed refusal: reason newer, the package, both versionCodes, and a hint to use the matching or a newer agent-device or run adb uninstall <package>. Nothing is uninstalled, and the refusal records no decision. open and snapshot report it: keyboard activation no longer treats it as an unavailable helper, and a snapshot rethrows it without stopping or resetting the newer helper. Other states keep install -r; transport errors are unchanged.

Cached decisions no longer report the bundled digest as installedSha256; the IME cache accepts only the bundled versionCode.

Before / after

API 36 AVD. Helpers from before #4729/#4722 built as versionCode 21099 (daemon bundles 21045); the helper keyboard selected over a stored user keyboard (voice typing), as an unclosed newer session leaves it.

base 13279ef563
snapshot: installedVersionCode=21099 reason=current, helperTransport=instrumentation
fill: COMMAND_FAILED android_ime_helper_no_ack, field value ''

head (this change on 13279ef563)
open: The Android IME helper on the device (versionCode 21099) is newer than this agent-device's (versionCode 21045). reason=newer
snapshot -i: The Android snapshot helper on the device (versionCode 21099) is newer ... reason=newer
before and after: both helpers 21099, default_input_method = helper, stored restore target = voice typing
after adb uninstall of both: open ok, snapshot persistent-session, fill "123456"

Validation

  • This change on 13279ef563: format, lint, typecheck, layering, fallow, build, related tests, provider-integration (325) and doc checks pass. Rebased onto 47e3fbe275 as b382f30f8e (no overlapping files); changed tests and Android provider scenarios pass there.
  • Tests refuse newer on each path without uninstall or install, and keep a version-read transport error unremembered. All 11 guard mutants fail a test.