Commit graph

26 commits

Author SHA1 Message Date
Jason Monk
6517ab4613
Deduplicate 39 copy-paste health query methods via shared helper (#442) (#445)
Extract RecordReader.queryRecords() extension that handles read-map-sort-limit,
replacing 39 private suspend fun query*() methods across 7 category files with
inline lambdas. Zero behavior change, verified by all existing tests.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-03 09:34:11 -04:00
Jason Monk
56d689fbbc
Fix #427: Wrap McpTool error paths in JSON envelope (#433)
The two framework-level error paths in McpTool.invoke() (param-extraction
failure and catch-all exception handler) produced plain-text ToolResult.Error
bodies. The Anthropic connector proxy expects JSON in the TextContent text
field, causing "Invalid content from server" errors on any missing-param
or unhandled-exception path.

Add ToolErrorResponse @Serializable data class with {"success":false,"error":"..."}
shape (matching the outreachError/usageError pattern from #418), and wrap both
error sites. Remove the expectJsonBody=false bypass in UsageMcpProviderTest
that was pinned for this issue.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-27 14:44:59 -04:00
Jason Monk
8e17ff84c3
Fix #431: Expose actions param in send_notification schema + add click_url contentIntent (#432)
The actions param was read from rawArgs directly, bypassing the McpTool
param DSL so Claude couldn't discover it via tools/list. Declare it as
an optional stringParam (JSON-serialized array) and parse inside
addNotificationActions(). Also add click_url optional param that sets
the notification's contentIntent via PendingIntent with http/https
validation.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-27 14:38:03 -04:00
Jason Monk
567e9ee9a7
Fix #426: Test-methodology gap that let #417 ship (#428)
Two gates to prevent reintroduction of the malformed-JSON bug class
that shipped in #417 (Outreach error helpers used a """{...}""" template
with raw exception text, producing unparseable bodies).

(A) Harness-level JSON parse assertion. Introduces shared
`McpToolTestHarness` (in `integrations/src/test/.../testing/`) that
wraps the duplicated mockk(Server) + addTool capture pattern previously
copy-pasted across `OutreachMcpProviderTest`, `UsageMcpProviderTest`,
`NotificationMcpToolExecutionTest`, and `NotificationMcpProviderToolsTest`.
Every `callTool(...)` invocation runs the result body through
`Json.parseToJsonElement`; parse failures throw with the offending tool
name and body content. Per-call `expectJsonBody = false` opt-out for
tools whose contract is plain text (currently only one test uses it,
referencing #427 which tracks the underlying core MCP DSL gap the
harness surfaced).

Regression test `McpToolTestHarnessTest` constructs fake tools that
return non-JSON bodies and asserts the harness throws with the tool
name + body in the message, plus a passing-case to lock down the
expectJsonBody opt-out.

(B) CI grep check. New `scripts/check-no-manual-json.sh` greps
`*/src/main/*.kt` for `"""\{` and fails the build on hits unless the
line carries a `// allow-manual-json: <reason>` marker, or matches the
explicit `AuditDetailScreen.kt` allowlist (Compose preview fixtures).
Wired into `.github/workflows/android-ci.yml` next to the existing
`check-zombie-screens.sh` step. Verified manually that the script
fires on a synthetic `"""{"x":"$bar"}"""` and clears once the marker
is added.

Documents the convention in new `docs/agent-quickstart.md`.

Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>
2026-04-26 17:31:31 -04:00
Jason Monk
3071bf787f
Fix #419: Apply awaitReady pattern to securityAlertCheck + OutreachIntegration + DeviceRegistrationStatus (#421)
Three sibling instances of the cold-start async-state-not-loaded-yet race
that #416 fixed for ProviderRegistry (issue #414). Each used the same
shape: async state seeded into a StateFlow with a default value, read
synchronously by callers that fire during the cold-start window between
process spawn and the first DataStore emission.

Finding #1 (HIGH) - securityAlertCheck

The McpSession `securityAlertCheck` lambda was `() -> Boolean` reading
`alertFlag.value` from a `combine().stateIn(..., initialValue = false)`
flow. On cold-start FCM wake the very first request arrived before the
flow had emitted, so a device whose security check reported `alert`
answered the request anyway. Subsequent requests refused correctly.

Fix: introduce SecurityAlertGate (mirrors ProviderRegistry's awaitReady
shape) that suspends until the underlying combined flow has emitted
once, then exposes `suspend fun isAlerting()`. McpRouting's
`securityAlertCheck` lambda type changes to `suspend () -> Boolean`;
existing test lambdas (`{ true }` / `{ false }`) auto-cast.

Finding #2 (MEDIUM) - OutreachIntegration._directLaunchEnabled

`canLaunchDirectly` was a `() -> Boolean` reading
`_directLaunchEnabled.value` from a MutableStateFlow seeded by an
`appScope.launch{}` collector. First tool call after cold-start could
mis-route through the notification fallback even when the user had
opted into direct launch.

Fix: convert `canLaunchDirectly` to `suspend () -> Boolean` through the
chain (LaunchAppTool, OpenLinkTool, launchActivitySafely). Add
`awaitReady` / `awaitReadyBlocking` to OutreachIntegration; the lambda
becomes `{ isDirectLaunchAllowed() }` which suspends on awaitReady
before reading the flow value.

Finding #3 (MEDIUM, latent) - DeviceRegistrationStatus

Constructed with `initiallyRegistered = false` and an
`appScope.launch{ if (certStore.getSubdomain() != null) markComplete() }`.
Currently safe only because IntegrationSetupViewModel.awaitRegistrationIfNeeded
(issue #242) consults the cert store directly; future readers that add
`.complete.value` without copying the workaround re-introduce the bug.

Fix: add `DeviceRegistrationStatus.create(scope, suspend isRegistered)`
factory that runs the check in `scope` and signals `awaitReady` once it
resolves. AppModule's Koin binding switches to `create()`. The
synchronous constructor is preserved for tests; both code paths signal
readiness eagerly when the answer is known up front.

Per #419 hard rules:
- Workaround in IntegrationSetupViewModel.awaitRegistrationIfNeeded
  left in place; no UX-flow files touched.
- No runBlocking added to production code.

Tests:
- SecurityAlertGateTest (new): slow-flow regression + idempotent
  awaitReady + empty-first-emission ready signal.
- DeviceRegistrationStatusTest (extended): create() defers awaitReady
  until check resolves; both true/false verdicts unblock.
- OutreachIntegrationTest (extended): mockk-based slow settings store
  proves awaitReady waits for first emission.
- HttpRoutingTest (extended): suspend-awaiting securityAlertCheck still
  rejects with 503.

Verification:
- `./gradlew :app:testDebugUnitTest :work:testDebugUnitTest :core:mcp:jvmTest :integrations:testDebugUnitTest` all green.
- `./gradlew ktlintCheck detekt` clean.

Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>
2026-04-26 14:18:17 -04:00
Jason Monk
5d8b65ed60
Fix #417: Migrate manual JSON in MCP providers to @Serializable data classes (#418)
The manual `"""{"key":"$value"}"""` pattern in five integrations files routinely
produced malformed JSON when interpolated values contained `"`, `\`, newlines,
or tabs — exactly what `Throwable.message` from Android exceptions tends to
carry. The bug surfaced as the Phone Outreach connector returning "malformed
responses through the Anthropic proxy" on any failure path.

This commit replaces every interpolated JSON template in the integration MCP
providers with `@Serializable` data classes encoded via `kotlinx.serialization`,
so user-supplied content is escaped by the serializer rather than concatenated
into a string. The wire shape (field names, types, nesting) is preserved
exactly — only the encoding step changes. Per-file `*JsonModels.kt` files
hold the new DTOs alongside a per-file `Json { encodeDefaults = true }`
instance that keeps the constant `success` defaults on the wire.

Files migrated:
  - integrations/.../outreach/OutreachMcpProvider.kt (~10 sites)
  - integrations/.../usage/UsageMcpProvider.kt (~10 sites)
  - integrations/.../notifications/NotificationMcpProvider.kt (5 sites)
  - integrations/.../health/query/VitalsQueries.kt (skin temp deltas)
  - integrations/.../health/query/SleepQueries.kt (sleep stages)

The two health-query string-of-JSON fields (`deltas`, `stages`) preserved
their unusual legacy shape (`"deltas":"[{...},{...}]"`) by building the inner
arrays with `buildJsonArray` and stringifying — no wire change.

The local `escapeJson()` extensions in OutreachMcpProvider and UsageMcpProvider
became dead code and were deleted.

`AuditDetailScreen.kt` was audited: its `"""{` occurrences are only `@Preview`
fixture data, not runtime JSON construction, so no change is needed there.

Tests: each new DTO has round-trip coverage including regression cases for
`#417` — error/message strings containing `"`, `\`, `\n`, `\t` round-trip via
`Json.parseToJsonElement` without throwing. The existing
`OutreachQueryInstalledAppsTest` was updated to assert on typed fields rather
than substring-matching JSON strings (queryInstalledApps now returns
`List<InstalledApp>` instead of `List<String>`).

Cross-references: this is the broader migration referenced by closed issue
#130, which did the same work for OAuth protocol responses in McpRouting.

Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>
2026-04-26 12:10:10 -04:00
Jason Monk
723a9b080d
Fix #383: ToolCallRow multi-line padding + top-align time + never render ciphertext fallback (#384)
Three tightly-coupled bugs in the shared audit-row surfaces:

1. ListRow previously used `defaultMinSize(minHeight = 56.dp)` with no
   vertical padding. Single-line rows looked right (floor set by
   min-height, content centered) but multi-line content (e.g. a long
   JSON `arguments` string in ToolCallRow) grew the row height and then
   pressed flush against the top and bottom edges of the card. Replace
   the min-height floor with `padding(vertical = 12.dp)`: single-line
   rows keep a ~48 dp height which matches existing density, multi-line
   rows now have breathing room. Applied to `ListRow`,
   `ListRowWithIcon`, and `ListRowWithTrailing`.

2. `AuditHistoryViewModel.toHistoryEntry` fell back to the raw
   `entry.argumentsJson` / `entry.resultJson` columns whenever the
   FieldEncryptor was null or `decrypt()` returned null. Those columns
   hold ciphertext at rest, so the fallback rendered base64-looking
   blobs into the dashboard's Recent Activity teaser and the audit
   detail screen. Root cause of the null-encryptor path was that
   MainDashboardViewModel and IntegrationManageViewModel never received
   the encryptor. Fix both:
   - Remove the raw-column fallback everywhere. Render "" (empty) when
     decrypt is unavailable; ciphertext is never rendered as plaintext
     even if future call sites forget to wire the encryptor.
   - Thread `FieldEncryptor` through MainDashboardViewModel and
     IntegrationManageViewModel via Koin so production paths always
     decrypt.
   - Apply the same fix to `AuditDetailDestination` and to
     `NotificationMcpProvider.recordToJson` (which returned ciphertext
     over the MCP wire to the AI client when the encryptor was null).

3. In ToolCallRow's row 2 the outer Row was
   `verticalAlignment = CenterVertically`. When a long `arguments`
   string wrapped to multiple lines, the timestamp on the right floated
   to the vertical center of the wrapped block while the duration
   stayed pinned to the top, looking misaligned. Switch to
   `Alignment.Top` so the time stays pinned alongside the duration on
   the first wrapped line.

Tests:
- New AuditHistoryViewModelTest cases pin the fallback contract: with
  a null FieldEncryptor or a decrypt that returns null, the resulting
  AuditHistoryEntry.arguments is "" and argumentsJson / resultJson are
  null, never raw ciphertext.
- New screenshot case 34b_audit_history_long_args (light + dark)
  renders a multi-line JSON `arguments` block. Locks in the padding
  + top-alignment fix; regressions will show immediately as a visual
  diff.
- Re-record affected goldens (08 dashboard, 17/18a integration manage,
  34/36/36a audit history, 99 bottom-inset manage, quick_* preview set).
  Trust-card 50* goldens intentionally NOT re-recorded (different
  issue area).
- Update NotificationMcpToolExecutionTest to use a passthrough
  encryptor by default so existing plaintext-round-trip tests keep
  working under the stricter no-ciphertext-fallback contract.

Closes #383

Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>
2026-04-23 16:04:40 -04:00
Jason Monk
86448beca4
Fix #341: Replace polling helper in NotificationCaptureServiceTest with deterministic signal (#357)
The test's `waitForRecordCount` 10ms-polling/2s-timeout loop was flaking in
CI, surfacing real assertion failures as polling timeouts per the project's
"hangs hide broken tests" convention. Replace it with a `SignalingDao`
decorator that completes a `CompletableDeferred` from inside each write,
letting awaiters resume deterministically once the service's
`Dispatchers.IO`-launched coroutine finishes its DAO call.

Confirmed stable across 20 back-to-back runs under the same Gradle/JVM
config CI uses.

Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>
2026-04-22 01:01:38 -04:00
Jason Monk
3fc3554156
Fix #346: Add ToolNameHumanizer utility + all-tools validation test (#352)
Convert snake_case MCP tool names to human-readable titles for display in
notifications (e.g. `get_steps` -> `Get Steps`, `set_dnd_state` -> `Set DND
State`). The acronym set is a simple constant that can be extended as new
tools with abbreviations land. Non-snake_case input throws
`IllegalArgumentException` so a malformed tool name surfaces loudly rather
than rendering as garbled UI copy.

The validation test dynamically enumerates every tool registered by every
`McpServerProvider` in `:integrations` (notifications, outreach with DND
enabled, usage, health) by recording `Server.addTool` calls and running
each captured name through the humanizer. A new tool landing with a
non-snake_case name will fail this guard rail before notification copy
work (#347) can rely on it.

Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>
2026-04-21 22:55:29 -04:00
Jason Monk
b7d9c2783d
Fix #301: Raise integrations/notifications coverage to 90.6% (#313)
Adds two new test files + extends NotificationDaoTest to close the
coverage gaps reported in #301:

- NotificationMcpToolExecutionTest drives every tool's execute() path
  through the SDK handler (happy paths, error paths, own-package
  blocking, ISO time parsing, field decryption, period ranges).
- NotificationCaptureServiceTest uses Robolectric ServiceController to
  exercise onNotificationPosted / onNotificationRemoved /
  onListenerConnected / onListenerDisconnected / onDestroy, plus
  dao-failure swallow paths and encryption wiring.
- NotificationDaoTest gains a file-backed NotificationDatabase.create()
  round-trip.

Per-class line coverage before -> after:

  NotificationCaptureService          0%   -> 72.3%
  NotificationMcpProviderKt           0%   -> 100%
  DismissNotificationTool             41.2% -> 100%
  GetNotificationStatsTool            16%   -> 100%
  ListActiveNotificationsTool         38.5% -> 100%
  NotificationDatabase                50%   -> 100%
  PerformNotificationActionTool       42.1% -> 100%
  SearchNotificationHistoryTool       41.7% -> 100%

Package total: 60.2% -> 90.6% line (462/510).

The remaining ~28% in NotificationCaptureService lives in
seedActiveNotifications, which calls the inherited
NotificationListenerService.getActiveNotifications() binder — only
reachable with a bound system service on a real device.

Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>
2026-04-19 23:58:38 -04:00
Jason Monk
9af562452c
Fix #248: Add Kover coverage measurement + CI aggregated report (#254)
Applies the `org.jetbrains.kotlinx.kover` 0.9.8 plugin to every production
module and wires the root project as the merging target, so
`./gradlew koverHtmlReport` produces one aggregated HTML + XML report across
`:app`, `:core:{tunnel,mcp,bridge}`, `:api`, `:notifications`, `:work`, and
`:integrations`.

Key pieces:

- `:core:tunnel:integrationTest` (real-relay subprocess tier) is now
  registered as a `KotlinJvmTest`, not a plain `Test`. Kover's KMP locator
  only auto-discovers tasks whose superclass is `KotlinJvmTest`; without
  this change, coverage from integration tests (e.g.
  `LazyMtlsKeyManager.chooseClientAlias`, exercised only by the real-relay
  flow) would silently be dropped from the report.
- Android `testReleaseUnitTest` tasks are excluded via
  `instrumentation.disabledForTestTasks`. CI only runs debug unit tests, and
  some release-variant unit tests aren't configured to work (e.g. Roborazzi
  screenshot tests in `:notifications`).
- Filters exclude generated code: `BuildConfig`, Compose `ComposableSingletons`
  + `*_ComposableKt`, kotlinx.serialization `$$serializer`, Room `*_Impl`,
  and Hilt/Koin glue for future-proofing.
- `:app`'s release-signing check is tightened to the exact signing-triggering
  task names so Kover's transitively-scheduled `packageReleaseResources` /
  `packageReleaseUnitTestForUnitTest` no longer trip the fail-fast guard.
- CI runs `koverHtmlReport koverXmlReport` after the existing test steps,
  uploads the HTML as `test-coverage` artifact, and writes a per-module line
  coverage summary to `$GITHUB_STEP_SUMMARY` (awk over each module's XML).

No `koverVerify` rule — report-only for the first pass as specified in #248.

Verified on the aggregated XML: `LazyMtlsKeyManager.chooseClientAlias` reports
`LINE covered=1 missed=0` (was unreachable from unit tests alone).

Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>
2026-04-18 17:11:09 -04:00
Jason Monk
2501f7349c
Fix #214: Trim tools/list descriptions and schemas (#220)
Shorten tool descriptions and drop redundant parameter descriptions
across all integrations to reduce per-session token cost on tools/list.

Per-integration tools/list bytes (before -> after):
- outreach:      3342 -> 2358  (-29.4%)
- usage:         1845 -> 1437  (-22.1%)
- health:        1070 ->  838  (-21.7%)
- notifications: 1848 -> 1349  (-27.0%)

Also teach the param DSL to skip emitting "description" when it's
empty, so self-evident params (e.g. a required `text` string) don't
pay for a useless description field.

No tools removed, no parameter names or types changed. Added a test
that measures tools/list byte size per integration (useful for future
audits).

Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>
2026-04-17 19:29:11 -04:00
Jason Monk
5bd8817cc2 Fix #196: Robolectric regression tests for Outreach package-visibility queries
Two test groups covering the queryInstalledApps fix from 50ef690d:

1. Functional behavior (8 tests): ShadowPackageManager with fake apps
   verifying system-app filtering, launcher-intent requirement, updated
   system app passthrough, name filter, and JSON output structure.

2. Manifest assertions (3 tests): XML-parsed verification that the
   integrations module manifest declares the required <queries> entries
   (MAIN+LAUNCHER, ACTION_VIEW https, ACTION_VIEW http) for Android 11+
   package visibility.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 17:22:06 -04:00
Jason Monk
d1848db4a1 Show the actual AI client name in outreach launch notifications
"AI client wants to open Spotify" is now "Claude wants to open Spotify"
when the calling client supplied client_name during OAuth DCR. Falls
back to the generic "AI client" label when no name is set.

Plumbing:
 - TokenStore gains resolveClientName(integrationId, token). Both the
   in-memory and Room-backed implementations resolve from the stored
   DCR label (or null when that equals the opaque clientId).
 - McpRouting.handleMcp reads the name right after bearer validation
   and wraps the SDK dispatch in withContext(McpClientContext(...)),
   a tiny CoroutineContext.Element in :core:mcp.
 - LaunchRequestNotifierApi.postLaunchApp / postOpenLink take an
   optional clientName. LaunchRequestNotifier uses it to format the
   notification title (%1$s wants to open %2$s).
 - OutreachMcpProvider's launch_app and open_link tools read the name
   from coroutineContext[McpClientContext] and pass it to the notifier
   fallback.

Non-goals: this only touches the launch-app/open-link notifications.
Other user-facing prompts (auth approval, per-tool-call) already show
client identity via a different path and are unchanged.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 16:35:06 -04:00
Jason Monk
50ef690d4e Add <queries> so Outreach can actually see installed apps
Android 11+ package-visibility filtering makes getInstalledApplications()
and getLaunchIntentForPackage() return a very small subset unless the
caller declares <queries> or holds QUERY_ALL_PACKAGES.

OutreachMcpProvider.queryInstalledApps filters to apps that "have a
launcher" (MAIN + LAUNCHER) and launchApp invokes getLaunchIntentForPackage,
so the right shape is an <intent> query for MAIN+LAUNCHER. Also add
ACTION_VIEW queries for http/https so open_link can resolve browsers /
deep-link handlers.

Not using QUERY_ALL_PACKAGES -- Play Store policy is strict about that
permission and the targeted queries give us what the tools need.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 16:00:12 -04:00
Jason Monk
207725a58c Fix #161: Inject NotificationDatabase/FieldEncryptor via Koin
NotificationCaptureService created its own NotificationDatabase via
`by lazy { NotificationDatabase.create(this) }`, producing a second Room
instance against the same SQLite file as the Koin-provided singleton
used by NotificationMcpProvider. Two instances wastes memory and can
cause subtle cache inconsistencies between the writer (service) and
reader (search tool).

Switch the service to `by inject()` so it shares the NotificationDao
and FieldEncryptor singletons already bound in AppModule. Adds
koin-android to :integrations so the service can use the inject
extension.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 09:49:10 -04:00
Jason Monk
897e8a40f2 Fix #156: Migrate :integrations/notifications to McpTool DSL
Convert NotificationMcpProvider's five tools (list_active_notifications,
perform_notification_action, dismiss_notification,
search_notification_history, get_notification_stats) from hand-rolled
server.addTool(...) calls to McpTool subclasses registered via
server.registerTool { ... }. Provider shrinks from 412 -> 313 LOC (-24%)
and drops the previous LongMethod-sized registerPerformAction helper in
favour of a dedicated PerformNotificationActionTool subclass.

Wire format stays byte-identical for happy-path results and tool-logic
errors (own-notification guards, allowActions policy). Required-param
errors now use the framework's uniform message format.

The #151 lockdown test (asserts exactly these five tool names + schema
round-trip) continues to pass unchanged.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 22:25:35 -04:00
Jason Monk
377edd832e Fix #155: Migrate :integrations/health to McpTool DSL
Converts HealthConnectMcpServer's three tools (list_record_types,
query_health_data, get_health_summary) from hand-rolled
server.addTool() calls to McpTool subclasses registered via
server.registerTool { ... }.

Wire format for success + tool-logic errors is byte-identical:
- Date parsing (accepting both ISO-8601 instants and date-only
  strings) stays inside the tool logic via StringParam rather than
  InstantParam, so "2026-04-01" keeps working on the happy path.
- Period validation message stays tool-logic so the existing
  "Invalid period" error text is preserved.

Provider LOC drops 37% (267 -> 167).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 22:18:15 -04:00
Jason Monk
f3048c6f4e Fix #154: Migrate :integrations/usage to McpTool DSL
Convert `UsageMcpProvider` from hand-rolled `server.addTool(...)` calls
to `McpTool` subclasses registered via `server.registerTool { ... }`.
Each of the four tools (`get_usage_summary`, `get_app_usage`,
`get_usage_events`, `compare_usage`) is now a dedicated class that
declares its parameters via the DSL and returns `ToolResult`. Wire
format for success and tool-logic errors is byte-identical.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 22:18:04 -04:00
Jason Monk
ce2de38708 Fix #123: Migrate :integrations/outreach to McpTool DSL
Converts all ten outreach tools (launch_app, open_link, copy_to_clipboard,
send_notification, create/list/delete_notification_channel,
list_installed_apps, get/set_dnd_state) from hand-rolled addTool blocks
to McpTool subclasses registered via server.registerTool { ... }.

The provider file shrinks from 883 to 547 lines: hand-built JSON schema
builders, manual argument extraction, and the errorResult / successResult
helpers collapse into the framework. OutreachMcpProviderTest is unchanged
— the existing "expected tool count + names" assertion now serves as the
registration lockdown.

Wire format for successful calls and tool-logic errors is byte-identical
to the previous implementation; the outreachSuccess / outreachError
helpers preserve the `{"success":true,"message":...}` and
`{"success":false,"error":...}` envelopes. Framework-level parameter
validation (missing required, type mismatch, range / choice) is the only
output path whose format changed — and those paths had no test coverage
or user-facing contract.

Also suppresses ReturnCount on each ParamDef.extract to keep detekt at
baseline; those functions are intentionally a series of short-circuit
guards.

Three follow-up issues will be filed for the remaining providers
(:usage, :health, :integrations/notifications) per the migration plan
in #123.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 22:07:19 -04:00
Jason Monk
f198df6b05 Fix #124: Wire :integrations, drop old modules
Final consolidation commit:

- :app depends on :integrations (and :notifications) instead of the four
  separate modules.
- AppModule.kt, integration registry classes, ViewModels, screens, and
  destinations updated to import from the new com.rousecontext.integrations
  and com.rousecontext.notifications packages.
- settings.gradle.kts drops :outreach, :usage, :health.
- outreach/, usage/, health/ directories removed (build.gradle.kts and
  AndroidManifest.xml only — all sources moved in the per-subtree commits).
- CI workflow collapses the four test tasks into :integrations:testDebugUnitTest.
- README module table reflects the new layout.
- New IntegrationOrthogonalityTest enforces the "integrations must remain
  independent" rule by failing if any integration source file imports from
  a sibling integration package.

Behavior preserved: APK permission set is byte-identical to main (verified
via aapt2 dump permissions), Koin graph wires the same providers in the
same order, tools/list returns identical tool counts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 21:45:10 -04:00
Jason Monk
60abaef726 Fix #124: Move notifications/capture into :integrations/notifications
Pure subtree relocation + package rename
(com.rousecontext.notifications.capture -> com.rousecontext.integrations.notifications).

FieldEncryptor stays in :notifications as cross-cutting infra (it is also
used by :notifications/audit/RoomAuditListener) and moves up one package
to com.rousecontext.notifications.FieldEncryptor. All callers updated.

App-side wiring (registry, Koin, ViewModels) updated in the final
consolidation commit.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 21:45:10 -04:00
Jason Monk
381f492d63 Fix #124: Move :health into :integrations/health
Pure subtree relocation + package rename
(com.rousecontext.mcp.health -> com.rousecontext.integrations.health,
com.rousecontext.mcp.health.query -> com.rousecontext.integrations.health.query).
Internal imports inside the health tree updated; intra-health query refs
preserved. App-side wiring updated in the final consolidation commit.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 21:45:10 -04:00
Jason Monk
56bb948948 Fix #124: Move :usage into :integrations/usage
Pure subtree relocation + package rename
(com.rousecontext.usage -> com.rousecontext.integrations.usage).
App-side wiring updated in the final consolidation commit.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 21:45:10 -04:00
Jason Monk
4e5575e67d Fix #124: Move :outreach into :integrations/outreach
Pure subtree relocation + package rename
(com.rousecontext.outreach -> com.rousecontext.integrations.outreach).
App-side wiring (registry, Koin) still references the old package; fixed
in the final consolidation commit.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 21:45:10 -04:00
Jason Monk
ac952cae90 Fix #124: Add :integrations module skeleton
Empty module with merged manifest (HC permissions, NotificationListener
service) and union of dependencies from :outreach, :usage, :health, and
:notifications/capture. Subsequent commits move each subtree in.
2026-04-14 21:45:10 -04:00