Skip to content

feat(compat): version compatibility profiles for the Lua sandbox#25

Merged
fatal10110 merged 2 commits into
mainfrom
feat/compat-profiles
Jun 30, 2026
Merged

feat(compat): version compatibility profiles for the Lua sandbox#25
fatal10110 merged 2 commits into
mainfrom
feat/compat-profiles

Conversation

@fatal10110

Copy link
Copy Markdown
Owner

What

Make the engine emulate the Lua sandbox behavior of a chosen Redis/Valkey version via a profile option.

Researched the sandbox setup (script_lua.c; 6.2 = scripting.c) across redis 6.2/7.0/7.2/7.4/8.0 and valkey 7.2/8.0/8.1. Only three behaviors actually differ — everything else (cjson/cmsgpack/struct/bit/math/table/string, deny of dofile/loadfile, globals protection, setresp/RESP3) is constant since 6.2:

behavior available in
print global redis 6.2 only (enters deny_list at 7.0)
os library redis 7.4+, valkey 8.0+
server.* alias valkey 8.0+ only — redis 8.0 has no server alias

How

Three orthogonal flags (COMPAT_PRINT/OS/SERVER_ALIAS) as a u8 bitmask, passed via a new set_compat() WASM export and consumed by a shared setup_state() (dedupes the near-identical init/reset). No per-version build fork — one binary, per-engine choice.

await load({ profile: "redis6.2" });                  // print kept, no os/server
await load({ profile: "redis7.2", compat: { os: true } }); // override one flag
await load();                                          // default ≈ valkey8.0 (unchanged)

profile is a named preset over the version matrix; compat overrides individual flags. Default (no profile) preserves prior behavior, so this is non-breaking.

Test

  • 6 new compat ... tests in test/engine.test.ts covering each profile + override + default.
  • WASM rebuilt (Docker); full suite 187 pass / 0 fail.

🤖 Generated with Claude Code

fatal10110 and others added 2 commits June 30, 2026 20:12
Emulate the Lua sandbox behavior of a chosen Redis/Valkey version. Only
three behaviors actually differ across Redis 6.2-8.x and Valkey:

  - `print` global     -> present only in Redis 6.2
  - `os` library       -> Redis 7.4+ / Valkey 8.0+
  - `server` alias     -> Valkey 8.0+ only (Redis keeps `redis`)

Modeled as three orthogonal flags (COMPAT_PRINT/OS/SERVER_ALIAS) passed as
a u8 bitmask via a new `set_compat()` WASM export, consumed by a shared
`setup_state()` (init/reset deduped). TS exposes `load({ profile, compat })`
where `profile` is a named preset over the version matrix and `compat`
overrides individual flags. Default (no profile) preserves prior behavior
(os + server alias, no print; ~ valkey 8.0).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Drop valkey-7.2 and valkey-8.1; add valkey-9.0. Profile set is now
redis-6.2, redis-7.0, redis-7.2, redis-7.4, redis-8.0, valkey-8.0,
valkey-9.0. valkey-9.0 mirrors valkey-8.0 (no known Lua sandbox delta).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@fatal10110 fatal10110 merged commit 7bf3e86 into main Jun 30, 2026
5 checks passed
@fatal10110 fatal10110 deleted the feat/compat-profiles branch June 30, 2026 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant