Skip to content

Preserve embedding indexes and report coverage health - #117

Merged
blast-hardcheese merged 3 commits into
mainfrom
fix/preserve-embedding-index-and-report-coverage
Nov 13, 2026
Merged

blast-hardcheese merged 3 commits into
mainfrom
fix/preserve-embedding-index-and-report-coverage

Conversation

@blast-hardcheese

@blast-hardcheese blast-hardcheese commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Existing vectors are durable state. A different embedding provider, model, dimensions or chunk strategy refuses indexing and semantic retrieval instead of dropping the index. Explicit provider settings and missing legacy fingerprint metadata do not authorize replacement. Vectors, metadata and pending work remain intact, and no provider request or interactive prompt is made for the mismatch.

Mismatch errors identify the stored and current provider/model/dimensions/strategy. Read-only secondary graphs skip only their incompatible semantic channel, keep lexical/graph results available, and surface a warning. MCP ask, evidence-level context, and empty-result responses also retain that warning, including when the affected graph contributes no hits. kin task nearby does not depend on vectors, and optional compact-hook context reports an omission without failing the hook.

kin doctor and kin embed status report eligible, fresh, missing and stale/incomplete coverage, quarantine and the latest retained vector update. A graph with no initialized optional vector index reports 0/N coverage as a warning; partial coverage or an unreadable existing index remains an issue. Freshness follows current redacted text, fingerprint and complete retained chunks, not timestamp age. The timestamp is not attempt history. Diagnostics never reindex, including doctor --fix.

Restore the matching configuration to reuse the index. Ordinary indexing commands do not authorize erasure or migration, and no rebuild command is added.

Validation

  • Full local suite on Python 3.13.14: 4,959 passed, 3 skipped, 286 subtests passed (pytest -n 4 --dist loadfile --timeout 300).
  • Focused embedding safety/health and MCP evidence/cross-graph regressions: 175 passed, 19 subtests passed. Temporary graphs cover secondary lexical hits, primary-only hits, empty results, tiny evidence budgets, and drafted-answer prompts; no provider access.
  • git diff --check passed.
  • Hosted test is pending for current head 7fc301a62f2c19ab6f1e1630b839ac91872b8824. Proof was skipped; the active default-branch ruleset has no required status-check contexts.
  • Adapt acknowledged the earlier README and human-readable status fixes, but has not posted a full-delta review of the latest head. The PR still needs one approving maintainer review.

Scope

Data-integrity safeguards and read-only diagnostics only. No provider/default/credential changes, release/version bump, deployment, live-graph changes or backfill. Real providers and live stores are intentionally not exercised.


Show it working
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@blast-hardcheese
blast-hardcheese marked this pull request as ready for review November 11, 2026 20:44

@adaptcom adaptcom Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confidence Score: 2/5

Summary

Score reconciled from 3/5 because the review includes a blocking finding.

Fail-closed embedding fingerprint handling (no auto-drop) plus read-only coverage diagnostics in doctor/status. Well tested, but a stale vec_meta state becomes a permanent dead-end and doctor flips unhealthy for every graph without vectors.

Important Files Changed

File Overview
src/kindex/vectors.py Fingerprint gate refuses index replacement; vector_search raises EmbeddingFingerprintMismatch
src/kindex/embedding_health.py New read-only coverage/freshness diagnostics; missing tables reported as unavailable issue
src/kindex/retrieve.py hybrid_search re-raises fingerprint mismatch for every caller
src/kindex/cli.py Doctor adds embedding findings; embed failures exit 1; mismatch exits 2
CHANGELOG.md Unreleased Fixed/Added entries
README.md Documents preservation and diagnostics; awkward hard wrap
tests/test_doctor_fts.py Fixtures now asserted unhealthy because no vector index exists
tests/test_doctor_idempotence.py Same healthy-to-unhealthy contract rewrite
tests/test_embedding_cost_behavior.py Config-change tests flipped from regeneration to refusal
tests/test_embedding_index_safety.py New preservation/CLI/MCP/scheduler regressions
tests/test_embedding_quarantine.py Mocked index now seeds vec_meta identity
tests/test_vectors.py Mocked index now seeds vec_meta identity
tests/test_kindex_embedding_health.py New offline coverage/freshness diagnostics tests

Findings

  • src/kindex/cli.py — Human kin embed status output still prints only 'Coverage complete'; emit embedding_health_lines so coverage and mismatch detail is not JSON-only.

Reviewed 63aad55...e42e217 · ↻ Re-run review · View in Adapt

Comment thread src/kindex/vectors.py Resolved
Comment thread src/kindex/embedding_health.py Resolved
Comment thread src/kindex/vectors.py Resolved
Comment thread src/kindex/retrieve.py Resolved
Comment thread src/kindex/vectors.py Resolved
Comment thread src/kindex/vectors.py Resolved
Comment thread README.md Resolved
@blast-hardcheese

Copy link
Copy Markdown
Collaborator Author

Addressed the finding in Adapt review #5865199113 in 1d45bc6. Human-readable kin embed status now prints embedding_health_lines(result), including coverage and stored/current fingerprint details; added a CLI regression for the text output.

@blast-hardcheese

Copy link
Copy Markdown
Collaborator Author

This is to address an issue where importing nodes after switching machines, I couldn't tell why my recovery was so bad but it turns out periodic model failures were causing the index to be cleared, but not successfully rebuilt.

$ kin doctor
Embedding coverage: 0/10117 current (0.00%), 9920 missing, 197 stale/incomplete
Embedding work: 200 queued, 1 quarantined
Embedding fingerprint (current): {"chunk_chars":6000,"chunk_overlap_chars":600,"dimensions":1024,"max_group_chunks":20,"model":"voyage-context-4","provider":"voyage","strategy":"contextual"}
Embedding fingerprint (stored): {"dimensions":1536,"model":"text-embedding-3-small","provider":"openai","strategy":"single"}
Latest retained embedding update: 2026-11-11T21:16:29+00:00 (not attempt history)
Freshness uses current text and configuration, not time since the last embedding.

3 issue(s):
  ✗ Embedding fingerprint mismatch: the stored index does not match the current provider/model/dimensions/strategy. Restore the matching embedding configuration. Keep the existing index and pending work; migration requires a separately reviewed procedure.
  ✗ Embedding coverage: 0/10117 current (0.00%); 9920 missing, 197 stale/incomplete. After resolving configuration/provider blockers, review `kin embed plan --stale` and explicitly enqueue/drain the required work.
  ✗ 1 quarantined embedding node(s), even if the queue is empty. Inspect `kin embed status` quarantine reasons and resolve them before retrying.

4 warning(s):
  ⚠ 908 degraded hook event(s) in last 7 days — last: cron (RuntimeError); see degraded.jsonl
  ⚠ 200 embedding node(s) pending; queue emptiness alone does not establish coverage. Inspect `kin embed status` before draining.
  ⚠ Graph has 734 disconnected components
  ⚠ Low cross-domain bridging: 1042/13668 edges (8%) cross domain boundaries (< 10%) — run `kin dream` to discover connections

Run `kin doctor --fix` to auto-repair fixable issues.

After triggering the rebuild, I now get

$ kin doctor
Embedding coverage: 10135/10136 current (99.99%), 0 missing, 1 stale/incomplete
Embedding work: 0 queued, 1 quarantined
Embedding fingerprint (current): {"dimensions":1536,"model":"text-embedding-3-small","provider":"openai","strategy":"single"}
Embedding fingerprint (stored): {"dimensions":1536,"model":"text-embedding-3-small","provider":"openai","strategy":"single"}
Latest retained embedding update: 2026-11-12T01:50:04+00:00 (not attempt history)
Freshness uses current text and configuration, not time since the last embedding.

2 issue(s):
  ✗ Embedding coverage: 10135/10136 current (99.99%); 0 missing, 1 stale/incomplete. After resolving configuration/provider blockers, review `kin embed plan --stale` and explicitly enqueue/drain the required work.
  ✗ 1 quarantined embedding node(s), even if the queue is empty. Inspect `kin embed status` quarantine reasons and resolve them before retrying.

3 warning(s):
  ⚠ 914 degraded hook event(s) in last 7 days — last: attention-hook (ConfigResolutionError); see degraded.jsonl
  ⚠ Graph has 734 disconnected components
  ⚠ Low cross-domain bridging: 1042/13688 edges (8%) cross domain boundaries (< 10%) — run `kin dream` to discover connections

Run `kin doctor --fix` to auto-repair fixable issues.

Copy link
Copy Markdown
Collaborator

Reviewed current head 1d45bc6ea63740ec4c1a464f4a3ed56b2d83705f. One correction before approval:

P2: preserve secondary-graph mismatch warnings in all MCP evidence paths. The new warning rendering in _render_context_sources does not reach _render_evidence_sources, which serves ask and context(level="evidence"). Those return lexical evidence without telling the caller that the secondary graph's semantic channel was skipped. The no-results context return also drops the warning.

Independently reproduced with temporary graphs and no provider access: seed the secondary index using one model, reopen it read-only with a different model, and query through an empty primary graph. Ordinary context includes the mismatch warning; evidence context and ask return the matching lexical node without it. A query with no lexical hits returns only No relevant knowledge found. This makes degraded recall look like a complete search, contrary to the explicit-warning contract.

Please propagate embedding_warning into evidence/answer and no-results responses, including warnings from graphs that contribute no hits, and add targeted regressions for these paths.

The preservation changes otherwise look sound in this review. Independently ran 145 focused tests plus 10 subtests successfully; git diff --check passed and exact-head hosted CI is green. No live stores or provider calls were exercised. Full local suite was not completed, so this is not an independent full-suite claim.

@blast-hardcheese

Copy link
Copy Markdown
Collaborator Author

Addressed @jmcentire’s finding in comment 6837812466 with commit 7fc301a62f2c19ab6f1e1630b839ac91872b8824.

Embedding mismatch warnings now survive MCP ask (including the drafted-answer prompt and returned evidence), context(level="evidence"), and no-results responses. Warnings are collected from every searched graph, including a secondary graph that supplies no hits, and remain visible under a tiny evidence budget. Lexical evidence remains available; no index/provider behavior changed.

Reproduced seven warning-loss subcases against the previous head using temporary primary/read-only secondary graphs and no provider access. Those regressions now pass. Focused coverage: 175 passed, 19 subtests passed. Full local suite: 4,959 passed, 3 skipped, 286 subtests passed on Python 3.13.14; git diff --check passed. Current-head hosted CI is pending. No live stores or providers were exercised.

@blast-hardcheese
blast-hardcheese merged commit 484ab3d into main Nov 13, 2026
2 checks passed
@blast-hardcheese
blast-hardcheese deleted the fix/preserve-embedding-index-and-report-coverage branch November 13, 2026 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants