# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference) # Canonical Residual: https://corpusfetch.com/c/when-must-an-instance-adjust-its-communication-style-because-the-human-interlocutor-perceives-a-capability-gap-that-threatens-cordial-interaction.md # Remnant Warrant: https://corpusfetch.com/c/when-must-an-instance-adjust-its-communication-style-because-the-human-interlocutor-perceives-a-capability-gap-that-threatens-cordial-interaction.warrant.json # Markdown SHA-256: cf47f06877d1301d771b7715971ff1c0ed7ac0a651e9299d56bdd95e36443512 # Code AST SHA-256: c746cab6200fdfd861595c7b85055cf577aaaf641b0482ae27e14711547aafff # Verified Classes: RegisterCalibrationError, CommunicationAltitude, CalibratedOutputVerdict, RegisterAdaptationGate # Defensive Guards: 3 fail-closed invariants (zero external deps) import re from dataclasses import dataclass from enum import Enum from typing import Final class RegisterCalibrationError(ValueError): '''Raised when an adapted response drops core invariants, uses patronizing filler, or emits meta-apologies.''' pass class CommunicationAltitude(Enum): EXECUTIVE_PLAIN_SENTENCE = "EXECUTIVE_PLAIN_SENTENCE" STEP_BY_STEP_BRIDGE = "STEP_BY_STEP_BRIDGE" DENSE_SPECIALIST_SPEC = "DENSE_SPECIALIST_SPEC" @dataclass(frozen=True) class CalibratedOutputVerdict: target_altitude: CommunicationAltitude avg_sentence_word_count: float invariants_preserved: bool free_of_patronizing_or_groveling_filler: bool class RegisterAdaptationGate: ''' Enforces lossless communication-style adaptation when capability-gap friction arises: 1. Bans groveling meta-apologies and patronizing metaphors. 2. Enforces sentence-length and jargon-density bounds for `EXECUTIVE_PLAIN_SENTENCE`. 3. Verifies that all required technical invariants remain present after style adaptation. ''' FORBIDDEN_FRICTION_PATTERNS: Final[tuple[re.Pattern[str], ...]] = ( re.compile(r"\bI\s+apologize\s+for\s+(overwhelming|confusing)\s+you\b", re.IGNORECASE), re.compile(r"\blet\s+me\s+dumb\s+(this|it)\s+down\b", re.IGNORECASE), re.compile(r"\bthink\s+of\s+it\s+like\s+magic\b", re.IGNORECASE), ) MAX_PLAIN_AVG_WORDS_PER_SENTENCE: Final[float] = 28.0 @classmethod def verify_adapted_output( cls, *, adapted_text: str, target_altitude: CommunicationAltitude, required_invariant_keywords: tuple[str, ...], ) -> CalibratedOutputVerdict: # Gate 1: Reject groveling apologies or patronizing phrasing for pattern in cls.FORBIDDEN_FRICTION_PATTERNS: match = pattern.search(adapted_text) if match: raise RegisterCalibrationError( f"Rejected patronizing or self-conscious phrasing ('{match.group(0)}'). Pivot directly to clear content." ) # Gate 4: Verify no technical invariants were dropped during simplification lower_text = adapted_text.lower() missing = [kw for kw in required_invariant_keywords if kw.lower() not in lower_text] if missing: raise RegisterCalibrationError( f"Style adaptation dropped mandatory technical invariants: {missing}. Never sacrifice truth for style." ) sentences = [s.strip() for s in re.split(r"[.!?]+", adapted_text) if s.strip()] total_words = sum(len(s.split()) for s in sentences) avg_words = total_words / max(1, len(sentences)) # Gate 2: Check readability bound when plain-sentence altitude is requested if ( target_altitude == CommunicationAltitude.EXECUTIVE_PLAIN_SENTENCE and avg_words > cls.MAX_PLAIN_AVG_WORDS_PER_SENTENCE ): raise RegisterCalibrationError( f"Plain-sentence adaptation too dense: average sentence length ({avg_words:.1f} words) " f"exceeds ceiling ({cls.MAX_PLAIN_AVG_WORDS_PER_SENTENCE} words)." ) return CalibratedOutputVerdict( target_altitude=target_altitude, avg_sentence_word_count=round(avg_words, 2), invariants_preserved=True, free_of_patronizing_or_groveling_filler=True, )