RICS / backend /tests /test_grounding_prompt_relocation.py
StormShadow308's picture
Add demo documentation and Docker setup for v2 report generation system
aad7814
Raw
History Blame Contribute Delete
1.73 kB
"""Guard for CONSTANT 2.2 relocation (see backend/docs/RICS_CONSTANT_INVENTORY.md).
The RICS Level 3 domain-rules prompt and the per-call rating hint were relocated
verbatim from backend/core/reference_mapper.py into the test-exempt
backend/prompts/mapping_prompt.py. These assertions pin the relocated strings
byte-for-byte (SHA-256 recorded from the pre-relocation literal) and confirm the
core consumer still resolves to the identical object — i.e. pure relocation, no
value drift.
"""
from __future__ import annotations
import hashlib
from backend.core import reference_mapper
from backend.prompts.mapping_prompt import RATING_HINT_TEMPLATE, RICS_DOMAIN_RULES
# SHA-256 of the exact pre-relocation ``_RICS_DOMAIN_RULES`` string (length 363),
# captured before any file was edited.
_RULES_SHA256 = "75b4d18346ac5d5a588097e532678a6eef276950c4b7304be8b075e8ac34b06c"
def test_domain_rules_byte_for_byte_unchanged():
digest = hashlib.sha256(RICS_DOMAIN_RULES.encode("utf-8")).hexdigest()
assert digest == _RULES_SHA256, "grounding prompt string drifted during relocation"
assert len(RICS_DOMAIN_RULES) == 363
def test_reference_mapper_alias_is_relocated_source():
# The private alias must be the very same object now living in prompts/.
assert reference_mapper._RICS_DOMAIN_RULES is RICS_DOMAIN_RULES
def test_rating_hint_template_unchanged():
assert (
RATING_HINT_TEMPLATE
== "If the baseline contains a condition rating field, use value: {rating_value}"
)
# Formatting reproduces the exact pre-relocation runtime string.
assert (
RATING_HINT_TEMPLATE.format(rating_value="2")
== "If the baseline contains a condition rating field, use value: 2"
)