A key-less inject_message made by one profile's plugin while it runs for another profile's local
session was refused correctly (False, nothing admitted), but the gateway log said only that gateway
mode needs a session_key or an origin. Main's keyed path logs that such a session is not a live local
session of the plugin's profile, and main's parity test expects that line for both calls.
resolve() now logs main's keyed refusal line when the calling route is a live local session of
another served profile, and keeps the plain line for every other route (a messaging chat). No
refusal outcome changes.
Refs #134889 (PLG-7)
Refs #139523
plugin_keyless_inject._warned kept one timestamp per (plugin, refusal
kind) for the life of the gateway: it rate-limited the warning to one per
window but was never pruned.
Each refusal now drops the marks older than the window before checking
its own, under a lock (refusals run on plugin threads), so the map holds
only the plugins refused within the last window. Warning behaviour is
unchanged: one per (plugin, kind) per window.
Refs #134889 (PLG-7)
Refs #139523
Before the one-gateway runtime each classic CLI loaded its own plugins, so
ctx.inject_message(text) without a session key meant that CLI's own chat.
On a gateway session the classic CLI now loads no plugin code (PLG-7): the
only copy of a plugin is the gateway's (or its plugin host's), which serves
every session of its profile, so a key-less inject had no chat to target
and was refused.
The gateway now picks the target, in order:
1. The plugin is handling a local session's own call (its slash command, a
hook fired for that session, a tool or hook in its turn): the message
goes to that session. The key is read from the calling context, so this
never guesses, however many sessions are open. pre_command deliveries
now bind the session they fire for. Under plugins.isolation: host the
forwarded ctx call already runs in its caller's context.
2. No session in the calling context (a timer, the plugin's own thread):
the one local session of the plugin's profile launched by the classic
CLI (frozen policy source "cli") with a viewer attached. TUI, Desktop,
messaging and other profiles' sessions are never picked this way.
3. Otherwise (none, or several): refused. inject_message returns False,
nothing is injected, and one warning per plugin and reason (rate
limited) names the plugin and says to pass a session key.
A resolved target is committed through the keyed path's producer
admission: a queued input in that session's FIFO, run once and in order.
A key-less call made for a messaging chat keeps main's refusal; a keyed
inject is unchanged; allow_gateway_injection is still required.
The classic chat view's client-side inject slot (gateway_chat_inject) is
removed: nothing in that process calls it any more. Off the gateway the
in-process _cli_ref path is unchanged. The plugin guide describes the three
rules and recommends passing a session key.
Refs #134889 (PLG-7)
Refs #139523
Refs #139847