exonware-xwsystem 0.1.0.1__py3-none-any.whl → 0.1.0.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (341) hide show
  1. exonware/__init__.py +2 -1
  2. exonware/conf.py +2 -2
  3. exonware/xwsystem/__init__.py +115 -43
  4. exonware/xwsystem/base.py +30 -0
  5. exonware/xwsystem/caching/__init__.py +39 -13
  6. exonware/xwsystem/caching/base.py +24 -6
  7. exonware/xwsystem/caching/bloom_cache.py +2 -2
  8. exonware/xwsystem/caching/cache_manager.py +2 -1
  9. exonware/xwsystem/caching/conditional.py +2 -2
  10. exonware/xwsystem/caching/contracts.py +85 -139
  11. exonware/xwsystem/caching/decorators.py +6 -19
  12. exonware/xwsystem/caching/defs.py +2 -1
  13. exonware/xwsystem/caching/disk_cache.py +2 -1
  14. exonware/xwsystem/caching/distributed.py +2 -1
  15. exonware/xwsystem/caching/errors.py +2 -1
  16. exonware/xwsystem/caching/events.py +110 -27
  17. exonware/xwsystem/caching/eviction_strategies.py +2 -2
  18. exonware/xwsystem/caching/external_caching_python.py +701 -0
  19. exonware/xwsystem/caching/facade.py +253 -0
  20. exonware/xwsystem/caching/factory.py +300 -0
  21. exonware/xwsystem/caching/fluent.py +14 -12
  22. exonware/xwsystem/caching/integrity.py +21 -6
  23. exonware/xwsystem/caching/lfu_cache.py +2 -1
  24. exonware/xwsystem/caching/lfu_optimized.py +18 -6
  25. exonware/xwsystem/caching/lru_cache.py +7 -4
  26. exonware/xwsystem/caching/memory_bounded.py +2 -2
  27. exonware/xwsystem/caching/metrics_exporter.py +2 -2
  28. exonware/xwsystem/caching/observable_cache.py +2 -2
  29. exonware/xwsystem/caching/pluggable_cache.py +2 -2
  30. exonware/xwsystem/caching/rate_limiter.py +2 -2
  31. exonware/xwsystem/caching/read_through.py +2 -2
  32. exonware/xwsystem/caching/secure_cache.py +81 -28
  33. exonware/xwsystem/caching/serializable.py +9 -7
  34. exonware/xwsystem/caching/stats.py +2 -2
  35. exonware/xwsystem/caching/tagging.py +2 -2
  36. exonware/xwsystem/caching/ttl_cache.py +4 -3
  37. exonware/xwsystem/caching/two_tier_cache.py +6 -3
  38. exonware/xwsystem/caching/utils.py +30 -12
  39. exonware/xwsystem/caching/validation.py +2 -2
  40. exonware/xwsystem/caching/warming.py +6 -3
  41. exonware/xwsystem/caching/write_behind.py +15 -6
  42. exonware/xwsystem/config/__init__.py +11 -17
  43. exonware/xwsystem/config/base.py +5 -5
  44. exonware/xwsystem/config/contracts.py +93 -153
  45. exonware/xwsystem/config/defaults.py +3 -2
  46. exonware/xwsystem/config/defs.py +3 -2
  47. exonware/xwsystem/config/errors.py +2 -5
  48. exonware/xwsystem/config/logging.py +12 -8
  49. exonware/xwsystem/config/logging_setup.py +3 -2
  50. exonware/xwsystem/config/performance.py +1 -46
  51. exonware/xwsystem/config/performance_modes.py +9 -8
  52. exonware/xwsystem/config/version_manager.py +1 -0
  53. exonware/xwsystem/config.py +27 -0
  54. exonware/xwsystem/console/__init__.py +53 -0
  55. exonware/xwsystem/console/base.py +133 -0
  56. exonware/xwsystem/console/cli/__init__.py +61 -0
  57. exonware/xwsystem/{cli → console/cli}/args.py +27 -24
  58. exonware/xwsystem/{cli → console/cli}/base.py +18 -87
  59. exonware/xwsystem/{cli → console/cli}/colors.py +15 -13
  60. exonware/xwsystem/console/cli/console.py +98 -0
  61. exonware/xwsystem/{cli → console/cli}/contracts.py +51 -69
  62. exonware/xwsystem/console/cli/defs.py +87 -0
  63. exonware/xwsystem/console/cli/encoding.py +69 -0
  64. exonware/xwsystem/{cli → console/cli}/errors.py +8 -3
  65. exonware/xwsystem/console/cli/event_logger.py +166 -0
  66. exonware/xwsystem/{cli → console/cli}/progress.py +25 -21
  67. exonware/xwsystem/{cli → console/cli}/prompts.py +3 -2
  68. exonware/xwsystem/{cli → console/cli}/tables.py +27 -24
  69. exonware/xwsystem/console/contracts.py +113 -0
  70. exonware/xwsystem/console/defs.py +154 -0
  71. exonware/xwsystem/console/errors.py +34 -0
  72. exonware/xwsystem/console/event_logger.py +385 -0
  73. exonware/xwsystem/console/writer.py +132 -0
  74. exonware/xwsystem/contracts.py +28 -0
  75. exonware/xwsystem/data_structures/__init__.py +23 -0
  76. exonware/xwsystem/data_structures/trie.py +34 -0
  77. exonware/xwsystem/data_structures/union_find.py +144 -0
  78. exonware/xwsystem/defs.py +17 -0
  79. exonware/xwsystem/errors.py +23 -0
  80. exonware/xwsystem/facade.py +62 -0
  81. exonware/xwsystem/http_client/__init__.py +22 -1
  82. exonware/xwsystem/http_client/advanced_client.py +8 -5
  83. exonware/xwsystem/http_client/base.py +3 -2
  84. exonware/xwsystem/http_client/client.py +7 -4
  85. exonware/xwsystem/http_client/contracts.py +42 -56
  86. exonware/xwsystem/http_client/defs.py +2 -1
  87. exonware/xwsystem/http_client/errors.py +2 -1
  88. exonware/xwsystem/http_client/facade.py +156 -0
  89. exonware/xwsystem/io/__init__.py +22 -3
  90. exonware/xwsystem/io/archive/__init__.py +8 -2
  91. exonware/xwsystem/io/archive/archive.py +1 -1
  92. exonware/xwsystem/io/archive/archive_files.py +4 -7
  93. exonware/xwsystem/io/archive/archivers.py +120 -10
  94. exonware/xwsystem/io/archive/base.py +4 -5
  95. exonware/xwsystem/io/archive/codec_integration.py +1 -2
  96. exonware/xwsystem/io/archive/compression.py +1 -2
  97. exonware/xwsystem/io/archive/facade.py +263 -0
  98. exonware/xwsystem/io/archive/formats/__init__.py +2 -3
  99. exonware/xwsystem/io/archive/formats/brotli_format.py +20 -7
  100. exonware/xwsystem/io/archive/formats/lz4_format.py +20 -7
  101. exonware/xwsystem/io/archive/formats/rar.py +11 -5
  102. exonware/xwsystem/io/archive/formats/sevenzip.py +12 -6
  103. exonware/xwsystem/io/archive/formats/squashfs_format.py +1 -2
  104. exonware/xwsystem/io/archive/formats/tar.py +52 -7
  105. exonware/xwsystem/io/archive/formats/wim_format.py +11 -5
  106. exonware/xwsystem/io/archive/formats/zip.py +1 -2
  107. exonware/xwsystem/io/archive/formats/zpaq_format.py +1 -2
  108. exonware/xwsystem/io/archive/formats/zstandard.py +20 -7
  109. exonware/xwsystem/io/base.py +119 -115
  110. exonware/xwsystem/io/codec/__init__.py +4 -2
  111. exonware/xwsystem/io/codec/base.py +19 -13
  112. exonware/xwsystem/io/codec/contracts.py +59 -2
  113. exonware/xwsystem/io/codec/registry.py +67 -21
  114. exonware/xwsystem/io/common/__init__.py +1 -1
  115. exonware/xwsystem/io/common/atomic.py +29 -16
  116. exonware/xwsystem/io/common/base.py +11 -10
  117. exonware/xwsystem/io/common/lock.py +6 -5
  118. exonware/xwsystem/io/common/path_manager.py +2 -1
  119. exonware/xwsystem/io/common/watcher.py +1 -2
  120. exonware/xwsystem/io/contracts.py +301 -433
  121. exonware/xwsystem/io/contracts_1.py +1180 -0
  122. exonware/xwsystem/io/data_operations.py +19 -20
  123. exonware/xwsystem/io/defs.py +4 -3
  124. exonware/xwsystem/io/errors.py +3 -2
  125. exonware/xwsystem/io/facade.py +87 -61
  126. exonware/xwsystem/io/file/__init__.py +1 -1
  127. exonware/xwsystem/io/file/base.py +8 -9
  128. exonware/xwsystem/io/file/conversion.py +2 -3
  129. exonware/xwsystem/io/file/file.py +61 -18
  130. exonware/xwsystem/io/file/paged_source.py +8 -8
  131. exonware/xwsystem/io/file/paging/__init__.py +1 -2
  132. exonware/xwsystem/io/file/paging/byte_paging.py +4 -5
  133. exonware/xwsystem/io/file/paging/line_paging.py +2 -3
  134. exonware/xwsystem/io/file/paging/record_paging.py +2 -3
  135. exonware/xwsystem/io/file/paging/registry.py +1 -2
  136. exonware/xwsystem/io/file/source.py +13 -17
  137. exonware/xwsystem/io/filesystem/__init__.py +1 -1
  138. exonware/xwsystem/io/filesystem/base.py +1 -2
  139. exonware/xwsystem/io/filesystem/local.py +3 -4
  140. exonware/xwsystem/io/folder/__init__.py +1 -1
  141. exonware/xwsystem/io/folder/base.py +1 -2
  142. exonware/xwsystem/io/folder/folder.py +16 -7
  143. exonware/xwsystem/io/indexing/__init__.py +14 -0
  144. exonware/xwsystem/io/indexing/facade.py +443 -0
  145. exonware/xwsystem/io/path_parser.py +98 -0
  146. exonware/xwsystem/io/serialization/__init__.py +21 -3
  147. exonware/xwsystem/io/serialization/auto_serializer.py +146 -20
  148. exonware/xwsystem/io/serialization/base.py +84 -34
  149. exonware/xwsystem/io/serialization/contracts.py +50 -73
  150. exonware/xwsystem/io/serialization/defs.py +2 -1
  151. exonware/xwsystem/io/serialization/errors.py +2 -1
  152. exonware/xwsystem/io/serialization/flyweight.py +154 -7
  153. exonware/xwsystem/io/serialization/format_detector.py +15 -14
  154. exonware/xwsystem/io/serialization/formats/__init__.py +8 -5
  155. exonware/xwsystem/io/serialization/formats/binary/bson.py +15 -6
  156. exonware/xwsystem/io/serialization/formats/binary/cbor.py +5 -5
  157. exonware/xwsystem/io/serialization/formats/binary/marshal.py +5 -5
  158. exonware/xwsystem/io/serialization/formats/binary/msgpack.py +5 -5
  159. exonware/xwsystem/io/serialization/formats/binary/pickle.py +5 -5
  160. exonware/xwsystem/io/serialization/formats/binary/plistlib.py +5 -5
  161. exonware/xwsystem/io/serialization/formats/database/dbm.py +7 -7
  162. exonware/xwsystem/io/serialization/formats/database/shelve.py +7 -7
  163. exonware/xwsystem/io/serialization/formats/database/sqlite3.py +7 -7
  164. exonware/xwsystem/io/serialization/formats/tabular/__init__.py +27 -0
  165. exonware/xwsystem/io/serialization/formats/tabular/base.py +89 -0
  166. exonware/xwsystem/io/serialization/formats/tabular/csv.py +319 -0
  167. exonware/xwsystem/io/serialization/formats/tabular/df.py +249 -0
  168. exonware/xwsystem/io/serialization/formats/tabular/excel.py +291 -0
  169. exonware/xwsystem/io/serialization/formats/tabular/googlesheets.py +374 -0
  170. exonware/xwsystem/io/serialization/formats/text/__init__.py +1 -1
  171. exonware/xwsystem/io/serialization/formats/text/append_only_log.py +5 -7
  172. exonware/xwsystem/io/serialization/formats/text/configparser.py +5 -5
  173. exonware/xwsystem/io/serialization/formats/text/csv.py +7 -5
  174. exonware/xwsystem/io/serialization/formats/text/formdata.py +5 -5
  175. exonware/xwsystem/io/serialization/formats/text/json.py +27 -18
  176. exonware/xwsystem/io/serialization/formats/text/json5.py +8 -4
  177. exonware/xwsystem/io/serialization/formats/text/jsonlines.py +18 -14
  178. exonware/xwsystem/io/serialization/formats/text/multipart.py +5 -5
  179. exonware/xwsystem/io/serialization/formats/text/toml.py +8 -6
  180. exonware/xwsystem/io/serialization/formats/text/xml.py +25 -20
  181. exonware/xwsystem/io/serialization/formats/text/yaml.py +8 -6
  182. exonware/xwsystem/io/serialization/parsers/__init__.py +3 -2
  183. exonware/xwsystem/io/serialization/parsers/base.py +6 -5
  184. exonware/xwsystem/io/serialization/parsers/hybrid_parser.py +7 -6
  185. exonware/xwsystem/io/serialization/parsers/msgspec_parser.py +10 -7
  186. exonware/xwsystem/io/serialization/parsers/orjson_direct_parser.py +7 -6
  187. exonware/xwsystem/io/serialization/parsers/orjson_parser.py +11 -8
  188. exonware/xwsystem/io/serialization/parsers/pysimdjson_parser.py +13 -9
  189. exonware/xwsystem/io/serialization/parsers/rapidjson_parser.py +10 -7
  190. exonware/xwsystem/io/serialization/parsers/registry.py +11 -10
  191. exonware/xwsystem/io/serialization/parsers/standard.py +7 -6
  192. exonware/xwsystem/io/serialization/parsers/ujson_parser.py +10 -7
  193. exonware/xwsystem/io/serialization/registry.py +4 -4
  194. exonware/xwsystem/io/serialization/serializer.py +168 -79
  195. exonware/xwsystem/io/serialization/universal_options.py +367 -0
  196. exonware/xwsystem/io/serialization/utils/__init__.py +1 -2
  197. exonware/xwsystem/io/serialization/utils/path_ops.py +5 -6
  198. exonware/xwsystem/io/source_reader.py +223 -0
  199. exonware/xwsystem/io/stream/__init__.py +1 -1
  200. exonware/xwsystem/io/stream/async_operations.py +61 -14
  201. exonware/xwsystem/io/stream/base.py +1 -2
  202. exonware/xwsystem/io/stream/codec_io.py +6 -7
  203. exonware/xwsystem/ipc/__init__.py +1 -0
  204. exonware/xwsystem/ipc/async_fabric.py +4 -4
  205. exonware/xwsystem/ipc/base.py +6 -5
  206. exonware/xwsystem/ipc/contracts.py +41 -66
  207. exonware/xwsystem/ipc/defs.py +2 -1
  208. exonware/xwsystem/ipc/errors.py +2 -1
  209. exonware/xwsystem/ipc/message_queue.py +5 -2
  210. exonware/xwsystem/ipc/pipes.py +70 -34
  211. exonware/xwsystem/ipc/process_manager.py +7 -5
  212. exonware/xwsystem/ipc/process_pool.py +6 -5
  213. exonware/xwsystem/ipc/shared_memory.py +64 -11
  214. exonware/xwsystem/monitoring/__init__.py +7 -0
  215. exonware/xwsystem/monitoring/base.py +11 -8
  216. exonware/xwsystem/monitoring/contracts.py +86 -144
  217. exonware/xwsystem/monitoring/defs.py +2 -1
  218. exonware/xwsystem/monitoring/error_recovery.py +16 -3
  219. exonware/xwsystem/monitoring/errors.py +2 -1
  220. exonware/xwsystem/monitoring/facade.py +183 -0
  221. exonware/xwsystem/monitoring/memory_monitor.py +1 -0
  222. exonware/xwsystem/monitoring/metrics.py +1 -0
  223. exonware/xwsystem/monitoring/performance_manager_generic.py +7 -7
  224. exonware/xwsystem/monitoring/performance_monitor.py +1 -0
  225. exonware/xwsystem/monitoring/performance_validator.py +1 -0
  226. exonware/xwsystem/monitoring/system_monitor.py +6 -5
  227. exonware/xwsystem/monitoring/tracing.py +18 -16
  228. exonware/xwsystem/monitoring/tracker.py +2 -1
  229. exonware/xwsystem/operations/__init__.py +5 -50
  230. exonware/xwsystem/operations/base.py +3 -44
  231. exonware/xwsystem/operations/contracts.py +25 -15
  232. exonware/xwsystem/operations/defs.py +1 -1
  233. exonware/xwsystem/operations/diff.py +5 -4
  234. exonware/xwsystem/operations/errors.py +1 -1
  235. exonware/xwsystem/operations/merge.py +6 -4
  236. exonware/xwsystem/operations/patch.py +5 -4
  237. exonware/xwsystem/patterns/__init__.py +1 -0
  238. exonware/xwsystem/patterns/base.py +2 -1
  239. exonware/xwsystem/patterns/context_manager.py +2 -1
  240. exonware/xwsystem/patterns/contracts.py +215 -256
  241. exonware/xwsystem/patterns/defs.py +2 -1
  242. exonware/xwsystem/patterns/dynamic_facade.py +1 -0
  243. exonware/xwsystem/patterns/errors.py +2 -4
  244. exonware/xwsystem/patterns/handler_factory.py +2 -3
  245. exonware/xwsystem/patterns/import_registry.py +1 -0
  246. exonware/xwsystem/patterns/object_pool.py +1 -0
  247. exonware/xwsystem/patterns/registry.py +4 -43
  248. exonware/xwsystem/plugins/__init__.py +2 -1
  249. exonware/xwsystem/plugins/base.py +6 -5
  250. exonware/xwsystem/plugins/contracts.py +94 -158
  251. exonware/xwsystem/plugins/defs.py +2 -1
  252. exonware/xwsystem/plugins/errors.py +2 -1
  253. exonware/xwsystem/py.typed +3 -0
  254. exonware/xwsystem/query/__init__.py +36 -0
  255. exonware/xwsystem/query/contracts.py +56 -0
  256. exonware/xwsystem/query/errors.py +22 -0
  257. exonware/xwsystem/query/registry.py +128 -0
  258. exonware/xwsystem/runtime/__init__.py +2 -1
  259. exonware/xwsystem/runtime/base.py +4 -3
  260. exonware/xwsystem/runtime/contracts.py +39 -60
  261. exonware/xwsystem/runtime/defs.py +2 -1
  262. exonware/xwsystem/runtime/env.py +11 -9
  263. exonware/xwsystem/runtime/errors.py +2 -1
  264. exonware/xwsystem/runtime/reflection.py +3 -2
  265. exonware/xwsystem/security/__init__.py +68 -11
  266. exonware/xwsystem/security/audit.py +167 -0
  267. exonware/xwsystem/security/base.py +121 -24
  268. exonware/xwsystem/security/contracts.py +91 -146
  269. exonware/xwsystem/security/crypto.py +17 -16
  270. exonware/xwsystem/security/defs.py +2 -1
  271. exonware/xwsystem/security/errors.py +2 -1
  272. exonware/xwsystem/security/facade.py +321 -0
  273. exonware/xwsystem/security/file_security.py +330 -0
  274. exonware/xwsystem/security/hazmat.py +11 -8
  275. exonware/xwsystem/security/monitor.py +372 -0
  276. exonware/xwsystem/security/path_validator.py +140 -18
  277. exonware/xwsystem/security/policy.py +357 -0
  278. exonware/xwsystem/security/resource_limits.py +1 -0
  279. exonware/xwsystem/security/validator.py +455 -0
  280. exonware/xwsystem/shared/__init__.py +14 -1
  281. exonware/xwsystem/shared/base.py +285 -2
  282. exonware/xwsystem/shared/contracts.py +415 -126
  283. exonware/xwsystem/shared/defs.py +2 -1
  284. exonware/xwsystem/shared/errors.py +2 -2
  285. exonware/xwsystem/shared/xwobject.py +316 -0
  286. exonware/xwsystem/structures/__init__.py +1 -0
  287. exonware/xwsystem/structures/base.py +3 -2
  288. exonware/xwsystem/structures/circular_detector.py +15 -14
  289. exonware/xwsystem/structures/contracts.py +53 -76
  290. exonware/xwsystem/structures/defs.py +2 -1
  291. exonware/xwsystem/structures/errors.py +2 -1
  292. exonware/xwsystem/structures/tree_walker.py +2 -1
  293. exonware/xwsystem/threading/__init__.py +21 -4
  294. exonware/xwsystem/threading/async_primitives.py +6 -5
  295. exonware/xwsystem/threading/base.py +3 -2
  296. exonware/xwsystem/threading/contracts.py +87 -143
  297. exonware/xwsystem/threading/defs.py +2 -1
  298. exonware/xwsystem/threading/errors.py +2 -1
  299. exonware/xwsystem/threading/facade.py +175 -0
  300. exonware/xwsystem/threading/locks.py +1 -0
  301. exonware/xwsystem/threading/safe_factory.py +1 -0
  302. exonware/xwsystem/utils/__init__.py +40 -0
  303. exonware/xwsystem/utils/base.py +22 -21
  304. exonware/xwsystem/utils/contracts.py +50 -73
  305. exonware/xwsystem/utils/dt/__init__.py +19 -3
  306. exonware/xwsystem/utils/dt/base.py +5 -4
  307. exonware/xwsystem/utils/dt/contracts.py +22 -29
  308. exonware/xwsystem/utils/dt/defs.py +2 -1
  309. exonware/xwsystem/utils/dt/errors.py +2 -5
  310. exonware/xwsystem/utils/dt/formatting.py +88 -2
  311. exonware/xwsystem/utils/dt/humanize.py +10 -9
  312. exonware/xwsystem/utils/dt/parsing.py +56 -5
  313. exonware/xwsystem/utils/dt/timezone_utils.py +2 -24
  314. exonware/xwsystem/utils/errors.py +2 -4
  315. exonware/xwsystem/utils/paths.py +1 -0
  316. exonware/xwsystem/utils/string.py +49 -0
  317. exonware/xwsystem/utils/test_runner.py +185 -0
  318. exonware/xwsystem/utils/utils_contracts.py +2 -1
  319. exonware/xwsystem/utils/web.py +110 -0
  320. exonware/xwsystem/validation/__init__.py +25 -1
  321. exonware/xwsystem/validation/base.py +6 -5
  322. exonware/xwsystem/validation/contracts.py +29 -41
  323. exonware/xwsystem/validation/data_validator.py +1 -0
  324. exonware/xwsystem/validation/declarative.py +11 -8
  325. exonware/xwsystem/validation/defs.py +2 -1
  326. exonware/xwsystem/validation/errors.py +2 -1
  327. exonware/xwsystem/validation/facade.py +198 -0
  328. exonware/xwsystem/validation/fluent_validator.py +22 -19
  329. exonware/xwsystem/validation/schema_discovery.py +210 -0
  330. exonware/xwsystem/validation/type_safety.py +2 -1
  331. exonware/xwsystem/version.py +2 -2
  332. {exonware_xwsystem-0.1.0.1.dist-info → exonware_xwsystem-0.1.0.4.dist-info}/METADATA +71 -4
  333. exonware_xwsystem-0.1.0.4.dist-info/RECORD +337 -0
  334. exonware/xwsystem/cli/__init__.py +0 -43
  335. exonware/xwsystem/cli/console.py +0 -113
  336. exonware/xwsystem/cli/defs.py +0 -134
  337. exonware/xwsystem/conf.py +0 -44
  338. exonware/xwsystem/security/auth.py +0 -484
  339. exonware_xwsystem-0.1.0.1.dist-info/RECORD +0 -284
  340. {exonware_xwsystem-0.1.0.1.dist-info → exonware_xwsystem-0.1.0.4.dist-info}/WHEEL +0 -0
  341. {exonware_xwsystem-0.1.0.1.dist-info → exonware_xwsystem-0.1.0.4.dist-info}/licenses/LICENSE +0 -0
@@ -1,16 +1,18 @@
1
+ #exonware/xwsystem/src/exonware/xwsystem/shared/contracts.py
1
2
  #exonware/xwsystem/shared/contracts.py
2
3
  """
3
4
  Company: eXonware.com
4
5
  Author: Eng. Muhammad AlShehri
5
6
  Email: connect@exonware.com
6
- Version: 0.1.0.1
7
+ Version: 0.1.0.4
7
8
  Generation Date: September 10, 2025
8
9
 
9
10
  Shared protocol interfaces (merged from the former core module).
10
11
  """
11
12
 
12
- from abc import ABC, abstractmethod
13
- from typing import Any, Iterator, Optional, Union
13
+ from typing import Protocol, runtime_checkable
14
+ from typing import Any, Iterator, Optional
15
+ from datetime import datetime
14
16
 
15
17
  from .defs import CloneMode, CoreMode, CorePriority, CoreState, DataType
16
18
 
@@ -20,7 +22,8 @@ from .defs import CloneMode, CoreMode, CorePriority, CoreState, DataType
20
22
  # ============================================================================
21
23
 
22
24
 
23
- class IID(ABC):
25
+ @runtime_checkable
26
+ class IID(Protocol):
24
27
  """
25
28
  Interface for objects that have unique identification.
26
29
 
@@ -28,7 +31,6 @@ class IID(ABC):
28
31
  """
29
32
 
30
33
  @property
31
- @abstractmethod
32
34
  def id(self) -> str:
33
35
  """
34
36
  Get the primary identifier.
@@ -36,10 +38,9 @@ class IID(ABC):
36
38
  Returns:
37
39
  Primary ID string
38
40
  """
39
- pass
41
+ ...
40
42
 
41
43
  @property
42
- @abstractmethod
43
44
  def uid(self) -> str:
44
45
  """
45
46
  Get the unique identifier (UUID).
@@ -47,9 +48,8 @@ class IID(ABC):
47
48
  Returns:
48
49
  UUID string
49
50
  """
50
- pass
51
+ ...
51
52
 
52
- @abstractmethod
53
53
  def generate_id(self) -> str:
54
54
  """
55
55
  Generate a new ID.
@@ -57,9 +57,8 @@ class IID(ABC):
57
57
  Returns:
58
58
  New ID string
59
59
  """
60
- pass
60
+ ...
61
61
 
62
- @abstractmethod
63
62
  def validate_id(self, id_value: str) -> bool:
64
63
  """
65
64
  Validate an ID format.
@@ -70,9 +69,8 @@ class IID(ABC):
70
69
  Returns:
71
70
  True if valid
72
71
  """
73
- pass
72
+ ...
74
73
 
75
- @abstractmethod
76
74
  def is_same_id(self, other: "IID") -> bool:
77
75
  """
78
76
  Check if this object has the same ID as another.
@@ -83,7 +81,7 @@ class IID(ABC):
83
81
  Returns:
84
82
  True if same ID
85
83
  """
86
- pass
84
+ ...
87
85
 
88
86
 
89
87
  # ============================================================================
@@ -91,14 +89,14 @@ class IID(ABC):
91
89
  # ============================================================================
92
90
 
93
91
 
94
- class IStringable(ABC):
92
+ @runtime_checkable
93
+ class IStringable(Protocol):
95
94
  """
96
95
  Interface for objects that can convert to/from string representation.
97
96
 
98
97
  Enforces consistent string conversion behavior across XWSystem.
99
98
  """
100
99
 
101
- @abstractmethod
102
100
  def to_string(self) -> str:
103
101
  """
104
102
  Convert object to string representation.
@@ -106,9 +104,8 @@ class IStringable(ABC):
106
104
  Returns:
107
105
  String representation of the object
108
106
  """
109
- pass
107
+ ...
110
108
 
111
- @abstractmethod
112
109
  def from_string(self, string: str) -> bool:
113
110
  """
114
111
  Initialize object from string representation.
@@ -119,17 +116,17 @@ class IStringable(ABC):
119
116
  Returns:
120
117
  True if parsing was successful, False otherwise
121
118
  """
122
- pass
119
+ ...
123
120
 
124
121
 
125
- class INative(ABC):
122
+ @runtime_checkable
123
+ class INative(Protocol):
126
124
  """
127
125
  Interface for objects that can convert to/from native Python types.
128
126
 
129
127
  Enforces consistent native data conversion across XWSystem.
130
128
  """
131
129
 
132
- @abstractmethod
133
130
  def to_native(self) -> Any:
134
131
  """
135
132
  Convert to native Python object.
@@ -137,9 +134,8 @@ class INative(ABC):
137
134
  Returns:
138
135
  Native Python object (dict, list, str, int, float, bool, etc.)
139
136
  """
140
- pass
137
+ ...
141
138
 
142
- @abstractmethod
143
139
  def from_native(self, data: Any) -> "INative":
144
140
  """
145
141
  Create from native Python object.
@@ -150,9 +146,8 @@ class INative(ABC):
150
146
  Returns:
151
147
  New instance created from native data
152
148
  """
153
- pass
149
+ ...
154
150
 
155
- @abstractmethod
156
151
  def is_native_compatible(self, data: Any) -> bool:
157
152
  """
158
153
  Check if data is compatible with native conversion.
@@ -163,9 +158,8 @@ class INative(ABC):
163
158
  Returns:
164
159
  True if compatible
165
160
  """
166
- pass
161
+ ...
167
162
 
168
- @abstractmethod
169
163
  def get_native_type(self) -> DataType:
170
164
  """
171
165
  Get the native data type.
@@ -173,7 +167,136 @@ class INative(ABC):
173
167
  Returns:
174
168
  DataType enum value
175
169
  """
176
- pass
170
+ ...
171
+
172
+
173
+ # ============================================================================
174
+ # CORE OBJECT INTERFACE
175
+ # ============================================================================
176
+
177
+
178
+ @runtime_checkable
179
+ class IObject(IID, INative, Protocol):
180
+ """
181
+ Core interface for all objects in the eXonware ecosystem.
182
+
183
+ This is the foundational object interface that combines identity (IID),
184
+ native conversion (INative), timestamps, metadata (title/description),
185
+ serialization, and storage operations. This interface can be used by
186
+ xwauth, xwstorage, xwentity, and other libraries to ensure consistency.
187
+
188
+ Objects implementing IObject can be:
189
+ - Identified (id, uid)
190
+ - Converted to/from native Python types (to_native, from_native)
191
+ - Tracked with timestamps (created_at, updated_at)
192
+ - Described with metadata (title, description)
193
+ - Serialized (to_dict)
194
+ - Stored and loaded (save, load)
195
+ """
196
+
197
+ @property
198
+ def created_at(self) -> datetime:
199
+ """
200
+ Get the creation timestamp.
201
+
202
+ Returns:
203
+ Creation datetime
204
+ """
205
+ ...
206
+
207
+ @property
208
+ def updated_at(self) -> datetime:
209
+ """
210
+ Get the last update timestamp.
211
+
212
+ Returns:
213
+ Last update datetime
214
+ """
215
+ ...
216
+
217
+ @property
218
+ def title(self) -> Optional[str]:
219
+ """
220
+ Get the object title.
221
+
222
+ Returns:
223
+ Title string or None if not set
224
+ """
225
+ ...
226
+
227
+ @property
228
+ def description(self) -> Optional[str]:
229
+ """
230
+ Get the object description.
231
+
232
+ Returns:
233
+ Description string or None if not set
234
+ """
235
+ ...
236
+
237
+ def to_dict(self) -> dict[str, Any]:
238
+ """
239
+ Export object as dictionary.
240
+
241
+ Should include id, uid, created_at, updated_at, title, description,
242
+ and any object-specific data.
243
+
244
+ Returns:
245
+ Dictionary representation of the object
246
+ """
247
+ ...
248
+
249
+ def save(self, *args, **kwargs) -> None:
250
+ """
251
+ Save object to storage.
252
+
253
+ Subclasses implement object-specific storage logic. This method
254
+ can be decorated with @XWAction to enable action-based execution,
255
+ validation, and authorization.
256
+
257
+ Args:
258
+ *args: Positional arguments (implementation-specific)
259
+ **kwargs: Keyword arguments (implementation-specific)
260
+ """
261
+ ...
262
+
263
+ def load(self, *args, **kwargs) -> None:
264
+ """
265
+ Load object from storage.
266
+
267
+ Subclasses implement object-specific loading logic. This method
268
+ can be decorated with @XWAction to enable action-based execution,
269
+ validation, and authorization.
270
+
271
+ Args:
272
+ *args: Positional arguments (implementation-specific)
273
+ **kwargs: Keyword arguments (implementation-specific)
274
+ """
275
+ ...
276
+
277
+ def __getitem__(self, key: str) -> Any:
278
+ """
279
+ Get object property using dictionary-style access.
280
+
281
+ Supports accessing properties like:
282
+ - obj["uid"] -> returns uid property
283
+ - obj["title"] -> returns title property
284
+ - obj["description"] -> returns description property
285
+ - obj["id"] -> returns id property
286
+ - obj["created_at"] -> returns created_at property
287
+ - obj["updated_at"] -> returns updated_at property
288
+ - obj["property_name"] -> returns any other attribute
289
+
290
+ Args:
291
+ key: Property name to access
292
+
293
+ Returns:
294
+ Property value
295
+
296
+ Raises:
297
+ KeyError: If property doesn't exist
298
+ """
299
+ ...
177
300
 
178
301
 
179
302
  # ============================================================================
@@ -181,14 +304,14 @@ class INative(ABC):
181
304
  # ============================================================================
182
305
 
183
306
 
184
- class ICloneable(ABC):
307
+ @runtime_checkable
308
+ class ICloneable(Protocol):
185
309
  """
186
310
  Interface for objects that can be cloned.
187
311
 
188
312
  Enforces consistent cloning behavior across XWSystem.
189
313
  """
190
314
 
191
- @abstractmethod
192
315
  def clone(self, mode: CloneMode = CloneMode.DEEP) -> "ICloneable":
193
316
  """
194
317
  Create a clone of this object.
@@ -199,9 +322,8 @@ class ICloneable(ABC):
199
322
  Returns:
200
323
  Cloned object
201
324
  """
202
- pass
325
+ ...
203
326
 
204
- @abstractmethod
205
327
  def deep_clone(self) -> "ICloneable":
206
328
  """
207
329
  Create a deep clone.
@@ -209,9 +331,8 @@ class ICloneable(ABC):
209
331
  Returns:
210
332
  Deep cloned object
211
333
  """
212
- pass
334
+ ...
213
335
 
214
- @abstractmethod
215
336
  def shallow_clone(self) -> "ICloneable":
216
337
  """
217
338
  Create a shallow clone.
@@ -219,9 +340,8 @@ class ICloneable(ABC):
219
340
  Returns:
220
341
  Shallow cloned object
221
342
  """
222
- pass
343
+ ...
223
344
 
224
- @abstractmethod
225
345
  def reference_clone(self) -> "ICloneable":
226
346
  """
227
347
  Create a reference clone (same object, different reference).
@@ -229,9 +349,8 @@ class ICloneable(ABC):
229
349
  Returns:
230
350
  Reference cloned object
231
351
  """
232
- pass
352
+ ...
233
353
 
234
- @abstractmethod
235
354
  def is_cloneable(self, mode: CloneMode = CloneMode.DEEP) -> bool:
236
355
  """
237
356
  Check if object can be cloned in given mode.
@@ -242,7 +361,7 @@ class ICloneable(ABC):
242
361
  Returns:
243
362
  True if cloneable
244
363
  """
245
- pass
364
+ ...
246
365
 
247
366
 
248
367
  # ============================================================================
@@ -250,14 +369,14 @@ class ICloneable(ABC):
250
369
  # ============================================================================
251
370
 
252
371
 
253
- class IComparable(ABC):
372
+ @runtime_checkable
373
+ class IComparable(Protocol):
254
374
  """
255
375
  Interface for objects that can be compared.
256
376
 
257
377
  Enforces consistent comparison behavior across XWSystem.
258
378
  """
259
379
 
260
- @abstractmethod
261
380
  def equals(self, other: Any) -> bool:
262
381
  """
263
382
  Check if this object equals another.
@@ -268,9 +387,8 @@ class IComparable(ABC):
268
387
  Returns:
269
388
  True if equal
270
389
  """
271
- pass
390
+ ...
272
391
 
273
- @abstractmethod
274
392
  def compare_to(self, other: Any) -> int:
275
393
  """
276
394
  Compare this object to another.
@@ -281,9 +399,8 @@ class IComparable(ABC):
281
399
  Returns:
282
400
  -1 if less than, 0 if equal, 1 if greater than
283
401
  """
284
- pass
402
+ ...
285
403
 
286
- @abstractmethod
287
404
  def hash_code(self) -> int:
288
405
  """
289
406
  Get hash code for this object.
@@ -291,9 +408,8 @@ class IComparable(ABC):
291
408
  Returns:
292
409
  Hash code
293
410
  """
294
- pass
411
+ ...
295
412
 
296
- @abstractmethod
297
413
  def is_comparable(self, other: Any) -> bool:
298
414
  """
299
415
  Check if this object can be compared to another.
@@ -304,7 +420,7 @@ class IComparable(ABC):
304
420
  Returns:
305
421
  True if comparable
306
422
  """
307
- pass
423
+ ...
308
424
 
309
425
 
310
426
  # ============================================================================
@@ -312,14 +428,14 @@ class IComparable(ABC):
312
428
  # ============================================================================
313
429
 
314
430
 
315
- class IIterable(ABC):
431
+ @runtime_checkable
432
+ class IIterable(Protocol):
316
433
  """
317
434
  Interface for objects that can be iterated.
318
435
 
319
436
  Enforces consistent iteration behavior across XWSystem.
320
437
  """
321
438
 
322
- @abstractmethod
323
439
  def __iter__(self) -> Iterator[Any]:
324
440
  """
325
441
  Get iterator for this object.
@@ -327,9 +443,8 @@ class IIterable(ABC):
327
443
  Returns:
328
444
  Iterator
329
445
  """
330
- pass
446
+ ...
331
447
 
332
- @abstractmethod
333
448
  def __len__(self) -> int:
334
449
  """
335
450
  Get length of this object.
@@ -337,9 +452,8 @@ class IIterable(ABC):
337
452
  Returns:
338
453
  Length
339
454
  """
340
- pass
455
+ ...
341
456
 
342
- @abstractmethod
343
457
  def __contains__(self, item: Any) -> bool:
344
458
  """
345
459
  Check if object contains item.
@@ -350,9 +464,8 @@ class IIterable(ABC):
350
464
  Returns:
351
465
  True if contains
352
466
  """
353
- pass
467
+ ...
354
468
 
355
- @abstractmethod
356
469
  def is_iterable(self) -> bool:
357
470
  """
358
471
  Check if object is iterable.
@@ -360,9 +473,8 @@ class IIterable(ABC):
360
473
  Returns:
361
474
  True if iterable
362
475
  """
363
- pass
476
+ ...
364
477
 
365
- @abstractmethod
366
478
  def get_iterator_type(self) -> str:
367
479
  """
368
480
  Get the type of iterator this object provides.
@@ -370,7 +482,7 @@ class IIterable(ABC):
370
482
  Returns:
371
483
  Iterator type name
372
484
  """
373
- pass
485
+ ...
374
486
 
375
487
 
376
488
  # ============================================================================
@@ -378,14 +490,14 @@ class IIterable(ABC):
378
490
  # ============================================================================
379
491
 
380
492
 
381
- class IContainer(ABC):
493
+ @runtime_checkable
494
+ class IContainer(Protocol):
382
495
  """
383
496
  Interface for objects that act as containers.
384
497
 
385
498
  Enforces consistent container behavior across XWSystem.
386
499
  """
387
500
 
388
- @abstractmethod
389
501
  def add(self, item: Any) -> bool:
390
502
  """
391
503
  Add item to container.
@@ -396,9 +508,8 @@ class IContainer(ABC):
396
508
  Returns:
397
509
  True if added successfully
398
510
  """
399
- pass
511
+ ...
400
512
 
401
- @abstractmethod
402
513
  def remove(self, item: Any) -> bool:
403
514
  """
404
515
  Remove item from container.
@@ -409,16 +520,14 @@ class IContainer(ABC):
409
520
  Returns:
410
521
  True if removed successfully
411
522
  """
412
- pass
523
+ ...
413
524
 
414
- @abstractmethod
415
525
  def clear(self) -> None:
416
526
  """
417
527
  Clear all items from container.
418
528
  """
419
- pass
529
+ ...
420
530
 
421
- @abstractmethod
422
531
  def is_empty(self) -> bool:
423
532
  """
424
533
  Check if container is empty.
@@ -426,9 +535,8 @@ class IContainer(ABC):
426
535
  Returns:
427
536
  True if empty
428
537
  """
429
- pass
538
+ ...
430
539
 
431
- @abstractmethod
432
540
  def size(self) -> int:
433
541
  """
434
542
  Get size of container.
@@ -436,9 +544,8 @@ class IContainer(ABC):
436
544
  Returns:
437
545
  Number of items
438
546
  """
439
- pass
547
+ ...
440
548
 
441
- @abstractmethod
442
549
  def contains(self, item: Any) -> bool:
443
550
  """
444
551
  Check if container contains item.
@@ -449,7 +556,7 @@ class IContainer(ABC):
449
556
  Returns:
450
557
  True if contains
451
558
  """
452
- pass
559
+ ...
453
560
 
454
561
 
455
562
  # ============================================================================
@@ -457,14 +564,14 @@ class IContainer(ABC):
457
564
  # ============================================================================
458
565
 
459
566
 
460
- class IMetadata(ABC):
567
+ @runtime_checkable
568
+ class IMetadata(Protocol):
461
569
  """
462
570
  Interface for objects that have metadata.
463
571
 
464
572
  Enforces consistent metadata handling across XWSystem.
465
573
  """
466
574
 
467
- @abstractmethod
468
575
  def get_metadata(self, key: str) -> Any:
469
576
  """
470
577
  Get metadata value by key.
@@ -475,9 +582,8 @@ class IMetadata(ABC):
475
582
  Returns:
476
583
  Metadata value
477
584
  """
478
- pass
585
+ ...
479
586
 
480
- @abstractmethod
481
587
  def set_metadata(self, key: str, value: Any) -> None:
482
588
  """
483
589
  Set metadata value by key.
@@ -486,9 +592,8 @@ class IMetadata(ABC):
486
592
  key: Metadata key
487
593
  value: Metadata value
488
594
  """
489
- pass
595
+ ...
490
596
 
491
- @abstractmethod
492
597
  def has_metadata(self, key: str) -> bool:
493
598
  """
494
599
  Check if metadata key exists.
@@ -499,9 +604,8 @@ class IMetadata(ABC):
499
604
  Returns:
500
605
  True if exists
501
606
  """
502
- pass
607
+ ...
503
608
 
504
- @abstractmethod
505
609
  def remove_metadata(self, key: str) -> bool:
506
610
  """
507
611
  Remove metadata by key.
@@ -512,9 +616,8 @@ class IMetadata(ABC):
512
616
  Returns:
513
617
  True if removed
514
618
  """
515
- pass
619
+ ...
516
620
 
517
- @abstractmethod
518
621
  def get_all_metadata(self) -> dict[str, Any]:
519
622
  """
520
623
  Get all metadata.
@@ -522,14 +625,13 @@ class IMetadata(ABC):
522
625
  Returns:
523
626
  Dictionary of all metadata
524
627
  """
525
- pass
628
+ ...
526
629
 
527
- @abstractmethod
528
630
  def clear_metadata(self) -> None:
529
631
  """
530
632
  Clear all metadata.
531
633
  """
532
- pass
634
+ ...
533
635
 
534
636
 
535
637
  # ============================================================================
@@ -537,34 +639,30 @@ class IMetadata(ABC):
537
639
  # ============================================================================
538
640
 
539
641
 
540
- class ILifecycle(ABC):
642
+ @runtime_checkable
643
+ class ILifecycle(Protocol):
541
644
  """
542
645
  Interface for objects with lifecycle management.
543
646
 
544
647
  Enforces consistent lifecycle behavior across XWSystem.
545
648
  """
546
649
 
547
- @abstractmethod
548
650
  def initialize(self) -> None:
549
651
  """Initialize the object."""
550
- pass
652
+ ...
551
653
 
552
- @abstractmethod
553
654
  def start(self) -> None:
554
655
  """Start the object."""
555
- pass
656
+ ...
556
657
 
557
- @abstractmethod
558
658
  def stop(self) -> None:
559
659
  """Stop the object."""
560
- pass
660
+ ...
561
661
 
562
- @abstractmethod
563
662
  def shutdown(self) -> None:
564
663
  """Shutdown the object."""
565
- pass
664
+ ...
566
665
 
567
- @abstractmethod
568
666
  def is_initialized(self) -> bool:
569
667
  """
570
668
  Check if object is initialized.
@@ -572,9 +670,8 @@ class ILifecycle(ABC):
572
670
  Returns:
573
671
  True if initialized
574
672
  """
575
- pass
673
+ ...
576
674
 
577
- @abstractmethod
578
675
  def is_running(self) -> bool:
579
676
  """
580
677
  Check if object is running.
@@ -582,9 +679,8 @@ class ILifecycle(ABC):
582
679
  Returns:
583
680
  True if running
584
681
  """
585
- pass
682
+ ...
586
683
 
587
- @abstractmethod
588
684
  def get_state(self) -> str:
589
685
  """
590
686
  Get current state.
@@ -592,7 +688,7 @@ class ILifecycle(ABC):
592
688
  Returns:
593
689
  Current state string
594
690
  """
595
- pass
691
+ ...
596
692
 
597
693
 
598
694
  # ============================================================================
@@ -600,14 +696,14 @@ class ILifecycle(ABC):
600
696
  # ============================================================================
601
697
 
602
698
 
603
- class IFactory(ABC):
699
+ @runtime_checkable
700
+ class IFactory(Protocol):
604
701
  """
605
702
  Interface for factory objects.
606
703
 
607
704
  Enforces consistent factory behavior across XWSystem.
608
705
  """
609
706
 
610
- @abstractmethod
611
707
  def create(self, *args, **kwargs) -> Any:
612
708
  """
613
709
  Create a new instance.
@@ -619,9 +715,8 @@ class IFactory(ABC):
619
715
  Returns:
620
716
  New instance
621
717
  """
622
- pass
718
+ ...
623
719
 
624
- @abstractmethod
625
720
  def create_from_config(self, config: dict[str, Any]) -> Any:
626
721
  """
627
722
  Create instance from configuration.
@@ -632,9 +727,8 @@ class IFactory(ABC):
632
727
  Returns:
633
728
  New instance
634
729
  """
635
- pass
730
+ ...
636
731
 
637
- @abstractmethod
638
732
  def get_supported_types(self) -> list[str]:
639
733
  """
640
734
  Get list of supported types.
@@ -642,9 +736,8 @@ class IFactory(ABC):
642
736
  Returns:
643
737
  List of supported type names
644
738
  """
645
- pass
739
+ ...
646
740
 
647
- @abstractmethod
648
741
  def can_create(self, type_name: str) -> bool:
649
742
  """
650
743
  Check if factory can create type.
@@ -655,7 +748,7 @@ class IFactory(ABC):
655
748
  Returns:
656
749
  True if can create
657
750
  """
658
- pass
751
+ ...
659
752
 
660
753
 
661
754
  # ============================================================================
@@ -663,48 +756,244 @@ class IFactory(ABC):
663
756
  # ============================================================================
664
757
 
665
758
 
666
- class ICore(ABC):
759
+ @runtime_checkable
760
+ class ICore(Protocol):
667
761
  """Interface for core functionality."""
668
762
 
669
763
  @property
670
- @abstractmethod
671
764
  def mode(self) -> CoreMode:
672
765
  """Get core mode."""
673
- pass
766
+ ...
674
767
 
675
768
  @property
676
- @abstractmethod
677
769
  def state(self) -> CoreState:
678
770
  """Get core state."""
679
- pass
771
+ ...
680
772
 
681
- @abstractmethod
682
773
  def initialize(self) -> None:
683
774
  """Initialize core functionality."""
684
- pass
775
+ ...
685
776
 
686
- @abstractmethod
687
777
  def shutdown(self) -> None:
688
778
  """Shutdown core functionality."""
689
- pass
779
+ ...
690
780
 
691
- @abstractmethod
692
781
  def is_initialized(self) -> bool:
693
782
  """Check if core is initialized."""
694
- pass
783
+ ...
695
784
 
696
- @abstractmethod
697
785
  def is_shutdown(self) -> bool:
698
786
  """Check if core is shutdown."""
699
- pass
787
+ ...
700
788
 
701
- @abstractmethod
702
789
  def get_dependencies(self) -> list[str]:
703
790
  """Get all dependencies."""
704
- pass
791
+ ...
705
792
 
706
- @abstractmethod
707
793
  def check_dependencies(self) -> bool:
708
794
  """Check if all dependencies are satisfied."""
709
- pass
795
+ ...
796
+
797
+
798
+ # ============================================================================
799
+ # PROVIDER INTERFACES (for xwauth/xwstorage decoupling)
800
+ # ============================================================================
801
+ # These minimal basic interfaces enable dependency inversion to avoid circular
802
+ # dependencies between xwauth and xwstorage. They are defined here in xwsystem
803
+ # (the foundation) so both libraries can import them without creating circular
804
+ # dependencies.
805
+ #
806
+ # Architecture:
807
+ # - xwsystem defines IBasicProviderAuth and IBasicProviderStorage (minimal core)
808
+ # - xwstorage extends IBasicProviderAuth to IAuthProvider (full interface)
809
+ # - xwauth extends IBasicProviderStorage to IStorageProvider (full interface)
810
+ # - xwentity uses IBasicProviderAuth and IBasicProviderStorage from xwsystem
811
+ #
812
+ # Data models (User, Token, Session, etc.) stay in their original locations:
813
+ # - xwstorage/auth/interface.py - TokenValidationResult, TokenIntrospectionResult, User
814
+ # - xwauth/storage/interface.py - User, Session, Token, AuditLog, etc.
815
+
816
+
817
+ # ============================================================================
818
+ # BASIC AUTH PROVIDER INTERFACE
819
+ # ============================================================================
820
+
821
+ @runtime_checkable
822
+ class IBasicProviderAuth(Protocol):
823
+ """
824
+ Basic authentication provider interface (minimal core).
825
+
826
+ This minimal interface provides only the essential auth operations needed
827
+ by xwstorage and xwentity. Full IAuthProvider extends this with additional
828
+ methods (validate_token, introspect_token, etc.).
829
+
830
+ Defined in xwsystem to serve as single source of truth for all libraries.
831
+ Uses simple types (dict, str, list) that can be replaced at runtime by
832
+ advanced objects in external projects.
833
+ """
834
+
835
+ async def check_permission(
836
+ self,
837
+ user_id: str,
838
+ resource: str,
839
+ action: str
840
+ ) -> bool:
841
+ """
842
+ Check if a user has permission for a resource action.
843
+
844
+ Args:
845
+ user_id: User identifier
846
+ resource: Resource identifier (e.g., "bucket:my-bucket", "entity:entity_id")
847
+ action: Action to check (e.g., "read", "write", "delete", "admin")
848
+
849
+ Returns:
850
+ True if user has permission, False otherwise
851
+ """
852
+ ...
853
+
854
+ async def get_user_roles(self, user_id: str) -> list[str]:
855
+ """
856
+ Get list of roles for a user.
857
+
858
+ Args:
859
+ user_id: User identifier
860
+
861
+ Returns:
862
+ List of role names
863
+ """
864
+ ...
865
+
866
+ async def validate_token(self, token: str) -> dict[str, Any]:
867
+ """
868
+ Validate a token and return simple token information.
869
+
870
+ Returns a simple dict with:
871
+ - valid: bool - Whether token is valid
872
+ - user_id: Optional[str] - User ID if valid
873
+ - scopes: list[str] - List of scopes
874
+ - expires_at: Optional[float] - Expiration timestamp
875
+
876
+ Args:
877
+ token: Token string to validate
878
+
879
+ Returns:
880
+ Dictionary with token validation result (simple types only)
881
+ """
882
+ ...
883
+
884
+
885
+ # ============================================================================
886
+ # BASIC STORAGE PROVIDER INTERFACE
887
+ # ============================================================================
710
888
 
889
+ @runtime_checkable
890
+ class IBasicProviderStorage(Protocol):
891
+ """
892
+ Basic storage provider interface (minimal, generic core).
893
+
894
+ This minimal interface provides generic CRUD operations that work with
895
+ ANY entity/table/object type. Full IStorageProvider extends this with
896
+ domain-specific convenience methods (save_user, get_session, etc.).
897
+
898
+ Defined in xwsystem to serve as single source of truth for all libraries.
899
+ The interface is entity-agnostic - it works with any entity type.
900
+ """
901
+
902
+ async def save(
903
+ self,
904
+ entity_type: str,
905
+ entity_id: str,
906
+ data: dict[str, Any]
907
+ ) -> None:
908
+ """
909
+ Save entity to storage.
910
+
911
+ Args:
912
+ entity_type: Entity type identifier (e.g., "user", "session", "token", "product")
913
+ entity_id: Entity identifier
914
+ data: Entity data dictionary
915
+ """
916
+ ...
917
+
918
+ async def get(
919
+ self,
920
+ entity_type: str,
921
+ entity_id: str
922
+ ) -> Optional[dict[str, Any]]:
923
+ """
924
+ Get entity by ID.
925
+
926
+ Args:
927
+ entity_type: Entity type identifier
928
+ entity_id: Entity identifier
929
+
930
+ Returns:
931
+ Entity data dictionary if found, None otherwise
932
+ """
933
+ ...
934
+
935
+ async def get_by_field(
936
+ self,
937
+ entity_type: str,
938
+ field: str,
939
+ value: Any
940
+ ) -> Optional[dict[str, Any]]:
941
+ """
942
+ Get entity by field value.
943
+
944
+ Args:
945
+ entity_type: Entity type identifier
946
+ field: Field name to search by
947
+ value: Field value to match
948
+
949
+ Returns:
950
+ Entity data dictionary if found, None otherwise
951
+ """
952
+ ...
953
+
954
+ async def update(
955
+ self,
956
+ entity_type: str,
957
+ entity_id: str,
958
+ updates: dict[str, Any]
959
+ ) -> None:
960
+ """
961
+ Update entity data.
962
+
963
+ Args:
964
+ entity_type: Entity type identifier
965
+ entity_id: Entity identifier
966
+ updates: Dictionary of fields to update
967
+ """
968
+ ...
969
+
970
+ async def delete(
971
+ self,
972
+ entity_type: str,
973
+ entity_id: str
974
+ ) -> None:
975
+ """
976
+ Delete entity from storage.
977
+
978
+ Args:
979
+ entity_type: Entity type identifier
980
+ entity_id: Entity identifier
981
+ """
982
+ ...
983
+
984
+ async def list(
985
+ self,
986
+ entity_type: str,
987
+ filters: Optional[dict[str, Any]] = None
988
+ ) -> list[dict[str, Any]]:
989
+ """
990
+ List entities with optional filters.
991
+
992
+ Args:
993
+ entity_type: Entity type identifier
994
+ filters: Optional filter dictionary (e.g., {"status": "active"})
995
+
996
+ Returns:
997
+ List of entity data dictionaries
998
+ """
999
+ ...