openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

Feat/2358 clear reembed skipped

Open MrMrVlad opened this issue 6 months ago β€’ 5 comments

Summary

Adds clear_chunk_reembed_skipped, clear_summary_reembed_skipped, and clear_reembed_skipped_for_signature (https://github.com/tinyhumansai/openhuman/issues/2358). Input validation on mark/clear paths; library-only (no new RPC). Depends on https://github.com/tinyhumansai/openhuman/pull/2349. Closes #2358

Local verification (2026-05-21)

cargo test reembed_skip reembed_backfill_tombstones --lib β€” 5 passed bash scripts/test-rust-with-mock.sh --lib reembed_skip β€” passed Lifetime fix for Rust 1.93 (validate_reembed_skip_key<'a>) Upstream

Open against tinyhumansai/openhuman:main:

https://github.com/tinyhumansai/openhuman/compare/main...MrMrVlad:feat/2358-clear-reembed-skipped

Summary by CodeRabbit

  • Bug Fixes

    • Fixed infinite reprocessing loops for failed embeddings by implementing terminal failure tracking.
    • Improved database locking behavior to prevent contention during document ingestion.
  • Chores

    • Enhanced Windows development environment setup for improved PATH handling.
    • Updated data storage schema to support failure tracking and recovery management.

Review Change Stack

MrMrVlad avatar May 21 '26 12:05 MrMrVlad

πŸ“ Walkthrough

Walkthrough

This PR adds a persistent tombstone system to prevent infinite re-embed backfill retries on rows with terminal failures, migrates RPC pending/processed accounting to the sidecar embedding table, fixes SQLite ingest transaction locking, and improves Windows dev-server pnpm discovery.

Changes

Re-embed backfill runaway-loop fix with terminal failure tombstones

Layer / File(s) Summary
Tombstone schema and store APIs
src/openhuman/memory/tree/store.rs, src/openhuman/memory/tree/tree_source/store.rs
Two SQLite schema tables mem_tree_chunk_reembed_skipped and mem_tree_summary_reembed_skipped record terminal failures keyed by (id, model_signature) with reason and skipped_at_ms. Public APIs mark_chunk_reembed_skipped, clear_chunk_reembed_skipped, clear_reembed_skipped_for_signature, mark_summary_reembed_skipped, and clear_summary_reembed_skipped manage tombstone lifecycle. Input validator validate_reembed_skip_key enforces non-empty, max-length, and NUL-byte rejection. Migration probe excludes tombstoned rows from uncovered-work computation.
Job handler terminal failure marking and worklist exclusion
src/openhuman/memory/tree/jobs/handlers/mod.rs
handle_reembed_backfill marks chunks/summaries as terminally skipped (missing body, embed dimension mismatch, embed errors) and calls mark_*_reembed_skipped with failure reason. Chunk and summary worklist SQL adds NOT EXISTS clauses against respective tombstone tables to exclude already-failed rows from future selection.
Coverage probe exclusion of tombstoned rows
src/openhuman/memory/tree/jobs/mod.rs
ensure_reembed_backfill coverage-check SQL treats *_reembed_skipped sentinels as already-processed, excluding them from uncovered computation for both chunks and summaries to prevent repeated backfill re-enqueueing.
Tombstone lifecycle tests
src/openhuman/memory/tree/store_tests.rs, src/openhuman/memory/tree/jobs/handlers/mod.rs
Unit tests verify idempotent clear operations, bulk clear-by-signature with correct deletion counts, key validation, orphaned chunk tombstoning flow, and tombstone clearing that re-includes rows in uncovered-work probe.

Supporting infrastructure fixes and migrations

Layer / File(s) Summary
SQLite ingest transaction locking fix
src/openhuman/memory/tree/ingest.rs
Switches persist transaction from default unchecked_transaction() to explicit TransactionBehavior::Immediate to acquire write lock immediately at BEGIN, preventing fast-fail SQLITE_BUSY during contention and ensuring document-level ingest gates occur within serialized writer semantics.
RPC migration to sidecar embedding queries
src/openhuman/memory/sync_status/rpc.rs
Refactors openhuman.memory_sync_status_list RPC to compute embedded/processed/pending using mem_tree_chunk_embeddings sidecar table via EXISTS instead of legacy mem_tree_chunks.embedding inline column. Extracts query_sync_statuses(conn, now_ms) helper for testability and updates module docs with sidecar semantics.
Windows dev-server PATH discovery and de-duplication
scripts/run-dev-win.sh
Precomputes PNPM_DIR from resolved PNPM_EXE, conditionally prepends to PATH (avoiding degenerate .), then de-duplicates colon-separated entries keeping only first occurrence to prevent environment-block truncation in cmd /S /C child processes.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • tinyhumansai/openhuman#2349: Introduced the re-embed backfill pipeline, tombstone tables, and sidecar embedding cutover; this PR adds the terminal-failure marking system and bulk-clear helpers to prevent runaway loops (#1574 Β§6).
  • tinyhumansai/openhuman#2153: Added the ReembedBackfill job and memory_backfill_status frontend wiring; this PR extends the job handler to persistently mark terminal failures and updates the coverage probe to avoid infinite retries.
  • tinyhumansai/openhuman#2010: Introduced per-model mem_tree_chunk_embeddings sidecar tables and signature-scoped helpers; this PR queries those tables in RPC logic and adds schema dependencies for tombstone management.

Suggested labels

feature, memory, working

Suggested reviewers

  • M3gA-Mind
  • graycyrus
  • senamakel

Poem

🐰 With tombstones now marking the failures so true,
The backfill won't loop on the stuck work anew.
Each sidecar embedding now tells the right tale,
And when Windows pnpm is lost on the trail,
Our PATH finds the way, deduped and set free! πŸŽ‰

πŸš₯ Pre-merge checks | βœ… 5
βœ… Passed checks (5 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check βœ… Passed The title 'Feat/2358 clear reembed skipped' directly references issue #2358 and accurately summarizes the main feature addition: clearing reembed-skipped tombstones.
Linked Issues check βœ… Passed The PR implements all core requirements from #2358: clear_chunk_reembed_skipped and clear_summary_reembed_skipped helpers [#2358], bulk clear_reembed_skipped_for_signature function [#2358], input validation [#2358], and comprehensive unit tests [#2358].
Out of Scope Changes check βœ… Passed All changes are directly aligned with #2358 scope: helper functions, validation, tests, and schema updates for tombstone management. Admin RPC exposure is explicitly noted as optional/out-of-scope in the issue, which is not included in this PR.
Docstring Coverage βœ… Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

[!WARNING]

Review ran into problems

πŸ”₯ Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar May 21 '26 12:05 coderabbitai[bot]

@YellowSnnowmann this PR has merge conflicts with main β€” please rebase/resolve before review.

M3gA-Mind avatar May 21 '26 17:05 M3gA-Mind

@MrMrVlad this PR has merge conflicts with main β€” please rebase/resolve before review.

M3gA-Mind avatar May 21 '26 17:05 M3gA-Mind

Rebased onto latest main and pushed review follow-ups: shared has_uncovered_reembed_work, warn on tombstone write failures, debug logging, summary tombstones in bulk-clear test. Local: cargo test reembed_skip --lib (4 passed). sync_status/rpc.rs unchanged β€” window-scoped pending already on main.

MrMrVlad avatar May 22 '26 09:05 MrMrVlad

@MrMrVlad this PR has merge conflicts with main β€” please rebase/resolve before review.

M3gA-Mind avatar May 22 '26 12:05 M3gA-Mind