Skip to content

refactor(plugin-embeddings): one module per non-trivial function - #1100

Merged
thekevinbot merged 2 commits into
mainfrom
claude/1095-ofpf-embeddings
Sep 5, 2026
Merged

thekevinbot merged 2 commits into
mainfrom
claude/1095-ofpf-embeddings

Conversation

@thekevinbot

Copy link
Copy Markdown
Collaborator

Splits the three files in plugins/dirsql-plugin-embeddings/src that share a module with an over-threshold sibling, so the root 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 behavior change, no exemptions (the count stays zero).

Out of scope, per the issue: lowering or adding max_lines in any testing-conventions.toml, and adding the gate to plugin-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.toml carries no max_lines, so the default of 1 already applies; re-confirmed against a /tmp copy with an explicit [python.one_function_per_file] max_lines = 1):

testing-conventions@0.0.111 unit one-function-per-file --language python \
  --config plugins/dirsql-plugin-embeddings/testing-conventions.toml \
  plugins/dirsql-plugin-embeddings/src
  • on main: 6 violations (model_identifier, _search, run_search, normalize_glob, embed_call, build_search_sql)
  • on this branch: exit 0, zero violations

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:

$ python -c "from dirsql_plugin_embeddings.search.build_search_sql import build_search_sql; \
             print(build_search_sql('docs/*.md', 'hello world', 5))"
SELECT path, vec_distance_cosine(emb, embed('hello world')) AS distance FROM (SELECT path, embed(content) AS emb FROM './docs/*.md') WHERE emb IS NOT NULL ORDER BY distance LIMIT 5

With a model argument the call becomes embed('q', 'minishlab/potion-base-8M') in both positions, and model_identifier('minishlab/potion-base-8M', model) returns minishlab/potion-base-8M@0.7.0 when the model carries a model2vec_version, bare otherwise. Matches pre-split behavior.

E2E Verification

  • Ran e2e suites locally for every affected SDK
  • Python SDK e2e: N/A — no packages/python change
  • TypeScript SDK e2e: N/A
  • Rust core e2e (if applicable): N/A
  • packages/python/e2e-attestations/<branch>.json receipt written if packages/python changed (just e2e-attest-python) — N/A, packages/python untouched
  • packages/ts/e2e-attestations/<branch>.json receipt written if packages/ts changed (just e2e-attest-ts) — N/A, packages/ts untouched
  • Command(s) run: uv run --with-editable ../../packages/python python -m pytest tests/e2e/ -x -q from plugins/dirsql-plugin-embeddings
  • Result summary: 17 passed. Receipt committed at plugins/dirsql-plugin-embeddings/e2e-attestations/claude-1095-ofpf-embeddings.json (exit 0); the plugin's e2e-verify gate passes and no sibling receipts were pruned.

Changelog / Migrations

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.

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.
@thekevinbot
thekevinbot merged commit be01cd1 into main Sep 5, 2026
31 checks passed
@thekevinbot
thekevinbot deleted the claude/1095-ofpf-embeddings branch September 5, 2026 11:20
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.

one-function-per-file: split plugins/dirsql-plugin-embeddings/src to zero violations at threshold 1

1 participant