Commit graph

4 commits

Author SHA1 Message Date
monkopedia-coder
10fa29b210
#467: replace google/foss product flavors with a -Pgoogle build flag (#479)
Product flavors forced a symmetric frame onto two distributions that are
not peers: FOSS is the universal, secret-free base build (buildable by
anyone / F-Droid) and Google is a credentialed superset that requires our
private google-services.json. The flavor framing made the unsafe build the
default (bare `assemble` built both, google-services.json was required by
default) and needed task-name sniffing to re-derive "is this credentialed?".

Invert to a flag: a bare build is FOSS; `-Pgoogle` opts into Firebase.

- Drop flavorDimensions/productFlavors. Select the distribution sources by
  flag via sourceSets["main"]/["test"].java.srcDir(...). The src/{google,foss}
  and src/test{Google,Foss} dirs are unchanged — just no longer flavor sets.
- Overlay the distribution manifest (FcmReceiver vs UnifiedPushReceiver) by
  flag using AGP's Variant Sources API (addStaticManifestFile), so the merger
  pulls in exactly one component set with no module split or body duplication.
- Gate the Firebase deps, the google-services + crashlytics plugins, and the
  Crashlytics buildType config on `googleBuild`, replacing the isFossOnlyBuild
  task-name sniff. google-services.json is required only under -Pgoogle and
  still hard-fails loudly if absent (preserves the broken-target guard).
- Collapse fossIntegrationTest into integrationTest (one task, selected by
  flag); fix the release-signing task set and the Kover disabled-task list,
  which referenced the now-gone per-flavor task names.

CI: per-flavor tasks no longer exist, so cover both distributions with a
two-pass matrix — assemble/test/integration/ktlint run bare (FOSS) and again
with -Pgoogle; detekt already globs both src dirs so it stays single-pass;
release uses the un-prefixed release/ output paths. Docs updated to match.

Co-authored-by: Jason Monk <monkopedia@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-15 18:13:19 -04:00
monkopedia-coder
f163bd586a
Add google/foss product flavors (#461) (#466)
* Add google/foss product flavors (#461)

Introduce a `distribution` flavor dimension on `:app` with two flavors:

- `google` — the unchanged shipping build (Firebase/FCM/Crashlytics).
- `foss`   — compiles with zero firebase-*/google-services/Play-Services
  dependencies; google-services.json is not required to assemble it.

The google-services and firebase-crashlytics Gradle plugins are now applied
conditionally (skipped for a foss-only build, detected by requested task name),
and the Firebase deps are scoped to `googleImplementation`. The three runtime
seams get flavor-specific Koin bindings via a new `distributionModule`:
CrashReporter, AnonymousAuthClient/FcmTokenProvider/DeviceAuthTokenProvider, and
RenewalAuthProvider. The foss flavor binds NoOp/stub placeholders — real impls
land in #462-#464; #461 only needs both flavors to assemble.

Two direct FirebaseAuth call sites in shared `:app`/debug code
(IntegrationSetupViewModel, AddIntegrationDestination, TestCommandProvider) are
moved behind the seams so `main`/`debug`/`foss` compile Firebase-free.

The shared `:work` module keeps its Firebase types for now; only the FCM
`FcmReceiver` manifest entry moves to the google-flavor manifest so it is absent
from the foss build's merged manifest.

CI/task renames: assembleDebug -> assembleGoogle/FossDebug, testDebugUnitTest ->
testGoogleDebugUnitTest, release builds the google flavor only (dual-flavor
release is #465). Kover excludes the foss debug + flavored release test tasks.

Part of #460. Fixes #461.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* Load flavor distributionModule in integration test harness

PR #461 moved CrashReporter, AnonymousAuthClient, FcmTokenProvider,
DeviceAuthTokenProvider, and RenewalAuthProvider out of the base appModule
into per-flavor distributionModule. RouseApplication registers both, but the
integration-test Koin bootstrap (AppIntegrationTestHarness.bootKoin) only
loaded appModule, so those five definitions were missing and every
com.rousecontext.app.integration.* test failed with NoDefinitionFoundException.

Add distributionModule (google variant on the integrationTest classpath) to
the startKoin module list, between appModule and the test overrides so any
harness fake still wins. Mirrors RouseApplication's base + distribution
composition.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* Fix stale variant-task references missed in the flavor rename (#461)

- docs/self-hosting.md: :app:compileDebugKotlin -> :app:compileGoogleDebugKotlin
- app/build.gradle.kts comment: testDebugUnitTest -> testGoogleDebugUnitTest

Flagged by reviewer on PR #466.

---------

Co-authored-by: Jason Monk <monkopedia@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-13 08:55:11 -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