fix(next): retain Dock policy source through KVO teardown

Merged
TE
7d ago
+60-4

Starting notification observation could release NSRunningApplication.current while its activationPolicy KVO observer was still registered. This crashed the fork action test process with signal 11. The policy stream now retains its source until cancellation invalidates the observer, then releases it. The callback continues reading the policy directly from the observed object.

The regression uses the production KVO bridge with a test-owned observable. It checks source retention after the caller releases it, policy delivery, and source release on consumer cancellation while the stream remains alive.

Validation:

  • Before: fleet step e99abab9f1686afd420c4ed5 reached ForkConversationTests and crashed with signal 11 and the activation-policy observer warning.
  • After: fleet step a516a911b4aadb7c4290b739 compiled the package/tests and passed DockBadgeTests (4), DockBadgeObservationTests (1), and ForkConversationTests (6), at c3df46547462cf072a46971ac9e8eceeca9133a3. Subsequent changes document the holder invariant and remove an unnecessary unsafe annotation from Foundation's Sendable KVO token; executable behavior is unchanged.
  • Final head f23076a23ee69a5be132ea147dadd476e175eac5: remote fast gates passed crash-ratchet comparison, prepush checks, and crash-class rules. Exact-head app compile and independent review are running.

Risk: KVO ownership and cancellation ordering. The holder is initialized before publication and modified only by AsyncStream's once-only termination callback. The KVO token is invalidated before the source is released. No new production task or timer; the existing notification task owns stream consumption.

No capture: this corrects observer ownership and preserves the existing Dock badge appearance.

Agent session: agent session