Reflection

Configure the React Native native reflection tools to inspect registered native roots and built-in roots according to platform support.

Register the Suite

await Ansight.initializeAndActivate(
  Ansight.createOptionsBuilder()
    .withReflectionTools({
      includeBuiltInRoots: true,
      allowedRootIds: ["application"],
      allowedTypePrefixes: ["com.example."],
    })
    .withReadOnlyToolAccess()
    .build(),
);

Registration API

  • withReflectionTools(options): configures native reflection tool options.
  • remoteTools.reflection.includeBuiltInRoots: includes supported native built-in roots.
  • remoteTools.reflection.allowedRootIds: restricts roots.
  • remoteTools.reflection.allowedTypePrefixes: restricts type traversal.

Specific Concerns

  • Reflection can expose private native state, model graphs, and user data.
  • Built-in root availability depends on the native platform.
  • Set and invoke are write-scoped.

Tool Matrix

NameIdScopeDescriptionSecurity
List Reflection Rootsreflect.list_rootsReadLists registered or built-in native reflection roots.High
Inspect Objectreflect.inspect_objectReadReturns a snapshot of a native root or nested path.Critical
Describe Typereflect.describe_typeReadReturns native runtime type metadata.Moderate
Set Member Valuereflect.set_member_valueWriteWrites through supported native reflection paths.Critical
Invoke Methodreflect.invoke_methodWriteInvokes through supported native reflection paths.Critical

Tool Details

Use read tools to inspect native roots and describe types. Enable write access only when the native platform and registered roots intentionally support mutation or invocation.

Root descriptors returned by reflect.list_roots include hostRuntime, which identifies the runtime that owns the root. Current React Native reflection roots are native roots, so they report the iOS swift or Android jvm host runtime. JavaScript-hosted roots should report kind: "javascript" and bridge: "react-native" so clients can route reflection commands across the React Native runtime boundary deliberately.