Fail closed when notification pane identity is unproven

Merged
AU
3mo ago
+1443-202

Closes #11189

Summary

  • Require authoritative Claude PushNotification targets before feed/notification delivery.
  • Remove generic agent-hook focused-surface fallback and leave a resolution diagnostic.
  • Route caller TTY attribution through strict live/runtime evidence, prefer a valid surface identity, and remove focused-pane guesses.
  • Project notification-ring state on every portal reconciliation and hide it on dismantle.

Tests

  • Added deterministic Python socket regression for stale Claude PushNotification attribution.
  • Added generic-hook, TTY ambiguity/provenance, preferred-surface ordering, and portal ring lifecycle regressions.
  • First commit is tests-only (7d19970534); second commit is the fix (f51e160052).
  • Local checks: Python compile, Swift parse, PBX test wiring, package-resolved policy, workspace grouping, and swift test for CmuxNotifications/CmuxControlSocket.
  • Full cmux XCTest/XCUITest execution is delegated to CI per the repository focus-safety rule.

Notes

  • No user-facing strings or localization catalogs changed.
  • No Swift budget TSV changes.

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Fixes #11189 by failing closed when a notification's target pane can't be proven. Previously an unproven caller fell back to the workspace's focused pane and could ring the wrong pane; now delivery requires authoritative surface evidence and otherwise stays workspace-level or is dropped with a diagnostic.

  • Caller TTY attribution resolves lazily from live runtime evidence only; an explicit workspace is a hard scope, a valid surface outranks conflicting TTY claims, and freshness proof survives local surface moves.
  • Notification-ring publishing and teardown honor portal ownership so a dismantled view can't hide or override the replacement host's ring.
  • Codex settles stop by session identity without claiming the notification, rejects stale-turn stops, retries pending settlements with a bounded retry limit, validates persistent feed targets, journals unresolved targets as unattributed diagnostics, and uses a scoped resolver for relay feed hooks.
  • Synthetic debug notifications without caller selectors keep the focused-pane default; production caller resolution never uses it.
  • Added regression coverage for stale attribution, ambiguous TTY bindings, portal ring hand-off, and unresolved Codex lifecycle targets.

Summary by CodeRabbit

  • Bug Fixes

    • Improved notification delivery accuracy by requiring a verified target before sending notifications.
    • Prevented notifications from reaching focused panes when the originating pane cannot be identified.
    • Ensured stale notification indicators are hidden after panes or workspaces move.
    • Improved terminal attribution using current runtime information and safely handled ambiguous matches.
    • Ensured preferred surface identity takes precedence over conflicting terminal metadata.
    • Preserved child lifecycle cleanup when notification targets cannot be resolved.
  • Tests

    • Added regression coverage for unresolved targets, ambiguous attribution, stale metadata, lifecycle cleanup, and detached-pane notification visibility.