Read protection is on by default
What changed
Section titled “What changed”In Arc 22, a project that did not set <CratisReadProtection> ran with read protection Off: an injected read
model was a plain snapshot read that guarded nothing. From Arc 23 the default is On. Arc reads supported models
fresh, guards the append against what the command read, and refuses read-model parameters it cannot guard.
A command or project that declares a mode keeps it. Only commands with no declaration anywhere change.
Who is affected
Section titled “Who is affected”Applications that use Arc with Chronicle and inject read models into commands, validators, Provide() or
Handle(), and that never set <CratisReadProtection> or [ReadProtection].
What you may see after upgrading:
- Appends that raced with a concurrent change are refused where they previously succeeded.
- Read-model parameters that cannot be guarded, and missing generated key metadata or key accessors, are refused at startup or at first use. Mark a deliberately advisory
read with
[Unprotected("why")], or select the instance with[LookUpBy(nameof(Property))]. - Each guarded read is a fresh fold of the key’s events instead of the materialized state, so reads cost more for keys with long histories.
Keep the Arc 22 behavior
Section titled “Keep the Arc 22 behavior”Set the mode explicitly in each project:
<PropertyGroup> <CratisReadProtection>Off</CratisReadProtection></PropertyGroup>Or opt out for one command with [ReadProtection(ReadProtectionMode.Off)] or [Unprotected("why")], or for one
read with [Unprotected("why")] on the parameter, the read-model type or the method.
Adopt On gradually
Section titled “Adopt On gradually”- Set
<CratisReadProtection>Measure</CratisReadProtection>and run your workload or specs. - Fix what the measurement reports. See Adopting read protection.
- Remove the property, or set it to
On, to take the new default.
Check the result
Section titled “Check the result”Build with the analyzers enabled and run the specs of every command that injects a read model. A command that needed a lookup key or an opt-out fails the build or the spec instead of changing behavior silently in production.
Strict key coverage is the default
Section titled “Strict key coverage is the default”Two related defaults change in the same release:
ReadProtectionConfigurationnow requires generated command read-model key metadata unlessReadProtection:RequireGeneratedMetadatais set tofalse. Commands without generated metadata fail at startup withCommandReadModelKeysMissinginstead of reflecting. Enable the Arc source generator, or opt out withfalseon runtimes with dynamic code support.ProtectedReadModelKeyOptions.Strictdefaults totrue, so an uncovered composite key part throwsProtectedReadModelKeyAccessorMissing. Register the key accessors, or setStricttofalseto keep the reflection fallback.