Skip to content

fix(context-generator): emit @vocab coercion for any_of enum ranges #77

Description

@jdsika

Problem

The trafficAgentTypeValue slot in openlabel-v2 requires explicit {""@id"": ""openlabel_v2:VehicleCar""} notation in JSON-LD instance data, while all other enum slots allow bare string values like ""RoadTypeMotorway"".

Example (current -- verbose):

""trafficAgentTypeValue"": [
   {""@id"": ""openlabel_v2:VehicleCar""},
   {""@id"": ""openlabel_v2:HumanPedestrian""}
]

Desired (consistent with other enum slots):

""trafficAgentTypeValue"": [""VehicleCar"", ""HumanPedestrian""]

Root Cause

The LinkML JSON-LD context generator does not emit ""@type"": ""@vocab""`` for slots that use any_of` with multiple enum ranges:

trafficAgentTypeValue:
  any_of:
    - range: RoadUserHumanEnum
    - range: RoadUserVehicleEnum
  multivalued: true

Single-range enum slots get proper context coercion:

""DrivableAreaType"": {
   ""@context"": {""@vocab"": ""https://w3id.org/ascs-ev/envited-x/openlabel/v2/""},
   ""@id"": ""DrivableAreaType"",
   ""@type"": ""@vocab""
}

But trafficAgentTypeValue only gets:

""trafficAgentTypeValue"": {
   ""@id"": ""trafficAgentTypeValue""
}

Possible Solutions

  1. Fix in LinkML context generator (gen-jsonld-context): When a slot has any_of with exclusively enum ranges that share the same namespace, emit @type: @vocab with the shared @vocab.

  2. Schema workaround: Merge RoadUserHumanEnum and RoadUserVehicleEnum into a single TrafficAgentTypeEnum so the slot has a single enum range.

Affected Files

  • submodules/linkml -- gen-jsonld-context generator
  • artifacts/openlabel-v2/openlabel-v2.context.jsonld
  • tests/data/openlabel-v2/valid/openlabel-v2_instance.json
  • tests/data/openlabel-v2/invalid/fail11_traffic_agent_wrong_enum.json

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions