# XmobiTea DeviceId Agent Notes

Scope: everything inside `Assets/XmobiTea DeviceId`.

## Need-Based Routing

Choose by current need.

- `AI_USAGE.md`: normal code generation
- `AI_API_REFERENCE.md`: exact symbols and supported surface
- `AI_BEHAVIOR.md`: storage, reset, logging, and platform lifetime details
- `README.md`: package overview and file map

## Hard Rules

- Use `XmobiTea.MiniDeviceId.CXDevice.GetDeviceId()` for consumer code.
- Treat the return value as an opaque `string`.
- Keep generated code free of scene setup, prefabs, managers, settings assets, and init calls for this package.
- Do not route consumer code through `Implement.Get()`.
- Do not reference `CXKeyChain` from consumer code.
- Do not use `CustomId` as a product data contract.
- Mention platform variance when the ID affects business logic.

## Platform Facts

- Default target group: `SystemInfo.deviceUniqueIdentifier`.
- WebGL: generated GUID stored at `PlayerPrefs` key `MiniDeviceId_DeviceId`.
- Apple-path asmdef targets: `iOS`, `macOSStandalone`, `tvOS`.
- Shipped native keychain implementation sources are imported for `iOS` and `tvOS` under `Plugins/iOS`.
- No macOS standalone native bridge source is present in this package.
- Apple-path native storage keys are `UserID` and `UserUUID`; the C# read flow parses a JSON payload with `userId` and `uuid`, but only returns `uuid`.
- On empty Apple-path `uuid`, the package writes `SystemInfo.deviceUniqueIdentifier` back with user slot `"0"`.
- `CXDevice` has no in-memory cache.
- Apple-path implementation calls the native bridge on every read.
- Apple-path fallback write logs `===Saved uuid on empty: [...]`; native code may also log `No user information` on an empty keychain payload.

## False Assumptions

- The package returns a hardware-backed ID on every platform.
- The same reset or reinstall behavior applies on every platform.
- WebGL storage is durable like native device storage.
- The package ships a ready macOS standalone native bridge because the asmdef includes `macOSStandalone`.
- `CXDevice.GetDeviceId()` performs hashing, validation, encryption, consent, or compliance handling.
- The package has a lifecycle service that needs to be initialized.

## Preferred Wording

Use:

- "identifier string"
- "package device/app identifier"
- "platform-dependent identifier"

Avoid unless the product context explicitly accepts it:

- "guaranteed hardware ID"
- "permanent device ID"
- "secure identity"
- "cross-platform stable identity"
