@cratis/pi 7.135.0 → 7.136.1
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.
- package/package/corpus/harnesses/copilot/instructions/profiles.instructions.md +3 -1
- package/package/corpus/product-sync.json +26 -0
- package/package/corpus/rules/issue-assignment.md +2 -0
- package/package/corpus/rules/profiles.md +3 -1
- package/package/corpus/skills/cratis-arc-elixir/LICENSE +2 -0
- package/package/corpus/skills/cratis-arc-elixir/SKILL.md +117 -0
- package/package/corpus/skills/cratis-arc-elixir/references/commands-and-queries.md +64 -0
- package/package/corpus/skills/cratis-arc-elixir/references/hosting-and-testing.md +46 -0
- package/package/corpus/skills/cratis-arc-elixir/references/mongodb.md +79 -0
- package/package/corpus/skills/cratis-arc-elixir/references/observable-queries-and-hubs.md +54 -0
- package/package/corpus/skills/cratis-arc-elixir/references/pitfalls.md +25 -0
- package/package/corpus/skills/cratis-arc-elixir/references/product-sources.md +14 -0
- package/package/corpus/skills/cratis-arc-elixir/references/proxies-and-vertical-slices.md +55 -0
- package/package/corpus/skills/cratis-arc-elixir/references/tenancy-and-identity.md +55 -0
- package/package/corpus/skills/cratis-arc-elixir/verification.json +57 -0
- package/package/corpus/skills/cratis-engineering-issue-design-note/SKILL.md +2 -1
- package/package/corpus/skills/cratis-engineering-issue-hygiene/SKILL.md +5 -2
- package/package/profile-catalog.json +15 -0
- package/package.json +1 -1
|
@@ -59,7 +59,7 @@ The complete list of available profiles is defined in [profile-catalog.json](../
|
|
|
59
59
|
| `cratis/application/arc-chronicle` | Arc + Chronicle integration | `cratis/arc/core`, `cratis/chronicle/core`, `cratis/fundamentals`, `cratis/screenplay`, `cratis/specifications/dotnet` |
|
|
60
60
|
| `cratis/application/arc-only` | Arc without Chronicle | `cratis/arc/core`, `cratis/fundamentals`, `cratis/screenplay`, `cratis/specifications/dotnet` |
|
|
61
61
|
| `cratis/application/chronicle-dotnet` | Chronicle .NET client | `cratis/chronicle/client-dotnet`, `cratis/chronicle/core`, `cratis/fundamentals`, `cratis/screenplay`, `cratis/specifications/dotnet` |
|
|
62
|
-
| `cratis/application/elixir` | Elixir Chronicle client | `cratis/chronicle/client-elixir`, `cratis/language/elixir`, `cratis/screenplay` |
|
|
62
|
+
| `cratis/application/elixir` | Elixir Arc and Chronicle client | `cratis/arc/elixir`, `cratis/chronicle/client-elixir`, `cratis/language/elixir`, `cratis/screenplay` |
|
|
63
63
|
| `cratis/application/kotlin` | Kotlin Arc + Chronicle application | `cratis/arc/client-kotlin`, `cratis/chronicle/client-kotlin`, `cratis/language/kotlin`, `cratis/screenplay` |
|
|
64
64
|
| `cratis/application/java` | Java Arc + Chronicle application | `cratis/arc/client-kotlin`, `cratis/chronicle/client-java`, `cratis/language/java`, `cratis/screenplay` |
|
|
65
65
|
|
|
@@ -76,6 +76,7 @@ profile includes neither Screenplay nor Stage.
|
|
|
76
76
|
| `cratis/chronicle` | Chronicle event sourcing engine (does not compose `cratis/chronicle/mcp`) | `cratis/chronicle/compliance`, `cratis/chronicle/csharp`, `cratis/chronicle/elixir`, `cratis/chronicle/java`, `cratis/chronicle/kotlin`, `cratis/chronicle/multi-tenancy`, `cratis/chronicle/typescript`, `cratis/chronicle/web-workbench` |
|
|
77
77
|
| `cratis/components` | React component library, including `cratis-components-common-controls` and `cratis-components-data-surfaces` | (no child profiles) |
|
|
78
78
|
| `cratis/fundamentals` | Core primitives and generated .NET telemetry (`cratis-fundamentals-telemetry`) | (no child profiles) |
|
|
79
|
+
| `cratis/arc/elixir` | Arc for Elixir (source preview): commands, queries, SSE and WebSocket hubs, tenancy, MongoDB, proxies | `cratis/chronicle/client-elixir`, `cratis/language/elixir` |
|
|
79
80
|
| `cratis/arc/go` | Experimental Arc.Go HTTP CQRS (root module) | `cratis/language/go`, `cratis/fundamentals/go` |
|
|
80
81
|
| `cratis/chronicle/client-go` | Experimental standalone Chronicle.Go client | `cratis/language/go`, `cratis/fundamentals/go` |
|
|
81
82
|
| `cratis/fundamentals/go` | Fundamentals.Go named scalar concepts and codecs | `cratis/language/go` |
|
|
@@ -194,6 +195,7 @@ corpus's harness setup or Pi package.
|
|
|
194
195
|
| Profile | Skill | Verified experimental version |
|
|
195
196
|
| --- | --- | --- |
|
|
196
197
|
| `cratis/chronicle/client-go` | `cratis-chronicle-client-go` | Chronicle.Go v0.9.1 (Chronicle kernel 19.32.3 profile) |
|
|
198
|
+
| `cratis/arc/elixir` | `cratis-arc-elixir` | Arc for Elixir source preview (`cratis_arc`, `cratis_arc_mongodb`) |
|
|
197
199
|
| `cratis/arc/go` | `cratis-arc-go` | Arc.Go v0.1.1 |
|
|
198
200
|
| `cratis/fundamentals/go` | `cratis-fundamentals-concept-go` | Fundamentals.Go v0.3.2 |
|
|
199
201
|
|
|
@@ -325,6 +325,32 @@
|
|
|
325
325
|
},
|
|
326
326
|
"notes": "Reviewed all 60 stable releases 19.82.0-19.110.1 against tagged v19.110.1 source: append uncertainty and constraint-index repair, .NET keyed appends and multi-scope guards, request completion ownership, concurrent reactor/reducer partitions and returned-event receipts, projection replay/upgrade repairs, seeded scenarios, SQL/composite indexes, SQL membership/schema ownership, Localhost single-writer fencing, health probes, Azure identity/Key Vault purge, webhook target validation/retries/managed identity/real-delivery probes, and disabled-by-default projection-generation groundwork. 19.110.0 .NET packages were not published; use 19.110.1. Other covered skills were reviewed for release relevance without mechanical changes. Existing protected-read guidance retained. No new kernel/transport probe or capability."
|
|
327
327
|
},
|
|
328
|
+
{
|
|
329
|
+
"id": "arc-elixir",
|
|
330
|
+
"name": "Arc.Elixir",
|
|
331
|
+
"repository": "Cratis/Arc.Elixir",
|
|
332
|
+
"packages": [
|
|
333
|
+
{
|
|
334
|
+
"ecosystem": "hex",
|
|
335
|
+
"id": "cratis_arc"
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
"ecosystem": "hex",
|
|
339
|
+
"id": "cratis_arc_mongodb"
|
|
340
|
+
}
|
|
341
|
+
],
|
|
342
|
+
"synced": null,
|
|
343
|
+
"covers": {
|
|
344
|
+
"skills": [
|
|
345
|
+
"cratis-arc-elixir"
|
|
346
|
+
],
|
|
347
|
+
"rules": [
|
|
348
|
+
"elixir.md"
|
|
349
|
+
]
|
|
350
|
+
},
|
|
351
|
+
"coverage": "tracked",
|
|
352
|
+
"notes": "Initial skill for the source preview (Cratis/Arc.Elixir#11): commands, queries, SSE and WebSocket hubs with delta transfer, tenancy, filters, MongoDB, identity, proxies and vertical slices. Not yet published to Hex: pin a git ref."
|
|
353
|
+
},
|
|
328
354
|
{
|
|
329
355
|
"id": "arc-go",
|
|
330
356
|
"name": "Arc.Go",
|
|
@@ -12,3 +12,5 @@ the issue authorizes this claim only, not comments, labels or closure; follow
|
|
|
12
12
|
[pull-requests.md](./pull-requests.md) and the user's request for those.
|
|
13
13
|
|
|
14
14
|
Assign each PR you open to the same user: `gh pr create --assignee @me`.
|
|
15
|
+
|
|
16
|
+
Issues stay generic: never name a customer or a customer's customer.
|
|
@@ -58,7 +58,7 @@ The complete list of available profiles is defined in [profile-catalog.json](../
|
|
|
58
58
|
| `cratis/application/arc-chronicle` | Arc + Chronicle integration | `cratis/arc/core`, `cratis/chronicle/core`, `cratis/fundamentals`, `cratis/screenplay`, `cratis/specifications/dotnet` |
|
|
59
59
|
| `cratis/application/arc-only` | Arc without Chronicle | `cratis/arc/core`, `cratis/fundamentals`, `cratis/screenplay`, `cratis/specifications/dotnet` |
|
|
60
60
|
| `cratis/application/chronicle-dotnet` | Chronicle .NET client | `cratis/chronicle/client-dotnet`, `cratis/chronicle/core`, `cratis/fundamentals`, `cratis/screenplay`, `cratis/specifications/dotnet` |
|
|
61
|
-
| `cratis/application/elixir` | Elixir Chronicle client | `cratis/chronicle/client-elixir`, `cratis/language/elixir`, `cratis/screenplay` |
|
|
61
|
+
| `cratis/application/elixir` | Elixir Arc and Chronicle client | `cratis/arc/elixir`, `cratis/chronicle/client-elixir`, `cratis/language/elixir`, `cratis/screenplay` |
|
|
62
62
|
| `cratis/application/kotlin` | Kotlin Arc + Chronicle application | `cratis/arc/client-kotlin`, `cratis/chronicle/client-kotlin`, `cratis/language/kotlin`, `cratis/screenplay` |
|
|
63
63
|
| `cratis/application/java` | Java Arc + Chronicle application | `cratis/arc/client-kotlin`, `cratis/chronicle/client-java`, `cratis/language/java`, `cratis/screenplay` |
|
|
64
64
|
|
|
@@ -75,6 +75,7 @@ profile includes neither Screenplay nor Stage.
|
|
|
75
75
|
| `cratis/chronicle` | Chronicle event sourcing engine (does not compose `cratis/chronicle/mcp`) | `cratis/chronicle/compliance`, `cratis/chronicle/csharp`, `cratis/chronicle/elixir`, `cratis/chronicle/java`, `cratis/chronicle/kotlin`, `cratis/chronicle/multi-tenancy`, `cratis/chronicle/typescript`, `cratis/chronicle/web-workbench` |
|
|
76
76
|
| `cratis/components` | React component library, including `cratis-components-common-controls` and `cratis-components-data-surfaces` | (no child profiles) |
|
|
77
77
|
| `cratis/fundamentals` | Core primitives and generated .NET telemetry (`cratis-fundamentals-telemetry`) | (no child profiles) |
|
|
78
|
+
| `cratis/arc/elixir` | Arc for Elixir (source preview): commands, queries, SSE and WebSocket hubs, tenancy, MongoDB, proxies | `cratis/chronicle/client-elixir`, `cratis/language/elixir` |
|
|
78
79
|
| `cratis/arc/go` | Experimental Arc.Go HTTP CQRS (root module) | `cratis/language/go`, `cratis/fundamentals/go` |
|
|
79
80
|
| `cratis/chronicle/client-go` | Experimental standalone Chronicle.Go client | `cratis/language/go`, `cratis/fundamentals/go` |
|
|
80
81
|
| `cratis/fundamentals/go` | Fundamentals.Go named scalar concepts and codecs | `cratis/language/go` |
|
|
@@ -193,6 +194,7 @@ corpus's harness setup or Pi package.
|
|
|
193
194
|
| Profile | Skill | Verified experimental version |
|
|
194
195
|
| --- | --- | --- |
|
|
195
196
|
| `cratis/chronicle/client-go` | `cratis-chronicle-client-go` | Chronicle.Go v0.9.1 (Chronicle kernel 19.32.3 profile) |
|
|
197
|
+
| `cratis/arc/elixir` | `cratis-arc-elixir` | Arc for Elixir source preview (`cratis_arc`, `cratis_arc_mongodb`) |
|
|
196
198
|
| `cratis/arc/go` | `cratis-arc-go` | Arc.Go v0.1.1 |
|
|
197
199
|
| `cratis/fundamentals/go` | `cratis-fundamentals-concept-go` | Fundamentals.Go v0.3.2 |
|
|
198
200
|
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cratis-arc-elixir
|
|
3
|
+
description: Use when building an Elixir CQRS application with Arc for Elixir (`cratis_arc`, `cratis_arc_mongodb`) with commands, read-model queries, observable queries over WebSocket or SSE hubs, tenancy, MongoDB, identity, generated TypeScript proxies and vertical slices. Not for the Chronicle client alone, or for .NET, JVM, Go or TypeScript Arc.
|
|
4
|
+
license: MIT
|
|
5
|
+
compatibility: Elixir 1.18 or later; Plug and Bandit, or Phoenix.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
<!-- Copyright (c) Cratis. All rights reserved. -->
|
|
9
|
+
<!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
|
|
10
|
+
|
|
11
|
+
# Arc for Elixir
|
|
12
|
+
|
|
13
|
+
> **Source preview.** `Cratis/Arc.Elixir` builds and tests the packages, but the API may still
|
|
14
|
+
> change. Pin a git ref you tested, and do not claim more than its
|
|
15
|
+
> `Documentation/limits-and-gaps.md` says is verified. Companion guidance:
|
|
16
|
+
> `cratis-chronicle-client-elixir` (events, read models and the kernel).
|
|
17
|
+
|
|
18
|
+
Arc for Elixir serves the **Arc HTTP contract**, so `@cratis/arc`, `@cratis/arc.react` and
|
|
19
|
+
Cratis Components work against it unchanged. A command is one module, a query is a function
|
|
20
|
+
on a read-model module, and neither is a controller. Events are optional: a command can
|
|
21
|
+
return a response and record nothing. Arc for Elixir works with **Chronicle** for events
|
|
22
|
+
and with **MongoDB** (`cratis_arc_mongodb`) for documents.
|
|
23
|
+
|
|
24
|
+
## Verified product sources
|
|
25
|
+
|
|
26
|
+
| Product | Source checked |
|
|
27
|
+
| --- | --- |
|
|
28
|
+
| Arc for Elixir (`cratis_arc`) | `Source/arc/lib/arc/{command,read_model,application,pipeline,tenancy,filter,watch,proxy_generator}.ex`, `lib/arc/plug/{hub_session,hub,sse_hub}.ex`, `Documentation/*.md` |
|
|
29
|
+
| Arc for Elixir MongoDB (`cratis_arc_mongodb`) | `Source/arc_mongodb/lib/arc/mongodb.ex`, `lib/arc/mongodb/*.ex` |
|
|
30
|
+
| Samples | `Samples/showcase` (every feature, plain Plug), `Samples/phoenix` (LiveView, Chronicle) |
|
|
31
|
+
|
|
32
|
+
Source is authoritative. `Documentation/` excerpts marked `# From: <path>` are verified
|
|
33
|
+
against the samples in CI, so prefer them to memory.
|
|
34
|
+
|
|
35
|
+
## Declare a command
|
|
36
|
+
|
|
37
|
+
```elixir
|
|
38
|
+
defmodule Library.Authors.Registration.RenameAuthor do
|
|
39
|
+
@moduledoc "Renames an author. Only editors may."
|
|
40
|
+
use Arc.Command
|
|
41
|
+
authorize roles: ["editor"]
|
|
42
|
+
|
|
43
|
+
schema do
|
|
44
|
+
field :id, Library.Authors.AuthorId, key: true, required: true
|
|
45
|
+
field :name, :string, required: true, min_length: 2, max_length: 50
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def handle(%__MODULE__{name: name}, _ctx),
|
|
49
|
+
do: {:append, %Library.Authors.AuthorRenamed{name: name}}
|
|
50
|
+
end
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Only `handle/2` is required. The order is validate, `provide/2`, then `handle/2`.
|
|
54
|
+
`handle/2` returns `{:append, event | [events]}`, `{:append, events, response}`,
|
|
55
|
+
`{:ok, response}` (records nothing) or `{:error, results}`. `key: true` marks the event
|
|
56
|
+
source. A handler that returns an event with no key and no source id is rejected as
|
|
57
|
+
`frameworkFailure`. Read [references/commands-and-queries.md](references/commands-and-queries.md).
|
|
58
|
+
|
|
59
|
+
## Declare a query
|
|
60
|
+
|
|
61
|
+
```elixir
|
|
62
|
+
defmodule Library.Authors.Listing.Authors do
|
|
63
|
+
use Arc.ReadModel, model: Library.Authors.Author, types: [id: :uuid]
|
|
64
|
+
|
|
65
|
+
@query many: true
|
|
66
|
+
def all_authors(_args, ctx), do: Chronicle.all(Library.Authors.Author, ctx.chronicle)
|
|
67
|
+
|
|
68
|
+
@observe many: true, watch: [Library.Authors.Author]
|
|
69
|
+
def live_authors(_args, ctx), do: Chronicle.all(Library.Authors.Author, ctx.chronicle)
|
|
70
|
+
end
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
A query is `(args, ctx)` returning `{:ok, value}` or `{:error, results}`. `@observe`
|
|
74
|
+
is the same function, run again whenever its inputs change and pushed to the client. Pass
|
|
75
|
+
`ctx.chronicle` to Chronicle calls. Read
|
|
76
|
+
[references/observable-queries-and-hubs.md](references/observable-queries-and-hubs.md)
|
|
77
|
+
before choosing a transport or a transfer mode.
|
|
78
|
+
|
|
79
|
+
## Host it
|
|
80
|
+
|
|
81
|
+
```elixir
|
|
82
|
+
defmodule MyApp.Arc do
|
|
83
|
+
use Arc.Application, otp_app: :my_app
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# in the supervision tree, before the endpoint
|
|
87
|
+
children = [MyApp.Arc, {Bandit, plug: MyApp.Router, port: 4000}]
|
|
88
|
+
|
|
89
|
+
# the router
|
|
90
|
+
plug Arc.Plug, application: MyApp.Arc
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
`MyApp.Arc` **must be in the supervision tree**: it owns the processes behind observable
|
|
94
|
+
queries. There is no global configuration; every option is on the application. Arc
|
|
95
|
+
discovers commands and read models under the application's namespace, with no registration.
|
|
96
|
+
Phoenix and LiveView use the same application in process. Read
|
|
97
|
+
[references/hosting-and-testing.md](references/hosting-and-testing.md).
|
|
98
|
+
|
|
99
|
+
## Rules that are easy to get wrong
|
|
100
|
+
|
|
101
|
+
- **Authorization is declared, not assumed.** A command or query without `authorize` or
|
|
102
|
+
`allow_anonymous()` is not public by accident; say which you mean.
|
|
103
|
+
- **A tenant resolver only selects.** A header, query string or host is chosen by the caller.
|
|
104
|
+
Membership is yours to check. Read [references/tenancy-and-identity.md](references/tenancy-and-identity.md).
|
|
105
|
+
- **`trust_forwarded_identity_headers: true` is for samples and for an ingress that sets
|
|
106
|
+
the headers.** It trusts unsigned `x-ms-client-principal*` headers from any caller.
|
|
107
|
+
- **A browser `WebSocket` and `EventSource` cannot set headers.** Authenticate hub
|
|
108
|
+
connections with cookies and a plug or handler that reads them.
|
|
109
|
+
- **Change streams need a replica set.** MongoDB observation does not work on a standalone
|
|
110
|
+
server. Read [references/mongodb.md](references/mongodb.md).
|
|
111
|
+
- **Proxy generation is opt-in.** Add the `:arc` compiler, and commit the generated
|
|
112
|
+
files. Read [references/proxies-and-vertical-slices.md](references/proxies-and-vertical-slices.md).
|
|
113
|
+
- **Organize by feature.** Backend, generated proxies and React page of a feature share a
|
|
114
|
+
folder. `layout: :colocated` generates that layout.
|
|
115
|
+
|
|
116
|
+
See [references/pitfalls.md](references/pitfalls.md) for the full list, and
|
|
117
|
+
[references/product-sources.md](references/product-sources.md) for package facts.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<!-- Copyright (c) Cratis. All rights reserved. -->
|
|
2
|
+
<!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
|
|
3
|
+
|
|
4
|
+
# Commands and queries
|
|
5
|
+
|
|
6
|
+
## Fields
|
|
7
|
+
|
|
8
|
+
Types: `:string`, `:integer`, `:float`, `:boolean`, `:uuid` (a `Guid` in TypeScript),
|
|
9
|
+
`:date` (`DateOnly`), `:datetime`, `:map`, `{:list, type}`, a `Chronicle.Concept` module (the
|
|
10
|
+
primitive it wraps) and a module that `use Arc.Schema`. **Nested lists are not supported.**
|
|
11
|
+
Options: `required: true`, `nullable:`, `key: true`, `default:`, `doc:`, `min_length`,
|
|
12
|
+
`max_length`, `email`, `matches`, `min`, `max`, `greater_than`, `less_than`.
|
|
13
|
+
|
|
14
|
+
Use a `Chronicle.Concept` for domain values such as an author id, so the type is declared
|
|
15
|
+
once and is what Chronicle records.
|
|
16
|
+
|
|
17
|
+
## Callbacks
|
|
18
|
+
|
|
19
|
+
| Callback | Use |
|
|
20
|
+
| --- | --- |
|
|
21
|
+
| `validate/2` | A cross-field or state-dependent rule: `:ok` or `{:error, result_or_results}` |
|
|
22
|
+
| `provide/2` | Load data once, after authorization and validation: `:ok`, `{:ok, map}` (merged into `ctx.provided`) or `{:error, results}` |
|
|
23
|
+
| `handle/2` | Decide |
|
|
24
|
+
|
|
25
|
+
Each callback runs only if the previous steps passed.
|
|
26
|
+
|
|
27
|
+
## When Chronicle refuses
|
|
28
|
+
|
|
29
|
+
A constraint or concurrency rejection never raises. It is a validation result with reason
|
|
30
|
+
`constraintViolation` (constraint name in `reasonDetail`) or `concurrencyViolation`.
|
|
31
|
+
|
|
32
|
+
## Run from code
|
|
33
|
+
|
|
34
|
+
```elixir
|
|
35
|
+
result = Arc.execute(MyApp.Arc, %RegisterAuthor{id: Arc.new_id(), name: "Ada"}, principal: principal)
|
|
36
|
+
Arc.CommandResult.success?(result)
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Pass `{RegisterAuthor, %{"id" => "...", "name" => "..."}}` to bind a wire map first.
|
|
40
|
+
Options: `principal:`, `tenant:`, `correlation_id:`, `metadata:`, `validate_only: true`.
|
|
41
|
+
|
|
42
|
+
## Query options
|
|
43
|
+
|
|
44
|
+
`params: [name: type]` (`{type, optional: true}`), `many: bool` (default `true`),
|
|
45
|
+
`authorize:` or `allow_anonymous: true`, `http_method: :get | :query`, and for `@observe`
|
|
46
|
+
`watch: [...]` and `topics: [...]`. Arguments arrive cast; a missing or wrongly typed
|
|
47
|
+
argument is `malformedRequest` before your function runs.
|
|
48
|
+
|
|
49
|
+
`use Arc.ReadModel, types: [id: :uuid]` overrides inferred field types for the proxies:
|
|
50
|
+
a struct default of `""` or `nil` reads as a string.
|
|
51
|
+
|
|
52
|
+
## Paging and sorting
|
|
53
|
+
|
|
54
|
+
`page` (zero-based), `pageSize`, `sortBy` and `sortDirection` are reserved query-string
|
|
55
|
+
names, matched case-insensitively; `QUERY` requests carry them in the body. A returned
|
|
56
|
+
list is sorted and paged **in memory**. For a large collection page in the database and
|
|
57
|
+
return `%Arc.Page{items:, total:, page:, size:}`; Arc then does not touch the items.
|
|
58
|
+
`ctx.query` holds the requested page, page size and sorting.
|
|
59
|
+
|
|
60
|
+
## Results
|
|
61
|
+
|
|
62
|
+
`Arc.CommandResult.to_wire/1` and `Arc.QueryResult.to_wire/1` are the contract envelopes.
|
|
63
|
+
An exception becomes `exceptionMessages`; outside development the message is generic and
|
|
64
|
+
the detail is logged with the correlation id.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<!-- Copyright (c) Cratis. All rights reserved. -->
|
|
2
|
+
<!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
|
|
3
|
+
|
|
4
|
+
# Hosting and testing
|
|
5
|
+
|
|
6
|
+
## Plug
|
|
7
|
+
|
|
8
|
+
`plug Arc.Plug, application: MyApp.Arc` answers `/api/...` commands and queries, `/.cratis/*`
|
|
9
|
+
(identity, discovery, both hubs) and passes everything else on. `max_body_bytes` is the only
|
|
10
|
+
request limit; there are no connection or subscription caps. `Arc.Plug.SinglePage` serves a
|
|
11
|
+
built SPA (`root:`, `api_prefixes:`). Plug and Bandit are enough; no Phoenix is needed.
|
|
12
|
+
|
|
13
|
+
## Phoenix and LiveView
|
|
14
|
+
|
|
15
|
+
The same application runs in process: `Arc.execute/3`, `Arc.query/5`, and `Arc.LiveView` keeps
|
|
16
|
+
an assign current from an observable query, with forms that show pipeline errors on the
|
|
17
|
+
field. Hand the endpoint the Arc plug as for Plug.
|
|
18
|
+
|
|
19
|
+
## Configuration
|
|
20
|
+
|
|
21
|
+
On the application: `chronicle:`, `authentication:`, `trust_forwarded_identity_headers:`,
|
|
22
|
+
`introspection:` (`:authenticated`, `:anonymous` or a policy), `tenancy:`, `filters:`,
|
|
23
|
+
`mongodb:`, `segments_to_skip:` (default 1), `route_prefix:`, `expose_exceptions:`,
|
|
24
|
+
`max_body_bytes:`, `on_behalf_of:`. Read secrets from the environment in `config/runtime.exs`.
|
|
25
|
+
|
|
26
|
+
## Testing
|
|
27
|
+
|
|
28
|
+
`use Arc.Test.Case, application: MyApp.Arc, event_types: [...]` starts a Chronicle in-memory
|
|
29
|
+
test client per test and gives an `Arc.Test.Scenario` as `:arc`; `async: true` is safe.
|
|
30
|
+
|
|
31
|
+
```elixir
|
|
32
|
+
result = Arc.Test.execute(arc, {RegisterAuthor, %{"id" => Arc.new_id(), "name" => "A"}})
|
|
33
|
+
Arc.Test.assert_invalid(result, :name)
|
|
34
|
+
Arc.Test.refute_appended(arc, AuthorRegistered)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Also `Arc.Test.query/5`, `principal/2`, `assert_success/1`, `assert_forbidden/1`,
|
|
38
|
+
`assert_appended/3` and `wait_for_observers/1`. For a plain Plug application without
|
|
39
|
+
Chronicle, call `Arc.execute/3` and `Arc.query/5` with `principal:` and `tenant:` and assert
|
|
40
|
+
on the result. In-memory Chronicle has the limits listed in the Chronicle client skill.
|
|
41
|
+
|
|
42
|
+
## Running samples
|
|
43
|
+
|
|
44
|
+
`Samples/*/run.sh` starts (`./run.sh`) or tests (`./run.sh test`) each sample. `plug` and
|
|
45
|
+
`phoenix` need a Chronicle on port 35000; the showcase needs MongoDB (a replica set) only
|
|
46
|
+
for its MongoDB page.
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<!-- Copyright (c) Cratis. All rights reserved. -->
|
|
2
|
+
<!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
|
|
3
|
+
|
|
4
|
+
# MongoDB (`cratis_arc_mongodb`)
|
|
5
|
+
|
|
6
|
+
```elixir
|
|
7
|
+
{:cratis_arc_mongodb, "~> 0.0"}
|
|
8
|
+
|
|
9
|
+
config :my_app, MyApp.Arc,
|
|
10
|
+
mongodb: [server: System.get_env("MONGODB_URL"), database: "library", naming_policy: :camel_case]
|
|
11
|
+
|
|
12
|
+
children = [MyApp.Arc, {Arc.MongoDB, application: MyApp.Arc}, MyApp.Endpoint]
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Start `Arc.MongoDB` **after** the Arc application. `server` and `database` are required; a
|
|
16
|
+
missing one raises on first use. **Change streams need a replica set or sharded cluster**;
|
|
17
|
+
a single node started with `--replSet` is enough. Keep credentials out of source control.
|
|
18
|
+
|
|
19
|
+
Other options: `direct_connection`, `database_resolver`, `server_resolver`,
|
|
20
|
+
`connection_resolution`, `pool_size` (default 5).
|
|
21
|
+
|
|
22
|
+
## Documents
|
|
23
|
+
|
|
24
|
+
```elixir
|
|
25
|
+
use Arc.MongoDB.Document, types: [id: :uuid, created_at: :datetime]
|
|
26
|
+
defstruct id: "", name: "", created_at: ~U[1970-01-01 00:00:00Z]
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Types: `:string`, `:integer`, `:float`, `:boolean`, `:uuid` (binary subtype 4), `:object_id`,
|
|
30
|
+
`:datetime` (UTC), `:date` (UTC at noon), `{:list, t}` (never `nil` when read), `:map`, a
|
|
31
|
+
`Chronicle.Concept`, a struct module. `id` is stored as `_id`. Use a datetime default of
|
|
32
|
+
`~U[1970-01-01 00:00:00Z]` if the generated TypeScript should be non-optional.
|
|
33
|
+
|
|
34
|
+
Naming policies: `:none`, `:camel_case`, `:snake_case` or a module (`property_name/1`,
|
|
35
|
+
`collection_name/1`). `collection:` names a collection explicitly.
|
|
36
|
+
|
|
37
|
+
## Using a collection
|
|
38
|
+
|
|
39
|
+
Every function takes `{ctx, DocumentModule}` (or an `Arc.MongoDB.Collection`): `all`, `find`,
|
|
40
|
+
`find_one`, `find_by_id`, `count`, `page`, `insert`, `insert_many`, `save`, `update`,
|
|
41
|
+
`update_many`, `delete`, `delete_many`, `create_index`, `provide`. The context selects the
|
|
42
|
+
tenant's database.
|
|
43
|
+
|
|
44
|
+
- **Atom filter keys are struct fields** (translated to stored names and values); **string
|
|
45
|
+
keys are raw MongoDB** (`"$or"`, dotted paths). A field the struct lacks raises instead of
|
|
46
|
+
matching nothing.
|
|
47
|
+
- A broken unique index returns `{:error, :duplicate}`, not an exception.
|
|
48
|
+
- `page` pages and sorts in the database from what the client asked.
|
|
49
|
+
- `update` takes an operator map: `%{"$set" => %{title: "New"}}`.
|
|
50
|
+
|
|
51
|
+
## Tenancy
|
|
52
|
+
|
|
53
|
+
The default tenant uses `database`; a named tenant uses `database+tenant`. Change it with a
|
|
54
|
+
`database_resolver` (`resolve(tenant, options)`). Naming a database is not authorizing the
|
|
55
|
+
caller; **changing the naming of a database in use is a data migration.**
|
|
56
|
+
|
|
57
|
+
`connection_resolution` places tenants on servers and credentials of their own by
|
|
58
|
+
`:default`, a rule (`{:template, ...}`), an endpoint (`{:http, ...}`) or a module
|
|
59
|
+
implementing `Arc.MongoDB.ConnectionResolver`, following the shared connection-resolution
|
|
60
|
+
contract. Answers are cached by purpose and tenant (never by credential) until a minute before
|
|
61
|
+
expiry; an authentication failure drops the cached answer. **An OIDC `accessToken` is refused**:
|
|
62
|
+
the Elixir driver has no such mechanism.
|
|
63
|
+
|
|
64
|
+
## Observation
|
|
65
|
+
|
|
66
|
+
```elixir
|
|
67
|
+
@observe many: true, watch: [Arc.MongoDB.watch(Book)]
|
|
68
|
+
def live_books(_args, ctx), do: {:ok, Arc.MongoDB.all({ctx, Book}, sort: [title: :asc])}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
One database-level change stream is shared by every observer of a database; it resumes
|
|
72
|
+
from its token, notifies observers on reopening and closes when the last observer leaves.
|
|
73
|
+
Observation says a collection changed; the query decides what to send. A query that watches
|
|
74
|
+
the collection another query writes to is how one change updates several lists.
|
|
75
|
+
|
|
76
|
+
## Test
|
|
77
|
+
|
|
78
|
+
`Arc.MongoDB.Test.unique_database/1`, `connect`, `available?` and `drop_databases/3`. Tests
|
|
79
|
+
that need MongoDB should skip when none answers (`MONGODB_URL`).
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<!-- Copyright (c) Cratis. All rights reserved. -->
|
|
2
|
+
<!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
|
|
3
|
+
|
|
4
|
+
# Observable queries and hubs
|
|
5
|
+
|
|
6
|
+
A client reads one `@observe` query four ways from one route: a plain `GET`, direct
|
|
7
|
+
Server-Sent Events (`Accept: text/event-stream`), a direct WebSocket upgrade, or a shared
|
|
8
|
+
hub that carries many subscriptions on one connection.
|
|
9
|
+
|
|
10
|
+
## The two hubs
|
|
11
|
+
|
|
12
|
+
Both speak one protocol (`Connected`, `Subscribe`, `Unsubscribe`, `QueryResult`,
|
|
13
|
+
`Unauthorized`, `Error`, `Ping`/`Pong`) through `Arc.Plug.HubSession`.
|
|
14
|
+
|
|
15
|
+
| | WebSocket | Server-Sent Events |
|
|
16
|
+
| --- | --- | --- |
|
|
17
|
+
| Open | `GET /.cratis/queries/ws` | `GET /.cratis/queries/sse`; first event is `Connected` with the connection id |
|
|
18
|
+
| Subscribe | a `Subscribe` message | `POST /.cratis/queries/sse/subscribe` with `{connectionId, queryId, revision, request}` |
|
|
19
|
+
| Unsubscribe | an `Unsubscribe` message | `POST /.cratis/queries/sse/unsubscribe` |
|
|
20
|
+
|
|
21
|
+
- A subscription carries a revision, so a delayed subscribe cannot bring back a cancelled one.
|
|
22
|
+
- **An SSE control request must come from the caller that opened the stream.** An unknown
|
|
23
|
+
connection or a different caller is `404`; a malformed body is `400`.
|
|
24
|
+
- The tenant of an SSE subscription is that of the control `POST`, not the stream.
|
|
25
|
+
- Each subscription goes through the ordinary pipeline, so authorization, filters and the
|
|
26
|
+
tenant apply as for a `GET`.
|
|
27
|
+
- The generated React client uses the WebSocket hub by default;
|
|
28
|
+
`QueryTransportMethod.ServerSentEvents` selects SSE.
|
|
29
|
+
|
|
30
|
+
## Transfer modes
|
|
31
|
+
|
|
32
|
+
`ObservableQueryTransferMode.Full` sends a snapshot every time. `Delta` sends a snapshot
|
|
33
|
+
first and then only the change set (`added`, `replaced`, `removed`); with no preference
|
|
34
|
+
each emission carries both. The hub computes the change set per subscription by comparing
|
|
35
|
+
with the previous emission, so **a source needs nothing extra**. Items match on an `id`
|
|
36
|
+
member (any case); without one the change set has additions and removals only. An ordered
|
|
37
|
+
or paged query always sends the snapshot too, because position matters.
|
|
38
|
+
|
|
39
|
+
## What triggers a re-run
|
|
40
|
+
|
|
41
|
+
- `watch: [ReadModel]` re-runs when Chronicle changes that read model.
|
|
42
|
+
- `watch: [Arc.MongoDB.watch(Doc)]`, or any `{module, target}` for a module implementing
|
|
43
|
+
`Arc.Watch`, re-runs when that source reports a change.
|
|
44
|
+
- `topics: ["name"]` re-runs on `Arc.Notifier.notify(MyApp.Arc, "name")`. It reaches
|
|
45
|
+
**subscriptions on the same node only**; across nodes broadcast with `Phoenix.PubSub`
|
|
46
|
+
and notify in each receiver.
|
|
47
|
+
|
|
48
|
+
Re-runs are debounced by 25 ms. A subscription is a `:temporary` process: a failure ends
|
|
49
|
+
it and the client resubscribes.
|
|
50
|
+
|
|
51
|
+
## Authentication of browser connections
|
|
52
|
+
|
|
53
|
+
Use cookies. A plug in front of `Arc.Plug` can turn a sign-in cookie and a tenant cookie
|
|
54
|
+
into the headers Arc reads (the showcase's `Samples.Web.CookieIdentity` does, for a demo).
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<!-- Copyright (c) Cratis. All rights reserved. -->
|
|
2
|
+
<!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
|
|
3
|
+
|
|
4
|
+
# Pitfalls
|
|
5
|
+
|
|
6
|
+
- **Nested lists, enums and derived types are not supported** in schemas or generated proxies.
|
|
7
|
+
- **The tenant is selection, not membership.** Authorize it.
|
|
8
|
+
- **There is no tenant resolver chain**, and Arc does not require or enforce a tenant.
|
|
9
|
+
- **`/.cratis/tenants` and `/.cratis/users` list; they do not select.**
|
|
10
|
+
- **A subscription runs with the context of the request that created it.** For SSE that is the
|
|
11
|
+
control `POST`.
|
|
12
|
+
- **`Arc.Notifier` is one node.** Broadcast across nodes yourself.
|
|
13
|
+
- **In-memory sorting and paging.** A large list needs `%Arc.Page{}` from the database.
|
|
14
|
+
- **A query with no `authorize` or `allow_anonymous()` is a decision you have not made.**
|
|
15
|
+
- **Replay memory is per node.** Signed forwarded-identity and on-behalf-of replay caches
|
|
16
|
+
live in a process per application and node, and verification fails closed when the
|
|
17
|
+
application is not started.
|
|
18
|
+
- **`X-Allowed-Severity` is read on commands only**, as a number, capped at `Warning`.
|
|
19
|
+
- **`/.cratis/me` never sets or reads a `.cratis-identity` cookie.**
|
|
20
|
+
- **MongoDB**: no `IMongoCollection` injection; no OIDC access tokens; no geospatial or
|
|
21
|
+
convention-pack features; `Join<T>` watchers are expressed as several `watch:` entries.
|
|
22
|
+
- **A `.ts` in `lib` is ignored by Mix** (a feature, not a bug); the proxy file marker is
|
|
23
|
+
what protects hand-written files from being overwritten.
|
|
24
|
+
- **Do not copy .NET idioms**: no `[Command]` attributes, no DI-injected `IEventLog`. Events are
|
|
25
|
+
returned from `handle/2` as `{:append, ...}`.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!-- Copyright (c) Cratis. All rights reserved. -->
|
|
2
|
+
<!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
|
|
3
|
+
|
|
4
|
+
# Product sources
|
|
5
|
+
|
|
6
|
+
| Fact | Value | Source |
|
|
7
|
+
| --- | --- | --- |
|
|
8
|
+
| Packages | `cratis_arc` (core, Plug, Phoenix, LiveView), `cratis_arc_mongodb` | `Source/arc/mix.exs`, `Source/arc_mongodb/mix.exs` |
|
|
9
|
+
| Elixir requirement | `~> 1.18` | `mix.exs` |
|
|
10
|
+
| Chronicle dependency | `cratis_chronicle ~> 3.16` | `Source/arc/mix.exs` |
|
|
11
|
+
| MongoDB driver | `mongodb_driver ~> 1.6` | `Source/arc_mongodb/mix.exs` |
|
|
12
|
+
| Release | Source preview; pin a git ref and check hex.pm before quoting a version | repository |
|
|
13
|
+
| Documented gaps | `Documentation/limits-and-gaps.md` | repository |
|
|
14
|
+
| Contract | The Arc HTTP contract | Cratis/Arc `Documentation/http-contract.md` |
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<!-- Copyright (c) Cratis. All rights reserved. -->
|
|
2
|
+
<!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
|
|
3
|
+
|
|
4
|
+
# Proxies and vertical slices
|
|
5
|
+
|
|
6
|
+
Proxy generation is opt-in. Add the compiler and every `mix compile` regenerates the
|
|
7
|
+
TypeScript for commands and queries:
|
|
8
|
+
|
|
9
|
+
```elixir
|
|
10
|
+
# mix.exs
|
|
11
|
+
compilers: Mix.compilers() ++ [:arc],
|
|
12
|
+
arc: [application: MyApp.Arc, output: "assets/src/arc"]
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
`mix arc.gen.proxies` runs it directly: `--application`, `--output`, `--layout`, `--check`
|
|
16
|
+
(write nothing; fail if out of date, for CI) and `--no-remove-stale`.
|
|
17
|
+
|
|
18
|
+
- One file per artifact plus an `index.ts` per folder, deterministic: generating twice gives
|
|
19
|
+
identical bytes.
|
|
20
|
+
- Every generated file starts `// @generated by Cratis. Source: <module>. Hash: <sha256>`. **A
|
|
21
|
+
file without that marker is never overwritten or removed.**
|
|
22
|
+
- Enums, nested lists and derived types are not generated.
|
|
23
|
+
- The identity details type is generated, for `useIdentity`.
|
|
24
|
+
|
|
25
|
+
## Vertical slices
|
|
26
|
+
|
|
27
|
+
Organize by feature, not by layer: the Elixir, the generated proxies and the React page of
|
|
28
|
+
one feature share a folder. This matches the .NET guidance.
|
|
29
|
+
|
|
30
|
+
```text
|
|
31
|
+
lib/samples/ticker/
|
|
32
|
+
ticker.ex queries.ex clock.ex # backend
|
|
33
|
+
Ticker.ts Observe.ts index.ts # generated
|
|
34
|
+
TickerPage.tsx # written by hand
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
```elixir
|
|
38
|
+
arc: [application: Samples.Arc, output: "lib", layout: :colocated]
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
`layout: :colocated` writes each proxy in the folder of the `.ex` file that defines its module,
|
|
42
|
+
relative to `output`; two modules in one file share a folder; a module whose source is
|
|
43
|
+
outside `output` falls back to a namespace-mirroring folder. Imports between proxies are
|
|
44
|
+
relative and generated. The default `:namespace` layout mirrors the module namespace
|
|
45
|
+
under `output` after `segments_to_skip`.
|
|
46
|
+
|
|
47
|
+
Make the tooling see both: Mix and the Phoenix reloader ignore `.ts` and `.tsx`, but
|
|
48
|
+
**`package.json` and `node_modules` must sit above `lib`** so a slice finds `@cratis/arc` by
|
|
49
|
+
looking upward, and the TypeScript and bundler config must include `lib`. Keep the app shell
|
|
50
|
+
(`index.html`, providers, the page that picks a slice) in its own folder.
|
|
51
|
+
|
|
52
|
+
Commit the generated files so a pull request shows the contract change beside its cause, and
|
|
53
|
+
run `mix arc.gen.proxies --check` in CI. What several slices share (a concept, a shared read
|
|
54
|
+
model) lives in a shared folder; slices reach each other through commands, queries and contracts,
|
|
55
|
+
never internals.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<!-- Copyright (c) Cratis. All rights reserved. -->
|
|
2
|
+
<!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
|
|
3
|
+
|
|
4
|
+
# Tenancy and identity
|
|
5
|
+
|
|
6
|
+
## Three decisions
|
|
7
|
+
|
|
8
|
+
| Decision | Who |
|
|
9
|
+
| --- | --- |
|
|
10
|
+
| Selection: which tenant is this request for | `Arc.Tenancy` |
|
|
11
|
+
| Membership: may this caller use it | You, in a command, query, policy or `Arc.Filter` |
|
|
12
|
+
| Storage isolation: where the data lives | Chronicle namespace and the MongoDB database |
|
|
13
|
+
|
|
14
|
+
**A resolver only selects.** Do not treat a header, query value or host as evidence of
|
|
15
|
+
membership.
|
|
16
|
+
|
|
17
|
+
## Resolvers
|
|
18
|
+
|
|
19
|
+
```elixir
|
|
20
|
+
config :my_app, MyApp.Arc, tenancy: [resolver: :header]
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`:header` (default; `header:`, default `x-cratis-tenant-id`), `:query` (`query_parameter:`,
|
|
24
|
+
default `tenantId`), `:claim` (`claim_type:`, default `tenant_id`; ties selection to the
|
|
25
|
+
authenticated principal), `:subdomain` (`base_domain:` required), `:fixed` or `:development`
|
|
26
|
+
(`tenant_id:`), or a module implementing `Arc.Tenancy` (`resolve(conn, principal, options)`).
|
|
27
|
+
There is **no chain of resolvers**. The `:subdomain` resolver accepts only exactly one label
|
|
28
|
+
before a registrable base domain and otherwise falls back to the client-controlled header, so
|
|
29
|
+
strip the header at the ingress; the application refuses to start with an unusable base
|
|
30
|
+
domain. `nil`, `""` and `"Default"` are all the default tenant. The result is `ctx.tenant`.
|
|
31
|
+
|
|
32
|
+
A named tenant becomes the Chronicle `namespace:` of calls through the context, unless an
|
|
33
|
+
explicit `namespace:` is given. `:arc_tenant` is Logger metadata.
|
|
34
|
+
|
|
35
|
+
## Authentication and identity
|
|
36
|
+
|
|
37
|
+
Authentication handlers return `{:authenticated, principal}`, `:failed` (terminal, generic
|
|
38
|
+
401) or `:anonymous` (the next handler tries). `Arc.Authentication.MicrosoftIdentityPlatform`
|
|
39
|
+
reads `x-ms-client-principal`, `-id` and `-name`; **forwarded headers are trusted only with
|
|
40
|
+
`trust_forwarded_identity_headers: true`**, or when signed (HMAC with audience, key id,
|
|
41
|
+
timestamp, nonce and method/path coverage). An RS256 on-behalf-of assertion is checked for
|
|
42
|
+
signature (RSA 2048+), issuer, audience, expiry and replay.
|
|
43
|
+
|
|
44
|
+
Identity for the frontend: `use Arc.Identity.Provider, details: MyApp.IdentityDetails`;
|
|
45
|
+
`/.cratis/me` answers 401 not signed in, 403 when the provider says `:unauthorized`, else the
|
|
46
|
+
identity with `details`. The provider receives the tenant (`Arc.Identity.Context.tenant`).
|
|
47
|
+
`/.cratis/users` and `/.cratis/tenants` list development users and tenants for tools such
|
|
48
|
+
as Lens; they do not decide the request's tenant.
|
|
49
|
+
|
|
50
|
+
## Authorize a namespace
|
|
51
|
+
|
|
52
|
+
An `Arc.Filter` implements `on_command(ctx, descriptor)` and `on_query(ctx, descriptor, query)`
|
|
53
|
+
returning `:ok` or `{:unauthorized, reason}`. Register with `filters: [MyFilter]`. Filters run
|
|
54
|
+
**after authorization and before validation**, for every artifact; match the descriptor's
|
|
55
|
+
`namespace` to scope one. A refusal is `403` and the artifact never runs.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"skill": "cratis-arc-elixir",
|
|
3
|
+
"input": "Build an Elixir Arc application with a command, an observable query over the SSE hub, tenancy and MongoDB.",
|
|
4
|
+
"fixtures": [],
|
|
5
|
+
"assertions": [
|
|
6
|
+
{
|
|
7
|
+
"kind": "skill-contains",
|
|
8
|
+
"value": "`cratis_arc`"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"kind": "skill-contains",
|
|
12
|
+
"value": "**must be in the supervision tree**"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"kind": "skill-contains",
|
|
16
|
+
"value": "**A tenant resolver only selects.**"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"kind": "skill-contains",
|
|
20
|
+
"value": "**Change streams need a replica set.**"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"kind": "skill-contains",
|
|
24
|
+
"value": "`layout: :colocated`"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"kind": "skill-contains",
|
|
28
|
+
"value": "**An SSE control request must come from the caller that opened the stream.**",
|
|
29
|
+
"file": "references/observable-queries-and-hubs.md"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"kind": "skill-contains",
|
|
33
|
+
"value": "**a source needs nothing extra**",
|
|
34
|
+
"file": "references/observable-queries-and-hubs.md"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"kind": "skill-contains",
|
|
38
|
+
"value": "There is **no chain of resolvers**",
|
|
39
|
+
"file": "references/tenancy-and-identity.md"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"kind": "skill-contains",
|
|
43
|
+
"value": "**An OIDC `accessToken` is refused**",
|
|
44
|
+
"file": "references/mongodb.md"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"kind": "skill-contains",
|
|
48
|
+
"value": "**`package.json` and `node_modules` must sit above `lib`**",
|
|
49
|
+
"file": "references/proxies-and-vertical-slices.md"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"kind": "skill-contains",
|
|
53
|
+
"value": "**`Arc.Notifier` is one node.**",
|
|
54
|
+
"file": "references/pitfalls.md"
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}
|
|
@@ -120,7 +120,8 @@ There is no fast path that checks only the named files or only `--stat`.
|
|
|
120
120
|
|
|
121
121
|
## Public text
|
|
122
122
|
|
|
123
|
-
No
|
|
123
|
+
No customer or customer-of-customer names (keep every reference generic), local
|
|
124
|
+
paths (including the draft file path), model or agent names, session
|
|
124
125
|
IDs, verification receipts or work-folder names. Use absolute URLs and commit
|
|
125
126
|
permalinks.
|
|
126
127
|
|
|
@@ -73,7 +73,9 @@ duplicated or already managed by another active writer. A minimal template is:
|
|
|
73
73
|
Replace the example with the real scope and remaining work. Use public PR or
|
|
74
74
|
issue URLs when they exist. Summarize a local plan; never link its file path.
|
|
75
75
|
Do not put local paths, harness commands, credentials or private context in
|
|
76
|
-
public issue or PR text.
|
|
76
|
+
public issue or PR text. Never name a customer or a customer's customer in an
|
|
77
|
+
issue, comment or PR; describe the situation generically ("a large enterprise
|
|
78
|
+
tenant") and strip identifying products, systems and people. Read [secrets.md](../../rules/secrets.md) before handling
|
|
77
79
|
output, and [local-work-artifacts.md](../../rules/local-work-artifacts.md) before
|
|
78
80
|
creating the private working copy.
|
|
79
81
|
|
|
@@ -132,7 +134,8 @@ For example, use `gh issue view <n> --repo OWNER/REPO --comments` and
|
|
|
132
134
|
`gh issue list --repo OWNER/REPO --state all --search "<area> in:title,body"`.
|
|
133
135
|
Reuse an existing issue instead of duplicating it; comment only when that
|
|
134
136
|
effect is authorized and adds necessary context.
|
|
135
|
-
3.
|
|
137
|
+
3. Keep every issue generic: no customer or customer-of-customer names, ever.
|
|
138
|
+
Group related findings into one checklist issue per area. Include concrete,
|
|
136
139
|
testable `## Acceptance criteria`. No speculative hardening, ideas or
|
|
137
140
|
"investigate later" issues. If filing is outside the request, list necessary
|
|
138
141
|
follow-ups in the report instead of creating them.
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"cratis/arc/core",
|
|
20
20
|
"cratis/arc/csharp",
|
|
21
21
|
"cratis/arc/ef-core",
|
|
22
|
+
"cratis/arc/elixir",
|
|
22
23
|
"cratis/arc/go",
|
|
23
24
|
"cratis/arc/identity",
|
|
24
25
|
"cratis/arc/java",
|
|
@@ -173,6 +174,7 @@
|
|
|
173
174
|
{
|
|
174
175
|
"id": "cratis/application/elixir",
|
|
175
176
|
"composes": [
|
|
177
|
+
"cratis/arc/elixir",
|
|
176
178
|
"cratis/chronicle/client-elixir",
|
|
177
179
|
"cratis/language/elixir",
|
|
178
180
|
"cratis/screenplay"
|
|
@@ -311,6 +313,19 @@
|
|
|
311
313
|
"csharp"
|
|
312
314
|
]
|
|
313
315
|
},
|
|
316
|
+
{
|
|
317
|
+
"id": "cratis/arc/elixir",
|
|
318
|
+
"composes": [
|
|
319
|
+
"cratis/chronicle/client-elixir",
|
|
320
|
+
"cratis/language/elixir"
|
|
321
|
+
],
|
|
322
|
+
"availableTargets": [
|
|
323
|
+
"cratis-arc-elixir"
|
|
324
|
+
],
|
|
325
|
+
"languages": [
|
|
326
|
+
"elixir"
|
|
327
|
+
]
|
|
328
|
+
},
|
|
314
329
|
{
|
|
315
330
|
"id": "cratis/arc/go",
|
|
316
331
|
"composes": [
|