Skip to content

apply post-optimization adversarial review fixes and pool improvements#14

Merged
Esity merged 33 commits into
mainfrom
feature/cache-post-optimization
Apr 6, 2026
Merged

apply post-optimization adversarial review fixes and pool improvements#14
Esity merged 33 commits into
mainfrom
feature/cache-post-optimization

Conversation

@Esity

@Esity Esity commented Apr 6, 2026

Copy link
Copy Markdown

Summary

  • Phase A: Apply fixes from 3 adversarial reviewers (Sonnet 4.6, Codex gpt-5.3, Codex gpt-5.4) — TOCTOU race fix, reconnector deadlock, serialization gaps, auth passthrough, shutdown ordering, async: false for internal callers, enabled? guards, tier-aware settings
  • Phase B: Connection pool improvements — normalized pool_size, separate checkout timeout, AtomicBoolean state flags, public pool accessor, failback to local, lifecycle integration test
  • Bumps version from 1.4.0 to 1.4.1

Test plan

  • 395 examples, 0 failures (full rspec suite)
  • rubocop clean (only 4 pre-existing Metrics conventions)
  • Verify with RUN_INTEGRATION_SPECS=1 bundle exec rspec against live Redis/Memcached

Esity added 29 commits April 6, 2026 12:33
- refactor @connected to Concurrent::AtomicBoolean
- invert call graph: set_sync/delete_sync own mutation logic
- mset_sync holds mutex for atomic batch writes
- add mget/mset/mset_sync for interface consistency
- add exception handling on reads (get/fetch return nil)
- add lifecycle rescue (setup/shutdown/restart force connected=false)
- fix reset! race: make_false inside mutex before clearing store
- add enforce_phi_ttl with minimum 1s clamp
- add flush rescue returning false on error
- add restart method
…improvements

Phase A - adversarial review fixes:
- force helper and cacheable to use async: false for read-after-write consistency
- fix async writer TOCTOU race in enqueue (local executor reference)
- add failed_count to async writer stats
- fix reconnector deadlock, atomic reset, and missing require
- add reconnect_shared! raising method, start reconnector on any shared failure
- guard setup with enabled? check
- make async writer and reconnector tier-aware for settings
- apply serialization to redis mget/mset_sync, force binary encoding
- pass auth/TLS options to redis cluster flush per-node connections
- drain async writer before closing pools on shutdown

Phase B - connection pool improvements:
- remove hardcoded pool_size from redis driver, resolve from settings
- separate pool checkout timeout from operation timeout
- refactor state flags to Concurrent::AtomicBoolean for thread safety
- add public pool accessor, replace direct @client access in redis_hash
- add end-to-end lifecycle integration test
- add automatic failback to local when shared cache unavailable
- bump version to 1.4.1
@Esity
Esity requested a review from a team as a code owner April 6, 2026 19:11

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 19c7eee8c2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/legion/cache/memcached.rb Outdated
Comment thread lib/legion/cache.rb
@Esity
Esity merged commit d035368 into main Apr 6, 2026
15 checks passed
@Esity
Esity removed the request for review from Copilot April 6, 2026 19:32
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.

1 participant