dprod icon indicating copy to clipboard operation
dprod copied to clipboard

Recurring Duties

Open aacraf opened this issue 3 months ago • 3 comments

Reading through contract semantics I got a question regarding recurring duties.

In 5.4, these are stated as:

performed(a, x, s, Σ) :=
    ∃(a', x', s', t) ∈ Σ.performed :
        a' = a ∧ (x' = x ∨ x' includedIn⁺ x) ∧ s' matches s

Σ.performed records exact actions as they occur.

I see t in the tuple but not in the conditions, and since each occurrence keeps the same subject, action and asset, it looks like a duty fulfilled on day 1 would still count as fulfilled on day 2. Would adding t to the evaluation help here, or is it intended to be read in another manner?

aacraf avatar Aug 12 '26 01:08 aacraf

Good catch — this is a real gap in §5.4, and you're reading it correctly: t is carried in the Σ.performed tuple but never constrained, so the check is intended-but-incomplete rather than deliberately time-blind.

Confirmed core problem. Since instantiate(duty, t) (§5.5) carries the same subject/action/asset into every occurrence instance, a single performance record satisfies performed() for all instances, past and future. A duty fulfilled on day 1 immediately fulfills the day-2 instance the moment it activates, and D-VIOLATE can never fire for later occurrences — recurring duties degenerate into "fulfill once, fulfilled forever."

Two adjacent defects that the same fix resolves:

  1. Stuck-Active state in the non-recurring case. D-FULFILL (§5.2) requires performed = true ∧ deadline ≥ Σ.clock, while D-VIOLATE requires performed = false ∧ clock > deadline. If the action was performed before the deadline but evaluation only runs after it, neither rule applies and the duty stays Active forever. Constraining the performance time (rather than the evaluation clock) makes fulfillment decidable at any later clock.
  2. Pre-activation performances count. A performance recorded before the duty ever activated (even before the agreement existed) currently fulfills it.

Proposed direction — window-parameterize the check, i.e. yes, adding t to the evaluation is exactly the right move:

performed(a, x, s, w, Σ) :=
    ∃(a', x', s', t) ∈ Σ.performed :
        a' matches a ∧ x' matches x ∧ s' matches s ∧ t ∈ w

with w = [Σ.activatedAt(d), effectiveDeadline(d, Σ)] in D-FULFILL/D-VIOLATE. For a schedule instance activated at occurrence time tᵢ this naturally becomes [tᵢ, tᵢ + deadline], so each occurrence needs its own performance inside its own window. D-FULFILL's deadline ≥ Σ.clock premise can then be dropped, since the window subsumes it.

One related inconsistency worth folding into the same change: §5.4 defines agent subsumption (a₁ matches a₂ ⟺ a₁ = a₂ ∨ a₁ memberOf⁺ a₂), yet the performed formula uses exact a' = a. Either the formula should use a' matches a (as above) or the agent-matching paragraph is dead text.

We'll address this on the schedule-model branch (#184) where this semantics landed.

jgeluk avatar Aug 20 '26 15:08 jgeluk

@rivettp @tonyseale @matthiasautrata please add your view to this?

jgeluk avatar Aug 20 '26 15:08 jgeluk

Thanks for the imaging issue. We will, I think, raise a bug against the formal semantics. We believe the RDF is solid for doing this thought: It works. I wrote a recurring duty using the ontology on the issue/184-schedule-model branch and ran it through pySHACL against that branch's shapes (ontology loaded, RDFS inference on). It passes cleanly. The shapes also catch every way I tried to get it wrong.

turtle

WHEN: a reusable, identified schedule. It says nothing about what happens.

ex:weekdays-0600-london a dprod:Schedule ; dct:conformsTo dprod:Rfc5545ScheduleFormat ; dprod:scheduleExpression "DTSTART;TZID=Europe/London:20260105T060000\nRRULE:FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR" .

THE RECURRING DUTY: a template, one obligation per occurrence

ex:weekday-delivery a odrl:Duty ; dprod:subjectOfDuty ex:platform-team ; # who must act dprod:objectOfDuty ex:quant-research ; # who it's owed to odrl:action ex:deliver ; # what odrl:target ex:market-prices ; # to which asset dprod:schedule ex:weekdays-0600-london ; # when each occurrence opens dprod:deadline "PT30M"^^xsd:duration . # how long each one stays open

ex:contract-001 a dprod:DataContract ; odrl:profile https://www.omg.org/spec/DPROD/ ; dprod:acceptsOffer ex:offer-001 ; odrl:assigner ex:platform-team ; odrl:assignee ex:quant-research ; odrl:target ex:market-prices ; dprod:effectiveDate "2026-01-05T00:00:00Z"^^xsd:dateTime ; dprod:expirationDate "2026-12-31T23:59:59Z"^^xsd:dateTime ; odrl:obligation ex:weekday-delivery .

tonyseale avatar Sep 24 '26 16:09 tonyseale