Repository navigation
docs(r11): embedded Lua policy engine — example 42 + chapter 42 (Deep Dives) - #11
Merged
Merged
Conversation
… Dives) Part 12 opens: pmon lifts its restart/backoff decision out of the compiled host and into a single shared policy.lua, embedded three structurally different ways — C++23 via sol2 (Lua 5.4), Go via gopher-lua (Lua 5.1), Rust via mlua (Lua 5.4) — and hot-reloaded live on a real SIGHUP with no process restart. Example 42-embedded-lua-scripting (mode: local): - one Lua-5.1-safe policy.lua drives all three hosts to byte-identical decisions (diff-confirmed); policy-v2 is the SIGHUP edit (500ms→100ms backoff, max_restarts 8→2 flipping a restart into an escalate). - sandbox opens only base/string/table/math, nils the loader globals, and never loads os/io/package/debug; policy-evil.lua (os.execute) and policy-broken.lua (missing end) prove runtime + load-time rejection, with genuinely different diagnostics per binding. - verify.lua asserts behaviour (PASS 19/FAIL 0 per language), not exit codes. Chapter 42 to the spine: Tools-used box, 3 verbatim tri-language codetab sets, Figures 42.1 (host↔script boundary) + 42.2 (SIGHUP reload lifecycle), verified footer. validate.py: teach check_lua to skip fixtures declaring "validate: expect-syntax-error" (policy-broken.lua is invalid by design). Gate: test-all-examples.py --only 42 → 3 passed/0 failed; full --mode local → 96 passed/0 failed/3 skipped (skips are 38-otel, lgtm down). validate: OK.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 12 (Deep Dives) opens.
pmonlifts its restart/backoff decision out of the compiled host and into a single sharedpolicy.lua, embedded three structurally different ways — C++23 via sol2 (Lua 5.4), Go via gopher-lua (Lua 5.1), Rust via mlua (Lua 5.4) — and hot-reloaded live on a real SIGHUP with no process restart.Example
42-embedded-lua-scripting(mode: local)policy.luadrives all three hosts to byte-identical decisions (diff-confirmed).policy-v2.luais the SIGHUP edit: 500ms→100ms base backoff,max_restarts8→2, flipping a would-be restart into an escalate.base/string/table/math, nils the loader globals, never loadsos/io/package/debug.policy-evil.lua(os.execute) andpolicy-broken.lua(missingend) prove runtime + load-time rejection — with genuinely different diagnostics per binding (sol2/mlua name the nil global via PUC-Lua; gopher-lua's guard table names the blocked field).verify.luaasserts behaviour (PASS 19 / FAIL 0 per language), not exit codes.Chapter 42
To the spine (Part "Deep Dives"): Tools-used box, 3 verbatim tri-language codetab sets, Figures 42.1 (host↔script boundary) + 42.2 (SIGHUP reload lifecycle), verified footer.
Tooling
validate.pynow skips.luafixtures declaringvalidate: expect-syntax-error(policy-broken.luais invalid by design).Gate
test-all-examples.py --only 42-embedded-lua-scripting→ 3 passed / 0 failed--mode local→ 96 passed / 0 failed / 3 skipped (skips are38-otel, lgtm down)validate.py: OKLibraries:
sol2/3.5.0+lua/5.4.6(Conan),gopher-lua v1.1.2,mlua 0.12(lua54+vendored).