M104 — AP238 producer emits SETUP where WORKPIECE_SETUP is required

§12.8 mixed (sub-class: AP238 setup type)

P1 — silent data loss

spec-violation

Sources

Sender

deduced — STEP-NC publisher merging machine setup and workpiece setup into one entity

Description

AP238 distinguishes `SETUP` (machine-fixture configuration: vise, palette, tombstone) from `WORKPIECE_SETUP` (workpiece-on-fixture placement and clamping). A producer emits a single `SETUP` and references it from contexts that expect a `WORKPIECE_SETUP`. Consumers conflate the two and lose either the fixture geometry or the workpiece-clamp data. Bug-reporter language: "AP238 setup vs workpiece_setup confusion", "STEP-NC fixture data lost", "wrong setup entity type".

Reproducer recipe

A `MACHINING_WORKINGSTEP`'s `its_setup` attribute references a `SETUP` (rather than the `WORKPIECE_SETUP` per AP238 schema).

Expected kernel behavior

detect type mismatch; reject or coerce with diagnostic.

Notes

Synonyms: "setup type mismatch", "AP238 fixture vs workpiece confusion", "SETUP used where WORKPIECE_SETUP needed", "AP238 wrong setup class". Synonyms: "setup type mismatch", "AP238 fixture vs workpiece confusion".

Expected validation

occt=empty/empty gmsh=empty ifc=schema_n/a

Byte assertions

Tier-3 assertions

Live oracle output

No live oracle data — run _run_corpus to populate.

Fixture content

Show fixture bytes (with defect highlighting)
1ISO-10303-21;
2/* M104: AP238 SETUP emitted where WORKPIECE_SETUP is required */
3/* DEFECT: MACHINING_WORKINGSTEP.its_setup references SETUP not WORKPIECE_SETUP */
4/* SETUP = machine-fixture config; WORKPIECE_SETUP = workpiece-on-fixture placement */
5/* Consumers lose workpiece clamp data or fixture geometry — wrong tool-origin offset */
6/* Violates ISO 10303-238 §5.4 setup vs workpiece_setup distinction */
7/* Byte assertion: contains(b'AP238_STEP_NC_MIM') */
8/* Byte assertion: contains(b'SETUP') */
9HEADER;
10FILE_DESCRIPTION(('M104: AP238 SETUP where WORKPIECE_SETUP required'),'2;1');
11FILE_NAME('M104.stp','2026-06-21T00:00:00',(''),(''),'cad-research-suite','','');
12/* Byte assertion: contains(b'AP238_STEP_NC_MIM') */
13FILE_SCHEMA(('AP238_STEP_NC_MIM { 1 0 10303 238 1 0 0 }'));
14ENDSEC;
15DATA;
16#1=APPLICATION_CONTEXT('step_nc_mim');
17#2=APPLICATION_PROTOCOL_DEFINITION('international standard',
18  'ap238_step_nc_mim',2007,#1);
19/* Standard unit context — mm */
20#10=(LENGTH_UNIT()NAMED_UNIT(*)SI_UNIT(.MILLI.,.METRE.));
21#11=(NAMED_UNIT(*)PLANE_ANGLE_UNIT()SI_UNIT($,.RADIAN.));
22#12=(NAMED_UNIT(*)SI_UNIT($,.STERADIAN.)SOLID_ANGLE_UNIT());
23#13=UNCERTAINTY_MEASURE_WITH_UNIT(LENGTH_MEASURE(0.001),#10,
24  'distance_accuracy_value','maximum model space distance between geometric entities');
25#14=(GEOMETRIC_REPRESENTATION_CONTEXT(3)
26  GLOBAL_UNCERTAINTY_ASSIGNED_CONTEXT((#13))
27  GLOBAL_UNIT_ASSIGNED_CONTEXT((#10,#11,#12))
28  REPRESENTATION_CONTEXT('nc','3D'));
29/* Byte assertion: contains(b'SETUP') */
30/* DEFECT: SETUP entity for machine-fixture configuration (vise on tombstone) */
31/* This should be WORKPIECE_SETUP (workpiece-on-fixture placement with clamp data) */
32/* The publisher merged both concepts into a single SETUP entity — type mismatch */
33#50=SETUP('vise_config',$,$,$);
34/* Target machined feature — a face milling pass */
35#55=MACHINED_FEATURE('face_d',$,$,$,$,$);
36/* 50mm face mill */
37#60=MACHINING_TOOL('facemill_50mm',$,$,$);
38/* Machining operation for face milling */
39#70=MACHINING_OPERATION('face_op',#60,$,$,$,$,$,$,#55,$,$);
40/* DEFECT: MACHINING_WORKINGSTEP.its_setup references SETUP #50 */
41/* Per AP238 §5.4 its_setup must reference WORKPIECE_SETUP, not bare SETUP */
42/* Correct fix: replace #50 with WORKPIECE_SETUP('vise_config_wp',...) */
43#80=MACHINING_WORKINGSTEP('face_step',#55,#70,#50);
44/* WORKPLAN referencing the workingstep with the mistyped setup reference */
45#90=WORKPLAN('main',(#80),$,$,$);
46/* GEOMETRIC_CURVE_SET IS the model entity — OCC yields empty */
47#300=GEOMETRIC_CURVE_SET('ap238-setup-emitted-where-workpiece-setup-required',
48  (#50,#55,#60,#70,#80,#90));
49/* Product chain */
50#400=APPLICATION_CONTEXT('mechanical design');
51#401=PRODUCT_CONTEXT('',#400,'mechanical');
52#402=PRODUCT('M104','M104','M104',(#401));
53#403=PRODUCT_DEFINITION_FORMATION('','',#402);
54#404=PRODUCT_DEFINITION_CONTEXT(#400,'design');
55#405=PRODUCT_DEFINITION('','',#403,#404);
56#406=PRODUCT_DEFINITION_SHAPE('','',#405);
57#407=SHAPE_REPRESENTATION('',(#300),#14);
58#408=SHAPE_DEFINITION_REPRESENTATION(#406,#407);
59ENDSEC;
60END-ISO-10303-21;