# Deterministic Safety Shields: Priority Tier Protection Mechanisms

> Formal Syntactic Safeguards for Directives, Code Blocks, and Structured Data

By Yashvardhan Thanvi (LLMSlim Author & Core Maintainer) · Published July 15, 2026 · Updated July 15, 2026 · Systems & Architecture

## Abstract

Technical breakdown of how LLMSlim prevents the accidental deletion of system rules, code syntax, and imperative directives during statistical context pruning.

## Intuition

Overrides TF-IDF and centrality scores for sentences matching Tier 4 deterministic regex patterns and AST code fence boundaries.

## 1. Priority Tier Classification Specification

To ensure prompt compression never breaks application invariants, sentences are classified into four discrete priority tiers:

- **Tier 4 (trusted provenance)**: Protected priority is available to trusted system/developer context. In v0.3.1, untrusted RAG, tool, and assistant content is capped at Tier 2 regardless of imperative wording.
- **Tier 3 (Entity Protection - High Priority)**: Sentences containing proper nouns, numbers, currency symbols, and technical identifiers.
- **Tier 2 (Informative Content - Scored)**: Standard informative sentences evaluated by graph centrality.
- **Tier 1 (Structural Padding - Eligible for Pruning)**: Low-centrality conversational fluff.

```python
import re

TIER_4_PATTERNS = [
    re.compile(r"\b(must|never|always|required|strictly|do not|shall not)\b", re.IGNORECASE),
    re.compile(r"^(system|developer|user|assistant):", re.IGNORECASE),
]

def evaluate_sentence_priority(sentence: str, is_inside_code_fence: bool) -> int:
    """Evaluates deterministic priority tier for a given sentence boundary."""
    if is_inside_code_fence:
        return 4
    for pattern in TIER_4_PATTERNS:
        if pattern.search(sentence):
            return 4
    return 2  # Default candidate for centrality scoring
```

## Key takeaways

- Pure statistical sentence scoring risks dropping low-frequency imperative directives.
- v0.3.1 applies protected priority according to caller-supplied provenance; untrusted RAG, tool, and assistant content cannot obtain Tier 4 from wording.
- Ensures AST syntactic integrity for Python, JavaScript, and JSON code snippets embedded in prompts.

## References

- [LLMSlim Core Docs] [LLMSlim Core Engine Architecture & Priority Shield Implementation](https://www.llmslim.app/docs/context-role)

Canonical page: https://www.llmslim.app/articles/priority-tier-protection
