@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.
- package/package/corpus/harnesses/copilot/instructions/elixir.instructions.md +26 -4
- package/package/corpus/hooks/README.md +36 -1
- package/package/corpus/hooks/scripts/cratis-guard-shell-writes.sh +62 -17
- package/package/corpus/rules/elixir.md +26 -4
- package/package/corpus/skills/cratis-arc-elixir/SKILL.md +22 -12
- package/package/corpus/skills/cratis-arc-elixir/references/availability.md +14 -14
- package/package/corpus/skills/cratis-arc-elixir/references/commands-and-queries.md +8 -8
- package/package/corpus/skills/cratis-arc-elixir/references/event-model.md +79 -0
- package/package/corpus/skills/cratis-arc-elixir/references/hosting-and-testing.md +10 -10
- package/package/corpus/skills/cratis-arc-elixir/references/mongodb.md +9 -9
- package/package/corpus/skills/cratis-arc-elixir/references/observable-queries-and-hubs.md +5 -5
- package/package/corpus/skills/cratis-arc-elixir/references/pitfalls.md +13 -2
- package/package/corpus/skills/cratis-arc-elixir/references/product-sources.md +3 -2
- package/package/corpus/skills/cratis-arc-elixir/references/tenancy-and-identity.md +7 -7
- package/package/corpus/skills/cratis-arc-elixir/verification.json +14 -1
- package/package/corpus/skills/cratis-chronicle-client-elixir/SKILL.md +43 -43
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/append-api.md +4 -4
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/captures.md +5 -5
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/client-options.md +5 -5
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/compliance.md +6 -6
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/connections.md +3 -3
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/constraints.md +6 -6
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/decision-reads.md +12 -12
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/discovery-and-generations.md +10 -10
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/event-sources.md +7 -7
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/graphs.md +6 -6
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/idioms-and-inspection.md +5 -5
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/observability.md +2 -2
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/patterns.md +6 -6
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/pitfalls.md +4 -4
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/projections.md +4 -4
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/reactor-example.md +2 -2
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/read-models.md +7 -7
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/testing.md +15 -15
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/upgrading.md +19 -3
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/variants.md +9 -9
- package/package/corpus/skills/cratis-chronicle-client-elixir/verification.json +3 -3
- package/package.json +1 -1
|
@@ -12,13 +12,14 @@ paths:
|
|
|
12
12
|
# Elixir Conventions
|
|
13
13
|
|
|
14
14
|
Use Elixir and OTP idioms, not translated C# or JVM shapes. These conventions
|
|
15
|
-
are grounded in `Cratis/Chronicle.Elixir
|
|
16
|
-
`.formatter.exs`, and `lib/chronicle/`)
|
|
17
|
-
|
|
15
|
+
are grounded in `Cratis/Chronicle.Elixir` 4.x (`Source/chronicle/mix.exs`,
|
|
16
|
+
`.formatter.exs`, and `lib/cratis/chronicle/`) and `Cratis/Arc.Elixir` 1.4.x
|
|
17
|
+
(`lib/cratis/arc/`). Client-specific APIs belong in the
|
|
18
|
+
**cratis-chronicle-client-elixir** skill, Arc APIs in **cratis-arc-elixir**.
|
|
18
19
|
|
|
19
20
|
## Build and format
|
|
20
21
|
|
|
21
|
-
-
|
|
22
|
+
- Use Elixir 1.18 or later (`~> 1.18`); the packages build on 1.19.
|
|
22
23
|
- Run `mix compile --warnings-as-errors`, `mix test`, and
|
|
23
24
|
`mix format --check-formatted` with the project's formatter inputs.
|
|
24
25
|
- Use two-space indentation and let `mix format` own layout.
|
|
@@ -42,6 +43,27 @@ are grounded in `Cratis/Chronicle.Elixir v3.13.0` (`Source/chronicle/mix.exs`,
|
|
|
42
43
|
operational logging and keep credentials out of messages and crash reports.
|
|
43
44
|
- Use American English in identifiers, comments and documentation.
|
|
44
45
|
|
|
46
|
+
## Event-sourced applications on Arc and Chronicle
|
|
47
|
+
|
|
48
|
+
Read the **cratis-arc-elixir** and **cratis-chronicle-client-elixir** skills before touching a slice.
|
|
49
|
+
|
|
50
|
+
- **Folders are Module, Feature, Slice, and sub-features nest.** One folder per behavior, named for what
|
|
51
|
+
it does as a gerund (`RotatingSecrets`); the command inside is the verb. Group slices that act on one
|
|
52
|
+
thing into a sub-feature (`Secrets`, `Credentials`, `Viewing`), and put a reactor with the facts it
|
|
53
|
+
reacts to, not in a folder named for the third party it calls. No folders named for a kind of file.
|
|
54
|
+
- **Names are ids.** `use Cratis.Arc.Command, id: "rotate-secret"`, an event type's `id:`, a reactor's
|
|
55
|
+
`id:`; the model shows the id in PascalCase, so a module can be renamed without renaming the model.
|
|
56
|
+
- **A command and its events live in one file**, events first. An event is past tense, one fact, and
|
|
57
|
+
never carries a secret.
|
|
58
|
+
- **Every slice tells a whole story**: a state change has a command and the events it appends; a view
|
|
59
|
+
has a read model and consumes events (`consumes:` when it reads the event log); an automation reacts to
|
|
60
|
+
an event and records a fact of its own, so the event model shows what it did. A reactor that calls a
|
|
61
|
+
third party returns the event recording that it did.
|
|
62
|
+
- **Order is the story**: a slice that uses events of several sub-features goes in a sub-feature after
|
|
63
|
+
them. Build with `arc: [event_model_strict: true]` so an incomplete model fails the build.
|
|
64
|
+
- **Third parties are integrations behind a behaviour**, with an in-memory stand-in for specs; only
|
|
65
|
+
reactors write to them.
|
|
66
|
+
|
|
45
67
|
Every `.ex` and `.exs` source file starts with:
|
|
46
68
|
|
|
47
69
|
```elixir
|
|
@@ -421,7 +421,21 @@ path (or stdout) only with exactly recognised non-executing, non-deleting option
|
|
|
421
421
|
source deletion and program execution are refused. Option environments (`UNZIP`, `UNZIPOPT`,
|
|
422
422
|
`TAR_OPTIONS`, `ZIPOPT`) and argfile arguments are refused; assigning/exporting those variables is
|
|
423
423
|
also blocked. Extraction-to-stdout forms do not accept `--`. Extract outside the agent shell (or ask
|
|
424
|
-
the user), then copy the specific files needed.
|
|
424
|
+
the user), then copy the specific files needed.
|
|
425
|
+
|
|
426
|
+
Archive operands (tar/bsdtar/gtar, zip, 7z, jar, ar, cpio, pax; ditto and unar are already refused outright)
|
|
427
|
+
must not be able to expand into an option or an `@listfile` reference. A word containing an active glob
|
|
428
|
+
(`*`, `?`, `[`) is admitted only when its **first** character is a literal character other than `-` or `@`: a plain
|
|
429
|
+
character, a character of a plain quoted segment, or a backslash-escaped plain character. A leading glob, a
|
|
430
|
+
`$` expansion, a backquote or a `$'..'`/`$".."` segment never anchors, quoted or not (`"$x"?`, `"$PWD"/?x`). The
|
|
431
|
+
same rule applies in an option-value position (`-f ""?`). In archive mode any word containing a `$'..'` segment
|
|
432
|
+
with a backslash is refused whether or not it has a glob, because its escapes are not decoded. This is a lexical
|
|
433
|
+
check: it never expands the glob, reads the directory or runs anything, so it does not depend on which files
|
|
434
|
+
exist today. **Compatibility change:** `tar -cf out.tar ?x`, `zip out.zip [a]*` and similar unanchored patterns are
|
|
435
|
+
now refused even in a directory with no option-shaped names. Re-spell them with a literal anchor (`./?x`,
|
|
436
|
+
`dir/?x`), which stays allowed. `--` is not an anchor for any family (tar, zip, 7z, cpio, pax, ...): the guard
|
|
437
|
+
cannot verify what each tool does after it, so the remediation is `./`. A `--` that is itself an option value
|
|
438
|
+
(`zip out.zip -x -- ?x`) is data, not a terminator. Git checkout-index still requires a directory
|
|
425
439
|
prefix ending in `/`, checked against all protected-path policy.
|
|
426
440
|
|
|
427
441
|
In destructive scope only, an existing directory also receives a metadata-only inventory for
|
|
@@ -489,6 +503,27 @@ arguments are operands. A lone `-` is a stdin operand. Value-free short flags ma
|
|
|
489
503
|
| `rsync` | `-a -r -v -n -u -z -t -p`; `--archive --recursive --verbose --dry-run --update --compress --times --perms` |
|
|
490
504
|
| `install` | `-c -v -C -p`; `-d` directory operands; `-m MODE`/`-mMODE` (three or four octal digits); the same target-directory forms as `cp` |
|
|
491
505
|
|
|
506
|
+
### Support matrix and boundary (#1252, #1223)
|
|
507
|
+
|
|
508
|
+
These guards check a **supported command-shape subset on a best-effort basis**; they are defense in depth,
|
|
509
|
+
not a sandbox. File permissions and OS-level isolation are the boundary. "Out of scope" below means the guard
|
|
510
|
+
does not examine the shape, **not** that the shape is safe: a zero verdict there proves only the limit.
|
|
511
|
+
Standalone verdicts differ: the secrets guard decides reads, the shell-write guard decides writes and
|
|
512
|
+
destructive scope, and an allowance by one never authorizes the other. A support-matrix spec in the
|
|
513
|
+
Cratis AI repository pins each row with JSON-only invocations (no candidate text is executed).
|
|
514
|
+
|
|
515
|
+
| Class | Supported | Refused | Out of scope (not examined) |
|
|
516
|
+
|---|---|---|---|
|
|
517
|
+
| State inherited from earlier calls | The supplied `cwd`; literal `cd`/`git -C` within one command; modeled archive option environments | Unresolved destructive destinations; `UNZIP`/`TAR_OPTIONS`-style archive environments | Earlier assignments, executor shell options (`dotglob`, `nullglob`), files created by prior calls or races |
|
|
518
|
+
| Aliases and functions | Literal executable names | Protected references and unresolved destructive effects stay visible | What an alias, function or shadowing executable does; definitions are never loaded or run |
|
|
519
|
+
| Directory resolution | Literal cwd, `cd`, Git `-C`, logical and physical (symlink) path checks | Ambiguous destructive cwd; links resolving into protected or whole-worktree scope | `CDPATH`, unmodeled directory options, symlinks created during execution |
|
|
520
|
+
| Expansion and quoting | Literal and quoted operands; ordinary source globs and bounded literal-prefix probes; archive operands whose first character is a literal other than `-`/`@` (`./?x`, `dir/?x`; a quoted expansion such as `"$x"` never anchors, and `--` is no anchor) or quoting | Archive operands that can expand to options or `@` (above); unresolved destructive operands; over-budget parsing | General shell grammar (bash versus zsh), indirect expansion |
|
|
521
|
+
| Wrappers and shell entry points | Modeled wrappers (`env`, `nice`, `sudo`, `timeout`, …) and literal nested `sh -c` bodies | Protected inline-interpreter vocabulary; executable heredocs; uncertain destructive wrapper context | Dynamic code, external scripts, generated stdin, custom wrappers, archive file-list (`-T`) contents |
|
|
522
|
+
|
|
523
|
+
Remaining redesign (a command-shape allowlist per tool family, argument-file and dynamic-code handling, a
|
|
524
|
+
recovered #1222 shape inventory) stays on #1223. Shipped hook changes reach a consuming repository through
|
|
525
|
+
`cratis ai update`.
|
|
526
|
+
|
|
492
527
|
### Read-only admissions and deliberate refusals (#1255)
|
|
493
528
|
|
|
494
529
|
| Case | Decision | Reason | Workaround |
|
|
@@ -1070,8 +1070,8 @@ function data_substitutions(text, d, word, i, c, body, k) {
|
|
|
1070
1070
|
}
|
|
1071
1071
|
}
|
|
1072
1072
|
}
|
|
1073
|
-
function lex(text, d, i, c, nextc, quote, word, quoted, active, n, body, k, pending, delimiter, strip, hd_index, end, word_start) {
|
|
1074
|
-
n = 0; quote = ""; word = ""; active = 0; quoted = 0; pending = 0
|
|
1073
|
+
function lex(text, d, i, c, nextc, quote, word, quoted, active, n, body, k, pending, delimiter, strip, hd_index, end, word_start, glob_at, xf, ansi) {
|
|
1074
|
+
n = 0; quote = ""; word = ""; active = 0; quoted = 0; pending = 0; glob_at = 0; xf = ""; ansi = 0
|
|
1075
1075
|
for (i = 1; i <= length(text); i++) {
|
|
1076
1076
|
c = substr(text, i, 1); nextc = substr(text, i + 1, 1)
|
|
1077
1077
|
if (!active) word_start = i
|
|
@@ -1085,14 +1085,17 @@ function lex(text, d, i, c, nextc, quote, word, quoted, active, n, body, k, p
|
|
|
1085
1085
|
i = sub_end; word = word "$__sub"; active = 1; continue
|
|
1086
1086
|
}
|
|
1087
1087
|
if (quote != "") {
|
|
1088
|
-
if (c == quote) { quote = ""; continue }
|
|
1088
|
+
if (c == quote) { quote = ""; ansi = 0; continue }
|
|
1089
|
+
if (ansi && c == "\\" && xf !~ /e/) xf = xf "e"
|
|
1090
|
+
if (c == "\\" && quote != "\047" && nextc == "\n") { i++; continue }
|
|
1089
1091
|
if (c == "\\" && quote != "\047" && nextc ~ /[$`"\\]/) c = substr(text, ++i, 1)
|
|
1090
1092
|
word = word c; continue
|
|
1091
1093
|
}
|
|
1092
1094
|
if (c == "\047" || c == "\"" || (c == "$" && nextc == "\047")) {
|
|
1093
|
-
if (c == "$") c = substr(text, ++i, 1)
|
|
1095
|
+
if (c == "$") { c = substr(text, ++i, 1); ansi = 1; if (word == "") xf = xf "f" }
|
|
1094
1096
|
quote = c; if (!active) quoted = 1; active = 1; continue
|
|
1095
1097
|
}
|
|
1098
|
+
if (c == "\\" && nextc == "\n") { i++; continue }
|
|
1096
1099
|
if (c == "\\") { if (!active) quoted = 1; word = word substr(text, ++i, 1); active = 1; continue }
|
|
1097
1100
|
if (c == "#" && !active) {
|
|
1098
1101
|
while (i <= length(text) && substr(text, i, 1) != "\n") i++
|
|
@@ -1106,7 +1109,7 @@ function lex(text, d, i, c, nextc, quote, word, quoted, active, n, body, k, p
|
|
|
1106
1109
|
}
|
|
1107
1110
|
if (c == "{" && nextc == "}") { word = word "{}"; i++; active = 1; continue }
|
|
1108
1111
|
if (c ~ /[ \t\r\n;&|(){}<>]/) {
|
|
1109
|
-
if (active) { W[d, ++n] = word; Q[d, n] = quoted; DQ[d, n] = quoted_prefix(substr(text, word_start, i - word_start)); CT[d, n] = literal_current_directory(substr(text, word_start, i - word_start), word); K[d, n] = "word"; T[d, n] = i - 1; F[d, n] = !quoted && word ~ /^[0-9]+$/ && substr(text, i - length(word), length(word)) == word; word = ""; active = quoted = 0 }
|
|
1112
|
+
if (active) { W[d, ++n] = word; Q[d, n] = quoted; DQ[d, n] = quoted_prefix(substr(text, word_start, i - word_start)); CT[d, n] = literal_current_directory(substr(text, word_start, i - word_start), word); K[d, n] = "word"; T[d, n] = i - 1; F[d, n] = !quoted && word ~ /^[0-9]+$/ && substr(text, i - length(word), length(word)) == word; GL[d, n] = glob_at; XF[d, n] = xf; word = ""; active = quoted = glob_at = 0; xf = "" }
|
|
1110
1113
|
if (c ~ /[ \t\r]/) continue
|
|
1111
1114
|
if (c == "<" && nextc == "<") {
|
|
1112
1115
|
if (substr(text, i, 3) == "<<<") { W[d, ++n] = "<<<"; K[d, n] = "<<<"; T[d, n] = i; i += 2; continue }
|
|
@@ -1140,8 +1143,10 @@ function lex(text, d, i, c, nextc, quote, word, quoted, active, n, body, k, p
|
|
|
1140
1143
|
continue
|
|
1141
1144
|
}
|
|
1142
1145
|
word = word c; active = 1
|
|
1146
|
+
# Offset of the first unquoted pathname-expansion character; quoted and escaped ones never get here.
|
|
1147
|
+
if (!glob_at && c ~ /[*?\[]/) glob_at = length(word)
|
|
1143
1148
|
}
|
|
1144
|
-
if (active) { W[d, ++n] = word; Q[d, n] = quoted; DQ[d, n] = quoted_prefix(substr(text, word_start)); CT[d, n] = literal_current_directory(substr(text, word_start), word); K[d, n] = "word" }
|
|
1149
|
+
if (active) { W[d, ++n] = word; Q[d, n] = quoted; DQ[d, n] = quoted_prefix(substr(text, word_start)); CT[d, n] = literal_current_directory(substr(text, word_start), word); K[d, n] = "word"; GL[d, n] = glob_at; XF[d, n] = xf }
|
|
1145
1150
|
if (quote != "" || pending) unclassified(remaining(d, 1, n))
|
|
1146
1151
|
return n
|
|
1147
1152
|
}
|
|
@@ -1178,7 +1183,7 @@ function wrapper_flag(program, option) {
|
|
|
1178
1183
|
function copy_token(source, from, dest, to, j) {
|
|
1179
1184
|
W[dest, to] = W[source, from]; Q[dest, to] = Q[source, from]; DQ[dest, to] = DQ[source, from]; K[dest, to] = K[source, from]
|
|
1180
1185
|
H[dest, to] = H[source, from]; T[dest, to] = T[source, from]; F[dest, to] = F[source, from]
|
|
1181
|
-
BC[dest, to] = BC[source, from]
|
|
1186
|
+
BC[dest, to] = BC[source, from]; GL[dest, to] = GL[source, from]; XF[dest, to] = XF[source, from]
|
|
1182
1187
|
for (j = 1; j <= BC[source, from]; j++) B[dest, to, j] = B[source, from, j]
|
|
1183
1188
|
}
|
|
1184
1189
|
function redirection(d, i) { return K[d, i] ~ /^[<>]/ || K[d, i] ~ /^&>/ }
|
|
@@ -1203,7 +1208,7 @@ function env_words(text, slot, i, c, nextc, quote, word, active, n) {
|
|
|
1203
1208
|
for (i = 1; i <= length(text) + 1; i++) {
|
|
1204
1209
|
c = substr(text, i, 1); nextc = substr(text, i + 1, 1)
|
|
1205
1210
|
if (c == "" || (quote == "" && c ~ /[[:space:]]/)) {
|
|
1206
|
-
if (active) { W[slot, ++n] = word; Q[slot, n] = 1; K[slot, n] = "word"; word = ""; active = 0 }
|
|
1211
|
+
if (active) { W[slot, ++n] = word; Q[slot, n] = 1; K[slot, n] = "word"; GL[slot, n] = 0; XF[slot, n] = ""; word = ""; active = 0 }
|
|
1207
1212
|
continue
|
|
1208
1213
|
}
|
|
1209
1214
|
if (quote == "" && c == "#" && !active) break
|
|
@@ -1212,7 +1217,7 @@ function env_words(text, slot, i, c, nextc, quote, word, active, n) {
|
|
|
1212
1217
|
if (nextc == "c") break
|
|
1213
1218
|
if (nextc == "_") {
|
|
1214
1219
|
if (quote == "") {
|
|
1215
|
-
if (active) { W[slot, ++n] = word; Q[slot, n] = 1; K[slot, n] = "word"; word = ""; active = 0 }
|
|
1220
|
+
if (active) { W[slot, ++n] = word; Q[slot, n] = 1; K[slot, n] = "word"; GL[slot, n] = 0; XF[slot, n] = ""; word = ""; active = 0 }
|
|
1216
1221
|
continue
|
|
1217
1222
|
}
|
|
1218
1223
|
c = " "
|
|
@@ -1230,7 +1235,7 @@ function env_words(text, slot, i, c, nextc, quote, word, active, n) {
|
|
|
1230
1235
|
word = word c; active = 1
|
|
1231
1236
|
}
|
|
1232
1237
|
if (quote != "") { unclassified(text); return -1 }
|
|
1233
|
-
if (active) { W[slot, ++n] = word; Q[slot, n] = 1; K[slot, n] = "word" }
|
|
1238
|
+
if (active) { W[slot, ++n] = word; Q[slot, n] = 1; K[slot, n] = "word"; GL[slot, n] = 0; XF[slot, n] = "" }
|
|
1234
1239
|
return n
|
|
1235
1240
|
}
|
|
1236
1241
|
function executable(d, start, end, i, j, program, option, split_at, text, slot, count, first, expansions) {
|
|
@@ -1343,8 +1348,37 @@ function option_grammars() {
|
|
|
1343
1348
|
option_schema("read-tree", "uminv", "", "reset merge dry-run verbose no-sparse-checkout", "prefix index-output")
|
|
1344
1349
|
option_schema("checkout-index", "afqunz", "", "all force quiet index no-create stdin temp", "prefix")
|
|
1345
1350
|
}
|
|
1351
|
+
# Archive operands. A word whose expansion can begin with `-` or `@` is an option, or a bsdtar/7z list-file
|
|
1352
|
+
# reference. A word with an active glob is therefore admitted only when its FIRST element is a literal character
|
|
1353
|
+
# other than `-`/`@`: a plain character, a character of a plain quoted segment, or an escaped plain character.
|
|
1354
|
+
# A `$` expansion, backquote, `$'..'` segment or leading glob never anchors, because it can expand to nothing or to
|
|
1355
|
+
# an option. A `$'..'` segment containing a backslash is refused outright: its escapes are not decoded here.
|
|
1356
|
+
# Lexical only: no expansion and no filesystem access, and `--` is never treated as proof.
|
|
1357
|
+
function archive_escape(d, i) { return XF[d, i] ~ /e/ }
|
|
1358
|
+
function option_shaped_glob(d, i) {
|
|
1359
|
+
return archive_escape(d, i) || (GL[d, i] && (GL[d, i] == 1 || W[d, i] ~ /^[-@$`]/ || XF[d, i] ~ /f/))
|
|
1360
|
+
}
|
|
1361
|
+
# A simple copy may retain a leading glob only after the same bounded metadata check as reader_globs.
|
|
1362
|
+
# Keep this exception local to the current directory and plain star/question patterns; never evaluate text.
|
|
1363
|
+
function copy_source_glob(d, i, cwd, uncertain, script, cmd, line, count, ok) {
|
|
1364
|
+
if (!exception_allowed || uncertain || cwd != ENVIRON["GSW_CWD"] || ENVIRON["GSW_GLOB_SAFE"] != "1") return 0
|
|
1365
|
+
if (!GL[d, i] || XF[d, i] != "" || W[d, i] !~ /^[*?][a-zA-Z0-9._*?-]*$/) return 0
|
|
1366
|
+
script = "cd -- \"$1\" && [ -r . ] && [ -x . ] || exit 3; unset GLOBIGNORE; " \
|
|
1367
|
+
"shopt -s nullglob dotglob nocaseglob && shopt -q nullglob dotglob nocaseglob || exit 3; : *; " \
|
|
1368
|
+
"n=0; while IFS= read -r f; do n=$((n+1)); [ \"$n\" -le 200 ] || exit 3; " \
|
|
1369
|
+
"case $f in -*|*[!a-zA-Z0-9._/@+=,:%-]*) exit 3;; esac; printf \"F:%s\\n\" \"$f\"; done < <(compgen -G \"$2\"); echo OK"
|
|
1370
|
+
cmd = "bash -c " quote_path(script) " guard-copy-glob " quote_path(cwd) " " quote_path(W[d, i]) " 2>/dev/null"
|
|
1371
|
+
while ((cmd | getline line) > 0) {
|
|
1372
|
+
if (line == "OK") { ok = 1; continue }
|
|
1373
|
+
if (ok || substr(line, 1, 2) != "F:" || ++count > 200) { ok = 0; break }
|
|
1374
|
+
}
|
|
1375
|
+
return close(cmd) == 0 && ok
|
|
1376
|
+
}
|
|
1377
|
+
function option_operand(d, i, family, cwd, uncertain) {
|
|
1378
|
+
return !option_shaped_glob(d, i) || (member("cp rsync", family) && copy_source_glob(d, i, cwd, uncertain))
|
|
1379
|
+
}
|
|
1346
1380
|
function option_value(d, i, end) {
|
|
1347
|
-
return i <= end && K[d, i] == "word" && W[d, i] != "" && (Q[d, i] || W[d, i] !~ /[$`*?\[{}]/)
|
|
1381
|
+
return i <= end && K[d, i] == "word" && W[d, i] != "" && (Q[d, i] || W[d, i] !~ /[$`*?\[{}]/) && !(archive_operands && (GL[d, i] || archive_escape(d, i)))
|
|
1348
1382
|
}
|
|
1349
1383
|
# Return the last consumed word, or zero. Option values are data, never another option.
|
|
1350
1384
|
function option_end(d, i, end, family, old, schema, w, key, kind, j, last) {
|
|
@@ -1375,14 +1409,21 @@ function option_end(d, i, end, family, old, schema, w, key, kind, j, last) {
|
|
|
1375
1409
|
}
|
|
1376
1410
|
return last
|
|
1377
1411
|
}
|
|
1378
|
-
function known_options(d, start, end, family, cwd, uncertain, creation, i, w, old, last, schema) {
|
|
1412
|
+
function known_options(d, start, end, family, cwd, uncertain, creation, i, j, w, old, last, schema) {
|
|
1379
1413
|
schema = creation ? "creation:" family : family
|
|
1380
1414
|
for (i = start; i <= end; i++) {
|
|
1381
1415
|
w = W[d, i]
|
|
1382
1416
|
if (redirection(d, i)) break
|
|
1383
|
-
if (
|
|
1417
|
+
if (archive_operands && archive_escape(d, i)) return 0
|
|
1418
|
+
if (w == "--") {
|
|
1419
|
+
if (member("unzip jar ar", family)) return 0
|
|
1420
|
+
# A terminator is not proof for any family: tool behaviour after it is unverified.
|
|
1421
|
+
if (archive_operands) for (j = i + 1; j <= end && !redirection(d, j); j++) if (!option_operand(d, j, family, cwd, uncertain)) return 0
|
|
1422
|
+
return 1
|
|
1423
|
+
}
|
|
1384
1424
|
old = member("tar jar ar", family) && i == start && w ~ /^[a-zA-Z]+$/
|
|
1385
1425
|
if (w !~ /^-/ && !old) {
|
|
1426
|
+
if (archive_operands && !option_operand(d, i, family, cwd, uncertain)) return 0
|
|
1386
1427
|
if (w ~ /[$`]/ && (!Q[d, i] || DQ[d, i]) && (!DQ[d, i] || resolved(w, Q[d, i], cwd, uncertain, DQ[d, i]) == "!")) return 0
|
|
1387
1428
|
continue
|
|
1388
1429
|
}
|
|
@@ -1483,10 +1524,12 @@ function archive_command(d, verb, end, cwd, uncertain, fed, family, i, mode)
|
|
|
1483
1524
|
if (W[d, i] ~ /^@/) { emit("!archive"); return }
|
|
1484
1525
|
}
|
|
1485
1526
|
mode = archive_mode(d, verb + 1, end, family)
|
|
1527
|
+
archive_operands = 1
|
|
1486
1528
|
if (mode == 2) {
|
|
1487
1529
|
if (!known_options(d, verb + 1, end, family, cwd, uncertain, 1)) emit("!archive")
|
|
1488
1530
|
else archive_creation(d, verb, end, cwd, uncertain, family)
|
|
1489
1531
|
} else if (mode != 1 || !known_options(d, verb + 1, end, family, cwd, uncertain)) emit("!archive")
|
|
1532
|
+
archive_operands = 0
|
|
1490
1533
|
}
|
|
1491
1534
|
function creation_output_option(family, flag) {
|
|
1492
1535
|
return (member("tar jar pax", family) && member("-f --file", flag)) ||
|
|
@@ -1942,8 +1985,10 @@ function segment(d, start, end, cwd, uncertain, depth, findpaths, pipe, fed, out
|
|
|
1942
1985
|
else if (w == "find") find_command(d, head, end, cwd, context, depth + 1, fed)
|
|
1943
1986
|
else if (bulk_family(w) != "") {
|
|
1944
1987
|
if (w == "cp" || w == "rsync") {
|
|
1988
|
+
archive_operands = 1
|
|
1945
1989
|
if (fed || !known_options(d, head + 1, end, w, cwd, context)) emit("!")
|
|
1946
1990
|
else copy_effect(d, head, end, cwd, context)
|
|
1991
|
+
archive_operands = 0
|
|
1947
1992
|
} else archive_command(d, head, end, cwd, context, fed, bulk_family(w))
|
|
1948
1993
|
}
|
|
1949
1994
|
else if (destructive(w)) {
|
|
@@ -1961,7 +2006,7 @@ function segment(d, start, end, cwd, uncertain, depth, findpaths, pipe, fed, out
|
|
|
1961
2006
|
function parse(text, cwd, uncertain, depth, fed, n, i, start, kind, level, head, path, old, j, pipe, data) {
|
|
1962
2007
|
# Lex before the depth fallback so properly terminated heredoc bodies stay data.
|
|
1963
2008
|
# A depth slot may be reused by several script words.
|
|
1964
|
-
for (i = 1; i <= N[depth]; i++) { delete W[depth, i]; delete Q[depth, i]; delete DQ[depth, i]; delete CT[depth, i]; delete K[depth, i]; delete H[depth, i]; delete T[depth, i]; delete F[depth, i]; BC[depth, i] = 0 }
|
|
2009
|
+
for (i = 1; i <= N[depth]; i++) { delete W[depth, i]; delete Q[depth, i]; delete DQ[depth, i]; delete CT[depth, i]; delete K[depth, i]; delete H[depth, i]; delete T[depth, i]; delete F[depth, i]; delete GL[depth, i]; delete XF[depth, i]; BC[depth, i] = 0 }
|
|
1965
2010
|
n = lex(text, depth); N[depth] = n; start = 1; level = 0
|
|
1966
2011
|
if (text ~ /(^|[[:space:]])GIT_[A-Z_]+=/) git_context_unknown = 1
|
|
1967
2012
|
if (depth == 0) simple_tool = simple_command(text, depth, n)
|
|
@@ -2006,7 +2051,9 @@ while [ ! -e "$repository_root/.git" ]; do
|
|
|
2006
2051
|
repository_root="${repository_root%/*}"
|
|
2007
2052
|
[ -n "$repository_root" ] || repository_root=/
|
|
2008
2053
|
done
|
|
2009
|
-
|
|
2054
|
+
glob_shell_safe=1
|
|
2055
|
+
if [[ -n "${BASH_ENV+x}" || -n "${ENV+x}" || -n "${GLOBIGNORE+x}" ]]; then glob_shell_safe=0; fi
|
|
2056
|
+
destructive_text="$(GSW_COMMAND="$command_text" GSW_CWD="$cwd" GSW_ROOT="$repository_root" GSW_GLOB_SAFE="$glob_shell_safe" LC_ALL=C awk "$destructive_program" </dev/null)" || parser_failed
|
|
2010
2057
|
if [ -n "$destructive_text" ]; then
|
|
2011
2058
|
destructive_candidates=()
|
|
2012
2059
|
while IFS= read -r candidate; do
|
|
@@ -2034,8 +2081,6 @@ if [ -n "$destructive_text" ]; then
|
|
|
2034
2081
|
exit 2
|
|
2035
2082
|
fi
|
|
2036
2083
|
fi
|
|
2037
|
-
glob_shell_safe=1
|
|
2038
|
-
if [[ -n "${BASH_ENV+x}" || -n "${ENV+x}" || -n "${GLOBIGNORE+x}" ]]; then glob_shell_safe=0; fi
|
|
2039
2084
|
candidates_text="$(GSW_COMMAND="$command_text" GSW_CWD="$cwd" GSW_GLOB_SAFE="$glob_shell_safe" GSW_MODE=targets LC_ALL=C awk "$program" </dev/null)" || parser_failed
|
|
2040
2085
|
[ -n "$candidates_text" ] || exit 0
|
|
2041
2086
|
# The lowercase alias of a mixed-case path serves case-insensitive file systems. Drop it only where the
|
|
@@ -11,13 +11,14 @@ paths:
|
|
|
11
11
|
# Elixir Conventions
|
|
12
12
|
|
|
13
13
|
Use Elixir and OTP idioms, not translated C# or JVM shapes. These conventions
|
|
14
|
-
are grounded in `Cratis/Chronicle.Elixir
|
|
15
|
-
`.formatter.exs`, and `lib/chronicle/`)
|
|
16
|
-
|
|
14
|
+
are grounded in `Cratis/Chronicle.Elixir` 4.x (`Source/chronicle/mix.exs`,
|
|
15
|
+
`.formatter.exs`, and `lib/cratis/chronicle/`) and `Cratis/Arc.Elixir` 1.4.x
|
|
16
|
+
(`lib/cratis/arc/`). Client-specific APIs belong in the
|
|
17
|
+
**cratis-chronicle-client-elixir** skill, Arc APIs in **cratis-arc-elixir**.
|
|
17
18
|
|
|
18
19
|
## Build and format
|
|
19
20
|
|
|
20
|
-
-
|
|
21
|
+
- Use Elixir 1.18 or later (`~> 1.18`); the packages build on 1.19.
|
|
21
22
|
- Run `mix compile --warnings-as-errors`, `mix test`, and
|
|
22
23
|
`mix format --check-formatted` with the project's formatter inputs.
|
|
23
24
|
- Use two-space indentation and let `mix format` own layout.
|
|
@@ -41,6 +42,27 @@ are grounded in `Cratis/Chronicle.Elixir v3.13.0` (`Source/chronicle/mix.exs`,
|
|
|
41
42
|
operational logging and keep credentials out of messages and crash reports.
|
|
42
43
|
- Use American English in identifiers, comments and documentation.
|
|
43
44
|
|
|
45
|
+
## Event-sourced applications on Arc and Chronicle
|
|
46
|
+
|
|
47
|
+
Read the **cratis-arc-elixir** and **cratis-chronicle-client-elixir** skills before touching a slice.
|
|
48
|
+
|
|
49
|
+
- **Folders are Module, Feature, Slice, and sub-features nest.** One folder per behavior, named for what
|
|
50
|
+
it does as a gerund (`RotatingSecrets`); the command inside is the verb. Group slices that act on one
|
|
51
|
+
thing into a sub-feature (`Secrets`, `Credentials`, `Viewing`), and put a reactor with the facts it
|
|
52
|
+
reacts to, not in a folder named for the third party it calls. No folders named for a kind of file.
|
|
53
|
+
- **Names are ids.** `use Cratis.Arc.Command, id: "rotate-secret"`, an event type's `id:`, a reactor's
|
|
54
|
+
`id:`; the model shows the id in PascalCase, so a module can be renamed without renaming the model.
|
|
55
|
+
- **A command and its events live in one file**, events first. An event is past tense, one fact, and
|
|
56
|
+
never carries a secret.
|
|
57
|
+
- **Every slice tells a whole story**: a state change has a command and the events it appends; a view
|
|
58
|
+
has a read model and consumes events (`consumes:` when it reads the event log); an automation reacts to
|
|
59
|
+
an event and records a fact of its own, so the event model shows what it did. A reactor that calls a
|
|
60
|
+
third party returns the event recording that it did.
|
|
61
|
+
- **Order is the story**: a slice that uses events of several sub-features goes in a sub-feature after
|
|
62
|
+
them. Build with `arc: [event_model_strict: true]` so an incomplete model fails the build.
|
|
63
|
+
- **Third parties are integrations behind a behaviour**, with an in-memory stand-in for specs; only
|
|
64
|
+
reactors write to them.
|
|
65
|
+
|
|
44
66
|
Every `.ex` and `.exs` source file starts with:
|
|
45
67
|
|
|
46
68
|
```elixir
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
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.
|
|
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, availability, the generated event model, generated TypeScript proxies and vertical slices grouped into sub-features. Not for the Chronicle client alone, or for .NET, JVM, Go or TypeScript Arc.
|
|
4
4
|
license: MIT
|
|
5
5
|
compatibility: Elixir 1.18 or later; Plug and Bandit, or Phoenix.
|
|
6
6
|
---
|
|
@@ -25,8 +25,8 @@ and with **MongoDB** (`cratis_arc_mongodb`) for documents.
|
|
|
25
25
|
|
|
26
26
|
| Product | Source checked |
|
|
27
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` |
|
|
28
|
+
| Arc for Elixir (`cratis_arc`) | `Source/arc/lib/cratis/arc/{command,read_model,application,pipeline,tenancy,filter,watch,proxy_generator}.ex`, `lib/cratis/arc/plug/{hub_session,hub,sse_hub}.ex`, `Documentation/*.md` |
|
|
29
|
+
| Arc for Elixir MongoDB (`cratis_arc_mongodb`) | `Source/arc_mongodb/lib/cratis/arc/mongodb.ex`, `lib/cratis/arc/mongodb/*.ex` |
|
|
30
30
|
| Samples | `Samples/showcase` (every feature, plain Plug), `Samples/phoenix` (LiveView, Chronicle) |
|
|
31
31
|
|
|
32
32
|
Source is authoritative. `Documentation/` excerpts marked `# From: <path>` are verified
|
|
@@ -37,7 +37,7 @@ against the samples in CI, so prefer them to memory.
|
|
|
37
37
|
```elixir
|
|
38
38
|
defmodule Library.Authors.Registration.RenameAuthor do
|
|
39
39
|
@moduledoc "Renames an author. Only editors may."
|
|
40
|
-
use Arc.Command
|
|
40
|
+
use Cratis.Arc.Command, id: "rename-author"
|
|
41
41
|
authorize roles: ["editor"]
|
|
42
42
|
|
|
43
43
|
schema do
|
|
@@ -50,7 +50,8 @@ defmodule Library.Authors.Registration.RenameAuthor do
|
|
|
50
50
|
end
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
`id:` is the command's kebab-case name: its route is `/api/<namespace>/rename-author`, and the structure
|
|
54
|
+
and the event model show `RenameAuthor`, whatever the module is called. Only `handle/2` is required. The order is validate, `provide/2`, then `handle/2`.
|
|
54
55
|
`handle/2` returns `{:append, event | [events]}`, `{:append, events, response}`,
|
|
55
56
|
`{:ok, response}` (records nothing) or `{:error, results}`. `key: true` marks the event
|
|
56
57
|
source. A handler that returns an event with no key and no source id is rejected as
|
|
@@ -60,13 +61,13 @@ source. A handler that returns an event with no key and no source id is rejected
|
|
|
60
61
|
|
|
61
62
|
```elixir
|
|
62
63
|
defmodule Library.Authors.Listing.Authors do
|
|
63
|
-
use Arc.ReadModel, model: Library.Authors.Author, types: [id: :uuid]
|
|
64
|
+
use Cratis.Arc.ReadModel, model: Library.Authors.Author, types: [id: :uuid]
|
|
64
65
|
|
|
65
66
|
@query many: true
|
|
66
|
-
def all_authors(_args, ctx), do: Chronicle.all(Library.Authors.Author, ctx.chronicle)
|
|
67
|
+
def all_authors(_args, ctx), do: Cratis.Chronicle.all(Library.Authors.Author, ctx.chronicle)
|
|
67
68
|
|
|
68
69
|
@observe many: true, watch: [Library.Authors.Author]
|
|
69
|
-
def live_authors(_args, ctx), do: Chronicle.all(Library.Authors.Author, ctx.chronicle)
|
|
70
|
+
def live_authors(_args, ctx), do: Cratis.Chronicle.all(Library.Authors.Author, ctx.chronicle)
|
|
70
71
|
end
|
|
71
72
|
```
|
|
72
73
|
|
|
@@ -80,14 +81,14 @@ before choosing a transport or a transfer mode.
|
|
|
80
81
|
|
|
81
82
|
```elixir
|
|
82
83
|
defmodule MyApp.Arc do
|
|
83
|
-
use Arc.Application, otp_app: :my_app
|
|
84
|
+
use Cratis.Arc.Application, otp_app: :my_app
|
|
84
85
|
end
|
|
85
86
|
|
|
86
87
|
# in the supervision tree, before the endpoint
|
|
87
88
|
children = [MyApp.Arc, {Bandit, plug: MyApp.Router, port: 4000}]
|
|
88
89
|
|
|
89
90
|
# the router
|
|
90
|
-
plug Arc.Plug, application: MyApp.Arc
|
|
91
|
+
plug Cratis.Arc.Plug, application: MyApp.Arc
|
|
91
92
|
```
|
|
92
93
|
|
|
93
94
|
`MyApp.Arc` **must be in the supervision tree**: it owns the processes behind observable
|
|
@@ -113,8 +114,17 @@ Phoenix and LiveView use the same application in process. Read
|
|
|
113
114
|
- **Organize by feature.** Backend, generated proxies and React page of a feature share a
|
|
114
115
|
folder. `layout: :colocated` generates that layout.
|
|
115
116
|
|
|
116
|
-
- **
|
|
117
|
-
|
|
117
|
+
- **Names are ids.** A command (`id:`), event type (`id:`), reactor (`id:`) and read model (optional `id:`)
|
|
118
|
+
is named by its kebab-case id; `/.cratis/structure` and the event model show it in PascalCase (the
|
|
119
|
+
application's `display_names:` picks `:pascal_case`, `:kebab_case`, `:as_declared` or a function).
|
|
120
|
+
The module name is free, so never read meaning from its last segment.
|
|
121
|
+
- **Group slices into sub-features, and validate the event model.** A folder is a feature, a folder in a
|
|
122
|
+
folder a sub-feature; the board and the Screenplay nest them. A view is drawn after the slices that
|
|
123
|
+
produce what it consumes, and the `:arc_event_model` compiler warns (errors with
|
|
124
|
+
`event_model_strict: true`) about a slice without its command, events or read model. Read
|
|
125
|
+
[references/event-model.md](references/event-model.md) before adding a slice.
|
|
126
|
+
- **Availability ships (v1.3.0).** Read [references/availability.md](references/availability.md) for `available`,
|
|
127
|
+
the definition, suspension and the dev model route.
|
|
118
128
|
|
|
119
129
|
See [references/pitfalls.md](references/pitfalls.md) for the full list, and
|
|
120
130
|
[references/product-sources.md](references/product-sources.md) for package facts.
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
Arc for Elixir ships availability (v1.3.0): the same model as Arc for .NET and Screenplay, in the same words.
|
|
7
7
|
Verify names against the package's `Documentation/availability.md`.
|
|
8
8
|
|
|
9
|
-
It is one gate and runs **first**, before binding, `Arc.Filter`, authorization and validation.
|
|
9
|
+
It is one gate and runs **first**, before binding, `Cratis.Arc.Filter`, authorization and validation.
|
|
10
10
|
|
|
11
11
|
| Decision | Result |
|
|
12
12
|
| --- | --- |
|
|
@@ -29,7 +29,7 @@ config :my_app, MyApp.Arc,
|
|
|
29
29
|
|
|
30
30
|
```elixir
|
|
31
31
|
defmodule MyApp.Availability do
|
|
32
|
-
use Arc.Availability.Definition
|
|
32
|
+
use Cratis.Arc.Availability.Definition
|
|
33
33
|
|
|
34
34
|
audience "Plus", "Customers on the Plus package"
|
|
35
35
|
block "Paid", "Sold with Plus", for: ["Plus", "Admin"]
|
|
@@ -38,37 +38,37 @@ defmodule MyApp.Availability do
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
defmodule MyApp.Fleet.Vessels.DockVessel do
|
|
41
|
-
use Arc.Command
|
|
41
|
+
use Cratis.Arc.Command
|
|
42
42
|
available for: ["Plus", "Admin"], not: "Preview", with: "Reported"
|
|
43
|
-
available when: Arc.Availability.Condition.equal("vessel.package", "Plus")
|
|
43
|
+
available when: Cratis.Arc.Availability.Condition.equal("vessel.package", "Plus")
|
|
44
44
|
end
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
- `for:` audience(s), one is enough; `not:` none may be held; `with:` a named block; `when:` a condition
|
|
48
|
-
(`Arc.Availability.Condition` data shared with other languages, or a module implementing the behaviour).
|
|
48
|
+
(`Cratis.Arc.Availability.Condition` data shared with other languages, or a module implementing the behaviour).
|
|
49
49
|
- On a read model `available` gates every query; `@query available: [...]` gates one query.
|
|
50
|
-
- Module, feature and slice come from `Arc.Descriptor.slice_location/2`.
|
|
50
|
+
- Module, feature and slice come from `Cratis.Arc.Descriptor.slice_location/2`.
|
|
51
51
|
- Conditions read `tenant`, `identity.user`, `arguments.<name>` (camelCase wire name) and `<name>.<path>` of a
|
|
52
52
|
provided value; tenant and identity always come from the server.
|
|
53
53
|
- Three values: available, unavailable, unknown. Only available opens a gate; an absent value is unknown for every
|
|
54
|
-
operator. `Arc.Availability.Engine` passes the shared conformance cases.
|
|
54
|
+
operator. `Cratis.Arc.Availability.Engine` passes the shared conformance cases.
|
|
55
55
|
|
|
56
56
|
## Sources: audiences granted and withdrawn, parts suspended and resumed
|
|
57
57
|
|
|
58
|
-
- `Arc.Availability.AudienceSource`: `grants(subject)` returns the audience names held. Undeclared audiences never match.
|
|
59
|
-
- `Arc.Availability.SuspensionSource`: `suspended/0` returns paths (`"Fleet"`, `"Fleet/Vessels"`,
|
|
58
|
+
- `Cratis.Arc.Availability.AudienceSource`: `grants(subject)` returns the audience names held. Undeclared audiences never match.
|
|
59
|
+
- `Cratis.Arc.Availability.SuspensionSource`: `suspended/0` returns paths (`"Fleet"`, `"Fleet/Vessels"`,
|
|
60
60
|
`"Fleet/Vessels/Dock"`, or a part's full name); suspension is decided before any gate.
|
|
61
|
-
- `Arc.Availability.Memory` serves specifications and samples (`grant/2`, `withdraw/2`, `suspend/1`, `resume/1`).
|
|
62
|
-
- Call `Arc.Availability.changed/1` when a source changes; open sessions decide again, on every node with `:pubsub`.
|
|
61
|
+
- `Cratis.Arc.Availability.Memory` serves specifications and samples (`grant/2`, `withdraw/2`, `suspend/1`, `resume/1`).
|
|
62
|
+
- Call `Cratis.Arc.Availability.changed/1` when a source changes; open sessions decide again, on every node with `:pubsub`.
|
|
63
63
|
|
|
64
64
|
## Client
|
|
65
65
|
|
|
66
66
|
- `/.cratis/availability` is an observable query listing what is unavailable to the caller (name, module, feature,
|
|
67
67
|
slice, reason); `?part=<name>&arguments=<json>` asks about one part. A decision that cannot be made is a retryable error.
|
|
68
68
|
- Generated proxies carry `static readonly part` (part identity).
|
|
69
|
-
- LiveView: `<Arc.LiveView.Availability.available socket={@socket} version={@arc_availability} command={...}>`
|
|
70
|
-
hides a part (`Arc.LiveView.available?/3`). Hiding is presentation; the server still refuses.
|
|
71
|
-
- `Arc.Availability.Manifest.build/1`, `to_json/1`, `decode/1`, `decide/3` use the shared
|
|
69
|
+
- LiveView: `<Cratis.Arc.LiveView.Availability.available socket={@socket} version={@arc_availability} command={...}>`
|
|
70
|
+
hides a part (`Cratis.Arc.LiveView.available?/3`). Hiding is presentation; the server still refuses.
|
|
71
|
+
- `Cratis.Arc.Availability.Manifest.build/1`, `to_json/1`, `decode/1`, `decide/3` use the shared
|
|
72
72
|
`cratis-availability-manifest` (version 1).
|
|
73
73
|
|
|
74
74
|
## Rules
|
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
## Fields
|
|
7
7
|
|
|
8
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.**
|
|
9
|
+
`:date` (`DateOnly`), `:datetime`, `:map`, `{:list, type}`, a `Cratis.Chronicle.Concept` module (the
|
|
10
|
+
primitive it wraps) and a module that `use Cratis.Arc.Schema`. **Nested lists are not supported.**
|
|
11
11
|
Options: `required: true`, `nullable:`, `key: true`, `default:`, `doc:`, `min_length`,
|
|
12
12
|
`max_length`, `email`, `matches`, `min`, `max`, `greater_than`, `less_than`.
|
|
13
13
|
|
|
14
|
-
Use a `Chronicle.Concept` for domain values such as an author id, so the type is declared
|
|
14
|
+
Use a `Cratis.Chronicle.Concept` for domain values such as an author id, so the type is declared
|
|
15
15
|
once and is what Chronicle records.
|
|
16
16
|
|
|
17
17
|
## Callbacks
|
|
@@ -32,8 +32,8 @@ A constraint or concurrency rejection never raises. It is a validation result wi
|
|
|
32
32
|
## Run from code
|
|
33
33
|
|
|
34
34
|
```elixir
|
|
35
|
-
result = Arc.execute(MyApp.Arc, %RegisterAuthor{id: Arc.new_id(), name: "Ada"}, principal: principal)
|
|
36
|
-
Arc.CommandResult.success?(result)
|
|
35
|
+
result = Cratis.Arc.execute(MyApp.Arc, %RegisterAuthor{id: Cratis.Arc.new_id(), name: "Ada"}, principal: principal)
|
|
36
|
+
Cratis.Arc.CommandResult.success?(result)
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
Pass `{RegisterAuthor, %{"id" => "...", "name" => "..."}}` to bind a wire map first.
|
|
@@ -46,7 +46,7 @@ Options: `principal:`, `tenant:`, `correlation_id:`, `metadata:`, `validate_only
|
|
|
46
46
|
`watch: [...]` and `topics: [...]`. Arguments arrive cast; a missing or wrongly typed
|
|
47
47
|
argument is `malformedRequest` before your function runs.
|
|
48
48
|
|
|
49
|
-
`use Arc.ReadModel, types: [id: :uuid]` overrides inferred field types for the proxies:
|
|
49
|
+
`use Cratis.Arc.ReadModel, types: [id: :uuid]` overrides inferred field types for the proxies:
|
|
50
50
|
a struct default of `""` or `nil` reads as a string.
|
|
51
51
|
|
|
52
52
|
## Paging and sorting
|
|
@@ -54,11 +54,11 @@ a struct default of `""` or `nil` reads as a string.
|
|
|
54
54
|
`page` (zero-based), `pageSize`, `sortBy` and `sortDirection` are reserved query-string
|
|
55
55
|
names, matched case-insensitively; `QUERY` requests carry them in the body. A returned
|
|
56
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.
|
|
57
|
+
return `%Cratis.Arc.Page{items:, total:, page:, size:}`; Arc then does not touch the items.
|
|
58
58
|
`ctx.query` holds the requested page, page size and sorting.
|
|
59
59
|
|
|
60
60
|
## Results
|
|
61
61
|
|
|
62
|
-
`Arc.CommandResult.to_wire/1` and `Arc.QueryResult.to_wire/1` are the contract envelopes.
|
|
62
|
+
`Cratis.Arc.CommandResult.to_wire/1` and `Cratis.Arc.QueryResult.to_wire/1` are the contract envelopes.
|
|
63
63
|
An exception becomes `exceptionMessages`; outside development the message is generic and
|
|
64
64
|
the detail is logged with the correlation id.
|