SWISH: no permission to call sandboxed assert

i have a problem with the following code:

q(_) :-
   assert( (newp(F,A) :- p(F,A))).

The neck :- into the assert gives the note: neck outofsync,
moreover the assert doesn’t work and gives the error : no permission to call sandboxed assert.

How can i do?


The out-of-sync is a bug, but rather innocent. The reason it doesn’t work is this snipped from the sandboxing code:

%!  safe_assert(+Term) is semidet.
%   True if assert(Term) is safe,  which   means  it  asserts in the
%   current module. Cross-module asserts are   considered unsafe. We
%   only allow for adding facts. In theory,  we could also allow for
%   rules if we prove the safety of the body.

safe_assert(C) :- cyclic_term(C), !, fail.
safe_assert(X) :- var(X), !, fail.
safe_assert(_Head:-_Body) :- !, fail.
safe_assert(_:_) :- !, fail.

So can i assert a rule or i have just to change the code?

safe_assert/1 on a rule fails. So no, you cannot assert rules in the anonymous web version. You can do so if you run SWI-Prolog locally or in a local SWISH instance after tweaking the configuration to disable the sandbox. Sorry …

1 Like

Thank you anyway

How can i make a local SWISH version to assert a fact?

Either run it as IDE on top of Prolog using the supplied ide.pl from the SWISH distro. Alternatively, set it up with the config file auth_http_always.pl which demands login and disables the sandbox. See README for SWISH.

1 Like