Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cbindings/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
ctx := context.Background()

opts := options.Node()
opts.DB().SetLensRuntime(options.NodeWASMLensRuntime)
// Currently the only supported lens runtime is wazero, so use it explicitly
opts.DB().SetLensRuntime("wazero")

Check warning on line 43 in cbindings/node.go

View check run for this annotation

Codecov / codecov/patch

cbindings/node.go#L43

Added line #L43 was not covered by tests
Comment on lines +42 to +43
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 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 -n

Repository: 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 lens

Repository: 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_modules

Repository: 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 -i

Repository: sourcenetwork/defradb

Length of output: 47


🏁 Script executed:

#!/bin/bash
# Check how SetLensRuntime is defined in the options package
rg -n 'SetLensRuntime' --type=go

Repository: 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 -B2

Repository: sourcenetwork/defradb

Length of output: 47


🏁 Script executed:

#!/bin/bash
# Search for NodeLensRuntimeType definition and related constants
rg -n 'NodeLensRuntimeType\|NodeJSLensRuntime\|NodeWASMLensRuntime' --type=go

Repository: sourcenetwork/defradb

Length of output: 47


🏁 Script executed:

#!/bin/bash
# Read the SetLensRuntime method and surrounding code
sed -n '435,450p' client/options/node.go

Repository: 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 -30

Repository: 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.go

Repository: 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.go

Repository: 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 -A2

Repository: 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 -A2

Repository: 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 wazero

Repository: 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:

  1. Adding a NodeWazeroLensRuntime constant to client/options/node.go to formalize this as a supported public runtime type, or
  2. 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.


if gocOptions.DbPath != "" {
opts.Store().SetPath(gocOptions.DbPath)
Expand Down
Loading