Skip to content

Fix CI, correct docs, and fix high/medium review findings - #1

Merged
austingregoryus merged 7 commits into
mainfrom
claude/gallant-cray-r0op8a
Oct 14, 2026
Merged

austingregoryus merged 7 commits into
mainfrom
claude/gallant-cray-r0op8a

Conversation

@austingregoryus

Copy link
Copy Markdown
Owner

Summary

Code review of the whole repository, followed by fixes for every high and medium finding. main CI has been red since the initial release because of one wrong Android test; this PR fixes it.

CI fix

TurnDetectorTest asserted that digital silence scores below 0.5. Smart Turn v3.2 scores it 0.987 (identical under Python onnxruntime). The detector only runs after the VAD hears speech, so the test now checks front-padding and len handling instead.

Docs and schemas

  • protocol.md: the batch example used the wrong arguments; the decision pipeline order now matches the code; audit retention is documented; field, column and version details are corrected.
  • JSON schemas: missing action classes, event topics and audit kind added; pairing and tool-result schemas accept what the runtime actually emits.
  • README offline checks now match CI, plus corrections to config.example.yaml, the gateway README and the development, architecture, automation, security and review docs.

Android runtime

  • Screen control can't operate the app itself (ui.self_protected); FLAG_SECURE; sensitive controls hidden from accessibility.
  • Admin token rotation, which closes the old token's sessions and cancels its pending approvals.
  • Debug receivers require DUMP.
  • Approval prompts show the target and body first, in full and escaped; undeclared args are flagged.
  • Approving requires an unlocked device; lock-screen notifications are redacted.
  • notifications.reply is EXTERNAL_COMMITMENT and resolves its sender for the contact lists.
  • Approvals within 10 s of screen control are held pending.
  • Session events are scoped to the session owner.
  • Concurrent dials can't both go through, and hang-up/DTMF bind to the session's own Telecom call.
  • Release builds start the microphone foreground service.
  • WAV parsing is bounded and sample_rate is limited to 8000-48000.
  • Session frames tolerate slow consumers and report gaps.
  • Backup and device-to-device transfer exclude all app data.

Gateway

  • transport.not_sent / transport.outcome_unknown results with the idempotency key; client-supplied _meta.correlationId for safe retries.
  • Event replay recovers from failure; replies are matched by ref.
  • Invalid phone results are no longer passed through as success.
  • Anthropic thinking blocks keep their order; Gemini ids are unique and API-safe, and thoughtSignature is preserved.
  • wait_for_event uses a fresh per-wait subscription; cursors reset on journal or subscription change.
  • The SQLite DB is created 0600.
  • Malformed tool arguments never reach the phone.

Python drivers

  • MCP session re-init after the phone forgets it.
  • Elevated-mode send_sms restricted to numbers the owner wrote or allowlisted; tool results marked untrusted.
  • Preset/flag conflict is an error; API keys only go to their own host.
  • Python 3.13 pinned TLS works; gap-replay send errors reconnect.

Behavior changes

  • wait_for_event only returns events that arrive after the wait starts.
  • notifications.reply is hidden from peers paired with a COMMUNICATION ceiling.
  • Phone JSON-RPC errors keep their code.

Validation

  • Android: 150 unit tests pass, lint 0 errors, assembleDebug OK.
  • Go: go test -race, go vet and gofmt clean.
  • Python: 30 unittest checks, 5 inbound scenarios and 55 conversation scenarios pass; publication.py check passes; the manifest is regenerated.
  • Not exercised on a physical phone or carrier call.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CUcr2CsB79a6i7qk7hbSUP


Generated by Claude Code

The Android CI job has failed on every run since the initial release:
TurnDetectorTest asserted that one second of digital silence scores
below 0.5, but Smart Turn v3.2 returns 0.987 for it (identical under
Python onnxruntime). The detector only runs after the VAD hears speech,
so replace the assertion with a front-padding and len equivalence check.

Documentation and schema corrections found in review:
- protocol.md: batch example used a nonexistent `text` arg and a wrong
  contacts path; decision pipeline order now matches ToolDispatch and
  PolicyEngine; audit retention/anchors documented; column names,
  /health and /pair fields, accepted MCP versions, wake daily limit,
  dead section references fixed.
- JSON schemas: add AUTOMATION and SENSITIVE_READ action classes, ten
  missing event topics, workflow.run audit kind, actual redaction
  regex, pair-response URL/TLS fields, and the detail/replay fields the
  runtime emits in tool results.
- README offline checks match CI; directory table completed.
- config.example.yaml, gateway README, development, architecture,
  automation, security and review docs corrected against the code.
- Dead doc references removed from tool help text and code comments.
- PUBLICATION_MANIFEST.json hashes refreshed for changed files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CUcr2CsB79a6i7qk7hbSUP
- converse.Runtime re-initializes once when the phone reports an unknown
  MCP session (404 before dispatch). The inbound daemon previously failed
  every reply after a phone app restart while looking healthy.
- inbound.py elevated mode: send_sms is refused unless the recipient
  appears in the owner's own message or on a new outbound allowlist
  (--allow-send-to / secrets/inbound-send-allowlist); tool results are
  marked as untrusted data.
