Commit graph

87 commits

Author SHA1 Message Date
monkopedia-coder
4b2ec2fd68
Stop FGS gracefully on dataSync run-time timeout (#450) (#452)
Android 15+ enforces a cumulative ~6h/24h limit on dataSync foreground
services. When the budget is exhausted while the service is running, the
system calls Service.onTimeout() and requires a prompt stop; otherwise it
force-kills the process with ForegroundServiceDidNotStopInTimeException
(#450, #451).

TunnelForegroundService handled the symmetric start-time case
(ForegroundServiceStartNotAllowedException -> notify + stopSelf) but never
overrode onTimeout, so a budget that ran out mid-session crashed silently.
v1.0.2's keep-Ktor-alive-across-idle change made the service stay
foregrounded longer, accelerating accumulation toward the cap.

Override onTimeout to mirror the start-time path: suppress reconnect, post
the existing FgsLimitNotifier, and stopSelf. Add a Robolectric test
(@Config sdk=35) covering the handler, and a docs/ux-decisions.md entry for
the new lifecycle moment at which the budget notification can appear.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-26 16:13:24 -04:00
Jason Monk
7d2e6ec348 Remove 4 broken screenshot gallery entries (never-existed files) 2026-04-27 18:50:28 -04:00
Jason Monk
5460de160d
Clean up orphan screenshots and add missing test coverage (#434)
Delete 13 orphan screenshot PNGs that had no backing tests (disabled
picker, add-client, bottom-inset, quick-render variants). Remove
ManageScreenQuickRender.kt (duplicated by ScreenScreenshotTest) and
stop BottomInsetScreenshotTest from writing screenshot side-effects
so the deleted files stay gone.

Add screenshot tests for IntegrationEnabledScreen with Loading URL
state (16b) and AllClientsContent (20). Update gallery index.html
to match.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-27 17:51:31 -04:00
Jason Monk
d586bbdd14
Cut auto-loaded context overhead (#425)
Three changes to reduce per-turn and per-agent-launch context cost:

1. New `.claude/agent-preamble.md` — single source for agent-launch
   boilerplate (don't touch .claude, use opus, branch/PR conventions,
   relay deploy method, device targeting). Agent prompts can now
   reference it instead of repeating ~15-20 lines per launch.

2. Trim `.claude/CLAUDE.md` from 73 to 51 lines — drop Architecture
   and Module Boundaries sections that now live (and are kept current)
   in `docs/design/overall.md` and `docs/design/android-app.md`. Keep
   build commands, workflow pointers, code style, signing keystore
   warning, domain.

3. New `docs/agent-quickstart.md` — distilled commands and paths
   agents reach for repeatedly: module->path map, build/test recipes,
   gh CLI patterns, adb-via-ssh patterns, gcloud relay ssh, common
   file locations, common gotchas. Pre-loading saves grep-then-discover
   cycles.

Net: ~22 lines off the per-turn auto-load (CLAUDE.md), ~15-20 lines
saved per agent launch (boilerplate consolidation), and the quickstart
removes a class of repeated discovery work.
2026-04-26 17:57:12 -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
d2595ed091
Fix #406 final wave: ui.md drift fixes + relay.md endpoint pointer (#413)
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>
2026-04-25 18:49:10 -04:00
Jason Monk
ae4245882b
Update README and security docs to match shipped behavior (#406 chunk A) (#411)
Address the audit findings in #406 chunk A for README.md, the 2026-04-07
security audit summary, and the security decisions log:

- README.md: 6 copy fixes — per-integration URL form (`{adj}-{integration}.subdomain/mcp`,
  not legacy `{adj}-{noun}/integration/mcp`); CA is Google Trust Services
  (post-#391/#398), Let's Encrypt is supported but not the default; certs are
  per-device, not "wildcard"; build prereqs are JDK 21 and SDK 36/35/24; add
  `:core:testfixtures` to the module table.
- docs/security-audit-2026-04-07.md: annotate all 23 findings inline with
  current status (15 FIXED with code refs, 6 ACCEPTED-AS-RISK referencing
  security-decisions.md, 1 PARTIAL — #8 SHA-256 hashes not encryption,
  3 UNKNOWN — #17 #18 #21 flagged for follow-up review). Doc structure
  preserved.
- docs/security-decisions.md: refresh the stale "Not yet implemented" line
  for finding #23 — refresh-token rotation with OAuth 2.1 §4.14 reuse
  detection now ships in `RoomTokenStore.refreshToken`. Also resolve the
  "Needs verification" line for finding #15 (`open_link` validates
  http/https in `OutreachMcpProvider`).

Documentation only; no behavior changes. Per .claude/rules/ux-changes.md,
doc updates describing already-shipped behavior do not require user
approval.

Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>
2026-04-25 18:38:12 -04:00
Jason Monk
2482559e00
Update tunnel-client + health-connect-expansion docs; delete superseded proposal docs (#406) (#412)
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>
2026-04-25 18:13:09 -04:00
Jason Monk
ddddcc39eb
Update docs/design/overall.md to match shipped system (#406 chunk D) (#409)
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>
2026-04-25 17:54:12 -04:00
Jason Monk
40a5ebd4b0
Rewrite docs/design/android-app.md to match shipped behavior (#408)
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>
2026-04-25 17:43:22 -04:00
Jason Monk
0b5e755c22
Fix #406 (chunk B, relay-api.md): rewrite to match shipped relay API (#410)
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>
2026-04-25 17:26:38 -04:00
Jason Monk
696f1c71e6
Delete stale planning + status + QA-snapshot docs (#405)
All three tracked in docs/audit.md as "delete" recommendations:

- docs/overnight-plan-2.md — execution plan from 2026-04-06; every
  phase 1 item shipped weeks ago, GH Issues is the tracker now.
- docs/e2e-status.md — described the AI-client-EOF blocker as open
  (resolved by #389/#390); also still referenced LE rate limits
  contradicted by the actual GTS deployment (see #391/#398).
- docs/device-test-report.md — point-in-time QA snapshot from
  2026-04-07 against commit a3a0c1a on a Pixel 3 XL. Several listed
  "non-blocking issues" are now fixed; the LE cert reference is wrong
  post-#391; the report has aged out.

Plus the four PNGs that paired with device-test-report:
- docs/screenshot_audit_tab.png
- docs/screenshot_connected.png
- docs/screenshot_dashboard.png
- docs/screenshot_settings_tab.png

Kept: docs/screenshots/index.html — that's a separate gallery referencing
the live app/screenshots/*.png roborazzi outputs, not the deleted PNGs.

Updated docs/audit.md and docs/test-coverage-audit.md to reflect the
deletions; the audit's punch list still tracks the remaining "delete"
recommendations (BLOCKERS.md, docs/workflow.md, etc).
2026-04-25 15:08:59 -04:00
Jason Monk
a97caf0941
Fix #391: Update design docs to reflect GTS as primary CA (#398)
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>
2026-04-24 22:41:23 -04:00
Jason Monk
7c8a91b9f9
Add UX changes rule + decision log + onboarding flow page (#397)
Three pieces, one PR:

1. `.claude/rules/ux-changes.md` — auto-loaded rule listing change categories
   that require explicit user approval before implementation, plus a
   decision-log entry. Filing an issue with a ranked recommendation is
   explicitly NOT approval.

2. `docs/ux-decisions.md` — append-only log of UX flow decisions. Seeded
   with the #389 cert-provisioning-at-Continue decision, retroactively
   approved (was originally landed unilaterally; this rule + log exist
   so that cannot recur).

3. `docs/internal/flows/index.html` — onboarding flow page composed of
   existing roborazzi screenshots, wired together with action labels +
   error-branch screens (Rate limited, Failed). Linked into the existing
   internal dashboard as a new Flows tab.

The motivating incident: #389 moved cert provisioning from "first
integration add" to "right after Continue, before Home". That is a real
UX timing change that an agent picked unilaterally based on a ranked
recommendation in the issue body. The user spotted the change after the
fact ("immediately after the notifications screen its showing
registering, before any integrations are set up") and asked for a
structural check that survives across Claude sessions, not just a memory
entry.
2026-04-24 19:39:08 -04:00
Jason Monk
e7ab0f9a99
Fix #389: Provision certs during onboarding so fresh installs work (#390)
* Fix #389: Provision certs during onboarding so fresh installs land in a usable state

Extend OnboardingFlow to chain CertProvisioningFlow.execute after subdomain
registration succeeds so a fresh install ends with all three PEMs (ACME
server cert, relay-CA client cert, relay CA) persisted on disk instead of
just the subdomain file. Without this hop the device appeared functional
(dashboard rendered, pending integrations visible) but every incoming AI
TLS handshake EOF'd and every WS reconnect 401'd because the store had no
certs to present — the root cause of #386 and #387.

OnboardingViewModel now routes cert-provisioning outcomes into retryable
OnboardingState.Failed / RateLimited surfaces with a "Try again" entry
point, and the UI holds on the onboarding screen during the several-second
ACME hop instead of silently dropping the user on Home with a half-
configured install. The subdomain is preserved across cert failures (#163)
so retry re-runs only the cert issuance step.

Idempotency via CertProvisioningFlow.AlreadyProvisioned means the existing
IntegrationSetupViewModel path is unchanged: enabling an integration on a
device that already has certs short-circuits as before.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>

* Fix #389 (follow-up): Keep integration harness OnboardingFlow without chained cert provisioning

The initial commit wired CertProvisioningFlow into the integration harness's
OnboardingFlow override to mirror production. That broke every integration
scenario that drives both flows explicitly (HarnessSmokeTest +
OnboardingHappyPathTest pattern) because the second explicit cert call
returns AlreadyProvisioned instead of Success, tripping the asserts, and
also inflated the per-test /register/certs counter assertions.

Flip the override back to an OnboardingFlow without the chained cert step
so ProvisioningExtensions.provisionDevice keeps its "call both flows
explicitly" contract. Production still chains — the change in appModule
and the OnboardingFlow surface are untouched.

OnboardingInterruptedResumableTest can go back to using the Koin-supplied
flow now that the harness override is no-cert-chain again.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>
2026-04-23 20:00:15 -04:00
Jason Monk
8b906a4341
Fix #379: Scrub sensitive data from production logs + add regression gate (#380)
Auditted every production log site in Kotlin and Rust against the
sensitivity list in #379. Two real leaks found and fixed; a logging
policy is documented and a CI grep gate catches known-bad patterns in
future PRs.

Scrubbed:

- `OnboardingViewModel`: was logging 20-char prefixes of the Firebase
  ID token and the FCM token. Both are bearer credentials and `logcat`
  is reachable via adb / `READ_LOGS` on older Android, so even prefixes
  are sensitive. Replaced with length-only summaries.

- `relay/src/main.rs` connection handler: the "Routing decision" log
  used `?decision` (Debug format) on `RouteDecision`, which includes
  the `integration_secret` string on `DevicePassthrough`. That secret
  is the bearer credential an AI client presents in the SNI label to
  route to a specific integration -- logging it defeats the point.
  Added a `route_decision_log` helper that renders the variant plus the
  subdomain (public routing identity) without the secret.

Everything else on the priority list (McpRouting, RoomTokenStore,
CertRenewalScheduler/Worker, AcmeClient, TunnelClientImpl, MuxDemux,
FcmReceiver, relay main/tls/ws) was already scrub-clean: they log
state transitions, counts, durations, error types, and the relay's
operational subdomain -- never tokens, bodies, tool-call arguments,
cert material, or secrets.

Regression protection:

- CI grep gate in `.github/workflows/ci.yml` fails the build if known
  bad patterns (`Log.<level>(... "$token"` etc., `args: $...`) appear
  in Kotlin production sources.

- `docs/internal/logging.md` documents what we log, what we don't,
  and how to add new log lines safely.

Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>
2026-04-23 12:07:54 -04:00
Jason Monk
6b01f412c3
Fix #366: Land variant 7 in production ToolCallRow (#367)
* Tighten variant 7 time right-edge (4dp end padding)

The user felt the pill in variant 7 looked like it had extra padding
to its right. The cause is optical: the pill has 8dp internal
horizontal padding, so its inner text ends ~9dp left of its outer
border. The time text below had no end padding, so its last glyph
sat at the row's full right-inset edge — making the time read as
"further right" than the pill's text.

Adding 4dp of end padding to the time pulls its glyph inward to
partially match the pill's internal right inset, bringing the two
text right-edges closer optically.

Only variant 7's time is touched; production ToolCallRow and
ListRow are unchanged.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>

* Fix #366: Land variant 7 in production ToolCallRow and drop preview scaffolding

Ships the winning audit-row design (variant 7 from the #343 preview review,
tuned in #363 / #365) into the production audit history screen, wiring the
real `AuditEntry.clientLabel` added in #344 through the ViewModel and
rendering it as a right-aligned client pill on row 1 with the call time
stacked directly below. Rows whose `clientLabel` is null (predate the
schema v3 -> v4 migration) omit the pill entirely rather than render a
placeholder that would collide with the real `Unknown (#N)` labels the
[UnknownClientLabeler] produces (#345).

Extracts `ClientPill` as a shared composable in `ui/components/` so the
pill is now part of the app's real design language — not a preview helper.

Deletes the preview scaffolding (`AuditRowVariants.kt`,
`AuditRowVariantsScreenshotTest.kt`, `AuditRowCatalogHtmlWriter.kt`, the
`app/screenshots/audit-row-variants/` directory, and
`docs/internal/audit-row-variants/index.html`), removes the corresponding
tab from the unified internal dashboard (#348) and drops the matching
copy step from `pages.yml`.

Regenerates the four audit-screen Roborazzi goldens
(`34_audit_history_populated_*`, `36_audit_history_filtered_*`,
`36a_audit_history_show_all_mcp_messages_*`) with representative
clientLabel values (short, long, null, and `Unknown (#1)`) so the pill
behaviour is visible across all three length classes.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>
2026-04-22 13:39:08 -04:00
Jason Monk
6fa797c04e
Add audit row variant 7: pill top-right, time below (#363)
* Fix #347: Client-subject notification copy + deep-link taps + Manage action

Rewrite per-tool-call and session-summary notification copy per the locked
#342 design, wire up notification tap deep-links, and add a Manage action
button.

Per-tool-call notifications now read "${clientLabel} used ${humanized(toolName)}"
with the integration display name as body and the call timestamp rendered
natively via setWhen(). Session-summary notifications partition by client
label and emit one notification per client titled "${clientLabel} used
${count} ${tool|tools}" with up to 3 unique humanized tool names in the
body (Oxford comma, "and N more" past the cap).

Tap deep-links route to the audit-history screen — scrolled to the
specific call (per-tool-call) or filtered to the session time window
(summary) — and a single Manage action button points at the integration
manage page (or home, when a summary's calls span multiple integrations).

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>

* Update integration tests for per-client summary notification ids

#347 changed SessionSummaryNotifier from a single-id summary to one
notification per client, keyed by the clientLabel hash. The existing
:app:integrationTest fixtures still asserted against the legacy
SessionSummaryNotifier.NOTIFICATION_ID constant, so they failed in CI.

Updated each affected test to compute the expected id via
SessionSummaryNotifier.idForClient(<clientLabel>) and dropped the
now-unused NOTIFICATION_ID companion constant. The InMemoryTokenStore
resolves clientName=null to the clientId, so for tests that pass
clientName=null the expected label is their clientId string (e.g.
"race-test", "multi-test", "runtime-mode-switch"). ToolCallHappyPathTest
passes clientName = "Test Client" explicitly.

Also retargeted the MultiToolSessionTest title-string assertion from the
old "{count} calls across {N} integrations" copy to the new
"{clientLabel} used {count} tools" title shape.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>

* Move summary notification id bucket below per-call range

The previous summary id bucket (6000..15999) overlapped with
PerToolCallNotifier.BASE_ID = 7000, so any clientLabel whose hash
.mod(10000) landed in 1000..9999 produced an id that collided with
per-call notifications. RuntimeNotificationModeSwitchTest failed in CI
because its clientLabel "runtime-mode-switch" hashes to
idForClient(...) = 7465, which the test's "id >= PerToolCallNotifier.BASE_ID"
probe flagged as a per-call notification during phase 1 (SUMMARY mode).

Narrow the bucket to 4000..4999 so summary ids stay clear of the per-call
range. Collisions inside the 1000-entry bucket remain acceptable for the
expected <100-clients-on-a-device cardinality.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>

* Add audit row variant 7 (pill top-right, time below)

Extends the #343 design-review catalog with a seventh client-label
placement option: the client pill sits alone at the top-right of row 1
and the timestamp right-aligns on row 2 directly beneath it. Unlike
variant 3, which packs the pill and time together on row 1, this layout
keeps the pill prominent without crowding the time next to it.

Preview-only; production `ToolCallRow` and `AuditEntry` are unchanged.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>
2026-04-22 07:40:03 -04:00
Jason Monk
ad628ae545
Fix #347: Client-subject notification copy + deep-link taps + Manage action (#362)
* Fix #347: Client-subject notification copy + deep-link taps + Manage action

Rewrite per-tool-call and session-summary notification copy per the locked
#342 design, wire up notification tap deep-links, and add a Manage action
button.

Per-tool-call notifications now read "${clientLabel} used ${humanized(toolName)}"
with the integration display name as body and the call timestamp rendered
natively via setWhen(). Session-summary notifications partition by client
label and emit one notification per client titled "${clientLabel} used
${count} ${tool|tools}" with up to 3 unique humanized tool names in the
body (Oxford comma, "and N more" past the cap).

Tap deep-links route to the audit-history screen — scrolled to the
specific call (per-tool-call) or filtered to the session time window
(summary) — and a single Manage action button points at the integration
manage page (or home, when a summary's calls span multiple integrations).

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>

* Update integration tests for per-client summary notification ids

#347 changed SessionSummaryNotifier from a single-id summary to one
notification per client, keyed by the clientLabel hash. The existing
:app:integrationTest fixtures still asserted against the legacy
SessionSummaryNotifier.NOTIFICATION_ID constant, so they failed in CI.

Updated each affected test to compute the expected id via
SessionSummaryNotifier.idForClient(<clientLabel>) and dropped the
now-unused NOTIFICATION_ID companion constant. The InMemoryTokenStore
resolves clientName=null to the clientId, so for tests that pass
clientName=null the expected label is their clientId string (e.g.
"race-test", "multi-test", "runtime-mode-switch"). ToolCallHappyPathTest
passes clientName = "Test Client" explicitly.

Also retargeted the MultiToolSessionTest title-string assertion from the
old "{count} calls across {N} integrations" copy to the new
"{clientLabel} used {count} tools" title shape.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>

* Move summary notification id bucket below per-call range

The previous summary id bucket (6000..15999) overlapped with
PerToolCallNotifier.BASE_ID = 7000, so any clientLabel whose hash
.mod(10000) landed in 1000..9999 produced an id that collided with
per-call notifications. RuntimeNotificationModeSwitchTest failed in CI
because its clientLabel "runtime-mode-switch" hashes to
idForClient(...) = 7465, which the test's "id >= PerToolCallNotifier.BASE_ID"
probe flagged as a per-call notification during phase 1 (SUMMARY mode).

Narrow the bucket to 4000..4999 so summary ids stay clear of the per-call
range. Collisions inside the 1000-entry bucket remain acceptable for the
expected <100-clients-on-a-device cardinality.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>
2026-04-22 03:11:08 -04:00
Jason Monk
e47d179058
Fix #348: Unified internal design-review dashboard with tabbed catalogs (#355)
New docs/internal/index.html embeds the four design-review catalogs
(notifications, app UI, OAuth auth pages, audit row variants) behind
client-side tabs. Tab state is mirrored in the URL hash so deep-links
and reloads land on the expected tab. Iframes lazy-load on first
activation.

Extends .github/workflows/pages.yml:
- Broadens the paths trigger to cover docs/screenshots/**,
  docs/auth-pages/**, and all of app/screenshots/** (not just the
  audit-row-variants subdir).
- Copies docs/internal/ into _site/internal/ first so the landing
  and its sibling audit-row-variants catalog are in place, then the
  per-catalog copies overlay notifications/, app/, and auth/ without
  clobbering the landing's index.html.
- Adds copy steps for the app UI gallery (HTML to /internal/app/,
  PNGs to /app/screenshots/ to match the HTML's ../../app/screenshots
  references) and the OAuth auth-pages catalog (/internal/auth/).

Simulated locally by reproducing the pages.yml copy sequence and
serving via python3 http.server: all four tabs fetch 200, sampled
image and child-HTML URLs resolve.

Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>
2026-04-21 23:21:32 -04:00
Jason Monk
e4563a6de9
Fix #343: Render audit row client-label placement variants (#349)
Produces six candidate layouts for the audit history's ToolCallRow so the
client-label placement decision (#342) can be approved against actual
screenshots. Each variant renders three client-label length classes
(short, long, unknown) in both light and dark theme, publishing the
catalog to rousecontext.com/internal/audit-row-variants/ via the existing
Pages workflow.

- New `AuditRowVariants.kt` preview composables for:
  1. Third row, full-width client label
  2. Second-row prefix (`Claude . 142ms . {args...}`)
  3. Right-aligned pill between tool name and time
  4. Leading colored initial chip
  5. Session-grouped header (client shown once per session)
  6. Variant 1 + Variant 5 combined
- Roborazzi screenshot test writes to
  `app/screenshots/audit-row-variants/` and emits the catalog HTML to
  `docs/internal/audit-row-variants/index.html` via a `@ClassRule` mirror
  of `NotificationCatalogHtmlWriter` from #335.
- Pages workflow path trigger extended to include `docs/internal/**` and
  `app/screenshots/audit-row-variants/**`; new copy step serves the
  catalog and its screenshots under `/internal/audit-row-variants/`.

Production `ToolCallRow` at `AuditHistoryScreen.kt:413` is not modified;
`AuditEntry.clientLabel` is not introduced. Both are deferred to the
follow-up that implements the chosen variant after design review.

Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>
2026-04-21 20:31:20 -04:00
Jason Monk
fcf9dc3a12
Fix #337: Add copy-branch variants to notification catalog (#338)
Covers the notifier branches that were not previously exercised:

- SessionSummaryNotifier: adds "1 tool call" (singular, 1 call / 1
  integration) and "3 tool calls" (plural, N calls / 1 integration)
  alongside the existing multi-integration variant, so all three
  buildSummaryTitle() shapes appear in the catalog.
- PerToolCallNotifier: long tool name (to show title wrapping) and a
  different integration id (to exercise display-name substitution).
- AndroidSecurityCheckNotifier: CT log Alert with multiple unexpected
  issuers (list formatting) and a CT log Warning via postInfo() -- the
  entry point SecurityCheckWorker hits after the 3-run debounce trips.
- LaunchRequestNotifier: long caller name + long URL to show wrapping
  on the open-link path.
- AuthRequestNotifier: only one shape exists; documented inline.

Each new case drives the real notifier with realistic inputs and reads
the posted Notification back via Robolectric's shadow
NotificationManager, exactly like the existing cases. docs/notifications/
index.html is regenerated from the CapturedNotifications snapshot by
the existing ClassRule writer.

Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>
2026-04-21 16:12:05 -04:00
Jason Monk
e34b0e70e8
Fix #335: Auto-generate docs/notifications/index.html from real notifier output (#336)
The QA notification catalog at `docs/notifications/index.html` previously
mixed hand-coded HTML mockups (with hand-typed titles like "Session
Complete" that never existed in production) alongside Roborazzi PNGs
captured from real notifiers. The two sources had drifted, so users
lost trust in the catalog.

Every title, body, sub-text, channel ID, and `<img>` reference in the
page is now emitted by `NotificationScreenshotTest` itself: each test
case records its notifier's posted `Notification.extras` into a
class-scoped collector, and a JUnit `@ClassRule` writes the HTML to
`../docs/notifications/index.html` after the suite finishes. Output is
sorted by screenshot base name so runs are idempotent.

Hand-coded mockups and the CSS icon-chip PNG palette they used
(`icon*.png` in `docs/notifications/`) are removed; the only way this
file changes now is by running the test.

Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>
2026-04-21 13:35:41 -04:00
Jason Monk
5e49fded97
Fix #332: Drive notification screenshot catalog from real notifiers (#333)
Refactors NotificationScreenshotTest to invoke the production notifiers
directly (ForegroundNotifier, AuthRequestNotifier, PerToolCallNotifier,
SessionSummaryNotifier, LaunchRequestNotifier, FgsLimitNotifier,
AndroidSecurityCheckNotifier) and capture the posted Notification via
Robolectric's ShadowNotificationManager instead of hand-rolled builders.
Any future copy or behavior change in a notifier now either intentionally
updates the catalog or breaks the screenshot diff.

Adds FgsLimitNotifier coverage (the gap called out in the issue) and
prunes stale cases (session warning/info, error variants, outreach) that
no longer map to a real producer. Renumbers docs/notifications/index.html
to match the new notifier-centric section layout.

Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>
2026-04-21 12:11:46 -04:00
Jason Monk
ffcc73ead8
Fix #322: Add startup CAA verification for ACME provider (#329)
Guards against the latent cert-renewal failure described in #322: a CAA
record on the base domain that excludes the configured ACME provider
will silently break renewal 60-90 days later, long after any operator
would correlate it with a config change.

At startup the relay now does a public-DNS CAA lookup on the base
domain, verifies the configured ACME provider (GTS or Let's Encrypt)
is in the `issue` allowlist, and logs a loud ERROR when it isn't. A
transient DNS failure is deliberately non-fatal — a crash loop is worse
than a latent renewal issue — but operators can opt into strict mode
via `acme.fail_on_caa_mismatch = true`.

Also documents the CAA requirement in docs/self-hosting.md and updates
the example relay.toml with the new flag.

Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>
2026-04-20 22:33:27 -04:00
Jason Monk
73b0182dcd
Fix #323: Remove personal machine identifiers from public repo (#326)
Replace `adolin.lan`, device serial `84TY004PW`, and LAN IPs
`192.168.68.*` scattered across e2e tests, device-tests, and docs
with placeholder syntax (`<your-dev-host>`, `<your-device-serial>`,
`<your-lan-ip>`). These values were defaults for local development
and had no reason to live in a public repo.

- `e2e/build.gradle.kts` no longer defaults `adb.host`; the `e2eTest`
  task now fails fast via `doFirst` if it's unset.
- e2e test classes read `adb.host` and throw a helpful error when
  missing instead of silently falling back to a host that only exists
  on the author's LAN.
- `device-tests/DeviceIntegrationTest` reads `lan.ip` from a system
  property (or env var) and skips via JUnit `assumeTrue` when unset.
- README grows a short "End-to-end tests" section documenting the
  required properties.

Git history still contains the leaked values — per the issue,
rewriting history is disruptive and unlikely to undo exposure on an
already-public repo.

Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>
2026-04-20 12:24:01 -04:00
Jason Monk
7c5397661f
Fix #215: Render relay env + firebase-sa from GH secrets at deploy time (#219)
Move all relay runtime secrets off manually-maintained /etc/rouse-relay/env
and into GitHub repo secrets. The deploy workflow now renders both the
systemd EnvironmentFile and the Firebase service account JSON from repo
secrets on each run, scps them to /tmp, then moves them into
/etc/rouse-relay/ with the correct ownership and mode.

Rotation is now a gh secret set + workflow_dispatch instead of an SSH
session. Bootstrapping a fork only needs the secrets populated — no more
remembering which env vars the VPS needs.

- relay-deploy.yml: new "Render" step writes env + firebase-sa.json into a
  mode-0700 tempdir using printf + file redirection (never echo, never
  secret values on argv). Deploy step scps and installs alongside the
  binary. Tempdir is shredded on exit.
- scripts/backfill-relay-secrets.sh: maintainer tool that re-syncs GH
  secrets from the live VPS. Explicit "yes" prompt, set -u -o pipefail
  (no -x to avoid leaking values), shred -u on exit, never echoes
  secret values.
- docs/self-hosting.md: new appendix documenting the secret inventory,
  naming convention split (existing CLOUDFLARE_* unprefixed; new
  RELAY_*), rotation procedure, and pointer to the backfill script.

Secrets already populated on the repo (values pulled from the running
VPS and verified byte-for-byte parity with the workflow-rendered output):
  CLOUDFLARE_API_TOKEN, CLOUDFLARE_ZONE_ID (pre-existing, re-synced),
  RELAY_RUST_LOG, RELAY_GTS_EAB_KID, RELAY_GTS_EAB_HMAC,
  RELAY_FIREBASE_SERVICE_ACCOUNT_JSON (base64 of firebase-sa.json).

First post-merge deploy will overwrite /etc/rouse-relay/env and
firebase-sa.json with the workflow-rendered versions. Parity confirmed
before merging; flagging for user's eyes on the first run.

Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>
2026-04-17 19:39:41 -04:00
Jason Monk
f439d5f5fc Fix #205: move release keystore passwords to env/.properties file
Release keystore passwords were hardcoded as string literals in
`app/build.gradle.kts`, public to anyone who forks or clones the repo.
Combined with a leaked keystore file (from a backup or CI compromise),
that collapses two factors into one and lets an attacker sign arbitrary
APKs as `com.rousecontext`.

Release passwords are now resolved from, in order of precedence:
  1. `ROUSE_RELEASE_STORE_PASSWORD` / `ROUSE_RELEASE_KEY_PASSWORD` env vars
  2. `storePassword` / `keyPassword` keys in `.signing/release.properties`

Both are absent from the tracked repo. A new
`.signing/release.properties.example` template is committed so new clones
see the expected format, and `.gitignore` now allows that one file while
still ignoring the real `release.properties`, keystores, and any other
signing artifacts.

Resolution is lazy: non-release tasks (lint, unit tests, debug builds)
do not require the env var or .properties file. A `taskGraph.whenReady`
check produces a clear error message when a release-signing task is
actually requested without credentials, instead of failing obscurely
inside the Android signing task.

Debug keystore password stays hardcoded on purpose — the debug key is
not a secret.

Docs updated in `docs/self-hosting.md`. Keystore files themselves are
untouched (regenerating would force a user uninstall and burn ACME cert
quota).
2026-04-17 14:36:01 -04:00
Jason Monk
4fc30669d9 Set baseurl to empty for custom domain on GitHub Pages
GitHub Pages defaults baseurl to /<repo-name> for project sites, which
puts /rouse-context/ in every CSS/JS/link path. With the custom domain
rousecontext.com active, baseurl must be empty so assets resolve at the
root.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 17:47:49 -04:00
Jason Monk
4c442a8f48 Fix #170: align /renew request/response shapes between client and relay
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>
2026-04-15 19:41:25 -04:00
Jason Monk
444fbbcbee Center and scale down screenshots in security.md
Images were rendering at full width, dominating the page. Wrap each in
<p align="center"><img ... width=...> so they stay at a natural size
(420px for notifications, 400px for trust cards) and sit centered
against the prose.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 16:17:47 -04:00
Jason Monk
c302580735 Embed real Security Alert notification screenshots
Added DebugSecurityAlertReceiver (debug build only) that fires the
production AndroidSecurityCheckNotifier.postAlert for either the
self-cert or CT-log check. Used it on a device to capture real
notification-tray screenshots for embedding under each alert section
in docs/user/security.md.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 16:10:51 -04:00
Jason Monk
dcd992a133 Rewrite security alert docs to match real notification wording
The previous headings ("Certificate mismatch detected", "Unexpected
certificate in public logs") are not strings the app ever shows. Users
scanning the docs for text they just saw in the notification shade
would have come up empty.

Rewrite each alert section around the real notification title/body
(Security Alert - Self-cert verification: Verification failed, etc.)
and split the former single "alert" screenshot into the two distinct
failure modes: self-check alert vs CT log alert. Troubleshooting
heading for the FGS notification gets the same treatment (Rouse
Context paused is what users see).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 16:05:30 -04:00
Jason Monk
9710cc4586 Recrop FGS-limit notification screenshot to include full card
Previous crop cut off the card's bottom rounded corners. This version
includes the full card with proper padding.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 15:57:05 -04:00
Jason Monk
d811c08710 Embed FGS-limit notification screenshot in security.md
Captured from a real debug build using the broadcast receiver added in
ef6a4cc6. Cropped and resized to 800px wide for the docs site.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 15:53:31 -04:00
Jason Monk
8373faaed6 Polish user docs + add trust-card screenshots
- Document live security notification + audit log in "how it works"
- Replace Claude-as-adversary example with ChatGPT (neutral phrasing)
- Broaden MCP client list beyond Claude/Cursor to reflect current ecosystem
- Add security@ and bugs@ email addresses (Cloudflare Email Routing),
  with GitHub issues still the primary channel
- Clarify Notifications integration behaviour for Rouse Context's own
  notifications
- New Roborazzi screenshots of the Trust Status card (warning, alert)
  framed with an 8dp background border, embedded in security.md so
  users can recognise the in-app alert UI

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 15:45:25 -04:00
Jason Monk
6d9a04fa14 Fix #119: Scaffold docs/user/ for GitHub Pages at rousecontext.com
Adds the user-facing docs tree that will be published to the apex domain
via GitHub Pages. Content is first-pass: plain English rewrites of the
engineering security and integration docs, plus a troubleshooting page,
FAQ, privacy overview, and landing page. Uses just-the-docs remote theme.

DNS and Pages repo settings still require user action and are not part
of this change.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 22:07:12 -04:00
Jason Monk
9d96409fc6 Fix #138: Add documentation audit — inventory, classify, punch list
Inventory of every .md under docs/, plus top-level README.md and
BLOCKERS.md. Classifies by audience (user/engineering/contributor/
historical) and accuracy (current/partially stale/rewrite/delete).
HTML files under docs/ also called out.

Output is a file — the rewrite/cleanup work becomes follow-up issues
per doc. No docs were rewritten, moved, or deleted in this pass.
2026-04-14 19:24:15 -04:00
Jason Monk
ca5d1cab13 Fix #70: Parameterize base domain for self-hosting
Extract the hardcoded "rousecontext.com" base domain to a single Gradle
property (`-Pdomain`) that flows through BuildConfig to all Kotlin call
sites, and to a matching optional config field on the Rust relay. A fork
can now point a deployment at their own domain by setting one value.

Kotlin:
- New `BASE_DOMAIN` buildConfigField in :app, driven by `-Pdomain`
  Gradle property (default "rousecontext.com"). `RELAY_HOST` derives
  from it unless `-Prelay.host` is set explicitly.
- `McpUrlProvider` default reads `BuildConfig.BASE_DOMAIN`.
- `AppModule` session hostname uses `BuildConfig.BASE_DOMAIN` directly
  instead of stripping "relay." from `RELAY_HOST`.
- `CertProvisioningFlow` / `CertRenewalFlow` / `CtLogMonitor` accept
  base domain via constructor (still with a safe default so tests don't
  need to change).

Rust relay:
- New `base_domain` field on `ServerConfig`. Empty (default) means
  "derive by stripping 'relay.' from relay_hostname" -- the existing
  convention. Operators with non-conforming hostnames can set it.
- `ServerConfig::resolved_base_domain()` helper centralizes the lookup.
- `RELAY_BASE_DOMAIN` env var override.
- Removed duplicate `strip_prefix("relay.")` logic in main.rs, api/register.rs,
  api/renew.rs in favor of the helper.

Docs:
- `docs/self-hosting.md` walks through Cloudflare + Firebase + keystore
  setup, Android build with `-Pdomain=...`, Rust relay cross-compile and
  systemd deployment, and verification steps.

Test fixtures (test-only hostnames like "test.rousecontext.com",
@Preview composables, e2e helpers) remain as-is -- they're load-bearing
assertions about the URL format, not deployment-specific constants.

Verified:
- ./gradlew :app:compileDebugKotlin ktlintCheck :app:testDebugUnitTest
- ./gradlew -Pdomain=example.com :app:compileDebugKotlin (BuildConfig
  shows BASE_DOMAIN="example.com", RELAY_HOST="relay.example.com")
- ./gradlew -Pdomain=example.com :app:testDebugUnitTest (still green)
- cd relay && cargo test && cargo clippy

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 13:06:07 -04:00
Jason Monk
d9bf8c4ab7 Fix #79: Remove stale NotificationModel references from docs
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>
2026-04-12 13:02:21 -04:00
Jason Monk
5caae171ea Fix #78: Remove unused NotificationSettings, NotificationModel, and NotificationModelTest
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>
2026-04-12 12:59:49 -04:00
Jason Monk
4af048d525 Add comprehensive security overview document
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 09:39:55 -04:00
Jason Monk
5bd58cb678 Add design doc for per-integration hostnames
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>
2026-04-08 17:23:24 -04:00
Jason Monk
b9f4403e56 Update README and add secret prefix bot rejection design doc
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>
2026-04-08 10:59:23 -04:00
Jason Monk
74cefcde82 Regenerate auth page gallery with correct icon
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 08:53:44 -04:00
Jason Monk
6e1c3cfe0b Add comprehensive test coverage audit: 12 gaps found, 17 recommendations
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 20:05:29 -04:00
Jason Monk
5a91a4cfa0 OAuth icon: use 512px source at 128px with correct navy (#1A2744)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 16:53:40 -04:00
Jason Monk
ba732fe346 Fix corrupted base64 icon in OAuth authorize page
The embedded PNG data was truncated by 19 bytes, causing a broken
image. Regenerated from ic_launcher_96.svg.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 16:52:21 -04:00
Jason Monk
730d53a337 Regenerate screenshots after design language refactor
All 86 Roborazzi screenshots (43 screen variants x light/dark) are now
up to date with the shared DesignSystem components and visual changes.

- Add AuditDetailScreen screenshots (loading + populated states)
- Add TestApplication for Robolectric to avoid Koin/WorkManager init
- Fix SettingUpVariant.FirstTime() call (now a data class, not object)
- Remove 30 stale screenshots from the old naming scheme
- Remove obsolete dashboard.html
- Update gallery index.html with new Audit Detail section (9 categories, 43 variants)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 12:25:12 -04:00
Jason Monk
d711efaf9d Fix launcher icon: use PNG mipmaps for adaptive icon layers
The vector drawable foreground was too complex (525 circle paths) and
didn't render correctly. Now uses rasterized PNGs at all density
buckets for both foreground and background adaptive icon layers.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 12:14:22 -04:00