Skip to content

release: v0.4.0 — sync develop to main - #447

Merged
ajianaz merged 9 commits into
mainfrom
release/v0.4.0-main
Jun 22, 2026
Merged

ajianaz merged 9 commits into
mainfrom
release/v0.4.0-main

Conversation

@ajianaz

@ajianaz ajianaz commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

v0.4.0: hierarchical documents + doc_search + document API + deadlock fix + SemVer correction.

ajianaz and others added 9 commits June 22, 2026 06:52
#434)

Release checklist now explicitly lists ALL docs that must be updated
before tagging: README, CHANGELOG, cli-reference, configuration,
architecture, roadmap, hermes integration. No exceptions.

Also updated version to 0.3.1 and test count to 295.
* fix: harden schema migrations for partially-migrated databases

Three fixes for edge cases encountered during v0.2.0 → v0.3.1 upgrade:

1. migrate_v9_to_v10: add column_exists guards for source/source_type
   - Fresh v0.3.0 DBs already have these columns via SCHEMA constant
   - Running migration on such DBs crashed with 'duplicate column name'

2. migrate_v7_to_v8: make idx_memories_slug best-effort
   - Separated from memory_edges batch to prevent fatal error
   - Log at debug level if index creation fails (defensive)

3. SCHEMA source_type default: 'user' → 'unknown'
   - Consistent with migrate_v9_to_v10 default
   - Fresh DBs and migrated DBs now use the same source_type default

* refactor: keep slug index as hard error, separate from batch

CodeCora flagged that making idx_memories_slug best-effort could leave
databases without the index while reporting migration success.

Revert to hard error but separate from the memory_edges batch for
clearer error messages (separate error context: 'slug index' vs 'memory_edges').

The original production bug was in SCHEMA_INDEXES ordering (fixed in
develop), not in this migration itself.

* revert: restore source_type DEFAULT 'user' in SCHEMA

CodeCora flagged that changing the default affects existing databases
inconsistently — SQLite doesn't support ALTER DEFAULT, so old DBs
keep 'user' while new DBs would get 'unknown'.

The intentional difference is documented:
- SCHEMA DEFAULT 'user' — fresh DBs, code always sets source_type explicitly
- Migration DEFAULT 'unknown' — legacy rows without provenance info

This is the original behavior, now with column_exists guards as the
real fix for partially-migrated databases.

---------

Co-authored-by: ajianaz <[email protected]>
- Bump version 0.3.1 → 0.3.2 across all crates
- Add CHANGELOG entry for #435 (migration hardening) and #434 (docs checklist)
- Update AGENT.md version + schema version (v7 → v11)
- Update README badge + CLI reference version

Co-authored-by: ajianaz <[email protected]>
…438 #440) (#439)

* feat: hierarchical documents with depth-10 tree engine (#438)

- Add parent_id, path (materialized UUID), depth, sort_order, has_children
  columns to documents table
- Schema migration v11→v12 with column_exists guards for idempotency
- Add column_exists_in() helper for table-scoped column checks
- Add Error::validation() convenience constructor
- Store methods: list_root_documents, list_document_children,
  list_descendants, get_breadcrumbs, move_document, count_descendants,
  cascade_delete_safe
- lib.rs API: doc_upsert_with_parent (max depth 10), doc_list_roots,
  doc_list_children, doc_list_descendants, doc_breadcrumbs, doc_move
- doc_delete now returns (bool, usize) for cascade reporting
- CLI: create --parent, list --tree, children, move, breadcrumbs,
  descendants subcommands
- Tree display with indent-based hierarchy in CLI output

* fix: resolve borrow checker error in list_descendants

stmt was being dropped inside if/else branches while MappedRows
iterator still held a reference. Collect results inside each branch.

* style: apply rustfmt formatting

* fix: path prefix double-slash bug + bump version assertions to 12

- list_descendants, count_descendants, move_document: path already ends
  with '/', so format!('/{}/') created '//' which broke LIKE queries
- Updated 3 migration test assertions from schema v11 to v12
  (edges.rs, timeline.rs, crud.rs)

* fix: LIKE queries need '%' wildcard for prefix scan

SQL LIKE without % is exact match — children paths like /root/eng/
never matched LIKE '/root/'. Added % suffix to all path prefix
queries in list_descendants, count_descendants, move_document.
Also exclude self via 'AND id != ?' since % matches empty string.

* fix: split old_prefix into exact + LIKE for REPLACE vs WHERE

REPLACE(path, '/root/%', ...) treated '%' as literal — fixed by using
old_path_exact for REPLACE target and old_prefix (with %) for WHERE.

* feat: add doc_search with hybrid semantic+FTS5 and usearch chunk indexing

- FTS5 virtual table for documents (title/slug keyword search)
- Sync triggers keep FTS5 in sync with documents table
- doc_search() supports 3 modes: semantic, fts, hybrid (RRF fusion)
- Chunk embeddings now indexed in usearch with 'chunk:' prefix
- Old chunks cleaned from usearch on document update/delete
- CLI: uteke doc search <query> --mode <semantic|fts|hybrid>
- delete_chunks_for_documents() for batch chunk cleanup
- get_chunks_by_ids() for search result enrichment
- DocumentSearchResult struct with score, chunk heading/snippet

* style: fix clippy and rustfmt issues in doc_search implementation

- Prefix unused variables with underscore (_pid, _ns, _chunk_key, _chunk_id)
- Replace &[doc_id.clone()] with std::slice::from_ref(&doc_id)
- Reformat long lines per rustfmt (sort_by, map closures, method chains)

* fix: resolve clippy borrowed expression and rustfmt match pattern

- Remove unnecessary & on format! in Error::validation (line 943)
- Collapse DocCommands::Search match pattern to single line per rustfmt

* fix: address CodeCora findings — path predicates, namespace, ordering

Bug fixes:
- move_document: use old_prefix (full path) for descendant LIKE instead of cur_id
- delete_document: fetch doc path for cascade delete instead of hardcoded /{id}/%
- doc_delete: accept namespace param instead of hardcoding DEFAULT_NAMESPACE
- move_document: recompute has_children on old parent after moving child
- get_chunks_by_ids_ordered: preserve input order for usearch score alignment

False positives documented:
- sec-sql-concat: table names are internal constants, never user input
- LIKE without %: format! explicitly adds % (lines 441, 545, 597)
- max_depth absolute: design choice, consistent with stored depth values

* fix: use correct type comparison for old_parent in move_document

* fix: use stable as_ref/as_deref for parent comparison

* fix: remove redundant as_deref on Option<&str>

* fix: remove unnecessary usize cast in move_document

---------

Co-authored-by: ajianaz <[email protected]>
* feat: add document API endpoints to uteke-serve

Endpoints:
- POST /doc/create — create/upsert document with optional parent
- POST /doc/get — get document by id or slug
- POST /doc/list — list documents (roots_only, parent filter)
- POST /doc/search — hybrid/semantic/fts document search
- POST /doc/move — move document to new parent
- DELETE /doc/delete — delete document with cascade

All endpoints accept namespace parameter. Added to startup banner.

* docs: update cli-reference and AGENT.md for v0.4.0 doc API

- cli-reference.md: add doc search, move, --tree, --roots-only, --parent flags
- cli-reference.md: add doc HTTP endpoints to API table
- AGENT.md: add Function ↔ API ↔ CLI parity table for v0.4.0
- Document all 6 doc functions with corresponding CLI + API endpoints
- Note breadcrumbs, descendants, export as CLI-only (intentional)

* fix: use correct parse_query_param function name in doc endpoints

* fix: remove unused DocDeleteParams struct

---------

Co-authored-by: ajianaz <[email protected]>
…res (#443)

Root cause: RwLock deadlock in remember_precomputed().

remember_precomputed() holds an RwLockWriteGuard on the vector index
(variable `index`). It then calls auto_link_cosine(), which tries to
acquire self.index.read() — a read lock on the SAME RwLock while the
write lock is still held. This deadlocks the thread permanently.

After 2-3 remember() calls, the server Mutex<Uteke> is held by the
deadlocked thread, making the entire server unresponsive (even
GET /health hangs).

Fix: explicitly `drop(index)` (the write guard) BEFORE calling
auto_link_cosine(). The index entry has already been inserted and
saved, so the write lock is no longer needed.

This also fixes the "no edges created" bug — auto_link_cosine was
never reaching the search/edge-creation code because it deadlocked
on the first read lock attempt.
Fix: server deadlock on POST /remember (#442).
RwLock deadlock in remember_precomputed() held the write lock when
auto_link_cosine() tried to acquire a read lock on the same RwLock.

Version bump 0.3.2 → 0.3.3.
v0.3.2 added hierarchical documents + doc_search + document API endpoints.
Those are NEW FEATURES (minor bump per SemVer), not patches.
v0.3.3 fixed the deadlock bug.

Correct version: v0.4.0 (minor bump from v0.3.x feature additions).
@ajianaz
ajianaz merged commit ece4142 into main Jun 22, 2026
1 check passed
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

❌ Blocked — critical issues found.

🔴 Error (1)

  • CHANGELOG.md:1 — The diff deletes the entire 0.4.0 section, including documented fixes for a server deadlock and document-tree/search changes, and leaves 0.3.2 as the newest visible release. If this version rollback is intentional, removing the release notes makes the published history inconsistent with the codebase and hides important upgrade/downgrade information for users.

Review powered by cora-cli · BYOK · MIT

@ajianaz
ajianaz deleted the release/v0.4.0-main branch July 9, 2026 14:28
ajianaz added a commit that referenced this pull request Aug 13, 2026
release: v0.4.0 — sync develop to main
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