Skip to content

feat(api): OpenAI-compatible POST /v1/embeddings - #133

Closed
seonghobae wants to merge 2 commits into
mainfrom
feat/v1-embeddings-sync
Closed

feat(api): OpenAI-compatible POST /v1/embeddings#133
seonghobae wants to merge 2 commits into
mainfrom
feat/v1-embeddings-sync

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Status: Draft — embedding/model provenance is not honest enough to merge

This PR exposes a useful buyer-facing endpoint shape, but the current implementation must not be marked Ready or merged.

Exact identity

  • protected base: main@6841b71935e0b7cb98fb52bcb4709cc5100c8d87
  • contributor head: e36d0b19e6e33eec2baf6da12e1090ed38d9512d
  • state: Draft
  • formal reviews: zero
  • inline review threads: zero

No predecessor, status-only, synthetic-merge, or local result transfers after this head changes.

Valid product requirement

Provide a provider-neutral OpenAI-compatible POST /v1/embeddings endpoint with bounded inputs, exact backend/model identity, usage and cost provenance, deterministic error semantics, and standalone plus modular operation.

Current root defect

The endpoint reuses LocalEmbeddingBatchBackend, whose protected-main implementation creates an 8-dimensional SHA-256-derived offline test vector. That helper explicitly states that it is not semantically meaningful and exists only to exercise the batch lifecycle without a provider call.

This PR nevertheless accepts an arbitrary requested model, echoes that model in the OpenAI response, and routes the document through the cost ledger. A caller can therefore receive a local heuristic vector and evidence that appears to attribute it to the requested provider/model even though that model did not execute. A deterministic vector is not equivalent to a real embedding model, and backend: local as a nonstandard extension does not repair the false standard-field provenance.

The branch also copies suppression-only SQL, dynamic-urllib, and unverified-TLS annotations instead of inheriting the accepted source-level security boundary from PR #96.

Required test-first repair

Before Ready, rebuild this endpoint on the exact protected security line and prove:

  1. a request is bound to a configured embedding backend and exact model identity before execution;
  2. unknown, disabled, capability-incompatible, or unbound models fail closed before producing a vector or ledger entry;
  3. local test embeddings use an explicit reserved model/backend identity and can never masquerade as an arbitrary requested provider model;
  4. standard response model, dimensions, encoding, usage, provider/backend evidence, and ledger attribution all describe the same executed operation;
  5. no heuristic, translated, cached, fallback, or reconstructed vector is labelled native or provider-produced;
  6. provider failure cannot silently fall back to the SHA helper under the same model id;
  7. float/base64 encoding, requested dimensions, finite values, response cardinality/order, bounded response size, and redacted failures are verified through the real HTTP path;
  8. package/API/architecture/threat-model/operability/CHANGELOG contracts distinguish mock/offline evidence from production model evidence; and
  9. exact-head 100% owned production statement/branch/public-docstring, security, fuzz, package, semantic review, zero-valid-finding, and qualifying independent-approval gates pass.

Do not close the underlying buyer requirement, but do not enable auto-merge or mark this branch Ready until one honest execution and provenance contract exists.

Gateway consumers (OpenAI SDKs, naruon callers) can embed without the batch
poll lifecycle. Uses the existing embeddings backend + cost ledger; local
backend completes in-process with deterministic vectors.
@seonghobae
seonghobae enabled auto-merge (squash) August 12, 2026 23:43
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@seonghobae, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 22 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1683da65-6372-4f63-947c-b15720207375

📥 Commits

Reviewing files that changed from the base of the PR and between 6841b71 and e36d0b1.

📒 Files selected for processing (8)
  • README.md
  • contextual_orchestrator/api_contract.py
  • contextual_orchestrator/cost_ledger.py
  • contextual_orchestrator/cost_router.py
  • contextual_orchestrator/orchestrator.py
  • contextual_orchestrator/server.py
  • docs/architecture.md
  • tests/test_openai_embeddings.py

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@seonghobae
seonghobae marked this pull request as draft August 13, 2026 13:33
auto-merge was automatically disabled August 13, 2026 13:33

Pull request was converted to draft

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

OpenCode cannot approve yet because required coverage evidence did not pass.

Review outcome

1. HIGH .github/workflows/opencode-review.yml:1 - Coverage evidence did not prove required test/docstring evidence

  • Problem: The required coverage-evidence job result was failure, so OpenCode cannot establish approval sufficiency for this head.

  • Root cause: Automated approval is only valid when the same-head coverage-evidence job proves supported repository test suites passed and configured docstring gates passed or were advisory, or reports not applicable because no supported source files or package manifests exist. Missing, failed, skipped, unavailable, or unsupported-tooling test evidence is a blocker.

  • Fix: Install or configure the repository test/docstring evidence tooling when source files or package manifests exist, rerun the current-head coverage-evidence job, and approve only after it reports success with required evidence or explicit no-source not-applicable evidence.

  • Regression test: Keep the approval branch checking needs.coverage-evidence.result == success before posting APPROVE, and publish REQUEST_CHANGES when coverage-evidence blocker states such as cancelled, skipped, failed, unsupported-tooling, or below-100 evidence are present.

  • Result: REQUEST_CHANGES

  • Reason: coverage-evidence result was failure, so required test/docstring evidence was not proven for current head e36d0b19e6e33eec2baf6da12e1090ed38d9512d.

  • Head SHA: e36d0b19e6e33eec2baf6da12e1090ed38d9512d

  • Workflow run: 31702411945

  • Workflow attempt: 1

Coverage evidence

Coverage evidence job did not run or did not publish coverage evidence.

Changed-File Evidence Map

flowchart LR
  PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
  Evidence --> S1["Changed file (6 files)"]
  S1 --> I1["repository behavior"]
  I1 --> R1["Review risk: Changed file (6 files)"]
  R1 --> V1["required checks"]
  Evidence --> S2["Docs: architecture.md"]
  S2 --> I2["operator or user guidance"]
  I2 --> R2["Review risk: Docs: architecture.md"]
  R2 --> V2["docs review"]
  Evidence --> S3["Test: test_openai_embeddings.py"]
  S3 --> I3["regression suite"]
  I3 --> R3["Review risk: Test: test_openai_embeddings.py"]
  R3 --> V3["targeted test run"]
Loading

@opencode-agent

Copy link
Copy Markdown
Contributor

OpenCode Review Overview

  • Head SHA: e36d0b19e6e33eec2baf6da12e1090ed38d9512d
  • Workflow run: 31702411945
  • Workflow attempt: 1
  • Gate result: REQUEST_CHANGES (approval step)

Pull request overview

OpenCode cannot approve yet because required coverage evidence did not pass.

Review outcome

1. HIGH .github/workflows/opencode-review.yml:1 - Coverage evidence did not prove required test/docstring evidence

  • Problem: The required coverage-evidence job result was failure, so OpenCode cannot establish approval sufficiency for this head.

  • Root cause: Automated approval is only valid when the same-head coverage-evidence job proves supported repository test suites passed and configured docstring gates passed or were advisory, or reports not applicable because no supported source files or package manifests exist. Missing, failed, skipped, unavailable, or unsupported-tooling test evidence is a blocker.

  • Fix: Install or configure the repository test/docstring evidence tooling when source files or package manifests exist, rerun the current-head coverage-evidence job, and approve only after it reports success with required evidence or explicit no-source not-applicable evidence.

  • Regression test: Keep the approval branch checking needs.coverage-evidence.result == success before posting APPROVE, and publish REQUEST_CHANGES when coverage-evidence blocker states such as cancelled, skipped, failed, unsupported-tooling, or below-100 evidence are present.

  • Result: REQUEST_CHANGES

  • Reason: coverage-evidence result was failure, so required test/docstring evidence was not proven for current head e36d0b19e6e33eec2baf6da12e1090ed38d9512d.

  • Head SHA: e36d0b19e6e33eec2baf6da12e1090ed38d9512d

  • Workflow run: 31702411945

  • Workflow attempt: 1

Coverage evidence

Coverage evidence job did not run or did not publish coverage evidence.

Changed-File Evidence Map

flowchart LR
  PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
  Evidence --> S1["Changed file (6 files)"]
  S1 --> I1["repository behavior"]
  I1 --> R1["Review risk: Changed file (6 files)"]
  R1 --> V1["required checks"]
  Evidence --> S2["Docs: architecture.md"]
  S2 --> I2["operator or user guidance"]
  I2 --> R2["Review risk: Docs: architecture.md"]
  R2 --> V2["docs review"]
  Evidence --> S3["Test: test_openai_embeddings.py"]
  S3 --> I3["regression suite"]
  I3 --> R3["Review risk: Test: test_openai_embeddings.py"]
  R3 --> V3["targeted test run"]
Loading

@seonghobae seonghobae closed this Aug 20, 2026
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