@skillstech/thunderlang 1.8.0 → 2.0.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/CHANGELOG.md +78 -1
- package/README.md +5 -0
- package/dist/core.cjs +73 -25
- package/dist/index.cjs +1230 -519
- package/dist/learn.cjs +89 -32
- package/package.json +17 -15
- package/src/cli-main.mjs +186 -151
- package/src/core/ThunderRuntime.cs +22 -1
- package/src/core/check.mjs +8 -0
- package/src/core/engine-core.mjs +7 -0
- package/src/core/engine-values.mjs +2 -0
- package/src/core/from-python.mjs +1 -1
- package/src/core/go-run.mjs +3 -1
- package/src/core/index.mjs +7 -2
- package/src/core/java/thunder/ThunderRuntime.java +1 -0
- package/src/core/kind.mjs +3 -0
- package/src/core/parser.mjs +22 -21
- package/src/core/project.mjs +21 -0
- package/src/core/runtime-go/thunder_runtime.go +41 -1
- package/src/core/rust/thunder_runtime.rs +1 -0
- package/src/core/target-csharp.mjs +14 -0
- package/src/core/target-go.mjs +14 -0
- package/src/core/target-java.mjs +14 -0
- package/src/core/target-python.mjs +8 -0
- package/src/core/target-rust.mjs +14 -0
- package/src/core/target-typescript.mjs +14 -0
- package/src/core-changes-fs.mjs +1 -1
- package/src/emit.mjs +3 -3
- package/src/evidence-words.d.mts +6 -0
- package/src/evidence-words.mjs +47 -0
- package/src/evidence.mjs +8 -1
- package/src/index.d.ts +15 -0
- package/src/index.mjs +4 -1
- package/src/learn-lessons.mjs +1 -1
- package/src/lsp.mjs +110 -0
- package/src/mcp.mjs +5 -9
- package/src/obligations.d.mts +5 -0
- package/src/obligations.mjs +30 -2
- package/src/program.d.mts +3 -0
- package/src/program.mjs +3 -0
- package/src/review.mjs +6 -3
- package/src/same.mjs +16 -6
- package/src/scan-queries.mjs +2 -1
- package/src/symbols.d.mts +23 -0
- package/src/symbols.mjs +351 -0
- package/src/template.d.mts +31 -0
- package/src/template.mjs +189 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,80 @@
|
|
|
1
|
+
# 2.0.0
|
|
2
|
+
|
|
3
|
+
**Thunder 2.0: a stable language.** Thunder language 2 is specified and frozen for every 2.x release
|
|
4
|
+
([docs/spec-2.md](../docs/spec-2.md)): its grammar, its meaning on every target ([docs/meaning.md](../docs/meaning.md),
|
|
5
|
+
each rule tied to the tests that run it on Python, the Thunder engine, TypeScript, C#, Rust, Go, and Java), its
|
|
6
|
+
diagnostic codes, and a compatibility promise: a valid 2.0 program stays valid, and means the same, in every 2.x
|
|
7
|
+
release. Programs written for 1.x are read as language 2 with no changes, apart from the Never-rule fix below, which
|
|
8
|
+
makes a broken rule on a list stop the change as the rule always said.
|
|
9
|
+
|
|
10
|
+
**Upgrading from 1.8:** nothing to rewrite. New projects get `language = "2"` in `thunder.toml`. If a program added to
|
|
11
|
+
a list that a `Never allow` rule watches and relied on the rule being skipped, it now stops with TC504 at that line.
|
|
12
|
+
|
|
13
|
+
Also in 2.0: templates from data definitions (`thunder template`), go to definition, find references, and rename in
|
|
14
|
+
VS Code and every LSP editor, Core diagnostics in the editor, and one set of evidence words (Proven, Tested, Partially
|
|
15
|
+
checked, Unverified, Violated) everywhere Thunder says how strongly something is checked. Everyday commands stay
|
|
16
|
+
under the 2.0 speed targets (`thunder check`, `run`, and `test` 40 ms of CPU on Node 22).
|
|
17
|
+
|
|
18
|
+
- **Test runs no longer leave temporary folders behind** (the Go build check, and the passport, write, read, and MCP
|
|
19
|
+
tests).
|
|
20
|
+
|
|
21
|
+
- **The Thunder 2.0 language specification** (roadmap 4.1). `docs/spec-2.md`: the grammar of Thunder Core, its
|
|
22
|
+
meaning (docs/meaning.md), the diagnostic codes (frozen: never removed, renamed, or reused in 2.x), and the
|
|
23
|
+
compatibility promise (a valid 2.0 program stays valid and means the same in every 2.x release; a breaking change
|
|
24
|
+
waits for language 3, with warnings first and `thunder upgrade`). `test/spec-2.test.mjs` compiles every example in
|
|
25
|
+
it and checks its code table against the compiler's.
|
|
26
|
+
- **Language version.** `thunder.toml` names it (`[project] language = "2"`; `thunder new` writes it). A project
|
|
27
|
+
without it is read as language 2; one that names a newer major version is refused with what to install, never read
|
|
28
|
+
as something else. `thunder --version` prints `language 2`.
|
|
29
|
+
|
|
30
|
+
- **Thunder's meaning, written down** (roadmap 3.1). `docs/meaning.md` gives every rule for decimals, division,
|
|
31
|
+
rounding, text, nothing, changing values, errors, large numbers, and effects, each tied to the cross-target tests
|
|
32
|
+
that check it, and lists what no cross-target test covers yet. New `core-meaning.test.mjs` closes the gaps found:
|
|
33
|
+
shared lists and records, whole numbers past 64 bits, 28-digit decimals, text length and order by code point,
|
|
34
|
+
Unicode case, nothing in a comparison, and If this fails.
|
|
35
|
+
- **Fix: a Never rule now watches Add and Remove on a list, on every target.** Adding to a record's list field never
|
|
36
|
+
checked the record's rules, and adding to a watched list name was refused but kept the item. Now a watched list is
|
|
37
|
+
changed on a copy, checked, then kept: a refused change leaves the list as it was, like any other value.
|
|
38
|
+
- **Fix: lowercase on Go and C#.** A word-final `Σ` became `σ` instead of `ς` (Go and C#), and `İ` stayed `İ` (C#);
|
|
39
|
+
both now match Python, the Thunder engine, TypeScript, Rust, and Java.
|
|
40
|
+
- **docs/core.md:** rounding is half away from zero (`round -2.5` is `-3`); it was described as "half up".
|
|
41
|
+
|
|
42
|
+
- **Evidence words** (roadmap 4.5). Everywhere Thunder says how strongly something is checked, it now uses one of
|
|
43
|
+
five words with one meaning (docs/evidence-words.md): **Proven** (every possible input; today only structural facts,
|
|
44
|
+
like `thunder write`'s tree comparison), **Tested** (passed on the cases that ran, only those), **Partially
|
|
45
|
+
checked**, **Unverified**, **Violated**. `thunder prove` and `thunder test --contracts` print the words with the test
|
|
46
|
+
behind each claim; `thunder same` says Tested (with the count) or Partially checked; `thunder review` no longer calls
|
|
47
|
+
a rule whose code changed "only the form changed" when its answers matched on sampled edge cases (it says Tested);
|
|
48
|
+
`thunder write` labels each check. `thunder coverage` and `thunder report` say a claim *names* a check, not that it
|
|
49
|
+
is verified. Machine fields are unchanged; obligations, evidence records, `thunder same --json`, and evidence events
|
|
50
|
+
add `evidenceLevel`/`evidenceWord` (or `evidence`). Library: `EVIDENCE_WORDS`, `evidenceWord`, `combineEvidence`,
|
|
51
|
+
and one `foldObligations` / `claimStatus` used by the CLI, MCP, and the website (four copies of the status table
|
|
52
|
+
are gone).
|
|
53
|
+
- **Fixes found on the way:** a mission with any `verify` block marked every guarantee "planned" in a fresh evidence
|
|
54
|
+
record, even ones naming no check (now `needs_verification`); `thunder same` said "same answer on all N edge cases"
|
|
55
|
+
when it stopped at its 4,096-case limit (now "the first N of M"); MCP tool descriptions and site pages no longer say
|
|
56
|
+
"proves" for pattern checks and declared test cases.
|
|
57
|
+
|
|
58
|
+
- **Go to definition, find references, and rename in VS Code and any LSP editor** (roadmap 2.4). In Thunder Core
|
|
59
|
+
programs: functions, data types, alternatives, kept and stored values, top-level values, and a function's inputs
|
|
60
|
+
and values (scoped to that function), across a project's `src/` and `tests/`, using unsaved editor text. In
|
|
61
|
+
missions: decisions, rules, the fields under `input`/`output`/`data`, and other named blocks. A rename keeps each
|
|
62
|
+
use's capital letter and plural, and is refused with the reason when the name is invalid, already used, would
|
|
63
|
+
give a file a new problem (Core files are compiled again to check), or is an endpoint input callers send. Fields
|
|
64
|
+
are not covered yet. Library: `symbolAt`, `definitionsAt`, `referencesAt`, `renameAt`, `applyRename` from
|
|
65
|
+
`@skillstech/thunderlang/program`.
|
|
66
|
+
- **Thunder Core programs get Core diagnostics in the editor.** The language server used to run the mission checks
|
|
67
|
+
on every file, so a Core program showed false problems ("Unrecognized top-level block"); it now shows the Core
|
|
68
|
+
compiler's own problems at their lines, with the hint.
|
|
69
|
+
|
|
70
|
+
- **Templates from data** (roadmap D.4, the Design Recipe's template step). `thunder template <file> <data type>`
|
|
71
|
+
writes the shape of a function from a data definition: the input and a hole for an atomic kind, one `Set` line per
|
|
72
|
+
field for a record, `Depending on` with a case per alternative for an either/or type, and a call to the function
|
|
73
|
+
itself for each recursive part (`For each child in children:` for a list of the same type), with holes for the
|
|
74
|
+
answers. Checked before it is shown: added to the file it is a draft with only holes. `--name`, `--gives <kind>`,
|
|
75
|
+
`--write` (writes nothing if the template would cause a problem), `--json`. Deterministic. Library:
|
|
76
|
+
`templateOf(source, type, { name, gives })` from `@skillstech/thunderlang/program` (`thunder-template-v1`).
|
|
77
|
+
|
|
1
78
|
# 1.8.0
|
|
2
79
|
|
|
3
80
|
- **Behaviour changes across services** (roadmap 3.4 + D.5, part 2). Thunder Trace reads Thunder Core programs:
|
|
@@ -1685,7 +1762,7 @@ The executable + interoperable release. Everything is deterministic and requires
|
|
|
1685
1762
|
returns the canonical graph + flat PM fields; `proposeIntent(structured, { base })` regenerates
|
|
1686
1763
|
ThunderLang source with a reviewable diff, surfaced ambiguities (non-factual nodes), round-trip
|
|
1687
1764
|
fidelity gaps, and validation , never a silent rewrite. Browser-safe via `/core` (for Studio).
|
|
1688
|
-
- **Comment-preserving structural editing (`intent-patch-v1`).** `
|
|
1765
|
+
- **Comment-preserving structural editing (`intent-patch-v1`).** `applyRename(source, edits)`
|
|
1689
1766
|
applies field-level edits (`setField`, `add/removeGuarantee`, `add/removeNever`,
|
|
1690
1767
|
`add/removeField`, `setFieldType` on inputs/outputs, `add/removeMetric`, `setMetricField`,
|
|
1691
1768
|
`add/removeOutcome`, and decision rules `add/removeRule`/`setRule`/`setDefault`) directly to
|
package/README.md
CHANGED
|
@@ -8,6 +8,11 @@ result, so intent can be diffed, merged, tested, and trusted.
|
|
|
8
8
|
|
|
9
9
|
Part of [ThunderLang](https://thunderlang.dev), the intent language for AI-era software.
|
|
10
10
|
|
|
11
|
+
**Thunder 2.0 is a stable language.** Thunder language 2 is [specified](https://thunderlang.dev/docs/spec-2) and frozen
|
|
12
|
+
for every 2.x release: the grammar, [what every program means on every target](https://thunderlang.dev/docs/meaning)
|
|
13
|
+
(each rule tied to the tests that run it on Python, the Thunder engine, TypeScript, C#, Rust, Go, and Java), the
|
|
14
|
+
diagnostic codes, and a compatibility promise. `thunder --version` prints the language it speaks.
|
|
15
|
+
|
|
11
16
|
**Learn ThunderLang:** the [10-minute tutorial](https://thunderlang.dev/learn), then the
|
|
12
17
|
[full course on Skills Tech Talk](https://app.skillstechtalk.com/learn/technology/t/thunderlang).
|
|
13
18
|
The tutorial also ships in this package as data (`@skillstech/thunderlang/learn`): 12 lessons on reading code, and
|
package/dist/core.cjs
CHANGED
|
@@ -19410,7 +19410,7 @@ function notesSummary(ast) {
|
|
|
19410
19410
|
byLens
|
|
19411
19411
|
};
|
|
19412
19412
|
}
|
|
19413
|
-
var COMPILER_VERSION = "
|
|
19413
|
+
var COMPILER_VERSION = "2.0.0";
|
|
19414
19414
|
var PROOF_SCHEMA_VERSION = "0.1.0";
|
|
19415
19415
|
var SOURCE_PRODUCT = "skillstech-compiler";
|
|
19416
19416
|
function buildContractGraph(ast, generatedAt) {
|
|
@@ -19884,7 +19884,6 @@ function semanticDiagnostics(ast) {
|
|
|
19884
19884
|
}
|
|
19885
19885
|
function buildProof(ast, { sourceFile, sourceHash, targetsRequested, targetsGenerated, diagnostics, generatedAt, origin = "authored" }) {
|
|
19886
19886
|
const passedSemantic = !diagnostics.some((x) => x.level === "error");
|
|
19887
|
-
const verifiedText = ast.verify.join(" ").toLowerCase();
|
|
19888
19887
|
return {
|
|
19889
19888
|
schemaVersion: PROOF_SCHEMA_VERSION,
|
|
19890
19889
|
sourceProduct: SOURCE_PRODUCT,
|
|
@@ -19902,7 +19901,8 @@ function buildProof(ast, { sourceFile, sourceHash, targetsRequested, targetsGene
|
|
|
19902
19901
|
guarantees: ast.guarantees.map((g) => ({
|
|
19903
19902
|
id: g.id,
|
|
19904
19903
|
text: g.statement,
|
|
19905
|
-
|
|
19904
|
+
// planned only when this guarantee names its own check; a verify block elsewhere in the mission doesn't count.
|
|
19905
|
+
status: g.verify.length > 0 ? "planned" : "needs_verification",
|
|
19906
19906
|
evidence: g.verify,
|
|
19907
19907
|
verifications: g.verifications || []
|
|
19908
19908
|
})),
|
|
@@ -30651,7 +30651,7 @@ var ExprParser = class {
|
|
|
30651
30651
|
const ak = this.longest(run, (key) => this.names.alts.has(key));
|
|
30652
30652
|
if (ak && !this.longest(run, (key) => this.names.known.has(key))) {
|
|
30653
30653
|
s.i += ak;
|
|
30654
|
-
return wrap({ k: "isAlt", e: l, alt: keyOf(run.slice(0, ak)), text: run.slice(0, ak).map((x) => x.text).join(" "), line });
|
|
30654
|
+
return wrap({ k: "isAlt", e: l, alt: keyOf(run.slice(0, ak)), text: run.slice(0, ak).map((x) => x.text).join(" "), col: run[0].col, line });
|
|
30655
30655
|
}
|
|
30656
30656
|
}
|
|
30657
30657
|
return { k: "cmp", op: neg ? "!=" : "==", l, r: this.add(s, o), line };
|
|
@@ -30704,7 +30704,7 @@ var ExprParser = class {
|
|
|
30704
30704
|
if (!run.length) s.fail(`I expected a field name after "'s".`, null, "TC108");
|
|
30705
30705
|
const k = this.longest(run, (key) => this.names.fields.has(key)) || run.length;
|
|
30706
30706
|
s.i -= run.length - k;
|
|
30707
|
-
e = { k: "field", obj: e, name: keyOf(run.slice(0, k)), text: run.slice(0, k).map((w) => w.text).join(" "), line: s.line };
|
|
30707
|
+
e = { k: "field", obj: e, name: keyOf(run.slice(0, k)), text: run.slice(0, k).map((w) => w.text).join(" "), col: run[0].col, line: s.line };
|
|
30708
30708
|
} else if (isWord(t, "at") && !isWord(s.peek(1), "least") && !isWord(s.peek(1), "most")) {
|
|
30709
30709
|
s.next();
|
|
30710
30710
|
const key = this.unary(s, { ...o, noAnd: true });
|
|
@@ -30806,7 +30806,7 @@ var ExprParser = class {
|
|
|
30806
30806
|
if (!k) s.fail(`I don't know the kind of value "${run.map((x) => x.text).join(" ")}".`, 'Kinds: number, whole number, text, yes/no, money, date, list of \u2026, map of \u2026 to \u2026, optional \u2026, or a record you defined with "A \u2026 has:".', "TC306");
|
|
30807
30807
|
s.i -= run.length - k;
|
|
30808
30808
|
const key = keyOf(run.slice(0, k));
|
|
30809
|
-
return { k: "record", name: this.names.records.has(key) ? key : key.replace(/s$/, "") };
|
|
30809
|
+
return { k: "record", name: this.names.records.has(key) ? key : key.replace(/s$/, ""), col: run[0].col, line: s.line };
|
|
30810
30810
|
}
|
|
30811
30811
|
/** The fields a record is built with: with name "Ann" and balance $10 (none without "with"). */
|
|
30812
30812
|
recordFields(s, line) {
|
|
@@ -30971,14 +30971,14 @@ var ExprParser = class {
|
|
|
30971
30971
|
const rk = this.longest(run.slice(i), (key) => recs.includes(key));
|
|
30972
30972
|
if (!rk || i + rk !== run.length) continue;
|
|
30973
30973
|
s.i -= run.length - i - rk;
|
|
30974
|
-
const node2 = { k: "new", record: keyOf(run.slice(i, i + rk)), alt, altText: run.slice(0, i).map((x) => x.text).join(" "), fields: this.recordFields(s, line), line };
|
|
30974
|
+
const node2 = { k: "new", record: keyOf(run.slice(i, i + rk)), alt, altText: run.slice(0, i).map((x) => x.text).join(" "), altCol: run[0].col, recordCol: run[i].col, fields: this.recordFields(s, line), line };
|
|
30975
30975
|
return node2;
|
|
30976
30976
|
}
|
|
30977
30977
|
for (let i = 1; i < run.length; i++) {
|
|
30978
30978
|
const rk = this.longest(run.slice(i), (key) => this.names.altsOf.has(key));
|
|
30979
30979
|
if (!rk || i + rk !== run.length) continue;
|
|
30980
30980
|
s.i -= run.length - i - rk;
|
|
30981
|
-
return { k: "new", record: keyOf(run.slice(i, i + rk)), alt: keyOf(run.slice(0, i)), altText: run.slice(0, i).map((x) => x.text).join(" "), fields: this.recordFields(s, line), line };
|
|
30981
|
+
return { k: "new", record: keyOf(run.slice(i, i + rk)), alt: keyOf(run.slice(0, i)), altText: run.slice(0, i).map((x) => x.text).join(" "), altCol: run[0].col, recordCol: run[i].col, fields: this.recordFields(s, line), line };
|
|
30982
30982
|
}
|
|
30983
30983
|
}
|
|
30984
30984
|
let off = run[0]?.lower === "new" && run.length > 1 ? 1 : 0;
|
|
@@ -30988,7 +30988,7 @@ var ExprParser = class {
|
|
|
30988
30988
|
s.i -= run.length - off - recK;
|
|
30989
30989
|
const name = keyOf(run.slice(off, off + recK));
|
|
30990
30990
|
const fields = this.recordFields(s, line);
|
|
30991
|
-
const node2 = { k: "new", record: name, fields, line };
|
|
30991
|
+
const node2 = { k: "new", record: name, recordCol: run[off].col, fields, line };
|
|
30992
30992
|
if (!fields.length && this.open) this.open.push(node2);
|
|
30993
30993
|
return node2;
|
|
30994
30994
|
}
|
|
@@ -31003,20 +31003,21 @@ var ExprParser = class {
|
|
|
31003
31003
|
const key = keyOf(run.slice(0, k));
|
|
31004
31004
|
const text2 = run.slice(0, k).map((x) => x.text).join(" ");
|
|
31005
31005
|
if (this.names.known.get(key) === "func") {
|
|
31006
|
-
|
|
31007
|
-
if (s.
|
|
31008
|
-
|
|
31006
|
+
const col = run[0].col;
|
|
31007
|
+
if (isSym(s.peek(), "(")) return { k: "call", name: key, text: text2, col, args: this.parenArgs(s), line };
|
|
31008
|
+
if (s.word("with")) return { k: "call", name: key, text: text2, col, args: this.withArgs(s), line };
|
|
31009
|
+
const node2 = { k: "call", name: key, text: text2, col, args: [], line, bare: true };
|
|
31009
31010
|
if (this.open) this.open.push(node2);
|
|
31010
31011
|
return node2;
|
|
31011
31012
|
}
|
|
31012
|
-
return { k: "name", name: key, text: text2, line };
|
|
31013
|
+
return { k: "name", name: key, text: text2, col: run[0].col, line };
|
|
31013
31014
|
}
|
|
31014
31015
|
const fk = this.longest(run, (key) => this.names.fields.has(key));
|
|
31015
31016
|
if (fk) {
|
|
31016
31017
|
s.i -= run.length - fk;
|
|
31017
|
-
return { k: "name", name: keyOf(run.slice(0, fk)), text: run.slice(0, fk).map((x) => x.text).join(" "), line, unknown: true };
|
|
31018
|
+
return { k: "name", name: keyOf(run.slice(0, fk)), text: run.slice(0, fk).map((x) => x.text).join(" "), col: run[0].col, line, unknown: true };
|
|
31018
31019
|
}
|
|
31019
|
-
return { k: "name", name: keyOf(run), text: run.map((x) => x.text).join(" "), line, unknown: true };
|
|
31020
|
+
return { k: "name", name: keyOf(run), text: run.map((x) => x.text).join(" "), col: run[0]?.col, line, unknown: true };
|
|
31020
31021
|
}
|
|
31021
31022
|
};
|
|
31022
31023
|
|
|
@@ -31419,6 +31420,28 @@ function readingOf(f, language = readableLanguage(f.path, f.source)) {
|
|
|
31419
31420
|
return f.reading ?? readCode(f.source, { language, file: f.path });
|
|
31420
31421
|
}
|
|
31421
31422
|
|
|
31423
|
+
// src/evidence-words.mjs
|
|
31424
|
+
var EVIDENCE_LEVELS = ["proven", "tested", "partial", "unverified", "violated"];
|
|
31425
|
+
var EVIDENCE_WORDS = {
|
|
31426
|
+
proven: { word: "Proven", means: "holds for every possible input: checked exhaustively, or proved by a solver" },
|
|
31427
|
+
tested: { word: "Tested", means: "passed on the cases that ran, and only on those" },
|
|
31428
|
+
partial: { word: "Partially checked", means: "some parts are checked and passed; others are not checked yet" },
|
|
31429
|
+
unverified: { word: "Unverified", means: "nothing checks it yet" },
|
|
31430
|
+
violated: { word: "Violated", means: "a check failed: there is a case where it does not hold" }
|
|
31431
|
+
};
|
|
31432
|
+
function evidenceWord(level) {
|
|
31433
|
+
return EVIDENCE_WORDS[level]?.word ?? null;
|
|
31434
|
+
}
|
|
31435
|
+
function combineEvidence(levels) {
|
|
31436
|
+
const ls = [...levels].filter((l) => EVIDENCE_LEVELS.includes(l));
|
|
31437
|
+
if (!ls.length) return "unverified";
|
|
31438
|
+
if (ls.includes("violated")) return "violated";
|
|
31439
|
+
if (ls.every((l) => l === "proven")) return "proven";
|
|
31440
|
+
if (ls.every((l) => l === "proven" || l === "tested")) return "tested";
|
|
31441
|
+
if (ls.every((l) => l === "unverified")) return "unverified";
|
|
31442
|
+
return "partial";
|
|
31443
|
+
}
|
|
31444
|
+
|
|
31422
31445
|
// src/plain-contract.mjs
|
|
31423
31446
|
var PLAIN_SCHEMA = "thunder-plain-v1";
|
|
31424
31447
|
var COMPARISONS = [
|
|
@@ -32157,7 +32180,9 @@ function comparePlainRules(a, b) {
|
|
|
32157
32180
|
}
|
|
32158
32181
|
const bAsA = { ...b, inputs: b.inputs.map((i) => ({ ...i, id: toA.get(key(i)) })), rules: b.rules.map((r) => ({ ...r, conditions: r.conditions.map((c) => ({ ...c, input: toA.get(key(b.inputs.find((i) => i.id === c.input))) })) })) };
|
|
32159
32182
|
let tried = 0;
|
|
32160
|
-
|
|
32183
|
+
const axes = caseValues([a, bAsA]);
|
|
32184
|
+
const total = axes.reduce((n, [, vs]) => n * Math.max(1, vs.length), 1);
|
|
32185
|
+
for (const values of product(axes)) {
|
|
32161
32186
|
if (++tried > MAX_CASES) {
|
|
32162
32187
|
tried--;
|
|
32163
32188
|
break;
|
|
@@ -32165,7 +32190,7 @@ function comparePlainRules(a, b) {
|
|
|
32165
32190
|
const x = explainPlain(a, values).outcome, y = explainPlain(bAsA, values).outcome;
|
|
32166
32191
|
if (x !== y) return { same: false, tried, counterexample: { values: { ...values }, facts: a.inputs.map((i) => `${i.label} ${i.kind === "yesno" ? values[i.id] ? i.yes ?? "yes" : i.no ?? "no" : values[i.id]}`).join(", "), old: x, new: y } };
|
|
32167
32192
|
}
|
|
32168
|
-
return { same: true, tried };
|
|
32193
|
+
return { same: true, tried, total, ...total > tried ? { capped: true } : {} };
|
|
32169
32194
|
}
|
|
32170
32195
|
var SYNTAX = new Set("const let var val final auto def fn func function return await async new public private protected static self this my local export mut ref out in of for foreach if elif elsif while do then end each as range".split(" "));
|
|
32171
32196
|
var OPS5 = { "&&": "and", "||": "or", "!": "not", "===": "==", "!==": "!=", "<>": "!=", "**": "^", and: "and", or: "or", not: "not", is: "==", None: "null", nil: "null", undefined: "null", NULL: "null", nullptr: "null", True: "true", False: "false" };
|
|
@@ -32188,7 +32213,7 @@ function compareItems(o, n) {
|
|
|
32188
32213
|
if (o.kind === "decision") {
|
|
32189
32214
|
const r = compareRules(o, n);
|
|
32190
32215
|
if (!r) return { status: "cannot-check", reason: "One rule could not be drawn as a card, so its answers could not be compared.", ...where2 };
|
|
32191
|
-
if (r.same) return { status: "same", reason: `Same answer on all ${r.tried} edge cases.`, ...where2 };
|
|
32216
|
+
if (r.same) return { status: "same", reason: r.capped ? `Same answer on the first ${r.tried} of ${r.total} edge cases (the rest were not tried).` : `Same answer on all ${r.tried} edge cases.`, ...where2 };
|
|
32192
32217
|
if (r.counterexample) {
|
|
32193
32218
|
const facts = r.counterexample.facts;
|
|
32194
32219
|
return { status: "different", reason: `Different answer for ${facts}: ${r.counterexample.old} before, ${r.counterexample.new} after.`, counterexample: r.counterexample, ...where2 };
|
|
@@ -32221,13 +32246,18 @@ function sameMeaning(oldFiles, newFiles) {
|
|
|
32221
32246
|
}
|
|
32222
32247
|
for (const [key, n] of B.items) if (!used.has(key)) items.push({ name: n.name, status: "only-new", reason: "New: not in the old code.", new: { file: n.file, line: n.line, language: n.language } });
|
|
32223
32248
|
const counts = { same: 0, different: 0, "only-old": 0, "only-new": 0, "cannot-check": 0 };
|
|
32224
|
-
for (const it of items)
|
|
32249
|
+
for (const it of items) {
|
|
32250
|
+
counts[it.status]++;
|
|
32251
|
+
it.evidence = it.status === "same" ? /edge cases/.test(it.reason) ? "tested" : "partial" : it.status === "cannot-check" ? "unverified" : "violated";
|
|
32252
|
+
}
|
|
32225
32253
|
const verdict = counts.different || counts["only-old"] || counts["only-new"] ? "different" : counts["cannot-check"] ? "partly-checked" : "same";
|
|
32226
|
-
|
|
32254
|
+
const evidence2 = combineEvidence(items.map((it) => it.evidence));
|
|
32255
|
+
return { schema: SAME_SCHEMA, verdict, evidence: evidence2, counts, items, unreadable: [...A.unreadable, ...B.unreadable] };
|
|
32227
32256
|
}
|
|
32228
32257
|
function renderSame(r) {
|
|
32229
32258
|
const head = r.verdict === "same" ? "Same meaning." : r.verdict === "partly-checked" ? "No differences found, but some parts could not be checked." : "Different meaning.";
|
|
32230
|
-
const
|
|
32259
|
+
const how = r.evidence ? ` ${evidenceWord(r.evidence)}${r.evidence === "tested" ? " (answers compared on edge cases, not every input)" : r.evidence === "partial" ? " (some parts compared by running, others only by reading)" : ""}.` : "";
|
|
32260
|
+
const lines = [`${head}${how} ${r.counts.same} same, ${r.counts.different} different, ${r.counts["only-old"]} only in the old code, ${r.counts["only-new"]} only in the new code, ${r.counts["cannot-check"]} not checked.`];
|
|
32231
32261
|
const order = ["different", "only-old", "only-new", "cannot-check", "same"];
|
|
32232
32262
|
const label = { different: "different", "only-old": "only old", "only-new": "only new", "cannot-check": "not checked", same: "same" };
|
|
32233
32263
|
for (const st of order) for (const it of r.items.filter((x) => x.status === st)) {
|
|
@@ -43077,7 +43107,13 @@ function compareMember(o, n, items, { extracted = false } = {}) {
|
|
|
43077
43107
|
if (o.m.rule && n.m.rule && !o.m.rule.partial && !n.m.rule.partial) {
|
|
43078
43108
|
const r = comparePlainRules(o.m.rule, n.m.rule);
|
|
43079
43109
|
if (r.same) {
|
|
43080
|
-
|
|
43110
|
+
items.push(item2(
|
|
43111
|
+
renamedOrMoved.length ? moveKind : "form",
|
|
43112
|
+
"form",
|
|
43113
|
+
subject,
|
|
43114
|
+
whereOf2(n),
|
|
43115
|
+
`${renamedOrMoved.length ? `${cap5(renamedOrMoved.join(" and "))}. ` : ""}The code changed, but the answers are the same: Tested on ${r.capped ? `the first ${r.tried} of ${r.total}` : `all ${r.tried}`} edge cases, run on both versions (not every input).`
|
|
43116
|
+
));
|
|
43081
43117
|
return "form";
|
|
43082
43118
|
}
|
|
43083
43119
|
noteMove();
|
|
@@ -43405,7 +43441,7 @@ function evidenceBlock(ev) {
|
|
|
43405
43441
|
}
|
|
43406
43442
|
function renderReview(r, { title = "Thunder review", maxChars = 6e4, footer = "" } = {}) {
|
|
43407
43443
|
const out = [REVIEW_MARKER, `### ${title}`, "", `**${r.says}**`, ""];
|
|
43408
|
-
out.push('Read from the code by the Thunder compiler, with no AI. "Only the form changed" is said only when it is shown: the code is identical apart from spacing, comments, or names it declares itself
|
|
43444
|
+
out.push('Read from the code by the Thunder compiler, with no AI. "Only the form changed" is said only when it is shown: the code is identical apart from spacing, comments, or names it declares itself. A rule whose code changed but whose answers match on every edge case tried is listed here too, marked Tested: other inputs were not tried.', "");
|
|
43409
43445
|
const alsoIn = (x) => x.also?.length ? [` <details><summary>Also in ${x.also.length} more</summary>`, "", ...x.also.slice(0, 50).map((a) => ` - **${a.subject}** \xB7 \`${a.where.file}:${a.where.line}\``), ...x.also.length > 50 ? [` - and ${x.also.length - 50} more`] : [], "", " </details>"] : [];
|
|
43410
43446
|
const line = (x) => [`- **${x.subject}** \xB7 \`${x.where.file}:${x.where.line}\`: ${x.says}`, ...evidenceBlock(x.evidence).map((l) => l ? ` ${l}` : ""), ...alsoIn(x)];
|
|
43411
43447
|
const section = (sev, head) => {
|
|
@@ -43421,7 +43457,7 @@ function renderReview(r, { title = "Thunder review", maxChars = 6e4, footer = ""
|
|
|
43421
43457
|
};
|
|
43422
43458
|
section("risk", "Needs a careful look");
|
|
43423
43459
|
section("meaning", "Changes in meaning");
|
|
43424
|
-
section("form", "Only the form changed");
|
|
43460
|
+
section("form", "Only the form changed, or the same answers where tested");
|
|
43425
43461
|
if (r.notRead.length) out.push(`Also changed, not read by Thunder: ${r.notRead.slice(0, 20).map((f) => `\`${f.path}\``).join(", ")}${r.notRead.length > 20 ? `, and ${r.notRead.length - 20} more` : ""}.`, "");
|
|
43426
43462
|
if (footer) out.push(footer, "");
|
|
43427
43463
|
let text2 = out.join("\n");
|
|
@@ -46206,11 +46242,14 @@ function resolveObligations(ast) {
|
|
|
46206
46242
|
const evidence2 = names.map((name) => byTarget.get(name) || (name.startsWith("test ") ? byTarget.get(name.slice(5).trim()) : null) || { name, pass: null, cases: 0 });
|
|
46207
46243
|
const unresolved = evidence2.filter((e) => e.pass === null).map((e) => e.name);
|
|
46208
46244
|
const status = !names.length ? "unverified" : evidence2.some((e) => e.pass === false) ? "failed" : unresolved.length ? "declared" : "verified";
|
|
46245
|
+
const evidenceLevel = combineEvidence(evidence2.map((e) => e.pass === true ? "tested" : e.pass === false ? "violated" : "unverified"));
|
|
46209
46246
|
return {
|
|
46210
46247
|
kind,
|
|
46211
46248
|
id: claim.id,
|
|
46212
46249
|
text: claim.statement,
|
|
46213
46250
|
status,
|
|
46251
|
+
evidenceLevel,
|
|
46252
|
+
evidenceWord: evidenceWord(evidenceLevel),
|
|
46214
46253
|
verify,
|
|
46215
46254
|
kinds: [...new Set((claim.verifications || []).map((v) => v.kind).filter((k) => k && k !== "unclassified"))],
|
|
46216
46255
|
provenBy: status === "verified" || status === "failed" ? evidence2.filter((e) => e.pass !== null).map((e) => e.name).join(", ") : null,
|
|
@@ -46223,7 +46262,16 @@ function resolveObligations(ast) {
|
|
|
46223
46262
|
...(ast.neverRules || []).map((n) => build("prohibition", n))
|
|
46224
46263
|
];
|
|
46225
46264
|
const count2 = (s) => obligations.filter((o) => o.status === s).length;
|
|
46226
|
-
|
|
46265
|
+
const byLevel = (l) => obligations.filter((o) => o.evidenceLevel === l).length;
|
|
46266
|
+
return {
|
|
46267
|
+
obligations,
|
|
46268
|
+
tests,
|
|
46269
|
+
verified: count2("verified"),
|
|
46270
|
+
declared: count2("declared"),
|
|
46271
|
+
unverified: count2("unverified"),
|
|
46272
|
+
failed: count2("failed"),
|
|
46273
|
+
evidence: { tested: byLevel("tested"), partial: byLevel("partial"), unverified: byLevel("unverified"), violated: byLevel("violated") }
|
|
46274
|
+
};
|
|
46227
46275
|
}
|
|
46228
46276
|
|
|
46229
46277
|
// src/review-atlas.mjs
|