Skip to content

Feature-gate Python EXIProcessor surface — Fragment/XmldsigFragment methods present iff schema defines the root #41

@JakeMG-INL

Description

@JakeMG-INL

Parent

#8

What to build

Replace the current "method always exists, raises NotImplementedError at call time" pattern with feature-gated method binding: on Namespaces whose libcbv2g schema doesn't define *_exiFragment or xmldsigFragment roots (today: SAP, DIN), the corresponding EXIProcessor methods (encode_fragment, decode_fragment, encode_xmldsig, decode_xmldsig) are absent — accessing them raises AttributeError, and hasattr(p, "encode_fragment") returns False.

Today the binders in _bind_decoder / _bind_encoder silently skip missing ctypes symbols and the Python methods raise NotImplementedError mentioning the internal ctypes symbol name. The new behavior makes feature detection honest: a consumer can hasattr to dispatch instead of try/except.

Implementation: EXIProcessor.__init__ should conditionally bind the Fragment / XmldsigFragment methods to the instance only when the underlying ctypes symbol exists. Methods on the class continue to exist for type-checker visibility, but instances of SAP/DIN Processors don't carry them — or alternatively, the class-level methods are removed entirely and the implementation lives in instance-bound closures gated by the ctypes-symbol check. Either is acceptable; choose the simpler.

Update tests/integration/test_namespace_parity.py and tests/integration/test_unsupported_methods.py accordingly: the expectation flips from "calling the method on SAP/DIN raises NotImplementedError" to "the method is not present on SAP/DIN processors; hasattr returns False and accessing the attribute raises AttributeError".

Per ADR-0014 supersedes ADR-0006 lines 12 and 21 on this point.

Acceptance criteria

  • EXIProcessor instances for Namespace.SAP and Namespace.DIN lack encode_fragment, decode_fragment, encode_xmldsig, decode_xmldsig attributes
  • hasattr(EXIProcessor(Namespace.ISO2), "encode_fragment") returns True; same for the five ISO-20 Namespaces
  • Accessing encode_fragment on a SAP/DIN processor raises AttributeError (not NotImplementedError)
  • tests/integration/test_namespace_parity.py updated — parity expectations match feature gating
  • tests/integration/test_unsupported_methods.py updated — asserts AttributeError, not NotImplementedError
  • All other integration test suites still pass

Blocked by

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agentFully specified, ready for an AFK agent

    Type

    No type
    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