Skip to content

Move NPU catalog refresh bootstrap into SDK APIs #523

Description

@sanchitmonga22

Overview

CodeRabbit flagged that PR #522 repeats NPU catalog bootstrap logic in the example apps: each app registers all logical HNPU rows, catches per-model failures, and refreshes the model registry. That works for the current PR, but it means example apps carry SDK orchestration knowledge instead of making one thin SDK call.

Impact: Medium
Priority: P2
Effort: Medium

Problem Statement

The current PR intentionally registers logical HNPU rows from Android, Flutter, and React Native example apps so token changes immediately re-seed private QHexRT/HNPU bundles. However, the register/count/catch/refresh sequence is duplicated across platforms:

  • Android: examples/android/RunAnywhereAI/app/src/main/java/com/runanywhere/runanywhereai/data/ModelBootstrap.kt
  • Flutter: examples/flutter/RunAnywhereAI/lib/core/services/model_catalog_bootstrap.dart
  • React Native: examples/react-native/RunAnywhereAI/src/services/ModelCatalogBootstrap.ts

This makes the examples less thin and increases the chance that future SDK behavior changes drift across platforms.

Current State

PR #522 applies quick stability fixes in the example apps:

  • Android catches per-model failures and now guards final registry refresh failures.
  • Settings token save/clear refreshes the NPU catalog after updating auth.
  • Flutter and RN refresh their NPU catalogs after token changes.

The remaining structural issue is API shape: the SDK should provide a single catalog re-registration or NPU refresh helper.

Proposed Solution

Expose a shared SDK-level entry point, for example one of:

RunAnywhere.refreshNpuCatalog(models)
RunAnywhere.reregisterCatalog(models)
RunAnywhere.registerCatalog(models, refresh = true)

The SDK API should own:

  • registering each provided catalog row,
  • per-row failure handling/reporting,
  • registry refresh,
  • consistent result/count reporting,
  • platform bindings for Kotlin, Flutter, and React Native.

Example apps should then only call the SDK API after auth changes.

Implementation Plan

  • Design a small cross-platform result type for catalog refresh counts/errors.
  • Add the native/shared SDK API or platform wrapper API.
  • Wire Kotlin, Flutter, and React Native SDK bindings.
  • Replace example-app register/count/catch loops with one SDK call.
  • Add focused tests for success, per-row failure, and registry refresh failure behavior.
  • Update example app docs where needed.

Success Criteria

  • Example apps no longer implement multi-step NPU catalog bootstrap logic.
  • Android, Flutter, and RN all use the same SDK-level contract.
  • Token save/clear still refreshes HNPU catalog visibility.
  • Per-model failures are surfaced consistently without crashing the UI.

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium priorityenhancementNew feature or requestflutter-sampleFlutter example appflutter-sdkFlutter SDKkotlin-sdkKotlin / Android SDKrn-sampleReact Native example apprn-sdkReact Native SDKtech-debtRefactoring and code-quality cleanup

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions