Skip to content

Split @mentra/island into main/internal/devtools entry points#3342

Merged
PhilippeFerreiraDeSousa merged 8 commits into
integration/toolkit-boundaryfrom
codex/island-entrypoint-split
Jul 6, 2026
Merged

Split @mentra/island into main/internal/devtools entry points#3342
PhilippeFerreiraDeSousa merged 8 commits into
integration/toolkit-boundaryfrom
codex/island-entrypoint-split

Conversation

@PhilippeFerreiraDeSousa

@PhilippeFerreiraDeSousa PhilippeFerreiraDeSousa commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Phase 4 of the 020 integration review (cloud-v2/docs/issues/020-glasses-status-boundary/integration-review.md §D): split @mentra/island into three entry points and repoint every host import. Pure module topology — zero runtime behavior change. The entries resolve the same concrete modules, so every singleton stays single and module-load side effects (e.g. PhoneLocationService's background-task registration, which the toolkit graph still loads transitively) keep their timing.

What moved where

Entry Contents
@mentra/island (main) toolkit (configure/start/stop + facades), contract/read-model types (OTA, gallery, reports, runtime DTOs, ClientApp + hardware tables), and pure helpers host UI renders with: decideReconnect/decideConnectButtonAction, readiness predicates, deriveDisplayState + OTA policy constants (OtaProgressMessages, MINIMUM_OTA_STATUS_BUILD, …), the useApps-style hook layer + sort/order helpers + DUMMY_APPLET, decideDevLaunchRoute, HardwareCompatibility, MediaLibraryPermissions, BgTimer/throttle/debounce, WebSocketStatus
@mentra/island/internal Raw stores (useCoreStore, useDisplayStore, useConnectionStore, useCloudClientStatusStore, useSettingsStore/useSetting/SETTINGS, useAppStatusStore + installAppStoreHooks) and service singletons: appRegistry cluster (incl. dev-app registration), cloudClientService, restComms, cloudSecureStore, gallery cluster (gallerySyncService, asgCameraApi, localStorageService, mediaProcessingQueue, gallerySettingsService, validation + notices), miniapp engine cluster (routers, launcher, localMiniappRuntime, webview shim/globals builders), displayProcessor, navigationService, audioPlaybackService, phone coordinators + phoneLocationService, STT/TTS model managers, flat OTA check helpers + clock fixes, logBuffer, storage, GlobalEventEmitter, BluetoothSdk passthrough, configureRuntime/getRuntimeHooks
@mentra/island/devtools miniappRunningRegistry, devServerBridge

Judgment rule (from the task/§D): read models, commands, pure functions, and types = main; anything that mutates runtime state or exposes a store/service = not main. Refinement applied: types travel with the surface they describe (e.g. RuntimeSnapshot types live with the internal store; GalleryNotice stays main because it types toolkit.gallery.onNotice), and pure helpers that only serve an internal cluster (manifest normalizers, gallery-sync clock utils, webview script builders) stay with their cluster instead of widening main.

toolkit.stores.* is deleted from island.ts — its five stores were already flat exports on /internal, and the "2 remaining users" the boundary counter reported were comment mentions in the @/stores/{core,connection} shims (updated).

Mechanics

  • package.json exports map mirrors the bluetooth-sdk precedent: typesbuild/*.d.ts, react-nativesrc/*.ts (so Metro/jest/tsc resolve live source, no build-staleness), defaultbuild/*.js; ./src/* and ./build/* blocked. Metro's existing root hook is untouched; subpaths resolve via the exports map exactly like @mentra/bluetooth-sdk/internal already does in this app.
  • tsc: the existing @mentra/island/* path wildcard covers the new subpaths.
  • jest: moduleNameMapper pins both subpaths to source (mirroring @mentra/bluetooth-sdk-internal), and the island mock became a lazily built, cached three-entry registry sharing one underlying state — key sets mirror the real entry partition.
  • Repoint: 42 host files changed imports; only island import/export statements were touched (audited — no other line in mobile/src changed). @/stores/* and @/utils/* shims re-export from /internal, so their ~150 importers are untouched.
  • Boundary script: new report-only counters for /internal and /devtools imports; raw-store counter relabeled (store access now routes through /internal + shims — pattern kept for metric continuity); report_count fixed to survive zero-match patterns under set -euo pipefail.
  • Drive-by: restored the BluetoothSdk import in wifi/scan.tsx that the third dev-sync merge dropped (baseline tsc was failing on this branch).

Boundary counters (before → after)

Counter Before After
Blocking glasses/gallery check pass, 0 allowlisted pass, 0 allowlisted
Raw island stores (hook names) 41 files 41 files (no new users)
@mentra/island/internal importers n/a 39 files
@mentra/island/devtools importers n/a 2 files
toolkit.stores escape hatch 2 files (both comments) 0 files
bluetooth-sdk internal in host 6 files 7 files (the wifi/scan.tsx fix)
Flat island OTA helpers in host 2 files 2 files

Test evidence

  • cd mobile && bun run compile — clean (baseline was failing; fixed in the first commit)
  • cd mobile && bun run test50 suites / 364 tests pass (= baseline)
  • cd mobile/modules/island && bun run test194 tests pass (= baseline)
  • ./scripts/check-mobile-runtime-boundary.sh — passes, counters above
  • Gates were run before every commit; the compile pass after the main-barrel slim is the proof that no host file still pulls internal/devtools symbols from the main entry.

Notes


Note

Low Risk
Import-path and export-surface refactor with no intended runtime behavior change; risk is limited to mis-partitioned exports or broken resolution in Metro/jest/tsc.

Overview
Phase 4 (020 §D) splits @mentra/island into three package entry points so OEM-facing imports stay narrow while the Mentra host keeps a migration path to raw runtime APIs.

@mentra/island is trimmed to toolkit, contract/read-model types, and pure UI helpers (hooks like useApps, OTA policy constants, decideReconnect, etc.). @mentra/island/internal holds zustand stores and service singletons (appRegistry, restComms, gallery cluster, miniapp engine, flat OTA check helpers). @mentra/island/devtools exposes miniappRunningRegistry and devServerBridge. package.json exports (with react-nativesrc/) and new internal.ts / devtools.ts barrels implement the split; toolkit.stores.* is removed from island.ts.

Host code and @/stores/* / @/utils/* shims now import stores and services from /internal (and dev screens from /devtools) instead of the main barrel. Jest maps all three entries to source and uses one cached three-way mock; check-mobile-runtime-boundary.sh adds report-only /internal and /devtools import counts. Island README, integration-review §D, and the example OEM app are updated to match.

Reviewed by Cursor Bugbot for commit 6886091. Bugbot is set up for automated code reviews on this repo. Configure here.

PhilippeFerreiraDeSousa added 5 commits July 3, 2026 16:13
The third dev sync (f29e401) kept dev's wifi_scan_result listener hunk in
the wifi scan screen but dropped its import line during conflict resolution,
leaving the branch failing tsc. Import the SDK singleton from
@mentra/bluetooth-sdk-internal, matching the other host files that listen to
raw SDK events on this branch.
Declare a package exports map with three entries (., ./internal, ./devtools),
each with the react-native condition pointing at src so Metro and tooling
resolve live TypeScript source, mirroring the @mentra/bluetooth-sdk map.
src/internal.ts carries the migration-era runtime surface (raw stores +
service singletons); src/devtools.ts carries the debug-only singletons
(miniappRunningRegistry, devServerBridge). The main barrel is unchanged in
this commit, so both new entries are additive.

Jest: resolve the two subpaths to source via moduleNameMapper (like
@mentra/bluetooth-sdk-internal) and split the island mock into a lazily built,
cached three-entry registry sharing one underlying state. The main mock still
spreads the internal + devtools surfaces until the barrel slims down.
Mechanical import split across mobile/src: symbols that expose or mutate
runtime state (raw stores, service singletons, runtime wiring, flat OTA/
gallery helpers, BluetoothSdk passthrough, logBuffer, storage,
GlobalEventEmitter) now come from @mentra/island/internal; the debug-only
singletons (miniappRunningRegistry, devServerBridge) come from
@mentra/island/devtools. Host UI keeps plain @mentra/island imports where it
only uses toolkit, types, and pure helpers (decide* functions, useApps-style
hooks, DUMMY_APPLET, BgTimer, OTA policy constants + deriveDisplayState,
readiness predicates, hardware capability tables).

The @/stores/* and @/utils/* shims re-export from /internal, so their many
importers are unchanged. No statement other than island imports is touched;
behavior is identical — the entries resolve the same concrete modules.
The main barrel now exports only the OEM-facing surface: the toolkit
namespace, contract/read-model types, and the pure helpers host UI renders
with (readiness predicates, connect/reconnect decisions, OTA policy constants
and deriveDisplayState, app-list hooks and sort/order helpers, hardware
capability tables, BgTimer). Everything store- or service-shaped is reachable
only via @mentra/island/internal, and the debug singletons only via
@mentra/island/devtools.

Also delete the toolkit.stores escape hatch: its five raw stores are already
flat exports on the internal entry, its two remaining mentions were shim
comments, and its jest mirror goes with it. Module loading is unchanged —
toolkit still transitively constructs the same runtime graph — so behavior is
identical; this only shrinks the importable API surface.
Add report-only counters for @mentra/island/internal (39 files) and
@mentra/island/devtools (2 files) imports in mobile/src, relabel the
raw-store counter to reflect that store access now routes through /internal
and the @/stores shims (count unchanged at 41), and mark the deleted
toolkit.stores hatch as a should-stay-0 counter. Also make report_count
survive zero-match patterns under set -euo pipefail — rg exits 1 on no
matches, which silently killed the script halfway through the report.

Docs: mark integration-review §D phase 4 done with the landed shape, and
describe the three entry points in the island README.
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

📋 PR Review Helper

📱 Mobile App Build

Ready to test! (commit 6886091)

📥 Download APK

🕶️ ASG Client Build

Waiting for build...


🔀 Test Locally

gh pr checkout 3342

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c0224e7dde

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

*/

// Which miniapps the local runtime currently has running (stress-test screen).
export {miniappRunningRegistry} from "./services/MiniappRunningRegistry"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Update the SDK example for the devtools subpath

Moving miniappRunningRegistry exclusively onto /devtools leaves sdk/example-oem-app/App.tsx still importing it from @mentra/island (repo-wide rg '@mentra/island' shows this remaining consumer). When that example is bundled through its Metro alias to mobile/modules/island, the root entry no longer exports the binding, so the example fails to typecheck/bundle before rendering; please repoint the example (and its TS path mapping if needed) to @mentra/island/devtools or keep a compatibility export.

Useful? React with 👍 / 👎.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 53 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread mobile/modules/island/README.md
The example OEM app under sdk/ was the one island consumer outside mobile/src
the split missed: it imported miniappRunningRegistry from the main entry,
which the slimmed barrel no longer exports. Import it from
@mentra/island/devtools, add the matching tsconfig path onto the built
devtools types, and note the extra entry in the example README. Verified with
a fresh expo-module build of island: the example app typechecks clean and the
main .d.ts carries no internal/devtools symbols.

Also fix two doc inconsistencies from the same review pass: the island README
bullets still described the pre-rename miniappGlobals/devMiniappLaunch
exports, and the integration review's 'Present today' escape-hatch list now
carries phase-4 disposition brackets so it agrees with the status note above
it.
@PhilippeFerreiraDeSousa

Copy link
Copy Markdown
Contributor Author

Addressed all three review-bot findings in 19d287c:

  • P2 (codex): SDK example appsdk/example-oem-app/App.tsx now imports miniappRunningRegistry from @mentra/island/devtools (with a matching tsconfig path onto build/devtools.d.ts). Verified against a fresh expo-module build: the example app typechecks clean, and the rebuilt build/index.d.ts carries no internal/devtools symbols. This was the one island consumer outside mobile/src the split survey missed.
  • P3 (cubic): island README — bullets now use the current export names (buildMiniappGlobalsScript, decideDevLaunchRoute).
  • P3 (cubic): integration review §D — the 'Present today' escape-hatch list now carries phase-4 disposition brackets (toolkit.stores deleted; flat exports moved to /internal+/devtools; shims still present for phase 5), so it reads consistently with the status note.

Standard gates re-run after the fix: mobile compile clean, 50 suites/364 tests, island 194 tests, boundary script green (counters unchanged).

PhilippeFerreiraDeSousa added 2 commits July 3, 2026 19:09
…t-split

Both sides fixed the report_count zero-match abort independently; keep the
base's brace-group form so this branch's boundary-script diff reduces to the
new entry-point counters. The base now routes streamed wifi scan results
through toolkit.glasses.wifi.onScanResult, which removes the raw
BluetoothSdk listener from the wifi scan screen — drop the import this branch
had restored for it, making the screen identical to the base again.
…x/island-entrypoint-split

jest.config.js: keep both sides' island source mappers — the base's new main
entry mapping plus this branch's internal/devtools subpath mappings.
jest.setup.js: keep the three-entry mock registry and adopt the base's fuller
localDisplayManager stub (display-render v1 tests exercise its methods).
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 4, 2026

Copy link
Copy Markdown

Deploying mentra-live-ota-site with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6886091
Status: ✅  Deploy successful!
Preview URL: https://6dffccd4.mentra-live-ota-site.pages.dev
Branch Preview URL: https://codex-island-entrypoint-spli.mentra-live-ota-site.pages.dev

View logs

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying mentra-store-dev with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6886091
Status: ✅  Deploy successful!
Preview URL: https://17edfef5.augmentos-appstore-2.pages.dev
Branch Preview URL: https://codex-island-entrypoint-spli.augmentos-appstore-2.pages.dev

View logs

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying dev-augmentos-console with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6886091
Status: ✅  Deploy successful!
Preview URL: https://6ff4d032.dev-augmentos-console.pages.dev
Branch Preview URL: https://codex-island-entrypoint-spli.dev-augmentos-console.pages.dev

View logs

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying prod-augmentos-account with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6886091
Status: ✅  Deploy successful!
Preview URL: https://6ed9c421.augmentos-e84.pages.dev
Branch Preview URL: https://codex-island-entrypoint-spli.augmentos-e84.pages.dev

View logs

@PhilippeFerreiraDeSousa PhilippeFerreiraDeSousa merged commit 8050a95 into integration/toolkit-boundary Jul 6, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant