Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

4.9 KB
Raw Blame

Compile-Time Semantic Introspection

Firmament schema is an opt-in, static description of the public authoring surface. It does not perform runtime reflection, mutate semantic objects, or replace the parser and binder.

Aetheris.Firmament.SchemaGenerator is a Roslyn incremental source generator. It visits classes marked with FirmamentConstructAttribute, reads explicit FirmamentFieldAttribute and FirmamentOutputAttribute declarations, validates stable IDs and supported kinds, sorts by stable ID, and emits FirmamentSemanticSchemas.g.cs. The generated file is inspectable at Aetheris.Kernel.Firmament/obj/Generated/Aetheris.Firmament.SchemaGenerator/Aetheris.Firmament.SchemaGenerator.SemanticSchemaGenerator/FirmamentSemanticSchemas.g.cs after a build. It is excluded from source control with obj/.

The generated registry contains read-only FirmamentConstructSchema, FirmamentFieldSchema, and FirmamentOutputSchema descriptors. IDs are explicit construct, field, and output keys; field/output IDs are qualified by construct ID. They do not depend on declaration or hash iteration order. Unit kind is derived from Length or Angle value kinds, or declared explicitly for a vector or point such as Box Size. Descriptors contain no callbacks, UI layout, runtime setters, or CLR member names. FMS001 is a build error for duplicate/missing construct or field IDs, duplicate construct names, unsupported kinds, incompatible units, invalid choice declarations, and duplicate output IDs.

The schema is available to the browser through versioned language.schema() transport. Its JSON uses semantic strings for kinds and units. The existing language.complete() path takes Helix and solid Loft fields from the generated descriptors. It still uses parser-owned context detection. The Web tree preserves its existing body kind and separately projects the parser's semanticConstruct for schema lookup. Helios shows generic field and output metadata for a selected construct when that identity matches a schema; it never edits the compiled object through schema metadata.

X1 adds FirmamentFieldProjector as a typed, read-only companion to the generated schema. It reads bound canonical Box and Hole instances, WireAxisCoilAir, and bound Loft authoring data. The generated registry emits a typed ProjectHoleDiameter(FirmamentV2SemanticHoleDecl) getter and reports a compile-time FMS001 error if a field advertises source editing without a matching public static projector. All other schema fields are marked source-only. Field projections carry schema and semantic IDs, effective and authored values, origin, exact parser-owned declaration and value spans, source document, source hash, build revision, editability, and refusal reason. The Web contract exposes firmament-field-projection/1 through describeConstruct.

Canonical Box/Hole and WireForm/Loft parsers retain lexical field boundaries while recognizing declarations. The range scanner ignores comments and nested values; it does not search the completed document for a label to edit. The canonical Hole parser now takes its common legal field inventory from the generated schema and keeps Counterbore/Countersink additions local. Other Box/Hole validation and semantic rules still live in the parser and binder.

rewriteField is bounded to an already-authored canonical Hole.Diameter literal in mm. It requires the exact source hash and successful build revision, checks the projected literal against source, validates a positive finite typed Length, and replaces only the value span. It returns source text and a replacement edit without mutating the session or compiled object. Helios applies that edit through Monaco, marks the document dirty, and uses its normal setSource rebuild. Monaco undo and Telos save/reopen retain the source edit. Omitted values have no synthetic span and remain read-only. Expression-backed Helix values show both expression text and effective typed value and remain source-only.

The generated schema also carries buildable full-document Helix and Loft entry templates. language.complete exposes them for bare construct searches, and Helios palette commands open the same schema entries. Concept requirements remain user-defined members, so there is no fixed Concept field projection to expose without a separate member-schema design. The pre-existing experimental effective override editor remains distinct from X1 field editing and is not used by the source rewrite path.

The schema, typed projector, and span rewrite paths use ordinary generated C# and static collection access. They do not scan assemblies, use PropertyInfo, call MethodInfo, invoke dynamic, or require runtime reflection metadata preservation. The existing Web host's JSON transport still has IL2026 trim warnings. NativeAOT compatibility of the broader runtime still requires its normal qualification path; this projection introduces no reflection-specific preservation requirement.