Skip to content

refactor: corvus env uppercase#18

Merged
yacosta738 merged 5 commits into
mainfrom
refactor/corvus-env-uppercase
Feb 17, 2026
Merged

refactor: corvus env uppercase#18
yacosta738 merged 5 commits into
mainfrom
refactor/corvus-env-uppercase

Conversation

@yacosta738
Copy link
Copy Markdown
Contributor

@yacosta738 yacosta738 commented Feb 17, 2026

This pull request standardizes environment variable naming by switching from lower-case corvus_* to upper-case CORVUS_* throughout the codebase, and improves the handling of Ollama model fetching by allowing the base URL to be configurable via environment variables. It also introduces utility functions for environment variable access and HTTP URL normalization, making the configuration logic more robust and maintainable.

Environment variable naming and config standardization:

  • All references to environment variables have been updated from the lower-case corvus_* format to the upper-case CORVUS_* format throughout the codebase, including in config schema, gateway, memory, main, and onboarding wizard modules. This affects both code and tests. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16]

Ollama model fetching improvements:

  • The Ollama model fetch logic now supports configuring the base URL via CORVUS_OLLAMA_BASE_URL or OLLAMA_BASE_URL environment variables, falling back to the default if unset. This is handled by new utility functions normalize_http_url and resolve_ollama_base_url_for_fetch. [1] [2] [3] [4]
  • The onboarding wizard now provides clearer instructions for setting the Ollama base URL when running in Docker or remote environments.

Utility and code cleanup:

  • Introduced helper functions for environment variable access and HTTP URL normalization, improving code clarity and reducing duplication. [1] [2] [3]

Minor formatting:

  • Minor formatting and whitespace cleanups for consistency.

These changes improve configuration consistency, make environment variable handling more robust, and enhance support for flexible deployments, especially with Ollama.

Summary by CodeRabbit

  • New Features

    • Enhanced Ollama integration with configurable base URL support and improved Docker/remote usage guidance during onboarding.
  • Documentation

    • Added Bolt performance agent documentation with structured workflows for profiling, optimization, and performance verification.
  • Chores

    • Standardized environment variable naming convention to uppercase (CORVUS_*) format across the agent runtime for consistency.

@github-actions
Copy link
Copy Markdown
Contributor

Thank you for contributing to this project with this PR, welcome to the community and the amazing world of open source!

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 17, 2026

📝 Walkthrough

Walkthrough

The changes introduce a new Bolt performance agent documentation and standardize environment variable naming conventions across the agent-runtime codebase from lowercase corvus_* to uppercase CORVUS_* format, while adding enhanced Ollama base URL resolution capabilities with environment variable and API key lookups.

Changes

Cohort / File(s) Summary
Documentation
.agents/command/bolt.agent.md
New comprehensive guide for the Bolt performance agent in Kotlin Multiplatform mono-repo, covering workflows, profiling procedures, verification steps, and presentation templates for performance improvements.
Environment Variable Standardization
clients/agent-runtime/src/config/schema.rs, clients/agent-runtime/src/gateway/mod.rs, clients/agent-runtime/src/main.rs, clients/agent-runtime/src/memory/lucid.rs, clients/agent-runtime/src/providers/mod.rs, clients/agent-runtime/src/skills/mod.rs, clients/agent-runtime/src/tools/shell.rs
Renamed environment variables from lowercase corvus_* pattern to uppercase CORVUS_* across multiple modules including WhatsApp secrets, autostart channels, Lucid memory settings, and API key overrides. Updated corresponding tests to reflect new variable names.
Ollama Integration Enhancement
clients/agent-runtime/src/onboard/wizard.rs
Added Ollama base URL support with resolve_ollama_base_url_for_fetch() and normalize_http_url() helper functions. Updated fetch_ollama_models() to accept optional API key parameter for endpoint construction. Enhanced onboarding messaging and environment variable mapping for Ollama provider.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'refactor: corvus env uppercase' directly describes the main change—standardizing environment variable naming from lowercase to uppercase format throughout the codebase.
Description check ✅ Passed The PR description provides a comprehensive overview of changes including environment variable standardization, Ollama improvements, and utility functions, addressing the template's summary requirement effectively.
Docstring Coverage ✅ Passed Docstring coverage is 87.50% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/corvus-env-uppercase

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 and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 17, 2026

✅ Contributor Report

User: @yacosta738
Status: Passed (12/13 metrics passed)

Metric Description Value Threshold Status
PR Merge Rate PRs merged vs closed 89% >= 30%
Repo Quality Repos with ≥100 stars 0 >= 0
Positive Reactions Positive reactions received 9 >= 1
Negative Reactions Negative reactions received 0 <= 5
Account Age GitHub account age 3034 days >= 30 days
Activity Consistency Regular activity over time 108% >= 0%
Issue Engagement Issues with community engagement 0 >= 0
Code Reviews Code reviews given to others 361 >= 0
Merger Diversity Unique maintainers who merged PRs 3 >= 0
Repo History Merge Rate Merge rate in this repo 92% >= 0%
Repo History Min PRs Previous PRs in this repo 15 >= 0
Profile Completeness Profile richness (bio, followers) 90 >= 0
Suspicious Patterns Spam-like activity detection 1 N/A

Contributor Report evaluates based on public GitHub activity. Analysis period: 2025-02-17 to 2026-02-17

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
clients/agent-runtime/src/config/schema.rs (1)

1635-1701: ⚠️ Potential issue | 🟡 Minor

Inconsistent legacy fallback strategy — MODEL, WORKSPACE, and TEMPERATURE lost their non-prefixed fallbacks.

API_KEY, PROVIDER, GATEWAY_PORT, and GATEWAY_HOST correctly fall back to their non-prefixed variants (API_KEY, PROVIDER, PORT, HOST), but MODEL, WORKSPACE, and TEMPERATURE only check CORVUS_* — no legacy fallback. This is a breaking change for users who previously set MODEL=gpt-4o (or similar) in their environment.

If removing these fallbacks is intentional, please document it (e.g., in a migration note). Otherwise, add fallbacks for consistency:

Proposed fix for consistent fallback
-        // Model: CORVUS_MODEL
-        if let Ok(model) = corvus_env("MODEL") {
+        // Model: CORVUS_MODEL or MODEL
+        if let Ok(model) = corvus_env("MODEL").or_else(|_| std::env::var("MODEL")) {
             if !model.is_empty() {
                 self.default_model = Some(model);
             }
         }

-        // Workspace directory: CORVUS_WORKSPACE
-        if let Ok(workspace) = corvus_env("WORKSPACE") {
+        // Workspace directory: CORVUS_WORKSPACE or WORKSPACE
+        if let Ok(workspace) = corvus_env("WORKSPACE").or_else(|_| std::env::var("WORKSPACE")) {
             if !workspace.is_empty() {
                 self.workspace_dir = PathBuf::from(workspace);
             }
         }

         // ...

-        // Temperature: CORVUS_TEMPERATURE
-        if let Ok(temp_str) = corvus_env("TEMPERATURE") {
+        // Temperature: CORVUS_TEMPERATURE or TEMPERATURE
+        if let Ok(temp_str) = corvus_env("TEMPERATURE").or_else(|_| std::env::var("TEMPERATURE")) {

Based on learnings: "Preserve CLI contract unless change is intentional and documented; prefer explicit errors over silent fallback for unsupported critical paths."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@clients/agent-runtime/src/config/schema.rs` around lines 1635 - 1701, The
code only checks CORVUS_MODEL, CORVUS_WORKSPACE, and CORVUS_TEMPERATURE but not
their legacy unprefixed env vars, causing a breaking change; update the
environment lookups to use the same fallback pattern as other settings by using
the corvus_env closure with .or_else(|_| std::env::var("MODEL")) / .or_else(|_|
std::env::var("WORKSPACE")) / .or_else(|_| std::env::var("TEMPERATURE"))
respectively, then parse/assign into self.default_model, self.workspace_dir
(PathBuf::from), and self.default_temperature (parse f64 and validate range)
just like the existing blocks for provider/port/host so legacy MODEL, WORKSPACE,
and TEMPERATURE env vars are respected.
🧹 Nitpick comments (4)
.agents/command/bolt.agent.md (1)

145-145: Fix code span spacing in stable/immutable.

There’s a space inside the code span, which triggers MD038 and renders oddly.

Proposed fix
-- Missing `stable`/` immutable` annotations for better Compose compiler optimization
+- Missing `stable`/`immutable` annotations for better Compose compiler optimization
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.agents/command/bolt.agent.md at line 145, The markdown contains code spans
with extra leading spaces in the annotations so change the spans from `
stable`/` immutable` to `stable`/`immutable` (remove the spaces inside the
backticks) so MD038 is not triggered and the annotations render correctly;
update the occurrences of the `stable` and `immutable` code spans in
.agents/command/bolt.agent.md, ensuring there are no internal spaces inside the
backticks.
clients/agent-runtime/src/providers/mod.rs (1)

132-132: Ollama base URL resolution piggybacked on resolve_api_key is a semantic mismatch.

resolve_api_key returns what callers treat as an "API key", but for Ollama, it now resolves a base URL. This works today because resolve_ollama_base_url on line 200–207 validates the result with normalize_http_url, but a future maintainer could reasonably assume the return value is a credential.

Consider extracting a dedicated resolve_ollama_base_url_from_env that reads CORVUS_OLLAMA_BASE_URL / OLLAMA_BASE_URL directly, rather than routing through the API-key resolution path. This would make the intent clearer and avoid the generic fallback (CORVUS_API_KEY / API_KEY) from accidentally being interpreted as a base URL for Ollama.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@clients/agent-runtime/src/providers/mod.rs` at line 132, The current code
routes Ollama's base URL lookup through resolve_api_key which semantically
returns API keys; create a dedicated resolver resolve_ollama_base_url_from_env
that reads only CORVUS_OLLAMA_BASE_URL and OLLAMA_BASE_URL from the environment
(no generic API_KEY fallbacks), remove the "ollama" entry from the
resolve_api_key mapping, and change resolve_ollama_base_url to call
resolve_ollama_base_url_from_env and then validate the result with
normalize_http_url so the base-URL intent is explicit and cannot be confused
with credentials.
clients/agent-runtime/src/onboard/wizard.rs (2)

757-795: CORVUS_API_KEY / API_KEY fallbacks in the Ollama base-URL resolver are semantically misleading.

resolve_ollama_base_url_for_fetch falls back to CORVUS_API_KEY and API_KEY env vars (lines 784-793), which conventionally hold bearer tokens, not HTTP base URLs. Although normalize_http_url safely rejects non-URL strings, including these in a URL resolution chain is confusing for maintainers and creates a silent semantic mismatch: any user who happens to set CORVUS_API_KEY to a URL-like string would unexpectedly have it used as an Ollama endpoint.

Consider removing the CORVUS_API_KEY and API_KEY fallbacks to keep this function's intent clear — it resolves a base URL, not an API key.

Proposed simplification
 fn resolve_ollama_base_url_for_fetch(api_key: Option<&str>) -> String {
     api_key
         .and_then(normalize_http_url)
         .or_else(|| {
             std::env::var("CORVUS_OLLAMA_BASE_URL")
                 .ok()
                 .and_then(|value| normalize_http_url(&value))
         })
         .or_else(|| {
             std::env::var("OLLAMA_BASE_URL")
                 .ok()
                 .and_then(|value| normalize_http_url(&value))
         })
-        .or_else(|| {
-            std::env::var("CORVUS_API_KEY")
-                .ok()
-                .and_then(|value| normalize_http_url(&value))
-        })
-        .or_else(|| {
-            std::env::var("API_KEY")
-                .ok()
-                .and_then(|value| normalize_http_url(&value))
-        })
         .unwrap_or_else(|| OLLAMA_DEFAULT_BASE_URL.to_string())
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@clients/agent-runtime/src/onboard/wizard.rs` around lines 757 - 795, The
function resolve_ollama_base_url_for_fetch currently falls back to
CORVUS_API_KEY and API_KEY environment variables (via normalize_http_url), which
is semantically incorrect because those vars are tokens not base URLs; remove
the two or_else branches that read CORVUS_API_KEY and API_KEY so the resolver
only checks api_key, CORVUS_OLLAMA_BASE_URL and OLLAMA_BASE_URL before
defaulting to OLLAMA_DEFAULT_BASE_URL, and update any related tests or callers
to stop relying on API key env vars as URL fallbacks; reference
resolve_ollama_base_url_for_fetch and normalize_http_url when making the change.

1827-1829: provider_env_var("ollama") now returns a URL env var instead of an API-key env var — trace the downstream impact.

Every other provider arm returns an *_API_KEY variable, but Ollama now returns OLLAMA_BASE_URL. Callers in fetch_live_models_for_provider (line 960) read this env var into a local named api_key, which then flows into fetch_ollama_models as the api_key parameter. The indirection works because resolve_ollama_base_url_for_fetch tries to parse the value as a URL, but the variable naming (api_key) throughout the call chain is misleading.

This also affects the "Skipped" message in setup_provider (line 1523-1527), which tells users to set the env var from provider_env_var(...). For Ollama, this would say "Set OLLAMA_BASE_URL" — which is reasonable but different in nature from "Set YOUR_API_KEY".

No functional bug, but worth a short inline comment at line 1829 to clarify the intentional semantic difference.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@clients/agent-runtime/src/onboard/wizard.rs` around lines 1827 - 1829,
provider_env_var("ollama") intentionally returns OLLAMA_BASE_URL (a URL) rather
than an API key; add a short inline comment next to the "ollama" arm in
provider_env_var clarifying that Ollama uses a base URL, callers
(fetch_live_models_for_provider -> fetch_ollama_models) still read it into a
variable named `api_key` for historical reasons and rely on
resolve_ollama_base_url_for_fetch to parse the URL, and that setup_provider’s
"Set ..." message intentionally points to OLLAMA_BASE_URL. Mention the specific
symbols provider_env_var, fetch_live_models_for_provider, fetch_ollama_models,
resolve_ollama_base_url_for_fetch, and setup_provider in the comment so future
readers understand the semantic difference.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.agents/command/bolt.agent.md:
- Around line 204-208: Update the three bullets under "Choose an optimization
that:" so each is a complete sentence by adding a clear subject (e.g., "The
optimization" or "It") to each bullet; specifically change "- **Has clear and
measurable performance impact** (can you benchmark it?)" to "- The optimization
has clear and measurable performance impact (can you benchmark it?)", change "-
**Can be implemented cleanly with low risk** (low regression risk)" to "- The
optimization can be implemented cleanly with low risk (low regression risk)",
and change "- Does not compromise code readability or maintainability" to "- It
does not compromise code readability or maintainability".

---

Outside diff comments:
In `@clients/agent-runtime/src/config/schema.rs`:
- Around line 1635-1701: The code only checks CORVUS_MODEL, CORVUS_WORKSPACE,
and CORVUS_TEMPERATURE but not their legacy unprefixed env vars, causing a
breaking change; update the environment lookups to use the same fallback pattern
as other settings by using the corvus_env closure with .or_else(|_|
std::env::var("MODEL")) / .or_else(|_| std::env::var("WORKSPACE")) /
.or_else(|_| std::env::var("TEMPERATURE")) respectively, then parse/assign into
self.default_model, self.workspace_dir (PathBuf::from), and
self.default_temperature (parse f64 and validate range) just like the existing
blocks for provider/port/host so legacy MODEL, WORKSPACE, and TEMPERATURE env
vars are respected.

---

Nitpick comments:
In @.agents/command/bolt.agent.md:
- Line 145: The markdown contains code spans with extra leading spaces in the
annotations so change the spans from ` stable`/` immutable` to
`stable`/`immutable` (remove the spaces inside the backticks) so MD038 is not
triggered and the annotations render correctly; update the occurrences of the
`stable` and `immutable` code spans in .agents/command/bolt.agent.md, ensuring
there are no internal spaces inside the backticks.

In `@clients/agent-runtime/src/onboard/wizard.rs`:
- Around line 757-795: The function resolve_ollama_base_url_for_fetch currently
falls back to CORVUS_API_KEY and API_KEY environment variables (via
normalize_http_url), which is semantically incorrect because those vars are
tokens not base URLs; remove the two or_else branches that read CORVUS_API_KEY
and API_KEY so the resolver only checks api_key, CORVUS_OLLAMA_BASE_URL and
OLLAMA_BASE_URL before defaulting to OLLAMA_DEFAULT_BASE_URL, and update any
related tests or callers to stop relying on API key env vars as URL fallbacks;
reference resolve_ollama_base_url_for_fetch and normalize_http_url when making
the change.
- Around line 1827-1829: provider_env_var("ollama") intentionally returns
OLLAMA_BASE_URL (a URL) rather than an API key; add a short inline comment next
to the "ollama" arm in provider_env_var clarifying that Ollama uses a base URL,
callers (fetch_live_models_for_provider -> fetch_ollama_models) still read it
into a variable named `api_key` for historical reasons and rely on
resolve_ollama_base_url_for_fetch to parse the URL, and that setup_provider’s
"Set ..." message intentionally points to OLLAMA_BASE_URL. Mention the specific
symbols provider_env_var, fetch_live_models_for_provider, fetch_ollama_models,
resolve_ollama_base_url_for_fetch, and setup_provider in the comment so future
readers understand the semantic difference.

In `@clients/agent-runtime/src/providers/mod.rs`:
- Line 132: The current code routes Ollama's base URL lookup through
resolve_api_key which semantically returns API keys; create a dedicated resolver
resolve_ollama_base_url_from_env that reads only CORVUS_OLLAMA_BASE_URL and
OLLAMA_BASE_URL from the environment (no generic API_KEY fallbacks), remove the
"ollama" entry from the resolve_api_key mapping, and change
resolve_ollama_base_url to call resolve_ollama_base_url_from_env and then
validate the result with normalize_http_url so the base-URL intent is explicit
and cannot be confused with credentials.

Comment thread .agents/command/bolt.agent.md Outdated
@yacosta738 yacosta738 merged commit 7229c7b into main Feb 17, 2026
10 checks passed
@yacosta738 yacosta738 deleted the refactor/corvus-env-uppercase branch February 17, 2026 15:00
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