unsupportedpastels 4e0806d5dc fix(approval): skip the execute_code gate only while an approving viewer is attached
The exemption's last condition, a notifier registered for the bound session
key, holds for every gateway session turn: TurnRunner registers it whether
or not a viewer is attached. It only told side tasks apart and did not show
that anyone could answer. A viewer's queued turn that ran after the viewer
detached still skipped the whole-script gate, so non-terminal() code in the
script ran unprompted while its terminal() prompts timed out.

The attached-viewer records are reachable without a new protocol: the live
session that execute_admission binds for a viewer turn holds its
subscribers, the same records the approval resolver checks
(SessionAuthority accepts an approval answer only from an attached
subscriber holding session:approve) and the local clarify path already
reads. approval_context.is_viewer_turn_with_approver() now also requires
such a subscriber at gate time; a read-only viewer or nobody attached keeps
the whole-script gate. The notifier check stays, documented as what it is:
it tells side tasks apart, not that a human is present.

Tests: a viewer turn with nobody or only a read-only viewer attached gets the
whole-script prompt and a denied script never runs, and a viewer's turn
submitted after it detached keeps the gate in the real drain (both failed
before this change: the script ran / the gate was skipped).

Refs #134889 (T2)
Refs #139523
2026-10-16 19:42:20 -04:00
..