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
| Name | Id | Scope | Description | Security |
|---|---|---|---|---|
List Reflection Roots | reflect.list_roots | Read | Lists registered or built-in native reflection roots. | High |
Inspect Object | reflect.inspect_object | Read | Returns a snapshot of a native root or nested path. | Critical |
Describe Type | reflect.describe_type | Read | Returns native runtime type metadata. | Moderate |
Set Member Value | reflect.set_member_value | Write | Writes through supported native reflection paths. | Critical |
Invoke Method | reflect.invoke_method | Write | Invokes 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.