eyeling 1.5.38 → 1.5.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,23 +1,48 @@
1
- # =====================================================================================
2
- # OSLO-STEPS workflow composition “Library / Scholarly access” (translation pipeline)
1
+ # =======================================================================================
2
+ # OSLO-STEPS minimal “Library / Scholarly access” workflow composition example
3
3
  #
4
- # Story (toy):
5
- # A scholar wants to obtain access to a scholarly article (PDF).
4
+ # Purpose
5
+ # A compact, representative test case for Eyeling/EYE workflow composition in the
6
+ # OSLO-STEPS style, without SHACL or shape machinery.
6
7
  #
7
- # Pipeline style (like OSLO-STEPS docs):
8
- # 1) Define o-steps:State + SHACL StateShapes (each state is a full signature)
9
- # 2) Define o-steps:Step with requiresState / producesState + costs
10
- # 3) Translate:
11
- # - StateShape -> State constraints (targetClass, path, value)
12
- # - Step + (required/produced) States -> gps:description transitions
13
- # 4) Compose transitions into a plan — terminates because the state graph is a DAG
8
+ # What it models
9
+ # A scholar (Alice) wants access to a scholarly item. The workflow progresses through
10
+ # five “state flags”:
11
+ # 1) identityVerified
12
+ # 2) affiliationVerified
13
+ # 3) requestSubmitted
14
+ # 4) itemLocated
15
+ # 5) accessGranted
14
16
  #
15
- # Run:
16
- # npx eyeling examples/oslo-steps-library-scholarly.n3
17
+ # OSLO-STEPS core used
18
+ # - Each step is an o-steps:Step with:
19
+ # o-steps:requiresState (precondition state)
20
+ # o-steps:producesState (postcondition state)
21
+ # plus simple costs:
22
+ # cost:duration, cost:monetaryCost, cost:success, cost:usersatifaction
17
23
  #
18
- # Output:
19
- # :alice gps:path ( (step:... step:... ...) duration cost success satisfaction ).
20
- # =====================================================================================
24
+ # State representation
25
+ # - Each “State” is stored as a quoted N3 formula term in state:si :formula { ... }.
26
+ # - We use var:x inside formulas as a stable placeholder to avoid variable-renaming
27
+ # explosions and to keep formula-term matching predictable.
28
+ #
29
+ # Compilation and planning
30
+ # - A small compiler turns each o-steps:Step into a gps:description transition:
31
+ # (FROM true TO STEP duration cost success satisfaction)
32
+ # - A minimal planner composes gps:description transitions into a gps:path by chaining
33
+ # them and aggregating metrics:
34
+ # duration + monetaryCost = sum
35
+ # success * satisfaction = product
36
+ # - No “fuel” bound is used here; termination is ensured because the workflow graph is
37
+ # acyclic (s0 -> s1 -> s2 -> s3 -> s4 -> s5) and has a finite number of alternatives.
38
+ #
39
+ # Output
40
+ # - Derives :alice gps:path ( ?Steps ?Duration ?Cost ?Success ?Satisfaction ).
41
+ #
42
+ # Run (examples)
43
+ # eye --quiet --nope --pass-only-new oslo-steps-library-scholarly-min.n3
44
+ # node eyeling.js oslo-steps-library-scholarly-min.n3
45
+ # =======================================================================================
21
46
 
22
47
  @prefix math: <http://www.w3.org/2000/10/swap/math#>.
23
48
  @prefix list: <http://www.w3.org/2000/10/swap/list#>.
@@ -25,7 +50,7 @@
25
50
  @prefix : <https://eyereasoner.github.io/eye/reasoning#>.
26
51
 
27
52
  @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
28
- @prefix sh: <http://www.w3.org/ns/shacl#>.
53
+ @prefix var: <http://www.w3.org/2000/10/swap/var#>.
29
54
  @prefix foaf: <http://xmlns.com/foaf/0.1/>.
30
55
 
31
56
  @prefix o-steps: <https://fast.ilabt.imec.be/ns/oslo-steps#>.
@@ -34,10 +59,9 @@
34
59
  @prefix cost: <https://example.org/cost#>.
35
60
  @prefix state: <https://example.org/states#>.
36
61
  @prefix step: <https://example.org/steps#>.
37
- @prefix shape: <https://example.org/shapes#>.
38
62
 
39
- # ---------------------------------------------------------------------
40
- # 1) OSLO-STEPS-like INPUT
63
+ # -----------------------------------------------------------------------------
64
+ # 1) States as formula terms (no SHACL)
41
65
  #
42
66
  # State signature booleans (5):
43
67
  # ex:identityVerified (can the scholar authenticate?)
@@ -45,79 +69,73 @@
45
69
  # ex:requestSubmitted (has the access request been submitted?)
46
70
  # ex:itemLocated (did we locate a route to the item?)
47
71
  # ex:accessGranted (final: scholar can access/download)
48
- # ---------------------------------------------------------------------
49
- # States (each has a StateShape with a full 5-boolean signature)
50
- state:s0 a o-steps:State; rdfs:label "Start"@en; o-steps:hasStateShape shape:s0Shape.
51
- state:s1 a o-steps:State; rdfs:label "Identity verified"@en; o-steps:hasStateShape shape:s1Shape.
52
- state:s2 a o-steps:State; rdfs:label "Affiliation verified"@en; o-steps:hasStateShape shape:s2Shape.
53
- state:s3 a o-steps:State; rdfs:label "Request submitted"@en; o-steps:hasStateShape shape:s3Shape.
54
- state:s4 a o-steps:State; rdfs:label "Item located"@en; o-steps:hasStateShape shape:s4Shape.
55
- state:s5 a o-steps:State; rdfs:label "Access granted"@en; o-steps:hasStateShape shape:s5Shape.
56
-
57
- # StateShapes
58
- shape:s0Shape a o-steps:StateShape; sh:targetClass foaf:Person;
59
- sh:property shape:s0ID, shape:s0AFF, shape:s0REQ, shape:s0LOC, shape:s0ACC.
60
- shape:s1Shape a o-steps:StateShape; sh:targetClass foaf:Person;
61
- sh:property shape:s1ID, shape:s1AFF, shape:s1REQ, shape:s1LOC, shape:s1ACC.
62
- shape:s2Shape a o-steps:StateShape; sh:targetClass foaf:Person;
63
- sh:property shape:s2ID, shape:s2AFF, shape:s2REQ, shape:s2LOC, shape:s2ACC.
64
- shape:s3Shape a o-steps:StateShape; sh:targetClass foaf:Person;
65
- sh:property shape:s3ID, shape:s3AFF, shape:s3REQ, shape:s3LOC, shape:s3ACC.
66
- shape:s4Shape a o-steps:StateShape; sh:targetClass foaf:Person;
67
- sh:property shape:s4ID, shape:s4AFF, shape:s4REQ, shape:s4LOC, shape:s4ACC.
68
- shape:s5Shape a o-steps:StateShape; sh:targetClass foaf:Person;
69
- sh:property shape:s5ID, shape:s5AFF, shape:s5REQ, shape:s5LOC, shape:s5ACC.
70
-
71
- # s0: all false
72
- shape:s0ID a sh:PropertyShape; sh:path ex:identityVerified; sh:hasValue false; sh:minCount 1.
73
- shape:s0AFF a sh:PropertyShape; sh:path ex:affiliationVerified; sh:hasValue false; sh:minCount 1.
74
- shape:s0REQ a sh:PropertyShape; sh:path ex:requestSubmitted; sh:hasValue false; sh:minCount 1.
75
- shape:s0LOC a sh:PropertyShape; sh:path ex:itemLocated; sh:hasValue false; sh:minCount 1.
76
- shape:s0ACC a sh:PropertyShape; sh:path ex:accessGranted; sh:hasValue false; sh:minCount 1.
77
-
78
- # s1: identity true
79
- shape:s1ID a sh:PropertyShape; sh:path ex:identityVerified; sh:hasValue true; sh:minCount 1.
80
- shape:s1AFF a sh:PropertyShape; sh:path ex:affiliationVerified; sh:hasValue false; sh:minCount 1.
81
- shape:s1REQ a sh:PropertyShape; sh:path ex:requestSubmitted; sh:hasValue false; sh:minCount 1.
82
- shape:s1LOC a sh:PropertyShape; sh:path ex:itemLocated; sh:hasValue false; sh:minCount 1.
83
- shape:s1ACC a sh:PropertyShape; sh:path ex:accessGranted; sh:hasValue false; sh:minCount 1.
84
-
85
- # s2: identity true, affiliation true
86
- shape:s2ID a sh:PropertyShape; sh:path ex:identityVerified; sh:hasValue true; sh:minCount 1.
87
- shape:s2AFF a sh:PropertyShape; sh:path ex:affiliationVerified; sh:hasValue true; sh:minCount 1.
88
- shape:s2REQ a sh:PropertyShape; sh:path ex:requestSubmitted; sh:hasValue false; sh:minCount 1.
89
- shape:s2LOC a sh:PropertyShape; sh:path ex:itemLocated; sh:hasValue false; sh:minCount 1.
90
- shape:s2ACC a sh:PropertyShape; sh:path ex:accessGranted; sh:hasValue false; sh:minCount 1.
91
-
92
- # s3: request submitted
93
- shape:s3ID a sh:PropertyShape; sh:path ex:identityVerified; sh:hasValue true; sh:minCount 1.
94
- shape:s3AFF a sh:PropertyShape; sh:path ex:affiliationVerified; sh:hasValue true; sh:minCount 1.
95
- shape:s3REQ a sh:PropertyShape; sh:path ex:requestSubmitted; sh:hasValue true; sh:minCount 1.
96
- shape:s3LOC a sh:PropertyShape; sh:path ex:itemLocated; sh:hasValue false; sh:minCount 1.
97
- shape:s3ACC a sh:PropertyShape; sh:path ex:accessGranted; sh:hasValue false; sh:minCount 1.
98
-
99
- # s4: item located
100
- shape:s4ID a sh:PropertyShape; sh:path ex:identityVerified; sh:hasValue true; sh:minCount 1.
101
- shape:s4AFF a sh:PropertyShape; sh:path ex:affiliationVerified; sh:hasValue true; sh:minCount 1.
102
- shape:s4REQ a sh:PropertyShape; sh:path ex:requestSubmitted; sh:hasValue true; sh:minCount 1.
103
- shape:s4LOC a sh:PropertyShape; sh:path ex:itemLocated; sh:hasValue true; sh:minCount 1.
104
- shape:s4ACC a sh:PropertyShape; sh:path ex:accessGranted; sh:hasValue false; sh:minCount 1.
105
-
106
- # s5: access granted
107
- shape:s5ID a sh:PropertyShape; sh:path ex:identityVerified; sh:hasValue true; sh:minCount 1.
108
- shape:s5AFF a sh:PropertyShape; sh:path ex:affiliationVerified; sh:hasValue true; sh:minCount 1.
109
- shape:s5REQ a sh:PropertyShape; sh:path ex:requestSubmitted; sh:hasValue true; sh:minCount 1.
110
- shape:s5LOC a sh:PropertyShape; sh:path ex:itemLocated; sh:hasValue true; sh:minCount 1.
111
- shape:s5ACC a sh:PropertyShape; sh:path ex:accessGranted; sh:hasValue true; sh:minCount 1.
112
-
113
- # Steps + costs (branching, but still a DAG)
72
+ # -----------------------------------------------------------------------------
73
+
74
+ state:s0 :formula {
75
+ var:x a foaf:Person.
76
+ var:x ex:identityVerified false.
77
+ var:x ex:affiliationVerified false.
78
+ var:x ex:requestSubmitted false.
79
+ var:x ex:itemLocated false.
80
+ var:x ex:accessGranted false.
81
+ }.
82
+
83
+ state:s1 :formula {
84
+ var:x a foaf:Person.
85
+ var:x ex:identityVerified true.
86
+ var:x ex:affiliationVerified false.
87
+ var:x ex:requestSubmitted false.
88
+ var:x ex:itemLocated false.
89
+ var:x ex:accessGranted false.
90
+ }.
91
+
92
+ state:s2 :formula {
93
+ var:x a foaf:Person.
94
+ var:x ex:identityVerified true.
95
+ var:x ex:affiliationVerified true.
96
+ var:x ex:requestSubmitted false.
97
+ var:x ex:itemLocated false.
98
+ var:x ex:accessGranted false.
99
+ }.
100
+
101
+ state:s3 :formula {
102
+ var:x a foaf:Person.
103
+ var:x ex:identityVerified true.
104
+ var:x ex:affiliationVerified true.
105
+ var:x ex:requestSubmitted true.
106
+ var:x ex:itemLocated false.
107
+ var:x ex:accessGranted false.
108
+ }.
109
+
110
+ state:s4 :formula {
111
+ var:x a foaf:Person.
112
+ var:x ex:identityVerified true.
113
+ var:x ex:affiliationVerified true.
114
+ var:x ex:requestSubmitted true.
115
+ var:x ex:itemLocated true.
116
+ var:x ex:accessGranted false.
117
+ }.
118
+
119
+ state:s5 :formula {
120
+ var:x a foaf:Person.
121
+ var:x ex:identityVerified true.
122
+ var:x ex:affiliationVerified true.
123
+ var:x ex:requestSubmitted true.
124
+ var:x ex:itemLocated true.
125
+ var:x ex:accessGranted true.
126
+ }.
127
+
128
+ # -----------------------------------------------------------------------------
129
+ # 2) Steps (OSLO-STEPS core) + costs
130
+ #
114
131
  # Costs:
115
132
  # cost:duration (minutes)
116
133
  # cost:monetaryCost (arbitrary units)
117
134
  # cost:success (0..1)
118
- # cost:usersatifaction (0..1) # keep the same spelling you used elsewhere
135
+ # cost:usersatifaction (0..1) (keep spelling consistent with earlier examples)
136
+ # -----------------------------------------------------------------------------
119
137
 
120
- # s0 -> s1 (identity verification)
138
+ # s0 -> s1 (identity)
121
139
  step:verifyIdentitySSO a o-steps:Step;
122
140
  rdfs:label "Verify identity (SSO)"@en;
123
141
  o-steps:requiresState state:s0; o-steps:producesState state:s1;
@@ -128,7 +146,7 @@ step:verifyIdentityDesk a o-steps:Step;
128
146
  o-steps:requiresState state:s0; o-steps:producesState state:s1;
129
147
  cost:duration 20.0; cost:monetaryCost 0.0; cost:success 0.995; cost:usersatifaction 0.85.
130
148
 
131
- # s1 -> s2 (affiliation / membership)
149
+ # s1 -> s2 (affiliation)
132
150
  step:verifyAffiliationAuto a o-steps:Step;
133
151
  rdfs:label "Verify affiliation (automatic)"@en;
134
152
  o-steps:requiresState state:s1; o-steps:producesState state:s2;
@@ -150,7 +168,7 @@ step:submitRequestLibrarian a o-steps:Step;
150
168
  o-steps:requiresState state:s2; o-steps:producesState state:s3;
151
169
  cost:duration 15.0; cost:monetaryCost 0.0; cost:success 0.99; cost:usersatifaction 0.90.
152
170
 
153
- # s3 -> s4 (locate item / route)
171
+ # s3 -> s4 (locate item)
154
172
  step:locateViaCatalogue a o-steps:Step;
155
173
  rdfs:label "Locate item (catalogue + resolver)"@en;
156
174
  o-steps:requiresState state:s3; o-steps:producesState state:s4;
@@ -165,71 +183,32 @@ step:locateViaDiscovery a o-steps:Step;
165
183
  step:grantAccessOpenAccess a o-steps:Step;
166
184
  rdfs:label "Grant access (open access)"@en;
167
185
  o-steps:requiresState state:s4; o-steps:producesState state:s5;
168
- cost:duration 1.0; cost:monetaryCost 0.0; cost:success 0.92; cost:usersatifaction 0.97.
186
+ cost:duration 1.0; cost:monetaryCost 0.0; cost:success 0.92; cost:usersatifaction 0.97.
169
187
 
170
188
  step:grantAccessSubscription a o-steps:Step;
171
189
  rdfs:label "Grant access (subscription)"@en;
172
190
  o-steps:requiresState state:s4; o-steps:producesState state:s5;
173
- cost:duration 2.0; cost:monetaryCost 0.5; cost:success 0.97; cost:usersatifaction 0.94.
191
+ cost:duration 2.0; cost:monetaryCost 0.5; cost:success 0.97; cost:usersatifaction 0.94.
174
192
 
175
193
  step:grantAccessInterlibraryLoan a o-steps:Step;
176
194
  rdfs:label "Grant access (interlibrary loan)"@en;
177
195
  o-steps:requiresState state:s4; o-steps:producesState state:s5;
178
196
  cost:duration 2880.0; cost:monetaryCost 5.0; cost:success 0.985; cost:usersatifaction 0.80.
179
197
 
180
- # -----------------------
181
- # 2) TRANSLATION PIPELINE
182
- # -----------------------
183
- # 2.1) StateShape -> State constraints (targetClass, path, value)
184
- { ?STATE :constraint (?TARGET ?PATH ?VALUE). } <=
185
- {
186
- ?STATE o-steps:hasStateShape ?SHAPE.
187
- ?SHAPE sh:targetClass ?TARGET.
188
- ?SHAPE sh:property ?PS.
189
- ?PS sh:path ?PATH.
190
- ?PS sh:hasValue ?VALUE.
191
- ?PS sh:minCount 1.
192
- }.
198
+ # -----------------------------------------------------------------------------
199
+ # 3) Compile OSLO-STEPS core -> internal gps:description transitions
200
+ # -----------------------------------------------------------------------------
193
201
 
194
- # 2.2) Step -> internal gps:description transition (compiled)
195
- # We compile FROM/TO formulas from required/produced state constraints.
196
202
  {
197
- ex:libmap gps:description
198
- (
199
- { ?x a ?T.
200
- ?x ex:identityVerified ?ID1.
201
- ?x ex:affiliationVerified ?AFF1.
202
- ?x ex:requestSubmitted ?REQ1.
203
- ?x ex:itemLocated ?LOC1.
204
- ?x ex:accessGranted ?ACC1.
205
- }
206
- true
207
- { ?x a ?T.
208
- ?x ex:identityVerified ?ID2.
209
- ?x ex:affiliationVerified ?AFF2.
210
- ?x ex:requestSubmitted ?REQ2.
211
- ?x ex:itemLocated ?LOC2.
212
- ?x ex:accessGranted ?ACC2.
213
- }
214
- ?STEP
215
- ?DUR ?MC ?SUC ?SAT
216
- ).
203
+ ex:libmap gps:description ( ?FROM true ?TO ?STEP ?DUR ?MC ?SUC ?SAT ).
217
204
  } <=
218
205
  {
219
- ?STEP o-steps:requiresState ?REQSTATE.
220
- ?STEP o-steps:producesState ?PRODSTATE.
206
+ ?STEP a o-steps:Step.
207
+ ?STEP o-steps:requiresState ?REQ.
208
+ ?STEP o-steps:producesState ?PROD.
221
209
 
222
- ?REQSTATE :constraint (?T ex:identityVerified ?ID1).
223
- ?REQSTATE :constraint (?T ex:affiliationVerified ?AFF1).
224
- ?REQSTATE :constraint (?T ex:requestSubmitted ?REQ1).
225
- ?REQSTATE :constraint (?T ex:itemLocated ?LOC1).
226
- ?REQSTATE :constraint (?T ex:accessGranted ?ACC1).
227
-
228
- ?PRODSTATE :constraint (?T ex:identityVerified ?ID2).
229
- ?PRODSTATE :constraint (?T ex:affiliationVerified ?AFF2).
230
- ?PRODSTATE :constraint (?T ex:requestSubmitted ?REQ2).
231
- ?PRODSTATE :constraint (?T ex:itemLocated ?LOC2).
232
- ?PRODSTATE :constraint (?T ex:accessGranted ?ACC2).
210
+ ?REQ :formula ?FROM.
211
+ ?PROD :formula ?TO.
233
212
 
234
213
  ?STEP cost:duration ?DUR.
235
214
  ?STEP cost:monetaryCost ?MC.
@@ -237,28 +216,23 @@ step:grantAccessInterlibraryLoan a o-steps:Step;
237
216
  ?STEP cost:usersatifaction ?SAT.
238
217
  }.
239
218
 
240
- # --------------
241
- # 3) START STATE
242
- # --------------
243
- :alice :start
244
- {
245
- ?x a foaf:Person.
246
- ?x ex:identityVerified false.
247
- ?x ex:affiliationVerified false.
248
- ?x ex:requestSubmitted false.
249
- ?x ex:itemLocated false.
250
- ?x ex:accessGranted false.
219
+ # -----------------------------------------------------------------------------
220
+ # 4) Start + planner (NO fuel; terminates because workflow is acyclic)
221
+ # -----------------------------------------------------------------------------
222
+
223
+ :alice :start {
224
+ var:x a foaf:Person.
225
+ var:x ex:identityVerified false.
226
+ var:x ex:affiliationVerified false.
227
+ var:x ex:requestSubmitted false.
228
+ var:x ex:itemLocated false.
229
+ var:x ex:accessGranted false.
251
230
  }.
252
231
 
253
- # ----------
254
- # 4) PLANNER
255
- # ----------
256
232
  # Base: one step is a path
257
233
  { (?From ?To (?Act) ?Dur ?Cost ?Suc ?Sat) :path true. }
258
234
  <=
259
- {
260
- ex:libmap gps:description (?From true ?To ?Act ?Dur ?Cost ?Suc ?Sat).
261
- }.
235
+ { ex:libmap gps:description (?From true ?To ?Act ?Dur ?Cost ?Suc ?Sat). }.
262
236
 
263
237
  # Recursive: step + rest, aggregate
264
238
  { (?From ?To ?Acts ?Dur ?Cost ?Suc ?Sat) :path true. }
@@ -276,41 +250,28 @@ step:grantAccessInterlibraryLoan a o-steps:Step;
276
250
 
277
251
  # Wrapper: OSLO-like findpath with bounds
278
252
  {
279
- :scope gps:findpath
280
- (
281
- ?GOAL
282
- ?PATH
283
- ?DURATION
284
- ?MONETARYCOST
285
- ?SUCCESS
286
- ?SATISFACTION
287
- (?DL ?CL ?SL ?AL)
288
- ).
253
+ :scope gps:findpath ( ?GOAL ?PATH ?DUR ?COST ?SUC ?SAT (?DL ?CL ?SL ?AL) ).
289
254
  } <=
290
255
  {
291
256
  :alice :start ?START.
292
- (?START ?GOAL ?PATH ?DURATION ?MONETARYCOST ?SUCCESS ?SATISFACTION) :path true.
257
+ (?START ?GOAL ?PATH ?DUR ?COST ?SUC ?SAT) :path true.
293
258
 
294
- ?DURATION math:lessThan ?DL.
295
- ?MONETARYCOST math:lessThan ?CL.
296
- ?SUCCESS math:greaterThan ?SL.
297
- ?SATISFACTION math:greaterThan ?AL.
259
+ ?DUR math:lessThan ?DL.
260
+ ?COST math:lessThan ?CL.
261
+ ?SUC math:greaterThan ?SL.
262
+ ?SAT math:greaterThan ?AL.
298
263
  }.
299
264
 
300
- # -----------------------
301
- # 5) GOAL QUERY -> OUTPUT
302
- # -----------------------
265
+ # -----------------------------------------------------------------------------
266
+ # 5) Goal query -> output
267
+ # -----------------------------------------------------------------------------
268
+
303
269
  {
270
+ state:s5 :formula ?GOAL.
271
+
304
272
  :scope gps:findpath
305
273
  (
306
- {
307
- ?x a foaf:Person.
308
- ?x ex:identityVerified true.
309
- ?x ex:affiliationVerified true.
310
- ?x ex:requestSubmitted true.
311
- ?x ex:itemLocated true.
312
- ?x ex:accessGranted true.
313
- }
274
+ ?GOAL
314
275
  ?PATH ?DUR ?COST ?SUC ?SAT
315
276
  (
316
277
  5000.0 # duration limit (minutes)