familia 2.0.0.pre5 → 2.0.0.pre7

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 (151) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/claude-code-review.yml +57 -0
  3. data/.github/workflows/claude.yml +71 -0
  4. data/.gitignore +5 -1
  5. data/.rubocop.yml +3 -0
  6. data/CLAUDE.md +32 -10
  7. data/Gemfile +2 -2
  8. data/Gemfile.lock +4 -3
  9. data/docs/wiki/API-Reference.md +95 -18
  10. data/docs/wiki/Connection-Pooling-Guide.md +437 -0
  11. data/docs/wiki/Encrypted-Fields-Overview.md +40 -3
  12. data/docs/wiki/Expiration-Feature-Guide.md +596 -0
  13. data/docs/wiki/Feature-System-Guide.md +631 -0
  14. data/docs/wiki/Features-System-Developer-Guide.md +892 -0
  15. data/docs/wiki/Field-System-Guide.md +784 -0
  16. data/docs/wiki/Home.md +82 -15
  17. data/docs/wiki/Implementation-Guide.md +126 -33
  18. data/docs/wiki/Quantization-Feature-Guide.md +721 -0
  19. data/docs/wiki/Relationships-Guide.md +684 -0
  20. data/docs/wiki/Security-Model.md +65 -25
  21. data/docs/wiki/Transient-Fields-Guide.md +280 -0
  22. data/examples/bit_encoding_integration.rb +237 -0
  23. data/examples/redis_command_validation_example.rb +231 -0
  24. data/examples/relationships_basic.rb +273 -0
  25. data/lib/familia/base.rb +1 -1
  26. data/lib/familia/connection.rb +3 -3
  27. data/lib/familia/data_type/types/counter.rb +38 -0
  28. data/lib/familia/data_type/types/hashkey.rb +18 -0
  29. data/lib/familia/data_type/types/lock.rb +43 -0
  30. data/lib/familia/data_type/types/string.rb +9 -2
  31. data/lib/familia/data_type.rb +9 -6
  32. data/lib/familia/encryption/encrypted_data.rb +137 -0
  33. data/lib/familia/encryption/manager.rb +21 -4
  34. data/lib/familia/encryption/providers/aes_gcm_provider.rb +20 -0
  35. data/lib/familia/encryption/providers/xchacha20_poly1305_provider.rb +20 -0
  36. data/lib/familia/encryption.rb +1 -1
  37. data/lib/familia/errors.rb +17 -3
  38. data/lib/familia/features/encrypted_fields/concealed_string.rb +293 -0
  39. data/lib/familia/features/encrypted_fields/encrypted_field_type.rb +94 -26
  40. data/lib/familia/features/encrypted_fields.rb +413 -4
  41. data/lib/familia/features/expiration.rb +319 -33
  42. data/lib/familia/features/quantization.rb +385 -44
  43. data/lib/familia/features/relationships/cascading.rb +438 -0
  44. data/lib/familia/features/relationships/indexing.rb +370 -0
  45. data/lib/familia/features/relationships/membership.rb +503 -0
  46. data/lib/familia/features/relationships/permission_management.rb +264 -0
  47. data/lib/familia/features/relationships/querying.rb +620 -0
  48. data/lib/familia/features/relationships/redis_operations.rb +274 -0
  49. data/lib/familia/features/relationships/score_encoding.rb +442 -0
  50. data/lib/familia/features/relationships/tracking.rb +379 -0
  51. data/lib/familia/features/relationships.rb +466 -0
  52. data/lib/familia/features/safe_dump.rb +1 -1
  53. data/lib/familia/features/transient_fields/redacted_string.rb +1 -1
  54. data/lib/familia/features/transient_fields.rb +192 -10
  55. data/lib/familia/features.rb +2 -1
  56. data/lib/familia/field_type.rb +5 -2
  57. data/lib/familia/horreum/{connection.rb → core/connection.rb} +2 -8
  58. data/lib/familia/horreum/{database_commands.rb → core/database_commands.rb} +14 -3
  59. data/lib/familia/horreum/core/serialization.rb +535 -0
  60. data/lib/familia/horreum/{utils.rb → core/utils.rb} +0 -2
  61. data/lib/familia/horreum/core.rb +21 -0
  62. data/lib/familia/horreum/{settings.rb → shared/settings.rb} +0 -2
  63. data/lib/familia/horreum/{definition_methods.rb → subclass/definition.rb} +45 -29
  64. data/lib/familia/horreum/{management_methods.rb → subclass/management.rb} +9 -8
  65. data/lib/familia/horreum/{related_fields_management.rb → subclass/related_fields_management.rb} +15 -10
  66. data/lib/familia/horreum.rb +17 -17
  67. data/lib/familia/validation/command_recorder.rb +336 -0
  68. data/lib/familia/validation/expectations.rb +519 -0
  69. data/lib/familia/validation/test_helpers.rb +443 -0
  70. data/lib/familia/validation/validator.rb +412 -0
  71. data/lib/familia/validation.rb +140 -0
  72. data/lib/familia/version.rb +1 -1
  73. data/lib/familia.rb +1 -1
  74. data/try/core/create_method_try.rb +240 -0
  75. data/try/core/database_consistency_try.rb +299 -0
  76. data/try/core/errors_try.rb +25 -4
  77. data/try/core/familia_try.rb +1 -1
  78. data/try/core/persistence_operations_try.rb +297 -0
  79. data/try/data_types/counter_try.rb +93 -0
  80. data/try/data_types/lock_try.rb +133 -0
  81. data/try/debugging/debug_aad_process.rb +82 -0
  82. data/try/debugging/debug_concealed_internal.rb +59 -0
  83. data/try/debugging/debug_concealed_reveal.rb +61 -0
  84. data/try/debugging/debug_context_aad.rb +68 -0
  85. data/try/debugging/debug_context_simple.rb +80 -0
  86. data/try/debugging/debug_cross_context.rb +62 -0
  87. data/try/debugging/debug_database_load.rb +64 -0
  88. data/try/debugging/debug_encrypted_json_check.rb +53 -0
  89. data/try/debugging/debug_encrypted_json_step_by_step.rb +62 -0
  90. data/try/debugging/debug_exists_lifecycle.rb +54 -0
  91. data/try/debugging/debug_field_decrypt.rb +74 -0
  92. data/try/debugging/debug_fresh_cross_context.rb +73 -0
  93. data/try/debugging/debug_load_path.rb +66 -0
  94. data/try/debugging/debug_method_definition.rb +46 -0
  95. data/try/debugging/debug_method_resolution.rb +41 -0
  96. data/try/debugging/debug_minimal.rb +24 -0
  97. data/try/debugging/debug_provider.rb +68 -0
  98. data/try/debugging/debug_secure_behavior.rb +73 -0
  99. data/try/debugging/debug_string_class.rb +46 -0
  100. data/try/debugging/debug_test.rb +46 -0
  101. data/try/debugging/debug_test_design.rb +80 -0
  102. data/try/edge_cases/hash_symbolization_try.rb +1 -0
  103. data/try/edge_cases/reserved_keywords_try.rb +1 -0
  104. data/try/edge_cases/string_coercion_try.rb +2 -0
  105. data/try/encryption/encryption_core_try.rb +6 -4
  106. data/try/features/categorical_permissions_try.rb +515 -0
  107. data/try/features/encrypted_fields_core_try.rb +19 -11
  108. data/try/features/encrypted_fields_integration_try.rb +66 -70
  109. data/try/features/encrypted_fields_no_cache_security_try.rb +22 -8
  110. data/try/features/encrypted_fields_security_try.rb +151 -144
  111. data/try/features/encryption_fields/aad_protection_try.rb +108 -23
  112. data/try/features/encryption_fields/concealed_string_core_try.rb +253 -0
  113. data/try/features/encryption_fields/context_isolation_try.rb +30 -8
  114. data/try/features/encryption_fields/error_conditions_try.rb +6 -6
  115. data/try/features/encryption_fields/fresh_key_derivation_try.rb +20 -14
  116. data/try/features/encryption_fields/fresh_key_try.rb +27 -22
  117. data/try/features/encryption_fields/key_rotation_try.rb +16 -10
  118. data/try/features/encryption_fields/nonce_uniqueness_try.rb +15 -13
  119. data/try/features/encryption_fields/secure_by_default_behavior_try.rb +310 -0
  120. data/try/features/encryption_fields/thread_safety_try.rb +6 -6
  121. data/try/features/encryption_fields/universal_serialization_safety_try.rb +174 -0
  122. data/try/features/feature_dependencies_try.rb +3 -3
  123. data/try/features/relationships_edge_cases_try.rb +145 -0
  124. data/try/features/relationships_performance_minimal_try.rb +132 -0
  125. data/try/features/relationships_performance_simple_try.rb +155 -0
  126. data/try/features/relationships_performance_try.rb +420 -0
  127. data/try/features/relationships_performance_working_try.rb +144 -0
  128. data/try/features/relationships_try.rb +237 -0
  129. data/try/features/safe_dump_try.rb +3 -0
  130. data/try/features/transient_fields/redacted_string_try.rb +2 -0
  131. data/try/features/transient_fields/single_use_redacted_string_try.rb +2 -0
  132. data/try/features/transient_fields_core_try.rb +1 -1
  133. data/try/features/transient_fields_integration_try.rb +1 -1
  134. data/try/helpers/test_helpers.rb +26 -1
  135. data/try/horreum/base_try.rb +14 -8
  136. data/try/horreum/enhanced_conflict_handling_try.rb +3 -1
  137. data/try/horreum/initialization_try.rb +1 -1
  138. data/try/horreum/relations_try.rb +2 -2
  139. data/try/horreum/serialization_persistent_fields_try.rb +8 -8
  140. data/try/horreum/serialization_try.rb +39 -4
  141. data/try/models/customer_safe_dump_try.rb +1 -1
  142. data/try/models/customer_try.rb +1 -1
  143. data/try/validation/atomic_operations_try.rb.disabled +320 -0
  144. data/try/validation/command_validation_try.rb.disabled +207 -0
  145. data/try/validation/performance_validation_try.rb.disabled +324 -0
  146. data/try/validation/real_world_scenarios_try.rb.disabled +390 -0
  147. metadata +81 -12
  148. data/TEST_COVERAGE.md +0 -40
  149. data/lib/familia/features/relatable_objects.rb +0 -125
  150. data/lib/familia/horreum/serialization.rb +0 -473
  151. data/try/features/relatable_objects_try.rb +0 -220
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5517961b53f3213a7d92f9bd07001291bcdae102f1ca5cf59570537020e4fc2f
4
- data.tar.gz: 44610f83cf5b65d1cde483c91b9a259816bb1040da2b1ff77867061be8aeaf36
3
+ metadata.gz: 7a93de51c8a35c420067d9e48895af37862866667af224a8e13f44647c4e4c76
4
+ data.tar.gz: bbdf64f77c182a0498fc757c393071b04b5da3594b4c7d5c12992fe058b44777
5
5
  SHA512:
6
- metadata.gz: 9e02c91aa204b248bf6853637c21ffdeabc90d7b04661c5ddc2cb99260fc0ebb6cc2d4780aed0d45e6f30e64e49229e15201551073f5c804fa8c2a0add328c97
7
- data.tar.gz: ef296043a9b843fa27745d15b505fa11f2df4f5baeb505189d02013fb3f02cfccb49f9d3606912b101ed95ef6b2f3967ade5b8ff79e67c6e50ebda7a81ef0e15
6
+ metadata.gz: 59a39a481db42739bbebabab9211645b2f7e9eb605742ab936c0b65dfc32973931b1b1f8a1c5d725fed5f5eb0ebdbb87c1c405f87108390ad3b6eb8f5ca89c5a
7
+ data.tar.gz: 4dc7dededb21bd7ee988a4d260e30eceb43f19be4c3f5d99f87bac5d632af6e517af5eab2633758e0c6b1552a2635bd0e024ace2210ee1ee83362aa811458b8c
@@ -0,0 +1,57 @@
1
+ name: Claude Code Review
2
+
3
+ on:
4
+ pull_request:
5
+ types: [opened, synchronize]
6
+ # Optional: Only run on specific file changes
7
+ # paths:
8
+ # - "src/**/*.ts"
9
+ # - "src/**/*.tsx"
10
+ # - "src/**/*.js"
11
+ # - "src/**/*.jsx"
12
+
13
+ jobs:
14
+ claude-review:
15
+ # Optional: Filter by PR author
16
+ # if: |
17
+ # github.event.pull_request.user.login == 'external-contributor' ||
18
+ # github.event.pull_request.user.login == 'new-developer' ||
19
+ # github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
20
+
21
+ runs-on: ubuntu-latest
22
+ permissions:
23
+ contents: read
24
+ pull-requests: read
25
+ issues: read
26
+ id-token: write
27
+
28
+ steps:
29
+ - name: Checkout repository
30
+ uses: actions/checkout@v4
31
+ with:
32
+ fetch-depth: 1
33
+
34
+ - name: Run Claude Code Review
35
+ id: claude-review
36
+ uses: anthropics/claude-code-action@beta
37
+ with:
38
+ claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
39
+
40
+ # Optional: Use sticky comments to make Claude reuse the same comment on subsequent pushes to the same PR
41
+ use_sticky_comment: true
42
+
43
+ prompt: |
44
+ Please review this pull request and provide feedback on:
45
+ - Code quality and best practices
46
+ - Potential bugs or issues
47
+ - Performance considerations
48
+ - Security concerns
49
+ - Test coverage
50
+
51
+ Use the repository's CLAUDE.md for guidance on style and conventions. Be constructive and helpful in your feedback.
52
+
53
+ Use `gh pr comment` with your Bash tool to leave your review as a comment on the PR.
54
+
55
+ # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
56
+ # or https://docs.anthropic.com/en/docs/claude-code/sdk#command-line for available options
57
+ claude_args: '--allowed-tools "Bash(gh issue view:*),Bash(gh search:*),Bash(gh issue list:*),Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr list:*)"'
@@ -0,0 +1,71 @@
1
+ name: Claude Code
2
+
3
+ on:
4
+ issue_comment:
5
+ types: [created]
6
+ pull_request_review_comment:
7
+ types: [created]
8
+ issues:
9
+ types: [opened, assigned]
10
+ pull_request_review:
11
+ types: [submitted]
12
+
13
+ jobs:
14
+ claude:
15
+ if: |
16
+ (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
17
+ (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
18
+ (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
19
+ (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
20
+ runs-on: ubuntu-latest
21
+ permissions:
22
+ contents: read
23
+ pull-requests: read
24
+ issues: read
25
+ id-token: write
26
+ actions: read # Required for Claude to read CI results on PRs
27
+ steps:
28
+ - name: Checkout repository
29
+ uses: actions/checkout@v4
30
+ with:
31
+ fetch-depth: 1
32
+
33
+ - name: Run Claude Code
34
+ id: claude
35
+ uses: anthropics/claude-code-action@v1
36
+ with:
37
+ claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
38
+
39
+ # This is an optional setting that allows Claude to read CI results on PRs
40
+ additional_permissions: |
41
+ actions: read
42
+
43
+ # Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4)
44
+ # model: "claude-opus-4-20250514"
45
+
46
+ # Optional: Customize the trigger phrase (default: @claude)
47
+ # trigger_phrase: "/claude"
48
+
49
+ # Optional: Trigger when specific user is assigned to an issue
50
+ # assignee_trigger: "claude-bot"
51
+
52
+ # Optional: Allow Claude to run specific commands
53
+ # allowed_tools: "Bash(npm install),Bash(npm run build),Bash(npm run test:*),Bash(npm run lint:*)"
54
+
55
+ # Optional: Add custom instructions for Claude to customize its behavior for your project
56
+ # custom_instructions: |
57
+ # Follow our coding standards
58
+ # Ensure all new code has tests
59
+ # Use TypeScript for new files
60
+
61
+ # Optional: Custom environment variables for Claude
62
+ # claude_env: |
63
+ # NODE_ENV: test
64
+
65
+ # Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it.
66
+ # prompt: 'Update the pull request description to include a summary of changes.'
67
+
68
+ # Optional: Add claude_args to customize behavior and configuration
69
+ # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
70
+ # or https://docs.anthropic.com/en/docs/claude-code/sdk#command-line for available options
71
+ # claude_args: '--model claude-opus-4-1-20250805 --allowed-tools Bash(gh pr:*)'
data/.gitignore CHANGED
@@ -1,14 +1,19 @@
1
1
  .DS_Store
2
2
  .bundle
3
3
  .byebug*
4
+ .ruby-lsp
4
5
  .prompts
5
6
  .history
6
7
  .devcontainer
7
8
  .vscode
9
+ .serena
10
+ .claude
11
+ .yardoc
8
12
  .*.json
9
13
  *.env
10
14
  *.log
11
15
  *.md
16
+ .mcp.json
12
17
  !README.md
13
18
  !CLAUDE.md
14
19
  *.txt
@@ -21,7 +26,6 @@ tmp
21
26
  vendor
22
27
  *.gem
23
28
  doc/
24
- .yardoc
25
29
  !docs/overview.md
26
30
  !docs/connection_pooling.md
27
31
  !docs/wiki/**/*.md
data/.rubocop.yml CHANGED
@@ -80,3 +80,6 @@ Naming/AsciiIdentifiers:
80
80
 
81
81
  Style/FrozenStringLiteralComment:
82
82
  Enabled: false
83
+
84
+ Naming/MemoizedInstanceVariableName:
85
+ Enabled: false
data/CLAUDE.md CHANGED
@@ -6,16 +6,38 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
6
6
 
7
7
  ### Testing
8
8
 
9
- A couple rules when writing tests:
10
- 1) Every tryouts file has three sections: setup, testcases, teardown.
11
- 2) Every tryouts testcase also has three parts: description, code, expectations.
12
- 3) Tryouts tests are meant to double as documentation examples; keep that in mind when considering syntax choices.
13
- 4) There are multiple kinds of expectations: `#=>` is the default comparison, `#=:>` is a class comparison via `is_a?` or `kind_of?`, `#=!>` is an exception class which allows you to knowingly raise an exception without needing a begin/rescue.
14
-
15
- - **Run tests**: `bundle exec try` (uses tryouts testing framework)
16
- - **Run specific test file, verbose**: `bundle exec try -v try/specific_test_try.rb`
17
- - **Debug mode**: `FAMILIA_DEBUG=1 bundle exec try -D`
18
- - **Trace mode**: `FAMILIA_TRACE=1 bundle exec try -D` (detailed Redis operation logging)
9
+ **Tryouts framework rules:**
10
+ 1. **Structure**: Each file has 3 sections - setup (optional), testcases, teardown (optional); each testcase has 3 required parts: description, code, expectations.
11
+ 2. **Test cases**: Use `##` line prefix for test descriptions, Ruby code, then `#=>` expectations
12
+ 3. **Variables**: Instance variables (`@var`) persist across sections; local variables do not.
13
+ 4. **Expectations**: Multiple expectation types available (`#=>`, `#==>`, `#=:>`, `#=!>`, etc.); each testcase can have multiple expectations.
14
+ 5. **Comments**: Use single `#` prefix, but DO NOT label file sections
15
+ 6. **Philosophy**: Plain realistic code, avoid mocks/test DSL
16
+ 7. **Result**: Last expression in each test case is the result
17
+
18
+ **Running tests:**
19
+ - **Basic**: `bundle exec try` (auto-discovers `*_try.rb` and `*.try.rb` files)
20
+ - **All options**: `bundle exec try --help` (complete CLI reference with agent-specific notes)
21
+
22
+ **Agent-optimized workflow:**
23
+ - **Default agent mode**: `bundle exec try --agent` (structured, token-efficient output for LLMs)
24
+ - **Focus modes**: `bundle exec try --agent --agent-focus summary` (options: `summary|first-failure|critical`)
25
+ - `summary`: Overview of test results only
26
+ - `first-failure`: Stop at first failure with details
27
+ - `critical`: Only show critical issues and summary
28
+
29
+ **Framework integration:**
30
+ - **RSpec**: `bundle exec try --rspec` (generates RSpec-compatible output)
31
+ - **Minitest**: `bundle exec try --minitest` (generates Minitest-compatible output)
32
+
33
+ **Debugging options:**
34
+ - **Stack traces**: `bundle exec try -s` (stack traces without debug logging)
35
+ - **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)
38
+
39
+ *Note: Use `--agent` mode for optimal token efficiency when analyzing test results programmatically.*
40
+
19
41
 
20
42
  ### Development Setup
21
43
  - **Install dependencies**: `bundle install`
data/Gemfile CHANGED
@@ -9,7 +9,7 @@ group :test do
9
9
  gem 'tryouts', path: '../tryouts'
10
10
  gem 'uri-valkey', path: '..//uri-valkey/gems', glob: 'uri-valkey.gemspec'
11
11
  else
12
- gem 'tryouts', '~> 3.2.2', require: false
12
+ gem 'tryouts', '~> 3.5.1', require: false
13
13
  end
14
14
  gem 'concurrent-ruby', '~> 1.3.5', require: false
15
15
  gem 'ruby-prof'
@@ -19,13 +19,13 @@ end
19
19
  group :development, :test do
20
20
  # byebug only works with MRI
21
21
  gem 'byebug', '~> 11.0', require: false if RUBY_ENGINE == 'ruby'
22
+ gem 'irb', '~> 1.15.2', require: false
22
23
  gem 'kramdown', require: false # Required for YARD markdown processing
23
24
  gem 'pry-byebug', '~> 3.10.1', require: false if RUBY_ENGINE == 'ruby'
24
25
  gem 'rubocop', require: false
25
26
  gem 'rubocop-performance', require: false
26
27
  gem 'rubocop-thread_safety', require: false
