Skip to content

Commit 43873f7

Browse files
zaloclaude
andcommitted
pysrc=upstream: docs (CLAUDE.md flag bullet, upstream-py README), sweep results
Broad-sample scoreboard folded into INVENTORY.md: 10/19 example ids MATCH lite exactly (boxes_on_faces joins), tea_cup end-to-end at ~0.3% sweep delta, two new open S-items (Edge.make_tangent_arc, make_text kwargs), clock/joints/key_cap_algebra exceeded the sweep's per-script budget. Clean rebuild + gate: python-mode, py-runtime, py-src-upstream all green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 265f14d commit 43873f7

3 files changed

Lines changed: 60 additions & 6 deletions

File tree

CLAUDE.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,20 @@ see `test/b123d-validation/runtime-comparison.md`)**:
223223
`_list_getitem`/`_property_getter`/`_bit_length` helpers, setattr loops
224224
instead of `__dict__.update`, and the scipy shim only sets `__path__ = []`
225225
when missing (MicroPython needs its native STRING `__path__`).
226+
- **`?pyruntime=micropython&pysrc=upstream`** (experimental PoC, localStorage
227+
`cascade-py-src`) additionally swaps the SOURCE layer: the `build123d`
228+
package becomes UPSTREAM build123d 0.11.1 Level-A source (builders,
229+
build_common, objects_*, operations_*, joints, pack — vendored via
230+
`node packages/cascade-core/scripts/fetch-upstream-b123d.cjs`, gitignored
231+
`vendor/build123d-0.11.1/`, transformed at load by
232+
`packages/cascade-core/src/worker/UpstreamB123d.js`) running over lite's
233+
classes re-exported as `build123d.geometry`/`build123d.topology[.*]`
234+
(adapters in `packages/cascade-core/upstream-py/`); lite registers as
235+
`build123d_lite`. Requires MicroPython; other runtimes reject the flag
236+
loudly. Frozen by `test/py-src-upstream.spec.js` (skips when not
237+
vendored). The seam-gap ledger + integration-cost estimate live in
238+
`experiments/upstream-on-micropython/INVENTORY.md`; compare against lite
239+
with `experiments/upstream-on-micropython/compare-examples.mjs`.
226240

227241
**build123d-lite coverage** (vs real build123d 0.11.1 — validated by running
228242
EVERY runnable script in the upstream `examples/` and `docs/` trees through both,

experiments/upstream-on-micropython/INVENTORY.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ capability differently — usually as a module-level builder-aware function)
6565
| B16 | `BoundBox.to_align_offset`, `BoundBox.add` | absent | adapter (ported from upstream geometry) | S |
6666
| B17 | `LocationList.__mul__/__rmul__` algebra products (`GridLocations(...) * shape`) — upstream's own topology provides this via `Shape.__rmul__` over Location iterables | lite's LocationList has them, but upstream's build_common LocationList (now in charge) didn't | adapter patches upstream's class post-import | S |
6767
| B18 | `Compound.get_type` see A5 | | | |
68+
| B19 | `Edge.make_tangent_arc` (canadian_flag) | lite `TangentArc` object | adapter classmethod (not yet written) | open, S |
69+
| B20 | `Compound.make_text(single_line_width=, ...)` — upstream Text passes kwargs lite's text seam lacks (examples/extrude) | lite `Text`/`make_text` (narrower signature) | open (needs a kwargs audit of the text seam) | open, S–M |
6870

6971
## C. Enum identity across the seam
7072

@@ -127,11 +129,16 @@ Upstream EXAMPLE scripts, lite-vs-upstream measurement diff
127129
(`compare-examples.mjs`; MATCH = every module variable within 0.5% volume):
128130
`holes`, `holes_algebra`, `intersecting_chamfers`, `circuit_board`,
129131
`din_rail`, `lego`, `handle` (multisection sweep!), `loft`, `key_cap`
130-
(extrude until=NEXT/LAST + taper) all **MATCH**. `tea_cup` runs end-to-end
131-
but the swept handle differs ~0.3% (upstream path chains `Wire(edges)` where
132-
lite sweeps its recorded pending path — same MakePipeShell numeric family as
133-
COMPROMISE(sweep)). Heavy text/Airfoil examples stay out of reach
134-
(numpy/glyph parity, same as lite's own gaps).
132+
(extrude until=NEXT/LAST + taper) and `boxes_on_faces` (workplanes on faces)
133+
all **MATCH** — 10 of the ~19 example ids attempted. `tea_cup` runs
134+
end-to-end but the swept handle differs ~0.3% (upstream path chains
135+
`Wire(edges)` where lite sweeps its recorded pending path — same
136+
MakePipeShell numeric family as COMPROMISE(sweep)). Remaining errors in the
137+
sample: B19/B20 above (`make_tangent_arc`, text kwargs), and
138+
`clock`/`joints`/`key_cap_algebra` produced no measurement inside the
139+
sweep's 120 s per-script budget (uninvestigated — clock is slow in lite
140+
too). Heavy text/Airfoil examples stay out of reach (numpy/glyph parity,
141+
same family as lite's own gaps).
135142

136143
## G. Judgment: cost of the full Level-A integration
137144

@@ -149,6 +156,6 @@ themselves demonstrably run verbatim).
149156

150157
Boot cost: the upstream layer adds ~180 ms to MicroPython's boot
151158
(lite 123 ms → upstream 305 ms libMs in-browser) and ~300 KB of fetched
152-
Python source (uncompressed; the vendored Level-A files total ~250 KB).
159+
Python source (uncompressed; the vendored Level-A files total ~340 KB, the committed shims + adapters ~60 KB).
153160
Model-evaluation speed is indistinguishable in these examples (time lives in
154161
OCCT, not the interpreter).
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# upstream-py — the `?pysrc=upstream` source layer
2+
3+
Python sources for the experimental **upstream-build123d-on-MicroPython**
4+
mode (`?pyruntime=micropython&pysrc=upstream`): UPSTREAM build123d 0.11.1
5+
Level-A source runs verbatim (after mechanical transforms) on the MicroPython
6+
runtime, over build123d-lite's classes re-exported as upstream's
7+
`build123d.geometry` / `build123d.topology[.*]` seam.
8+
9+
- `shims/` — stdlib shims MicroPython lacks (typing, metaclass-free enum,
10+
contextvars, inspect-over-settrace, ...). Registered via `sys.modules`
11+
aliasing (MicroPython builtins shadow `/lib`).
12+
- `build123d/` — the seam adapter package: `geometry.py` and
13+
`topology/__init__.py` re-export lite's classes under upstream's names and
14+
install the (additive, upstream-boot-only) patches lite needs to serve
15+
upstream's call surface; `_finalize.py` populates the package namespace and
16+
the worker's reset hook. Every adaptation is catalogued in
17+
`experiments/upstream-on-micropython/INVENTORY.md`.
18+
- `ocp_import_map.json` — the OCP names build123d imports, used to generate
19+
inert OCP stubs (`OCP.Standard`/`OCP.StdFail` become real Exception
20+
subclasses; `OCP.GccEnt` values ints).
21+
- `manifest.json` — shim registration order.
22+
23+
The UPSTREAM sources themselves are NOT committed: run
24+
`node packages/cascade-core/scripts/fetch-upstream-b123d.cjs` (gitignored
25+
`vendor/build123d-0.11.1/`), then `npm run build` copies everything to
26+
`dist/upstream-b123d/`. Loader + source transforms:
27+
`packages/cascade-core/src/worker/UpstreamB123d.js`. Frozen contract:
28+
`test/py-src-upstream.spec.js` (skips when not vendored).
29+
30+
Iterate in node (no build, semantic mock of the CAD library):
31+
`node experiments/upstream-on-micropython/upstream-poc.mjs [script.py]`.
32+
Diff real examples against lite in the browser:
33+
`CS_TEST_HEADFUL=1 DISPLAY=:99 node experiments/upstream-on-micropython/compare-examples.mjs examples/lego ...`

0 commit comments

Comments
 (0)