Repository navigation
FEAT: sources in the registry (scorer phase 13) - #3528
Merged
Richard Lundeen (richlundeen) merged 3 commits intoNov 9, 2026
Merged
Richard Lundeen (richlundeen) merged 3 commits into
Richard Lundeen (richlundeen) merged 3 commits into
Conversation
Adds SourceRegistry, which discovers the observation sources exported from pyrit.score.observation and holds configured instances, and wires ComponentType.SOURCE into reference resolution so a source-backed scorer can be built from a registered source name. ScorerIdentifier declares source as a constructor reference rather than a promoted field, so stored identities, hashes and the memory schema are unchanged.
Preserve source and scenario-suite registry exports and align source imports with main's public API contract. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Richard Lundeen (richlundeen)
approved these changes
Nov 9, 2026
Richard Lundeen (richlundeen)
left a comment
Contributor
There was a problem hiding this comment.
Automated review completed. No blocking concerns remain. This review records source coverage; it does not authorize merge.
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
One or more reviewer sessions failed, leaving the review evidence incomplete.
No open issues 🎉
What changed in this PR
Implements scorer roadmap phase 13 by making observation sources registry-constructible. Sources gain their own namespace, allowing source-backed scorers to reference configured instances by name without changing persisted scorer identities or hashes.
Changes:
- Adds
SourceRegistrywith structural discovery, instance storage, public exports, and setup reset support. - Wires source-name resolution into scorer construction and broadens instance containers to accept structural identifiers.
- Adds registry tests, frontend reference typing, and source configuration documentation.
| File | Description |
|---|---|
tests/unit/registry/test_source_registry.py |
Tests discovery, construction, references, resets, and identity stability. |
tests/unit/registry/test_resolution.py |
Adds sources to reference-resolution classification tests. |
pyrit/setup/initialization.py |
Resets the source registry with other setup registries. |
pyrit/score/observation/observation_source.py |
Makes the source protocol runtime-checkable. |
pyrit/registry/resolution.py |
Maps source references to SourceRegistry. |
pyrit/registry/registry.py |
Uses the structural identifier bound for held instances. |
pyrit/registry/instance_registry.py |
Introduces the SupportsIdentifier protocol. |
pyrit/registry/components/source_registry.py |
Implements source discovery, construction, and storage. |
pyrit/registry/components/__init__.py |
Lazily exports source registry classes. |
pyrit/registry/__init__.py |
Exposes source registry classes through the public package. |
pyrit/models/parameter.py |
Adds the source component type. |
pyrit/models/identifiers/scorer_identifier.py |
Declares the scorer’s source constructor reference. |
pyrit/models/identifiers/component_identifier.py |
Supports constructor references without promoted identity fields. |
frontend/src/types/index.ts |
Adds source to parameter reference types. |
doc/code/registry/0_registry.md |
Documents source registration and named scorer references. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Implements phase 13 of the scorer design and roadmap. Observation sources are now registry-constructible, as targets, converters, and scorers already are, so a source can be named and configured from a scenario or the backend instead of only being wired in Python.
SourceRegistry
SourceRegistrydiscovers the source classes exported frompyrit.score.observation(ConversationSource,LocalFileSurfaceSource,OtelTraceSource, andProgramExecutionSourcefrom #3218) and holds configured instances under.instances.ObservationSourceis a protocol, so sources share no base class to walk. The registry reads the package exports instead and keeps the classes that satisfy the protocol, which is now@runtime_checkable. Protocols, abstract classes, and private classes are skipped. It is reset with the other setup registries.Scorers take a source by name
ComponentType.SOURCEis wired into reference resolution, andScorerIdentifierdeclaressourceas a reference, soScorerRegistry.create_instance("FileWriteScorer", source="workspace")resolves the registered source. This applies toFileWriteScorer,OtelToolCallScorer, andProgramExecutionScorer. A live source still passes through unchanged, and an unknown name fails with the usual "not found" error.The reference is declared through a new
constructor_referencesclass variable on the identifier rather than as a promotedsourcefield. A promoted child gets its own persistence column and table, and the source identity already lives inchildren["source"], so this way no stored identity, identity hash, eval hash, or memory schema changes. A test checks both hashes on the typed projection.Instance container bound
InstanceHoldingRegistryandDefaultInstanceRegistrywere bound toIdentifiable, while sources implementget_identifier()structurally. The bound is now a smallSupportsIdentifierprotocol, which everyIdentifiablesatisfies and which is the one method the container calls.The roadmap decision
This gives sources their own namespace rather than joining the scorer namespace. A source is configured independently of the scorer that reads it, one source can serve several scorers, and the scorer catalog stays limited to classes that score. Happy to move them under the scorer namespace if you would rather have that.
Tests and documentation
tests/unit/registry/test_source_registry.pycovers discovery, building and holding sources, rejecting non-sources, scorer resolution by name and by instance, unknown names, the setup reset, and hash stability. The classification spec intest_resolution.pynow includesSOURCE. Each production change was reverted in turn and the new tests fail without it.On Python 3.13,
tests/unit/registry,models,score,setup,backend,memory, anddocspass (13,574 passed, rebased on main after #3218). Ruff is clean, and ty reports nothing new (the remaining diagnostics are the optional torch, a2a, copilot, and litellm imports). The registry doc has a new Source Registry section.