Skip to content

refactor(database): resolve_writable_collection delegates, and its comments match reality - #2385

Open
cyberlife-coder wants to merge 1 commit into
developfrom
refactor/dedup-resolve-writable-collection
Open

cyberlife-coder wants to merge 1 commit into
developfrom
refactor/dedup-resolve-writable-collection

Conversation

@cyberlife-coder

@cyberlife-coder cyberlife-coder commented Sep 22, 2026

Copy link
Copy Markdown
Owner

⚠️ Target branch (Git Flow)

refactor/* → targets develop. ✅

Description

resolve_writable_collection and resolve_collection (both in
crates/velesdb-core/src/database/query_engine.rs) had byte-identical
bodies — check the vector registry, then graph, then metadata — but
three call sites carried comments claiming a behavioral difference
that never existed:

  • ddl_executor.rs's execute_truncate chained
    .resolve_writable_collection(...).or_else(|_| self.resolve_collection(...))
    with a comment saying the writable resolver "skips" metadata
    collections. Since the two resolvers are identical, that fallback
    branch is provably dead code — it can never fire.
  • training.rs's resolve_train_collection attributed the "no
    vectors on a metadata-only collection" guard to
    resolve_writable_collection itself. That guard actually lives in
    extract_training_vectors, which filters out points with an empty
    vector before training — not in collection resolution.

This is the AGENTS.md-flagged pattern of documentation describing
enforcement the code doesn't actually perform (docs must describe
what the code enforces, not what it aspires to).

Type of Change

  • 🔧 Refactoring (no functional changes)

What changed

  • resolve_writable_collection now delegates to resolve_collection
    instead of repeating its body, with an accurate doc comment
    explaining the two names exist for call-site intent (write path vs.
    read path), not a difference in what gets resolved.
  • Dropped the dead .or_else fallback in execute_truncate and its
    stale comment.
  • Corrected resolve_train_collection's doc comment to point at the
    actual location of the "no vectors" guard.

No behavior change: same resolution order, same error on an unknown
collection, same TRUNCATE and TRAIN semantics.

How Has This Been Tested?

  • Unit tests
  • cargo check -p velesdb-core --features persistence
  • cargo clippy -p velesdb-core --all-targets --features persistence,gpu,update-check,openapi,test-fault-injection -- -D warnings -D clippy::pedantic
  • cargo clippy -p velesdb-core --lib --bins --features persistence,gpu,update-check -- -A warnings -D clippy::undocumented_unsafe_blocks
  • cargo test -p velesdb-core --features persistence --lib database:: -- --test-threads=1 (207 passed)
  • cargo test -p velesdb-core --features persistence --lib database::ddl_executor_tests:: -- --test-threads=1 (39 passed, covers TRUNCATE)
  • cargo test -p velesdb-core --features persistence --lib velesql::train_tests:: -- --test-threads=1 (10 passed)
  • cargo fmt --all -- --check (clean)

Test Configuration:

  • OS: Linux
  • Rust version: per rust-toolchain.toml (MSRV 1.90)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works — not applicable, no behavior change; existing tests cover the paths touched

Additional Notes

Not a high-risk change: doesn't touch hnsw, storage, Drop, unsafe, or SIMD dispatch paths. Scoped to crates/velesdb-core/src/database/ only.

@github-actions

github-actions Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA. Thank you!
Posted by the CLA Assistant Lite bot.

@cyberlife-coder
cyberlife-coder force-pushed the refactor/dedup-resolve-writable-collection branch from 3bad750 to f262b60 Compare September 22, 2026 03:15

Copy link
Copy Markdown
Owner Author

cla-assistant is failing: the bot requires a comment on this PR literally saying "I have read the CLA Document and I hereby sign the CLA" before it passes. Signing a CLA is a legal declaration on the contributor's behalf, so I'm not posting that on your behalf — @cyberlife-coder, this one needs you.

Everything else on the current head (f262b60) is green or in progress (ci.yml's jobs, security/snyk, Devin Review); PR Governance re-ran against this SHA after I amended out a server-appended attribution footer from the PR body. I'll keep watching and pick up anything else CI or review turns up.


Generated by Claude Code

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity

Metric Results
Complexity 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

…mments match reality

resolve_writable_collection and resolve_collection had byte-identical
bodies (vector, then graph, then metadata registries), but three
call-site comments described a behavioral difference that never
existed: ddl_executor's TRUNCATE fallback claimed the writable
resolver skips metadata collections and chained an .or_else that
could never actually run, and training.rs attributed the "no vectors
on a metadata collection" guard to the wrong function (it actually
lives in extract_training_vectors's is_empty filter).

Make resolve_writable_collection delegate to resolve_collection,
drop the now-provably-dead .or_else fallback, and correct the three
comments to say what the code does today.
@cyberlife-coder
cyberlife-coder force-pushed the refactor/dedup-resolve-writable-collection branch from f262b60 to 781d8a0 Compare September 22, 2026 03:19

Copy link
Copy Markdown
Owner Author

PR Governance's attribution guard was failing for real on f262b60: the commit's git author/committer identity (not just message text) was Claude <noreply@anthropic.com>, set by my session's default git config rather than anything I wrote into the commit message. Re-authored as Wiscale <...@users.noreply.github.com> (matching this repo's existing commit convention) via git commit --amend --reset-author and force-pushed my own branch's sole commit to 781d8a0. scripts/check-ai-attribution.py now passes locally against origin/develop..HEAD.

Still waiting on your CLA-sign comment; everything else should re-check green against 781d8a0.


Generated by Claude Code

This branch has not been deployed

No deployments
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.

1 participant