@enspirit/opspicy 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +91 -47
- package/bin/entry.js +22 -1
- package/bin/help.js +115 -0
- package/bin/opspicy +12 -4
- package/dist/explorer/document.js +21 -13
- package/dist/explorer/html.js +48 -3
- package/dist/explorer/index.js +5 -4
- package/dist/explorer/operation.js +7 -4
- package/dist/explorer/pages.js +61 -34
- package/dist/explorer/script/ranking.js +1 -1
- package/dist/explorer/site.js +5 -4
- package/dist/explorer/style.css +6 -0
- package/dist/explorer/wiki.js +14 -0
- package/dist/files.js +6 -4
- package/dist/judging.js +35 -7
- package/dist/main.js +1 -1
- package/dist/modelling.js +70 -12
- package/dist/planning.js +11 -2
- package/dist/reach.js +177 -0
- package/dist/reading.js +21 -6
- package/dist/report.js +6 -5
- package/dist/running.js +5 -2
- package/dist/suite.js +9 -6
- package/dist/upgrade.js +27 -0
- package/dist/upgrading.js +76 -0
- package/dist/world.js +5 -4
- package/package.json +2 -2
package/dist/explorer/index.js
CHANGED
|
@@ -12,8 +12,9 @@
|
|
|
12
12
|
import { PRE } from '../suite.js';
|
|
13
13
|
import { areaTitle } from './operation.js';
|
|
14
14
|
import { idOf, violating } from './wiki.js';
|
|
15
|
-
const
|
|
16
|
-
const STATE = 'State
|
|
15
|
+
const WORLD = 'World';
|
|
16
|
+
const STATE = 'State';
|
|
17
|
+
const BACKGROUNDS = 'Backgrounds';
|
|
17
18
|
const answered = (then) => `${then.status}${then.code ? ` ${then.code}` : ''}`;
|
|
18
19
|
const told = (...parts) => parts.filter(Boolean).join(' · ');
|
|
19
20
|
const definition = (one, ctx) => ({ h: idOf(one.kind, one.name), k: one.kind === 'predicate' ? 'Predicate' : 'Function', n: one.name, x: one.description, c: one.formaldef, ctx, a: one.area, q: one.description });
|
|
@@ -55,7 +56,7 @@ export function indexOf(wiki, pages) {
|
|
|
55
56
|
...wiki.operations.flatMap((operation) => [...operation.clauses.map((one) => clause(operation, one)), ...operation.cases.flatMap((one) => [kase(operation, one), ...also(operation, one)])]),
|
|
56
57
|
...wiki.state.map((one) => plain('state', 'State', STATE, one, `GET ${one.path}`)),
|
|
57
58
|
...wiki.relations.map((one) => ({ h: idOf('relation', one.name), k: 'Relation', n: `db.${one.name}`, x: told(one.description, one.table, one.attributes.join(', ')), c: '', ctx: STATE, q: one.description })),
|
|
58
|
-
...wiki.backgrounds.map((one) => plain('background', 'Background',
|
|
59
|
-
...wiki.actors.map((one) => plain('actor', 'Actor',
|
|
59
|
+
...wiki.backgrounds.map((one) => plain('background', 'Background', BACKGROUNDS, one)),
|
|
60
|
+
...wiki.actors.map((one) => plain('actor', 'Actor', WORLD, one, one.is)),
|
|
60
61
|
];
|
|
61
62
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// The page of an operation: what it is, its input and its output, its clauses, its examples and
|
|
2
2
|
// its counterexamples. What the suite says, and nothing of a run: that is in tests.ts.
|
|
3
3
|
// Pure: the wiki is given, markup is what comes out.
|
|
4
|
-
import { PRE, SAID, sameSentence } from '../suite.js';
|
|
4
|
+
import { PRE, SAID, isForType, sameSentence } from '../suite.js';
|
|
5
5
|
import { requestOf } from './calls.js';
|
|
6
6
|
import { eloHtml } from './elo.js';
|
|
7
7
|
import { jsonHtml } from './json.js';
|
|
@@ -19,6 +19,8 @@ const GROUP = {
|
|
|
19
19
|
export const crumbs = (...parts) => `<p class="crumb">${parts.join('<span aria-hidden="true">›</span>')}</p>`;
|
|
20
20
|
export const areaTitle = (name) => (name === '_shared' ? 'Shared' : name.charAt(0).toUpperCase() + name.slice(1));
|
|
21
21
|
const row = (label, value) => `<dt>${esc(label)}</dt><dd>${value}</dd>`;
|
|
22
|
+
/** States, each leading to its row of the State page; a list its file does not say is derived, and says so. */
|
|
23
|
+
const statesOf = (names, said) => `${names.map((name) => link(`#${idOf('state', name)}`, name)).join(', ') || '<span class="m">none</span>'}${said ? '' : ' <span class="m s" title="Not said by its file: derived from its formaldefs">· derived</span>'}`;
|
|
22
24
|
const typeLink = (name) => (name ? link(`#${idOf('type', name)}`, name) : '<span class="m">nothing</span>');
|
|
23
25
|
/** Who calls, and from which Background: a name for a table cell, each leading to who and what it is. */
|
|
24
26
|
export const callerOf = (kase) => {
|
|
@@ -64,7 +66,7 @@ function casesShown(operation, kind, refs) {
|
|
|
64
66
|
name: `${said(kase.description)}${kase.generated ? '<br><span class="m s">from a condition</span>' : ''}`,
|
|
65
67
|
description: callerOf(kase),
|
|
66
68
|
formaldef: alsoDecided(kase, refs) || undefined,
|
|
67
|
-
more: [sentOf(kase, refs), answeredOf(kase), example ? alsoShown(kase) : said(kase.for ?? '')],
|
|
69
|
+
more: [sentOf(kase, refs), answeredOf(kase), example ? alsoShown(kase) : isForType(operation, kase) ? `what is not ${typeLink(operation.input)}` : said(kase.for ?? '')],
|
|
68
70
|
}));
|
|
69
71
|
return citizens(example ? 'Examples' : 'Counterexamples', shown, { level: 'h3', columns: ['When', 'Caller', 'Sends', 'Answers', example ? 'Also shows' : 'Refuses'], widths: CASE_WIDTHS, note: `${cases.length} of them` });
|
|
70
72
|
}
|
|
@@ -78,9 +80,10 @@ function typeSide(label, name, { types, refs }) {
|
|
|
78
80
|
return `<section aria-label="${label}"><p class="sub">${said(type.description)}</p>${elo(`${type.name} = ${type.formaldef}`, refs, { self: idOf('type', type.name) })}</section>`;
|
|
79
81
|
}
|
|
80
82
|
export function operationPage(operation, around) {
|
|
81
|
-
const gaps = operation.gaps.length ? fold('Gaps', `<p class="sub">
|
|
83
|
+
const gaps = operation.gaps.length ? fold('Gaps', `<p class="sub">The transition the operation does not say, what no case shows, or no counterexample violates.</p>${list(operation.gaps.map((gap) => `<span class="m">· ${esc(gap)}</span>`))}`) : '';
|
|
82
84
|
const kind = operation.observes ? 'Observation: it only reads, so it is checked to change nothing' : 'Operation';
|
|
83
|
-
const
|
|
85
|
+
const { reach } = operation;
|
|
86
|
+
const meta = [row('Performed by', link(`#${idOf('agent', operation.agent)}`, operation.agent)), row('Route', mono(`${operation.entry.method} ${operation.entry.path}`)), row('Kind', esc(kind)), row('Input', typeLink(operation.input)), row('Output', typeLink(operation.output)), row('Monitors', statesOf(reach.monitors, reach.said.monitors)), row('Controls', statesOf(reach.controls, reach.said.controls)), row('Specification', mono(operation.file)), row('Tests', link(`#${idOf('test', operation.name)}`, 'Results of the last run'))];
|
|
84
87
|
const io = `<div class="io">${typeSide('Input', operation.input, around)}<span class="arrow" aria-hidden="true">→</span>${typeSide('Output', operation.output, around)}</div>`;
|
|
85
88
|
const body = `<div class="page-top">${crumbs(link('#home', 'Specification'), link(`#${idOf('area', operation.area)}`, areaTitle(operation.area)))}<button type="button" class="fold-all" aria-expanded="true">Collapse all</button></div>
|
|
86
89
|
<h1 class="code">${esc(operation.name)}</h1>
|
package/dist/explorer/pages.js
CHANGED
|
@@ -2,9 +2,14 @@
|
|
|
2
2
|
// every citizen at home on one of them, under an anchor of its own. What the suite says, and
|
|
3
3
|
// nothing of a run: that is in tests.ts. Pure: the wiki is given, markup is what comes out.
|
|
4
4
|
import { isA } from '../suite.js';
|
|
5
|
-
import { citizens, elo, esc, link, list, mono, plural, said } from './html.js';
|
|
5
|
+
import { citizens, described, elo, esc, link, list, mono, plural, said } from './html.js';
|
|
6
6
|
import { areaTitle, crumbs, operationPage } from './operation.js';
|
|
7
7
|
import { idOf } from './wiki.js';
|
|
8
|
+
/**
|
|
9
|
+
* What a section says first: what its file says of it, in the words of the domain, when it says
|
|
10
|
+
* something; then how opspicy reads it, quieter. Without the first, the second leads.
|
|
11
|
+
*/
|
|
12
|
+
const introOf = (description, how) => (description ? `${described(description)}<p class="sub how">${esc(how)}</p>` : `<p class="lead">${esc(how)}</p>`);
|
|
8
13
|
const tile = (value, label) => `<div class="tile"><b>${esc(value)}</b><span>${esc(label)}</span></div>`;
|
|
9
14
|
const WIDTHS = ['30%', '70%'];
|
|
10
15
|
/** The problems of the specification, when it cannot be read: what follows may be incomplete. */
|
|
@@ -24,13 +29,24 @@ function overviewPage(wiki) {
|
|
|
24
29
|
const of = count(area.operations);
|
|
25
30
|
return listed('home', idOf('area', area.name), { source: area.source, name: '', description: said(area.description) }, link(`#${idOf('area', area.name)}`, areaTitle(area.name)), [String(area.operations.length), String(of.clauses), String(of.examples), String(of.counterexamples)]);
|
|
26
31
|
});
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
|
|
32
|
+
const { system, descriptions } = wiki;
|
|
33
|
+
const how = 'What each operation of the system promises, area by area. Every name is a page or leads to one: follow the links. The results of the last run are under Testing.';
|
|
34
|
+
const body = `<h1>${esc(system.name ?? 'Specification')}</h1>
|
|
35
|
+
${introOf(descriptions.system, how)}
|
|
30
36
|
${problemsOf(wiki)}
|
|
31
37
|
<div class="tiles">${tiles.join('')}</div>
|
|
32
|
-
${citizens('Areas', areas, { columns: ['Area', '', 'Operations', 'Clauses', 'Examples', 'Counterexamples'], widths: ['14%', '46%', '10%', '10%', '10%', '10%'] })}`;
|
|
33
|
-
return { id: 'home', kind: 'Specification', title: 'Specification', said:
|
|
38
|
+
${citizens('Areas', areas, { columns: ['Area', '', 'Operations', 'Clauses', 'Examples', 'Counterexamples'], widths: ['14%', '46%', '10%', '10%', '10%', '10%'], intro: descriptions.areas ? `<div class="prose intro">${described(descriptions.areas)}</div>` : '' })}`;
|
|
39
|
+
return { id: 'home', kind: 'Specification', title: system.name ?? 'Specification', said: firstOf(descriptions.system) ?? how, source: 'system.yml', body };
|
|
40
|
+
}
|
|
41
|
+
/** The first paragraph of a description, as the search tells a page by it. */
|
|
42
|
+
const firstOf = (description) => description?.trim().split(/\n\s*\n/)[0]?.replace(/\s+/g, ' ');
|
|
43
|
+
/** A page that is the home of a file at the root: its description first, then how opspicy reads it, then what it lists. */
|
|
44
|
+
function homePage(wiki, home, id, title, how, sections) {
|
|
45
|
+
const description = wiki.descriptions[home];
|
|
46
|
+
const body = `<h1>${esc(title)}</h1>
|
|
47
|
+
${introOf(description, how)}
|
|
48
|
+
${sections}`;
|
|
49
|
+
return { id, kind: title, title, said: firstOf(description) ?? how, source: `${home}.yml`, body };
|
|
34
50
|
}
|
|
35
51
|
/**
|
|
36
52
|
* A row that lists a citizen at home elsewhere, on the page of that id: it says where its home is,
|
|
@@ -68,6 +84,13 @@ function areaPage(area, refs) {
|
|
|
68
84
|
${citizens('Types', area.types.map((one) => typeShown(one, refs)), { widths: WIDTHS })}`;
|
|
69
85
|
return { id, kind: 'Area', title: areaTitle(area.name), source: area.source, said: area.description, area: area.name, quote: area.description, body };
|
|
70
86
|
}
|
|
87
|
+
const statesLinked = (names) => names.map((name) => link(`#${idOf('state', name)}`, name)).join(', ') || '<span class="m">none</span>';
|
|
88
|
+
const operationsLinked = (all) => all.map((one) => link(`#${idOf('op', one.name)}`, one.name)).join(', ') || '<span class="m">none</span>';
|
|
89
|
+
/** What an agent monitors, or controls: what the operations it performs do, in the order of the state. */
|
|
90
|
+
const reachOfAgent = (agent, wiki, of) => {
|
|
91
|
+
const all = new Set(performedBy(agent, wiki).flatMap((one) => one.reach[of]));
|
|
92
|
+
return wiki.state.map((one) => one.name).filter((name) => all.has(name));
|
|
93
|
+
};
|
|
71
94
|
/** What an agent performs: the operations that name it, and those that name an agent it also is. */
|
|
72
95
|
const performedBy = (agent, { agents, operations }) => operations.filter((one) => isA(agents, agent.name, one.agent));
|
|
73
96
|
/** An agent, on a page of its own: what it is, who of the actors is one, and what it performs, itself or as an agent it also is. */
|
|
@@ -78,55 +101,59 @@ function agentPage(agent, wiki) {
|
|
|
78
101
|
const performed = performedBy(agent, wiki).map((one) => operationListed(id, one, [link(`#${idOf('area', one.area)}`, areaTitle(one.area)), as(one)]));
|
|
79
102
|
const body = `${crumbs(link('#home', 'Specification'), link('#agents', 'Agents'))}<h1>${esc(agent.name)}</h1>
|
|
80
103
|
<p class="lead">${said(agent.description)}</p>
|
|
81
|
-
<dl class="meta"><dt>Is also</dt><dd>${agent.is ? link(`#${idOf('agent', agent.is)}`, agent.is) : '<span class="m">nothing else</span>'}</dd><dt>Actors</dt><dd>${actors.join(', ') || '<span class="m">none</span>'}</dd></dl>
|
|
104
|
+
<dl class="meta"><dt>Is also</dt><dd>${agent.is ? link(`#${idOf('agent', agent.is)}`, agent.is) : '<span class="m">nothing else</span>'}</dd><dt>Actors</dt><dd>${actors.join(', ') || '<span class="m">none</span>'}</dd><dt>Monitors</dt><dd>${statesLinked(reachOfAgent(agent, wiki, 'monitors'))}</dd><dt>Controls</dt><dd>${statesLinked(reachOfAgent(agent, wiki, 'controls'))}</dd></dl>
|
|
82
105
|
${citizens('Performs', performed, { columns: ['Operation', '', 'Area', 'As'], widths: ['22%', '52%', '13%', '13%'] })}`;
|
|
83
106
|
return { id, kind: 'Agent', title: agent.name, nav: 'agents', source: agent.source, said: agent.description, quote: agent.description, body };
|
|
84
107
|
}
|
|
85
108
|
function agentsPage(wiki) {
|
|
86
109
|
const agents = wiki.agents.map((one) => listed('agents', idOf('agent', one.name), { source: one.source, name: '', description: said(one.description) }, link(`#${idOf('agent', one.name)}`, one.name), [one.is ? link(`#${idOf('agent', one.is)}`, one.is) : '', String(performedBy(one, wiki).length)]));
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
const body = `<h1>Agents and actors</h1>
|
|
90
|
-
<p class="lead">${lead}</p>
|
|
91
|
-
${citizens('Agents', agents, { columns: ['Agent', '', 'Is also', 'Operations'], widths: ['16%', '60%', '12%', '12%'] })}
|
|
92
|
-
${citizens('Actors', actors, { columns: ['Actor', '', 'Is', ''], widths: ['16%', '60%', '12%', '12%'] })}`;
|
|
93
|
-
return { id: 'agents', kind: 'Agents', title: 'Agents and actors', said: lead, body };
|
|
110
|
+
const how = 'Who performs the operations: each agent leads to a page of its own, with what it performs. Who of them calls in a case is under World.';
|
|
111
|
+
return homePage(wiki, 'agents', 'agents', 'Agents', how, citizens('Agents', agents, { columns: ['Agent', '', 'Is also', 'Operations'], widths: ['16%', '60%', '12%', '12%'] }));
|
|
94
112
|
}
|
|
95
113
|
/** A word or a type, where an index names it: its name leads to where it is at home, in its area, and its formaldef is here too. */
|
|
96
114
|
const indexed = (page, shown, one) => listed(page, shown.id ?? '', shown, `<a class="mono" href="#${esc(shown.id ?? '')}">${esc(one.name)}</a>`, [link(`#${idOf('area', one.area)}`, areaTitle(one.area))]);
|
|
97
115
|
const INDEX = { columns: ['', '', 'Area'], widths: ['28%', '58%', '14%'] };
|
|
98
|
-
function
|
|
116
|
+
function definitionsPage(wiki) {
|
|
99
117
|
const of = (pick) => wiki.areas.flatMap(pick);
|
|
100
|
-
const definitions = (all) => all.map((one) => indexed('
|
|
101
|
-
const lead = '
|
|
102
|
-
const body = `<h1>
|
|
103
|
-
<p class="lead">${lead}</p>
|
|
118
|
+
const definitions = (all) => all.map((one) => indexed('definitions', definitionShown(one, wiki.refs), one));
|
|
119
|
+
const lead = 'An index of what the sentences are written with: the predicates, true or false of the state, the functions, which give something of it, and the conditions, which several operations say in the same words. Each is at home in its area: its name leads there.';
|
|
120
|
+
const body = `<h1>Formal definitions</h1>
|
|
121
|
+
<p class="lead">${esc(lead)}</p>
|
|
104
122
|
${citizens('Predicates', definitions(of((area) => area.predicates)), INDEX)}
|
|
105
123
|
${citizens('Functions', definitions(of((area) => area.functions)), INDEX)}
|
|
106
|
-
${citizens('Conditions', of((area) => area.conditions).map((one) => indexed('
|
|
107
|
-
return { id: '
|
|
124
|
+
${citizens('Conditions', of((area) => area.conditions).map((one) => indexed('definitions', conditionShown(one, wiki.refs), one)), INDEX)}`;
|
|
125
|
+
return { id: 'definitions', kind: 'Formal definitions', title: 'Formal definitions', said: lead, body };
|
|
108
126
|
}
|
|
109
127
|
function typesPage(wiki) {
|
|
110
128
|
const types = wiki.areas.flatMap((area) => area.types).sort((a, b) => a.name.localeCompare(b.name));
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
129
|
+
const of = (kind) => types.filter((one) => (wiki.typeKinds.get(one.name) ?? 'data') === kind).map((one) => indexed('types', typeShown(one, wiki.refs), one));
|
|
130
|
+
const lead = 'An index of the data, as the areas declare it in their types.elo, each with what it means: what a state tells, what an operation exchanges, and other data. Each is at home in its area: its name leads there.';
|
|
131
|
+
const body = `<h1>Types</h1><p class="lead">${esc(lead)}</p>
|
|
132
|
+
${citizens('State types', of('state'), INDEX)}
|
|
133
|
+
${citizens('Message types', of('message'), INDEX)}
|
|
134
|
+
${citizens('Other data', of('data'), INDEX)}`;
|
|
135
|
+
return { id: 'types', kind: 'Types', title: 'Types', said: lead, body };
|
|
114
136
|
}
|
|
115
137
|
function statePage(wiki) {
|
|
116
|
-
const
|
|
138
|
+
const by = (name, of) => operationsLinked(wiki.operations.filter((one) => one.reach[of].includes(name)));
|
|
139
|
+
const state = wiki.state.map((one) => ({ id: idOf('state', one.name), source: one.source, name: mono(one.name), description: said(one.description), more: [mono(`GET ${one.path}`), one.type ? link(`#${idOf('type', one.type)}`, one.type) : '', by(one.name, 'monitors'), by(one.name, 'controls')] }));
|
|
117
140
|
const relations = wiki.relations.map((one) => ({ id: idOf('relation', one.name), source: one.source, name: mono(`db.${one.name}`), description: said(one.description), more: [mono(one.table), esc(one.key.join(', ')), esc(one.attributes.join(', '))] }));
|
|
141
|
+
const how = 'What is observed: by the routes that tell it, and behind them, in the database. Each state says the operations that must read it to meet their clauses (monitored by) and those that may change it (controlled by).';
|
|
142
|
+
return homePage(wiki, 'state', 'state', 'State', how, `${citizens('State', state, { columns: ['State', '', 'Route', 'Type', 'Monitored by', 'Controlled by'], widths: ['11%', '27%', '18%', '10%', '17%', '17%'] })}
|
|
143
|
+
${citizens('Relations', relations, { columns: ['Relation', '', 'Table', 'Key', 'Attributes'], widths: ['14%', '40%', '12%', '8%', '26%'] })}`);
|
|
144
|
+
}
|
|
145
|
+
function worldPage(wiki) {
|
|
146
|
+
const actors = wiki.actors.map((one) => ({ id: idOf('actor', one.name), source: one.source, name: mono(one.name), description: said(one.description), more: [link(`#${idOf('agent', one.is)}`, one.is), one.signsIn ? 'signs in' : '<span class="m">not signed in</span>'] }));
|
|
147
|
+
const how = 'What the runner knows: who calls in a case, each the agent they are, and what else the world holds. What an actor signs in with, and the values of the world, are not shown: some of them are secrets.';
|
|
148
|
+
return homePage(wiki, 'world', 'world', 'World', how, `${citizens('Actors', actors, { columns: ['Actor', '', 'Is', ''], widths: ['16%', '60%', '12%', '12%'] })}
|
|
149
|
+
<h2>What else it holds</h2>${list(wiki.worldKeys.map(mono)) || '<p class="sub">Nothing but its actors.</p>'}`);
|
|
150
|
+
}
|
|
151
|
+
function backgroundsPage(wiki) {
|
|
118
152
|
const backgrounds = wiki.backgrounds.map((one) => ({ id: idOf('background', one.name), source: one.source, name: mono(one.name), description: said(one.description) }));
|
|
119
|
-
|
|
120
|
-
const body = `<h1>State and world</h1>
|
|
121
|
-
<p class="lead">${lead}</p>
|
|
122
|
-
${citizens('State', state, { columns: ['State', '', 'Route', 'Type'], widths: ['12%', '48%', '26%', '14%'] })}
|
|
123
|
-
${citizens('Relations', relations, { columns: ['Relation', '', 'Table', 'Key', 'Attributes'], widths: ['14%', '40%', '12%', '8%', '26%'] })}
|
|
124
|
-
${citizens('Backgrounds', backgrounds, { columns: ['Background', ''], widths: ['16%', '84%'] })}
|
|
125
|
-
<h2>World</h2>${list(wiki.worldKeys.map(mono)) || '<p class="sub">Nothing but its actors.</p>'}`;
|
|
126
|
-
return { id: 'state', kind: 'State', title: 'State and world', said: lead, body };
|
|
153
|
+
return homePage(wiki, 'backgrounds', 'backgrounds', 'Backgrounds', 'Where a case starts: each the state the configuration puts the system in, by its name.', citizens('Backgrounds', backgrounds, { columns: ['Background', ''], widths: ['16%', '84%'] }));
|
|
127
154
|
}
|
|
128
155
|
/** The pages of the specification, in the order the navigation shows them. */
|
|
129
156
|
export function specPagesOf(wiki) {
|
|
130
157
|
const around = { types: new Map(wiki.areas.flatMap((area) => area.types).map((one) => [one.name, one])), conditions: wiki.areas.flatMap((area) => area.conditions), refs: wiki.refs };
|
|
131
|
-
return [overviewPage(wiki), ...wiki.areas.map((area) => areaPage(area, wiki.refs)), ...wiki.operations.map((one) => operationPage(one, around)),
|
|
158
|
+
return [overviewPage(wiki), agentsPage(wiki), statePage(wiki), ...wiki.areas.map((area) => areaPage(area, wiki.refs)), ...wiki.operations.map((one) => operationPage(one, around)), ...wiki.agents.map((one) => agentPage(one, wiki)), definitionsPage(wiki), typesPage(wiki), worldPage(wiki), backgroundsPage(wiki)];
|
|
132
159
|
}
|
|
@@ -9,7 +9,7 @@ const SCOPES = {
|
|
|
9
9
|
All: null,
|
|
10
10
|
Operations: ['Operation', 'Observation'],
|
|
11
11
|
Types: ['Type'],
|
|
12
|
-
|
|
12
|
+
Definitions: ['Predicate', 'Function', 'Condition'],
|
|
13
13
|
Clauses: ['Clause'],
|
|
14
14
|
Cases: ['Case'],
|
|
15
15
|
State: ['State', 'Relation'],
|
package/dist/explorer/site.js
CHANGED
|
@@ -59,12 +59,13 @@ export function reportAt(file) {
|
|
|
59
59
|
throw new Error(`${file} is not a report of opspicy`);
|
|
60
60
|
return report;
|
|
61
61
|
}
|
|
62
|
-
/** The name of a suite, when it is given none: that of its directory. */
|
|
63
|
-
export const nameOf = (suite) => basename(resolve(suite));
|
|
62
|
+
/** The name of a suite, when it is given none: that of the system its specification names, or of its directory. The page and its API say the same: the notes of one are kept under it. */
|
|
63
|
+
export const nameOf = (suite) => suiteAt(suite).model.system.name ?? basename(resolve(suite));
|
|
64
64
|
/** The whole wiki, as one HTML document, written now. */
|
|
65
65
|
export function documentAt({ suite, report, name, version, runner }) {
|
|
66
|
-
const
|
|
67
|
-
|
|
66
|
+
const read = suiteAt(suite);
|
|
67
|
+
const about = { name: name ?? read.model.system.name ?? basename(resolve(suite)), version, generated: new Date().toISOString(), runner: runner ?? `opspicy ${suite}` };
|
|
68
|
+
return documentOf(wikiOf(read, reportAt(report)), dressHere(), about);
|
|
68
69
|
}
|
|
69
70
|
/**
|
|
70
71
|
* The same document, as a server gives it: written again only when what it is made of is no
|
package/dist/explorer/style.css
CHANGED
|
@@ -89,6 +89,12 @@ h3{font-size:15px;font-weight:600;margin:28px 0 8px}
|
|
|
89
89
|
.meta{display:grid;grid-template-columns:max-content minmax(0,1fr);gap:6px 22px;margin:22px 0 0;font-size:15px}
|
|
90
90
|
.meta dt{color:var(--muted)}.meta dd{margin:0;overflow-wrap:anywhere}
|
|
91
91
|
.sub{margin:8px 0 0;font-size:14px;color:var(--muted)}
|
|
92
|
+
.prose{max-width:66ch;margin:14px 0 0;line-height:1.6}
|
|
93
|
+
.prose p,.prose ul{margin:10px 0 0}.prose ul{padding-left:22px}.prose li{margin:4px 0}
|
|
94
|
+
.prose h3{margin:22px 0 0;font-size:16px}
|
|
95
|
+
.prose.lead p:first-child,.prose:not(.lead)>:first-child{margin-top:0}
|
|
96
|
+
.how{max-width:66ch;margin-top:14px}
|
|
97
|
+
.by{margin:12px 0 0;font-size:12px;color:var(--muted)}.by a{color:inherit}
|
|
92
98
|
.page-top{display:flex;justify-content:space-between;align-items:flex-start;gap:16px}
|
|
93
99
|
.fold-all{font-size:13px;color:var(--ink);background:none;border:1px solid var(--rule);border-radius:999px;padding:3px 12px;cursor:pointer;white-space:nowrap}
|
|
94
100
|
.fold-all:hover{background:var(--hover)}
|
package/dist/explorer/wiki.js
CHANGED
|
@@ -53,11 +53,24 @@ function areasOf(suite, operations) {
|
|
|
53
53
|
types: of(model.types, name),
|
|
54
54
|
}));
|
|
55
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* The kind of each type, from what is written and nothing else: a type `state.yml` says a state
|
|
58
|
+
* tells, or the items of one that is a list (`Expense` of `Expenses = [Expense]`), is a state
|
|
59
|
+
* type; a type an operation names as its input or its output, and no state tells, is a message.
|
|
60
|
+
*/
|
|
61
|
+
function typeKindsOf(model, operations) {
|
|
62
|
+
const itemOf = (name) => /^\[\s*(\w+)\s*\]$/.exec(model.types.find((one) => one.name === name)?.formaldef.trim() ?? '')?.[1];
|
|
63
|
+
const told = new Set(model.state.flatMap((one) => (one.type ? [one.type, itemOf(one.type) ?? one.type] : [])));
|
|
64
|
+
const exchanged = new Set(operations.flatMap((one) => [one.input, one.output]).filter((one) => Boolean(one)));
|
|
65
|
+
return new Map(model.types.map((one) => [one.name, told.has(one.name) ? 'state' : exchanged.has(one.name) ? 'message' : 'data']));
|
|
66
|
+
}
|
|
56
67
|
/** The wiki of a suite, and of its last run when there is one. */
|
|
57
68
|
export function wikiOf(suite, report) {
|
|
58
69
|
const { model } = suite;
|
|
59
70
|
const operations = suite.operations.map((operation) => operationView(operation, suite, report)).sort((a, b) => a.area.localeCompare(b.area) || a.name.localeCompare(b.name));
|
|
60
71
|
return {
|
|
72
|
+
system: model.system,
|
|
73
|
+
descriptions: model.descriptions,
|
|
61
74
|
problems: suite.problems,
|
|
62
75
|
areas: areasOf(suite, operations),
|
|
63
76
|
operations,
|
|
@@ -70,6 +83,7 @@ export function wikiOf(suite, report) {
|
|
|
70
83
|
worldKeys: Object.keys(model.world),
|
|
71
84
|
refs: refsOf(model),
|
|
72
85
|
run: report ? runOf(report, operations) : null,
|
|
86
|
+
typeKinds: typeKindsOf(model, suite.operations),
|
|
73
87
|
};
|
|
74
88
|
}
|
|
75
89
|
/** The counterexamples that violate a precondition: those that are "for" its sentence. */
|
package/dist/files.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
//
|
|
6
6
|
// config.ts how the suite meets the system (configuration.ts)
|
|
7
7
|
// specification/
|
|
8
|
+
// system.yml what the specified system is called, and is (optional)
|
|
8
9
|
// areas.yml, agents.yml, backgrounds.yml the areas, who performs operations, where a case starts
|
|
9
10
|
// state.yml what is observed: the routes that tell, the relations behind
|
|
10
11
|
// world.yml what the runner knows: who calls, and what they hold
|
|
@@ -60,8 +61,9 @@ const WORLD = 'world.yml';
|
|
|
60
61
|
const AREAS = 'areas.yml';
|
|
61
62
|
const AGENTS = 'agents.yml';
|
|
62
63
|
const BACKGROUNDS = 'backgrounds.yml';
|
|
64
|
+
const SYSTEM = 'system.yml';
|
|
63
65
|
/** What a specification holds beside its areas. */
|
|
64
|
-
const HELD = [AREAS, AGENTS, BACKGROUNDS, STATE, WORLD];
|
|
66
|
+
const HELD = [SYSTEM, AREAS, AGENTS, BACKGROUNDS, STATE, WORLD];
|
|
65
67
|
const SAID = ['predicates.yml', 'functions.yml', 'conditions.yml', 'types.elo', OPERATIONS, OBSERVATIONS];
|
|
66
68
|
/** What is filed with the operations or the observations of an area and is not a `.yml` file: it would be there, and not read. */
|
|
67
69
|
function strays(root, area, problems) {
|
|
@@ -100,9 +102,9 @@ function saidBy(root, area, problems) {
|
|
|
100
102
|
/** What the suite says apart from its operations, as it is written: its own files, and the words of each area. */
|
|
101
103
|
function saidIn(root, areas, problems) {
|
|
102
104
|
const said = (name) => (existsSync(join(root, name)) ? written(join(root, name), problems) : {});
|
|
103
|
-
const [areasSaid, agents, backgrounds, state, world] = [AREAS, AGENTS, BACKGROUNDS, STATE, WORLD].map(said);
|
|
104
|
-
const lines = { areas: areasSaid?.lines, agents: agents?.lines, backgrounds: backgrounds?.lines, state: state?.lines, world: world?.lines };
|
|
105
|
-
return { areas: areasSaid?.data, agents: agents?.data, backgrounds: backgrounds?.data, state: state?.data, world: world?.data, lines, words: areas.map((area) => saidBy(root, area, problems)) };
|
|
105
|
+
const [system, areasSaid, agents, backgrounds, state, world] = [SYSTEM, AREAS, AGENTS, BACKGROUNDS, STATE, WORLD].map(said);
|
|
106
|
+
const lines = { system: system?.lines, areas: areasSaid?.lines, agents: agents?.lines, backgrounds: backgrounds?.lines, state: state?.lines, world: world?.lines };
|
|
107
|
+
return { system: system?.data, areas: areasSaid?.data, agents: agents?.data, backgrounds: backgrounds?.data, state: state?.data, world: world?.data, lines, words: areas.map((area) => saidBy(root, area, problems)) };
|
|
106
108
|
}
|
|
107
109
|
/** The types of the suite as one text: what every area uses first, since a type is declared before it is used. */
|
|
108
110
|
const typesIn = (said) => (said.words ?? []).flatMap((one) => (one.types === undefined ? [] : [one.types])).join('\n');
|
package/dist/judging.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { POST, isPre, sameSentence } from './suite.js';
|
|
1
|
+
import { POST, isForType, isPre, sameSentence } from './suite.js';
|
|
2
2
|
const excerpt = (value) => (JSON.stringify(value) ?? 'nothing').slice(0, 300);
|
|
3
3
|
/** Whether a clause holds, or why nobody can tell. */
|
|
4
4
|
function holds(meaning, clause, context) {
|
|
@@ -40,12 +40,16 @@ function answer(operation, kase, observed, meaning, refusal) {
|
|
|
40
40
|
const typed = misfit ? [{ says: `what is answered is not a ${type}`, saw: `${misfit} — ${excerpt(observed.body)}` }] : [];
|
|
41
41
|
return [...typed, ...(kase.then.code && code !== kase.then.code ? [{ says: `it is not refused as ${kase.then.code}`, saw: `refused as ${excerpt(code)}` }] : [])];
|
|
42
42
|
}
|
|
43
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* The names of what is not as it was: of the state, of the relations, of what others see. Each is
|
|
45
|
+
* named as a whole, `me` or `seenBy.admin.me`, never by a part of it: a state is what an operation
|
|
46
|
+
* controls, and what others see is a state.
|
|
47
|
+
*/
|
|
44
48
|
export function changed(before, after, path = '') {
|
|
45
49
|
if (JSON.stringify(before) === JSON.stringify(after))
|
|
46
50
|
return [];
|
|
47
51
|
const nested = (value) => Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
48
|
-
const deeper = path === '' || path === 'db' || path
|
|
52
|
+
const deeper = path === '' || path === 'db' || path === 'seenBy' || /^seenBy\.[^.]+$/.test(path);
|
|
49
53
|
if (!deeper || !nested(before) || !nested(after))
|
|
50
54
|
return [path];
|
|
51
55
|
return [...new Set([...Object.keys(before), ...Object.keys(after)])].flatMap((name) => changed(before[name], after[name], path ? `${path}.${name}` : name));
|
|
@@ -54,10 +58,24 @@ function unchanged(observed, why) {
|
|
|
54
58
|
const names = changed(observed.before, observed.after);
|
|
55
59
|
return names.length ? [{ says: `${why}, yet this is not as it was: ${names.join(', ')}` }] : [];
|
|
56
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* The states that changed and that the operation does not control, as it says or as it is derived:
|
|
63
|
+
* a state is named whoever sees it change, `seenBy.admin.boards` as `boards`; a relation is behind
|
|
64
|
+
* the front door, and is no state; one that was refused before or after the call did not change
|
|
65
|
+
* for who looks, who now sees it or no longer does (a sign-in, a sign-out).
|
|
66
|
+
*/
|
|
67
|
+
function uncontrolled(operation, observed) {
|
|
68
|
+
// A state somebody is refused reads as nothing: from or to nothing, what changed is whether they see it, not the state.
|
|
69
|
+
const at = (state, path) => path.split('.').reduce((value, key) => (value && typeof value === 'object' ? value[key] : undefined), state);
|
|
70
|
+
const seen = (path) => at(observed.before, path) !== null && at(observed.after, path) !== null;
|
|
71
|
+
const states = changed(observed.before, observed.after).filter((name) => !name.startsWith('db') && seen(name)).map((name) => name.replace(/^seenBy\.[^.]+\./, ''));
|
|
72
|
+
return [...new Set(states)].filter((name) => !operation.reach.controls.includes(name)).map((name) => ({ says: `"${name}" changed, which ${operation.name} does not control` }));
|
|
73
|
+
}
|
|
57
74
|
function postconditions(operation, kase, observed, meaning) {
|
|
58
75
|
const context = { ...observed, output: observed.body };
|
|
59
76
|
const clauses = [...operation.clauses.filter((clause) => POST.includes(clause.kind)), ...kase.and];
|
|
60
|
-
|
|
77
|
+
const reads = operation.observes || operation.entry.method === 'GET';
|
|
78
|
+
return [...clauses.flatMap((clause) => about(meaning, clause, context, true, 'does not hold after the call')), ...(reads ? unchanged(observed, operation.observes ? 'an observation changes nothing' : 'a route that reads changes nothing') : uncontrolled(operation, observed))];
|
|
61
79
|
}
|
|
62
80
|
/** What a case shows that the specification does not say: nothing, when it passes. */
|
|
63
81
|
export function judge(operation, kase, observed, meaning, refusal) {
|
|
@@ -68,8 +86,18 @@ export function judge(operation, kase, observed, meaning, refusal) {
|
|
|
68
86
|
const after = kase.kind === 'example' ? postconditions(operation, kase, observed, meaning) : unchanged(observed, 'the call was refused');
|
|
69
87
|
return [...before, ...answered, ...after];
|
|
70
88
|
}
|
|
71
|
-
/**
|
|
89
|
+
/**
|
|
90
|
+
* What the type of the input says of the input of a case. That of an example is one, and so is that
|
|
91
|
+
* of a counterexample for a precondition: one that is not violates more than what it is for. That
|
|
92
|
+
* of a counterexample for the type is not one: it is sent as it is, on purpose.
|
|
93
|
+
*/
|
|
72
94
|
export function inputMisfit(operation, kase, input, meaning) {
|
|
73
|
-
|
|
74
|
-
|
|
95
|
+
if (!operation.input)
|
|
96
|
+
return [];
|
|
97
|
+
const misfit = meaning.misfit(operation.input, input);
|
|
98
|
+
if (isForType(operation, kase))
|
|
99
|
+
return misfit ? [] : [{ says: `the input is a ${operation.input}: the case does not violate what it is for` }];
|
|
100
|
+
if (!misfit)
|
|
101
|
+
return [];
|
|
102
|
+
return [{ says: kase.kind === 'example' ? `the input is not a ${operation.input}` : `the input is not a ${operation.input}: the case violates more than what it is for, unless it says "for: ${operation.input}"`, saw: misfit }];
|
|
75
103
|
}
|
package/dist/main.js
CHANGED
|
@@ -103,7 +103,7 @@ function tell(ran, stopped) {
|
|
|
103
103
|
for (const line of summaryLines(ran))
|
|
104
104
|
console.log(line);
|
|
105
105
|
if (asked.fast)
|
|
106
|
-
console.log('The fast run: nothing was read behind the front door.');
|
|
106
|
+
console.log('The fast run: nothing was read behind the front door, and each case observed the states its operation monitors and controls.');
|
|
107
107
|
if (narrowed(asked).length)
|
|
108
108
|
console.log(`Asked: ${narrowed(asked).join(' ')}. The rest of the suite was not run.`);
|
|
109
109
|
if (stopped)
|
package/dist/modelling.js
CHANGED
|
@@ -61,9 +61,11 @@ function relationOf({ name, description, source, raw }, problems) {
|
|
|
61
61
|
function observedIn(written, problems, place) {
|
|
62
62
|
const raw = record(written);
|
|
63
63
|
for (const key of Object.keys(raw))
|
|
64
|
-
if (!['state', 'relations'].includes(key))
|
|
65
|
-
problems.push(`"${key}" is not something it says (state, relations)`);
|
|
64
|
+
if (!['description', 'state', 'relations'].includes(key))
|
|
65
|
+
problems.push(`"${key}" is not something it says (description, state, relations)`);
|
|
66
|
+
const description = describedBy(raw.description, problems);
|
|
66
67
|
return {
|
|
68
|
+
...(description ? { description } : {}),
|
|
67
69
|
state: listed('state', raw.state, problems, (at) => place('state', at), { formaldef: true }).map((item) => stateOf(item, problems)),
|
|
68
70
|
relations: listed('relation', raw.relations, problems, (at) => place('relations', at), { also: ['table', 'key', 'attributes'] }).map((item) => relationOf(item, problems)),
|
|
69
71
|
};
|
|
@@ -80,10 +82,58 @@ function actorOf({ name, description, source, raw }, agents, problems) {
|
|
|
80
82
|
}
|
|
81
83
|
/** What the runner knows, from `world.yml`: who may call, its actors, and whatever else it says. */
|
|
82
84
|
function knownIn(written, agents, problems, place) {
|
|
83
|
-
const { actors, ...world } = record(written);
|
|
85
|
+
const { actors, description: written_, ...world } = record(written);
|
|
84
86
|
if ('requester' in world)
|
|
85
87
|
problems.push('"requester" is who calls, which a case says');
|
|
86
|
-
|
|
88
|
+
const description = describedBy(written_, problems);
|
|
89
|
+
return { ...(description ? { description } : {}), actors: listed('actor', actors, problems, (at) => place('actors', at), { also: ['is', 'with'] }).map((item) => actorOf(item, agents, problems)), world };
|
|
90
|
+
}
|
|
91
|
+
/** A description of a file at the root: what its section is about, in Markdown. */
|
|
92
|
+
function describedBy(written, problems) {
|
|
93
|
+
if (written === undefined || written === null)
|
|
94
|
+
return undefined;
|
|
95
|
+
if (typeof written === 'string' && written.trim())
|
|
96
|
+
return written.trim();
|
|
97
|
+
problems.push('"description" is a text, in Markdown');
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* A file at the root that lists citizens: a map of its description and its list, under the name
|
|
102
|
+
* the file says them by. A list alone was the form of opspicy 0.2, which `opspicy upgrade` rewrites.
|
|
103
|
+
*/
|
|
104
|
+
function sectionOf(written, key, problems) {
|
|
105
|
+
if (Array.isArray(written)) {
|
|
106
|
+
problems.push(`it says its "description" and its "${key}": a list alone is the form of opspicy 0.2, which \`opspicy upgrade\` rewrites`);
|
|
107
|
+
return { list: written };
|
|
108
|
+
}
|
|
109
|
+
if (written !== undefined && written !== null && typeof written !== 'object')
|
|
110
|
+
problems.push(`it says its "description" and its "${key}"`);
|
|
111
|
+
const raw = record(written);
|
|
112
|
+
for (const other of Object.keys(raw))
|
|
113
|
+
if (!['description', key].includes(other))
|
|
114
|
+
problems.push(`"${other}" is not something it says (description, ${key})`);
|
|
115
|
+
const description = describedBy(raw.description, problems);
|
|
116
|
+
return { ...(description ? { description } : {}), list: raw[key] };
|
|
117
|
+
}
|
|
118
|
+
/** What the specified system is called and is, from `system.yml`. */
|
|
119
|
+
function systemOf(written, problems, place) {
|
|
120
|
+
if (written !== undefined && written !== null && (typeof written !== 'object' || Array.isArray(written)))
|
|
121
|
+
problems.push('it says the "name" of the system, and its "description"');
|
|
122
|
+
const raw = record(written);
|
|
123
|
+
for (const key of Object.keys(raw))
|
|
124
|
+
if (!['name', 'description'].includes(key))
|
|
125
|
+
problems.push(`"${key}" is not something it says (name, description)`);
|
|
126
|
+
const system = {};
|
|
127
|
+
if (raw.name !== undefined && raw.name !== null) {
|
|
128
|
+
if (typeof raw.name === 'string' && raw.name.trim())
|
|
129
|
+
system.name = raw.name.trim();
|
|
130
|
+
else
|
|
131
|
+
problems.push('"name" is the name of the system, a text');
|
|
132
|
+
}
|
|
133
|
+
if (Object.keys(raw).length)
|
|
134
|
+
system.source = place();
|
|
135
|
+
const description = describedBy(raw.description, problems);
|
|
136
|
+
return { system, ...(description ? { description } : {}) };
|
|
87
137
|
}
|
|
88
138
|
/** Every directory of the specification is an area that `areas.yml` describes, and nothing else is one. */
|
|
89
139
|
function unplaced(areas, words) {
|
|
@@ -95,21 +145,29 @@ function unplaced(areas, words) {
|
|
|
95
145
|
}
|
|
96
146
|
/** The model of a suite, from what it says. */
|
|
97
147
|
export function modelOf(said) {
|
|
98
|
-
const [inAreas, inAgents, inBackgrounds, inState, inWorld, inWords] = [[], [], [], [], [], []];
|
|
148
|
+
const [inSystem, inAreas, inAgents, inBackgrounds, inState, inWorld, inWords] = [[], [], [], [], [], [], []];
|
|
99
149
|
const words = said.words ?? [];
|
|
100
150
|
const at = (file) => placeOf(`${file}.yml`, said.lines?.[file]);
|
|
101
|
-
|
|
151
|
+
/** Where an item of the list of a file is: under the key the file says it by. */
|
|
152
|
+
const within = (file, key) => (...path) => at(file)(key, ...path);
|
|
153
|
+
const { system, description: ofSystem } = systemOf(said.system, inSystem, at('system'));
|
|
154
|
+
const areasFile = sectionOf(said.areas, 'areas', inAreas);
|
|
155
|
+
const areas = plain(areasFile.list, 'area', inAreas, within('areas', 'areas'));
|
|
102
156
|
inAreas.push(...unplaced(areas, words));
|
|
103
|
-
const
|
|
104
|
-
const
|
|
105
|
-
const
|
|
106
|
-
const
|
|
157
|
+
const agentsFile = sectionOf(said.agents, 'agents', inAgents);
|
|
158
|
+
const agents = agentsOf(agentsFile.list, inAgents, within('agents', 'agents'));
|
|
159
|
+
const backgroundsFile = sectionOf(said.backgrounds, 'backgrounds', inBackgrounds);
|
|
160
|
+
const backgrounds = plain(backgroundsFile.list, 'background', inBackgrounds, within('backgrounds', 'backgrounds'));
|
|
161
|
+
const { description: ofState, ...observed } = observedIn(said.state, inState, at('state'));
|
|
162
|
+
const { description: ofWorld, ...known } = knownIn(said.world, agents, inWorld, at('world'));
|
|
107
163
|
const conditions = conditionsOf(words, inWords);
|
|
108
164
|
const definitions = definitionsOf(words, observed.state.map((one) => one.name), inWords);
|
|
109
165
|
const types = words.flatMap((one) => typesOf(one.types ?? '', one.area, inWords));
|
|
110
166
|
for (const condition of conditions)
|
|
111
167
|
if (condition.violated && !named(known.actors, condition.violated.actor))
|
|
112
168
|
inWords.push(`condition "${condition.description}": nobody is called "${condition.violated.actor}" in the world`);
|
|
113
|
-
const
|
|
114
|
-
|
|
169
|
+
const texts = { system: ofSystem, areas: areasFile.description, agents: agentsFile.description, backgrounds: backgroundsFile.description, state: ofState, world: ofWorld };
|
|
170
|
+
const descriptions = Object.fromEntries(Object.entries(texts).filter(([, text]) => text));
|
|
171
|
+
const problems = [...under('system.yml', inSystem), ...under('areas.yml', inAreas), ...under('agents.yml', inAgents), ...under('backgrounds.yml', inBackgrounds), ...under('state.yml', inState), ...under('world.yml', inWorld), ...inWords];
|
|
172
|
+
return { model: { system, descriptions, areas, agents, backgrounds, ...known, ...observed, definitions, conditions, types }, problems };
|
|
115
173
|
}
|
package/dist/planning.js
CHANGED
|
@@ -22,11 +22,20 @@ export function witnessesOf(operation, kase) {
|
|
|
22
22
|
const sources = [...operation.clauses, ...kase.and].map((clause) => clause.formaldef ?? '').concat(typeof kase.input === 'string' ? kase.input : '');
|
|
23
23
|
return [...new Set(sources.flatMap(witnessesNamed))];
|
|
24
24
|
}
|
|
25
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* What a reader should know is missing: what the operation is, a rule nothing violates, an
|
|
27
|
+
* operation nothing shows. An operation says the transition it makes, every rule aside: its DomPre
|
|
28
|
+
* and its DomPost. An observation makes none, and says none. A DomPre is the state the transition
|
|
29
|
+
* starts from, which a counterexample may show refused and need not: of an operation that makes
|
|
30
|
+
* something, nothing names what is not made yet.
|
|
31
|
+
*/
|
|
26
32
|
export function gapsOf(operation, cases) {
|
|
27
33
|
const violated = (clause) => cases.some((kase) => kase.kind === 'counterexample' && sameSentence(kase.for ?? '', clause.description));
|
|
34
|
+
const says = (kind) => operation.clauses.some((clause) => clause.kind === kind);
|
|
28
35
|
return [
|
|
36
|
+
...(operation.observes || says('DomPre') ? [] : ['no DomPre says the state it starts from']),
|
|
37
|
+
...(operation.observes || says('DomPost') ? [] : ['no DomPost says the state it makes']),
|
|
29
38
|
...(cases.some((kase) => kase.kind === 'example') ? [] : ['no example shows it succeed']),
|
|
30
|
-
...operation.clauses.filter((clause) =>
|
|
39
|
+
...operation.clauses.filter((clause) => clause.kind === 'ReqPre' && !violated(clause)).map((clause) => `no counterexample violates "${clause.description}"`),
|
|
31
40
|
];
|
|
32
41
|
}
|