Skip to content

expressions: no test validates dispatch routes to concrete implementations, not stubs #115

Description

@discreteds

Problem

The expressions protocol alignment tests (test_protocol_alignment.py) verify that every protocol method has a concrete implementation on the composed ExpressionSystem class. But no test validates that the __getattr__ dispatch mechanism on BaseExpressionAPI actually routes to a real implementation rather than an inherited Protocol stub.

Gap

Consider a scenario where:

  1. A builder class inherits SomeProtocol (which declares method_x)
  2. The builder forgets to implement method_x
  3. The alignment test checks the composed ExpressionSystem — but __getattr__ dispatch operates on individual builder classes

The alignment test passes (because another builder or the composed class might have method_x), but the dispatch routes to the wrong builder's inherited stub.

What's needed

A test that:

  1. For each method discoverable via _FLAT_NAMESPACES dispatch, verifies the dispatched method is a concrete implementation (defined in __dict__ of the builder class), not an inherited Protocol stub
  2. Alternatively: a test that instantiates the API, calls each method name through normal attribute access, and verifies it doesn't return None/... (the protocol stub return values)

Relationship to #114

Issue #114 proposes fixing the dispatch to use ns_cls.__dict__ instead of hasattr. That fix makes this test less critical (stubs would never be dispatched), but the test remains valuable as defence-in-depth — verifying that every method the dispatch could route is actually implemented.

Discovered during

Codex adversarial review of the Relation API builder decomposition spec (2026-05-06).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions