Currently, Scribunto Lua modules receive their wiki text input as a string which has been partially pre processed in the old-school MediaWiki parser; for instance it may include strip markers (T133477).
Eventually it would be nice for the classic parser to be removed entirely or retooled to produce an intermediate DOM based on parsoid's model, but if Lua scripts are tied to the old model, we'll need a compat layer that reflattens them and emulates the strip marker behavior.
At that point we could perhaps let new modules opt in to receiving their input, and producing their output, through the DOM model.
This will allow for a cleaner interface that's not as fragile with respect to extension strip markers -- they'll be relatively sanely marked DOM nodes instead of weird looking substrings -- and should be more flexible in terms of allowing scripts to be used on wikis that aren't as tied to the wiki text editing model.
Most likely this would extend or supplement the frame object that provides the current wiki text-centric parser API: https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Frame_object
There are probably many difficulties to think about, so this is a long-term epic task.