@mostra/conformance 0.0.0-stage → 0.2.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/LICENSE +202 -0
- package/README.md +69 -2
- package/baselines/reference-host-rust-broken.json +8 -0
- package/baselines/reference-host-ts-broken.json +8 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +106 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +403 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/protocol-RQ9lbehE.js +207 -0
- package/dist/protocol-RQ9lbehE.js.map +1 -0
- package/dist/reference-host-BJ-A_Qd_.d.ts +257 -0
- package/dist/reference-host-BJ-A_Qd_.d.ts.map +1 -0
- package/dist/reference-host-d6gs3Tal.js +409 -0
- package/dist/reference-host-d6gs3Tal.js.map +1 -0
- package/dist/reference-host.d.ts +2 -0
- package/dist/reference-host.js +3 -0
- package/dist/runner-CvoSJlfk.js +1940 -0
- package/dist/runner-CvoSJlfk.js.map +1 -0
- package/package.json +67 -3
- package/src/baseline.ts +51 -0
- package/src/cli.ts +117 -0
- package/src/fixtures.ts +87 -0
- package/src/harness/client.ts +224 -0
- package/src/harness/protocol.ts +381 -0
- package/src/harness/serve.ts +146 -0
- package/src/index.ts +65 -0
- package/src/reference-host.ts +359 -0
- package/src/runner.ts +189 -0
- package/src/scenario.ts +376 -0
- package/src/scenarios/delivery.ts +267 -0
- package/src/scenarios/index.ts +20 -0
- package/src/scenarios/interaction.ts +453 -0
- package/src/scenarios/ports.ts +278 -0
- package/src/scenarios/session.ts +183 -0
- package/src/scenarios/viewing.ts +184 -0
- package/src/version.ts +29 -0
- package/src/viewer.ts +380 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,70 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @mostra/conformance
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Prove that a host's Mostra integration holds. The kit runs scenarios against your host (durable
|
|
4
|
+
submissions, delivery once in effect across crashes, retries and outbox replay, identity, trusted
|
|
5
|
+
controls, hygiene, version negotiation, long-lived state, the authoring directory's removal, and
|
|
6
|
+
more), compares the outcome with your expected-failure baseline, and exits 0 only when nothing
|
|
7
|
+
changed for the worse.
|
|
8
|
+
|
|
9
|
+
## How it reaches your host
|
|
10
|
+
|
|
11
|
+
Your host ships a small **harness shim**: a program the kit starts, which reads JSON-RPC 2.0
|
|
12
|
+
requests on stdin (one per line) and answers them with your real integration. Any language works.
|
|
13
|
+
|
|
14
|
+
| Method | Your shim |
|
|
15
|
+
|---|---|
|
|
16
|
+
| `harness/initialize` | names the host, the ports it registers and its features (`attach`, `faults`, `events`) |
|
|
17
|
+
| `harness/start { home, env, mode? }` | starts or attaches to your Mostra instance for that home, adding `env` to its environment |
|
|
18
|
+
| `harness/call { method, params, timeoutMs? }` | sends one host-protocol request through your client; answers `{ result }` or `{ error }` |
|
|
19
|
+
| `harness/stop` | ends your session |
|
|
20
|
+
| `harness/store` | reports what your own store holds: deliveries, draft mirrors, activations, identity, policy and secret calls, with what your identity and policy ports answered (scenarios judge a host that can't be scripted by those answers) |
|
|
21
|
+
| `harness/script` | (feature `faults`) answers a port the way the kit asks |
|
|
22
|
+
| `harness/events` | (feature `events`) reads pages from your own named event stream |
|
|
23
|
+
|
|
24
|
+
TypeScript hosts write the shim with `serveHarness`:
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { serveHarness } from "@mostra/conformance";
|
|
28
|
+
|
|
29
|
+
await serveHarness({
|
|
30
|
+
initialize: () => ({ host: { name: "my-host", version: "1.0.0" }, ports: ["submissions"], features: [] }),
|
|
31
|
+
start: (params) => myHost.startMostra(params.home, params.env),
|
|
32
|
+
call: (method, params) => myHost.mostra.call(method, params),
|
|
33
|
+
stop: () => myHost.stopMostra(),
|
|
34
|
+
store: () => myHost.conformanceStore(),
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Rust hosts copy `crates/mostra-host-reference` in the Mostra repository.
|
|
39
|
+
|
|
40
|
+
## Running it
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
npx -p @mostra/conformance mostra-conformance --host "node my-harness.js" --baseline conformance.json
|
|
44
|
+
npx -p @mostra/conformance mostra-conformance --list
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
`--only <id or prefix>` picks scenarios, `--json` prints the report, `--verify` publishes through
|
|
48
|
+
verify's gate (it needs the verify browser). Exit codes: 0 conformant, 1 not, 2 a usage error.
|
|
49
|
+
|
|
50
|
+
## Baselines
|
|
51
|
+
|
|
52
|
+
A host that fails a scenario today records it with the reason:
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{ "schemaVersion": 1, "expectedFailures": { "delivery.exactly-once": "our store isn't idempotent yet (#123)" } }
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The run stays green while those fail and goes red when a new scenario fails or a listed one passes,
|
|
59
|
+
so the baseline only ever shrinks.
|
|
60
|
+
|
|
61
|
+
## Reference hosts
|
|
62
|
+
|
|
63
|
+
`mostra-conformance-reference-host` is the TypeScript reference host, built on `@mostra/sdk`.
|
|
64
|
+
`--standalone` registers no port (Mostra's built-in adapters); `--unscripted` serves every port
|
|
65
|
+
without the `faults` feature, naming people by its own IDs and allowing both channels, as a host
|
|
66
|
+
that can't be scripted would; `--break <fault,…>` is a
|
|
67
|
+
deliberately broken host for proving the kit. Both reference hosts pass every scenario that applies
|
|
68
|
+
to them.
|
|
69
|
+
|
|
70
|
+
License: Apache-2.0.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"expectedFailures": {
|
|
4
|
+
"delivery.exactly-once": "--break store-duplicates: the store keeps every delivery call, so a redelivery is stored twice",
|
|
5
|
+
"drafts.mirror": "--break drafts-as-submissions: the store takes draft mirrors for submissions",
|
|
6
|
+
"ports.trusted-controls": "--break ignore-policy: the policy allows both channels whatever the host meant"
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"expectedFailures": {
|
|
4
|
+
"delivery.exactly-once": "--break store-duplicates: the store keeps every delivery call, so a redelivery is stored twice",
|
|
5
|
+
"drafts.mirror": "--break drafts-as-submissions: the store takes draft mirrors for submissions",
|
|
6
|
+
"ports.trusted-controls": "--break ignore-policy: the policy allows both channels whatever the host meant"
|
|
7
|
+
}
|
|
8
|
+
}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { n as SCENARIOS, t as runConformance, y as readBaseline } from "./runner-CvoSJlfk.js";
|
|
3
|
+
import { parseArgs } from "node:util";
|
|
4
|
+
//#region src/cli.ts
|
|
5
|
+
/**
|
|
6
|
+
* `mostra-conformance`: runs the host conformance kit (HO-05) against a host's harness shim.
|
|
7
|
+
*
|
|
8
|
+
* mostra-conformance --host "<command>" [--baseline <file>] [--only <id-or-prefix>]…
|
|
9
|
+
* [--verify] [--json] [--list]
|
|
10
|
+
*
|
|
11
|
+
* Exit codes: 0 the run passes (every failure expected by the baseline, no stale entry), 1 it
|
|
12
|
+
* doesn't, 2 a usage error.
|
|
13
|
+
*/
|
|
14
|
+
const MARKS = {
|
|
15
|
+
passed: "pass",
|
|
16
|
+
failed: "FAIL",
|
|
17
|
+
skipped: "skip",
|
|
18
|
+
"expected-failure": "xfail",
|
|
19
|
+
"unexpected-pass": "XPASS"
|
|
20
|
+
};
|
|
21
|
+
function parse() {
|
|
22
|
+
return parseArgs({
|
|
23
|
+
options: {
|
|
24
|
+
host: { type: "string" },
|
|
25
|
+
baseline: { type: "string" },
|
|
26
|
+
only: {
|
|
27
|
+
type: "string",
|
|
28
|
+
multiple: true
|
|
29
|
+
},
|
|
30
|
+
verify: { type: "boolean" },
|
|
31
|
+
json: { type: "boolean" },
|
|
32
|
+
list: { type: "boolean" },
|
|
33
|
+
help: { type: "boolean" }
|
|
34
|
+
},
|
|
35
|
+
strict: true
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async function main() {
|
|
39
|
+
let parsed;
|
|
40
|
+
try {
|
|
41
|
+
parsed = parse();
|
|
42
|
+
} catch (error) {
|
|
43
|
+
process.stderr.write(`mostra-conformance: ${error.message} (see --help).\n`);
|
|
44
|
+
return 2;
|
|
45
|
+
}
|
|
46
|
+
const { values } = parsed;
|
|
47
|
+
if (values.help) {
|
|
48
|
+
process.stdout.write([
|
|
49
|
+
"Usage: mostra-conformance --host <command> [--baseline <file>] [--only <id>]… [--verify] [--json]",
|
|
50
|
+
" mostra-conformance --list",
|
|
51
|
+
"",
|
|
52
|
+
"Runs the host conformance scenarios against the harness shim <command> starts.",
|
|
53
|
+
"Exit codes: 0 passes, 1 fails (a new failure, or a baseline entry that now passes), 2 usage.",
|
|
54
|
+
""
|
|
55
|
+
].join("\n"));
|
|
56
|
+
return 0;
|
|
57
|
+
}
|
|
58
|
+
if (values.list) {
|
|
59
|
+
for (const scenario of SCENARIOS) process.stdout.write(values.json ? `${JSON.stringify({
|
|
60
|
+
id: scenario.id,
|
|
61
|
+
title: scenario.title,
|
|
62
|
+
covers: scenario.covers,
|
|
63
|
+
needs: scenario.needs ?? []
|
|
64
|
+
})}\n` : `${scenario.id} ${scenario.title}\n`);
|
|
65
|
+
return 0;
|
|
66
|
+
}
|
|
67
|
+
if (!values.host) {
|
|
68
|
+
process.stderr.write("mostra-conformance: --host <command> is required (see --help).\n");
|
|
69
|
+
return 2;
|
|
70
|
+
}
|
|
71
|
+
const known = SCENARIOS.map((scenario) => scenario.id);
|
|
72
|
+
let baseline;
|
|
73
|
+
try {
|
|
74
|
+
baseline = values.baseline ? readBaseline(values.baseline, known) : void 0;
|
|
75
|
+
} catch (error) {
|
|
76
|
+
process.stderr.write(`mostra-conformance: ${error.message}\n`);
|
|
77
|
+
return 2;
|
|
78
|
+
}
|
|
79
|
+
const report = await runConformance({
|
|
80
|
+
host: values.host,
|
|
81
|
+
...baseline ? { baseline } : {},
|
|
82
|
+
...values.only ? { only: values.only.flatMap((entry) => entry.split(",")).filter(Boolean) } : {},
|
|
83
|
+
verify: values.verify ?? false,
|
|
84
|
+
onOutcome: (outcome) => {
|
|
85
|
+
if (values.json) return;
|
|
86
|
+
const reason = outcome.reason ? `\n ${outcome.reason}` : "";
|
|
87
|
+
process.stderr.write(`${MARKS[outcome.status].padEnd(5)} ${outcome.id} (${(outcome.durationMs / 1e3).toFixed(1)} s)${reason}\n`);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
if (values.json) process.stdout.write(`${JSON.stringify(report)}\n`);
|
|
91
|
+
else {
|
|
92
|
+
const count = (status) => report.outcomes.filter((outcome) => outcome.status === status).length;
|
|
93
|
+
process.stderr.write(`\n${report.host?.host.name ?? "host"}: ${count("passed")} passed, ${count("failed")} failed, ${count("expected-failure")} expected failures, ${count("unexpected-pass")} stale baseline entries, ${count("skipped")} skipped: ${report.ok ? "conformant" : "not conformant"}\n`);
|
|
94
|
+
}
|
|
95
|
+
return report.ok ? 0 : 1;
|
|
96
|
+
}
|
|
97
|
+
main().then((code) => {
|
|
98
|
+
process.exitCode = code;
|
|
99
|
+
}, (error) => {
|
|
100
|
+
process.stderr.write(`mostra-conformance: ${error.stack ?? error}\n`);
|
|
101
|
+
process.exitCode = 2;
|
|
102
|
+
});
|
|
103
|
+
//#endregion
|
|
104
|
+
export {};
|
|
105
|
+
|
|
106
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","names":[],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n/**\n * `mostra-conformance`: runs the host conformance kit (HO-05) against a host's harness shim.\n *\n * mostra-conformance --host \"<command>\" [--baseline <file>] [--only <id-or-prefix>]…\n * [--verify] [--json] [--list]\n *\n * Exit codes: 0 the run passes (every failure expected by the baseline, no stale entry), 1 it\n * doesn't, 2 a usage error.\n */\nimport { parseArgs } from \"node:util\";\nimport { readBaseline } from \"./baseline.ts\";\nimport { runConformance, type ScenarioOutcome } from \"./runner.ts\";\nimport { SCENARIOS } from \"./scenarios/index.ts\";\n\nconst MARKS: Readonly<Record<ScenarioOutcome[\"status\"], string>> = {\n passed: \"pass\",\n failed: \"FAIL\",\n skipped: \"skip\",\n \"expected-failure\": \"xfail\",\n \"unexpected-pass\": \"XPASS\",\n};\n\nfunction parse() {\n return parseArgs({\n options: {\n host: { type: \"string\" },\n baseline: { type: \"string\" },\n only: { type: \"string\", multiple: true },\n verify: { type: \"boolean\" },\n json: { type: \"boolean\" },\n list: { type: \"boolean\" },\n help: { type: \"boolean\" },\n },\n strict: true,\n });\n}\n\nasync function main(): Promise<number> {\n let parsed: ReturnType<typeof parse>;\n try {\n parsed = parse();\n } catch (error) {\n process.stderr.write(`mostra-conformance: ${(error as Error).message} (see --help).\\n`);\n return 2;\n }\n const { values } = parsed;\n if (values.help) {\n process.stdout.write(\n [\n \"Usage: mostra-conformance --host <command> [--baseline <file>] [--only <id>]… [--verify] [--json]\",\n \" mostra-conformance --list\",\n \"\",\n \"Runs the host conformance scenarios against the harness shim <command> starts.\",\n \"Exit codes: 0 passes, 1 fails (a new failure, or a baseline entry that now passes), 2 usage.\",\n \"\",\n ].join(\"\\n\"),\n );\n return 0;\n }\n if (values.list) {\n for (const scenario of SCENARIOS) {\n process.stdout.write(\n values.json\n ? `${JSON.stringify({ id: scenario.id, title: scenario.title, covers: scenario.covers, needs: scenario.needs ?? [] })}\\n`\n : `${scenario.id} ${scenario.title}\\n`,\n );\n }\n return 0;\n }\n if (!values.host) {\n process.stderr.write(\"mostra-conformance: --host <command> is required (see --help).\\n\");\n return 2;\n }\n const known = SCENARIOS.map((scenario) => scenario.id);\n let baseline: ReturnType<typeof readBaseline> | undefined;\n try {\n baseline = values.baseline ? readBaseline(values.baseline, known) : undefined;\n } catch (error) {\n process.stderr.write(`mostra-conformance: ${(error as Error).message}\\n`);\n return 2;\n }\n const report = await runConformance({\n host: values.host,\n ...(baseline ? { baseline } : {}),\n ...(values.only\n ? { only: values.only.flatMap((entry) => entry.split(\",\")).filter(Boolean) }\n : {}),\n verify: values.verify ?? false,\n onOutcome: (outcome) => {\n if (values.json) return;\n const reason = outcome.reason ? `\\n ${outcome.reason}` : \"\";\n process.stderr.write(\n `${MARKS[outcome.status].padEnd(5)} ${outcome.id} (${(outcome.durationMs / 1000).toFixed(1)} s)${reason}\\n`,\n );\n },\n });\n if (values.json) process.stdout.write(`${JSON.stringify(report)}\\n`);\n else {\n const count = (status: ScenarioOutcome[\"status\"]): number =>\n report.outcomes.filter((outcome) => outcome.status === status).length;\n process.stderr.write(\n `\\n${report.host?.host.name ?? \"host\"}: ${count(\"passed\")} passed, ${count(\"failed\")} failed, ${count(\"expected-failure\")} expected failures, ${count(\"unexpected-pass\")} stale baseline entries, ${count(\"skipped\")} skipped: ${report.ok ? \"conformant\" : \"not conformant\"}\\n`,\n );\n }\n return report.ok ? 0 : 1;\n}\n\nmain().then(\n (code) => {\n process.exitCode = code;\n },\n (error: unknown) => {\n process.stderr.write(`mostra-conformance: ${(error as Error).stack ?? error}\\n`);\n process.exitCode = 2;\n },\n);\n"],"mappings":";;;;;;;;;;;;;AAeA,MAAM,QAA6D;CACjE,QAAQ;CACR,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