Addresses both inline comments left by gemini-code-assist on PR #1578.
## What this commit does
1. **HIGH PRIORITY (gemini, hallways.py:260) — canonicalize dynamics
preservation lookup key.** The previous code built the lookup key as
``(h.get("entity_a"), h.get("entity_b"))``, but the
``pair_counts`` dict and ``_hallway_id`` both use sorted entity pairs
for symmetric IDs. A persisted record with reversed entity order
(Lumi as entity_a, Aya as entity_b) would silently miss the lookup
and lose its accumulated dynamics on recompute. Now the lookup
canonicalizes the same way ID generation does:
key = tuple(sorted([h.get("entity_a"), h.get("entity_b")]))
Failure mode is rare in practice (the algorithm normally writes
sorted records), but any legacy data, manual JSON edit, or future
import path that violates the ordering would have silently broken
L7 preservation. Belt-and-suspenders fix.
2. **MEDIUM PRIORITY (gemini, palace_graph.py:512) — idiomatic field
preservation in tunnel dedup path.** Refactored the manual for-loop
into a dict-update with a comprehension. Field list lives in one
place; future schema expansion can't accidentally drop a field. No
behavior change.
## Test added (RED-first)
test_recompute_preserves_dynamics_when_existing_record_has_reversed_entity_order
Pre-populates the hallway store with a record whose ``entity_a`` /
``entity_b`` are in REVERSED (non-sorted) order, bumps its strength /
stability / access_count to non-default values, then runs
``compute_hallways_for_wing``. Asserts the recomputation preserves the
bumped values — proving the canonical lookup matches against
arbitrarily-ordered persisted entity pairs.
Reproduces the bug class gemini flagged: RED before this commit
(strength=1.0 instead of 4.2), GREEN after.
## Verification
pytest tests/test_hallways.py::TestHallwayDynamicsIntegration
tests/test_palace_graph_tunnels.py::TestTunnelDynamicsIntegration
tests/test_dynamics.py
→ 32 passed (was 31; added 1 new for the reverse-order case)
pytest -q (full mempalace suite)
→ 2112 passed, 3 skipped, 0 regressions
ruff check mempalace/dynamics.py mempalace/hallways.py mempalace/palace_graph.py tests/
→ All checks passed!
ruff format --check ...
→ 3 files already formatted (pinned 0.15.9)