Spaces:
Sleeping
Sleeping
| """Deterministic phrase-pattern matchers used to corroborate LLM-proposed | |
| attribution and scope for Commit memory proposals. An LLM claiming | |
| attribution="explicit_student" or scope="global" on its own is not | |
| sufficient — these patterns are checked against the verified quote text | |
| before either claim is trusted. See docs/commit-memory-adaptation-architecture.md. | |
| """ | |
| from __future__ import annotations | |
| import re | |
| _EXPLICIT_SIGNAL_PATTERNS = ( | |
| re.compile(r"\bi prefer\b", re.IGNORECASE), | |
| re.compile(r"\bi learn better\b", re.IGNORECASE), | |
| re.compile(r"\bi already know\b", re.IGNORECASE), | |
| re.compile(r"\bi struggle with\b", re.IGNORECASE), | |
| re.compile(r"\bi do not understand\b", re.IGNORECASE), | |
| re.compile(r"\bi don't understand\b", re.IGNORECASE), | |
| re.compile(r"\bdo not give me\b", re.IGNORECASE), | |
| re.compile(r"\bdon't give me\b", re.IGNORECASE), | |
| re.compile(r"\bmy goal is\b", re.IGNORECASE), | |
| re.compile(r"\bremember that\b", re.IGNORECASE), | |
| re.compile(r"\bfrom now on\b", re.IGNORECASE), | |
| ) | |
| _GLOBAL_SIGNAL_PATTERNS = ( | |
| re.compile(r"\bi generally prefer\b", re.IGNORECASE), | |
| re.compile(r"\bi always prefer\b", re.IGNORECASE), | |
| re.compile(r"\bi usually prefer\b", re.IGNORECASE), | |
| re.compile(r"\bi learn better when\b", re.IGNORECASE), | |
| re.compile(r"\bfrom now on\b", re.IGNORECASE), | |
| re.compile(r"\balways\b", re.IGNORECASE), | |
| re.compile(r"\bnever\b", re.IGNORECASE), | |
| ) | |
| def is_explicit_student_signal(text: str) -> bool: | |
| return any(pattern.search(text) for pattern in _EXPLICIT_SIGNAL_PATTERNS) | |
| def is_explicit_global_signal(text: str) -> bool: | |
| return any(pattern.search(text) for pattern in _GLOBAL_SIGNAL_PATTERNS) | |