Skip to content

fix: strip embedding fields from search responses#60

Merged
rluisr merged 3 commits intomainfrom
fix/exclude-embedding-from-search-responses
Apr 17, 2026
Merged

fix: strip embedding fields from search responses#60
rluisr merged 3 commits intomainfrom
fix/exclude-embedding-from-search-responses

Conversation

@rluisr
Copy link
Copy Markdown
Contributor

@rluisr rluisr commented Apr 17, 2026

Pull Request

Summary

Prevent OpenSearch and MCP responses from exposing embedding vectors in returned source metadata.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Refactoring (no functional changes)

Changes Made

  • Excluded embedding from BM25 and vector search _source payloads.
  • Excluded embedding from term query _source payloads.
  • Added MCP-side sanitization so include_metadata=true never returns embedding.

Motivation and Context

Search responses do not need to expose raw vector payloads, and returning them increases response size while leaking internal indexing details.

How Has This Been Tested?

  • Unit tests (go test ./...)
  • Integration tests
  • Manual testing with local setup
  • Tested with AWS services (S3 Vectors, OpenSearch, Bedrock)

Test Configuration

  • Go version: go1.26.0 darwin/arm64
  • AWS Region: N/A
  • OpenSearch version (if applicable): N/A

Executed:

  • go test ./internal/pkg/opensearch -timeout 120s
  • go test ./internal/mcpserver -timeout 120s
  • go test ./tests/unit/... -timeout 120s

Impact Analysis

Components Affected

  • CLI commands (cmd/)
  • Vectorization (internal/vectorizer/)
  • OpenSearch integration (internal/opensearch/)
  • S3 Vector operations (internal/s3vector/)
  • Slack bot (internal/slackbot/)
  • Bedrock embedding (internal/embedding/)
  • Configuration (internal/config/)

Additional affected slice:

  • MCP server (internal/mcpserver/)

AWS Resources Impact

  • No AWS resource changes
  • S3 bucket operations
  • OpenSearch index structure
  • IAM permissions required
  • Bedrock model usage

Breaking Changes

  • None
  • Yes (describe below)

Migration Guide

Not required.

Dependencies

  • No new dependencies
  • Dependencies added/updated (list below)

Documentation

  • README.md updated
  • CLAUDE.md updated
  • Inline code comments added/updated
  • API documentation updated
  • Configuration examples updated

Checklist

  • My code follows the project's style guidelines (go fmt ./... and go vet ./...)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published
  • I have checked my code for any security issues or exposed secrets
  • I have tested with the minimum supported Go version (1.23)
  • I have run go mod tidy to clean up dependencies

Performance Considerations

  • No performance impact
  • Performance improved (describe metrics)
  • Performance degraded but acceptable (explain trade-offs)

Additional Notes

This change adds exclusion at both query-construction time and MCP response-construction time so the protection holds even if one layer changes later.

Screenshots/Logs

N/A


プルリクエスト(日本語版)

概要

OpenSearch および MCP のレスポンスに embedding ベクトルが含まれないようにし、不要な内部データの露出を防ぎます。

変更の種類

  • バグ修正(既存機能を破壊しない問題の修正)
  • 新機能(既存機能を破壊しない機能の追加)
  • 破壊的変更(既存機能の動作に影響を与える修正や機能)
  • ドキュメント更新
  • パフォーマンス改善
  • リファクタリング(機能的変更なし)

実装された変更

  • BM25 / vector 検索の _source から embedding を除外しました。
  • term query の _source から embedding を除外しました。
  • include_metadata=true の MCP レスポンスでも embedding を除去する防御を追加しました。

動機と背景

検索レスポンスで raw ベクトルを返す必要はなく、レスポンス肥大化と内部実装の露出につながるためです。

テスト方法

  • ユニットテスト(go test ./...
  • 統合テスト
  • ローカル環境での手動テスト
  • AWSサービス(S3 Vectors、OpenSearch、Bedrock)でのテスト

テスト設定

  • Goバージョン: go1.26.0 darwin/arm64
  • AWSリージョン: N/A
  • OpenSearchバージョン(該当する場合): N/A

実行コマンド:

  • go test ./internal/pkg/opensearch -timeout 120s
  • go test ./internal/mcpserver -timeout 120s
  • go test ./tests/unit/... -timeout 120s

影響分析

影響を受けるコンポーネント

  • CLIコマンド(cmd/
  • ベクトル化(internal/vectorizer/
  • OpenSearch統合(internal/opensearch/
  • S3 Vector操作(internal/s3vector/
  • Slack bot(internal/slackbot/
  • Bedrock埋め込み(internal/embedding/
  • 設定(internal/config/

追加影響:

  • MCP server(internal/mcpserver/

AWSリソースへの影響

  • AWSリソースの変更なし
  • S3バケット操作
  • OpenSearchインデックス構造
  • IAM権限が必要
  • Bedrockモデルの使用

破壊的変更

  • なし
  • あり(以下に記述)

移行ガイド

不要です。

依存関係

  • 新しい依存関係なし
  • 依存関係の追加/更新(以下にリスト)

ドキュメント

  • README.md更新
  • CLAUDE.md更新
  • インラインコードコメントの追加/更新
  • APIドキュメント更新
  • 設定例の更新

チェックリスト

  • コードがプロジェクトのスタイルガイドラインに従っている(go fmt ./...go vet ./...
  • 自分のコードをセルフレビューした
  • 理解が困難な領域にコメントを追加した
  • ドキュメントに対応する変更を行った
  • 変更によって新しい警告やエラーが生成されない
  • 修正が効果的であることまたは機能が動作することを証明するテストを追加した
  • 新しいテストと既存のユニットテストがローカルで成功する
  • 依存する変更がマージされ公開されている
  • セキュリティ問題や露出した秘密情報がないかコードをチェックした
  • サポートされる最小Goバージョン(1.23)でテストした
  • go mod tidyを実行して依存関係をクリーンアップした

パフォーマンスに関する考慮事項

  • パフォーマンスへの影響なし
  • パフォーマンス改善(メトリクスを記述)
  • パフォーマンス低下だが許容範囲(トレードオフを説明)

追加ノート

クエリ生成時と MCP レスポンス生成時の両方で除外しているため、どちらか一方の層が今後変わっても防御が残る構成です。

スクリーンショット/ログ

N/A

rluisr and others added 3 commits April 17, 2026 19:55
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@rluisr rluisr self-assigned this Apr 17, 2026
@rluisr rluisr merged commit 2504e51 into main Apr 17, 2026
15 checks passed
@rluisr rluisr deleted the fix/exclude-embedding-from-search-responses branch April 17, 2026 11:01
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