Skip to content

test(desktop): isolate Rewind owner snapshot authority - #12192

Merged
undivisible merged 1 commit into
BasedHardware:mainfrom
aryanorastar:codex/12039-rewind-owner-snapshot
Aug 27, 2026
Merged

test(desktop): isolate Rewind owner snapshot authority#12192
undivisible merged 1 commit into
BasedHardware:mainfrom
aryanorastar:codex/12039-rewind-owner-snapshot

Conversation

@aryanorastar

@aryanorastar aryanorastar commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

What changed and why

Addresses the Rewind/auth occurrence reported in #12039. The regression test changed auth_userId directly even though runtime owner authorization is process-wide and deliberately revokes out-of-band owner changes. That made the result depend on which owner-bound suite ran first and produced the observed anonymous versus auth-leading-… failure.

The test now recreates that revoked-authority state deliberately, then establishes and restores its owner through RuntimeOwnerAuthorityTestFixture. This follows the same serialized transition boundary as production and automatically places the suite in the runner's derived owner-isolation cluster.

Product invariants affected

none

How it was verified

  • xcrun swift test --package-path desktop/macos/Desktop --filter 'RewindCaptureExclusionGenerationTests' — 9/9 passed.
  • Repeated the exact contamination-recovery regression 50 times with --skip-build — 50/50 passed.
  • Ran the full 5,769-test macOS Swift process three times. The repaired test passed under real process-order contamination in every run; each full run retained one unrelated baseline failure elsewhere, consistent with Desktop Swift Static & Test Contracts: four different test suites flaked in one afternoon #12039's broader multi-suite report.

This is test-harness isolation only; there is no user-facing path or physical-device behavior to exercise.

Tests

RewindCaptureExclusionGenerationTests.testOwnerSnapshotStaysCurrentWhenAuthLeadsUnresolvedRewindDatabase now starts from the exact revoked authority that previously arrived nondeterministically, then proves the auth-leading owner remains current while RewindDatabase.currentUserId is unresolved.

Failure class (fixes)

Failure-Class: FC-hand-listed-test-isolation-membership

Review in cubic

Reproduce the revoked process-wide owner state, then establish and restore the test owner through RuntimeOwnerAuthorityTestFixture so suite order cannot turn authenticated capture into anonymous capture.

Verification: RewindCaptureExclusionGenerationTests 9/9 passed; deterministic contamination recovery passed 50/50 runs; the repaired test passed inside two 5,769-test process runs (each full run retained one unrelated baseline failure).

Failure-Class: FC-hand-listed-test-isolation-membership
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@Git-on-my-level

Copy link
Copy Markdown
Collaborator

Thanks @aryanorastar — verified end to end against the current authorization implementation; this is a clean fix for the #12039 flake signature.

What I checked in desktop/macos/Desktop/Tests/RewindCaptureExclusionGenerationTests.swift:

  • The rewrite matches production semantics: RuntimeOwnerAuthorizationAuthority fails closed on out-of-band auth_userId writes (revokeUnexpectedOwnerMismatch() in RuntimeOwnerIdentity.swift) and stays revoked until a real beginTransition/endTransition pair. So the old direct defaults.set(..., forKey: .authUserId) made the result depend on which owner-bound suite ran first — exactly the nondeterminism reported in Desktop Swift Static & Test Contracts: four different test suites flaked in one afternoon #12039.
  • Nice touch: the test now asserts the revoked precondition explicitly (XCTAssertNil(RuntimeOwnerIdentity.captureAuthorizationSnapshot()) right after the out-of-band write) instead of assuming it, turning an order-dependent flake into a deterministic reproduction.
  • Teardown via RuntimeOwnerAuthorityTestFixture.restore() is the right call — it re-enters through the production transition boundary, whereas raw defaults restoration would leave the process-wide authority revoked for subsequent suites (the exact cross-suite contamination the fixture was built to prevent).
  • Confirmed swift-test-suites.sh auto-derives the sequential owner-isolation cluster by grepping test files for RuntimeOwnerAuthorityTestFixture, so this suite is now serialized with the other owner-bound suites as the description states.
  • Desktop Swift Build & Tests, Static & Test Contracts, and Release Compile all pass on this head; the repeated-run verification in the description is appreciated.

