@mylasertools/kerfscript 0.5.0 → 0.7.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 +195 -1
- package/LANGUAGE.md +160 -30
- package/README.md +22 -5
- package/THIRD-PARTY-NOTICES.md +113 -0
- package/dist/analysis.d.cts +20 -0
- package/dist/analysis.d.ts +20 -0
- package/dist/assembly.d.cts +28 -1
- package/dist/assembly.d.ts +28 -1
- package/dist/ast.d.cts +9 -0
- package/dist/ast.d.ts +9 -0
- package/dist/cli.js +13060 -5013
- package/dist/diff.d.cts +18 -0
- package/dist/diff.d.ts +18 -0
- package/dist/evaluator.d.cts +34 -0
- package/dist/evaluator.d.ts +34 -0
- package/dist/functions.d.cts +1 -0
- package/dist/functions.d.ts +1 -0
- package/dist/geometry.d.cts +17 -0
- package/dist/geometry.d.ts +17 -0
- package/dist/hardware.d.cts +13 -0
- package/dist/hardware.d.ts +13 -0
- package/dist/highlight.cjs +2 -2
- package/dist/highlight.js +2 -2
- package/dist/import/index.d.cts +16 -0
- package/dist/import/index.d.ts +16 -0
- package/dist/import/shapes.d.cts +76 -0
- package/dist/import/shapes.d.ts +76 -0
- package/dist/import/svg.d.cts +48 -0
- package/dist/import/svg.d.ts +48 -0
- package/dist/import/xml.d.cts +12 -0
- package/dist/import/xml.d.ts +12 -0
- package/dist/index.cjs +1955 -32
- package/dist/index.d.cts +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +1955 -32
- package/dist/instructions.d.cts +3 -0
- package/dist/instructions.d.ts +3 -0
- package/dist/language.cjs +1899 -51
- package/dist/language.js +1899 -51
- package/dist/libraries.cjs +1874 -26
- package/dist/libraries.d.cts +3 -0
- package/dist/libraries.d.ts +3 -0
- package/dist/libraries.js +1874 -26
- package/dist/paths.d.cts +1 -1
- package/dist/paths.d.ts +1 -1
- package/dist/png.d.cts +9 -0
- package/dist/png.d.ts +9 -0
- package/dist/render.d.cts +22 -1
- package/dist/render.d.ts +22 -1
- package/dist/signatures.cjs +244 -11
- package/dist/signatures.js +244 -11
- package/dist/slots.d.cts +8 -0
- package/dist/slots.d.ts +8 -0
- package/dist/values.d.cts +6 -1
- package/dist/values.d.ts +6 -1
- package/dist/verify/command.d.cts +1 -0
- package/dist/verify/command.d.ts +1 -0
- package/dist/verify/geometry.d.cts +25 -0
- package/dist/verify/geometry.d.ts +25 -0
- package/dist/verify/index.d.cts +10 -0
- package/dist/verify/index.d.ts +10 -0
- package/dist/verify/joints.d.cts +7 -0
- package/dist/verify/joints.d.ts +7 -0
- package/dist/verify/mechanics.d.cts +11 -0
- package/dist/verify/mechanics.d.ts +11 -0
- package/dist/verify/motion.d.cts +8 -0
- package/dist/verify/motion.d.ts +8 -0
- package/dist/verify/pose.d.cts +5 -0
- package/dist/verify/pose.d.ts +5 -0
- package/dist/verify/relations.d.cts +8 -0
- package/dist/verify/relations.d.ts +8 -0
- package/dist/verify/snapshot.d.cts +11 -0
- package/dist/verify/snapshot.d.ts +11 -0
- package/dist/verify/solids.d.cts +39 -0
- package/dist/verify/solids.d.ts +39 -0
- package/dist/verify/spec.d.cts +9 -0
- package/dist/verify/spec.d.ts +9 -0
- package/dist/verify/summary.d.cts +17 -0
- package/dist/verify/summary.d.ts +17 -0
- package/dist/verify/types.d.cts +299 -0
- package/dist/verify/types.d.ts +299 -0
- package/docs/cli.md +96 -15
- package/docs/import.md +149 -0
- package/docs/javascript.md +88 -25
- package/docs/layers.md +42 -2
- package/docs/library/calibration.svg +1 -1
- package/docs/library/hanging.svg +1 -1
- package/docs/library/hinge.svg +1 -1
- package/docs/library.md +299 -3
- package/docs/mcp.md +88 -0
- package/docs/parts-and-sheets.md +186 -1
- package/docs/shared-libraries.md +8 -1
- package/docs/specification.md +78 -23
- package/docs/verification.md +363 -0
- package/docs/versions.md +2 -2
- package/package.json +3 -3
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
# Assembly verification
|
|
2
|
+
|
|
3
|
+
`kerf verify` checks declared requirements against the evaluated geometry of a
|
|
4
|
+
design: fit, retention, installation, support, stability and operating motion for
|
|
5
|
+
rigid sheet parts and cylindrical/box hardware. Each claim names its scope and
|
|
6
|
+
assumptions. Checks measure the evaluated geometry independently of the formulas
|
|
7
|
+
that generated it.
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
kerf verify model.kerf --spec model.verify.json -o report.json
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The specification is JSON data. The command never imports or executes a sibling
|
|
14
|
+
JavaScript file. Supported options are `--spec`, `-o`/`--out` and `--font`.
|
|
15
|
+
Parameters belong in each specification configuration. `kerf check --sweep`
|
|
16
|
+
remains available for ordinary warning/parameter sweeps.
|
|
17
|
+
|
|
18
|
+
## Reading the result
|
|
19
|
+
|
|
20
|
+
`--summary` also writes a triage to standard error: every claim that did not
|
|
21
|
+
pass, failures first, grouped by status and diagnostic code, each with its
|
|
22
|
+
configurations, the bodies involved and the first measurements. The report
|
|
23
|
+
and the exit code are unchanged; `triage()` and `triageText()` give the same
|
|
24
|
+
from JavaScript.
|
|
25
|
+
|
|
26
|
+
The command returns `{ "kind": "report", "report": ... }`, or `invalid-spec` /
|
|
27
|
+
`invalid-snapshot` with input issues. Each claim has a status, diagnostic code,
|
|
28
|
+
configuration, implicated part/hardware references, measurements, assumptions and
|
|
29
|
+
coverage. Exit codes are:
|
|
30
|
+
|
|
31
|
+
| Code | Meaning |
|
|
32
|
+
| ---- | ------------------------------------------------------------------------------- |
|
|
33
|
+
| 0 | Every required claim passed within its reported scope |
|
|
34
|
+
| 1 | A required claim or required design configuration failed |
|
|
35
|
+
| 2 | A required claim is unverified, input is invalid, or a report cannot be written |
|
|
36
|
+
|
|
37
|
+
A `pass` applies to the listed requirements and configurations. Reports also list
|
|
38
|
+
uncovered capabilities; a passing fit alone does not establish retention or motion.
|
|
39
|
+
`strength` currently returns `unverified`. Material capacity, adhesive strength,
|
|
40
|
+
friction, wear, torque, actual gear/cam driving contact and flexible-body dynamics
|
|
41
|
+
need separate evidence. Unsupported cases and exhausted checking budgets remain
|
|
42
|
+
unverified.
|
|
43
|
+
|
|
44
|
+
Missing cutting metadata, open cutting lines affecting rigid material, bends,
|
|
45
|
+
legacy `echo("hardware", ...)`, compiler warnings, exhausted budgets and numerical
|
|
46
|
+
boundary cases cannot produce a required geometric pass. Cases refused by the
|
|
47
|
+
renderer remain failed required configurations; they are not dropped from coverage.
|
|
48
|
+
|
|
49
|
+
## A glue contact specification
|
|
50
|
+
|
|
51
|
+
This example checks a patch's bottom face against a host's top face. Measurements
|
|
52
|
+
use millimetres and square millimetres, after all model scaling and placement.
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"schemaVersion": 1,
|
|
57
|
+
"model": "Mounted decoration",
|
|
58
|
+
"configurations": [{ "id": "default" }],
|
|
59
|
+
"claims": [
|
|
60
|
+
{
|
|
61
|
+
"id": "decoration-contact",
|
|
62
|
+
"kind": "glue-contact",
|
|
63
|
+
"a": { "part": "host" },
|
|
64
|
+
"b": { "part": "patch" },
|
|
65
|
+
"faceA": "top",
|
|
66
|
+
"faceB": "bottom",
|
|
67
|
+
"minimumArea": 110
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Parts bind by unique name and copy, with `copy` defaulting to 1. Hardware binds by
|
|
74
|
+
unique native `hardware(..., label = "shaft")` labels. A missing or ambiguous
|
|
75
|
+
reference is an input error. Array positions cannot identify hardware. Claim IDs
|
|
76
|
+
starting with `$` are reserved for verifier diagnostics.
|
|
77
|
+
|
|
78
|
+
Configurations may contain `params`; `kerf verify` refuses a name the model
|
|
79
|
+
does not assign (`unknown-parameter`, exit 2), so a typo cannot verify the
|
|
80
|
+
defaults instead. Claims may restrict their `configurations`
|
|
81
|
+
to a subset, and may set `required: false` for informational checks. At least one
|
|
82
|
+
claim must be required. Optional checks never hide a required failure.
|
|
83
|
+
|
|
84
|
+
A revolute `range` may span more than half a turn: a pose gives the hinge's
|
|
85
|
+
angle relative to the first configuration up to whole turns, and the check
|
|
86
|
+
accepts it when some whole turn of it lies in the range. Captured-shaft stops
|
|
87
|
+
pair with the bearings by their position along the shaft, in any order.
|
|
88
|
+
|
|
89
|
+
## Supported contracts
|
|
90
|
+
|
|
91
|
+
| Kind | Fields in addition to `id` and `kind` | What is measured |
|
|
92
|
+
| --------------------- | --------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
|
|
93
|
+
| `glue-contact` | `a`, `b`, `faceA`, `faceB`, `minimumArea` | Opposing coplanar nominal faces and overlap after subtracting holes |
|
|
94
|
+
| `tab-slot` | `tab`, `receiver`, `region: [x0,y0,x1,y1]`, `clearance: [min,max]`, `flushTolerance`, `minimumLigament` | Rectangular tongue, closed rectangular slot, both directional total clearances, side gaps, through engagement and remaining edge material |
|
|
95
|
+
| `captured-shaft` | `shaft`, two `bearings`, `stack`, two `stops`, `clearance`, `endplay`, `minimumOverlap`, `maximumStopGap` | Coaxial bore fit, bearing engagement, ordered axial stack, endplay and positive end capture |
|
|
96
|
+
| `material-assignment` | No extra fields | A stock profile exists for every sheet part and contains its design thickness |
|
|
97
|
+
| `cut-invariant` | At least two configurations | Actual local cut regions/lines, material, thickness, compensation and inventory stay fixed across the declared poses |
|
|
98
|
+
| `rigid-clearance` | `minimumGap`, optional `bodies` | Clearance between actual extruded cut regions and native hardware; defaults to the whole inventory |
|
|
99
|
+
| `retention` | `roots`, `links`, optional `removable` | Every permanent component has checked attachment geometry and installed fastening leading to a supported root |
|
|
100
|
+
| `assembly-access` | `initial`, `steps`, `minimumGap`, optional `scope`, `maxIntervals` | Continuous straight insertion and optional tool paths against already installed bodies |
|
|
101
|
+
| `assembly-support` | `plan`, `retention`, optional `holds` | Previously installed components remain retained or explicitly held at every step; final temporary holds are released |
|
|
102
|
+
| `stability` | `supports`, `loads`, `ground`, `gravity`, `minimumMargin`, optional `retention` | The declared gravity line lies within the actual ground contact support polygon |
|
|
103
|
+
| `joint-constraints` | `bodies`, `roots`, `joints`, `expectedDof` | Fixed/revolute/prismatic/gear pose constraints and constraint-Jacobian mobility at the declared configurations |
|
|
104
|
+
| `motion-clearance` | `from`, `to`, `moving`, `minimumGap`, optional `constraints`, `maxIntervals` | Continuous clearance for explicit rigid translations or rotations about fixed world axes |
|
|
105
|
+
|
|
106
|
+
`tab-slot.region` selects the tongue in the tab's own coordinates. It cannot be
|
|
107
|
+
an arbitrary crop out of a larger plate: at most one edge may continue into the
|
|
108
|
+
parent, along the insertion direction. Shapes outside this limited contract remain
|
|
109
|
+
unverified. A successful fit does not establish fastening or retention.
|
|
110
|
+
|
|
111
|
+
`captured-shaft` supports cylindrical hardware and circular polygon bores whose
|
|
112
|
+
panel normals follow the shaft direction. `stack` lists the spacers/rotors between
|
|
113
|
+
the two bearing faces. Each stop is a hardware reference with an `attachment`:
|
|
114
|
+
|
|
115
|
+
```json
|
|
116
|
+
{
|
|
117
|
+
"body": { "hardware": "nut" },
|
|
118
|
+
"attachment": {
|
|
119
|
+
"kind": "threaded",
|
|
120
|
+
"thread": { "hardware": "usable thread envelope" },
|
|
121
|
+
"minimumEngagement": 3,
|
|
122
|
+
"secured": true
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
The other supported attachment is `{ "kind": "integral" }`, for a head at the
|
|
128
|
+
shaft end. `{ "kind": "unknown" }` leaves fastening unverified. Integral purchase
|
|
129
|
+
construction and installation of matching threaded hardware are explicit
|
|
130
|
+
assumptions. A rendered collar alone does not prove fastening. Hardware dimensions
|
|
131
|
+
are nominal in this implementation; thread capacity, clamp force, resistance to
|
|
132
|
+
loosening remain separate properties. Check the rotor's full swept envelope with
|
|
133
|
+
`motion-clearance`.
|
|
134
|
+
|
|
135
|
+
Working synthetic examples are in `test/fixtures/verification/`, including a
|
|
136
|
+
captured-shaft specification, a fully contracted glue coupon, two material redesigns
|
|
137
|
+
and a slider path. These are geometric test fixtures, not rated fastening designs.
|
|
138
|
+
|
|
139
|
+
## Retention and installation
|
|
140
|
+
|
|
141
|
+
A retention root identifies a body whose support is assumed. Each link references
|
|
142
|
+
a passed geometric contract and states the fastening actually installed:
|
|
143
|
+
|
|
144
|
+
```json
|
|
145
|
+
{
|
|
146
|
+
"id": "attached",
|
|
147
|
+
"kind": "retention",
|
|
148
|
+
"roots": [{ "part": "host" }],
|
|
149
|
+
"links": [{ "claim": "decoration-contact", "fastening": "glued", "installed": true }]
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
`glued` means a cured fixed adhesive bond is assumed at measured glue contact.
|
|
154
|
+
`captured` uses a passed shaft-capture contract. A tab fitting a slot does not prove
|
|
155
|
+
a lock: labelling it `locked` leaves retention unverified. Every permanent native
|
|
156
|
+
part and hardware item must reach a root. Explicit `removable` items are excluded
|
|
157
|
+
from this claim and still need their own support case.
|
|
158
|
+
|
|
159
|
+
`assembly-access.initial` contains zero or one already supported body. Every other
|
|
160
|
+
scoped body must occur exactly once in `steps`. Each step has `id`, `part`,
|
|
161
|
+
`from: [dx,dy,dz]` (the starting displacement from its final pose) and `held: true`
|
|
162
|
+
for the operator or fixture holding the incoming part. The checker moves it in a
|
|
163
|
+
straight line to its final position, testing all already installed bodies. A gap
|
|
164
|
+
of zero allows nonpenetrating terminal contact; no whole body collision exemptions
|
|
165
|
+
are applied. Rotation/flex insertion and automatic assembly planning are unsupported.
|
|
166
|
+
|
|
167
|
+
Optional `tool: {from, to, diameter, travel}` describes a cylindrical tool at the
|
|
168
|
+
working position and its starting displacement `travel`. Its approach is checked
|
|
169
|
+
after the incoming body is installed, including against that body. The envelope
|
|
170
|
+
must describe the tool's free space accurately.
|
|
171
|
+
|
|
172
|
+
`assembly-support.plan` references the access claim, and `retention` references the
|
|
173
|
+
final retention claim. Each installation step can name geometric contract IDs in
|
|
174
|
+
`fasten`; those connections become effective only after all their bodies are
|
|
175
|
+
installed. Optional `holds: [{step, bodies}]` declare temporary support at each
|
|
176
|
+
step boundary. Incoming `held: true` covers insertion only. Earlier loose bodies
|
|
177
|
+
must also be held until fastening, and the final assembly must stand without
|
|
178
|
+
temporary holds. Adhesive installation/cure timing remains an explicit assumption.
|
|
179
|
+
|
|
180
|
+
For `stability`, list a positive `mass` for every body in `loads`, with optional
|
|
181
|
+
local `center: [x,y,z]`. Otherwise the checker uses a uniform sheet or hardware
|
|
182
|
+
centroid, subtracting holes. List the bodies touching the horizontal `ground`
|
|
183
|
+
plane in `supports`; `gravity` is a downward world vector. Multiple loads require
|
|
184
|
+
a passed retention claim covering every load. The checker rejects ground penetration
|
|
185
|
+
and measures the gravity-line margin within the convex hull of actual contacts.
|
|
186
|
+
Sliding resistance, impact and structural capacity are separate properties.
|
|
187
|
+
|
|
188
|
+
## Mechanisms and continuous motion
|
|
189
|
+
|
|
190
|
+
`joint-constraints` declares ideal connections between body references `a` and `b`:
|
|
191
|
+
|
|
192
|
+
| Joint | Additional fields |
|
|
193
|
+
| ----------- | ------------------------------------------------------------------------------------------------------------------------ |
|
|
194
|
+
| `fixed` | No extra fields; relative transform must match the first declared configuration |
|
|
195
|
+
| `revolute` | Local `anchorA`, `anchorB`, `axisA`, `axisB`; optional `range: [min,max]` in degrees relative to the first configuration |
|
|
196
|
+
| `prismatic` | Local `axisA`, `travel: [min,max]` relative to the first configuration |
|
|
197
|
+
| `gear` | Local `axisA`, `axisB`, positive `ratio`; angles satisfy `angleB + ratio * angleA = 0` |
|
|
198
|
+
|
|
199
|
+
Roots stay fixed. The constraint Jacobian establishes the number of independent
|
|
200
|
+
instantaneous degrees of freedom for at most 64 scoped bodies. Unintended free
|
|
201
|
+
bodies, separated anchors, wrong guide motion and conflicting mobility fail.
|
|
202
|
+
Redundant constraint rows are reported; singular ranks remain unverified. Gear
|
|
203
|
+
pose deltas use the principal quarter-turn branch; add intermediate configurations
|
|
204
|
+
for larger pose changes. The ideal joints do not establish physical bearings,
|
|
205
|
+
retainers or driving tooth contact.
|
|
206
|
+
|
|
207
|
+
Native `glue` and `stack` relationships add fixed constraints after contact checks.
|
|
208
|
+
Installed measured adhesive links also add fixed constraints. A glued decoration
|
|
209
|
+
cannot become a rotor simply because an animation turns it.
|
|
210
|
+
|
|
211
|
+
Motion uses one analytic world-space trajectory per moving body. Every unlisted
|
|
212
|
+
body stays fixed. For example:
|
|
213
|
+
|
|
214
|
+
```json
|
|
215
|
+
{
|
|
216
|
+
"id": "turn",
|
|
217
|
+
"kind": "motion-clearance",
|
|
218
|
+
"from": "closed",
|
|
219
|
+
"to": "open",
|
|
220
|
+
"constraints": "hinge",
|
|
221
|
+
"moving": [
|
|
222
|
+
{
|
|
223
|
+
"body": { "part": "arm" },
|
|
224
|
+
"trajectory": { "kind": "rotate", "origin": [0, 0, 0], "axis": [0, 0, 1], "angle": 45 }
|
|
225
|
+
}
|
|
226
|
+
],
|
|
227
|
+
"minimumGap": 0.2
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
The other trajectory is `{ "kind": "translate", "by": [dx,dy,dz] }`. All controls
|
|
232
|
+
share phase 0 to 1. The destination must match the rendered endpoint, cut geometry
|
|
233
|
+
and inventory must stay fixed, and installed bonds must move together. With
|
|
234
|
+
`constraints`, both endpoints must pass that joint claim and the analytic path must
|
|
235
|
+
obey its supported joint tree, travel stops and gear rates. General closed linkages
|
|
236
|
+
and composed moving-axis constraints remain unverified.
|
|
237
|
+
|
|
238
|
+
Continuous clearance uses convex material decomposition preserving holes, exact
|
|
239
|
+
box envelopes, and inner/outer cylindrical bounds. Separating-axis bounds and
|
|
240
|
+
adaptive interval subdivision include all intermediate poses through a conservative
|
|
241
|
+
displacement bound. Approximation boundaries, unresolved contacts and exhausted
|
|
242
|
+
budgets return `unverified`. The report records a failing phase when available.
|
|
243
|
+
This proves the authored analytic path; arbitrary parameter expressions between
|
|
244
|
+
rendered poses do not acquire a continuous guarantee. Add a separate static
|
|
245
|
+
clearance claim to cover pairs that stay fixed throughout the path.
|
|
246
|
+
|
|
247
|
+
## Material profiles and frozen cuts
|
|
248
|
+
|
|
249
|
+
Optional `materials` map the evaluated material names to measured stock profiles:
|
|
250
|
+
|
|
251
|
+
```json
|
|
252
|
+
{
|
|
253
|
+
"plywood": {
|
|
254
|
+
"thickness": [2.9, 3.1],
|
|
255
|
+
"kerf": [0.12, 0.18],
|
|
256
|
+
"edgeError": 0.02,
|
|
257
|
+
"lot": "measured sheet A"
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
`thickness` and `kerf` are actual manufacturing intervals. `edgeError` is an
|
|
263
|
+
additional nonnegative uncertainty per cut edge. The snapshot records the design's
|
|
264
|
+
compensation kerf separately. Profiles do not redraw a slot for each possible
|
|
265
|
+
actual thickness. Larger actual kerf enlarges an internal opening and shrinks an
|
|
266
|
+
external tongue relative to its compensated design.
|
|
267
|
+
|
|
268
|
+
Tab/slot checks bound dimensional fit at the captured placements. The receiving
|
|
269
|
+
panel's actual maximum thickness also controls shoulder interference and through
|
|
270
|
+
engagement. Shaft stack checks bound endplay with fixed bearing locations; varying
|
|
271
|
+
bearing thickness changes retainer seating and currently makes capture unverified.
|
|
272
|
+
Profiles do not provide general tolerance propagation through an arbitrary mechanism.
|
|
273
|
+
Glue-contact claims remain nominal geometric claims even when profiles are present.
|
|
274
|
+
|
|
275
|
+
A redesign for a different stock size is a separate configuration, producing a new
|
|
276
|
+
set of cuts. Global `materials` profiles apply by default. Each configuration may
|
|
277
|
+
override them with its own `materials` map, so 3 mm and 4 mm redesigns can have
|
|
278
|
+
different measured lots. Choose supported configurations deliberately; finite
|
|
279
|
+
configurations and pose samples do not prove a continuous parameter range. Apply
|
|
280
|
+
`cut-invariant` only to operating poses within one manufactured design, not across
|
|
281
|
+
intentional stock redesigns. Continuous clearance and static stability currently
|
|
282
|
+
use nominal geometry; profile intervals apply to the supported fit/stack checks.
|
|
283
|
+
|
|
284
|
+
## JavaScript API
|
|
285
|
+
|
|
286
|
+
```js
|
|
287
|
+
import {
|
|
288
|
+
render,
|
|
289
|
+
snapshotFromRender,
|
|
290
|
+
verify,
|
|
291
|
+
verificationIsCurrent,
|
|
292
|
+
} from '@mylasertools/kerfscript';
|
|
293
|
+
|
|
294
|
+
const rendered = render(source, { params, analysis: true });
|
|
295
|
+
const snapshot = snapshotFromRender(rendered, {
|
|
296
|
+
configuration: 'default',
|
|
297
|
+
params,
|
|
298
|
+
provenance: {
|
|
299
|
+
sourceHash,
|
|
300
|
+
engineHash, // SHA-256 of exact source and loaded runtime artifact
|
|
301
|
+
dependencies: {}, // logical source names -> SHA-256 of resolved bytes
|
|
302
|
+
fonts: {}, // font names -> SHA-256 of actual font bytes
|
|
303
|
+
},
|
|
304
|
+
});
|
|
305
|
+
const result = verify(specification, [snapshot]);
|
|
306
|
+
if (result.kind === 'report') {
|
|
307
|
+
const current = verificationIsCurrent(result.report, specification, [snapshot]);
|
|
308
|
+
}
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
The application supplies actual fingerprints; the portable core performs no file
|
|
312
|
+
access or hashing. Missing provenance makes the overall result unverified. The CLI
|
|
313
|
+
records source, loaded engine artifact, resolved external dependencies and fonts
|
|
314
|
+
itself. Reports retain exact parameters and the resolved specification, so a cached
|
|
315
|
+
result can be checked against changed inputs. A package version alone cannot identify
|
|
316
|
+
an edited checkout. Before reusing an archived report, capture current fingerprints
|
|
317
|
+
and call `verificationIsCurrent(report, specification, snapshots)`. Source, runtime,
|
|
318
|
+
dependency, font, parameter, render-setting or requirement/profile changes make it
|
|
319
|
+
stale. This checks supplied fingerprints; applications must hash actual input bytes.
|
|
320
|
+
|
|
321
|
+
`analysis: true` captures nominal cut regions and cut lines before toolpath kerf
|
|
322
|
+
compensation. It is opt-in and does not affect cutting output. The snapshot copies
|
|
323
|
+
and freezes the geometry; later mutations of a render result cannot change it.
|
|
324
|
+
Without analysis, unavailable cut lines remain `null`, distinct from a known empty
|
|
325
|
+
list. Verification never reconstructs authoritative cuts from the viewer's marks.
|
|
326
|
+
|
|
327
|
+
`verify(spec, snapshots, limits)` accepts `maxPoints` (default 200000), `maxClaims`
|
|
328
|
+
(1000), `maxConfigurations` (100) and `maxOperations` (2000000). Motion/access claims
|
|
329
|
+
may set `maxIntervals` from 1 to 10000 (default 1000). The command also bounds cases
|
|
330
|
+
before rendering.
|
|
331
|
+
The point budget includes the cylindrical/box hardware envelopes used by the checker.
|
|
332
|
+
Coordinate limits are 1000000 mm in local cut geometry and 10000000 mm for placement
|
|
333
|
+
translations. Linear acceptance predicates use a 0.001 mm uncertainty band; glue
|
|
334
|
+
area uncertainty scales with boundary length. Near-boundary results are unverified.
|
|
335
|
+
Zero-gap nonpenetrating terminal contact is supported for straight insertions and
|
|
336
|
+
fixed relative envelopes. Geometry invariance compares normalized exact coordinates, not bounding dimensions
|
|
337
|
+
or rounded cut lengths. The verification API is available in the JavaScript build;
|
|
338
|
+
the WASI JSON command surface has not yet gained a `verify` operation.
|
|
339
|
+
|
|
340
|
+
## Previewing findings
|
|
341
|
+
|
|
342
|
+
The site's assembly viewer exposes `view.verification(report, configuration)`.
|
|
343
|
+
It lists failures/unverified claims and highlights implicated part copies and
|
|
344
|
+
hardware. `createAssemblyView(element, {onVerificationSelect(finding) { ... }})`
|
|
345
|
+
lets the host select a configuration or a reported failing `measurements.phase`.
|
|
346
|
+
Installation findings also identify `assemblyStep`.
|
|
347
|
+
Every `show()` clears previous diagnostics; the host should check report freshness
|
|
348
|
+
before attaching a report to new inputs. The viewer does not display a global
|
|
349
|
+
certification badge.
|
|
350
|
+
|
|
351
|
+
`poseAssembly(rendered, moving, phase)` returns a render result with the exact
|
|
352
|
+
analytic motion applied to its assembly and hardware. It preserves the original
|
|
353
|
+
render result and cut files, so a diagnostic preview can show the same path that
|
|
354
|
+
was checked. It changes the preview pose only; rerender and recapture the source
|
|
355
|
+
to verify a new manufacturing configuration.
|
|
356
|
+
|
|
357
|
+
Run the public paired fixtures after building:
|
|
358
|
+
|
|
359
|
+
```sh
|
|
360
|
+
npm run build
|
|
361
|
+
npm run verify:fixtures
|
|
362
|
+
node scripts/verify-models.mjs path/to/contracts path/to/reports
|
|
363
|
+
```
|
package/docs/versions.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Versions
|
|
2
2
|
|
|
3
|
-
KerfScript 0.
|
|
3
|
+
KerfScript 0.7.0 implements language version 0.3. The package version tracks
|
|
4
4
|
the software release; the language version tracks the syntax and behavior
|
|
5
5
|
of `.kerf` programs.
|
|
6
6
|
|
|
@@ -30,4 +30,4 @@ files used with a design. Applications that store designs should retain
|
|
|
30
30
|
that information and compare the output before upgrading the interpreter.
|
|
31
31
|
|
|
32
32
|
Pin the npm package to an exact version when your application needs a fixed
|
|
33
|
-
renderer, for example `@mylasertools/kerfscript@0.
|
|
33
|
+
renderer, for example `@mylasertools/kerfscript@0.7.0`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mylasertools/kerfscript",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "KerfScript: a programming language and library for laser-cutting generators. Write parametric 2D parts with cut, score and engrave layers, kerf compensation and joinery, then turn settings into SVG or DXF cut files from Node.js, the browser, the command line or WebAssembly.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "AGPL-3.0-only",
|
|
@@ -113,6 +113,7 @@
|
|
|
113
113
|
"scripts": {
|
|
114
114
|
"build": "node scripts/stdlib.mjs && tsc -p tsconfig.json && node scripts/build.mjs",
|
|
115
115
|
"test": "node --test \"test/**/*.test.mjs\"",
|
|
116
|
+
"verify:fixtures": "node scripts/verify-models.mjs",
|
|
116
117
|
"snapshots": "npm run build && node scripts/snapshots.mjs",
|
|
117
118
|
"check": "npm run build && npm test",
|
|
118
119
|
"examples": "node scripts/examples.mjs",
|
|
@@ -122,8 +123,7 @@
|
|
|
122
123
|
"format": "prettier --write . --ignore-path .gitignore --ignore-path .prettierignore --ignore-path .git/info/exclude",
|
|
123
124
|
"format:check": "prettier --check . --ignore-path .gitignore --ignore-path .prettierignore --ignore-path .git/info/exclude",
|
|
124
125
|
"compat": "node scripts/compat.mjs",
|
|
125
|
-
"wasm": "node scripts/wasm.mjs"
|
|
126
|
-
"readme-images": "npm run build && cd site && node ../scripts/readme-images.mjs"
|
|
126
|
+
"wasm": "node scripts/wasm.mjs"
|
|
127
127
|
},
|
|
128
128
|
"devDependencies": {
|
|
129
129
|
"@types/node": "20.19.43",
|