Sensitive
Declares a sensitive field of a query model: its level and how query results mask it.
It decides what a read returns: a query, a state read, an event query, a trace, an entry of the state view cache. A published stream carries both levels masked, unless its owner declares that it reveals its SensitivityLevel.DISPLAY values (@AggregateRoot(revealsDisplay = true)) and the service shares them (wow.query.sensitivity.display-shared): a topic's ACL is then what protects those. It does not change what Wow stores, and it is not encryption at rest: the log, the snapshots and what the sinks store (ClickHouse's tables, Elasticsearch's event index) hold the value as written, so a store's grants are what protect it there.
Sensitivity is declared only on the domain field, never in a declaration file or by a string path, so renaming the field cannot silently drop the protection. The field must be a JVM String that serializes as a JSON string. A value is masked by its path, so a recursive type (a tree whose children are trees) of a state, an event or a command holds none: no path reaches one below the recursion, and the build refuses such a type.
data class AccountState(
@field:Sensitive(SensitivityLevel.CONFIDENTIAL)
val password: String,
@field:Sensitive(SensitivityLevel.DISPLAY, mask = Mask(keepPrefix = 3, keepSuffix = 4))
val phone: String?,
)It can also annotate an annotation class, which then declares the same sensitivity wherever it is used.
On a value type — a Kotlin value class or a type with a @JsonValue member (its own, a superclass's or an interface's getter), serialized as a string — it protects every property declared with that type, in a collection, a map's values, an Optional, a Sequence or through a type parameter (Page<PhoneNumber>) alike, in states, events and commands, so one value keeps one level everywhere. It is declared on the class, or on the member the type is written by (the value class's property, the @JsonValue member, or a getter that member overrides). A value type whose member holds a sensitive one, itself or in a container, is sensitive too, at that level or a stricter one it declares, never a looser one. A class and its member that both declare it declare the same, or the build fails; so does a @Sensitive on another member of the type, which is not written, and a generic value type holding a sensitive one through its type parameter, which the schema describes as any value. A property may repeat or tighten the type's level, never loosen it:
@JvmInline
@Sensitive(SensitivityLevel.DISPLAY, mask = Mask(keepPrefix = 3, keepSuffix = 4))
value class PhoneNumber(val value: String)Any other class carrying @Sensitive fails the schema build.
A property also carries the @Sensitive of the members it overrides, a getter of an interface the state implements or a property of its superclass, so a read model interface can declare it once (@get:Sensitive) for the states that implement it, and an override cannot drop it. The overriding property may declare its own, to choose the mask or tighten the level, never to loosen it. Two overridden members that declare different ones fail the build, naming both; the property declares its own, at the stricter level, to choose.