feat: add synchronous embeddings and KV-only secret bootstrap - #66
feat: add synchronous embeddings and KV-only secret bootstrap#66seonghobae wants to merge 11 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a synchronous OpenAI-compatible embeddings endpoint to contextual-orchestrator while tightening the secret-handling story so runtime/provider/auth secret values are bootstrapped via stdin into the KV and resolved by KV name (not argv/env). This aligns the gateway with downstream consumers that expect /v1/embeddings and enforces KV-only secret resolution at the CLI/server boundary.
Changes:
- Introduces
POST /v1/embeddingswith shared validation/limits and sync-wait behavior over the existing embeddings batch backend. - Extends embeddings plumbing to support optional
dimensions, deadline-aware backend calls, and reconciliation metadata for ambiguous submissions. - Removes runtime secret-value paths via argv/env and updates docs/tests/Docker defaults to stdin JSON bootstrap + KV-name flags.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_kv_credentials.py | Adds regression tests ensuring runtime secrets are not accepted via env/argv and stdin bootstrap resolves KV credentials correctly. |
| tests/test_batch_embeddings.py | Adds sync embeddings endpoint tests plus deadline/timeout/reconciliation coverage for embedding backends. |
| tests/test_api_contract.py | Asserts OpenAPI exposes /v1/embeddings with inference bearer auth and correct operationId. |
| README.md | Updates local run and credential bootstrap instructions to KV-name + stdin JSON flow; documents sync embeddings behavior. |
| examples/agents.openai.json | Refreshes the OpenAI example model configuration. |
| docs/rest_api_design.md | Documents the new /v1/embeddings endpoint behavior and error semantics. |
| docs/kv-credentials.md | Updates credential resolution/bootstrapping guidance to stdin-only value transport and KV-only runtime lookup. |
| Dockerfile | Changes container default startup to bootstrap credentials from stdin into KV before serving. |
| contextual_orchestrator/server.py | Adds /v1/embeddings handler, dimensions validation, and consistent error mapping for sync/batch embeddings. |
| contextual_orchestrator/cost_router.py | Implements sync embeddings orchestration via polling the batch backend, adds dimension limits, and strengthens result validation. |
| contextual_orchestrator/batch_routing.py | Makes embedding backends deadline-aware; adds dimensions to embedding requests; adds reconciliation support for pg-llm-batch submissions. |
| contextual_orchestrator/api_contract.py | Extends OpenAPI contract to include /v1/embeddings and dimensions for embeddings endpoints. |
| contextual_orchestrator/main.py | Removes runtime secret flags/env lookups; adds KV-name token flags and stdin bootstrap modes. |
| contextual_orchestrator/init.py | Exposes EmbeddingSubmissionTimeout in the public package exports. |
| CLAUDE.md | Updates developer commands/examples to use stdin bootstrap + KV-name tokens. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
contextual_orchestrator/main.py:71
register-credentialstill exposes--value-stdinbut the flag is not used (the command always reads from stdin). This makes the CLI misleading: callers can omit the flag and still hit stdin parsing errors, and the help implies the flag changes behavior.
parser.add_argument("--name", required=True, help="Credential name, e.g. OPENAI_API_KEY.")
parser.add_argument(
"--value-stdin",
action="store_true",
help="Read the secret value from stdin (the only supported secret transport).",
)
args = parser.parse_args(argv)
value = _read_stdin_credential()
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
contextual_orchestrator/cost_router.py:584
- The vector validation treats JSON booleans as valid embedding components because
boolis a subclass ofint(soTrue/Falsepass the(int, float)check). This can let invalid embeddings through and be cost-recorded as successful.
isinstance(component, (int, float)) and math.isfinite(float(component))
|
Consumer linkage: ContextualWisdomLab/noema#19 now requires this PR’s KV-backed inference-token contract for production reviews, verifies |
|
Warning Review limit reached
Next review available in: 6 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (18)
Comment |
There was a problem hiding this comment.
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
successwith required evidence or explicit no-source not-applicable evidence. -
Regression test: Keep the approval branch checking
needs.coverage-evidence.result == successbefore 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 heade7020795c6c5cbaac884dbcee3e0a37c409ab360. -
Head SHA:
e7020795c6c5cbaac884dbcee3e0a37c409ab360 -
Workflow run: 30868407263
-
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 (12 files)"]
S1 --> I1["repository behavior"]
I1 --> R1["Review risk: Changed file (12 files)"]
R1 --> V1["required checks"]
Evidence --> S2["Docs (2 files)"]
S2 --> I2["operator or user guidance"]
I2 --> R2["Review risk: Docs (2 files)"]
R2 --> V2["docs review"]
Evidence --> S3["Test (4 files)"]
S3 --> I3["regression suite"]
I3 --> R3["Review risk: Test (4 files)"]
R3 --> V3["targeted test run"]
OpenCode Review Overview
Pull request overviewOpenCode cannot approve yet because required coverage evidence did not pass. Review outcome1. HIGH .github/workflows/opencode-review.yml:1 - Coverage evidence did not prove required test/docstring evidence
Coverage evidenceCoverage evidence job did not run or did not publish coverage evidence. Changed-File Evidence Mapflowchart LR
PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
Evidence --> S1["Changed file (12 files)"]
S1 --> I1["repository behavior"]
I1 --> R1["Review risk: Changed file (12 files)"]
R1 --> V1["required checks"]
Evidence --> S2["Docs (2 files)"]
S2 --> I2["operator or user guidance"]
I2 --> R2["Review risk: Docs (2 files)"]
R2 --> V2["docs review"]
Evidence --> S3["Test (4 files)"]
S3 --> I3["regression suite"]
I3 --> R3["Review risk: Test (4 files)"]
R3 --> V3["targeted test run"]
|
|
Temporarily Draft to preserve stacked integration order. This feature touches |
Purpose
Add a standard synchronous OpenAI-compatible embeddings endpoint and make KV-backed stdin bootstrap the only accepted provider/API-auth secret-value entry path.
Product behavior
POST /v1/embeddingsshares the existing embeddings engine, validation, request limits, timeout behavior, model routing, and response contract with the batch API.bool-is-intrelationship.Exact-head verification
Current head:
e7020795c6c5cbaac884dbcee3e0a37c409ab360Integration order
This PR remains Draft because it changes
orchestrator.py,cost_ledger.py,batch_routing.py, package exports, and adjacent contracts also touched by the security and coverage stack. The required order is:main, preserve the reviewed synchronous-embeddings/KV behavior, and rerun exact-head tests, statement/branch coverage, docstrings, package build/install smoke tests, SAST, security, and independent review;No branch-protection, exact-head, or independent-review gate may be bypassed.