modality-ts 0.0.17 → 0.0.18

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 CHANGED
@@ -11,29 +11,33 @@ It extracts a finite transition model from React + TypeScript code, checks devel
11
11
 
12
12
  ## Install
13
13
 
14
+ Install `modality-ts` as a dev dependency in the app you are checking. Property files such as `app.props.mjs` import `modality-ts/core`, so the package must resolve from that app's dependency graph.
15
+
14
16
  ```bash
15
- npm install -g modality-ts
17
+ npm install -D modality-ts
16
18
  ```
17
19
 
20
+ (`pnpm add -D modality-ts` and `yarn add -D modality-ts` work the same way.)
21
+
18
22
  ## Usage
19
23
 
20
24
  Start by extracting a model from a React component:
21
25
 
22
26
  ```bash
23
- modality init
24
- modality extract
27
+ npx modality init
28
+ npx modality extract
25
29
  ```
26
30
 
27
31
  If your component calls side-effect APIs that should appear in the model, name them explicitly:
28
32
 
29
33
  ```bash
30
- modality extract --effect-api api.placeOrder
34
+ npx modality extract --effect-api api.placeOrder
31
35
  ```
32
36
 
33
37
  Check the extracted model against a property file:
34
38
 
35
39
  ```bash
36
- modality check
40
+ npx modality check
37
41
  ```
38
42
 
39
43
  `modality check` applies conservative default search limits (`--max-states`, `--max-edges`, `--max-frontier`, `--memory-guard-mb`). Use `--no-search-limits` for intentionally unbounded runs.
@@ -41,25 +45,25 @@ modality check
41
45
  When a property fails, replay the generated counterexample trace:
42
46
 
43
47
  ```bash
44
- modality replay .modality/traces/noDoubleSubmit.violated.trace.json
48
+ npx modality replay .modality/traces/noDoubleSubmit.violated.trace.json
45
49
  ```
46
50
 
47
51
  For CI, write all verification artifacts into one directory:
48
52
 
49
53
  ```bash
50
- modality ci .modality/model.json src/app.props.mjs --artifacts .modality
54
+ npx modality ci .modality/model.json src/app.props.mjs --artifacts .modality
51
55
  ```
52
56
 
53
57
  Useful commands:
54
58
 
55
59
  ```bash
56
- modality init
57
- modality extract [source.tsx ...]
58
- modality check [model.json] [props.mjs ...] [--max-states N] [--max-edges N] [--max-frontier N] [--memory-guard-mb N] [--no-search-limits]
59
- modality replay <trace.json>
60
- modality conform --count 8 --depth 4
61
- modality export
62
- modality ci <model.json> [props.ts] --artifacts .modality
60
+ npx modality init
61
+ npx modality extract [source.tsx ...]
62
+ npx modality check [model.json] [props.mjs ...] [--max-states N] [--max-edges N] [--max-frontier N] [--memory-guard-mb N] [--no-search-limits]
63
+ npx modality replay <trace.json>
64
+ npx modality conform --count 8 --depth 4
65
+ npx modality export
66
+ npx modality ci <model.json> [props.ts] --artifacts .modality
63
67
  ```
64
68
 
65
69
  ## Limitation
@@ -1,5 +1,15 @@
1
1
  import type { Model, ModelState, Property, TraceStep } from "modality-ts/core";
2
2
  import type { CheckOptions, CheckResult } from "./types.js";
3
+ export type LinuxLibcKind = "gnu" | "musl";
4
+ export interface NativeRuntime {
5
+ platform: NodeJS.Platform;
6
+ arch: string;
7
+ libcKind?: LinuxLibcKind;
8
+ }
9
+ export declare function nativeTriplesForRuntime(platform: NodeJS.Platform, arch: string, libcKind?: LinuxLibcKind): string[];
10
+ export declare function detectLinuxLibc(): LinuxLibcKind;
11
+ export declare function candidateNativeFilenames(runtime: NativeRuntime): string[];
12
+ export declare function resolveNativeBinaryInDirs(nativeDirs: string[], runtime: NativeRuntime): string | undefined;
3
13
  export declare function runRustCheck(model: Model, properties: readonly Property[], options?: CheckOptions): CheckResult;
4
14
  export declare function runRustInitialStates(model: Model): ModelState[];
5
15
  export declare function runRustSuccessors(model: Model, state: ModelState): TraceStep[];
@@ -1 +1 @@
1
- {"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../../src/check/native.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE/E,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAmD5D,wBAAgB,YAAY,CAC1B,KAAK,EAAE,KAAK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AAE,CAG/D;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,UAAU,GAChB,SAAS,EAAE,CAMb"}
@@ -1,27 +1,101 @@
1
- import { createRequire } from "node:module";
2
- import { existsSync, readdirSync } from "node:fs";
1
+ import { execFileSync } from "node:child_process";
2
+ import { existsSync } from "node:fs";
3
3
  import { dirname, join } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
+ import { createRequire } from "node:module";
5
6
  import { serializeProperties } from "./serialize-properties.js";
6
7
  const require = createRequire(import.meta.url);
7
- function resolveNativeBinary() {
8
+ export function nativeTriplesForRuntime(platform, arch, libcKind) {
9
+ if (platform === "darwin") {
10
+ if (arch === "arm64")
11
+ return ["darwin-arm64", "darwin-universal"];
12
+ if (arch === "x64")
13
+ return ["darwin-x64", "darwin-universal"];
14
+ return [];
15
+ }
16
+ if (platform === "linux") {
17
+ if (arch === "x64") {
18
+ if (libcKind === "musl")
19
+ return ["linux-x64-musl"];
20
+ return ["linux-x64-gnu"];
21
+ }
22
+ if (arch === "arm64")
23
+ return ["linux-arm64-gnu"];
24
+ return [];
25
+ }
26
+ if (platform === "win32" && arch === "x64") {
27
+ return ["win32-x64-msvc"];
28
+ }
29
+ return [];
30
+ }
31
+ export function detectLinuxLibc() {
32
+ if (typeof process.report?.getReport === "function") {
33
+ const report = process.report.getReport();
34
+ if (report.header?.glibcVersionRuntime) {
35
+ return "gnu";
36
+ }
37
+ }
38
+ try {
39
+ const lddVersion = execFileSync("ldd", ["--version"], {
40
+ encoding: "utf8",
41
+ });
42
+ return lddVersion.includes("musl") ? "musl" : "gnu";
43
+ }
44
+ catch {
45
+ return "musl";
46
+ }
47
+ }
48
+ function currentNativeRuntime() {
49
+ const runtime = {
50
+ platform: process.platform,
51
+ arch: process.arch,
52
+ };
53
+ if (process.platform === "linux") {
54
+ runtime.libcKind = detectLinuxLibc();
55
+ }
56
+ return runtime;
57
+ }
58
+ export function candidateNativeFilenames(runtime) {
59
+ const triples = nativeTriplesForRuntime(runtime.platform, runtime.arch, runtime.libcKind);
60
+ const suffixed = triples.map((triple) => `modality-checker.${triple}.node`);
61
+ return [...suffixed, "modality-checker.node"];
62
+ }
63
+ export function resolveNativeBinaryInDirs(nativeDirs, runtime) {
64
+ const candidates = candidateNativeFilenames(runtime);
65
+ for (const dir of nativeDirs) {
66
+ if (!existsSync(dir))
67
+ continue;
68
+ for (const filename of candidates) {
69
+ const candidate = join(dir, filename);
70
+ if (existsSync(candidate))
71
+ return candidate;
72
+ }
73
+ }
74
+ return undefined;
75
+ }
76
+ function defaultNativeDirs() {
8
77
  const here = dirname(fileURLToPath(import.meta.url));
9
- const nativeDirs = [
78
+ return [
10
79
  join(here, "..", "..", "native"),
11
80
  join(here, "native"),
12
81
  join(process.cwd(), "native"),
13
82
  ];
14
- for (const dir of nativeDirs) {
15
- const exact = join(dir, "modality-checker.node");
16
- if (existsSync(exact))
17
- return exact;
18
- if (!existsSync(dir))
19
- continue;
20
- const platformMatch = readdirSync(dir).find((entry) => entry.startsWith("modality-checker.") && entry.endsWith(".node"));
21
- if (platformMatch)
22
- return join(dir, platformMatch);
23
- }
24
- throw new Error("Native modality-checker addon not found. Run `pnpm build:rust` before checking.");
83
+ }
84
+ function resolveNativeBinary() {
85
+ const runtime = currentNativeRuntime();
86
+ const nativeDirs = defaultNativeDirs();
87
+ const resolved = resolveNativeBinaryInDirs(nativeDirs, runtime);
88
+ if (resolved)
89
+ return resolved;
90
+ const candidates = candidateNativeFilenames(runtime);
91
+ const triples = nativeTriplesForRuntime(runtime.platform, runtime.arch, runtime.libcKind);
92
+ const libc = runtime.platform === "linux" ? ` (${runtime.libcKind ?? "unknown"})` : "";
93
+ throw new Error(`Native modality-checker addon not found for ${runtime.platform}/${runtime.arch}${libc}. ` +
94
+ `Expected one of: ${candidates.join(", ")}. ` +
95
+ `Searched: ${nativeDirs.join(", ")}. ` +
96
+ (triples.length === 0
97
+ ? "This platform is not supported by the published native artifact set."
98
+ : "Run `pnpm build:rust` for a local build or install a published package that includes the matching native binary."));
25
99
  }
26
100
  let binding;
27
101
  function loadBinding() {
@@ -1 +1 @@
1
- {"version":3,"file":"native.js","sourceRoot":"","sources":["../../src/check/native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAWhE,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C,SAAS,mBAAmB;IAC1B,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACrD,MAAM,UAAU,GAAG;QACjB,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC;QAChC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC;QACpB,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC;KAC9B,CAAC;IACF,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,uBAAuB,CAAC,CAAC;QACjD,IAAI,UAAU,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;QACpC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,SAAS;QAC/B,MAAM,aAAa,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,CACzC,CAAC,KAAK,EAAE,EAAE,CACR,KAAK,CAAC,UAAU,CAAC,mBAAmB,CAAC,IAAI,KAAK,CAAC,QAAQ,CAA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,MAAM,UAAU,iBAAiB,CAC/B,KAAY,EACZ,KAAiB;IAEjB,MAAM,GAAG,GAAG,WAAW,EAAE,CAAC,eAAe,CACvC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EACrB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CACtB,CAAC;IACF,OAAO,aAAa,CAAc,GAAG,CAAC,CAAC;AACzC,CAAC"}
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "modality-ts",
3
- "version": "0.0.17",
3
+ "version": "0.0.18",
4
4
  "description": "Model-checking-based testing tools for React state-transition bugs.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/native/index.d.ts DELETED
@@ -1,8 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
-
4
- /* auto-generated by NAPI-RS */
5
-
6
- export declare function checkModel(serializedRequest: string): string
7
- export declare function modelInitialStates(modelJson: string): string
8
- export declare function modelSuccessors(modelJson: string, stateJson: string): string
package/native/index.js DELETED
@@ -1,317 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
- /* prettier-ignore */
4
-
5
- /* auto-generated by NAPI-RS */
6
-
7
- const { existsSync, readFileSync } = require('fs')
8
- const { join } = require('path')
9
-
10
- const { platform, arch } = process
11
-
12
- let nativeBinding = null
13
- let localFileExisted = false
14
- let loadError = null
15
-
16
- function isMusl() {
17
- // For Node 10
18
- if (!process.report || typeof process.report.getReport !== 'function') {
19
- try {
20
- const lddPath = require('child_process').execSync('which ldd').toString().trim()
21
- return readFileSync(lddPath, 'utf8').includes('musl')
22
- } catch (e) {
23
- return true
24
- }
25
- } else {
26
- const { glibcVersionRuntime } = process.report.getReport().header
27
- return !glibcVersionRuntime
28
- }
29
- }
30
-
31
- switch (platform) {
32
- case 'android':
33
- switch (arch) {
34
- case 'arm64':
35
- localFileExisted = existsSync(join(__dirname, 'modality-checker.android-arm64.node'))
36
- try {
37
- if (localFileExisted) {
38
- nativeBinding = require('./modality-checker.android-arm64.node')
39
- } else {
40
- nativeBinding = require('modality-ts-android-arm64')
41
- }
42
- } catch (e) {
43
- loadError = e
44
- }
45
- break
46
- case 'arm':
47
- localFileExisted = existsSync(join(__dirname, 'modality-checker.android-arm-eabi.node'))
48
- try {
49
- if (localFileExisted) {
50
- nativeBinding = require('./modality-checker.android-arm-eabi.node')
51
- } else {
52
- nativeBinding = require('modality-ts-android-arm-eabi')
53
- }
54
- } catch (e) {
55
- loadError = e
56
- }
57
- break
58
- default:
59
- throw new Error(`Unsupported architecture on Android ${arch}`)
60
- }
61
- break
62
- case 'win32':
63
- switch (arch) {
64
- case 'x64':
65
- localFileExisted = existsSync(
66
- join(__dirname, 'modality-checker.win32-x64-msvc.node')
67
- )
68
- try {
69
- if (localFileExisted) {
70
- nativeBinding = require('./modality-checker.win32-x64-msvc.node')
71
- } else {
72
- nativeBinding = require('modality-ts-win32-x64-msvc')
73
- }
74
- } catch (e) {
75
- loadError = e
76
- }
77
- break
78
- case 'ia32':
79
- localFileExisted = existsSync(
80
- join(__dirname, 'modality-checker.win32-ia32-msvc.node')
81
- )
82
- try {
83
- if (localFileExisted) {
84
- nativeBinding = require('./modality-checker.win32-ia32-msvc.node')
85
- } else {
86
- nativeBinding = require('modality-ts-win32-ia32-msvc')
87
- }
88
- } catch (e) {
89
- loadError = e
90
- }
91
- break
92
- case 'arm64':
93
- localFileExisted = existsSync(
94
- join(__dirname, 'modality-checker.win32-arm64-msvc.node')
95
- )
96
- try {
97
- if (localFileExisted) {
98
- nativeBinding = require('./modality-checker.win32-arm64-msvc.node')
99
- } else {
100
- nativeBinding = require('modality-ts-win32-arm64-msvc')
101
- }
102
- } catch (e) {
103
- loadError = e
104
- }
105
- break
106
- default:
107
- throw new Error(`Unsupported architecture on Windows: ${arch}`)
108
- }
109
- break
110
- case 'darwin':
111
- localFileExisted = existsSync(join(__dirname, 'modality-checker.darwin-universal.node'))
112
- try {
113
- if (localFileExisted) {
114
- nativeBinding = require('./modality-checker.darwin-universal.node')
115
- } else {
116
- nativeBinding = require('modality-ts-darwin-universal')
117
- }
118
- break
119
- } catch {}
120
- switch (arch) {
121
- case 'x64':
122
- localFileExisted = existsSync(join(__dirname, 'modality-checker.darwin-x64.node'))
123
- try {
124
- if (localFileExisted) {
125
- nativeBinding = require('./modality-checker.darwin-x64.node')
126
- } else {
127
- nativeBinding = require('modality-ts-darwin-x64')
128
- }
129
- } catch (e) {
130
- loadError = e
131
- }
132
- break
133
- case 'arm64':
134
- localFileExisted = existsSync(
135
- join(__dirname, 'modality-checker.darwin-arm64.node')
136
- )
137
- try {
138
- if (localFileExisted) {
139
- nativeBinding = require('./modality-checker.darwin-arm64.node')
140
- } else {
141
- nativeBinding = require('modality-ts-darwin-arm64')
142
- }
143
- } catch (e) {
144
- loadError = e
145
- }
146
- break
147
- default:
148
- throw new Error(`Unsupported architecture on macOS: ${arch}`)
149
- }
150
- break
151
- case 'freebsd':
152
- if (arch !== 'x64') {
153
- throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
154
- }
155
- localFileExisted = existsSync(join(__dirname, 'modality-checker.freebsd-x64.node'))
156
- try {
157
- if (localFileExisted) {
158
- nativeBinding = require('./modality-checker.freebsd-x64.node')
159
- } else {
160
- nativeBinding = require('modality-ts-freebsd-x64')
161
- }
162
- } catch (e) {
163
- loadError = e
164
- }
165
- break
166
- case 'linux':
167
- switch (arch) {
168
- case 'x64':
169
- if (isMusl()) {
170
- localFileExisted = existsSync(
171
- join(__dirname, 'modality-checker.linux-x64-musl.node')
172
- )
173
- try {
174
- if (localFileExisted) {
175
- nativeBinding = require('./modality-checker.linux-x64-musl.node')
176
- } else {
177
- nativeBinding = require('modality-ts-linux-x64-musl')
178
- }
179
- } catch (e) {
180
- loadError = e
181
- }
182
- } else {
183
- localFileExisted = existsSync(
184
- join(__dirname, 'modality-checker.linux-x64-gnu.node')
185
- )
186
- try {
187
- if (localFileExisted) {
188
- nativeBinding = require('./modality-checker.linux-x64-gnu.node')
189
- } else {
190
- nativeBinding = require('modality-ts-linux-x64-gnu')
191
- }
192
- } catch (e) {
193
- loadError = e
194
- }
195
- }
196
- break
197
- case 'arm64':
198
- if (isMusl()) {
199
- localFileExisted = existsSync(
200
- join(__dirname, 'modality-checker.linux-arm64-musl.node')
201
- )
202
- try {
203
- if (localFileExisted) {
204
- nativeBinding = require('./modality-checker.linux-arm64-musl.node')
205
- } else {
206
- nativeBinding = require('modality-ts-linux-arm64-musl')
207
- }
208
- } catch (e) {
209
- loadError = e
210
- }
211
- } else {
212
- localFileExisted = existsSync(
213
- join(__dirname, 'modality-checker.linux-arm64-gnu.node')
214
- )
215
- try {
216
- if (localFileExisted) {
217
- nativeBinding = require('./modality-checker.linux-arm64-gnu.node')
218
- } else {
219
- nativeBinding = require('modality-ts-linux-arm64-gnu')
220
- }
221
- } catch (e) {
222
- loadError = e
223
- }
224
- }
225
- break
226
- case 'arm':
227
- if (isMusl()) {
228
- localFileExisted = existsSync(
229
- join(__dirname, 'modality-checker.linux-arm-musleabihf.node')
230
- )
231
- try {
232
- if (localFileExisted) {
233
- nativeBinding = require('./modality-checker.linux-arm-musleabihf.node')
234
- } else {
235
- nativeBinding = require('modality-ts-linux-arm-musleabihf')
236
- }
237
- } catch (e) {
238
- loadError = e
239
- }
240
- } else {
241
- localFileExisted = existsSync(
242
- join(__dirname, 'modality-checker.linux-arm-gnueabihf.node')
243
- )
244
- try {
245
- if (localFileExisted) {
246
- nativeBinding = require('./modality-checker.linux-arm-gnueabihf.node')
247
- } else {
248
- nativeBinding = require('modality-ts-linux-arm-gnueabihf')
249
- }
250
- } catch (e) {
251
- loadError = e
252
- }
253
- }
254
- break
255
- case 'riscv64':
256
- if (isMusl()) {
257
- localFileExisted = existsSync(
258
- join(__dirname, 'modality-checker.linux-riscv64-musl.node')
259
- )
260
- try {
261
- if (localFileExisted) {
262
- nativeBinding = require('./modality-checker.linux-riscv64-musl.node')
263
- } else {
264
- nativeBinding = require('modality-ts-linux-riscv64-musl')
265
- }
266
- } catch (e) {
267
- loadError = e
268
- }
269
- } else {
270
- localFileExisted = existsSync(
271
- join(__dirname, 'modality-checker.linux-riscv64-gnu.node')
272
- )
273
- try {
274
- if (localFileExisted) {
275
- nativeBinding = require('./modality-checker.linux-riscv64-gnu.node')
276
- } else {
277
- nativeBinding = require('modality-ts-linux-riscv64-gnu')
278
- }
279
- } catch (e) {
280
- loadError = e
281
- }
282
- }
283
- break
284
- case 's390x':
285
- localFileExisted = existsSync(
286
- join(__dirname, 'modality-checker.linux-s390x-gnu.node')
287
- )
288
- try {
289
- if (localFileExisted) {
290
- nativeBinding = require('./modality-checker.linux-s390x-gnu.node')
291
- } else {
292
- nativeBinding = require('modality-ts-linux-s390x-gnu')
293
- }
294
- } catch (e) {
295
- loadError = e
296
- }
297
- break
298
- default:
299
- throw new Error(`Unsupported architecture on Linux: ${arch}`)
300
- }
301
- break
302
- default:
303
- throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
304
- }
305
-
306
- if (!nativeBinding) {
307
- if (loadError) {
308
- throw loadError
309
- }
310
- throw new Error(`Failed to load native binding`)
311
- }
312
-
313
- const { checkModel, modelInitialStates, modelSuccessors } = nativeBinding
314
-
315
- module.exports.checkModel = checkModel
316
- module.exports.modelInitialStates = modelInitialStates
317
- module.exports.modelSuccessors = modelSuccessors