Node Type Conformance Suite: the generalized runner a contributed Node Type must pass
This guide covers how engine/conformance_suite.py implements the Node Type Registry's contribution model. A contributed Node Type, built-in or third-party, is gated purely by passing the Conformance Suite. There is no separate registry service or human approval step. node-types/ itself is the registry, and passing this suite is what "contributed" means.
engine/conformance.py holds the Conformance Suite's fail-safe-behavior mechanism (see cross-node-type-validation-fault-injection.md). This module makes the suite reusable: one runner, run_conformance_suite, covers all three of the suite's testable properties (schema conformance, idempotent event handling and fail-safe behavior). It is driven by a small ConformanceHarness that any Node Type supplies, and is composed over engine/conformance.py, engine/node_type.py and engine/trigger_queue.py.
Building a harness for your Node Type
from engine.conformance_suite import ConformanceHarness
harness = ConformanceHarness(
node_type=my_node_type, # engine/node_type.py's NodeTypeDefinition
event_type_name="PrintCompleted", # which declared event type to validate against
registered_source_type="my-source", # a source_type your registry/Ingestion actually handles
unregistered_source_type="never-registered",
valid_raw_record={"event": "print_done", "label": "LBL-1"},
malformed_raw_record={"event": "jam_detected"}, # missing whatever valid_raw_record has
ingest=lambda source_type, raw, event_schema: my_registry.transform(source_type, raw),
)
ingest: the one seam that makes this generic
ingest has the shape (source_type, raw, event_schema) -> result, returning whatever your own ingest path returns for a successful call.
| Node Type shape | What ingest does |
|---|---|
Built on a bare TransformationRegistry (PLC/Generic Device) |
Ignores event_schema and returns the transform's dict directly. |
Built on a full *Ingestion class (MES/ERP) |
Passes event_schema straight through and returns a CrossTypeEnvelope. |
If ingest doesn't already return a plain dict, you must supply extract_event_fields to pull one out, for example lambda envelope: envelope.event_fields. Left at its identity default, the malformed-data check fails loudly with a clear TypeError rather than silently passing. A non-dict fed straight to jsonschema.validate fails on the type mismatch alone, never on the field content it is supposed to be checking.
enqueue_with_stable_id
If your Node Type has a real Trigger-enqueue pipeline of its own (MES/ERP's shape, not PLC/Generic Device's), also supply enqueue_with_stable_id. Its shape is (source_type, raw, trigger_id) -> None, and it must enqueue exactly the given trigger_id, not a freshly generated one, into the same trigger_queue you pass to run_conformance_suite.
This lets the idempotency check verify that your ingest path reuses a caller-supplied id on redelivery, not just that TriggerQueue.enqueue's own dedup works in isolation. Leave it at its None default if your Node Type has no enqueue pipeline of its own.
Running it
from engine.conformance_suite import run_conformance_suite
report = run_conformance_suite(harness, activity_log, trigger_queue, node_instance_id="my-node-1")
assert report.passed
for result in report.results:
print(f"{'PASS' if result.passed else 'FAIL'} {result.name}: {result.detail}")
activity_log and trigger_queue are caller-provisioned, the same dependency-injection shape run_fault_tolerant_ingestion uses. This module has no opinion on schema lifecycle.
Every check is independently wrapped. One broken property produces one failed ConformanceCheckResult naming which property failed, not an aborted run or an uncaught traceback.
The suite is tested in both directions. tests/test_conformance_suite.py runs it against a synthetic, non-product "LabelPrinter" Node Type (tests/fixtures/hypothetical_contrib_node_type.json):
- A run against a conformant harness passes every check.
- A run against a harness with a deliberately broken transform (it fabricates a
label_idinstead of leaving a non-matching record unchanged) fails only thefail_safe_malformed_datacheck. That proves the suite discriminates rather than always reporting green.
The five checks
schema_conformance:event_type_namenames a real declared event type, and itsfieldsfragment is independentlycheck_schema-valid.engine/node_type.pyalready guarantees this atNodeTypeDefinitionconstruction time for a harness built the normal way, so this check mostly catches a harness itself misnamingevent_type_name.idempotent_event_handling: enqueueing the sameTriggerQueueEntryid twice is a no-op the second time (TriggerQueue.enqueue'sON CONFLICT DO NOTHING). This is verified for every harness, Node-Type-agnostic. Ifenqueue_with_stable_idis supplied, it also verifies that your ingest path reuses one caller-suppliedtrigger_idacross two calls with the same raw record, rather than minting a fresh one each time. That is the actual redelivery-duplication bug this property exists to catch. It is reported as a weaker, mechanism-only check whenenqueue_with_stable_idisn't supplied.fail_safe_unreachable_retry_exhaustion: aFaultInjectingConnectorthat always raises ends inOutcome.GAVE_UPafter exhausting retries. It honorsunresponsive_exceptionsif you override it, so a harness declaring its own connector's transport exception type gets it actually used, not just the built-inhttpx.HTTPErrorandSidecarErrordefault.fail_safe_malformed_data:malformed_raw_record, once ingested, fails its own declared schema rather than being silently coerced into something schema-valid.fail_safe_unregistered_source_type: ingestingunregistered_source_typeagainstvalid_raw_recorddoesn't raise, and its fields come back equal tovalid_raw_recordunchanged. That is the mandatoryGENERIC_TRANSFORMfallback's passthrough contract, the same assertion every built-in Node Type's own conformance test makes (tests/test_conformance.py).
Pitfalls
malformed_raw_recordmust actually miss somethingvalid_raw_recordhas, and your transform must not fill that gap with a default. The whole point of check 4 is proving a real gap surfaces as a schema failure rather than getting silently papered over.- Check 5 assumes your
GENERIC_TRANSFORMfallback is still plain passthrough. If you've deliberately overridden your own registry'sGENERIC_TRANSFORMdefault to do something else (TransformationRegistry.register(GENERIC_TRANSFORM, ...)inengine/transformation.pysupports this), this check's equality assertion will fail even though your fallback is working as designed. Note that explicitly in your contribution rather than treating a failure here as a bug. enqueue_with_stable_idmust enqueue into the exactTriggerQueueinstance you pass torun_conformance_suite. A separate instance, even one built the same way, means check 2'squeue.get(trigger_id)will never find the row your closure enqueued.- This suite doesn't check Mandatory-Human Status the way the MES and ERP tests in
test_conformance.pydo. That is specific to Node Types built on identity resolution. Not every Node Type has one (PLC/Generic Device doesn't either), so it is out of this generalized runner's scope. - There is no CLI wrapper. Run the suite from a test (
tests/test_conformance_suite.pyis the reference example). There is no dedicated contribution-checking command.
Release: v0.11.0