ui.md (chunk C) — replace fictional CertStatus interface with real
OnboardingState (only two steps: Registering, ProvisioningCerts), drop
the "Connection Confirmed" screen and "Integration Settings
(integration-owned)" wireframe (neither exist in code), update the
Integration Enabled URL example to the per-integration-hostname format
(https://<integration-secret>.<subdomain>.rousecontext.com/mcp), redraw
the navigation flow to show the post-#389/#392 path
(Welcome → NotificationPreferences → onboarding?autostart=true → Home),
rename DeviceCodeApprovalViewModel to AuthorizationApprovalViewModel
and add rows for OnboardingViewModel, NotificationPreferencesViewModel,
and the four per-integration setup VMs, expand the screen catalog with
the missing screens (NotificationSetup/OutreachSetup/UsageSetup,
AllClients, AuditDetail). Add a top-of-doc note explaining the
Screen / Content / Destination split so readers know production
renders *Content via *Destination, with *Screen reserved for previews
and screenshot tests.
relay.md (chunk B) — fix mux frame numbering (DATA=0x00, OPEN=0x01,
CLOSE=0x02, ERROR=0x03) and add PING=0x04 / PONG=0x05 with the 8-byte
nonce on stream id 0; replace the wrong single-round /register and
single-body /renew Path A snippets with a high-level endpoint table
that defers to docs/design/relay-api.md for the canonical request /
response shapes; drop /wake/:subdomain (no such endpoint — FCM wakeup
is internal to passthrough on cache miss).
Refs #406. android-app.md "Still needs design" section reviewed; the
sole remaining item (third-party provider discovery) is genuinely
undesigned and a non-v1 future feature, so it stays.
Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>
Apply audit findings from #406:
- docs/design/tunnel-client.md (chunk B, 7 findings): drop the KMP
framing (module is JVM-only); update TunnelClient to current
surface (connect(url), sendFcmToken, healthCheck); replace
TunnelError taxonomy with the actual sealed Exception subclasses;
rewrite MuxStream block (id: UInt, incoming: Flow<ByteArray>, send,
close); move reconnect ownership description to :work; rewrite
onboarding section as 3-hop flow with cert provisioning chained in
(#389); refresh CertificateStore section to cover per-integration
secrets, fingerprint bootstrap markers, and the deprecated PEM-key
hooks (#200).
- docs/design/health-connect-expansion.md (chunk C, 4 findings): flip
status to Implemented; replace the 12-entry record-type snippet
with a category table summarizing the shipped registry; rename
cycle category to reproductive and add mindfulness; update module
path from :health to :integrations and describe the
category-grouped query files (ActivityQueries.kt etc.) that
shipped instead of per-type RecordTypeHandlers.
- docs/design/per-integration-hostnames.md: deleted. Status was
proposed but the feature shipped with a different schema; the
shipped behavior is now in docs/design/relay-api.md and
docs/design/overall.md (post-#409, #410 rewrites).
- docs/design/secret-prefix-bot-rejection.md: deleted. Superseded by
the per-integration-hostnames work which generalized it; same
shipped behavior is covered by relay-api.md + overall.md.
- docs/design/overall.md: redirect the surviving inbound link from
secret-prefix-bot-rejection.md to relay-api.md.
- docs/audit.md: collapse the per-integration-hostnames + secret-prefix
entries to "deleted (superseded)" and update the punch list.
Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>
Doc maintenance only — no code change. Removes the 363-line embedded
test-case inventory that had drifted off the implementation, and fixes
the prose drift items called out in the chunk D audit on #406:
- Onboarding flow rewritten as the post-#389 three-hop sequence:
/request-subdomain -> /register -> /register/certs (CSR generated
after subdomain assignment so its SAN matches), citing
OnboardingFlow.execute() and docs/ux-decisions.md (2026-04-24).
- Firestore data model gains the three load-bearing fields on
devices/ (secret_prefix legacy, valid_secrets, integration_secrets)
and the subdomain_reservations/ collection.
- Auth-method table adds the /register/certs row and corrects the
/renew rows to show that both paths are body-driven and signature
is over CSR DER (not firebase_token).
- Ghost "Wake pre-flight" subsection removed — /wake is not a public
endpoint; FCM wake is internal to passthrough on SNI-cache miss.
- Subdomain Format reframed around the post-#92 single-word pool with
adjective-noun as overflow.
- Module Structure replaces the stale KMP framing (no commonMain ships)
with the actual 11-module layout from settings.gradle.kts.
- Integration Model and OAuth/MCP examples reframed around per-
integration hostnames as the routing key, with /.well-known/...,
/device/authorize, /token, /mcp at the root of each per-integration
host (not URL path segments).
- FCM payload format adds the type:"renew" example used by the
maintenance loop's expiry nudge.
- Test inventory replaced with a one-paragraph pointer to the test
source roots in each module — per-feature coverage notes belong
with the feature, not in this design doc.
Refs #406.
Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>
The doc had drifted materially from the codebase (chunk C of #406 audit).
Module map listed a non-existent :health module and missed :core:bridge
and :core:testfixtures; the McpIntegration interface sketch invented a
registerNavigation() that has never shipped; the route table didn't
match Routes.kt; and the onboarding sequence predated the #389/#392
chained cert-provisioning flow.
Restructured around an architecture overview, a single source-of-truth
module table (verified against each build.gradle.kts), the actual
McpIntegration interface from api/, the canonical Routes catalog with
the autostart re-entry trick from #392, and the three-hop onboarding
sequence (request-subdomain → register → register/certs).
Refs #406.
Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>
The relay-api.md document had drifted significantly from the implementation.
This rewrite addresses every chunk B finding for relay-api.md (#406):
* Removed the fictitious POST /wake/:subdomain endpoint section (item 1).
Wake-up is internal to the passthrough resolver; documented as the
"Internal FCM wakeup" subsection pointing at resolve_device_stream.
* Rewrote /register as the two-round flow it actually is (item 2): round 1
assigns subdomain + per-integration secrets; round 2 takes the CSR.
* Added the missing /register/certs section (item 3) including the
proof-of-possession signature semantics (#201).
* Added the missing /request-subdomain section (item 4) including the
per-UID rate limiter, idempotent-retry behaviour, and pool tiers.
* Added the missing /rotate-secret section (item 5): mTLS-only,
replace-by-request-set semantics, empty-list legitimacy (#202, #285).
* Added an "Admin / Test-Mode Endpoints" appendix (item 6) listing
/test/kill-ws, /test/fcm-wake, /test/open-stream,
/test/emit-stream-error, /test/wait-session-registered, /test/stats,
with the test-mode feature + loopback-only guarantees.
* Split signature semantics by endpoint (item 7): /register
re-registration signs the firebase_token bytes; /register/certs PoP
and /renew sign the CSR DER bytes. Added a dedicated table.
* Renumbered the mux frame types (item 8): DATA=0x00, OPEN=0x01,
CLOSE=0x02, ERROR=0x03, plus PING=0x04 and PONG=0x05 with their
u64-BE nonce payload semantics (#179).
* Replaced the ERROR code table (item 9) with the actual codes
STREAM_REFUSED=1, STREAM_RESET=2, PROTOCOL_ERROR=3, INTERNAL_ERROR=4
encoded as u32 BE (4 bytes), not u8.
* Expanded the devices/{subdomain} schema (item 10) with secret_prefix
(deprecated), valid_secrets, and integration_secrets.
* Added the subdomain_reservations/{subdomain} collection (item 11).
* Swept ACME rate-limit text (item 12) so GTS is the primary CA in
prose, not just in passing references.
Also restructured the endpoint catalog into a summary table at the top
plus a per-endpoint section, since the previous numbering scheme
fought the new contents.
Documentation only; no code changes.
Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>
Production rousecontext.com has been on Google Trust Services since #213
(relay default when no [acme] section is configured). The three design
docs still described Let's Encrypt as primary and cited LE-specific
limits (50/registered-domain/week, ISRG roots). This updates:
- docs/design/relay.md: CA Selection now names GTS with the
dv.acme-v02.api.pki.goog directory and the EAB requirement; CAA
example flipped to pki.goog; rate-limit section now covers both
CAs; mTLS trust anchors corrected (relay's own private device CA
loaded from tls.ca_cert_path, not public CA roots embedded in
the binary — this was wrong on two counts).
- docs/design/overall.md: Primary CA header flipped to GTS, with
LE framed as a supported option for self-hosters; CAA example
updated.
- docs/design/relay-api.md: mTLS auth description, server_cert
field description, and rate-limit tables no longer claim LE.
- docs/self-hosting.md: troubleshooting note about quotas broadened
to cover both CAs (kept the LE example intact per the issue).
Docs-only; no code or config change.
Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>
The Android RelayApiClient and the relay's POST /renew endpoint had drifted
apart on both request and response shapes: the client was sending
{ csrPem, authMethod, currentCertPem } while the relay required
{ csr, subdomain, firebase_token, signature }, and the client expected
{ certificatePem } in the response while the relay returned
{ server_cert, client_cert, relay_ca_cert }. Neither side had integration
coverage on the renew path, so /renew returned 422 unconditionally in
production and cert renewal was quietly broken until devices approached
expiry.
This change keeps the relay's response shape (it already matched
/register/certs) and aligns the client to the relay side, plus a small
relay-side simplification so both auth paths are body-driven:
Request (both paths):
{ csr, subdomain, signature, firebase_token? }
Path A ("mTLS-equivalent", cert still valid): omit firebase_token.
Path B (cert expired): include firebase_token.
The relay verifies the signature against the public key it registered
earlier, and additionally verifies firebase_token (+ UID match) on Path B.
Response (matches /register/certs):
{ server_cert, client_cert, relay_ca_cert }
Wire-contract tests pin both sides:
- relay/tests/api_renew_test.rs gains a Path A signature-only success case
and a bad-signature-on-Path-A case; pre-existing tests were adjusted
for the new "signature always required" rule.
- core/tunnel CertRenewalTest gains serializer tests that assert the
snake_case field names on both the request and the response, so a
future rename on either side fails loudly here first.
CertRenewalFlow now routes the signature through a CsrSigner (parallel to
the existing FirebaseRenewalCredentialsProvider) so both paths sign over
the freshly-generated CSR DER rather than accepting a pre-computed value,
and stores all three cert bundle fields (mirroring CertProvisioningFlow).
RenewalAuthProvider in :work gains a signCsr hook to match.
docs/design/relay-api.md is updated to the new shape; the old stale
"Path A uses TLS client cert" language no longer reflects reality and
would have slowly misled future work.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Follow-up to #78 cleanup. The code for NotificationModel was deleted
but implementation-specific references remained in other docs:
- docs/design/overall.md: rename section heading from
"NotificationModel + audit" to "notification behavior + audit"
- docs/test-coverage-audit.md: drop NotificationModelTest row and
update file count from 7 to 6
- docs/notifications/index.html: remove "/ NotificationModel.kt"
from source references (hand-written HTML, not generated)
Historical planning references in docs/workflow.md describing the
original T-7 plan are left intact.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The notifications-package NotificationModel state machine was never wired into
production code — only its own unit test referenced it. Its companion
NotificationSettings data class is exclusively used by NotificationModel (the
real per-user notification settings live in :api as a separate type). Delete
all three files.
Also prune design-doc claims in android-app.md that described the deleted
state machine as the implementation; leave high-level notification architecture
intact.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Each integration gets its own hostname with the format
{adjective}-{integration}.{subdomain}.rousecontext.com/mcp
so Claude can't confuse integrations that share a host.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Rewrite README to lead with the project vision and current status.
Add design doc for secret URL prefix scheme that prevents bots from
waking devices without knowing a rotatable secret.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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>
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>
- 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>
- 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>
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>
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>
- 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>
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>
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>