familia 2.0.0.pre10 → 2.0.0.pre13

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 (95) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +2 -3
  3. data/CHANGELOG.rst +507 -0
  4. data/CLAUDE.md +5 -55
  5. data/Gemfile +1 -6
  6. data/Gemfile.lock +13 -7
  7. data/changelog.d/README.md +45 -34
  8. data/changelog.d/scriv.ini +5 -0
  9. data/docs/archive/FAMILIA_RELATIONSHIPS.md +1 -1
  10. data/docs/archive/FAMILIA_UPDATE.md +1 -1
  11. data/docs/archive/README.md +15 -19
  12. data/docs/guides/Feature-System-Autoloading.md +228 -0
  13. data/docs/guides/Home.md +1 -1
  14. data/docs/guides/Implementation-Guide.md +1 -1
  15. data/docs/guides/relationships-methods.md +1 -1
  16. data/docs/guides/time-utilities.md +221 -0
  17. data/docs/migrating/.gitignore +2 -0
  18. data/docs/migrating/v2.0.0-pre.md +84 -0
  19. data/docs/migrating/v2.0.0-pre11.md +253 -0
  20. data/docs/migrating/v2.0.0-pre12.md +306 -0
  21. data/docs/migrating/v2.0.0-pre13.md +329 -0
  22. data/docs/migrating/v2.0.0-pre5.md +110 -0
  23. data/docs/migrating/v2.0.0-pre6.md +154 -0
  24. data/docs/migrating/v2.0.0-pre7.md +222 -0
  25. data/docs/overview.md +6 -7
  26. data/{examples/redis_command_validation_example.rb → docs/reference/auditing_database_commands.rb} +29 -32
  27. data/examples/autoloader/mega_customer/safe_dump_fields.rb +6 -0
  28. data/examples/autoloader/mega_customer.rb +17 -0
  29. data/examples/{bit_encoding_integration.rb → permissions.rb} +30 -27
  30. data/examples/{relationships_basic.rb → relationships.rb} +2 -3
  31. data/examples/safe_dump.rb +281 -0
  32. data/familia.gemspec +5 -4
  33. data/lib/familia/autoloader.rb +53 -0
  34. data/lib/familia/base.rb +57 -0
  35. data/lib/familia/data_type.rb +4 -0
  36. data/lib/familia/encryption/encrypted_data.rb +4 -4
  37. data/lib/familia/encryption/manager.rb +6 -4
  38. data/lib/familia/{encryption_request_cache.rb → encryption/request_cache.rb} +1 -1
  39. data/lib/familia/encryption.rb +1 -1
  40. data/lib/familia/errors.rb +5 -0
  41. data/lib/familia/features/autoloadable.rb +113 -0
  42. data/lib/familia/features/encrypted_fields/concealed_string.rb +4 -2
  43. data/lib/familia/features/expiration.rb +4 -0
  44. data/lib/familia/features/external_identifier.rb +310 -0
  45. data/lib/familia/features/object_identifier.rb +307 -0
  46. data/lib/familia/features/quantization.rb +5 -0
  47. data/lib/familia/features/safe_dump.rb +74 -73
  48. data/lib/familia/features.rb +109 -17
  49. data/lib/familia/field_type.rb +2 -0
  50. data/lib/familia/horreum/core/serialization.rb +3 -3
  51. data/lib/familia/horreum/subclass/definition.rb +50 -7
  52. data/lib/familia/horreum.rb +2 -0
  53. data/lib/familia/json_serializer.rb +70 -0
  54. data/lib/familia/logging.rb +12 -10
  55. data/lib/familia/refinements/logger_trace.rb +57 -0
  56. data/lib/familia/refinements/snake_case.rb +40 -0
  57. data/lib/familia/refinements/time_utils.rb +248 -0
  58. data/lib/familia/refinements.rb +3 -49
  59. data/lib/familia/secure_identifier.rb +51 -75
  60. data/lib/familia/utils.rb +2 -0
  61. data/lib/familia/validation/{test_helpers.rb → validation_helpers.rb} +2 -2
  62. data/lib/familia/validation.rb +1 -1
  63. data/lib/familia/verifiable_identifier.rb +162 -0
  64. data/lib/familia/version.rb +1 -1
  65. data/lib/familia.rb +15 -2
  66. data/try/core/autoloader_try.rb +112 -0
  67. data/try/core/extensions_try.rb +38 -21
  68. data/try/core/familia_extended_try.rb +4 -3
  69. data/try/core/secure_identifier_try.rb +47 -18
  70. data/try/core/time_utils_try.rb +130 -0
  71. data/try/core/verifiable_identifier_try.rb +171 -0
  72. data/try/data_types/datatype_base_try.rb +3 -2
  73. data/try/features/autoloadable/autoloadable_try.rb +61 -0
  74. data/try/features/encrypted_fields/concealed_string_core_try.rb +8 -3
  75. data/try/features/encrypted_fields/secure_by_default_behavior_try.rb +59 -17
  76. data/try/features/encrypted_fields/universal_serialization_safety_try.rb +36 -12
  77. data/try/features/{external_identifiers/external_identifiers_try.rb → external_identifier/external_identifier_try.rb} +25 -28
  78. data/try/features/feature_improvements_try.rb +127 -0
  79. data/try/features/{object_identifiers/object_identifiers_integration_try.rb → object_identifier/object_identifier_integration_try.rb} +28 -30
  80. data/try/features/{object_identifiers/object_identifiers_try.rb → object_identifier/object_identifier_try.rb} +13 -13
  81. data/try/features/real_feature_integration_try.rb +8 -7
  82. data/try/features/safe_dump/safe_dump_autoloading_try.rb +111 -0
  83. data/try/features/safe_dump/safe_dump_try.rb +8 -9
  84. data/try/helpers/test_helpers.rb +41 -17
  85. data/try/integration/cross_component_try.rb +3 -1
  86. metadata +61 -26
  87. data/CHANGELOG.md +0 -184
  88. data/changelog.d/fragments/.keep +0 -0
  89. data/changelog.d/template.md.j2 +0 -29
  90. data/lib/familia/core_ext.rb +0 -135
  91. data/lib/familia/features/external_identifiers/external_identifier_field_type.rb +0 -120
  92. data/lib/familia/features/external_identifiers.rb +0 -111
  93. data/lib/familia/features/object_identifiers/object_identifier_field_type.rb +0 -91
  94. data/lib/familia/features/object_identifiers.rb +0 -194
  95. data/setup.cfg +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f09bb44b39f033bc38faaff02dd33c645ecd6a98bee533a756707daeb47e00c
4
- data.tar.gz: 77afd574073258009058ed9f638151b1ca26ba65d06b49f841ad46b52e50a82a
3
+ metadata.gz: ca101edcf531af301428b4b29bc83f464a84e47339a9d67f1b8a70ead828aa74
4
+ data.tar.gz: 56255e7fbc191f8c15b75d5cab0a990b83c3e54fe07362f1b20dbf392edca65d
5
5
  SHA512:
6
- metadata.gz: c9bf8c181236218f04e7fff9902b63521d316265792a416525ee5da671789ddd636c372d0481b926b9b65b3116680bac698ebef6d37fd3d0117c9235053b98aa
7
- data.tar.gz: d046f73ca2f6d46833e4bdb0f2a59c6c400b807f5e44f92657a470bd50c09ffae56debfd991f6513898a603ce44e761047d1e4449f8526d3d2a5ac333ebb8e72
6
+ metadata.gz: d92e09f275bcf262a73afe443fa5e099fff6c0836502de52d485358ec1f5d5a095878fe69ff9c4d5fcdbe26aa00c404474418cc72e9748b10d783ded2942e1b5
7
+ data.tar.gz: 2e22b89f457a6b188b31820e794960a5ad288c406ad7550fc47f48501489394fb891c966f7e147fe2b89b8d2eaa36b736258b75184a0aee5e5aa2aaf63ac6878
data/.rubocop_todo.yml CHANGED
@@ -64,14 +64,13 @@ Naming/BlockForwarding:
64
64
  - "lib/familia/data_type/types/list.rb"
65
65
  - "lib/familia/data_type/types/sorted_set.rb"
66
66
  - "lib/familia/data_type/types/unsorted_set.rb"
67
- - "lib/familia/refinements.rb"
67
+ - "lib/familia/refinements/logger_trace.rb"
68
68
 
69
69
  # Offense count: 8
70
70
  # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
71
71
  # AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
72
72
  Naming/MethodParameterName:
73
73
  Exclude:
74
- - "lib/familia/core_ext.rb"
75
74
  - "lib/familia/horreum/class_methods.rb"
76
75
  - "lib/familia/data_type/types/sorted_set.rb"
77
76
  - "lib/familia/data_type/types/unsorted_set.rb"
@@ -107,7 +106,7 @@ Style/ArgumentsForwarding:
107
106
  - "lib/familia/data_type/types/list.rb"
108
107
  - "lib/familia/data_type/types/sorted_set.rb"
109
108
  - "lib/familia/data_type/types/unsorted_set.rb"
110
- - "lib/familia/refinements.rb"
109
+ - "lib/familia/refinements/logger_trace.rb"
111
110
 
112
111
  # Offense count: 11
113
112
  # Configuration parameters: AllowedConstants.
data/CHANGELOG.rst ADDED
@@ -0,0 +1,507 @@
1
+ CHANGELOG.rst
2
+ =============
3
+
4
+ All notable changes to Familia are documented here.
5
+
6
+ The format is based on `Keep a
7
+ Changelog <https://keepachangelog.com/en/1.1.0/>`__, and this project
8
+ adheres to `Semantic
9
+ Versioning <https://semver.org/spec/v2.0.0.html>`__.
10
+
11
+ .. raw:: html
12
+
13
+ <!--scriv-insert-here-->
14
+
15
+ .. _changelog-2.0.0.pre13:
16
+
17
+ 2.0.0.pre13 — 2025-09-07
18
+ ========================
19
+
20
+ Added
21
+ -----
22
+
23
+ - **Feature-specific autoloading**: Features can now automatically discover and load extension files from your project directories. When you include a feature like ``safe_dump``, Familia searches for configuration files using conventional patterns like ``{model_name}/{feature_name}_*.rb``, enabling clean separation between core model definitions and feature-specific configurations.
24
+
25
+ - **Consolidated autoloader architecture**: Introduced ``Familia::Autoloader`` as a shared utility for consistent file loading patterns across the framework, supporting both general-purpose and feature-specific autoloading scenarios.
26
+
27
+ - Added ``PER_MONTH`` constant (2,629,746 seconds = 30.437 days) derived from Gregorian year for consistent month calculations.
28
+ - Added ``months``, ``month``, and ``in_months`` conversion methods to Numeric refinement.
29
+ - Added month unit mappings (``'mo'``, ``'month'``, ``'months'``) to TimeUtils ``UNIT_METHODS`` hash.
30
+
31
+ - **Error Handling**: Added ``NotSupportedError`` for invalid serialization mode combinations in encryption subsystem. PR #97
32
+
33
+ Changed
34
+ -------
35
+
36
+ - Refactored time and numeric extensions from global monkey patches to proper Ruby refinements for better encapsulation and reduced global namespace pollution
37
+ - Updated all internal classes to use refinements via ``using Familia::Refinements::TimeUtils`` statements
38
+ - Added centralized ``RefinedContext`` module in test helpers to support refinement testing in tryouts files
39
+
40
+ - Updated ``PER_YEAR`` constant to use Gregorian year (31,556,952 seconds = 365.2425 days) for calendar consistency.
41
+
42
+ - **Performance**: Replaced stdlib JSON with OJ gem for 2-5x faster JSON operations and reduced memory allocation. All existing code remains compatible through mimic_JSON mode. PR #97
43
+
44
+ - **Encryption**: Enhanced serialization safety for encrypted fields with improved ConcealedString handling across different JSON processing modes. Strengthened protection against accidental data exposure during serialization. PR #97
45
+
46
+ Fixed
47
+ -----
48
+
49
+ - Fixed byte conversion logic in ``to_bytes`` method to correctly handle exact 1024-byte boundaries (``size >= 1024`` instead of ``size > 1024``)
50
+ - Resolved refinement testing issues in tryouts by implementing ``eval``-based code execution within refined contexts
51
+
52
+ - Fixed TimeUtils refinement ``months_old`` and ``years_old`` methods returning incorrect values (raw seconds instead of months/years). The underlying ``age_in`` method now properly handles ``:months`` and ``:years`` units. Issue #94.
53
+ - Fixed calendar consistency issue where ``12.months != 1.year`` by updating ``PER_YEAR`` to use Gregorian year (365.2425 days) and defining ``PER_MONTH`` as ``PER_YEAR / 12``.
54
+
55
+ Security
56
+ --------
57
+
58
+ - **Encryption**: Improved concealed value protection during JSON serialization, ensuring encrypted data remains properly protected across all OJ serialization modes. PR #97
59
+
60
+ Documentation
61
+ -------------
62
+
63
+ - **Feature System Autoloading Guide**: Added comprehensive guide at ``docs/guides/Feature-System-Autoloading.md`` explaining the new autoloading system, including file naming conventions, directory patterns, and usage examples.
64
+ - **Enhanced API documentation**: Added detailed YARD documentation for autoloading modules and methods.
65
+
66
+ AI Assistance
67
+ -------------
68
+
69
+ - Provided comprehensive analysis of Ruby refinement scoping issues and designed the eval-based testing solution
70
+ - Assisted with refactoring global extensions to proper refinements while maintaining backward compatibility
71
+ - Helped debug and fix the byte conversion boundary condition bug
72
+
73
+ - Significant AI assistance in architectural design and implementation of the feature-specific autoloading system, including pattern matching logic, Ruby introspection methods, and comprehensive debugging of edge cases and thread safety considerations.
74
+
75
+ - Claude Code assisted with implementing the fix for broken ``months_old`` and ``years_old`` methods in the TimeUtils refinement, including analysis, implementation, testing, and documentation.
76
+
77
+ - Performance optimization research and OJ gem integration strategy, including compatibility analysis and testing approach for seamless stdlib JSON replacement. PR #97
78
+
79
+ 2.0.0.pre12 — 2025-09-04
80
+ ========================
81
+
82
+ Added
83
+ ~~~~~
84
+
85
+ - Added the ``Familia::VerifiableIdentifier`` module to create and
86
+ verify identifiers with an embedded HMAC signature. This allows an
87
+ application to stateless-ly confirm that an identifier was generated
88
+ by itself, preventing forged IDs from malicious sources.
89
+
90
+ - **Scoped VerifiableIdentifier**: Added ``scope`` parameter to
91
+ ``generate_verifiable_id()`` and ``verified_identifier?()`` methods,
92
+ enabling cryptographically isolated identifier namespaces for
93
+ multi-tenant, multi-domain, or multi-environment applications while
94
+ maintaining full backward compatibility with existing code.
95
+
96
+ Changed
97
+ ~~~~~~~
98
+
99
+ - ObjectIdentifier feature now tracks which generator (uuid_v7,
100
+ uuid_v4, hex, or custom) was used for each objid to provide
101
+ provenance information for security-sensitive operations.
102
+
103
+ - Updated external identifier derivation to normalize objid format
104
+ based on the known generator type, eliminating format ambiguity
105
+ between UUID and hex formats.
106
+
107
+ - Refactored identifier generation methods for clarity and consistency.
108
+ Method ``generate_objid`` is now ``generate_object_identifier``, and
109
+ ``generate_external_identifier`` is now
110
+ ``derive_external_identifier`` to reflect its deterministic nature.
111
+
112
+ Removed
113
+ ~~~~~~~
114
+
115
+ - Removed the ``generate_extid`` class method, which was less secure
116
+ than the instance-level derivation logic.
117
+
118
+ Security
119
+ ~~~~~~~~
120
+
121
+ - Hardened external identifier derivation with provenance validation.
122
+ ExternalIdentifier now validates that objid values come from the
123
+ ObjectIdentifier feature before deriving external identifiers,
124
+ preventing derivation from potentially malicious or unvalidated objid
125
+ values while maintaining deterministic behavior for legitimate use
126
+ cases.
127
+
128
+ - Improved the security of external identifiers (``extid``) by using
129
+ the internal object identifier (``objid``) as a seed for a new random
130
+ value, rather than deriving the ``extid`` directly. This prevents
131
+ potential information leakage from the internal ``objid``.
132
+
133
+ Documentation
134
+ ~~~~~~~~~~~~~
135
+
136
+ - Added detailed YARD documentation for ``VerifiableIdentifier``,
137
+ explaining how to securely generate and manage the required
138
+ ``VERIFIABLE_ID_HMAC_SECRET`` key.
139
+
140
+ AI Assistance
141
+ ~~~~~~~~~~~~~
142
+
143
+ - Security analysis of external identifier derivation and hardened
144
+ design approach was discussed and developed with AI assistance,
145
+ including provenance tracking, validation logic, format
146
+ normalization, and comprehensive test updates.
147
+
148
+ - Implementation of scoped verifiable identifiers was developed with AI
149
+ assistance to ensure cryptographic security properties and
150
+ comprehensive test coverage.
151
+
152
+ 2.0.0.pre11 - 2025-09-03
153
+ ======================
154
+
155
+ .. _added-1:
156
+
157
+ Added
158
+ ~~~~~
159
+
160
+ - **Enhanced Feature System**: Introduced a hierarchical feature system
161
+ with ancestry chain traversal for model-specific feature
162
+ registration. This enables better organization, standardized naming,
163
+ and automatic loading of project-specific features via the new
164
+ ``Familia::Autoloader`` module.
165
+ - **Improved SafeDump DSL**: Replaced the internal
166
+ ``@safe_dump_fields`` implementation with a cleaner, more robust DSL
167
+ using ``safe_dump_field`` and ``safe_dump_fields`` methods.
168
+ - Added ``generate_short_id`` and ``shorten_securely`` utility methods
169
+ for creating short, secure identifiers, adapted from
170
+ ``OT::Utils::SecureNumbers``.
171
+ - For a detailed guide on migrating to the new feature system, see
172
+ ``docs/migration/v2.0.0-pre11.md``.
173
+
174
+ .. _changed-1:
175
+
176
+ Changed
177
+ ~~~~~~~
178
+
179
+ - External identifier now raises an ``ExternalIdentifierError`` if the
180
+ model does not have an objid field. Previously: returned nil. In
181
+ practice this should never happen, since the external_identifier
182
+ feature declares its dependency on object_identifier.
183
+ - Moved lib/familia/encryption_request_cache.rb to
184
+ lib/familia/encryption/request_cache.rb for consistency.
185
+ - **Simplified ObjectIdentifier Feature Implementation**: Consolidated
186
+ the ObjectIdentifier feature from two files (~190 lines) to a single
187
+ file (~140 lines) by moving the ObjectIdentifierFieldType class
188
+ inline. This reduces complexity while maintaining all existing
189
+ functionality including lazy generation, data integrity preservation,
190
+ and multiple generator strategies.
191
+ - **Renamed Identifier Features to Singular Form**: Renamed
192
+ ``object_identifier`` → ``object_identifier`` and
193
+ ``external_identifier`` → ``external_identifier`` for more accurate
194
+ naming. Added full-length aliases
195
+ (``object_identifier``/``external_identifier``) alongside the short
196
+ forms (``objid``/``extid``) for clarity when needed.
197
+ - **Simplified ExternalIdentifier Feature Implementation**:
198
+ Consolidated the ExternalIdentifier feature from two files (~240
199
+ lines) to a single file (~120 lines) by moving the
200
+ ExternalIdentifierFieldType class inline, following the same pattern
201
+ as ObjectIdentifier.
202
+
203
+ Fixed
204
+ ~~~~~
205
+
206
+ - Fixed external identifier generation returning all zeros for
207
+ UUID-based objids. The ``shorten_to_external_id`` method now
208
+ correctly handles both 256-bit secure identifiers and 128-bit UUIDs
209
+ by detecting input length and applying appropriate bit truncation
210
+ only when needed.
211
+
212
+ .. _security-1:
213
+
214
+ Security
215
+ ~~~~~~~~
216
+
217
+ - Improved input validation in ``shorten_to_external_id`` method by
218
+ replacing insecure character count checking with proper bit length
219
+ calculation and explicit validation. Invalid inputs now raise clear
220
+ error messages instead of being silently processed incorrectly.
221
+
222
+ 2.0.0-pre10 - 2025-09-02
223
+ ======================
224
+
225
+ .. _added-2:
226
+
227
+ Added
228
+ ~~~~~
229
+
230
+ - The ``Familia::Horreum`` initializer now supports creating an object
231
+ directly from its identifier by passing a single argument (e.g.,
232
+ ``Customer.new(customer_id)``). This provides a more convenient and
233
+ intuitive way to instantiate objects from lookups.
234
+
235
+ - Automatic indexing and class-level tracking on ``save()`` operations,
236
+ eliminating the need for manual index updates.
237
+
238
+ - Enhanced collection syntax supports the Ruby-idiomatic ``<<``
239
+ operator for more natural relationship management.
240
+
241
+ .. _changed-2:
242
+
243
+ Changed
244
+ ~~~~~~~
245
+
246
+ - The ``member_of`` relationship is now bidirectional. A single call to
247
+ ``member.add_to_owner_collection(owner)`` is sufficient to establish
248
+ the relationship, removing the need for a second, redundant call on
249
+ the owner object. This fixes bugs where members could be added to
250
+ collections twice.
251
+
252
+ - **BREAKING**: Refactored Familia Relationships API to remove “global”
253
+ terminology and simplify method generation. (Closes #86)
254
+
255
+ - Split ``generate_indexing_instance_methods`` into focused
256
+ ``generate_direct_index_methods`` and
257
+ ``generate_relationship_index_methods`` for better separation between
258
+ direct class-level and relationship-based indexing.
259
+
260
+ - Simplified method generation by removing complex global vs parent
261
+ conditionals.
262
+
263
+ - All indexes are now stored at the class level for consistency.
264
+
265
+ .. _fixed-1:
266
+
267
+ Fixed
268
+ ~~~~~
269
+
270
+ - Fixed a bug in the ``class_indexed_by`` feature where finder methods
271
+ (e.g., ``find_by_email``) would fail to correctly instantiate objects
272
+ from the index, returning partially-formed objects.
273
+
274
+ - Refactored connection handling to properly cache and reuse Redis
275
+ connections. This eliminates repetitive “Overriding existing
276
+ connection” warnings and improves performance.
277
+
278
+ - Method generation now works consistently for both
279
+ ``class_indexed_by`` and ``indexed_by`` with a ``parent:``.
280
+
281
+ - Resolved metadata storage issues for dynamically created classes.
282
+
283
+ - Improved error handling for nil class names in tracking
284
+ relationships.
285
+
286
+ .. _documentation-1:
287
+
288
+ Documentation
289
+ ~~~~~~~~~~~~~
290
+
291
+ - Updated the ``examples/relationships_basic.rb`` script to reflect the
292
+ improved, bidirectional ``member_of`` API and to ensure a clean
293
+ database state for each run.
294
+
295
+ .. _ai-assistance-1:
296
+
297
+ AI Assistance
298
+ ~~~~~~~~~~~~~
299
+
300
+ - This refactoring was implemented with Claude Code assistance,
301
+ including comprehensive test updates and API modernization.
302
+
303
+ 2.0.0-pre9 - 2025-09-02
304
+ ======================
305
+
306
+ .. _added-3:
307
+
308
+ Added
309
+ ~~~~~
310
+
311
+ - Added ``class_tracked_in`` method for global tracking relationships
312
+ following Horreum’s established ``class_`` prefix convention
313
+ - Added ``class_indexed_by`` method for global index relationships with
314
+ consistent API design
315
+
316
+ .. _changed-3:
317
+
318
+ Changed
319
+ ~~~~~~~
320
+
321
+ - **BREAKING**: ``tracked_in :global, collection`` syntax now raises
322
+ ArgumentError - use ``class_tracked_in collection`` instead
323
+ - **BREAKING**: ``indexed_by field, index, context: :global`` syntax
324
+ replaced with ``class_indexed_by field, index``
325
+ - **BREAKING**: ``indexed_by field, index, context: SomeClass`` syntax
326
+ replaced with ``indexed_by field, index, parent: SomeClass``
327
+ - Relationships API now provides consistent parameter naming across all
328
+ relationship types
329
+
330
+ .. _documentation-2:
331
+
332
+ Documentation
333
+ ~~~~~~~~~~~~~
334
+
335
+ - Updated Relationships Guide with new API syntax and migration
336
+ examples
337
+ - Updated relationships method documentation with new method signatures
338
+ - Updated basic relationships example to demonstrate new API patterns
339
+ - Added tryouts test coverage in
340
+ try/features/relationships/relationships_api_changes_try.rb
341
+
342
+ 2.0.0-pre8 - 2025-09-01
343
+ ======================
344
+
345
+ .. _added-4:
346
+
347
+ Added
348
+ ~~~~~
349
+
350
+ - Implemented Scriv-based changelog system for sustainable
351
+ documentation
352
+ - Added fragment-based workflow for tracking changes
353
+ - Created structured changelog templates and configuration
354
+
355
+ .. _documentation-3:
356
+
357
+ Documentation
358
+ ~~~~~~~~~~~~~
359
+
360
+ - Set up Scriv configuration and directory structure
361
+ - Created README for changelog fragment workflow
362
+
363
+ .. raw:: html
364
+
365
+ <!-- scriv-end-here -->
366
+
367
+ 2.0.0-pre7 - 2025-08-31
368
+ ======================
369
+
370
+ .. _added-5:
371
+
372
+ Added
373
+ ~~~~~
374
+
375
+ - Comprehensive relationships system with three relationship types:
376
+
377
+ - ``tracked_in`` - Multi-presence tracking with score encoding
378
+ - ``indexed_by`` - O(1) hash-based lookups
379
+ - ``member_of`` - Bidirectional membership with collision-free
380
+ naming
381
+
382
+ - Categorical permission system with bit-encoded permissions
383
+ - Time-based permission scoring for temporal access control
384
+ - Permission tier hierarchies with inheritance patterns
385
+ - Scalable permission management for large object collections
386
+ - Score-based sorting with custom scoring functions
387
+ - Permission-aware queries filtering by access levels
388
+ - Relationship validation framework ensuring data integrity
389
+
390
+ .. _changed-4:
391
+
392
+ Changed
393
+ ~~~~~~~
394
+
395
+ - Performance optimizations for large-scale relationship operations
396
+
397
+ .. _security-2:
398
+
399
+ Security
400
+ ~~~~~~~~
401
+
402
+ - GitHub Actions security hardening with matrix optimization
403
+
404
+ 2.0.0-pre6 - 2025-08-15
405
+ ======================
406
+
407
+ .. _added-6:
408
+
409
+ Added
410
+ ~~~~~
411
+
412
+ - New ``save_if_not_exists`` method for conditional persistence
413
+ - Atomic persistence operations with transaction support
414
+ - Enhanced error handling for persistence failures
415
+ - Improved data consistency guarantees
416
+
417
+ .. _changed-5:
418
+
419
+ Changed
420
+ ~~~~~~~
421
+
422
+ - Connection provider pattern for flexible pooling strategies
423
+ - Multi-database support with intelligent pool management
424
+ - Thread-safe connection handling for concurrent applications
425
+ - Configurable pool sizing and timeout management
426
+ - Modular class structure with cleaner separation of concerns
427
+ - Enhanced feature system with dependency management
428
+ - Improved inheritance patterns for better code organization
429
+ - Streamlined base class functionality
430
+
431
+ .. _fixed-2:
432
+
433
+ Fixed
434
+ ~~~~~
435
+
436
+ - Critical security fixes in Ruby workflow vulnerabilities
437
+ - Systematic dependency resolution via multi-constraint optimization
438
+
439
+ 2.0.0-pre5 - 2025-08-05
440
+ ======================
441
+
442
+ .. _added-7:
443
+
444
+ Added
445
+ ~~~~~
446
+
447
+ - Field-level encryption with transparent access patterns
448
+ - Multiple encryption providers:
449
+
450
+ - XChaCha20-Poly1305 (preferred, requires rbnacl)
451
+ - AES-256-GCM (fallback, OpenSSL-based)
452
+
453
+ - Field-specific key derivation for cryptographic domain separation
454
+ - Configurable key versioning supporting key rotation
455
+ - Non-persistent field storage for sensitive runtime data
456
+ - RedactedString wrapper preventing accidental logging/serialization
457
+ - Memory-safe handling of sensitive data in Ruby objects
458
+ - API-safe serialization excluding transient fields
459
+
460
+ .. _security-3:
461
+
462
+ Security
463
+ ~~~~~~~~
464
+
465
+ - Encryption field security hardening with additional validation
466
+ - Enhanced memory protection for sensitive data handling
467
+ - Improved key management patterns and best practices
468
+ - Security test suite expansion with comprehensive coverage
469
+
470
+ 2.0.0-pre - 2025-07-25
471
+ ======================
472
+
473
+ .. _added-8:
474
+
475
+ Added
476
+ ~~~~~
477
+
478
+ - Complete API redesign for clarity and modern Ruby conventions
479
+ - Valkey compatibility alongside traditional Redis support
480
+ - Ruby 3.4+ modernization with fiber and thread safety improvements
481
+ - Connection pooling foundation with provider pattern architecture
482
+
483
+ .. _changed-6:
484
+
485
+ Changed
486
+ ~~~~~~~
487
+
488
+ - ``Familia::Base`` replaced by ``Familia::Horreum`` as the primary
489
+ base class
490
+ - Connection configuration moved from simple string to block-based
491
+ setup
492
+ - Feature activation changed from ``include`` to ``feature``
493
+ declarations
494
+ - Method naming updated for consistency (``delete`` → ``destroy``,
495
+ ``exists`` → ``exists?``, ``dump`` → ``serialize``)
496
+
497
+ .. _documentation-4:
498
+
499
+ Documentation
500
+ ~~~~~~~~~~~~~
501
+
502
+ - YARD documentation workflow with automated GitHub Pages deployment
503
+ - Comprehensive migrating guide for v1.x to v2.0.0-pre transition
504
+
505
+ .. raw:: html
506
+
507
+ <!-- scriv-end-here -->
data/CLAUDE.md CHANGED
@@ -32,9 +32,10 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
32
32
 
33
33
  **Debugging options:**
34
34
  - **Stack traces**: `bundle exec try -s` (stack traces without debug logging)
35
+ - **Verbose failures**: `bundle exec try -vfs` (detailed failure output)
35
36
  - **Debug mode**: `bundle exec try -D` (additional logging including stack traces)
36
- - **Verbose failures**: `bundle exec try -vf` (detailed failure output)
37
- - **Fresh context**: `bundle exec try --fresh-context` (isolate test cases)
37
+ - **Shared context**: `bundle exec try --shared-context` (DEFAULT - reuse shared context across setup, testcases, and teardown)
38
+ - **Fresh context**: `bundle exec try --no-shared-context` (isolate test cases, no shared variables)
38
39
 
39
40
  *Note: Use `--agent` mode for optimal token efficiency when analyzing test results programmatically.*
40
41
 
@@ -46,7 +47,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
46
47
 
47
48
  ### Changelog Management
48
49
 
49
- Add changelog fragment with each user-facing or documented change (optional but encouraged). See:
50
+ Add changelog fragment with each user-facing or documented change (optional but encouraged). Fragments use RST format. See:
50
51
  @changelog.d/README.md
51
52
 
52
53
  ### Known Issues & Quirks
@@ -60,9 +61,6 @@ Add changelog fragment with each user-facing or documented change (optional but
60
61
  - Updates live as tests run or code executes
61
62
  - Essential for debugging Familia ORM Database interactions, multi/exec, pipelining, logical_database issues
62
63
 
63
- ### Testing Framework
64
- This project uses `tryouts` instead of RSpec/Minitest. Test files are located in the `try/` directory and follow the pattern `*_try.rb`.
65
-
66
64
  ## Architecture Overview
67
65
 
68
66
  ### Core Components
@@ -88,7 +86,7 @@ This project uses `tryouts` instead of RSpec/Minitest. Test files are located in
88
86
  Familia uses a modular feature system where features are mixed into classes:
89
87
  - **Expiration** (`lib/familia/features/expiration.rb`) - TTL management with cascading
90
88
  - **SafeDump** (`lib/familia/features/safe_dump.rb`) - API-safe object serialization
91
- - **Quantization** (`lib/familia/features/quantization.rb`) - Time-based data bucketing
89
+ - **Relationships** (`lib/familia/features/relationships.rb`) - CRUD operations for related objects
92
90
 
93
91
  #### Key Architectural Patterns
94
92
 
@@ -110,15 +108,6 @@ end
110
108
  - Proc: `identifier ->(user) { "user:#{user.email}" }`
111
109
  - Array: `identifier [:type, :email]`
112
110
 
113
- ### Directory Structure
114
-
115
- - `lib/familia.rb` - Main entry point and module definition
116
- - `lib/familia/horreum/` - Horreum class implementation (class_methods, commands, serialization, etc.)
117
- - `lib/familia/data_type/` - Valkey/Redis type implementations and commands
118
- - `lib/familia/features/` - Modular feature implementations
119
- - `try/` - Test files using tryouts framework
120
- - `try/test_helpers.rb` - Shared test utilities and sample classes
121
-
122
111
  ### Database Connection Management
123
112
  - Connection handling in `lib/familia/connection.rb`
124
113
  - Settings management in `lib/familia/settings.rb`
@@ -128,46 +117,7 @@ end
128
117
  ### Important Implementation Notes
129
118
 
130
119
  **Field Initialization**: Objects can be initialized with positional args (brittle) or keyword args (robust). Keyword args are recommended.
131
-
132
120
  **Serialization**: Uses JSON by default but supports custom `serialize_value`/`deserialize_value` methods.
133
-
134
121
  **Database Key Generation**: Automatic key generation using class name, identifier, and field/type names (aka dbkey). Pattern: `classname:identifier:fieldname`
135
-
136
122
  **Memory Efficiency**: Only non-nil values are stored in keystore database to optimize memory usage.
137
-
138
123
  **Thread Safety**: Data types are frozen after instantiation to ensure immutability.
139
-
140
- ## Common Patterns
141
-
142
- ### Defining a Horreum Class
143
- ```ruby
144
- class Customer < Familia::Horreum
145
- feature :safe_dump
146
- feature :expiration
147
-
148
- identifier_field :custid
149
- default_expiration 5.years
150
-
151
- field :custid
152
- field :email
153
- list :sessions
154
- hashkey :settings
155
- end
156
- ```
157
-
158
- ### Using Features
159
- ```ruby
160
- # Safe dump for API responses
161
- customer.safe_dump # Returns only whitelisted fields
162
-
163
- # Expiration management
164
- customer.update_expiration(default_expiration: 1.hour)
165
- ```
166
-
167
- ### Transaction Support
168
- ```ruby
169
- customer.transaction do |conn|
170
- conn.set("key1", "value1")
171
- conn.zadd("key2", score, member)
172
- end
173
- ```
data/Gemfile CHANGED
@@ -5,12 +5,7 @@ source 'https://rubygems.org'
5
5
  gemspec
6
6
 
7
7
  group :test do
8
- if ENV['LOCAL_DEV']
9
- gem 'tryouts', path: '../tryouts'
10
- gem 'uri-valkey', path: '..//uri-valkey/gems', glob: 'uri-valkey.gemspec'
11
- else
12
- gem 'tryouts', '~> 3.5.2', require: false
13
- end
8
+ gem 'tryouts', '~> 3.6.0', require: false
14
9
  gem 'concurrent-ruby', '~> 1.3.5', require: false
15
10
  gem 'ruby-prof'
16
11
  gem 'stackprof'