@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.
Files changed (47) hide show
  1. package/CHANGELOG.md +78 -1
  2. package/README.md +5 -0
  3. package/dist/core.cjs +73 -25
  4. package/dist/index.cjs +1230 -519
  5. package/dist/learn.cjs +89 -32
  6. package/package.json +17 -15
  7. package/src/cli-main.mjs +186 -151
  8. package/src/core/ThunderRuntime.cs +22 -1
  9. package/src/core/check.mjs +8 -0
  10. package/src/core/engine-core.mjs +7 -0
  11. package/src/core/engine-values.mjs +2 -0
  12. package/src/core/from-python.mjs +1 -1
  13. package/src/core/go-run.mjs +3 -1
  14. package/src/core/index.mjs +7 -2
  15. package/src/core/java/thunder/ThunderRuntime.java +1 -0
  16. package/src/core/kind.mjs +3 -0
  17. package/src/core/parser.mjs +22 -21
  18. package/src/core/project.mjs +21 -0
  19. package/src/core/runtime-go/thunder_runtime.go +41 -1
  20. package/src/core/rust/thunder_runtime.rs +1 -0
  21. package/src/core/target-csharp.mjs +14 -0
  22. package/src/core/target-go.mjs +14 -0
  23. package/src/core/target-java.mjs +14 -0
  24. package/src/core/target-python.mjs +8 -0
  25. package/src/core/target-rust.mjs +14 -0
  26. package/src/core/target-typescript.mjs +14 -0
  27. package/src/core-changes-fs.mjs +1 -1
  28. package/src/emit.mjs +3 -3
  29. package/src/evidence-words.d.mts +6 -0
  30. package/src/evidence-words.mjs +47 -0
  31. package/src/evidence.mjs +8 -1
  32. package/src/index.d.ts +15 -0
  33. package/src/index.mjs +4 -1
  34. package/src/learn-lessons.mjs +1 -1
  35. package/src/lsp.mjs +110 -0
  36. package/src/mcp.mjs +5 -9
  37. package/src/obligations.d.mts +5 -0
  38. package/src/obligations.mjs +30 -2
  39. package/src/program.d.mts +3 -0
  40. package/src/program.mjs +3 -0
  41. package/src/review.mjs +6 -3
  42. package/src/same.mjs +16 -6
  43. package/src/scan-queries.mjs +2 -1
  44. package/src/symbols.d.mts +23 -0
  45. package/src/symbols.mjs +351 -0
  46. package/src/template.d.mts +31 -0
  47. package/src/template.mjs +189 -0
package/src/cli-main.mjs CHANGED
@@ -16,39 +16,42 @@ import { basename, join, relative, dirname, resolve } from 'node:path';
16
16
  import { execSync, execFileSync, spawnSync } from 'node:child_process';
17
17
  // <lazy-imports> generated by scripts/lazy-cli.mjs: run it after changing imports or commands
18
18
  // Thunder's own modules, loaded by preload(cmd) only for the commands that use them (see that script for how).
19
- let parseIntent, slug, subjectName, KNOWN_LENSES, previewHumanContract, renderHumanContract, previewPlainContract,
20
- thunderRepo, renderThunderRepo, parseGitHub, cloneGitHub, thunderizeFiles, THUNDER_TEXT_EXT, sameMeaning,
21
- renderSame, anchorReport, writeRule, thunderWrite, readCode, searchReading, readRepo, searchRepo,
22
- groupByFile, promoteDecision, collectReadableFiles, accessFlow, accessText, translateDecisions,
23
- buildContractGraph, buildArchitectureGraph, buildImplementationPlan, semanticDiagnostics, buildProof,
24
- sha256, COMPILER_VERSION, toSarif, renderMarkdown, renderLensDoc, renderMermaid, renderTestplan,
25
- getCompletions, getHover, getCodeActions, autocorrectSource, startLspServer, startMcpServer, formatSource,
26
- applyEdits, buildReport, scanProject, VIEWS, guardianReport, simulateChange, verifyLedger, ledgerExplain,
27
- verifyDiff, verifyRun, executedText, mergeTraces, runtimeOverlay, runtimeText, fromTrace, fromStack,
28
- fromLogs, fromOtlp, parseStacks, explainError, countWords, thunderModel, LEVELS, readLevel, renderLevel,
29
- findFocus, nearestLevel, traceMain, passportMain, isWriteAcross, writeAcrossMain, whyMain, tryMain,
30
- replayMain, homeText, helpFor, knownCommands, unknownCommandText, noProjectText, doctorMain,
31
- completionMain, paint, paintHelp, paintThunder, useColor, coreMain, behaviourCheck, findProjectRoot,
32
- pythonToCore, guardSummary, draftIntent, liftSource, liftAll, liftRepo, languageForFile, approveIntent,
33
- checkDrift, buildDriftHandoff, buildMissionIndex, parseSelection, regionMetrics, selectCandidate,
34
- buildIntentGraph, safeGraph, buildAtlas, searchAtlas, expandNode, buildReviewAtlas, renderReviewBrief,
35
- reviewAtlasExitCode, buildFocusGraph, intentBrief, makeScope, comprehensionLevel, comprehensionReport,
36
- COMPREHENSION_LEVELS, twelveFactorReport, GENERATORS, generateWithDiagnostics, changeReport, diffGraphs,
37
- mergeGraphs, applyWaivers, governanceDiagnostics, exportIntent, EXPORT_FORMATS, evaluateDecision,
38
- simulateLifecycle, runProperties, runMutations, thunderReview, renderReview, addServiceCallers,
39
- buildTrace, traceImpact, readRepoDir, gitChanges, coreChanges, affectedBy, renderAffected,
40
- withCoreBehaviour, coreFilesIn, buildConformance, semanticCoverage, runTypescriptTarget, runPythonTarget,
41
- pythonAvailable, runCSharpTarget, csharpAvailable, runJavaTarget, javaAvailable, runGoTarget, goAvailable,
42
- runRustTarget, rustAvailable, runKotlinTarget, kotlinAvailable, runScalaTarget, scalaAvailable,
43
- runElixirTarget, elixirAvailable, errorResult, runFailure, byText, importIntent, importReport,
44
- detectFormat, IMPORT_FORMATS, runTests, resolveObligations, toEvidenceEvents, verifyDiffToEvidence,
45
- conformToEvidence, driftToEvidence, behaviourToEvidence, evaluateOutcomes, analyzeStyle,
46
- intentProofJsonSchema, validateProof, graphToSource, migrateGraph, validateGraph, SCHEMA_VERSION,
47
- NODE_TYPES, RELATIONSHIP_TYPES, DIAGNOSTIC_RULES, ALL_DIAGNOSTICS, intentGraphJsonSchema, CLASSIFICATIONS,
48
- buildManifest, buildImplementationPrompt, resolveState, productionGate, adoptRegion, parseMarkers,
49
- contractHash, implementationHash, recordDecision, approvalFor, emptyApprovals, makeEvent, parseEventLog,
50
- serializeEventLog, recordEvent, timeline;
19
+ let LANGUAGE_VERSION, foldObligations, resolveObligations, templateOf, parseIntent, slug, subjectName,
20
+ KNOWN_LENSES, previewHumanContract, renderHumanContract, previewPlainContract, thunderRepo,
21
+ renderThunderRepo, parseGitHub, cloneGitHub, thunderizeFiles, THUNDER_TEXT_EXT, sameMeaning, renderSame,
22
+ anchorReport, writeRule, thunderWrite, readCode, searchReading, readRepo, searchRepo, groupByFile,
23
+ promoteDecision, collectReadableFiles, accessFlow, accessText, translateDecisions, buildContractGraph,
24
+ buildArchitectureGraph, buildImplementationPlan, semanticDiagnostics, buildProof, sha256,
25
+ COMPILER_VERSION, toSarif, renderMarkdown, renderLensDoc, renderMermaid, renderTestplan, getCompletions,
26
+ getHover, getCodeActions, autocorrectSource, startLspServer, startMcpServer, formatSource, applyEdits,
27
+ buildReport, scanProject, VIEWS, guardianReport, simulateChange, verifyLedger, ledgerExplain, verifyDiff,
28
+ verifyRun, executedText, mergeTraces, runtimeOverlay, runtimeText, fromTrace, fromStack, fromLogs,
29
+ fromOtlp, parseStacks, explainError, countWords, thunderModel, LEVELS, readLevel, renderLevel, findFocus,
30
+ nearestLevel, traceMain, passportMain, isWriteAcross, writeAcrossMain, whyMain, tryMain, replayMain,
31
+ homeText, helpFor, knownCommands, unknownCommandText, noProjectText, doctorMain, completionMain, paint,
32
+ paintHelp, paintThunder, useColor, coreMain, behaviourCheck, findProjectRoot, pythonToCore, guardSummary,
33
+ draftIntent, liftSource, liftAll, liftRepo, languageForFile, approveIntent, checkDrift, buildDriftHandoff,
34
+ buildMissionIndex, parseSelection, regionMetrics, selectCandidate, buildIntentGraph, safeGraph,
35
+ buildAtlas, searchAtlas, expandNode, buildReviewAtlas, renderReviewBrief, reviewAtlasExitCode,
36
+ buildFocusGraph, intentBrief, makeScope, comprehensionLevel, comprehensionReport, COMPREHENSION_LEVELS,
37
+ twelveFactorReport, GENERATORS, generateWithDiagnostics, changeReport, diffGraphs, mergeGraphs,
38
+ applyWaivers, governanceDiagnostics, exportIntent, EXPORT_FORMATS, evaluateDecision, simulateLifecycle,
39
+ runProperties, runMutations, thunderReview, renderReview, addServiceCallers, buildTrace, traceImpact,
40
+ readRepoDir, gitChanges, coreChanges, affectedBy, renderAffected, withCoreBehaviour, coreFilesIn,
41
+ buildConformance, semanticCoverage, runTypescriptTarget, runPythonTarget, pythonAvailable,
42
+ runCSharpTarget, csharpAvailable, runJavaTarget, javaAvailable, runGoTarget, goAvailable, runRustTarget,
43
+ rustAvailable, runKotlinTarget, kotlinAvailable, runScalaTarget, scalaAvailable, runElixirTarget,
44
+ elixirAvailable, errorResult, runFailure, byText, importIntent, importReport, detectFormat,
45
+ IMPORT_FORMATS, runTests, toEvidenceEvents, verifyDiffToEvidence, conformToEvidence, driftToEvidence,
46
+ behaviourToEvidence, evaluateOutcomes, analyzeStyle, intentProofJsonSchema, validateProof, graphToSource,
47
+ migrateGraph, validateGraph, SCHEMA_VERSION, NODE_TYPES, RELATIONSHIP_TYPES, DIAGNOSTIC_RULES,
48
+ ALL_DIAGNOSTICS, intentGraphJsonSchema, CLASSIFICATIONS, buildManifest, buildImplementationPrompt,
49
+ resolveState, productionGate, adoptRegion, parseMarkers, contractHash, implementationHash, recordDecision,
50
+ approvalFor, emptyApprovals, makeEvent, parseEventLog, serializeEventLog, recordEvent, timeline;
51
51
  const LAZY = {
52
+ './core/kind.mjs': (m) => ({ LANGUAGE_VERSION } = m),
53
+ './obligations.mjs': (m) => ({ foldObligations, resolveObligations } = m),
54
+ './template.mjs': (m) => ({ templateOf } = m),
52
55
  './parse.mjs': (m) => ({ parseIntent, slug, subjectName, KNOWN_LENSES } = m),
53
56
  './human-contract.mjs': (m) => ({ previewHumanContract, renderHumanContract } = m),
54
57
  './plain-contract.mjs': (m) => ({ previewPlainContract } = m),
@@ -135,7 +138,6 @@ const LAZY = {
135
138
  './text-order.mjs': (m) => ({ byText } = m),
136
139
  './importers.mjs': (m) => ({ importIntent, importReport, detectFormat, IMPORT_FORMATS } = m),
137
140
  './testing.mjs': (m) => ({ runTests } = m),
138
- './obligations.mjs': (m) => ({ resolveObligations } = m),
139
141
  './evidence.mjs': (m) => ({ toEvidenceEvents, verifyDiffToEvidence, conformToEvidence, driftToEvidence, behaviourToEvidence } = m),
140
142
  './outcome.mjs': (m) => ({ evaluateOutcomes } = m),
141
143
  './style.mjs': (m) => ({ analyzeStyle } = m),
@@ -149,90 +151,91 @@ const LAZY = {
149
151
  };
150
152
  // The modules each command can reach. A command that is not listed loads them all.
151
153
  const COMMAND_MODULES = {
152
- "": [15, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
153
- "--help": [15, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
154
- "--version": [15, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
155
- "-h": [15, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
156
- "-v": [15, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
157
- "12factor": [0, 25, 40, 41, 44, 57, 73, 74, 75, 76, 77, 78, 79, 80, 81],
158
- "affected": [25, 40, 41, 44, 69, 70, 73, 74, 75, 76, 77, 78, 79, 80, 81],
159
- "ai": [0, 25, 40, 41, 44, 48, 51, 73, 74, 75, 76, 77, 78, 79, 80, 81, 95, 96],
160
- "anchor": [6, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
161
- "apply-fix": [0, 15, 18, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
162
- "approve": [25, 40, 41, 44, 49, 73, 74, 75, 76, 77, 78, 79, 80, 81],
163
- "atlas": [0, 25, 40, 41, 44, 52, 53, 54, 73, 74, 75, 76, 77, 78, 79, 80, 81],
164
- "build": [0, 15, 17, 24, 25, 40, 41, 42, 44, 52, 73, 74, 75, 76, 77, 78, 79, 80, 81, 95],
165
- "changes": [0, 25, 40, 41, 44, 52, 59, 73, 74, 75, 76, 77, 78, 79, 80, 81],
166
- "check": [0, 15, 16, 24, 25, 40, 41, 42, 44, 61, 73, 74, 75, 76, 77, 78, 79, 80, 81],
167
- "code-actions": [0, 15, 18, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
168
- "completion": [25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
169
- "completions": [0, 15, 18, 24, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
170
- "comprehension": [0, 25, 40, 41, 44, 56, 73, 74, 75, 76, 77, 78, 79, 80, 81],
171
- "conform": [0, 15, 25, 40, 41, 44, 71, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 87],
172
- "diff": [0, 25, 40, 41, 44, 52, 53, 60, 73, 74, 75, 76, 77, 78, 79, 80, 81],
173
- "docs": [0, 17, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
174
- "doctor": [15, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
175
- "draft": [25, 40, 41, 44, 47, 73, 74, 75, 76, 77, 78, 79, 80, 81],
176
- "drift": [0, 15, 25, 40, 41, 44, 48, 49, 73, 74, 75, 76, 77, 78, 79, 80, 81, 87],
177
- "edit": [22, 24, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
178
- "evidence": [0, 15, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81, 86, 87],
179
- "explain": [25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81, 93],
180
- "export": [0, 25, 40, 41, 44, 62, 73, 74, 75, 76, 77, 78, 79, 80, 81],
181
- "fmt": [21, 24, 25, 40, 41, 42, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
182
- "focus": [0, 25, 40, 41, 44, 52, 53, 55, 73, 74, 75, 76, 77, 78, 79, 80, 81],
183
- "format": [0, 15, 24, 25, 40, 41, 42, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
184
- "gen": [0, 25, 40, 41, 44, 58, 73, 74, 75, 76, 77, 78, 79, 80, 81],
185
- "graph": [0, 15, 24, 25, 40, 41, 44, 52, 73, 74, 75, 76, 77, 78, 79, 80, 81],
186
- "guard": [0, 25, 40, 41, 44, 46, 73, 74, 75, 76, 77, 78, 79, 80, 81],
187
- "guardian": [25, 26, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
188
- "handoff": [0, 25, 40, 41, 44, 49, 73, 74, 75, 76, 77, 78, 79, 80, 81],
189
- "help": [15, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
190
- "hover": [0, 15, 18, 24, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
191
- "human": [1, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
192
- "impact": [25, 27, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
193
- "import": [0, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81, 84],
194
- "index": [25, 40, 41, 44, 50, 73, 74, 75, 76, 77, 78, 79, 80, 81],
195
- "init": [25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
196
- "ledger": [25, 28, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
197
- "lift": [0, 25, 40, 41, 44, 48, 73, 74, 75, 76, 77, 78, 79, 80, 81],
198
- "lsp": [19, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
199
- "mcp": [20, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
200
- "merge": [0, 25, 40, 41, 44, 52, 53, 60, 73, 74, 75, 76, 77, 78, 79, 80, 81],
201
- "migrate": [0, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81, 92],
202
- "mission": [0, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81, 83],
203
- "new": [25, 40, 41, 42, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
204
- "notes": [0, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
205
- "outcomes": [0, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81, 88],
206
- "passport": [25, 35, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
207
- "plain": [2, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
208
- "proof": [0, 15, 24, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81, 90],
209
- "prove": [0, 15, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81, 86],
210
- "read": [0, 1, 9, 10, 11, 12, 13, 14, 25, 32, 33, 40, 41, 44, 45, 73, 74, 75, 76, 77, 78, 79, 80, 81],
211
- "replay": [25, 39, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
212
- "repo": [3, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
213
- "report": [23, 24, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
214
- "review": [15, 25, 40, 41, 44, 66, 67, 68, 69, 73, 74, 75, 76, 77, 78, 79, 80, 81, 87],
215
- "rules": [25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81, 93],
216
- "run": [0, 25, 40, 41, 42, 44, 63, 73, 74, 75, 76, 77, 78, 79, 80, 81],
217
- "runtime": [12, 25, 30, 31, 32, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
218
- "same": [0, 5, 12, 15, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
219
- "scan": [24, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
220
- "schema": [25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81, 93, 94],
221
- "simulate": [0, 25, 40, 41, 44, 63, 73, 74, 75, 76, 77, 78, 79, 80, 81],
222
- "source": [0, 25, 40, 41, 44, 52, 73, 74, 75, 76, 77, 78, 79, 80, 81, 91],
223
- "style": [0, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81, 89],
224
- "test": [0, 25, 40, 41, 42, 44, 64, 65, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 85, 86],
225
- "text": [2, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
226
- "thunderize": [3, 4, 12, 25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
227
- "trace": [25, 34, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
228
- "try": [25, 38, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
229
- "twelve-factor": [0, 25, 40, 41, 44, 57, 73, 74, 75, 76, 77, 78, 79, 80, 81],
230
- "validate": [25, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81, 92],
231
- "verify": [0, 15, 25, 30, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81, 90],
232
- "verify-diff": [0, 15, 25, 29, 40, 41, 44, 48, 73, 74, 75, 76, 77, 78, 79, 80, 81, 87],
233
- "version": [15, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
234
- "why": [25, 37, 40, 41, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
235
- "write": [7, 8, 25, 36, 40, 41, 43, 44, 73, 74, 75, 76, 77, 78, 79, 80, 81],
154
+ "": [18, 28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
155
+ "--help": [18, 28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
156
+ "--version": [0, 18, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
157
+ "-h": [18, 28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
158
+ "-v": [0, 18, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
159
+ "12factor": [3, 28, 43, 44, 47, 60, 76, 77, 78, 79, 80, 81, 82, 83, 84],
160
+ "affected": [28, 43, 44, 47, 72, 73, 76, 77, 78, 79, 80, 81, 82, 83, 84],
161
+ "ai": [3, 28, 43, 44, 47, 51, 54, 76, 77, 78, 79, 80, 81, 82, 83, 84, 97, 98],
162
+ "anchor": [9, 28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
163
+ "apply-fix": [3, 18, 21, 28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
164
+ "approve": [28, 43, 44, 47, 52, 76, 77, 78, 79, 80, 81, 82, 83, 84],
165
+ "atlas": [3, 28, 43, 44, 47, 55, 56, 57, 76, 77, 78, 79, 80, 81, 82, 83, 84],
166
+ "build": [3, 18, 20, 27, 28, 43, 44, 45, 47, 55, 76, 77, 78, 79, 80, 81, 82, 83, 84, 97],
167
+ "changes": [3, 28, 43, 44, 47, 55, 62, 76, 77, 78, 79, 80, 81, 82, 83, 84],
168
+ "check": [3, 18, 19, 27, 28, 43, 44, 45, 47, 64, 76, 77, 78, 79, 80, 81, 82, 83, 84],
169
+ "code-actions": [3, 18, 21, 28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
170
+ "completion": [28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
171
+ "completions": [3, 18, 21, 27, 28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
172
+ "comprehension": [3, 28, 43, 44, 47, 59, 76, 77, 78, 79, 80, 81, 82, 83, 84],
173
+ "conform": [3, 18, 28, 43, 44, 47, 74, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 89],
174
+ "diff": [3, 28, 43, 44, 47, 55, 56, 63, 76, 77, 78, 79, 80, 81, 82, 83, 84],
175
+ "docs": [3, 20, 28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
176
+ "doctor": [18, 28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
177
+ "draft": [28, 43, 44, 47, 50, 76, 77, 78, 79, 80, 81, 82, 83, 84],
178
+ "drift": [3, 18, 28, 43, 44, 47, 51, 52, 76, 77, 78, 79, 80, 81, 82, 83, 84, 89],
179
+ "edit": [25, 27, 28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
180
+ "evidence": [1, 3, 18, 28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84, 89],
181
+ "explain": [28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84, 95],
182
+ "export": [3, 28, 43, 44, 47, 65, 76, 77, 78, 79, 80, 81, 82, 83, 84],
183
+ "fmt": [24, 27, 28, 43, 44, 45, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
184
+ "focus": [3, 28, 43, 44, 47, 55, 56, 58, 76, 77, 78, 79, 80, 81, 82, 83, 84],
185
+ "format": [3, 18, 27, 28, 43, 44, 45, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
186
+ "gen": [3, 28, 43, 44, 47, 61, 76, 77, 78, 79, 80, 81, 82, 83, 84],
187
+ "graph": [3, 18, 27, 28, 43, 44, 47, 55, 76, 77, 78, 79, 80, 81, 82, 83, 84],
188
+ "guard": [3, 28, 43, 44, 47, 49, 76, 77, 78, 79, 80, 81, 82, 83, 84],
189
+ "guardian": [28, 29, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
190
+ "handoff": [3, 28, 43, 44, 47, 52, 76, 77, 78, 79, 80, 81, 82, 83, 84],
191
+ "help": [18, 28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
192
+ "hover": [3, 18, 21, 27, 28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
193
+ "human": [4, 28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
194
+ "impact": [28, 30, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
195
+ "import": [3, 28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84, 87],
196
+ "index": [28, 43, 44, 47, 53, 76, 77, 78, 79, 80, 81, 82, 83, 84],
197
+ "init": [28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
198
+ "ledger": [28, 31, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
199
+ "lift": [3, 28, 43, 44, 47, 51, 76, 77, 78, 79, 80, 81, 82, 83, 84],
200
+ "lsp": [22, 28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
201
+ "mcp": [23, 28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
202
+ "merge": [3, 28, 43, 44, 47, 55, 56, 63, 76, 77, 78, 79, 80, 81, 82, 83, 84],
203
+ "migrate": [3, 28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84, 94],
204
+ "mission": [3, 28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84, 86],
205
+ "new": [28, 43, 44, 45, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
206
+ "notes": [3, 28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
207
+ "outcomes": [3, 28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84, 90],
208
+ "passport": [28, 38, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
209
+ "plain": [5, 28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
210
+ "proof": [3, 18, 27, 28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84, 92],
211
+ "prove": [1, 3, 18, 28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
212
+ "read": [3, 4, 12, 13, 14, 15, 16, 17, 28, 35, 36, 43, 44, 47, 48, 76, 77, 78, 79, 80, 81, 82, 83, 84],
213
+ "replay": [28, 42, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
214
+ "repo": [6, 28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
215
+ "report": [26, 27, 28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
216
+ "review": [18, 28, 43, 44, 47, 69, 70, 71, 72, 76, 77, 78, 79, 80, 81, 82, 83, 84, 89],
217
+ "rules": [28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84, 95],
218
+ "run": [3, 28, 43, 44, 45, 47, 66, 76, 77, 78, 79, 80, 81, 82, 83, 84],
219
+ "runtime": [15, 28, 33, 34, 35, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
220
+ "same": [3, 8, 15, 18, 28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
221
+ "scan": [27, 28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
222
+ "schema": [28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84, 95, 96],
223
+ "simulate": [3, 28, 43, 44, 47, 66, 76, 77, 78, 79, 80, 81, 82, 83, 84],
224
+ "source": [3, 28, 43, 44, 47, 55, 76, 77, 78, 79, 80, 81, 82, 83, 84, 93],
225
+ "style": [3, 28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84, 91],
226
+ "template": [2, 28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
227
+ "test": [1, 3, 28, 43, 44, 45, 47, 67, 68, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 88],
228
+ "text": [5, 28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
229
+ "thunderize": [6, 7, 15, 28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
230
+ "trace": [28, 37, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
231
+ "try": [28, 41, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
232
+ "twelve-factor": [3, 28, 43, 44, 47, 60, 76, 77, 78, 79, 80, 81, 82, 83, 84],
233
+ "validate": [28, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84, 94],
234
+ "verify": [3, 18, 28, 33, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84, 92],
235
+ "verify-diff": [3, 18, 28, 32, 43, 44, 47, 51, 76, 77, 78, 79, 80, 81, 82, 83, 84, 89],
236
+ "version": [0, 18, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
237
+ "why": [28, 40, 43, 44, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
238
+ "write": [10, 11, 28, 39, 43, 44, 46, 47, 76, 77, 78, 79, 80, 81, 82, 83, 84],
236
239
  };
237
240
  async function preload(cmd) {
238
241
  const specs = Object.keys(LAZY);
@@ -514,6 +517,8 @@ function parseArgs(argv) {
514
517
  else if (a === '--focus') args.focus = argv[++i];
515
518
  else if (a === '--kind') args.kind = (argv[++i] || '').split(',').map((k) => k.trim()).filter(Boolean);
516
519
  else if (a === '--in') args.inLang = argv[++i];
520
+ else if (a === '--name') args.name = argv[++i];
521
+ else if (a === '--gives') args.gives = argv[++i];
517
522
  else if (a === '--answer') args.answer = argv[++i];
518
523
  else if (a === '--promote') args.promote = argv[++i];
519
524
  else if (a === '--input') args.input = argv[++i];
@@ -656,6 +661,10 @@ Write and run programs (Thunder Core, docs/core.md)
656
661
  --target csharp compiles to C# (generated/csharp/; builds and runs with the .NET 8+ SDK)
657
662
  --target go compiles to Go (generated/go/; needs the go toolchain to run)
658
663
  --target java compiles to Java (generated/java/; runs with a JDK 17+)
664
+ template <file> <data type> [--name "<function>"] [--gives <kind>] [--write] [--json]
665
+ the Design Recipe's template: the shape of a function that takes the data type, written
666
+ from its definition (a case per alternative, each field by name, the call to itself for
667
+ recursive parts, and holes for the answers you fill in); --write adds it to the file
659
668
 
660
669
  Read and understand code
661
670
  read <file|dir> [--search q] [--kind decision,function,error,test] [--in <lang>] [--from <lang>] [--json]
@@ -692,8 +701,9 @@ Read and understand code
692
701
  Change code
693
702
  write <file> --edit '<json>' [--edit …] | --edits <list.json|-> [--also <file>] [--apply] [--test "<cmd>"] [--candidate <file>] [--json]
694
703
  Writing in Thunder: change a step, question, Stop, input, or function in Thunder; the code is
695
- written as a minimal patch (TS/JS, Python, Go) and proven (the edited steps mean exactly
696
- the edit; everything else means the same). Conditions and values in Thunder's words
704
+ written as a minimal patch (TS/JS, Python, Go) and checked by comparing the code's trees:
705
+ the edited steps read exactly as the edit says and the rest is unchanged (Proven, about the
706
+ code's shape; --test runs your tests on its behaviour: Tested). Conditions and values in Thunder's words
697
707
  ("amount is at least 100", "name is nothing") or as code; steps by their line in thunder read.
698
708
  Dry run by default; --apply saves; --test runs a command on the changed code. Other cases
699
709
  print an instruction for an AI coding agent; --candidate checks code it wrote (AI-written).
@@ -803,7 +813,7 @@ function main() {
803
813
  const args = parseArgs(restArgv);
804
814
  const file = args._[0];
805
815
  if (cmd === '--version' || cmd === '-v' || cmd === 'version') {
806
- console.log(`thunder ${COMPILER_VERSION} (the Thunder™ compiler, also called ThunderLang™)`);
816
+ console.log(`thunder ${COMPILER_VERSION} (the Thunder™ compiler, also called ThunderLang™), language ${LANGUAGE_VERSION}`);
807
817
  return;
808
818
  }
809
819
  const known = [...new Set([...knownCommands(HELP), ...Object.keys(VIEWS)])].sort();
@@ -979,16 +989,16 @@ function main() {
979
989
  if (r.after) { console.log('Thunder after:'); for (const l of r.after.split('\n')) console.log(` ${l}`); }
980
990
  console.log(`\n${r.author === 'ai' ? 'AI-written change (checked):' : 'Code change:'}\n`);
981
991
  process.stdout.write(r.patch);
982
- console.log('\nProof:');
983
- for (const c of r.proof.edited.checks) console.log(` edited ${c.member}: ${c.result === 'exact' ? 'reads exactly as the edit says' : c.result}`);
992
+ console.log('\nChecks (docs/evidence-words.md):');
993
+ for (const c of r.proof.edited.checks) console.log(` edited ${c.member}: ${c.result === 'exact' ? 'Proven: reads exactly as the edit says (its tree matches)' : `Violated: ${c.result}`}`);
984
994
  const u = r.proof.unchanged;
985
- console.log(` unchanged ${u.checked} other function${u.checked === 1 ? '' : 's'} in the changed file${Object.keys(r.files).length === 1 ? '' : 's'}: ${u.status === 'same' ? 'all mean the same' : u.status}`);
986
- if (r.proof.run) console.log(` run ${r.proof.run.command}: ${r.proof.run.passed ? 'passed' : `failed (exit ${r.proof.run.exit})`}`);
995
+ console.log(` unchanged ${u.checked} other function${u.checked === 1 ? '' : 's'} in the changed file${Object.keys(r.files).length === 1 ? '' : 's'}: ${u.status === 'same' ? 'Proven: unchanged (the same trees)' : `Violated: ${u.status}`}`);
996
+ if (r.proof.run) console.log(` run ${r.proof.run.command}: ${r.proof.run.passed ? 'Tested: passed' : `Violated: failed (exit ${r.proof.run.exit})`}`);
987
997
  if (r.proof.run && !r.proof.run.passed) console.log(r.proof.run.output);
988
998
  for (const b of r.proof.behaviour ?? []) {
989
999
  console.log(` behaviour ${b.function ?? ''}${b.function ? ': ' : ''}${b.status === 'changed' ? `${b.changes.length} of ${b.inputs} inputs give a different answer` : b.status === 'same' ? `all ${b.inputs} inputs give the same answer` : b.status === 'broken' ? `the changed file does not load (${b.reason})` : `not checked (${b.reason ?? b.says})`}`);
990
1000
  for (const ex of b.examples ?? []) console.log(` ${ex}`);
991
- if (b.status === 'same' || b.status === 'changed') console.log(' (tested on these inputs only; not a proof)');
1001
+ if (b.status === 'same' || b.status === 'changed') console.log(' (Tested: on these inputs only, not every input)');
992
1002
  }
993
1003
  console.log(`\n${r.says}`);
994
1004
  console.log(applied ? `\nSaved ${Object.keys(r.files).join(', ')}.` : broken ? '\nNot saved: the changed file does not load.' : r.proof?.run && !r.proof.run.passed ? '\nNot saved: the test command failed.' : '\nDry run; nothing was saved. Add --apply to save the change.');
@@ -1088,6 +1098,35 @@ function main() {
1088
1098
  } catch (e) { console.error(`thunder review: ${e.message}`); process.exitCode = 2; }
1089
1099
  return;
1090
1100
  }
1101
+ if (cmd === 'template') {
1102
+ try {
1103
+ const [file, ...type] = args._;
1104
+ if (!file || !type.length) throw new Error('Use thunder template <file> <data type> [--name "<function>"] [--gives <kind>] [--json] [--write], for example: thunder template main.thunder Payment');
1105
+ if (!existsSync(file)) throw new Error(`${file} does not exist.`);
1106
+ const source = readFileSync(file, 'utf8');
1107
+ const r = templateOf(source, type.join(' '), { name: args.name ?? null, gives: args.gives ?? null, file });
1108
+ if (!r.ok) throw new Error(r.problem);
1109
+ if (args.json) console.log(JSON.stringify(r, null, 2));
1110
+ else if (args.write) {
1111
+ if (!r.check.draft) throw new Error(`nothing written: added to ${file}, the template would have problems: ${r.check.problems.map((p) => `line ${p.line}: ${p.message}`).join(' ')} Use --name to give the function another name.`);
1112
+ writeFileSync(file, `${source.replace(/\s+$/, '')}\n\n${r.text}`);
1113
+ console.log(`thunder template: added "To ${r.function.name}:" to ${file}, a draft with ${r.check.holes} ${r.check.holes === 1 ? 'hole' : 'holes'} to fill in. thunder check ${file} says what each needs.`);
1114
+ } else {
1115
+ process.stdout.write(r.text);
1116
+ const why = r.type.form === 'atomic' ? `${r.type.text} has no parts, so the template is the input and a hole`
1117
+ : r.type.form === 'compound' ? `a ${r.type.text} has ${r.cases[0].fields.length} ${r.cases[0].fields.length === 1 ? 'field' : 'fields'}, each taken out by name`
1118
+ : `a ${r.type.text} is one of ${r.cases.length} alternatives, so there is a case for each`;
1119
+ const notes = [why];
1120
+ if (r.type.recursive) notes.push(`it holds a ${r.type.text} again, so the function calls itself for that part`);
1121
+ if (r.related.length) notes.push(`it uses ${r.related.join(', ')}: thunder template ${file} ${r.related[0]} writes ${r.related.length === 1 ? 'its' : 'their'} own`);
1122
+ console.error(`\n# ${notes.join('; ')}.`);
1123
+ console.error(r.check.draft ? `# Checked: added to ${file}, it is a draft with ${r.check.holes} ${r.check.holes === 1 ? 'hole' : 'holes'} and nothing else to fix. Fill in each ? (Thunder won't choose for you).`
1124
+ : `# Added to ${file}, it would have problems: ${r.check.problems.map((p) => `line ${p.line}: ${p.message}`).join(' ')}`);
1125
+ }
1126
+ process.exitCode = r.check.draft ? 0 : 1;
1127
+ } catch (e) { console.error(`thunder template: ${e.message}`); process.exitCode = 2; }
1128
+ return;
1129
+ }
1091
1130
  if (cmd === 'affected') {
1092
1131
  try {
1093
1132
  if (!args._.length) throw new Error('Use thunder affected <rule…> [--in <folder|file>] [--json], for example: thunder affected "review limit" --in examples/apps/refund-desk');
@@ -1524,7 +1563,7 @@ goal
1524
1563
 
1525
1564
  guarantee an example property that must always hold
1526
1565
  because state why it matters
1527
- verify a test that proves it
1566
+ verify a test that checks it
1528
1567
 
1529
1568
  never
1530
1569
  do something this mission must never do
@@ -2211,14 +2250,17 @@ test Example
2211
2250
  const bad = rep.failed > 0 || (args.strict && rep.unverified > 0);
2212
2251
  if (args.json) { console.log(JSON.stringify(rep, null, 2)); process.exit(bad ? 1 : 0); return; }
2213
2252
  if (!rep.total) { console.log(`thunder test ${basename(file)} --contracts: no guarantees or prohibitions declared.`); return; }
2214
- console.log(`thunder test ${basename(file)} --contracts: ${rep.total} obligation(s), ${rep.verified} verified, ${rep.declared} declared, ${rep.unverified} unverified${rep.failed ? `, ${rep.failed} failed` : ''}`);
2215
- const LABEL = { verified: 'PASS', failed: 'FAIL', declared: 'DECLARED', unverified: 'UNVERIFIED' };
2253
+ const ev = res.evidence;
2254
+ console.log(`thunder test ${basename(file)} --contracts: ${rep.total} obligation(s): ${ev.tested} Tested, ${ev.partial} Partially checked, ${ev.unverified} Unverified${ev.violated ? `, ${ev.violated} Violated` : ''}`);
2216
2255
  for (const o of obligations) {
2217
2256
  const by = o.kinds.length ? ` by ${o.kinds.join('+')}` : '';
2218
- const detail = o.provenBy ? ` proven by test ${o.provenBy}`
2219
- : o.status === 'declared' ? ' (declared, runs in target mode)'
2220
- : o.status === 'unverified' ? ' (nothing verifies this)' : '';
2221
- console.log(` ${LABEL[o.status].padEnd(10)} ${o.kind} ${o.id}: ${o.text}${by}${detail}`);
2257
+ const ran = o.evidence.filter((e) => e.pass !== null).map((e) => e.name);
2258
+ const detail = o.evidenceLevel === 'violated' ? ` (test ${o.evidence.filter((e) => e.pass === false).map((e) => e.name).join(', ')} failed)`
2259
+ : o.evidenceLevel === 'tested' ? ` (passed test ${ran.join(', ')}; only its cases)`
2260
+ : o.evidenceLevel === 'partial' ? ` (passed ${ran.join(', ')}; ${o.unresolved.join(', ')} runs in target mode, not here)`
2261
+ : o.status === 'declared' ? ` (${o.unresolved.join(', ')} runs in target mode, not here)`
2262
+ : ' (nothing checks this yet)';
2263
+ console.log(` ${o.evidenceWord.padEnd(17)} ${o.kind} ${o.id}: ${o.text}${by}${detail}`);
2222
2264
  }
2223
2265
  if (args.strict && rep.unverified) console.log(`\n strict: ${rep.unverified} unverified obligation(s) , run fails until every claim carries a verification.`);
2224
2266
  process.exit(bad ? 1 : 0);
@@ -2258,11 +2300,7 @@ test Example
2258
2300
  generatedAt: new Date().toISOString(),
2259
2301
  });
2260
2302
  // Fold per-claim verdicts into the proof so it records real status, not just planned/needs_verification.
2261
- const CLAIM_MAP = { verified: 'verified', failed: 'failed', declared: 'planned', unverified: 'needs_verification' };
2262
- const byId = new Map(resolved.obligations.map((o) => [o.id, o]));
2263
- const applyStatus = (claim) => { const o = byId.get(claim.id); return o ? { ...claim, status: CLAIM_MAP[o.status], provenBy: o.provenBy || null } : claim; };
2264
- proof.guarantees = proof.guarantees.map(applyStatus);
2265
- proof.neverRules = proof.neverRules.map(applyStatus);
2303
+ foldObligations(proof, resolved);
2266
2304
  // Freshness tuple: what `thunder verify` recomputes to mark this proof STALE later.
2267
2305
  proof.freshness = freshnessFor(file, proof, args.env);
2268
2306
  const proofId = `proof-${proof.sourceHash.replace('sha256:', '').slice(0, 6)}`;
@@ -2274,7 +2312,7 @@ test Example
2274
2312
  return;
2275
2313
  }
2276
2314
 
2277
- console.log(`Proof created: ${proofId}`);
2315
+ console.log(`Evidence record created: ${proofId} (what was checked, and how: docs/evidence-words.md)`);
2278
2316
  console.log('');
2279
2317
  console.log(` Intent: ${proof.missionName || stripSourceExt(basename(file))}`);
2280
2318
  console.log(` Intent hash: ${proof.sourceHash}`);
@@ -2283,15 +2321,16 @@ test Example
2283
2321
  console.log(` Syntax: ${proof.verification.syntaxPassed ? 'PASS' : 'FAIL'}`);
2284
2322
  console.log(` Semantics: ${proof.verification.semanticPassed ? 'PASS' : 'FAIL'}`);
2285
2323
  console.log(` Tests: ${tests.total ? `${tests.passed}/${tests.total} passed` : 'none'}`);
2286
- console.log(` Claims: ${resolved.verified} verified, ${resolved.declared} declared, ${resolved.unverified} UNVERIFIED${resolved.failed ? `, ${resolved.failed} FAILED` : ''} (of ${resolved.obligations.length})`);
2287
- console.log(` Proof status: ${String(proof.proofStatus).toUpperCase()}${(resolved.unverified || resolved.failed) ? ' (not fully proven)' : ''}`);
2324
+ const ev = resolved.evidence;
2325
+ console.log(` Claims: ${ev.tested} Tested, ${ev.partial} Partially checked, ${ev.unverified} Unverified${ev.violated ? `, ${ev.violated} VIOLATED` : ''} (of ${resolved.obligations.length}; Tested = passed its named cases, only those)`);
2326
+ console.log(` Status: ${String(proof.proofStatus).toUpperCase()}${(ev.unverified || ev.partial || ev.violated) ? ` (${ev.unverified + ev.partial + ev.violated} not fully tested)` : ''}`);
2288
2327
  const fr = proof.freshness;
2289
2328
  console.log(` Bound to: commit ${fr.implementation ? fr.implementation.slice(0, 7) : 'n/a'}${fr.dependencies ? ` · deps ${fr.dependencies.hash.replace('sha256:', '').slice(0, 7)} (${fr.dependencies.file})` : ''}${fr.environment ? ` · env ${fr.environment}` : ''}`);
2290
- const problems = resolved.obligations.filter((o) => o.status === 'unverified' || o.status === 'failed');
2329
+ const problems = resolved.obligations.filter((o) => o.evidenceLevel !== 'tested');
2291
2330
  if (problems.length) {
2292
2331
  console.log('');
2293
- console.log(' Not proven (this is where drift hides , a claim like this never counts as proven):');
2294
- for (const o of problems) console.log(` - ${o.status === 'failed' ? 'FAILED ' : 'UNVERIFIED'} ${o.kind} ${o.id}: ${o.text}`);
2332
+ console.log(' Not tested yet, or Violated (this is where drift hides):');
2333
+ for (const o of problems) console.log(` - ${o.evidenceWord.padEnd(17)} ${o.kind} ${o.id}: ${o.text}`);
2295
2334
  }
2296
2335
  const outName = `${slug(ast.mission || stripSourceExt(basename(file)))}.thunder-proof.json`;
2297
2336
  const outDir = args.out && args.out !== '.intent' ? args.out : dirname(file);
@@ -2320,11 +2359,7 @@ test Example
2320
2359
  diagnostics,
2321
2360
  generatedAt: new Date().toISOString(),
2322
2361
  });
2323
- const CLAIM_MAP = { verified: 'verified', failed: 'failed', declared: 'planned', unverified: 'needs_verification' };
2324
- const byId = new Map(resolved.obligations.map((o) => [o.id, o]));
2325
- const applyStatus = (claim) => { const o = byId.get(claim.id); return o ? { ...claim, status: CLAIM_MAP[o.status], provenBy: o.provenBy || null } : claim; };
2326
- proof.guarantees = proof.guarantees.map(applyStatus);
2327
- proof.neverRules = proof.neverRules.map(applyStatus);
2362
+ foldObligations(proof, resolved);
2328
2363
  proof.freshness = freshnessFor(file, proof, args.env);
2329
2364
  const events = toEvidenceEvents(proof);
2330
2365
  console.log(JSON.stringify(events, null, 2));
@@ -2723,8 +2758,8 @@ test Example
2723
2758
  const v = VIEWS[cmd](scan);
2724
2759
  if (args.json) { console.log(JSON.stringify(v, null, 2)); return; }
2725
2760
  if (cmd === 'coverage') {
2726
- console.log(`thunder coverage ${root}: ${v.verified}/${v.total} claims verified (${v.coverage}%)`);
2727
- for (const c of v.unverified) console.log(` unverified [${c.type}] ${c.title}`);
2761
+ console.log(`thunder coverage ${root}: ${v.verified}/${v.total} claims name a check (${v.coverage}%). Naming a check is not running it: thunder test <file> --contracts says which are Tested.`);
2762
+ for (const c of v.unverified) console.log(` Unverified [${c.type}] ${c.title} (no check named)`);
2728
2763
  process.exit(v.coverage === 100 ? 0 : 1); return;
2729
2764
  }
2730
2765
  if (cmd === 'risks') {
@@ -2778,7 +2813,7 @@ test Example
2778
2813
  console.log(`thunder report ${root}: ${rep.totals.missions} mission(s) in ${rep.totals.files} file(s), ${rep.totals.diagnostics} diagnostic(s)`);
2779
2814
  console.log(` severity ${rep.bySeverity.blocker} blocker, ${rep.bySeverity.error} error, ${rep.bySeverity.warning} warning, ${rep.bySeverity.info} info`);
2780
2815
  console.log(' coverage '
2781
- + `guarantees verified ${c.guaranteesVerified}/${c.guarantees}${c.guaranteeVerifyRate != null ? ` (${c.guaranteeVerifyRate}%)` : ''}, `
2816
+ + `guarantees with a check named ${c.guaranteesVerified}/${c.guarantees}${c.guaranteeVerifyRate != null ? ` (${c.guaranteeVerifyRate}%)` : ''} (named, not run), `
2782
2817
  + `missions with tests ${c.missionsWithTests}/${rep.totals.missions}${c.testCoverageRate != null ? ` (${c.testCoverageRate}%)` : ''}, `
2783
2818
  + `outcomes contracted ${c.outcomeContracts}/${c.outcomes}${c.outcomeContractRate != null ? ` (${c.outcomeContractRate}%)` : ''}`);
2784
2819
  if (rep.topCodes.length) {
@@ -10,6 +10,7 @@
10
10
  #pragma warning disable CS0162, CS0168, CS0219, CS8321
11
11
  using System;
12
12
  using System.Collections.Generic;
13
+ using System.Globalization;
13
14
  using System.IO;
14
15
  using System.Linq;
15
16
  using System.Numerics;
@@ -425,7 +426,26 @@ namespace Thunder
425
426
  for (int i = 0; i < ip.Length; i++) { if (i > 0 && (ip.Length - i) % 3 == 0) sb.Append(','); sb.Append(ip[i]); }
426
427
  return sb.ToString();
427
428
  }
428
- static string jsLower(string s) => s.ToLowerInvariant();
429
+ // Lowercase as Python and JavaScript do, including Unicode's Final_Sigma rule (.NET's ToLowerInvariant has no
430
+ // context, so a word-final Σ would become σ instead of ς).
431
+ static string jsLower(string s)
432
+ {
433
+ // ToLowerInvariant maps one UTF-16 unit to one, so positions line up for the Σ pass. It leaves İ as it is;
434
+ // Python and JavaScript give i followed by a combining dot, so that is done last.
435
+ var sb = new StringBuilder(s.ToLowerInvariant());
436
+ if (s.IndexOf('Σ') >= 0) for (int i = 0; i < s.Length; i++) if (s[i] == 'Σ' && finalSigma(s, i)) sb[i] = 'ς';
437
+ return sb.ToString().Replace("İ", "i\u0307");
438
+ }
439
+ static bool finalSigma(string s, int i)
440
+ {
441
+ static bool cased(char c) => char.IsUpper(c) || char.IsLower(c) || CharUnicodeInfo.GetUnicodeCategory(c) == UnicodeCategory.TitlecaseLetter;
442
+ static bool ignorable(char c) { var k = CharUnicodeInfo.GetUnicodeCategory(c); return k == UnicodeCategory.NonSpacingMark || k == UnicodeCategory.EnclosingMark || k == UnicodeCategory.Format || k == UnicodeCategory.ModifierLetter || k == UnicodeCategory.ModifierSymbol || c == '\'' || c == '.' || c == ':' || c == '’' || c == '·'; }
443
+ bool before = false;
444
+ for (int j = i - 1; j >= 0; j--) { if (ignorable(s[j])) continue; before = cased(s[j]); break; }
445
+ if (!before) return false;
446
+ for (int j = i + 1; j < s.Length; j++) { if (ignorable(s[j])) continue; return !cased(s[j]); }
447
+ return true;
448
+ }
429
449
  static string jsUpper(string s) => s.ToUpperInvariant().Replace("ß", "SS");
430
450
 
431
451
  // ── Kinds ───────────────────────────────────────────────────────────────────────────────────────────────
@@ -1054,6 +1074,7 @@ namespace Thunder
1054
1074
  }
1055
1075
 
1056
1076
  public static object addTo(object target, object value) { if (target is List<object> l) { l.Add(value); return l; } return add(target, value); }
1077
+ public static List<object> copyList(object target) { if (!(target is List<object> l)) throw attrErr(target, "append"); return new List<object>(l); }
1057
1078
  public static void appendTo(object target, object value) { if (!(target is List<object> l)) throw attrErr(target, "append"); l.Add(value); }
1058
1079
  public static void removeFrom(object target, object value)
1059
1080
  {
@@ -470,6 +470,13 @@ class Checker {
470
470
  // An empty list learns what it holds from the first thing added to it.
471
471
  if (s.k === 'add' && s.targetKind === 'list' && !known(tt.of) && known(te) && s.target.k === 'name' && s.target.ref?.type?.k === 'list') s.target.ref.type = T('list', { of: te });
472
472
  this.afterAssign(s, s.target, sc);
473
+ // A list a Never rule watches (a name, or a record's field) is changed on a copy, checked, then kept: a change
474
+ // that breaks the rule is refused and the old list stays, like any other value. Every target does the same.
475
+ if (s.targetKind === 'list' || (s.targetKind === 'map' && s.k === 'remove')) {
476
+ const watched = s.target.k === 'name' ? s.rules?.length > 0
477
+ : s.target.k === 'field' && (this.records.get(s.target.record)?.rulesToCheck ?? []).some((r) => r.subject === s.target.name);
478
+ if (watched && s.targetKind === 'list') s.guard = true;
479
+ }
473
480
  return;
474
481
  }
475
482
  case 'increase': case 'decrease': {
@@ -761,6 +768,7 @@ class Checker {
761
768
  case 'field': {
762
769
  const ot = this.ex(e.obj, sc, o);
763
770
  const r = ot.k === 'record' ? this.records.get(ot.name) : null;
771
+ if (r) e.record = r.name;
764
772
  if (r?.altMap && e.name !== 'which' && r.fieldMap.has(e.name)) {
765
773
  // A field one alternative has: only where that alternative is known.
766
774
  const alt = this.narrowed(e.obj);
@@ -389,6 +389,13 @@ class Engine {
389
389
  const isName = s.target.k === 'name';
390
390
  const target = this.x(s.target, env);
391
391
  const py = isName ? s.target.ref?.py ?? 'unknown' : null;
392
+ if (s.guard) {
393
+ // A watched list: change a copy, then keep it through the checked assignment (the old list stays if refused).
394
+ const copy = V.copyList(target);
395
+ if (s.k === 'add') V.appendTo(copy, v); else this.removeFrom(copy, v);
396
+ if (isName) this.assign(s, py, copy, env); else this.store(s.target, copy, env);
397
+ return;
398
+ }
392
399
  if (s.targetKind === 'list') { if (s.k === 'add') { if (!Array.isArray(target)) throw attrErr(target, 'append'); target.push(v); } else this.removeFrom(target, v); }
393
400
  else if (s.targetKind === 'map') this.removeFrom(target, v);
394
401
  else if (s.targetKind === 'number') {
@@ -826,6 +826,8 @@ export function setFieldWith(setAttr, obj, key, value) {
826
826
  }
827
827
 
828
828
  export function addTo(target, value) { if (Array.isArray(target)) { target.push(value); return target; } return add(target, value); }
829
+ /** A new list with the same items (a watched list is changed on a copy, so a refused change leaves it as it was). */
830
+ export function copyList(target) { if (!Array.isArray(target)) throw attrErr(target, 'append'); return [...target]; }
829
831
  export function appendTo(target, value) { if (!Array.isArray(target)) throw attrErr(target, 'append'); target.push(value); }
830
832
  export function removeFrom(target, value) {
831
833
  if (target instanceof PyDict) { if (!target.has(value)) throw MissingValue(`There is no entry for ${show(value)} to remove.`); target.delete(value); return; }