Repository navigation
Commit 04b133f
authored
refactor: organize app.state into typed namespaces (#31)
* docs: app.state organization design
Consolidate 15+ loose app.state attributes into one typed slot per
owner (framework + each module), delete three duplicate locale fields,
and drop runtime drift detection. Storage stays on app.state; only
the shape changes.
* docs: app.state organization implementation plan
14-task staged migration from loose app.state keys to typed slots
(app.state.sm for framework + app.state.<module> for each module).
Each task is a single revertable commit.
* feat(core): add Services dataclass for framework singletons
* test(core): match codebase test-class convention for Services
* feat(hosting): populate app.state.sm alongside loose keys
* refactor(hosting): read framework singletons via app.state.sm
* refactor(hosting): read i18n + permission singletons via app.state.sm
* refactor(host): read i18n state via app.state.sm with fallback
* refactor(modules): read framework state via app.state.sm
* feat(users): introduce UsersServices at app.state.users
* refactor(users): read module state via app.state.users
Migrate all users-module consumers from loose app.state keys
(mailer, users_settings, rate_limiter, auth_throughput_limiter, event_bus, db)
to the structured UsersServices slot introduced in Task 7. Update two test
helpers that patched the old loose keys to patch app.state.users.* instead.
* refactor(users): migrate bootstrap + its test helper to app.state.users/sm
* test(users+auth): migrate remaining app.state reads to sm/users slots
* refactor: delete deprecated loose app.state keys
* refactor: migrate consumers to read from app.state.sm.*
- Update conftest fixtures to access app.state.sm.db and app.state.sm.settings
- Update get_db FastAPI dependency to use app.state.sm.db
- Update test mocks and fixtures to use app.state.sm.* paths
- Update dashboard stats and products deps to use app.state.sm.*
- Update test assertions to verify sm instance instead of loose keys
* fix: migrate remaining app.state reads missed in Task 10
* revert: restore generated i18n files (regen had stale fixture)
* refactor: drop duplicate locale fields, update SM012, simplify i18n routes
* refactor(hosting): plumb inertia_config via return value instead of app.state
* docs+scaffold: adopt app.state.sm + app.state.<module> convention
Add services.py.tpl template and register_settings scaffolding so new
modules store settings inside a typed Services dataclass at
app.state.<module_lower> rather than the old app.state.<module>_settings
flat attribute. Update framework-conventions.md with Framework state and
Module settings subsections reflecting the new pattern.
* fix(verify): migrate remaining app.state reads in test fixtures + lint fixes
* cleanup: simplify defensive guards + remove stale migration comments1 parent b4b944c commit 04b133f
54 files changed
Lines changed: 2148 additions & 156 deletions
File tree
- docs
- superpowers
- plans
- specs
- framework
- core
- simple_module_core
- tests
- db
- simple_module_db
- tests
- hosting
- simple_module_hosting
- templates/module/__PACKAGE__
- tests
- host
- templates
- tests
- modules
- auth
- auth
- tests
- dashboard
- dashboard
- tests
- products
- products
- tests
- users
- tests
- users
- endpoints
- scripts
- tests/integration
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | | - | |
| 128 | + | |
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
149 | | - | |
| 149 | + | |
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
166 | | - | |
| 166 | + | |
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
176 | | - | |
| 176 | + | |
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
95 | 111 | | |
96 | 112 | | |
97 | | - | |
98 | | - | |
| 113 | + | |
| 114 | + | |
99 | 115 | | |
100 | 116 | | |
101 | | - | |
| 117 | + | |
102 | 118 | | |
103 | | - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
104 | 123 | | |
105 | 124 | | |
106 | 125 | | |
| |||
0 commit comments