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.
- checksums.yaml +4 -4
- data/.github/workflows/claude-code-review.yml +57 -0
- data/.github/workflows/claude.yml +71 -0
- data/.gitignore +5 -1
- data/.rubocop.yml +3 -0
- data/CLAUDE.md +32 -10
- data/Gemfile +2 -2
- data/Gemfile.lock +4 -3
- data/docs/wiki/API-Reference.md +95 -18
- data/docs/wiki/Connection-Pooling-Guide.md +437 -0
- data/docs/wiki/Encrypted-Fields-Overview.md +40 -3
- data/docs/wiki/Expiration-Feature-Guide.md +596 -0
- data/docs/wiki/Feature-System-Guide.md +631 -0
- data/docs/wiki/Features-System-Developer-Guide.md +892 -0
- data/docs/wiki/Field-System-Guide.md +784 -0
- data/docs/wiki/Home.md +82 -15
- data/docs/wiki/Implementation-Guide.md +126 -33
- data/docs/wiki/Quantization-Feature-Guide.md +721 -0
- data/docs/wiki/Relationships-Guide.md +684 -0
- data/docs/wiki/Security-Model.md +65 -25
- data/docs/wiki/Transient-Fields-Guide.md +280 -0
- data/examples/bit_encoding_integration.rb +237 -0
- data/examples/redis_command_validation_example.rb +231 -0
- data/examples/relationships_basic.rb +273 -0
- data/lib/familia/base.rb +1 -1
- data/lib/familia/connection.rb +3 -3
- data/lib/familia/data_type/types/counter.rb +38 -0
- data/lib/familia/data_type/types/hashkey.rb +18 -0
- data/lib/familia/data_type/types/lock.rb +43 -0
- data/lib/familia/data_type/types/string.rb +9 -2
- data/lib/familia/data_type.rb +9 -6
- data/lib/familia/encryption/encrypted_data.rb +137 -0
- data/lib/familia/encryption/manager.rb +21 -4
- data/lib/familia/encryption/providers/aes_gcm_provider.rb +20 -0
- data/lib/familia/encryption/providers/xchacha20_poly1305_provider.rb +20 -0
- data/lib/familia/encryption.rb +1 -1
- data/lib/familia/errors.rb +17 -3
- data/lib/familia/features/encrypted_fields/concealed_string.rb +293 -0
- data/lib/familia/features/encrypted_fields/encrypted_field_type.rb +94 -26
- data/lib/familia/features/encrypted_fields.rb +413 -4
- data/lib/familia/features/expiration.rb +319 -33
- data/lib/familia/features/quantization.rb +385 -44
- data/lib/familia/features/relationships/cascading.rb +438 -0
- data/lib/familia/features/relationships/indexing.rb +370 -0
- data/lib/familia/features/relationships/membership.rb +503 -0
- data/lib/familia/features/relationships/permission_management.rb +264 -0
- data/lib/familia/features/relationships/querying.rb +620 -0
- data/lib/familia/features/relationships/redis_operations.rb +274 -0
- data/lib/familia/features/relationships/score_encoding.rb +442 -0
- data/lib/familia/features/relationships/tracking.rb +379 -0
- data/lib/familia/features/relationships.rb +466 -0
- data/lib/familia/features/safe_dump.rb +1 -1
- data/lib/familia/features/transient_fields/redacted_string.rb +1 -1
- data/lib/familia/features/transient_fields.rb +192 -10
- data/lib/familia/features.rb +2 -1
- data/lib/familia/field_type.rb +5 -2
- data/lib/familia/horreum/{connection.rb → core/connection.rb} +2 -8
- data/lib/familia/horreum/{database_commands.rb → core/database_commands.rb} +14 -3
- data/lib/familia/horreum/core/serialization.rb +535 -0
- data/lib/familia/horreum/{utils.rb → core/utils.rb} +0 -2
- data/lib/familia/horreum/core.rb +21 -0
- data/lib/familia/horreum/{settings.rb → shared/settings.rb} +0 -2
- data/lib/familia/horreum/{definition_methods.rb → subclass/definition.rb} +45 -29
- data/lib/familia/horreum/{management_methods.rb → subclass/management.rb} +9 -8
- data/lib/familia/horreum/{related_fields_management.rb → subclass/related_fields_management.rb} +15 -10
- data/lib/familia/horreum.rb +17 -17
- data/lib/familia/validation/command_recorder.rb +336 -0
- data/lib/familia/validation/expectations.rb +519 -0
- data/lib/familia/validation/test_helpers.rb +443 -0
- data/lib/familia/validation/validator.rb +412 -0
- data/lib/familia/validation.rb +140 -0
- data/lib/familia/version.rb +1 -1
- data/lib/familia.rb +1 -1
- data/try/core/create_method_try.rb +240 -0
- data/try/core/database_consistency_try.rb +299 -0
- data/try/core/errors_try.rb +25 -4
- data/try/core/familia_try.rb +1 -1
- data/try/core/persistence_operations_try.rb +297 -0
- data/try/data_types/counter_try.rb +93 -0
- data/try/data_types/lock_try.rb +133 -0
- data/try/debugging/debug_aad_process.rb +82 -0
- data/try/debugging/debug_concealed_internal.rb +59 -0
- data/try/debugging/debug_concealed_reveal.rb +61 -0
- data/try/debugging/debug_context_aad.rb +68 -0
- data/try/debugging/debug_context_simple.rb +80 -0
- data/try/debugging/debug_cross_context.rb +62 -0
- data/try/debugging/debug_database_load.rb +64 -0
- data/try/debugging/debug_encrypted_json_check.rb +53 -0
- data/try/debugging/debug_encrypted_json_step_by_step.rb +62 -0
- data/try/debugging/debug_exists_lifecycle.rb +54 -0
- data/try/debugging/debug_field_decrypt.rb +74 -0
- data/try/debugging/debug_fresh_cross_context.rb +73 -0
- data/try/debugging/debug_load_path.rb +66 -0
- data/try/debugging/debug_method_definition.rb +46 -0
- data/try/debugging/debug_method_resolution.rb +41 -0
- data/try/debugging/debug_minimal.rb +24 -0
- data/try/debugging/debug_provider.rb +68 -0
- data/try/debugging/debug_secure_behavior.rb +73 -0
- data/try/debugging/debug_string_class.rb +46 -0
- data/try/debugging/debug_test.rb +46 -0
- data/try/debugging/debug_test_design.rb +80 -0
- data/try/edge_cases/hash_symbolization_try.rb +1 -0
- data/try/edge_cases/reserved_keywords_try.rb +1 -0
- data/try/edge_cases/string_coercion_try.rb +2 -0
- data/try/encryption/encryption_core_try.rb +6 -4
- data/try/features/categorical_permissions_try.rb +515 -0
- data/try/features/encrypted_fields_core_try.rb +19 -11
- data/try/features/encrypted_fields_integration_try.rb +66 -70
- data/try/features/encrypted_fields_no_cache_security_try.rb +22 -8
- data/try/features/encrypted_fields_security_try.rb +151 -144
- data/try/features/encryption_fields/aad_protection_try.rb +108 -23
- data/try/features/encryption_fields/concealed_string_core_try.rb +253 -0
- data/try/features/encryption_fields/context_isolation_try.rb +30 -8
- data/try/features/encryption_fields/error_conditions_try.rb +6 -6
- data/try/features/encryption_fields/fresh_key_derivation_try.rb +20 -14
- data/try/features/encryption_fields/fresh_key_try.rb +27 -22
- data/try/features/encryption_fields/key_rotation_try.rb +16 -10
- data/try/features/encryption_fields/nonce_uniqueness_try.rb +15 -13
- data/try/features/encryption_fields/secure_by_default_behavior_try.rb +310 -0
- data/try/features/encryption_fields/thread_safety_try.rb +6 -6
- data/try/features/encryption_fields/universal_serialization_safety_try.rb +174 -0
- data/try/features/feature_dependencies_try.rb +3 -3
- data/try/features/relationships_edge_cases_try.rb +145 -0
- data/try/features/relationships_performance_minimal_try.rb +132 -0
- data/try/features/relationships_performance_simple_try.rb +155 -0
- data/try/features/relationships_performance_try.rb +420 -0
- data/try/features/relationships_performance_working_try.rb +144 -0
- data/try/features/relationships_try.rb +237 -0
- data/try/features/safe_dump_try.rb +3 -0
- data/try/features/transient_fields/redacted_string_try.rb +2 -0
- data/try/features/transient_fields/single_use_redacted_string_try.rb +2 -0
- data/try/features/transient_fields_core_try.rb +1 -1
- data/try/features/transient_fields_integration_try.rb +1 -1
- data/try/helpers/test_helpers.rb +26 -1
- data/try/horreum/base_try.rb +14 -8
- data/try/horreum/enhanced_conflict_handling_try.rb +3 -1
- data/try/horreum/initialization_try.rb +1 -1
- data/try/horreum/relations_try.rb +2 -2
- data/try/horreum/serialization_persistent_fields_try.rb +8 -8
- data/try/horreum/serialization_try.rb +39 -4
- data/try/models/customer_safe_dump_try.rb +1 -1
- data/try/models/customer_try.rb +1 -1
- data/try/validation/atomic_operations_try.rb.disabled +320 -0
- data/try/validation/command_validation_try.rb.disabled +207 -0
- data/try/validation/performance_validation_try.rb.disabled +324 -0
- data/try/validation/real_world_scenarios_try.rb.disabled +390 -0
- metadata +81 -12
- data/TEST_COVERAGE.md +0 -40
- data/lib/familia/features/relatable_objects.rb +0 -125
- data/lib/familia/horreum/serialization.rb +0 -473
- data/try/features/relatable_objects_try.rb +0 -220
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a93de51c8a35c420067d9e48895af37862866667af224a8e13f44647c4e4c76
|
4
|
+
data.tar.gz: bbdf64f77c182a0498fc757c393071b04b5da3594b4c7d5c12992fe058b44777
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
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
|
-
|
10
|
-
1
|
11
|
-
2
|
12
|
-
3
|
13
|
-
4
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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.
|
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.
|
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.
|
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.
|
151
|
+
tryouts (~> 3.5.1)
|
151
152
|
yard (~> 0.9)
|
152
153
|
|
153
154
|
BUNDLED WITH
|
data/docs/wiki/API-Reference.md
CHANGED
@@ -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
|
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
|
-
|
70
|
-
|
71
|
-
|
72
|
-
- `additional_data` (String, nil) - Optional AAD for authentication
|
81
|
+
### encrypt_with
|
82
|
+
|
83
|
+
Encrypts plaintext with a specific algorithm.
|
73
84
|
|
74
|
-
|
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
|
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
|
-
|
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
|
-
|
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
|
-
###
|
140
|
+
### derivation_count / reset_derivation_count!
|
104
141
|
|
105
|
-
|
142
|
+
Monitors key derivation operations (for testing and debugging).
|
106
143
|
|
107
144
|
```ruby
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
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
|