oc_connect
Loading...
Searching...
No Matches
oc_connect.inbound.classify Namespace Reference

Functions

str normalise (str text)
tuple[InboundClassification, str|None] classify (str text, *, str|None correlated_audit_id=None)
str render_untrusted (InboundMessage message)

Variables

str UNTRUSTED_BEGIN = "<<<BEGIN UNTRUSTED OPERATOR TEXT {message_id}>>>"
str UNTRUSTED_END = "<<<END UNTRUSTED OPERATOR TEXT {message_id}>>>"
str NEUTRALISED_MARKER = "<< <"

Detailed Description

Mechanical classification and the untrusted-content delimiters.

Proposal V1 §4. Classification is string-exact and has no model in the loop:

* ``command`` - the text is exactly a :data:`COMMAND_VOCABULARY` token.
  ``STATUS`` is a command whether or not it arrived as a reply; §4 lists it as
  the standalone verb and P4 pins the reply vocabulary without it, so there is
  no reading under which a ``STATUS`` reply is an approval.
* ``structured-reply`` - the text is exactly a :data:`REPLY_VOCABULARY` token
  AND the reply resolved to an outbound audit id. Both conditions, never one.
* ``free-text`` - everything else, including an uncorrelated ``YES``.

The only normalisation is stripping surrounding whitespace. Case is *not*
folded: ``yes`` is free text, because widening the match is how a mechanical
vocabulary quietly stops being mechanical.

§2 makes free text display-only. :func:`render_untrusted` is the single place
it may be shown, and it does two things: it wraps the body in delimiters that
carry the message's own id, and it neutralises any literal ``<<<`` in the body
so a message cannot forge its own closing delimiter. Neutralisation applies to
the RENDERED copy only - the stored text stays verbatim, because the operator's
words are evidence.

Dependencies
------------
- oc_diagnostics (_dbg structured logger)
- option_c_connector_contracts (COMMAND_VOCABULARY, REPLY_VOCABULARY, InboundClassification, InboundMessage - the vocabularies and message types)

Function Documentation

◆ classify()

tuple[InboundClassification, str | None] oc_connect.inbound.classify.classify ( str text,
* ,
str | None correlated_audit_id = None )
Return the classification and vocabulary token for one message.

Definition at line 54 of file classify.py.

Here is the call graph for this function:

◆ normalise()

str oc_connect.inbound.classify.normalise ( str text)
Return the exact-match candidate: surrounding whitespace removed.

Definition at line 47 of file classify.py.

Here is the caller graph for this function:

◆ render_untrusted()

str oc_connect.inbound.classify.render_untrusted ( InboundMessage message)
Return the only representation in which inbound text may be displayed.

Definition at line 78 of file classify.py.

Variable Documentation

◆ NEUTRALISED_MARKER

str oc_connect.inbound.classify.NEUTRALISED_MARKER = "<< <"

Definition at line 44 of file classify.py.

◆ UNTRUSTED_BEGIN

str oc_connect.inbound.classify.UNTRUSTED_BEGIN = "<<<BEGIN UNTRUSTED OPERATOR TEXT {message_id}>>>"

Definition at line 40 of file classify.py.

◆ UNTRUSTED_END

str oc_connect.inbound.classify.UNTRUSTED_END = "<<<END UNTRUSTED OPERATOR TEXT {message_id}>>>"

Definition at line 41 of file classify.py.