27
28
  gem 'yard', '~> 0.9', require: false
28
- gem 'irb', '~> 1.15.2', require: false
29
29
  end
30
30
 
31
31
  group :optional do
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- familia (2.0.0.pre5)
4
+ familia (2.0.0.pre6)
5
5
  benchmark
6
6
  connection_pool
7
7
  csv
@@ -113,7 +113,8 @@ GEM
113
113
  ruby-progressbar (1.13.0)
114
114
  stackprof (0.2.27)
115
115
  stringio (3.1.7)
116
- tryouts (3.2.2)
116
+ tryouts (3.5.1)
117
+ concurrent-ruby (~> 1.0)
117
118
  irb
118
119
  minitest (~> 5.0)
119
120
  pastel (~> 0.8)
@@ -147,7 +148,7 @@ DEPENDENCIES
147
148
  rubocop-thread_safety
148
149
  ruby-prof
149
150
  stackprof
150
- tryouts (~> 3.2.2)
151
+ tryouts (~> 3.5.1)
151
152
  yard (~> 0.9)
152
153
 
153
154
  BUNDLED WITH
@@ -55,9 +55,21 @@ vault.secret_data(passphrase_value: "user_passphrase")
55
55
 
56
56
  ## Familia::Encryption Module
57
57
 
58
+ ### manager
59
+
60
+ Creates a manager instance with optional algorithm selection.
61
+
62
+ ```ruby
63
+ # Use best available provider
64
+ mgr = Familia::Encryption.manager
65
+
66
+ # Use specific algorithm
67
+ mgr = Familia::Encryption.manager(algorithm: 'xchacha20poly1305')
68
+ ```
69
+
58
70
  ### encrypt
