Lk dev #21

Merged
likang merged 11 commits from lk_dev into main 2026-09-09 18:52:28 +08:00

11 Commits

Author SHA1 Message Date
likang d8fc2a9207 Merge branch 'codex/integrate-ganjihong-refactor-2' into lk_dev
# Conflicts:
#	backend/app/cad_agent/domain/operation_contract.py
#	backend/engine/cdsl_engine/runtime.py
#	backend/engine/cdsl_engine/runtime_types.py
#	backend/engine/cdsl_engine/semantic_validation.py
2026-09-09 18:50:31 +08:00
likang 21a5185926 integrate ganjihong engine refactor 2026-09-09 18:41:56 +08:00
likang 387b99e255 wip: preserve local engine and agent workflow changes before ganjihong refactor integration 2026-09-09 17:08:24 +08:00
ganjihong cf9cd0366a refactor(cdsl_engine): extract topology evidence export from the adapter
Phase 6 of the decoupling refactor (behavior-preserving move):
- topology_export.py: body_geometry / surface_geometry / topology_records
  (~290 lines) moved verbatim out of build123d_adapter.py as module-level
  functions; includes the circle_center_mm/radius_mm concentric-circle
  evidence added by the lk_dev integration
- build123d_adapter.py: the three methods are now one-line forwards, so
  kernel construction and topology evidence export live in separate files
  and can evolve independently

No protocol change (GeometryAdapter untouched). Verified by:
- golden comparison: full-corpus analyze (2881 docs) + 12 complete
  rebuilds -- zero field differences vs f79c287
- full test suite: 435 tests, failure set identical to baseline
2026-09-09 16:07:25 +08:00
ganjihong 6fa4501f16 docs(cdsl_engine): document package layout and the add-atomic-operation workflow
Phase 8: README now maps every module of the split package, documents
the executor registration + schema-contract workflow for new atomic
operations, and restates the schema maintenance rule for executors/.
2026-09-09 14:34:14 +08:00
ganjihong 95cae203f4 refactor(cdsl_engine): freeze legacy engine paths under legacy/
Phase 7 of the decoupling refactor (behavior-preserving move):
- legacy/llm_compiler.py, legacy/llm_engine.py: frozen build_pack path
  (unused by run_cdsl_only), moved with git mv for history
- legacy/exact_rebuild.py: _run_parameterized / _run_exact /
  _apply_geometric_compensations moved out of rebuild.py, including
  the part-specific compensation table
- rebuild.py keeps run_rebuild / run_cdsl_only / compare_with_gold and
  imports the moved functions
- llm_compiler.py / llm_engine.py become compatibility shims

Frozen zone: new capability belongs in executors/ + schema contracts.
The project-specific compensation no longer sits in the main pipeline.
2026-09-09 14:02:53 +08:00
ganjihong ad88d92ab9 refactor(cdsl_engine): split translator.py into the translator package
Phase 5 of the decoupling refactor (behavior-preserving move):
- translator/ir.py: SolidWorks plugin JSON to backend-IR conversion (70 syms)
- translator/codegen.py: backend IR to build123d source generation (64 syms)
- translator/runtime_lib.py: frozen generated-script runtime library,
  spliced into generate_build123d_code as *RUNTIME_LIB_LINES
- translator/common.py: helpers shared by both sides
- translator/__init__.py: full historical symbol surface re-exported

Generated-code equivalence verified byte-for-byte against the pre-split
output for a representative IR sample; py_compile clean.
2026-09-09 13:56:08 +08:00
ganjihong beac59fc8b refactor(cdsl_engine): sink atomic runtime capability flags into schema contracts
Phase 4 of the decoupling refactor (behavior-preserving):
- profile_schema.json: every operation contract now carries
  runtime_capability {body_mutating, requires_active_body,
  replayable, requires_selector, open_profile_ok} (single source of truth)
- operation_contracts.py: validates and forwards the flags
- capabilities.py: the five data-classification frozensets are now
  derived from the schema at import time; dispatch-logic sets
  (_HOLE_ATOMICS, _PATTERN_ATOMICS, extent constants) stay in code
- test_profile_schema.py: completeness + structural invariants test

Equivalence proven by flag counts (27/13/25/6/2) matching the previous
hand-written sets and by the unchanged test-baseline failure set.
2026-09-09 13:41:38 +08:00
ganjihong 5ffb106f36 refactor(cdsl_engine): executor registry + per-family executor package
Phase 3 of the decoupling refactor (behavior-preserving):
- registry.py: atomic_executor decorator, ALL_ATOMIC_IDS with
  fail-fast registration validation, execute_node dispatcher
- executors/: one module per family (extrude, revolve, surfaces,
  loft_sweep, bodies, context, primitives, parametric, holes,
  dressup, patterns) + shared helpers in executors/common
- executors/__init__: explicit aggregation + completeness check
  (registry must cover every declared atomic id at import time)
- runtime.py: slimmed to entry points (analyze_cdsl/rebuild_cdsl)
  plus full historical re-exports incl. test-referenced privates

Adding an atomic operation now touches only one executor module and
its schema contract; the shared registry never changes. Verified
against baseline: zero new failures.
2026-09-09 13:33:06 +08:00
ganjihong 871070c440 refactor(cdsl_engine): extract session/extents/pattern_transform from runtime
Phase 2 of the decoupling refactor (behavior-preserving move):
- runtime_base.py: RuntimeExecutionError, FeatureExecutionError, ExtentVector
- session.py: GeometryAdapter protocol + ExecutionSession
- extents.py: end-condition planning (_extent_vectors family)
- pattern_transform.py: translate/mirror/rotate replay parameter algebra
- runtime.py: keeps executors + registry + entry points; re-exports all
  moved names (incl. test-referenced privates) for import stability

No behavior change; verified against baseline (zero new failures).
2026-09-09 13:13:17 +08:00
ganjihong 3fb08423da refactor(cdsl_engine): split runtime_types into specs + topology with shim
Phase 1 of the decoupling refactor (behavior-preserving move):
- specs.py: vector math, plane/axis helpers, parametric feature specs
- topology.py: diagnostics, planning contracts, TopologyRegistry
- runtime_types.py: compatibility shim re-exporting all public names

No behavior change; all historical import paths keep working.
2026-09-09 12:58:58 +08:00