- converse.py: --local-*/--llm-api-key with a preset --brain now errors
  instead of being silently replaced; explicit keys go only to the
  custom primary, other brains use the key for their own host.
- Pinned TLS clears VERIFY_X509_STRICT so Python 3.13 accepts the phone's
  extension-less self-signed cert; the fingerprint pin still decides.
- EventChannel gap replay send failures reconnect instead of escaping.
- Call outcome no longer overwritten by True; "off" reasoning sentinel
  mapped to None in inbound.py and dry_call.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CUcr2CsB79a6i7qk7hbSUP
- tools/call failures are isError results: transport.not_sent when the
  request never reached the phone, transport.outcome_unknown (with
  correlation_id and idempotency_key) when it may have run. Clients can
  pass _meta.correlationId so retries reuse the phone-side idempotency
  key. Phone JSON-RPC errors keep their own code. The agent loop uses the
  same classification and tells the model not to retry blindly.
- Event replay: requests carry a ref matched on reply, so an unrelated
  error frame no longer fails a pending replay; replay_result is checked
  against its subscription; failed replays retry with backoff and force a
  reconnect after repeated failure instead of leaving catch-up stuck.
- Results the gateway cannot validate are returned as outcome-unknown
  errors instead of passing through as success.
- Anthropic: opaque thinking parts are replayed in their original order.
- Gemini: unique API-safe call ids; thoughtSignature preserved and
  replayed only to the same Gemini provider; illegal legacy tool ids are
  sanitized for Anthropic.
- wait_for_event uses a fresh per-wait subscription (no stale backlog,
  no collision between concurrent waits); unsubscribing deletes the
  stored cursor; cursors reset on subscription id change or journal reset.
- SQLite database and WAL/SHM files are created 0600 (DACL on Windows).
- Malformed tool-call arguments return tool.invalid_arguments without
  calling the phone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CUcr2CsB79a6i7qk7hbSUP
- Screen control can no longer operate the app itself: ui.* is refused
  while any of our windows is showing, launching our package and acting
  on our own notifications are refused (ui.self_protected). MainActivity
  sets FLAG_SECURE and marks token, code, switch and approval controls
  as sensitive data.
- The admin token can be rotated from the app; rotation closes the old
  admin's sockets and sessions and cancels its pending approvals.
- Debug ApprovalReceiver and DebugReceiver require DUMP, so only adb can
  drive them.
- Approval prompts list the target first, then the body, then declared
  params, in full and with control/bidi characters escaped; undeclared
  args are flagged. Approve/Deny need an unlocked device and the lock
  screen shows a redacted version.
- notifications.reply is EXTERNAL_COMMITMENT and resolves its sender for
  the contact deny/allow lists.
- Approvals arriving within 10 s of screen control are left pending and
  audited instead of executing; our own notifications are hidden from
  notification tools.
- Backup and device-to-device transfer exclude all app data.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CUcr2CsB79a6i7qk7hbSUP
- Session events (call.transcript, session.state, ...) are delivered only to
  the session's owner or the admin, on live push, replay, events.wait,
  workflow triggers and phone://events/recent (Principal.canSeeEvent,
  SessionManager.ownerOf). Unknown or ownerless sessions are admin-only.
- place_call treats a slot mid-placement as busy, so two concurrent
  requests can no longer both dial.
- Each call session is bound to its own Telecom Call (outgoing, dialed
  number, within 30 s of dialing). end_call, dial_dtmf, the dial watchdog,
  driver lease and emergency stop act only on that Call, and precise states
  of other calls no longer drive the session. Without an identified call,
  TelecomManager.endCall is used only when no other call existed at dial
  time and none has rung since; otherwise call.unidentified, no call touched.
- The InCallService starts its microphone foreground service in release
  builds too (the debug-only gate was a leftover).
- WAV parsing reads chunk sizes as unsigned and bounds them by the bytes
  present (a crafted size looped forever), requires 8..48 kHz and caps
  decoded audio at 300 s; play_audio validates sample_rate likewise.
- /ws/sessions subscribes before reading the backlog, de-duplicates by seq,
  refills frames a slow socket missed from session_messages and sends a gap
  frame when it cannot; the frame flow drops oldest instead of stalling
  every socket.
- Server fan-out gap NPE race, atomic subscription version, closed
  EventBroker statements.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CUcr2CsB79a6i7qk7hbSUP
The PR's Android job failed "model reproduces the reference probability"
while the push run on the same commit passed. The model is QDQ int8; with
ALL_OPT, ONNX Runtime runs it on fused integer kernels chosen per CPU, so
some x86 runners produce a different probability than the reference.

Compare against the stored reference with an unoptimized session, which
executes the graph as float math on every CPU (0.00844 vs reference
0.00913 under onnxruntime). The front-end check (Kotlin features vs
reference features) still uses the production ALL_OPT session on the same
host. Production inference is unchanged. Assertion messages now include
the values.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CUcr2CsB79a6i7qk7hbSUP
@austingregoryus
austingregoryus merged commit c1964e1 into main Oct 14, 2026
6 checks passed
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.

2 participants