Test-only change, no production behavior touched — leaving for human maintainer review before merge.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added positive-signal Good PR — positive signal, not a formal approval macOS labels Aug 25, 2026

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Test-isolation fix, low risk (test-file only, zero prod code touched), verified real and not already fixed. Bug-fix fast-lane heuristic scores 2/5 (below the 3/5 owner-override bar) and title doesn't match fix(desktop)/fix(macos)/fix(windows), so holding at approve rather than owner-override merge.

@aryanorastar

Copy link
Copy Markdown
Contributor Author

@undivisible this one is ready for a merge press — approved by @kodjima33, all checks green, no conflicts. It just needs someone to click, since the bug-fix fast lane scored it 2/5 (below the 3/5 owner-override bar) and held at approve.

On the title: test(desktop): doesn't match the fix(desktop)/fix(macos)/fix(windows) pattern the fast lane looks for, and I deliberately didn't rename it to slip through. test: is the accurate Conventional Commits type for correcting a test, and the 2/5 score would have held it anyway — so renaming would have been gaming the heuristic without even working.

Two others in the same neighbourhood while you're here, both green with zero conflicts:

PR What State
#12288 web/app/bun.lock is missing the prettier deps 64db30c791 added to package.json, so bun install --frozen-lockfile fails on main green — reproduces on a pristine main checkout; every PR touching web/app/src/** inherits a red Hygiene + Build until this lands
#12259 the same owner-authority flake as this PR, in FloatingBarNotificationPreviewPolicyTests — a suite #12039 doesn't name green, 0 reviews

#12288 is the one I'd take first: it's six lines, it's a break on main rather than in any branch, and it's currently reddening #12262 for reasons that have nothing to do with that PR.

#12259 is worth a glance as a pair with this one — same root cause (RuntimeOwnerIdentity.swift:51 revoking on an out-of-band auth_userId write), same fix shape, and I proved it rather than assumed: identical command, same three owner-bound suites, 1 failure before and 0 failures after. Both suites pass 19/19 in isolation either way, which is exactly why the flake looked nondeterministic.

No rush on any of them.

@undivisible

Copy link
Copy Markdown
Collaborator

@undivisible this one is ready for a merge press — approved by @kodjima33, all checks green, no conflicts. It just needs someone to click, since the bug-fix fast lane scored it 2/5 (below the 3/5 owner-override bar) and held at approve.

On the title: test(desktop): doesn't match the fix(desktop)/fix(macos)/fix(windows) pattern the fast lane looks for, and I deliberately didn't rename it to slip through. test: is the accurate Conventional Commits type for correcting a test, and the 2/5 score would have held it anyway — so renaming would have been gaming the heuristic without even working.

Two others in the same neighbourhood while you're here, both green with zero conflicts:

PR What State
#12288 web/app/bun.lock is missing the prettier deps 64db30c791 added to package.json, so bun install --frozen-lockfile fails on main green — reproduces on a pristine main checkout; every PR touching web/app/src/** inherits a red Hygiene + Build until this lands
#12259 the same owner-authority flake as this PR, in FloatingBarNotificationPreviewPolicyTests — a suite #12039 doesn't name green, 0 reviews

#12288 is the one I'd take first: it's six lines, it's a break on main rather than in any branch, and it's currently reddening #12262 for reasons that have nothing to do with that PR.

#12259 is worth a glance as a pair with this one — same root cause (RuntimeOwnerIdentity.swift:51 revoking on an out-of-band auth_userId write), same fix shape, and I proved it rather than assumed: identical command, same three owner-bound suites, 1 failure before and 0 failures after. Both suites pass 19/19 in isolation either way, which is exactly why the flake looked nondeterministic.

No rush on any of them.

"merge my shit like a good boy" ahh guy

ok i will also idc if you kinda name shit a bit different its obvious that you can write test its all good

@undivisible
undivisible merged commit 351ec09 into BasedHardware:main Aug 27, 2026
37 of 38 checks passed
@aryanorastar

aryanorastar commented Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

@undivisible this one is ready for a merge press — approved by @kodjima33, all checks green, no conflicts. It just needs someone to click, since the bug-fix fast lane scored it 2/5 (below the 3/5 owner-override bar) and held at approve.
On the title: test(desktop): doesn't match the fix(desktop)/fix(macos)/fix(windows) pattern the fast lane looks for, and I deliberately didn't rename it to slip through. test: is the accurate Conventional Commits type for correcting a test, and the 2/5 score would have held it anyway — so renaming would have been gaming the heuristic without even working.
Two others in the same neighbourhood while you're here, both green with zero conflicts:

PR
What
State

#12288
web/app/bun.lock is missing the prettier deps 64db30c791 added to package.json, so bun install --frozen-lockfile fails on main
green — reproduces on a pristine main checkout; every PR touching web/app/src/** inherits a red Hygiene + Build until this lands

#12259
the same owner-authority flake as this PR, in FloatingBarNotificationPreviewPolicyTests — a suite #12039 doesn't name
green, 0 reviews

#12288 is the one I'd take first: it's six lines, it's a break on main rather than in any branch, and it's currently reddening #12262 for reasons that have nothing to do with that PR.
#12259 is worth a glance as a pair with this one — same root cause (RuntimeOwnerIdentity.swift:51 revoking on an out-of-band auth_userId write), same fix shape, and I proved it rather than assumed: identical command, same three owner-bound suites, 1 failure before and 0 failures after. Both suites pass 19/19 in isolation either way, which is exactly why the flake looked nondeterministic.
No rush on any of them.

"merge my shit like a good boy" ahh guy

ok i will also idc if you kinda name shit a bit different its obvious that you can write test its all good

i was trying to reach you on discord wanna learn a lot from you my id is astar6969 @undivisible

kodjima33 pushed a commit that referenced this pull request Sep 3, 2026
…12650)

`SuggestedTasksStoreTests.testNotMineAndAlreadyHandledPersistReasonAndResolveCandidate`
is one of the flakes tracked in #12039. It failed in CI on an unrelated backend PR with:

    ("nil") is not equal to ("Optional(…TaskIntelligenceFeedbackReason.not_mine)")

The store resolves two owner authorities. `suppressionStore` was injected, but
`feedbackOutboxStore` was left on the default `SuggestedFeedbackOutboxDefaults`, whose
owner is process-global:

    fixedOwnerID ?? defaults.string(forKey: .authUserId) ?? "signed-out"

`dismiss` re-checks owner currency *after* awaiting the backend reject. Any other suite
in the same binary that writes `auth_userId` while that await is suspended flips the
owner, so `dismiss` returns early without recording feedback — the assertion above sees
an empty `api.feedback`. 34 other test files touch that key, which is why the failure
tracks suite order rather than anything in this suite.

27 of the 37 store constructions in this file were half-isolated this way; the other 10
already injected a `MemoryFeedbackOutboxStore` because they assert on outbox contents.
All 37 now pin both owners to the suite, which is the same repair #12192 and #12259 made
for the Rewind and FloatingBar owner authorities.

`testDismissSurvivesAGlobalAuthOwnerFlipAtTheAwaitedRejectPoint` pins the contract. It
drives the flip through the existing `onReject` hook — the exact suspension point — so
the hazard is deterministic rather than order-dependent.

Verification: 40/40 in this suite; 99/99 with the owner and auth suites that write
`auth_userId` in one process. Mutation-checked: dropping the `feedbackOutboxStore`
injection from the new test reproduces CI's failure byte for byte,
`("nil") is not equal to ("Optional(Omi_Computer.OmiAPI.TaskIntelligenceFeedbackReason.not_mine)")`,
and restoring it returns green.

This is one leg of #12039. `KernelTurnRecordedProjectionTests` remains open; the chat
gesture, Rewind owner, and FloatingBar owner legs landed in #12406, #12192 and #12259.

Failure-Class: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

macOS positive-signal Good PR — positive signal, not a formal approval

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants