feat(session): trace lifecycle close provenance#794
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (9)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Code Review
This pull request introduces a lifecycle provenance tracking system to categorize session interruptions, such as instance reloads or disposals. It adds a new lifecycle-provenance utility, updates the Runner and SessionRunState to propagate lifecycle metadata, and enhances the observability recorder to include these details in session summaries. Feedback identifies a potential race condition in the withLifecycleCloseAction utility due to the use of a global map with asynchronous operations, suggesting FiberRef as a safer alternative. Additionally, there is a concern regarding the use of a static Instance.directory reference in the session processor, which may not behave correctly in multi-instance environments.
Add the first #808 RunIncident diagnostic/export layer so provider transport disconnects, partial tool input interruptions, cleanup/finalizer evidence, and materialized-but-not-executed tool boundaries are derived from ordered append-only evidence instead of mutable summary overwrites. This keeps the PR diagnostic-only: it adds structured sanitized run_incidents export while preserving legacy classification, summary_key, and retry_safety compatibility, without adding recovery UI, retry behavior, or provider SDK changes. Verification: - bun test test/session/run-observability.test.ts test/session/export.test.ts --timeout 30000 — passed - bun run typecheck — passed - git diff --check — passed - PR CI for #812 — all checks passed Review follow-ups: - Preserved newest terminal/cleanup anchors when bounded evidence exceeds the export cap. - Aligned stream phase derivation with provider progress and terminal cause. - Resolved all Gemini and CodeRabbit review threads. Related: #808, #803, #788, #794
Summary
Adds lifecycle close provenance to run observability diagnostics. Instance reload/dispose paths now create bounded lifecycle action IDs, propagate them through run-state interrupts, and classify known local lifecycle closes separately from unknown scope closes.
Why
PR #788 added the run-level diagnostic spine for #783, but local scope-close failures still stopped at
unknown_scope_closewhen the parent instance lifecycle action was missing. This PR makes exports answer whether an in-flight run was interrupted byInstanceStore.reload,dispose,disposeDirectory, ordisposeAllwithout changing retry behavior or user-facing copy.Related Issue
Part of #783. This does not close #783's related follow-up space, and it does not close #721 or #755.
Human Review Status
Pending
Review Focus
disposeAllfan-out correctly shares one parent action across affected in-flight runs.Risk Notes
How To Verify
Screenshots or Recordings
Not applicable — no visible UI changes.
Checklist
bug,enhancement,task,documentation. Type labels are author-added; the labeler bot does NOT assign them. Add the label in the GitHub UI, then tick this.app,ui,platform,harness,ci. The labeler bot assigns these on PR open based on changed paths. Confirm the bot's choice (or override if wrong), then tick this.P0,P1,P2,P3. The priority-triage bot suggests one on PR open. Confirm or override, then tick this.Pending,Approved by @<reviewer>, orNot required: <reason>(default isPending; "not required" is restricted to bot-authored low-risk PRs).dev, and my PR title and commit messages use Conventional Commits in English.