feat: advance FreeCAD parity verification and runtime boundaries
Some checks failed
real-verification / chrome (push) Has been cancelled
real-verification / freecad-oracle (push) Has been cancelled
real-verification / wasm (push) Has been cancelled

This commit is contained in:
2026-08-11 02:14:45 -04:00
parent 26ea9b57d7
commit 2be18a511e
31 changed files with 451 additions and 57 deletions

View File

@@ -16,7 +16,7 @@ import { createFinalShapeOnlyNamingEvidence, createNativeStageNamingEvidence, va
import { runTopologyMutationReplay } from '../src/facade/topologyReplay'
import { captureNativeTopologyHistory, captureNativeTopologyHistoryStages, captureSignatureTopologyHistory, composeNativeTopologyHistoryLineage } from '../src/facade/topologyHistory'
import { createNativeOcctStepHistoryBridge, mapNativeOcctHistoryRecords } from '../src/facade/nativeHistoryProvider'
import { DirectNativeOcctHistoryProvider, NativeOcctHistoryCoordinator, NATIVE_OCCT_HISTORY_PROTOCOL_VERSION, type NativeOcctHistoryProvider } from '../src/facade/nativeHistoryProtocol'
import { DirectNativeOcctHistoryProvider, NativeOcctHistoryCoordinator, NATIVE_OCCT_HISTORY_PROTOCOL_VERSION, nativeNamingAbiCapabilities, type NativeOcctHistoryProvider } from '../src/facade/nativeHistoryProtocol'
import { NativeOcctHistoryWorkerProvider } from '../src/facade/nativeHistoryWorkerClient'
import { assessResourceQuota, planResourceSweep } from '../src/facade/resourcePolicy'
import { applySketchAutoConstraints, cloneSketch, createSketch, deleteSketchGeometry, dragSketchPoint, editBsplineGeometry, editSketchBspline, extendSketchLine, replaySketchEditorEvents, setSketchConstruction, SketchEditorInteractionSession, sketchGeometrySignature, solveSketch, splitSketchLine, suggestSketchAutoConstraints, trimSketchLine, validateSketchGeometry, type SketchGeometry } from '../src/facade/sketcher'
@@ -65,6 +65,14 @@ test('facade exposes a stable initial document projection', () => {
assert.equal(state.document.id, 'doc-pump-housing')
assert.equal(state.document.tree.find((item) => item.id === 'body')?.type, 'body')
assert.equal(facade.gui.workbench.getActive(), 'Part Design')
assert.deepEqual(facade.runtime, {
mode: 'mock',
geometry: { engine: 'bitbybit-occt', execution: 'facade-runtime', compatibility: 'demo-bootstrap' },
nativeHistory: { transport: 'optional-worker', availability: 'not-configured' },
naming: { nativeAbi: 'not-exposed', preservation: 'opaque-preserved' },
persistence: 'sqlite-opfs-with-memory-fallback',
viewport: 'three-webgl2',
})
assert.equal(facade.geometry.capabilities().provider, 'Bitbybit OCCT')
assert.deepEqual({ shapeCount: facade.geometry.capabilities().shapeCount, kernelReferenceCount: facade.geometry.capabilities().kernelReferenceCount, releasedShapeCount: facade.geometry.capabilities().releasedShapeCount }, { shapeCount: 0, kernelReferenceCount: 0, releasedShapeCount: 0 })
})
@@ -77,6 +85,9 @@ test('production facade starts from an empty document unless an application boot
assert.deepEqual(state.document.tree, [])
assert.deepEqual(state.document.objects, [])
assert.deepEqual(state.selectedObjectIds, [])
assert.equal(facade.runtime.mode, 'production')
assert.equal(facade.runtime.geometry.compatibility, 'none')
assert.equal(facade.runtime.naming.nativeAbi, 'not-exposed')
facade.geometry.dispose()
})
@@ -686,6 +697,12 @@ test('native OCCT history protocol validates STEP context and isolates stale gen
assert.equal(staleExecution.status, 'stale')
})
test('native naming ABI capabilities forbid synthetic FreeCAD tokens unless a provider declares native evidence', () => {
const base = { providerId: 'occt-native.history-step', providerVersion: '8.0.0-embind', occtVersion: '8.0.0', availability: 'available' as const, operations: ['cut' as const], transport: 'step-text' as const }
assert.deepEqual(nativeNamingAbiCapabilities(base), { mappedNameRef: 'unavailable', stringHasher: 'unavailable', tokenGeneration: 'forbidden' })
assert.deepEqual(nativeNamingAbiCapabilities({ ...base, naming: { mappedNameRef: 'optional', stringHasher: 'opaque-preserved', tokenGeneration: 'native-only' } }), { mappedNameRef: 'optional', stringHasher: 'opaque-preserved', tokenGeneration: 'native-only' })
})
test('native OCCT history coordinator reports timeout and cancellation', async () => {
const hanging: NativeOcctHistoryProvider = { capabilities: () => ({ providerId: 'test', providerVersion: '1', occtVersion: '8.0.0', availability: 'available', operations: ['cut'], transport: 'step-text' }), capture: async (_request, signal) => await new Promise<never>((_, reject) => { signal.addEventListener('abort', () => reject(new DOMException('cancelled', 'AbortError')), { once: true }) }) }
const timedOut = await new NativeOcctHistoryCoordinator(() => 1, 5).capture(hanging, { documentId: 'doc', documentVersion: 1, operationId: 'cut-timeout', operation: 'cut', objectStep: 'ISO-10303-21; object', toolStep: 'ISO-10303-21; tool' })
@@ -5446,6 +5463,41 @@ test('Part workbench commands create primitive and boolean document objects', ()
assert.equal(facade.gui.command.getState('check-shape').status, 'disabled')
})
test('Datum and ShapeBinder stay in the active Body without stealing its Tip and survive FCStd metadata projection', () => {
const facade = createMockFacade()
facade.gui.command.execute({ commandId: 'create-body' })
facade.task.apply()
const initial = facade.app.document.getActive()
assert.equal(initial.tree.find((item) => item.id === 'body')?.state, 'valid')
assert.equal(initial.tree.find((item) => item.id === 'body001')?.state, 'active')
assert.equal(facade.app.document.getObject('body001')?.properties.find((property) => property.name === 'Tip')?.value, null)
facade.gui.command.execute({ commandId: 'datum' })
facade.task.update({ datumType: 'Line' })
facade.task.apply()
const datum = facade.app.document.getObject('datum-line')
assert.equal(datum?.typeId, 'PartDesign::Line')
assert.equal(datum?.properties.find((property) => property.name === 'DatumType')?.value, 'Line')
assert.equal(facade.app.document.getActive().tree.find((item) => item.id === 'body001')?.children?.includes('datum-line'), true)
assert.equal(facade.app.document.getObject('body001')?.properties.find((property) => property.name === 'Tip')?.value, null)
facade.selection.select('pad')
facade.gui.command.execute({ commandId: 'shape-binder' })
facade.task.apply()
const binder = facade.app.document.getObject('shape-binder')
assert.equal(binder?.typeId, 'PartDesign::ShapeBinder')
assert.deepEqual(binder?.properties.find((property) => property.name === 'Support')?.value, { schemaVersion: 1, objectId: 'pad', subElements: [] })
assert.equal(facade.app.document.getActive().tree.find((item) => item.id === 'body001')?.children?.includes('shape-binder'), true)
assert.equal(facade.app.document.getObject('body001')?.properties.find((property) => property.name === 'Tip')?.value, null)
assert.deepEqual(facade.app.document.getDependencies().filter((edge) => edge.sourceId === 'shape-binder').map((edge) => edge.targetId), ['pad'])
const inspection = inspectFcstdArchive(serializeFcstdMetadataArchive(facade.app.document.getActive()))
assert.equal(inspection.objects.find((object) => object.name === 'datum-line')?.support, 'recognized')
assert.equal(inspection.objects.find((object) => object.name === 'shape-binder')?.support, 'recognized')
facade.geometry.dispose()
})
test('Part Design loft and pipe tasks preserve ordered Body Tip bases', () => {
const facade = createMockFacade()
facade.gui.command.execute({ commandId: 'create-sketch' })