59
71
 
60
- Encrypts plaintext with context-specific key.
72
+ Encrypts plaintext using the default provider.
61
73
 
62
74
  ```ruby
63
75
  Familia::Encryption.encrypt(plaintext,
@@ -66,16 +78,20 @@ Familia::Encryption.encrypt(plaintext,
66
78
  )
67
79
  ```
68
80
 
69
- **Parameters:**
70
- - `plaintext` (String) - Data to encrypt
71
- - `context` (String) - Key derivation context
72
- - `additional_data` (String, nil) - Optional AAD for authentication
81
+ ### encrypt_with
82
+
83
+ Encrypts plaintext with a specific algorithm.
73
84
 
74
- **Returns:** JSON string with encrypted data structure
85
+ ```ruby
86
+ Familia::Encryption.encrypt_with('aes-256-gcm', plaintext,
87
+ context: "User:favorite_snack:user123",
88
+ additional_data: nil
89
+ )
90
+ ```
75
91
 
76
92
  ### decrypt
77
93
 
78
- Decrypts ciphertext with context-specific key.
94
+ Decrypts ciphertext (auto-detects algorithm from JSON).
79
95
 
80
96
  ```ruby
81
97
  Familia::Encryption.decrypt(encrypted_json,
@@ -84,12 +100,33 @@ Familia::Encryption.decrypt(encrypted_json,
84
100
  )
85
101
  ```
86
102
 
87
- **Parameters:**
88
- - `encrypted_json` (String) - JSON-encoded encrypted data
89
- - `context` (String) - Key derivation context
90
- - `additional_data` (String, nil) - Optional AAD for verification
103
+ ### status
91
104
 
92
- **Returns:** Decrypted plaintext string
105
+ Returns current encryption configuration and available providers.
106
+
107
+ ```ruby
108
+ Familia::Encryption.status
109
+ # => {
110
+ # default_algorithm: "xchacha20poly1305",
111
+ # available_algorithms: ["xchacha20poly1305", "aes-256-gcm"],
112
+ # preferred_available: "Familia::Encryption::Providers::XChaCha20Poly1305Provider",
113
+ # using_hardware: false,
114
+ # key_versions: [:v1],
115
+ # current_version: :v1
116
+ # }
117
+ ```
118
+
119
+ ### benchmark
120
+
121
+ Benchmarks available providers.
122
+
123
+ ```ruby
124
+ Familia::Encryption.benchmark(iterations: 1000)
125
+ # => {
126
+ # "xchacha20poly1305" => { time: 0.45, ops_per_sec: 4444, priority: 100 },
127
+ # "aes-256-gcm" => { time: 0.52, ops_per_sec: 3846, priority: 50 }
128
+ # }
129
+ ```
93
130
 
94
131
  ### validate_configuration!
95
132
 
@@ -100,17 +137,57 @@ Familia::Encryption.validate_configuration!
100
137
  # Raises Familia::EncryptionError if configuration invalid
101
138
  ```
102
139
 
103
- ### with_key_cache
140
+ ### derivation_count / reset_derivation_count!
104
141
 
105
- Provides request-scoped key caching.
142
+ Monitors key derivation operations (for testing and debugging).
106
143
 
107
144
  ```ruby
108
- Familia::Encryption.with_key_cache do
109
- # Operations here share derived keys
110
- users.each { |u| u.decrypt_fields }
111
- end
145
+ # Check how many key derivations have occurred
146
+ count = Familia::Encryption.derivation_count.value
147
+ # => 42
148
+
149
+ # Reset counter
150
+ Familia::Encryption.reset_derivation_count!
112
151
  ```
113
152
 
153
+ ## Familia::Encryption::Manager
154
+
155
+ Low-level manager class for direct provider control.
156
+
157
+ ### initialize
158
+
159
+ ```ruby
160
+ # Use default provider
161
+ manager = Familia::Encryption::Manager.new
162
+
163
+ # Use specific algorithm
164
+ manager = Familia::Encryption::Manager.new(algorithm: 'aes-256-gcm')
165
+ ```
166
+
167
+ ### encrypt / decrypt
168
+
169
+ Same interface as module-level methods but tied to specific provider.
170
+
171
+ ## Familia::Encryption::Registry
172
+
173
+ Provider management system.
174
+
175
+ ### setup!
176
+
177
+ Registers all available providers.
178
+
179
+ ### get
180
+
181
+ Returns provider instance by algorithm name.
182
+
183
+ ### default_provider
184
+
185
+ Returns highest-priority available provider instance.
186
+
187
+ ### available_algorithms
188
+
189
+ Returns array of available algorithm names.
190
+
114
191
  ## Configuration
115
192
 
116
193
  ### Familia.configure