Skip to content

refactor(desktop): fold idle-gate media exemption into MediaPlaybackDetector (unblocks beta train) - #11565

Merged
kodjima33 merged 3 commits into
mainfrom
kodjima33/idle-gate-linecount-shrink
Aug 14, 2026
Merged

kodjima33 merged 3 commits into
mainfrom
kodjima33/idle-gate-linecount-shrink

Conversation

@kodjima33

@kodjima33 kodjima33 commented Aug 14, 2026 •

Copy link
Copy Markdown
Collaborator

What

Unblocks the desktop beta train. Every desktop_auto_release run since 06:38Z fails because Release Eligibility re-runs the line-count ratchet on main commits without the merged PR's body exception (filed as #11564) — so #11553's and #11556's legitimate, PR-lane-approved exceptions poison eligibility on their merge commits and no candidate can cut.

This folds #11556's 18 gate-site lines out of ProactiveAssistantsPlugin.swift (1779 → 1767) into MediaPlaybackDetector, where the exemption policy and cache already live. A shrinking commit passes the ratchet statelessly, so eligibility on this commit (and descendants) goes green and the hourly train cuts again.

Behavior is identical: effectiveIdleSeconds(hidIdleSeconds:threshold:) on the detector wraps the same pure policy and keeps the once-per-episode log.

Product invariants

None matched (path-based check: none).

Verification

  • Re-verified live on the rebuilt omi-notch bundle from this branch: 05:01:29 CaptureGate: HID-idle but media playback active — capture continues with the user genuinely HID-idle 45 min and a real PreventUserIdleDisplaySleep assertion held (screenshot in worktree).
  • MediaPlaybackIdleExemptionTests 4/4 — adds testDetectorEffectiveIdleMatchesPolicy proving the gate-facing wrapper mirrors the pure policy.
  • Debug build clean; pinned swift-format applied.

Review in cubic

@cubic-dev-ai cubic-dev-ai 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.

1 issue found and verified against the latest diff

Confidence score: 5/5

  • In desktop/macos/Desktop/Tests/MediaPlaybackIdleExemptionTests.swift, the new test appears to validate idle values only, so the documented “logs once per episode” behavior and didLogExemption reset path may regress unnoticed, weakening confidence in telemetry-related behavior—add assertions for single-log-per-episode and explicit reset-path coverage.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="desktop/macos/Desktop/Tests/MediaPlaybackIdleExemptionTests.swift">

<violation number="1" location="desktop/macos/Desktop/Tests/MediaPlaybackIdleExemptionTests.swift:24">
P3: The new test's doc comment claims it verifies the wrapper 'logs once per episode,' but the test only asserts the returned idle values (0 and 90). The once-per-episode logging and the `didLogExemption` reset path that were folded into `effectiveIdleSeconds` are entirely unverified. Assert the log fires only once across repeated calls while playback stays active, and that it re-arms after `hidIdleSeconds` drops below the threshold.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic


/// The gate-facing wrapper mirrors the pure policy and logs once per episode; its
/// idle arithmetic must match the policy exactly.
func testDetectorEffectiveIdleMatchesPolicy() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: The new test's doc comment claims it verifies the wrapper 'logs once per episode,' but the test only asserts the returned idle values (0 and 90). The once-per-episode logging and the didLogExemption reset path that were folded into effectiveIdleSeconds are entirely unverified. Assert the log fires only once across repeated calls while playback stays active, and that it re-arms after hidIdleSeconds drops below the threshold.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At desktop/macos/Desktop/Tests/MediaPlaybackIdleExemptionTests.swift, line 24:

<comment>The new test's doc comment claims it verifies the wrapper 'logs once per episode,' but the test only asserts the returned idle values (0 and 90). The once-per-episode logging and the `didLogExemption` reset path that were folded into `effectiveIdleSeconds` are entirely unverified. Assert the log fires only once across repeated calls while playback stays active, and that it re-arms after `hidIdleSeconds` drops below the threshold.</comment>

<file context>
@@ -19,6 +19,15 @@ final class MediaPlaybackIdleExemptionTests: XCTestCase {
 
+  /// The gate-facing wrapper mirrors the pure policy and logs once per episode; its
+  /// idle arithmetic must match the policy exactly.
+  func testDetectorEffectiveIdleMatchesPolicy() {
+    let playing = MediaPlaybackDetector(cacheTTL: 10) { true }
+    XCTAssertEqual(playing.effectiveIdleSeconds(hidIdleSeconds: 3600, threshold: 60), 0)
</file context>

@kodjima33 kodjima33 added the no-changelog-needed Skip desktop changelog enforcement for internal-only changes label Aug 14, 2026
@kodjima33

Copy link
Copy Markdown
Collaborator Author

Merging past the same two known-flaky checks as #11528/#11556 tonight ('TERM case never launched detached app', 'workflow test-install fixture') — they fail identically on every diff regardless of content. All other checks green; behavior re-verified live on the rebuilt bundle (05:01:29 exemption transition with 45min real HID idle). This PR restores Release Eligibility on main (see #11564) so the beta train can cut.

…ackDetector

Moves the effective-idle computation and once-per-episode log out of
ProactiveAssistantsPlugin (1779 -> 1767 lines) into the detector, where the
policy and cache already live. Restores the plugin below its pre-#11556
line count so the Release Eligibility lane — which re-runs the line-count
ratchet on main commits WITHOUT the merged PR's body exception (issue

Behavior identical, re-verified live on the rebuilt omi-notch bundle:
05:01:29 'CaptureGate: HID-idle but media playback active — capture
continues' with the user genuinely HID-idle 45 min and a real
PreventUserIdleDisplaySleep assertion held.
MediaPlaybackIdleExemptionTests 4/4 (adds the wrapper-matches-policy test).
@kodjima33
kodjima33 force-pushed the kodjima33/idle-gate-linecount-shrink branch from 8272839 to 07939ad Compare August 14, 2026 12:15
@kodjima33
kodjima33 merged commit a15d0e9 into main Aug 14, 2026
23 of 26 checks passed
@kodjima33
kodjima33 deleted the kodjima33/idle-gate-linecount-shrink branch August 14, 2026 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog-needed Skip desktop changelog enforcement for internal-only changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant