Repository navigation
refactor(plugin-embeddings): one module per non-trivial function - #1100
Merged
Merged
Conversation
Splits the three files that share a module with an over-threshold sibling, so plugins/dirsql-plugin-embeddings/src is clean at one-function-per-file's strictest threshold of 1. - search/sql.py becomes quote.py, normalize_glob.py, embed_call.py, build_search_sql.py and count_corpus_sql.py, each named for its function. - search/run.py keeps NothingToRank and run_search; no_rows_message and the async search (renamed search_rows, since it is no longer module-private) move out with config_fragment, its only caller. - embedding/model.py keeps DEFAULT_MODEL_ID and load_model; model_identifier moves to its own module, so worker.py imports it directly rather than through the model module object. Each new module carries a colocated unit test that mocks its siblings, so the split does not smuggle real collaborators into the unit tier. No exemptions, no behavior change.
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.
Splits the three files in
plugins/dirsql-plugin-embeddings/srcthat share a module with an over-threshold sibling, so the root is clean atone-function-per-file's strictest threshold of 1.search/sql.pybecomesquote.py,normalize_glob.py,embed_call.py,build_search_sql.pyandcount_corpus_sql.py, each named for its function.search/run.pykeepsNothingToRankandrun_search;no_rows_messageand the async search (renamedsearch_rows, since it is no longer module-private) move out withconfig_fragment, its only caller.embedding/model.pykeepsDEFAULT_MODEL_IDandload_model;model_identifiermoves to its own module, soworker.pyimports it directly rather than through the model module object.Each new module carries a colocated unit test that mocks its siblings, so the split does not smuggle real collaborators into the unit tier. No behavior change, no exemptions (the count stays zero).
Out of scope, per the issue: lowering or adding
max_linesin anytesting-conventions.toml, and adding the gate toplugin-dirsql-embedding-ci.yml— a separate config PR lands that at the end of the campaign.Fixes #1095
Verification
Gate, measured both ways at threshold 1 (the plugin's
testing-conventions.tomlcarries nomax_lines, so the default of 1 already applies; re-confirmed against a/tmpcopy with an explicit[python.one_function_per_file] max_lines = 1):main: 6 violations (model_identifier,_search,run_search,normalize_glob,embed_call,build_search_sql)Full lane preflight (
just preflight --conventions .github/workflows/plugin-dirsql-embedding-ci.yml): 0 failing pairs, 0 skipped —uv-sync,declared-deps,colocated-test,one-function-per-file,unit-lint,integration-lint,unit-coverage,mutation(8 mutants, no survivors),e2e-verify.Tests:
pytest src tests/integration→ 169 passed.pytest tests/e2e/ -x -q→ 17 passed.Manual run of the moved functions against the installed package:
With a model argument the call becomes
embed('q', 'minishlab/potion-base-8M')in both positions, andmodel_identifier('minishlab/potion-base-8M', model)returnsminishlab/potion-base-8M@0.7.0when the model carries amodel2vec_version, bare otherwise. Matches pre-split behavior.E2E Verification
packages/pythonchangepackages/python/e2e-attestations/<branch>.jsonreceipt written ifpackages/pythonchanged (just e2e-attest-python) — N/A,packages/pythonuntouchedpackages/ts/e2e-attestations/<branch>.jsonreceipt written ifpackages/tschanged (just e2e-attest-ts) — N/A,packages/tsuntoucheduv run --with-editable ../../packages/python python -m pytest tests/e2e/ -x -qfromplugins/dirsql-plugin-embeddingsplugins/dirsql-plugin-embeddings/e2e-attestations/claude-1095-ofpf-embeddings.json(exit 0); the plugin'se2e-verifygate passes and no sibling receipts were pruned.Changelog / Migrations
<root>/<pkg>/changelog.d/for each changed package —plugins/dirsql-plugin-embeddings/changelog.d/2026-09-05-one-function-per-file.md<root>/<pkg>/migrations.d/(or: not required — additive/bugfix only) — not required: the moved symbols are plugin-internal helpers, the entry points and plugin protocol are unchanged, and there is no runtime behavior change. Matches the other lanes of this campaign (ci: one-function-per-file at max_lines = 1 — packages/python/dirsql/resolve_config_extensions.py #1079, one-function-per-file: split internals/distcheck/src to zero violations at threshold 1 #1097, ci: split packages/ts/src to one_function_per_file max_lines = 1 #1065).PARITY.md
No SDK public API touched (
packages/python/dirsql/,packages/rust/src/,packages/ts/src/are all untouched), so no parity update and no drift.