-
Notifications
You must be signed in to change notification settings - Fork 0
chore(opencode): migrate to released contextual-orchestrator (owner prerequisite) #881
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
5f8d748
8f3f163
acf1f37
e40172e
4e07356
13306c6
398e807
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # Local OpenCode NVIDIA NIM contract | ||
|
|
||
| Next action: keep root `opencode.jsonc` on NVIDIA NIM only. Bind `{env:NVIDIA_API_KEY}` to | ||
| `https://integrate.api.nvidia.com/v1`. Do not rename that local binding to the organization | ||
| secret name `NVIDIA_NIM_API_KEY`. Do not put OpenAI-style `reasoningEffort` anywhere in the | ||
| local OpenCode configuration. | ||
|
|
||
| ## Why this lock exists | ||
|
|
||
| Local developer OpenCode is a separate trust boundary from central OpenCode Review and the | ||
| PR review/merge scheduler in `ContextualWisdomLab/.github`. Those workflows keep their own | ||
| credential names. This repository only records the local client allowlist. | ||
|
|
||
| NVIDIA NIM reasoning models use `chat_template_kwargs` (for example `enable_thinking`) rather | ||
| than the OpenAI `reasoning_effort` field. NVIDIA documents `reasoning_effort` as a Chat | ||
| Completions knob for GPT-OSS models on multi-LLM NIM, not for Llama 3.3 Nemotron Super 49B | ||
| v1.5 (NVIDIA, n.d.-a; NVIDIA, n.d.-b). Forwarding `reasoningEffort` from OpenCode can be | ||
| ignored or rejected. The contract therefore forbids that OpenCode option across the whole | ||
| repository config instead of checking only one model's nested `options` object. | ||
|
|
||
| The organization GitHub secret remains `NVIDIA_NIM_API_KEY`. CI maps that secret onto process | ||
| env `NVIDIA_API_KEY` because that is the NVIDIA/OpenCode client binding. | ||
|
|
||
| ## Held values | ||
|
|
||
| - `enabled_providers`: `["nvidia-nim"]` | ||
| - default model: `nvidia-nim/nvidia/llama-3.3-nemotron-super-49b-v1.5` | ||
| - `small_model`: `nvidia-nim/meta/llama-3.3-70b-instruct` | ||
| - `apiKey`: `{env:NVIDIA_API_KEY}` | ||
| - leftover deny-list: `github-models`, `STRIX_GITHUB_MODELS_TOKEN`, `COPILOT_GITHUB_TOKEN`, | ||
| `openai/gpt-5`, `openai/o3`, `openai/o4-mini`, `models.github.ai` | ||
|
|
||
| ## References | ||
|
|
||
| NVIDIA. (n.d.-a). *Use reasoning models with NVIDIA NIM for LLMs*. | ||
| https://docs.nvidia.com/nim/large-language-models/latest/reasoning-model.html | ||
|
|
||
| NVIDIA. (n.d.-b). *nvidia / llama-3.3-nemotron-super-49b-v1.5*. | ||
| https://docs.api.nvidia.com/nim/reference/nvidia-llama-3_3-nemotron-super-49b-v1_5 | ||
|
|
||
| ## Security Notes | ||
|
|
||
| - Attack surface: local OpenCode HTTPS calls to `https://integrate.api.nvidia.com/v1` using a | ||
| process-env API key. | ||
| - Trust boundary: untrusted prompts and repository contents sent to the provider; trusted | ||
| repo-controlled provider allowlist; secret name `NVIDIA_NIM_API_KEY` stays in GitHub and is | ||
| mapped onto `NVIDIA_API_KEY` only at process start. | ||
| - Mitigations: single enabled provider, no GitHub Models or Copilot token fallback, leftover | ||
| string deny-list, and explicit whole-config bans on `reasoningEffort` and | ||
| `{env:NVIDIA_NIM_API_KEY}` inside `opencode.jsonc`. | ||
| - Test points: `test_opencode_uses_nvidia_nim_only` owns the structured provider/model/secret | ||
| contract; `test_opencode_forbids_reasoning_effort_anywhere` independently prevents the | ||
| forbidden OpenAI-style option from being pasted at any config level. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| """Focused regression for forbidden OpenCode reasoning options.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from pathlib import Path | ||
|
|
||
|
|
||
| def test_opencode_forbids_reasoning_effort_anywhere() -> None: | ||
| """Reject OpenAI-style reasoningEffort anywhere in the local NIM config.""" | ||
| repo_root = Path(__file__).resolve().parents[3] | ||
| opencode_text = (repo_root / "opencode.jsonc").read_text(encoding="utf-8") | ||
|
|
||
| assert '"reasoningEffort"' not in opencode_text |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5073,14 +5073,44 @@ def test_opencode_approval_write_failure_updates_overview_only() -> None: | |
| assert "source-backed repository findings" in policy | ||
|
|
||
|
|
||
| def test_opencode_uses_nvidia_nim_only() -> None: | ||
| """Ensure local OpenCode is NVIDIA NIM only and does not use GitHub Models.""" | ||
| repo_root = Path(__file__).resolve().parents[3] | ||
| opencode_text = (repo_root / "opencode.jsonc").read_text(encoding="utf-8") | ||
| opencode_config = json.loads(opencode_text) | ||
|
|
||
| assert opencode_config["model"] == "nvidia-nim/nvidia/llama-3.3-nemotron-super-49b-v1.5" | ||
| assert opencode_config["small_model"] == "nvidia-nim/meta/llama-3.3-70b-instruct" | ||
| assert opencode_config["enabled_providers"] == ["nvidia-nim"] | ||
| assert set(opencode_config["provider"]) == {"nvidia-nim"} | ||
|
|
||
| nim_provider = opencode_config["provider"]["nvidia-nim"] | ||
| assert nim_provider["options"]["baseURL"] == "https://integrate.api.nvidia.com/v1" | ||
| assert nim_provider["options"]["apiKey"] == "{env:NVIDIA_API_KEY}" | ||
| assert "nvidia/llama-3.3-nemotron-super-49b-v1.5" in nim_provider["models"] | ||
| assert "meta/llama-3.3-70b-instruct" in nim_provider["models"] | ||
|
|
||
| primary_model = nim_provider["models"]["nvidia/llama-3.3-nemotron-super-49b-v1.5"] | ||
| assert "reasoningEffort" not in primary_model.get("options", {}) | ||
| assert "{env:NVIDIA_NIM_API_KEY}" not in opencode_text | ||
|
Comment on lines
+5076
to
+5095
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Info: opencode.jsonc parses as strict JSON
Was this helpful? React with 👍 or 👎 to provide feedback. |
||
|
|
||
| leftover_tokens = ( | ||
| "github-models", | ||
| "STRIX_GITHUB_MODELS_TOKEN", | ||
| "COPILOT_GITHUB_TOKEN", | ||
| "openai/gpt-5", | ||
| "openai/o3", | ||
| "openai/o4-mini", | ||
| "models.github.ai", | ||
| ) | ||
| for leftover in leftover_tokens: | ||
| assert leftover not in opencode_text | ||
|
|
||
|
|
||
| def test_pr_review_merge_scheduler_uses_central_mutation_credential() -> None: | ||
| """Ensure mechanical PR queue handling uses the central mutation credential.""" | ||
| repo_root = Path(__file__).resolve().parents[3] | ||
| policy = central_required_workflow_policy_text() | ||
|
|
||
| opencode_config = (repo_root / "opencode.jsonc").read_text(encoding="utf-8") | ||
| assert '"openai/o3"' in opencode_config | ||
| assert '"openai/o4-mini"' in opencode_config | ||
| assert_local_review_workflows_removed() | ||
| assert "selected workflow mutation" in policy | ||
| assert "credential, not by a maintainer's local `gh` session" in policy | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Info: json.loads on .jsonc breaks if comments are added
test_opencode_uses_nvidia_nim_onlyparses opencode.jsonc withjson.loads(services/analysis-engine/tests/test_supply_chain_policy.py:5080). The.jsoncformat allows comments and trailing commas; the file currently has none. Adding either later would fail parsing with a decode error rather than a clear contract assertion.Was this helpful? React with 👍 or 👎 to provide feedback.