Commit graph

32 commits

Author SHA1 Message Date
Jason Monk
c3aabad9fb Use app icon in notification dashboard instead of RC placeholder
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 11:20:40 -04:00
Jason Monk
ca9cee2a0c Add notification preview dashboard: all 6 channels with state variations
HTML catalog styled as Android notification cards showing every
notification the app sends: foreground service (6 states), auth
requests, session activity, errors, security alerts, AI outreach.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 11:14:40 -04:00
Jason Monk
69262d80b3 Add screenshot gallery: 112 preview screenshots with HTML dashboard
Robolectric-based screenshot tests capture every @Preview composable
in both light and dark mode. HTML gallery at docs/screenshots/index.html
displays all screens grouped by category.

Covers: Dashboard (8 states), Settings (4 states), Audit History,
Add Client, Authorization Approval, Integration Picker, Integration
Manage, Welcome, Setting Up, Onboarding Error, Health Connect Setup,
Notification Setup, Outreach Setup, Usage Setup, Device Code Approval.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 10:47:26 -04:00
Jason Monk
883f5437cf Add security decisions log for evaluated-and-accepted risks
Documents security concerns we've reviewed and decided not to address,
with reasoning: debug receiver, intent extras, cert pinning, stream IDs,
CORS. Prevents revisiting already-evaluated items.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 09:07:31 -04:00
Jason Monk
2bdf8fa4f0 Add device integration test report and screenshots
All 10 tests passed on Pixel 3 XL: build, deploy, launch, tunnel,
TLS passthrough, OAuth flow, MCP tool calls, audit, reconnect.

4 non-blocking issues found: dashboard status indicator, Firestore
permission error, WebSocket initial instability, protocol version.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 09:03:32 -04:00
Jason Monk
cf2f0edbf2 Add security audit report: 23 findings across 4 severity levels
4 critical (redirect_uri validation, PKCE format, unencrypted notification
storage, plaintext private key), 8 high, 8 medium, 3 low. Full analysis
with code locations, impact assessment, and remediation recommendations.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 08:49:14 -04:00
Jason Monk
3ab4af53f3 Add connection hardening, integration test gaps to backlog and plan
Backlog now 45 items. New sections:
- Connection resilience (auto-reconnect, keepalive, stale detection)
- Bridge/TLS hardening (timeouts, thread safety, cleanup)
- MuxDemux hardening (thread-safe map, stream leak protection)
- Auth hardening (cleanup, rate limiting)
- Error handling (structured logging, proper JSON-RPC errors)
- Integration test gaps (tests using production code paths,
  600 lines dedup, missing coverage for split TLS records and PKCE)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 17:11:39 -04:00
Jason Monk
ca4c53d87f Add Phase 6: device integration testing before security audit
Tests on the Pixel 3 XL via ADB: onboarding, tunnel, OAuth, tool calls,
integration setup, audit, notifications, UI screenshots, idle/reconnect.
Generates a test report at docs/device-test-report.md.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 17:07:49 -04:00
Jason Monk
4d03fc34f6 Add design specs for new integrations and overnight execution plan
New integration designs:
- Notifications: active + Room-backed history, actions, search
- Outreach: launch apps, links, clipboard, notifications, optional DND
- Usage: UsageStatsManager queries for app usage patterns
- Health Connect: generic query interface replacing hardcoded tools

Also: launcher icon (adaptive vector, navy bg + amber sun foreground),
updated backlog (28 items), overnight execution plan.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 17:03:37 -04:00
Jason Monk
d3acbab99e Document e2e status: mTLS connection works, passthrough routing is the current blocker 2026-04-06 14:10:36 -04:00
Jason Monk
c1eccc116e Remove relay_host/relay_port from FCM payloads, add FCM base URL override
Device now gets its relay URL from BuildConfig at compile time, so
FCM payloads no longer need to carry relay_host or relay_port. Updated
all design docs to reflect the simplified payloads.

Added RealFcmClient to relay/src/fcm.rs with a configurable base_url
so the device test framework can point the relay at a fake FCM server
via the FCM_BASE_URL env var.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 15:46:05 -04:00
Jason Monk
d11d04ba1f Add T-11 security monitoring task, renumber subsequent tasks
New task T-11 in Phase 3: self-cert verification + CT log monitoring.
Covers SelfCertVerifier, CtLogMonitor, SecurityCheckWorker, and
CertificateStore fingerprint additions. Depends on T-5 and T-7.

Renumbered: old T-11→T-12, T-12→T-13, T-13→T-14, T-14→T-15, T-15→T-16.
Updated branch names, test ID references, and phase description.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 19:48:46 -04:00
Jason Monk
91d81e8373 Add security monitoring design: self-cert verification, CT log monitoring, CAA records
Two complementary mechanisms for user-verifiable trust:
- Self-cert verification: app connects to its own subdomain and checks the
  TLS leaf cert fingerprint against what it provisioned (handles renewal
  window with dual-fingerprint acceptance)
- CT log monitoring via crt.sh: detects any cert issued for the subdomain
  that the app didn't issue, defeating targeted MITM attacks
- CAA record requirement documented for production DNS zone
- Trust status UI component for Settings screen (verified/warning/alert)
- 9 new test scenarios (45-53) covering both monitoring mechanisms

Changes across 4 design docs:
- overall.md: new Security Monitoring section + test scenarios, renumbered
  all subsequent scenarios (old 45-265 → 54-274)
- tunnel-client.md: CertificateStore additions, implementation details for
  both self-check and CT monitoring, WorkManager scheduling
- android-app.md: trust status UI spec, alert behavior, new preferences
- relay.md: CAA record configuration for rousecontext.com DNS zone

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 19:41:45 -04:00
Jason Monk
fa87318b53 Add workflow & dependency tree: 16 tasks across 6 phases
Complete implementation roadmap with:
- Module dependency graph and independence analysis
- 6 phases: scaffold → leaf modules → integration modules → service
  layer → health → app shell
- 16 tasks (S-1, T-1 through T-15) with per-task: files to create,
  tests to write first, acceptance criteria, owning agent
- Worktree strategy: branch naming, creation, merge order
- Task dependency DAG showing parallelization opportunities
- Agent assignments: relay, tunnel, mcp, android agents
- Up to 4 concurrent agents supported by design

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 16:35:52 -04:00
Jason Monk
6a52536271 Add comprehensive relay API specification
778-line API reference covering:
- All 5 REST endpoints with full JSON schemas, auth requirements,
  error responses, rate limiting, and examples
- Mux WebSocket binary framing protocol: exact byte layout, message
  types (DATA/OPEN/CLOSE/ERROR), stream lifecycle, edge cases
- FCM message formats (wake + renew)
- Common error envelope with error code table
- Firestore document schemas with indexes
- Signature verification algorithm
- Rate limiting summary

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 16:34:38 -04:00
Jason Monk
232f1e4f0d Add missing relay test scenarios, fix numbering to 265 total
Added 25 relay-specific tests that were missing from coverage review:
- Subdomain generation (63-66): two-word format, DNS-safe, collision retry
- Graceful shutdown (67-71): SIGTERM drain, CLOSE all streams, stats logged
- /status endpoint (72-76): correct counts for all metrics
- Daily maintenance job (77-83): cert nudge with dedup, pending queue, reclamation
- Config loading (84-87): TOML parsing, env vars, missing config errors

Renumbered all scenarios sequentially 1-265 with no gaps or duplicates.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 16:21:28 -04:00
Jason Monk
0f792bd171 Add UI test scenarios: navigation flows, screen states, integration manage
240 total test scenarios (was 189). New UI coverage:
- Navigation flows (15): first launch, first/second integration setup,
  re-enable, pending/active taps, device code from notification,
  audit deep-link, subdomain rotation
- Bottom nav (3): tab switching, state preservation
- Dashboard states (12): all CertStatus variants, empty/populated,
  connection status, recent activity
- Add picker (4): Available/Disabled/Unavailable rendering
- Integration manage (6): Active/Pending variants, revoke, disable,
  settings navigation
- Settings (5): idle timeout, battery, notifications, rotation
- Audit history (6): rendering, filters, deep-link, clear, empty

All UI tests designed as Compose host-side JVM tests with fake ViewModels.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 16:12:11 -04:00
Jason Monk
cf0a98429d Move authorized clients into per-integration manage screen
- Removed global Authorized Clients screen and bottom nav tab
- Bottom nav is now 3 tabs: Home, Audit, Settings
- New Integration Manage screen (app-owned, /integration/{id}/manage):
  URL, recent activity, authorized clients, disable, settings link
- Integration Settings screen (integration-owned) reached via Settings
  button on Manage screen
- Dashboard taps Active/Pending → Integration Manage
- Updated navigation flow, ViewModel table, wireframes

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 16:11:23 -04:00
Jason Monk
cc329064e9 Fix duplicate test numbering and missing AuditListener Koin binding
- Renumbered test scenarios 103-189 (was 99-185 with duplicates at 99-102)
- 189 total test scenarios, sequential with no gaps or duplicates
- Added missing AuditListener Koin binding (RoomAuditListener) in app doc

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 15:55:57 -04:00
Jason Monk
a357ade13b Fix consistency issues from per-integration auth changes
- Renumbered duplicate test IDs (69-70 appeared twice)
- Updated mcp-core OAuth test paths to use integration prefixes
  (/health/device/authorize, /health/token, etc.)
- Added test for cross-integration token rejection (91)
- Rewrote tests 168-173: removed stale isEnabled() references,
  now test IntegrationStateStore + ProviderRegistry + permission banners
- Fixed stale OnboardingFlow references in ui.md → onboardingRoute
- Authorized Clients screen now grouped by integration with per-integration
  revoke (matches per-integration TokenStore API)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 15:52:14 -04:00
Jason Monk
f4f501caf5 Per-integration auth, IntegrationStateStore, and gap analysis fixes
Major changes from final gap analysis:
- OAuth is now per-integration: each path has its own OAuth endpoints,
  device codes, and tokens. /health token can't access /notifications.
- TokenStore scoped by integrationId (validateToken, createToken, etc.)
- IntegrationStateStore: user-toggled enable/disable decoupled from
  platform permission checks. Backed by Preferences DataStore.
- NotificationSettingsProvider interface replaces static NotificationSettings
  in NotificationModel — settings changes take effect immediately
- DeviceInfo subdomain injected as StateFlow<String?> via Koin
- McpIntegration interface: added description field, removed isEnabled()
  (enabled state managed by IntegrationStateStore)
- Integration dashboard states derived: Available/Disabled/Pending/Active
  from IntegrationStateStore + TokenStore.hasTokens()
- CertStatus expanded with Onboarding sub-states (GENERATING_KEYS,
  REGISTERING, ISSUING_CERT)
- Device code approval shows integration name ("wants to access Health Connect")
- OAuth metadata per-integration (issuer = subdomain + path)
- Koin graph updated with new bindings

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 15:36:54 -04:00
Jason Monk
bac3d10647 Refactor integration UI: own screens via Nav3 route registration
McpIntegration no longer injects Composables (OnboardingFlow, SettingsContent).
Instead, integrations register their own routes via registerNavigation() with
an app-provided prefix for uniqueness. Each integration owns its screens
entirely — the app just navigates to integration/{id}/setup or
integration/{id}/settings.

Updated Nav3 route table, Health Connect integration description, and UI
wireframes to reflect integration-owned detail/settings screens.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 15:12:23 -04:00
Jason Monk
86b873d31f Update UI design: integration detail screen, device code navigation rules
- Added Integration Detail screen (Active integrations: URL, recent
  activity, settings, disable button)
- Clarified device code navigation: auto-navigate ONLY from Integration
  Enabled screen, all other contexts use notification
- Multiple simultaneous auth requests: each posts notification, first-come
  first-served approval
- Pending integration tap: routes to Setting Up or Integration Enabled
  depending on cert state
- Added IntegrationDetailViewModel to ViewModel table

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 14:58:08 -04:00
Jason Monk
762b24dd6d Add UI design doc: wireframes, navigation flow, ViewModels, integration states
Complete UI specification:
- 12 screens with ASCII wireframes (Welcome, Dashboard, Add Picker,
  Integration Setup flow (4 screens), Device Code Approval, Connection
  Confirmed, Audit History, Authorized Clients, Settings)
- Integration states: Available, Disabled, Pending, Active with transitions
- Cert status banners: None, Valid, Renewing, Expired, RateLimited
- Navigation flow map with all transitions
- ViewModel table with observables and key state
- Testing strategy: ViewModel unit tests, screenshot/preview tests,
  integration setup flow tests

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 14:44:24 -04:00
Jason Monk
4d1aacfde4 Add app module test scenarios: notifications, work, health, app wiring
185 total test scenarios (was 137). New coverage:
- :notifications (15): NotificationModel state machine, all setting
  combinations, audit persistence/queries/retention
- :work (15): foreground service lifecycle, wakelock per TunnelState,
  idle timeout behavior, WorkManager cert renewal, FCM dispatch
- :api + :health (6): McpIntegration contract, availability/enabled
  checks, permission revocation, onboarding flow completion/cancel
- :app (12): navigation, integration enable/disable → ProviderRegistry,
  device code approval/denial, client revocation, subdomain rotation,
  battery optimization UX, notification permission gating

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 14:05:40 -04:00
Jason Monk
f6c6e12167 Rewrite app design doc with full module architecture
Complete restructure into focused modules:
- :core:tunnel, :core:mcp — KMP protocol layers
- :api — McpIntegration contract (onboarding UI, settings UI, MCP binding)
- :health — Health Connect implementation of :api
- :notifications — NotificationModel state machine, audit persistence, channels
- :work — foreground service, WorkManager, FCM receiver, wakelock management
- :app — Compose shell, Koin graph, navigation, provider registration

Includes: dependency graph, Koin wiring, Compose navigation routes,
McpIntegration interface, integration state machine, settings schema.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 13:43:03 -04:00
Jason Monk
337771cb20 Add comprehensive test scenarios for mcp-core, tunnel, and cross-module
137 test scenarios total (was 60). New coverage:
- Cross-module: tunnel→mcp-core full stack, tunnel↔relay mux protocol,
  cert flow through app→CertificateStore→tunnel→relay
- mcp-core: Streamable HTTP, MCP tool/resource calls, OAuth device code
  flow, auth middleware, ProviderRegistry dynamic behavior, per-stream
  HTTP server lifecycle
- Tunnel: mux frame parser/outbound, TLS server accept, CertificateStore
  integration, state machine transitions, FCM dispatch, cert renewal
  execution, onboarding execution
- App scenarios deferred pending architecture discussion

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 13:27:19 -04:00
Jason Monk
505184326b Fix McpSession wiring in app doc to match ProviderRegistry design
App doc showed creating a new McpSession per stream with a static list.
Updated to match overall.md: McpSession is a shared singleton taking
ProviderRegistry and TokenStore, with run() called per stream.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 13:19:42 -04:00
Jason Monk
ac7955cee9 Resolve third design review: McpSession interface, stream IDs, rate limits
Pass 3 findings (8 items):
- McpSession reworked: takes ProviderRegistry (live, dynamic) and TokenStore
  interfaces instead of static provider list. No reconstruction on config change.
- Mux stream IDs: u32 per-connection (routing only), tunnel generates UUID
  per stream for audit trail (MuxStream.sessionId)
- /wake rate limited: 6/min per subdomain, prevents battery-drain DoS
- Cert renewal threshold aligned to 14 days (was 30 in tunnel doc)
- OAuth metadata: full RFC 8414 response specified
- Post-renewal cert validation: device verifies CN/SAN matches subdomain
- /register always runs ACME (relay never has private key, can't reuse certs)
- 60 integration test scenarios (was 57)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 13:17:47 -04:00
Jason Monk
4c6c31dc00 Resolve second design review: TLS layers, HTTP protocol, routing, deployment
Addresses 8 gaps from second review pass:
- mcp-core HTTP server: Streamable HTTP (MCP spec) over Ktor, per-stream
  instances, auth middleware checks Bearer on non-OAuth routes
- Inner TLS: tunnel terminates using device cert via CertificateStore
  interface (defined in tunnel, implemented by app)
- Port 443 SNI routing: relay.rousecontext.com → terminate TLS + serve
  HTTP (REST + WebSocket); *.rousecontext.com → passthrough
- Relay TLS: optional client cert at TLS level, enforced per-route
  (/ws requires cert, /register doesn't, /renew accepts either)
- Relay cert: manually provisioned via certbot, deployed from GitHub
  Secrets (VPS is stateless)
- Daily maintenance job: cert expiry nudge (7-day, with renewal_nudge_sent
  tracking), pending cert queue, subdomain reclamation
- FCM types: "wake" (high priority) and "renew" (normal priority)
- 57 integration test scenarios (was 52)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 12:58:28 -04:00
Jason Monk
851e4dee58 Resolve design review gaps: auth details, rate limits, notifications, rotation
Addresses findings from thorough design review across all docs:
- Crypto: ECDSA P-256, SHA256withECDSA, Base64 DER for keys/signatures
- OAuth: device code TTL 10min, polling 5s, opaque tokens (no expiry)
- Cert renewal: two-stage (14 days proactive, 7 days relay-pushed warning)
- Expired certs rejected for mux — must renew via /renew endpoint first
- ACME: Let's Encrypt primary (50/week), rate limit handling with pending
  queue, admin alerts, and device notification
- Subdomain rotation: once per 30 days, old invalidated, tokens revoked
- Max 8 concurrent streams per device (configurable)
- TunnelClient interface: added errors SharedFlow, TunnelError sealed class,
  unified TunnelState enum with ACTIVE state
- FCM payload format specified (data-only, type/relay_host/relay_port)
- Disabled integration returns 404 + app notification
- 52 integration test scenarios covering all flows
- Cross-references between docs for mux wire format

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 12:04:00 -04:00
Jason Monk
015430e85c Add comprehensive design docs for all system components
Four design documents covering the full architecture:
- overall.md: end-to-end flows, identity model, Firestore schema, integration
  model (per-provider URLs), OAuth device code auth, 38 integration test
  scenarios, KMP module structure, subdomain format (two-word memorable)
- relay.md: Rust relay internals — mux framing protocol, SNI parsing, API
  endpoints (/register, /renew, /wake), ACME via ZeroSSL/Cloudflare,
  FCM REST integration, config/shutdown/monitoring
- tunnel-client.md: KMP tunnel module — mux WebSocket client, stream demux,
  FCM receiver, Keystore/CSR/cert management, TunnelClient interface
- android-app.md: Compose UI, integration management, device code auth UI,
  testable notification model, wakelock/battery strategy, audit logging,
  onboarding flow with notification permission gating

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 11:34:59 -04:00