@enspirit/opspicy 0.3.1 → 0.4.0
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 +29 -26
- package/bin/help.js +6 -1
- package/dist/configuration.d.ts +16 -1
- package/dist/explorer/api.js +4 -3
- package/dist/explorer/elo-refs.js +6 -3
- package/dist/explorer/index.js +1 -2
- package/dist/explorer/operation.js +2 -4
- package/dist/explorer/pages.js +9 -14
- package/dist/explorer/script/ranking.js +2 -2
- package/dist/explorer/wiki.js +1 -2
- package/dist/files.js +27 -16
- package/dist/judging.js +2 -34
- package/dist/main.js +1 -1
- package/dist/meaning.js +2 -2
- package/dist/modelling.js +99 -25
- package/dist/naming.js +44 -15
- package/dist/notation.js +18 -3
- package/dist/observing.js +112 -0
- package/dist/planning.js +3 -3
- package/dist/reach.js +244 -140
- package/dist/reading.js +14 -18
- package/dist/running.js +18 -8
- package/dist/starting.js +4 -3
- package/dist/suite.js +8 -1
- package/dist/upgrade.js +3 -9
- package/dist/upgrading-state.js +197 -0
- package/dist/upgrading.js +13 -2
- package/dist/variables.js +62 -0
- package/dist/world.js +12 -40
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,7 +19,6 @@ ReqPre:
|
|
|
19
19
|
# Of an expense that is kept: of one that is not, the DomPre says it.
|
|
20
20
|
- (x) the requester paid it: expense(input.id) == null || expense(input.id).paidBy == me
|
|
21
21
|
ReqPost:
|
|
22
|
-
- (x) it is one expense fewer: count(expenses) == count(old.expenses) - 1
|
|
23
22
|
- (x) the balances still sum to zero: balanced
|
|
24
23
|
- (x) each who shared it, the payer aside, owes their share less, to the cent: >-
|
|
25
24
|
let e = old.expense(input.id), n = count(e.sharedBy) in
|
|
@@ -46,7 +45,7 @@ counterexamples:
|
|
|
46
45
|
then: 403 expenses.notTheirs
|
|
47
46
|
```
|
|
48
47
|
|
|
49
|
-
It is one operation of [the example](#try-it), a splitter of a group's shared expenses.
|
|
48
|
+
It is one operation of [the example](#try-it), a splitter of a group's shared expenses. What it reads is derived from its clauses, as [state variables](doc/suite.md#state-variables) say: one expense, by what it is given, and the balance of whoever has one. Nothing says what it changes, and nothing checks that the rest stayed as it was: only its clauses and its answer are checked.
|
|
50
49
|
|
|
51
50
|
One responsibility: *read a suite of such files, run each case against a running system through its front door, and say what does not hold.*
|
|
52
51
|
|
|
@@ -78,10 +77,9 @@ AddExpense — Member · POST /api/expenses · expenses/operations/AddExpense.ym
|
|
|
78
77
|
DomPost ✓ the expense is kept
|
|
79
78
|
ReqPre ✓ the requester is signed in
|
|
80
79
|
ReqPre ✓ it is shared among the group
|
|
81
|
-
ReqPost ✓ it is
|
|
80
|
+
ReqPost ✓ it is as given, paid by the requester
|
|
82
81
|
ReqPost ✓ the balances still sum to zero
|
|
83
82
|
ReqPost ✓ each who shares it, the payer aside, owes their share more, to the cent
|
|
84
|
-
ReqPost ✓ nobody else's balance moves
|
|
85
83
|
✓ example: Bob pays a lunch for the three, which splits evenly
|
|
86
84
|
✗ example: Ann pays a dinner for the three, which leaves a cent over
|
|
87
85
|
ReqPost "the balances still sum to zero" does not hold after the call
|
|
@@ -94,8 +92,8 @@ Its four specifications are small. Each operation says first the transition it m
|
|
|
94
92
|
|
|
95
93
|
| | Its transition | What the rules demand of it |
|
|
96
94
|
| --- | --- | --- |
|
|
97
|
-
| [`AddExpense`](example/suite/specification/expenses/operations/AddExpense.yml) | The expense is not kept yet; then it is. | Shared among the group; an amount above zero, which its type says, `Int(c \| c > 0)`, and a counterexample `for` the type shows refused. It is
|
|
98
|
-
| [`SettleUp`](example/suite/specification/expenses/operations/SettleUp.yml) | The requester has a debt; then a smaller one. | The requester owes at least the amount, and whom it is paid to is owed at least that much: constraints on the state, not on the input. Both balances move by exactly that much
|
|
95
|
+
| [`AddExpense`](example/suite/specification/expenses/operations/AddExpense.yml) | The expense is not kept yet; then it is. | Shared among the group; an amount above zero, which its type says, `Int(c \| c > 0)`, and a counterexample `for` the type shows refused. It is as given; each who shares it owes their share more, to the cent; another member sees it too. |
|
|
96
|
+
| [`SettleUp`](example/suite/specification/expenses/operations/SettleUp.yml) | The requester has a debt; then a smaller one. | The requester owes at least the amount, and whom it is paid to is owed at least that much: constraints on the state, not on the input. Both balances move by exactly that much. |
|
|
99
97
|
| [`RemoveExpense`](example/suite/specification/expenses/operations/RemoveExpense.yml) | The expense is kept; then it is not. | Only who paid it, and who shared it owes their share less. |
|
|
100
98
|
| [`ListBalances`](example/suite/specification/expenses/observations/ListBalances.yml) | None: an observation makes no transition. | What it tells is the state, and sums to zero. |
|
|
101
99
|
|
|
@@ -112,22 +110,22 @@ bin/opspicy serve example/suite --report=last.json --api # http://127.0.0
|
|
|
112
110
|
| | |
|
|
113
111
|
| --- | --- |
|
|
114
112
|
| **Given** | The Background: the database is put in a seed, and who calls is signed in. |
|
|
115
|
-
| | The state is observed: `_.before`. |
|
|
113
|
+
| | The state is observed: `_.before`. [What of it](doc/derived.md#what-a-case-observes), and by which mechanism, is the run's to say: [two runs](#two-runs). |
|
|
116
114
|
| **When** | The operation is called once, through the front door, with the input. What it started and did not wait for is waited for. |
|
|
117
115
|
| **Then** | The state is observed again: `_.after`. |
|
|
118
|
-
| an example | Every precondition held before the call · the answer has the status said, and is of the type said, when the operation names one: a text is not a number there, nor true or false · every postcondition holds
|
|
119
|
-
| a counterexample | Its input is of the operation's type, unless it is `for` that type, on purpose · the precondition it is `for` did not hold, and every other did (one that a condition gives is not asked the second: who violates a condition, somebody not signed in say, violates more) · it is refused with the status and the code said, as the type refusals have
|
|
116
|
+
| an example | Every precondition held before the call · the answer has the status said, and is of the type said, when the operation names one: a text is not a number there, nor true or false · every postcondition holds |
|
|
117
|
+
| a counterexample | Its input is of the operation's type, unless it is `for` that type, on purpose · the precondition it is `for` did not hold, and every other did (one that a condition gives is not asked the second: who violates a condition, somebody not signed in say, violates more) · it is refused with the status and the code said, as the type refusals have |
|
|
120
118
|
|
|
121
119
|
Nothing is instrumented: a precondition is never *made* to hold. A case chooses its Background, and what is checked is that the preconditions are what the case says they are.
|
|
122
120
|
|
|
123
121
|
### Two runs
|
|
124
122
|
|
|
125
|
-
| | Checks |
|
|
123
|
+
| | Checks | Observes |
|
|
126
124
|
| --- | --- | --- |
|
|
127
|
-
| **complete** | Every clause that has a formaldef. |
|
|
128
|
-
| **fast** (`--fast`) | What must hold: every clause but those marked `(+)`, which it tells. |
|
|
125
|
+
| **complete** | Every clause that has a formaldef, `(+)` included. | [What each case reads](doc/derived.md#what-a-case-observes), by every mechanism it reads it through: the front door, as who calls and as whoever looks on, and the database. |
|
|
126
|
+
| **fast** (`--fast`) | What must hold: every clause but those marked `(+)`, which it tells. | Through the front door alone, [what each case reads](doc/derived.md#what-a-case-observes), as narrowly as it is named: an item by the route that tells it alone, where the state says one. What the configuration's `atRest` asks of the database is still asked. |
|
|
129
127
|
|
|
130
|
-
The fast run is the system as a black box: it passes whatever the schema is, so it is the one that must stay as it is when the system is rebuilt inside. A clause that reads the database is checked in the complete run only, and [says so](doc/suite.md#an-operation-specificationareaoperationsoperationyml-and-an-observation-beside-it).
|
|
128
|
+
The fast run is the system as a black box: it passes whatever the schema is, so it is the one that must stay as it is when the system is rebuilt inside. It is as long as what its cases touch, and not as the system is large: an operation that reads one item, `board(input.id).name`, has its cases ask for that board, not for every board. A clause that reads the database is checked in the complete run only, and [says so](doc/suite.md#an-operation-specificationareaoperationsoperationyml-and-an-observation-beside-it).
|
|
131
129
|
|
|
132
130
|
## Public interface
|
|
133
131
|
|
|
@@ -172,7 +170,7 @@ What of the suite is run, and how much of it is told, is asked through the envir
|
|
|
172
170
|
| `ROBUST=no\|only\|generated` | Only the examples; only the counterexamples; only those the conditions give. |
|
|
173
171
|
| `FAILFAST=yes` | Stops at the first case that fails. |
|
|
174
172
|
| `FAST=yes` | [The fast run](#two-runs); `--fast` says the same. |
|
|
175
|
-
| `LOG_LEVEL=DEBUG` | Also shows, under each case, the Background it was set in, then what it sent and what it was answered. `TRACE` adds everything around, in a line each and in the order it happened: each wait for the server to be at rest, who signed in, and what each route of the state told whom, before and after. Each of these lines begins with how long that step took: putting the database in the seed, a wait, a call. What the runner sends and is answered to sign an actor in is never shown; a case that is itself a sign-in is shown as any case is. `WARN` tells only the cases that fail. |
|
|
173
|
+
| `LOG_LEVEL=DEBUG` | Also shows, under each case, the Background it was set in, then what it sent and what it was answered. `TRACE` adds everything around, in a line each and in the order it happened: each wait for the server to be at rest, who signed in, and what each route of the state told whom, before and after: what a case asked of the system to be judged. Each of these lines begins with how long that step took: putting the database in the seed, a wait, a call. What the runner sends and is answered to sign an actor in is never shown; a case that is itself a sign-in is shown as any case is. `WARN` tells only the cases that fail. |
|
|
176
174
|
|
|
177
175
|
They combine: `O=expenses ROBUST=no FAILFAST=yes LOG_LEVEL=DEBUG`. What is not understood stops the run before anything is called: `ROBUST=maybe`, a `LOG_LEVEL` that is none of `WARN`, `INFO`, `DEBUG` and `TRACE`, a flag the command does not have, a second directory. So does asking for what no case is. A run that was narrowed says so in its last lines.
|
|
178
176
|
|
|
@@ -186,16 +184,16 @@ A system that stops answering during the run is not that: each case then could n
|
|
|
186
184
|
|
|
187
185
|
| Tag | Is |
|
|
188
186
|
| --- | --- |
|
|
189
|
-
| `0.
|
|
187
|
+
| `0.4.0` | The version tagged `v0.4.0`: the image of that commit, as it was tested. Name one of these. |
|
|
190
188
|
| `latest`, `sha-<commit>` | The main branch, and one commit of it. |
|
|
191
189
|
|
|
192
190
|
**As a tool**, on a suite that is mounted:
|
|
193
191
|
|
|
194
192
|
```sh
|
|
195
|
-
docker run --rm -v "$PWD":/suite:ro enspirit/opspicy:0.
|
|
196
|
-
docker run --rm -v "$PWD":/suite:ro enspirit/opspicy:0.
|
|
197
|
-
docker run --rm -v "$PWD":/suite enspirit/opspicy:0.
|
|
198
|
-
docker run --rm -v "$PWD":/suite:ro -p 127.0.0.1:8080:8080 enspirit/opspicy:0.
|
|
193
|
+
docker run --rm -v "$PWD":/suite:ro enspirit/opspicy:0.4.0 opspicy --check
|
|
194
|
+
docker run --rm -v "$PWD":/suite:ro enspirit/opspicy:0.4.0 tsc -p . # type-checks its config.ts
|
|
195
|
+
docker run --rm -v "$PWD":/suite enspirit/opspicy:0.4.0 opspicy explorer --out=explorer.html
|
|
196
|
+
docker run --rm -v "$PWD":/suite:ro -p 127.0.0.1:8080:8080 enspirit/opspicy:0.4.0 opspicy serve --host=0.0.0.0
|
|
199
197
|
```
|
|
200
198
|
|
|
201
199
|
The last one is read-only: `--api` is offered on the machine the server runs on, which a container is not.
|
|
@@ -203,7 +201,7 @@ The last one is read-only: `--api` is offered on the machine the server runs on,
|
|
|
203
201
|
**As the base of a suite's image**, where the system is reached: on the network of its stack, say.
|
|
204
202
|
|
|
205
203
|
```dockerfile
|
|
206
|
-
FROM enspirit/opspicy:0.
|
|
204
|
+
FROM enspirit/opspicy:0.4.0
|
|
207
205
|
COPY . /suite
|
|
208
206
|
CMD ["tail", "-f", "/dev/null"] # it sleeps, and `opspicy` is run in it
|
|
209
207
|
```
|
|
@@ -244,7 +242,7 @@ A wiki of a suite, as one HTML document that fetches nothing: the specification,
|
|
|
244
242
|
| `@enspirit/elo`, `luxon` | What a formaldef is written in, and the types; the dates Elo computes with. |
|
|
245
243
|
| `highlight.js`, `@enspirit/highlightjs-elo` | Elo as the explorer shows it: the grammar is Elo's own, applied when the document is written, so the page carries neither. |
|
|
246
244
|
| `@enspirit/elo-form` | The form an operation is called with, in the explorer: Elo's own contrib, whose standalone script and style a document is written with. |
|
|
247
|
-
| `yaml`, `pg` | Reading the files; reading the
|
|
245
|
+
| `yaml`, `pg` | Reading the files; reading what the database shows of the state. |
|
|
248
246
|
| `typescript`, `@types/node` (development, and in the image) | Type-checking opspicy itself, and compiling the package; in the image, type-checking a suite's `config.ts`. Who installs the package downloads neither. |
|
|
249
247
|
| `playwright-core` (development) | Drives the installed Chrome in the browser tests; downloads no browser. |
|
|
250
248
|
| [dbagent](https://github.com/enspirit/dbagent), PostgreSQL (of a suite that wants them) | `dbagent(url)` sets a Background by installing a seed, and `noKeyHeld` reads PostgreSQL's advisory locks: both are handed to a `config.ts`, which may do without. |
|
|
@@ -269,8 +267,8 @@ npm run test:package # needs the registry: installs what would be published, a
|
|
|
269
267
|
|
|
270
268
|
| What | Is held by |
|
|
271
269
|
| --- | --- |
|
|
272
|
-
| What reads a suite ([`notation`](src/notation.ts), [`citizens`](src/citizens.ts), [`modelling`](src/modelling.ts), [`words`](src/words.ts), [`lines`](src/lines.ts), [`reading`](src/reading.ts), and [`files`](src/files.ts) on a directory made for the test), names ([`naming`](src/naming.ts)), plans ([`planning`](src/planning.ts)), chooses what is run ([`selecting`](src/selecting.ts)), judges ([`judging`](src/judging.ts)) and tells ([`report`](src/report.ts), [`report-file`](src/report-file.ts)) | Pure, and tables of cases with no server and no mock: [`test/`](test/). |
|
|
273
|
-
| What sets a Background, calls and observes ([`world`](src/world.ts), [`running`](src/running.ts)), and the command | Cases run over the wire against a keeper of boards, [`test/boards/`](test/boards/), started in the test's own process: a small real server, and the suite that specifies it. |
|
|
270
|
+
| What reads a suite ([`notation`](src/notation.ts), [`citizens`](src/citizens.ts), [`modelling`](src/modelling.ts), [`words`](src/words.ts), [`lines`](src/lines.ts), [`reading`](src/reading.ts), and [`files`](src/files.ts) on a directory made for the test), names ([`naming`](src/naming.ts)), says what a state variable is and which covers which ([`variables`](src/variables.ts)), what a formaldef reads of them ([`reach`](src/reach.ts)), plans ([`planning`](src/planning.ts), and what a case observes: [`observing`](src/observing.ts)), chooses what is run ([`selecting`](src/selecting.ts)), judges ([`judging`](src/judging.ts)) and tells ([`report`](src/report.ts), [`report-file`](src/report-file.ts)) | Pure, and tables of cases with no server and no mock: [`test/`](test/). |
|
|
271
|
+
| What sets a Background, calls and observes ([`world`](src/world.ts), [`observing`](src/observing.ts), [`running`](src/running.ts)), and the command | Cases run over the wire against a keeper of boards, [`test/boards/`](test/boards/), started in the test's own process: a small real server, and the suite that specifies it. What is asked of a database is held as the statements it is asked: no test has one. |
|
|
274
272
|
| The example | [`test/example.test.ts`](test/example.test.ts): the suite of [`example/`](example/) reads, and a run of it against the splitter finds its one fault, and nothing else. |
|
|
275
273
|
| What writes the explorer ([`src/explorer/`](src/explorer/)) and what its API answers | The same: pure for the document, over the wire for the API. |
|
|
276
274
|
| What the page's script decides: what a search finds and in what order, the review file, what a call sends and the command that says it ([`src/explorer/script/`](src/explorer/script/)) | `test/script*.test.ts`, which read the script as the page does; the copied command is run through a shell, with a stand-in for `curl`. |
|
|
@@ -298,20 +296,25 @@ What the notation cannot say yet:
|
|
|
298
296
|
- **One precondition violated per counterexample**, so the order of two refusals is said nowhere.
|
|
299
297
|
- **What is answered is its status and its body.** A cookie cleared, a header set, a file that is neither JSON nor text: told only.
|
|
300
298
|
- **A member is checked where a type says what there is.** Elo's checker reads a formaldef under the types of the suite, and only a member that no type has is told: what may be `null` and is read as if it were not is left to the run. What a function is given has no type, so `withId(expenses, 1).amout` is read, and gives nothing.
|
|
299
|
+
- **A key is said of what the operation is given**: one item, or each of a list, `board(input.ids)`. An item that only the state names (the first board, the boards of the requester, who shared the expense that is taken back) is read as any of them, which is every item: `boards(*)`.
|
|
300
|
+
- **A view is compared whole where nothing else is read through it.** `seenBy.admin == old.seenBy.admin` and `db == old.db` compare what was told and shown. In a formaldef that also names an item, a predicate or a function (`board(1)`, `seesBoard(1)`), a view holds what reads it too, and two are never the same: such a formaldef compares the states it means, `seenBy.admin.boards == old.seenBy.admin.boards`.
|
|
301
301
|
- **A predicate or a function is said in Elo, which decides and does not ask.** What a formaldef reads was observed before it is decided: neither can call the system.
|
|
302
302
|
- **What an area says is known to every area**: a condition by its sentence, a predicate, a function and a type by their name. The directory says where a word is at home, not who may say it. The same words written elsewhere with a formaldef of their own make that file unreadable, and the same words written with none take the formaldef silently.
|
|
303
|
-
- **A trigger is told.** `ReqTrig` says when an operation is performed without being asked, and one call shows nothing of it.
|
|
303
|
+
- **A trigger is told.** `ReqTrig` says when an operation is performed without being asked, and one call shows nothing of it. It may say its formaldef, which is read and not checked: that the postcondition of the operation that leaves the state so implies it is for a reader to see, in the same state variables.
|
|
304
304
|
- **An agent is who calls.** What performs an operation without being asked (the server on its clock, say) has no entry to call, and is not an agent of `agents.yml`.
|
|
305
305
|
- **An operation with no example gets no counterexample from a condition**, which gives its first example to who violates it. And one written by hand does not stand in for it: who is not signed in violates more than the one precondition a counterexample is `for`. So that such an operation refuses a visitor is shown by no case.
|
|
306
306
|
- **`PATCH` is not a method an `entry` says.**
|
|
307
307
|
- **A type that is one of several is tried in their order.** Under `Int|String`, `"12"` is refused as a text given for a number; under `String|Int` it is a text.
|
|
308
308
|
- **Elo has no pattern**: "is an address" is approximated.
|
|
309
|
-
- **A Background is
|
|
309
|
+
- **A Background is what the configuration's `background` sets**, by its name. `dbagent(url)` puts the database in a seed; what else a case starts from (a mail server, a queue) is the configuration's to put back there too, before or after it, or it stays as the case before left it. opspicy hands it nothing for that.
|
|
310
310
|
- **`atRest` looks at the database.** Work a system starts without leaving a trace there is not waited for.
|
|
311
311
|
|
|
312
312
|
What the runner does not do yet:
|
|
313
313
|
|
|
314
|
-
- **"Nothing changed" is said of what was observed.** A requester whom every route of the state refuses is told nothing, before and after: where
|
|
314
|
+
- **"Nothing changed" is said of what was observed.** A requester whom every route of the state refuses is told nothing, before and after: where nothing is read in the database (the fast run) and nobody looks on, a counterexample called by them shows that it is refused as said, and nothing of what the call left. A clause that names `seenBy.<actor>` has somebody look on. Nothing else is checked: a call that changes what no clause names is not a finding, in either run.
|
|
315
|
+
- **The database is read where a clause reads it.** The complete run looks in the database at what the clauses read, and the fast run at nothing behind the front door.
|
|
316
|
+
- **A mechanism is the front door or the database.** What else shows the state of a system (a mailbox, a queue, a file) is not observed.
|
|
317
|
+
- **A column is an attribute of the same name, or the one the state says it is** (`filter_json: filter`), as a formaldef reads it. A formaldef still reads a row by its columns, `db.board(1).filter_json`, and a column holds what the table holds, which need not be what the front door tells of that attribute.
|
|
315
318
|
- **A call has no time limit of its own**, nor a question asked of the database: a system that hangs holds a case for as long as Node waits.
|
|
316
319
|
- **An origin is a case's own within one run.** Given an `originHeader`, two runs may call from the same origins, and whoever looks on calls from the requester's.
|
|
317
320
|
- **A cookie is kept until it is taken back by name**: when it expires is not read.
|
package/bin/help.js
CHANGED
|
@@ -18,7 +18,8 @@ the suite is the current directory: \`opspicy --check\` reads the one you are in
|
|
|
18
18
|
|
|
19
19
|
Options:
|
|
20
20
|
--check read the suite and say what cannot be read; call nothing
|
|
21
|
-
--fast the fast run: every clause but those marked (+),
|
|
21
|
+
--fast the fast run: every clause but those marked (+), through the front
|
|
22
|
+
door alone, of what each case reads
|
|
22
23
|
--report=<file> also write what the run decided, as JSON, for the explorer
|
|
23
24
|
-h, --help show this help
|
|
24
25
|
-v, --version show the version
|
|
@@ -101,6 +102,10 @@ current directory when none is named. Commit before, and read the difference aft
|
|
|
101
102
|
From 0.1 and 0.2: areas.yml, agents.yml and backgrounds.yml, a list each, become a map of their
|
|
102
103
|
description and their list.
|
|
103
104
|
|
|
105
|
+
From 0.3: state.yml said the routes of the state and, apart, the relations of the database. It
|
|
106
|
+
becomes one list of state variables, each with what observes it (web, db); a function that reads
|
|
107
|
+
one item of a collection by its key becomes the item of that state.
|
|
108
|
+
|
|
104
109
|
Documentation: ${DOCUMENTATION}/blob/main/CHANGELOG.md`;
|
|
105
110
|
|
|
106
111
|
const TEXTS = { opspicy: OPSPICY, explorer: EXPLORER, serve: SERVE, upgrade: UPGRADE };
|
package/dist/configuration.d.ts
CHANGED
|
@@ -3,9 +3,24 @@ export interface Answer {
|
|
|
3
3
|
/** JSON as data, a text as it is, nothing otherwise. */
|
|
4
4
|
body: unknown;
|
|
5
5
|
}
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Somebody's browser: it keeps the cookies it is given, by a call or by the configuration, and
|
|
8
|
+
* comes from one origin. Any other scheme of sign-in is a header it sends with every call.
|
|
9
|
+
*/
|
|
7
10
|
export interface Browser {
|
|
8
11
|
call(method: string, path: string, body?: unknown): Promise<Answer>;
|
|
12
|
+
/**
|
|
13
|
+
* Sends a header with every call from now on, in place of one of the same name: `authorization`
|
|
14
|
+
* with `Bearer <token>`, say, for a system that signs its software in with a token. A header is
|
|
15
|
+
* never told of: a run says what was sent and what was answered, not what the call was signed with.
|
|
16
|
+
*/
|
|
17
|
+
header(name: string, value: string): void;
|
|
18
|
+
/**
|
|
19
|
+
* Gives it a cookie, as if a call had been answered with it: `sid` with the session a seed
|
|
20
|
+
* holds for somebody, say, who is then signed in without a call. A cookie a later call is
|
|
21
|
+
* given under the same name replaces it, and one it is taken takes it away.
|
|
22
|
+
*/
|
|
23
|
+
cookie(name: string, value: string): void;
|
|
9
24
|
}
|
|
10
25
|
/** Asks the database, to read: one statement, its rows. */
|
|
11
26
|
export type Ask = (sql: string) => Promise<Record<string, unknown>[]>;
|
package/dist/explorer/api.js
CHANGED
|
@@ -13,6 +13,7 @@ import { namesOf } from '../files.js';
|
|
|
13
13
|
import { meaningOf } from '../meaning.js';
|
|
14
14
|
import { addressed, queryOf } from '../notation.js';
|
|
15
15
|
import { runCase } from '../running.js';
|
|
16
|
+
import { observedBy } from '../suite.js';
|
|
16
17
|
import { NotStarted, reachOf } from '../starting.js';
|
|
17
18
|
import { browserOf } from '../world.js';
|
|
18
19
|
import { suiteAt } from './afresh.js';
|
|
@@ -22,8 +23,8 @@ import { ranOf } from './telling.js';
|
|
|
22
23
|
const PROTECTED = 'This stack does not say that its database may be emptied';
|
|
23
24
|
/** Whether the database is somebody's: it is, unless the configuration says in so many words that it may be emptied. What only looks like yes (`'yes'`, `1`) is not. */
|
|
24
25
|
export const isProtected = (config) => config.mayEmptyTheDatabase !== true;
|
|
25
|
-
/** Whether the complete run can be made: it reads the
|
|
26
|
-
const completes = (suite, config) => suite.model.
|
|
26
|
+
/** Whether the complete run can be made: it reads what the database shows of the state, which takes a database. */
|
|
27
|
+
const completes = (suite, config) => observedBy(suite.model, 'db').length === 0 || Boolean(config.database);
|
|
27
28
|
/** What is served: the specification, the system it is run against, whether its database is somebody's, and the runs that can be made. */
|
|
28
29
|
export function health(bench) {
|
|
29
30
|
const suite = suiteAt(bench.root);
|
|
@@ -41,7 +42,7 @@ export async function run(bench, asked) {
|
|
|
41
42
|
if (isProtected(bench.config))
|
|
42
43
|
return refused(403, `${PROTECTED}, and running a case sets its Background, which empties it.`);
|
|
43
44
|
if (found.mode === 'complete' && !completes(suite, bench.config))
|
|
44
|
-
return refused(400, 'The complete run reads the
|
|
45
|
+
return refused(400, 'The complete run reads what the database shows of the state, and the configuration names no database to read it from.');
|
|
45
46
|
// What a run reads is reached as the runner reaches it, and a database that is not there is its sentence, not a failure of this server.
|
|
46
47
|
const reach = await reachOf(suite, bench.config, found.mode === 'fast').catch((error) => (error instanceof NotStarted ? refused(503, error.message) : Promise.reject(error)));
|
|
47
48
|
if (isTold(reach))
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// The names of a formaldef that lead to a citizen of the suite, as Elo's parser reads them. Pure.
|
|
2
2
|
//
|
|
3
3
|
// Elo's parser says where each expression stands (`parse(source, { locations: true })`), so a
|
|
4
|
-
// name is resolved from the tree: a free name, a member of `old`, of `seenBy.<actor>` or of `db
|
|
4
|
+
// name is resolved from the tree: a free name, a member of `old`, of `seenBy.<actor>` or of `db`
|
|
5
|
+
// (a state or the item of one, as that mechanism shows it),
|
|
5
6
|
// a type a value is given to. What the expression binds (a lambda's parameters, a `let`'s names)
|
|
6
7
|
// is not the citizen of the same name, inside that scope only. A member and a record key are never
|
|
7
8
|
// a citizen. A type of a declaration has no position in the tree: it is found among the words of
|
|
@@ -10,13 +11,15 @@ import { parse, splitProgramHeader } from '@enspirit/elo';
|
|
|
10
11
|
import { RESERVED } from '../naming.js';
|
|
11
12
|
import { idOf } from './wiki.js';
|
|
12
13
|
/** The anchors of the citizens a formaldef may name, from what a suite says. */
|
|
14
|
+
/** An item leads to the state it is one of. */
|
|
15
|
+
const items = (state) => state.flatMap((one) => (one.item ? [[one.item.name, idOf('state', one.name)]] : []));
|
|
13
16
|
export function refsOf(model) {
|
|
14
17
|
const by = (kind, names) => names.map((name) => [name, idOf(kind, name)]);
|
|
15
18
|
const definitions = model.definitions.map((one) => [one.name, idOf(one.kind, one.name)]);
|
|
16
19
|
return {
|
|
17
|
-
names: new Map([...by('state', model.state.map((one) => one.name)), ...definitions]),
|
|
20
|
+
names: new Map([...by('state', model.state.map((one) => one.name)), ...items(model.state.filter((one) => one.web)), ...definitions]),
|
|
18
21
|
types: new Map(by('type', model.types.map((one) => one.name))),
|
|
19
|
-
relations: new Map(by('
|
|
22
|
+
relations: new Map([...by('state', model.state.filter((one) => one.db).map((one) => one.name)), ...items(model.state.filter((one) => one.db))]),
|
|
20
23
|
actors: new Map(by('actor', model.actors.map((one) => one.name))),
|
|
21
24
|
};
|
|
22
25
|
}
|
package/dist/explorer/index.js
CHANGED
|
@@ -54,8 +54,7 @@ export function indexOf(wiki, pages) {
|
|
|
54
54
|
...pages.map((page) => ({ h: page.id, k: page.kind, n: page.title, x: page.said ?? '', c: '', ctx: '', ...(page.area ? { a: page.area } : {}), ...(page.quote ? { q: page.quote } : {}) })),
|
|
55
55
|
...wiki.areas.flatMap(wordsOf),
|
|
56
56
|
...wiki.operations.flatMap((operation) => [...operation.clauses.map((one) => clause(operation, one)), ...operation.cases.flatMap((one) => [kase(operation, one), ...also(operation, one)])]),
|
|
57
|
-
...wiki.state.map((one) => plain('state', 'State', STATE, one, `GET ${one.path}`)),
|
|
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 })),
|
|
57
|
+
...wiki.state.map((one) => plain('state', 'State', STATE, one, told(one.item ? `${one.item.name}(${one.item.key.join(', ')})` : '', one.web ? `GET ${one.web.path}` : '', one.web?.one ? `GET ${one.web.one.path}` : '', one.db ? told(one.db.table, one.db.attributes.join(', ')) : ''))),
|
|
59
58
|
...wiki.backgrounds.map((one) => plain('background', 'Background', BACKGROUNDS, one)),
|
|
60
59
|
...wiki.actors.map((one) => plain('actor', 'Actor', WORLD, one, one.is)),
|
|
61
60
|
];
|
|
@@ -2,6 +2,7 @@
|
|
|
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
4
|
import { PRE, SAID, isForType, sameSentence } from '../suite.js';
|
|
5
|
+
import { shown } from '../variables.js';
|
|
5
6
|
import { requestOf } from './calls.js';
|
|
6
7
|
import { eloHtml } from './elo.js';
|
|
7
8
|
import { jsonHtml } from './json.js';
|
|
@@ -19,8 +20,6 @@ const GROUP = {
|
|
|
19
20
|
export const crumbs = (...parts) => `<p class="crumb">${parts.join('<span aria-hidden="true">›</span>')}</p>`;
|
|
20
21
|
export const areaTitle = (name) => (name === '_shared' ? 'Shared' : name.charAt(0).toUpperCase() + name.slice(1));
|
|
21
22
|
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>'}`;
|
|
24
23
|
const typeLink = (name) => (name ? link(`#${idOf('type', name)}`, name) : '<span class="m">nothing</span>');
|
|
25
24
|
/** Who calls, and from which Background: a name for a table cell, each leading to who and what it is. */
|
|
26
25
|
export const callerOf = (kase) => {
|
|
@@ -82,8 +81,7 @@ function typeSide(label, name, { types, refs }) {
|
|
|
82
81
|
export function operationPage(operation, around) {
|
|
83
82
|
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>`))}`) : '';
|
|
84
83
|
const kind = operation.observes ? 'Observation: it only reads, so it is checked to change nothing' : 'Operation';
|
|
85
|
-
const {
|
|
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
|
+
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('Specification', mono(operation.file)), row('Tests', link(`#${idOf('test', operation.name)}`, 'Results of the last run'))];
|
|
87
85
|
const io = `<div class="io">${typeSide('Input', operation.input, around)}<span class="arrow" aria-hidden="true">→</span>${typeSide('Output', operation.output, around)}</div>`;
|
|
88
86
|
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>
|
|
89
87
|
<h1 class="code">${esc(operation.name)}</h1>
|
package/dist/explorer/pages.js
CHANGED
|
@@ -84,13 +84,7 @@ function areaPage(area, refs) {
|
|
|
84
84
|
${citizens('Types', area.types.map((one) => typeShown(one, refs)), { widths: WIDTHS })}`;
|
|
85
85
|
return { id, kind: 'Area', title: areaTitle(area.name), source: area.source, said: area.description, area: area.name, quote: area.description, body };
|
|
86
86
|
}
|
|
87
|
-
const statesLinked = (names) => names.map((name) => link(`#${idOf('state', name)}`, name)).join(', ') || '<span class="m">none</span>';
|
|
88
87
|
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
|
-
};
|
|
94
88
|
/** What an agent performs: the operations that name it, and those that name an agent it also is. */
|
|
95
89
|
const performedBy = (agent, { agents, operations }) => operations.filter((one) => isA(agents, agent.name, one.agent));
|
|
96
90
|
/** 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. */
|
|
@@ -101,7 +95,7 @@ function agentPage(agent, wiki) {
|
|
|
101
95
|
const performed = performedBy(agent, wiki).map((one) => operationListed(id, one, [link(`#${idOf('area', one.area)}`, areaTitle(one.area)), as(one)]));
|
|
102
96
|
const body = `${crumbs(link('#home', 'Specification'), link('#agents', 'Agents'))}<h1>${esc(agent.name)}</h1>
|
|
103
97
|
<p class="lead">${said(agent.description)}</p>
|
|
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
|
|
98
|
+
<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>
|
|
105
99
|
${citizens('Performs', performed, { columns: ['Operation', '', 'Area', 'As'], widths: ['22%', '52%', '13%', '13%'] })}`;
|
|
106
100
|
return { id, kind: 'Agent', title: agent.name, nav: 'agents', source: agent.source, said: agent.description, quote: agent.description, body };
|
|
107
101
|
}
|
|
@@ -135,12 +129,13 @@ function typesPage(wiki) {
|
|
|
135
129
|
return { id: 'types', kind: 'Types', title: 'Types', said: lead, body };
|
|
136
130
|
}
|
|
137
131
|
function statePage(wiki) {
|
|
138
|
-
const
|
|
139
|
-
const
|
|
140
|
-
const
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
132
|
+
const typed = (type) => (type ? ` → ${link(`#${idOf('type', type)}`, type)}` : '');
|
|
133
|
+
const told = ({ web }) => (web ? [`${mono(`GET ${web.path}`)}${typed(web.type)}${web.member ? mono(`.${web.member.join('.')}`) : ''}`, ...(web.one ? [`${mono(`GET ${web.one.path}`)}${typed(web.one.type)}`] : [])] : []);
|
|
134
|
+
const kept = ({ db }) => (db ? [`<span class="m">db</span> ${mono(db.table)} <span class="m">by</span> ${esc(db.key.join(', '))}${db.attributes.length ? `<span class="m">:</span> ${esc(db.attributes.map((column) => (db.named?.[column] ? `${column} as ${db.named[column]}` : column)).join(', '))}` : ''}`] : []);
|
|
135
|
+
const named = (one) => `${mono(one.name)}${one.item ? `<br>${mono(`${one.item.name}(${one.item.key.join(', ')})`)}` : ''}`;
|
|
136
|
+
const state = wiki.state.map((one) => ({ id: idOf('state', one.name), source: one.source, name: named(one), description: said(one.description), more: [[...told(one), ...kept(one)].join('<br>')] }));
|
|
137
|
+
const how = 'What the system keeps, as state variables: a collection is named whole, and one item at a time by its key. Each says what observes it, the route that tells it through the front door and the table that shows it behind (read as db.<state>), ';
|
|
138
|
+
return homePage(wiki, 'state', 'state', 'State', how, citizens('State', state, { columns: ['State', '', 'Observed by'], widths: ['12%', '26%', '62%'] }));
|
|
144
139
|
}
|
|
145
140
|
function worldPage(wiki) {
|
|
146
141
|
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>'] }));
|
|
@@ -154,6 +149,6 @@ function backgroundsPage(wiki) {
|
|
|
154
149
|
}
|
|
155
150
|
/** The pages of the specification, in the order the navigation shows them. */
|
|
156
151
|
export function specPagesOf(wiki) {
|
|
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 };
|
|
152
|
+
const around = { types: new Map(wiki.areas.flatMap((area) => area.types).map((one) => [one.name, one])), conditions: wiki.areas.flatMap((area) => area.conditions), state: wiki.state, refs: wiki.refs };
|
|
158
153
|
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)];
|
|
159
154
|
}
|
|
@@ -12,12 +12,12 @@ const SCOPES = {
|
|
|
12
12
|
Definitions: ['Predicate', 'Function', 'Condition'],
|
|
13
13
|
Clauses: ['Clause'],
|
|
14
14
|
Cases: ['Case'],
|
|
15
|
-
State: ['State'
|
|
15
|
+
State: ['State'],
|
|
16
16
|
Tests: ['Tests'],
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
/** The order the kinds are shown in; one that is not named here comes last. */
|
|
20
|
-
const ORDER = ['Operation', 'Observation', 'Area', 'Type', 'Predicate', 'Function', 'Condition', 'Clause', 'Case', 'State', '
|
|
20
|
+
const ORDER = ['Operation', 'Observation', 'Area', 'Type', 'Predicate', 'Function', 'Condition', 'Clause', 'Case', 'State', 'Agent', 'Actor', 'Background', 'Tests'];
|
|
21
21
|
|
|
22
22
|
/** The words of what was typed: all of them must be found. */
|
|
23
23
|
const wordsOf = (text) => text.trim().toLowerCase().split(/\s+/).filter(Boolean);
|
package/dist/explorer/wiki.js
CHANGED
|
@@ -60,7 +60,7 @@ function areasOf(suite, operations) {
|
|
|
60
60
|
*/
|
|
61
61
|
function typeKindsOf(model, operations) {
|
|
62
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) =>
|
|
63
|
+
const told = new Set(model.state.flatMap((one) => [one.web?.type, one.web?.one?.type]).flatMap((type) => (type ? [type, itemOf(type) ?? type] : [])));
|
|
64
64
|
const exchanged = new Set(operations.flatMap((one) => [one.input, one.output]).filter((one) => Boolean(one)));
|
|
65
65
|
return new Map(model.types.map((one) => [one.name, told.has(one.name) ? 'state' : exchanged.has(one.name) ? 'message' : 'data']));
|
|
66
66
|
}
|
|
@@ -78,7 +78,6 @@ export function wikiOf(suite, report) {
|
|
|
78
78
|
actors: model.actors.map(({ name, description, source, is, with: held }) => ({ name, description, source, is, signsIn: held !== null })),
|
|
79
79
|
backgrounds: model.backgrounds,
|
|
80
80
|
state: model.state,
|
|
81
|
-
relations: model.relations,
|
|
82
81
|
types: model.types,
|
|
83
82
|
worldKeys: Object.keys(model.world),
|
|
84
83
|
refs: refsOf(model),
|
package/dist/files.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// specification/
|
|
8
8
|
// system.yml what the specified system is called, and is (optional)
|
|
9
9
|
// areas.yml, agents.yml, backgrounds.yml the areas, who performs operations, where a case starts
|
|
10
|
-
// state.yml what
|
|
10
|
+
// state.yml the state variables, and what observes each: a route, a table
|
|
11
11
|
// world.yml what the runner knows: who calls, and what they hold
|
|
12
12
|
// _shared/predicates.yml, functions.yml, conditions.yml, types.elo what every area says
|
|
13
13
|
// <area>/predicates.yml, functions.yml, conditions.yml, types.elo what one area says
|
|
@@ -23,7 +23,7 @@ import { modelOf } from './modelling.js';
|
|
|
23
23
|
import { misnamed } from './naming.js';
|
|
24
24
|
import { crowded } from './notation.js';
|
|
25
25
|
import { operationOf } from './reading.js';
|
|
26
|
-
import { NOTHING_SAID,
|
|
26
|
+
import { NOTHING_SAID, isBefore, observedBy } from './suite.js';
|
|
27
27
|
/**
|
|
28
28
|
* A YAML file as it was written, and where each thing is in it. What cannot be read is told, and
|
|
29
29
|
* is nothing: under the name the file is told by, which of an operation is its file from the
|
|
@@ -41,14 +41,20 @@ function written(path, problems, as = path) {
|
|
|
41
41
|
}
|
|
42
42
|
const named = (directory, extension) => (existsSync(directory) ? readdirSync(directory, { recursive: true, encoding: 'utf8' }).filter((file) => file.endsWith(extension)).sort() : []);
|
|
43
43
|
/** What a suite names, that its formaldefs may read. */
|
|
44
|
-
export
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
export function namesOf(model) {
|
|
45
|
+
const told = observedBy(model, 'web');
|
|
46
|
+
const kept = observedBy(model, 'db');
|
|
47
|
+
return {
|
|
48
|
+
states: told.map((one) => one.name),
|
|
49
|
+
relations: kept.map((one) => one.name),
|
|
50
|
+
items: model.state.flatMap((one) => (one.item ? [{ name: one.item.name, of: one.name, key: one.item.key, web: Boolean(one.web), ...(one.db ? { db: one.db.key } : {}) }] : [])),
|
|
51
|
+
actors: model.actors.map((one) => one.name),
|
|
52
|
+
definitions: model.definitions,
|
|
53
|
+
types: Object.fromEntries(told.flatMap((one) => (one.web?.type ? [[one.name, one.web.type]] : []))),
|
|
54
|
+
members: Object.fromEntries(told.flatMap((one) => (one.web?.member ? [[one.name, one.web.member]] : []))),
|
|
55
|
+
columns: Object.fromEntries(kept.map((one) => [one.name, [...one.db.key, ...one.db.attributes]])),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
52
58
|
/** Where a suite says what it specifies. */
|
|
53
59
|
export const SPECIFICATION = 'specification';
|
|
54
60
|
/** Where every area's words are. */
|
|
@@ -120,7 +126,7 @@ function unreadable(operation, meaning, types) {
|
|
|
120
126
|
const clauses = [...operation.clauses, ...operation.cases.flatMap((kase) => kase.and)].filter((clause) => clause.formaldef);
|
|
121
127
|
const declared = (type) => (type && types.includes(type) ? type : undefined);
|
|
122
128
|
const exchanged = { input: declared(operation.input), output: declared(operation.output) };
|
|
123
|
-
const said = clauses.map((clause) => [clause.description, meaning.unreadable(clause.formaldef ?? '',
|
|
129
|
+
const said = clauses.map((clause) => [clause.description, meaning.unreadable(clause.formaldef ?? '', isBefore(clause) ? 'pre' : 'post', exchanged)]);
|
|
124
130
|
const given = operation.cases.filter((kase) => typeof kase.input === 'string').map((kase) => [`the input of "${kase.description}"`, meaning.unreadable(kase.input, 'given')]);
|
|
125
131
|
const unknown = [operation.input, operation.output].filter((type) => type && !types.includes(type)).map((type) => `"${type}" is not a type of the suite`);
|
|
126
132
|
return [...unknown, ...[...said, ...given].flatMap(([says, problem]) => (problem ? [`"${says}": ${problem}`] : []))].map((problem) => `${operation.file}: ${problem}`);
|
|
@@ -143,12 +149,17 @@ function duplicates(operations) {
|
|
|
143
149
|
const names = operations.map((operation) => operation.name);
|
|
144
150
|
return [...new Set(names.filter((name, at) => names.indexOf(name) !== at))].map((name) => `two files specify the operation "${name}"`);
|
|
145
151
|
}
|
|
146
|
-
/** The states whose type no area declares: told, and read as states of no type. */
|
|
152
|
+
/** The states whose type no area declares, of what tells them whole or of one item: told, and read as states of no type. */
|
|
147
153
|
function untyped(model, declared) {
|
|
148
|
-
const
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
154
|
+
const problems = [];
|
|
155
|
+
for (const one of model.state) {
|
|
156
|
+
for (const told of [one.web, one.web?.one]) {
|
|
157
|
+
if (!told?.type || declared.includes(told.type))
|
|
158
|
+
continue;
|
|
159
|
+
problems.push(`${STATE}: state "${one.name}": "${told.type}" is not a type of the suite`);
|
|
160
|
+
told.type = undefined;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
152
163
|
return problems;
|
|
153
164
|
}
|
|
154
165
|
/** Reads the suite of a directory. */
|
package/dist/judging.js
CHANGED
|
@@ -40,42 +40,10 @@ 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
|
-
/**
|
|
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
|
-
*/
|
|
48
|
-
export function changed(before, after, path = '') {
|
|
49
|
-
if (JSON.stringify(before) === JSON.stringify(after))
|
|
50
|
-
return [];
|
|
51
|
-
const nested = (value) => Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
52
|
-
const deeper = path === '' || path === 'db' || path === 'seenBy' || /^seenBy\.[^.]+$/.test(path);
|
|
53
|
-
if (!deeper || !nested(before) || !nested(after))
|
|
54
|
-
return [path];
|
|
55
|
-
return [...new Set([...Object.keys(before), ...Object.keys(after)])].flatMap((name) => changed(before[name], after[name], path ? `${path}.${name}` : name));
|
|
56
|
-
}
|
|
57
|
-
function unchanged(observed, why) {
|
|
58
|
-
const names = changed(observed.before, observed.after);
|
|
59
|
-
return names.length ? [{ says: `${why}, yet this is not as it was: ${names.join(', ')}` }] : [];
|
|
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
|
-
}
|
|
74
43
|
function postconditions(operation, kase, observed, meaning) {
|
|
75
44
|
const context = { ...observed, output: observed.body };
|
|
76
45
|
const clauses = [...operation.clauses.filter((clause) => POST.includes(clause.kind)), ...kase.and];
|
|
77
|
-
|
|
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))];
|
|
46
|
+
return clauses.flatMap((clause) => about(meaning, clause, context, true, 'does not hold after the call'));
|
|
79
47
|
}
|
|
80
48
|
/** What a case shows that the specification does not say: nothing, when it passes. */
|
|
81
49
|
export function judge(operation, kase, observed, meaning, refusal) {
|
|
@@ -83,7 +51,7 @@ export function judge(operation, kase, observed, meaning, refusal) {
|
|
|
83
51
|
const answered = answer(operation, kase, observed, meaning, refusal);
|
|
84
52
|
if (answered.length && observed.status !== kase.then.status)
|
|
85
53
|
return [...before, ...answered];
|
|
86
|
-
const after = kase.kind === 'example' ? postconditions(operation, kase, observed, meaning) :
|
|
54
|
+
const after = kase.kind === 'example' ? postconditions(operation, kase, observed, meaning) : [];
|
|
87
55
|
return [...before, ...answered, ...after];
|
|
88
56
|
}
|
|
89
57
|
/**
|
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, and each case observed
|
|
106
|
+
console.log('The fast run: nothing was read behind the front door, and each case observed what its clauses read.');
|
|
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/meaning.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// It can do nothing else: Elo has no input or output of its own.
|
|
4
4
|
import { compileToJavaScript, parse, typecheck, typecheckWithType } from '@enspirit/elo';
|
|
5
5
|
import { DateTime, Duration, Interval } from 'luxon';
|
|
6
|
-
import { NOTHING_NAMED, misnamed, relationsType, sourceOf, typedSourceOf } from './naming.js';
|
|
6
|
+
import { NOTHING_NAMED, explained, misnamed, relationsType, sourceOf, typedSourceOf } from './naming.js';
|
|
7
7
|
const firstLine = (error) => String(error instanceof Error ? error.message : error).split('\n')[0] ?? '';
|
|
8
8
|
function compiled(source) {
|
|
9
9
|
const javascript = compileToJavaScript(parse(source));
|
|
@@ -33,7 +33,7 @@ export function meaningOf(types, names = NOTHING_NAMED) {
|
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
const prelude = `${types}\n${relationsType(names)}`;
|
|
36
|
-
const unreadable = (source, moment, exchanged) => moment ? misnamed(source, names) ?? unread(() => at(source, moment)) ?? mistyped(`${prelude}\n${typedSourceOf(source, moment, names, exchanged)}`) : unread(() => expression(source));
|
|
36
|
+
const unreadable = (source, moment, exchanged) => moment ? misnamed(source, names) ?? explained(unread(() => at(source, moment)), names) ?? mistyped(`${prelude}\n${typedSourceOf(source, moment, names, exchanged)}`) : unread(() => expression(source));
|
|
37
37
|
const decides = (name) => truthOf(`${prelude}\n${typedSourceOf(name, 'post', names)}`);
|
|
38
38
|
return { value, misfit: (type, given) => misfit(expression, types, type, given), unreadable, decides };
|
|
39
39
|
}
|