Skip to content

feat: capture LiquidCortex runtime exceptions in Sentry - #32

Merged
rmems merged 4 commits into
mainfrom
feature/issue-18-sentry-runtime
Jul 13, 2026
Merged

feat: capture LiquidCortex runtime exceptions in Sentry#32
rmems merged 4 commits into
mainfrom
feature/issue-18-sentry-runtime

Conversation

@rmems

@rmems rmems commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Adds guarded runtime exception capture for LiquidCortex hot paths and enriches Sentry initialization metadata.\n\nCloses #18


Note

Low Risk
Observability-only wrappers around existing hot paths; capture is best-effort and bounded so failures still propagate unchanged.

Overview
Adds runtime exception reporting for GPU simulation entry points when SENTRY_DSN is set, without changing simulation logic.

Sentry init now sets a release from package version and tags version / julia_version, and tracks success in _sentry_enabled[].

New _capture_runtime_exception accepts any thrown value (@nospecialize), runs Sentry.capture_exception in @async, and only timedwaits ~50ms so a full Sentry queue cannot block rethrow() on the hot path.

step! and ensemble_step! delegate to _step_impl! / _ensemble_step_impl!; the public APIs try/catch, capture, then rethrow. Ensemble stepping calls _step_impl! per lobe so inner failures are not double-reported.

Reviewed by Cursor Bugbot for commit 0c1f053. Configure here.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 48 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fcd858a1-b10f-4337-a10e-150ed430f239

📥 Commits

Reviewing files that changed from the base of the PR and between 6f09b29 and b103856.

📒 Files selected for processing (2)
  • src/LiquidCortex.jl
  • src/sparse_brain.jl

Comment @coderabbitai help to get the list of available commands.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@amazon-q-developer amazon-q-developer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review Summary

This PR successfully implements Sentry runtime exception capture for LiquidCortex with proper error handling and metadata enrichment. The changes are well-structured and maintain backward compatibility.

Key Changes:

  • Added _sentry_enabled flag with guarded initialization
  • Enhanced Sentry initialization with release version, package, and Julia version tags
  • Implemented _capture_runtime_exception helper with nested error handling to prevent Sentry failures from affecting core functionality
  • Refactored step! and ensemble_step! functions to separate implementation from exception capture, maintaining clean separation of concerns

Technical Review:

  • Error handling is comprehensive with proper guards to prevent Sentry initialization failures from blocking module load
  • The refactoring pattern (separating _step_impl! from step! wrapper) maintains the same logic while adding observability
  • Function scoping is correct - _capture_runtime_exception is accessible to included files through module scope
  • Environment variable handling for SENTRY_DSN follows security best practices

Merge Status: ✓ Approved - No blocking issues identified


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request integrates Sentry error tracking into the simulation steps (step! and ensemble_step!) of LiquidCortex.jl. It wraps the core step implementations in try-catch blocks to capture and report runtime exceptions before rethrowing them. The review feedback points out a potential issue in the exception-capturing helper: restricting the exception argument to the Exception type can cause a MethodError if a non-Exception object is thrown in Julia, which would mask the original error. It is recommended to remove this type constraint.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/LiquidCortex.jl Outdated
@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 8.69565% with 21 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/LiquidCortex.jl 11.76% 15 Missing ⚠️
src/sparse_brain.jl 0.00% 6 Missing ⚠️

📢 Thoughts on this report? Let us know!

Comment thread src/LiquidCortex.jl Outdated
Comment thread src/LiquidCortex.jl Outdated
…rsion

Accept any thrown value in _capture_runtime_exception and fall back to
'unknown' when Base.pkgversion returns nothing.
@rmems rmems self-assigned this Jul 9, 2026
@rmems
rmems marked this pull request as ready for review July 9, 2026 19:17

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6c11a346db

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/LiquidCortex.jl Outdated
@linear-code

linear-code Bot commented Jul 9, 2026

Copy link
Copy Markdown

LIM-250

Comment thread src/sparse_brain.jl
Comment thread src/sparse_brain.jl
@kilo-code-bot

kilo-code-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Incremental Review (since 6c11a34)

Previous Issues Resolved

  • src/sparse_brain.jl:304step! docstring restored to public wrapper
  • src/sparse_brain.jl:476ensemble_step! docstring restored to public wrapper
  • src/LiquidCortex.jl:79timedwait pollint=0.005 applied for early return

Changed Files Reviewed (2 files, 78 lines)

  • src/LiquidCortex.jl — 0 new issues (@async + timedwait(pollint=0.005) non-blocking capture pattern is sound; inner/outer try/catch guards Sentry and scheduling failures; @nospecialize handles non-Exception throws)
  • src/sparse_brain.jl — 0 new issues (docstrings correctly moved back to public API wrappers; _step_impl!/_ensemble_step_impl! internal comments updated; ensemble loop correctly calls _step_impl! to avoid double-capture)
Existing External Findings (not duplicated)
  • gitar-bot: LiquidCortex.jl:79timedwait default pollint=0.1 exceeds the 0.05s timeout → fixed in b103856
  • codex-connector: LiquidCortex.jl:79 — drop timed-out Sentry capture tasks → acknowledged as intentional by design
Prior Review Note

Test coverage for exception capture paths (_capture_runtime_exception, try/catch wrappers, _sentry_enabled gating) remains untested. This finding is scoped to test/runtests.jl which was not changed in this incremental diff.

Previous Review Summary (commit 6c11a34)

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

Previous review (commit 6c11a34)

Status: No Issues Found | Recommendation: Merge

Incremental Review (since 6c11a34)

Previous Issues Resolved

  • src/sparse_brain.jl:304step! docstring restored to public wrapper
  • src/sparse_brain.jl:476ensemble_step! docstring restored to public wrapper
  • src/LiquidCortex.jl:79timedwait pollint=0.005 applied for early return

Changed Files Reviewed (2 files, 72 lines)

  • src/LiquidCortex.jl — 0 new issues (@async + timedwait(pollint=0.005) non-blocking capture pattern is sound; inner/outer try/catch guards Sentry and scheduling failures)
  • src/sparse_brain.jl — 0 new issues (docstrings correctly moved back to public API; internal comments updated)
Existing External Findings (not duplicated)
  • gitar-bot: LiquidCortex.jl:79timedwait default pollint=0.1 exceeds the 0.05s timeout → fixed in b103856
Prior Review Note

Test coverage for exception capture paths (_capture_runtime_exception, try/catch wrappers, _sentry_enabled gating) remains untested. This finding is scoped to test/runtests.jl which was not changed in this incremental diff.


Reviewed by mimo-v2.5-pro · Input: 39.4K · Output: 5.1K · Cached: 239.1K

Review guidance: REVIEW.md from base branch main

Schedule runtime exception capture asynchronously with a short timedwait
so a full Sentry.jl Channel cannot hang rethrow on step!/ensemble_step!.
Move step! and ensemble_step! docstrings back onto the public wrappers.
Comment thread src/LiquidCortex.jl Outdated
gitar-bot[bot]
gitar-bot Bot previously approved these changes Jul 10, 2026

@gitar-bot gitar-bot Bot 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.

Gitar has auto-approved this PR (configure)

@gitar-bot gitar-bot Bot added the gitar-approved Added by Gitar label Jul 10, 2026

rmems commented Jul 11, 2026

Copy link
Copy Markdown
Owner Author

@kilo-code-bot run review again

- Add pollint=0.005 to timedwait so task-done check fires before 0.05s timeout
- Allows early return when capture_exception completes quickly
- Addresses Gitar performance review

@gitar-bot gitar-bot Bot 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.

Gitar has auto-approved this PR (configure)

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b103856729

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/LiquidCortex.jl
@rmems
rmems merged commit 5a1d2f2 into main Jul 13, 2026
11 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Julia stack Jul 13, 2026
@gitar-bot

gitar-bot Bot commented Jul 13, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 3 resolved / 3 findings

Implements asynchronous Sentry runtime exception capture for LiquidCortex hot paths. The implementation addresses potential error masking for non-Exception throws, missing package version tags, and timing inconsistencies in the capture mechanism.

Auto-approved: No blocking issues found.
Please see Auto-approve Docs for details on setting custom approval criteria.

✅ 3 resolved
Edge Case: _capture_runtime_exception can mask original error for non-Exception throws

📄 src/LiquidCortex.jl:59-67 📄 src/sparse_brain.jl:301-310 📄 src/sparse_brain.jl:470-483
_capture_runtime_exception(exc::Exception, bt) restricts its first argument to <:Exception, but the catch exc blocks in step! and ensemble_step! bind whatever value was thrown. Julia permits throwing arbitrary (non-Exception) values, and some lower-level/CUDA paths may surface such objects. If a non-Exception is thrown, the call _capture_runtime_exception(exc, catch_backtrace()) raises a MethodError inside the catch block, which propagates instead of the original error, and the intended rethrow() never executes — masking the true failure in exactly the reliability path this feature is meant to harden.

Suggested fix: widen the parameter type to Any (or @nospecialize exc) so capture is best-effort and never itself throws a dispatch error. The internal try/catch around Sentry.capture_exception already guards Sentry failures.

Quality: pkgversion may be nothing, yielding release tag 'LiquidCortex.jl@nothing'

📄 src/LiquidCortex.jl:46-49
Base.pkgversion(@__MODULE__) returns nothing when the package version cannot be determined (e.g. loaded outside a proper package context / dev environment). string(nothing) produces the literal "nothing", so the Sentry release becomes LiquidCortex.jl@nothing and the version tag is set to "nothing". This degrades release-tracking/grouping in Sentry. Consider guarding with a fallback.

Performance: timedwait pollint default (0.1s) exceeds the 0.05s timeout

📄 src/LiquidCortex.jl:78-79
timedwait(() -> istaskdone(t), 0.05) uses the default pollint=0.1. Julia's timedwait only evaluates the test callback inside its timer callback, which first fires after one pollint interval (0.1s). Since the timeout (0.05s) is only checked inside that callback, the condition is never checked before 0.1s has elapsed. Consequences:

  1. The call blocks ~0.1s (100ms), not the ~50ms stated in the comment/PR description.
  2. It never returns early even when the capture task finishes almost immediately — every captured exception pays the full wait.

This undercuts the stated goal of a short, best-effort window that short-circuits once capture_exception completes. Because this only runs on the exception/rethrow path it is not a throughput hot path, hence minor, but the observed behavior does not match the intended design.

Fix by setting a poll interval smaller than the timeout so the task-done check can fire early.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@rmems
rmems deleted the feature/issue-18-sentry-runtime branch July 13, 2026 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant