refactor: add DesignIR distillation pipeline
This commit is contained in:
@@ -6,11 +6,10 @@ Capture these fields when known:
|
||||
|
||||
- Natural-language request and normalized part family.
|
||||
- Units and dimensions.
|
||||
- Manufacturing intent: machining, printing, laser cutting, simulation, or concept.
|
||||
- Required primary and secondary output formats.
|
||||
- STEP is the fixed geometry artifact format.
|
||||
- New model versus modification, and existing source/artifact paths.
|
||||
- Part versus assembly, standard components, mating requirements, and motion relationships.
|
||||
- Required parameter controls, replay, semantic tags, or FreeCAD interchange.
|
||||
- Required parameter controls, replay, or semantic tags.
|
||||
- Geometry and visual validation targets.
|
||||
- Optional schema `2.0` generalized experience library. Never pass a case
|
||||
DesignIR, teacher STEP, source dimensions, coordinates, or surface references
|
||||
@@ -23,13 +22,12 @@ Capture these fields when known:
|
||||
|
||||
Record:
|
||||
|
||||
- `selected_backend`: `build123d`, `simplecadapi`, or `cadam`.
|
||||
- `selected_backend`: `build123d` or `simplecadapi`.
|
||||
- Origin project and optional executable adapter.
|
||||
- `runner_skill`: installed Skill responsible for generation.
|
||||
- Ranked backend scores and human-readable reasons.
|
||||
- Fallback order.
|
||||
- Workflow profiles such as `requirement_refinement` and `visual_repair`.
|
||||
- Focused downstream Skills.
|
||||
- Any explicit override and its reason.
|
||||
- `operation`: create or modify; for modification also record the explicit
|
||||
source path and whether the route uses native parameter editing, local feature
|
||||
@@ -47,7 +45,7 @@ Write `cad-task.json` beside the task artifacts with this minimum shape:
|
||||
"selected_backend": "build123d",
|
||||
"runner_skill": "cad",
|
||||
"project": "text-to-cad",
|
||||
"fallback_order": ["simplecadapi", "cadam"],
|
||||
"fallback_order": ["simplecadapi"],
|
||||
"workflow_profiles": ["requirement_refinement", "visual_repair"]
|
||||
},
|
||||
"source": {
|
||||
@@ -56,12 +54,11 @@ Write `cad-task.json` beside the task artifacts with this minimum shape:
|
||||
"backend": "build123d"
|
||||
},
|
||||
"artifacts": [
|
||||
{"path": "connecting_rod.step", "role": "primary"},
|
||||
{"path": "connecting_rod.stl", "role": "secondary"}
|
||||
{"path": "connecting_rod.step", "role": "primary"}
|
||||
],
|
||||
"parameters": {},
|
||||
"experience": {
|
||||
"library": "../../../cad-experience-library/library.json",
|
||||
"library": "../../../designir-pipeline/workspace/promotion/promoted/library.json",
|
||||
"context_kind": "generalized_cad_experience_query",
|
||||
"methods_applied": []
|
||||
},
|
||||
@@ -73,13 +70,14 @@ Write `cad-task.json` beside the task artifacts with this minimum shape:
|
||||
|
||||
Paths are relative to the task directory unless an external input must remain absolute.
|
||||
Do not store authoritative model parameters in `cad-task.json`. Every part must
|
||||
have a sibling `model-spec.json` that owns its parameter values, reconstruction
|
||||
mode, parametric modification layer, and output paths. See `model-spec.md`.
|
||||
have a sibling `*.designir.json` that owns its coordinate system, datums,
|
||||
parameters, expressions, features, constraints, edit interface, and validation
|
||||
contract. See `designir-2.0.md`.
|
||||
|
||||
For an imported STEP, use `exact_step_base`: copy the explicitly supplied file
|
||||
into the task directory, record its checksum and geometry signature, and keep
|
||||
the imported B-Rep unchanged when the modification list is empty. This is an
|
||||
exact geometric base contract, not recovery of the original CAD feature tree.
|
||||
For an uploaded STEP, keep teacher geometry in the protected ingestion and
|
||||
acceptance workspace. The reconstruction task contains private evidence,
|
||||
DesignIR, backend source, and rebuilt STEP but no teacher STEP or imported
|
||||
B-Rep.
|
||||
|
||||
## Backend adapter requirements
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ Best fit:
|
||||
- Brackets, connecting rods, cranks, levers, shafts, bushings, flanges, plates, housings, covers, enclosures, fixtures, and machined features.
|
||||
- Parametric Python sources with holes, pockets, slots, bosses, ribs, shells, fillets, chamfers, lofts, sweeps, and revolves.
|
||||
- Source-level assemblies, named datums, joints, imported components, measurements, alignment checks, and existing STEP inspection.
|
||||
- STEP primary output with STL, 3MF, or GLB sidecars.
|
||||
- STEP output compiled from executable DesignIR 2.0.
|
||||
|
||||
Weak signals: a specialized mechanical family already implemented by SimpleCADAPI, SCAD-native output, browser-only execution, or decorative repeated CSG where OpenSCAD is substantially shorter.
|
||||
Weak signals: a specialized mechanical family already implemented by SimpleCADAPI or a browser-only execution requirement.
|
||||
|
||||
## SimpleCADAPI
|
||||
|
||||
@@ -21,23 +21,11 @@ Best fit:
|
||||
|
||||
- Spur, helical, and herringbone gears; internal ring gears; racks; cycloidal discs; ball bearings.
|
||||
- Planetary and cycloidal reducers, joint actuators, and mechanism-heavy assemblies.
|
||||
- Parameter expressions, operation-graph JSON, replay, semantic tags, topology queries, and FreeCAD translation.
|
||||
- Parameter expressions, operation-graph JSON, replay, semantic tags, and topology queries.
|
||||
- Reusable mechanical product families whose formulas should become deterministic library functions.
|
||||
|
||||
Before invocation, inspect the installed package and Skill versions together. Do not mix the current single-`Solid` boolean API with older `*rsolidlist` documentation. If the installed runtime and docs disagree, stop that route and use build123d or repair the installation.
|
||||
|
||||
## CADAM
|
||||
|
||||
Use CADAM's separately installed OpenSCAD WASM runtime for fast CSG authoring and printable parameterized models. Execute generated SCAD through `scripts/cadam_compile.mjs`; do not copy CADAM's GPL runtime into this Skill.
|
||||
|
||||
Best fit:
|
||||
|
||||
- Vases, containers, knobs, adapters, printable threads, lattice/honeycomb patterns, repeated details, decorative models, and quick concept geometry.
|
||||
- SCAD source, STL output, simple projected DXF, and UI-facing parameter controls.
|
||||
- BOSL/BOSL2/MCAD-backed printable features.
|
||||
|
||||
Do not use as the primary route for editable STEP, stable face/edge references, fit-critical source-level assemblies, or modification of imported STEP.
|
||||
|
||||
## Router refinement and repair
|
||||
|
||||
Use text-to-cad's own requirement expansion and visual repair when requirements
|
||||
@@ -51,11 +39,4 @@ one-pass generation unreliable:
|
||||
5. Inspect a multi-view render against the brief.
|
||||
6. Repair visual mismatches, capped at three automatic visual rounds.
|
||||
|
||||
## Focused downstream Skills
|
||||
|
||||
- `$dxf`: 2D profiles, flat patterns, laser/plasma/waterjet drawings.
|
||||
- `$urdf`, `$srdf`, `$sdf`: robot structure, MoveIt semantics, and simulation models/worlds.
|
||||
- `$gcode`: slice validated meshes with a real slicer.
|
||||
- `$sendcutsend`: vendor-specific manufacturing preflight.
|
||||
- `$bambu-labs`: cautious local printer handoff.
|
||||
- `$cad-viewer`: visual review of supported generated artifacts.
|
||||
CAD Viewer reviews the generated or reconstructed STEP.
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
# DesignIR 2.0 contract
|
||||
|
||||
Every generated, reconstructed, or modified part owns one executable
|
||||
`*.designir.json`. It records design intent rather than source faces or a copied
|
||||
solid.
|
||||
|
||||
Required sections:
|
||||
|
||||
- `coordinate_system`
|
||||
- `datums`
|
||||
- `parameters`
|
||||
- `expressions`
|
||||
- `sketches`
|
||||
- `constraints`
|
||||
- `features`
|
||||
- `patterns`
|
||||
- `attachments`
|
||||
- `construction_stages`
|
||||
- `edit_interface`
|
||||
- `validation_contract`
|
||||
|
||||
The compiler translates this backend-neutral representation to build123d or
|
||||
SimpleCADAPI and exports STEP.
|
||||
|
||||
## Uploaded STEP boundary
|
||||
|
||||
The uploaded STEP is teacher and acceptance truth only:
|
||||
|
||||
1. A deterministic ingestion process extracts private geometric evidence.
|
||||
2. The reconstruction agent sees evidence and promoted experience, not the
|
||||
teacher STEP.
|
||||
3. It authors complete DesignIR and records uncertainty or missing vocabulary.
|
||||
4. The compiler rebuilds STEP in a sandbox containing no teacher STEP.
|
||||
5. A separate acceptance agent compares the teacher and rebuilt STEP and runs
|
||||
parameter perturbations.
|
||||
|
||||
Reject DesignIR or generators that:
|
||||
|
||||
- import or reference the teacher STEP;
|
||||
- embed STEP text, B-Rep bytes, meshes, vertices, triangles, or topology refs;
|
||||
- retain teacher face, edge, or surface identifiers;
|
||||
- use the teacher as a base feature;
|
||||
- fail to rebuild after the teacher is removed.
|
||||
|
||||
If the operation vocabulary is insufficient, set
|
||||
`reconstruction_status` to `unsupported_feature_vocabulary` and enumerate
|
||||
`missing_capabilities`. Never hide the gap with teacher geometry.
|
||||
|
||||
## Acceptance
|
||||
|
||||
Keep geometry, semantic, editability, and stability metrics separate. At
|
||||
minimum report bounding-box error, volume error, center-of-mass error,
|
||||
symmetric-difference volume, topology deltas, declared feature/constraint
|
||||
coverage, editable parameter coverage, and perturbation rebuild success.
|
||||
|
||||
Only deterministic policy code may move a method from candidate to
|
||||
`replay_validated` and then promoted experience after several independent cases
|
||||
pass.
|
||||
@@ -1,111 +0,0 @@
|
||||
# Per-part model specification
|
||||
|
||||
Use one `model-spec.json` per generated or imported part. Treat it as the
|
||||
editable geometry contract. Keep `cad-task.json` separate for routing,
|
||||
experience use, validation results, and viewer links.
|
||||
|
||||
## Native generator
|
||||
|
||||
Use `native_generator` when the part has editable Python source:
|
||||
|
||||
```json
|
||||
{
|
||||
"schema_version": "1.0",
|
||||
"model_spec_kind": "parametric_cad_model",
|
||||
"model_id": "example_part",
|
||||
"units": "mm",
|
||||
"reconstruction": {
|
||||
"mode": "native_generator",
|
||||
"generator": {
|
||||
"path": "example_part.py",
|
||||
"entrypoint": "gen_step"
|
||||
}
|
||||
},
|
||||
"parameters": {
|
||||
"width": {
|
||||
"value": 40,
|
||||
"unit": "mm",
|
||||
"role": "overall_width"
|
||||
}
|
||||
},
|
||||
"modifications": [],
|
||||
"outputs": {
|
||||
"step": "example_part.step",
|
||||
"stl": "example_part.stl"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The generator must read its sibling `model-spec.json`. Do not duplicate
|
||||
authoritative parameter values as editable constants in both files.
|
||||
|
||||
## Imported STEP
|
||||
|
||||
Convert an explicitly supplied STEP into a task-local exact-base specification:
|
||||
|
||||
```bash
|
||||
python scripts/model_spec.py import-step input.step \
|
||||
--task-dir models/cad-router-v1/imported_part \
|
||||
--model-id imported_part
|
||||
```
|
||||
|
||||
This copies the source to `source.step`, records its SHA-256 and geometry
|
||||
signature, writes `model-spec.json`, and exports regenerated STEP/STL files.
|
||||
With an empty modification list, `verify` requires the imported B-Rep to retain
|
||||
the same bounds, center, topology counts, solid count, and volume.
|
||||
|
||||
STEP normally contains final B-Rep geometry, not the original sketches,
|
||||
constraints, names, or feature history. Therefore:
|
||||
|
||||
- `exact_step_base` guarantees an unchanged imported base, not recovered native
|
||||
design history.
|
||||
- Add later edits as named parametric modifications.
|
||||
- Use semantic native reconstruction only when the feature family can be
|
||||
reliably recognized and validate it independently against the source.
|
||||
- Never claim arbitrary STEP-to-JSON conversion recovers the author’s original
|
||||
parameters or construction order.
|
||||
|
||||
## Parametric modification layer
|
||||
|
||||
Supported V1 operations are `add_box`, `cut_box`, `add_cylinder`, and
|
||||
`cut_cylinder`. Values may be literals, direct parameter references, or affine
|
||||
parameter expressions:
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "central_bore",
|
||||
"operation": "cut_cylinder",
|
||||
"axis": "z",
|
||||
"center": [0, 0, 0],
|
||||
"diameter": {"parameter": "bore_diameter"},
|
||||
"length": {"parameter": "bore_length"},
|
||||
"enabled": true
|
||||
}
|
||||
```
|
||||
|
||||
Use `scale` and `offset` when a tool center must stay anchored while its size
|
||||
changes. For example, a positive-Z face at `z = 14.1` can remain the lower face
|
||||
of an added box while `extension` changes:
|
||||
|
||||
```json
|
||||
{
|
||||
"center": [
|
||||
13.1,
|
||||
-1.0,
|
||||
{"parameter": "extension", "scale": 0.5, "offset": 14.1}
|
||||
],
|
||||
"size": [22.2, 2.0, {"parameter": "extension"}]
|
||||
}
|
||||
```
|
||||
|
||||
Change a named value and rebuild:
|
||||
|
||||
```bash
|
||||
python scripts/model_spec.py set path/to/model-spec.json bore_diameter 18
|
||||
python scripts/model_spec.py build path/to/model-spec.json
|
||||
python scripts/model_spec.py verify path/to/model-spec.json
|
||||
```
|
||||
|
||||
Use `apply_patch` when adding or structurally editing parameters and features so
|
||||
the modification remains reviewable. After every visible rebuild, run the CAD
|
||||
inspection and snapshot workflow and update `cad-task.json`.
|
||||
Reference in New Issue
Block a user