operbe 1.0.0-rc.2 → 1.0.0-rc.3
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/README.md +26 -22
- package/conformance/describe/edge/body.json +1 -1
- package/conformance/describe/edge/digest +1 -1
- package/conformance/describe/edge/project/operbe.md +1 -1
- package/conformance/describe/example/body.json +1 -1
- package/conformance/describe/example/digest +1 -1
- package/conformance/describe/example/project/behaviors/B-0001.md +13 -9
- package/conformance/describe/example/project/behaviors/B-0002.md +1 -1
- package/conformance/describe/example/project/behaviors/B-0003.md +2 -2
- package/conformance/describe/example/project/behaviors/B-0004.md +2 -2
- package/conformance/describe/example/project/behaviors/B-0005.md +2 -2
- package/conformance/describe/example/project/behaviors/coverage/mcp.md +9 -0
- package/conformance/describe/example/project/operbe.md +9 -5
- package/conformance/diff/core/a/behaviors/B-0002.md +1 -1
- package/conformance/diff/core/a/behaviors/B-0003.md +1 -1
- package/conformance/diff/core/a/operbe.md +5 -5
- package/conformance/diff/core/b/behaviors/B-0002.md +1 -1
- package/conformance/diff/core/b/behaviors/B-0003.md +1 -1
- package/conformance/diff/core/b/operbe.md +5 -5
- package/conformance/diff/core/changes.json +45 -17
- package/conformance/diff/declared/a/operbe.md +1 -1
- package/conformance/diff/declared/b/operbe.md +1 -1
- package/conformance/diff/reworded/a/behaviors/B-0002.md +1 -1
- package/conformance/diff/reworded/a/behaviors/B-0003.md +1 -1
- package/conformance/diff/reworded/a/operbe.md +5 -5
- package/conformance/diff/reworded/b/behaviors/B-0002.md +1 -1
- package/conformance/diff/reworded/b/behaviors/B-0003.md +1 -1
- package/conformance/diff/reworded/b/operbe.md +5 -5
- package/dist/check.d.ts +1 -1
- package/dist/check.js +124 -67
- package/dist/cli.js +19 -15
- package/dist/describe.js +23 -20
- package/dist/diff.js +35 -24
- package/dist/indexes.js +20 -12
- package/dist/read.d.ts +8 -6
- package/dist/read.js +39 -15
- package/dist/reconcile.d.ts +2 -2
- package/dist/reconcile.js +12 -13
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
- package/schema/description.schema.json +26 -9
- package/skills/operbe/SKILL.md +42 -16
- package/skills/operbe/example/behaviors/B-0001.md +13 -9
- package/skills/operbe/example/behaviors/B-0002.md +1 -1
- package/skills/operbe/example/behaviors/B-0003.md +2 -2
- package/skills/operbe/example/behaviors/B-0004.md +2 -2
- package/skills/operbe/example/behaviors/B-0005.md +2 -2
- package/skills/operbe/example/behaviors/coverage/mcp.md +9 -0
- package/skills/operbe/example/operbe.md +9 -5
- package/skills/operbe/references/actions.md +226 -0
- package/skills/operbe/references/adopting.md +6 -6
- package/skills/operbe/references/behaviors.md +75 -59
- package/skills/operbe/references/formats.md +69 -51
- package/skills/operbe/references/operations.md +13 -14
- package/skills/operbe/references/tandem.md +31 -30
- package/skills/operbe/templates/{client-action.md → action.md} +3 -3
- package/skills/operbe/templates/behavior.md +1 -1
- package/skills/operbe/templates/coverage.md +1 -1
- package/skills/operbe/templates/operbe.md +1 -1
- package/skills/operbe/references/client-actions.md +0 -211
- /package/conformance/describe/example/project/{client-actions → actions}/archive-conversation.md +0 -0
- /package/conformance/describe/example/project/{client-actions → actions}/show-conversations.md +0 -0
- /package/conformance/describe/example/project/{client-actions → actions}/start-retitle.md +0 -0
- /package/conformance/describe/example/project/{client-actions → actions}/unarchive-conversation.md +0 -0
- /package/conformance/diff/core/a/{client-actions → actions}/archive-conversation.md +0 -0
- /package/conformance/diff/core/a/{client-actions → actions}/show-conversations.md +0 -0
- /package/conformance/diff/core/a/{client-actions → actions}/start-retitle.md +0 -0
- /package/conformance/diff/core/a/{client-actions → actions}/unarchive-conversation.md +0 -0
- /package/conformance/diff/core/b/{client-actions → actions}/archive-conversation.md +0 -0
- /package/conformance/diff/core/b/{client-actions → actions}/show-conversations.md +0 -0
- /package/conformance/diff/core/b/{client-actions → actions}/unarchive-conversation.md +0 -0
- /package/conformance/diff/reworded/a/{client-actions → actions}/archive-conversation.md +0 -0
- /package/conformance/diff/reworded/a/{client-actions → actions}/show-conversations.md +0 -0
- /package/conformance/diff/reworded/a/{client-actions → actions}/start-retitle.md +0 -0
- /package/conformance/diff/reworded/a/{client-actions → actions}/unarchive-conversation.md +0 -0
- /package/conformance/diff/reworded/b/{client-actions → actions}/archive-conversation.md +0 -0
- /package/conformance/diff/reworded/b/{client-actions → actions}/show-conversations.md +0 -0
- /package/conformance/diff/reworded/b/{client-actions → actions}/start-retitle.md +0 -0
- /package/conformance/diff/reworded/b/{client-actions → actions}/unarchive-conversation.md +0 -0
- /package/skills/operbe/example/{client-actions → actions}/archive-conversation.md +0 -0
- /package/skills/operbe/example/{client-actions → actions}/show-conversations.md +0 -0
- /package/skills/operbe/example/{client-actions → actions}/start-retitle.md +0 -0
- /package/skills/operbe/example/{client-actions → actions}/unarchive-conversation.md +0 -0
package/dist/check.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { list, section, str } from "./read.js";
|
|
1
|
+
import { items as valuesOf, list, section, str } from "./read.js";
|
|
2
2
|
const CLASSES = ["query", "change", "signal"];
|
|
3
3
|
const REASONS = ["side-effect", "different-right", "together", "restricted-state", "intent"];
|
|
4
4
|
const RISKS = ["reads", "changes", "destroys", "changes-rights"];
|
|
@@ -15,12 +15,17 @@ const B_ID = /^B-\p{Nd}+$/u;
|
|
|
15
15
|
// The unprefixed fields each kind may carry. Unprefixed names are operbe's namespace, so any other
|
|
16
16
|
// is a typo (`aprove:`) or a field that belongs under an architecture's prefix.
|
|
17
17
|
export const KNOWN = {
|
|
18
|
-
"profile": ["operbe", "operations", "behaviors", "
|
|
18
|
+
"profile": ["operbe", "operations", "behaviors", "actions", "front-ends", "groups", "operations-offered-on", "architectures"],
|
|
19
19
|
"operation": ["name", "class", "named-because", "needs", "safe-to-repeat", "taken-back-by", "risk", "many-at-once"],
|
|
20
|
-
"behavior": ["id", "name", "status", "form", "applies-to", "operations", "replaced-by", "
|
|
21
|
-
"
|
|
20
|
+
"behavior": ["id", "name", "status", "form", "applies-to", "operations", "replaced-by", "actions"],
|
|
21
|
+
"action": ["name", "class", "status", "form", "behaviors", "operations", "show-because", "local", "available-when", "applies-to", "replaced-by"],
|
|
22
22
|
"architecture": ["architecture", "format"],
|
|
23
23
|
};
|
|
24
|
+
// Names from before 1.0.0-rc.3, each with its new name: one word per concept, inside and out.
|
|
25
|
+
const RENAMED = {
|
|
26
|
+
profile: { "uis": "front-ends", "client-actions": "actions" },
|
|
27
|
+
behavior: { "client-actions": "actions" },
|
|
28
|
+
};
|
|
24
29
|
const VERSION = "1"; // the profile's `operbe:` this build reads
|
|
25
30
|
// Lists the way check.py printed them (Python's list form), so messages match.
|
|
26
31
|
const py = (xs) => `[${xs.map((x) => `'${x}'`).join(", ")}]`;
|
|
@@ -29,6 +34,7 @@ const sorted = (xs) => [...xs].sort();
|
|
|
29
34
|
export const whole = (v) => /^[0-9]+$/.test(v) && Number.isSafeInteger(Number(v));
|
|
30
35
|
const items = (text) => [...text.matchAll(/^- ([^:\n]+):/gm)].map((m) => m[1].trim()); // "- name: ..." list items
|
|
31
36
|
const sends = (cls) => cls === "change" || cls === "signal";
|
|
37
|
+
const isMap = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
32
38
|
export function check(m) {
|
|
33
39
|
const out = [...m.findings];
|
|
34
40
|
if (!m.profile)
|
|
@@ -53,16 +59,25 @@ export function check(m) {
|
|
|
53
59
|
const needSections = (r, titles) => { for (const t of titles)
|
|
54
60
|
if (!has(r, t))
|
|
55
61
|
err(r, "operbe/section-missing", `missing or empty section '${t}'`); };
|
|
56
|
-
|
|
62
|
+
// applies-to: `all`, a group, or a list of front ends and groups; a group stands for its front ends.
|
|
63
|
+
const groupOf = (n) => (Object.hasOwn(m.groups, n) && Array.isArray(m.groups[n]) ? m.groups[n] : null);
|
|
64
|
+
const appliesTo = (r) => {
|
|
65
|
+
const a = r.fields["applies-to"]?.value;
|
|
66
|
+
if (a === "all")
|
|
67
|
+
return m.frontEnds;
|
|
68
|
+
const names = typeof a === "string" ? [a] : Array.isArray(a) ? a : [];
|
|
69
|
+
return [...new Set(names.flatMap((n) => groupOf(n) ?? [n]))];
|
|
70
|
+
};
|
|
57
71
|
const appliesOk = (r) => {
|
|
58
72
|
const a = r.fields["applies-to"]?.value;
|
|
59
73
|
if (a === "all")
|
|
60
74
|
return;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
75
|
+
const names = typeof a === "string" && a ? [a] : Array.isArray(a) ? a : [];
|
|
76
|
+
if (!names.length)
|
|
77
|
+
return err(r, "operbe/applies-to", "applies-to must be 'all', a group, or a list of front ends", "applies-to");
|
|
78
|
+
for (const u of names)
|
|
79
|
+
if (!m.frontEnds.includes(u) && !groupOf(u))
|
|
80
|
+
err(r, "operbe/applies-to", `applies-to names '${u}', which is not a front end or a group in operbe.md`, "applies-to");
|
|
66
81
|
};
|
|
67
82
|
const formOf = (r) => (whole(str(r, "form")) ? Number(str(r, "form")) : 0);
|
|
68
83
|
const formOk = (r) => { if (formOf(r) < 1)
|
|
@@ -87,7 +102,10 @@ export function check(m) {
|
|
|
87
102
|
const fieldsOk = (r) => {
|
|
88
103
|
for (const k of Object.keys(r.fields)) {
|
|
89
104
|
const dot = k.indexOf(".");
|
|
90
|
-
|
|
105
|
+
const old = RENAMED[r.kind], renamed = old && Object.hasOwn(old, k) ? old[k] : undefined; // own keys only: `constructor` is just a name
|
|
106
|
+
if (dot < 0 && renamed && !(renamed in r.fields))
|
|
107
|
+
err(r, "operbe/renamed", `'${k}' was renamed '${renamed}' in operbe 1.0.0-rc.3; write '${renamed}:'`, k);
|
|
108
|
+
else if (dot < 0) {
|
|
91
109
|
if (!KNOWN[r.kind].includes(k))
|
|
92
110
|
err(r, "operbe/unknown-field", `'${k}' is not an operbe field; an architecture's field takes its prefix ('${archs[0] ?? "<architecture>"}.${k}')`, k);
|
|
93
111
|
}
|
|
@@ -107,8 +125,7 @@ export function check(m) {
|
|
|
107
125
|
const applies = (d, r) => {
|
|
108
126
|
if (d.required === "yes" || d.required === "no")
|
|
109
127
|
return d.required === "yes";
|
|
110
|
-
|
|
111
|
-
return (Array.isArray(v) ? v : [v]).some((x) => d.required.is.includes(x));
|
|
128
|
+
return valuesOf(r.fields[d.required.when]?.value).some((x) => d.required.is.includes(x));
|
|
112
129
|
};
|
|
113
130
|
const declaredOk = (r) => {
|
|
114
131
|
for (const a of m.architectures)
|
|
@@ -123,37 +140,52 @@ export function check(m) {
|
|
|
123
140
|
(str(r, "status") === "rough" ? gap : err)(r, `${a.name}/field-missing`, `missing '${d.field}', which ${a.file} requires${why}`, d.field);
|
|
124
141
|
}
|
|
125
142
|
else if (d.values)
|
|
126
|
-
for (const x of
|
|
143
|
+
for (const x of valuesOf(v))
|
|
127
144
|
if (!d.values.includes(x))
|
|
128
145
|
err(r, `${a.name}/field-value`, `${d.field} '${x}' must be one of [${d.values.join(", ")}]`, d.field);
|
|
129
146
|
}
|
|
130
147
|
};
|
|
131
148
|
// 0. The profile.
|
|
132
149
|
if (readable(p)) {
|
|
133
|
-
need(p, ["operbe", "operations", "behaviors", "uis"]);
|
|
150
|
+
need(p, ["operbe", "operations", "behaviors", ...("uis" in p.fields ? [] : ["front-ends"])]); // an old `uis` is reported as renamed
|
|
134
151
|
if ("operbe" in p.fields && str(p, "operbe") !== VERSION)
|
|
135
152
|
err(p, "operbe/version", `this build of operbe reads 'operbe: ${VERSION}'; this project says '${str(p, "operbe")}'`, "operbe");
|
|
136
153
|
for (const t of ["Decisions", "Known deviations"])
|
|
137
154
|
if (!p.sections.some((s) => s.title === t))
|
|
138
155
|
err(p, "operbe/section-missing", `missing section '${t}'`);
|
|
139
156
|
fieldsOk(p);
|
|
157
|
+
if ("front-ends" in p.fields)
|
|
158
|
+
asList(p, "front-ends");
|
|
159
|
+
if ("operations-offered-on" in p.fields)
|
|
160
|
+
asList(p, "operations-offered-on");
|
|
161
|
+
// Groups: a map of named lists of front ends. A group's name is never a front end's, or `all`.
|
|
162
|
+
const g = p.fields.groups?.value;
|
|
163
|
+
if (g !== undefined && !isMap(g))
|
|
164
|
+
err(p, "operbe/groups", "groups is written as 'groups:' and then one indented 'name: [a, b]' line per group", "groups");
|
|
165
|
+
for (const [name, fes] of Object.entries(m.groups)) {
|
|
166
|
+
if (name === "all" || m.frontEnds.includes(name))
|
|
167
|
+
err(p, "operbe/groups", `group '${name}' has the name of ${name === "all" ? "'all'" : "a front end"}; name it something else`, "groups");
|
|
168
|
+
for (const fe of fes)
|
|
169
|
+
if (!m.frontEnds.includes(fe))
|
|
170
|
+
err(p, "operbe/groups", `group '${name}' names '${fe}', which is not a front end in operbe.md`, "groups");
|
|
171
|
+
}
|
|
140
172
|
}
|
|
141
|
-
const { operations: opsDir, behaviors: behDir,
|
|
173
|
+
const { operations: opsDir, behaviors: behDir, actions: actDir } = m.folders;
|
|
142
174
|
for (const d of [opsDir, behDir])
|
|
143
175
|
if (m.absent.includes(d))
|
|
144
176
|
err(p, "operbe/folder-missing", `the folder '${d.split("/").pop()}' it names does not exist`, d === opsDir ? "operations" : "behaviors");
|
|
145
177
|
let actions = actDir !== null;
|
|
146
178
|
if (actDir === "") {
|
|
147
|
-
if (!m.findings.some((f) => f.rule === "operbe/path" && f.field === "
|
|
148
|
-
err(p, "operbe/
|
|
179
|
+
if (!m.findings.some((f) => f.rule === "operbe/path" && f.field === "actions"))
|
|
180
|
+
err(p, "operbe/actions-folder", "actions is empty; name the folder, or remove the line", "actions");
|
|
149
181
|
actions = false;
|
|
150
182
|
}
|
|
151
183
|
else if (actDir !== null && (actDir === opsDir || actDir === behDir)) {
|
|
152
|
-
err(p, "operbe/
|
|
184
|
+
err(p, "operbe/actions-folder", "actions must be a folder of its own", "actions");
|
|
153
185
|
actions = false;
|
|
154
186
|
}
|
|
155
187
|
else if (actDir !== null && m.absent.includes(actDir)) {
|
|
156
|
-
err(p, "operbe/folder-missing", `the folder '${actDir.split("/").pop()}' it names does not exist`, "
|
|
188
|
+
err(p, "operbe/folder-missing", `the folder '${actDir.split("/").pop()}' it names does not exist`, "actions");
|
|
157
189
|
actions = false;
|
|
158
190
|
}
|
|
159
191
|
// The declarations themselves: a `when <field>` names a field the record kind can carry.
|
|
@@ -228,8 +260,7 @@ export function check(m) {
|
|
|
228
260
|
err(b, "operbe/status", `status must be one of ${py(sorted(STATUSES))}`, "status");
|
|
229
261
|
formOk(b);
|
|
230
262
|
appliesOk(b);
|
|
231
|
-
const
|
|
232
|
-
for (const o of bOps)
|
|
263
|
+
for (const o of asList(b, "operations"))
|
|
233
264
|
if (!ops.has(o))
|
|
234
265
|
err(b, "operbe/unknown-reference", `operation '${o}' is not in the operation list`, "operations");
|
|
235
266
|
replacedOk(b, "behavior");
|
|
@@ -241,7 +272,7 @@ export function check(m) {
|
|
|
241
272
|
const examples = section(b, "Examples").match(/^- /gm)?.length ?? 0;
|
|
242
273
|
if (status === "firm" && examples < 2)
|
|
243
274
|
err(b, "operbe/examples", "a firm behavior needs at least two examples");
|
|
244
|
-
behaviors.set(id, { rec: b, name, status, form: formOf(b),
|
|
275
|
+
behaviors.set(id, { rec: b, name, status, form: formOf(b), fes: appliesTo(b), callable: (str(b, "actions") || str(b, "client-actions")) !== "none" }); // rc.2's name is reported as renamed, and still read
|
|
245
276
|
}
|
|
246
277
|
for (const b of m.behaviors) {
|
|
247
278
|
const r = str(b, "replaced-by");
|
|
@@ -250,7 +281,7 @@ export function check(m) {
|
|
|
250
281
|
}
|
|
251
282
|
const acts = new Map();
|
|
252
283
|
if (actions) {
|
|
253
|
-
for (const a of m.
|
|
284
|
+
for (const a of m.actions) {
|
|
254
285
|
if (!readable(a))
|
|
255
286
|
continue;
|
|
256
287
|
const name = str(a, "name"), cls = str(a, "class"), status = str(a, "status");
|
|
@@ -266,7 +297,7 @@ export function check(m) {
|
|
|
266
297
|
err(a, "operbe/status", `status must be one of ${py(sorted(STATUSES))}`, "status");
|
|
267
298
|
const behs = asList(a, "behaviors");
|
|
268
299
|
if (!behs.length)
|
|
269
|
-
err(a, "operbe/behaviors-empty", "
|
|
300
|
+
err(a, "operbe/behaviors-empty", "an action must name at least one behavior that describes it", "behaviors");
|
|
270
301
|
for (const id of behs) {
|
|
271
302
|
const known = behaviors.get(id);
|
|
272
303
|
if (!known)
|
|
@@ -274,31 +305,31 @@ export function check(m) {
|
|
|
274
305
|
else if (known.status === "retired" && status !== "retired")
|
|
275
306
|
err(a, "operbe/behavior-retired", `behavior '${id}' is retired`, "behaviors");
|
|
276
307
|
else if (!known.callable)
|
|
277
|
-
err(a, "operbe/behavior-not-callable", `behavior '${id}' says '
|
|
308
|
+
err(a, "operbe/behavior-not-callable", `behavior '${id}' says 'actions: none', but this action names it`, "behaviors");
|
|
278
309
|
}
|
|
279
310
|
const used = asList(a, "operations");
|
|
280
311
|
for (const o of used)
|
|
281
312
|
if (!ops.has(o))
|
|
282
313
|
err(a, "operbe/unknown-reference", `operation '${o}' is not in the operation list`, "operations");
|
|
283
|
-
const sent = used.filter((o) => sends(ops.get(o)));
|
|
314
|
+
const sent = used.filter((o) => sends(ops.get(o))); // the changes and signals it calls
|
|
284
315
|
const local = str(a, "local") === "yes", because = str(a, "show-because").trim();
|
|
285
|
-
// The class must not lie: a show
|
|
316
|
+
// The class must not lie: a show calls only queries, unless the project decided the change is
|
|
286
317
|
// a consequence the person already agreed to, and says so in show-because.
|
|
287
318
|
if (cls === "show" && sent.length && !because)
|
|
288
|
-
err(a, "operbe/show-sends", `a show may
|
|
319
|
+
err(a, "operbe/show-sends", `a show may call only queries, but lists ${py(sent)}; if the project decided this change is already agreed to, say why in 'show-because'`, "operations");
|
|
289
320
|
if (a.fields["show-because"]?.value && !(cls === "show" && sent.length))
|
|
290
321
|
err(a, "operbe/show-because", "'show-because' is only for a show that lists a change", "show-because");
|
|
291
322
|
if (cls === "do" && !sent.length && !local)
|
|
292
|
-
err(a, "operbe/do-sends", "a do must
|
|
323
|
+
err(a, "operbe/do-sends", "a do must call at least one operation that is a change or a signal, or say 'local: yes'", "operations");
|
|
293
324
|
if (local && cls !== "do")
|
|
294
325
|
err(a, "operbe/local", "'local: yes' is only for a do", "local");
|
|
295
326
|
if (cls === "prepare" && sent.length)
|
|
296
|
-
gap(a, "operbe/prepare-sends", `a prepare that
|
|
327
|
+
gap(a, "operbe/prepare-sends", `a prepare that calls ${py(sent)}; make sure nobody else can see or is bound by what it leaves`, "operations");
|
|
297
328
|
if (!a.fields["available-when"]?.value)
|
|
298
329
|
err(a, "operbe/available-when", "available-when is empty; write 'always' if there is no condition", "available-when");
|
|
299
330
|
formOk(a);
|
|
300
331
|
appliesOk(a);
|
|
301
|
-
replacedOk(a, "
|
|
332
|
+
replacedOk(a, "action");
|
|
302
333
|
needSections(a, ["Sentence", "Result"]);
|
|
303
334
|
for (const s of a.sections)
|
|
304
335
|
if (!A_ORDER.includes(s.title))
|
|
@@ -317,29 +348,36 @@ export function check(m) {
|
|
|
317
348
|
err(a, "operbe/result", `result '${k}' must be one of ${py(sorted(A_RESULTS))}`);
|
|
318
349
|
if (section(a, "Result") && !kinds.includes("done"))
|
|
319
350
|
err(a, "operbe/result", "Result must say what 'done' reports");
|
|
320
|
-
acts.set(name, { status, behaviors: behs, form: formOf(a),
|
|
351
|
+
acts.set(name, { rec: a, status, behaviors: behs, form: formOf(a), fes: appliesTo(a) });
|
|
321
352
|
}
|
|
322
|
-
for (const a of m.
|
|
353
|
+
for (const a of m.actions) {
|
|
323
354
|
const r = str(a, "replaced-by");
|
|
324
355
|
if (r && !acts.has(r))
|
|
325
|
-
err(a, "operbe/unknown-reference", `replaced-by '${r}' is not
|
|
356
|
+
err(a, "operbe/unknown-reference", `replaced-by '${r}' is not an action`, "replaced-by");
|
|
357
|
+
}
|
|
358
|
+
// Behaviors describe actions. Nothing is inferred: only `applies-to` and `actions: none` opt out.
|
|
359
|
+
// An action applies no wider than the behaviors that describe it, taken together.
|
|
360
|
+
for (const [name, a] of acts) {
|
|
361
|
+
const described = a.behaviors.map((id) => behaviors.get(id)).filter((b) => b !== undefined);
|
|
362
|
+
if (!described.length)
|
|
363
|
+
continue; // already an error above
|
|
364
|
+
const covered = new Set(described.flatMap((b) => b.fes));
|
|
365
|
+
for (const fe of a.fes)
|
|
366
|
+
if (!covered.has(fe))
|
|
367
|
+
err(a.rec, "operbe/action-wider", `${name} applies to ${fe}, but no behavior that describes it does`, "applies-to");
|
|
326
368
|
}
|
|
327
|
-
// A firm behavior that sends something should be callable, or say why not.
|
|
328
|
-
const carried = new Set([...acts.values()].filter((a) => a.status !== "retired").flatMap((a) => a.behaviors));
|
|
329
|
-
for (const [id, b] of behaviors)
|
|
330
|
-
if (b.status === "firm" && b.sends && b.callable && !carried.has(id))
|
|
331
|
-
gap(b.rec, "operbe/not-carried", `${id} '${b.name}' is firm, sends a change or a signal, and no client action carries it out (or mark it 'client-actions: none')`);
|
|
332
369
|
}
|
|
333
370
|
// 4. Coverage. A coverage finding is about a file, not a record header, so it is built by hand.
|
|
334
371
|
const table = new Map(); // "id\0ui" -> value
|
|
335
|
-
const key = (id,
|
|
336
|
-
for (const
|
|
337
|
-
const { file, lines } = m.coverage[
|
|
372
|
+
const key = (id, fe) => `${id}\0${fe}`;
|
|
373
|
+
for (const fe of m.frontEnds) {
|
|
374
|
+
const { file, lines } = m.coverage[fe];
|
|
338
375
|
const cov = (level, rule, message, line, record) => out.push({ rule, level, file, ...(line ? { line } : {}), ...(record ? { record } : {}), message });
|
|
339
376
|
if (!lines) {
|
|
340
|
-
cov("gap", "operbe/coverage-missing", "no coverage file for this
|
|
377
|
+
cov("gap", "operbe/coverage-missing", "no coverage file for this front end yet");
|
|
341
378
|
continue;
|
|
342
379
|
}
|
|
380
|
+
let rows = 0;
|
|
343
381
|
for (const { line, cells } of lines) {
|
|
344
382
|
const first = cells[0], known = behaviors.has(first) || acts.has(first);
|
|
345
383
|
if (!known && !B_ID.test(first) && !(acts.size && NAME.test(first)))
|
|
@@ -349,15 +387,16 @@ export function check(m) {
|
|
|
349
387
|
continue;
|
|
350
388
|
}
|
|
351
389
|
const [id, value, form, note] = cells;
|
|
390
|
+
rows++;
|
|
352
391
|
if (!known) {
|
|
353
|
-
cov("error", "operbe/unknown-reference", `${id} is not a behavior` + (acts.size ? " or
|
|
392
|
+
cov("error", "operbe/unknown-reference", `${id} is not a behavior` + (acts.size ? " or an action" : ""), line, id);
|
|
354
393
|
continue;
|
|
355
394
|
}
|
|
356
395
|
const b = behaviors.get(id) ?? acts.get(id);
|
|
357
|
-
if (table.has(key(id,
|
|
396
|
+
if (table.has(key(id, fe)))
|
|
358
397
|
cov("error", "operbe/coverage-duplicate", `${id} has more than one line`, line, id);
|
|
359
|
-
if (!b.
|
|
360
|
-
cov("error", "operbe/coverage-
|
|
398
|
+
if (!b.fes.includes(fe))
|
|
399
|
+
cov("error", "operbe/coverage-front-end", `${id} doesn't apply to ${fe}`, line, id);
|
|
361
400
|
if (!COVER.includes(value))
|
|
362
401
|
cov("error", "operbe/coverage-value", `${id}: value must be one of ${py(sorted(COVER))}`, line, id);
|
|
363
402
|
if (["differs", "limited", "not-here"].includes(value) && !note)
|
|
@@ -372,28 +411,46 @@ export function check(m) {
|
|
|
372
411
|
}
|
|
373
412
|
if (value === "differs")
|
|
374
413
|
cov("gap", "operbe/coverage-differs", `${id} differs (${note})`, line, id);
|
|
375
|
-
table.set(key(id,
|
|
414
|
+
table.set(key(id, fe), value);
|
|
376
415
|
}
|
|
416
|
+
if (!rows)
|
|
417
|
+
cov("gap", "operbe/coverage-missing", "this front end's coverage file has no lines yet");
|
|
377
418
|
}
|
|
378
|
-
// Only
|
|
379
|
-
const missing = (
|
|
380
|
-
for (const [id, b] of behaviors) // the forward check: firm means every
|
|
419
|
+
// Only front ends the profile lists: one that it doesn't is already an applies-to error.
|
|
420
|
+
const missing = (fe, id, message) => out.push({ rule: "operbe/not-built", level: "gap", file: m.coverage[fe].file, record: id, message });
|
|
421
|
+
for (const [id, b] of behaviors) // the forward check: firm means every front end builds it
|
|
381
422
|
if (b.status === "firm")
|
|
382
|
-
for (const
|
|
383
|
-
if (m.
|
|
384
|
-
missing(
|
|
385
|
-
for (const [name, a] of acts) // every
|
|
386
|
-
for (const
|
|
387
|
-
if (!m.coverage[
|
|
423
|
+
for (const fe of b.fes)
|
|
424
|
+
if (m.frontEnds.includes(fe) && !table.has(key(id, fe)))
|
|
425
|
+
missing(fe, id, `${id} '${b.name}' is firm and not yet built`);
|
|
426
|
+
for (const [name, a] of acts) // every front end offers each firm action, or says why not
|
|
427
|
+
for (const fe of a.fes) {
|
|
428
|
+
if (!m.coverage[fe]?.lines)
|
|
388
429
|
continue;
|
|
389
|
-
if (!table.has(key(name,
|
|
430
|
+
if (!table.has(key(name, fe))) {
|
|
390
431
|
if (a.status === "firm")
|
|
391
|
-
missing(
|
|
432
|
+
missing(fe, name, `action '${name}' is firm and not yet built`);
|
|
433
|
+
}
|
|
434
|
+
else if (table.get(key(name, fe)) !== "not-here")
|
|
435
|
+
for (const id of a.behaviors) // an action built before a behavior that describes it
|
|
436
|
+
if (behaviors.get(id)?.fes.includes(fe) && !table.has(key(id, fe)))
|
|
437
|
+
missing(fe, name, `action '${name}' is built, but ${id}, which describes it, has no coverage line`);
|
|
438
|
+
}
|
|
439
|
+
// Every behavior a person can ask for describes an action on each front end it applies to, unless
|
|
440
|
+
// that front end's coverage line says not-here (opting out is written down, never inferred).
|
|
441
|
+
const live = [...acts.values()].filter((a) => a.status !== "retired");
|
|
442
|
+
if (actions)
|
|
443
|
+
for (const [id, b] of behaviors) {
|
|
444
|
+
if (b.status === "retired" || !b.callable)
|
|
445
|
+
continue;
|
|
446
|
+
const describes = live.filter((a) => a.behaviors.includes(id));
|
|
447
|
+
if (!describes.length) {
|
|
448
|
+
gap(b.rec, "operbe/action-missing", `${id} '${b.name}' describes no action; name it in an action's behaviors, or mark it 'actions: none'`);
|
|
449
|
+
continue;
|
|
392
450
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
missing(ui, name, `client action '${name}' is built, but ${id} which it carries out has no coverage line`);
|
|
451
|
+
for (const fe of b.fes)
|
|
452
|
+
if (m.frontEnds.includes(fe) && table.get(key(id, fe)) !== "not-here" && !describes.some((a) => a.fes.includes(fe)))
|
|
453
|
+
gap(b.rec, "operbe/action-missing", `${id} '${b.name}' describes no action on ${fe}`);
|
|
397
454
|
}
|
|
398
455
|
return out;
|
|
399
456
|
}
|
|
@@ -411,12 +468,12 @@ export function counts(m, findings) {
|
|
|
411
468
|
errors: findings.filter((f) => f.level === "error").length,
|
|
412
469
|
gaps: findings.filter((f) => f.level === "gap").length,
|
|
413
470
|
behaviors: tally(m.behaviors),
|
|
414
|
-
|
|
471
|
+
actions: m.folders.actions ? tally(m.actions) : null,
|
|
415
472
|
};
|
|
416
473
|
}
|
|
417
|
-
// "0 errors · 18 gaps · behaviors 0/240 firm ·
|
|
474
|
+
// "0 errors · 18 gaps · behaviors 0/240 firm · actions 0/162 firm"
|
|
418
475
|
export function summary(c) {
|
|
419
476
|
const firm = (t) => `${t.firm}/${t.firm + t.rough} firm`;
|
|
420
477
|
const n = (k, w) => `${k} ${w}${k === 1 ? "" : "s"}`;
|
|
421
|
-
return [n(c.errors, "error"), n(c.gaps, "gap"), ...(c.behaviors ? [`behaviors ${firm(c.behaviors)}`] : []), ...(c.
|
|
478
|
+
return [n(c.errors, "error"), n(c.gaps, "gap"), ...(c.behaviors ? [`behaviors ${firm(c.behaviors)}`] : []), ...(c.actions ? [`actions ${firm(c.actions)}`] : [])].join(" · ");
|
|
422
479
|
}
|
package/dist/cli.js
CHANGED
|
@@ -23,9 +23,9 @@ const USAGE = `usage: operbe check [root] [--at <rev>] [--json]
|
|
|
23
23
|
operbe describe [root] [--at <rev>] [--body | --pretty]
|
|
24
24
|
operbe diff <side> <side> [--root <root>] [--fail-on breaking|warning] [--json]
|
|
25
25
|
a side is a description file, a project folder, or --at <rev> (the project at --root, default .)
|
|
26
|
-
operbe reconcile [root] --kind operation|
|
|
26
|
+
operbe reconcile [root] --kind operation|action [--front-end <name>] [--via <field>] --names <file|-> [--json]
|
|
27
27
|
operbe index [root] [--at <rev>]
|
|
28
|
-
operbe new operation|
|
|
28
|
+
operbe new operation|action <name> [root]
|
|
29
29
|
operbe new behavior "<behavior name>" [root]
|
|
30
30
|
operbe schema
|
|
31
31
|
--at reads a jj revision without snapshotting the working copy: --at @ is the last snapshot,
|
|
@@ -37,7 +37,7 @@ const OPTIONS = {
|
|
|
37
37
|
check: { flags: ["--json"], values: ["--at"] },
|
|
38
38
|
describe: { flags: ["--body", "--pretty"], values: ["--at"] },
|
|
39
39
|
diff: { flags: ["--json"], values: ["--fail-on", "--root", "--at"] },
|
|
40
|
-
reconcile: { flags: ["--json"], values: ["--kind", "--
|
|
40
|
+
reconcile: { flags: ["--json"], values: ["--kind", "--front-end", "--via", "--names"] },
|
|
41
41
|
schema: { flags: [], values: [] },
|
|
42
42
|
index: { flags: [], values: ["--at"] },
|
|
43
43
|
new: { flags: [], values: [] },
|
|
@@ -70,7 +70,7 @@ for (let i = 0; i < args.length; i++) {
|
|
|
70
70
|
values[a] = v;
|
|
71
71
|
}
|
|
72
72
|
else
|
|
73
|
-
fail(`unknown option '${a}'`);
|
|
73
|
+
fail(a === "--ui" ? "--ui was renamed --front-end in operbe 1.0.0-rc.3" : `unknown option '${a}'`);
|
|
74
74
|
}
|
|
75
75
|
const most = cmd === "new" ? 3 : 1;
|
|
76
76
|
if (cmd === "diff" ? sides.length !== 2 : positional.length > most)
|
|
@@ -105,7 +105,7 @@ const tellAt = (l) => { if (l.at)
|
|
|
105
105
|
const findingsOf = (l) => [...l.findings, ...check(l.model)];
|
|
106
106
|
if (cmd === "schema")
|
|
107
107
|
process.stdout.write(readFileSync(new URL("../schema/description.schema.json", import.meta.url), "utf8"));
|
|
108
|
-
// index: the behavior index, the coverage table and the
|
|
108
|
+
// index: the behavior index, the coverage table and the action index, printed (never committed).
|
|
109
109
|
else if (cmd === "index") {
|
|
110
110
|
const l = await load(positional[0] ?? ".", values["--at"]);
|
|
111
111
|
tellAt(l);
|
|
@@ -116,8 +116,10 @@ else if (cmd === "index") {
|
|
|
116
116
|
// and the one not yet merged is renumbered.
|
|
117
117
|
else if (cmd === "new") {
|
|
118
118
|
const [kind, name, root = "."] = positional;
|
|
119
|
-
if (kind
|
|
120
|
-
fail("
|
|
119
|
+
if (kind === "client-action")
|
|
120
|
+
fail("client-action was renamed action in operbe 1.0.0-rc.3: operbe new action <name>");
|
|
121
|
+
if (kind !== "operation" && kind !== "behavior" && kind !== "action")
|
|
122
|
+
fail("new makes an operation, a behavior or an action");
|
|
121
123
|
if (!name)
|
|
122
124
|
fail(`new ${kind} needs a name`);
|
|
123
125
|
if (kind !== "behavior" && !/^[a-z0-9]+(-[a-z0-9]+)+$/.test(name))
|
|
@@ -125,9 +127,9 @@ else if (cmd === "new") {
|
|
|
125
127
|
const m = read(folderSource(root));
|
|
126
128
|
if (!m.profile)
|
|
127
129
|
fail(`${root} has no operbe.md`, false);
|
|
128
|
-
const folder = kind === "operation" ? m.folders.operations : kind === "behavior" ? m.folders.behaviors : m.folders.
|
|
130
|
+
const folder = kind === "operation" ? m.folders.operations : kind === "behavior" ? m.folders.behaviors : m.folders.actions;
|
|
129
131
|
if (!folder)
|
|
130
|
-
fail("this project keeps no
|
|
132
|
+
fail("this project keeps no actions (operbe.md has no actions line)", false);
|
|
131
133
|
let template = readFileSync(new URL(`../skills/operbe/templates/${kind}.md`, import.meta.url), "utf8");
|
|
132
134
|
let stem = name;
|
|
133
135
|
if (kind === "behavior") {
|
|
@@ -230,10 +232,12 @@ else {
|
|
|
230
232
|
findings = findingsOf(l);
|
|
231
233
|
else {
|
|
232
234
|
const kind = values["--kind"];
|
|
233
|
-
if (kind
|
|
234
|
-
fail("--kind
|
|
235
|
-
if (kind
|
|
236
|
-
fail("--
|
|
235
|
+
if (kind === "client-action")
|
|
236
|
+
fail("--kind client-action was renamed --kind action in operbe 1.0.0-rc.3");
|
|
237
|
+
if (kind !== "operation" && kind !== "action")
|
|
238
|
+
fail("--kind must be operation or action");
|
|
239
|
+
if (kind === "action" && !values["--front-end"])
|
|
240
|
+
fail("--front-end is needed for actions");
|
|
237
241
|
const from = values["--names"] ?? fail("--names <file|-> is needed");
|
|
238
242
|
let text = "";
|
|
239
243
|
try {
|
|
@@ -256,11 +260,11 @@ else {
|
|
|
256
260
|
}
|
|
257
261
|
else
|
|
258
262
|
names = text.split(/\r?\n/).map((x) => x.trim()).filter(Boolean);
|
|
259
|
-
findings = reconcile(m, { kind: kind,
|
|
263
|
+
findings = reconcile(m, { kind: kind, frontEnd: values["--front-end"], via: values["--via"], names });
|
|
260
264
|
}
|
|
261
265
|
findings = sortFindings(findings);
|
|
262
266
|
// reconcile reports only its own findings, so its summary has no status counts.
|
|
263
|
-
const c = cmd === "check" ? counts(m, findings) : { ...counts(m, findings), behaviors: null,
|
|
267
|
+
const c = cmd === "check" ? counts(m, findings) : { ...counts(m, findings), behaviors: null, actions: null };
|
|
264
268
|
if (flags.has("--json"))
|
|
265
269
|
console.log(JSON.stringify({ findings, counts: c }, null, 2));
|
|
266
270
|
else {
|
package/dist/describe.js
CHANGED
|
@@ -19,7 +19,7 @@ import { VERSION } from "./version.js";
|
|
|
19
19
|
export const FORMAT = "operbe.description/1";
|
|
20
20
|
// A query reads, a change changes, a signal passes: pinned by format/1.
|
|
21
21
|
const EFFECT = { query: "reads", change: "changes", signal: "passes" };
|
|
22
|
-
// Risk from lowest to highest, for
|
|
22
|
+
// Risk from lowest to highest, for an action's rollup.
|
|
23
23
|
const RISK_ORDER = ["reads", "changes", "changes-rights", "destroys"];
|
|
24
24
|
// One record's header and sections, normalized:
|
|
25
25
|
// - operbe's own fields as written; `form` as an integer when it is one;
|
|
@@ -64,14 +64,14 @@ export function body(m) {
|
|
|
64
64
|
if (!m.profile)
|
|
65
65
|
return {};
|
|
66
66
|
const profile = record(m.profile);
|
|
67
|
-
for (const k of ["operations", "behaviors", "
|
|
67
|
+
for (const k of ["operations", "behaviors", "actions"])
|
|
68
68
|
delete profile[k]; // folders: where, not what
|
|
69
69
|
const behaviorIds = new Set(m.behaviors.map((b) => str(b, "id")));
|
|
70
|
-
const actionNames = new Set(m.
|
|
71
|
-
// Coverage: per
|
|
70
|
+
const actionNames = new Set(m.actions.map((a) => str(a, "name")));
|
|
71
|
+
// Coverage: per front end with a file, per row that names a behavior or action. First row wins.
|
|
72
72
|
const coverage = dict();
|
|
73
|
-
for (const
|
|
74
|
-
const lines = m.coverage[
|
|
73
|
+
for (const fe of m.frontEnds) {
|
|
74
|
+
const lines = m.coverage[fe]?.lines;
|
|
75
75
|
if (!lines)
|
|
76
76
|
continue;
|
|
77
77
|
const rows = dict();
|
|
@@ -80,7 +80,7 @@ export function body(m) {
|
|
|
80
80
|
continue;
|
|
81
81
|
rows[id] = { value, ...(form ? { form: whole(form) ? Number(form) : form } : {}), ...(note ? { note } : {}) };
|
|
82
82
|
}
|
|
83
|
-
coverage[
|
|
83
|
+
coverage[fe] = rows;
|
|
84
84
|
}
|
|
85
85
|
// Declarations: fields sorted by (field, on), diff rules by (field, change); their order means nothing.
|
|
86
86
|
const architectures = dict();
|
|
@@ -96,7 +96,7 @@ export function body(m) {
|
|
|
96
96
|
operations: keyed(m.operations, "name", (_r, o) => { const e = EFFECT[o.class]; if (e)
|
|
97
97
|
o.effect = e; }),
|
|
98
98
|
behaviors: keyed(m.behaviors, "id"),
|
|
99
|
-
...(m.folders.
|
|
99
|
+
...(m.folders.actions !== null ? { actions: keyed(m.actions, "name") } : {}),
|
|
100
100
|
coverage,
|
|
101
101
|
architectures,
|
|
102
102
|
};
|
|
@@ -106,16 +106,19 @@ const cmp = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
|
106
106
|
function derived(b) {
|
|
107
107
|
const ops = (b.operations ?? {});
|
|
108
108
|
const behs = (b.behaviors ?? {});
|
|
109
|
-
const acts = (b
|
|
110
|
-
const
|
|
109
|
+
const acts = (b.actions ?? {});
|
|
110
|
+
const fes = (b.profile?.["front-ends"] ?? []);
|
|
111
|
+
const groups = (b.profile?.groups ?? {});
|
|
111
112
|
const names = (v) => (Array.isArray(v) ? v : []);
|
|
113
|
+
// applies-to as front ends: `all`, a group, or a list of front ends and groups.
|
|
114
|
+
const appliesTo = (a) => a === "all" ? fes : (typeof a === "string" ? [a] : names(a)).flatMap((n) => (Object.hasOwn(groups, n) ? names(groups[n]) : [n]));
|
|
112
115
|
const sorted = (xs) => [...xs].sort(cmp);
|
|
113
|
-
// used-by: which behaviors and
|
|
116
|
+
// used-by: which behaviors describe each operation's outcome, and which actions call it.
|
|
114
117
|
const usedBy = dict();
|
|
115
118
|
for (const op of Object.keys(ops))
|
|
116
119
|
usedBy[op] = {
|
|
117
120
|
behaviors: sorted(Object.keys(behs).filter((id) => names(behs[id].operations).includes(op))),
|
|
118
|
-
|
|
121
|
+
actions: sorted(Object.keys(acts).filter((n) => names(acts[n].operations).includes(op))),
|
|
119
122
|
};
|
|
120
123
|
// Status counts per kind.
|
|
121
124
|
const statuses = (rs) => {
|
|
@@ -125,13 +128,13 @@ function derived(b) {
|
|
|
125
128
|
t[r.status]++;
|
|
126
129
|
return t;
|
|
127
130
|
};
|
|
128
|
-
// Coverage tallies per
|
|
131
|
+
// Coverage tallies per front end: each value, and `unbuilt` for applying behaviors with no row.
|
|
129
132
|
const tallies = dict();
|
|
130
|
-
for (const
|
|
131
|
-
const rows = (b.coverage[
|
|
133
|
+
for (const fe of fes) {
|
|
134
|
+
const rows = (b.coverage[fe] ?? {});
|
|
132
135
|
const t = { honours: 0, differs: 0, limited: 0, "not-here": 0, unbuilt: 0 };
|
|
133
136
|
for (const [id, r] of Object.entries(behs)) {
|
|
134
|
-
const applies =
|
|
137
|
+
const applies = appliesTo(r["applies-to"]).includes(fe);
|
|
135
138
|
if (!applies || r.status === "retired")
|
|
136
139
|
continue;
|
|
137
140
|
const v = rows[id]?.value;
|
|
@@ -140,9 +143,9 @@ function derived(b) {
|
|
|
140
143
|
else if (!v)
|
|
141
144
|
t.unbuilt++;
|
|
142
145
|
}
|
|
143
|
-
tallies[
|
|
146
|
+
tallies[fe] = t;
|
|
144
147
|
}
|
|
145
|
-
// Per
|
|
148
|
+
// Per action: its class, the highest risk among the operations it calls, and whether any of them
|
|
146
149
|
// can't be taken back (a change or signal with taken-back-by: nothing).
|
|
147
150
|
const rollup = dict();
|
|
148
151
|
for (const [n, a] of Object.entries(acts)) {
|
|
@@ -157,9 +160,9 @@ function derived(b) {
|
|
|
157
160
|
return {
|
|
158
161
|
tool: `operbe ${VERSION}`,
|
|
159
162
|
"used-by": usedBy,
|
|
160
|
-
statuses: { behaviors: statuses(behs), ...(b
|
|
163
|
+
statuses: { behaviors: statuses(behs), ...(b.actions ? { actions: statuses(acts) } : {}) },
|
|
161
164
|
coverage: tallies,
|
|
162
|
-
|
|
165
|
+
actions: rollup,
|
|
163
166
|
};
|
|
164
167
|
}
|
|
165
168
|
// The exact bytes the digest is taken over.
|