Search and contents

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 shapeWhat 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_id instead of leaving a non-matching record unchanged) fails only the fail_safe_malformed_data check. That proves the suite discriminates rather than always reporting green.

The five checks

  1. schema_conformance: event_type_name names a real declared event type, and its fields fragment is independently check_schema-valid. engine/node_type.py already guarantees this at NodeTypeDefinition construction time for a harness built the normal way, so this check mostly catches a harness itself misnaming event_type_name.
  2. idempotent_event_handling: enqueueing the same TriggerQueueEntry id twice is a no-op the second time (TriggerQueue.enqueue's ON CONFLICT DO NOTHING). This is verified for every harness, Node-Type-agnostic. If enqueue_with_stable_id is supplied, it also verifies that your ingest path reuses one caller-supplied trigger_id across 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 when enqueue_with_stable_id isn't supplied.
  3. fail_safe_unreachable_retry_exhaustion: a FaultInjectingConnector that always raises ends in Outcome.GAVE_UP after exhausting retries. It honors unresponsive_exceptions if you override it, so a harness declaring its own connector's transport exception type gets it actually used, not just the built-in httpx.HTTPError and SidecarError default.
  4. fail_safe_malformed_data: malformed_raw_record, once ingested, fails its own declared schema rather than being silently coerced into something schema-valid.
  5. fail_safe_unregistered_source_type: ingesting unregistered_source_type against valid_raw_record doesn't raise, and its fields come back equal to valid_raw_record unchanged. That is the mandatory GENERIC_TRANSFORM fallback's passthrough contract, the same assertion every built-in Node Type's own conformance test makes (tests/test_conformance.py).

Pitfalls

  • malformed_raw_record must actually miss something valid_raw_record has, 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_TRANSFORM fallback is still plain passthrough. If you've deliberately overridden your own registry's GENERIC_TRANSFORM default to do something else (TransformationRegistry.register(GENERIC_TRANSFORM, ...) in engine/transformation.py supports 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_id must enqueue into the exact TriggerQueue instance you pass to run_conformance_suite. A separate instance, even one built the same way, means check 2's queue.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.py do. 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.py is the reference example). There is no dedicated contribution-checking command.

Release: v0.11.0