@cratis/pi 7.189.2 → 7.189.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/package/corpus/harnesses/copilot/instructions/elixir.instructions.md +26 -4
  2. package/package/corpus/hooks/README.md +36 -1
  3. package/package/corpus/hooks/scripts/cratis-guard-shell-writes.sh +62 -17
  4. package/package/corpus/rules/elixir.md +26 -4
  5. package/package/corpus/skills/cratis-arc-elixir/SKILL.md +22 -12
  6. package/package/corpus/skills/cratis-arc-elixir/references/availability.md +14 -14
  7. package/package/corpus/skills/cratis-arc-elixir/references/commands-and-queries.md +8 -8
  8. package/package/corpus/skills/cratis-arc-elixir/references/event-model.md +79 -0
  9. package/package/corpus/skills/cratis-arc-elixir/references/hosting-and-testing.md +10 -10
  10. package/package/corpus/skills/cratis-arc-elixir/references/mongodb.md +9 -9
  11. package/package/corpus/skills/cratis-arc-elixir/references/observable-queries-and-hubs.md +5 -5
  12. package/package/corpus/skills/cratis-arc-elixir/references/pitfalls.md +13 -2
  13. package/package/corpus/skills/cratis-arc-elixir/references/product-sources.md +3 -2
  14. package/package/corpus/skills/cratis-arc-elixir/references/tenancy-and-identity.md +7 -7
  15. package/package/corpus/skills/cratis-arc-elixir/verification.json +14 -1
  16. package/package/corpus/skills/cratis-chronicle-client-elixir/SKILL.md +43 -43
  17. package/package/corpus/skills/cratis-chronicle-client-elixir/references/append-api.md +4 -4
  18. package/package/corpus/skills/cratis-chronicle-client-elixir/references/captures.md +5 -5
  19. package/package/corpus/skills/cratis-chronicle-client-elixir/references/client-options.md +5 -5
  20. package/package/corpus/skills/cratis-chronicle-client-elixir/references/compliance.md +6 -6
  21. package/package/corpus/skills/cratis-chronicle-client-elixir/references/connections.md +3 -3
  22. package/package/corpus/skills/cratis-chronicle-client-elixir/references/constraints.md +6 -6
  23. package/package/corpus/skills/cratis-chronicle-client-elixir/references/decision-reads.md +12 -12
  24. package/package/corpus/skills/cratis-chronicle-client-elixir/references/discovery-and-generations.md +10 -10
  25. package/package/corpus/skills/cratis-chronicle-client-elixir/references/event-sources.md +7 -7
  26. package/package/corpus/skills/cratis-chronicle-client-elixir/references/graphs.md +6 -6
  27. package/package/corpus/skills/cratis-chronicle-client-elixir/references/idioms-and-inspection.md +5 -5
  28. package/package/corpus/skills/cratis-chronicle-client-elixir/references/observability.md +2 -2
  29. package/package/corpus/skills/cratis-chronicle-client-elixir/references/patterns.md +6 -6
  30. package/package/corpus/skills/cratis-chronicle-client-elixir/references/pitfalls.md +4 -4
  31. package/package/corpus/skills/cratis-chronicle-client-elixir/references/projections.md +4 -4
  32. package/package/corpus/skills/cratis-chronicle-client-elixir/references/reactor-example.md +2 -2
  33. package/package/corpus/skills/cratis-chronicle-client-elixir/references/read-models.md +7 -7
  34. package/package/corpus/skills/cratis-chronicle-client-elixir/references/testing.md +15 -15
  35. package/package/corpus/skills/cratis-chronicle-client-elixir/references/upgrading.md +19 -3
  36. package/package/corpus/skills/cratis-chronicle-client-elixir/references/variants.md +9 -9
  37. package/package/corpus/skills/cratis-chronicle-client-elixir/verification.json +3 -3
  38. package/package.json +1 -1
@@ -3,7 +3,7 @@
3
3
 
4
4
  # Captures
5
5
 
6
- Source: `Cratis/Chronicle.Elixir`: `Source/chronicle/lib/chronicle/captures.ex`, `captures/capture.ex`, `captures/registrar.ex`, and `Documentation/captures.md`.
6
+ Source: `Cratis/Chronicle.Elixir`: `Source/chronicle/lib/cratis/chronicle/captures.ex`, `captures/capture.ex`, `captures/registrar.ex`, and `Documentation/captures.md`.
7
7
 
8
8
  Requires `cratis_chronicle` 3.13.0.
9
9
 
@@ -14,7 +14,7 @@ A capture turns data that arrives from outside the event log (an external API, a
14
14
  # Licensed under the MIT license. See LICENSE file in the project root for full license information.
15
15
 
16
16
  defmodule MyApp.Captures.InvoiceCapture do
17
- use Chronicle.Captures.Capture, name: "InvoiceCapture"
17
+ use Cratis.Chronicle.Captures.Capture, name: "InvoiceCapture"
18
18
 
19
19
  api_source("InvoicingApi", route: "/invoices", poll: "10m")
20
20
 
@@ -32,12 +32,12 @@ end
32
32
  - `when:` takes a property name, `{:any, [...]}`, `{:all, [...]}`, `{:transition, property, from, to}`, `:added`, `:removed`, or `{:expression, "template"}`. `set/2` maps a target field from `"$.path"` (payload) or `"$context.<property>"`.
33
33
  - The DSL also has `nested` and `children` scopes, and a `map do` block with `rename`, `template`, `translate` and `split`.
34
34
 
35
- **An appended event type's id must start with an uppercase letter and contain only letters, digits and underscores.** The kernel's CDL parser rejects hyphens, so `use Chronicle.Events.EventType, id: "InvoiceStatusChanged"` works as an `append` target and `id: "invoice-status-changed"` raises `ArgumentError` at compile time. This restriction does not apply to `events_source/1`.
35
+ **An appended event type's id must start with an uppercase letter and contain only letters, digits and underscores.** The kernel's CDL parser rejects hyphens, so `use Cratis.Chronicle.Events.EventType, id: "InvoiceStatusChanged"` works as an `append` target and `id: "invoice-status-changed"` raises `ArgumentError` at compile time. This restriction does not apply to `events_source/1`.
36
36
 
37
37
  **The kernel's capture engine runs a subset of the language**: only `api` and `events` sources, and only root-level `append` rules. `map`, `nested` and `children` compile and validate but are not applied at runtime, and webhook sources cannot carry authentication.
38
38
 
39
39
  ## Registering and managing
40
40
 
41
- Captures are discovered with `otp_app:` or listed in the client's `:captures` option. `Chronicle.Captures.Registrar` saves them at `:registered` and again on every reconnect. It skips a capture whose declaration already matches, and warns before saving over a **started** capture whose declaration changed, because saving stops it on the kernel.
41
+ Captures are discovered with `otp_app:` or listed in the client's `:captures` option. `Cratis.Chronicle.Captures.Registrar` saves them at `:registered` and again on every reconnect. It skips a capture whose declaration already matches, and warns before saving over a **started** capture whose declaration changed, because saving stops it on the kernel.
42
42
 
43
- Manage directly with `Chronicle.Captures.register/1`, `start/1`, `stop/1`, `delete/1`, `list/0`, `validate/1` (a module or raw CDL text) and `captured_events/1`. `start`, `stop` and `delete` also accept a raw capture id; `delete` is destructive, so obtain authority for the specific capture first.
43
+ Manage directly with `Cratis.Chronicle.Captures.register/1`, `start/1`, `stop/1`, `delete/1`, `list/0`, `validate/1` (a module or raw CDL text) and `captured_events/1`. `start`, `stop` and `delete` also accept a raw capture id; `delete` is destructive, so obtain authority for the specific capture first.
@@ -1,15 +1,15 @@
1
1
  # Client options and supervision
2
2
 
3
- This reference holds the `Chronicle.Client` child-spec options, its supervision tree and the multiple-client rule.
3
+ This reference holds the `Cratis.Chronicle.Client` child-spec options, its supervision tree and the multiple-client rule.
4
4
 
5
5
  ### Options
6
6
 
7
7
  Pass **child-spec keyword options**. The client reads no application env;
8
- your app must read its own configuration and pass it in (`lib/chronicle/client.ex`).
8
+ your app must read its own configuration and pass it in (`lib/cratis/chronicle/client.ex`).
9
9
 
10
10
  | Option | Default |
11
11
  | --- | --- |
12
- | `:name` | `Chronicle.Client` |
12
+ | `:name` | `Cratis.Chronicle.Client` |
13
13
  | `:connection_string` | `ConnectionString.default/0` |
14
14
  | `:event_store` | `"default"` |
15
15
  | `:namespace` | `"Default"` — capital D |
@@ -34,7 +34,7 @@ your app must read its own configuration and pass it in (`lib/chronicle/client.e
34
34
  without it the client falls back to scanning every loaded module.
35
35
 
36
36
  Configuration is stashed in `:persistent_term` and read back with
37
- `Chronicle.Client.config/1` (`client.ex`). Its subset includes `event_sources`,
37
+ `Cratis.Chronicle.Client.config/1` (`client.ex`). Its subset includes `event_sources`,
38
38
  but not `read_models`, `projections`, or `migrations`.
39
39
 
40
40
  ### The supervision tree
@@ -45,5 +45,5 @@ The connection, session and registration precede observers.
45
45
 
46
46
  ### Multiple clients
47
47
 
48
- Pass `name:` to `Chronicle.Client` and `client:` to every API call. Every public
48
+ Pass `name:` to `Cratis.Chronicle.Client` and `client:` to every API call. Every public
49
49
  function takes a `:client` option.
@@ -3,7 +3,7 @@
3
3
 
4
4
  # Personal data, concepts and operational secrets
5
5
 
6
- Source: `Cratis/Chronicle.Elixir`: `Source/chronicle/lib/chronicle/{concept,compliance,confidentiality}.ex`, `events/event_type.ex`, and `read_models/read_model.ex`.
6
+ Source: `Cratis/Chronicle.Elixir`: `Source/chronicle/lib/cratis/chronicle/{concept,compliance,confidentiality}.ex`, `events/event_type.ex`, and `read_models/read_model.ex`.
7
7
 
8
8
  `pii/1,2` marks personal data for compliance encryption and right-to-erasure. `encrypted/1,2,3` marks non-personal operational secrets for separate confidentiality encryption with no compliance erasure operation. Its scopes are `:subject` (default), `:namespace`, `:global`. They are not interchangeable.
9
9
 
@@ -14,12 +14,12 @@ Requires `cratis_chronicle` 3.5.0 for `encrypted/1,2,3`.
14
14
  # Licensed under the MIT license. See LICENSE file in the project root for full license information.
15
15
 
16
16
  defmodule MyApp.PersonName do
17
- use Chronicle.Concept, type: :string
17
+ use Cratis.Chronicle.Concept, type: :string
18
18
  pii("Legal name of the data subject")
19
19
  end
20
20
 
21
21
  defmodule MyApp.Events.PartnerIntegrationConfigured do
22
- use Chronicle.Events.EventType, id: "partner-integration-configured"
22
+ use Cratis.Chronicle.Events.EventType, id: "partner-integration-configured"
23
23
  defstruct contact_name: %MyApp.PersonName{}, email: "", api_key: ""
24
24
 
25
25
  pii(:email, "Partner contact's email address")
@@ -27,8 +27,8 @@ defmodule MyApp.Events.PartnerIntegrationConfigured do
27
27
  end
28
28
  ```
29
29
 
30
- `Chronicle.Concept` is published on Hex; on a client without it, annotate fields with `pii/1,2`. `type:` is required: `:string`, `:integer`, `:float`, `:boolean`, `:uuid`. Typed concept defaults let the schema generator carry the wrapped type and classification onto every leaf that uses it. The concept's `Jason.Encoder` serializes only its wrapped value.
30
+ `Cratis.Chronicle.Concept` is published on Hex; on a client without it, annotate fields with `pii/1,2`. `type:` is required: `:string`, `:integer`, `:float`, `:boolean`, `:uuid`. Typed concept defaults let the schema generator carry the wrapped type and classification onto every leaf that uses it. The concept's `Jason.Encoder` serializes only its wrapped value.
31
31
 
32
- On a concept use `pii/0,1` to classify its sole value, not the field-oriented `Chronicle.Compliance.pii/1,2`. Concept `encrypted/0,1,2` similarly marks that value. Neither classification is allowed on a concept with `event_source_id: true`; use a non-sensitive surrogate stream identity instead. Both classifications on one schema leaf raise `Chronicle.Confidentiality.PiiAndEncryptedCombinedNotSupported`.
32
+ On a concept use `pii/0,1` to classify its sole value, not the field-oriented `Cratis.Chronicle.Compliance.pii/1,2`. Concept `encrypted/0,1,2` similarly marks that value. Neither classification is allowed on a concept with `event_source_id: true`; use a non-sensitive surrogate stream identity instead. Both classifications on one schema leaf raise `Cratis.Chronicle.Confidentiality.PiiAndEncryptedCombinedNotSupported`.
33
33
 
34
- For a read model whose subject is not its `:id`, declare `subject(:customer_id)` in the module using `Chronicle.ReadModels.ReadModel`. It identifies the natural person for PII release; there is only one subject declaration per module. `subject/1` is not imported by `EventType`; append-time `:subject` is an append option, not this read-model macro.
34
+ For a read model whose subject is not its `:id`, declare `subject(:customer_id)` in the module using `Cratis.Chronicle.ReadModels.ReadModel`. It identifies the natural person for PII release; there is only one subject declaration per module. `subject/1` is not imported by `EventType`; append-time `:subject` is an append option, not this read-model macro.
@@ -3,11 +3,11 @@
3
3
 
4
4
  # Connections, trust and resilience
5
5
 
6
- Source: `Cratis/Chronicle.Elixir`: `Source/chronicle/lib/chronicle/connections/{connection_string,connection,keep_alive,client_certificate,transport}.ex`, `registration/coordinator.ex`, and `Documentation/connections/{connection-strings,resilience,crash-reports}.md`.
6
+ Source: `Cratis/Chronicle.Elixir`: `Source/chronicle/lib/cratis/chronicle/connections/{connection_string,connection,keep_alive,client_certificate,transport}.ex`, `registration/coordinator.ex`, and `Documentation/connections/{connection-strings,resilience,crash-reports}.md`.
7
7
 
8
8
  ## Connection strings and authentication
9
9
 
10
- `Chronicle.Connections.ConnectionString` accepts `chronicle://` and `chronicle+srv://`; the default port is `35000`. Multiple comma-separated hosts are resolved again on reconnect; SRV accepts only one host (`connection_string.ex`).
10
+ `Cratis.Chronicle.Connections.ConnectionString` accepts `chronicle://` and `chronicle+srv://`; the default port is `35000`. Multiple comma-separated hosts are resolved again on reconnect; SRV accepts only one host (`connection_string.ex`).
11
11
 
12
12
  | Function | Line in `connection_string.ex` |
13
13
  | --- | --- |
@@ -45,7 +45,7 @@ The client uses grpc 1.x and Mint 1.11+, owns its transport, and needs no `GRPC.
45
45
 
46
46
  ## Credential-safe logging is still necessary
47
47
 
48
- Chronicle's own process status redacts credentials, but dependency crash reports can expose gRPC headers, bearer tokens, API keys and Mint HPACK tables. The client itself installs a primary Logger filter (`Chronicle.Connections.ResponseCrashRedaction`) when a connection starts, replacing the Mint response-process termination report, the one shape it can intercept generically, with a one-line notice (requires `cratis_chronicle` 3.13.0). The `ConnectionProcess` and `GRPC.Client.Connection` state can still print credentials, so before starting the client, install the primary Logger filter from the [client crash-report guide](https://github.com/Cratis/Chronicle.Elixir/blob/main/Documentation/connections/crash-reports.md). It matches `Elixir.GRPC.Client`, `Elixir.GRPC.Channel`, and `Elixir.Mint.` report content and replaces reports with a notice.
48
+ Chronicle's own process status redacts credentials, but dependency crash reports can expose gRPC headers, bearer tokens, API keys and Mint HPACK tables. The client itself installs a primary Logger filter (`Cratis.Chronicle.Connections.ResponseCrashRedaction`) when a connection starts, replacing the Mint response-process termination report, the one shape it can intercept generically, with a one-line notice (requires `cratis_chronicle` 3.13.0). The `ConnectionProcess` and `GRPC.Client.Connection` state can still print credentials, so before starting the client, install the primary Logger filter from the [client crash-report guide](https://github.com/Cratis/Chronicle.Elixir/blob/main/Documentation/connections/crash-reports.md). It matches `Elixir.GRPC.Client`, `Elixir.GRPC.Channel`, and `Elixir.Mint.` report content and replaces reports with a notice.
49
49
 
50
50
  Keep `handle_sasl_reports: false`. This is a safety net, not a guarantee: plain warning strings carrying exit reasons are not covered, and filters do not survive a Logger restart. Restrict production log access and rotate any credential already exposed. Never log connection strings ([`secrets.md`](../../../rules/secrets.md)).
51
51
 
@@ -3,7 +3,7 @@
3
3
 
4
4
  # Constraints
5
5
 
6
- Source: `Cratis/Chronicle.Elixir`: `Source/chronicle/lib/chronicle/events/event_type.ex`, `events/constraint.ex`, `events/constraint_violation.ex`, and `Documentation/constraints.md`.
6
+ Source: `Cratis/Chronicle.Elixir`: `Source/chronicle/lib/cratis/chronicle/events/event_type.ex`, `events/constraint.ex`, `events/constraint_violation.ex`, and `Documentation/constraints.md`.
7
7
 
8
8
  Requires `cratis_chronicle` 3.13.0 for standalone constraint modules, `remove_constraint/2`, `:scope` and `ConstraintViolation.details/1`.
9
9
 
@@ -11,7 +11,7 @@ A constraint is checked by the kernel at append time; a violation returns `{:err
11
11
 
12
12
  ## On the event type
13
13
 
14
- `unique/2`, `unique_event_type/1`, `remove_constraint/1,2` and `closes_stream/1` are imported by `use Chronicle.Events.EventType`.
14
+ `unique/2`, `unique_event_type/1`, `remove_constraint/1,2` and `closes_stream/1` are imported by `use Cratis.Chronicle.Events.EventType`.
15
15
 
16
16
  | Option | Meaning |
17
17
  | --- | --- |
@@ -30,14 +30,14 @@ In `:per_value` mode, `remove_constraint("Name")` releases every value the remov
30
30
 
31
31
  ## Standalone constraint modules
32
32
 
33
- Use `use Chronicle.Events.Constraint` when one name spans several event types or lives apart from any one event type's module.
33
+ Use `use Cratis.Chronicle.Events.Constraint` when one name spans several event types or lives apart from any one event type's module.
34
34
 
35
35
  ```elixir
36
36
  # Copyright (c) Cratis. All rights reserved.
37
37
  # Licensed under the MIT license. See LICENSE file in the project root for full license information.
38
38
 
39
39
  defmodule MyApp.Constraints.UniqueEmail do
40
- use Chronicle.Events.Constraint
40
+ use Cratis.Chronicle.Events.Constraint
41
41
 
42
42
  unique name: "UniqueEmail" do
43
43
  on MyApp.Events.UserRegistered, [:email]
@@ -54,10 +54,10 @@ end
54
54
 
55
55
  ## Violation details
56
56
 
57
- `Chronicle.Events.ConstraintViolation.details(violation)` maps the kernel's detail keys to atoms: `:property_name`, `:property_value`, `:closed_by`, `:closed_at_sequence_number`; any other key stays a string. A PII property's `:property_value` is its **encrypted** form. Use it in a `:message` callback: `"A project named '#{ConstraintViolation.details(violation)[:property_value]}' already exists."`.
57
+ `Cratis.Chronicle.Events.ConstraintViolation.details(violation)` maps the kernel's detail keys to atoms: `:property_name`, `:property_value`, `:closed_by`, `:closed_at_sequence_number`; any other key stays a string. A PII property's `:property_value` is its **encrypted** form. Use it in a `:message` callback: `"A project named '#{ConstraintViolation.details(violation)[:property_value]}' already exists."`.
58
58
 
59
59
  ## Closing events
60
60
 
61
- `closes_stream event_stream_id_from: :period, reopened_by: [MyApp.Events.PeriodReopened]` on an event type closes that stream scope when the event is appended; later events in the scope are refused. Options: `:dimensions`, `:event_stream_id_from`, `:reopened_by`, `:name`, `:event_sequences`; same-named declarations merge and must agree on dimensions. Registration closes nothing in history. Inspect closed scopes with `Chronicle.EventSequences.Streams`. The in-memory test kernel does not model `closes_stream`.
61
+ `closes_stream event_stream_id_from: :period, reopened_by: [MyApp.Events.PeriodReopened]` on an event type closes that stream scope when the event is appended; later events in the scope are refused. Options: `:dimensions`, `:event_stream_id_from`, `:reopened_by`, `:name`, `:event_sequences`; same-named declarations merge and must agree on dimensions. Registration closes nothing in history. Inspect closed scopes with `Cratis.Chronicle.EventSequences.Streams`. The in-memory test kernel does not model `closes_stream`.
62
62
 
63
63
  Constraint drift is not detected: the kernel cannot list registered constraints.
@@ -5,7 +5,7 @@
5
5
 
6
6
  Requires Chronicle.Elixir 3.14.2 for the rejection/cleanup behavior below; check `mix deps`, or upgrade before relying on a rejected callback to discard buffered events.
7
7
 
8
- A `Chronicle.decide/2` callback returning `{:error, reason}` rejects all buffered
8
+ A `Cratis.Chronicle.decide/2` callback returning `{:error, reason}` rejects all buffered
9
9
  appends and returns that tuple unchanged.
10
10
  Migrate matches on `{:ok, {:error, _}}` to `{:error, _}`. A failed commit rolls
11
11
  back the unit of work, and both `decide/2` and `with_unit_of_work/2` stop their
@@ -13,32 +13,32 @@ unit-of-work process on return, so later appends from long-lived GenServers or
13
13
  Phoenix connections are not trapped in a failed buffer. Spec the rejection and
14
14
  failed-commit paths, not only successful decisions.
15
15
 
16
- Source: `Cratis/Chronicle.Elixir`: `Source/chronicle/lib/chronicle/read_models/decision_reads.ex`, `decision_read_refused.ex`, `decision_conflict.ex`, `transactions/unit_of_work.ex`, and `Documentation/dynamic-consistency-boundary.md`.
16
+ Source: `Cratis/Chronicle.Elixir`: `Source/chronicle/lib/cratis/chronicle/read_models/decision_reads.ex`, `decision_read_refused.ex`, `decision_conflict.ex`, `transactions/unit_of_work.ex`, and `Documentation/dynamic-consistency-boundary.md`.
17
17
 
18
18
  Requires `cratis_chronicle` 3.13.0.
19
19
 
20
- Use a decision read when an append depends on state that a concurrent append could change (a seat can be booked once, a course has capacity). It folds a read model at a key in a fresh session and remembers the exact log position it stopped at; the commit is then rejected by the kernel if a matching event arrived since. An ordinary `Chronicle.read_model/3` followed by `append/3` is **not** a guard: it can silently act on stale state.
20
+ Use a decision read when an append depends on state that a concurrent append could change (a seat can be booked once, a course has capacity). It folds a read model at a key in a fresh session and remembers the exact log position it stopped at; the commit is then rejected by the kernel if a matching event arrived since. An ordinary `Cratis.Chronicle.read_model/3` followed by `append/3` is **not** a guard: it can silently act on stale state.
21
21
 
22
22
  ## Decide
23
23
 
24
24
  ```elixir
25
25
  result =
26
- Chronicle.decide(fn _unit_of_work ->
27
- {:ok, read} = Chronicle.ReadModels.DecisionReads.get(MyApp.ReadModels.Seat, "seat-5")
26
+ Cratis.Chronicle.decide(fn _unit_of_work ->
27
+ {:ok, read} = Cratis.Chronicle.ReadModels.DecisionReads.get(MyApp.ReadModels.Seat, "seat-5")
28
28
 
29
29
  if read.instance == nil do
30
- Chronicle.EventSequences.EventLog.append("seat-5", %MyApp.Events.SeatBooked{by: "alice"})
30
+ Cratis.Chronicle.EventSequences.EventLog.append("seat-5", %MyApp.Events.SeatBooked{by: "alice"})
31
31
  end
32
32
  end)
33
33
 
34
34
  case result do
35
35
  {:ok, _} -> :booked
36
- {:error, %Chronicle.ReadModels.DecisionConflict{}} -> :retry
36
+ {:error, %Cratis.Chronicle.ReadModels.DecisionConflict{}} -> :retry
37
37
  {:error, reason} -> {:error, reason}
38
38
  end
39
39
  ```
40
40
 
41
- - `Chronicle.decide/2` runs the function in a unit of work and commits on return. It returns `{:ok, result}`, or `{:error, %DecisionConflict{}}` when an enrolled decision read conflicted with a concurrent append; nothing from that attempt was written, so re-read and decide again. Other commit failures are plain `{:error, reason}`.
41
+ - `Cratis.Chronicle.decide/2` runs the function in a unit of work and commits on return. It returns `{:ok, result}`, or `{:error, %DecisionConflict{}}` when an enrolled decision read conflicted with a concurrent append; nothing from that attempt was written, so re-read and decide again. Other commit failures are plain `{:error, reason}`.
42
42
  - Unlike `with_unit_of_work/2`, `decide/2` never raises on a conflict. A concurrency violation without an enrolled decision read stays `{:error, {:concurrency_violations, _}}`.
43
43
  - **`DecisionReads.get/2` enrolls the read only inside a unit of work** (`decide/2` or `UnitOfWork.with_unit_of_work/2`). Outside one it returns `{:error, :requires_unit_of_work}`.
44
44
  - `DecisionReads.get_detached/2` folds the same way and enrolls nothing; use it for a read you do not intend to guard.
@@ -47,13 +47,13 @@ end
47
47
 
48
48
  ## Admission
49
49
 
50
- `DecisionReads.admit/2` and `admit_for_stream/2` check a model's shape without any I/O and return `{:ok, event_types}` or `{:error, reason}`. `get` and `get_detached` **raise** `Chronicle.ReadModels.DecisionReadRefused` for a refused shape, because that is a programming error. Refusal reasons: `:reducer` (an active reducer), `:join`, `:hierarchy` (`children/2`), `:not_event_log`, `:open_ended_event_types` (`from_every/1`), `:no_event_types`, `:not_event_source_keyed`, `:unsupported_event_type_id`, `:all_streams_not_supported`, `:stream_scope_not_supported`, `:fold_incomplete`.
50
+ `DecisionReads.admit/2` and `admit_for_stream/2` check a model's shape without any I/O and return `{:ok, event_types}` or `{:error, reason}`. `get` and `get_detached` **raise** `Cratis.Chronicle.ReadModels.DecisionReadRefused` for a refused shape, because that is a programming error. Refusal reasons: `:reducer` (an active reducer), `:join`, `:hierarchy` (`children/2`), `:not_event_log`, `:open_ended_event_types` (`from_every/1`), `:no_event_types`, `:not_event_source_keyed`, `:unsupported_event_type_id`, `:all_streams_not_supported`, `:stream_scope_not_supported`, `:fold_incomplete`.
51
51
 
52
- A model with `join/2`, `removed_with_join/2`, `children/2` or `from_every/1` cannot be guarded. A **passive** reducer (`use Chronicle.Reducers.Reducer, model: M, active: false`) can back a decision read because it is folded fresh on the client; an active reducer cannot.
52
+ A model with `join/2`, `removed_with_join/2`, `children/2` or `from_every/1` cannot be guarded. A **passive** reducer (`use Cratis.Chronicle.Reducers.Reducer, model: M, active: false`) can back a decision read because it is folded fresh on the client; an active reducer cannot.
53
53
 
54
54
  ## Explicit concurrency scopes
55
55
 
56
- When a plain guard on the tail is enough, use `Chronicle.Events.ConcurrencyScope` (`:concurrency_scope` append option) instead of a read model.
56
+ When a plain guard on the tail is enough, use `Cratis.Chronicle.Events.ConcurrencyScope` (`:concurrency_scope` append option) instead of a read model.
57
57
 
58
58
  | Need | Builder |
59
59
  | --- | --- |
@@ -67,7 +67,7 @@ When a plain guard on the tail is enough, use `Chronicle.Events.ConcurrencyScope
67
67
  ## Default optimistic strategy
68
68
 
69
69
  ```elixir
70
- {Chronicle.Client, ..., concurrency: [default: :optimistic, check_first_append: false]}
70
+ {Cratis.Chronicle.Client, ..., concurrency: [default: :optimistic, check_first_append: false]}
71
71
  ```
72
72
 
73
73
  By default an append with no explicit or definition-derived scope sends no guard. With `default: :optimistic` the client reads the tail, narrowed the way the append is routed, and expects nothing newer. `check_first_append: true` also guards the first append into an empty narrowing with `expecting_no_matching_event/1`. An explicit or definition-derived scope always wins.
@@ -3,13 +3,13 @@
3
3
 
4
4
  # Discovery, artifact identity and event generations
5
5
 
6
- Source: `Cratis/Chronicle.Elixir`: `Source/chronicle/lib/chronicle/discovery/`, `artifacts.ex`, `client.ex`, `events/event_type.ex`, `events/event_types.ex`, `reactors/reactor.ex`, `reducers/reducer.ex`, `lib/mix/tasks/chronicle.discover.ex`, and `Documentation/discovery.md`, `events.md`, `reactors.md`, `reducers.md`.
6
+ Source: `Cratis/Chronicle.Elixir`: `Source/chronicle/lib/cratis/chronicle/discovery/`, `artifacts.ex`, `client.ex`, `events/event_type.ex`, `events/event_types.ex`, `reactors/reactor.ex`, `reducers/reducer.ex`, `lib/mix/tasks/chronicle.discover.ex`, and `Documentation/discovery.md`, `events.md`, `reactors.md`, `reducers.md`.
7
7
 
8
8
  Requires `cratis_chronicle` 3.13.0.
9
9
 
10
10
  ## The discovery report
11
11
 
12
- `Chronicle.Client` builds a `%Chronicle.Discovery.Report{}` at start, logs a one-line summary at `:info` and the whole report at `:debug`. Read it with `Chronicle.Client.discovery_report()` and print it with `Chronicle.Discovery.Report.format/1`. `Chronicle.Artifacts.report(:my_app)` builds the same report without starting a client; `Chronicle.Artifacts.discover/1` still returns its plain map.
12
+ `Cratis.Chronicle.Client` builds a `%Cratis.Chronicle.Discovery.Report{}` at start, logs a one-line summary at `:info` and the whole report at `:debug`. Read it with `Cratis.Chronicle.Client.discovery_report()` and print it with `Cratis.Chronicle.Discovery.Report.format/1`. `Cratis.Chronicle.Artifacts.report(:my_app)` builds the same report without starting a client; `Cratis.Chronicle.Artifacts.discover/1` still returns its plain map.
13
13
 
14
14
  Run it from the shell with `mix chronicle.discover --otp-app my_app`; add `--connection-string "chronicle://..."` to compare against a kernel (event store `"default"`, namespace `"Default"`) and `--fail-on-drift` to exit `1` on a warning-severity finding. Exit codes: `0` clean, `1` drift found, `2` could not run (no `--otp-app`, or kernel unreachable). `--fail-on-drift` has no effect without `--connection-string`.
15
15
 
@@ -18,11 +18,11 @@ Run it from the shell with `mix chronicle.discover --otp-app my_app`; add `--con
18
18
  A reactor, reducer or declarative projection with no `:id` defaults it from its module name (reactors and reducers: the full module name; projections: the last segment). **Renaming or moving the module then creates a different artifact and silently resets its observation position.** Pin it:
19
19
 
20
20
  ```elixir
21
- use Chronicle.Reactors.Reactor, id: "notification-reactor"
22
- use Chronicle.Projections.Projection, id: "account-summary", model: MyApp.ReadModels.AccountSummary
21
+ use Cratis.Chronicle.Reactors.Reactor, id: "notification-reactor"
22
+ use Cratis.Chronicle.Projections.Projection, id: "account-summary", model: MyApp.ReadModels.AccountSummary
23
23
  ```
24
24
 
25
- Discovery logs a warning once per module per BEAM node for a defaulted id. `warn_defaulted_ids: false` on `Chronicle.Client` suppresses it; prefer pinning. In-memory test clients skip it.
25
+ Discovery logs a warning once per module per BEAM node for a defaulted id. `warn_defaulted_ids: false` on `Cratis.Chronicle.Client` suppresses it; prefer pinning. In-memory test clients skip it.
26
26
 
27
27
  ## Drift policy
28
28
 
@@ -34,7 +34,7 @@ Before registering, the client compares what it would register with the kernel.
34
34
  | `:fail` | Log findings and refuse to register on a `:warning`-severity finding |
35
35
  | `:ignore` | Skip the check and its kernel calls |
36
36
 
37
- Findings: `:schema_changed_without_generation` (an event type generation's coarse shape changed: added, removed or retyped field), `:observer_missing_from_code` (always `:info`, never blocks: other clients may own the observer), `:observer_event_types_changed` (a reactor's handled types differ; `:warning`). An indeterminate check (kernel unreachable, exception, 5 s deadline) continues under `:warn` and stops under `:fail`. Read the current findings with `Chronicle.Client.identity_drift()`. The kernel rejects a schema change without a bumped generation itself, regardless of policy.
37
+ Findings: `:schema_changed_without_generation` (an event type generation's coarse shape changed: added, removed or retyped field), `:observer_missing_from_code` (always `:info`, never blocks: other clients may own the observer), `:observer_event_types_changed` (a reactor's handled types differ; `:warning`). An indeterminate check (kernel unreachable, exception, 5 s deadline) continues under `:warn` and stops under `:fail`. Read the current findings with `Cratis.Chronicle.Client.identity_drift()`. The kernel rejects a schema change without a bumped generation itself, regardless of policy.
38
38
 
39
39
  ## Event type generations
40
40
 
@@ -42,15 +42,15 @@ A module for an **older** generation uses `generation_for:` instead of its own `
42
42
 
43
43
  ```elixir
44
44
  defmodule MyApp.Events.CustomerRegisteredV1 do
45
- use Chronicle.Events.EventType, generation_for: MyApp.Events.CustomerRegistered, generation: 1
45
+ use Cratis.Chronicle.Events.EventType, generation_for: MyApp.Events.CustomerRegistered, generation: 1
46
46
  defstruct customer_id: "", owner_name: ""
47
47
  end
48
48
  ```
49
49
 
50
- `generation_for:` requires an explicit `generation:` and cannot be combined with `:id`. Bridge the generations with `Chronicle.Events.Migration` (exactly one migrator per pair).
50
+ `generation_for:` requires an explicit `generation:` and cannot be combined with `:id`. Bridge the generations with `Cratis.Chronicle.Events.Migration` (exactly one migrator per pair).
51
51
 
52
- Mistakes such as two modules for one id and generation, two migrators for a pair, or `generation_for:` naming a module that is not an event type are logged and the client continues. Set `strict_validation: true` on `Chronicle.Client` to raise instead; `Chronicle.Events.EventTypes.validate/2` returns `:ok | {:error, exception}` and `validate!/2` raises.
52
+ Mistakes such as two modules for one id and generation, two migrators for a pair, or `generation_for:` naming a module that is not an event type are logged and the client continues. Set `strict_validation: true` on `Cratis.Chronicle.Client` to raise instead; `Cratis.Chronicle.Events.EventTypes.validate/2` returns `:ok | {:error, exception}` and `validate!/2` raises.
53
53
 
54
54
  ## Pinned generation delivery
55
55
 
56
- By default (`:compatibility`) every event is upgraded to the generation of the module a reactor or reducer handles. For a handler written against an **older** generation, `use Chronicle.Reactors.Reactor, generation_delivery: :pinned` (or the same on a reducer) delivers the event as appended. `context.appended_generation` reports the appended generation (`0` means unknown). The client-wide default is `event_generation_delivery: :pinned`; an artifact's own option wins. A pinned observer that handles two generations of one event type raises `Chronicle.Observers.MultipleGenerationsOfEventTypeInObserver` on start.
56
+ By default (`:compatibility`) every event is upgraded to the generation of the module a reactor or reducer handles. For a handler written against an **older** generation, `use Cratis.Chronicle.Reactors.Reactor, generation_delivery: :pinned` (or the same on a reducer) delivers the event as appended. `context.appended_generation` reports the appended generation (`0` means unknown). The client-wide default is `event_generation_delivery: :pinned`; an artifact's own option wins. A pinned observer that handles two generations of one event type raises `Cratis.Chronicle.Observers.MultipleGenerationsOfEventTypeInObserver` on start.
@@ -3,7 +3,7 @@
3
3
 
4
4
  # Event sources and streams
5
5
 
6
- Source: `Cratis/Chronicle.Elixir`: `Source/chronicle/lib/chronicle/event_sources/event_source.ex`, `event_sources/routing.ex`, `event_sequences/definition_routing.ex`, and `Documentation/event-sources.md`.
6
+ Source: `Cratis/Chronicle.Elixir`: `Source/chronicle/lib/cratis/chronicle/event_sources/event_source.ex`, `event_sources/routing.ex`, `event_sequences/definition_routing.ex`, and `Documentation/event-sources.md`.
7
7
 
8
8
  Requires `cratis_chronicle` 3.10.0 and Chronicle kernel 19.30.0 for definitions.
9
9
 
@@ -14,7 +14,7 @@ An event source definition gives appends a stable name, optional streams and def
14
14
  # Licensed under the MIT license. See LICENSE file in the project root for full license information.
15
15
 
16
16
  defmodule MyApp.AccountEventSource do
17
- use Chronicle.EventSources.EventSource,
17
+ use Cratis.Chronicle.EventSources.EventSource,
18
18
  name: "Account",
19
19
  description: "A bank account",
20
20
  concurrency: [:event_source_id]
@@ -26,16 +26,16 @@ defmodule MyApp.AccountEventSource do
26
26
  end
27
27
  ```
28
28
 
29
- `:name` defaults to the last module segment without a trailing `EventSource`. Dimensions are `:event_source_id`, `:event_source_type`, `:event_stream_type`, `:event_stream_id`. A stream with no dimensions inherits its source's dimensions. Duplicate stream names fail compilation; duplicate source names raise `Chronicle.EventSources.DuplicateEventSourceName` at client startup.
29
+ `:name` defaults to the last module segment without a trailing `EventSource`. Dimensions are `:event_source_id`, `:event_source_type`, `:event_stream_type`, `:event_stream_id`. A stream with no dimensions inherits its source's dimensions. Duplicate stream names fail compilation; duplicate source names raise `Cratis.Chronicle.EventSources.DuplicateEventSourceName` at client startup.
30
30
 
31
31
  ## Register and append
32
32
 
33
- Set `otp_app:` so discovery finds the definition, or pass `event_sources: [MyApp.AccountEventSource]` to `Chronicle.Client`. Definitions register after event types and before observers on every reconnect. Registration is an upsert; omitting a definition later does not delete it from the kernel.
33
+ Set `otp_app:` so discovery finds the definition, or pass `event_sources: [MyApp.AccountEventSource]` to `Cratis.Chronicle.Client`. Definitions register after event types and before observers on every reconnect. Registration is an upsert; omitting a definition later does not delete it from the kernel.
34
34
 
35
35
  With the client registered and the `MyApp.Events.FundsDeposited` event from the skill declared:
36
36
 
37
37
  ```elixir
38
- case Chronicle.append("account-1", %MyApp.Events.FundsDeposited{amount: 50},
38
+ case Cratis.Chronicle.append("account-1", %MyApp.Events.FundsDeposited{amount: 50},
39
39
  event_source: MyApp.AccountEventSource,
40
40
  event_stream: "Transactions",
41
41
  event_stream_id: "2024-05"
@@ -47,7 +47,7 @@ end
47
47
 
48
48
  The source name becomes the event source type and event `EventSource` metadata; the stream name becomes the event stream type. Sources can be modules or names. Without `:event_stream`, the stream type is `"All"`. `append_many/3` and units of work accept the same source/stream options.
49
49
 
50
- Each `Chronicle.EventSequences.EventForEventSourceId` can carry `event_source` and `event_stream`. In `append_many_for_event_sources/2`, entry-level routing wins; batch defaults fill only entries with no source. A routing rejection prevents the whole batch from being sent.
50
+ Each `Cratis.Chronicle.EventSequences.EventForEventSourceId` can carry `event_source` and `event_stream`. In `append_many_for_event_sources/2`, entry-level routing wins; batch defaults fill only entries with no source. A routing rejection prevents the whole batch from being sent.
51
51
 
52
52
  | Reason inside `{:error, reason}` | Cause |
53
53
  | --- | --- |
@@ -59,7 +59,7 @@ Each `Chronicle.EventSequences.EventForEventSourceId` can carry `event_source` a
59
59
 
60
60
  ## Default concurrency is not an explicit decision guard
61
61
 
62
- Without an explicit `:concurrency_scope`, the client reads the tail narrowed by the effective definition dimensions and uses that sequence number as a scope. With no dimensions, it sends no scope. Explicit scopes, including `Chronicle.Events.ConcurrencyScope.none()`, win and avoid that read. Do not disable a guard just to silence a rejection; choose a scope that protects the business decision's reads.
62
+ Without an explicit `:concurrency_scope`, the client reads the tail narrowed by the effective definition dimensions and uses that sequence number as a scope. With no dimensions, it sends no scope. Explicit scopes, including `Cratis.Chronicle.Events.ConcurrencyScope.none()`, win and avoid that read. Do not disable a guard just to silence a rejection; choose a scope that protects the business decision's reads.
63
63
 
64
64
  The wire carries one scope per event source id. Guarded entries of that id must agree on dimensions and selected source type, stream type and stream id. Unguarded entries never suppress a later guarded entry. Incompatible derived guards fail before any tail read or append; use separate batches, or deliberately supply one explicit scope on an entry for that id.
65
65
 
@@ -13,22 +13,22 @@
13
13
 
14
14
  ```elixir
15
15
  defmodule MyApp.Graphs.Person do
16
- use Chronicle.Graphs.Node
16
+ use Cratis.Chronicle.Graphs.Node
17
17
  defstruct person_id: "", name: ""
18
18
  end
19
19
 
20
20
  defmodule MyApp.Graphs.Group do
21
- use Chronicle.Graphs.Node
21
+ use Cratis.Chronicle.Graphs.Node
22
22
  defstruct group_id: "", name: ""
23
23
  end
24
24
 
25
25
  defmodule MyApp.Graphs.MemberOf do
26
- use Chronicle.Graphs.Edge, type: "MEMBER_OF"
26
+ use Cratis.Chronicle.Graphs.Edge, type: "MEMBER_OF"
27
27
  defstruct since: ""
28
28
  end
29
29
 
30
30
  defmodule MyApp.Graphs.Organization do
31
- use Chronicle.Graphs.Graph, id: "Organization"
31
+ use Cratis.Chronicle.Graphs.Graph, id: "Organization"
32
32
 
33
33
  node MyApp.Graphs.Person, key: :person_id do
34
34
  from MyApp.Events.PersonRegistered, key: :person_id, set: [name: :name]
@@ -105,7 +105,7 @@ identity; or a mapped field, option or module is unknown.
105
105
  ## Registering and choosing the sink
106
106
 
107
107
  ```elixir
108
- {Chronicle.Client,
108
+ {Cratis.Chronicle.Client,
109
109
  connection_string: "chronicle://localhost:35000",
110
110
  event_store: "my-store",
111
111
  default_graph_sink_type_id: :in_memory_graph,
@@ -119,5 +119,5 @@ and tests. `:default_sink_type_id` still chooses the sink of document read model
119
119
 
120
120
  ## Not supported yet
121
121
 
122
- The client does not read a graph (use the engine driver) and `Chronicle.Testing` has no
122
+ The client does not read a graph (use the engine driver) and `Cratis.Chronicle.Testing` has no
123
123
  graph scenario, so test a graph by asserting the definition it registers.
@@ -4,12 +4,12 @@ This reference holds process-scoped context, discovery and formatter notes, watc
4
4
 
5
5
  ## Operational inspection
6
6
 
7
- `Chronicle.Observers.get_all/1` lists namespace observers; `remove/2` removes an
7
+ `Cratis.Chronicle.Observers.get_all/1` lists namespace observers; `remove/2` removes an
8
8
  orphaned observer across the store, refuses running/subscribed observers in any
9
9
  namespace, and leaves read model data intact (`observers.ex`). Obtain
10
10
  explicit authority before removal and inspect `RemovalResult.outcome` —
11
- `{:ok, result}` alone does not mean removed. `Chronicle.FailedPartitions` and
12
- `Chronicle.Jobs` provide failure/job inspection; `Jobs.get/2` lists then finds
11
+ `{:ok, result}` alone does not mean removed. `Cratis.Chronicle.FailedPartitions` and
12
+ `Cratis.Chronicle.Jobs` provide failure/job inspection; `Jobs.get/2` lists then finds
13
13
  client-side. Observer types include `:reactor`, `:projection`, `:reducer`,
14
14
  `:external`; states include `:active`, `:suspended`, `:replaying`, `:disconnected`,
15
15
  `:quarantined` and `:unknown`.
@@ -17,9 +17,9 @@ client-side. Observer types include `:reactor`, `:projection`, `:reducer`,
17
17
  ## Idioms worth knowing
18
18
 
19
19
  - **Process-scoped context.** Correlation id, identity, and causation are held per
20
- process: `Chronicle.current_correlation_id/0`, `set_correlation_id/1`,
20
+ process: `Cratis.Chronicle.current_correlation_id/0`, `set_correlation_id/1`,
21
21
  `clear_correlation_id/0`; `current_identity/0`, `set_identity/1`,
22
- `clear_identity/0`; `Chronicle.Auditing.CausationManager`. They are picked up
22
+ `clear_identity/0`; `Cratis.Chronicle.Auditing.CausationManager`. They are picked up
23
23
  automatically on append. **A `Task` is a different process** and does not
24
24
  inherit them.
25
25
  - **Discovery is compile-time reflection.** The `use` macros generate
@@ -3,7 +3,7 @@
3
3
 
4
4
  # Observability: OpenTelemetry and `:telemetry`
5
5
 
6
- Source: `Cratis/Chronicle.Elixir`: `Source/chronicle/lib/chronicle/diagnostics/tracing.ex`, `connections/trace_propagation_interceptor.ex`, and `Documentation/observability.md`.
6
+ Source: `Cratis/Chronicle.Elixir`: `Source/chronicle/lib/cratis/chronicle/diagnostics/tracing.ex`, `connections/trace_propagation_interceptor.ex`, and `Documentation/observability.md`.
7
7
 
8
8
  Requires `cratis_chronicle` 3.13.0.
9
9
 
@@ -34,4 +34,4 @@ The `:stop` metadata carries `error: true` when the operation returned `{:error,
34
34
 
35
35
  ## Trace propagation
36
36
 
37
- Every outbound gRPC call carries W3C `traceparent`/`tracestate` for the span active in the **calling process**, injected by `Chronicle.Connections.TracePropagationInterceptor` (always installed). A trace continues into the kernel only when the append or query runs inside the active span (for example inside `OpenTelemetry.Tracer.with_span/2`); a `Task` is a different process. The kernel does not store trace context on events, so an observer's span is not linked to the append that caused it. OpenTelemetry metrics instruments are not emitted, only `:telemetry` events.
37
+ Every outbound gRPC call carries W3C `traceparent`/`tracestate` for the span active in the **calling process**, injected by `Cratis.Chronicle.Connections.TracePropagationInterceptor` (always installed). A trace continues into the kernel only when the append or query runs inside the active span (for example inside `OpenTelemetry.Tracer.with_span/2`); a `Task` is a different process. The kernel does not store trace context on events, so an observer's span is not linked to the append that caused it. OpenTelemetry metrics instruments are not emitted, only `:telemetry` events.
@@ -3,20 +3,20 @@
3
3
 
4
4
  # Behavior patterns
5
5
 
6
- Source: `Cratis/Chronicle.Elixir`: `Source/chronicle/lib/chronicle/patterns.ex` and `Documentation/patterns.md`.
6
+ Source: `Cratis/Chronicle.Elixir`: `Source/chronicle/lib/cratis/chronicle/patterns.ex` and `Documentation/patterns.md`.
7
7
 
8
8
  Requires `cratis_chronicle` 3.13.0.
9
9
 
10
- `Chronicle.Patterns` queries the recurring behavior (combinations of facets such as `Day`, `TimeBucket`, `CommandType`, `AggregateType`) that Chronicle mined from an event store's history for a scope, for example one user. **An empty result is an answer, not a failure**: the scope has no established behavior for that context. Treat it as "do not claim to know".
10
+ `Cratis.Chronicle.Patterns` queries the recurring behavior (combinations of facets such as `Day`, `TimeBucket`, `CommandType`, `AggregateType`) that Chronicle mined from an event store's history for a scope, for example one user. **An empty result is an answer, not a failure**: the scope has no established behavior for that context. Treat it as "do not claim to know".
11
11
 
12
12
  ```elixir
13
- {:ok, patterns} = Chronicle.Patterns.get_patterns_at("user-42")
14
- {:ok, patterns} = Chronicle.Patterns.get_patterns_at("user-42", moment, also_constraining: %{Chronicle.Patterns.FacetName.aggregate_type() => "Invoice"})
15
- action = pattern.facets[Chronicle.Patterns.FacetName.command_type()]
13
+ {:ok, patterns} = Cratis.Chronicle.Patterns.get_patterns_at("user-42")
14
+ {:ok, patterns} = Cratis.Chronicle.Patterns.get_patterns_at("user-42", moment, also_constraining: %{Cratis.Chronicle.Patterns.FacetName.aggregate_type() => "Invoice"})
15
+ action = pattern.facets[Cratis.Chronicle.Patterns.FacetName.command_type()]
16
16
  ```
17
17
 
18
18
  - Default to `get_patterns_at/3` ("what does this scope usually do now"). It derives `Day` and `TimeBucket` from the moment's **own offset**, not UTC, with the rule the kernel mined with; the moment defaults to now.
19
19
  - Use `get_patterns/3` and `get_usual_actions/3` only for a hand-built facet map; `get_usual_actions/3` returns at most one answer per action.
20
20
  - `get_patterns_for_scope/2` and `get_scopes/1` inspect what has been mined.
21
- - `Chronicle.Patterns.time_bucket/1` exposes the kernel's part-of-day rule (`:early_morning`, `:morning`, `:midday`, `:afternoon`, `:evening`, `:night`). **Never write a copy**: a slot the mining never used looks exactly like "nothing established".
21
+ - `Cratis.Chronicle.Patterns.time_bucket/1` exposes the kernel's part-of-day rule (`:early_morning`, `:morning`, `:midday`, `:afternoon`, `:evening`, `:night`). **Never write a copy**: a slot the mining never used looks exactly like "nothing established".
22
22
  - Options on every call: `:client`, `:namespace`, `:minimum_confidence` (0.0 to 1.0) and `:max_results`. The all-patterns query is not exposed.
@@ -8,13 +8,13 @@ Source: `Cratis/Chronicle.Elixir`.
8
8
  | Pitfall | Why it bites |
9
9
  | --- | --- |
10
10
  | Copying an older root README | Its module names may not exist; use namespaced `Chronicle.*` modules |
11
- | Using `Chronicle.Concept` on a client that lacks it | Annotate fields with `pii/1,2` instead |
11
+ | Using `Cratis.Chronicle.Concept` on a client that lacks it | Annotate fields with `pii/1,2` instead |
12
12
  | Combining `pii` and `encrypted` | The same leaf raises `PiiAndEncryptedCombinedNotSupported`; neither is allowed on an `event_source_id: true` concept |
13
13
  | Quoting the `VERSION` file | It is a build-time placeholder |
14
14
  | Putting options only in `config.exs` | The client reads no application env; your app must pass child-spec keyword options |
15
15
  | Omitting `:otp_app` | Discovery falls back to scanning every loaded module |
16
16
  | Assuming the namespace default is `"default"` | It is `"Default"`; the moduledoc is wrong |
17
- | `:ok = Chronicle.append(...)` in a server | A constraint violation returns `{:error, _}` and raises `MatchError` |
17
+ | `:ok = Cratis.Chronicle.append(...)` in a server | A constraint violation returns `{:error, _}` and raises `MatchError` |
18
18
  | Waiting for `:connected` | Observers attach at `:registered` |
19
19
  | Reading `:correlation_id` or `:caused_by` from the context of an older client | It was a bare six-key map before the `EventContext` struct; see the upgrading reference |
20
20
  | Two read models with the same final module segment | The default id is the last segment only |
@@ -23,9 +23,9 @@ Source: `Cratis/Chronicle.Elixir`.
23
23
  | Shipping the default TLS behavior | `skip_tls_validation` defaults to `true` |
24
24
  | Forgetting `global_handlers:` or `:otp_app` discovery | Shared mappings are not merged into variants unless registered |
25
25
  | A shared handler mapping a field one variant lacks | `GlobalHandlerPropertyNotOnVariant` at registration, not a silently skipped mapping |
26
- | `DecisionReads.get/2` outside `Chronicle.decide/2` | Returns `{:error, :requires_unit_of_work}`; it guards nothing |
26
+ | `DecisionReads.get/2` outside `Cratis.Chronicle.decide/2` | Returns `{:error, :requires_unit_of_work}`; it guards nothing |
27
27
  | Unset expected sequence number as "expect no event" | It disables the check; use `ConcurrencyScope.expecting_no_matching_event/1` |
28
- | Passing no `client: client` in a `Chronicle.Testing.Case` spec | The call addresses the default client, not the test's |
28
+ | Passing no `client: client` in a `Cratis.Chronicle.Testing.Case` spec | The call addresses the default client, not the test's |
29
29
  | Trusting a spec that passed on the in-memory kernel | Queries, projections and `closes_stream` return `{:error, {:not_supported_in_memory, rpc}}`; use `Testing.Integration` |
30
30
  | Renaming a reactor, reducer or projection module without a pinned `:id` | Its observation position silently resets |
31
31
  | Capture event type ids with hyphens | `append/2,3` needs an uppercase-first, letters-digits-underscore id |
@@ -3,9 +3,9 @@
3
3
 
4
4
  # Projection options and keys
5
5
 
6
- Source: `Cratis/Chronicle.Elixir`: `Source/chronicle/lib/chronicle/read_models/read_model.ex`, `projections/projection.ex`, and `registration/coordinator.ex`.
6
+ Source: `Cratis/Chronicle.Elixir`: `Source/chronicle/lib/cratis/chronicle/read_models/read_model.ex`, `projections/projection.ex`, and `registration/coordinator.ex`.
7
7
 
8
- `use Chronicle.ReadModels.ReadModel` accepts `id:`, `passive: true`, `not_rewindable: true`, and `event_sequence: "sequence-name"`. Defaults are the last module segment as id, active, rewindable, and `"event-log"`. Standalone `Chronicle.Projections.Projection` also accepts sequence/rewindability options and requires `model:`.
8
+ `use Cratis.Chronicle.ReadModels.ReadModel` accepts `id:`, `passive: true`, `not_rewindable: true`, and `event_sequence: "sequence-name"`. Defaults are the last module segment as id, active, rewindable, and `"event-log"`. Standalone `Cratis.Chronicle.Projections.Projection` also accepts sequence/rewindability options and requires `model:`.
9
9
 
10
10
  AutoMap maps matching event/model properties by default. `no_auto_map()` disables it for the whole projection; `no_auto_map([:balance, :status])` excludes only those properties so explicit mappings can own them.
11
11
 
@@ -22,7 +22,7 @@ This module excerpt assumes a registered `MyApp.Events.AccountOpened` event. The
22
22
  # Licensed under the MIT license. See LICENSE file in the project root for full license information.
23
23
 
24
24
  defmodule MyApp.ReadModels.WeeklyAccountOpenings do
25
- use Chronicle.ReadModels.ReadModel
25
+ use Cratis.Chronicle.ReadModels.ReadModel
26
26
  defstruct transaction_count: 0
27
27
 
28
28
  from(MyApp.Events.AccountOpened,
@@ -55,7 +55,7 @@ from_every(increment: [event_counts: {:event_context, :type}])
55
55
 
56
56
  Requires `cratis_chronicle` 3.13.0 for the one-line form, `removed_with_join/2`, `clear_with/2` and the compile-time checks below; `children/2,3` itself requires 3.11.0.
57
57
 
58
- `children/2,3` declares a list on the parent that grows, changes and shrinks with events. It works in `use Chronicle.ReadModels.ReadModel` and `use Chronicle.Projections.Projection`; declare the list field's element type with `types: [items: {:list, MyApp.ReadModels.BasketItem}]`.
58
+ `children/2,3` declares a list on the parent that grows, changes and shrinks with events. It works in `use Cratis.Chronicle.ReadModels.ReadModel` and `use Cratis.Chronicle.Projections.Projection`; declare the list field's element type with `types: [items: {:list, MyApp.ReadModels.BasketItem}]`.
59
59
 
60
60
  ```elixir
61
61
  children :items, identified_by: :item_id do
@@ -4,7 +4,7 @@ This reference holds a worked reactor module and a worked model-bound read model
4
4
 
5
5
  ```elixir
6
6
  defmodule MyApp.Reactors.DepositLogger do
7
- use Chronicle.Reactors.Reactor
7
+ use Cratis.Chronicle.Reactors.Reactor
8
8
  require Logger
9
9
 
10
10
  alias MyApp.Events.FundsDeposited
@@ -22,7 +22,7 @@ end
22
22
 
23
23
  ```elixir
24
24
  defmodule MyApp.ReadModels.AccountBalance do
25
- use Chronicle.ReadModels.ReadModel
25
+ use Cratis.Chronicle.ReadModels.ReadModel
26
26
  defstruct id: "", balance: 0
27
27
 
28
28
  from(MyApp.Events.FundsDeposited,