core/tests/test_language_pack_cache.py
Shay 7fccf368fb feat(adr-0024): Phase 1 — wire inner-loop admissibility + determinism proof
Phase 1 of the post-ADR-0024 sequence: wire the inner-loop flag into live
cognition paths and prove deterministic-when-wired in the same milestone.

Changes:
- RuntimeConfig: add inner_loop_admissibility + admissibility_threshold.
- ChatRuntime: pass both into generate() on the chat hot path.
- CLI: --inner-loop-admissibility / --admissibility-threshold flags.
- vocab/manifold.py: document strict `>` tie-break as load-bearing for
  ADR-0024 rejected_attempts ordering (determinism by construction, not
  by accident).
- tests/test_inner_loop_admissibility.py: three new determinism tests —
  identical rejected_attempts across 5 runs, identical trace hash across
  5 runs (non-empty), and legacy hash equivalence when no rejections
  occur (flag on/off byte-identical).
- tests/test_language_pack_cache.py: fix stale fixture (en-core-cog-070
  -> en-core-cog-085 after pack growth).

Suite: 995 passed, 0 failed, 2 skipped.

Acceptance criteria met:
- wired through RuntimeConfig + CLI + ChatRuntime + generate()
- deterministic rejected_attempts sequence (verified by repetition)
- deterministic trace hash under inner_loop=True
- legacy ADR-0023 trace hashes preserved when no rejections
- nearest_next determinism is by construction (sequenced iteration +
  strict > tie-break), now documented

Next: Phase 2 — corpus-observation eval on existing v1 corpus with the
four-condition matrix (boundary-only, null control, inner-loop t=0.0,
inner-loop t>0) and exhaustion_rate + latency metrics.
2026-05-17 13:38: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-085"