| 1 |
# ===================================================================== |
| 2 |
# Delfour — PHONE side |
| 3 |
# Inputs: |
| 4 |
# - profile graph (may contain sensitive facts) |
| 5 |
# - session context (retailer/device/event + created/expiry timestamps) |
| 6 |
# Outputs (pass-only-new): |
| 7 |
# - a neutral ins:Insight (no sensitive terms) |
| 8 |
# - an ODRL policy envelope derived from the insight |
| 9 |
# ===================================================================== |
| 10 |
|
| 11 |
@prefix health: <https://example.org/health#> . |
| 12 |
@prefix need: <https://example.org/need#> . |
| 13 |
@prefix ctx: <https://example.org/context#> . |
| 14 |
@prefix ins: <https://example.org/insight#> . |
| 15 |
@prefix odrl: <http://www.w3.org/ns/odrl/2/> . |
| 16 |
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . |
| 17 |
@prefix vocab: <https://example.org/vocab/> . |
| 18 |
@prefix profile: <https://example.org/profile/> . |
| 19 |
|
| 20 |
# --------------------------------------------------------------------- |
| 21 |
# 1) Desensitization: private health -> neutral need |
| 22 |
# (kept on device; only the neutral need leaves the POD) |
| 23 |
# --------------------------------------------------------------------- |
| 24 |
{ ?p health:householdCondition health:Diabetes. } |
| 25 |
=> |
| 26 |
{ ?p need:needsLowSugar true. } . |
| 27 |
|
| 28 |
# --------------------------------------------------------------------- |
| 29 |
# 2) Derive a neutral Insight "envelope" for this concrete session |
| 30 |
# The envelope is scoped by device/event/retailer and limited in time. |
| 31 |
# Note: here we mint a blank insight _:ins; in practice you may prefer a stable IRI. |
| 32 |
# --------------------------------------------------------------------- |
| 33 |
{ |
| 34 |
?p need:needsLowSugar true. |
| 35 |
|
| 36 |
# concrete session context is provided as data (see sample below) |
| 37 |
?c ctx:retailer ?ret ; |
| 38 |
ctx:device ?dev ; |
| 39 |
ctx:event ?ev ; |
| 40 |
ctx:createdAt ?ts ; |
| 41 |
ctx:expiresAt ?exp . |
| 42 |
} |
| 43 |
=> |
| 44 |
{ |
| 45 |
_:ins a ins:Insight ; |
| 46 |
ins:metric "sugar_g_per_serving" ; |
| 47 |
ins:threshold "10.0"^^xsd:decimal ; |
| 48 |
ins:suggestionPolicy "lower_metric_first_higher_price_ok" ; |
| 49 |
ins:scopeDevice ?dev ; |
| 50 |
ins:scopeEvent ?ev ; |
| 51 |
ins:retailer ?ret ; |
| 52 |
ins:createdAt ?ts ; |
| 53 |
ins:expiresAt ?exp . |
| 54 |
} . |
| 55 |
|
| 56 |
# --------------------------------------------------------------------- |
| 57 |
# 3) From the Insight, emit an ODRL policy with: |
| 58 |
# - permission: use@shopping_assist (targeting the insight) |
| 59 |
# - prohibition: share@marketing |
| 60 |
# - duty: delete at expiresAt |
| 61 |
# --------------------------------------------------------------------- |
| 62 |
{ |
| 63 |
?ins a ins:Insight ; |
| 64 |
ins:retailer ?ret ; |
| 65 |
ins:scopeDevice ?dev ; |
| 66 |
ins:scopeEvent ?ev ; |
| 67 |
ins:expiresAt ?exp . |
| 68 |
} |
| 69 |
=> |
| 70 |
{ |
| 71 |
_:pol a odrl:Policy ; |
| 72 |
odrl:profile profile:Delfour-Insight-Policy ; |
| 73 |
|
| 74 |
odrl:permission [ |
| 75 |
a odrl:Permission ; |
| 76 |
odrl:action odrl:use ; |
| 77 |
odrl:target ?ins ; |
| 78 |
odrl:constraint [ |
| 79 |
a odrl:Constraint ; |
| 80 |
odrl:leftOperand odrl:purpose ; |
| 81 |
odrl:operator odrl:eq ; |
| 82 |
odrl:rightOperand vocab:shopping_assist |
| 83 |
] |
| 84 |
] ; |
| 85 |
|
| 86 |
odrl:prohibition [ |
| 87 |
a odrl:Prohibition ; |
| 88 |
odrl:action odrl:distribute ; |
| 89 |
odrl:target ?ins ; |
| 90 |
odrl:constraint [ |
| 91 |
a odrl:Constraint ; |
| 92 |
odrl:leftOperand odrl:purpose ; |
| 93 |
odrl:operator odrl:eq ; |
| 94 |
odrl:rightOperand vocab:marketing |
| 95 |
] |
| 96 |
] ; |
| 97 |
|
| 98 |
odrl:duty [ |
| 99 |
a odrl:Duty ; |
| 100 |
odrl:action odrl:delete ; |
| 101 |
odrl:constraint [ |
| 102 |
a odrl:Constraint ; |
| 103 |
odrl:leftOperand odrl:dateTime ; |
| 104 |
odrl:operator odrl:eq ; |
| 105 |
odrl:rightOperand ?exp |
| 106 |
] |
| 107 |
] . |
| 108 |
} . |
| 109 |
|