Single Source Of Truth
Every value that drives the UI lives in exactly one place — a ViewModel, a remembered state holder, or a state-hoisted parameter. Composables read it and emit it.…
$ prime install @android-compose/rule-single-source-of-truth Projection
Always in _index.xml · the agent never has to ask for this.
SingleSourceOfTruth [rule] v0.1.0
Every value that drives the UI lives in exactly one place — a ViewModel, a remembered state holder, or a state-hoisted parameter. Composables read it and emit it. They do NOT copy it into a second remember { mutableStateOf(...) } they then keep in sync with the original via LaunchedEffect. Two copies of the same fact will drift the moment the synchronisation code has a bug, and you cannot tell which is correct.
Loaded when retrieval picks the atom as adjacent / supporting.
SingleSourceOfTruth [rule] v0.1.0
Every value that drives the UI lives in exactly one place — a ViewModel, a remembered state holder, or a state-hoisted parameter. Composables read it and emit it. They do NOT copy it into a second remember { mutableStateOf(...) } they then keep in sync with the original via LaunchedEffect. Two copies of the same fact will drift the moment the synchronisation code has a bug, and you cannot tell which is correct.
Checks
- No
LaunchedEffect(externalValue) { internalState = externalValue }patterns — that is a duplicated source of truth. - Forms read directly from the ViewModel state object; they do not snapshot it into a local copy at composition time.
- When a composable needs a derived value from another value, use
derivedStateOfor compute it directly — do not store the derived result. - Selection, scroll, and focus state belong to a hoisted state holder (e.g.
LazyListState,TextFieldState), used by both reader and writer.
Label
Each piece of state has exactly one owner; UI reads, never duplicates
Loaded when retrieval picks the atom as a focal / direct hit.
SingleSourceOfTruth [rule] v0.1.0
Every value that drives the UI lives in exactly one place — a ViewModel, a remembered state holder, or a state-hoisted parameter. Composables read it and emit it. They do NOT copy it into a second remember { mutableStateOf(...) } they then keep in sync with the original via LaunchedEffect. Two copies of the same fact will drift the moment the synchronisation code has a bug, and you cannot tell which is correct.
Checks
- No
LaunchedEffect(externalValue) { internalState = externalValue }patterns — that is a duplicated source of truth. - Forms read directly from the ViewModel state object; they do not snapshot it into a local copy at composition time.
- When a composable needs a derived value from another value, use
derivedStateOfor compute it directly — do not store the derived result. - Selection, scroll, and focus state belong to a hoisted state holder (e.g.
LazyListState,TextFieldState), used by both reader and writer.
Label
Each piece of state has exactly one owner; UI reads, never duplicates
Label
Each piece of state has exactly one owner; UI reads, never duplicates
Source
prime-system/examples/android-compose/primes/compiled/@android-compose/rule-single-source-of-truth/atom.yaml