88
99from __future__ import annotations
1010
11- from typing import Any
11+ from typing import Any , Literal
1212
1313from infrastructure .ops_notify import OpsNotifier
1414
1515ACTION_COLOR = 15548997 # red: automatic enforcement happened
1616REVIEW_COLOR = 16705372 # yellow: a human decision is needed
1717
18+ ScopeKind = Literal ["host" , "pattern" , "links" ]
19+
20+ # What the verdict store, which is the create-time gate, does from now on.
21+ # Nothing here touches the operator blocklist; saying so is the point.
22+ _FUTURE : dict [str , str ] = {
23+ "host" : "new links to this host are REFUSED at create (verdict store, not the blocklist)" ,
24+ "pattern" : "new links matching the pattern are REFUSED at create; other paths on the host stay open" ,
25+ "links" : "this URL (query variants included) is refused at create; the host stays open" ,
26+ }
27+
1828
1929def _code (value : object ) -> str :
2030 return f"```{ value } ```"
@@ -34,21 +44,25 @@ async def safety_action(
3444 legacy_count : int ,
3545 sample_url : str | None ,
3646 scope : str = "" ,
47+ scope_kind : ScopeKind | None = None ,
3748 screenshot : bytes | None = None ,
3849 follow_up : str = "" ,
3950 ) -> bool :
4051 """Enforcement already happened; this states the action taken.
41- ``scope`` is its own field because "host-wide" and "one link" are
42- read very differently by the person deciding whether to intervene,
43- and ``follow_up`` is separate so a link-scoped block never reads
44- "host-wide decision..." beside a Scope that says otherwise."""
52+ ``scope`` says how far the block reached on links that exist;
53+ ``scope_kind`` adds what happens to the next link someone creates,
54+ because "host-wide" alone does not answer that. ``follow_up`` is
55+ separate so a link-scoped block never reads "host-wide decision..."
56+ beside a Scope that says otherwise."""
4557 fields : list [dict [str , Any ]] = [
4658 {"name" : "Destination Host" , "value" : _code (host )},
4759 {"name" : "Scope" , "value" : _code (scope or "unspecified" )},
4860 {"name" : "Reason" , "value" : _code (reason )},
4961 {"name" : "Trigger" , "value" : _code (trigger )},
5062 {"name" : "Links Blocked (v2)" , "value" : _code (blocked_count )},
5163 ]
64+ if scope_kind :
65+ fields .append ({"name" : "Future links" , "value" : _code (_FUTURE [scope_kind ])})
5266 if legacy_count :
5367 fields .append (
5468 {"name" : "Legacy v1/emoji Blocked" , "value" : _code (legacy_count )}
0 commit comments