Repository navigation
feat(sleep): make transcript sources and backends pluggable with entry points and public harvest helpers - #370
Open
RohithPariki wants to merge 1 commit into
Conversation
…y points and public harvest helpers
- Discover external transcript harvesters via the 'skillopt_sleep.sources' entry-point group or in-memory 'register_source()'
- Discover external replay/optimizer backends via 'skillopt_sleep.backends' entry-point group or in-memory 'register_backend()'
- Add '--source-module pkg.mod:func' and '--backend-module pkg.mod:Class' flags for unpackaged standalone adapters
- Expose standard harvest helpers ('is_headless_replay', 'is_agent_session', 'is_meta_prompt', 'detect_feedback', 'redact_secrets') in 'skillopt_sleep.harvest' for external harvesters
- Provide informative ValueError messages with all registered sources and backends on unknown input
- Add unit test suite in tests/test_sleep_pluggable_registry.py
Fixes microsoft#314
This branch has not been deployed
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.
Problem
Currently, adding custom transcript harvesters or replay/optimizer backends to SkillOpt-Sleep requires modifying core codebase files or writing external harness wrappers. As noted in #314, external ecosystems (such as Antigravity, zcode, Crush, or specialized LLM harnesses) had no sanctioned plugin mechanism to register their harvesters or backends directly into
skillopt-sleep. Furthermore, external harvesters could not reuse the internal session sanitization, feedback detection, and meta-prompt filtering logic without reaching into private underscored functions.Items 3 and 4 of #314 were previously merged (in #350 and #322). On Nov 4, maintainer Yifan Yang (@Yif-Yang) confirmed:
Solution
This PR implements items 1, 2, and 5 of #314:
skillopt_sleep/harvest_sources.py):skillopt_sleep.sourcesentry-point group and in-memoryregister_source(name, fn)registry alongside built-in harvesters.--source-module pkg.mod:func(andsource_moduleconfig support) for loading unpackaged adapter functions directly.normalize_transcript_source()validates against all built-in, entry-point, and registered source names with an informative error listing available options.skillopt_sleep/backend.py):skillopt_sleep.backendsentry-point group and in-memoryregister_backend(name, factory)registry.--backend-module pkg.mod:Class(andbackend_moduleconfig support) for loading unpackaged backend classes or factories directly.get_backend()validates unknown names against all available backends, raising an informativeValueError.build_backend()wiresbackend_modulethrough to single or dual backend construction.skillopt_sleep/__main__.py):--source-moduleand--backend-moduleflags.--sourceand--backendso registered and entry-point names are cleanly accepted from the CLI.skillopt_sleep/harvest.py):is_headless_replay,is_agent_session,is_meta_prompt,detect_feedback, andredact_secretsin__all__, allowing external adapters to apply identical filtering and secret redaction.## [Unreleased] / ### Added.Testing
tests/test_sleep_pluggable_registry.py:test_custom_source_registration_and_harvest: Validatesregister_source()and invocation inharvest_for_config().test_entry_point_source_discovery: Mocksskillopt_sleep.sourcesentry points.test_source_module_invocation: Validates loading viamodule:funcspec.test_unknown_source_raises_informative_error: VerifiesValueErrorlists available sources.test_custom_backend_registration: Validatesregister_backend()andget_backend().test_entry_point_backend_discovery: Mocksskillopt_sleep.backendsentry points.test_backend_module_invocation: Validates loading viamodule:Classspec.test_unknown_backend_raises_informative_error: VerifiesValueErrorlists available backends.test_public_harvest_helpers: Verifiesis_meta_prompt,detect_feedback,is_agent_session,is_headless_replay, andredact_secrets.tests/test_sleep_pluggable_registry.pypass cleanly.ruff checkpasses with 0 errors.Risk
Low. Fully backwards-compatible. All existing built-in sources (
claude,codex,copilot,cursor,pi,opencode,auto) and backends (azure,claude,codex,copilot,cursor,handoff,mock,opencode,pi) remain default and behaviorally identical.Fixes #314