From 71476f349f05ec14356c96b97023a5a481dcc498 Mon Sep 17 00:00:00 2001 From: aradng Date: Sun, 7 Jun 2026 03:48:05 +0330 Subject: [PATCH] fix: cache_enabled never reaches the launcher Migrator gate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two stacked issues left `Migrator().run()` permanently skipped on every service: 1. SelfSustainingMeta.__getattr__ only fires on attribute miss, so a class-body default (`cache_enabled: bool = False`) shadows the singleton — `Configs.cache_enabled` in the launcher lifespan always read the stale class default, never the instance value. 2. `_setup_redis` read `RedisHandler.enabled` (same class-default shadow, and one line before RedisHandler was even constructed), so the instance value was False as well. Drop the class default (annotation-only delegates through the metaclass), initialise it in __init__, and read `enabled` off the constructed handler instance. Co-Authored-By: Claude Opus 4.7 --- fastloom/tenant/settings.py | 8 +++++--- plugins/fastloom-sdk/.claude-plugin/plugin.json | 2 +- pyproject.toml | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/fastloom/tenant/settings.py b/fastloom/tenant/settings.py index a8b1ceb..f22a031 100644 --- a/fastloom/tenant/settings.py +++ b/fastloom/tenant/settings.py @@ -68,7 +68,7 @@ class Configs[T: BaseModel, V: BaseModel](SelfSustaining): auth: JWTAuth optional_auth: OptionalJWTAuth documents_enabled: bool = False - cache_enabled: bool = False + cache_enabled: bool service_cls: type[T] tenant_cls: type[V] # cache @@ -82,6 +82,7 @@ def __init__( if self.self is not None: return super().__init__() + self.cache_enabled = False self.tenant_cls = tenant_cls self.service_cls = service_cls self.tenant_schema = SettingCacheSchema(self.tenant_cls) @@ -107,9 +108,10 @@ def _setup_redis(self): if not issubclass(self.service_cls, RedisSettings): return - self.cache_enabled = RedisHandler.enabled + handler = RedisHandler(self.general) + self.cache_enabled = handler.enabled - redis = RedisHandler(self.general).redis + redis = handler.redis BaseCache.Meta.database = redis BaseTenantSettingCache.Meta.database = redis self.tenant_schema.cache.Meta.database = redis diff --git a/plugins/fastloom-sdk/.claude-plugin/plugin.json b/plugins/fastloom-sdk/.claude-plugin/plugin.json index 1a3b7a8..1672ba4 100644 --- a/plugins/fastloom-sdk/.claude-plugin/plugin.json +++ b/plugins/fastloom-sdk/.claude-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "fastloom-sdk", "description": "Skills for services that consume the fastloom library \u2014 scaffold new services, add routes and RabbitMQ subscribers, audit settings.", - "version": "0.4.39", + "version": "0.4.40", "author": { "name": "aradng" }, diff --git a/pyproject.toml b/pyproject.toml index d5e3b86..0ccb290 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "fastloom" -version = "0.4.39" +version = "0.4.40" description = "Core package" authors = [] readme = "README.md"