@cratis/pi 7.131.0 → 7.131.2
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/hooks/README.md +6 -4
- package/package/corpus/hooks/scripts/cratis-guard-secrets.sh +790 -61
- package/package/corpus/hooks/scripts/cratis-guard-store-mutations.sh +89 -28
- package/package/corpus/hooks/scripts/cratis-guard-writes.sh +18 -11
- package/package/corpus/hooks/scripts/hook-lib.sh +17 -2
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/SKILL.md +1 -0
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/public-events-and-direction.md +3 -0
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/realization-and-gap-fill.md +2 -1
- package/package/corpus/skills/cratis-screenplay-captures-and-reactions/SKILL.md +2 -2
- package/package/corpus/skills/cratis-screenplay-model-review/references/report-template.md +1 -1
- package/package/corpus/skills/cratis-screenplay-read-surface/references/screen-patterns.md +5 -0
- package/package/corpus/skills/cratis-screenplay-specifications/references/actions-beyond-commands.md +1 -1
- package/package/corpus/skills/cratis-screenplay-specifications/references/source-notes.md +2 -1
- package/package/corpus/skills/cratis-screenplay-specifications/references/vocabulary.md +3 -2
- package/package/corpus/skills/cratis-screenplay-toolchain/references/diagnostics.md +3 -1
- package/package/corpus/skills/cratis-screenplay-toolchain/references/executable-subset.md +2 -2
- package/package/corpus/skills/cratis-screenplay-toolchain/references/traps.md +3 -3
- package/package.json +1 -1
|
@@ -7,13 +7,13 @@
|
|
|
7
7
|
# `chronicle` group, classified against cratis-store-mutations.json. Anything that is not on the
|
|
8
8
|
# read-only allowlist — replay, retry, quarantine clearing, job control, recommendations, users,
|
|
9
9
|
# applications, subscriptions, and any command a newer CLI adds — exits 2 (block the tool call,
|
|
10
|
-
# stderr goes back to the model). Unknown commands fail closed.
|
|
10
|
+
# stderr goes back to the model). Unknown commands fail closed, and so does every call while jq is missing.
|
|
11
11
|
#
|
|
12
12
|
# Other groups (ai, arc, context, llm, screenplay, prologue, completions) and the top-level commands
|
|
13
13
|
# (init, new, render, run, update, version, ...) are out of scope and always allowed.
|
|
14
14
|
#
|
|
15
|
-
# What it sees is the command text. A `cratis` reached through a variable, an alias, a function or
|
|
16
|
-
# script file is invisible to it; see .cratis/ai/hooks/README.md for the full list of limits.
|
|
15
|
+
# What it sees is the command text. A `cratis` reached through a variable, an alias, a function, a glob or
|
|
16
|
+
# brace pattern or a script file is invisible to it; see .cratis/ai/hooks/README.md for the full list of limits.
|
|
17
17
|
#
|
|
18
18
|
# Escape hatch for a human who authorized the mutation — set in the environment the agent harness was
|
|
19
19
|
# started from, never inside the command (an assignment in the command is ignored):
|
|
@@ -31,15 +31,29 @@ set -euo pipefail
|
|
|
31
31
|
|
|
32
32
|
input="$(hook_read_stdin)"
|
|
33
33
|
[ -n "$input" ] || exit 0
|
|
34
|
-
|
|
34
|
+
hook_require_jq cratis-guard-store-mutations CRATIS_HOOKS_ALLOW_STORE_MUTATIONS
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
parser_failed() {
|
|
37
|
+
printf 'BLOCKED by cratis-guard-store-mutations: parser failed%s; cannot check this tool call.\n' "${1:+ ($1)}" >&2
|
|
38
|
+
exit 2
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
command_text="$(jq -r '.tool_input.command // empty' <<<"$input")" || parser_failed
|
|
37
42
|
[ -n "$command_text" ] || exit 0
|
|
38
43
|
|
|
39
|
-
# Cheap exit for the overwhelming majority of shell commands, which never mention the CLI.
|
|
40
|
-
|
|
44
|
+
# Cheap exit for the overwhelming majority of shell commands, which never mention the CLI. The shell reads a
|
|
45
|
+
# word after removing quotes, escapes and line continuations, so the name is looked for in that form; a raw
|
|
46
|
+
# `$'` (an ANSI-C string) goes on to the parser, which decodes it.
|
|
47
|
+
probe=${command_text//\\$'\n'/}
|
|
48
|
+
probe=${probe//[\'\"\\]/}
|
|
49
|
+
probe_lower="$(printf '%s' "$probe" | tr '[:upper:]' '[:lower:]')" || parser_failed
|
|
50
|
+
case "$probe_lower" in
|
|
41
51
|
*cratis*) ;;
|
|
42
|
-
*)
|
|
52
|
+
*)
|
|
53
|
+
case "$command_text" in
|
|
54
|
+
*'$'\'*) ;;
|
|
55
|
+
*) exit 0 ;;
|
|
56
|
+
esac ;;
|
|
43
57
|
esac
|
|
44
58
|
|
|
45
59
|
# ── Command lists: shipped defaults + optional local extension, or a replacement ─────────
|
|
@@ -53,7 +67,7 @@ if [ -f "$data_file" ]; then
|
|
|
53
67
|
merged="$(jq -ce 'select(type == "object" and (.group | type == "string") and
|
|
54
68
|
(.readOnly | type == "array") and (.mutating | type == "array") and
|
|
55
69
|
(.helpOptions | type == "array") and (.versionOptions | type == "array") and
|
|
56
|
-
(.flagOptions | type == "array") and (.valueOptions | type == "array"))' "$data_file" 2>/dev/null ||
|
|
70
|
+
(.flagOptions | type == "array") and (.valueOptions | type == "array"))' "$data_file" 2>/dev/null)" || parser_failed "$data_file"
|
|
57
71
|
fi
|
|
58
72
|
if [ -n "$merged" ] && [ -f "$local_file" ]; then
|
|
59
73
|
# A local file adds entries; it never removes one. A command it lists as mutating is blocked even
|
|
@@ -66,7 +80,7 @@ if [ -n "$merged" ] && [ -f "$local_file" ]; then
|
|
|
66
80
|
then error("invalid local list") else . end
|
|
67
81
|
| $base + (["readOnly", "mutating", "helpOptions", "versionOptions", "flagOptions", "valueOptions"]
|
|
68
82
|
| map({key: ., value: (($base[.] // []) + ($add[.] // []))}) | from_entries)
|
|
69
|
-
' 2>/dev/null ||
|
|
83
|
+
' 2>/dev/null)" || parser_failed "$local_file"
|
|
70
84
|
if [ -n "$extended" ]; then
|
|
71
85
|
merged="$extended"
|
|
72
86
|
else
|
|
@@ -81,16 +95,16 @@ data_ok=1
|
|
|
81
95
|
[ -n "$merged" ] || { data_ok=0; merged='{}'; }
|
|
82
96
|
|
|
83
97
|
list() {
|
|
84
|
-
printf '%s' "$merged" | jq -r "$1" 2>/dev/null
|
|
98
|
+
printf '%s' "$merged" | jq -r "$1" 2>/dev/null
|
|
85
99
|
}
|
|
86
100
|
|
|
87
|
-
group="$(list '.group // "chronicle"')"
|
|
88
|
-
read_only="$(list '(.readOnly // [])[] | .command // empty')"
|
|
89
|
-
mutating="$(list '(.mutating // [])[] | select(.command) | "\(.command)\t\(.effect // "")"')"
|
|
90
|
-
help_options="$(list '(.helpOptions // [])[]')"
|
|
91
|
-
version_options="$(list '(.versionOptions // [])[]')"
|
|
92
|
-
flag_options="$(list '(.flagOptions // [])[]')"
|
|
93
|
-
value_options="$(list '(.valueOptions // [])[]')"
|
|
101
|
+
group="$(list '.group // "chronicle"')" || parser_failed
|
|
102
|
+
read_only="$(list '(.readOnly // [])[] | .command // empty')" || parser_failed
|
|
103
|
+
mutating="$(list '(.mutating // [])[] | select(.command) | "\(.command)\t\(.effect // "")"')" || parser_failed
|
|
104
|
+
help_options="$(list '(.helpOptions // [])[]')" || parser_failed
|
|
105
|
+
version_options="$(list '(.versionOptions // [])[]')" || parser_failed
|
|
106
|
+
flag_options="$(list '(.flagOptions // [])[]')" || parser_failed
|
|
107
|
+
value_options="$(list '(.valueOptions // [])[]')" || parser_failed
|
|
94
108
|
|
|
95
109
|
tab_char="$(printf '\t')"
|
|
96
110
|
|
|
@@ -113,10 +127,11 @@ findings="$(
|
|
|
113
127
|
CSM_VALUES="$value_options" \
|
|
114
128
|
LC_ALL=C awk '
|
|
115
129
|
function toset(text, set, parts, n, k) {
|
|
130
|
+
delete set; delete parts
|
|
116
131
|
n = split(text, parts, "\n")
|
|
117
132
|
for (k = 1; k <= n; k++) if (parts[k] != "") set[tolower(parts[k])] = 1
|
|
118
133
|
}
|
|
119
|
-
function words_in(text, parts) { return split(text, parts, " ") }
|
|
134
|
+
function words_in(text, parts) { delete parts; return split(text, parts, " ") }
|
|
120
135
|
function norm(text) {
|
|
121
136
|
text = tolower(text); gsub(/[ \t]+/, " ", text); sub(/^ /, "", text); sub(/ $/, "", text)
|
|
122
137
|
return text
|
|
@@ -127,8 +142,42 @@ findings="$(
|
|
|
127
142
|
reported[key] = 1
|
|
128
143
|
printf "%s\t%s\t%s\n", kind, path, effect
|
|
129
144
|
}
|
|
145
|
+
# True when text can name the CLI once the shell has read it: quotes, escapes and line continuations removed,
|
|
146
|
+
# or an ANSI-C string that the parser decodes.
|
|
147
|
+
function mentions(text, t) {
|
|
148
|
+
if (index(text, "$\047")) return 1
|
|
149
|
+
t = tolower(text)
|
|
150
|
+
gsub("\\\\\n", "", t); gsub("\047", "", t); gsub("\"", "", t); gsub("\\\\", "", t)
|
|
151
|
+
return index(t, "cratis") > 0
|
|
152
|
+
}
|
|
153
|
+
# Decodes the body of an ANSI-C string (i is just after the opening quote) into word and returns the position
|
|
154
|
+
# after the closing quote. The same decoder is in cratis-guard-secrets.sh (ansi_c).
|
|
155
|
+
function ansi_c(s, i, n, c, c2, v, d, k, lim, stop, digits) {
|
|
156
|
+
stop = 0
|
|
157
|
+
while (i <= n) {
|
|
158
|
+
c = substr(s, i, 1)
|
|
159
|
+
if (c == "\047") return i + 1
|
|
160
|
+
if (c != "\\") { if (!stop) word = word c; i++; continue }
|
|
161
|
+
c2 = substr(s, i + 1, 1); i += 2; v = -1
|
|
162
|
+
if (c2 in ESC) v = ESC[c2]
|
|
163
|
+
else if (c2 ~ /^[0-7]$/) {
|
|
164
|
+
v = c2 + 0
|
|
165
|
+
for (k = 0; k < 2 && substr(s, i, 1) ~ /^[0-7]$/; k++) { v = v * 8 + substr(s, i, 1); i++ }
|
|
166
|
+
v = v % 256
|
|
167
|
+
} else if (c2 == "x" || c2 == "u" || c2 == "U") {
|
|
168
|
+
lim = (c2 == "x") ? 2 : (c2 == "u") ? 4 : 8; v = 0; digits = 0
|
|
169
|
+
while (digits < lim && (d = tolower(substr(s, i, 1))) != "" && (d in HEX)) { v = v * 16 + HEX[d]; i++; digits++ }
|
|
170
|
+
if (digits == 0) { if (!stop) word = word "\\" c2; continue }
|
|
171
|
+
if (c2 != "x" && v >= 128) { if (!stop) word = word "?"; continue }
|
|
172
|
+
} else if (c2 == "c" && i <= n) { v = ORD[substr(s, i, 1)] % 32; i++ }
|
|
173
|
+
else { if (!stop) word = word "\\" c2; continue }
|
|
174
|
+
if (v == 0) stop = 1
|
|
175
|
+
else if (!stop) word = word CH[v]
|
|
176
|
+
}
|
|
177
|
+
return i
|
|
178
|
+
}
|
|
130
179
|
function enqueue(text) {
|
|
131
|
-
if (text == "" || !
|
|
180
|
+
if (text == "" || !mentions(text)) return
|
|
132
181
|
queue[++queued] = text
|
|
133
182
|
}
|
|
134
183
|
function base(word) { word = tolower(word); sub(/.*\//, "", word); return word }
|
|
@@ -186,7 +235,7 @@ findings="$(
|
|
|
186
235
|
if (test == delimiter[k]) break
|
|
187
236
|
body = body line "\n"
|
|
188
237
|
}
|
|
189
|
-
if (
|
|
238
|
+
if (mentions(body) && candidates < 256) candidate[++candidates] = body
|
|
190
239
|
}
|
|
191
240
|
pending = 0
|
|
192
241
|
return i
|
|
@@ -228,6 +277,8 @@ findings="$(
|
|
|
228
277
|
if (c == "#" && !inword) { while (i <= n && substr(s, i, 1) != "\n") i++; continue }
|
|
229
278
|
if (c == "$") {
|
|
230
279
|
c2 = substr(s, i + 1, 1)
|
|
280
|
+
if (c2 == "\047") { inword = 1; quoted = 1; i = ansi_c(s, i + 2, n); continue }
|
|
281
|
+
if (c2 == "\"") { in_dq = 1; inword = 1; quoted = 1; i += 2; continue }
|
|
231
282
|
if (c2 == "(" && substr(s, i + 2, 1) == "(") { j = skip_group(s, i + 1, "(", ")"); word = word substr(s, i, j - i); inword = 1; i = j; continue }
|
|
232
283
|
if (c2 == "(") { push("subst"); i += 2; continue }
|
|
233
284
|
if (c2 == "{") { j = skip_group(s, i + 1, "{", "}"); word = word substr(s, i, j - i); inword = 1; i = j; continue }
|
|
@@ -289,6 +340,7 @@ findings="$(
|
|
|
289
340
|
|
|
290
341
|
# ── simple commands ──
|
|
291
342
|
function analyze(text, parts, n, k) {
|
|
343
|
+
delete parts
|
|
292
344
|
n = split(text, parts, SEP)
|
|
293
345
|
for (k = 1; k <= n; k++) { Q[k] = substr(parts[k], 1, 1); W[k] = substr(parts[k], 2) }
|
|
294
346
|
count = n
|
|
@@ -342,7 +394,8 @@ findings="$(
|
|
|
342
394
|
eq = index(lower, "=")
|
|
343
395
|
return eq > 1 && (substr(lower, 1, eq - 1) in value_option)
|
|
344
396
|
}
|
|
345
|
-
function classify(first, j, m, x, t, lower, name, values, only_options, count_words,
|
|
397
|
+
function classify(first, j, m, x, t, lower, name, values, only_options, count_words, command_words, shown, key) {
|
|
398
|
+
delete command_words; delete shown
|
|
346
399
|
values = " "
|
|
347
400
|
for (j = first; j <= count; j++) {
|
|
348
401
|
lower = tolower(W[j])
|
|
@@ -381,12 +434,12 @@ findings="$(
|
|
|
381
434
|
if (known_value(lower)) continue
|
|
382
435
|
break
|
|
383
436
|
}
|
|
384
|
-
count_words++;
|
|
437
|
+
count_words++; command_words[count_words] = lower; shown[count_words] = W[m]
|
|
385
438
|
}
|
|
386
439
|
if (count_words == 0) { report("unknown", "cratis " W[j], ""); return }
|
|
387
440
|
for (m = count_words; m >= 1; m--) {
|
|
388
|
-
key =
|
|
389
|
-
for (x = 2; x <= m; x++) { key = key " "
|
|
441
|
+
key = command_words[1]; t = shown[1]
|
|
442
|
+
for (x = 2; x <= m; x++) { key = key " " command_words[x]; t = t " " shown[x] }
|
|
390
443
|
if (key in mutating) { report("mutating", "cratis " W[j] " " t, mutating[key]); return }
|
|
391
444
|
if (key in read_only) return
|
|
392
445
|
}
|
|
@@ -405,7 +458,7 @@ findings="$(
|
|
|
405
458
|
read_only[key] = 1
|
|
406
459
|
if (words_in(key) > max_depth) max_depth = words_in(key)
|
|
407
460
|
}
|
|
408
|
-
n = split(ENVIRON["CSM_MUTATING"], lines, "\n")
|
|
461
|
+
delete lines; n = split(ENVIRON["CSM_MUTATING"], lines, "\n")
|
|
409
462
|
for (k = 1; k <= n; k++) {
|
|
410
463
|
tab = index(lines[k], "\t"); if (tab == 0) continue
|
|
411
464
|
key = norm(substr(lines[k], 1, tab - 1)); if (key == "") continue
|
|
@@ -421,14 +474,22 @@ findings="$(
|
|
|
421
474
|
toset("!\n{\n}\nif\nthen\nelse\nelif\ndo\nwhile\nuntil\ntime", keyword)
|
|
422
475
|
toset("env\ncommand\nexec\nbuiltin\nnohup\ntime\nnice\nionice\nsudo\ndoas\ntimeout\ngtimeout\nxargs\nparallel\nstdbuf\nunbuffer\ncaffeinate\nwatch\nrtk\ndotnet\narch\nssh\nnoglob\nnocorrect\ntaskset\nflock\nsetsid\nchronic", wrapper)
|
|
423
476
|
|
|
477
|
+
# Decoding tables for ANSI-C strings.
|
|
478
|
+
for (k = 1; k < 256; k++) { CH[k] = sprintf("%c", k); ORD[CH[k]] = k }
|
|
479
|
+
delete lines; n = split("0 1 2 3 4 5 6 7 8 9 a b c d e f", lines, " ")
|
|
480
|
+
for (k = 1; k <= n; k++) HEX[lines[k]] = k - 1
|
|
481
|
+
delete lines; n = split("a b e E f n r t v", lines, " "); split("7 8 27 27 12 10 13 9 11", codes, " ")
|
|
482
|
+
for (k = 1; k <= n; k++) ESC[lines[k]] = codes[k] + 0
|
|
483
|
+
ESC["\\"] = 92; ESC["\047"] = 39; ESC["\""] = 34; ESC["?"] = 63
|
|
484
|
+
|
|
424
485
|
queued = 1; queue[1] = ENVIRON["CSM_COMMAND"]
|
|
425
486
|
for (done = 1; done <= queued; done++) {
|
|
426
487
|
if (done > 64) { report("unparsed", "(more than 64 nested shell scripts)", ""); break }
|
|
427
|
-
if (
|
|
488
|
+
if (mentions(queue[done])) parse(queue[done])
|
|
428
489
|
}
|
|
429
490
|
}
|
|
430
491
|
'
|
|
431
|
-
)" ||
|
|
492
|
+
)" || parser_failed
|
|
432
493
|
|
|
433
494
|
[ -n "$findings" ] || exit 0
|
|
434
495
|
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
# 3. Environment files — .env and friends (secrets)
|
|
10
10
|
# 4. Agent controls — permissions, hooks and installed managed corpus/adapters
|
|
11
11
|
#
|
|
12
|
+
# While jq is missing the guard cannot read the tool call, so it refuses every call.
|
|
13
|
+
#
|
|
12
14
|
# .cratis/ai.json allowDependencyManifestWrites overrides only the manifest policy:
|
|
13
15
|
# true allows them in any repository; false blocks them even in a Cratis repository.
|
|
14
16
|
#
|
|
@@ -31,10 +33,15 @@ script_directory="${BASH_SOURCE[0]%/*}"
|
|
|
31
33
|
input=""
|
|
32
34
|
IFS= read -r -d '' input || true
|
|
33
35
|
[ -n "$input" ] || exit 0
|
|
34
|
-
|
|
36
|
+
hook_require_jq cratis-guard-writes CRATIS_HOOKS_ALLOW_PROTECTED_WRITES
|
|
37
|
+
|
|
38
|
+
parser_failed() {
|
|
39
|
+
printf '%s\n' 'BLOCKED by cratis-guard-writes: parser failed; cannot check this tool call.' >&2
|
|
40
|
+
exit 2
|
|
41
|
+
}
|
|
35
42
|
|
|
36
43
|
# One jq call reads every field the guard uses. Fields are NUL-terminated (embedded NULs are dropped,
|
|
37
|
-
# as a command substitution would drop them); a missing, null
|
|
44
|
+
# as a command substitution would drop them); a missing, null or false path is empty.
|
|
38
45
|
cwd="" file="" notebook="" new_content="" new_string=""
|
|
39
46
|
{
|
|
40
47
|
IFS= read -r -d '' cwd
|
|
@@ -49,7 +56,9 @@ cwd="" file="" notebook="" new_content="" new_string=""
|
|
|
49
56
|
[field(.cwd), field(.tool_input.file_path), field(.tool_input.notebook_path),
|
|
50
57
|
field(.tool_input.content), field(.tool_input.new_string)]
|
|
51
58
|
| .[] | ., "\u0000"
|
|
52
|
-
' <<<"$input" 2>/dev/null) ||
|
|
59
|
+
' <<<"$input" 2>/dev/null) || parser_failed
|
|
60
|
+
# Process substitutions do not propagate their exit status to the reading group.
|
|
61
|
+
wait "$!" || parser_failed
|
|
53
62
|
# Command substitution stripped trailing newlines from each field; keep that behaviour.
|
|
54
63
|
for field_name in cwd file notebook new_content new_string; do
|
|
55
64
|
while [[ "${!field_name}" == *$'\n' ]]; do printf -v "$field_name" '%s' "${!field_name%$'\n'}"; done
|
|
@@ -177,7 +186,7 @@ origin_matches() {
|
|
|
177
186
|
|
|
178
187
|
# ── 4. Agent controls and installed managed trees ─────────────────────────────
|
|
179
188
|
agent_control_target() {
|
|
180
|
-
local target="$1" directory policy_root target_rel
|
|
189
|
+
local target="$1" directory policy_root target_rel managed
|
|
181
190
|
dir_of "$target"
|
|
182
191
|
directory="$REPLY"
|
|
183
192
|
# Keep the addressed spelling here, even when an adapter directory is a symlink.
|
|
@@ -196,18 +205,16 @@ agent_control_target() {
|
|
|
196
205
|
.claude/* | .pi/*)
|
|
197
206
|
# The installer records adapter ownership in Integrations (Path, IsDirectory),
|
|
198
207
|
# not Files: those destinations are relative to the managed corpus root.
|
|
199
|
-
#
|
|
200
|
-
|
|
201
|
-
if jq -e --arg path "$target_rel" '
|
|
208
|
+
# A readable manifest must establish ownership before classifying local adapters.
|
|
209
|
+
managed="$(jq -r --arg path "$target_rel" '
|
|
202
210
|
(.Integrations // [])
|
|
203
211
|
| if type != "array" then false else
|
|
204
212
|
[.[] | select(type == "object") | select(.Path | type == "string")]
|
|
205
213
|
| any(.[]; . as $entry | $entry.Path == $path
|
|
206
214
|
or ($entry.IsDirectory == true and ($path | startswith($entry.Path + "/"))))
|
|
207
215
|
end
|
|
208
|
-
' "$policy_root/.cratis/ai.manifest.json" >/dev/null
|
|
209
|
-
|
|
210
|
-
fi
|
|
216
|
+
' "$policy_root/.cratis/ai.manifest.json" 2>/dev/null)" || parser_failed
|
|
217
|
+
[ "$managed" != "true" ] || return 0
|
|
211
218
|
;;
|
|
212
219
|
esac
|
|
213
220
|
else
|
|
@@ -284,7 +291,7 @@ manifest_writes_allowed() {
|
|
|
284
291
|
policy_root="$(git -C "$directory" rev-parse --show-toplevel 2>/dev/null)" || return 1
|
|
285
292
|
if [ -f "$policy_root/.cratis/ai.json" ]; then
|
|
286
293
|
# Only actual booleans override the default; jq's `// empty` would discard false.
|
|
287
|
-
setting="$(jq -r '.allowDependencyManifestWrites | select(type == "boolean") | tostring' "$policy_root/.cratis/ai.json" 2>/dev/null ||
|
|
294
|
+
setting="$(jq -r '.allowDependencyManifestWrites | select(type == "boolean") | tostring' "$policy_root/.cratis/ai.json" 2>/dev/null)" || parser_failed
|
|
288
295
|
fi
|
|
289
296
|
case "$setting" in
|
|
290
297
|
true) return 0 ;;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# Shared helpers for the Cratis enforcement hooks.
|
|
3
3
|
#
|
|
4
|
-
# Sourced by cratis-guard-
|
|
5
|
-
# cratis-quality-gate.sh.
|
|
4
|
+
# Sourced by cratis-guard-secrets.sh, cratis-guard-writes.sh, cratis-guard-store-mutations.sh,
|
|
5
|
+
# cratis-pattern-scan.sh and cratis-quality-gate.sh.
|
|
6
6
|
# Portable: bash 3.2 (macOS system bash) and up, BSD + GNU userland. No GNU-only flags,
|
|
7
7
|
# no `mapfile`/`readarray`, no associative arrays, no `eval`.
|
|
8
8
|
set -euo pipefail
|
|
@@ -34,6 +34,21 @@ hook_read_stdin() {
|
|
|
34
34
|
cat 2>/dev/null || true
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
# Refuse the tool call when jq is missing: $1 is the guard name, $2 the variable that lets a person run without it.
|
|
38
|
+
# A guard that cannot read the tool call cannot check it, so this ends the sourcing script with exit 2
|
|
39
|
+
# (the deny signal every wired harness honors). It uses only builtins, so it works without jq.
|
|
40
|
+
hook_require_jq() {
|
|
41
|
+
hook_have jq && return 0
|
|
42
|
+
{
|
|
43
|
+
printf 'BLOCKED by %s: jq is not installed, so this guard cannot read the tool call and refuses every call until it is.\n' "$1"
|
|
44
|
+
printf 'Stop and ask the user to install jq (macOS: brew install jq; Debian/Ubuntu: sudo apt-get install jq;\n'
|
|
45
|
+
printf 'Windows: winget install jqlang.jq), then retry. Do not work around the guard.\n'
|
|
46
|
+
printf 'A person who accepts running without this guard sets %s=1 in the environment the agent\n' "$2"
|
|
47
|
+
printf 'harness was started from; setting it inside the command has no effect.\n'
|
|
48
|
+
} >&2
|
|
49
|
+
exit 2
|
|
50
|
+
}
|
|
51
|
+
|
|
37
52
|
# Extract a single scalar from a JSON document on $1 using the jq path in $2.
|
|
38
53
|
# Prints the empty string when jq is absent, the JSON is malformed, or the path is null.
|
|
39
54
|
hook_json() {
|
|
@@ -59,6 +59,7 @@ A todo list + reaction + unique constraint proves the first. It does **not** pro
|
|
|
59
59
|
the send can succeed and the append fail (crash, lost reply, constraint race), and the retry
|
|
60
60
|
sends again.
|
|
61
61
|
|
|
62
|
+
- A specification runs its own slice only: to prove an automation that invokes another slice's command, state `then invokes <Command>` with the values passed (ESM v34); that command's own slice states its events. A command spec never states what another slice's reaction appends.
|
|
62
63
|
- A reaction cascade is not one transaction: earlier accepted facts stay when a later invoked
|
|
63
64
|
command rejects (Screenplay `reactions.md`). Design each step to be retried on its own.
|
|
64
65
|
- Read `references/effects-and-idempotency.md` when specifying redelivery,
|
|
@@ -178,6 +178,9 @@ append without `when` holds on any change, not on every delivery. Maps apply to
|
|
|
178
178
|
before and after states; `$.field` reads the mapped merged state. An expression
|
|
179
179
|
guard evaluates the after state only on a change. Root `when removed` never holds.
|
|
180
180
|
|
|
181
|
+
A command's specification never states the public event an outbound Translate slice publishes
|
|
182
|
+
(`PLAY0285`, decision 0115); the outbound slice's own specification does.
|
|
183
|
+
|
|
181
184
|
Captures run after reactions to the same input settle; each capture append settles
|
|
182
185
|
its own cascade before the next. Mixed capture/reaction assertions may need
|
|
183
186
|
`then events in any order`: reference order does not prove independent observer
|
|
@@ -9,7 +9,8 @@ The CLI and Stage render supported event-triggered Automation slices as Chronicl
|
|
|
9
9
|
reactors. Translate/captures, non-event triggers and opaque bodies remain `STAGE-ESM-024`;
|
|
10
10
|
Claim-reading/opaque `runs as` gates (`-034`), legacy `from` (`-035`), mixed effects (`-037`), unsupported mappings (`-039`)
|
|
11
11
|
and protected destinations (`-040`) also remain refused. Command specs that cascade into
|
|
12
|
-
reactions remain `-011
|
|
12
|
+
reactions remain `-011`. Specifications that state the commands their reactions invoke
|
|
13
|
+
(`then invokes`, ESM v34) are not yet admitted either: check current boundaries. Supported single-hop append specs now render, as do semantic
|
|
13
14
|
reaction `from` and role/authenticated system identities. Only refused scope is hand-written delivery with the model as
|
|
14
15
|
its contract. Source: Stage `Documentation/reference/reaction-rendering.md`;
|
|
15
16
|
full admission: `cratis-stage-rendering-and-sandbox` `references/admission.md`.
|
|
@@ -28,7 +28,7 @@ Language claims follow Screenplay `reactions.md`, `triggers.md`, `captures.md` a
|
|
|
28
28
|
|
|
29
29
|
The compiler's ESM admission decides, not the slice type. Reactions, triggers and
|
|
30
30
|
captures bind/reference-execute from v6; older compilers refuse them. Read toolchain
|
|
31
|
-
`references/diagnostics.md` when diagnosing skew or
|
|
31
|
+
`references/diagnostics.md` when diagnosing skew or `PLAY0285`/`PLAY0816` on a specification.
|
|
32
32
|
- **Stage realization:** read `cratis-stage-rendering-and-sandbox` `references/admission.md`
|
|
33
33
|
before claiming rendering. Supported event-triggered Automation renders; captures,
|
|
34
34
|
Translate, clocks and opaque bodies remain gap-fill (`-024`).
|
|
@@ -225,7 +225,7 @@ Requires Screenplay 4.176.0 or later (`screenplay --version`) for PLAY0694; olde
|
|
|
225
225
|
|
|
226
226
|
- [ ] `screenplay <model> --warnaserror` reports zero errors and zero warnings
|
|
227
227
|
(standalone, or a `cratis` whose compiler admits ESM v6). Under an older compiler expect
|
|
228
|
-
`PLAY0268` at binding and
|
|
228
|
+
`PLAY0268` at binding, and `then invokes` unreadable before 4.246.0 (ESM v34); report them
|
|
229
229
|
as tool skew.
|
|
230
230
|
- [ ] The tool that bound the model is named (standalone, or a `cratis` whose compiler admits ESM v6, for ESM v6 constructs); reference scenarios use
|
|
231
231
|
`screenplay test`/MCP. Unadmitted refusal/redelivery is not executed evidence.
|
|
@@ -40,7 +40,7 @@ V2 executable diagnostics: <clean | n diagnostics: codes | not run: reason>
|
|
|
40
40
|
V3 binding-ready: <ready | blocked: codes | not run: reason>
|
|
41
41
|
V4 reference specs run: <route, expected vs discovered, passed/failed/unsupported; overall unbound | not run: no route>
|
|
42
42
|
V5 rendered, target-verified: admission <...>; publication <...>; build <...>; tests <...> (each "not run: reason" when absent)
|
|
43
|
-
Gaps: <capability gaps and tool-version gaps, e.g.
|
|
43
|
+
Gaps: <capability gaps and tool-version gaps, e.g. `then invokes` unreadable by a compiler older than 4.246.0>
|
|
44
44
|
|
|
45
45
|
## Inventory (read-only audit; MCP describe-application view=summary, find-assertion-gaps)
|
|
46
46
|
Modules n, features n, slices n (StateChange n, StateView n, Automation n, Translate n),
|
|
@@ -118,6 +118,11 @@ module Berths
|
|
|
118
118
|
action BookBerth for screen
|
|
119
119
|
```
|
|
120
120
|
|
|
121
|
+
State what an action acts on: `action CancelBooking for item` acts on the selected row or the record the screen shows,
|
|
122
|
+
`action BookBerth for screen` does not depend on a selection. An omitted subject is inferred from the declared data
|
|
123
|
+
and identifier types and reported as `PLAY0818` (and `PLAY0819` when the row binding differs from legacy name matching),
|
|
124
|
+
so write the clause. Source: Screenplay v5.1.0 `Documentation/screenplay/action-subjects.md`.
|
|
125
|
+
|
|
121
126
|
## What a screen pattern is not
|
|
122
127
|
|
|
123
128
|
- Not a column or a lane: a screen is a declaration in a slice, not a position on a timeline.
|
package/package/corpus/skills/cratis-screenplay-specifications/references/actions-beyond-commands.md
CHANGED
|
@@ -29,7 +29,7 @@ projection is the fact's occurrence time: the reference runner executes it in `f
|
|
|
29
29
|
**Which tools bind these actions.** A compiler that admits ESM v6 binds the clock, trigger
|
|
30
30
|
and capture actions, and the `Automation` and `Translate` slices, reactions and captures they
|
|
31
31
|
drive; the reference runner executes them through `screenplay test` or MCP `run-specifications`,
|
|
32
|
-
with the semantics in [Reactions and
|
|
32
|
+
with the semantics in [Reactions and one slice per specification](reactions-and-cascades.md). The complete example in
|
|
33
33
|
that reference reports `executableReady` with no executable error in `open-workspace` readiness
|
|
34
34
|
and `read-workspace` view `executable-diagnostics`.
|
|
35
35
|
|
|
@@ -16,7 +16,8 @@ Actions beyond commands (`given clock`, `when clock`, `when trigger`, `given cap
|
|
|
16
16
|
| Parser, binder and reference execution | Original evidence for the worked example |
|
|
17
17
|
| Inline facts, `optional` and clock spelling | Changed examples compile; the reference runner was not rerun for them |
|
|
18
18
|
| ESM v7 | Generated fixtures and `then returns` (`specifications.md` "Generated fixtures and return expectations"): the excerpt matches the compiled example in `cratis-screenplay-toolchain`, whose specifications run in the reference runner |
|
|
19
|
-
| ESM
|
|
19
|
+
| ESM v34 | `then invokes`; a specification runs its own slice only (Screenplay decision 0115, `Documentation/screenplay/specifications.md`) |
|
|
20
|
+
| ESM v6 | Specification actions and same-slice reactions, `then no readmodel`, `$strings` rejections, `invokes` caller rule |
|
|
20
21
|
|
|
21
22
|
The inline-facts update followed `commands.md`, `events.md`, `types.md` and
|
|
22
23
|
`specifications.md`. That pass compiled the changed examples; it did not rerun the reference
|
|
@@ -13,7 +13,7 @@ This reference holds the given/when/then construct table and the enumeration and
|
|
|
13
13
|
| `given readmodel <ReadModelType>` | prior read-model state, established directly — a **complete** instance including its identifier |
|
|
14
14
|
| `given caller` / `given caller as <Persona>` | explicit caller (`authenticated`, roles, claims; empty means anonymous), or an authenticated synthesized persona witness |
|
|
15
15
|
| `when <CommandType>` | run a command |
|
|
16
|
-
| `when append <EventType>` | append one event: constraints and projections run, the command does not; reactions run
|
|
16
|
+
| `when append <EventType>` | append one event: constraints and projections run, the command does not; only the specification's own slice's reactions run (ESM v6), and `then` lists what followed |
|
|
17
17
|
| `when query <Query>` | perform a query with the argument values beneath it |
|
|
18
18
|
| `then result [exactly]` | one expected row of the performed query; repeat for several |
|
|
19
19
|
| `then no result` | the performed query returns nothing |
|
|
@@ -23,7 +23,8 @@ This reference holds the given/when/then construct table and the enumeration and
|
|
|
23
23
|
| `given capture` / `when capture <Capture>` | earlier/current records for non-event sources; for `source events` use typed `given <Event>` / `when append <Event>` (PLAY0701) |
|
|
24
24
|
| `generated <name> = <value>` | beneath `when <Command>`: the fixture for a generated property other than the identifier (ESM v7); `for` beneath the `when` supplies the generated identifier |
|
|
25
25
|
| `then returns [<value>]` | the command's response (ESM v7): `then returns "<uuid>"` for a scalar, `then returns` with named `field = value` lines for a subset of a record |
|
|
26
|
-
| `then <EventType>` | an expected new event |
|
|
26
|
+
| `then <EventType>` | an expected new event of the specification's own slice |
|
|
27
|
+
| `then invokes <Command>` | a command the slice's own reactions invoke, with the values passed beneath it (ESM v34, Screenplay 4.246.0) |
|
|
27
28
|
| `then events in any order` | compare the new events without regard to order |
|
|
28
29
|
| `then readmodel <ReadModelType> [exactly]` | read-model state afterwards — must state the identifier |
|
|
29
30
|
| `then no readmodel <ReadModelType> for <key>` | exactly that keyed instance is absent; the key is concrete and typed |
|
|
@@ -396,7 +396,9 @@ or V4 execution. Run the CLI or MCP for those verdicts.
|
|
|
396
396
|
| PLAY0282 | `validate` rule targets a field absent from the command |
|
|
397
397
|
| PLAY0283 | `reads View by field` type matches no `by` param of the view's queries |
|
|
398
398
|
| PLAY0284 | `children`/`nested` never populates a declared element field |
|
|
399
|
-
| PLAY0285 | a spec's `then` event contradicts every possible declared producer of its `when` command (decidable literals, property copies, equality conditions).
|
|
399
|
+
| PLAY0285 | a spec's `then` event contradicts every possible declared producer of its `when` command (decidable literals, property copies, equality conditions). Follows only reactions, invocations and publications declared in the specification's own slice (decision 0115), so stating another slice's reaction event or an outbound publication is refused; move the `then` to that slice or state `then invokes <Command>`. Fix the model or the spec deliberately |
|
|
400
|
+
| PLAY0815 | a specification `then invokes` line is not `then invokes <Command>` |
|
|
401
|
+
| PLAY0816 | a specification states `then invokes <Command>`, but no reaction declared in its own slice invokes that command; a specification runs its own slice only, so the invocation can never be made |
|
|
400
402
|
| PLAY0286 | spec value is not a member of the enum |
|
|
401
403
|
| PLAY0287 | producer/capture/spec assigns a field the event lacks |
|
|
402
404
|
| PLAY0291-0294 | bad single-line JSON / unknown key / wrong shape / duplicate key |
|
|
@@ -161,10 +161,10 @@ Requires Screenplay 4.105.0 or later (`screenplay --version`) for list queries (
|
|
|
161
161
|
due **after** the given clock and **at or before** the when clock, once each, in time
|
|
162
162
|
order. `when clock` needs `given clock`. Limits: 10,000 occurrences per advance, 1,000
|
|
163
163
|
facts per scenario. A scenario with given equal to when fires nothing.
|
|
164
|
-
- Command specifications that list reaction
|
|
164
|
+
- Command specifications that list another slice's reaction events (`PLAY0285`; decision 0115).
|
|
165
165
|
- In a `then` list after `when append`, only what followed the appended event.
|
|
166
166
|
|
|
167
|
-
Requires Screenplay 4.61 or later (`screenplay --version`) for ESM v6 constructs, and Cratis CLI 3.28.2 or later for the bundled compiler; older compilers refuse them with PLAY0268
|
|
167
|
+
Requires Screenplay 4.61 or later (`screenplay --version`) for ESM v6 constructs, and Cratis CLI 3.28.2 or later for the bundled compiler; older compilers refuse them with PLAY0268. `then invokes` needs Screenplay 4.246.0 (ESM v34).
|
|
168
168
|
|
|
169
169
|
Requires Screenplay 4.125.0 or later (`screenplay --version`) for reaction `runs as system`.
|
|
170
170
|
|
|
@@ -17,9 +17,9 @@ Compiler syntax: `cheat-sheet.md`. Negative capability claims depend on the tool
|
|
|
17
17
|
13. Projection `key` routes only on `from` (projection-level: PLAY0381). `all` is per event source. Joins never create instances and match the joined event's source id.
|
|
18
18
|
14. AutoMap is on by default: same-named event properties fill read-model properties silently (scoped: case-insensitive, same type only; flat-bound: exact name, no type check, so a type mismatch invalidates the model). Use `no automap` for control.
|
|
19
19
|
15. `given readmodel` bypasses the projection; prove a projection with `given` events + `when append`/command + `then readmodel`/`then query`.
|
|
20
|
-
16. PLAY0285/0286/0287 are static spec checks: do not edit expectations blindly.
|
|
20
|
+
16. PLAY0285/0286/0287 are static spec checks: do not edit expectations blindly. A spec runs its own slice only (decision 0115): PLAY0285 on an event another slice's reaction appends is correct, so move the `then` to that slice or state `then invokes <Command>` (ESM v34, PLAY0815/0816).
|
|
21
21
|
17. `null` in specs only for optional read-model properties (PLAY0350). A `when` command or `then` event states every property with a concrete value, optional ones too (PLAY0524); whether an optional detail is really a separate fact is a review question, not the fix for this code.
|
|
22
|
-
18. `then` events are exhaustive and ordered (use `then events in any order` for order only).
|
|
22
|
+
18. `then` events are exhaustive and ordered (use `then events in any order` for order only). They are the facts of the specification's own slice (its reactions follow, other slices' do not); after `when append` they list only what followed the append.
|
|
23
23
|
19. Under `command reads protected`, omitted `by` uses the command identifier; absent identifier is PLAY0782. Eligible reads bind v25; legacy reads and `concurrency` retain PLAY0271. Combining reads/concurrency under opt-in is PLAY0783.
|
|
24
24
|
20. Declare each event once, in its producing slice; renaming a persisted event needs `id "OldName"`; renaming a constraint discards its index.
|
|
25
25
|
21. Quoted `import "x/*.play"` = my files; unquoted `import Ctx.Event` = another context's contract (does not bind: PLAY0268).
|
|
@@ -36,7 +36,7 @@ Compiler syntax: `cheat-sheet.md`. Negative capability claims depend on the tool
|
|
|
36
36
|
30. Claims compare with `matches` (`claim "dept" matches "Finance"`); `==` is PLAY0120. Conditions with `contains`/`starts with` compile but do not bind.
|
|
37
37
|
31. One `every`/`all` block per projection level for V3; `$eventContext.occurred.Week` does not bind.
|
|
38
38
|
32. Concept rules: `min`/`max`/`length ==`, not `length 3 to 10` (PLAY0141).
|
|
39
|
-
33. Which compiler matters: an older cratis bundle can reject constructs the standalone tool binds (ESM v6 Automation/Translate) and
|
|
39
|
+
33. Which compiler matters: an older cratis bundle can reject constructs the standalone tool binds (ESM v6 Automation/Translate) and cannot read `then invokes` (ESM v34). Check `cratis --version` and name the tool in every verdict.
|
|
40
40
|
|
|
41
41
|
34. A `from <Event> key <property>` routes only if every such event carries that property: an event that frees or updates a row keyed by another stream's id must carry that id in its payload, or the row never changes. The compiler may not report a missing key property; check by hand.
|
|
42
42
|
35. `description`/`documentation` are authoring metadata: board, MCP and Prologue show them; `cratis render` emits them only as XML doc comments (invalid XML characters are CLI-RENDER-005), never as behavior. A rule only in prose is unenforced in rendered code; make it a rule layer, a spec or a recorded target requirement.
|