The history as an RDF 1.2 dataset¶
arch-history.mjs timeline writes one dataset per history. The terms are the plugin's history module,
ontology/c4-history.ttl (prefix c4h:, namespace
https://caviri.github.io/c4-model-agentic-plugin/ontology/c4-history#), built on PROV-O. The architecture inside each
version is in the core, data and view terms (c4:, c4d:, c4v:), produced by the explorer template's own mapping
(window.archRdf), so a version graph is exactly what build-explorer.mjs exports for that model, apart from the two
renamings below. Schemas, entities, fields and relations are versioned like boxes and arrows: their triples are in the
version graphs, every one added or removed has its reifier, and each changed schema, entity, field or relation has its
element change.
| File | What |
|---|---|
history.trig |
TriG 1.2: the default graph, then one named graph per changeset, then one per version |
history.nq |
the same quads as N-Quads 1.2 (triple terms written <<( s p o )>>) |
history.rete |
the same, as one queryable .rete file with its named graphs (when the rete CLI or rete-graph is available) |
history.json |
compact form for the explorer page (build-explorer.mjs --history): every version's model, deduplicated, with element-level changes, and the git details its version list shows (the commit's full message, parents and authored time, the same values as c4h:message, c4h:parentSha, c4h:authoredAtTime on that commit; the pull request's head and base branches, as c4h:headRef, c4h:baseRef) |
timeline.md |
the versions as a table, then the changes of each version |
diff-<A>-<B>.md, .trig |
diff A B: report and changeset; --with-graphs adds both version graphs to the .trig |
pr-<N>.md, .trig |
pr N: the same for a pull request |
blame-<ref>.md, .trig |
blame ref: the origin of every triple of one version |
Layout¶
default graph the history, its versions, the activities that generated them, the agents, changeset descriptions
GRAPH <changeset:A..B> one reifier per added or removed triple, one element change per changed box, arrow, scenario …
GRAPH <version:sha> the whole architecture at that commit (c4:, c4v:)
GRAPH <blame:sha> (blame-*.trig) one origin reifier per triple of that version
:history:image-annotation-tool a c4h:History, prov:Collection ;
c4h:modelPath "communications/architecture-explorer/model.js" ; c4h:resolution "merges" ;
c4h:includesEmails false ; prov:hadMember :version:7e691fd…, :version:91a0e03… ;
c4h:hasChangeSet :changeset:7e691fd…..91a0e03… .
:version:91a0e03… a c4h:Version, prov:Entity ;
c4h:sequenceNumber 7 ; c4h:commitSha "91a0e03…" ; c4h:modelCommit :commit:b32f917… ;
c4h:modelPath "communications/architecture-explorer/model.js" ; c4h:modelOrigin c4h:Committed ;
prov:wasRevisionOf :version:7e691fd… ;
prov:generatedAtTime "2026-10-08T07:00:00Z"^^xsd:dateTime ;
prov:wasGeneratedBy :commit:91a0e03… ; # a c4h:Merge
prov:wasAttributedTo :agent:bo-sample, :agent:alex-example ; # the branch's authors, then the merger
c4h:tripleCount 3280 ; c4h:pullRequest :pr:5 .
:commit:91a0e03… a prov:Activity, c4h:Merge, c4h:Commit ;
c4h:sha "91a0e03…" ; c4h:parentSha "7e691fd…", "b32f917…" ; c4h:message "Merge pull request #5 …" ;
c4h:author :agent:alex-example ; c4h:committer :agent:alex-example ; prov:endedAtTime "…"^^xsd:dateTime .
:agent:bo-sample a prov:Agent ; foaf:name "Bo Sample" .
GRAPH :changeset:7e691fd…..91a0e03… {
:change:510d737… rdf:reifies <<( :worker rdfs:label "Worker" )>> ;
a c4h:Addition ; c4h:inChangeSet :changeset:7e691fd…..91a0e03… ;
c4h:changedIn :version:91a0e03… ; # the version of this history that holds the change
prov:wasGeneratedBy :commit:9564ac7… ; # the commit that made it, inside the merged branch
prov:wasAttributedTo :agent:bo-sample ; prov:generatedAtTime "2026-10-06T10:05:00Z"^^xsd:dateTime .
:delta:1a2b…:worker a c4h:ElementAddition ; c4h:element :worker ; c4h:elementKind "box" ; c4h:elementKey "worker" ;
c4h:changedIn :version:91a0e03… ; prov:wasGeneratedBy :commit:9564ac7… ; prov:wasAttributedTo :agent:bo-sample .
}
GRAPH :version:91a0e03… { :worker a c4:Element, c4:Container ; rdfs:label "Worker" ; … }
The reified triple is not asserted in the changeset graph (r rdf:reifies <<( s p o )>>, not the annotation syntax
s p o {| … |}): a removed triple stays removed. Asserted, it lives in the version graphs.
What carries what¶
| Question | Where |
|---|---|
| The previous version | prov:wasRevisionOf (two for a merge at all resolution) |
| When | prov:generatedAtTime on the version (commit time; tag time for releases; merge time for PRs; regeneration time for regenerated models) |
| Generated by | prov:wasGeneratedBy → c4h:Commit, c4h:Merge, c4h:Release, c4h:PullRequest, c4h:Squash, c4h:Regeneration, c4h:WorkingTreeEdit |
| Whose changes | prov:wasAttributedTo on the version: the authors of the model commits it adds, and for merges, releases and PRs also the merger, tagger or PR author |
| Git details | c4h:commitSha, c4h:modelCommit (last commit that changed the model file), c4h:ref (branches pointing there), c4h:tag, c4h:pullRequest → c4h:prNumber, c4h:prUrl; on commits c4h:sha, c4h:parentSha, c4h:message, c4h:author, c4h:committer, c4h:authoredAtTime, rdfs:seeAlso (web page) |
| The model file | c4h:modelPath; c4h:modelOrigin c4h:Committed, c4h:Regenerated (see the workflows) or c4h:WorkingTree |
| A squashed range | c4h:SquashedVersion with c4h:rangeBase, c4h:rangeHead, c4h:coversCommit (each model commit of the range) |
| Per triple: added or removed | the reifier's type, c4h:Addition or c4h:Removal |
| Per triple: caused by | prov:wasGeneratedBy the exact commit (inside a merged branch, a release, a squash), c4h:changedIn the version of this history, prov:wasAttributedTo, prov:generatedAtTime |
| Two diverged branches | c4h:mergeBase on the changeset; c4h:fromSide true on a reifier whose commit is on the earlier ref's side (the change is the reverse of what it did) |
| Per element | c4h:ElementAddition / ElementRemoval / ElementModification, c4h:element, c4h:elementKind (box, state, arrow, transition, scenario, variant, schema, entity, field, relation, setting), c4h:elementKey, c4h:changedField (model field names; for a field, its changed properties such as type, required, ref), c4h:changedProperty (RDF properties), c4h:possibleRenameOf (a box, or an entity of the same schema with the same field names) |
| Per data element | an entity whose fields changed is a modification with c4h:changedField "fields", and each field added, removed or changed has its own element change (c4h:elementKind "field", key <entity>.<field>); a step's or an arrow's reads and writes are fields of the step (in its scenario's change) or of the arrow |
| Blame | c4h:Blame (c4h:blameOf the version) holding c4h:TripleOrigin reifiers with c4h:introducedIn, prov:wasGeneratedBy, prov:wasAttributedTo |
Stable IRIs¶
Every resource is under one IRI base: the base of the newest model (MODEL.rdf.base, else source.repoUrl#, else
urn:architecture:<project>:), or --iri-base. Older versions are rebased onto it if their own base differed.
| Resource | IRI |
|---|---|
| History | <base>history:<project> |
| Version | <base>version:<full sha>; version:worktree; version:squash:<base sha>..<head sha> |
| Commit, PR, release | <base>commit:<sha>, <base>pr:<n>, <base>release:<tag> |
| Agent | <base>agent:<slug of the name> |
| Changeset | <base>changeset:<version A>..<version B> (also its graph name) |
| Reifier, element change, origin | <base>change:<hash>, <base>delta:<hash>:<element>, <base>origin:<hash> (the element: a node id, rel:…, scenario:<id>, dataschema:<id>, entity:<id>, field:<entity>.<field>, relation:…, model:<setting>) |
| Schema, entity, field, index | as archRdf writes them: <base>dataschema:<id>, <base>entity:<id>, <base>field:<entity>.<field>, <base>index:<entity>:<k> (stable by id and name, see the RDF graph reference) |
Two renamings make graphs of different versions comparable triple by triple; everything else is archRdf's output:
- Relationships, steps and data relations are keyed by their ends, not their position:
rel:<from>:<to>(:2,:3for further edges between the same pair, in declaration order),step:<scenario>:<from>:<to>[:k], andrelation:<kind>:<from>:<to>[:k]for arelations[]entry (an end is<entity>or<entity>.<field>, the kind isrefwhen the model gives none). Inserting an edge or a relation at the top ofmodel.jsno longer renumbers every other one. - List cells get IRIs instead of blank nodes:
list:<owner>:<property>:<i>, so an unchanged list is the same triples in both versions.
archRdf.fromTriples() reads a version graph back unchanged: it orders by c4v:order and schema:position, not by IRI.
The skill's verification checks this for every version.
Moving a node within model.js is not an element change, but it does shift c4v:order on every node after it, and a step
inserted into a scenario shifts schema:position on the steps after it. The fields of an entity are different: their
order is part of the entity's definition, so a column inserted in the middle shifts the schema:position of the
columns after it, and a field moved is reported (reordered) in the entity's change. Those triples are real changes of the view module
and appear in the changeset; reports count them ("presentation only, c4v:"). Leave them out of a query with the filter
in the third query below.
Privacy¶
Agents carry foaf:name only. Git commit e-mail addresses are personal data: anyone with the repository can read them,
but a dataset copies them to new places (a published page, a shared .rete file) and makes them trivial to harvest.
--emails adds foaf:mbox, and the history says which it is (c4h:includesEmails). Without it, e-mail addresses in
commit messages (Signed-off-by: and Co-authored-by: trailers, or anywhere else) are dropped from c4h:message and
from history.json. Remote URLs are reduced to the host and path, so a token in an https://user:token@… remote is
never exported.
SPARQL queries¶
Run them with rete sparql history.rete '<query>', or in JavaScript: (await rete.open(bytes)).query(sparql). Every
query below was run on the demonstration history (scripts/make-demo-history.mjs) with rete-graph 0.7.4.
PREFIX c4h: <https://caviri.github.io/c4-model-agentic-plugin/ontology/c4-history#>
PREFIX c4: <https://caviri.github.io/c4-model-agentic-plugin/ontology/c4#>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
The timeline¶
SELECT ?n ?version ?when (GROUP_CONCAT(DISTINCT ?name; separator=", ") AS ?by)
WHERE { ?version a c4h:Version ; c4h:sequenceNumber ?n ; prov:generatedAtTime ?when ; prov:wasAttributedTo/foaf:name ?name }
GROUP BY ?n ?version ?when ORDER BY ?n
Triples added from one version to the next (the diff, straight from the version graphs)¶
SELECT ?s ?p ?o WHERE {
?cs a c4h:ChangeSet ; c4h:fromVersion ?a ; c4h:toVersion ?b .
GRAPH ?b { ?s ?p ?o } FILTER NOT EXISTS { GRAPH ?a { ?s ?p ?o } }
}
Swap ?a and ?b for the removals. This is the same set as the changeset's c4h:Addition reifiers.
Architecture changes only, with who and when¶
SELECT ?kind ?s ?p ?o ?who ?when WHERE {
GRAPH ?cs { ?r rdf:reifies <<( ?s ?p ?o )>> ; a ?kind ; prov:wasAttributedTo ?a ; prov:generatedAtTime ?when }
?a foaf:name ?who .
FILTER (?kind IN (c4h:Addition, c4h:Removal))
FILTER (!STRSTARTS(STR(?p), "https://caviri.github.io/c4-model-agentic-plugin/ontology/c4-view#"))
}
ORDER BY ?when
Who added one triple¶
SELECT ?who ?when ?commit WHERE {
GRAPH ?cs { ?r rdf:reifies <<( <urn:architecture:image-annotation-tool:worker> rdfs:label "Worker" )>> ;
prov:wasAttributedTo ?a ; prov:generatedAtTime ?when ; prov:wasGeneratedBy ?commit }
?a foaf:name ?who .
}
What changed per element, by whom¶
SELECT ?version ?kind ?key ?change (GROUP_CONCAT(DISTINCT ?field; separator=", ") AS ?fields) (SAMPLE(?name) AS ?who)
WHERE {
GRAPH ?cs { ?d c4h:elementKind ?kind ; c4h:elementKey ?key ; a ?change ; c4h:changedIn ?version ; prov:wasAttributedTo ?a
OPTIONAL { ?d c4h:changedField ?field } }
?a foaf:name ?name . # agents are described in the default graph, outside GRAPH
FILTER (?change IN (c4h:ElementAddition, c4h:ElementRemoval, c4h:ElementModification))
}
GROUP BY ?version ?kind ?key ?change ORDER BY ?version ?kind ?key
Schema changes: schemas, tables, columns and relations, by whom¶
SELECT ?version ?kind ?change ?key ?renameOf (SAMPLE(?name) AS ?who) WHERE {
GRAPH ?cs { ?d c4h:elementKind ?kind ; c4h:elementKey ?key ; a ?change ; c4h:changedIn ?version ; prov:wasAttributedTo ?a
OPTIONAL { ?d c4h:possibleRenameOf ?renameOf } }
?a foaf:name ?name .
FILTER (?kind IN ("schema", "entity", "field", "relation"))
FILTER (?change IN (c4h:ElementAddition, c4h:ElementRemoval, c4h:ElementModification))
}
GROUP BY ?version ?kind ?change ?key ?renameOf ORDER BY ?version ?kind ?key
On the demonstration history built from a model with a data layer this lists, for example, the three columns of
images added with the thumbnail worker, and exports added with ?renameOf export-jobs (the table renamed).
Who added a column¶
PREFIX c4d: <https://caviri.github.io/c4-model-agentic-plugin/ontology/c4-data#>
SELECT ?who ?when ?commit WHERE {
GRAPH ?cs { ?r rdf:reifies <<( <urn:architecture:image-annotation-tool:field:images.thumbnail_key> rdf:type c4d:Field )>> ;
a c4h:Addition ; prov:wasAttributedTo ?a ; prov:generatedAtTime ?when ; prov:wasGeneratedBy ?commit }
?a foaf:name ?who .
}
Everything one person changed¶
SELECT ?version ?kind ?key WHERE {
?a foaf:name "Bo Sample" .
GRAPH ?cs { ?d prov:wasAttributedTo ?a ; c4h:changedIn ?version ; c4h:elementKind ?kind ; c4h:elementKey ?key }
}
ORDER BY ?version
Check: every addition is in the later version and not in the earlier one¶
SHACL validates one graph; this check spans three. It returns nothing on a correct dataset.
SELECT ?r WHERE {
?cs a c4h:ChangeSet ; c4h:fromVersion ?a ; c4h:toVersion ?b .
GRAPH ?cs { ?r a c4h:Addition ; rdf:reifies <<( ?s ?p ?o )>> }
FILTER (NOT EXISTS { GRAPH ?b { ?s ?p ?o } } || EXISTS { GRAPH ?a { ?s ?p ?o } })
}
Check: no e-mail addresses unless asked for¶
Validation¶
arch-history.mjs validate [history.nq] checks the dataset against ontology/c4-history-shapes.ttl: the default graph
merged with the changeset and blame graphs (SHACL sees one graph at a time). It uses rete-graph when it can be
resolved (--rete-module <dist/index.js> or the RETE_GRAPH_MODULE environment variable point at it), else pyshacl,
on a copy where each triple term is replaced by an IRI made from its hash (rdflib does not read RDF 1.2 triple terms).
When ontology/c4-shapes.ttl exists and the version graphs use its namespace, each version graph is also checked
against it. timeline, diff, pr and blame validate what they wrote unless --no-validate.
Source
This page is skills/architecture-history/references/history-graph.md, the guide the skill reads while it works. Edit it there; the documentation includes it as is. The terms are listed in the history term reference.