← Back to Pull requests

Fix two flaky tests: Jev prefetch timeout reporting and ACP gateway port collisions #276

Open
unknown opened this pull request with 457 lines diff across 5 files
View on GitHub
unknown unknown commented on Oct 03, 2026 17:31 UTC
Author

Summary

Two tests failed intermittently under full-suite load and passed when run alone. Both causes are fixed; one was also a real telemetry bug.

Jev prefetch: a deadline hit during collection was reported as no-candidates

buildJevPrefetch gives candidate collection and the provider call one shared deadline. Source reads swallow aborts, so when the deadline lapsed mid-collection the pool came back empty and the run was logged as no-candidates instead of timeout. The fail-open test's 50 ms budget could expire during collection under load, so it flaked.

  • src/shared/jev-prefetch.ts: check the deadline before concluding the pool is empty. Both orderings now report timeout.

  • test/jev-prefetch.test.ts: a zero-budget case pins the collection-time path deterministically. It failed 3/3 before the fix and passes 5/5 after.
  • ACP remote test: a taken port became a silent 15 s timeout

    The test started the gateway on a random port and waited 15 s for its listening line. The gateway starts in about 0.1 s, but exits on EADDRINUSE, and the test neither noticed the exit nor kept its stderr.

  • test/acp-remote.test.ts: startup retries on a fresh port when the gateway exits before listening (up to 3 attempts), kills it on timeout, and includes its stderr in any failure. With the first port deliberately occupied, the test now passes in about 0.7 s instead of timing out.
  • Review-quality gate

    Neither file is a trigger path, and model inputs are unchanged; no benchmark run.

    Validation

    npm run lint, npm run typecheck (only the pre-existing @cline/sdk resolution errors), npm test (1163 pass, 0 fail), npm run build.

    <!-- This is an auto-generated description by cubic. -->
    ---

    Summary by cubic


    Fixes two flaky tests and a real telemetry bug behind one of them: Jev prefetch deadline hits during candidate collection were logged as no-candidates instead of timeout, and the ACP remote test silently timed out when its randomly chosen port was taken.

  • Jev prefetch: the deadline is now checked before concluding the candidate pool is empty, so both timeout orderings report timeout; a zero-budget test case pins the collection-time path and asserts no provider call was made.

  • ACP remote test: gateway startup retries on a port that wasn't previously tried when the gateway exits before listening (up to 3 attempts), waits for the close event so stderr drains, kills the gateway on timeout, and includes stderr from every failed attempt in failure output.
  • <sup>Written for commit 1ae0e8bcaa9007f72ee9c3fea445b8abfb6307cb. Summary will update on new commits.</sup>

    <a href="https://cubic.dev/pr/pgup-ai/jbot-review/pull/276?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>

    <!-- End of auto-generated description by cubic. -->

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    Summary by CodeRabbit

    Bug Fixes
    Improved timeout handling during context preparation. When a request’s deadline expires while candidates are being collected, it now returns the baseline context and is reported as a timeout instead of appearing to have no candidates. This makes timeout outcomes more accurate and consistent.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 457 lines (+342 / -115) across 5 files Reviewer: github-actions[bot] Review duration: 16m
    All Vouch review confidence checks passed
    Residual risk 0.24 = Change Risk (0.46) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.46 · 457 lines diff across 5 files
    0.46
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.367
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #276"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.5% (MEDIUM) · Higher = larger blast radius
    45.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 24.3% · Safe to merge
    24.3%