Skip to content

refactor(sdk): remove panic-prone call sites in auth and ssh - #69

Merged
KooshaPari merged 2 commits into
masterfrom
fix/panic-budget-sdk
Oct 15, 2026
Merged

KooshaPari merged 2 commits into
masterfrom
fix/panic-budget-sdk

Conversation

@KooshaPari

@KooshaPari KooshaPari commented Oct 15, 2026 •

Copy link
Copy Markdown
Owner

User description

Summary

Removes all 13 panic-prone call sites (unwrap() / expect()) from the SDK auth and ssh modules. The panic ratchet reports this as an improvement with no baseline change.

Files

  • crates/jcode-sdk/src/auth.rs — 10 -> 0
  • crates/jcode-sdk/src/ssh.rs — 3 -> 0

Validation

  • cargo check -p jcode-sdk --all-targets -> 0 errors
  • python3 scripts/check_panic_budget.py -> reports production panic-prone usage removed: crates/jcode-sdk/src/auth.rs (10 -> 0) and the ssh equivalent

Ledger

tx-agent: jcode
tx-task: panic-budget-ratchet
tx-validated: cargo-check
tx-scope: crates/jcode-sdk/src/auth.rs, crates/jcode-sdk/src/ssh.rs
tx-intent: drive panic-prone count in the SDK auth/ssh modules from 13 to 0

Part of a multi-worker panic-budget sweep. Sibling PRs: #66 (TUI SSH auth), plus branches for the grok-runtime/telemetry cluster and the small core modules.

🤖 Generated with Claude Code


CodeAnt-AI Description

Return errors instead of crashing during SDK login and SSH setup

What Changed

  • SDK login and SSH setup now return errors when required process streams or state are unavailable, rather than panicking.
  • Login cancellation still stops its child process and attempts cleanup when its state lock has been poisoned.

Impact

✅ Fewer app crashes during login and SSH setup
✅ Pending logins can still be cleaned up after a lock failure

💡 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.

Replace 13 unwrap/expect occurrences in the SDK auth and ssh modules with
typed error propagation. The panic-prone ratchet treats this as an
improvement, tightening the budget from 140 to 127 with no baseline change.

tx-agent: jcode
tx-task: panic-budget-ratchet
tx-validated: cargo-check
tx-scope: crates/jcode-sdk/src/auth.rs, crates/jcode-sdk/src/ssh.rs
tx-intent: drive panic-prone count in the SDK auth/ssh modules from 13 to 0
Copilot AI balanced review requested due to automatic review settings October 15, 2026 04:53
@codeant-ai

codeant-ai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

🤖 CodeAnt AI — Review Status

Status Commit Started (UTC) Finished (UTC)
✅ Incremental review completed f8e0c12 Oct 15, 2026 · 06:02 06:03
✅ Reviewed your PR 4705118 Oct 15, 2026 · 04:53 04:59

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 15, 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

@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

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

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: fea34482-e5b5-4483-b868-d9f7ca0d21a8
📥 Commits

Reviewing files that changed from the base of the PR and between 50f91b7 and f8e0c12.

📒 Files selected for processing: 2
  • crates/jcode-sdk/src/auth.rs
  • crates/jcode-sdk/src/ssh.rs
  • 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 added the size:M This PR changes 30-99 lines, ignoring generated files label Oct 15, 2026
@codeant-ai

codeant-ai Bot commented Oct 15, 2026

Copy link
Copy Markdown

CodeAnt Nitpicks

1 code suggestion

1. If the state mutex is poisoned, ? exits after setting cancellation and killing the child, so flow-scoped CLI cleanup never runs and persisted pending login state remains.

Missing cleanup · crates/jcode-sdk/src/auth.rs:322

@codeant-ai

codeant-ai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

CodeAnt PR Risk: Low Risk

  • The PR appears safe to merge; the changes replace panic paths with explicit errors or recover poisoned locks.
  • No concrete functional regression is evident in the changed authentication or SSH transport behavior.

Assessed commit: f8e0c12589b6

Comment thread crates/jcode-sdk/src/auth.rs Outdated
self.0.cancelled.store(true, Ordering::Release);
self.0.kill_child();
let _state = self.0.state.lock().unwrap();
let _state = locked(self.0.state.lock())?;

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: Early return on poisoned state mutex may skip cleanup of persisted pending login state

Explanation: If the state mutex is poisoned, the ? operator returns an error early, skipping the CLI cancel operation and setting of the finished flag. This may leave persisted pending login state uncleaned, as noted by CodeAnt AI.


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

self.kill_child();
}
self.child.lock().unwrap().take();
let _ = self.child.lock().map(|mut c| c.take());

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: Consider handling poisoned mutex in child lock cleanup

Explanation: The current code uses map on the lock result, which skips taking the child if the mutex is poisoned. This may leave the child in the mutex, potentially causing unnecessary kill/wait operations in Drop. Consider using unwrap_or_else to recover the guard and take the child, similar to the kill_child method.


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

@kilo-code-bot

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

Copy link
Copy Markdown

Code Review Summary

Status: 1 Issue Found | Recommendation: Merge (1 non-blocking suggestion remains)

Overview

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

SUGGESTION

File Line Issue
crates/jcode-sdk/src/auth.rs 494 Consider handling poisoned mutex in child lock cleanup — carried forward from previous review; line unchanged by this PR, active comment already exists
Files Reviewed (1 file)
  • crates/jcode-sdk/src/auth.rs — 1 carried-forward suggestion (line 494); the previous WARNING at line 322 was resolved by commit f8e0c12

Fix these issues in Kilo Cloud

Previous Review Summary (commit 4705118)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 4705118)

Status: 2 Issues Found | Recommendation: Address before merge

Overview

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

WARNING

File Line Issue
crates/jcode-sdk/src/auth.rs 322 Early return on poisoned state mutex may skip cleanup of persisted pending login state

SUGGESTION

File Line Issue
crates/jcode-sdk/src/auth.rs 491 Consider handling poisoned mutex in child lock cleanup
Files Reviewed (2 files)
  • crates/jcode-sdk/src/auth.rs - 2 issues
  • crates/jcode-sdk/src/ssh.rs - 0 issues

Fix these issues in Kilo Cloud


Reviewed by free · Input: 299.8K · Output: 32.5K · Cached: 153.6K

@KooshaPari
KooshaPari merged commit 5a54bc0 into master Oct 15, 2026
6 checks passed
KooshaPari pushed a commit that referenced this pull request Oct 15, 2026
… to '0 in tracked subset'

tx-agent:     jcode
tx-task:      B.8.79
tx-parent:    5a54bc0
tx-validated: rg-ratchet-rebaseline (3 categories A/B/C, whole-tree vs tracked-subset), rg-verify (PR #69 effect = -5 .expect() + -8 .unwrap() in sdk/auth.rs), cargo-test (3 restore_session tests pass on new HEAD via prebuilt binary)
tx-scope:     docs/sessions/2026-10-12-cleanup-and-release/01_AUDIT.md
tx-intent:    Record B.8.79 — Master moved to 5a54bc0 (PR #69 sdk auth/ssh panic-budget). B.8.78's 'Ratchet A = 0 in production' was misleading: it was 0 in the 46-file peer-agent tracked subset, but the whole-tree non-test production count is 492. CORRECTED framing: tracked-subset panic-budget work is COMPLETE (140→0); whole-tree ratchet is at 492 sites. PR #69 actual effect: -5 .expect() + -8 .unwrap() in sdk/auth.rs (Ratchet B), no change to panic! macros (Ratchet A). 3 restore_session tests still PASS on new HEAD. 4 untracked operator dirs noted (not committed by orchestrator).
@KooshaPari
KooshaPari deleted the fix/panic-budget-sdk branch November 27, 2026 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants