Skip to content

test(adapter_base): signature snapshot — drift gate for adapter public surface (#2364 item 2) - #2378

Merged
HongmingWang-Rabbit merged 1 commit into
stagingfrom
auto/base-adapter-signature-snapshot
Apr 30, 2026
Merged

HongmingWang-Rabbit merged 1 commit into
stagingfrom
auto/base-adapter-signature-snapshot

Conversation

@HongmingWang-Rabbit

Copy link
Copy Markdown
Contributor

Implements #2364 item 2.

Summary

Every workspace template subclasses `BaseAdapter`. Renaming, removing, or re-typing a method on the base class silently breaks templates: the override stops being recognized as an override; the old method-name's caller silently invokes the default no-op; the new method-name is unimplemented in templates that haven't migrated.

Recent #87 universal-runtime + #1957 recordResource refactor both renamed/added methods. Without a frozen snapshot, the next rename ships quietly and surfaces only when a template's CI catches the `AttributeError` days later.

This snapshot pins BaseAdapter's public method surface against a checked-in JSON file. Same-shape pattern as PR #2363's A2A protocol-compat replay gate, applied to a Python public-API surface.

Tests

  1. `test_base_adapter_signature_matches_snapshot` — full introspection diff against `tests/snapshots/adapter_base_signature.json`. Drift = test failure with both expected + actual JSON in the message so the reviewer sees what changed.
  2. `test_snapshot_has_required_methods` — defense-in-depth: even if both the source AND snapshot are updated together, this catches removal of the short list of methods that EVERY template depends on (`name`, `display_name`, `description`, `capabilities`, `memory_filename`). Removing one of these requires an explicit edit to the `required` set with a justification.

Verification

Hand-tested: deliberately renamed `memory_filename` to `memory_filename_RENAMED` in adapter_base.py — gate fires with full snapshot diff in the failure message. Reverted; tests pass.

How to handle intentional changes

When a template-affecting API change is real:

  1. Make the API change in `adapter_base.py`
  2. Run the test once to see the diff in the failure message
  3. Update `tests/snapshots/adapter_base_signature.json` to match the new shape — that update IS the explicit ack that templates need follow-up. Reviewer sees the snapshot diff in the PR.

Test plan

  • Both tests pass
  • Verified gate fires red on deliberate rename
  • Snapshot is human-readable JSON with stable sort order

🤖 Generated with Claude Code

…c surface (#2364 item 2)

Every workspace template (langgraph, claude-code, hermes, etc.)
subclasses BaseAdapter. Renaming, removing, or re-typing a method
on the base class silently breaks templates: the override stops
being recognized as an override; the old method-name's caller
silently invokes the default no-op; the new method-name is
unimplemented in templates that haven't migrated.

Recent #87 universal-runtime + #1957 recordResource refactor both
renamed/added methods. Without a frozen snapshot, the next rename
ships quietly and surfaces only when a template's CI catches the
AttributeError days later — long after the merge window for an
easy revert.

This snapshot pins BaseAdapter's public method surface against a
checked-in JSON file. Same-shape pattern as PR #2363's A2A
protocol-compat replay gate, applied to a Python public-API
surface instead of JSON message shapes. Both close drift classes
by snapshotting the structural surface that consumers depend on.

Two tests:

  1. test_base_adapter_signature_matches_snapshot — full
     introspection diff against tests/snapshots/adapter_base_signature.json.
     Drift = test failure with both expected + actual JSON in
     the message so the reviewer sees what changed.
  2. test_snapshot_has_required_methods — defense-in-depth: even
     if both the source AND snapshot are updated together
     (intentional API removal), this catches removal of the
     short list of methods that EVERY template depends on (name,
     display_name, description, capabilities, memory_filename).
     Removing one of these requires explicit edit to the
     `required` set with a justification.

Verified the gate fires red on a deliberate rename
(memory_filename → memory_filename_RENAMED) — failure message
shows the full snapshot diff including parameter shapes and
return annotations.

Updating the snapshot is the explicit acknowledgment that a
template-affecting API change is intentional. Reviewer of the
introducing PR sees the snapshot diff and decides whether
template repos need coordinated updates.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant