Skip to content

feat: resolve third-party backends via entry points (makes ADR 0005 real)#20

Merged
vigneshnarayanaswamy merged 1 commit into
mainfrom
feat/entrypoint-backends
Jun 8, 2026
Merged

feat: resolve third-party backends via entry points (makes ADR 0005 real)#20
vigneshnarayanaswamy merged 1 commit into
mainfrom
feat/entrypoint-backends

Conversation

@vigneshnarayanaswamy

Copy link
Copy Markdown
Collaborator

Turns a documented-but-fake extension point into a working one.

ADR 0005 (storage-agnostic) promises you can register a backend via an entry point with no core change — but nothing read the model_ledger.backends group, so following that contract gave you a backend that never loaded.

  • backends/registry.pyload_backend_class(name) discovers a backend in the model_ledger.backends entry-point group (mirrors the working introspector pattern).
  • CLI--backend <name> falls back to entry-point discovery for any non-built-in name; constructs Backend(path) / Backend().
  • tests — entry-point resolution (monkeypatched), graceful None for unknown, and a runtime-checkable protocol-conformance check.
  • docs — the backends guide now documents the registration contract, because it works.

mypy clean (76 files) · 729 passed / 24 skipped · coverage 74.76%.

🤖 Generated with Claude Code

…eal)

ADR 0005 promises storage is an open extension point — "register an entry
point, no core change" — but no code read the model_ledger.backends group; a
user following that contract got a backend that never loaded.

- backends/registry.py: load_backend_class(name) discovers a backend target
  in the model_ledger.backends entry-point group (mirrors the working
  introspector pattern).
- cli/_resolve_backend: falls back to entry-point discovery for any --backend
  name that isn't built in; constructs Backend(path) or Backend().
- tests: entry-point resolution (monkeypatched), graceful None for unknown,
  and a protocol-conformance check (a real backend satisfies LedgerBackend).
- docs/guides/backends: document the registration contract, now that it works.

mypy clean (76 files), ruff clean, 729 passed / 24 skipped, coverage 74.76%.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@vigneshnarayanaswamy vigneshnarayanaswamy merged commit 121e4dd into main Jun 8, 2026
8 checks passed
@vigneshnarayanaswamy vigneshnarayanaswamy deleted the feat/entrypoint-backends branch June 8, 2026 02:36

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 060ca627a8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +37 to +40
if ep.name == name:
return ep.load()
except Exception:
return None

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Fail instead of falling back when backend plugin won't load

When an installed third-party backend entry point matches the requested name but ep.load() raises (for example because the plugin has a missing dependency or an invalid target), this broad except returns None. In the inspected CLI path, both model-ledger mcp --backend <name> and model-ledger serve --backend <name> pass that None into create_server/create_app, which default to an in-memory backend, so a production service can silently start with transient empty storage instead of reporting the broken configured backend.

Useful? React with 👍 / 👎.

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