fix: Make Wazero the lens runtime for C bindings#4524
fix: Make Wazero the lens runtime for C bindings#4524ChrisBQu merged 2 commits intosourcenetwork:developfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #4524 +/- ##
===========================================
+ Coverage 76.11% 76.15% +0.04%
===========================================
Files 521 521
Lines 41892 41892
===========================================
+ Hits 31883 31900 +17
+ Misses 7529 7517 -12
+ Partials 2480 2475 -5
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 11 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
📝 WalkthroughWalkthroughThe C bindings node configuration is updated to hardcode the lens runtime to "wazero" instead of using the previous lens runtime value. A comment documents that wazero is the only supported runtime for C bindings. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Assessment against linked issues
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@cbindings/node.go`:
- Around line 42-43: Replace the hardcoded "wazero" string used in
opts.DB().SetLensRuntime("wazero") with a named constant to document the
dependency and avoid magic strings; either add a public constant
NodeWazeroLensRuntime in client/options/node.go (type
options.NodeLensRuntimeType) and use that, or add a local const wazeroRuntime =
"wazero" in cbindings/node.go and call opts.DB().SetLensRuntime(wazeroRuntime);
include a brief comment explaining why the wazero runtime is chosen if you keep
it local.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
cbindings/node.go
🧰 Additional context used
🪛 GitHub Check: codecov/patch
cbindings/node.go
[warning] 43-43: cbindings/node.go#L43
Added line #L43 was not covered by tests
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
| // Currently the only supported lens runtime is wazero, so use it explicitly | ||
| opts.DB().SetLensRuntime("wazero") |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Search for "wazero" references to find any constants or defined values
rg -n -C3 'wazero' --type=go -g '!vendor/**' -g '!cbindings/**'Repository: sourcenetwork/defradb
Length of output: 1453
🏁 Script executed:
#!/bin/bash
# Check cbindings/node.go imports and context
head -60 cbindings/node.go | cat -nRepository: sourcenetwork/defradb
Length of output: 2065
🏁 Script executed:
#!/bin/bash
# Search for LensRuntimeType definition and check if there's a public constant
rg -n 'type LensRuntimeType' --type=go
rg -n 'const.*LensRuntime' --type=go -g '!vendor/**'Repository: sourcenetwork/defradb
Length of output: 422
🏁 Script executed:
#!/bin/bash
# Check if options package exposes any lens runtime constants
rg -n 'LensRuntime\|Wazero' --type=go internal/client/options/ 2>/dev/null | head -20
# Also check if there's any public constant in options
rg -n 'const' internal/client/options/ --type=go | grep -i lensRepository: sourcenetwork/defradb
Length of output: 129
🏁 Script executed:
#!/bin/bash
# Find the options package location
find . -name "options" -type d | grep -v vendor | grep -v node_modulesRepository: sourcenetwork/defradb
Length of output: 100
🏁 Script executed:
#!/bin/bash
# Check the client/options package for any lens runtime related constants
rg -n 'LensRuntime\|lens' client/options/ --type=go -iRepository: sourcenetwork/defradb
Length of output: 47
🏁 Script executed:
#!/bin/bash
# Check how SetLensRuntime is defined in the options package
rg -n 'SetLensRuntime' --type=goRepository: sourcenetwork/defradb
Length of output: 552
🏁 Script executed:
#!/bin/bash
# Check client/options/node.go for NodeLensRuntimeType constants
rg -n 'const.*LensRuntime\|type NodeLensRuntimeType' client/options/node.go -A2 -B2Repository: sourcenetwork/defradb
Length of output: 47
🏁 Script executed:
#!/bin/bash
# Search for NodeLensRuntimeType definition and related constants
rg -n 'NodeLensRuntimeType\|NodeJSLensRuntime\|NodeWASMLensRuntime' --type=goRepository: sourcenetwork/defradb
Length of output: 47
🏁 Script executed:
#!/bin/bash
# Read the SetLensRuntime method and surrounding code
sed -n '435,450p' client/options/node.goRepository: sourcenetwork/defradb
Length of output: 708
🏁 Script executed:
#!/bin/bash
# Find NodeLensRuntimeType type definition
rg -n 'type NodeLensRuntimeType' client/options/ --type=go -A3
# Also search for any constants in the file
rg -n 'const.*=' client/options/node.go | head -30Repository: sourcenetwork/defradb
Length of output: 270
🏁 Script executed:
#!/bin/bash
# Get the full const block for lens runtime types
sed -n '60,70p' client/options/node.goRepository: sourcenetwork/defradb
Length of output: 560
🏁 Script executed:
#!/bin/bash
# Check if "wasm" and "wazero" are related or if there's documentation
rg -n 'wasm.*wazero\|wazero.*wasm' --type=go -B2 -A2
# Also check the internal/db config to understand the lens runtime types
sed -n '45,100p' internal/db/config.goRepository: sourcenetwork/defradb
Length of output: 798
🏁 Script executed:
#!/bin/bash
# Check if "wasm" maps to wazero or if they're different
rg -n '"wasm"' internal/db/ --type=go -B2 -A2Repository: sourcenetwork/defradb
Length of output: 47
🏁 Script executed:
#!/bin/bash
# Check if "wazero" is a valid/recognized lens runtime type
rg -n 'runtimeConstructors\[' internal/db/ --type=go -B1 -A1
# Check how the lens runtime is used in tests
rg -n '"wazero"' --type=go -B2 -A2Repository: sourcenetwork/defradb
Length of output: 2207
🏁 Script executed:
#!/bin/bash
# Check what the public API offers for lens runtime types and verify if "wazero" is valid
cat client/options/node.go | sed -n '58,70p'
# Also verify - is "wazero" actually a valid value or should it be "wasm"?
# Let's check the PR context by looking at git log
git log --oneline --all -20 | grep -i wazeroRepository: sourcenetwork/defradb
Length of output: 593
Hardcoding "wazero" creates unnecessary coupling to an implementation detail.
While a Wazero constant exists in the internal db package, it's not accessible from cbindings (internal packages cannot be imported). The public options.NodeLensRuntimeType API only exports constants for "wasm", "js", and "" — not "wazero".
Consider either:
- Adding a
NodeWazeroLensRuntimeconstant toclient/options/node.goto formalize this as a supported public runtime type, or - Adding a local constant in
cbindings/node.go(e.g.,const wazeroRuntime = "wazero") to document the dependency.
Alternatively, if "wazero" is an internal-only detail, document why the magic string is necessary here.
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 43-43: cbindings/node.go#L43
Added line #L43 was not covered by tests
🤖 Prompt for AI Agents
In `@cbindings/node.go` around lines 42 - 43, Replace the hardcoded "wazero"
string used in opts.DB().SetLensRuntime("wazero") with a named constant to
document the dependency and avoid magic strings; either add a public constant
NodeWazeroLensRuntime in client/options/node.go (type
options.NodeLensRuntimeType) and use that, or add a local const wazeroRuntime =
"wazero" in cbindings/node.go and call opts.DB().SetLensRuntime(wazeroRuntime);
include a brief comment explaining why the wazero runtime is chosen if you keep
it local.
Relevant issue(s)
Resolves #4523
Description
A recent change removed a line of code that made the C Bindings'
NewNodefunction explicitly use Wazero as its lens runtime. This broke the C bindings, because that is currently the only runtime that is supported. This reverts that change.Tasks
How has this been tested?
Specify the platform(s) on which this was tested: