@rulecad/cad 0.9.0 → 0.10.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 (53) hide show
  1. package/AGENTS.md +21 -6
  2. package/CHANGELOG.md +320 -0
  3. package/EXAMPLES.md +22 -17
  4. package/README.md +192 -40
  5. package/bin/cad.mjs +465 -80
  6. package/lib/assembly.mjs +68 -33
  7. package/lib/cache-file.mjs +105 -0
  8. package/lib/code-text.mjs +28 -0
  9. package/lib/design-imports.mjs +127 -0
  10. package/lib/design.mjs +251 -55
  11. package/lib/designshapes.mjs +142 -0
  12. package/lib/edit.mjs +24 -2
  13. package/lib/estimates.mjs +51 -0
  14. package/lib/fasten.mjs +11 -5
  15. package/lib/fe-key.mjs +29 -0
  16. package/lib/fittings.mjs +20 -15
  17. package/lib/fixings.mjs +17 -4
  18. package/lib/framebuild.mjs +1 -1
  19. package/lib/framegen.mjs +9 -1
  20. package/lib/frames.mjs +6 -2
  21. package/lib/framesize.mjs +8 -81
  22. package/lib/host.mjs +7 -3
  23. package/lib/kit.mjs +5 -5
  24. package/lib/list.mjs +29 -21
  25. package/lib/loads.mjs +35 -23
  26. package/lib/measured.mjs +738 -98
  27. package/lib/motors.mjs +9 -29
  28. package/lib/names.mjs +15 -0
  29. package/lib/optimise.mjs +34 -25
  30. package/lib/order.mjs +4 -10
  31. package/lib/parts.mjs +3 -0
  32. package/lib/rules.mjs +2 -1
  33. package/lib/sandbox-hooks.mjs +109 -15
  34. package/lib/sandbox-lock.mjs +225 -0
  35. package/lib/sandbox-preload.mjs +2 -2
  36. package/lib/sandbox-run.mjs +22 -24
  37. package/lib/sandbox.mjs +173 -30
  38. package/lib/sheet.mjs +114 -3
  39. package/lib/versions.mjs +195 -32
  40. package/lib/workspace.mjs +3 -2
  41. package/package.json +11 -11
  42. package/schemas/assembly.schema.json +1 -1
  43. package/schemas/project.schema.json +6 -0
  44. package/templates/coupons/MEASURE.md +109 -0
  45. package/templates/coupons/assemblies/fixings-test.json +20 -0
  46. package/templates/coupons/assemblies/slot-test.json +11 -0
  47. package/templates/coupons/objects/fixings-coupon.js +88 -0
  48. package/templates/coupons/objects/fixings-coupon.json +26 -0
  49. package/templates/coupons/objects/holds-coupon.js +130 -0
  50. package/templates/coupons/objects/holds-coupon.json +42 -0
  51. package/templates/coupons/objects/slot-coupon.js +89 -0
  52. package/templates/coupons/objects/slot-coupon.json +29 -0
  53. package/templates/coupons/project.json +10 -0
package/AGENTS.md CHANGED
@@ -8,7 +8,10 @@ variable says which rule it comes from. Follow these steps; they're what makes a
8
8
  1. **Rules first.** Find the facts the part depends on: standards, the thing it fits, the printer. Put shared ones in
9
9
  `rules/<set>.json` with `kind`, `source` and `checked`. Research them, don't guess. Ask the person to measure what
10
10
  can't be looked up, and record it as `"kind": "measured"`; something nobody has published goes in as
11
- `"kind": "estimate"`, and the check will flag it.
11
+ `"kind": "estimate"`, and the check will flag it. A set from the kit is copied into `rules/` the first time a design
12
+ uses it; when `npx cad rules check` notes `rules.changed` or `rules.new` (the kit has corrected or added figures
13
+ since), run `npx cad rules update <set>`: it takes the kit's figures and keeps the measured ones. Say in your report
14
+ which figures moved, and check the designs that use them.
12
15
  2. `npx cad new <project>/<object>`, then write the variables in the .json and the shape in the .js. No numbers in
13
16
  the .js other than 0, 1 and 2: `cad check` fails on any other.
14
17
  3. `npx cad check`, then `npx cad preview`, and **look at the preview image** before saying it's done. Check the views
@@ -39,6 +42,16 @@ variable says which rule it comes from. Follow these steps; they're what makes a
39
42
  ## Changing a design
40
43
  1. `npx cad history <project>/<object>` first: read the print log. A failed print is the reason for most changes:
41
44
  fix the rule or variable it points at (a measured fit beats a community rule).
45
+ A figure the person measured goes back with `npx cad measured <project>/<assembly> <name>=<value>`: report what it
46
+ says moved. `--table` (`--json`) lists what is still unmeasured and the coupon that measures each. A figure of the
47
+ other sign, or under half or over twice the old one (a tenth to ten times for an estimate; 0 passes for a figure a
48
+ kit coupon measures), is refused as a likely slip: ask the person to measure again, and add `--force` only once
49
+ they confirm it. `--strike <date> <name>` takes a mistaken row out of the ledger; set the rule file it names back
50
+ too. The kit's coupons (test prints that settle the printer's holes, nuts, pins and slot fits) come into the
51
+ workspace with `npx cad coupons`, as `projects/coupons` with a MEASURE.md that says how to read each. A coupon's
52
+ figure needs no assembly: `npx cad measured x1c.pilot_m3=<value>`, and `npx cad history` lists those.
53
+ `npx cad measured --export` prints what was measured as a diff of the kit's rule sets: offer it to the person to
54
+ send to the kit, with the printer and plastic.
42
55
  2. Change, then check, preview and look, as for a new part. Change values with `npx cad set <project>/<object>
43
56
  name=value` and assemblies with `npx cad add fit|joint|item|beam|pose|fasten|join|guide|load …`, `npx cad set
44
57
  <project>/<assembly> x1.at=… joins.0.kind=…`, `npx cad move` and `npx cad remove`: they keep the file's layout and
