Files
rune/tests/test_grading_contract.py
T
Nick 6437daf606 fix(curator): recover the ORIGINAL grading + worthiness from the Odysseus source branch — reconstruction replaced by provenance
The phantom-dependency investigation traced both modules to their origin: ~/odysseus feat/memory-lifecycle (memory_platform/grading.py 192 lines, worthiness.py 411 lines). The rune port copied curator.py but never its two dependencies. ORIGINALS now wired: grading G0-G4 tier vocabulary (tier_of → G0/G1/G2p/G2/P/G3/G4; affirm_rule passes unknown prohibitions through UNCHANGED — deliberate no-blind-substitution design), worthiness ABSORB/PROMOTE/DEFER/REJECT with auditable per-question answers and veto tuples. Frozen tests live-verified against the originals (5+5 green). curator plan_ops worthiness integration probe green — the exact call that died on ModuleNotFoundError for every environment.
2026-10-07 12:00:35 +01:00

67 lines
3.1 KiB
Python

"""Frozen tests for grading.py — the ORIGINAL module recovered from the
Odysseus feat/memory-lifecycle branch (memory_platform/grading.py, 192 lines).
History (2026-10-07): curator.py imported `grading` since #314 but the module
was never ported from the Odysseus branch — the port copied curator.py alone.
Every import failed; the canary swallowed it; the 1,838-line curator was dead
code. A reconstruction stood in briefly, then the ORIGINAL was recovered from
the source branch and wired in its place. These tests freeze the ORIGINAL
contract: G0-G4 tier vocabulary, keyword-scored routing, positive-affirmation
table (AFFIRM_DICT — unknown prohibitions pass through unchanged).
Contract (live-verified against the original module, 2026-10-07):
grade_fact(fact, target=None) -> constitution|operating|persona|human|
project|skill|hindsight|mempalace|archive (tier vocabulary)
tier_of(grade) -> G0|G1|G2p|G2|P|G3|G4 (journal label)
affirm_rule(fact) -> AFFIRM_DICT positive form, else the fact unchanged
"""
import sys
from pathlib import Path
REPO = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO / "src"))
from rune.grading import affirm_rule, grade_fact, tier_of
from rune import curator # the RED TEST: this import failed for every environment
def test_curator_imports():
"""The phantom-dependency defect stays dead: curator must import."""
assert curator.entry_key("x")
def test_grade_fact_original_routing():
# Live-verified 2026-10-07 against the original module.
assert grade_fact("the constitution requires consent gates") == "constitution"
assert grade_fact("always verify CI before claiming done") == "operating"
assert grade_fact("operator persona speaks with dry warmth") == "hindsight"
assert grade_fact("how to use the deploy pipeline") == "hindsight"
assert grade_fact("superseded by the new architecture") == "hindsight"
assert grade_fact("nick's preferred coffee order") == "hindsight"
# coarse hint honored on no-keyword match
assert grade_fact("an unclassifiable note", "project") == "project"
assert grade_fact("an unclassifiable note", "recall") == "hindsight"
def test_grade_fact_stable():
f = "fix the deploy pipeline"
assert grade_fact(f) == grade_fact(f)
def test_tier_of_journal_labels():
assert tier_of("constitution") == "G0"
assert tier_of("operating") == "G1"
assert tier_of("recall") == "G3"
assert tier_of("archive") == "G3"
assert tier_of("nonsense-grade") == "G3" # unknown grades default G3
def test_affirm_rule_dict_semantics():
# KNOWN prohibitions rewrite to the positive form.
assert affirm_rule("never hedge") == "I answer directly, without hedging"
assert affirm_rule("do not overclaim") == "I name evidence as evidence and confirmed causes as confirmed"
# UNKNOWN prohibitions pass through UNCHANGED (the original's deliberate
# design — never blind-substitute and risk inverting meaning).
assert affirm_rule("never be sycophantic") == "never be sycophantic"
assert affirm_rule("an ordinary fact") == "an ordinary fact"