Skip to content

fix(provider-core): opt out of proxy discovery for qualification - #122

Closed
KooshaPari wants to merge 1 commit into
masterfrom
codex/qualification-no-proxy-20261018
Closed

KooshaPari wants to merge 1 commit into
masterfrom
codex/qualification-no-proxy-20261018

Conversation

@KooshaPari

@KooshaPari KooshaPari commented Oct 18, 2026 •

Copy link
Copy Markdown
Owner

User description

Under the Mach-denied qualification sandbox, constructing the shared provider HTTP client panicked during macOS system-proxy discovery before passive ACP attachment could proceed. Exact KCODE_QUALIFICATION_NO_PROXY=1 now applies reqwest's supported ClientBuilder::no_proxy() API to generic shared/fresh clients and their fallback construction. Unset and all other values preserve the existing proxy behavior, shared cache, timeouts, pooling, and User-Agent. Dependency features and sandbox grants remain unchanged.

The flag belongs only in the isolated child environment before startup. It does not enforce offline operation or change independently constructed clients. Full daemon/ACP and installed-binary qualification remain open.

Validation: baseline RED had two intended failures; the final focused suite passes 3/3. Real clients preserve unset/invalid-value loopback proxy routing, bypass it only for exact opt-in, and build with Mach/network denied only in the opted-in case while the normal-mode NULL panic remains the negative control. The shared cache and fresh-client paths are exercised. The test fixture explicitly sets accepted sockets to blocking before bounded reads and preserves primary failures during cleanup. cargo check -p jcode-provider-core --jobs 1, scoped formatting, and git diff --check pass. No whole suite or hosted/runtime acceptance is claimed.

Refs #11. Fork-only delivery to KooshaPari/KCode; no install, shared-daemon restart, upstream publication, merge, or release.


CodeAnt-AI Description

Prevent proxy-discovery crashes in restricted provider qualification

What Changed

  • An explicit qualification opt-in lets shared and retry provider clients build without proxy discovery when Mach access is denied.
  • Without the exact opt-in, existing proxy behavior is preserved.

Impact

✅ Provider clients start in Mach-restricted qualification
✅ Opted-in qualification skips proxy discovery
✅ Default proxy routing remains unchanged

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

Use the supported no_proxy builder API only for exact KCODE_QUALIFICATION_NO_PROXY=1. Preserve normal proxy behavior and exercise shared/fresh clients under identical Mach and network denial.

Focused regression: 3 passed, 0 failed; cargo check -p jcode-provider-core --jobs 1 passed.
Refs #11.
tx-agent: codex
tx-validated: cargo-check
tx-scope: qualification
Copilot AI balanced review requested due to automatic review settings October 18, 2026 04:23
@codeant-ai

codeant-ai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

🤖 CodeAnt AI — Review Status

Status Commit Started (UTC) Finished (UTC)
✅ Reviewed your PR 14902ad Oct 18, 2026 · 04:23 04:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@codeant-ai

codeant-ai Bot commented Oct 18, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai codeant-ai Bot added the size:L This PR changes 100-499 lines, ignoring generated files label Oct 18, 2026
@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 4a61292c-465e-4c2d-b41e-aaa1480296f1
📥 Commits

Reviewing files that changed from the base of the PR and between 27ee6d6 and 14902ad.

📒 Files selected for processing: 5
  • crates/jcode-provider-core/src/lib.rs
  • crates/jcode-provider-core/src/qualification_http.rs
  • crates/jcode-provider-core/tests/qualification_proxy.rs
  • docs/ENVIRONMENT.md
  • docs/sessions/20261018-qualification-proxy/01_RESEARCH.md

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout: 2
  • GitHub Check: Kilo Code Review
  • GitHub Check: semgrep-cloud-platform/scan
🧰 Additional context used
🪛 LanguageTool
docs/sessions/20261018-qualification-proxy/01_RESEARCH.md

[style] ~28-~28: This phrase is redundant (‘OS’ stands for ‘operating system’). Use simply “macOS”.
Context: ...proxies and sets it false. Hyper-util's macOS system matcher calls `SCDynamicStoreBuilder::n...

(ACRONYM_TAUTOLOGY)

🔇 Additional comments: 5
crates/jcode-provider-core/src/lib.rs: 1

13-13: LGTM!

Also applies to: 734-734, 751-751, 760-760, 778-778

crates/jcode-provider-core/src/qualification_http.rs: 1

1-28: LGTM!

crates/jcode-provider-core/tests/qualification_proxy.rs: 1

1-190: LGTM!

docs/ENVIRONMENT.md: 1

84-97: LGTM!

docs/sessions/20261018-qualification-proxy/01_RESEARCH.md: 1

1-90: LGTM!

📝 Summary

Summary

The change adds KCODE_QUALIFICATION_NO_PROXY=1 as an opt-out from proxy discovery for generic shared and fresh provider HTTP clients, including fallback construction. Unset and other values retain normal proxy behavior. The flag does not enforce offline operation and must be set before the shared client is first used.

Must Fix

No blocking issues are identified in the supplied implementation and test evidence.

Should Fix

No non-blocking changes are identified in the supplied evidence.

Consider

The author reports that the focused regression tests pass (3/3), cargo check -p jcode-provider-core --jobs 1 passes, and formatting and git diff --check pass. Full-suite and hosted/runtime acceptance are not established. Installed-binary qualification remains open.

Approve / Request Changes

Approve with notes. The reported verification supports the focused change, but it does not establish full-suite or hosted/runtime acceptance.

Generic shared and fresh provider HTTP clients now use a qualification-specific builder. Setting KCODE_QUALIFICATION_NO_PROXY to exactly "1" disables proxy discovery for these clients and the shared-client fallback. Tests and documentation describe the setting’s behavior and limits.

Changes: Qualification proxy behavior

Layer / File(s) Summary
Qualification HTTP client setup
crates/jcode-provider-core/src/qualification_http.rs, crates/jcode-provider-core/src/lib.rs
Adds a builder that calls no_proxy() only when KCODE_QUALIFICATION_NO_PROXY is exactly "1". Shared and fresh clients use the builder. The shared-client fallback uses the qualification builder and fallback factory.
Behavior checks and documentation
crates/jcode-provider-core/tests/qualification_proxy.rs, docs/ENVIRONMENT.md, docs/sessions/20261018-qualification-proxy/01_RESEARCH.md
Adds process-isolated tests for proxy behavior and macOS sandbox client construction. Documents the flag, its limits, and the recorded research and verification results.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 14902

No specific merge-blocking issue is identified; the change is mergeable after normal checks.

Security architecture risk: 🔵 Low · up to 14902

The bypass requires an exact opt-in and leaves normal proxy behavior unchanged. It must remain confined to an already restricted child process: the setting does not prevent network access. No introduced security finding was established, but full daemon startup and installed-runtime isolation remain unvalidated.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — Effective exposure is process-wide for consumers of these generic constructors, not a per-request or per-session exception. Someone controlling the process startup environment can select direct routing for those clients. Independently constructed clients are outside this setting's stated scope.

Trust Boundaries and Controls

  • observed — Proxy bypass is explicitly not an offline security boundary. The documented control remains an independently restricted qualification sandbox. The macOS test applies identical Mach-lookup and network denials to opted-in and normal-mode child construction; it does not establish production deployment isolation.

Resilience and Maintainability Implications

  • inferred — OnceLock preserves atomic publication and reuse of one shared client during concurrent initialization. Policy consistency across shared, fresh, and fallback clients depends on keeping the startup environment stable; later mutation can split their routing policies without updating the cached client.

Hardening Proposals

  • proposed — When integrating the actual qualification launcher, verify child-only environment ownership, retained outbound and Mach restrictions, and replacement-process rollback. Treat full daemon and installed-binary qualification as separate acceptance work, not as established by these constructor tests.
Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 41.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 3 files. (2 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: disabling proxy discovery for provider qualification.
Description check Passed The description directly explains the proxy-discovery fix, opt-in behavior, preserved defaults, scope, and validation results.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 41.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 3 files. (2 skipped: 2 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
✨ Simplify code
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@codeant-ai

codeant-ai Bot commented Oct 18, 2026

Copy link
Copy Markdown

CodeAnt PR Risk: Low Risk

  • The PR appears safe to merge; proxy bypass is limited to an explicit opt-in for generic provider clients, and default proxy behavior remains unchanged.
  • Focused tests cover proxy routing, cached and fresh clients, and client construction under Mach and network restrictions.

Assessed commit: 14902ad14787

@KooshaPari

Copy link
Copy Markdown
Owner Author

Superseded by #123.

PR #123 is a fresh cherry-pick of this same commit onto a clean branch off
master, with no stacked changes. The merge target is identical and the
canonical implementation lives on #123. Verified on this branch:
cargo check -p jcode-provider-core --tests --jobs 2 clean (8 s).

@KooshaPari KooshaPari closed this Oct 18, 2026
// Do not reintroduce system-proxy discovery via Client::new on a fallback.
builder()
.build()
.expect("failed to build qualification provider HTTP client")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: Panic in library code via .expect().

fallback_client() panics if builder().build() fails. The original code gracefully degraded to reqwest::Client::new() on build failure. Library code should avoid panicking; propagate or handle the error instead.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

std::env::var_os("KCODE_QUALIFICATION_NO_PROXY").as_deref() == Some(OsStr::new("1"))
}

pub(crate) fn builder() -> reqwest::ClientBuilder {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: Missing doc comment on pub(crate) fn builder().

CodeRabbit's pre-merge check requires 80% docstring coverage; current coverage is 41.67%. Add a doc comment explaining what the builder does and when no_proxy() is applied.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

}
}

pub(crate) fn fallback_client() -> reqwest::Client {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: Missing doc comment on pub(crate) fn fallback_client().

CodeRabbit's pre-merge check requires 80% docstring coverage; current coverage is 41.67%. Add a doc comment explaining the fallback behavior and the panic-on-error path.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

@kilo-code-bot

kilo-code-bot Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: 3 Issues Found | Recommendation: Address before merge

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 2
Issue Details (click to expand)

WARNING

File Line Issue
crates/jcode-provider-core/src/qualification_http.rs 24 Panic in library code via .expect(). fallback_client() panics if builder().build() fails. The original code gracefully degraded to reqwest::Client::new() on build failure.

SUGGESTION

File Line Issue
crates/jcode-provider-core/src/qualification_http.rs 9 Missing doc comment on pub(crate) fn builder(). CodeRabbit's pre-merge check requires 80% docstring coverage; current coverage is 41.67%.
crates/jcode-provider-core/src/qualification_http.rs 19 Missing doc comment on pub(crate) fn fallback_client(). CodeRabbit's pre-merge check requires 80% docstring coverage; current coverage is 41.67%.
Files Reviewed (5 files)
  • crates/jcode-provider-core/src/lib.rs - 0 issues
  • crates/jcode-provider-core/src/qualification_http.rs - 3 issues
  • crates/jcode-provider-core/tests/qualification_proxy.rs - 0 issues
  • docs/ENVIRONMENT.md - 0 issues
  • docs/sessions/20261018-qualification-proxy/01_RESEARCH.md - 0 issues

Fix these issues in Kilo Cloud


Reviewed by free · Input: 65.3K · Output: 18.7K · Cached: 173.4K

@KooshaPari
KooshaPari deleted the codex/qualification-no-proxy-20261018 branch November 27, 2026 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants