Demonstrator - Reasoning WebAPI issueshttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues2020-11-07T14:54:30Zhttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/8Test common theory predicates2020-11-07T14:54:30ZSiebers, MichaelTest common theory predicatesTest whether the common theory predicates
- work,
- conform to type expectations, and
- are semi-deterministic, deterministic or non-deterministic as expected.Test whether the common theory predicates
- work,
- conform to type expectations, and
- are semi-deterministic, deterministic or non-deterministic as expected.Siebers, MichaelSiebers, Michaelhttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/7Change endpoints as in readme defined2020-11-07T16:45:25ZSebastian SeufertChange endpoints as in readme defined*"§=A!!! SWI-Documentation is wrong/old (GET/DELETE not working with a body),
hence all endpoints handling data parameters need to be changed to POST.
readme is the 'file of truth'*"§=A!!! SWI-Documentation is wrong/old (GET/DELETE not working with a body),
hence all endpoints handling data parameters need to be changed to POST.
readme is the 'file of truth'Sebastian SeufertSebastian Seuferthttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/3Hand-over Brose-Version2020-11-07T22:11:02ZSiebers, MichaelHand-over Brose-VersionUte (and the student first using this version) should know where to find the code and how to use the software.Ute (and the student first using this version) should know where to find the code and how to use the software.Version 1.0https://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/13Bug in same_directory/22020-11-09T12:49:10ZSiebers, MichaelBug in same_directory/2The predicate same_directory/2 relies on in_directory/2. This produces a trailing slash on path names, which hinders matching of the absolute path name of the parent directory.
Why do unit tests for in_directory/1 and same_directory/2 p...The predicate same_directory/2 relies on in_directory/2. This produces a trailing slash on path names, which hinders matching of the absolute path name of the parent directory.
Why do unit tests for in_directory/1 and same_directory/2 pass?Siebers, MichaelSiebers, Michaelhttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/10Incorrect transmission of response content type2020-11-16T10:59:54ZSiebers, MichaelIncorrect transmission of response content type*Steps to reproduce*
- start the server
- place a POST request at /bg (or /clear) with arbitrary valid payload, e.g. `[{"type" : "directory","abs_path": "/A/B/","creation_time": 1604235509}]`
*Expected behavior*
Response with `Content...*Steps to reproduce*
- start the server
- place a POST request at /bg (or /clear) with arbitrary valid payload, e.g. `[{"type" : "directory","abs_path": "/A/B/","creation_time": 1604235509}]`
*Expected behavior*
Response with `Content-Type: application/json; charset=UTF-8` in headers and `"Action: add, Details: 2"` as payload.
*Observed behavior*
Response with `Content-Type: text/plain; charset=UTF-8` in headers and
```
Content-type: application/json; charset=UTF-8 [sic!]
"Action: add, Details: 2"
```
as payload.Sebastian SeufertSebastian Seuferthttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/9/clear fails with status code 500 when clearing an empty bg2020-11-16T13:09:34ZSiebers, Michael/clear fails with status code 500 when clearing an empty bg**Steps to reproduce**
- start the server
- place a POST request without payload at /clear
Can also be reproduced by first adding something to the bg and then clearing that twice.
**Expected behavior**
Fail gracefully, that is return...**Steps to reproduce**
- start the server
- place a POST request without payload at /clear
Can also be reproduced by first adding something to the bg and then clearing that twice.
**Expected behavior**
Fail gracefully, that is return 2xx status code.
**Observed behavior**
Server returns 500 Internal Server Error
*Error trace in PROLOG*
```
% [Thread httpd@4444_2] POST /clear: [500] goal unexpectedly failed: web_api:clear_bg([protocol(http),peer(ip(127,0,0,1)),pool(client('httpd@4444',web_api:http_dispatch,<stream>(0x7ff06c01a8e0),<stream>(0x7ff06c01aa70))),input(<stream>(0x7ff06c01a8e0)),method(post),request_uri('/clear'),path('/clear'),http_version(1-1),content_type('application/json'),user_agent('PostmanRuntime/7.26.5'),accept([media(_752/_754,[],1.0,[])]),postman_token('5eb7687c-b1e3-40d9-aa30-7b29f18623c3'),host(localhost),port(4444),accept_encoding('gzip, deflate, br'),connection('keep-alive'),content_length(434)])
In:
[19] throw(error(goal_failed(...),_864))
[18] http_dispatch:call_action(web_api:clear_bg,[protocol(http),...|...]) at /usr/lib/swi-prolog/library/http/http_dispatch.pl:772
[16] time:run_alarm_goal('<garbage_collected>','<garbage_collected>') at /usr/lib/swi-prolog/library/time.pl:145
[15] setup_call_catcher_cleanup(time:alarm(300,...,...,...),time:run_alarm_goal(...,...),_982,time:remove_alarm_notrace(...)) at /usr/lib/swi-prolog/boot/init.pl:443
[13] time:call_with_time_limit(300,'<garbage_collected>') at /usr/lib/swi-prolog/library/time.pl:136
[8] httpd_wrapper:call_handler('<garbage_collected>',1,'<garbage_collected>') at /usr/lib/swi-prolog/library/http/http_wrapper.pl:320
[7] catch(httpd_wrapper:call_handler(...,1,...),error(goal_failed(...),context(_1144,_1146)),httpd_wrapper:true) at /usr/lib/swi-prolog/boot/init.pl:371
[6] httpd_wrapper:handler_with_output_to(web_api:http_dispatch,1,'<garbage_collected>',current_output,error(goal_failed(...),context(_1210,_1212))) at /usr/lib/swi-prolog/library/http/http_wrapper.pl:297
[5] httpd_wrapper:handler_with_output_to('<garbage_collected>',1,'<garbage_collected>',<stream>(0x7ff06c01fd10),error(goal_failed(...),context(_1264,_1266))) at /usr/lib/swi-prolog/library/http/http_wrapper.pl:309
[4] httpd_wrapper:http_wrapper('<garbage_collected>',<stream>(0x7ff06c01a8e0),<stream>(0x7ff06c01aa70),_1302,'<garbage_collected>') at /usr/lib/swi-prolog/library/http/http_wrapper.pl:98
[3] thread_httpd:http_process('<garbage_collected>',<stream>(0x7ff06c01a8e0),<stream>(0x7ff06c01aa70),'<garbage_collected>') at /usr/lib/swi-prolog/library/http/thread_httpd.pl:778
[2] catch(thread_httpd:http_process(...,<stream>(0x7ff06c01a8e0),<stream>(0x7ff06c01aa70),...),_1366,thread_httpd:true) at /usr/lib/swi-prolog/boot/init.pl:371
[1] thread_httpd:http_worker([queue('httpd@4444'),...|...]) at /usr/lib/swi-prolog/library/http/thread_httpd.pl:554
[0] <meta call>
Note: some frames are missing due to last-call optimization.
Re-run your program in debug mode (:- debug.) to get more detail.
```Sebastian SeufertSebastian Seuferthttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/11Handle /irrelevant/file2020-11-16T17:03:20ZSiebers, MichaelHandle /irrelevant/file- [x] define helper for irrelevant file detection
- [x] document expected input and output (for helper)
- [x] write unit tests (for helper)
- [x] implement functionality (in helper)
- [x] transform output to response- [x] define helper for irrelevant file detection
- [x] document expected input and output (for helper)
- [x] write unit tests (for helper)
- [x] implement functionality (in helper)
- [x] transform output to responseSiebers, MichaelSiebers, Michaelhttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/12Handle /explain2020-11-16T17:03:21ZSiebers, MichaelHandle /explain- [x] define helper for explanation generation
- [x] document expected input and output (for helper)
- [x] write unit tests (for helper)
- [x] implement functionality (in helper)
- [x] transform output to response- [x] define helper for explanation generation
- [x] document expected input and output (for helper)
- [x] write unit tests (for helper)
- [x] implement functionality (in helper)
- [x] transform output to responseSiebers, MichaelSiebers, Michaelhttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/1Harmonize predicate-naming into a template definition for multifile use2020-11-16T17:33:29ZSebastian SeufertHarmonize predicate-naming into a template definition for multifile useSebastian SeufertSebastian Seuferthttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/5Handle missing explanation template.2020-11-21T16:30:20ZSiebers, MichaelHandle missing explanation template.## Original description
explain/4 should succeed even if an required explanation template is missing.
## Discussion
This is hard, if not impossible to realize. Let's suppose there are two possible traces for `irrelevant(F)`: `a(F)` and ...## Original description
explain/4 should succeed even if an required explanation template is missing.
## Discussion
This is hard, if not impossible to realize. Let's suppose there are two possible traces for `irrelevant(F)`: `a(F)` and `b(F)`. But there is only an explanation template for `b`. Then the result would be:
1. an explanation using `a` and
1. an empty explanation.
Or, if _only_ for `a` an explanation template is known, we have an empty explanation followed by an explanation using `b`. Either way, we have two explanations, one of which is empty. This is no sensible behavior.
## Desired behavior
Have a graceful API reply if a requested item is irrelevant but explain/4 cannot produce an explanation. The reply should be (following the current naming convention):
```json
{
"explanations": [],
"further_explanations": false
}
```Siebers, MichaelSiebers, Michaelhttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/6Complete explanation templates2020-11-21T17:18:11ZSiebers, MichaelComplete explanation templatesThere should be explanation templates for all predicates which might be used in the irrelevance theory.There should be explanation templates for all predicates which might be used in the irrelevance theory.Version 1.0Siebers, MichaelSiebers, Michaelhttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/15No count in /bg response2020-11-23T15:26:03ZSyed Mamoon AhmedNo count in /bg responseFollowing is the response from /bg endpoint:
> HTTP/1.1 201 Created
> Date: Mon, 16 Nov 2020 19:26:06 GMT
> Content-Type: text/plain; charset=UTF-8
> Connection: Keep-Alive
> Content-Length: 72
>
> Content-type: application/json; chars...Following is the response from /bg endpoint:
> HTTP/1.1 201 Created
> Date: Mon, 16 Nov 2020 19:26:06 GMT
> Content-Type: text/plain; charset=UTF-8
> Connection: Keep-Alive
> Content-Length: 72
>
> Content-type: application/json; charset=UTF-8
>
> "Action: add, Details: 1"
As you can see, there is no count there. (Also, what is count anyway?)Sebastian SeufertSebastian Seuferthttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/16No content in 204 response in /bg endpoint2020-11-23T15:33:10ZSyed Mamoon AhmedNo content in 204 response in /bg endpointAfter a file is registered to the background knowledge, I can receive the 204 response on the next request, but there is no conetent as described in the README:
> HTTP/1.1 204 No Content
> Date: Mon, 16 Nov 2020 19:31:39 GMT
> Content...After a file is registered to the background knowledge, I can receive the 204 response on the next request, but there is no conetent as described in the README:
> HTTP/1.1 204 No Content
> Date: Mon, 16 Nov 2020 19:31:39 GMT
> Content-Type: text/plain; charset=UTF-8
> Connection: Keep-Alive
> Content-Length: 107Sebastian SeufertSebastian Seuferthttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/20/explain: Is it supposed to be like this?2020-11-23T15:35:40ZSyed Mamoon Ahmed/explain: Is it supposed to be like this?Please tell me what am I doing wrong?
Here is my request:
> {
> "abs_path": "/A/B/Filename-2.exe"
> }
Here is the response:
> HTTP/1.1 400 Bad Request
> Date: Mon, 16 Nov 2020 21:43:23 GMT
> Connection: close
> Content-Le...Please tell me what am I doing wrong?
Here is my request:
> {
> "abs_path": "/A/B/Filename-2.exe"
> }
Here is the response:
> HTTP/1.1 400 Bad Request
> Date: Mon, 16 Nov 2020 21:43:23 GMT
> Connection: close
> Content-Length: 350
> Content-Type: text/html; charset=UTF-8
>
> <!DOCTYPE html>
> <html>
> <head>
> <title>400 Bad Request</title>
>
> <meta http-equiv="content-type" content="text/html; charset=UTF-8">
>
> </head>
> <body>
>
> <h1>Bad Request</h1>
>
> <p>
> Unknown message: not_irrelevant('/A/B/Filename-2.exe')</p>
>
> <address>
> <a href="http://www.swi-prolog.org">SWI-Prolog</a> httpd at transmatter-laptop
> </address>
>
> </body>
> </html>Sebastian SeufertSebastian Seuferthttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/26Startup parameters2020-11-26T13:39:06ZSiebers, MichaelStartup parametersStartup options for the server (like port to run on) seem to be managed in the predicate server_opts/1. However, I do not use how to use them. Regarding the port option, for instance, neither of the following works:
```
swipl -s run.pl ...Startup options for the server (like port to run on) seem to be managed in the predicate server_opts/1. However, I do not use how to use them. Regarding the port option, for instance, neither of the following works:
```
swipl -s run.pl --port 8976
```
```
swipl -s run.pl --port=8976
```
```
swipl -s run.pl port=8976
```
According to the swipl usage message, swi-options and programm arguments should (can?) be separated by `--`. This seems to kinda work. However, then our code complains that `--` is no valid argument.
Basically, I have the following questions:
1. How is it possible to start the server with arguments?
1. Which arguments are defined? Or rather, what do they do?
1. Can we print some usage message ourselves? For example with `-h` but without interfering with swipl's `-h` argument?Version 1.0Sebastian SeufertSebastian Seuferthttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/17Alternate misfiring in /bg endpoint2020-11-28T11:27:25ZSyed Mamoon AhmedAlternate misfiring in /bg endpointAfter a file is registered into the background knowledge, the first consecutive request yields 204 response. But after that the server starts misfiring on alternate requests:
> error getting response: org.apache.http.client.ClientProtoc...After a file is registered into the background knowledge, the first consecutive request yields 204 response. But after that the server starts misfiring on alternate requests:
> error getting response: org.apache.http.client.ClientProtocolExceptionSebastian SeufertSebastian Seuferthttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/18204 response not working in /clear endpoint2020-11-28T11:27:48ZSyed Mamoon Ahmed204 response not working in /clear endpointAfter a file is unregistered from the background knowledge, any repitition of same request yields the following result:
> (500 internal server error) goal unexpectedly failed: web_api:clear_bg([protocol(http),peer(ip(127,0,0,1)),pool(c...After a file is unregistered from the background knowledge, any repitition of same request yields the following result:
> (500 internal server error) goal unexpectedly failed: web_api:clear_bg([protocol(http),peer(ip(127,0,0,1)),pool(client('httpd@4444',web_api:http_dispatch,<stream>(0x7fe91c0310c0),<stream>(0x7fe91c0117b0))),input(<stream>(0x7fe91c0310c0)),method(post),request_uri('/clear'),path('/clear'),http_version(1-1),accept_encoding('gzip,deflate'),content_type('application/json'),content_length(274),host(localhost),port(4444),connection('Keep-Alive'),user_agent('Apache-HttpClient/4.1.1 (java 1.5)')])https://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/30'Request zero' at GET2020-11-30T16:09:54ZSebastian Seufert'Request zero' at GETAPI reacts with completed request 0.
```server(started, 1606395900).
/*Thu Nov 26 14:04:59 2020*/
request(1, 1606395899.985, [peer(ip(127,0,0,1)),method(get),request_uri('/bg'),path('/bg'),http_version(1-1),content_type('application/js...API reacts with completed request 0.
```server(started, 1606395900).
/*Thu Nov 26 14:04:59 2020*/
request(1, 1606395899.985, [peer(ip(127,0,0,1)),method(get),request_uri('/bg'),path('/bg'),http_version(1-1),content_type('application/json'),user_agent('PostmanRuntime/7.26.8'),postman_token('fc04c4f5-3f71-40a2-b3fe-66fc358a9f10'),host(localhost),port(5000),content_length(735)]).
completed(1, 0.029408105, 630, 200, ok).
completed(0, 0.047579236, 328, 400, error("Illegal HTTP parameter: { (in_http_request)")).
server(stopped, 1606395987).
```
----
I have no idea at the moment what causes this / where this comes from, but since it does not crop up in Postman or curl, I assume this _should_ not interfere with API functionality from the clients perspective.
Investigating.Sebastian SeufertSebastian Seuferthttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/27Add regex types to types module2020-12-01T01:41:16ZSiebers, MichaelAdd regex types to types module# Current state
In the types module the type of objects can be checked. This is not restricted to Prolog's definition of types: at least for dicts required and optional keys (with type restrictions) may be defined.
# Suggestion
The rege...# Current state
In the types module the type of objects can be checked. This is not restricted to Prolog's definition of types: at least for dicts required and optional keys (with type restrictions) may be defined.
# Suggestion
The regex type would extend this idea to strings: the value must not only be of type string but its content must satisfy additional requirements. Additionally, a regex type for `atom`s or general `text` is desired.
## Rationale
We have decided, that absolute paths of files and directories may not end in a slash unless it is the root directory '/'. Without the regex type, this restriction must be enforced after type checking. However for this, a mechanisms very similar to type checking are required. For example in `set_bg`:
- if we have a single dict:
- noting which values are concerned (probably only `abs_path`),
- extracting the value
- *checking the regex*
- if the check fails: throw exception
- if we have a list of dicts:
- iterate over all elements
- if we then have a dict, apply the steps from above
It is easier, less error prone, and more encapsulated to include this facility into types.
## Technical realisation
The actual checking of the type might be simple as there is a regex library in Prolog. Taking strings as example, the type definition could look like
- `regex(string, RegEx)` where `RegEx` must be a valid regular expression from Prolog's regex library or
- `string(RegEx)` where `RegEx`is defined as above.
The second option would convey the notion that this is a refinement of the string type more strongly. This is analogous to `dict` vs. `dict/1` and `dict/2` and `list` vs `list/1` already realized in `types`.https://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/22Map http_reply exceptions to JSON reply2020-12-01T12:37:34ZSiebers, MichaelMap http_reply exceptions to JSON replyVersion 1.0Siebers, MichaelSiebers, Michael