Pass exec/2 commands to the javascript host in the wasm version#177
Open
jeswr wants to merge 1 commit into
Open
Pass exec/2 commands to the javascript host in the wasm version#177jeswr wants to merge 1 commit into
jeswr wants to merge 1 commit into
Conversation
In the wasm version there is no shell/2, so the graph scoped builtins (log:collectAllIn, log:forAllIn, log:ifThenElseIn, log:conclusion, log:satisfiable, e:call, e:fail and e:findall) could not spawn their eye sub-reasoner. Following the userInput/2 precedent, exec/2 now yields exec(Args, File) to the javascript host via await/2 under the emscripten condition, where Args is the argv of the command and File is the target of its stdout redirection. See eyereasoner/eye-js#873 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
What
Wraps
exec/2in the same:- if(current_prolog_flag(emscripten, true))conditional already used foruserInput/2, so that in wasm builds the sub-reasoner invocations of the graph scoped builtins are passed to the JavaScript host viaawait/2instead of callingshell/2(which does not exist under Emscripten). Native builds keep the existingshell/2definition verbatim.This is the small patch proposed in eyereasoner/eye-js#873 ("Left for @josd" / upstream ask): all eight graph-literal-scoped builtins —
log:collectAllIn,log:forAllIn,log:ifThenElseIn,log:conclusion,log:satisfiable,e:call,e:fail,e:findall— funnel throughexec/2, so this one conditional makes them all bridgeable for any wasm embedder, and makes the sub-reasoner-spawn contract explicit rather than something each embedder has to shim in at image-build time.Host protocol
Per your preference for a structured term over a raw shell string, the emscripten branch splits the command line and yields
where
Argsis the argv of the command as a list of atoms (e.g.[eye, '--nope', '--quiet', Tmp1, '--query', Tmp2]) andFileis the target of its stdout redirection. The host is expected to run the command — for the graph scoped builtins, the eye sub-reasoner on a fresh wasm instance, which is the isolation analogue of the process spawn — write its standard output toFilein the requesting instance's filesystem, and answer"ok". Any other response, and any command without a stdout redirection (e.g. arbitrarye:execshell commands, which a wasm host cannot honour), raisesexec_error(A)just like a non-zero exit does natively; the scoped builtins already wrapexec/2incatch/3and treat that as failure.Validation
No native swipl was available here, so validation ran under swipl-wasm (where the emscripten branch is live and both conditional branches must parse):
eye.plin swipl-wasm produces no errors or warnings;log:collectAllIn), run throughqsave_programd images of this patched source with a JS host answering theexec(Args, File)yields by booting fresh sub-instances, returns(:x) a :Result.— identical to native EYE, with the expected two sub-reasoner invocations per scope evaluation.The native branch is byte-identical to the current definition, so non-wasm behaviour is unchanged; a native CI run is still the authoritative check there.
Reference host
eye-js is the reference consumer: eyereasoner/eye-js#1956 currently injects an equivalent (string-based) redefinition of
exec/2at pvm-generation time; once a release contains this patch, eye-js can drop that build-time shim and consume the structured yield directly (a small follow-up on their side).VERSION/RELEASE/eye.zipare deliberately untouched — left to your release flow.Prepared agent-assisted for @jeswr.