tslaws 0.6.4 → 0.8.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.
Files changed (78) hide show
  1. package/README.md +16 -9
  2. package/dist/api.d.ts +10 -0
  3. package/dist/api.js +7 -0
  4. package/dist/browser.d.ts +2 -2
  5. package/dist/browser.js +2 -6
  6. package/dist/check.d.ts +2 -0
  7. package/dist/check.js +218 -56
  8. package/dist/cli.d.ts +18 -0
  9. package/dist/cli.js +189 -56
  10. package/dist/compile.d.ts +12 -0
  11. package/dist/compile.js +207 -6
  12. package/dist/coverage.d.ts +21 -1
  13. package/dist/coverage.js +33 -23
  14. package/dist/derived.d.ts +8 -0
  15. package/dist/derived.js +52 -0
  16. package/dist/e2e.d.ts +0 -9
  17. package/dist/e2e.js +0 -20
  18. package/dist/generators.d.ts +8 -8
  19. package/dist/generators.js +59 -99
  20. package/dist/github.d.ts +121 -0
  21. package/dist/github.js +266 -0
  22. package/dist/githubCli.d.ts +46 -0
  23. package/dist/githubCli.js +502 -0
  24. package/dist/globs.d.ts +3 -0
  25. package/dist/globs.js +24 -0
  26. package/dist/init.js +5 -5
  27. package/dist/lawFiles.d.ts +21 -0
  28. package/dist/lawFiles.js +95 -0
  29. package/dist/lawKinds.d.ts +38 -0
  30. package/dist/lawKinds.js +210 -0
  31. package/dist/lawNames.d.ts +6 -0
  32. package/dist/lawNames.js +22 -0
  33. package/dist/list.d.ts +22 -0
  34. package/dist/list.js +36 -0
  35. package/dist/lock.d.ts +39 -3
  36. package/dist/lock.js +107 -4
  37. package/dist/lower.d.ts +10 -0
  38. package/dist/lower.js +178 -0
  39. package/dist/mcp.d.ts +2 -8
  40. package/dist/mcp.js +40 -61
  41. package/dist/migrate/arbitraries.d.ts +23 -0
  42. package/dist/migrate/arbitraries.js +202 -0
  43. package/dist/migrate/convert.d.ts +20 -0
  44. package/dist/migrate/convert.js +915 -0
  45. package/dist/migrate/framework.d.ts +48 -0
  46. package/dist/migrate/framework.js +249 -0
  47. package/dist/migrate/index.d.ts +16 -0
  48. package/dist/migrate/index.js +155 -0
  49. package/dist/migrate/report.d.ts +35 -0
  50. package/dist/migrate/report.js +40 -0
  51. package/dist/migrate/source.d.ts +42 -0
  52. package/dist/migrate/source.js +163 -0
  53. package/dist/migrate/tests.d.ts +44 -0
  54. package/dist/migrate/tests.js +184 -0
  55. package/dist/plan.d.ts +50 -0
  56. package/dist/plan.js +118 -0
  57. package/dist/pool.d.ts +21 -0
  58. package/dist/pool.js +54 -0
  59. package/dist/promote.d.ts +30 -2
  60. package/dist/promote.js +133 -7
  61. package/dist/property.d.ts +12 -26
  62. package/dist/property.js +33 -74
  63. package/dist/propertyRun.d.ts +35 -0
  64. package/dist/propertyRun.js +79 -0
  65. package/dist/propertyWorker.js +7 -9
  66. package/dist/proposals.d.ts +43 -0
  67. package/dist/proposals.js +192 -0
  68. package/dist/regressions.js +23 -2
  69. package/dist/reporters.d.ts +3 -0
  70. package/dist/reporters.js +17 -0
  71. package/dist/smt.d.ts +16 -0
  72. package/dist/smt.js +52 -9
  73. package/dist/solvers.d.ts +31 -0
  74. package/dist/solvers.js +121 -0
  75. package/dist/symbolic.js +2 -2
  76. package/dist/types.d.ts +19 -0
  77. package/hooks/AGENTS.snippet.md +2 -2
  78. package/package.json +9 -7
package/dist/types.d.ts CHANGED
@@ -2,6 +2,8 @@ export type LawStatus = 'proved' | 'bounded' | 'tested' | 'open' | 'failed' | 't
2
2
  export interface ManifestLaw {
3
3
  file: string;
4
4
  name: string;
5
+ /** The exported function the law lowers to, when its name is not itself an identifier. Defaults to `name`. */
6
+ symbol?: string;
5
7
  exported: boolean;
6
8
  proved: boolean;
7
9
  line: number;
@@ -23,10 +25,27 @@ export interface LawResult {
23
25
  seed?: number;
24
26
  counterexample?: string;
25
27
  message?: string;
28
+ /** The domain assumptions a `proved` or `bounded` result rests on, for the parameter types of this law only. */
29
+ assumptions?: string[];
26
30
  /** Project-relative path of a screenshot of the page at the counterexample (browser laws). */
27
31
  screenshot?: string;
28
32
  /** The project functions the law reaches and where they are declared, for an editor to mark on both ends. */
29
33
  exercises?: Exercised[];
34
+ /**
35
+ * Set on a `tampered` result whose law is not (or no longer) the one in the lock: what the law would be if a person
36
+ * accepted it. The law still ran, so a reviewer sees whether the proposal holds; the result stays `tampered`, so the
37
+ * check still fails until the lock records the law.
38
+ */
39
+ proposal?: ProposalOutcome;
40
+ }
41
+ /** Why a law is a proposal, and what it did when it ran. */
42
+ export interface ProposalOutcome {
43
+ reason: 'added' | 'changed' | 'removed' | 'level' | 'exempt';
44
+ /** The status the law would have if accepted; `removed` and `exempt` proposals run nothing and hold trivially. */
45
+ status: Exclude<LawStatus, 'tampered' | 'uncovered'>;
46
+ method: string;
47
+ counterexample?: string;
48
+ message?: string;
30
49
  }
31
50
  export interface CheckOptions {
32
51
  files: string[];
@@ -1,10 +1,10 @@
1
1
  ## Laws
2
2
 
3
- This project states behaviour as `law` declarations in `*.laws.ts`. They are the person's side of the contract.
3
+ This project states behaviour as laws in `*.laws.ts`, written as calls, `law('name', (a: int) => ...)` and `law.proved('name', ...)`, or, with the tsc-laws compiler, as `export law name(a: int) { ... }` declarations. Use the syntax the existing laws use and never mix the two in one project. They are the person's side of the contract.
4
4
 
5
5
  - Run `npx tslaws check` before you finish or commit. It must exit 0: every law `proved` or `tested`, none `open`, `failed` or `tampered`.
6
6
  - Every exported function must be reached by a law (`uncovered` fails). Do not add `@tslaws-exempt` yourself; the lock rejects it. If code needs a law, ask for one or write it in a `*.proposed.laws.ts`.
7
7
  - A failed law means the code is wrong. Fix the code. Never edit, weaken, delete or add a law in a `*.laws.ts` file, and never run `tslaws accept`; the lock (`tsc-laws.lock`) will reject the change anyway.
8
- - To suggest a law, write it in `<name>.proposed.laws.ts` and run `npx tslaws check --proposed` to see whether it holds. A person promotes it.
8
+ - To suggest a law, write it in `<name>.proposed.laws.ts` (in the project's syntax) and run `npx tslaws check --proposed` to see whether it holds. A person promotes it.
9
9
  - If the `tslaws` MCP server is configured (`npx tslaws mcp`), use its tools `tslaws_check`, `tslaws_check_proposed`, `tslaws_explain` and `tslaws_propose` instead of the shell; they cannot accept laws or change the lock. `tslaws promote` moves proposed laws into the accepted file and is the person's step, like `tslaws accept`; never run either.
10
10
  - `proved` laws need a proof the prover can find for every input. Keep proved code to `int`/`bigint`/`boolean`/`string`, records and `const`/`if`/`return`/calls; arrays and plain loops only reach `bounded`. To prove a scalar loop for every input, write `invariant(...)` first in its body (it is code, so it is yours to write). Use the `int` type from `tslaws` for whole numbers.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tslaws",
3
- "version": "0.6.4",
3
+ "version": "0.8.0",
4
4
  "description": "Runs and checks `law` declarations compiled by tsc-laws: property tests, SMT proofs, tamper lock.",
5
5
  "bin": {
6
6
  "tslaws": "bin/tslaws.js"
@@ -42,16 +42,18 @@
42
42
  "types": "./dist/adapters/element.d.ts",
43
43
  "default": "./dist/adapters/element.js"
44
44
  },
45
+ "./internal/*": "./dist/*.js",
45
46
  "./package.json": "./package.json"
46
47
  },
47
48
  "scripts": {
48
49
  "build": "tsc -p tsconfig.json",
49
50
  "test": "node --test --test-concurrency=1 test/*.test.ts",
50
51
  "check": "node bin/tslaws.js check",
52
+ "laws": "node bin/tslaws.js check laws/core.laws.ts",
51
53
  "check:watch": "node bin/tslaws.js check --watch"
52
54
  },
53
55
  "dependencies": {
54
- "esbuild": "^0.27.7",
56
+ "esbuild": "^0.28.1",
55
57
  "fast-check": "^4.0.0",
56
58
  "playwright-core": "^1.64.1",
57
59
  "typescript": "5.9",
@@ -71,11 +73,11 @@
71
73
  }
72
74
  },
73
75
  "optionalDependencies": {
74
- "tslaws-compiler-darwin-arm64": "0.6.4",
75
- "tslaws-compiler-darwin-x64": "0.6.4",
76
- "tslaws-compiler-linux-arm64-gnu": "0.6.4",
77
- "tslaws-compiler-linux-x64-gnu": "0.6.4",
78
- "tslaws-compiler-win32-x64-msvc": "0.6.4"
76
+ "tslaws-compiler-darwin-arm64": "0.8.0",
77
+ "tslaws-compiler-darwin-x64": "0.8.0",
78
+ "tslaws-compiler-linux-arm64-gnu": "0.8.0",
79
+ "tslaws-compiler-linux-x64-gnu": "0.8.0",
80
+ "tslaws-compiler-win32-x64-msvc": "0.8.0"
79
81
  },
80
82
  "publishConfig": {
81
83
  "access": "public"