Skip to content

fix: derive context_type from URI in index_resource#1346

Merged
qin-ctx merged 1 commit intovolcengine:mainfrom
yc111233:fix/index-resource-context-type
Apr 10, 2026
Merged

fix: derive context_type from URI in index_resource#1346
qin-ctx merged 1 commit intovolcengine:mainfrom
yc111233:fix/index-resource-context-type

Conversation

@yc111233
Copy link
Copy Markdown
Contributor

@yc111233 yc111233 commented Apr 9, 2026

Summary

  • index_resource() always used the default context_type="resource" when calling vectorize_directory_meta() and vectorize_file(), even for memory directories (/memories/ URIs)
  • This caused all records created via /api/v1/content/reindex to be tagged as "resource" instead of "memory", breaking StatsAggregator (which filters Eq("context_type", "memory")) and hierarchical search scoping
  • Fix: use the existing get_context_type_for_uri() helper to derive the correct context_type from the URI

Root cause

vectorize_file and vectorize_directory_meta both default their context_type parameter to "resource". The SemanticProcessor._process_memory_directory() path correctly hardcodes context_type="memory", but index_resource() (used by the reindex API) did not — it relied on the default.

Test plan

  • Reindex a memory directory via /api/v1/content/reindex
  • Verify new records have context_type="memory" (not "resource")
  • Verify /api/v1/stats/memories correctly counts reindexed records
  • Verify search scoping returns results from reindexed memory directories

🤖 Generated with Claude Code

index_resource() always passed the default context_type="resource" to
vectorize_directory_meta() and vectorize_file(), even when indexing
memory directories (URIs containing /memories/).  This caused all
records created via the /api/v1/content/reindex endpoint to be tagged
as "resource" instead of "memory", breaking stats aggregation
(which filters on context_type="memory") and search scoping.

Use the existing get_context_type_for_uri() helper to derive the
correct context_type from the URI and pass it through to both
vectorize_directory_meta() and vectorize_file().

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🏅 Score: 95
🧪 No relevant tests
🔒 No security concerns identified
📝 TODO sections

🔀 No multiple PR themes
⚡ No major issues detected

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

PR Code Suggestions ✨

No code suggestions found for the PR.

@qin-ctx qin-ctx merged commit 077e20e into volcengine:main Apr 10, 2026
4 of 6 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in OpenViking project Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants