Skip to content

fix(embeddings): reject malformed and empty provider vectors - #117200

Merged
steipete merged 1 commit into
mainfrom
codex/qa400-memory-embedding-vectors
Aug 1, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa400-memory-embedding-vectors

Conversation

@steipete

@steipete steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Reject empty embedding vectors in the existing shared direct-response producer instead of silently returning unusable query or document embeddings.
  • Reject non-array, nonnumeric, and nonfinite embedding vectors in the existing shared streamed-batch producer for both OpenAI and Voyage.
  • Preserve zero-valued coordinates, valid SDK responses, zero-input batches, existing provider errors, and all public contracts with zero net production lines.

Root causes

  1. readEmbeddingVector accepted empty arrays for nonempty requests, allowing direct embedding calls to return zero-dimensional vectors successfully.
  2. applyEmbeddingBatchOutputLine trusted .length without checking array shape or finite numeric coordinates, allowing both OpenAI and Voyage batch output to store malformed values as embedding vectors.

Verification

  • Real localhost baseline: direct calls accepted [[]]; full OpenAI and Voyage multipart-upload/batch/output pipelines each accepted ["poison"].
  • Real localhost candidate: direct query/document calls fail visibly; both provider pipelines reject malformed output; the official installed [email protected] SDK returns a valid [0.25], valid [[0]] is preserved, and zero-input batches still return [].
  • Blacksmith Testbox: pnpm tsgo:core, pnpm tsgo:test:packages, exact-four-path type-aware lint, 98/98 owner/OpenAI/Voyage/plugin tests across five shards, and the 11-request official-SDK localhost proof all passed.
  • Full gpt-5.6-sol high-reasoning structured autoreview through P3: zero findings, confidence 0.99.
  • Three fresh independent full-owner blind reviews: CLEAN (0.99, 0.99, 0.98).
  • Reviewed original/candidate blob guards, exact-four-path guards, unchanged package lockfile, and synthetic merge against 982add961804097f5a6b0b94255c5c855e8ad863 all passed.
  • Hosted run: https://github.com/openclaw/openclaw/actions/runs/30682347608

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Aug 1, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 31, 2026, 11:58 PM ET / August 1, 2026, 03:58 UTC.

ClawSweeper review

What this changes

This PR rejects empty, non-array, and non-finite embedding vectors returned by direct OpenAI-compatible requests and OpenAI/Voyage batch output before they reach the memory embedding engine.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

This is a focused repair for a source-proven current-main defect: direct responses accept empty vectors and batch output accepts malformed values based only on .length. The patch fixes those shared producer boundaries without changing provider APIs or configuration; no correctness finding was identified, but the protected maintainer label and still-running exact-head checks require normal maintainer handling rather than automated cleanup.

Priority: P2
Reviewed head: 18cfe2eb57dcda9217f9e3d948facf26642f5c64

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused shared-boundary repair with credible real behavior evidence, targeted regressions, and no identified correctness or security defect.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The PR body provides a concrete localhost before/after exercise across the changed direct and provider-batch paths, with valid-vector and zero-input controls; any retained proof artifact should remain redacted.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The PR body provides a concrete localhost before/after exercise across the changed direct and provider-batch paths, with valid-vector and zero-input controls; any retained proof artifact should remain redacted.
Evidence reviewed 6 items Current-main direct-response gap: Current main validates array shape and finite coordinates but permits an empty array, allowing a nonempty direct request to resolve with a zero-dimensional vector.
Current-main batch-output gap: Current main checks only embedding.length before storing the first batch response vector, so malformed non-array or non-finite values can enter the custom-ID result map.
Shared owner-boundary coverage: The direct helper is used by the shared memory embedding engine and both OpenAI and Voyage providers; the batch helper is called by both provider batch implementations, so the proposed checks sit at the common producer boundary.
Findings None None.
Security None None.

How this fits together

OpenClaw’s memory host obtains vectors from direct OpenAI-compatible embedding endpoints and from asynchronous provider batch files. The shared parsers validate those responses before the memory engine associates vectors with requests and uses them for indexing or retrieval.

flowchart LR
  A[Embedding request] --> B[Direct provider response]
  A --> C[OpenAI or Voyage batch output]
  B --> D[Direct vector validation]
  C --> E[Batch vector validation]
  D --> F[Memory embedding engine]
  E --> F
  D --> G[Visible embedding error]
  E --> G
Loading

Before merge

  • Complete next step (P2) - This maintainer-labeled PR has no mechanical review finding; complete the normal exact-head CI and maintainer merge review rather than routing an automated repair.
Agent review details

Security

None.

PR surface

Source 0, Tests +66. Total +66 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 3 3 0
Tests 2 66 0 +66
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 69 3 +66

Review metrics

None.

Stored data model

Persistent data-model change detected: vector/embedding metadata: packages/memory-host-sdk/src/host/batch-output.test.ts, vector/embedding metadata: packages/memory-host-sdk/src/host/batch-output.ts, vector/embedding metadata: packages/memory-host-sdk/src/host/embeddings-remote-fetch.test.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Merge the shared validation repair after the exact head completes required checks, preserving the regressions that distinguish invalid vectors from valid zero-valued coordinates and an intentionally empty input batch.

Do we have a high-confidence way to reproduce the issue?

Yes. Current main plainly permits empty direct arrays and stores batch values after only a .length check; the branch adds focused regression coverage and reports a real localhost before/after exercise.

Is this the best way to solve the issue?

Yes. Validating at the existing shared direct-response and batch-output producers is the narrowest maintainable fix, protecting both OpenAI and Voyage without provider-specific fallback behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 9dfbf6a8a06c.

Labels

Label changes:

  • add P2: Malformed provider vectors can corrupt or invalidate memory embedding work, but the repair is bounded to common response validation and no active release-blocking failure is evidenced.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides a concrete localhost before/after exercise across the changed direct and provider-batch paths, with valid-vector and zero-input controls; any retained proof artifact should remain redacted.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The PR body provides a concrete localhost before/after exercise across the changed direct and provider-batch paths, with valid-vector and zero-input controls; any retained proof artifact should remain redacted.

Label justifications:

  • P2: Malformed provider vectors can corrupt or invalidate memory embedding work, but the repair is bounded to common response validation and no active release-blocking failure is evidenced.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The PR body provides a concrete localhost before/after exercise across the changed direct and provider-batch paths, with valid-vector and zero-input controls; any retained proof artifact should remain redacted.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides a concrete localhost before/after exercise across the changed direct and provider-batch paths, with valid-vector and zero-input controls; any retained proof artifact should remain redacted.

Evidence

What I checked:

  • Current-main direct-response gap: Current main validates array shape and finite coordinates but permits an empty array, allowing a nonempty direct request to resolve with a zero-dimensional vector. (packages/memory-host-sdk/src/host/embeddings-remote-fetch.ts:20, 9dfbf6a8a06c)
  • Current-main batch-output gap: Current main checks only embedding.length before storing the first batch response vector, so malformed non-array or non-finite values can enter the custom-ID result map. (packages/memory-host-sdk/src/host/batch-output.ts:174, 9dfbf6a8a06c)
  • Shared owner-boundary coverage: The direct helper is used by the shared memory embedding engine and both OpenAI and Voyage providers; the batch helper is called by both provider batch implementations, so the proposed checks sit at the common producer boundary. (packages/memory-host-sdk/src/host/embeddings-remote-fetch.ts:39, 9dfbf6a8a06c)
  • Patch and regression coverage: The proposed commit adds finite-array validation for batch output and rejects empty direct vectors, with focused tests for malformed values, valid zero coordinates, and empty submitted batches. (packages/memory-host-sdk/src/host/batch-output.ts:177, 18cfe2eb57dc)
  • Feature provenance: Blame attributes the current validation lines to the recent shared-memory-host update by Peter Steinberger; the PR continues that owner boundary rather than adding provider-local duplicate logic. (packages/memory-host-sdk/src/host/batch-output.ts:174, f455eb76d85d)
  • Real-behavior and CI evidence: The PR body reports a localhost before/after exercise of direct, OpenAI batch, and Voyage batch paths, including valid [0.25], [[0]], and empty-input controls. The supplied PR state also shows successful real-behavior-proof, dependency, guard, lint, type, and security checks; remaining larger jobs were in progress. (18cfe2eb57dc)

Likely related people:

  • Peter Steinberger: Current-main blame for both shared validation boundaries and the proposed focused repair commit point to this memory-host area. (role: recent area contributor; confidence: high; commits: f455eb76d85d, 18cfe2eb57dc; files: packages/memory-host-sdk/src/host/embeddings-remote-fetch.ts, packages/memory-host-sdk/src/host/batch-output.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 618f329 into main Aug 1, 2026
130 of 137 checks passed
@steipete
steipete deleted the codex/qa400-memory-embedding-vectors branch August 1, 2026 04:38
@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant