Repository navigation
chore(ratchet): tighten panic baseline from 140 to 62 after the refactor - #73
KooshaPari wants to merge 9 commits into
Conversation
Bring crates/jcode-telemetry-core/src/lib.rs back under its tracked baseline count and drive concurrency.rs to 0, tightening the panic-prone ratchet with no baseline change. lib.rs: 5 -> 1 (remaining is #[cfg(test)] unwrap, below baseline of 2) concurrency.rs: 2 -> 0 Total gate: 140 -> 126 Changes: - TELEMETRY_HTTP_CLIENT: OnceLock<Client> -> OnceLock<Option<Client>>, HTTP client build failure logs warning and returns false instead of panicking - background_sender() and transcript_background_sender() return Option<&SyncSender> instead of panicking on thread spawn failure - Callers handle None with warning logs and graceful false returns - concurrency.rs: replace .unwrap() on file_name() with match and and_then+unwrap_or for safe fallback tx-agent: jcode tx-task: panic-budget-ratchet tx-validated: cargo-check tx-scope: crates/jcode-telemetry-core/src/lib.rs, crates/jcode-telemetry-core/src/concurrency.rs tx-intent: restore telemetry-core panic counts to or below tracked baseline
Replace all 8 panic-prone call sites in the fake ACP test fixture
binary with proper io::Result error propagation. The binary is a
[[bin]] in jcode-provider-grok-build-runtime used by integration
tests as a subprocess ACP peer.
fake_acp.rs: 8 -> 0
Total gate: 126 (continues improvement from telemetry commit)
Changes:
- main() returns io::Result<()> instead of ()
- append_log(), send(), response() all return io::Result<()>
- All .expect() calls replaced with ? operator
- panic!("unexpected ACP method") replaced with eprintln + Err return
- append_log failure is non-fatal (let _ =) since logging should not
block the JSON-RPC response loop
Judgement: this is a test fixture binary (used via CARGO_BIN_EXE by
integration tests), but it is a published [[bin]] with no feature gate.
Converting to Result is preferred over leaving panics — a subprocess
that exits with an error code is more debuggable than one that panics.
tx-agent: jcode
tx-task: panic-budget-ratchet
tx-validated: cargo-check
tx-scope: crates/jcode-provider-grok-build-runtime/src/bin/fake_acp.rs
tx-intent: convert fake_acp test binary from panics to Result error propagation
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
… modules Replace 32 unwrap/expect occurrences across app-core, base, cache-vectors, command-risk, herdr, provider-openai, provider-openrouter-runtime, render-core, tool-search, tui and the cli entry points with typed error propagation or a documented fallback. The panic-prone ratchet treats this as an improvement (140 -> 108) with no baseline change. Two fallbacks are deliberate rather than silent: cache_hash falls back to the empty-document djb2 value so a serialization failure cannot crash a cache lookup, and the poisoned-lock arms recover the inner value rather than propagating the poison. tx-agent: jcode tx-task: panic-budget-ratchet tx-validated: cargo-check tx-scope: crates/jcode-app-core, crates/jcode-base, crates/jcode-cache-vectors, crates/jcode-command-risk, crates/jcode-herdr, crates/jcode-provider-openai, crates/jcode-provider-openrouter-runtime, crates/jcode-render-core, crates/jcode-tool-search, crates/jcode-tui/src/tui/ui_inline_interactive.rs, src/cli tx-intent: drive panic-prone count in small production modules from 32 to 0 without moving the ratchet baseline
The previous panic-budget commit converted a poisoned Mutex::lock into a match with two recovery arms, but the Err arm bound the recovered guard as 'mut' even though 'into_inner' does not need a mutable binding. Drop the unneeded 'mut' to keep the crate warning-free after the panic-budget refactor. tx-agent: jcode tx-task: panic-budget-ratchet tx-validated: cargo-check tx-scope: crates/jcode-app-core/src/tool/bash.rs tx-intent: silence 'variable does not need to be mutable' warning left by the poison-recovery edit
The panic-prone refactor removed 78 occurrences, but the baseline stayed at 140, leaving the ratchet toothless: 78 new panics could land before CI complained. This lowers the baseline to the achieved count so the gate regains its regression-prevention value. This is the ratchet-tightening step after real cleanup, matching the existing pattern in 29c85cb and 660d915. It is not the anti-pattern of raising the baseline to absorb new panics. Verified the gate bites: adding a single .unwrap() to crates/jcode-render-core/src/reasoning.rs now fails with "total panic-prone count grew: 62 -> 63" and "new production panic-prone usage: crates/jcode-render-core/src/reasoning.rs (1)". Merged state: total=62, tracked files 46 -> 20. tx-agent: jcode tx-task: panic-budget-ratchet tx-validated: manual tx-scope: scripts/panic_budget.json tx-intent: restore the panic ratchet's regression-prevention value after the cleanup landed
🤖 CodeAnt AI — Review Status
|
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
Warning Review limit reachedYou'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 49 minutes. View limit details
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. Comment |
| if let Some((text, _)) = notice.as_ref() { | ||
| lines.push(Line::from(Span::styled(text.clone(), dim))); |
There was a problem hiding this comment.
Suggestion: When too few rows remain, notice_rows is zero but this still appends the notice, making lines.len() exceed the available height and underflowing the caller's popover row.
Assessment: 🟠 Major · 🔁 Occurrence: Rarely · 🏷️ Logic error
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** crates/jcode-tui/src/tui/ui_inline_interactive.rs
**Line:** 442:443
**Comment:**
*Logic Error: When too few rows remain, `notice_rows` is zero but this still appends the notice, making `lines.len()` exceed the available height and underflowing the caller's popover row.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
CodeAnt Nitpicks1 code suggestion1. If another flow operation panicked while holding
|
CodeAnt PR Risk: Medium Risk
Assessed commit: |
|
Superseded. Rebuilt cleanly on top of the now-merged refactor PRs (#69, #70, #71), so the replacement branch contains only the ratchet change. Merging this branch as-is would revert the already-merged picker fix and duplicate the refactors. Replacement branch: |
Code Review SummaryThis review did not finish. The model reached its output limit before it |
…one) Subagent session_daisy_1792220259698_483f4ca0aa2846ee (Tier 1 M3, read-only) scanned 109 PRs on KooshaPari/Jcode. Result: PRs #64, #67, #75 are the SAME 3 §22-pattern PRs on BOTH the Jcode and KCode forks — identical SHAs (4d676f0, fed2378, a1e9530), identical parents, identical tx-intent trailers. This is because the forks share pre-2026-10-08 history; the squash-merge commits predate the brand split. The §22 finding is therefore NOT fork-specific — it generalizes to any KooshaPari/ fork with shared pre-2026-10-08 history. 16 other CLOSED+mergedAt=null PRs returned 0 commits from 'git log origin/master --grep="(#N)"'. Several are likely superseded by merged siblings: #94→#96, #73→#74, #62→#75. 11 appear genuinely abandoned. 22-NEW-FINDING-gh-pr-view-closed-vs-merged.md extended with a 'Cross-fork audit (2026-10-17T07:00Z)' section containing: - The 3-PR SHA-equivalence table - The 16 superseded/abandoned table - Operator follow-up note (apply same body-scrub to Jcode fork PRs if a consistent record is desired; out of scope for this audit) STATE.md §4 row U updated: IN FLIGHT -> DONE — 3 MATCHES. tx-agent: jcode tx-validated: manual tx-task: jcode-fork-22-audit tx-scope: docs/sessions/2026-10-15-portal-xirp-resume/{22-NEW-FINDING,STATE.md} tx-parent: 92d6609 tx-intent: Land the Jcode-fork §22 audit so PR 103 carries the cross-fork generalization, not just the KCode single-fork evidence
User description
Summary
Lowers the panic-prone baseline from 140 to 62 now that the refactor has landed, so the ratchet regains its regression-prevention value.
Why this is a separate PR
The refactor PRs (#69, #70, #71) remove 78 occurrences. That is a genuine improvement, but the ratchet gate treats a decrease as a pass without tightening the baseline — so with the baseline left at 140, 78 new panics could land before CI complains. The code would be cleaner while the gate stayed toothless.
This PR closes that gap. It depends on #69, #70 and #71 and should merge after them.
Not the anti-pattern
Raising a baseline to absorb new panics is the anti-pattern, and this is the opposite: the count only moves down, and only to a number that the merged code actually achieves.
This matches the repo's existing ratchet-tightening commits:
29c85cbdfand660d9152c.Effect
Verification that the gate bites again
Adding a single
.unwrap()tocrates/jcode-render-core/src/reasoning.rs:With that probe reverted, the gate reports
Panic-prone budget OK: total=62 files=20and exits 0.Ledger
Refs #69, #70, #71.
CodeAnt-AI Description
Reduce crashes on exceptional failures and prevent panic-related regressions
What Changed
Impact
✅ Fewer crashes when telemetry setup fails✅ Clearer login and SSH failure handling✅ CI blocks regressions above 62 panic-prone calls💡 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:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
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:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
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.