Skip to content

Release discarded registries after cached queries - #65

Merged
HexDecimal merged 2 commits into
HexDecimal:mainfrom
antonsoo:fix/query-cache-lifetime
Oct 19, 2026
Merged

HexDecimal merged 2 commits into
HexDecimal:mainfrom
antonsoo:fix/query-cache-lifetime

Conversation

@antonsoo

@antonsoo antonsoo commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Evaluating a query prevents an otherwise discarded registry from being collected. The global WeakKeyDictionary holds cache values strongly; cached entities and dependency records point back to the registry, keeping the weak key alive.

Let each registry own its transient query cache instead. Route dependent invalidation through the existing cache getter and create a fresh cache when restoring saved state. The serialized fields stay unchanged. A query held by the application still keeps its registry alive.

Validation:

  • Eleven new lifetime cases fail before this change. With current main merged, the full suite passes on Python 3.10 and 3.12: 123 passed, 2 non-strict xpasses. Configured Mypy and Ruff pass.
  • A scene-transition workload checks tags, components, relations, compound queries and subqueries, with save/load continuation. All 180 previously retained registries are released. Game state remains identical across 1,152 turns; 36 no-query controls still release normally.

The scene-transition workload was replayed on the updated branch; its state digests and collection results remain unchanged.

OpenAI Codex assisted with investigation, implementation and validation.

@codecov

codecov Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.18%. Comparing base (c9510dd) to head (d64ec3d).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #65      +/-   ##
==========================================
- Coverage   99.18%   99.18%   -0.01%     
==========================================
  Files           9        9              
  Lines         979      978       -1     
==========================================
- Hits          971      970       -1     
  Misses          8        8              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@HexDecimal
HexDecimal merged commit 27b90c9 into HexDecimal:main Oct 19, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants