matrx-files 0.1.0__tar.gz

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 (236) hide show
  1. matrx_files-0.1.0/.gitignore +271 -0
  2. matrx_files-0.1.0/CLAUDE.md +47 -0
  3. matrx_files-0.1.0/DEPLOY.md +49 -0
  4. matrx_files-0.1.0/Dockerfile +31 -0
  5. matrx_files-0.1.0/INDEPENDENCE.md +61 -0
  6. matrx_files-0.1.0/PKG-INFO +74 -0
  7. matrx_files-0.1.0/README.md +5 -0
  8. matrx_files-0.1.0/matrx_files/FEATURE.md +230 -0
  9. matrx_files-0.1.0/matrx_files/MODULE_README.md +242 -0
  10. matrx_files-0.1.0/matrx_files/__init__.py +395 -0
  11. matrx_files-0.1.0/matrx_files/_config.py +89 -0
  12. matrx_files-0.1.0/matrx_files/analysis/__init__.py +104 -0
  13. matrx_files-0.1.0/matrx_files/analysis/context.py +52 -0
  14. matrx_files-0.1.0/matrx_files/analysis/dispatcher.py +547 -0
  15. matrx_files-0.1.0/matrx_files/analysis/label_catalog.py +249 -0
  16. matrx_files-0.1.0/matrx_files/analysis/ocr_router.py +89 -0
  17. matrx_files-0.1.0/matrx_files/analysis/persistence.py +293 -0
  18. matrx_files-0.1.0/matrx_files/analysis/preferences.py +153 -0
  19. matrx_files-0.1.0/matrx_files/analysis/protocol.py +165 -0
  20. matrx_files-0.1.0/matrx_files/analysis/registry.py +129 -0
  21. matrx_files-0.1.0/matrx_files/analysis/text_sanitize.py +87 -0
  22. matrx_files-0.1.0/matrx_files/api/__init__.py +23 -0
  23. matrx_files-0.1.0/matrx_files/api/router.py +24 -0
  24. matrx_files-0.1.0/matrx_files/api/router_assets.py +344 -0
  25. matrx_files-0.1.0/matrx_files/api/router_files.py +497 -0
  26. matrx_files-0.1.0/matrx_files/api/router_share.py +71 -0
  27. matrx_files-0.1.0/matrx_files/asset_builder.py +239 -0
  28. matrx_files-0.1.0/matrx_files/asset_envelope.py +462 -0
  29. matrx_files-0.1.0/matrx_files/backends/__init__.py +33 -0
  30. matrx_files-0.1.0/matrx_files/backends/base_backend.py +192 -0
  31. matrx_files-0.1.0/matrx_files/backends/llm_helpers.py +189 -0
  32. matrx_files-0.1.0/matrx_files/backends/router.py +638 -0
  33. matrx_files-0.1.0/matrx_files/backends/s3_backend.py +625 -0
  34. matrx_files-0.1.0/matrx_files/backends/server_backend.py +358 -0
  35. matrx_files-0.1.0/matrx_files/backends/supabase_backend.py +438 -0
  36. matrx_files-0.1.0/matrx_files/backends/url_parser.py +215 -0
  37. matrx_files-0.1.0/matrx_files/base_handler.py +21 -0
  38. matrx_files-0.1.0/matrx_files/batch_handler.py +89 -0
  39. matrx_files-0.1.0/matrx_files/cloud_mixin.py +202 -0
  40. matrx_files-0.1.0/matrx_files/cloud_sync/__init__.py +117 -0
  41. matrx_files-0.1.0/matrx_files/cloud_sync/_media_resolution.py +606 -0
  42. matrx_files-0.1.0/matrx_files/cloud_sync/backfill/__init__.py +17 -0
  43. matrx_files-0.1.0/matrx_files/cloud_sync/backfill/rekey.py +267 -0
  44. matrx_files-0.1.0/matrx_files/cloud_sync/backfill/restamp_headers.py +235 -0
  45. matrx_files-0.1.0/matrx_files/cloud_sync/backfill/thumbnails.py +261 -0
  46. matrx_files-0.1.0/matrx_files/cloud_sync/byte_cache.py +158 -0
  47. matrx_files-0.1.0/matrx_files/cloud_sync/cdn.py +184 -0
  48. matrx_files-0.1.0/matrx_files/cloud_sync/config.py +125 -0
  49. matrx_files-0.1.0/matrx_files/cloud_sync/db.py +974 -0
  50. matrx_files-0.1.0/matrx_files/cloud_sync/download_stream.py +251 -0
  51. matrx_files-0.1.0/matrx_files/cloud_sync/events/__init__.py +51 -0
  52. matrx_files-0.1.0/matrx_files/cloud_sync/events/default_logger.py +137 -0
  53. matrx_files-0.1.0/matrx_files/cloud_sync/idempotency.py +150 -0
  54. matrx_files-0.1.0/matrx_files/cloud_sync/media_ref.py +328 -0
  55. matrx_files-0.1.0/matrx_files/cloud_sync/migrations.py +165 -0
  56. matrx_files-0.1.0/matrx_files/cloud_sync/models.py +247 -0
  57. matrx_files-0.1.0/matrx_files/cloud_sync/permissions.py +489 -0
  58. matrx_files-0.1.0/matrx_files/cloud_sync/processing/__init__.py +8 -0
  59. matrx_files-0.1.0/matrx_files/cloud_sync/processing/thumbnails.py +214 -0
  60. matrx_files-0.1.0/matrx_files/cloud_sync/sql/001_initial_schema.sql +595 -0
  61. matrx_files-0.1.0/matrx_files/cloud_sync/sql/002_guest_support.sql +96 -0
  62. matrx_files-0.1.0/matrx_files/cloud_sync/sql/003_security_correctness_quotas.sql +1058 -0
  63. matrx_files-0.1.0/matrx_files/cloud_sync/sql/004_lineage_thumbnail_webhooks.sql +200 -0
  64. matrx_files-0.1.0/matrx_files/cloud_sync/sql/005_tus_uploads_realtime.sql +144 -0
  65. matrx_files-0.1.0/matrx_files/cloud_sync/sql/006_canonical_storage_uri.sql +55 -0
  66. matrx_files-0.1.0/matrx_files/cloud_sync/sql/007_drop_legacy_storage_uri.sql +163 -0
  67. matrx_files-0.1.0/matrx_files/cloud_sync/sql/008_idempotency.sql +81 -0
  68. matrx_files-0.1.0/matrx_files/cloud_sync/sql/009_variant_catalog_index.sql +27 -0
  69. matrx_files-0.1.0/matrx_files/cloud_sync/sql/010_canonical_media_columns.sql +267 -0
  70. matrx_files-0.1.0/matrx_files/cloud_sync/sql/011_drop_legacy_thumbnail_columns.sql +32 -0
  71. matrx_files-0.1.0/matrx_files/cloud_sync/sql/012_exclude_system_files_from_user_tree.sql +204 -0
  72. matrx_files-0.1.0/matrx_files/cloud_sync/sql/013_cleanup_cascade_variants.sql +116 -0
  73. matrx_files-0.1.0/matrx_files/cloud_sync/sql/014_user_tree_privacy_and_usability.sql +195 -0
  74. matrx_files-0.1.0/matrx_files/cloud_sync/sql/015_hide_system_namespace_from_user_tree.sql +169 -0
  75. matrx_files-0.1.0/matrx_files/cloud_sync/sql/015_legacy_storage_uri_nullable.sql +33 -0
  76. matrx_files-0.1.0/matrx_files/cloud_sync/sql/016_relocate_legacy_system_output_and_drop_scars.sql +117 -0
  77. matrx_files-0.1.0/matrx_files/cloud_sync/sync_engine.py +1969 -0
  78. matrx_files-0.1.0/matrx_files/cloud_sync/thumbnail_resolver.py +117 -0
  79. matrx_files-0.1.0/matrx_files/cloud_sync/transports/__init__.py +58 -0
  80. matrx_files-0.1.0/matrx_files/cloud_sync/transports/presigned.py +309 -0
  81. matrx_files-0.1.0/matrx_files/cloud_sync/transports/tus.py +756 -0
  82. matrx_files-0.1.0/matrx_files/cloud_sync/transports/tus_cleanup.py +206 -0
  83. matrx_files-0.1.0/matrx_files/cloud_sync/url_resolver.py +368 -0
  84. matrx_files-0.1.0/matrx_files/cloud_sync/variants.py +268 -0
  85. matrx_files-0.1.0/matrx_files/cloud_sync/variants_service.py +370 -0
  86. matrx_files-0.1.0/matrx_files/cloud_sync/versioning.py +422 -0
  87. matrx_files-0.1.0/matrx_files/content_headers.py +135 -0
  88. matrx_files-0.1.0/matrx_files/db/__init__.py +170 -0
  89. matrx_files-0.1.0/matrx_files/db/db_requirements.py +18 -0
  90. matrx_files-0.1.0/matrx_files/db/helpers/auto_config_files.py +62 -0
  91. matrx_files-0.1.0/matrx_files/db/managers/files/__init__.py +22 -0
  92. matrx_files-0.1.0/matrx_files/db/managers/files/account_tiers.py +205 -0
  93. matrx_files-0.1.0/matrx_files/db/managers/files/analysis.py +217 -0
  94. matrx_files-0.1.0/matrx_files/db/managers/files/analysis_result.py +235 -0
  95. matrx_files-0.1.0/matrx_files/db/managers/files/entities.py +229 -0
  96. matrx_files-0.1.0/matrx_files/db/managers/files/file_rag_jobs.py +223 -0
  97. matrx_files-0.1.0/matrx_files/db/managers/files/file_versions.py +223 -0
  98. matrx_files-0.1.0/matrx_files/db/managers/files/files.py +319 -0
  99. matrx_files-0.1.0/matrx_files/db/managers/files/folders.py +235 -0
  100. matrx_files-0.1.0/matrx_files/db/managers/files/idempotency.py +205 -0
  101. matrx_files-0.1.0/matrx_files/db/managers/files/overrides.py +235 -0
  102. matrx_files-0.1.0/matrx_files/db/managers/files/page_annotations.py +265 -0
  103. matrx_files-0.1.0/matrx_files/db/managers/files/pages.py +247 -0
  104. matrx_files-0.1.0/matrx_files/db/managers/files/rate_limit_buckets.py +199 -0
  105. matrx_files-0.1.0/matrx_files/db/managers/files/share_links.py +211 -0
  106. matrx_files-0.1.0/matrx_files/db/managers/files/structure.py +211 -0
  107. matrx_files-0.1.0/matrx_files/db/managers/files/uploads_inflight.py +217 -0
  108. matrx_files-0.1.0/matrx_files/db/managers/files/user_account.py +217 -0
  109. matrx_files-0.1.0/matrx_files/db/managers/files/user_storage_usage.py +205 -0
  110. matrx_files-0.1.0/matrx_files/db/managers/files/webhook_deliveries.py +217 -0
  111. matrx_files-0.1.0/matrx_files/db/managers/files/webhook_dispatch_state.py +199 -0
  112. matrx_files-0.1.0/matrx_files/db/managers/files/webhooks.py +229 -0
  113. matrx_files-0.1.0/matrx_files/db/migrations/.gitkeep +0 -0
  114. matrx_files-0.1.0/matrx_files/db/models_files.py +934 -0
  115. matrx_files-0.1.0/matrx_files/db/models_iam.py +76 -0
  116. matrx_files-0.1.0/matrx_files/dedup.py +389 -0
  117. matrx_files-0.1.0/matrx_files/file_handler.py +298 -0
  118. matrx_files-0.1.0/matrx_files/file_manager.py +869 -0
  119. matrx_files-0.1.0/matrx_files/local_files.py +129 -0
  120. matrx_files-0.1.0/matrx_files/media_sniff.py +303 -0
  121. matrx_files-0.1.0/matrx_files/service.py +1499 -0
  122. matrx_files-0.1.0/matrx_files/specific_handlers/MODULE_README.md +245 -0
  123. matrx_files-0.1.0/matrx_files/specific_handlers/__init__.py +0 -0
  124. matrx_files-0.1.0/matrx_files/specific_handlers/code_handler.py +106 -0
  125. matrx_files-0.1.0/matrx_files/specific_handlers/html_handler.py +45 -0
  126. matrx_files-0.1.0/matrx_files/specific_handlers/image_handler.py +1216 -0
  127. matrx_files-0.1.0/matrx_files/specific_handlers/image_ops/__init__.py +171 -0
  128. matrx_files-0.1.0/matrx_files/specific_handlers/image_ops/adjust.py +246 -0
  129. matrx_files-0.1.0/matrx_files/specific_handlers/image_ops/base.py +323 -0
  130. matrx_files-0.1.0/matrx_files/specific_handlers/image_ops/bg_remove.py +154 -0
  131. matrx_files-0.1.0/matrx_files/specific_handlers/image_ops/color.py +192 -0
  132. matrx_files-0.1.0/matrx_files/specific_handlers/image_ops/composite.py +305 -0
  133. matrx_files-0.1.0/matrx_files/specific_handlers/image_ops/detect.py +214 -0
  134. matrx_files-0.1.0/matrx_files/specific_handlers/image_ops/filter.py +251 -0
  135. matrx_files-0.1.0/matrx_files/specific_handlers/image_ops/geometry.py +316 -0
  136. matrx_files-0.1.0/matrx_files/specific_handlers/image_ops/inpaint.py +96 -0
  137. matrx_files-0.1.0/matrx_files/specific_handlers/image_ops/mask_ops.py +266 -0
  138. matrx_files-0.1.0/matrx_files/specific_handlers/image_ops/tone.py +175 -0
  139. matrx_files-0.1.0/matrx_files/specific_handlers/image_studio_presets.py +207 -0
  140. matrx_files-0.1.0/matrx_files/specific_handlers/json_handler.py +130 -0
  141. matrx_files-0.1.0/matrx_files/specific_handlers/markdown_handler.py +130 -0
  142. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/__init__.py +380 -0
  143. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/analyze/__init__.py +86 -0
  144. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/analyze/duplicate_pages.py +407 -0
  145. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/analyze/embedded_images.py +104 -0
  146. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/analyze/layout.py +245 -0
  147. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/analyze/metadata.py +147 -0
  148. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/analyze/models.py +128 -0
  149. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/analyze/outline.py +111 -0
  150. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/analyze/page_classification.py +66 -0
  151. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/analyze/pattern_candidates.py +255 -0
  152. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/analyze/reading_order.py +156 -0
  153. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/analyze/repeated_regions.py +519 -0
  154. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/analyze/repeated_regions_detector.py +62 -0
  155. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/analyze/tables_detector.py +51 -0
  156. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/analyze/text_extraction.py +317 -0
  157. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/cloud_ocr/__init__.py +5 -0
  158. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/concurrency.py +122 -0
  159. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/extract/__init__.py +63 -0
  160. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/extract/bbox.py +345 -0
  161. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/extract/chunking.py +162 -0
  162. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/extract/ocr.py +41 -0
  163. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/extract/region.py +132 -0
  164. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/extract/search.py +297 -0
  165. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/extract/tables.py +356 -0
  166. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/extract/text.py +307 -0
  167. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/generate/__init__.py +8 -0
  168. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/handler.py +1393 -0
  169. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/images_to_pdf.py +172 -0
  170. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/internal.py +118 -0
  171. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/ml/__init__.py +5 -0
  172. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/models.py +188 -0
  173. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/ops/__init__.py +86 -0
  174. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/ops/compose.py +114 -0
  175. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/ops/compress.py +396 -0
  176. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/ops/pages.py +354 -0
  177. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/ops/render.py +444 -0
  178. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/pipelines/__init__.py +6 -0
  179. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/pipelines/ai.py +59 -0
  180. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/redact/SCHEMA.sql +66 -0
  181. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/redact/__init__.py +135 -0
  182. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/redact/engine.py +326 -0
  183. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/redact/from_regions.py +101 -0
  184. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/redact/mapping_store.py +116 -0
  185. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/redact/models.py +117 -0
  186. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/redact/patterns.py +501 -0
  187. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/redact/reversible.py +309 -0
  188. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/redact/scrub.py +381 -0
  189. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/redact/substitutes.py +139 -0
  190. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/redact/validators.py +138 -0
  191. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/render/__init__.py +18 -0
  192. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/render/overlay.py +182 -0
  193. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/stream_bridge.py +56 -0
  194. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/studio/__init__.py +34 -0
  195. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/studio/presets.py +373 -0
  196. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/studio/render_spec.py +167 -0
  197. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/tmp.py +97 -0
  198. matrx_files-0.1.0/matrx_files/specific_handlers/pdf/wire.py +73 -0
  199. matrx_files-0.1.0/matrx_files/specific_handlers/pdf_handler.py +178 -0
  200. matrx_files-0.1.0/matrx_files/specific_handlers/ppt_handler.py +101 -0
  201. matrx_files-0.1.0/matrx_files/specific_handlers/svg_rasterizer.py +175 -0
  202. matrx_files-0.1.0/matrx_files/specific_handlers/text_handler.py +45 -0
  203. matrx_files-0.1.0/matrx_files/specific_handlers/thumbnail_source.py +632 -0
  204. matrx_files-0.1.0/matrx_files/specific_handlers/video_compose.py +316 -0
  205. matrx_files-0.1.0/matrx_files/specific_handlers/video_handler.py +230 -0
  206. matrx_files-0.1.0/matrx_files/standalone/__init__.py +0 -0
  207. matrx_files-0.1.0/matrx_files/standalone/app.py +154 -0
  208. matrx_files-0.1.0/matrx_files/system_paths.py +300 -0
  209. matrx_files-0.1.0/matrx_files/zip_stream.py +73 -0
  210. matrx_files-0.1.0/pyproject.toml +105 -0
  211. matrx_files-0.1.0/tests/cloud_sync_test.py +165 -0
  212. matrx_files-0.1.0/tests/conftest.py +12 -0
  213. matrx_files-0.1.0/tests/load_env_for_test.py +12 -0
  214. matrx_files-0.1.0/tests/test_access_checker_injection.py +130 -0
  215. matrx_files-0.1.0/tests/test_bbox_extractor.py +161 -0
  216. matrx_files-0.1.0/tests/test_content_headers.py +131 -0
  217. matrx_files-0.1.0/tests/test_dedup.py +402 -0
  218. matrx_files-0.1.0/tests/test_file_analysis_pipeline.py +360 -0
  219. matrx_files-0.1.0/tests/test_hard_delete_purge.py +111 -0
  220. matrx_files-0.1.0/tests/test_idempotency_key_stability.py +33 -0
  221. matrx_files-0.1.0/tests/test_image_studio.py +382 -0
  222. matrx_files-0.1.0/tests/test_independence_boot.py +36 -0
  223. matrx_files-0.1.0/tests/test_managed_write_dedup.py +453 -0
  224. matrx_files-0.1.0/tests/test_media_access_gate.py +157 -0
  225. matrx_files-0.1.0/tests/test_pdf_async_surface.py +176 -0
  226. matrx_files-0.1.0/tests/test_pdf_concurrency_and_tmp.py +188 -0
  227. matrx_files-0.1.0/tests/test_pdf_handler_operations.py +188 -0
  228. matrx_files-0.1.0/tests/test_pdf_phase2.py +382 -0
  229. matrx_files-0.1.0/tests/test_pdf_phase3.py +343 -0
  230. matrx_files-0.1.0/tests/test_pdf_phase4.py +421 -0
  231. matrx_files-0.1.0/tests/test_pdf_v2_helpers.py +152 -0
  232. matrx_files-0.1.0/tests/test_primitives.py +127 -0
  233. matrx_files-0.1.0/tests/test_tus_dedup.py +350 -0
  234. matrx_files-0.1.0/tests/test_uri_parsing.py +151 -0
  235. matrx_files-0.1.0/tests/test_variants.py +376 -0
  236. matrx_files-0.1.0/tests/test_zip_stream_and_iter_render.py +144 -0
@@ -0,0 +1,271 @@
1
+ *.pyc
2
+ secrets/
3
+ ignore/
4
+ temp/
5
+ logs/
6
+ # The broad `logs/` rule above is for RUNTIME log output, but it also matched
7
+ # the dashboard's SOURCE directory and silently swallowed an entire feature's
8
+ # files (only the pre-existing index.tsx stayed tracked), breaking the prod
9
+ # Docker build with "Could not resolve ./structured-tab". Re-include the source.
10
+ !apps/dashboard/src/features/logs/
11
+ !apps/dashboard/src/features/logs/**
12
+ todo
13
+ text_notes/
14
+ aidream/secrets/2.env
15
+ automation_matrix/matrix_processing/temp/*
16
+ cd
17
+ # Byte-compiled / optimized / DLL files
18
+ __pycache__/
19
+ *.py[cod]
20
+ *$py.class
21
+
22
+ # C extensions
23
+ *.so
24
+ .venv/
25
+
26
+ # Distribution / packaging
27
+ .Python
28
+ build/
29
+ develop-eggs/
30
+ dist/
31
+ downloads/
32
+ eggs/
33
+ .eggs/
34
+ lib/
35
+ lib64/
36
+ # The blanket lib/ rule above is from the standard Python .gitignore template
37
+ # and was silently swallowing TS source under the SPA `src/lib/` folders.
38
+ # Re-allow them explicitly so frontend builds don't ship without their lib layer.
39
+ !apps/dashboard/src/lib/
40
+ !apps/dashboard/src/lib/**
41
+ !apps/workflow-studio/src/lib/
42
+ !apps/workflow-studio/src/lib/**
43
+ parts/
44
+ sdist/
45
+ var/
46
+ wheels/
47
+ share/python-wheels/
48
+ *.egg-info/
49
+ .installed.cfg
50
+ *.egg
51
+ MANIFEST
52
+
53
+ # PyInstaller
54
+ # Usually these files are written by a python script from a template
55
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
56
+ *.manifest
57
+ *.spec
58
+
59
+ # Installer logs
60
+ pip-log.txt
61
+ pip-delete-this-directory.txt
62
+
63
+ # Unit test / coverage reports
64
+ ai/tests/clean_response.json
65
+ ai/tests/cx_storage_response.json
66
+ ai/tests/execution_test.py
67
+ ai/tests/final_response.json
68
+ htmlcov/
69
+ .tox/
70
+ .nox/
71
+ .coverage
72
+ .coverage.*
73
+ .cache
74
+ nosetests.xml
75
+ coverage.xml
76
+ *.cover
77
+ *.py,cover
78
+ .hypothesis/
79
+ .pytest_cache/
80
+ cover/
81
+
82
+ # Translations
83
+ *.mo
84
+ *.pot
85
+
86
+ # Django stuff:
87
+ *.log
88
+ local_settings.py
89
+ db.sqlite3
90
+ db.sqlite3-journal
91
+
92
+ # Flask stuff:
93
+ instance/
94
+ .webassets-cache
95
+
96
+ # Scrapy stuff:
97
+ .scrapy
98
+
99
+ # Sphinx documentation
100
+ docs/_build/
101
+
102
+ # PyBuilder
103
+ .pybuilder/
104
+ target/
105
+
106
+ # Jupyter Notebook
107
+ .ipynb_checkpoints
108
+
109
+ # IPython
110
+ profile_default/
111
+ ipython_config.py
112
+
113
+ # pyenv
114
+ # For a library or package, you might want to ignore these files since the code is
115
+ # intended to run in multiple environments; otherwise, check them in:
116
+ # .python-version
117
+
118
+ # pipenv
119
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
120
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
121
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
122
+ # install all needed dependencies.
123
+ #Pipfile.lock
124
+
125
+ # poetry
126
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
127
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
128
+ # commonly ignored for libraries.
129
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
130
+
131
+ # pdm
132
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
133
+ #pdm.lock
134
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
135
+ # in version control.
136
+ # https://pdm.fming.dev/#use-with-ide
137
+ .pdm.toml
138
+
139
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
140
+ __pypackages__/
141
+
142
+ # Celery stuff
143
+ celerybeat-schedule
144
+ celerybeat.pid
145
+
146
+ # SageMath parsed files
147
+ *.sage.py
148
+
149
+ # Environments
150
+ .env
151
+ .env_remote
152
+ .venv
153
+ env/
154
+ venv/
155
+ ENV/
156
+ env.bak/
157
+ venv.bak/
158
+ .env.armanonly
159
+
160
+ # Spyder project settings
161
+ .spyderproject
162
+ .spyproject
163
+
164
+ # Rope project settings
165
+ .ropeproject
166
+
167
+ # mkdocs documentation
168
+ /site
169
+
170
+ # mypy
171
+ .mypy_cache/
172
+ .dmypy.json
173
+ dmypy.json
174
+
175
+ # Pyre type checker
176
+ .pyre/
177
+
178
+ # random armani files
179
+ /armani_dev/secrets/
180
+ /armani/
181
+ /_armani/
182
+
183
+
184
+
185
+ # pytype static type analyzer
186
+ .pytype/
187
+
188
+ # Cython debug symbols
189
+ cython_debug/
190
+
191
+ .idea/
192
+ .vscode/
193
+ /node_modules/
194
+
195
+ # Frontend pnpm workspace (apps/) — node_modules at the workspace root and any
196
+ # member, plus Vite caches and build output. The unified lockfile (apps/pnpm-lock.yaml)
197
+ # IS committed; everything below is regenerated.
198
+ node_modules/
199
+ apps/**/.vite/
200
+ apps/**/dist/
201
+ .vite/
202
+
203
+ dump.rdb
204
+
205
+ frontend/
206
+
207
+ # AME Temp Files and directory structure
208
+ # Ignore all files in the temp directory and its subdirectories
209
+ /temp/**/*
210
+ /tmp/**/*
211
+
212
+ # Allow .gitkeep files to retain directory structure
213
+ !/temp/**/.gitkeep
214
+ !/tmp/**/.gitkeep
215
+
216
+ # Armani
217
+ .history*
218
+ .history/
219
+ local_data/
220
+ local_reports_data/
221
+ webscraper/quick_scrapes/temp/
222
+ automation_matrix/ai_apis/fireworks/_dev/*
223
+ automation_matrix/ai_apis/fireworks/_dev/fireworks_sample.py
224
+ *.pdf
225
+ *.flac
226
+ *.mp3
227
+ *.wav
228
+ miniconda.sh
229
+ /database/python_sql/temp_data/
230
+ .history*
231
+ .history/
232
+ .history/
233
+
234
+ _dev/
235
+ /_dev/
236
+ requirements_filtered.txt
237
+
238
+ # matrx-dev-tools backups
239
+ .env-backups/
240
+ # Matrx Ship config (contains API key)
241
+ .matrx-ship.json
242
+
243
+ # Matrx config (contains API keys)
244
+ .matrx.json
245
+ .matrx-tools.conf
246
+
247
+ # Claude Code local worktrees and per-user settings
248
+ .claude/worktrees/
249
+ .claude/settings.local.json
250
+
251
+ # Append-only snapshots from matrx_utils.update_history (unbounded; do not commit)
252
+ common/utils/data_in_code/data_history.json
253
+ packages/matrx-utils/matrx_utils/data_in_code/data_history.json
254
+
255
+ # Tool-dispatch debug logs — one file per server start, never committed
256
+ .matrx-debug/
257
+
258
+ # macOS Finder metadata
259
+ .DS_Store
260
+ **/.DS_Store
261
+
262
+ # Environment files
263
+ .env
264
+ .env.*
265
+ *.env
266
+ *.env.*
267
+
268
+ # Keep safe templates trackable
269
+ !.env.example
270
+ !.env.sample
271
+ !.env.template
@@ -0,0 +1,47 @@
1
+ # CLAUDE.md — matrx-files (development)
2
+
3
+ **All things files.** Cloud storage (S3/Supabase/CDN), media management, conversion,
4
+ PDF, sharing, analysis/OCR routing, and the package's own API layer. Carved out of
5
+ `matrx_utils.file_handling` on 2026-07-12 as the FIRST instance of the
6
+ **matrx-package-template** (`/Users/armanisadeghi/code/matrx-package-template`).
7
+
8
+ ## The law here: INDEPENDENCE.md
9
+
10
+ Read [INDEPENDENCE.md](INDEPENDENCE.md) before changing anything. This package is
11
+ **gate-enforced independent** — two gates run against it and both must stay green:
12
+
13
+ ```bash
14
+ # fast AST gate (forbidden host imports, undeclared siblings)
15
+ python /Users/armanisadeghi/code/matrx-package-template/scripts/check_imports.py packages/matrx-files
16
+ # proof by execution: bare venv, install THIS package only (+ declared siblings), boot, smoke test
17
+ /Users/armanisadeghi/code/matrx-package-template/scripts/independence_gate.sh \
18
+ packages/matrx-files packages/matrx-utils packages/matrx-connect packages/matrx-orm
19
+ ```
20
+
21
+ - ❌ NEVER import `aidream` or any host module. Need a host capability → grow a
22
+ `configure()` kwarg (`matrx_files/_config.py`) with a standalone fallback.
23
+ - ❌ NEVER add a dependency the bare-venv install can't resolve — the gate catches it
24
+ (it already caught rembg's fossil-metadata chain and the numba↔numpy cap; see
25
+ pyproject comments before "fixing" version pins).
26
+ - ✅ Every new feature adds at least one bare-venv smoke test under `tests/`.
27
+ - API surface lives in `matrx_files/api/` (router factories, caller-supplied auth dep);
28
+ `standalone/app.py` must mount everything a host can mount.
29
+
30
+ ## Consumer-side knowledge (NOT here)
31
+
32
+ How aidream uses this package (MediaRef resolution rules, `/assets` presets, URL
33
+ contract, storage_uri isolation) lives in the host docs: aidream root `CLAUDE.md`
34
+ "Files" section + [matrx_files/FEATURE.md](matrx_files/FEATURE.md) +
35
+ [matrx_files/MODULE_README.md](matrx_files/MODULE_README.md).
36
+
37
+ ## Status / roadmap
38
+
39
+ Live work order: `docs/handoffs/matrx-files-split.md` (aidream repo). Phase 2 DONE
40
+ 2026-07-13: the package OWNS its DB truth — generated models in `matrx_files/db/`
41
+ (`models_files.py` for files.*, `models_iam.py` borrowed iam.permissions,
42
+ `_database="matrx_files"`), bound via `matrx_files.db.bind_to_host` (hosted alias)
43
+ or `bootstrap_db` (standalone pool from `MATRX_FILES_POSTGRES_*`). ALL DB access
44
+ goes through matrx-orm — the Supabase PostgREST client is gone from the DB layer
45
+ (`cloud_sync/db.py` is the reference conversion; RPCs via `matrx_orm.call_function`).
46
+ `cloud_sync/sql/` holds the package's own migrations (sanctioned SQL). Phase 3 =
47
+ standalone microservice on EC2 us-east-1.
@@ -0,0 +1,49 @@
1
+ # Deploying the Matrx Files microservice (EC2 us-east-1)
2
+
3
+ The standalone service is BUILT and verified locally (boot, own DB pool, JWT
4
+ auth, all routers). What remains is infrastructure — an operator (or matrx-ship)
5
+ executes this; it needs AWS/DNS access the codebase doesn't have.
6
+
7
+ ## 1. Build the image (from the aidream monorepo root)
8
+
9
+ ```bash
10
+ docker build -f packages/matrx-files/Dockerfile -t matrx-files:latest .
11
+ ```
12
+
13
+ ## 2. Runtime environment (the COMPLETE registry — `standalone/app.py::_env_config`)
14
+
15
+ | Var | Required | Notes |
16
+ |---|---|---|
17
+ | `SUPABASE_MATRIX_HOST/_PORT/_USER/_PASSWORD` + `SUPABASE_MATRIX_DATABASE_NAME` | yes* | Same pooler values aidream uses (Supavisor transaction pooler). *Or the package trio `MATRX_FILES_POSTGRES_HOST/_PORT/_NAME/_USER/_PASSWORD`. |
18
+ | `AWS_S3_DEFAULT_BUCKET` (+ `AWS_ACCESS_KEY_ID`/`AWS_SECRET_ACCESS_KEY` or an instance role) | yes | Instance role preferred on EC2 — same region as the buckets is the whole point. |
19
+ | `SUPABASE_URL` (or `SUPABASE_MATRIX_URL`) | yes | Auth: JWKS derived as `{url}/auth/v1/.well-known/jwks.json` (ES256). |
20
+ | `SUPABASE_JWT_SECRET` | no | Only if HS256 tokens must also verify. |
21
+ | `MATRX_FILES_BASE_DIR` | no | Scratch dir; image defaults `/data/matrx-files`. |
22
+
23
+ No env at all = smoke mode (health only). PARTIAL env = loud refusal to start
24
+ (by design — never silently serve broken routes).
25
+
26
+ ## 3. Run
27
+
28
+ ```bash
29
+ docker run -d --name matrx-files -p 8080:8080 --env-file matrx-files.env \
30
+ -v /data/matrx-files:/data/matrx-files matrx-files:latest
31
+ # probe
32
+ curl -s localhost:8080/files-service/health # {"status":"ok","package":"matrx-files"}
33
+ ```
34
+
35
+ ## 4. Platform integration checklist (operator)
36
+
37
+ - [ ] EC2 instance (us-east-1, same region as `AWS_S3_DEFAULT_BUCKET`), instance role with S3 access.
38
+ - [ ] Register the service in **matrx-ship** (deploy/version tracking) like other projects.
39
+ - [ ] Dedicated domain (decision on record: e.g. `files.matrxserver.com`) → TLS via the standard edge (Cloudflare) → port 8080.
40
+ - [ ] aidream keeps serving the same routes in-process — traffic cutover for byte-heavy endpoints is a LATER, separate switch (route-by-route at the client/edge).
41
+ - [ ] PyPI publishing: tag `matrx-files/v0.1.0` triggers `.github/workflows/publish-package.yml` (matrx-utils v2.0.0 must be published first for a PyPI-only install; the Docker image above doesn't need PyPI).
42
+
43
+ ## Verification once live
44
+
45
+ ```bash
46
+ curl -s https://files.matrxserver.com/api-or-bare/files-service/health
47
+ # authenticated smoke: any real Supabase JWT
48
+ curl -s -H "Authorization: Bearer $JWT" https://.../files/<known-file-id>
49
+ ```
@@ -0,0 +1,31 @@
1
+ # Matrx Files — standalone microservice image.
2
+ #
3
+ # Build from the MONOREPO ROOT (siblings resolve from the local workspace —
4
+ # the local matrx-utils/orm/connect versions lead what's on PyPI):
5
+ # docker build -f packages/matrx-files/Dockerfile -t matrx-files .
6
+ #
7
+ # The image contains ONLY matrx-files + its declared dependencies. If the
8
+ # build ever needs anything else from the repo, the package is violating
9
+ # INDEPENDENCE.md — fix the package, not this file.
10
+ FROM python:3.13-slim
11
+
12
+ # tesseract: pytesseract OCR backend (same binary the CI gate installs).
13
+ RUN apt-get update -qq && apt-get install -y -qq --no-install-recommends \
14
+ tesseract-ocr \
15
+ && rm -rf /var/lib/apt/lists/*
16
+
17
+ RUN pip install --no-cache-dir uv
18
+
19
+ WORKDIR /app
20
+ # Declared local siblings first (leaf order), then the package itself.
21
+ COPY packages/matrx-utils /deps/matrx-utils
22
+ COPY packages/matrx-connect /deps/matrx-connect
23
+ COPY packages/matrx-orm /deps/matrx-orm
24
+ COPY packages/matrx-files /app
25
+
26
+ RUN uv pip install --system /deps/matrx-utils /deps/matrx-connect /deps/matrx-orm \
27
+ && uv pip install --system ".[standalone]"
28
+
29
+ ENV MATRX_FILES_BASE_DIR=/data/matrx-files
30
+ EXPOSE 8080
31
+ CMD ["uvicorn", "matrx_files.standalone.app:create_app", "--factory", "--host", "0.0.0.0", "--port", "8080"]
@@ -0,0 +1,61 @@
1
+ # INDEPENDENCE.md — the contract every Matrx package signs
2
+
3
+ > **A Matrx package is extremely opinionated, yet fully independent.** It may expect an
4
+ > exact Postgres structure, exact AWS buckets, exact conventions — but everything it
5
+ > expects is **handed to it** through `configure_*()`, or it provisions its **own exact
6
+ > duplicate copy**. It NEVER reaches into a host application.
7
+ >
8
+ > — This is Arman's standing order. Agents have repeatedly destroyed package
9
+ > independence by importing "just one thing" from the host. That is why this file and
10
+ > its enforcement gates exist. If you are an AI agent reading this: the rules below are
11
+ > not style preferences. They are mechanically enforced, and a violation FAILS the build.
12
+
13
+ ## The three laws
14
+
15
+ 1. **No host imports, ever.** Nothing under the package may import `aidream`, any
16
+ host-repo root module, or an undeclared sibling. If the package needs a host
17
+ capability, it grows a `configure_*()` kwarg with a standalone fallback.
18
+ *Test: would this import resolve in a fresh project that contains ONLY this package
19
+ and its declared dependencies? No → forbidden.*
20
+
21
+ 2. **Opinionated inputs, validated loudly, never defaulted silently.** Required config
22
+ is validated **all-errors-at-once at configure/boot time** with a screaming banner
23
+ that names every missing value and how to supply it. A missing value must be
24
+ impossible to miss — crash, never fall back to a legacy path. Optional seams get a
25
+ real standalone fallback (the package's own duplicate copy), never a stub that
26
+ pretends to work.
27
+
28
+ 3. **The package ships its own truth.** Its database schema (models + migrations), its
29
+ API layer (FastAPI routers), and its standalone app entry live INSIDE the package.
30
+ Installing the package gives a customer the entire structure that drives it.
31
+ - **Host mode:** the host resolves the package's `db/db_requirements.py` manifest
32
+ and calls `configure_db(...)`; the host mounts the package's routers.
33
+ - **Standalone mode:** `standalone/app.py` boots the same routers as a real
34
+ microservice against the same (or a fresh) database, using the package's own
35
+ migrations.
36
+ The two modes run the SAME code. A feature that only works in host mode is a defect.
37
+
38
+ ## Enforcement — the layers that SCREAM
39
+
40
+ Each layer is sufficient alone; each screams when it fires (per the extinction doctrine):
41
+
42
+ | Layer | What | When |
43
+ |---|---|---|
44
+ | `scripts/check_imports.py` | AST scan — forbidden host/undeclared-sibling imports | pre-commit / CI, instant |
45
+ | **Standalone-boot gate** `scripts/independence_gate.sh` | Fresh venv, install the package from its OWN pyproject (+ declared local siblings only), **boot the standalone app, run smoke tests** | CI + release. Proof by execution — the gate no agent can rationalize past |
46
+ | Boot validation | `configure()`/app factory raises `IndependenceConfigError` listing ALL missing config with a red banner | every process start |
47
+ | Host boundary ratchet | the host repo's `check_package_boundaries.py` | host CI |
48
+
49
+ **Never weaken a gate to make a build pass.** If a gate fires, the code is wrong, not
50
+ the gate. Deleting, skipping, baselining-up, or `# noqa`-ing an independence gate is
51
+ itself a defect — file it and fix the import instead.
52
+
53
+ ## What "opinionated" licenses — and what it does not
54
+
55
+ ✅ Allowed: expecting exact table names/schemas, exact bucket layouts, exact envelope
56
+ shapes, exact conventions — **received via configure() or shipped as the package's own
57
+ schema/migrations**.
58
+
59
+ ❌ Not licensed: reading the host's env vars, assuming the host's filesystem layout,
60
+ importing the host's settings object, "temporarily" importing a host helper, or a
61
+ fallback that silently no-ops instead of either working or crashing.
@@ -0,0 +1,74 @@
1
+ Metadata-Version: 2.4
2
+ Name: matrx-files
3
+ Version: 0.1.0
4
+ Summary: All things files: cloud storage, media management, conversion, PDF, sharing — the platform's independent file service.
5
+ Project-URL: Homepage, https://github.com/AI-Matrix-Engine/aidream-current
6
+ Project-URL: Repository, https://github.com/AI-Matrix-Engine/aidream-current
7
+ Project-URL: Issues, https://github.com/AI-Matrix-Engine/aidream-current/issues
8
+ Author-email: Matrx <admin@aimatrx.com>
9
+ License: MIT
10
+ Keywords: cdn,files,matrx,media,pdf,s3
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Requires-Python: >=3.13
17
+ Requires-Dist: boto3-stubs[s3]>=1.42.59
18
+ Requires-Dist: boto3>=1.42.59
19
+ Requires-Dist: httpx>=0.28.1
20
+ Requires-Dist: imageio-ffmpeg>=0.5
21
+ Requires-Dist: matrx-connect
22
+ Requires-Dist: matrx-orm>=3.1
23
+ Requires-Dist: matrx-utils
24
+ Requires-Dist: mozjpeg-lossless-optimization>=1.1.0
25
+ Requires-Dist: numpy<2.5,>=1.26
26
+ Requires-Dist: onnxruntime>=1.16
27
+ Requires-Dist: opencv-python-headless>=4.9
28
+ Requires-Dist: pandas>=3.0.1
29
+ Requires-Dist: pillow-avif-plugin>=1.4.6
30
+ Requires-Dist: pillow-heif>=0.18.0
31
+ Requires-Dist: pillow>=11.2.1
32
+ Requires-Dist: pydantic>=2.0.0
33
+ Requires-Dist: pymupdf>=1.27.0
34
+ Requires-Dist: pypdfium2>=4.30.0
35
+ Requires-Dist: pytesseract>=0.3.13
36
+ Requires-Dist: python-pptx>=1.0.2
37
+ Requires-Dist: pyyaml>=6.0.3
38
+ Requires-Dist: rembg>=2.0.69
39
+ Requires-Dist: requests>=2.32.5
40
+ Requires-Dist: supabase>=2.28.0
41
+ Provides-Extra: pdf-cloud-ocr
42
+ Requires-Dist: azure-ai-documentintelligence; extra == 'pdf-cloud-ocr'
43
+ Requires-Dist: boto3; extra == 'pdf-cloud-ocr'
44
+ Requires-Dist: google-cloud-documentai; extra == 'pdf-cloud-ocr'
45
+ Provides-Extra: pdf-forms
46
+ Requires-Dist: pypdfform>=1.4; extra == 'pdf-forms'
47
+ Provides-Extra: pdf-generate
48
+ Requires-Dist: reportlab>=4.0; extra == 'pdf-generate'
49
+ Provides-Extra: pdf-html
50
+ Requires-Dist: weasyprint>=60; extra == 'pdf-html'
51
+ Provides-Extra: pdf-ml-llm
52
+ Requires-Dist: pymupdf4llm>=0.0.30; extra == 'pdf-ml-llm'
53
+ Provides-Extra: pdf-ocr
54
+ Requires-Dist: ocrmypdf>=16; extra == 'pdf-ocr'
55
+ Provides-Extra: pdf-redact-ner
56
+ Requires-Dist: presidio-analyzer>=2.2; extra == 'pdf-redact-ner'
57
+ Requires-Dist: presidio-anonymizer>=2.2; extra == 'pdf-redact-ner'
58
+ Requires-Dist: spacy>=3.7; extra == 'pdf-redact-ner'
59
+ Provides-Extra: pdf-signatures
60
+ Requires-Dist: pyhanko>=0.20; extra == 'pdf-signatures'
61
+ Provides-Extra: pdf-tables
62
+ Requires-Dist: tabula-py>=2.9; extra == 'pdf-tables'
63
+ Provides-Extra: pdf-tables-extra
64
+ Requires-Dist: camelot-py>=0.11; extra == 'pdf-tables-extra'
65
+ Provides-Extra: standalone
66
+ Requires-Dist: fastapi>=0.115; extra == 'standalone'
67
+ Requires-Dist: uvicorn>=0.34; extra == 'standalone'
68
+ Description-Content-Type: text/markdown
69
+
70
+ # Matrx Files
71
+
72
+ All things files: cloud storage, media management, conversion, PDF, sharing — the platform's independent file service.
73
+
74
+ Contract: [INDEPENDENCE.md](INDEPENDENCE.md).
@@ -0,0 +1,5 @@
1
+ # Matrx Files
2
+
3
+ All things files: cloud storage, media management, conversion, PDF, sharing — the platform's independent file service.
4
+
5
+ Contract: [INDEPENDENCE.md](INDEPENDENCE.md).