refactor(commands): extract shared embedding core - #1071
Merged
Conversation
Contributor
There was a problem hiding this comment.
No issues found across 6 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
You’re at about 94% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.
- embed_note / embed_insight / embed_source now share a single load->embed->write runner (_embed_record) with one common ValueError/Exception epilogue; note and insight additionally share _embed_markdown_record for the identical load/validate/embed/UPSERT body - rebuild_embeddings submits jobs for sources/notes/insights through one _submit_embedding_jobs helper instead of three copy-pasted loops - the four embed-family commands reuse one EMBED_RETRY_CONFIG dict, with a NOTE marking that stop_on can never trigger today (commands catch ValueError internally) - preserved as-is for a future error-handling PR - full_model_dump() was copy-pasted in three command files but only used by podcast_commands: moved to open_notebook/utils/model_utils.py, imported where used, dead copies in embedding/source commands removed Behavior-identical: same outputs, success=False paths, log messages and retry configuration. 403 tests pass; ruff and mypy clean (no new errors).
lfnovo
force-pushed
the
refactor/embedding-command-core
branch
from
July 11, 2026 21:56
19b26ad to
0d60c68
Compare
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.
Summary
Deduplicates
commands/embedding_commands.py(and the thrice-copiedfull_model_dump). Pure refactor — behavior-identical: same outputs, samesuccess=Falsepaths, same log messages, same retry configuration.embed_note/embed_insight/embed_sourcewere structural clones (load → validate → embed → UPSERT + an identical ~20-line ValueError/Exception epilogue ×3). They now run through one_embed_record(...)runner holding the epilogue; note and insight additionally share_embed_markdown_record(...)for their identical bodies.rebuild_embeddings_commandsubmitted jobs via three copy-pasted loops — now one_submit_embedding_jobs(kind, command_name, id_field, ids)helper (same progress/error log messages).EMBED_RETRY_CONFIGdict. Added a# NOTE:marking thatstop_on: [ValueError, ...]can never trigger today (commands catch ValueError internally and returnsuccess=False) — intentionally preserved as-is for a future error-handling PR.full_model_dump(): was copy-pasted inembedding_commands.py,podcast_commands.pyandsource_commands.py, but onlypodcast_commandsactually used it. Moved toopen_notebook/utils/model_utils.py(exported fromopen_notebook.utils), imported inpodcast_commands; the two dead copies were removed rather than re-imported (F401 is enforced again as of chore(lint): re-enable F401/F841/E722 and fix fallout #1062).Line delta: +232 / −319 overall;
embedding_commands.pyalone drops from 799 to ~636 lines.Verification
uv run pytest tests/— 403 passedruff check .— clean;ruff format— cleanuv run python -m mypy commands/ open_notebook/utils/— 8 pre-existing errors, identical count and locations asmain(none in touched lines)import commandsregisters all 8 commands with retry configs identical to main (verified via the surreal-commands registry)