Skip to content

fix(android): rotate helper signing identity - #5260

Closed
thymikee wants to merge 21 commits into
fix/daybreak-android-helper-boundariesfrom
fix/android-helper-signing-identity
Closed

thymikee wants to merge 21 commits into
fix/daybreak-android-helper-boundariesfrom
fix/android-helper-signing-identity

Conversation

@thymikee

@thymikee thymikee commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Closed as superseded by #5341 on the 0.22 remediation line. Continue review and implementation there. Historical validation below remains attributed to its original commits; closure does not claim the replacements are merge-ready.

Summary

Rotate Android snapshot and IME helper package identities and remove the committed signing key. Local and PR builds use supplied or disposable keys. Nightly, stable, and helper asset publishing remain paused until an isolated signer produces and verifies both release APKs, checksums, and manifests with a stable external key.

Preserve the keyboard during legacy-to-v2 IME recovery. Doctor detects an orphaned legacy helper. Invalid saved keyboards emit a diagnostic and actionable guidance. Snapshot test probes use their fixture's package identity.

Before / after

  • With the retired helper active and no owning session, doctor reported the normal keyboard; it now reports an orphan and a safe restore command.
  • A stale helper restore target produced a generic close failure; it now records a warning and explains manual recovery.
  • The scoped snapshot fixture reported the retired package and attempted an install; it now reports the rotated package and captures normally.

Validation

c4af41b73a passed merge-tree. Hosted checks pending.

All 31 hosted checks passed at eea4c26ae8. On a fresh Android 16 emulator, the active base-built legacy helper had Gboard recorded as its previous IME. The head-built v2 helper entered and read back Unicode text in smoke:form-input. After session close, doctor and Android settings both confirmed the exact original Gboard component, and the restore record cleared. The run used disposable signing keys and a temporary runner patch to target the emulator and assert the exact component.

Merge requires both production-signed helpers with the expected certificate, matching manifests, and checksums.

@blacksmith-sh

This comment has been minimized.

@thymikee
thymikee force-pushed the fix/daybreak-android-helper-boundaries branch from 1c9851b to 84ef5e7 Compare November 30, 2026 14:59
@thymikee
thymikee force-pushed the fix/android-helper-signing-identity branch from 2c56c9c to e42cee8 Compare November 30, 2026 14:59
@thymikee
thymikee force-pushed the fix/daybreak-android-helper-boundaries branch from 84ef5e7 to 6449c02 Compare November 30, 2026 15:07
@thymikee
thymikee force-pushed the fix/android-helper-signing-identity branch from e42cee8 to 7ad8495 Compare November 30, 2026 15:08
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.78 MB 6.78 MB +1.1 kB
Package (unpacked) 6.78 MB 6.78 MB +1.1 kB
Package (download) 2.07 MB 2.07 MB +142 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 17.4 ms 17.4 ms -0.0 ms
CLI --help 37.0 ms 40.1 ms +3.1 ms

@thymikee
thymikee force-pushed the fix/android-helper-signing-identity branch 2 times, most recently from 90367c7 to b517984 Compare November 30, 2026 15:22
@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 3 new findings on b517984. The verdict and the full list are in the summary comment.

Comment thread android/ime-helper/README.md Resolved
@thymikee
thymikee force-pushed the fix/android-helper-signing-identity branch from b517984 to 0875de5 Compare November 30, 2026 15:55
@thymikee

Copy link
Copy Markdown
Member Author

Addressed the remaining instrumentation-runner item at 9fd6c31: the default now uses the Java class declared by the rotated manifest, and first-party fixtures use the same fully qualified component. The focused capture and retry tests passed. The other IME and signing-path review threads were already resolved. Production release remains blocked pending an isolated signer and new key.

@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 1 new finding on 63ba5b4. The verdict and the full list are in the summary comment.

@thymikee
thymikee force-pushed the fix/daybreak-android-helper-boundaries branch from c378296 to 1cacb3a Compare November 30, 2026 17:05
@thymikee
thymikee force-pushed the fix/android-helper-signing-identity branch from 66e5f8f to 60992e3 Compare November 30, 2026 17:14
@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 1 new finding on 60992e3. The verdict and the full list are in the summary comment.

Comment thread android/snapshot-helper/README.md Resolved
@thymikee

Copy link
Copy Markdown
Member Author

At 60992e3, an upgrade can lose the user's keyboard and leave the legacy helper in its place. A live Android run is also still missing.

The problem starts when the legacy helper IME is still active after a crashed or killed older daemon, and the device record holds the user's keyboard as previousIme. Restore compares the active IME only to the v2 component, so it returns helper-not-active. Unless the record is marked as displaced for rebinding, the next activation writes the legacy component as previousIme (see the restore target), and session close sets the device back to it. The base code restores the user's keyboard here. The rule: a helper service component, current or retired, must never be recorded or restored as the user's previous IME. Could one set of helper components next to ANDROID_IME_HELPER_SERVICE_COMPONENT in ime-helper.ts drive every site that picks or checks a restore target? That includes activationRestoreTarget (keep record.previousIme) and restoreAndroidTestImeFor (treat an active legacy helper as a helper). Please add a regression test with the user's IME in the record and the legacy component active, asserting that restore targets the user's IME. If no legacy awareness is wanted, activation should instead refuse with a typed reason while the legacy helper is active.

This change renames the packages and components used on the device, so a live run is required before merge. Use an emulator with the legacy snapshot and IME helpers installed, the legacy IME active, and a device record. Through the daemon, show the v2 helpers installed beside the legacy ones (pm list packages), a snapshot through com.callstack.agentdevice.snapshothelper.v2/...SnapshotInstrumentation, a fill through the v2 IME, and settings locale using the verified v2 APK. Show settings get secure default_input_method before the session and after close, with the user's original keyboard restored.

One lower-priority open thread also still applies.

Not blocking, so take or leave these: delete the .gitattributes line for the removed keystore, name the four AGENT_DEVICE_ANDROID_KEY* signing variables (a caller-supplied local key) in CONTRIBUTING.md and the IME README build command, drop the unused ANDROID_HELPER_* secret names or mark them as planned for the signing stage, and consider keeping only the build-job refusal instead of also keeping the always-failing release stub and its job (or delete the stub when the signer lands).

CI checks pass or are skipped. The Android smoke jobs are skipped, so CI did not exercise the device route.

Not verified here: the keyboard problem was traced from the code at this commit and the base, and was not run on a device or in a unit test. Not verified here: no tests were run, and the reported local results were not confirmed. Not verified here: whether CI emulators keep installed helpers between runs, where a kept v2 helper signed with an earlier run's key would fail install -r.

Before merge, the legacy helper must be kept from becoming or staying the restore target, and the live run above must pass.

@thymikee
thymikee force-pushed the fix/android-helper-signing-identity branch 3 times, most recently from 11545f7 to 908ef49 Compare November 30, 2026 18:58
@thymikee

Copy link
Copy Markdown
Member Author

Addressed at ba8494a. Restore now recognizes the current and retired IME components, and activation retains the recorded user keyboard when a retired helper is active. If no user keyboard is recorded, activation leaves the device unchanged; restore also refuses a helper component as its target. Focused IME activation and restore tests passed (36/36), including the interrupted-upgrade case. New-head CI and live Android verification remain pending. The isolated production signer is still a release blocker.

@thymikee
thymikee force-pushed the fix/android-helper-signing-identity branch from ba8494a to a5c96a4 Compare November 30, 2026 19:17
@thymikee
thymikee marked this pull request as ready for review November 30, 2026 19:28

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 58 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread test/repo-guards/release-assets.test.ts Resolved
Comment thread .github/workflows/release.yml Resolved
Comment thread android/snapshot-helper/README.md Resolved
Comment thread scripts/build-android-helper.sh Resolved
@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 2 new findings on 1e21bd2. The verdict and the full list are in the summary comment.

Comment thread .github/workflows/release.yml Resolved
@thymikee
thymikee force-pushed the fix/daybreak-android-helper-boundaries branch from 0388b6a to 3032f35 Compare November 30, 2026 19:51
@thymikee

thymikee commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

At 1b72dcd, the rebase onto ee8075e that was requested earlier is in place, but legacy keyboard recovery in doctor has regressed and needs a fix.

probeAndroidTestIme compares the active input method only with the current v2 service component. A device can still have com.callstack.agentdevice.imehelper/.TestInputMethodService active from a session before the upgrade, for example with no recovery record or after a failed restore. doctor then returns pass and says the normal keyboard is in use, with no restore command; on the base it returns fail with one. Every site that asks whether an input method is an agent-device helper should use isAndroidImeHelperServiceComponent. Please apply that here, which removes the need for resolveAndroidImeHelperServiceComponent, and never offer a helper component as the restore target in buildOrphanedTestImeCheck. Please add a doctor.test.ts case with the legacy component active and no owning session that expects fail.

Not blocking: these two notes can be taken or left, namely deriving each fake version probe's package name from the fixture artifact (IME_PACKAGE in the IME world, as already done in two files at this commit; git grep -nE "package:com\.callstack\.agentdevice\.(snapshothelper|imehelper) |show-versioncode com\.callstack" lists the sites, and the legacy replies make v2 look missing to the exact package match), and updating the PR body to name ee8075e (or the newer base after another rebase) instead of the PR's own head and to say that merge is held until the production signing path delivers both helpers with the expected certificate and matching manifests and checksums.

One earlier thread still applies at lower priority and does not block. These threads no longer apply and can be resolved: signing key note (requiring the key on every build path is intended and documented; its doctor and fixture points are covered above); service name (fully qualified now); snapshot README variables (named now); restore failure (now throws); custom packages (relative runner kept); release assets test (asserts the refusal); nightly pause (intended and documented); restore check order (helper check runs first); legacy package (accepted now); README passwords (no inline passwords); clickability test (colon form used); signing checks (run before compilation); activation diagnostic (emitted before refusal); restore comment (lists the result); publish gate (publish needs the refusing build); publishing pause docs (documented); IME README variables (named now).

Coverage (job) fails 28 tests at this commit and passes on base ee8075e and on 1c9a571. The failure is likely related to this PR: the 20 named tests are in Android helper unit and provider scenarios, and by reading they match the stale legacy probes above. The cancelled Body rules run is unrelated, and a later run passed. The Android, iOS, macOS and Linux smoke jobs passed.

Not verified here: no tests were run locally, the other 8 failing tests were not identified, the doctor problem was traced in code only with no device left on the legacy input method, and it was not checked that legacy helpers from older releases use the same android-ime-helper-v2 broadcast protocol.

Before merge, the doctor check must be fixed and Coverage must pass. Merge then stays held until the production signing path delivers both helper APKs with the expected certificate and matching manifests and checksums. Publishing is still refused at this commit by the release workflow and the helper asset workflow, and that signing path and its outputs were not verified.

@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging

This comment has been minimized.

@thymikee

thymikee commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

At eea4c26, the legacy keyboard problem in doctor from the earlier findings is fixed, and no required code change remains. Evidence from the production signing path is still missing.

Before merge, please show that this path delivers both helper APKs with the expected certificate and with matching manifests and checksums. The changes since 1b72dcd do not touch the release workflow or the helper asset workflow, and publishing is still refused.

Not blocking: these can be taken or left, namely letting the close error aggregator carry a failed step's curated details.hint (today only the web_browser step's nested hint is forwarded, so the new invalid saved keyboard hint and the README trigger for it never show in close output; an assertion through the daemon close route would cover this), and updating the snapshot helper README to say that a daemon restart clears the recovery marker once both secure settings are removed, without confirming that no helper is active, so the reader should first check the active keyboard with adb shell settings get secure default_input_method.

One earlier lower-priority review thread still applies.

CI shows no failing or pending check, and Coverage now passes.

Not verified here: no tests were run locally, whether new tests fail without their fixes was judged by reading the earlier code, the two optional points were traced in code only and not reproduced on a device or through a daemon test, only the changes since 1b72dcd were reviewed, and the production signing path, expected certificate, manifests and checksums were not checked.

@thymikee
thymikee force-pushed the fix/android-helper-signing-identity branch from eea4c26 to c4af41b Compare December 2, 2026 16:57
@thymikee
thymikee force-pushed the fix/daybreak-android-helper-boundaries branch from 88af7a6 to 7e9c0c4 Compare December 2, 2026 16:57
@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of c4af41b

Since the review of eea4c26: 0 new · 0 still open · 0 no longer raised

No open findings.

Not in the reviewers' scope (1 file)
  • android/snapshot-helper/debug.keystore: no text diff (a binary, empty or mode-only change)

Reviewed with this repository's own Sentinel configuration (7c6ef4a2ed46).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant