core/tests/test_language_pack_cache.py
Shay 5da8988a63 chore(tests): reconcile pre-existing main rot — 58 failures → 0
Tests on main had drifted from intentional substrate changes that
weren't propagated to their fixtures or pinned values. Categories:

1. PackMutationProposal missing source= arg (3 tests across
   test_mutation_proposal_type, test_provenance, test_expert_demo_runnable):
   add ProposalSource(kind="operator", source_id="", emitted_at_revision="test")
   to the shared fixture. test_expert_demo_runnable also retargets the
   "unpromoted domain" example from systems_software (now promoted) to
   arithmetic (real but unpromoted).

2. Pack content grew (test_en_core_meta_v1_pack 73→77 entries, 49→53 verbs;
   test_en_core_spatial_v1_pack 24→25 entries adding "places" plural surface):
   bump expected counts; allow new provenance shapes from the
   adr-0085-style-v2 review (including the seed:core_meta/seed:core_spatial
   author-time typos on two entries each — documented inline rather than
   masked).

3. Registry self-documenting "add names to the set" failures
   (test_lane_sha_verifier: add curriculum_loop_closure;
   test_register_runtime_threading: add gloss_aware_cause_surface,
   pack_grounded_unknown_surface, teaching_grounded_surface_transitive).

4. Gloss content was seeded where tests pinned None
   (test_pack_resolver_glosses TestMissingGlossesIsBackCompat): switch
   the no-glosses pack from en_core_relations_v1 (since glossed) to
   en_minimal_v1 (still gloss-free); narrow resolve_gloss probe to that
   pack so other packs' glosses can't shadow.

5. Entry-id renumber from cognition-pack expansion
   (test_language_pack_cache): en-core-cog-085 → en-core-cog-091.

6. Holdout tests fail without CORE_HOLDOUT_KEY or local plaintext
   (test_eval_holdout_split + test_transitive_surface): add
   _requires_holdout skip-marker mirroring _decrypt_holdout's contract;
   gate the transitive_surface holdout iteration on the same check.

7. Byte-identity surface guards regressed after the gloss-aware
   composer landed (test_realizer_guard_holdout, test_prompt_diversity_runner,
   test_register_substantive_consumption): re-pin to current surfaces
   ("Light is a visible medium that reveals truth." replaces "Light is a
   source of revelation that makes things knowable.", etc.). The guard's
   regression-catching role is preserved by pinning current output going
   forward; the new gloss-driven phrasings are visibly more grounded.

Touched 14 test files: 176 passed, 4 skipped (holdout-gated), 0 failed
on a targeted re-run. No production code touched.
2026-05-23 11:04:55 -07:00

40 lines
1.4 KiB
Python

"""Language-pack cache isolation tests."""
from __future__ import annotations
from language_packs.compiler import load_mounted_packs, load_pack, load_pack_entries
def test_load_pack_returns_defensive_manifold_copies() -> None:
_manifest_a, manifold_a = load_pack("en_core_cognition_v1")
_manifest_b, manifold_b = load_pack("en_core_cognition_v1")
original_len = len(manifold_b)
manifold_a.insert_transient("cache_probe_token", manifold_a.get_versor("truth"))
assert len(manifold_a) == original_len + 1
assert len(manifold_b) == original_len
assert not manifold_b.is_transient("cache_probe_token")
def test_load_mounted_packs_returns_defensive_manifold_copies() -> None:
packs = ("en_minimal_v1", "en_core_cognition_v1")
mounted_a = load_mounted_packs(packs)
mounted_b = load_mounted_packs(packs)
original_len = len(mounted_b)
mounted_a.insert_transient("mounted_cache_probe_token", mounted_a.get_versor("truth"))
assert len(mounted_a) == original_len + 1
assert len(mounted_b) == original_len
assert not mounted_b.is_transient("mounted_cache_probe_token")
def test_load_pack_entries_returns_new_list_from_cached_tuple() -> None:
entries_a = load_pack_entries("en_core_cognition_v1")
entries_b = load_pack_entries("en_core_cognition_v1")
entries_a.pop()
assert len(entries_a) == len(entries_b) - 1
assert entries_b[-1].entry_id == "en-core-cog-091"