@@ -73,9 +86,9 @@ variable says which rule it comes from. Follow these steps; they're what makes a
73
86
  - Use the print-aware features in `v.shapes` before drawing your own: `teardropHole`, `crushRibs`, `wallOpening`
74
87
  print without supports as drawn (and `countersink` and `nutPocket` for a size that is no screw's). Use `v.ops.union/subtract/intersect` for booleans: the
75
88
  workspace can switch them to Manifold (faster, watertight) without touching the design.
76
- - Designs run sandboxed: they may import only `@jscad/modeling`, `@rulecad/shapes`, `@rulecad/flexures`,
77
- `@rulecad/gears`, `@rulecad/motors`, `@rulecad/fixings` and files in their project, and can't write files or start
78
- programs. To see a value while designing, `console.log` it: it comes
89
+ - Designs run sandboxed: they may import only <!-- ALLOWED -->`@jscad/modeling`, `@rulecad/shapes`,
90
+ `@rulecad/flexures`, `@rulecad/gears`, `@rulecad/motors`, `@rulecad/frames`, `@rulecad/fixings`<!-- /ALLOWED --> and
91
+ files in their project, and can't write files or start programs. To see a value while designing, `console.log` it: it comes
79
92
  out with the command's output. A misspelt `v.name` stops the build and says which name was meant.
80
93
  A design may run for an hour (3600 s) and hold 4096 MB: `design.time` or `design.memory` means it was stopped
81
94
  there, most often by a loop that never ends. Fix the loop; raise `designTimeout` or `designMemory` in
@@ -161,8 +174,10 @@ variable says which rule it comes from. Follow these steps; they're what makes a
161
174
  estimate).
162
175
  - **A frame for a size starts from a generator**: `"frame": { "kind": "box", "inside": [w, d, h], "profile",
163
176
  "join": "blind" }` (also portal, table, gantry, shelf) expands into beams, joins, feet and caps before anything is
164
- checked. Ask by `inside` for what it must enclose, `outside` for what it must fit in; never work the lengths out by
165
- hand. Make it with `npx cad new <project>/<assembly> --assembly --frame box --inside 300,300,350 --profile …
177
+ checked. Ask by `inside` for what it must enclose, `outside` for what it must fit in (its feet and end caps with
178
+ it); never work the lengths out by hand. A join the kit cannot build yet (cube; bracket, gusset, hidden or anchor
179
+ with no fitting) is refused unless it says `"estimate": true`. Make it with
180
+ `npx cad new <project>/<assembly> --assembly --frame box --inside 300,300,350 --profile …
166
181
  --join blind`, which says what it expands into before it writes. Read `frame.generated` for what it made, and
167
182
  `npx cad frame <project>/<assembly> --expand` to write it out when it needs changes a generator cannot make, then
168
183
  change the beams and joins with `cad set`, `cad move`, `cad add` and `cad remove` as a hand-drawn frame's.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,326 @@ print (a hole's diameter, a seat's depth, a part's outline). Each release lists
5
5
  its reason. A **fasten** is an entry in an assembly's `"fasten"` list: one screwed joint, naming the screw by thread
6
6
  and head, the parts it passes through and the part it ends in.
7
7
 
8
+ ## 0.10.0: a build follows the files its design imports; slow caches follow their code and libraries, not their comments; the cache is written whole, and only inside the workspace; cad coupons puts the kit's coupons in your workspace, cad measured takes a coupon's figure with no assembly, and --export sends what you measured to the kit; cut lists name each bar's material where a profile comes in more than one, and short ones may buy less; cad fasten's seat check reads the head's bearing face; clip and link stresses follow every edit; the README says snap_clearance is measured; cad measured lists what truly moved, refuses slips, strikes a ledger row, and tables every unsettled figure; releases work below the git root, recover from a failed commit, and keep cad set working; releases record and rebuild from everything a design reads; a corrected kit rule is offered to workspaces holding an older copy; the sandbox's documents say what a design can do on each Node, and cad warns where the network is open; a design can no longer reach Node's own modules through the CommonJS loader (security); object checks report every estimate, shaft seats included, and a reference's holes get no hole compensation; cad applies --set to assemblies, reads the project's printer for minutes, and keeps text as typed
9
+
10
+ ### Fixed
11
+
12
+ - A design may import files of its own project (the starter template's `lid.js` imports `./box.js`), but the build
13
+ cache knew only the design's own file: after a helper was edited, `cad check`, `cad export` and every other command
14
+ used the part as it was before, from `.cache/builds/`, without a word, until that folder was deleted by hand. A kept
15
+ build now lists the files of the project its design imported (and the files those import), with a hash of each, and
16
+ is used only while each reads the same; an edit to any of them rebuilds the design. A design run in the tool's own
17
+ process (a trusted workspace) is loaded afresh when one of its helpers changes, where a program that keeps running
18
+ and builds again (one using the library, an editor's server say) used to keep the helper as it first read.
19
+ `build()` now returns `imports`: those files, as paths inside the workspace.
20
+ - A trusted design that imports a file the tool cannot read as one of the workspace's (a file outside the workspace,
21
+ or one reached through a link that leads out of it) is built afresh each time rather than kept, so it is never
22
+ served stale.
23
+
24
+ For someone upgrading: the first build of each design after the upgrade is made afresh (the cache's format moved on),
25
+ and designs that share a helper rebuild after it is edited. No printed size moves, except where a part was stale.
26
+
27
+ - A lamina's slow stages (its physics, the flood's probe, its frame's finite elements, kept in `.cache/stages`) were
28
+ kept by the code of `@rulecad/flexures` and `@rulecad/fea` only. An upgrade of manifold-3d or `@jscad/modeling`, or
29
+ a change to `@rulecad/fixings` or `@rulecad/gears`, which flexures calls, read results the old code had made. They
30
+ are now kept by those packages' code too (and `@rulecad/shapes`, which fixings calls), and by the installed versions
31
+ of manifold-3d and `@jscad/modeling`.
32
+ - An optimisation's densities (`.cache/densities`) were kept by topopt's code down to its "shapes from results" line,
33
+ but the virtual temperature, which decides every result with `voids: 'prevented'`, was below that line, so a change
34
+ to it kept the old densities. It is now above the line (in `@rulecad/topopt`), and a test holds every function the
35
+ solver calls above it.
36
+ - The same key was a hash of the code with its comments, so rewording a comment threw away minutes of solving. The
37
+ code is now hashed without its comment lines and blank lines (`lib/code-text.mjs`): a comment edit keeps the
38
+ densities, and any change to the code optimises again.
39
+ - A printed fitting's finite-element results (`.cache/fitting`) are kept by all of `@rulecad/fea`'s code as well as
40
+ by `@rulecad/frames`' own key, which now carries a hash of its code in place of a number written by hand.
41
+
42
+ For someone upgrading: the first build of a lamina, the first optimisation of each problem and the first check of
43
+ each printed fitting work their results out again, once, so they are slower. No printed size moves.
44
+
45
+ - Only the build, stage and route caches checked that a file of the workspace's `.cache/` folder really lay inside the
46
+ workspace before writing it. The rest (the remembered overlaps, the gears' contact, the finite elements' results for
47
+ fittings, clips, links and motor mounts, assembly orders, optimised shapes and their densities, recorded runs,
48
+ `links.json` and the links files, the record of `AGENTS.md`) were written through whatever was there: a workspace
49
+ cloned from someone else with `.cache/overlaps.json` as a link to a file elsewhere on your computer had that file
50
+ overwritten by the first `cad check` that found an overlap. Every cache file is now written only where it, and each
51
+ folder on its way down from the workspace, is a plain file and plain folders; where one is a link the result is
52
+ simply not kept (that work is done again next time). `cad link` prints the links where it can't keep them in
53
+ `.cache/links/`.
54
+ - A cache file was written in place, so a run stopped part way through (Ctrl-C, a time limit, a full disc) left it cut
55
+ short, and every later build of that part failed with "Unexpected end of JSON input" until the file was found and
56
+ deleted by hand. Each is now written to a new file beside it and renamed over it, so it is there whole or not at
57
+ all; and a kept file that does not read as JSON is counted as not kept, removed, and made again.
58
+
59
+ For someone upgrading: nothing to do. A workspace whose `.cache/` holds a file cut short by an earlier version mends
60
+ itself on the next run. Each optimised problem (`cad optimise`) is worked out once again after the upgrade, as the code
61
+ that reads and keeps its results is part of what its densities are kept by. No printed size moves.
62
+
63
+ - Where a frame has one profile in two materials (an aluminium and a steel tube of one section), `@rulecad/frames` now
64
+ lists their bars apart. The buy list, the build page and the frame's build steps name each by its profile and
65
+ material, so the two lines can be told apart.
66
+
67
+ - `cad check`'s `fasten.seat` pressure under a head takes the ring out to the head's bearing face (dw, from its
68
+ thread's rule set) that `@rulecad/fixings`' `seating` reads, not its outline or flats. A metric cap, button or hexagon
69
+ head's seat now takes 25 to 55% less, so the most it may be tightened to falls and some seats that passed warn.
70
+ The shelf in EXAMPLES.md's chapter on fixings now tightens its M3 cap screws to 0.12 N m, where it was 0.16.
71
+
72
+ Upgrading: re-check designs whose screws sit on printed seats near their limit. No printed size moves.
73
+
74
+ - `cad check` keeps the finite-element results for a joint's printed clips and for a bent link in `.cache`, as they
75
+ are slow to work out. They were kept under the part's number of triangles and its first one or four triangles, and
76
+ left out the material's Poisson's ratio, so a clip edited without changing those (a thinner neck, a taller tip) was
77
+ given the old clip's stress: a clip made four times thinner kept its pass, where worked out afresh it fails. Each
78
+ result is now kept under a hash of every triangle of the part, the material (stiffness and Poisson's ratio), the
79
+ loads, the cell size and a version, as a motor mount's already was; the three share one way of naming them
80
+ (`lib/fe-key.mjs`).
81
+
82
+ For someone upgrading: the first `cad check` after the upgrade works out each clip, link and motor mount again, once,
83
+ so it is slower. A clip or link that passed from a stale result may now fail or warn; that is its real margin. No
84
+ printed size moves.
85
+
86
+ - `cad measured` paired the findings before and after a measurement by their code and every one of their refs, and a
87
+ fasten's list of screws comes out in another order once its holes change size. On the starter template,
88
+ `cad measured home/lidded-box x1c.hole_comp=0.15` said "nothing the checks say has moved" while the lid's hole had
89
+ gone from 3.5 to 3.55 mm; and where several findings shared a code (a fasten's hole and its slot), one was compared
90
+ with another, so the joint rig's drop listed seven findings that had not moved. Findings are now paired by their code
91
+ and what they are about (the fasten, the fit's two parts, the join, the beam, one screw of several), in the order
92
+ the checks give them.
93
+ - An empty figure (`x1c.fit=`) was written as 0 mm, measured. It is refused.
94
+
95
+ - In a workspace in a folder below its git repository's root (as `examples/bench` is), every release command after
96
+ the first (`cad status`, `history`, `diff`, `link --md`, `release --dry-run`, `export <ref>@<version>`) failed with
97
+ git's "exists, but not" error, because a release's files were read from the repository's root. They are now read
98
+ from the workspace. The check that stops a release past uncommitted shared code (`lib/`, `bin/`) now works there
99
+ too: it never saw those files before.
100
+ - A release whose commit or tag git refused (a pre-commit hook that fails, a tag that can't be signed) left the bumped
101
+ version and changelog entry behind, and running it again wrote the changelog entry twice. Now the version, the
102
+ changelog, what was staged and any commit already made are put back as they were, and the message says, in plain
103
+ words, that nothing was released and what git said. A changelog entry for the same name and version that was
104
+ never committed (left by such a release) is replaced, never repeated; a committed one (an object named as its
105
+ project, released at the same version as the project) is kept.
106
+ - After `cad release <project>` (or `--all`), `cad set <project>` was refused for ever ("version: not allowed here"):
107
+ the release wrote `version` and `release` into `project.json`, which the project schema did not allow. The schema
108
+ now has both fields, and the release writes them into the file as it is laid out, changing nothing else. `cad set
109
+ <project>` leaves them to `cad release` and says so.
110
+ - On Windows (where git writes files with Windows line endings), every design showed as "changed since" its last
111
+ release straight after it was released, and a project release refused to go ahead ("has changes since"): the
112
+ design's code was compared with the release's line by line, endings included. Line endings are no longer counted
113
+ as a change.
114
+
115
+ - A release could not be rebuilt when its design imports a file of its project: after `cad release home/lid` in the
116
+ starter template, `cad check home/lid@0.1.0` (and export, diff and status) failed with "Cannot find module
117
+ .../box.js". A release's folder in `.versions/` now holds its files at the paths they have in the workspace, with the
118
+ files its code imports, so it builds as it did.
119
+ - A release was rebuilt with today's rule sets: `loadRuleSet(name, dir)` read the workspace's copy whatever folder it
120
+ was given, so `cad values home/box@0.1.0` gave the wall from a line width measured since, and `cad diff` and
121
+ `cad status` never saw a rule change. A release now reads its own rule sets, as its tag holds them, for its "uses",
122
+ for `v.fixings` and for `v.frames`, and the project's material and printer as they were.
123
+ - A changed helper, thread set or object read through "uses" left a released part "up to date". `cad status`,
124
+ `cad diff` and `cad release` now compare every file the release read besides the design's own: an edit to one is a
125
+ patch (`projects/home/objects/box.js changed`, `rules/m3.json changed`, `now reads rules/m3.json`), and an object
126
+ read through "uses" is rebuilt for the release as its tag holds it, so a box released wider since asks the lid for a
127
+ release. A design drawn with `v.fixings` reads every rule set in `rules/` (any of them may hold its threads or
128
+ material) and the project's material and printer, so an edit to any of those asks for its release too.
129
+
130
+ - Security: a CommonJS file in a design's project (a `.cjs` file, or a `.js` file Node reads as CommonJS) could load
131
+ Node's own modules past the sandbox's import hook, through `module.constructor._load` or `require.cache`, on every
132
+ Node: it could read every file of the workspace and, before Node 25, send what it read over the network. A design
133
+ added to your workspace from elsewhere could have read your other designs and sent them away when you ran
134
+ `cad check`. Now:
135
+ - No CommonJS file of a design's project is loaded in the sandbox, on any Node. Such a design stops with `designs
136
+ can't load …: it is a CommonJS file (require and module.exports), and a design's files are ES modules (import and
137
+ export)`. A copy of an allowed package kept in the project's own `node_modules` is held the same way.
138
+ - The sandbox's runner shuts the CommonJS loader to Node's own modules before the design loads: a request from a
139
+ file of the design's project, or from code with no file (`eval`, `new Function`, a callback queued onto the
140
+ loader), is refused whatever parent module it names; the tool's own packages still load what they need.
141
+ `module.register` and `module.registerHooks` are taken away, so no import hook can be added past the sandbox's.
142
+ - Node's own modules that reach the network, other programs or workers (`net`, `http`, `https`, `http2`, `tls`,
143
+ `dns`, `dgram`, `tty`, `child_process`, `worker_threads`, `vm`, `inspector` and the rest outside a short list of
144
+ quiet ones such as `fs`, `path`, `url` and `crypto`) are now refused to every caller in the sandbox, the tool's own
145
+ code included, by the import hook and by the CommonJS loader: a design can take the CommonJS loader from an
146
+ allowed package's own CommonJS code, hand it to a package's function as a callback or compile code under a tool
147
+ file's name, and could then load any of them. What it can still load that way reads only what the permission model
148
+ lets the sandbox read. The hook and the loader's lock also no longer read with `String.prototype.startsWith` and
149
+ the like, which a design can change for everyone where the hook runs in its own thread (Node 22.15 on): changing
150
+ them let a design import `node:net` past the hook.
151
+ - `process.loadEnvFile`, `process.execve`, `process.kill` and `process.openStdin` are taken away too.
152
+ - The design's `process.stdout`, `process.stderr`, `process.stdin` and `console` are plain streams: before Node 25
153
+ the real ones are sockets, whose class could connect anywhere. The runner reads its request and writes its reply
154
+ by file descriptor. What a design prints still comes out as before.
155
+ - The sandbox may now read, of the workspace, only the design's own project, the workspace's `package.json` and the
156
+ design's own cache folders: another project's files are out of its reach under Node's permission model too.
157
+ - Before Node 25 a plain design, with no CommonJS anywhere, could reach the network through Node's own web client:
158
+ touching `Headers`, `FormData`, `WebSocket` and the like loads it, and it leaves an agent on `globalThis` that
159
+ connects anywhere. The runner now holds that agent's place before the design loads, with one that refuses, and
160
+ takes those classes away.
161
+ - Node's permission model follows a link wherever it leads, so a link in a design's project could hand it a file of
162
+ another project or of yours elsewhere (one in the project's `node_modules` was not even looked at). Now a link
163
+ anywhere in the project that leads anywhere the sandbox does not read stops the design before it runs, with
164
+ `workspace.outside` and the link's name; a cache folder that holds a link is not read (each kept stage is made
165
+ afresh), and the workspace's `package.json` is not read where it is a link.
166
+ - Before Node 25, cad's note once a run now reads `designs are kept off the network on Node 24 by rulecad alone, not
167
+ by Node itself: use Node 25 or above for designs you did not write`: no way round the tests know of reaches the
168
+ network, but Node's permission model covers it only from Node 25.
169
+ - The README's Sandbox table says the new truth for each Node, and `test/sandbox-loader.test.mjs` tries each way
170
+ round on the Node it runs on.
171
+
172
+ Upgrading: a design whose project holds a CommonJS helper file must rewrite it with `import` and `export` (a `.mjs`
173
+ file, or a `.js` file in a workspace whose `package.json` says `"type": "module"`, as every workspace `npm create
174
+ rulecad` makes does). Nothing else changes; no printed size moves.
175
+
176
+ - `cad check` (and `preview`, `export`, `show`, `link`) on an assembly ignored `--set` without a word, even for names
177
+ that do not exist, so a size tried in an assembly seemed to pass when the check had used the old one. `--set
178
+ <item>.<variable>=<value>` now builds that object item at the value, held to the variable's tweak range as an
179
+ object's `--set` is, and the title says what was set. A name that is not an object item of the assembly, or not one
180
+ of that object's variables, is refused by name (`--set a.nonsense=1: item a (tray) has no variable "nonsense"`).
181
+ `cad list`, `wires`, `beams` and `animate` take `--set` the same way, and an assembly's link says what was set, as an
182
+ object's does (its downloads are named with it). `cad kit`, `plates`, `order`, `frame`, `machine`, `plot` and
183
+ `measured` build the assembly as its file says: they now refuse `--set` by name instead of passing it over.
184
+ - `cad list` (and the kit's README, the plates' and the motors' grams and minutes) estimated print time from the X1C's
185
+ flow whatever printer the project names. It now reads the `print_flow` of the printer the project names
186
+ (`project.json`'s `printer`, else `cad.config.json`'s), as `cad check` does. The total says whose flow it used,
187
+ and says so when it assumed one (12 mm³/s, for a printer whose rule set gives none) or assumed the material's
188
+ density (PLA's 1.25 g/cm³). `--json` adds `totals.printer`, `totals.flow` and, where assumed, `flowAssumed` and
189
+ `totals.density`.
190
+ - `cad set` turned a text variable's value into a number when it looked like one: a keycap legend `007` was saved as
191
+ `7`, and `1e3` was read as 1000. A text, anchor, layout or problem variable now keeps the text as typed; a choice
192
+ keeps the option named (text for a choice of strings, a number for a choice of numbers). `cad add item --object …
193
+ --set` reads the object's variables the same way.
194
+
195
+ For someone upgrading: print-time minutes change for projects on a printer other than the X1C (and the kit's README
196
+ with them); `--set` on an assembly now changes what is built, or is refused. No printed size moves.
197
+
198
+ ### Added
199
+
200
+ - `cad coupons` adds `projects/coupons` to a workspace: the fixings coupon, the holds coupon and the slot coupon, two
201
+ assemblies that lay them out (`coupons/fixings-test`, `coupons/slot-test`), and a `MEASURE.md` that says how to
202
+ print and read each row and the command that writes the figure back. The coupons lived only in the repository's
203
+ bench example, so the guide's `cad measured benchmarks/fixings-test` failed in a workspace made by
204
+ `npm create rulecad`. A workspace that has `projects/coupons` already keeps it as it is.
205
+ - `cad measured <name>=<value>` with no assembly (`cad measured x1c.pilot_m3=2.9`) writes a figure measured on a
206
+ coupon the same way as with one, into the workspace's copy of the rule set, marked measured with the date. Its row
207
+ goes in the workspace's own ledger, `ledger.jsonl`, with nothing said to have moved, since there are no checks to run
208
+ either side. `cad history` with no argument lists those rows, and `cad measured --strike <date> <name>` takes one out.
209
+ - `cad measured --export` prints every figure measured in the workspace that the kit does not hold yet as a unified
210
+ diff of the kit's rule sets (`packages/rules/<set>.json`), to send to the kit or apply to a copy of the repository;
211
+ `--json` gives the same as data. A set the kit has no file for is listed apart.
212
+
213
+ - A typed figure of the other sign from the one it replaces, or under half or over twice it (a tenth to ten times, for
214
+ an estimate), is refused as a likely slip of the pen before anything is written; `--force` writes it as it is. A fit
215
+ the coupon bounds by what a fit of its kind can be is held to that bound instead, as before, and a 0 for a figure a
216
+ coupon in the kit measures goes in as typed (the fixings coupon's nut slots start at 0).
217
+ - `cad measured <project>/<assembly> --strike <date> <name>` (or `<name>=<figure>`) takes a row out of the ledger,
218
+ and says what the rule set it went into still holds, since that is a file of its own.
219
+ - `--table` lists every rule the assembly reads that is an estimate, a community figure or a default (it listed
220
+ estimates only, so on the starter template it was empty), with the coupon in the kit that measures each, marked
221
+ where this assembly is that coupon, and the figures a coupon in the assembly measures that the rule set has no
222
+ figure for yet. It has a "Measured by" column, and `--json` gives its rows as data. `assumptions(ref)` in
223
+ `lib/measured.mjs` returns them.
224
+
225
+ For someone upgrading: a figure far from the one it replaces now needs `--force`; the moved list and the table are
226
+ longer. No printed size moves.
227
+
228
+ - A release commits, and its tag names (a line `reads: {…}`), what its build read besides the design's own files: the
229
+ files its code imported, whether it drew with `v.fixings` or `v.frames` (then the workspace's own rule sets those
230
+ read, and the project's `project.json`, are committed with it), and the files of the objects it reads.
231
+ - `build()` returns `reads`, that record; `readTexts(d, reads)` gives the text of each of those files; `inRelease()`
232
+ in `lib/versions.mjs` gives another object as a release has it. `framesContext()` and `fixingsContext()` also return
233
+ the files they read. The build cache's format moved on (a build says whether it used `v.frames`).
234
+
235
+ For someone upgrading: `cad status` may report released parts as changed for the first time, where a helper, a rule
236
+ set or an object they read changed since; release them, or put the file back. A release made before this is rebuilt
237
+ with the files its code imports by a path and with its own rule sets, so an old release exports its own geometry,
238
+ not today's: an exported size moves where a rule was measured again since. The first build of each design after the
239
+ upgrade is made afresh. A release's folder in `.versions/` has a new layout: one written by an earlier version, or from a tag since made
240
+ again, is made afresh.
241
+
242
+ - `cad rules update <set>` brings a workspace's copy of a kit rule set (`rules/<set>.json`) up to the kit's: it takes
243
+ each figure the kit checked after the copy's was, the kit's new rules, and the same figure where the kit says more of
244
+ it (a range, a newer source), and keeps every `measured` figure, every figure checked on or after the kit's date and
245
+ every rule the kit has none of. It prints each change (`cutout: 13.8 → 14`) and what it kept; `--dry-run` writes
246
+ nothing, `--json` gives it as data.
247
+ - `cad rules check` notes `rules.changed` where the kit has a different figure, checked after the copy's, for a rule
248
+ whose copy is not `measured` (before, a corrected kit figure never reached a workspace that had used the set, and the
249
+ check said nothing of it), and `rules.same` where a copy is the kit's set word for word. Notes never fail a set.
250
+
251
+ - Before Node 25, cad says once a run, on stderr, as it runs the first design in the sandbox, that designs are kept
252
+ off the network on your Node by rulecad alone, not by Node itself, and to use Node 25 or above for designs you did
253
+ not write (its words are under Fixed above). Node's permission model covers the network only from Node 25. Nothing
254
+ is said from Node 25 on, nor for a trusted workspace, whose designs run in the tool's own process.
255
+
256
+ - `cad check` now reports each seat a design draws with `v.shapes` for a bought part (`shaftBore`, `bearingSeat`,
257
+ `plainBearing`, `pulleyBore`) as it reports `v.fixings`'s holes: a `seat.drawn` finding saying what the seat was
258
+ drawn to, the fit it rests on and how far that fit is trusted (its kind). A press-fit bore for a 5 mm shaft, drawn
259
+ 5.06 mm, rests on `SHAFT_FITS.press`, an estimate nobody has pressed a shaft into yet, and now says so. The findings
260
+ are kept with the build, so a check that reuses a kept build says them too. `@rulecad/shapes` is unchanged.
261
+ - An object's own check now warns when it rests on estimates (`rules.estimate`), as an assembly's check always has:
262
+ the rule-set entries it reads that are estimates, and the seats drawn to an estimated fit. Before, only an assembly
263
+ that held the object said so, although `AGENTS.md` promises that the check flags an estimate. An assembly's warning
264
+ names those seats too: a seat drawn to an estimated printer rule (a bearing pocket on `x1c.press`) is named as that
265
+ rule, to settle with `cad measured`, and one drawn to `SHAFT_FITS.press` by giving the fit that works.
266
+
267
+ ### Changed
268
+
269
+ - The source a coupon's figure is written with names the coupon's `MEASURE.md` in your workspace
270
+ (`the fixings coupon (projects/coupons/MEASURE.md)`), or says how to get it, never the repository's
271
+ `examples/bench/...` path. A pilot or insert hole measured with no project names "the plastic it was printed in"
272
+ where it said "THE PROJECT'S PLASTIC".
273
+
274
+ For someone upgrading: nothing you have changes until you run `cad coupons` or measure with no assembly. No printed
275
+ size moves.
276
+
277
+ - The cut lists of short frames may buy fewer or shorter bars, as `@rulecad/frames` now packs a list of up to 20 beams
278
+ exactly: the worked example's box (EXAMPLES.md) now buys three 1000 mm bars, 3000 mm of metal, where it bought one
279
+ 4000 mm bar.
280
+
281
+ For someone upgrading: bars and their numbering in a cut list may change. No printed size moves.
282
+
283
+ - The README's section on pins and magnets says that `x1c.snap_clearance` is now measured (on the launcher's fit test
284
+ plate) and the other fits remain estimates until the holds coupon measures them. No command changed.
285
+
286
+ For someone upgrading: nothing to do. Snap pin sockets in your checks move with `@rulecad/rules` and
287
+ `@rulecad/fixings`: see their notes.
288
+
289
+ - A release outside a git repository, or where git has no name and email address to commit under, is refused before
290
+ anything is written, saying what to run (`git init`; `git config user.name` and `user.email`), instead of git's own
291
+ error after the version was bumped. `--dry-run` still works without a repository.
292
+ - With `--push`, a push that fails now says the release was made and tagged here and how to push it later.
293
+ - What changes when you upgrade: nothing to do. A project released with an earlier version can be changed with
294
+ `cad set` again. No printed size moves.
295
+
296
+ - The `rules.new` note now points at `cad rules update` rather than at deleting the copy.
297
+
298
+ For someone upgrading: `cad rules check` may show new notes in an older workspace. Run `cad rules update <set>` to take
299
+ the kit's corrections, then check the designs that use the set: a figure the update changes can move a printed size.
300
+ To keep a correction of your own, give it `"kind": "measured"` (or the date you checked it). The kit's own examples
301
+ were brought up to date (their copies identical to the kit's deleted, the rest updated); no printed size in them moved,
302
+ since no figure they share with the kit differed: the bench's printer now has its own `thread_gap`, so its fixings
303
+ coupons no longer note that the X1C's was borrowed.
304
+
305
+ - The README's Sandbox paragraph is now a table of what a design can read, write, import, start and send on Node
306
+ 22.13 to 22.14 (where the import hook runs in a worker, so a CommonJS file's `require()` passes it by), Node 22.15
307
+ to 24, and from Node 25, and what holds each. Each row is tried on the Node the tests run on. It says plainly what
308
+ the old paragraph did not: on every Node, a CommonJS file in a design's project can load Node's own modules past
309
+ the import hook and read any file in the folders the sandbox may read (the workspace among them); only Node's
310
+ permission model stops it writing, starting programs and, from Node 25, sending.
311
+ - The list of packages a design may import is the hook's own, `ALLOWED` in `lib/sandbox-hooks.mjs`, everywhere: the
312
+ README, AGENTS.md (which had left out `@rulecad/frames`) and the sandbox's own list of what it may read follow it,
313
+ and a test holds the documents to it.
314
+
315
+ Upgrading: nothing to change. On Node before 25 you see the one-line note on commands that build a design; use Node
316
+ 25 or above to run designs you did not write. No printed size moves.
317
+
318
+ - An object that is not printed (`"role": "reference"` or `"board"`: a bought circuit board, drilled by its maker) has
319
+ its `v.fixings` holes drawn to the rule's figure as it stands, with no printer hole compensation: a reference
320
+ board's M2.5 holes are now drawn 2.9 mm (`m2_5.clearance`), where they were 3.0 mm (with `x1c.hole_comp`). The
321
+ fasten check holds a reference's holes to the clearance figure as drilled, as it does a board's.
322
+ - The cad README lists `estimate` and `derived` among the kinds a rule carries.
323
+
324
+ For someone upgrading: object checks may now show a new warning, `uses estimates, not measurements`, and seat
325
+ findings; neither fails a check. Each design is built afresh once after the upgrade (the build cache's format moved
326
+ on). No printed part's size moves: only a reference's holes, which are never printed, are drawn smaller.
327
+
8
328
  ## 0.9.0: belt spans shared by their lengths; two joins at one end add their springs; generated frames on castors build, with the castors' bolts on the list; unused names and silent error handling tidied, with no change in behaviour; a design that runs for ever or fills memory is stopped, with design.time or design.memory; a fasten fails across air between its parts, warns on thin walls round its far hole, and holds a slot nut's whole length in its slot; feet are checked at the load the frame puts on them; a flat part's analysis reads box, polygon and part supports and loads as cad optimise does; the kit's code is laid out by a formatter, so cached builds are made again once; frame sizing solves each profile it tries on that profile's own join springs; frame.size says which members its stress limit could not check; cad frame --size --write checks the design it would write, and writes nothing that fails; frame.tip, a frame that would tip over; a gear mesh fails when the two gears' teeth sit at different heights along their axes; gear meshes in an assembly are judged where their axes are, with the room under their tips; meshes, zips and board models from elsewhere are limited, and malformed ones refused in plain words; join.drop predicts from the real frame, and skips beams held elsewhere; cad link refuses a model the page would turn away, using model-link's own checks; live views answer only to this computer's own names, and only their own page can stop a run; the motor checks count the weight of the parts a motor moves, and work for slides; needs Node 22.13 or later, the version the kit is tested on; cad check shows printcheck's overhang and hole findings; printed beams are checked for real buckling, sag after creep and softening; what a sandboxed design hands back for the caches is capped, and kept apart from other designs' results; a screw's tightening limit follows one rule with a load and without, a torque given is held against a plastic thread, and screws sharing a load are reckoned at the torque they are all tightened to; strength checks read the stress at a part's surface; links out of the workspace are refused, for designs, rule sets, project files and targets
9
329
 
10
330
  ### Fixed
package/EXAMPLES.md CHANGED
@@ -481,10 +481,14 @@ export function main (v) {
481
481
  ```
482
482
 
483
483
  ```sh
484
- npx cad check home/flick
484
+ npx cad check home/flick # warns: the gap rests on x1c.print_gap, an estimate
485
485
  npx cad animate home/flick
486
486
  ```
487
487
 
488
+ The check warns that the design rests on an estimate: `x1c.print_gap`, the gap that prints apart, is the printer's
489
+ best guess until a test print measures it. A warning never fails the check; `cad measured` settles the figure once you
490
+ have printed the part and measured it.
491
+
488
492
  `animate` writes the sequence as an animated SVG in `.preview/`, the leaf drawn bent, and a page that plays it with
489
493
  the force on each step. The launcher in `examples/bench/projects/launcher` is the same idea at full size: a flooded
490
494
  frame, catches, a trigger, and a shot.
@@ -4296,9 +4300,9 @@ The commands. The checks that print what they find are written with `--json` whe
4296
4300
 
4297
4301
  ```sh
4298
4302
  npx cad check arm/gripper
4299
- npx cad check arm/ghorn
4303
+ npx cad check arm/ghorn # warns: the horn's reach is an estimate
4300
4304
  npx cad check arm/zframe
4301
- npx cad check arm/zcar
4305
+ npx cad check arm/zcar # warns: it reads x1c.press, an estimate
4302
4306
  npx cad check arm/arm-upright --json
4303
4307
  npx cad check arm/gripper-check --json
4304
4308
  npx cad check arm/arm-z --json
@@ -6376,13 +6380,13 @@ What the check says, screw by screw:
6376
6380
  bottoming out), M3x8 cap for the insert, M3x16 countersunk for the nuts.
6377
6381
  - `fasten.engagement`: 6.6 mm of thread in PLA where `m3.pilot_depth` asks 5 mm; 4.6 mm in the insert, where
6378
6382
  `fixings.insert_engagement` asks a diameter or the whole insert; the nut's whole 2.4 mm.
6379
- - `fasten.seat`: the cap heads sit flat, 3 mm down their counterbores, and PLA under them takes 553 N, a tightening
6380
- of 0.33 N m, so they are tightened to 0.16 N m at most, half that; the countersunk heads sit in an 89.8° countersink, flush with the back.
6383
+ - `fasten.seat`: the cap heads sit flat, 3 mm down their counterbores, and PLA under them, out to the head's 5.07 mm
6384
+ bearing face, takes 414 N, a tightening of 0.25 N m, so they are tightened to 0.12 N m at most, half that; the countersunk heads sit in an 89.8° countersink, flush with the back.
6381
6385
  - `fasten.access`: a 2.5 mm hex key reaches each cap head along its axis, and a 2 mm key each countersunk head, with
6382
6386
  nothing within the key's corners for its long arm's 58.5 mm or 52 mm (`hexkey`, ISO 2936).
6383
- - `fasten.load`: with the shelf's 2 kg, the front screws are tightened to 0.16 N m, half what the seat under the head
6384
- takes, and the pilot's thread in PLA holds that preload and the pull 4.3 times over; the back screws hold 32.6 times
6385
- the load, the screw first (the nut's thread is steel and not checked). Each holds its shear by friction 4.6 and 3.6
6387
+ - `fasten.load`: with the shelf's 2 kg, the front screws are tightened to 0.12 N m, half what the seat under the head
6388
+ takes, and the pilot's thread in PLA holds that preload and the pull 5.7 times over; the back screws hold 32.6 times
6389
+ the load, the screw first (the nut's thread is steel and not checked). Each holds its shear by friction 3.5 and 3.6
6386
6390
  times over. The torque on the back screws is given (0.3 N m), because the check holds the
6387
6391
  pressure under a flat seat and not yet on a countersink's cone.
6388
6392
 
@@ -6511,11 +6515,11 @@ tighten to. The screws, the insert and the nuts are drawn faint in place.
6511
6515
  ### What is measured, and what waits on the bench
6512
6516
 
6513
6517
  The pilot is the X1C's own measured figure. The insert's hole, the nut's slot, the counterbore's room for a head and
6514
- the strength figures under `fasten.load` are not, and their findings say so. Print 7 in
6515
- `examples/bench/projects/benchmarks/MEASURE.md`, the fixings coupon, settles them: pilots at five sizes, insert holes,
6516
- nut pockets and slots at three fits, a counterbore and printed threads. Its results go back with `cad measured
6517
- benchmarks/fixings-test <rule>=<figure>`, and every design drawn from `v.fixings` follows them the next time it is
6518
- built.
6518
+ the strength figures under `fasten.load` are not, and their findings say so. The fixings coupon settles them:
6519
+ pilots at five sizes, insert holes, nut pockets and slots at three fits, a counterbore and printed threads.
6520
+ `npx cad coupons` adds it to your workspace, in `projects/coupons` with its `MEASURE.md`; its results go back with
6521
+ `cad measured <rule>=<figure>` (`x1c.pilot_m4=3.3`), and every design drawn from `v.fixings` follows them the next
6522
+ time it is built.
6519
6523
 
6520
6524
  ## 16. A frame: beams, joins and an axis
6521
6525
 
@@ -6743,10 +6747,11 @@ npx cad beams frame/box --jigs
6743
6747
  `cad list` gives the cut list. The beams come in seven marks, beams cut and drilled alike sharing one: `A`, the four
6744
6748
  rails along x at 260 mm, each tapped M5 18.5 mm deep at both ends; `B`, the two bracket-held rails at 220 mm, cut
6745
6749
  square and nothing more; `C`, the two top rails along y, tapped; and `D` to `G`, the four posts at 200 mm, each tapped
6746
- at its foot, with three access holes on the faces its rails meet. All twelve come out of one 4000 mm bar, with a
6747
- 3 mm kerf and 10 mm trimmed off its first end, leaving a 1234 mm offcut. Then the bought parts (the rods, bearings,
6748
- coupler, screw, nut and motor), the fasteners by size with the packs to buy, and 124 g printed in 17 parts, about
6749
- 134 minutes of printing. The fasteners, as `cad list` gives them:
6750
+ at its foot, with three access holes on the faces its rails meet. All twelve come out of three 1000 mm bars, 3000 mm
6751
+ of metal where one 4000 mm bar would hold them too, with a 3 mm kerf and 10 mm trimmed off each bar's first end,
6752
+ leaving 216 mm of offcuts. The first bar is filled: three rails and a post take 999 mm of it, and the last cut takes
6753
+ the millimetre left. Then the bought parts (the rods, bearings, coupler, screw, nut and motor), the fasteners by size
6754
+ with the packs to buy, and 124 g printed in 17 parts, about 134 minutes of printing. The fasteners, as `cad list` gives them:
6750
6755
 
6751
6756
  - 12 × M5x12 button, for the blind joins.
6752
6757
  - 16 × M4x10 cap, with 16 of the 18 drop-in nuts, for the brackets, the rod holders and the motor plate.