-
Notifications
You must be signed in to change notification settings - Fork 61
feat: add Mocker plugin for intercepting and mocking AI provider responses #106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Summary by CodeRabbit
Summary by CodeRabbit
WalkthroughThis update introduces a new, fully documented and benchmarked mocking plugin for the Bifrost framework. The changes add the Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Bifrost
participant MockerPlugin
Client->>Bifrost: Send Request
Bifrost->>MockerPlugin: PreHook(request)
alt Rule matches and triggers mock
MockerPlugin->>MockerPlugin: Simulate latency (optional)
MockerPlugin->>MockerPlugin: Generate mock response or error
MockerPlugin-->>Bifrost: ShortCircuit(mock response/error)
else No rule matches
MockerPlugin-->>Bifrost: Passthrough or default behavior
end
Bifrost->>Client: Return response or error
Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
🧪 Generate Unit Tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
plugins/mocker/go.sum
is excluded by!**/*.sum
📒 Files selected for processing (5)
plugins/mocker/README.md
(1 hunks)plugins/mocker/benchmark_test.go
(1 hunks)plugins/mocker/go.mod
(1 hunks)plugins/mocker/main.go
(1 hunks)plugins/mocker/plugin_test.go
(1 hunks)
🧰 Additional context used
🪛 LanguageTool
plugins/mocker/README.md
[uncategorized] ~213-~213: When ‘Match-specific’ is used as a modifier, it is usually spelled with a hyphen.
Context: ... | []string
| No | []
| Match specific providers: ["openai", "anthropic"]
| ...
(SPECIFIC_HYPHEN)
[uncategorized] ~214-~214: When ‘Match-specific’ is used as a modifier, it is usually spelled with a hyphen.
Context: ... | []string
| No | []
| Match specific models: ["gpt-4", "claude-3"]
| ...
(SPECIFIC_HYPHEN)
[uncategorized] ~591-~591: Do not mix variants of the same word (‘regexp’ and ‘regex’) within a single text.
Context: ...ing plugin initialization - Before: regexp.Compile()
on every request (~1000x slo...
(EN_WORD_COHERENCY)
[uncategorized] ~841-~841: Possible missing preposition found.
Context: ...l rules should have higher priority - Group related rules: Keep similar functiona...
(AI_HYDRA_LEO_MISSING_TO)
🪛 markdownlint-cli2 (0.17.2)
plugins/mocker/README.md
646-646: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
654-654: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
694-694: Trailing punctuation in heading
Punctuation: ':'
(MD026, no-trailing-punctuation)
726-726: Trailing punctuation in heading
Punctuation: ':'
(MD026, no-trailing-punctuation)
1057-1057: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
🪛 golangci-lint (1.64.8)
plugins/mocker/plugin_test.go
549-549: func boolPtr
is unused
(unused)
🔇 Additional comments (4)
plugins/mocker/go.mod (1)
3-3
: Verify Go version - appears to be invalidGo version 1.24.1 doesn't exist yet. The latest stable Go version is 1.23.x. This appears to be either a typo or configuration error.
What is the latest stable version of Go programming language?
Consider updating to a valid Go version:
-go 1.24.1 +go 1.23.0⛔ Skipped due to learnings
Learnt from: Pratham-Mishra04 PR: maximhq/bifrost#81 File: tests/core-providers/go.mod:3-4 Timestamp: 2025-06-16T03:55:16.949Z Learning: Go 1.24 was released in February 2025 and is stable and available for use in go.mod files.
plugins/mocker/README.md (2)
256-260
: Excellent warning about time.Duration usage!The warning about using Go's
time.Duration
constants instead of raw integers is crucial for preventing hard-to-debug issues. The examples clearly show the correct usage.
591-591
: Maintain consistency between 'regexp' and 'regex' terminologyThe documentation uses both 'regexp' and 'regex' which could be confusing. Consider using 'regex' consistently throughout.
-- **Before**: `regexp.Compile()` on every request (~1000x slower) +- **Before**: `regex.Compile()` on every request (~1000x slower)Likely an incorrect or invalid review comment.
plugins/mocker/benchmark_test.go (1)
1-296
: Well-structured benchmark suite with comprehensive coverageThe benchmark tests effectively cover all major performance scenarios:
- Simple string matching (fastest path)
- Regex pattern matching
- Multiple rule evaluation with priorities
- No-match passthrough (minimal overhead)
- Template variable substitution
Good practices observed:
- Proper use of
b.ResetTimer()
andb.ReportAllocs()
- Realistic test data setup
- Coverage of both common and edge cases
338fd40
to
0e076bf
Compare
57ebad0
to
1a9edd9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
♻️ Duplicate comments (4)
plugins/mocker/README.md (1)
646-646
: Add language specifiers to fenced code blocksAlso applies to: 654-654
plugins/mocker/plugin_test.go (1)
549-551
: Remove unused boolPtr helperplugins/mocker/main.go (2)
865-865
: Consider using a helper function for string pointer creation
884-892
: Optimize rule sorting algorithm
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
plugins/mocker/go.sum
is excluded by!**/*.sum
📒 Files selected for processing (5)
plugins/mocker/README.md
(1 hunks)plugins/mocker/benchmark_test.go
(1 hunks)plugins/mocker/go.mod
(1 hunks)plugins/mocker/main.go
(1 hunks)plugins/mocker/plugin_test.go
(1 hunks)
🧰 Additional context used
🪛 LanguageTool
plugins/mocker/README.md
[uncategorized] ~213-~213: When ‘Match-specific’ is used as a modifier, it is usually spelled with a hyphen.
Context: ... | []string
| No | []
| Match specific providers: ["openai", "anthropic"]
| ...
(SPECIFIC_HYPHEN)
[uncategorized] ~214-~214: When ‘Match-specific’ is used as a modifier, it is usually spelled with a hyphen.
Context: ... | []string
| No | []
| Match specific models: ["gpt-4", "claude-3"]
| ...
(SPECIFIC_HYPHEN)
[uncategorized] ~591-~591: Do not mix variants of the same word (‘regexp’ and ‘regex’) within a single text.
Context: ...ing plugin initialization - Before: regexp.Compile()
on every request (~1000x slo...
(EN_WORD_COHERENCY)
[uncategorized] ~841-~841: Possible missing preposition found.
Context: ...l rules should have higher priority - Group related rules: Keep similar functiona...
(AI_HYDRA_LEO_MISSING_TO)
🪛 markdownlint-cli2 (0.17.2)
plugins/mocker/README.md
646-646: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
654-654: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
694-694: Trailing punctuation in heading
Punctuation: ':'
(MD026, no-trailing-punctuation)
726-726: Trailing punctuation in heading
Punctuation: ':'
(MD026, no-trailing-punctuation)
1057-1057: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
🪛 golangci-lint (1.64.8)
plugins/mocker/plugin_test.go
549-549: func boolPtr
is unused
(unused)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Graphite / mergeability_check
- GitHub Check: Graphite / mergeability_check
🔇 Additional comments (7)
plugins/mocker/go.mod (1)
3-3
: Fix invalid Go versionGo version 1.24.1 doesn't exist. The latest stable version is 1.22.x. This will cause module initialization errors.
Apply this fix:
-go 1.24.1 +go 1.22⛔ Skipped due to learnings
Learnt from: Pratham-Mishra04 PR: maximhq/bifrost#81 File: tests/core-providers/go.mod:3-4 Timestamp: 2025-06-16T04:27:53.538Z Learning: In Go module files, `go 1.24.1` (with patch version) can work fine in some setups, contrary to the general rule that go directives should only include major.minor versions.
Learnt from: Pratham-Mishra04 PR: maximhq/bifrost#81 File: tests/core-providers/go.mod:3-4 Timestamp: 2025-06-16T03:55:16.949Z Learning: Go 1.24 was released in February 2025 and is stable and available for use in go.mod files.
plugins/mocker/README.md (1)
1-1060
: Excellent comprehensive documentation!The README provides thorough coverage of installation, configuration, usage examples, performance optimization, and troubleshooting. The structure is clear and includes helpful quick start examples.
plugins/mocker/benchmark_test.go (1)
12-295
: Well-structured benchmark suiteThe benchmarks effectively cover various scenarios including simple rules, regex matching, multiple rules, no-match cases, and template processing. Good use of
ResetTimer()
andReportAllocs()
for accurate measurements.plugins/mocker/plugin_test.go (1)
14-551
: Comprehensive test coverageThe test suite provides excellent coverage including:
- Plugin lifecycle (enable/disable)
- Default behaviors and custom rules
- Success and error responses
- Template processing
- Statistics tracking
- Configuration validation
The
BaseAccount
mock implementation is well-designed for testing purposes.plugins/mocker/main.go (3)
198-220
: Excellent performance optimization with pre-compiled regexPre-compiling regex patterns during initialization is a great optimization that significantly improves runtime performance. The error handling for invalid regex patterns is also properly implemented.
433-485
: Well-designed PreHook implementation with atomic operationsThe
PreHook
method efficiently handles request interception with:
- Early return for disabled plugin
- Atomic counters for lock-free statistics
- Priority-based rule matching
- Probability-based activation
- Proper latency simulation
The use of atomic operations for counters is a smart optimization for high-throughput scenarios.
566-620
: Efficient message extraction with string builderThe
extractMessageContentFast
method is well-optimized:
- Fast path for single messages
- Efficient string builder for multiple messages
- Proper handling of both text and chat completion inputs
1a9edd9
to
3ed1607
Compare
0e076bf
to
298ed94
Compare
298ed94
to
9f9ab0f
Compare
9f9ab0f
to
4842487
Compare
4842487
to
0ac12f0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (3)
plugins/mocker/benchmark_test.go (1)
47-47
: Add missing stringPtr helper functionThe
stringPtr
function is used throughout the benchmarks but not defined in this file. This will cause compilation errors.Add this helper function at the beginning of the file:
package mocker import ( "context" "strconv" "testing" bifrost "github.com/maximhq/bifrost/core" "github.com/maximhq/bifrost/core/schemas" ) + +// stringPtr returns a pointer to the string value +func stringPtr(s string) *string { + return &s +} // BenchmarkMockerPlugin_PreHook_SimpleRule benchmarks simple rule matchingAlso applies to: 75-75, 100-100, 175-175, 229-229, 261-261, 280-280
plugins/mocker/README.md (1)
1299-1299
: Add language specifier to fenced code block-``` +```textplugins/mocker/main.go (1)
905-905
: Consider using a helper function for string pointer creationFor consistency with other parts of the codebase, consider extracting the inline function to a helper:
+// stringPtr returns a pointer to the string value +func stringPtr(s string) *string { + return &s +} // ... in handleDefaultBehavior method ... - ContentStr: func() *string { s := "Mock plugin default response"; return &s }(), + ContentStr: stringPtr("Mock plugin default response"),
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
plugins/mocker/go.sum
is excluded by!**/*.sum
📒 Files selected for processing (8)
docs/mcp.md
(7 hunks)docs/plugins.md
(1 hunks)plugins/mocker/README.md
(1 hunks)plugins/mocker/benchmark_test.go
(1 hunks)plugins/mocker/go.mod
(1 hunks)plugins/mocker/main.go
(1 hunks)plugins/mocker/plugin_test.go
(1 hunks)tests/transports-integrations/README.md
(3 hunks)
🧰 Additional context used
🪛 LanguageTool
plugins/mocker/README.md
[uncategorized] ~214-~214: When ‘Match-specific’ is used as a modifier, it is usually spelled with a hyphen.
Context: ... | []string
| No | []
| Match specific providers: ["openai", "anthropic"]
| ...
(SPECIFIC_HYPHEN)
[uncategorized] ~215-~215: When ‘Match-specific’ is used as a modifier, it is usually spelled with a hyphen.
Context: ... | []string
| No | []
| Match specific models: ["gpt-4", "claude-3"]
| ...
(SPECIFIC_HYPHEN)
[uncategorized] ~833-~833: Do not mix variants of the same word (‘regexp’ and ‘regex’) within a single text.
Context: ...ing plugin initialization - Before: regexp.Compile()
on every request (~1000x slo...
(EN_WORD_COHERENCY)
[uncategorized] ~914-~914: You might be missing the article “the” here.
Context: ...lective mocking - Zero allocations when plugin is disabled #### **High-Speed Simple R...
(AI_EN_LECTOR_MISSING_DETERMINER_THE)
[uncategorized] ~1083-~1083: Possible missing preposition found.
Context: ...l rules should have higher priority - Group related rules: Keep similar functiona...
(AI_HYDRA_LEO_MISSING_TO)
🪛 markdownlint-cli2 (0.17.2)
plugins/mocker/README.md
391-391: Bare URL used
null
(MD034, no-bare-urls)
936-936: Trailing punctuation in heading
Punctuation: ':'
(MD026, no-trailing-punctuation)
968-968: Trailing punctuation in heading
Punctuation: ':'
(MD026, no-trailing-punctuation)
1299-1299: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
🪛 golangci-lint (1.64.8)
plugins/mocker/main.go
1008-1008: Error return value of fmt.Sscanf
is not checked
(errcheck)
1009-1009: Error return value of fmt.Sscanf
is not checked
(errcheck)
1018-1018: Error return value of fmt.Sscanf
is not checked
(errcheck)
🔇 Additional comments (16)
docs/plugins.md (1)
479-486
: Document Formatting Improvement: Specify code block language
Updated the plugin directory structure snippet to use atext
-fenced code block for consistent markdown rendering.tests/transports-integrations/README.md (3)
9-14
: Document Formatting Improvement: Specify ASCII diagram as text
Updated the architecture overview ASCII diagram to use atext
-fenced code block for improved consistency.
53-72
: Document Formatting Improvement: Specify directory listing as text
Updated the directory structure example to use atext
-fenced code block for consistent rendering.
440-452
: Document Formatting Improvement: Specify quick reference as text
Updated the test categories quick-reference list to use atext
-fenced code block for better readability.docs/mcp.md (6)
1344-1346
: Document Formatting Improvement: Specify error snippet as text
Converted the STDIO connection failure message to atext
-fenced code block for consistent formatting.
1357-1359
: Document Formatting Improvement: Specify error snippet as text
Converted the HTTP connection failure message to atext
-fenced code block for improved clarity.
1370-1372
: Document Formatting Improvement: Specify error snippet as text
Converted the SSE connection error message to atext
-fenced code block for consistent styling.
1386-1388
: Document Formatting Improvement: Specify error snippet as text
Converted the duplicate tool registration error message to atext
-fenced code block for uniform documentation.
1400-1402
: Document Formatting Improvement: Specify warning snippet as text
Converted the "No MCP tools found" warning to atext
-fenced code block for consistent documentation styling.
1413-1415
: Document Formatting Improvement: Specify warning snippet as text
Converted the "Restricted tool available" warning to atext
-fenced code block for clarity.plugins/mocker/go.mod (1)
1-6
: New module initialization: Mocker plugin
Declared theplugins/mocker
module with Go version1.24.1
and added a local replace for the core package.plugins/mocker/plugin_test.go (1)
1-539
: Well-structured and comprehensive test coverageThe test file provides excellent coverage of the plugin functionality including:
- Plugin initialization and configuration validation
- Disabled plugin behavior
- Default mock rules
- Custom success and error responses
- Template variable substitution
- Statistics tracking
- Various edge cases
The BaseAccount implementation is a good approach for testing without real API keys.
plugins/mocker/README.md (1)
1-1302
: Excellent and comprehensive documentationThe README provides:
- Clear quick start examples
- Detailed configuration reference with tables
- Advanced features like faker support and weighted responses
- Performance optimization guidelines
- Troubleshooting section with common issues
- Well-organized examples for various use cases
The documentation will greatly help users understand and effectively use the Mocker plugin.
plugins/mocker/main.go (3)
40-44
: Excellent performance optimizationsThe implementation includes several performance optimizations that make it suitable for high-throughput scenarios:
- Pre-compiled regex patterns (line 42) - Avoids expensive regex compilation on each request
- Pre-calculated normalized weights (lines 43, 230-269) - O(log n) binary search for response selection
- Atomic counters for statistics (lines 55-58) - Lock-free operations for minimal contention
- Efficient string operations with
strings.Builder
(lines 656-665)These optimizations align well with the benchmarking goals mentioned in the PR objectives.
Also applies to: 230-269, 823-850
15-15
: Comprehensive faker integrationThe faker integration using
jaswdr/faker
library is well-implemented with:
- Support for various data types (personal info, addresses, companies, etc.)
- Parameterized methods (e.g.,
{{faker.integer:10,50}}
)- Graceful fallback for unrecognized methods
- Clear documentation in the README
This feature significantly enhances the mocking capabilities for realistic test data generation.
Also applies to: 947-1043
271-473
: Thorough configuration validationThe validation logic is comprehensive and user-friendly:
- Clear error messages with context
- Reasonable bounds checking
- Validation of regex patterns at configuration time
- Proper validation of all nested structures
This prevents runtime errors and provides early feedback on configuration issues.
0ac12f0
to
947487a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
♻️ Duplicate comments (1)
plugins/mocker/main.go (1)
1003-1016
: Handle errors from fmt.Sscanf in faker value generationThe error return values from
fmt.Sscanf
are ignored, which could lead to unexpected behavior if parsing fails.case "integer": min, max := 1, 100 // defaults if len(parts) > 1 { params := strings.Split(parts[1], ",") if len(params) >= 2 { - fmt.Sscanf(params[0], "%d", &min) - fmt.Sscanf(params[1], "%d", &max) + if _, err := fmt.Sscanf(params[0], "%d", &min); err != nil { + min = 1 // fallback to default on parse error + } + if _, err := fmt.Sscanf(params[1], "%d", &max); err != nil { + max = 100 // fallback to default on parse error + } } } return fmt.Sprintf("%d", p.faker.IntBetween(min, max)) case "float": min, max := 0, 100 // defaults as integers if len(parts) > 1 { params := strings.Split(parts[1], ",") if len(params) >= 2 { - fmt.Sscanf(params[0], "%d", &min) - fmt.Sscanf(params[1], "%d", &max) + if _, err := fmt.Sscanf(params[0], "%d", &min); err != nil { + min = 0 // fallback to default on parse error + } + if _, err := fmt.Sscanf(params[1], "%d", &max); err != nil { + max = 100 // fallback to default on parse error + } } }Also applies to: 1017-1030
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
plugins/mocker/go.sum
is excluded by!**/*.sum
📒 Files selected for processing (8)
docs/mcp.md
(7 hunks)docs/plugins.md
(1 hunks)plugins/mocker/README.md
(1 hunks)plugins/mocker/benchmark_test.go
(1 hunks)plugins/mocker/go.mod
(1 hunks)plugins/mocker/main.go
(1 hunks)plugins/mocker/plugin_test.go
(1 hunks)tests/transports-integrations/README.md
(3 hunks)
🧰 Additional context used
🪛 LanguageTool
plugins/mocker/README.md
[uncategorized] ~214-~214: When ‘Match-specific’ is used as a modifier, it is usually spelled with a hyphen.
Context: ... | []string
| No | []
| Match specific providers: ["openai", "anthropic"]
| ...
(SPECIFIC_HYPHEN)
[uncategorized] ~215-~215: When ‘Match-specific’ is used as a modifier, it is usually spelled with a hyphen.
Context: ... | []string
| No | []
| Match specific models: ["gpt-4", "claude-3"]
| ...
(SPECIFIC_HYPHEN)
[uncategorized] ~833-~833: Do not mix variants of the same word (‘regexp’ and ‘regex’) within a single text.
Context: ...ing plugin initialization - Before: regexp.Compile()
on every request (~1000x slo...
(EN_WORD_COHERENCY)
[uncategorized] ~914-~914: You might be missing the article “the” here.
Context: ...lective mocking - Zero allocations when plugin is disabled #### **High-Speed Simple R...
(AI_EN_LECTOR_MISSING_DETERMINER_THE)
[uncategorized] ~1083-~1083: Possible missing preposition found.
Context: ...l rules should have higher priority - Group related rules: Keep similar functiona...
(AI_HYDRA_LEO_MISSING_TO)
🪛 markdownlint-cli2 (0.17.2)
plugins/mocker/README.md
391-391: Bare URL used
null
(MD034, no-bare-urls)
936-936: Trailing punctuation in heading
Punctuation: ':'
(MD026, no-trailing-punctuation)
968-968: Trailing punctuation in heading
Punctuation: ':'
(MD026, no-trailing-punctuation)
1299-1299: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
🔇 Additional comments (14)
docs/plugins.md (1)
479-486
: Consistent code block language annotation: Switching to ```text enhances readability and aligns with other documentation updates.tests/transports-integrations/README.md (3)
9-14
: Consistent code block language annotation: Updating the ASCII diagram to use ```text ensures proper rendering and consistency across docs.
53-60
: Consistent code block language annotation: Using ```text for the directory structure listing maintains uniform formatting with similar examples.
439-452
: Consistent code block language annotation: Annotating the Quick Reference section with ```text improves clarity and matches other docs formatting.docs/mcp.md (6)
1344-1346
: Consistent code block language annotation: Switching to ```text for this STDIO error example improves readability.
1357-1359
: Consistent code block language annotation: Annotating the HTTP error message with ```text ensures uniform formatting.
1370-1372
: Consistent code block language annotation: Using ```text for the SSE error example aligns with other troubleshooting code blocks.
1386-1388
: Consistent code block language annotation: Marking this tool registration error example as ```text enhances consistency.
1398-1402
: Consistent code block language annotation: The "No tools available" warning example benefits from ```text annotation for clarity.
1413-1415
: Consistent code block language annotation: Annotating the restricted tool warning with ```text maintains formatting uniformity.plugins/mocker/plugin_test.go (1)
1-538
: Comprehensive test coverage!The test file provides excellent coverage of the Mocker plugin functionality including disabled state, default behavior, custom rules, error responses, template substitution, statistics tracking, and configuration validation. The
BaseAccount
mock implementation is clean and the test structure follows best practices.plugins/mocker/benchmark_test.go (1)
1-296
: Well-designed performance benchmarks!The benchmark suite effectively measures performance across key scenarios including simple rules, regex matching, multiple rule evaluation, passthrough behavior, and template processing. Good use of
b.ResetTimer()
andb.ReportAllocs()
for accurate measurements. The consistent use ofbifrost.Ptr
is the correct approach.plugins/mocker/README.md (1)
1-1298
: Excellent comprehensive documentation!The README provides thorough coverage of all plugin features including quick start examples, detailed configuration reference, advanced features with faker support, performance optimization guidelines, and troubleshooting tips. The faker documentation is particularly well done with all available methods documented. Great work on creating user-friendly documentation!
plugins/mocker/main.go (1)
1-1083
: Excellent implementation with outstanding performance optimizations!The MockerPlugin implementation demonstrates exceptional attention to performance with pre-compiled regex patterns, pre-calculated normalized weights for O(log n) response selection, atomic counters, minimal locking, and efficient string operations. The comprehensive validation, clean architecture, and thorough inline documentation make this a high-quality plugin implementation.
Add Mocker Plugin for Bifrost
This PR introduces a new Mocker plugin for Bifrost that allows intercepting and mocking AI provider responses. The plugin provides flexible rule-based mocking capabilities for testing, development, and simulation purposes.
Features
Implementation Details
Documentation
The plugin is designed to be lightweight when disabled and highly performant for benchmarking scenarios, with minimal overhead in the no-match path.