Skip to content

fix: doc list honors --namespace on CLI, HTTP, and MCP (#1268) - #1269

Merged
ajianaz merged 2 commits into
developfrom
fix/doc-list-namespace-1268
Sep 17, 2026
Merged

ajianaz merged 2 commits into
developfrom
fix/doc-list-namespace-1268

Conversation

@ajianaz

@ajianaz ajianaz commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

What

  • doc list now honors the namespace on all three surfaces:
    • CLI: new --namespace flag on doc list (+ falls back to the existing global --namespace flag); doc export stays global
    • HTTP: DocListParams gains namespace (serde default, back-compat) — matches what main.rs help text already advertised
    • MCP: uteke_doc_list accepts a namespace argument
  • Core: Store::list_documents_ns(namespace, limit) with exact-match SQL filter; list_documents remains the legacy global wrapper; Uteke::doc_list / doc_list_roots take Option<&str> namespace (roots filtered in Rust — no (namespace, parent_id) index; the global view short-circuits the IS NULL OR predicate in SQL)
  • Regression test: scoped views, missing namespace, global view, NULL-namespace visibility (NULL docs only visible globally, consistent with memory listing)

Closes #1268

Why

doc list returned byte-identical output regardless of the namespace value on every surface: the CLI variant had no namespace field at all (the global flag was parsed but never used by the dispatcher), the HTTP struct lacked the field despite being advertised, and the MCP tool had no such argument. Per-namespace document inventory was impossible, and NULL-namespace docs leaked into every view — the same silent-ignore failure class fixed for v2 payloads in #1254.

Testing

  • cargo check + cargo clippy --all-targets + cargo fmt --check green on all 4 touched crates
  • cargo test --workspace: 691 passed, 0 failed (3 consecutive runs, incl. the new test_list_documents_namespace_scoped)
  • E2E against a backup-API snapshot of the PROD store (live store untouched): global = 20 docs (back-compat), --namespace default = 12, --namespace hermes = 2, md5 of outputs distinct per namespace
  • Pre-commit cora review: passed

The documents List surface silently ignored the namespace on every
surface: the CLI variant had no namespace field at all (the global
--namespace flag was parsed but never used by the dispatcher), the
HTTP DocListParams struct lacked the field despite the main.rs help
text advertising it, and the MCP tool had no namespace argument.
All three returned byte-identical output regardless of the requested
namespace, making per-namespace document inventory impossible.

Changes:
- core: add Store::list_documents_ns(namespace, limit) with an exact
  namespace match in SQL; list_documents stays as the legacy global
  wrapper; doc_list/doc_list_roots now take Option<&str> namespace
- cli: doc list gains --namespace, falling back to the global
  --namespace flag; doc export stays global (None)
- server: DocListParams.namespace (serde default) wired to the core
  call - matches the already-documented help text
- mcp: uteke_doc_list accepts namespace
- regression test: scoped/global/NULL-namespace visibility

Verified: cargo check/test/clippy/fmt green (workspace 691 tests);
E2E against a backup-API snapshot - global 20 docs, default 12,
hermes 2, distinct outputs per namespace.
Comment thread crates/uteke-core/src/lib.rs Outdated
namespace: Option<&str>,
limit: usize,
) -> Result<Vec<DocumentSummary>, Error> {
let roots = self.store.list_root_documents(limit)?;
@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

doc_list_roots fetched the N most-recent global roots and filtered by
namespace afterwards, so a scoped view could return short or empty
results when namespace matches fell outside the global top-N. Move the
filter into list_root_documents_ns SQL (parent_id IS NULL AND
(namespace = ?1 OR ?1 IS NULL)) applied before LIMIT - same semantics
as list_documents_ns.
@ajianaz
ajianaz merged commit e9f9fa5 into develop Sep 17, 2026
15 checks passed
@ajianaz
ajianaz deleted the fix/doc-list-namespace-1268 branch September 17, 2026 11:33
ajianaz added a commit that referenced this pull request Sep 17, 2026
…1270) (#1271)

* fix: unified recall scopes docs to namespace, reports honest scores (#1270)

recall_unified_all (the default CLI recall path) leaked documents
across namespaces and reported rank-derived scores that outranked
every memory:

- doc_search was called without a namespace (its ns param was _ns),
  so documents from any namespace - including NULL-namespace rows -
  appeared in every scoped recall
- doc scores were (k+1)/(k+1+rank): rank-0 reported 1.000 for every
  query, a pure rank function that beat all memory fusion scores
  (~0.16-0.19), flooding short-query results with the same doc set
- min_score was applied inside recall_hybrid against pre-boost
  rank-based scores (#1223), where it filters nothing meaningful

Changes:
- new Uteke::doc_search_in(query, limit, mode, namespace) retains
  only exact-namespace documents; NULL-namespace docs are global-
  view-only, matching the #1269 doc-list semantics
- unified doc arm keeps hybrid mode (index rebuilds evict chunk:
  vectors per #1110 - semantic-only would hide docs on affected
  stores) but reports the raw hybrid RRF sum (~0.016-0.033), same
  rank-based family as memory fusion base scores, never a fake 1.0
- memory arm called with min_score 0.0; the caller's threshold is
  applied post-merge on reported scores so --min/--strict work
- unified document results now carry their namespace

Verified: fmt/clippy clean; workspace 691 tests pass; E2E on a
PROD-snapshot store - short queries return only in-namespace
memories with honest scores, and 'memory lifecycle' surfaces the
ns=default chapter-6 document (0.016) instead of a cross-namespace
1.0 artifact.

* fix: over-fetch before namespace filter in doc_search_in (cora alert)

doc_search_in fetched the global top-limit results and only then
retained the requested namespace, so scoped searches could silently
return fewer results than exist when matching docs ranked below the
global top-N. Fetch 4x when scoping (mirrors the entity/category
post-filter heuristic on the memory path) and truncate to limit
after the retain.

* docs: correct stale comments on unified doc scoring (cora alert)

The score comment still said 'real cosine from the semantic doc arm'
from an earlier iteration of this change - it is the raw hybrid RRF
sum, and the min_score filter comment claimed both scales were honest
similarities. Spell out the actual caveat instead: both scales are
rank-based with different magnitudes (memory fusion ~0.2 max vs doc
hybrid ~0.033 max), so thresholds above ~0.033 filter all documents;
use --type memory + a vector strategy when cosine-style thresholding
is needed.
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.

bug: doc list ignores --namespace — identical output for every namespace value

2 participants