Skip to content

wasm: enable Fluent Typed Scripting in browser artifacts - #12645

Merged
edsiper merged 5 commits into
masterfrom
wasm-enable-processor-fts
Oct 24, 2026
Merged

edsiper merged 5 commits into
masterfrom
wasm-enable-processor-fts

Conversation

@edsiper

@edsiper edsiper commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Browser WASM artifacts cannot configure name: fts: the browser profile excludes
FTS, 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.

  • Enable FTS with FLB_WASM_LUA; retain explicit disable/minimal overrides and
    reject FTS when its Lua backend is disabled.
  • Map typed-view ownership to Lua 5.4 userdata uservalues, register methods through
    the portable API, and install the private helper environment through _ENV.
  • Preserve native LuaJIT behavior. Browser policies reject jit: true, retain
    instruction/memory limits, and cannot recover the Lua 5.4 warn host-I/O function.
  • Run the existing 59 FTS regression cases against portable Lua in Node/Chromium.
    Add SDK coverage for policy assets, typed integers, nested views across GC,
    dropping records, and explicit JIT rejection. Add a focused --fts-only mode.

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:

  • Optimized WASM: 18/18 CTests passed. ASan WASM: 20/20 passed.
  • All 59 FTS regression cases pass in Chromium, optimized and ASan.
  • Focused FTS SDK and the full browser SDK suite pass in both configurations.
  • Native FTS unit suite: 59 tests passed.
  • Native FTS integration: 29 passed normally and 29 under strict Valgrind.
  • SDK contract tests: 23 passed. Profile option checks, whitespace checks and
    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)):

pipeline:
  inputs:
    - name: lib
      alias: app
      tag: app
      processors:
        logs:
          - name: fts
            script: /config/typed.lua
  outputs:
    - name: stdout
      match: '*'
      format: json_lines

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:

HEAP SUMMARY:
    in use at exit: 0 bytes in 0 blocks
All heap blocks were freed -- no leaks are possible
ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

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:

FLUENT_BIT_BINARY=/tmp/flb-wasm-fts-native/bin/fluent-bit /home/edsiper/c/fluent-bit/tests/integration/.venv/bin/python -m pytest tests/integration/scenarios/processor_fts/tests/test_fts.py -q
FLUENT_BIT_BINARY=/tmp/flb-wasm-fts-native/bin/fluent-bit VALGRIND=1 VALGRIND_STRICT=1 /home/edsiper/c/fluent-bit/tests/integration/.venv/bin/python -m pytest tests/integration/scenarios/processor_fts/tests/test_fts.py -q
for variant in release asan; do
  ctest --test-dir "/tmp/flb-wasm-fts-$variant" --output-on-failure
  /home/edsiper/c/fluent-bit-worktree-wasm/browser-venv/bin/python tests/wasm/browser_smoke.py --build-dir "/tmp/flb-wasm-fts-$variant" --target flb-wasm-fts --browser /home/edsiper/.cache/ms-playwright/chromium-1234/chrome-linux64/chrome
  /home/edsiper/c/fluent-bit-worktree-wasm/browser-venv/bin/python tests/wasm/sdk_test.py --build-dir "/tmp/flb-wasm-fts-$variant" --browser /home/edsiper/.cache/ms-playwright/chromium-1234/chrome-linux64/chrome --fts-only
done

Summary by CodeRabbit

  • New Features
    • The browser build now includes the FTS scripting processor by default, enabling log-policy processing with portable Lua 5.4. Policies can work with typed values and nested views while remaining subject to sandbox and resource limits.
    • Browser builds do not support enabling JIT; requesting it is rejected.
  • Documentation
    • Added browser setup guidance for writing policy files and configuring the processor, with links to details on policies, typed values, and resource limits.

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>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T02:30:44.256221Z d63b94c PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d65375bc-1ca2-46c9-b04e-46bd0f6f92ec
Commits

Reviewing files that changed from the base of the PR and between 2e0aaee and d63b94c.

Files selected for processing: 14
  • cmake/wasm-browser.cmake
  • plugins/CMakeLists.txt
  • plugins/processor_fts/README.md
  • plugins/processor_fts/fts.h
  • plugins/processor_fts/fts_runtime.c
  • plugins/processor_fts/fts_values.c
  • sdk/browser/README.md
  • tests/internal/fts.c
  • tests/wasm/CMakeLists.txt
  • tests/wasm/browser_smoke.py
  • tests/wasm/check_profile.cmake
  • tests/wasm/profile/CMakeLists.txt
  • tests/wasm/sdk_test.js
  • tests/wasm/sdk_test.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Walkthrough

The browser WASM profile now enables the FTS processor when WASM Lua is enabled. FTS supports portable Lua APIs, and the browser test suite checks processor behavior, profile configuration, and JIT rejection.

Changes: Browser FTS support

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

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
Loading

Possibly related PRs

Merge Risk: Minimal · up to d63b9

No actionable issue is established; the change is mergeable after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning 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: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the primary change: enabling Fluent Typed Scripting in browser WebAssembly artifacts.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@edsiper edsiper added this to the Fluent Bit v5.2.0 milestone Oct 24, 2026
@edsiper
edsiper merged commit 05048e3 into master Oct 24, 2026
64 of 68 checks passed
@edsiper
edsiper deleted the wasm-enable-processor-fts branch October 24, 2026 03:36

This branch had an error being deployed

1 failed deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant