Skip to content

Feat/normalisation - #12

Open
woutslabbinck wants to merge 16 commits into
mainfrom
feat/normalisation
Open

woutslabbinck wants to merge 16 commits into
mainfrom
feat/normalisation

Conversation

@woutslabbinck

Copy link
Copy Markdown
Collaborator

Normalisation steps and closed shapes

Changes

Normalisation (src/Normalisation.ts)

  • N2: infer the types of policies, rules (odrl:Permission/Prohibition/Duty), constraints and logical constraints.
  • N3: apply odrl:inheritFrom (cycles are rejected).
  • N10: apply policy replacement (dct:isReplacedBy), including chains (cycles and external policies are rejected).

Closed shapes (src/shapes/modules/)

  • :PolicyShape, :RuleShape, :ConstraintShape and :LogicalConstraintShape are sh:closed.
  • dcterms metadata is ignored (a-01-dcterms-closed-list.ttl).
  • Removed R35 (odrl:includedIn) and R113 (odrl:implies): they describe the ODRL vocabulary, not policies.

Profiles (src/profiles/Profile.ts), so profile terms pass the closed shapes

  • Profile party functions and asset relations are allowed on policies and rules.
  • Profile logical-constraint operands are allowed.
  • Profile rule subclasses are disjoint with the other rule classes (R108–R110).

Tests

  • Updated to the normalised and closed shapes; party and asset tests check that the expected message is contained.
  • Removed tests for R35, R113 and two multiple-profile tests on policy classes of undeclared or unknown profiles.

Known failures (13 of 510)

  • R107 (2 tests): unknown policy types pass because N2 adds odrl:Policy. A direct sh:in would fix this, but it rejects policies also typed odrl:Asset (49 TOSL examples). Whether a policy may be an asset is still open.
  • Profile rule subclass linked with the wrong relation (2 tests): N2 adds odrl:Permission, so the profile type is not checked.
  • TOSL examples (9 tests): they use properties (tosl:onDispute, tosl:liability, tosl:limitationOfLiability, tosl:trigger) that are not part of the ODRL Profile mechanism, so the closed shapes reject them.

Summary

# Test file Test Cause Fix
1 test/unit/PolicyShapes.test.ts R107: :policy1 a :MyPolicy is reported N2 adds odrl:Policy; R107 only requires one policy type Potential (R107), blocked by open issue on odrl:Asset
2 test/unit/Validator.test.ts fails when a profile policy subclass is used without a profile Same as 1 Potential (R107), blocked by open issue on odrl:Asset
3 test/unit/Validator.test.ts fails policies that use a profile rule subclass and where the wrong relation is used N2 adds odrl:Permission; the extra rule type is not checked No
4 test/unit/Validator.test.ts fails when a profile rule subclass is used without a profile and a wrong relation is used Same as 3 No
5–13 test/integration/TOSLProfile.test.ts 9 TOSL examples (see below) Properties outside the ODRL Profile mechanism No (invalid policies); tosl:trigger possibly

1–2. R107: policy type (potential fix, blocked by an open issue)

N2 (inferPolicy) adds rdf:type odrl:Policy to every subject of odrl:permission/prohibition/obligation.
R107 uses sh:qualifiedValueShape + sh:qualifiedMinCount 1, so one valid type is enough and an unknown type (:MyPolicy, prof:MyPolicy without the profile) passes.

Potential fix: a direct sh:in on rdf:type, so every type must be a policy class (profile subclasses of odrl:Policy are appended by src/profiles/Profile.ts):

sh:property [
    sh:path rdf:type ;
    sh:in ( odrl:Policy odrl:Agreement odrl:Assertion odrl:Offer odrl:Privacy odrl:Request odrl:Set odrl:Ticket ) ;
] ;

This fixes tests 1 and 2, but breaks 49 TOSL examples: their policies are typed both as a policy and as odrl:Asset, which is not a policy class.

# data/profiles/tosl/elsevier/clause-1.1.ttl: valid now, invalid with the fix
:agreement01 a odrl:Agreement, odrl:Asset ;
    odrl:profile tosl: ;
    odrl:permission :permission01 ;
    odrl:assigner :elsevier .

Open issue: odrl:Asset cannot simply be added to the list.
With odrl:Asset added, tests 1 and 2 pass and no other test breaks (tested), but the shape would then state that a policy may also be an asset.
That is not decided yet, so neither variant of the fix can be applied:

Variant Tests 1–2 TOSL examples (on R107) Problem
Current (qualified, at least one policy type) Fail Pass Unknown policy types pass
sh:in with policy classes only Pass 49 fail Policies typed odrl:Asset are rejected
sh:in with policy classes + odrl:Asset Pass Pass Assumes a policy may be an asset (undecided)

3–4. Profile rule subclass with the wrong relation (no fix)

:policy odrl:permission :rule .
:rule a prof:MyRule .     # linked with odrl:permission instead of the profile's relation

Neither policy declares odrl:profile, so both are validated with the plain ODRL shapes.
N2 (inferRules) adds :rule a odrl:Permission, so :RuleShape's sh:or is satisfied and prof:MyRule is ignored.
Catching this would mean allowing only one type per rule (see the note in the test), which ODRL does not require.

5–13. TOSL examples (no fix: invalid policies, except possibly tosl:trigger)

The examples use TOSL properties that are not an extension point of the ODRL Profile mechanism (ODRL IM §3.3).
A profile may add Policy/Rule subclasses, odrl:relation/odrl:function/odrl:operand subproperties, and Action/LeftOperand/RightOperand/Operator/ConflictTerm instances, but not arbitrary properties on a Policy or Rule.
The closed :PolicyShape and :RuleShape correctly reject them (sh:ClosedConstraintComponent).

Example Property Domain (TOSL) Rejected by
elsevier/API_Service_Agreement_2017.ttl tosl:onDispute, tosl:trigger Policy, Permission :PolicyShape, :RuleShape
elsevier/clause-1.2.ttl tosl:trigger Permission :RuleShape
elsevier/clause-6.ttl tosl:onDispute Policy :PolicyShape
openai/Europe_terms_of_use_2024.ttl tosl:onDispute, tosl:limitationOfLiability, tosl:liability Policy :PolicyShape
openai/openai_28_liability04.ttl tosl:limitationOfLiability Policy :PolicyShape
openai/openai_29_liability05.ttl tosl:liability Policy :PolicyShape
openai/openai_31_litigation01.ttl tosl:onDispute Policy :PolicyShape
openai/openai_32_litigation02.ttl tosl:onDispute Policy :PolicyShape
openai/openai_40_litigation03.ttl tosl:onDispute Policy :PolicyShape

The same properties on an asset pass, because :AssetShape is not closed.

tosl:trigger (possible fix): it links a Permission to a Duty, like odrl:duty, odrl:remedy and odrl:consequence.
The Profile mechanism does not document such rule-to-rule relations, but it also does not document the relation between a policy and a profile rule subclass, and for that case we decided to support it (addRuleTypes in src/profiles/Profile.ts).
By the same reasoning, a profile property with a rule class as domain and range could be added to :RuleShape, which would fix clause-1.2.ttl.
API_Service_Agreement_2017.ttl would still fail on tosl:onDispute.

tosl:onDispute, tosl:liability and tosl:limitationOfLiability link a policy to a non-ODRL class (tosl:DisputeResolution, tosl:Liability), so this reasoning does not apply to them.

The reported messages are misleading: a closed-shape violation shows the shape's node-level message ("Policies must be identified by an IRI." or "A rule must be typed as odrl:Permission, odrl:Prohibition or odrl:Duty.").

…t of test fails because of closed rule shape. Also fix normalisation for odrl logical constraint operands
…ctual creation of the ODRL voc. We must not test that during validation of policies
…creating the voc). Also fixes action validation
… + ODRL Logical constraint needs to be added as a type to the other test case; other test cases can not be fixed yet
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

Successfully merging this pull request may close these issues.

1 participant