Skip to content
Alpha: see what works today →
Menu

Derivation

current-revision-candidates

The ladder's first three steps over a record's revisions. A revision an Erroneous that stands names is out. So is one a Before that stands places before another revision of the record that no such Erroneous names, unless that other is placed before it in turn, directly or through the record's other revisions: Befores that form a cycle remove nothing. Of what is left, the revisions at the latest source change time stay, and so does every one carrying none: the first instant xsd:dateTime can write stands for none, so a record none of whose revisions carries one keeps them all.

The query

PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX pav: <http://purl.org/pav/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

CONSTRUCT { ?record cascade:currentRevisionCandidate ?r }
WHERE {
  { SELECT ?record (MAX(COALESCE(?changed0, "0001-01-01T00:00:00Z"^^xsd:dateTime)) AS ?latest)
    WHERE {
      ?r0 cascade:revisionOf ?record .
      MINUS { ?r0 cascade:revisionJudgedErroneousBy ?wrong0 }
      MINUS {
        ?r0 cascade:judgedBeforeRevisionOfSameRecord ?later0 .
        FILTER NOT EXISTS { ?later0 cascade:revisionJudgedErroneousBy ?laterWrong0 }
        FILTER NOT EXISTS { ?later0 cascade:judgedBeforeRevisionOfSameRecord+ ?r0 }
      }
      OPTIONAL { ?r0 pav:lastUpdateOn ?changed0 }
    }
    GROUP BY ?record }
  ?r cascade:revisionOf ?record .
  MINUS { ?r cascade:revisionJudgedErroneousBy ?wrong }
  MINUS {
    ?r cascade:judgedBeforeRevisionOfSameRecord ?later .
    FILTER NOT EXISTS { ?later cascade:revisionJudgedErroneousBy ?laterWrong }
    FILTER NOT EXISTS { ?later cascade:judgedBeforeRevisionOfSameRecord+ ?r }
  }
  OPTIONAL { ?r pav:lastUpdateOn ?changed }
  FILTER (!BOUND(?changed) || ?changed = ?latest)
}

Terms it reads

cascade:currentRevisionCandidate · cascade:judgedBeforeRevisionOfSameRecord · cascade:revisionJudgedErroneousBy · cascade:revisionOf · pav:lastUpdateOn

Rules and decision notes that name it

No rule or decision note writes its path.

queries/derivations/current-revision-candidates.rq on GitHub ↗