Skip to content

Sessions review remediation: coverage, API hardening, docs, and structure#2

Draft
DevAM-Tools wants to merge 3 commits into
mainfrom
cursor/session-review-remediation-20ab
Draft

Sessions review remediation: coverage, API hardening, docs, and structure#2
DevAM-Tools wants to merge 3 commits into
mainfrom
cursor/session-review-remediation-20ab

Conversation

@DevAM-Tools

@DevAM-Tools DevAM-Tools commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Summary

Implements the remaining Sessions review findings on top of ownership validation for TryUnsubscribe and TryRemoveJob.

Production (NetworkInspector.Sessions)

  • Ownership: TryUnsubscribe / TryRemoveJob reject foreign or already-removed jobs via _ContainsJob
  • Parse path: _TryParseFrameUnderLock for non-throwing reparse in TryGetPacket
  • Source loop: record PacketToFrameMap before PacketStore.Store so mapping capacity failures surface correctly
  • Analyzer hygiene: initialize SpinLock in constructor; extract _RegisterListenerSlot; remove CA2213/CA2000 pragmas
  • ID overflow: AllocateJobId / AllocateListenerId throw InvalidOperationException at int.MaxValue
  • Allocations: _SourceInfos as SnapshotList<FrameSourceInfo>; GetFrameSources() returns CurrentSnapshot
  • Documentation: listener wait loop, TryAddListener during Restarting, Shutdown timeout behavior, listener notification cost, ThreadWaitHelper usage
  • Structure: #region blocks in Job and ListenerSlot

Tests (NetworkInspector.Sessions.Tests)

  • Shared WaitHelper replaces duplicated _WaitForCondition helpers
  • ExitPointCoverageTests: reparse mismatch, mapping capacity exceeded, non-indexed parse path, listener ID overflow
  • Ownership tests for TryUnsubscribe / TryRemoveJob
  • NotifyFlagsTests: JobRemoved and StackChanged bit-distinctness
  • AllocateJobId_AtCapacity_ThrowsInvalidOperationException

Verification

  • Release build: 0 warnings
  • Tests: 94/94 passed
  • ExitPointGaps (NetworkInspector.Sessions): exitGapCount == 0, gatePassed: true

Note on PR #1

This branch includes the ownership fixes from cursor/fix-tryunsubscribe-tryremovejob-ownership-20ab. Consider closing PR #1 in favor of this consolidated PR.

Open in Web Open in Cursor 

cursoragent and others added 3 commits July 11, 2026 17:55
TryUnsubscribe now returns false when a JobInfo is not registered in the
session job list before treating it as a user job. TryRemoveJob returns
false when the job is not found instead of always reporting success.

Adds regression tests for foreign and already-removed jobs. Stabilizes
TryUnsubscribe_UserJob_CancelsJob by keeping the session in Running phase.

Co-authored-by: DevAM <DevAM-Tools@users.noreply.github.com>
…parse helpers

- Document event-gated ManualResetEventSlim listener wait loop in class XML
- Initialize SpinLock in constructor; remove CA2213 pragma
- Add _SourceInfos SnapshotList; GetFrameSources returns CurrentSnapshot without copy
- Extract _RegisterListenerSlot for listener registration without CA2000 pragma
- Add _TryParseFrameUnderLock for non-throwing reparse in TryGetPacket
- Record PacketToFrameMap before PacketStore in source loop
- Preserve ownership validation (_ContainsJob, TryRemoveJob, TryUnsubscribe)

Co-authored-by: DevAM <DevAM-Tools@users.noreply.github.com>
- Validate TryUnsubscribe and TryRemoveJob ownership (prior commit)
- Add Try-parse reparse path and record mapping before store
- Remove analyzer suppressions; initialize SpinLock in constructor
- Guard job and listener ID generators against overflow
- Use SnapshotList for GetFrameSources without per-call allocation
- Update ISession and Session XML documentation
- Add #region structure to Job and ListenerSlot
- Consolidate test wait helpers; add exit-point coverage tests
- Document listener notification cost and ThreadWaitHelper usage

Co-authored-by: DevAM <DevAM-Tools@users.noreply.github.com>
@cursor cursor Bot force-pushed the cursor/session-review-remediation-20ab branch from 37bccab to 8ccdec8 Compare July 11, 2026 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants