feat(rag): typed HelpCorpusAdapter protocol; localize dynamic import#10
Merged
Conversation
Phase A of specs/architecture-realignment (workspace-level spec 2026-05-08). Closes finding #4 from the 2026-05-07 code-review: ``importlib.import_module("attune_help")`` lived at the module body of attune_rag.corpus.attune_help, hiding the rag→help dependency from static analysis. Changes: - New ``attune_rag/corpus/help_adapter.py`` defines the ``HelpCorpusAdapter`` Protocol (``templates_root``, ``version``). Smaller surface than the design.md draft (no ``iter_entries``); iteration stays in DirectoryCorpus where it already lives. Honest- to-the-code wins. - ``AttuneHelpCorpus.__init__`` now takes an adapter explicitly. ``AttuneHelpCorpus.from_attune_help()`` is the convenience factory that does the dynamic import inside one classmethod call instead of the module body. Static analyzers see the rag→help boundary as a runtime-only dependency in this single function. - Module-level ``_BundledAdapter`` frozen dataclass implements the protocol for the bundled-help case. Lifted out of the factory body because Python's class-body scoping rules don't see enclosing- function locals (one test made me discover this the hard way). Two new tests: - ``test_corpus_works_with_injected_adapter`` exercises the protocol path end-to-end; verifies the adapter is the only import surface needed for a working corpus. - ``test_invalid_templates_root_raises`` verifies adapter validation fails at construction with a clear error. Existing 7 tests updated to use ``.from_attune_help()``. Full suite: 308 passed, 3 xpassed. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Merged
4 tasks
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.
Phase A of specs/architecture-realignment. Closes code-review finding #4.
AttuneHelpCorpus.__init__now takes a typedHelpCorpusAdapter. The dynamic import is gone from the module body and lives in one classmethod factory (from_attune_help()). Existing call site inpipeline.pyupdated; existing 7 tests updated; 2 new tests verify the protocol path works without attune-help in scope.Deviation from design.md noted in commit body: shipped a smaller protocol (
templates_root,version) than the draft (iter_entries,name,version) because iteration already lives in DirectoryCorpus.308 passed, 3 xpassed.
🤖 Generated with Claude Code