c454a3af10
* feat(skill): replace skill-pack with per-harness conditional compiler
skillbuild compiles the skill tree into per-target harness builds:
- <!-- skill:if omp,!claude --> blocks include text only for matching
targets; name-list conditions only, no else/nesting, fail-loud on
unknown targets and unpaired/nested directives
- fence-aware: directive-looking lines inside code fences are literal
- layout is the filesystem; tree root configured in skillproj.toml
- post-build assertion: zero directive residue, SKILL.md frontmatter
name check
Migration to the new model:
- docs/skill/ becomes the self-contained source root (SKILL.md,
references/, generated api/stdlib/core/guides now under
references/docs/; SDK_OVERVIEW/LICENSE/inspect are ordinary tree
files)
- auto_docs_gen output redirected into the tree (docs/api ->
docs/skill/references/docs/api, likewise stdlib)
- skills/simplecadapi/ is now the compiled omp target output;
dist/generic/simplecadapi the generic target
- dropped skill-pack entry point (plus dangling evolve/make-export
entries and their orphaned test), release workflow builds via
skillbuild + tar; README updated
First real conditional block: harness reading paths in SKILL.md
(skill:// mount on omp vs disk-relative on generic).
Verified: 59 tests pass (skillbuild 31, auto_docs_gen 19, persistence
regression 9); both targets build; outputs residue-clean; full suite
collects (1376 tests).
* refactor(tools): auto_docs_gen moves out of the installed package
tools/ scripts are repo-checkout dev scripts, not packaged CLIs:
- auto_docs_gen.py now lives in tools/ beside the other generators;
auto_tools/ package removed entirely
- path resolution simplifies: repo root = parent of tools/, fail-loud
if pyproject.toml missing; site-packages/cwd fallback branches were
dead code once the script stopped shipping in the wheel
- auto-docs-gen console script dropped from [project.scripts];
release.yml and README invoke python tools/auto_docs_gen.py
- MANIFEST.in stale src/auto_tools include removed; CadQuery-free
runtime scan no longer needs the auto_tools filter
- run_examples.py retired (user removal): README example-runner text
updated to direct examples/ scripts; dangling runner-contract test
(runpy.run_path into the deleted script) removed
Verified: 53 tests pass (auto_docs_gen + skill_build + ocp runtime
scan) and test_example_model_contract passes; regeneration from
tools/ is byte-identical (zero docs drift).
* refactor(skill): strip harness and build-tool content from the skill tree
The skill is plain harness-neutral content again:
- SKILL.md 'Reading skill files' section removed (the omp skill://
mount block and its !omp complement were the only conditional
blocks; the tree compiles identically for every target now)
- references/README.md: build-tool meta removed ('per-harness
conditional compilation', skillbuild packaging/validation claims —
link validation was never implemented, so the claim was false)
- live test now asserts the tree stays harness-neutral (zero blocks)
- skillproj.toml targets aligned with the user's output table
(omp -> skills/simplecadapi-omp, opencode -> skills/simplecadapi-opencode;
leftover 'generic' entry had no output and failed the build)
- compiled outputs are regenerable artifacts: skills/simplecadapi/
untracked from git, skills/simplecadapi-*/ gitignored, release.yml
and README build via skillbuild and tar the omp output directly
(bsdtar has no --transform; inner dir keeps its suffixed name)
Verified: 49 tests pass; both targets build 372 files with zero
conditional blocks; no omp/conditional/directive residue in the tree
or outputs.
* chore(docs): drop stale architecture review and design notes
125 lines
4.6 KiB
Python
125 lines
4.6 KiB
Python
"""Structural checks for the example model/session contract."""
|
|
|
|
import importlib.util
|
|
import sys
|
|
from pathlib import Path
|
|
import unittest
|
|
|
|
|
|
import simplecadapi as scad
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
EXAMPLES = ROOT / "examples"
|
|
|
|
|
|
def _source_files() -> tuple[Path, ...]:
|
|
return tuple(
|
|
path
|
|
for path in EXAMPLES.rglob("*.py")
|
|
if "out" not in path.relative_to(EXAMPLES).parts
|
|
)
|
|
|
|
|
|
FORMAL_EXAMPLE_PACKAGES = {
|
|
"examples/04_dimension_tolerance_chain.py": (
|
|
"examples/out/dimension_tolerance_chain/dimension_tolerance_chain.scadpkg"
|
|
),
|
|
"examples/08_constrained_sketch.py": (
|
|
"examples/out/constrained_sketch/constrained_sketch.scadpkg"
|
|
),
|
|
"examples/09_naca0016_blade_freecad.py": (
|
|
"examples/out/naca0016_blade/naca0016_blade.scadpkg"
|
|
),
|
|
"examples/10_part_assembly.py": (
|
|
"examples/out/hydraulic_rod_assembly/hydraulic_rod_assembly.scadpkg"
|
|
),
|
|
"examples/11_external_reference_gear_train.py": (
|
|
"examples/out/external_reference_gear_train/"
|
|
"nested_external_reference_gear_trains.scadpkg"
|
|
),
|
|
"examples/7ep_caplcd_enclosure.py": (
|
|
"examples/out/7ep_caplcd_enclosure/caplcd_enclosure_7ep.scadpkg"
|
|
),
|
|
"examples/16_compact_two_stage_planetary_reducer/main.py": (
|
|
"examples/out/compact_two_stage_planetary_reducer/"
|
|
"compact_two_stage_planetary_reducer.scadpkg"
|
|
),
|
|
"examples/20_integrated_bldc_joint_actuator/main.py": (
|
|
"examples/out/integrated_bldc_joint_actuator/"
|
|
"integrated_bldc_joint_actuator.scadpkg"
|
|
),
|
|
}
|
|
|
|
|
|
class TestExampleModelContract(unittest.TestCase):
|
|
def test_example_10_output_dir_is_anchored_to_the_example_file(self):
|
|
path = EXAMPLES / "10_part_assembly.py"
|
|
spec = importlib.util.spec_from_file_location("example_10_path_contract", path)
|
|
self.assertIsNotNone(spec)
|
|
assert spec is not None and spec.loader is not None
|
|
module = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(module)
|
|
|
|
self.assertTrue(module.OUT_DIR.is_absolute())
|
|
self.assertEqual(
|
|
module.OUT_DIR,
|
|
EXAMPLES / "out" / "hydraulic_rod_assembly",
|
|
)
|
|
|
|
|
|
def test_examples_do_not_use_removed_decorator_api(self):
|
|
for path in _source_files():
|
|
source = path.read_text(encoding="utf-8")
|
|
self.assertNotIn("@scad.model", source, path)
|
|
self.assertNotIn("scad.requires_session", source, path)
|
|
self.assertNotIn("scad.capture_result", source, path)
|
|
|
|
def test_bldc_bearing_decorative_balls_are_part_of_outer_ring(self):
|
|
example_dir = EXAMPLES / "20_integrated_bldc_joint_actuator"
|
|
sys.path.insert(0, str(example_dir))
|
|
try:
|
|
path = example_dir / "bearings.py"
|
|
spec = importlib.util.spec_from_file_location(
|
|
"bldc_bearings_contract", path
|
|
)
|
|
self.assertIsNotNone(spec)
|
|
assert spec is not None and spec.loader is not None
|
|
module = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(module)
|
|
from dimensions import BearingSpec
|
|
|
|
bearing_spec = BearingSpec(3.0, 6.0, 3.0, 0.7, 8)
|
|
with scad.GraphSession():
|
|
material = scad.make_material_rmaterial(
|
|
"bearing_contract_steel",
|
|
density=7.85e-6,
|
|
density_unit="kg/mm^3",
|
|
)
|
|
bearing = module.make_main_bearing_rassembly(
|
|
bearing_id="bearing_contract",
|
|
spec=bearing_spec,
|
|
material=material,
|
|
)
|
|
solved = scad.solve_assembly_constraints_rassembly(
|
|
scad.ground_component_rassembly(bearing, "outer_ring")
|
|
)
|
|
report = scad.inspect_assembly_constraints_rconstraintreport(solved)
|
|
finally:
|
|
sys.path.remove(str(example_dir))
|
|
|
|
self.assertEqual(bearing.component_ids(), ("outer_ring", "inner_ring"))
|
|
self.assertEqual(bearing.constraint_ids(), ("inner_outer_revolute",))
|
|
self.assertEqual(report.unsolved_component_ids, ())
|
|
outer = bearing.get_component("outer_ring").item.body
|
|
outer_meta = bearing.get_metadata("std.bearing.ball_bearing")
|
|
self.assertTrue(outer_meta["rolling_elements_fused"])
|
|
self.assertEqual(outer_meta["rolling_element_fuse_mode"], "outer_ring_union")
|
|
self.assertGreater(outer.get_volume(), 0.0)
|
|
self.assertIn(
|
|
"role.rolling_elements_fused_into_outer_ring", scad.list_tags(outer)
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|