Repository navigation
wasm: enable Fluent Typed Scripting in browser artifacts - #12645
Conversation
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Enable FTS in the browser profile cmake/wasm-browser.cmake, plugins/CMakeLists.txt, tests/wasm/check_profile.cmake, tests/wasm/profile/CMakeLists.txt, plugins/processor_fts/README.md, sdk/browser/README.md |
The browser plugin list and registration condition include FTS when WASM Lua is enabled. Profile checks and documentation cover the enabled, disabled, and minimal configurations. |
Support portable Lua in FTS plugins/processor_fts/fts.h, plugins/processor_fts/fts_runtime.c, plugins/processor_fts/fts_values.c, tests/internal/fts.c |
FTS uses Lua-version compatibility macros for raw length, userdata values, and method registration. LuaJIT-specific runtime code and tests are conditional, and tests cover JIT rejection without LuaJIT. |
Build and test FTS in the browser tests/wasm/CMakeLists.txt, tests/wasm/browser_smoke.py, tests/wasm/sdk_test.js, tests/wasm/sdk_test.py |
The WASM test target and smoke harness include FTS. SDK tests cover policy processing, record dropping, nested and typed value updates, and rejection of JIT configuration. |
Priority:
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Feature
Sequence Diagram(s)
sequenceDiagram
participant BrowserSDK
participant FTSProcessor
participant LuaPolicy
BrowserSDK->>FTSProcessor: Configure input processor with policy
FTSProcessor->>LuaPolicy: Evaluate input records
LuaPolicy-->>FTSProcessor: Drop or update records
FTSProcessor-->>BrowserSDK: Return processed records
Possibly related PRs
- fluent/fluent-bit#12429: Establishes the browser WASM profile and SDK test framework that this change extends.
- fluent/fluent-bit#12589: Introduces the FTS processor that this change adapts for portable Lua and browser builds.
- fluent/fluent-bit#12641: Changes cmetrics OTLP metadata APIs used by FTS metrics code.
Merge Risk: 
Minimal · up to d63b9
-
No actionable issue is established; the change is mergeable after normal checks.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passedFull details: Docstring Coverage
-
Explanation
Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 7 files. (7 skipped: 7 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 1
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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 @coderabbitai help to get the list of available commands.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d63b94c728
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const char *blocked[] = {"io", "os", "debug", "jit", "ffi", "package", "coroutine", | ||
| "module", "load", "loadfile", "loadstring", "dofile", | ||
| "newproxy", "xpcall", "getfenv", "setfenv", "print", NULL}; | ||
| "newproxy", "xpcall", "getfenv", "setfenv", "print", "warn", NULL}; |
There was a problem hiding this comment.
Prevent policy finalizers from bypassing the instruction budget
With the newly enabled Lua 5.4 backend, policies can create table finalizers through the still-exposed setmetatable. For example, setmetatable({}, {__gc = function() while true do end end}); collectgarbage('collect') hangs the runtime despite a finite instruction_limit: Lua 5.4's collector explicitly disables debug hooks while invoking finalizers, so budget_hook never interrupts this loop. This path was unavailable with LuaJIT's userdata-only finalizers and the existing newproxy restriction. Restrict policy-defined finalizers in the portable backend so they cannot bypass the advertised execution limit.
Useful? React with 👍 / 👎.
Browser WASM artifacts cannot configure
name: fts: the browser profile excludesFTS, and plugin registration requires LuaJIT even though the browser uses Lua 5.4.
This enables the processor in the default browser artifact and supplies the Lua
API compatibility needed to run its existing typed-policy implementation.
FLB_WASM_LUA; retain explicit disable/minimal overrides andreject FTS when its Lua backend is disabled.
the portable API, and install the private helper environment through
_ENV.jit: true, retaininstruction/memory limits, and cannot recover the Lua 5.4
warnhost-I/O function.Add SDK coverage for policy assets, typed integers, nested views across GC,
dropping records, and explicit JIT rejection. Add a focused
--fts-onlymode.The existing Browser WebAssembly CI workflow builds this profile and publishes
experimental artifacts for the PR. Once merged, master artifacts include FTS.
No bundled library sources or toolchain pins are changed.
Validation on Linux, Emscripten 6.0.9, Chromium 151:
full PR commit-range prefix lint pass.
The new FTS test has a 180-second process deadline because its 60,000-key JSON
regression takes about a minute with WASM ASan. Policy instruction budgets, memory
limits and sanitizer settings are unchanged; no FTS regression cases are skipped.
The LuaJIT-only unit case remains on native builds and is replaced by explicit
JIT-rejection coverage for portable Lua.
Example configuration used by the SDK test (the policy asset is installed with
writeFile('/config/typed.lua', source)):Observed output after the policy edits a nested view and preserves an exact
unsigned value as text:
{"message":"fts browser","nested":{"value":42},"exact":"18446744073709551615","fts":true}All 29 strict-Valgrind runs report zero errors and zero bytes remaining at exit.
Representative footer:
The in-tree processor and browser SDK guides are updated. Native/container
packaging and stable-series backports are outside this change.
Exact focused integration and memory-check commands, from the worktree:
Summary by CodeRabbit