diff --git a/.claude/loopspec/sketch-focus-arbiter.spec.md b/.claude/loopspec/sketch-focus-arbiter.spec.md deleted file mode 100644 index f0c1287307..0000000000 --- a/.claude/loopspec/sketch-focus-arbiter.spec.md +++ /dev/null @@ -1,86 +0,0 @@ -# DELEGATION SPECIFICATION: HARNESS-DRIVEN VALIDATION LOOP -slug: sketch-focus-arbiter · repo: /home/tommaso/projects/apps/orca_cad · branch: cad-mainline - -## 1. TARGET GOAL - -**Functional Objective.** Keyboard input in the Design tab is routed by WHAT THE KEY IS, not by -which widget the window manager decided to focus. Adopted from FreeCAD's -`DrawSketchKeyboardManager::detectKeyboardEventHandlingMode` -(src/Mod/Sketcher/Gui/DrawSketchKeyboardManager.cpp), which never queries focus at all: - - - digit, `-`, `.`, `,` -> the open value field - - Backspace / Delete -> the open value field (when one is open) - - Enter / Return / Tab -> commit the field, control returns to the view - - a letter -> the sketch-tool shortcut map, as today - - Esc -> the existing CadLevel LIFO (DesignInteraction.hpp), unchanged - - anything else -> sticky: whoever had it keeps it - -Observable postcondition: for EVERY sketch tool that opens a value field, a value typed -immediately after the field appears — with NO click into the field — is the value committed. -Today the prefill is committed instead whenever the WM withholds focus. - -**Target Files / Scope (writable).** - src/slic3r/GUI/CAD/DesignPanel.cpp (the arbiter lives in the existing wxEVT_CHAR_HOOK) - src/slic3r/GUI/CAD/DesignCanvas.cpp/.hpp (forwarding entry points only) - src/slic3r/GUI/CAD/SketchInlineEditor.cpp/.hpp (accept a programmatically delivered character) - scripts/CAD/check-gui-click-edit.py (F2P oracle — authoring exception, see §4) -Everything else read-only. No dependency additions, no reformatting. - -**Open Bindings.** - - The in-canvas ImGui field on wip/in-canvas-value-field is NOT in scope. Default: the arbiter - is implemented against the CURRENT wxFrame field on cad-mainline, because content-based - routing makes the window's focus irrelevant either way. If it later moves in-canvas the - arbiter is unchanged. - - Tools whose field is opened by a toolbar button rather than a gesture (Constrain path) are - covered by the same arbiter but are not in the F2P tool list. Default: assert them in P2P only. - -## 2. HARNESS ENVIRONMENT & GROUND TRUTH - -The rig container `orcacad-gui` on nativedev IS the harness. Xvfb `:11` + openbox, the app under -test, `xdotool` for synthetic input, and an MCP socket at `/tmp/mcp.sock` that reports sketch -state as JSON. It is a closed loop: drive input, read geometry back, assert. No window manager -politics, no human. - - Harness interface (ordered; each slot one invocation, one exit code): - S1 sync docker cp orcacad-gui:/OrcaSlicer/ - S2 build docker exec orcacad-gui ninja -C /OrcaSlicer/build orca-slicer - S3 restart docker exec orcacad-gui /OrcaSlicer/scripts/CAD/start-headless-gui.sh - S4 F2P docker exec -e DISPLAY=:11 orcacad-gui python3 /tmp/check-gui-click-edit.py --attach - S5 P2P docker exec -e DISPLAY=:11 orcacad-gui python3 /tmp/check-gui-sketching.py - -**F2P.** `scripts/CAD/check-gui-click-edit.py`. For each of Line, Rectangle, Circle, Slot, -Polygon, Ellipse and Rounded rectangle: arm the tool, draw it, and type a value that differs -from the prefill WITHOUT clicking the field. Assert the committed value equals the typed value. -The ladder must FAIL against unmodified cad-mainline — that is what proves it asserts something. - -**P2P.** `scripts/CAD/check-gui-sketching.py`, the existing gesture ladder, minus anything red at -baseline. NOTE: it calls `focus_field()` — one click into the field before typing — which is the -workaround this whole task removes. It stays green as a regression guard; it is NOT evidence. - -**Test Integrity Constraint.** `focus_field()` in check-gui-sketching.py must NOT be deleted to -make things pass, and check-gui-click-edit.py must NOT be weakened. Either invalidates the run. - -## 3. VERIFICATION COMMANDS -1. Static: `docker exec orcacad-gui ninja -C /OrcaSlicer/build orca-slicer` (warnings delta only; - this repo configures no linter — the compiler is the static gate. Absolute-zero is NOT the gate.) -2. Harness: `docker exec -e DISPLAY=:11 orcacad-gui python3 /tmp/check-gui-click-edit.py --attach` -3. Regression: `docker exec -e DISPLAY=:11 orcacad-gui python3 /tmp/check-gui-sketching.py` - -## 4. CONVERGENCE LOOP — ceiling 8 iterations -EDIT (scoped) -> EXECUTE S1..S5 -> PARSE the ladder's per-tool assertions and the [UX]/[KEYTRACE] -lines -> PATCH from the parsed cause. On ceiling without convergence: stop, report the last diff -and the unresolved failure set. Do not report success. - -F2P authoring exception: check-gui-click-edit.py is writable, and must be shown RED against -unmodified source before any source edit counts. - -## 5. TERMINATION CRITERIA -- [ ] S2 exits 0, and introduces no compiler warning absent from the baseline. -- [ ] S4 ALL_PASSED — every tool commits the typed value, no click into the field. -- [ ] S5 shows zero regressions against its recorded baseline pass count. -- [ ] F2P proven red without the fix (source stashed, ladder re-run, must FAIL). - -## 6. GUARDRAILS -Zero-assumption: no completion claim without captured stdout and exit codes. Oracle supremacy: -the ladder's verdict overrides my judgement. Blast radius: §1 files only. Baseline obligation: -run §3 once before the first edit and record it. diff --git a/.github/workflows/check_cad_offer_table.yml b/.github/workflows/check_cad_offer_table.yml new file mode 100644 index 0000000000..4be8224b21 --- /dev/null +++ b/.github/workflows/check_cad_offer_table.yml @@ -0,0 +1,31 @@ +name: Check CAD offer table + +# src/slic3r/GUI/CAD/DesignOffer.hpp is generated from scripts/CAD/tool_atlas.json and must never be +# edited by hand. This fails when the checked-in header is not what the generator makes of the atlas. +on: + push: + paths: + - 'scripts/CAD/tool_atlas.json' + - 'scripts/CAD/gen_offer_table.py' + - 'src/slic3r/GUI/CAD/DesignOffer.hpp' + - '.github/workflows/check_cad_offer_table.yml' + pull_request: + paths: + - 'scripts/CAD/tool_atlas.json' + - 'scripts/CAD/gen_offer_table.py' + - 'src/slic3r/GUI/CAD/DesignOffer.hpp' + - '.github/workflows/check_cad_offer_table.yml' + +permissions: {} + +jobs: + check_cad_offer_table: + name: Check CAD offer table + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - name: Checkout repository + uses: actions/checkout@v7 + + - name: Check the offer table against the atlas + run: python3 scripts/CAD/gen_offer_table.py --check diff --git a/docs/CAD/design/SKETCHER_TOOL_ARCHITECTURE.md b/docs/CAD/design/SKETCHER_TOOL_ARCHITECTURE.md index b450835daa..c326d62121 100644 --- a/docs/CAD/design/SKETCHER_TOOL_ARCHITECTURE.md +++ b/docs/CAD/design/SKETCHER_TOOL_ARCHITECTURE.md @@ -305,9 +305,9 @@ codebase. Current state, verified: support exists, no GUI path yet (row shows disabled)"*, so the row renders as **"Measure (no GUI route)"** and is permanently disabled (`DesignPanel.cpp:6519`). With no refusal in the row, it contributes nothing to the family's "why" line either. -- The maths exists, for MCP callers only: `resolve_ref` + `measure` (`McpControl.cpp:522`, `:546`) - — refs `{face|edge|point}`, distance = `|pa - pb|` of **representative points** (face centroid, - edge mid-sample), angle = `acos(da·db)` when both refs carry a direction. +- The maths exists, for MCP callers only: the `measure` CAD tool (`cad_measure` in + `Mcp/McpToolsCad.cpp`) — refs `{face|edge|point}`, distance = `|pa - pb|` of **representative + points** (face centroid, edge mid-sample), angle = `acos(da·db)` when both refs carry a direction. - The correct OCCT primitive is already linked and already used: `BRepExtrema_DistShapeShape` (`GeometryEngine.cpp:31`, `:457`). - The Prepare tab ships a full measure gizmo — `GLGizmoMeasure` (`src/slic3r/GUI/Gizmos/`) over @@ -439,12 +439,11 @@ gesture has already added a constraint, and nothing says so). **`apply_dimension` records a poison value.** Its per-case thresholds move nothing for `v <= 0` (Length/Diameter/Radius, `:611-613`) or `v < 0` (Distance/DistanceToLine, `:622`, `:639`) — -and then `record_dimension_constraint(v)` runs **unconditionally** (`:659`). The file's own sibling -says it best, at the socket boundary: *"a negative/zero/NaN value that moved nothing would still be -pushed to the solver as a constraint it must satisfy and cannot, silently corrupting the sketch -rather than failing. (`apply_dimension` has the same flaw for any other caller; this guard protects -the socket, not the tool.)"* (`McpControl.cpp:1572-1577`). So the agent surface validates and the GUI -does not — the GUI is the less safe caller of its own function. +and then `record_dimension_constraint(v)` runs **unconditionally** (`:659`). A negative, zero or NaN +value that moved nothing is still pushed to the solver as a constraint it must satisfy and cannot, +silently corrupting the sketch rather than failing. The `sketch_set_value` CAD tool +(`Mcp/McpToolsCad.cpp`) refuses such a value before it calls `apply_dimension`. So the agent surface +validates and the GUI does not — the GUI is the less safe caller of its own function. **`record_dimension_constraint` never dedupes at all.** It `push_back`s unconditionally (`:674`, `:684`, `:691`, `:700`), so applying the selection-path dimension twice leaves **two** @@ -523,8 +522,8 @@ Three rules the type enforces, each closing a defect above: contradiction you can see. `drive == Reference` renders `measured` only, and the palette is the one already in the tab (green quote = measured, driving colour = driven). 2. **`apply(value)` returns a `WriteOutcome`** (`Ok | ClampedTo | Refused`, the base-operator type - from §0.2) — the same type for the solver path, the geometric path and the socket. The socket - guard already written in `McpControl.cpp:1572-1577` moves *into* `apply`, so the GUI cannot be the + from §0.2) — the same type for the solver path, the geometric path and the MCP server. The guard + `sketch_set_value` runs in `Mcp/McpToolsCad.cpp` moves *into* `apply`, so the GUI cannot be the unsafe caller of its own function any more. `Refused` keeps the field open with the typed text and the reason, which is also what makes the `Coincident`-flip reversible: the dimension keeps its `type` and only its value changes. diff --git a/docs/HLSD/design-tab.md b/docs/HLSD/design-tab.md index 6515a8270e..88bb2a1cb4 100644 --- a/docs/HLSD/design-tab.md +++ b/docs/HLSD/design-tab.md @@ -347,25 +347,37 @@ An invariant across 93 verbs and 20 selection kinds does not survive by review, exists once, as data: `scripts/CAD/tool_atlas.json` carries every verb with its row, key, icon, accepted selections, preconditions and refusal string, and `scripts/CAD/gen_offer_table.py` emits `src/slic3r/GUI/CAD/DesignOffer.hpp` from it. The header is checked in and never -hand-edited; `scripts/CAD/run-all-checks.sh` runs the generator with `--check` as its first -rung, which is what makes "GENERATED — DO NOT EDIT" a fact rather than a request. The generator -also refuses an atlas with a duplicate verb id, since `mcp_run_verb` resolves a verb by id and -would make the second one unreachable. +hand-edited; the `check_cad_offer_table.yml` workflow runs the generator with `--check` on every +push and pull request that touches the atlas, the generator or the header, which is what makes +"GENERATED — DO NOT EDIT" a fact rather than a request. The generator also refuses an atlas with a +duplicate verb id, since `mcp_run_verb` resolves a verb by id and would make the second one +unreachable. The atlas and its generator sit in `scripts/CAD/` rather than in `docs/`: they are build inputs for a checked-in header, not documentation. ## Automation surface -`McpControl` exposes the document over JSON-RPC when `ORCA_CAD_MCP` is set in the environment, -with `tools/orca_cad_mcp_bridge.py` as the client side, and to the app's MCP server through its -`call_cad_tool` tool on every platform. It describes the scene, queries topology, measures, and runs -the same verbs the offer does — it re-implements nothing, so a scripted action and a clicked one -cannot diverge. The socket is off unless the variable is set. Where a GUI action is bound to a -selection, a card or a dialog, its work is split into a function both callers share, and the -automation calls that function with explicit arguments instead of driving the widgets. +The document is automated through the app's MCP server, on every platform, with three tools: +`list_cad_tools` lists the Design tab's CAD tools, `describe_cad_tool` gives a CAD tool's arguments, +how its failure shows and runnable examples, and `call_cad_tool {tool, args}` runs one. The CAD +tools (`Mcp/McpToolsCad.*`) describe the scene, query topology, measure, and run the same verbs the +offer does — they re-implement nothing, so a scripted action and a clicked one cannot diverge. Where +a GUI action is bound to a selection, a card or a dialog, its work is split into a function both +callers share, and the CAD tool calls that function with explicit arguments instead of driving the +widgets. -Its methods add features through the kernel calls the cards use, named as the cards name them, +`call_cad_tool` needs the MCP server on (`--mcp`, or Preferences) and the CAD feature on +(Preferences > Features, read only at startup); with the feature off it is refused, and the two +inspect tools still answer, with a note on how a person turns it on. A call is refused (`-32002`) +while the Design tab is busy: a `change` CAD tool does not run under an open feature card or sketch +session, nor a `change` or `sketch` one during a body Move, nor any while a rebuild owns the +document. Face and edge ids name faces and edges of the current model, and a rebuild renumbers +them while a stale id still names a real face or edge, so the replies carry the model's +`generation`: a call that passes ids with the `generation` they were read at is refused (`-32010`) +once the model has moved on, rather than acting on another face or edge. + +The CAD tools add features through the kernel calls the cards use, named as the cards name them, one checkpoint per call. A rebuild that fails is taken back with `CadDocument::rollback()`, which leaves nothing to redo, and the status line says "Edit rejected" as it does for a refused GUI edit; the call reports the kernel's reason. Planes are named as in the cards: a @@ -400,7 +412,7 @@ a value field is pending. Topology reads come from the kernel: `GeometryEngine::surface_info()` gives a face's surface type, area and analytic numbers, `edge_faces()` the faces along each edge, `edge_convexity()` whether two faces meet in an outside or inside corner (OCCT's fillet classification), and -`min_distance()` the closest points of two shapes. The Plane card's Confirm and the `plane` method +`min_distance()` the closest points of two shapes. The Plane card's Confirm and the `plane` CAD tool share `CadDocument::datum_plane_refusal()`, which refuses a construction that is missing a reference, names a face or edge no longer on the model, or puts a tangent plane on a face that is not a cylinder, so neither reaches the kernel's silent fallback to an offset plane; a refused @@ -420,7 +432,7 @@ clicks and drags it at pixels, so a left click picks and a right click opens the `wxEVT_CHAR_HOOK` as a real key press does, travelling up from the focused widget, so Escape, Enter and the tool shortcuts behave as they do for a person. -`docs/HLSD/mcp-server.md` describes the method table, access rules, error convention and replay +`docs/HLSD/mcp-server.md` describes the CAD tool table, access rules, error convention and replay tests. ## Where the code lives @@ -436,7 +448,7 @@ tests. | `src/slic3r/GUI/CAD/DesignRowList.*` | the Feature tree and Bodies lists, with per-row actions | | `src/slic3r/GUI/CAD/DesignCanvas.*` | viewport integration | | `src/slic3r/GUI/CAD/DesignSketchTool.*` | in-canvas sketching | -| `src/slic3r/GUI/Mcp/McpToolsCad.*` | the automation surface: the method table, shared by `call_cad_tool` and the socket | +| `src/slic3r/GUI/Mcp/McpToolsCad.*` | the automation surface: the CAD tool table behind the MCP server's `list_cad_tools`, `describe_cad_tool` and `call_cad_tool` | | `src/slic3r/GUI/CAD/DesignInteraction.hpp` | the Esc level contract | | `src/slic3r/GUI/CAD/DesignOffer.hpp` | generated offer table | | `scripts/CAD/tool_atlas.json` | source of truth for the offer | @@ -445,15 +457,25 @@ tests. The kernel is covered by Catch2 suites in `tests/libslic3r/` (`test_caddocument`, `test_sketchconstraints`, `test_sketchedit`, `test_sketchimport`, `test_sketchinference`, -`test_sketchprofile`, `test_slvs_constraints`), which need no display; -`scripts/CAD/run-kernel-tests.sh` builds only `libslic3r_tests` and runs them headless. +`test_sketchprofile`, `test_slvs_constraints`), which need no display. They are part of +`libslic3r_tests` in a CAD build and run under `ctest` and CI like any other suite; +`libslic3r_tests "[CadDocument]"` runs the document's cases. -The GUI half is not covered by CI, which has no OpenGL canvas or synthetic input: the ladders -in `scripts/CAD/` drive a running application in a local rig instead, and -`scripts/CAD/run-all-checks.sh` is the gate that runs all of them. A green kernel run says -nothing about the viewport, so the two are reported separately rather than as one number. +The automation surface has its own checks. `slic3rutils_tests "[Mcp][CAD]"` +(`tests/slic3rutils/test_mcp_cad.cpp`) runs the CAD tools' argument checks and kernel calls on a +`CadDocument` or a bare `DesignSketchTool`, with no panel, and checks the table itself: a row per +dispatched CAD tool, the summaries, and examples that call only real CAD tools with the arguments +they declare. On a live application launched with `tools/mcp/orca_mcp.py launch --cad`, the replays +`tools/mcp/tests/cad_*.json` drive `call_cad_tool`, the live tests `tools/mcp/test_cad_replay.py`, +`test_cad_slow_build.py` and `test_cad_failed_job.py` cover journaling and replay, the app staying +live through a long rebuild, and a call whose job fails after its reply, and +`tools/mcp/test_cad_examples.py` runs every CAD tool's examples, each on a fresh design. -The automation surface has its own checks: `tests/slic3rutils/test_mcp_cad.cpp` runs the methods' -argument checks and kernel calls on a `CadDocument` or a bare `DesignSketchTool`, with no panel, and -the replays `tools/mcp/tests/cad_*.json` run the methods on a live application through -`call_cad_tool`, launched with `tools/mcp/orca_mcp.py launch --cad`. +Three checks in `scripts/CAD/` drive a running app through its MCP server as an agent does and +grade the sketch layer against arithmetic: `check-mcp-sketch.py`, `check-sketch-engine.py` and +`check-sketch-engine-corpus.py`, which grades it against the vector geometry of real drawings. +They need the MCP server and the CAD feature on and run on every platform, but not in CI, which +runs no application. `scripts/CAD/README.md` says how to run each. + +The offer table is checked in CI: the `check_cad_offer_table.yml` workflow fails when +`DesignOffer.hpp` is not what `gen_offer_table.py` makes of `tool_atlas.json`. diff --git a/scripts/CAD/README.md b/scripts/CAD/README.md index a5c6836e29..5d7334b041 100644 --- a/scripts/CAD/README.md +++ b/scripts/CAD/README.md @@ -2,36 +2,37 @@ Everything here supports the parametric Design tab (`src/libslic3r/CAD/`, `src/slic3r/GUI/CAD/`). Nothing here is needed to build or run OrcaSlicer — these -are the development and verification tools for that one feature. +are the development and verification tools for that one feature. The kernel's own unit +tests are not here: they are part of `libslic3r_tests` and run under `ctest` like any +other suite. -The verb in the name is the role: +## Checks against a running app -| | | -|---|---| -| `build-…` | produce a binary | -| `start-…` | bring something up and leave it running | -| `run-…` | run a suite and report pass/fail | -| `check-…` | one specific assertion, usually driving a live app | +Three checks drive the Design tab through the app's MCP server, with the same CAD tools an +agent calls, and compare what the app reports with arithmetic. Each needs a running +OrcaSlicer with the MCP server on (`--mcp`, or "MCP server" under AI features in +Preferences) and the CAD feature on (Preferences > Features, read at startup). +`tools/mcp/orca_mcp.py launch --cad` starts one with both. A check finds the app through +its data directory, where the server writes its port and token: the one passed to the check, +else `$ORCA_DATADIR`, else the platform's own (`tools/mcp/README.md` describes attaching). +They run on Windows, macOS and Linux, and exit 0 when every assertion held. -## Verification - -| Script | What it proves | Needs | +| Check | What it proves | Run it | |---|---|---| -| `run-kernel-tests.sh` | The CAD kernel builds and the Catch2 `[CadDocument]` tags pass — every case builds a document, recomputes it and asserts on real geometry. **Exit 0 is the verification contract.** | Docker only. No display. | -| `run-all-checks.sh` | Every check below, in one command. The gate before pushing a Design-tab change. | Docker + the GUI container | -| `check-sketch-engine.py` | A ladder of 2D sketches of increasing complexity, judged on loop count, closure and void attribution rather than on area. | Kernel only | -| `check-sketch-engine-corpus.py` | The same ladder graded against a systematic sample of real drawings instead of shapes we chose. | Kernel + corpus | -| `check-gui-sketching.py` | The same profiles drawn the way a person draws them — synthetic mouse gestures and typed values. | Headless GUI | -| `check-gui-context-menu.py` | That right-click is the pivot of the design gesture, and adapts to what was clicked. | Headless GUI | -| `check-mcp-sketch.py` | The sketch layer driven over the MCP socket, asserting what decides whether a profile is buildable. | Headless GUI + `ORCA_CAD_MCP` | +| `check-mcp-sketch.py` | The sketch layer, asserting what decides whether a profile is buildable: closed loops, offsets that survive, a circle read as a void rather than a second body. | `python3 scripts/CAD/check-mcp-sketch.py [datadir]` | +| `check-sketch-engine.py` | A ladder of 2D sketches of increasing complexity, judged on vertices, lengths, radii, tangency, symmetry and closure rather than on area. | `python3 scripts/CAD/check-sketch-engine.py [datadir]` | +| `check-sketch-engine-corpus.py` | The same ladder graded against real drawings: a systematic sample of the StudyCadCam sheets, each judged against its own vector geometry. | `python3 scripts/CAD/check-sketch-engine-corpus.py --corpus DIR [--datadir DIR] [--step N] [--limit N] [--scale]` | -**`run-kernel-tests.sh` is the only one CI can run.** The rest need a live -application with an OpenGL canvas and synthetic input, which hosted runners do not -have. The kernel suite itself is already in CI by an ordinary route: the cases are -registered in `tests/libslic3r/CMakeLists.txt` under `if (SLIC3R_CAD)`, so they are -part of `libslic3r_tests` and run under `ctest` on every platform like any other -unit test. This script exists for the local loop, where it is a two-minute round -trip instead of a full application build. +For example: + + python3 tools/mcp/orca_mcp.py launch --cad --datadir + python3 scripts/CAD/check-sketch-engine.py + python3 tools/mcp/orca_mcp.py stop + +The corpus check takes the folder of `MPD*.pdf` sheets, which is not in the repository, and +reads them with poppler's `pdftocairo` and `pdfinfo`, which must be on the PATH. It grades +every 20th sheet by default (`--step`); `--scale` grades the largest drawings instead, each +round trip within `--budget` seconds. ## Generated sources @@ -41,28 +42,33 @@ compiled against it cannot drift apart: | Generator | Source | Output | |---|---|---| | `gen_offer_table.py` | `tool_atlas.json` — every offer verb with its row, key, icon, accepted selections and refusal string | `src/slic3r/GUI/CAD/DesignOffer.hpp` | -| `mate-glyph/emit_glyph_table.py` | `mate-glyph/bear_outline.json`, measured off `mate-glyph/bear.step` by `extract_outline.py` (needs FreeCAD) | the `kBear…` tables in `DesignSketchTool.cpp` | +| `mate-glyph/emit_glyph_table.py` | `mate-glyph/bear_outline.json`, measured off `mate-glyph/bear.step` by `extract_outline.py` | the `kBear…` tables in `DesignSketchTool.cpp` | `python3 scripts/CAD/gen_offer_table.py` rewrites the header and `--check` proves the -checked-in one matches the atlas — `run-all-checks.sh` runs the check as its first rung, -which is what makes the header's "GENERATED — DO NOT EDIT" enforceable. Edit the atlas, -never the header. +checked-in one matches the atlas. The "Check CAD offer table" workflow +(`.github/workflows/check_cad_offer_table.yml`) runs the check on every push and pull +request that touches the atlas, the generator or the header, which is what makes the +header's "GENERATED — DO NOT EDIT" enforceable. Edit the atlas, never the header. -## Build and run +`mate-glyph/` holds the bear connector the mate glyph is drawn from. `extract_outline.py` +runs in FreeCAD's Python (it reads the STEP with `Part`) and writes `bear_outline.json`. +`emit_glyph_table.py` runs in plain Python and simplifies that outline into the C++ tables, +printing them and writing them to `bear_glyph_table.h` beside it; `DesignSketchTool.cpp` +holds them as emitted. -| Script | Purpose | +## GUI checks + +`check-gui-sketching.py`, `check-gui-context-menu.py` and `check-gui-click-edit.py` drive +the app the way a person does, with synthetic mouse and keyboard input from `xdotool` on an +X display, and grade what the Design tab did. The display needs a window manager (on Xvfb, +openbox for example): without one no window takes focus, and an unfocused GTK app ignores +synthetic keys. + +| Check | What it proves | |---|---| -| `build-gui.sh` | Build the GUI binary in a throwaway container, writing into the build-cache volume the long-lived GUI container reads. | -| `build-gui-incremental.sh` | Incremental build against the deps-baked image, for a fast edit/compile loop. | -| `start-headless-gui.sh` | Bring the app up on a headless X display (Xvfb + a window manager), ready to drive or attach to over VNC. | +| `check-gui-sketching.py` | The engine ladder's profiles drawn the way a person draws them, with mouse gestures and values typed into the in-canvas field. | +| `check-gui-context-menu.py` | Right-click opens the offer, which adapts to what was clicked and shows exactly the verbs `DesignOffer.hpp` says apply. Grades the app's `ORCA_CAD_KEYTRACE=1` trace. | +| `check-gui-click-edit.py` | A value field that opens takes what is typed into it at once, without a click into the field. Grades the app's `ORCA_CAD_UXTRACE=1` trace. | -Two constraints that are not obvious and have each cost a session: - -- **Never build inside the GUI container.** Its baked source tree silently - reconfigures the shared build directory and this fork's targets vanish. -- **A window manager is required.** Without one, windows are never focused, and an - unfocused GTK app ignores synthetic keys — which looks exactly like a code bug. - -`scripts/CAD/rig_build_traps.md` documents these and three more, with symptoms and exact -recovery commands. Read it before debugging a configure or link failure one of -these scripts reports. +They read the results back through a local socket the app does not open, so none of them runs +until it reads them through the MCP server like the checks above. diff --git a/scripts/CAD/build-gui-incremental.sh b/scripts/CAD/build-gui-incremental.sh deleted file mode 100755 index f87113fdaf..0000000000 --- a/scripts/CAD/build-gui-incremental.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/env bash -# Incremental slicer build against the orcacad-deps base image. -# -# The deps-baked image (built from scripts/Dockerfile.deps) carries the pinned -# dependencies at /OrcaSlicer/deps/build/destdir. This script mounts the LIVE source -# tree and resources over the baked copy so code/CMake edits apply immediately, and -# persists /OrcaSlicer/build in a named volume so ninja recompiles only what changed. -# -# Result: edit -> rebuild in seconds-to-minutes instead of a full Docker rebuild. -# -# Usage (run on the build host, e.g. behemoth, from anywhere): -# scripts/CAD/build-gui-incremental.sh -# IMAGE=orcacad-deps scripts/CAD/build-gui-incremental.sh -# -# On success the binary is inside the persistent volume at -# /OrcaSlicer/build/package/bin/orca-slicer (copy it out with a follow-up -# `docker run --rm -v orcacad_buildcache:/b alpine cp ...` or via this script's tail). -# Rig build traps already paid for once each (stale project, NLopt cache, pybind11, OCCT_LIBS, SLIC3R_CAD gate): scripts/CAD/rig_build_traps.md -set -euo pipefail - -REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" -# orcacad-deps, NOT snapmaker-deps: see the note in run-kernel-tests.sh — the wrong image -# fails at CMake configure, not at link time. -IMAGE="${IMAGE:-orcacad-deps}" -BUILD_VOL="${BUILD_VOL:-orcacad_buildcache}" - -echo "REPO=$REPO IMAGE=$IMAGE BUILD_VOL=$BUILD_VOL" - -# The root CMakeLists.txt and cmake/ must be mounted too, not taken from the baked image: -# they carry the build-time gates (e.g. SLIC3R_CAD -> add_definitions(-DSLIC3R_CAD)) that the -# mounted headers are compiled against. With a stale baked copy the gate silently stays off and -# the build fails with "class GLCanvas3D has no member named set_design_sketch_tool". -# -# build_linux.sh must be mounted for the same reason, and here the stale copy is guaranteed -# wrong rather than merely risky: orcacad-deps is layered on snapmaker-deps, so the baked script -# is the OTHER fork's and builds `--target Snapmaker_Orca`. This fork's target is `OrcaSlicer`, -# so without this mount configure succeeds and then ninja dies on "unknown target". -# scripts/ likewise: build_linux.sh's packaging step sources scripts/appimage_lib_policy.sh, -# which the baked Snapmaker tree does not have, so a fully successful link still exited -# non-zero with "missing AppImage helper" and the binary check never ran. - -# ---- OOM guard (2026-08-21) ------------------------------------------------------------- -# Two of these builds ran at once on 2026-08-21, each with ninja -j$(nproc)=16: ~36 cc1plus -# holding 42 GB of a 62 GB box -> global OOM at 21:05, a 2h28m kill storm, ssh unreachable, -# lightdm destroyed. Neither build produced a single object. scripts/CAD/build-gui.sh grew the -# bounds first; every script that starts a compile needs the same three, or the guard is only -# as strong as the script you happened not to use. -# flock — the lock path is SHARED with build-gui.sh and the other fork on purpose, so -# concurrent builds serialise instead of summing. -# -j — bounded parallelism; ~1.17 GB per cc1plus was the measured average. -# --memory — the actual guarantee: a runaway build dies in its own cgroup instead of taking -# the host down. --memory-swap equal to --memory forbids swap, which is what made -# ssh hang. -JOBS="${JOBS:-12}" -MEM="${MEM:-40g}" -LOCK=/tmp/orca-rig-build.lock - -exec 9>"$LOCK" -if ! flock -n 9; then - echo "another build holds $LOCK — waiting (this is the OOM guard, not a hang)" - flock 9 -fi - -docker run --rm \ - --memory="$MEM" --memory-swap="$MEM" \ - -v "$REPO/src":/OrcaSlicer/src \ - -v "$REPO/resources":/OrcaSlicer/resources \ - -v "$REPO/CMakeLists.txt":/OrcaSlicer/CMakeLists.txt \ - -v "$REPO/cmake":/OrcaSlicer/cmake \ - -v "$REPO/deps_src":/OrcaSlicer/deps_src \ - -v "$REPO/build_linux.sh":/OrcaSlicer/build_linux.sh \ - -v "$REPO/scripts":/OrcaSlicer/scripts \ - -v "$BUILD_VOL":/OrcaSlicer/build \ - "$IMAGE" \ - bash -lc "cd /OrcaSlicer && ./build_linux.sh -sr -j $JOBS" - -# src/CMakeLists.txt:151 renames the OrcaSlicer target's output to "orca-slicer" — not -# "snapmaker-orca", which is the other fork's binary name. -echo "=== build finished; checking for binary ===" -docker run --rm -v "$BUILD_VOL":/b "$IMAGE" \ - bash -lc 'ls -lh /b/package/bin/orca-slicer 2>/dev/null && file /b/package/bin/orca-slicer || echo "NO BINARY"' diff --git a/scripts/CAD/build-gui.sh b/scripts/CAD/build-gui.sh deleted file mode 100755 index edf93a5ca0..0000000000 --- a/scripts/CAD/build-gui.sh +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/env bash -# Rebuild the GUI binary the design rig launches — in a THROWAWAY container, writing into the -# same build-cache volume the rig's long-lived GUI container reads from. -# -# NEVER build inside the GUI container (snapmaker-gui / orcacad-gui). Its baked /OrcaSlicer tree -# is the Jun-13 Snapmaker-derived source, so a `cmake .` in there silently reconfigures the -# shared build dir as project(Snapmaker_Orca) and this fork's targets vanish. That is Trap 1 of -# five; all of them, with symptoms and exact recovery commands, are in scripts/CAD/rig_build_traps.md. -# Read that file before debugging a configure or link failure this script reports. -# -# Usage: -# scripts/CAD/build-gui.sh # configure + build the fork's GUI target -# DRY_RUN=1 scripts/CAD/build-gui.sh # print the resolved fork identity and exit, no container -set -euo pipefail - -REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" - -# Fork identity is DERIVED from the repo, never hardcoded, so this file is byte-identical in -# both forks and cannot be mirrored into the wrong one. Pointing a fork at the other fork's -# image or volume is not a slow failure: with the wrong image CMake dies at configure, and with -# the wrong volume the two forks silently trade build artefacts. -PROJECT="$(sed -n 's/^project(\([A-Za-z_0-9]*\)).*/\1/p' "$REPO/CMakeLists.txt" | head -1)" -case "$PROJECT" in - Snapmaker_Orca) PREFIX=snapmaker; BIN=snapmaker-orca ;; - OrcaSlicer) PREFIX=orcacad; BIN=orca-slicer ;; - *) echo "FATAL: unrecognised project($PROJECT) in $REPO/CMakeLists.txt" >&2; exit 2 ;; -esac -TARGET="$PROJECT" -IMAGE="${PREFIX}-deps" -BUILD_VOL="${PREFIX}_buildcache" - -echo "REPO=$REPO PROJECT=$PROJECT IMAGE=$IMAGE BUILD_VOL=$BUILD_VOL TARGET=$TARGET BIN=$BIN" - -if [ -n "${DRY_RUN:-}" ]; then - echo "DRY_RUN: resolution only, no container started" - exit 0 -fi - -# Three memory bounds. On 2026-08-21 both forks ran this script at the same time, each with -# ninja -j$(nproc)=16: ~36 cc1plus holding 42 GB of a 62 GB box -> global OOM at 21:05, a -# 2h28m kill storm, ssh unreachable, lightdm destroyed, 2946 session kill events. Neither -# build produced a single object. The bounds, weakest to strongest: -# flock — the lock path is shared by both forks on purpose, so they SERIALISE instead of -# summing. Peak is one build's worth no matter who else starts one. -# -j12 — measured 1.17 GB average per cc1plus in the incident dump, so 12 in flight -# is ~14 GB typical and leaves the box usable. JOBS=n overrides. -# --memory — the actual guarantee. A runaway build hits its own cgroup limit and dies alone; -# the host never reaches global OOM again, whatever -j or flock do. -# --memory-swap equal to --memory forbids swap, which is what made ssh hang. -JOBS="${JOBS:-12}" -MEM="${MEM:-40g}" -LOCK=/tmp/orca-rig-build.lock - -exec 9>"$LOCK" -if ! flock -n 9; then - echo "another fork's build-gui holds $LOCK — waiting (this is the OOM guard, not a hang)" - flock 9 -fi - -# Every one of these mounts covers a trap, none is decorative: -# CMakeLists.txt + cmake/ carry the SLIC3R_CAD gate — inherit the baked copies and the cache -# says SLIC3R_CAD=ON while -DSLIC3R_CAD is never defined, so every #ifdef block compiles out. -# deps_src/ carries pybind11, which the image predates. -# src/, resources/, localization/, version.inc are the code under test. -rc=0 -docker run --rm \ - --memory="$MEM" --memory-swap="$MEM" \ - -v "$REPO/src":/OrcaSlicer/src \ - -v "$REPO/resources":/OrcaSlicer/resources \ - -v "$REPO/cmake":/OrcaSlicer/cmake \ - -v "$REPO/deps_src":/OrcaSlicer/deps_src \ - -v "$REPO/localization":/OrcaSlicer/localization \ - -v "$REPO/CMakeLists.txt":/OrcaSlicer/CMakeLists.txt \ - -v "$REPO/version.inc":/OrcaSlicer/version.inc \ - -v "$BUILD_VOL":/OrcaSlicer/build \ - "$IMAGE" bash -lc " - cd /OrcaSlicer/build || exit 1 - cmake . > /tmp/cfg.log 2>&1 || { echo 'CONFIGURE FAILED'; tail -25 /tmp/cfg.log; exit 1; } - # Twice, deliberately. src/libslic3r/CMakeLists.txt publishes OCCT_LIBS as CACHE INTERNAL - # at the END of its own configure, so a first pass after that list changes links the - # PREVIOUS one and drops TKBool/TKOffset — a wall of TopOpeBRepBuild undefined references - # that reads as a broken OCCT install and is not. Trap 4. - cmake . > /tmp/cfg2.log 2>&1 || { echo 'RECONFIGURE FAILED'; tail -25 /tmp/cfg2.log; exit 1; } - ninja -f build-Release.ninja -j$JOBS $TARGET > /tmp/bld.log 2>&1 - rc=\$? - echo \"EXIT=\$rc\" - grep -n 'error:' /tmp/bld.log | head -20 - tail -4 /tmp/bld.log - ls -la /OrcaSlicer/build/src/Release/$BIN 2>/dev/null - exit \$rc - " || rc=$? - -# A target-only build writes src/Release/, but this fork's start-headless-gui.sh may default BIN to the -# PACKAGED path that only build_linux.sh refreshes — launching with the default would then run a -# stale binary. Pass BIN explicitly. See scripts/CAD/rig_build_traps.md. -echo "=== launch the rig on the binary just built ===" -echo " docker exec -e BIN=/OrcaSlicer/build/src/Release/$BIN ${PREFIX}-gui /OrcaSlicer/scripts/CAD/start-headless-gui.sh" -exit "$rc" diff --git a/scripts/CAD/focus-loop.sh b/scripts/CAD/focus-loop.sh deleted file mode 100755 index 3c75f64a49..0000000000 --- a/scripts/CAD/focus-loop.sh +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/bin/env bash -# One turn of the keyboard-focus convergence loop, start to verdict, with no human in it. -# -# scripts/CAD/focus-loop.sh # full turn: sync -> build -> restart -> assert -# SKIP_BUILD=1 scripts/CAD/focus-loop.sh # re-assert against the binary already on the host -# -# Exit 0 only when every gate holds. Any other exit is a failing gate and names which. -# -# WHY THIS EXISTS. The focus defects in the Design tab were chased for days by hand: build, launch -# the GUI, drive it with xdotool, read a screenshot, guess, repeat. That needs a person at every -# step and it is where the days went. This does not: behemoth carries an agent-owned Xvfb :10 with -# openbox, the app, xdotool and an MCP socket that reports sketch state as JSON, so a turn is -# sync -> build -> restart -> assert, and the ASSERTION is the verdict, not my reading of a picture. -# -# WHY BEHEMOTH AND NOT THE orcacad-gui RIG CONTAINER. The rig was the obvious host and it does not -# work for this: its image pins a dependency set 216 non-CAD source files behind cad-mainline -# (assimp among them), so today's CAD sources call GUI_App::is_auto_close_sketch_loops and -# MainFrame::ensure_design_panel, which that tree has never heard of. Syncing all of src/ to fix -# that needs a deps rebuild measured in hours. behemoth already builds this exact tree, already -# runs a WM on :10, and is the machine the user actually runs the product on — so the loop asserts -# against the shipping artefact rather than a stale twin. Reviving the rig means rebuilding its -# deps image first; until then it cannot adjudicate anything about this code. -# -# SC2029: every ssh command below quotes locally-expanded config (HOST, SRC, DISP) on purpose -# -- the remote tree is not this checkout and has no such config of its own. -# shellcheck disable=SC2029 -set -uo pipefail - -HOST="${HOST:-tommaso@100.103.234.2}" -DISP="${DISP:-:10}" -SRC="${SRC:-\$HOME/projects/orca/orcacad-native/src}" -TRACE="${TRACE:-/tmp/ux-focus-loop.log}" -REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" -BIN="build/src/Release/orca-slicer" - -say() { printf '\n=== %s\n' "$*"; } -die() { printf 'GATE FAILED: %s\n' "$*" >&2; exit 1; } - -ssh -o ConnectTimeout=10 "$HOST" true || die "cannot reach $HOST" - -# ---------------------------------------------------------------- S1 sync -# Only the CAD paths and the ladders. behemoth's tree is a full cad-mainline checkout kept in step -# by its own realign; pushing unrelated files from here would make the build host disagree with -# git for reasons no later session could reconstruct. -say "S1 sync" -rsync -q "$REPO"/src/slic3r/GUI/CAD/*.{cpp,hpp} "$HOST:$SRC/src/slic3r/GUI/CAD/" || die "sync GUI/CAD" -rsync -q "$REPO"/src/libslic3r/CAD/*.{cpp,hpp} "$HOST:$SRC/src/libslic3r/CAD/" || die "sync libslic3r/CAD" -rsync -q "$REPO"/scripts/CAD/check-gui-click-edit.py "$REPO"/scripts/CAD/check-gui-sketching.py \ - "$HOST:/tmp/" || die "sync ladders" -echo " sources + ladders in place" - -# ---------------------------------------------------------------- S2 build -# flock: two concurrent Orca builds once OOM'd this machine for 2h28m. Every build script on the -# fleet takes this same lock. -# -# Grade the BINARY'S TIMESTAMP, never the build command's exit code. This is a Ninja Multi-Config -# tree whose default rules are Debug while the artefact under test is Release, so a wrong-config -# invocation returns success in seconds having touched nothing — it cost a wasted cycle here -# before anyone thought to look at the file. -if [ -z "${SKIP_BUILD:-}" ]; then - say "S2 build" - before=$(ssh "$HOST" "stat -c %Y $SRC/$BIN 2>/dev/null || echo 0") - ssh "$HOST" "flock /tmp/orca-rig-build.lock \$HOME/projects/orca/orcacad-native/rebuild.sh > /tmp/focus-build.log 2>&1" - rc=$? - after=$(ssh "$HOST" "stat -c %Y $SRC/$BIN 2>/dev/null || echo 0") - if [ "$rc" != 0 ] || [ "$after" = "$before" ]; then - ssh "$HOST" "grep -m5 -B2 'error:' /tmp/focus-build.log; tail -5 /tmp/focus-build.log" - die "S2 build (exit $rc, binary $( [ "$after" = "$before" ] && echo unchanged || echo rebuilt ))" - fi - echo " built" -fi - -# ---------------------------------------------------------------- S3 F2P -# The ladder launches and tears down the app itself, in its own datadir, so nothing here has to -# manage a process. It types WITHOUT clicking the field first, which is the whole contract. -say "S3 fail-to-pass: type without clicking the field" -ssh "$HOST" "cd $SRC && DISPLAY=$DISP python3 /tmp/check-gui-click-edit.py \ - --display $DISP --bin $BIN --trace $TRACE" -f2p=$? - -# ---------------------------------------------------------------- S4 P2P -say "S4 pass-to-pass: the existing gesture ladder" -ssh "$HOST" "cd $SRC && DISPLAY=$DISP python3 /tmp/check-gui-sketching.py 2>&1 | tail -3" -p2p=$? - -say "VERDICT" -[ "$f2p" = 0 ] || die "F2P: a tool did not take the typed value (exit $f2p)" -[ "$p2p" = 0 ] || die "P2P: the gesture ladder regressed (exit $p2p)" -echo "ALL GATES HELD" diff --git a/scripts/CAD/gen_offer_table.py b/scripts/CAD/gen_offer_table.py index 7a797c0c5c..11d36469a8 100644 --- a/scripts/CAD/gen_offer_table.py +++ b/scripts/CAD/gen_offer_table.py @@ -195,8 +195,9 @@ def main(): ] text = "\n".join(lines) # --check: prove the checked-in header IS what this generator produces, and change nothing. - # The header calls itself GENERATED and was hand-edited anyway; a claim like that is only - # worth having if something enforces it, so run-all-checks.sh runs this on every gate. + # The header calls itself GENERATED; a claim like that is only worth having if something + # enforces it, so the check_cad_offer_table.yml workflow runs this on every push and pull + # request that touches the atlas, this generator or the header. if "--check" in sys.argv: have = open(OUT, encoding="utf-8").read() if os.path.exists(OUT) else "" if have == text: diff --git a/scripts/CAD/rig_build_traps.md b/scripts/CAD/rig_build_traps.md deleted file mode 100644 index b620b244d9..0000000000 --- a/scripts/CAD/rig_build_traps.md +++ /dev/null @@ -1,151 +0,0 @@ -# Rig build traps - -The build rig is two long-lived containers, `snapmaker-gui` and `orcacad-gui`, one per fork. Each -mounts only its fork's build volume (`snapmaker_buildcache` / `orcacad_buildcache`) at -`/OrcaSlicer/build`, its fork's `resources/`, and a shots directory — nothing else. They run the -binary; they do not build it. Rebuild with `scripts/CAD/build-gui.sh`. - -| fork repo | project() | deps image | build volume | GUI container | binary | -|---|---|---|---|---|---| -| `Snapmaker` | `Snapmaker_Orca` | `snapmaker-deps` | `snapmaker_buildcache` | `snapmaker-gui` | `snapmaker-orca` | -| `orca_cad` | `OrcaSlicer` | `orcacad-deps` | `orcacad_buildcache` | `orcacad-gui` | `orca-slicer` | - -`scripts/CAD/build-gui.sh` exists alongside `scripts/CAD/build-gui-incremental.sh` for one reason: it does a -target-only `ninja` into the volume the GUI rig launches from, so a session can test a single -change without a full repackage, whereas `build-gui-incremental.sh` runs the full packaged build. -Both start a throwaway container from the deps image with the live repo mounted over the baked -tree — never build inside the GUI container (Trap 1). - -Every trap below has already cost about a session to re-derive, once each. They are recorded now -so no fresh session pays them again. Symptoms, causes, and exact recovery commands follow. - ---- - -## Trap 1 — never configure inside the GUI container - -**Symptom.** After building inside the GUI container, the fork's targets no longer exist; ninja -reports an unknown target, and `orca-slicer` / `OrcaSlicer` have been replaced by -`snapmaker-orca` / `Snapmaker_Orca`. - -**Cause.** The GUI image's baked `/OrcaSlicer` tree is the Jun-13 Snapmaker-derived source -(`project(Snapmaker_Orca)`, executable `snapmaker-orca`). `orcacad-deps` is layered on -`snapmaker-deps`, so even on the mainline fork the baked tree is the other fork's. A `cmake .` -there reconfigures the shared build dir under the wrong project name. - -**Fix.** Build only via `scripts/CAD/build-gui.sh`, which starts a throwaway container from the deps -image with the live repo mounted over the baked tree — `src`, `resources`, `cmake`, `deps_src`, -`localization`, `CMakeLists.txt`, `version.inc` — and writes into the same volume the rig -launches from. - ---- - -## Trap 2 — stale `NLopt_DIR` in CMakeCache - -**Symptom.** Configure fails with `Cannot find NLopt library 'nlopt_cxx' in '/lib'`. - -**Cause.** `cmake/modules/FindNLopt.cmake:26` is `set(NLopt_DIR $ENV{NLOPT})`. With `NLOPT` -unset that expands to `set(NLopt_DIR)` — zero arguments — which *unsets the normal variable* and -lets a leftover CACHE entry of the same name (e.g. `/lib/cmake/nlopt`) show through the -following `if(NOT NLopt_DIR)`. The `else()` branch then searches for `nlopt_cxx` under -`${NLopt_DIR}/lib` with `NO_DEFAULT_PATH`, while the deps prefix ships plain `nlopt`. - -**Fix.** From inside the build dir: - - cmake -U NLopt_DIR -U NLopt_LIBS . - -Do **not** `sed` the entry out of `CMakeCache.txt` — deleting a line breaks the cache parser. - ---- - -## Trap 3 — the image lacks `deps_src/pybind11` - -**Symptom.** Configure aborts with `pybind11 headers not found in /OrcaSlicer/deps_src/pybind11. -Did you initialize submodules?` (the `FATAL_ERROR` guarding `PYBIND11_SOURCE_DIR` in the mainline -fork's root `CMakeLists.txt`, near line 948). - -**Cause.** The deps image predates that requirement. Only the mainline (`orca_cad`) fork has -`deps_src/pybind11` and the requirement; Snapmaker has neither. - -**Fix.** Mount `deps_src` over the baked tree — `scripts/CAD/build-gui.sh` does. Corollary: mounting a -Snapmaker tree into an `orcacad-deps` build reproduces this error exactly. - ---- - -## Trap 4 — `OCCT_LIBS` lags one configure - -**Symptom.** A wall of undefined references to `TopOpeBRepBuild` symbols. It reads as a broken -OCCT installation. It is not. - -**Cause.** `src/libslic3r/CMakeLists.txt:603` does -`set(OCCT_LIBS "${OCCT_LIBS}" CACHE INTERNAL "OCCT toolkits linked by libslic3r")` at the END of -its own configure, while the consumer in the root `CMakeLists.txt` (`if (NOT OCCT_LIBS)` … -`foreach (_tk IN LISTS OCCT_LIBS)`) reads whatever is already in the cache. The first reconfigure -after the `TKFillet TKOffset` prepend (`src/libslic3r/CMakeLists.txt:599`) therefore links the -previous list and drops `TKBool`/`TKOffset`. - -**Fix.** Configure twice. `scripts/CAD/build-gui.sh` runs `cmake .` twice for exactly this reason; if -you ever configure by hand, run it twice. - ---- - -## Trap 5 — `SLIC3R_CAD=ON` in the cache, macro never defined - -**Symptom.** The build succeeds and links, but the Design tab is simply absent — or it fails with -`class GLCanvas3D has no member named set_design_sketch_tool`. - -**Cause.** The cache carries `SLIC3R_CAD=ON`, but the root `CMakeLists.txt` actually configured is -a stale baked copy that predates the gate and never runs `add_definitions(-DSLIC3R_CAD)` (the -gate is `if (SLIC3R_CAD)` / `add_definitions(-DSLIC3R_CAD)` in the root list — line 179/180 in -Snapmaker, 319/320 in orca_cad). Every `#ifdef SLIC3R_CAD` block therefore compiles out while the -option still reads ON. - -**Fix.** Always mount the live `CMakeLists.txt` and `cmake/` — never inherit them from the image. -This is why `scripts/CAD/build-gui-incremental.sh`, `scripts/CAD/run-kernel-tests.sh` and `scripts/CAD/build-gui.sh` -all mount both. - ---- - -## The binary the rig actually launches - -`ninja ` writes `/OrcaSlicer/build/src/Release/`; only `build_linux.sh` -additionally packages to `/OrcaSlicer/build/package/bin/`. `orca_cad`'s -`scripts/CAD/start-headless-gui.sh` defaults `BIN` to `src/Release/orca-slicer`, but Snapmaker's defaults to -`package/bin/snapmaker-orca`. So after a target-only rebuild on Snapmaker, launching -`start-headless-gui.sh` with its default runs the **stale packaged** binary — the change under test is -invisible and the session hunts a phantom. Pass `BIN` explicitly: - - docker exec -e BIN=/OrcaSlicer/build/src/Release/snapmaker-orca snapmaker-gui /OrcaSlicer/scripts/CAD/start-headless-gui.sh - -`scripts/CAD/build-gui.sh` prints the correct line for the current fork when it finishes. - -Note also that the GUI containers do **not** mount `scripts/`: `/OrcaSlicer/scripts` inside them -is the baked copy, so a local edit to `start-headless-gui.sh` has no effect until you -`docker cp scripts/CAD/start-headless-gui.sh :/OrcaSlicer/scripts/`. - ---- - -## Trap 6 — `src/Release/` resolves resources to `build/resources`, which may not exist - -The binary derives `resources_dir()` from its own location, so the `src/Release/` one looks in -`/OrcaSlicer/build/resources` while the packaged one looks inside `build/package/`. Only the -packaging step creates the latter; nothing creates the former. Without it the app fails every -`Failed to add custom font ".../build/resources/fonts/…"`, logs `Health check is not running`, -and **exits 255 with nothing on stdout** — which reads exactly like a crash in whatever you just -changed. Measured 2026-08-02: an hour was nearly spent bisecting a GUI change that was fine. - -`build/` is the shared cache volume, so one symlink fixes it permanently, and pointing it at the -bind-mounted repo tree means the rig also picks up new `resources/images/*.svg` without a rebuild: - - docker exec -gui ln -sfn /OrcaSlicer/resources /OrcaSlicer/build/resources - -Tell the two apart before debugging: a resource failure dies in the first second with no window; -a real fault in your code gets past the version banner. Compare -`~/.config//log/.log.0` against a known-good run — 47 lines versus 340 is the tell. - -## Trap 7 — a single-instance app plus a path-matched `pkill` - -`start-headless-gui.sh` used to kill by `"$BIN"`, while its own `app_pid()` matched by BASENAME. Launch -with a `BIN` that differs from the running instance's path and the old process survives, keeps -the single-instance lock, and the new one exits seconds after loading fonts — then `status` -reports the *stale* pid as a healthy session. Fixed by killing on the basename; `status` now also -prints `binary : $(readlink -f /proc//exe)`. **Read that line before trusting a screenshot.** diff --git a/scripts/CAD/run-all-checks.sh b/scripts/CAD/run-all-checks.sh deleted file mode 100755 index 8a99a3b6cb..0000000000 --- a/scripts/CAD/run-all-checks.sh +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/env bash -# Every ladder, in one command, as the gate before a push that touched the Design tab. -# -# WHY A SCRIPT AND NOT CI. Three of the four rungs need a running application with an OpenGL -# canvas and synthetic input; GitHub's runners have neither. So the gate is local and explicit: -# run this, read the last line, and do not push a red one. The kernel suite is the only part CI -# can carry, and it already does. -# -# scripts/CAD/run-all-checks.sh # kernel + engine + corpus (every 20th) + gestures + offer -# FULL=1 scripts/CAD/run-all-checks.sh # corpus over ALL 997 sheets (~25 min) -# SKIP_GUI=1 scripts/CAD/run-all-checks.sh # kernel only, for a machine with no rig -# -# The rig container is expected to be up with the app running and ORCA_CAD_MCP set; bring it up -# with scripts/CAD/start-headless-gui.sh inside it. The corpus lives at /corpus in that container. -set -uo pipefail -# ../.. -- this script lives in scripts/CAD/, so one level up is scripts/, not the repo -# root. It was scripts/ladder-all.sh when it was written; the move fixed the three sibling -# scripts and missed this one, which left every rung looking for its own path under -# scripts/scripts/ and reporting instant failures that were all the same typo. -cd "$(dirname "${BASH_SOURCE[0]}")/../.." || exit 1 - -# orcacad-gui, NOT snapmaker-gui: that is the other fork's rig, and defaulting to it makes -# this gate verify the wrong fork's binary while reporting green. run-kernel-tests.sh -# carries the same warning about the build volume, where the defect was found first. -C="${C:-orcacad-gui}" -CORPUS="${CORPUS:-/corpus}" -STEP="${STEP:-20}" -[ -n "${FULL:-}" ] && STEP=1 -fail=0 - -step() { - local name="$1"; shift - echo - echo "=== $name ===" - if "$@"; then echo "--- $name OK"; else echo "--- $name FAILED"; fail=1; fi -} - -# This fork's rig runs Xvfb on :11, the other fork's on :10, and the check scripts default -# to ":10" when DISPLAY is unset -- which docker exec leaves unset. The rungs that drive the -# GUI therefore looked for a window on a display that does not exist here and reported -# "FATAL no app window on :10", which reads like a dead app rather than a wrong display. -RIG_DISPLAY="${RIG_DISPLAY:-:11}" - -# SC2329: every call goes through step(), which invokes it via "$@", so shellcheck -# cannot see the callers below. -# shellcheck disable=SC2329 -run_in_rig() { # copy the script in fresh, then run it there - docker cp "$1" "$C:/tmp/$(basename "$1")" >/dev/null || return 1 - shift - docker exec -e DISPLAY="$RIG_DISPLAY" "$C" python3 "$@" -} - -# FIRST, and it needs no rig: the offer table the menu is compiled from must be what the atlas -# says. The header calls itself GENERATED and had been hand-edited anyway — which cost four rows -# that existed only in the header, one row wired to the wrong action, and a count of 91 for a -# 92-row array, so the last verb was unreachable (z8rs, ziam). -# The atlas and its generator live beside this script, in scripts/CAD/: they are build inputs -# for a checked-in header, not documentation, so they do not belong under docs/. -step "offer table matches the atlas" python3 scripts/CAD/gen_offer_table.py --check - -step "kernel suite" scripts/CAD/run-kernel-tests.sh --vol "${KVOL:-orcacad_kerneltest}" - -if [ -z "${SKIP_GUI:-}" ]; then - step "engine ladder (rungs 1-8, scripted geometry)" \ - run_in_rig scripts/CAD/check-sketch-engine.py /tmp/check-sketch-engine.py - step "corpus rung (real drawings, every ${STEP}th)" \ - run_in_rig scripts/CAD/check-sketch-engine-corpus.py /tmp/check-sketch-engine-corpus.py --corpus "$CORPUS" --step "$STEP" - step "corpus scale rung (the heaviest sheets)" \ - run_in_rig scripts/CAD/check-sketch-engine-corpus.py /tmp/check-sketch-engine-corpus.py --corpus "$CORPUS" --scale - step "gesture ladder (mouse and keyboard)" \ - run_in_rig scripts/CAD/check-gui-sketching.py /tmp/check-gui-sketching.py - # The offer ladder needs TWO extra things the others do not: the app must have been launched - # with ORCA_CAD_KEYTRACE=1 (its [OFFER] lines are the whole instrument), and it reads the - # generated offer table to predict what each selection should show — which is not in the - # container's own baked source tree, so it is copied in beside the script — /tmp, where - # run_in_rig puts the script, is one of the paths the ladder looks in. - docker cp src/slic3r/GUI/CAD/DesignOffer.hpp "$C:/tmp/DesignOffer.hpp" >/dev/null - step "offer ladder (right-click, the menu, the verbs behind it)" \ - run_in_rig scripts/CAD/check-gui-context-menu.py /tmp/check-gui-context-menu.py -fi - -echo -if [ "$fail" -eq 0 ]; then echo "ALL LADDERS HELD"; else echo "AT LEAST ONE LADDER FAILED"; fi -exit "$fail" diff --git a/scripts/CAD/run-kernel-tests.sh b/scripts/CAD/run-kernel-tests.sh deleted file mode 100755 index ac506a7056..0000000000 --- a/scripts/CAD/run-kernel-tests.sh +++ /dev/null @@ -1,159 +0,0 @@ -#!/usr/bin/env bash -# Headless CAD-kernel test loop. THE verification contract for delegated work: -# exit 0 means the kernel builds and the selected Catch2 tags pass. Nothing else counts. -# -# Builds only the `libslic3r_tests` target (not the GUI app), so a round trip is -# minutes, not tens of minutes. Needs no display: every [CadDocument] case builds a -# CadDocument, recompute()s it and asserts on geometry. -# -# Usage: -# scripts/CAD/run-kernel-tests.sh # [CadDocument] tags, default volume -# scripts/CAD/run-kernel-tests.sh --tags '[CadDocument],[Sketch]' -# scripts/CAD/run-kernel-tests.sh --vol wt_mirror # private build cache (parallel workers) -# scripts/CAD/run-kernel-tests.sh --host tommaso@100.103.234.2 # build on a remote host -# -# Parallel workers MUST pass a distinct --vol: two builds sharing one cache corrupt -# each other. A new volume pays one full build; runs after that are incremental. -# -# --host exists because the deps image lives wherever it was first built. It rsyncs this -# working tree to a per-volume staging dir on that host and re-runs this same script -# there, so the verification contract is identical either way. Drop --host once the image -# is present locally. -# Rig build traps already paid for once each (stale project, NLopt cache, pybind11, OCCT_LIBS, SLIC3R_CAD gate): scripts/CAD/rig_build_traps.md -set -euo pipefail - -REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" -# orcacad-deps, NOT snapmaker-deps: this fork is mainline-based and needs Eigen 5.0.1, -# CGAL 6.2.1, wx 3.3.2 and Python 3.12 Development.Embed, none of which snapmaker-deps has. -# With the wrong image CMake dies at configure, which is exactly why this fork went -# M1-M8 without ever compiling (see commit 1633005bba). -IMAGE="${IMAGE:-orcacad-deps}" -# Must NOT default to snapmaker_buildcache: that is the other fork's volume, and pointing -# this fork at it makes the two silently trade build artefacts. build-gui-incremental.sh had the -# identical defect and was fixed to orcacad_buildcache; this script was missed. -VOL="${BUILD_VOL:-orcacad_kerneltest}" -# No exclusions. Both cases that used to be quarantined now run: the solver SIGABRT on -# circle-line tangency is fixed (tkz), and the internal-thread case turned out to have -# correct geometry and a wrong reference in the test (kzy). A green run here now means -# the whole CAD suite passed, not "everything except the two we gave up on". -# -# ...and that claim was still not true, because the default tag was [CadDocument] alone while -# four CAD test files carry their own tags and NOTHING ELSE selected them. test_sketchinference -# ([inference], 15), test_sketchedit ([SketchEdit], 23), test_sketchconstraints -# ([SketchConstraints], 8) and test_sketchimport ([SketchImport], 4) never ran here, nor did the -# older [slvs]-only cases in test_slvs_constraints. Measured 2026-08-31: the default reported -# 2624 assertions / 206 cases, the full set 7648 / 264 -- so the gate was speaking for about a -# third of the assertions, and a whole file could be added, tagged by its own convention, and -# stay dark while the suite printed green. All 58 were passing; the coverage was simply never -# exercised. Adding a tag here is now part of adding a test file. -TAGS="${TAGS:-[CadDocument],[inference],[SketchEdit],[SketchConstraints],[SketchImport],[slvs]}" -HOST="" - -while [[ $# -gt 0 ]]; do - case "$1" in - --vol) VOL="$2"; shift 2 ;; - --tags) TAGS="$2"; shift 2 ;; - --image) IMAGE="$2"; shift 2 ;; - --host) HOST="$2"; shift 2 ;; - *) echo "unknown arg: $1" >&2; exit 2 ;; - esac -done - -echo "REPO=$REPO IMAGE=$IMAGE VOL=$VOL TAGS=$TAGS HOST=${HOST:-local}" - -if [[ -n "$HOST" ]]; then - # Stage per-volume so parallel workers never share a remote tree. - REMOTE="kt-$VOL" # relative: ssh and rsync both start in the remote home dir - # SC2029: $REMOTE expanding on the CLIENT is the point -- it is derived from $VOL here, - # and the remote has no such variable. The rsync destination below expands it the same way. - # shellcheck disable=SC2029 - ssh "$HOST" "mkdir -p $REMOTE" - # Only the inputs the build reads. --delete keeps a stale file from a prior worker from - # silently compiling in. - rsync -a --delete \ - "$REPO/src" "$REPO/tests" "$REPO/resources" "$REPO/cmake" "$REPO/scripts" \ - "$REPO/CMakeLists.txt" \ - "$HOST:$REMOTE/" - exec ssh "$HOST" "cd $REMOTE && scripts/CAD/run-kernel-tests.sh --vol '$VOL' --tags '$TAGS' --image '$IMAGE'" -fi - -if ! docker image inspect "$IMAGE" >/dev/null 2>&1; then - echo "FATAL: image '$IMAGE' not present locally. Either transfer it, or pass" >&2 - echo " --host to build where the image already exists." >&2 - exit 3 -fi - -# A private volume is always built CLEAN on first use. Cloning a warm cache from another -# tree looks tempting but is a correctness trap: rsync preserves source mtimes, so ninja -# compares foreign object timestamps against them, decides everything is up to date, and -# relinks stale objects. That produced a binary with NO [CadDocument] tests at all while -# reporting success -- a green run that tested nothing. Pay the one-off full build instead; -# incremental rebuilds within a volume are correct because the mtimes then share a lineage. -if ! docker volume inspect "$VOL" >/dev/null 2>&1; then - echo "=== $VOL: new volume, clean configure + full build (one-off, slow) ===" - docker volume create "$VOL" >/dev/null -fi - -# tests/ is mounted too -- unlike build-gui-incremental.sh, this script exists precisely to -# compile tests being edited. CMakeLists.txt and cmake/ carry the SLIC3R_CAD gate; taking -# them from the baked image instead leaves the gate off and the CAD symbols vanish. - -# ---- OOM guard (2026-08-21) ------------------------------------------------------------- -# Two of these builds ran at once on 2026-08-21, each with ninja -j$(nproc)=16: ~36 cc1plus -# holding 42 GB of a 62 GB box -> global OOM at 21:05, a 2h28m kill storm, ssh unreachable, -# lightdm destroyed. Neither build produced a single object. scripts/CAD/build-gui.sh grew the -# bounds first; every script that starts a compile needs the same three, or the guard is only -# as strong as the script you happened not to use. -# flock — the lock path is SHARED with build-gui.sh and the other fork on purpose, so -# concurrent builds serialise instead of summing. -# -j — bounded parallelism; ~1.17 GB per cc1plus was the measured average. -# --memory — the actual guarantee: a runaway build dies in its own cgroup instead of taking -# the host down. --memory-swap equal to --memory forbids swap, which is what made -# ssh hang. -JOBS="${JOBS:-12}" -MEM="${MEM:-40g}" -LOCK=/tmp/orca-rig-build.lock - -exec 9>"$LOCK" -if ! flock -n 9; then - echo "another build holds $LOCK — waiting (this is the OOM guard, not a hang)" - flock 9 -fi - -docker run --rm \ - --memory="$MEM" --memory-swap="$MEM" \ - -v "$REPO/src":/OrcaSlicer/src \ - -v "$REPO/tests":/OrcaSlicer/tests \ - -v "$REPO/resources":/OrcaSlicer/resources \ - -v "$REPO/CMakeLists.txt":/OrcaSlicer/CMakeLists.txt \ - -v "$REPO/cmake":/OrcaSlicer/cmake \ - -v "$REPO/deps_src":/OrcaSlicer/deps_src \ - -v "$VOL":/OrcaSlicer/build \ - "$IMAGE" \ - bash -lc "set -e - cd /OrcaSlicer - DESTDIR=/OrcaSlicer/deps/build/destdir/usr/local - export PATH=\$DESTDIR/bin:\$PATH # wx-config, and anything else the deps prefix ships - # Configure unconditionally. Guarding on 'CMakeCache.txt exists' is wrong: a FAILED - # configure still writes that file, so the guard then skips reconfiguring forever and - # every later run reuses a poisoned cache while ignoring corrected flags. A no-op - # reconfigure costs seconds; that bug costs an afternoon. - # SLIC3R_GTK=3 and BUILD_TESTS=ON are not optional extras: src/CMakeLists.txt turns - # SLIC3R_GTK into 'wx-config --toolkit=gtk', so omitting it asks for toolkit 'gtk' - # and no wx build matches -> 'Could NOT find wxWidgets'. BUILD_TESTS=ON is what makes - # the libslic3r_tests target exist at all. build_linux.sh sets both (lines 218, 226). - cmake -S . -B build -G 'Ninja Multi-Config' \ - -DCMAKE_PREFIX_PATH=\$DESTDIR \ - -DwxWidgets_CONFIG_EXECUTABLE=\$DESTDIR/bin/wx-config \ - -DSLIC3R_GTK=3 -DBUILD_TESTS=ON -DSLIC3R_GUI=OFF \ - -DSLIC3R_CAD=ON -DSLIC3R_STATIC=1 -DORCA_TOOLS=ON -DCMAKE_BUILD_TYPE=Release - # SLIC3R_GUI=OFF: this script builds ONLY libslic3r_tests, which links libslic3r and no GUI - # code, but cmake still PROCESSES the if SLIC3R_GUI block of src/CMakeLists.txt (lines 16-98) - # and every find_package inside it. That made the kernel suite depend on the GUI dependency - # set for no benefit, and it broke the moment upstream added wxInspector as a REQUIRED - # find_package at line 92: the orcacad-deps image predates it, so configure died pointing at - # src/CMakeLists.txt:92 while nothing about the kernel had changed. Turning the block off is - # not a workaround for that one dependency; it is the kernel suite finally declaring what it - # actually needs, so the next GUI-side dependency upstream adds cannot break it either. - cmake --build build --config Release --target libslic3r_tests -- -j$JOBS - ./build/tests/libslic3r/Release/libslic3r_tests '$TAGS' --order decl" diff --git a/scripts/CAD/start-headless-gui.sh b/scripts/CAD/start-headless-gui.sh deleted file mode 100755 index d9944da8cf..0000000000 --- a/scripts/CAD/start-headless-gui.sh +++ /dev/null @@ -1,148 +0,0 @@ -#!/usr/bin/env bash -# Bring the headless GUI up on a VNC-served X display, ready to drive or to attach Remmina to. -# -# Runs INSIDE the long-lived GUI container (see the header of scripts/CAD/build-gui-incremental.sh for how -# that container is created). Idempotent: safe to re-run to recover a session whose app died. -# -# docker exec /OrcaSlicer/scripts/CAD/start-headless-gui.sh # launch + settle -# docker exec /OrcaSlicer/scripts/CAD/start-headless-gui.sh --status # report, change nothing -# -# WHY THIS EXISTS. Dismissing the first-run dialogs by computing the titlebar close box from -# `xdotool getwindowgeometry --shell` and clicking it went wrong whenever the dialog had already -# closed: the eval left the geometry variables stale or empty, the click landed at a garbage -# coordinate, and it repeatedly hit the Sketch button in the toolbar underneath, so the app came up -# in sketch mode with a stray Sketch feature. Three of those in one session. -# -# The titlebar click is nevertheless the RIGHT mechanism and is kept. `xdotool windowclose` looks -# cleaner but kills the app: it destroys the GdkWindow out from under the dialog and the process -# dies with "GdkWindow unexpectedly destroyed", three GLib-GObject criticals and a segfault -# (measured 2026-07-30). Escape does not close the Setup Wizard either. So the fix is not a -# different mechanism, it is refusing to click on geometry we have not validated. -set -euo pipefail - -DISP="${DISP:-:11}" -GEOM="${GEOM:-1920x1080}" -BIN="${BIN:-/OrcaSlicer/build/src/Release/orca-slicer}" -# Packaging cannot bundle python (the deps python layer carries a doubled-DESTDIR RUNPATH), so the -# build-tree binary needs the deps libpython on the path. Packaging-only issue; the app runs fine. -LIBPY="/OrcaSlicer/deps/build/destdir/usr/local/libpython/lib" -LIBPY2="/OrcaSlicer/build/src/Release/python/lib" -LOG="${LOG:-/tmp/gui-session.log}" - -export DISPLAY="$DISP" HOME=/root -export LIBGL_ALWAYS_SOFTWARE=1 GALLIUM_DRIVER=llvmpipe -# The ladders read the document back through the MCP socket, and the offer ladder's only -# instrument is the [OFFER] keytrace. Neither is on by default, and a session launched without -# them comes up looking perfectly healthy: the window is there, status says app up, and every -# ladder then dies on "Connection refused" — which reads as a dead app rather than a rig that was -# started without its instrument. The script that launches the rig is where they belong. -export ORCA_CAD_MCP="${ORCA_CAD_MCP:-/tmp/mcp.sock}" -export ORCA_CAD_KEYTRACE="${ORCA_CAD_KEYTRACE:-1}" -export LD_LIBRARY_PATH="$LIBPY:$LIBPY2:${LD_LIBRARY_PATH:-}" -mkdir -p /root/.config # startup dies in boost::filesystem::create_directory without this - -# Skip zombies. This container accumulates instances of the app across runs, and pgrep -# matches them, so the naive "first match" reported a dead pid as if the session were healthy. -app_pid() { - local p - for p in $(pgrep -f "$(basename "$BIN")" 2>/dev/null); do - [ "$(awk "{print \$3}" "/proc/$p/stat" 2>/dev/null)" = "Z" ] && continue - echo "$p"; return 0 - done - return 1 -} - -status() { - echo "display : $(pgrep -f "Xvfb $DISP" >/dev/null && echo up || echo DOWN)" - echo "wm : $(pgrep -x openbox >/dev/null && echo up || echo DOWN)" - if pgrep -x x11vnc >/dev/null; then echo "vnc : up on :5900" - elif ! command -v x11vnc >/dev/null; then echo "vnc : n/a (x11vnc not installed here)" - else echo "vnc : DOWN"; fi - local p; p="$(app_pid || true)" - echo "app : ${p:-DOWN}" - # WHICH binary is on screen, not just that something is. A pid alone cannot tell you whether - # you are looking at the build you just linked or one from last week, and that is precisely - # the question every rig verification is asking. - [ -n "${p:-}" ] && echo "binary : $(readlink -f "/proc/$p/exe" 2>/dev/null || echo unknown)" - [ -n "${p:-}" ] && echo "windows : $(xdotool search --name . getwindowname %@ 2>/dev/null | paste -sd'|' -)" - return 0 -} - -[ "${1:-}" = "--status" ] && { status; exit 0; } - -# --- desktop: Xvfb, a window manager, and the VNC server ------------------------------------ -# openbox is REQUIRED: without it xdotool windowactivate aborts with "windowmanager claims not to -# support _NET_ACTIVE_WINDOW" and dialogs never take focus. -pgrep -f "Xvfb $DISP" >/dev/null || { nohup Xvfb "$DISP" -screen 0 "${GEOM}x24" -nolisten tcp >/tmp/xvfb.log 2>&1 & sleep 3; } -pgrep -x openbox >/dev/null || { nohup openbox >/tmp/openbox.log 2>&1 & sleep 1; } -if ! pgrep -x x11vnc >/dev/null && command -v x11vnc >/dev/null; then - AUTH=() - [ -f /root/.vnc/passwd ] && AUTH=(-rfbauth /root/.vnc/passwd) - nohup x11vnc -display "$DISP" -rfbport 5900 "${AUTH[@]}" -forever -shared -noxdamage \ - >/tmp/x11vnc.log 2>&1 & - sleep 2 -fi - -# --- app ------------------------------------------------------------------------------------ -# Kill by BASENAME, not by "$BIN". The app enforces a single instance, so an older copy launched -# from a DIFFERENT path (the packaged build/package/bin/ one, say, when BIN points at the freshly -# linked build/src/Release/ one) survives a path-matched pkill, keeps the instance lock, and the -# new process exits seconds after loading fonts — leaving no error anywhere. app_pid() below has -# always matched by basename, so status then reported that stale process as a healthy session: -# the launch looked green while the window on screen was days old. Measured 2026-08-02, where it -# nearly passed a UI change against a Jul-30 binary. The killer and the reporter must agree on -# what counts as "the app". -pkill -9 -f "$(basename "$BIN")" 2>/dev/null || true -sleep 2 -nohup "$BIN" >"$LOG" 2>&1 & -echo "launched $(basename "$BIN") pid $!" - -# Wait for the main window rather than sleeping a fixed amount: cold starts vary a lot under -# software GL, and a fixed sleep either wastes time or races. -for _ in $(seq 1 40); do - xdotool search --name "Untitled" >/dev/null 2>&1 && break - sleep 1 -done - -# --- first-run dialogs ---------------------------------------------------------------------- -# Click the titlebar close box, but only on geometry we have just read for a window that still -# exists, and only if the resulting point is inside the screen. Every variable is unset first so a -# failed read cannot leave the previous dialog's numbers behind — that is the whole bug. -screen_w="${GEOM%x*}"; screen_h="${GEOM#*x}" -close_dialog() { - local name="$1" id X Y WIDTH HEIGHT cx cy - id="$(xdotool search --name "$name" 2>/dev/null | head -1 || true)" - [ -z "$id" ] && return 1 - unset X Y WIDTH HEIGHT - eval "$(xdotool getwindowgeometry --shell "$id" 2>/dev/null || true)" - # All four must be present and numeric: an empty or stale read is how the stray click happened. - for v in "${X:-}" "${Y:-}" "${WIDTH:-}" "${HEIGHT:-}"; do - [[ "$v" =~ ^-?[0-9]+$ ]] || { echo " $name: unreadable geometry, not clicking"; return 1; } - done - cx=$((X + WIDTH - 11)); cy=$((Y - 31)) # openbox decoration: close box above the frame - if [ "$cx" -lt 0 ] || [ "$cy" -lt 0 ] || [ "$cx" -ge "$screen_w" ] || [ "$cy" -ge "$screen_h" ]; then - echo " $name: close box at ${cx},${cy} is off-screen, not clicking"; return 1 - fi - echo " $name: closing via titlebar at ${cx},${cy}" - xdotool mousemove "$cx" "$cy" click 1 - sleep 2 - return 0 -} -# "Restore" is not a first-RUN dialog, it is a second-run one: killing the app mid-session leaves -# unsaved items behind, and the next launch asks whether to restore them. It sits over the tab bar -# with a modal grab, so every synthetic click afterwards lands on it and the ladder reports -# geometry that never got drawn — that is the "success with no log" shape twice already. -for name in "Setup Wizard" "New version" "Restore"; do - for _ in 1 2 3; do close_dialog "$name" || break; done -done - -# --- main window ---------------------------------------------------------------------------- -main="$(xdotool search --name "Untitled" 2>/dev/null | head -1 || true)" -if [ -n "$main" ]; then - xdotool windowmove "$main" 0 0 windowsize "$main" "$screen_w" "$screen_h" 2>/dev/null || true - xdotool windowactivate "$main" 2>/dev/null || true - sleep 2 -fi - -echo "--- session ---" -status diff --git a/scripts/CAD/tool_atlas.json b/scripts/CAD/tool_atlas.json index 0610dbf7d3..a5acfbf497 100644 --- a/scripts/CAD/tool_atlas.json +++ b/scripts/CAD/tool_atlas.json @@ -6,7 +6,7 @@ " verbs + shortcuts + refusal messages -> src/slic3r/GUI/CAD/DesignPanel.cpp (feat_dropdown", " call sites at 524/662/734/790/874/904, sk_key table at 369-400, m_keys_feature)", " kernel coverage -> src/libslic3r/CAD/CadDocument.hpp (enum CadFeatureType)", - " headless coverage -> src/slic3r/GUI/CAD/McpControl.cpp (method == \"...\")", + " headless coverage -> src/slic3r/GUI/Mcp/McpToolsCad.cpp (the CAD tool table)", " selection kinds -> src/slic3r/GUI/CAD/DesignCanvas.hpp (the on_*_selected callbacks)", "gen_offer_table.py emits src/slic3r/GUI/CAD/DesignOffer.hpp from this file, so the map", "exists once. Edit the atlas and regenerate; never hand-edit the header." diff --git a/scripts/Dockerfile.deps b/scripts/Dockerfile.deps deleted file mode 100644 index 7bd98c6234..0000000000 --- a/scripts/Dockerfile.deps +++ /dev/null @@ -1,93 +0,0 @@ -# Deps-only base image for fast iteration on Orca. -# Identical system+pinned-dependency setup to scripts/Dockerfile, but STOPS after -# `build_linux.sh -dr` (no slicer/AppImage build). Produces an image with the pinned -# deps baked at /OrcaSlicer/deps/build/destdir, so the slicer can be rebuilt -# incrementally via scripts/CAD/build-gui-incremental.sh without re-running the long deps build. -# -# Build once (rebuild only when deps/ changes, e.g. OCCT module flags): -# docker build -t snapmaker-deps -f scripts/Dockerfile.deps . -FROM docker.io/ubuntu:24.04 -LABEL maintainer="Orca CAD iteration base" - -# Disable interactive package configuration -RUN apt-get update && \ - echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections - -# Add a deb-src -RUN echo deb-src http://archive.ubuntu.com/ubuntu \ - $(cat /etc/*release | grep VERSION_CODENAME | cut -d= -f2) main universe>> /etc/apt/sources.list - -RUN apt-get update && apt-get install -y \ - autoconf \ - build-essential \ - cmake \ - curl \ - eglexternalplatform-dev \ - extra-cmake-modules \ - file \ - git \ - gstreamer1.0-plugins-bad \ - gstreamer1.0-libav \ - libcairo2-dev \ - libcurl4-openssl-dev \ - libdbus-1-dev \ - libgstreamer1.0-dev \ - libgstreamerd-3-dev \ - libgstreamer-plugins-base1.0-dev \ - libgstreamer-plugins-good1.0-dev \ - libgtk-3-dev \ - libsecret-1-dev \ - libsoup2.4-dev \ - libssl3 \ - libssl-dev \ - libtool \ - libudev-dev \ - libwayland-dev \ - libwebkit2gtk-4.1-dev \ - libxkbcommon-dev \ - locales \ - locales-all \ - m4 \ - pkgconf \ - sudo \ - wayland-protocols \ - wget - -ENV LC_ALL=en_US.utf8 -RUN locale-gen $LC_ALL -ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt - -COPY ./ OrcaSlicer -WORKDIR OrcaSlicer - -# System dependencies -RUN ./build_linux.sh -u - -# Pinned dependencies in ./deps (OCCT 7.6 with ModelingAlgorithms enabled, OpenCV, -# OpenVDB, Boost, wxWidgets, ...). This is the long step; it is baked into the image. -# -j 12, not the default all-cores: on 2026-08-21 an unbounded deps build plus an unbounded -# app build put 42 GB of cc1plus on a 62 GB box and OOM-killed the host for 2h28m. 12 keeps -# the compile fast while leaving the machine usable. Pair with `docker build --memory`. -RUN ./build_linux.sh -dr -j 12 - -# Compatibility symlink. This deps tree installs into deps/build/OrcaSlicer_dep/, while the -# orcacad_buildcache volume was configured against the previous image, whose prefix was -# deps/build/destdir/. Those paths are baked as absolute strings into the app's CMakeCache, so -# without this symlink a rebuild on the new image reconfigures from scratch — hours of compile -# to change one directory name. Same tree, two names. -RUN ln -sfn /OrcaSlicer/deps/build/OrcaSlicer_dep /OrcaSlicer/deps/build/destdir - -# The rig's GUI runtime. This used to arrive for free because orcacad-deps was layered on -# snapmaker-deps; that lineage is Trap 1 in docs/rig_build_traps.md (a baked project(Snapmaker_Orca) -# tree) and building from this Dockerfile is what removes it — along with the X stack the rig -# needs. scripts/CAD/start-headless-gui.sh requires Xvfb and openbox (without a window manager `xdotool -# windowactivate` aborts with "windowmanager claims not to support..."), drives the UI with -# xdotool, and captures to /shots with scrot/ImageMagick. Same set snapmaker-deps carries. -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - imagemagick \ - openbox \ - scrot \ - xauth \ - xdotool \ - xvfb \ - && rm -rf /var/lib/apt/lists/* diff --git a/scripts/Dockerfile.deps-assimp b/scripts/Dockerfile.deps-assimp deleted file mode 100644 index 505eb3e4f5..0000000000 --- a/scripts/Dockerfile.deps-assimp +++ /dev/null @@ -1,70 +0,0 @@ -# Adds assimp to the orcacad-deps image. -# -# WHY THIS EXISTS. OrcaSlicer mainline gained `find_package(assimp REQUIRED)` in -# src/libslic3r/CMakeLists.txt (glTF/GLB/FBX import for texture-to-colour), and the baked -# orcacad-deps image predates it: the image's deps/ tree has no Assimp directory at all, and -# nothing named assimp exists anywhere in it. On the host, deps/build/dep_Assimp-prefix has -# only `patch` and `update` stamps -- no build, no install -- so the dependency was fetched -# and then never built, in the image or out of it. -# -# The consequence was that scripts/CAD/run-kernel-tests.sh failed at CMake CONFIGURE time, -# before a single source file compiled, so THIS FORK'S KERNEL SUITE COULD NOT RUN AT ALL. -# Every kernel change ported here was parity-checked against Snapmaker and never independently -# tested (w80c). The Snapmaker fork does not hit this: its base requires neither -# assimp nor OpenCV. -# -# WHY A LAYER AND NOT A FULL DEPS REBUILD. Rebuilding every dependency takes hours and would -# rewrite artifacts that are currently working. This adds exactly the one missing package on -# top of the existing image, and it is a Dockerfile rather than a `docker commit` so that what -# was done is reviewable and repeatable instead of being an undocumented mutation. -# -# The flags below are copied from the project's own recipe (deps/Assimp/Assimp.cmake) plus the -# standard superbuild arguments from orcaslicer_add_cmake_project (deps/CMakeLists.txt:158) and -# DEP_CMAKE_OPTS (deps/deps-linux.cmake). Keep them in step with that recipe: this file is a -# stand-in for the superbuild, not an independent opinion about how to build assimp. -# -# BUILD (from the repo root, tarball already in deps/DL_CACHE/Assimp/): -# docker build -f scripts/Dockerfile.deps-assimp -t orcacad-deps . -# -# VERIFY: -# docker run --rm orcacad-deps sh -c \ -# 'ls /OrcaSlicer/deps/build/destdir/usr/local/lib/cmake/assimp*' -# scripts/CAD/run-kernel-tests.sh -# -FROM orcacad-deps - -# v5.4.3 is the version deps/Assimp/Assimp.cmake selects for CMake >= 3.22 (the image has -# 3.28.3). The SHA256 is that recipe's URL_HASH, verified against the cached tarball before -# this file was written -- an unverified archive is not a dependency, it is whatever was -# sitting in the cache. -ARG ASSIMP_SHA256=66dfbaee288f2bc43172440a55d0235dfc7bf885dda6435c038e8000e79582cb -COPY deps/DL_CACHE/Assimp/v5.4.3.tar.gz /tmp/assimp.tar.gz - -RUN set -eux; \ - echo "${ASSIMP_SHA256} /tmp/assimp.tar.gz" | sha256sum -c -; \ - mkdir -p /tmp/assimp-src && \ - tar -xzf /tmp/assimp.tar.gz -C /tmp/assimp-src --strip-components=1; \ - DESTDIR=/OrcaSlicer/deps/build/destdir/usr/local; \ - cmake -S /tmp/assimp-src -B /tmp/assimp-build -G Ninja \ - -DCMAKE_POLICY_VERSION_MINIMUM=3.10 \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_PREFIX="$DESTDIR" \ - -DCMAKE_PREFIX_PATH="$DESTDIR" \ - -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ - -DBUILD_SHARED_LIBS=OFF \ - -DASSIMP_BUILD_USE_CCACHE=OFF \ - -DASSIMP_BUILD_TESTS=OFF \ - -DASSIMP_BUILD_SAMPLES=OFF \ - -DASSIMP_BUILD_ASSIMP_TOOLS=OFF \ - -DASSIMP_INSTALL_PDB=OFF \ - -DASSIMP_NO_EXPORT=ON \ - -DASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT=OFF \ - -DASSIMP_BUILD_GLTF_IMPORTER=ON \ - -DASSIMP_BUILD_OBJ_IMPORTER=ON \ - -DASSIMP_BUILD_FBX_IMPORTER=ON \ - -DASSIMP_BUILD_ZLIB=ON \ - -DASSIMP_WARNINGS_AS_ERRORS=OFF \ - -DBUILD_WITH_STATIC_CRT=OFF; \ - cmake --build /tmp/assimp-build --target install -- -j"$(nproc)"; \ - rm -rf /tmp/assimp-src /tmp/assimp-build /tmp/assimp.tar.gz; \ - test -n "$(ls "$DESTDIR"/lib/cmake/assimp* 2>/dev/null)" diff --git a/tests/libslic3r/test_caddocument.cpp b/tests/libslic3r/test_caddocument.cpp index 5347ea7aab..7baf337291 100644 --- a/tests/libslic3r/test_caddocument.cpp +++ b/tests/libslic3r/test_caddocument.cpp @@ -4295,7 +4295,7 @@ TEST_CASE("golden recipe v1 still deserialises", "[CadDocument]") // A failure BELOW this point means the on-disk serialization format changed: some field // in CadFeature::save/load was reordered, retyped, or removed. Fields may only ever be // APPENDED at the end of both lists. Do NOT regenerate the fixture to make this pass -- - // fix the field order instead. See scripts/CAD/run-kernel-tests.sh and the [.regen] case. + // fix the field order instead. The fixture is written only by the libslic3r_tests "[.regen]" run. // Field-by-field assertions against expected values. // Every field set to a distinctive non-default literal must be checked here.