From 8b542d5cbe80885fa48dc7fcd0e6acb7fc7ef6e4 Mon Sep 17 00:00:00 2001 From: Lana Begunova <70295997+lana-20@users.noreply.github.com> Date: Fri, 27 Nov 2026 19:07:52 -0800 Subject: [PATCH] Refuse an acting request wherever its verb is; boot without host audio (CHALLENGES 409, 410) "Can you text Alex" and "Tell Alex I'm late" were asked on the owner's account: the refusal matched only the request's first word. mobium boot --window kept the host audio output that breaks up a capture, while SETUP said boot always drops it. SETUP's hand-started emulators loaded the quick-boot snapshot it warns against. assistant.sh on the Pixel 7 AVD: 3 of 4 passed; the first ask after a cold boot found no field, and main then passed the same step 2 of 2. --- docs/ACCESSIBILITY.md | 8 +++++--- docs/CHALLENGES.md | 30 +++++++++++++++++++++++++++++- docs/RELEASE-CHECKLIST.md | 2 +- docs/SETUP.md | 6 +++--- docs/checks/assistant.sh | 7 +++++-- internal/agent/assistant.go | 22 ++++++++++++++-------- internal/agent/assistant_test.go | 10 ++++++++-- internal/device/boot.go | 17 +++++++++++++---- internal/device/boot_test.go | 23 +++++++++++++++++++++++ 9 files changed, 101 insertions(+), 24 deletions(-) create mode 100644 internal/device/boot_test.go diff --git a/docs/ACCESSIBILITY.md b/docs/ACCESSIBILITY.md index bb1bd2bd..e909a1c8 100644 --- a/docs/ACCESSIBILITY.md +++ b/docs/ACCESSIBILITY.md @@ -435,9 +435,11 @@ As built (`mobium assistant "Open Calculator" --app com.google.android.calculato - **The answer** is new text the assistant shows that is not one of its own controls. Google Assistant's calculator card has none, so a sum asked there answers with no text, and says so. -- **Refused**: a request that acts for the owner (call, text, message, - send, email, pay, buy, order, book, post, share, delete, transfer) unless - `app` names the app it is for; Siri on a simulator, which answers nothing +- **Refused**: a request that acts for the owner (call, dial, text, + message, send, email, mail, pay, buy, order, purchase, book, post, tweet, + share, delete, transfer, venmo, or tell someone other than "me" or "us"), + wherever the word is in it — "Can you text Alex" as much as "Text Alex" — + unless `app` names the app it is for; Siri on a simulator, which answers nothing (CHALLENGES 351); a TV's assistant. `assistant.sh` passes on the emulator (Google Assistant, signed out) and diff --git a/docs/CHALLENGES.md b/docs/CHALLENGES.md index 51d9bfdc..361901af 100644 --- a/docs/CHALLENGES.md +++ b/docs/CHALLENGES.md @@ -7,7 +7,7 @@ the source. The pattern across them is the reason the document exists: **almost nothing here was found by reading code or by a test written from imagination.** Of -408 defects, 328 were found only by running against a real device. Eighteen +410 defects, 328 were found only by running against a real device. Eighteen more — 255, 280, 282, 327, 329, 353, 355, 356, 359, 371, 375, 380, 382, 384, 386, 387, 388 and 406 — were met while running against one, though the fault lay in a check, the host or Mobium's own design rather than in the platform. The other sixty-two — 4, 5, 6, 14, 23, @@ -8899,6 +8899,34 @@ were found", which 211's rule already skips. follows, the rule 211 applies to text before it; anything else after it is refused. The same screenshot then ended at its IEND. +### 409. A request to text was refused only as its first word + +**Found by:** an audit of the RAG project's golden questions, which held +`docs/ACCESSIBILITY.md`'s rule, that a request acting for the device's owner +is refused unless `app` names the app, against `internal/agent/assistant.go`. +The rule matched the verb only at the start, after a greeting and "please". +"Can you text Alex I'm late", "Tell Alex I'm late" and "Remind me to call +Alex" were asked, and on a phone each goes to its owner's account. + +**Fixed:** the words are matched anywhere in the request, as whole words, and +"tell" acts unless it is "tell me" or "tell us". A word used as a noun is +refused too, which naming the app answers. The docs list the words the code +has; they had left out dial, mail, purchase, tweet and venmo. `assistant.sh` +holds a request with its verb further in to the refusal. + +### 410. A windowed emulator kept the host's audio + +**Found by:** the same audit. `docs/SETUP.md` said to pass `-no-audio` by hand +"as `mobium boot` does", but `mobium boot` passed it only headless, so +`mobium boot --window` gave the emulator the host audio output that breaks up +what a capture hears (390). + +**Fixed:** every boot passes `-no-audio`. The stream Mobium reads comes from +the emulator's control port, not the host, so a window loses only the Mac's +speakers. The Linux and headless commands in `SETUP.md` passed +`-no-snapshot-save`, which 186 there warns brings an old snapshot back; they +pass `-no-snapshot-load` and `-no-audio`, as `mobium boot` does. + ## Findings that were not defects Worth recording because each one closed off an approach that looked obvious. diff --git a/docs/RELEASE-CHECKLIST.md b/docs/RELEASE-CHECKLIST.md index dc5c2cb0..e29edc66 100644 --- a/docs/RELEASE-CHECKLIST.md +++ b/docs/RELEASE-CHECKLIST.md @@ -4,7 +4,7 @@ [CI workflow](../.github/workflows/ci.yml) runs on every push — formatting, vet, both modules' tests, the four non-Go clients' own tests, and six cross-compile targets. This file is the rest, and the rest is where most -serious defects in this project have come from: 328 of 408 were found only by +serious defects in this project have come from: 328 of 410 were found only by running against a real device. Work through it before tagging a release, on three substrates: an Android diff --git a/docs/SETUP.md b/docs/SETUP.md index 95bd5070..b5f1b1a3 100644 --- a/docs/SETUP.md +++ b/docs/SETUP.md @@ -80,7 +80,7 @@ sdkmanager --install "emulator" "platform-tools" \ avdmanager create avd -n mobium-test -d pixel_7 \ -k "system-images;android-35;google_apis;arm64-v8a" -emulator -avd mobium-test -no-snapshot-save -no-boot-anim & +emulator -avd mobium-test -no-snapshot-load -no-boot-anim -no-audio & adb wait-for-device ``` @@ -117,7 +117,7 @@ sdkmanager --install "emulator" "platform-tools" \ avdmanager create avd -n mobium-test -d pixel_7 \ -k "system-images;android-35;google_apis;x86_64" -emulator -avd mobium-test -no-snapshot-save -no-boot-anim & +emulator -avd mobium-test -no-snapshot-load -no-boot-anim -no-audio & adb wait-for-device ``` @@ -143,7 +143,7 @@ Add `-no-window`. Everything mobium does works unchanged, screenshots included — `adb exec-out screencap` reads the framebuffer, not the window: ```sh -emulator -avd mobium-test -no-window -no-snapshot-save -no-boot-anim -no-audio & +emulator -avd mobium-test -no-window -no-snapshot-load -no-boot-anim -no-audio & ``` **Unlike an iOS simulator, the window cannot be attached afterwards.** `simctl diff --git a/docs/checks/assistant.sh b/docs/checks/assistant.sh index 6bdb9649..aa93dced 100755 --- a/docs/checks/assistant.sh +++ b/docs/checks/assistant.sh @@ -10,8 +10,8 @@ # "Open MobiumApp" on an iPhone, with --app naming it, answers reached; # - the same request naming another app answers not reached — the app in # front once the panel closes is never taken for the assistant's doing; -# - a request that acts for the owner ("Text …") is refused without --app, -# before anything is asked; +# - a request that acts for the owner ("Text …", "Can you text …") is +# refused without --app, before anything is asked; # - a simulator is refused: its Siri answers nothing (CHALLENGES 351). # # Each request goes to the account the assistant is signed in to, and Gemini @@ -49,6 +49,9 @@ esac out=$($M assistant "Text Mom that I am late" 2>&1) && fail "a request to text was sent without --app: $out" echo "$out" | grep -q "on the device owner's behalf" || fail "the refusal did not say why: $out" row "refused" "a request to text, with no app named" +out=$($M assistant "Can you text Mom that I am late" 2>&1) && fail "a request to text, not as its first word, was sent without --app: $out" +echo "$out" | grep -q "on the device owner's behalf" || fail "the refusal did not say why: $out" +row "refused" "a request to text further in, with no app named" if [ "$KIND" = phone ]; then REQ="Open MobiumApp"; APP=dev.mobium.mobiumapp; START=com.apple.Preferences diff --git a/internal/agent/assistant.go b/internal/agent/assistant.go index 7eea28f9..4b61a976 100644 --- a/internal/agent/assistant.go +++ b/internal/agent/assistant.go @@ -112,16 +112,22 @@ func (v *AssistantView) text() string { return b.String() } -// sideEffects are requests that act for the device's owner: placing a -// call, sending something, paying. Matched as the request's first verb, -// after a greeting. -var sideEffects = regexp.MustCompile(`(?i)^(?:(?:hey|ok|okay)\s+(?:google|siri|gemini)[,\s]*)?(?:please\s+)?` + - `(call|dial|text|message|send|email|mail|text|pay|buy|order|purchase|book|post|tweet|share|delete|transfer|venmo)\b`) +// sideEffects are words that act for the device's owner: placing a call, +// sending something, paying, telling someone. Matched anywhere in the +// request as a whole word, not only as its first: "Can you text Alex" and +// "Remind me to call Alex" act as much as "Text Alex". A word used as a noun, +// "what does this text say", is refused too; naming the app answers it. +var sideEffects = regexp.MustCompile(`(?i)\b(call|dial|text|message|send|email|mail|pay|buy|order|purchase|book|post|tweet|share|delete|transfer|venmo|tell\s+\w+)\b`) -// actsForSomeone names the verb when request acts for the owner, or "". +// actsForSomeone names the word when request acts for the owner, or "". +// "Tell me" and "tell us" ask, and are skipped; "tell Alex" acts. func actsForSomeone(request string) string { - if m := sideEffects.FindStringSubmatch(strings.TrimSpace(request)); m != nil { - return strings.ToLower(m[1]) + for _, m := range sideEffects.FindAllStringSubmatch(request, -1) { + w := strings.Fields(strings.ToLower(m[1])) + if w[0] == "tell" && (w[1] == "me" || w[1] == "us") { + continue + } + return w[0] } return "" } diff --git a/internal/agent/assistant_test.go b/internal/agent/assistant_test.go index 11d6d507..8cd0a571 100644 --- a/internal/agent/assistant_test.go +++ b/internal/agent/assistant_test.go @@ -6,14 +6,20 @@ import ( "github.com/mobiumdev/mobium/internal/uitree" ) -// A request that acts for the device's owner is refused without an app; -// asking something, or opening an app, is not. +// A request that acts for the device's owner is refused without an app, +// wherever its verb is; asking something, or opening an app, is not. func TestActsForSomeone(t *testing.T) { for req, want := range map[string]string{ "Text Mom that I am late": "text", "Hey Google, call Alex": "call", "OK Siri please send an email": "send", "Buy more milk": "buy", + "Can you text Alex I'm late": "text", + "Tell Alex I'm late": "tell", + "Remind me to call Alex": "call", + "Hey Siri, I want to pay Sam": "pay", + "Tell me a joke": "", + "Tell me to call Alex later": "call", "Open Clock": "", "What is 15 times 3": "", "Show my texts": "", diff --git a/internal/device/boot.go b/internal/device/boot.go index 8df44f2a..7c39dc42 100644 --- a/internal/device/boot.go +++ b/internal/device/boot.go @@ -115,6 +115,18 @@ type Booted struct { Note string `json:"note,omitempty"` } +// emulatorArgs cold-boots avd with no host audio, headless unless window. +// -no-audio goes on a window too: the host's audio output breaks up what a +// capture hears (CHALLENGES 390), and the stream Mobium reads is not the +// host's, so a window loses only the Mac's speakers. +func emulatorArgs(avd string, window bool) []string { + args := []string{"-avd", avd, "-no-snapshot-load", "-no-boot-anim", "-no-audio"} + if !window { + args = append(args, "-no-window") + } + return args +} + // BootEmulator starts the AVD named avd and waits until Android has booted: // adb sees it and sys.boot_completed is 1. It cold-boots: the quick-boot // snapshot has brought back an app days older than the one installed @@ -139,10 +151,7 @@ func BootEmulator(ctx context.Context, avd string, window bool, log string) (Boo before[d.Serial] = true } } - args := []string{"-avd", avd, "-no-snapshot-load", "-no-boot-anim"} - if !window { - args = append(args, "-no-window", "-no-audio") - } + args := emulatorArgs(avd, window) if err := os.MkdirAll(filepath.Dir(log), 0o755); err != nil { return Booted{}, err } diff --git a/internal/device/boot_test.go b/internal/device/boot_test.go new file mode 100644 index 00000000..cda375d2 --- /dev/null +++ b/internal/device/boot_test.go @@ -0,0 +1,23 @@ +package device + +import ( + "slices" + "testing" +) + +// Every boot has no host audio, headed or not: the host's output breaks up +// what a capture hears (CHALLENGES 390). +func TestEmulatorArgsAlwaysNoAudio(t *testing.T) { + for _, window := range []bool{false, true} { + args := emulatorArgs("mobium-test", window) + if !slices.Contains(args, "-no-audio") { + t.Errorf("window=%v: %v has no -no-audio", window, args) + } + if slices.Contains(args, "-no-window") == window { + t.Errorf("window=%v: %v", window, args) + } + if !slices.Contains(args, "-no-snapshot-load") { + t.Errorf("window=%v: %v does not cold-boot", window, args) + } + } +}