Skip to content

Eye suddenly stops executing rules #143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
tpluscode opened this issue Mar 10, 2025 · 6 comments
Open

Eye suddenly stops executing rules #143

tpluscode opened this issue Mar 10, 2025 · 6 comments

Comments

@tpluscode
Copy link

I the API testing project, I found that when I run multiple test cases (and thus requests), there is a certain threshold which, when reached, suddenly stops

I thought it was related to simply running many processes with e:exec but a synthetic case did not work and I easily called curl 1000 times.

@josd
Copy link
Collaborator

josd commented Mar 10, 2025

I'm calling curl 10000 times (10 times more than you mentioned) in https://github.com/eyereasoner/eye/blob/master/reasoning/shell-command/query-10000.n3 and it nicely gives https://github.com/eyereasoner/eye/blob/master/reasoning/shell-command/query-10000-answer.n3

Could you give a concrete example showing that things are broken?

@tpluscode
Copy link
Author

I need to investigate. I assumed that it was something related to child processes but I must have been wrong. So far I only have example too complex to be useful

@tpluscode
Copy link
Author

Upon further investigation, maybe it is related to this trick you shared which prevents a rule from executing multiple times (to avoid side effects)

   # ... match ?req ...
 
  ({ ?req tuner:done true } false true) log:ifThenElseIn ?SCOPE .
  true log:becomes { ?req tuner:done true } .

I added a trace in the positive condition of this if statement and I found that with each matched instance of ?req, all those previously executed are evaluated over and over. At some point it looks like eye does not find an more rules to execute, prematurely...

@tpluscode tpluscode changed the title Eye suddenly stops executing rules (caused by e:exec, possibly) Eye suddenly stops executing rules Mar 12, 2025
@tpluscode
Copy link
Author

I also find something else. In my specific example, I iterate over a paged hydra collection (a HTTP API). Each response includes a hydra:next link. Until the last page, that is. I match that link and dereference when it exists.

Here's the relevant code:

  ?req tuner:response ?res ; tuner:url ?page .

  (
    {
      ?body log:includes {
        <countries>!hydra:view hydra:next ?nextPage .
      } .
    }
    {
      ?body log:includes {
        <countries> hydra:view ?view .
        ?view hydra:next ?nextPage .
      } .
   
     (?view!log:localName ": " ?page!log:localName " => " ?nextPage!log:localName)!string:concatenation^log:trace .

      true log:becomes {
        <#fetchEntireCollection> <#fetch> ?nextPage
      }
    }
    {
      true log:becomes { <#fetchEntireCollection> earl:outcome earl:passed }
    }
  )!log:ifThenElseIn .

See I added that log:trace to see how the links are followed. Depending on page size it works or works until a certain point. If I set limit=50, it goes through the entire collection. But for example if I set it to limit=10 it breaks after this being logged

?_90858 TRACE "countries?limit=10&offset=40: countries?limit=10&offset=260 => countries?limit=10&offset=50"

So it looks like a wrong value for ?view is bound. As if the body from a previous request /countries?limit=10&offset=40 is taken instead of the expected countries?limit=10&offset=260. Could it be that blank nodes or variable identifiers are incorrectly reused at some point and stuff gets mixed up?

tl;dr; ?req tuner:response ?res is a backward rule which does

( "curl -s -X " ?method " '" ?endpoint "' -o " ?responseBodyFile )!string:concatenation!e:exec .

?responseBodyFile log:semantics ?res .

@josd
Copy link
Collaborator

josd commented Mar 12, 2025

Can you give the simplest possible concrete case that I can run and that shows that things are broken?

@tpluscode
Copy link
Author

Yea, that's the hard part.

For now I could share the failing example if you are willing to run JS :)

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

No branches or pull requests

2 participants