@chronicle.app/schema 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,7 +4,8 @@ A deliberately small extraction vocabulary with generated TypeScript interfaces
4
4
  and Zod validators. The canonical file is [chronicle.ttl](chronicle.ttl); edit it and run
5
5
  `npm run schema:generate` from the repository root to regenerate the TypeScript/Zod
6
6
  schemas. `npm run schema:check` verifies that the committed output matches the
7
- ontology without rewriting it.
7
+ ontology without rewriting it. Write each term's `rdfs:comment` by the rules in
8
+ [WRITING.md](WRITING.md).
8
9
 
9
10
  ## Documentation site
10
11
 
@@ -13,6 +14,40 @@ The schema is documented at https://schema.chronicle.app, built from
13
14
  site lives in [apps/schema-site](../../apps/schema-site), which also describes
14
15
  the examples format.
15
16
 
17
+ ## Other vocabularies
18
+
19
+ Chronicle's vocabulary stands on its own. It borrows schema.org's model and
20
+ names, and `chronicle.ttl` points each term to the closest schema.org term as a
21
+ hint for mapping data between them: `skos:exactMatch` for the same meaning,
22
+ `skos:closeMatch` for a similar one, and `skos:broadMatch` when schema.org's
23
+ term is broader. A reasoner draws nothing from SKOS mappings, so the hints
24
+ don't claim the vocabularies are compatible. They aren't: values, scope, and
25
+ structure differ in places. No `rdfs:subClassOf`, `rdfs:subPropertyOf`,
26
+ `owl:equivalentClass`, or `owl:equivalentProperty` points to another
27
+ vocabulary, and the schema site's build fails on one.
28
+
29
+ [alignments/](alignments) holds one file for each vocabulary that Chronicle's
30
+ terms relate to, `schemaorg.ttl` and `activitystreams.ttl`. Each names the
31
+ release its terms were checked against, and holds:
32
+
33
+ - `doc:note`: how a Chronicle term differs from the term it maps to, written
34
+ by the rules in [WRITING.md](WRITING.md#8-notes-on-other-vocabularies).
35
+ - `doc:unlike`: a term with the same name as a Chronicle term but a different
36
+ meaning, such as schema.org's `Project`.
37
+ - The mappings to any vocabulary other than schema.org. They can change
38
+ without a vocabulary release.
39
+
40
+ `<name>.terms.json` lists the classes and properties of the release. To move to
41
+ a newer one, run `node scripts/snapshot-vocabulary.js schemaorg <release>` (or
42
+ `activitystreams`), update `doc:release`, and fix what the schema site's build
43
+ reports. The site shows each term's relations, has a page for each vocabulary,
44
+ and fails when a mapping names a term the release does not have, or when a
45
+ Chronicle term shares a name with a term it neither maps to nor marks unlike.
46
+ Names are also compared without the endings in `doc:nameEnding`, so
47
+ `LikeAction` is compared with Activity Streams' `Like`. To relate the
48
+ vocabulary to another one, add its alignment, its `.terms.json`, and a
49
+ comparison in [the site's vocabularies/](../../apps/schema-site/vocabularies).
50
+
16
51
  ## Vocabulary
17
52
 
18
53
  - `Base`: an identity-bearing node; carries `sourceId`.
@@ -22,13 +57,18 @@ the examples format.
22
57
  Plugins extend these roots only where their outputs require it: Things adds task
23
58
  lifecycle actions and collections/tags; shell adds commands, people, and machine
24
59
  realms; iMessage adds messages and attachment media; Claude Code adds threads,
25
- software agents, and model instruments. Shared properties cover source identity,
60
+ software agents, and model instruments; Safari adds page views; Arc Timeline adds
61
+ visits, trips, places, and journeys; WhatsApp adds group channels, members, and
62
+ quoted replies. Shared properties cover source identity,
26
63
  event time, agents, membership, authors, and recipients.
27
64
 
28
- `Text`, `URL`, and `DateTime` are literal datatypes. Cardinality in
29
- `chronicle.ttl` defines each property's constraints: `owl:minCardinality 1` makes
30
- it required, and `owl:maxCardinality 1` makes it single-valued; otherwise it is a list. Records carry `@type` and at least one of `@key` (a nonempty list of
31
- identity fields or computed key entries) or `@id` (an existing identity).
65
+ `Text`, `URL`, `DateTime`, and `Number` are datatypes. A
66
+ `DateTime` is a `Date` or an EDTF string at the source's precision, such as `1987` or
67
+ `XXXX-03-12`; `isDateTime` checks a string. A property takes a list of values
68
+ unless its SHACL shape sets `sh:maxCount 1`. Records carry `@type` and at least one of `@key` (a nonempty list of
69
+ identity fields or computed key entries) or `@id` (an existing identity). A
70
+ record can also carry `@assertedAt`, the instant its source observed it, and
71
+ `@asserts`, the predicates it states completely (`'*'` for all of them).
32
72
  Identity validation checks that declaration, not the existence or hash of the
33
73
  referenced fields. Source-specific extraction owns the values; never invent IDs
34
74
  to make a record pass validation.
@@ -60,12 +100,33 @@ and cardinality. Unknown object fields are stripped by Zod; undeclared record
60
100
  types are rejected. Import interfaces such as `Entity` and `Action` for static
61
101
  typing; use validators at runtime to enforce identity requirements.
62
102
 
103
+ ## Writing the ontology
104
+
105
+ `chronicle.ttl` says what terms mean in OWL, and how records use them in SHACL:
106
+
107
+ - A class is an `owl:Class`. `:Base` is the disjoint union of `:Entity` and
108
+ `:Action`, so nothing is both.
109
+ - A property is an `owl:ObjectProperty` when it links to records and an
110
+ `owl:DatatypeProperty` when it holds values. `:sameAs` takes either, so it is
111
+ an `rdf:Property`.
112
+ - A property's `rdfs:domain` and `rdfs:range` name one term, or several in one
113
+ `owl:unionOf`. Don't add a second `rdfs:domain` or `rdfs:range`: OWL reads two
114
+ as both at once, so the generator rejects it.
115
+ - A datatype is an `rdfs:Datatype` defined over XSD. Each accepts the plain
116
+ strings that Chronicle JSON becomes in JSON-LD as well as typed values, such
117
+ as an `xsd:dateTime` for an instant.
118
+ - A SHACL property shape after a property holds its record rules. `sh:maxCount 1`
119
+ makes it take one value. A shape with `sh:targetClass` and `sh:minCount 1`
120
+ makes it required on that class.
121
+
63
122
  ## Generation and compatibility
64
123
 
65
- The generator turns N3/Turtle into TypeScript types and Zod validators. It handles
66
- inheritance, domain/range, and OWL cardinality and fails for cyclic inheritance or
67
- undeclared referenced classes. The package has no persistence metadata, derived
68
- effects, or runtime filesystem parser.
124
+ The generator turns the ontology into TypeScript types and Zod validators. It
125
+ reads terms through `scripts/terms.js`, which the schema site also uses. It
126
+ handles inheritance, including a class with two parents, domains and ranges,
127
+ and SHACL counts, and it fails for cyclic inheritance, undeclared referenced
128
+ classes, or a property with two domains or ranges. The package has no
129
+ persistence metadata, derived effects, or runtime filesystem parser.
69
130
  Generated runtime code depends only on Zod; the TTL is also included in the package.
70
131
 
71
132
  ## Schema versions
@@ -80,12 +141,13 @@ Release notes map software versions to vocabulary versions.
80
141
  The package exports `@chronicle.app/schema/chronicle.ttl`; the former
81
142
  `@chronicle.app/schema/schema.ttl` export remains an alias for compatibility.
82
143
 
83
- Use patch releases for description corrections that preserve meaning, minor
84
- releases for compatible vocabulary additions, and major releases for removed
85
- terms, changed meanings, or incompatible constraints. These compatibility rules
86
- also apply during `0.x`. Keep term identifiers such as
87
- `https://schema.chronicle.app/Task` stable; introduce a new term and deprecate the
88
- old one when its concept changes fundamentally.
144
+ Use patch releases for description corrections that preserve meaning and minor
145
+ releases for anything else. Until 1.0, a minor release can rename or remove
146
+ terms, change what they mean, or add constraints, so data that validates against
147
+ one minor version may not validate against the next. From 1.0, those changes need
148
+ a major release. Term identifiers such as `https://schema.chronicle.app/Task` are
149
+ unversioned, so don't reuse one for a different concept. Give that concept a new
150
+ term.
89
151
 
90
152
  Snapshot paths use the vocabulary version, not the npm package version.
91
153
  The publication convention is
@@ -98,9 +160,8 @@ publish: work on new terms in a branch until it is ready. Any change to
98
160
  `npm run schema:check` enforces this against the latest release tag. See [Preparing a release](../../RELEASING.md) for the
99
161
  release procedure.
100
162
 
101
- The vocabulary is intentionally small. Add terms only when a plugin needs them,
102
- keeping existing term identifiers and meanings stable; regenerate and add
103
- focused tests alongside each addition.
163
+ The vocabulary is intentionally small. Add terms only when a plugin needs them;
164
+ regenerate and add focused tests alongside each addition.
104
165
 
105
166
  Node.js 22.13+. MIT covers the ontology, generator, generated code, and docs;
106
167
  see [LICENSE](LICENSE).