@dxos/echo-memory 0.0.0-stage → 0.0.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.
Files changed (147) hide show
  1. package/LICENSE +105 -0
  2. package/dist/lib/Fact.mjs +1 -0
  3. package/dist/lib/FactFeed.mjs +1 -0
  4. package/dist/lib/Graph.mjs +1 -0
  5. package/dist/lib/Hash.mjs +1 -0
  6. package/dist/lib/Mapping.mjs +1 -0
  7. package/dist/lib/MemoryError.mjs +1 -0
  8. package/dist/lib/MemoryQuery.mjs +1 -0
  9. package/dist/lib/MemoryService.mjs +1 -0
  10. package/dist/lib/Ontology.mjs +1 -0
  11. package/dist/lib/Pipeline.mjs +1 -0
  12. package/dist/lib/Predicate.mjs +1 -0
  13. package/dist/lib/Rdf.mjs +1 -0
  14. package/dist/lib/RdfStore.mjs +1 -0
  15. package/dist/lib/Sparql.mjs +1 -0
  16. package/dist/lib/Subscription.mjs +1 -0
  17. package/dist/lib/Trig.mjs +1 -0
  18. package/dist/lib/Vocab.mjs +1 -0
  19. package/dist/lib/Vocabularies.mjs +1 -0
  20. package/dist/lib/chunk-Fact.mjs +245 -0
  21. package/dist/lib/chunk-Fact.mjs.map +1 -0
  22. package/dist/lib/chunk-FactFeed.mjs +29 -0
  23. package/dist/lib/chunk-FactFeed.mjs.map +1 -0
  24. package/dist/lib/chunk-Graph.mjs +147 -0
  25. package/dist/lib/chunk-Graph.mjs.map +1 -0
  26. package/dist/lib/chunk-Hash.mjs +16 -0
  27. package/dist/lib/chunk-Hash.mjs.map +1 -0
  28. package/dist/lib/chunk-Mapping.mjs +226 -0
  29. package/dist/lib/chunk-Mapping.mjs.map +1 -0
  30. package/dist/lib/chunk-MemoryError.mjs +10 -0
  31. package/dist/lib/chunk-MemoryError.mjs.map +1 -0
  32. package/dist/lib/chunk-MemoryQuery.mjs +99 -0
  33. package/dist/lib/chunk-MemoryQuery.mjs.map +1 -0
  34. package/dist/lib/chunk-MemoryService.mjs +31 -0
  35. package/dist/lib/chunk-MemoryService.mjs.map +1 -0
  36. package/dist/lib/chunk-Ontology.mjs +529 -0
  37. package/dist/lib/chunk-Ontology.mjs.map +1 -0
  38. package/dist/lib/chunk-Pipeline.mjs +84 -0
  39. package/dist/lib/chunk-Pipeline.mjs.map +1 -0
  40. package/dist/lib/chunk-Predicate.mjs +66 -0
  41. package/dist/lib/chunk-Predicate.mjs.map +1 -0
  42. package/dist/lib/chunk-Rdf.mjs +120 -0
  43. package/dist/lib/chunk-Rdf.mjs.map +1 -0
  44. package/dist/lib/chunk-RdfStore.mjs +60 -0
  45. package/dist/lib/chunk-RdfStore.mjs.map +1 -0
  46. package/dist/lib/chunk-Sparql.mjs +153 -0
  47. package/dist/lib/chunk-Sparql.mjs.map +1 -0
  48. package/dist/lib/chunk-Subscription.mjs +44 -0
  49. package/dist/lib/chunk-Subscription.mjs.map +1 -0
  50. package/dist/lib/chunk-Trig.mjs +106 -0
  51. package/dist/lib/chunk-Trig.mjs.map +1 -0
  52. package/dist/lib/chunk-Vocab.mjs +164 -0
  53. package/dist/lib/chunk-Vocab.mjs.map +1 -0
  54. package/dist/lib/chunk-Vocabularies.mjs +343 -0
  55. package/dist/lib/chunk-Vocabularies.mjs.map +1 -0
  56. package/dist/lib/chunk-rolldown-runtime.mjs +13 -0
  57. package/dist/lib/index.mjs +19 -0
  58. package/dist/types/src/Fact.d.ts +339 -0
  59. package/dist/types/src/Fact.d.ts.map +1 -0
  60. package/dist/types/src/Fact.test.d.ts +2 -0
  61. package/dist/types/src/Fact.test.d.ts.map +1 -0
  62. package/dist/types/src/FactFeed.d.ts +11 -0
  63. package/dist/types/src/FactFeed.d.ts.map +1 -0
  64. package/dist/types/src/FactFeed.test.d.ts +2 -0
  65. package/dist/types/src/FactFeed.test.d.ts.map +1 -0
  66. package/dist/types/src/Graph.d.ts +31 -0
  67. package/dist/types/src/Graph.d.ts.map +1 -0
  68. package/dist/types/src/Graph.test.d.ts +2 -0
  69. package/dist/types/src/Graph.test.d.ts.map +1 -0
  70. package/dist/types/src/Hash.d.ts +3 -0
  71. package/dist/types/src/Hash.d.ts.map +1 -0
  72. package/dist/types/src/Mapping.d.ts +18 -0
  73. package/dist/types/src/Mapping.d.ts.map +1 -0
  74. package/dist/types/src/Mapping.test.d.ts +2 -0
  75. package/dist/types/src/Mapping.test.d.ts.map +1 -0
  76. package/dist/types/src/MemoryError.d.ts +33 -0
  77. package/dist/types/src/MemoryError.d.ts.map +1 -0
  78. package/dist/types/src/MemoryQuery.d.ts +136 -0
  79. package/dist/types/src/MemoryQuery.d.ts.map +1 -0
  80. package/dist/types/src/MemoryQuery.test.d.ts +2 -0
  81. package/dist/types/src/MemoryQuery.test.d.ts.map +1 -0
  82. package/dist/types/src/MemoryService.d.ts +72 -0
  83. package/dist/types/src/MemoryService.d.ts.map +1 -0
  84. package/dist/types/src/Ontology.d.ts +115 -0
  85. package/dist/types/src/Ontology.d.ts.map +1 -0
  86. package/dist/types/src/Ontology.test.d.ts +2 -0
  87. package/dist/types/src/Ontology.test.d.ts.map +1 -0
  88. package/dist/types/src/Pipeline.d.ts +103 -0
  89. package/dist/types/src/Pipeline.d.ts.map +1 -0
  90. package/dist/types/src/Predicate.d.ts +17 -0
  91. package/dist/types/src/Predicate.d.ts.map +1 -0
  92. package/dist/types/src/Predicate.test.d.ts +2 -0
  93. package/dist/types/src/Predicate.test.d.ts.map +1 -0
  94. package/dist/types/src/Rdf.d.ts +33 -0
  95. package/dist/types/src/Rdf.d.ts.map +1 -0
  96. package/dist/types/src/Rdf.test.d.ts +2 -0
  97. package/dist/types/src/Rdf.test.d.ts.map +1 -0
  98. package/dist/types/src/RdfStore.d.ts +471 -0
  99. package/dist/types/src/RdfStore.d.ts.map +1 -0
  100. package/dist/types/src/Sparql.d.ts +58 -0
  101. package/dist/types/src/Sparql.d.ts.map +1 -0
  102. package/dist/types/src/Sparql.test.d.ts +2 -0
  103. package/dist/types/src/Sparql.test.d.ts.map +1 -0
  104. package/dist/types/src/Subscription.d.ts +100 -0
  105. package/dist/types/src/Subscription.d.ts.map +1 -0
  106. package/dist/types/src/Trig.d.ts +8 -0
  107. package/dist/types/src/Trig.d.ts.map +1 -0
  108. package/dist/types/src/Trig.test.d.ts +2 -0
  109. package/dist/types/src/Trig.test.d.ts.map +1 -0
  110. package/dist/types/src/Vocab.d.ts +90 -0
  111. package/dist/types/src/Vocab.d.ts.map +1 -0
  112. package/dist/types/src/Vocabularies.d.ts +45 -0
  113. package/dist/types/src/Vocabularies.d.ts.map +1 -0
  114. package/dist/types/src/index.d.ts +19 -0
  115. package/dist/types/src/index.d.ts.map +1 -0
  116. package/dist/types/tsconfig.tsbuildinfo +1 -0
  117. package/package.json +133 -3
  118. package/src/Fact.test.ts +74 -0
  119. package/src/Fact.ts +269 -0
  120. package/src/FactFeed.test.ts +40 -0
  121. package/src/FactFeed.ts +38 -0
  122. package/src/Graph.test.ts +106 -0
  123. package/src/Graph.ts +158 -0
  124. package/src/Hash.ts +15 -0
  125. package/src/Mapping.test.ts +197 -0
  126. package/src/Mapping.ts +320 -0
  127. package/src/MemoryError.ts +10 -0
  128. package/src/MemoryQuery.test.ts +67 -0
  129. package/src/MemoryQuery.ts +114 -0
  130. package/src/MemoryService.ts +89 -0
  131. package/src/Ontology.test.ts +94 -0
  132. package/src/Ontology.ts +571 -0
  133. package/src/Pipeline.ts +97 -0
  134. package/src/Predicate.test.ts +47 -0
  135. package/src/Predicate.ts +89 -0
  136. package/src/Rdf.test.ts +104 -0
  137. package/src/Rdf.ts +158 -0
  138. package/src/RdfStore.ts +111 -0
  139. package/src/Sparql.test.ts +72 -0
  140. package/src/Sparql.ts +237 -0
  141. package/src/Subscription.ts +47 -0
  142. package/src/Trig.test.ts +199 -0
  143. package/src/Trig.ts +170 -0
  144. package/src/Vocab.ts +134 -0
  145. package/src/Vocabularies.ts +204 -0
  146. package/src/index.ts +22 -0
  147. package/README.md +0 -3
package/LICENSE ADDED
@@ -0,0 +1,105 @@
1
+ # Functional Source License, Version 1.1, ALv2 Future License
2
+
3
+ ## Abbreviation
4
+
5
+ FSL-1.1-Apache-2.0
6
+
7
+ ## Notice
8
+
9
+ Copyright 2026 DXOS
10
+
11
+ ## Terms and Conditions
12
+
13
+ ### Licensor ("We")
14
+
15
+ The party offering the Software under these Terms and Conditions.
16
+
17
+ ### The Software
18
+
19
+ The "Software" is each version of the software that we make available under
20
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
21
+ Conditions with the Software.
22
+
23
+ ### License Grant
24
+
25
+ Subject to your compliance with this License Grant and the Patents,
26
+ Redistribution and Trademark clauses below, we hereby grant you the right to
27
+ use, copy, modify, create derivative works, publicly perform, publicly display
28
+ and redistribute the Software for any Permitted Purpose identified below.
29
+
30
+ ### Permitted Purpose
31
+
32
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
33
+ means making the Software available to others in a commercial product or
34
+ service that:
35
+
36
+ 1. substitutes for the Software;
37
+
38
+ 2. substitutes for any other product or service we offer using the Software
39
+ that exists as of the date we make the Software available; or
40
+
41
+ 3. offers the same or substantially similar functionality as the Software.
42
+
43
+ Permitted Purposes specifically include using the Software:
44
+
45
+ 1. for your internal use and access;
46
+
47
+ 2. for non-commercial education;
48
+
49
+ 3. for non-commercial research; and
50
+
51
+ 4. in connection with professional services that you provide to a licensee
52
+ using the Software in accordance with these Terms and Conditions.
53
+
54
+ ### Patents
55
+
56
+ To the extent your use for a Permitted Purpose would necessarily infringe our
57
+ patents, the license grant above includes a license under our patents. If you
58
+ make a claim against any party that the Software infringes or contributes to
59
+ the infringement of any patent, then your patent license to the Software ends
60
+ immediately.
61
+
62
+ ### Redistribution
63
+
64
+ The Terms and Conditions apply to all copies, modifications and derivatives of
65
+ the Software.
66
+
67
+ If you redistribute any copies, modifications or derivatives of the Software,
68
+ you must include a copy of or a link to these Terms and Conditions and not
69
+ remove any copyright notices provided in or with the Software.
70
+
71
+ ### Disclaimer
72
+
73
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
74
+ IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
75
+ PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
76
+
77
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
78
+ SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
79
+ EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
80
+
81
+ ### Trademarks
82
+
83
+ Except for displaying the License Details and identifying us as the origin of
84
+ the Software, you have no right under these Terms and Conditions to use our
85
+ trademarks, trade names, service marks or product names.
86
+
87
+ ## Grant of Future License
88
+
89
+ We hereby irrevocably grant you an additional license to use the Software under
90
+ the Apache License, Version 2.0 that is effective on the second anniversary of
91
+ the date we make the Software available. On or after that date, you may use the
92
+ Software under the Apache License, Version 2.0, in which case the following
93
+ will apply:
94
+
95
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
96
+ this file except in compliance with the License.
97
+
98
+ You may obtain a copy of the License at
99
+
100
+ http://www.apache.org/licenses/LICENSE-2.0
101
+
102
+ Unless required by applicable law or agreed to in writing, software distributed
103
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
104
+ CONDITIONS OF ANY KIND, either express or implied. See the License for the
105
+ specific language governing permissions and limitations under the License.
@@ -0,0 +1 @@
1
+ export { t as Assertion, n as Attribution, r as Entity, i as EntityKey, a as EntityKind, o as EntityTerm, s as Fact, c as FactId, u as Factuality, d as FactualityValue, f as GraphIri, p as GraphStatus, m as Illocution, h as IllocutionaryForce, g as LiteralTerm, _ as PredicateEntry, v as SourceUri, y as Term, b as currentFacts, x as decode, S as factText, C as graphOf, w as graphStatus, T as make, E as makeMany, D as termText, O as termValue } from "./chunk-Fact.mjs";
@@ -0,0 +1 @@
1
+ export { n as NAMESPACE, r as decodeBlock, i as encodeBlock, a as feedId } from "./chunk-FactFeed.mjs";
@@ -0,0 +1 @@
1
+ export { t as EXPORT_PREFIXES, r as PREFIXES, i as assign, a as mintedPredicates, o as ontologyToTriG, s as toTriG } from "./chunk-Graph.mjs";
@@ -0,0 +1 @@
1
+ export { n as text } from "./chunk-Hash.mjs";
@@ -0,0 +1 @@
1
+ export { t as KIND_CLASSES, r as classIri, i as factToTriples, a as idInGraph, o as isKindQuad, s as predicateOf, c as triplesToFacts } from "./chunk-Mapping.mjs";
@@ -0,0 +1 @@
1
+ export { t as MemoryError } from "./chunk-MemoryError.mjs";
@@ -0,0 +1 @@
1
+ export { t as Any, n as Cursor, r as FactQuery, i as Facts, a as Graphs, s as Predicates, c as Sparql, l as SparqlRow, u as SparqlTerm, d as cursor, f as facts, p as graphs, m as predicates, h as resultOf, g as resultSchema, _ as results, v as sparql } from "./chunk-MemoryQuery.mjs";
@@ -0,0 +1 @@
1
+ export { t as MemoryService, r as PutOptions, i as ReadCursor, a as key } from "./chunk-MemoryService.mjs";
@@ -0,0 +1 @@
1
+ export { t as DEFAULT, n as DEFAULT_ENTRIES, r as Ontology, a as entry, o as fromQuads, s as iriFor, c as key, l as labelFromIri, u as make, d as nameFor, f as ontologyQuads, p as toQuads } from "./chunk-Ontology.mjs";
@@ -0,0 +1 @@
1
+ export { t as GRAPH, n as ModelUsage, i as SPARQL, a as STATE, o as Source, s as Stage, c as State, l as fromValues, u as toQuads, d as toTrig } from "./chunk-Pipeline.mjs";
@@ -0,0 +1 @@
1
+ export { n as label, r as normalize } from "./chunk-Predicate.mjs";
@@ -0,0 +1 @@
1
+ export { t as RDF_DIR_LANG_STRING, n as RDF_LANG_STRING, r as RDF_TYPE, a as XSD_STRING, o as blankNode, s as defaultGraph, c as literal, l as namedNode, u as quad, d as variable } from "./chunk-Rdf.mjs";
@@ -0,0 +1 @@
1
+ export { t as Batch, n as Clear, r as Delete, i as Format, a as ImportResult, o as Insert, s as Quad, c as RdfStore, l as RdfStoreError, d as Write } from "./chunk-RdfStore.mjs";
@@ -0,0 +1 @@
1
+ export { t as DESCRIBED_PREDICATES_SPARQL, n as ONTOLOGY_SPARQL, r as SEED_MARKER_SPARQL, i as STORED_PREDICATES_SPARQL, o as boundGraphs, s as candidateGraphs, c as deleteSeedSparql, l as graphQuadsSparql, u as graphValues, d as matchingPredicates, f as predicateLabels, p as rowsToQuads, m as statementMatches, h as toQuad, g as toTerm } from "./chunk-Sparql.mjs";
@@ -0,0 +1 @@
1
+ export { t as MAX_SUBSCRIPTIONS, n as MemoryEvent, r as MemoryEventId, i as Subscription, a as SubscriptionId } from "./chunk-Subscription.mjs";
@@ -0,0 +1 @@
1
+ export { n as write } from "./chunk-Trig.mjs";
@@ -0,0 +1 @@
1
+ export { t as BRAIN, n as DCTERMS, r as DCTERMS_CREATED, i as DCTERMS_CREATOR, a as DCTERMS_IS_REPLACED_BY, o as DX, s as ENTITY, c as FACT, l as FOAF, u as GRAPH, d as LOCAL_BRAIN, f as ONTOLOGY_GRAPH, p as ORG, m as OWL, h as OWL_DEPRECATED, g as OWL_EQUIVALENT_PROPERTY, _ as OWL_INVERSE_OF, v as OWL_SAME_AS, y as PROV, b as RDF, x as RDFS, S as RDFS_COMMENT, C as RDFS_DOMAIN, w as RDFS_IS_DEFINED_BY, T as RDFS_LABEL, E as RDFS_RANGE, D as RDF_PROPERTY, O as RDF_TYPE, k as SCHEMA, A as SIOC, j as SKOS, M as SKOS_ALT_LABEL, N as SKOS_EXAMPLE, P as SX, F as SX_GRAPH, I as SX_SEED, L as SX_SHORTHAND, z as XSD, B as brainNamespace, V as brainNamespaceOf, H as dx, U as entityIdFromIri, W as entityIri, G as entityKey, K as entityNode, q as factIdFromIri, J as factIri, Y as graphIri, X as isIri, Z as localEntityId, Q as localEntityIri, $ as localEntitySuffix, et as prov, tt as str, nt as sx } from "./chunk-Vocab.mjs";
@@ -0,0 +1 @@
1
+ export { t as ALL, n as DCTERMS, r as DEFAULT, i as FOAF, a as ORG, o as SCHEMA, s as SIOC, l as compose, u as get, d as parse } from "./chunk-Vocabularies.mjs";
@@ -0,0 +1,245 @@
1
+ import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
2
+ import * as Schema from "effect/Schema";
3
+ //#region src/Fact.ts
4
+ var Fact_exports = /* @__PURE__ */ __exportAll({
5
+ Assertion: () => Assertion,
6
+ Attribution: () => Attribution,
7
+ Entity: () => Entity,
8
+ EntityKey: () => EntityKey,
9
+ EntityKind: () => EntityKind,
10
+ EntityTerm: () => EntityTerm,
11
+ Fact: () => Fact,
12
+ FactId: () => FactId,
13
+ Factuality: () => Factuality,
14
+ FactualityValue: () => FactualityValue,
15
+ GraphIri: () => GraphIri,
16
+ GraphStatus: () => GraphStatus,
17
+ Illocution: () => Illocution,
18
+ IllocutionaryForce: () => IllocutionaryForce,
19
+ LiteralTerm: () => LiteralTerm,
20
+ PredicateEntry: () => PredicateEntry,
21
+ SourceUri: () => SourceUri,
22
+ Term: () => Term,
23
+ currentFacts: () => currentFacts,
24
+ decode: () => decode,
25
+ factText: () => factText,
26
+ graphOf: () => graphOf,
27
+ graphStatus: () => graphStatus,
28
+ make: () => make,
29
+ makeMany: () => makeMany,
30
+ termText: () => termText,
31
+ termValue: () => termValue
32
+ });
33
+ /** A statement's id, derived from its graph and the statement. */
34
+ var FactId = Schema.String.pipe(Schema.brand("@dxos/echo-memory/FactId"));
35
+ /** The IRI of a named graph. */
36
+ var GraphIri = Schema.String.pipe(Schema.brand("@dxos/echo-memory/GraphIri"));
37
+ /** An entity: an absolute IRI where one is known (`echo://…`, `did:…`, `mailto:…`, a URL), else a normalized slug. */
38
+ var EntityKey = Schema.String.pipe(Schema.brand("@dxos/echo-memory/EntityKey"));
39
+ /** The item facts were read from, or a source read into facts: a DXN or another URI. */
40
+ var SourceUri = Schema.String.pipe(Schema.brand("@dxos/echo-memory/SourceUri"));
41
+ var EntityKind = Schema.Literals([
42
+ "person",
43
+ "org",
44
+ "place",
45
+ "event",
46
+ "concept",
47
+ "thing"
48
+ ]);
49
+ /** A reference to an entity: `entity` is its key, `label` the surface form kept for display. */
50
+ var EntityTerm = Schema.Struct({
51
+ kind: Schema.Literal("entity"),
52
+ entity: EntityKey,
53
+ label: Schema.optional(Schema.String),
54
+ /** What sort of thing the extractor took it for. */
55
+ type: Schema.optional(EntityKind)
56
+ });
57
+ /** A literal value. */
58
+ var LiteralTerm = Schema.Struct({
59
+ kind: Schema.Literal("literal"),
60
+ literal: Schema.String
61
+ });
62
+ /** A subject or object: an entity reference or a literal, tagged by `kind`. */
63
+ var Term = Schema.Union([EntityTerm, LiteralTerm]);
64
+ /** A resolved entity. */
65
+ var Entity = Schema.Struct({
66
+ id: EntityKey,
67
+ kind: EntityKind,
68
+ label: Schema.String,
69
+ aliases: Schema.Array(Schema.String),
70
+ /** DXN of a canonical ECHO object, once resolved. */
71
+ ref: Schema.optional(Schema.String)
72
+ });
73
+ /** The proposition: subject, predicate, object, and when it holds in the world. */
74
+ var Assertion = Schema.Struct({
75
+ subject: Term,
76
+ /** The predicate's label: the surface form, or the ontology's label once stored. */
77
+ predicate: Schema.String,
78
+ /** The predicate's IRI; resolved from `predicate` through the ontology when absent. */
79
+ predicateIri: Schema.optional(Schema.String),
80
+ /** What a minted predicate means, as its extractor defined it. */
81
+ predicateDescription: Schema.optional(Schema.String),
82
+ object: Term,
83
+ /** ISO date from which the asserted state holds. */
84
+ validFrom: Schema.optional(Schema.String),
85
+ /** ISO date until which the asserted state holds. */
86
+ validTo: Schema.optional(Schema.String),
87
+ /** The source text it was read from. */
88
+ quote: Schema.optional(Schema.String)
89
+ });
90
+ /** FactBank values: a degree (CT certain, PR probable, PS possible) with a polarity, plus CTu and Uu (uncommitted). */
91
+ var FactualityValue = Schema.Literals([
92
+ "CT+",
93
+ "CT-",
94
+ "PR+",
95
+ "PR-",
96
+ "PS+",
97
+ "PS-",
98
+ "CTu",
99
+ "Uu"
100
+ ]);
101
+ /** The speaker's epistemic commitment to the proposition. */
102
+ var Factuality = Schema.Struct({
103
+ value: FactualityValue,
104
+ polarity: Schema.Literals([
105
+ "+",
106
+ "-",
107
+ "?"
108
+ ]),
109
+ /** The extractor's confidence in its reading, 0..1. */
110
+ confidence: Schema.optional(Schema.Number.pipe(Schema.check(Schema.isBetween({
111
+ minimum: 0,
112
+ maximum: 1
113
+ })))),
114
+ nature: Schema.optional(Schema.Literals(["epistemic", "aleatory"]))
115
+ });
116
+ /** Searle's illocutionary forces, minus `declarative`. */
117
+ var IllocutionaryForce = Schema.Literals([
118
+ "assertive",
119
+ "directive",
120
+ "commissive",
121
+ "expressive"
122
+ ]);
123
+ /** The speech act the source performed; `mood` tells a question from a request. */
124
+ var Illocution = Schema.Struct({
125
+ force: IllocutionaryForce,
126
+ mood: Schema.optional(Schema.Literals([
127
+ "declarative",
128
+ "interrogative",
129
+ "imperative"
130
+ ])),
131
+ /** Who is asked to act or answer; the message's recipient when absent. */
132
+ addressee: Schema.optional(Schema.String)
133
+ });
134
+ /** PROV-O-named provenance. */
135
+ var Attribution = Schema.Struct({
136
+ /** Who said it. */
137
+ agent: Schema.optional(EntityKey),
138
+ /** The speaker's display name; `agent` stays the join key. */
139
+ agentLabel: Schema.optional(Schema.String),
140
+ source: SourceUri,
141
+ /** When it was said (ISO). */
142
+ generatedAtTime: Schema.String,
143
+ wasDerivedFrom: Schema.optional(Schema.Array(Schema.String)),
144
+ span: Schema.optional(Schema.Struct({
145
+ start: Schema.Number,
146
+ end: Schema.Number
147
+ }))
148
+ });
149
+ /**
150
+ * One statement and what is known about it. Statements that share their provenance live in one named graph
151
+ * (`graph`), which carries that provenance once; a fact without a graph is the only statement of its own.
152
+ */
153
+ var Fact = Schema.Struct({
154
+ id: FactId,
155
+ graph: Schema.optional(GraphIri),
156
+ assertion: Assertion,
157
+ factuality: Factuality,
158
+ /** Absent ⇒ assertive. */
159
+ illocution: Schema.optional(Illocution),
160
+ attribution: Attribution,
161
+ /** When memory stored it (ISO transaction time). */
162
+ recordedAt: Schema.String,
163
+ extractor: Schema.Struct({
164
+ id: Schema.String,
165
+ model: Schema.String,
166
+ version: Schema.String
167
+ }),
168
+ /** Hash of the source content read, so a changed source is read again. */
169
+ sourceHash: Schema.String,
170
+ /** Extraction pass id, grouping the facts one run produced. */
171
+ pass: Schema.optional(Schema.String),
172
+ /** What sort of free-text memory the graph records (`preference`, `commitment`); absent for a fact. */
173
+ kind: Schema.optional(Schema.String),
174
+ /** Whether the speaker said it (`stated`) or the agent concluded it (`inferred`). */
175
+ origin: Schema.optional(Schema.String),
176
+ /** The graphs this one replaces. */
177
+ supersedes: Schema.optional(Schema.Array(GraphIri)),
178
+ /** The graphs this one withdraws. */
179
+ retracts: Schema.optional(Schema.Array(GraphIri))
180
+ });
181
+ /** Builds a fact from its plain form, applying the id brands; throws on a malformed fact. */
182
+ var make = Schema.decodeSync(Fact);
183
+ /** {@link make} over a list, so a literal list of facts is still checked against {@link Encoded}. */
184
+ var makeMany = (facts) => facts.map((fact) => make(fact));
185
+ /** Decodes facts from their JSON form, applying the id brands; throws on a malformed fact. */
186
+ var decode = Schema.decodeUnknownSync(Schema.Array(Fact));
187
+ /** A predicate a memory knows, as its ontology graph describes it (RDFS / OWL / SKOS). */
188
+ var PredicateEntry = Schema.Struct({
189
+ iri: Schema.String,
190
+ /** Lowercase shorthand rules use, e.g. `works_on`. */
191
+ name: Schema.String,
192
+ label: Schema.String,
193
+ synonyms: Schema.optional(Schema.Array(Schema.String)),
194
+ description: Schema.optional(Schema.String),
195
+ domain: Schema.optional(Schema.String),
196
+ range: Schema.optional(Schema.String),
197
+ inverse: Schema.optional(Schema.String),
198
+ equivalents: Schema.optional(Schema.Array(Schema.String)),
199
+ definedBy: Schema.optional(Schema.String),
200
+ created: Schema.optional(Schema.String),
201
+ creator: Schema.optional(Schema.String),
202
+ example: Schema.optional(Schema.String),
203
+ replacedBy: Schema.optional(Schema.String)
204
+ });
205
+ /** Prefix of the IRI a fact with no graph of its own is stored under. */
206
+ var FACT_IRI_PREFIX = "https://dxos.org/semantic/fact/";
207
+ /** The graph a fact's statement lives in: its own graph, else the graph of the fact alone. */
208
+ var graphOf = (fact) => fact.graph ?? GraphIri.make(FACT_IRI_PREFIX + encodeURIComponent(fact.id));
209
+ /** Whether a graph still holds: another graph can replace it (`supersedes`) or withdraw it (`retracts`). */
210
+ var GraphStatus = Schema.Literals([
211
+ "active",
212
+ "superseded",
213
+ "retracted"
214
+ ]);
215
+ /** The status of every graph the facts mention, by graph IRI. */
216
+ var graphStatus = (facts) => {
217
+ const statuses = new Map(facts.map((fact) => [graphOf(fact), "active"]));
218
+ for (const fact of facts) for (const superseded of fact.supersedes ?? []) if (statuses.get(superseded) !== "retracted") statuses.set(superseded, "superseded");
219
+ for (const fact of facts) for (const retracted of fact.retracts ?? []) statuses.set(retracted, "retracted");
220
+ return statuses;
221
+ };
222
+ /**
223
+ * The facts that still hold at `now` (ISO): none in a superseded or retracted graph, none past its `validTo`, and
224
+ * none in a graph with a `kind`, which records a free-text memory rather than a fact.
225
+ */
226
+ var currentFacts = (facts, now) => {
227
+ const statuses = graphStatus(facts);
228
+ const at = Date.parse(now);
229
+ return facts.filter((fact) => fact.kind === void 0 && statuses.get(graphOf(fact)) === "active" && holdsAt(fact.assertion.validTo, at));
230
+ };
231
+ /** Compared as instants, since extracted `validTo`s vary in offset and precision; one that does not parse is kept. */
232
+ var holdsAt = (validTo, now) => {
233
+ const until = validTo === void 0 ? NaN : Date.parse(validTo);
234
+ return Number.isNaN(until) || until > now;
235
+ };
236
+ /** The value a term contributes as a join key: the entity key, else the literal. */
237
+ var termValue = (term) => term.kind === "entity" ? term.entity : term.literal;
238
+ /** The text of a term, for display. */
239
+ var termText = (term) => term.kind === "entity" ? term.label ?? term.entity : term.literal;
240
+ /** A fact as one line: subject, predicate, object; a negated fact is marked "not:". */
241
+ var factText = (fact) => `${fact.factuality.polarity === "-" ? "not: " : ""}${termText(fact.assertion.subject)} ${fact.assertion.predicate} ${termText(fact.assertion.object)}`;
242
+ //#endregion
243
+ export { graphOf as C, termText as D, makeMany as E, termValue as O, factText as S, make as T, PredicateEntry as _, EntityKind as a, currentFacts as b, FactId as c, FactualityValue as d, GraphIri as f, LiteralTerm as g, IllocutionaryForce as h, EntityKey as i, Fact_exports as l, Illocution as m, Attribution as n, EntityTerm as o, GraphStatus as p, Entity as r, Fact as s, Assertion as t, Factuality as u, SourceUri as v, graphStatus as w, decode as x, Term as y };
244
+
245
+ //# sourceMappingURL=chunk-Fact.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-Fact.mjs","names":[],"sources":["../../src/Fact.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\n//\n// Identifiers. Branded so one kind of id cannot be passed for another; the encoded form stays a plain string, so\n// facts stored before the brands existed still decode.\n//\n\n/** A statement's id, derived from its graph and the statement. */\nexport const FactId = Schema.String.pipe(Schema.brand('@dxos/echo-memory/FactId'));\nexport type FactId = Schema.Schema.Type<typeof FactId>;\n\n/** The IRI of a named graph. */\nexport const GraphIri = Schema.String.pipe(Schema.brand('@dxos/echo-memory/GraphIri'));\nexport type GraphIri = Schema.Schema.Type<typeof GraphIri>;\n\n/** An entity: an absolute IRI where one is known (`echo://…`, `did:…`, `mailto:…`, a URL), else a normalized slug. */\nexport const EntityKey = Schema.String.pipe(Schema.brand('@dxos/echo-memory/EntityKey'));\nexport type EntityKey = Schema.Schema.Type<typeof EntityKey>;\n\n/** The item facts were read from, or a source read into facts: a DXN or another URI. */\nexport const SourceUri = Schema.String.pipe(Schema.brand('@dxos/echo-memory/SourceUri'));\nexport type SourceUri = Schema.Schema.Type<typeof SourceUri>;\n\n//\n// Terms.\n//\n\nexport const EntityKind = Schema.Literals(['person', 'org', 'place', 'event', 'concept', 'thing']);\nexport type EntityKind = Schema.Schema.Type<typeof EntityKind>;\n\n/** A reference to an entity: `entity` is its key, `label` the surface form kept for display. */\nexport const EntityTerm = Schema.Struct({\n kind: Schema.Literal('entity'),\n entity: EntityKey,\n label: Schema.optional(Schema.String),\n /** What sort of thing the extractor took it for. */\n type: Schema.optional(EntityKind),\n});\nexport interface EntityTerm extends Schema.Schema.Type<typeof EntityTerm> {}\n\n/** A literal value. */\nexport const LiteralTerm = Schema.Struct({\n kind: Schema.Literal('literal'),\n literal: Schema.String,\n});\nexport interface LiteralTerm extends Schema.Schema.Type<typeof LiteralTerm> {}\n\n/** A subject or object: an entity reference or a literal, tagged by `kind`. */\nexport const Term = Schema.Union([EntityTerm, LiteralTerm]);\nexport type Term = Schema.Schema.Type<typeof Term>;\n\n/** A resolved entity. */\nexport const Entity = Schema.Struct({\n id: EntityKey,\n kind: EntityKind,\n label: Schema.String,\n aliases: Schema.Array(Schema.String),\n /** DXN of a canonical ECHO object, once resolved. */\n ref: Schema.optional(Schema.String),\n});\nexport interface Entity extends Schema.Schema.Type<typeof Entity> {}\n\n//\n// The parts of a fact.\n//\n\n/** The proposition: subject, predicate, object, and when it holds in the world. */\nexport const Assertion = Schema.Struct({\n subject: Term,\n /** The predicate's label: the surface form, or the ontology's label once stored. */\n predicate: Schema.String,\n /** The predicate's IRI; resolved from `predicate` through the ontology when absent. */\n predicateIri: Schema.optional(Schema.String),\n /** What a minted predicate means, as its extractor defined it. */\n predicateDescription: Schema.optional(Schema.String),\n object: Term,\n /** ISO date from which the asserted state holds. */\n validFrom: Schema.optional(Schema.String),\n /** ISO date until which the asserted state holds. */\n validTo: Schema.optional(Schema.String),\n /** The source text it was read from. */\n quote: Schema.optional(Schema.String),\n});\nexport interface Assertion extends Schema.Schema.Type<typeof Assertion> {}\n\n/** FactBank values: a degree (CT certain, PR probable, PS possible) with a polarity, plus CTu and Uu (uncommitted). */\nexport const FactualityValue = Schema.Literals(['CT+', 'CT-', 'PR+', 'PR-', 'PS+', 'PS-', 'CTu', 'Uu']);\nexport type FactualityValue = Schema.Schema.Type<typeof FactualityValue>;\n\n/** The speaker's epistemic commitment to the proposition. */\nexport const Factuality = Schema.Struct({\n value: FactualityValue,\n polarity: Schema.Literals(['+', '-', '?']),\n /** The extractor's confidence in its reading, 0..1. */\n confidence: Schema.optional(Schema.Number.pipe(Schema.check(Schema.isBetween({ minimum: 0, maximum: 1 })))),\n nature: Schema.optional(Schema.Literals(['epistemic', 'aleatory'])),\n});\nexport interface Factuality extends Schema.Schema.Type<typeof Factuality> {}\n\n/** Searle's illocutionary forces, minus `declarative`. */\nexport const IllocutionaryForce = Schema.Literals(['assertive', 'directive', 'commissive', 'expressive']);\nexport type IllocutionaryForce = Schema.Schema.Type<typeof IllocutionaryForce>;\n\n/** The speech act the source performed; `mood` tells a question from a request. */\nexport const Illocution = Schema.Struct({\n force: IllocutionaryForce,\n mood: Schema.optional(Schema.Literals(['declarative', 'interrogative', 'imperative'])),\n /** Who is asked to act or answer; the message's recipient when absent. */\n addressee: Schema.optional(Schema.String),\n});\nexport interface Illocution extends Schema.Schema.Type<typeof Illocution> {}\n\n/** PROV-O-named provenance. */\nexport const Attribution = Schema.Struct({\n /** Who said it. */\n agent: Schema.optional(EntityKey),\n /** The speaker's display name; `agent` stays the join key. */\n agentLabel: Schema.optional(Schema.String),\n source: SourceUri,\n /** When it was said (ISO). */\n generatedAtTime: Schema.String,\n wasDerivedFrom: Schema.optional(Schema.Array(Schema.String)),\n span: Schema.optional(Schema.Struct({ start: Schema.Number, end: Schema.Number })),\n});\nexport interface Attribution extends Schema.Schema.Type<typeof Attribution> {}\n\n//\n// Fact.\n//\n\n/**\n * One statement and what is known about it. Statements that share their provenance live in one named graph\n * (`graph`), which carries that provenance once; a fact without a graph is the only statement of its own.\n */\nexport const Fact = Schema.Struct({\n id: FactId,\n graph: Schema.optional(GraphIri),\n assertion: Assertion,\n factuality: Factuality,\n /** Absent ⇒ assertive. */\n illocution: Schema.optional(Illocution),\n attribution: Attribution,\n /** When memory stored it (ISO transaction time). */\n recordedAt: Schema.String,\n extractor: Schema.Struct({ id: Schema.String, model: Schema.String, version: Schema.String }),\n /** Hash of the source content read, so a changed source is read again. */\n sourceHash: Schema.String,\n /** Extraction pass id, grouping the facts one run produced. */\n pass: Schema.optional(Schema.String),\n /** What sort of free-text memory the graph records (`preference`, `commitment`); absent for a fact. */\n kind: Schema.optional(Schema.String),\n /** Whether the speaker said it (`stated`) or the agent concluded it (`inferred`). */\n origin: Schema.optional(Schema.String),\n /** The graphs this one replaces. */\n supersedes: Schema.optional(Schema.Array(GraphIri)),\n /** The graphs this one withdraws. */\n retracts: Schema.optional(Schema.Array(GraphIri)),\n});\nexport interface Fact extends Schema.Schema.Type<typeof Fact> {}\n\n/** A fact before the id brands are applied: every id a plain string, as stored and as written by hand. */\nexport type Encoded = Schema.Codec.Encoded<typeof Fact>;\n\n/** A term before the id brands are applied, as a hand-built fact's {@link Encoded} assertion holds it. */\nexport type EncodedTerm = Schema.Codec.Encoded<typeof Term>;\n\n/** An entity term before the id brands are applied. */\nexport type EncodedEntityTerm = Schema.Codec.Encoded<typeof EntityTerm>;\n\n/** Builds a fact from its plain form, applying the id brands; throws on a malformed fact. */\nexport const make: (fact: Encoded) => Fact = Schema.decodeSync(Fact);\n\n/** {@link make} over a list, so a literal list of facts is still checked against {@link Encoded}. */\nexport const makeMany = (facts: readonly Encoded[]): Fact[] => facts.map((fact) => make(fact));\n\n/** Decodes facts from their JSON form, applying the id brands; throws on a malformed fact. */\nexport const decode = Schema.decodeUnknownSync(Schema.Array(Fact));\n\n//\n// Ontology.\n//\n\n/** A predicate a memory knows, as its ontology graph describes it (RDFS / OWL / SKOS). */\nexport const PredicateEntry = Schema.Struct({\n iri: Schema.String,\n /** Lowercase shorthand rules use, e.g. `works_on`. */\n name: Schema.String,\n label: Schema.String,\n synonyms: Schema.optional(Schema.Array(Schema.String)),\n description: Schema.optional(Schema.String),\n domain: Schema.optional(Schema.String),\n range: Schema.optional(Schema.String),\n inverse: Schema.optional(Schema.String),\n equivalents: Schema.optional(Schema.Array(Schema.String)),\n definedBy: Schema.optional(Schema.String),\n created: Schema.optional(Schema.String),\n creator: Schema.optional(Schema.String),\n example: Schema.optional(Schema.String),\n replacedBy: Schema.optional(Schema.String),\n});\nexport interface PredicateEntry extends Schema.Schema.Type<typeof PredicateEntry> {}\n\n//\n// Reading facts without a store.\n//\n\n/** Prefix of the IRI a fact with no graph of its own is stored under. */\nconst FACT_IRI_PREFIX = 'https://dxos.org/semantic/fact/';\n\n/** The graph a fact's statement lives in: its own graph, else the graph of the fact alone. */\nexport const graphOf = (fact: Fact): GraphIri =>\n fact.graph ?? GraphIri.make(FACT_IRI_PREFIX + encodeURIComponent(fact.id));\n\n/** Whether a graph still holds: another graph can replace it (`supersedes`) or withdraw it (`retracts`). */\nexport const GraphStatus = Schema.Literals(['active', 'superseded', 'retracted']);\nexport type GraphStatus = Schema.Schema.Type<typeof GraphStatus>;\n\n/** The status of every graph the facts mention, by graph IRI. */\nexport const graphStatus = (facts: readonly Fact[]): Map<GraphIri, GraphStatus> => {\n const statuses = new Map<GraphIri, GraphStatus>(facts.map((fact) => [graphOf(fact), 'active']));\n for (const fact of facts) {\n for (const superseded of fact.supersedes ?? []) {\n if (statuses.get(superseded) !== 'retracted') {\n statuses.set(superseded, 'superseded');\n }\n }\n }\n for (const fact of facts) {\n for (const retracted of fact.retracts ?? []) {\n statuses.set(retracted, 'retracted');\n }\n }\n return statuses;\n};\n\n/**\n * The facts that still hold at `now` (ISO): none in a superseded or retracted graph, none past its `validTo`, and\n * none in a graph with a `kind`, which records a free-text memory rather than a fact.\n */\nexport const currentFacts = (facts: readonly Fact[], now: string): Fact[] => {\n const statuses = graphStatus(facts);\n const at = Date.parse(now);\n return facts.filter(\n (fact) =>\n fact.kind === undefined && statuses.get(graphOf(fact)) === 'active' && holdsAt(fact.assertion.validTo, at),\n );\n};\n\n/** Compared as instants, since extracted `validTo`s vary in offset and precision; one that does not parse is kept. */\nconst holdsAt = (validTo: string | undefined, now: number): boolean => {\n const until = validTo === undefined ? Number.NaN : Date.parse(validTo);\n return Number.isNaN(until) || until > now;\n};\n\n/** The value a term contributes as a join key: the entity key, else the literal. */\nexport const termValue = (term: Term): string => (term.kind === 'entity' ? term.entity : term.literal);\n\n/** The text of a term, for display. */\nexport const termText = (term: Term): string => (term.kind === 'entity' ? (term.label ?? term.entity) : term.literal);\n\n/** A fact as one line: subject, predicate, object; a negated fact is marked \"not:\". */\nexport const factText = (fact: Fact): string =>\n `${fact.factuality.polarity === '-' ? 'not: ' : ''}${termText(fact.assertion.subject)} ${fact.assertion.predicate} ${termText(fact.assertion.object)}`;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,IAAa,SAAS,OAAO,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAC;;AAIjF,IAAa,WAAW,OAAO,OAAO,KAAK,OAAO,MAAM,4BAA4B,CAAC;;AAIrF,IAAa,YAAY,OAAO,OAAO,KAAK,OAAO,MAAM,6BAA6B,CAAC;;AAIvF,IAAa,YAAY,OAAO,OAAO,KAAK,OAAO,MAAM,6BAA6B,CAAC;AAOvF,IAAa,aAAa,OAAO,SAAS;CAAC;CAAU;CAAO;CAAS;CAAS;CAAW;AAAO,CAAC;;AAIjG,IAAa,aAAa,OAAO,OAAO;CACtC,MAAM,OAAO,QAAQ,QAAQ;CAC7B,QAAQ;CACR,OAAO,OAAO,SAAS,OAAO,MAAM;;CAEpC,MAAM,OAAO,SAAS,UAAU;AAClC,CAAC;;AAID,IAAa,cAAc,OAAO,OAAO;CACvC,MAAM,OAAO,QAAQ,SAAS;CAC9B,SAAS,OAAO;AAClB,CAAC;;AAID,IAAa,OAAO,OAAO,MAAM,CAAC,YAAY,WAAW,CAAC;;AAI1D,IAAa,SAAS,OAAO,OAAO;CAClC,IAAI;CACJ,MAAM;CACN,OAAO,OAAO;CACd,SAAS,OAAO,MAAM,OAAO,MAAM;;CAEnC,KAAK,OAAO,SAAS,OAAO,MAAM;AACpC,CAAC;;AAQD,IAAa,YAAY,OAAO,OAAO;CACrC,SAAS;;CAET,WAAW,OAAO;;CAElB,cAAc,OAAO,SAAS,OAAO,MAAM;;CAE3C,sBAAsB,OAAO,SAAS,OAAO,MAAM;CACnD,QAAQ;;CAER,WAAW,OAAO,SAAS,OAAO,MAAM;;CAExC,SAAS,OAAO,SAAS,OAAO,MAAM;;CAEtC,OAAO,OAAO,SAAS,OAAO,MAAM;AACtC,CAAC;;AAID,IAAa,kBAAkB,OAAO,SAAS;CAAC;CAAO;CAAO;CAAO;CAAO;CAAO;CAAO;CAAO;AAAI,CAAC;;AAItG,IAAa,aAAa,OAAO,OAAO;CACtC,OAAO;CACP,UAAU,OAAO,SAAS;EAAC;EAAK;EAAK;CAAG,CAAC;;CAEzC,YAAY,OAAO,SAAS,OAAO,OAAO,KAAK,OAAO,MAAM,OAAO,UAAU;EAAE,SAAS;EAAG,SAAS;CAAE,CAAC,CAAC,CAAC,CAAC;CAC1G,QAAQ,OAAO,SAAS,OAAO,SAAS,CAAC,aAAa,UAAU,CAAC,CAAC;AACpE,CAAC;;AAID,IAAa,qBAAqB,OAAO,SAAS;CAAC;CAAa;CAAa;CAAc;AAAY,CAAC;;AAIxG,IAAa,aAAa,OAAO,OAAO;CACtC,OAAO;CACP,MAAM,OAAO,SAAS,OAAO,SAAS;EAAC;EAAe;EAAiB;CAAY,CAAC,CAAC;;CAErF,WAAW,OAAO,SAAS,OAAO,MAAM;AAC1C,CAAC;;AAID,IAAa,cAAc,OAAO,OAAO;;CAEvC,OAAO,OAAO,SAAS,SAAS;;CAEhC,YAAY,OAAO,SAAS,OAAO,MAAM;CACzC,QAAQ;;CAER,iBAAiB,OAAO;CACxB,gBAAgB,OAAO,SAAS,OAAO,MAAM,OAAO,MAAM,CAAC;CAC3D,MAAM,OAAO,SAAS,OAAO,OAAO;EAAE,OAAO,OAAO;EAAQ,KAAK,OAAO;CAAO,CAAC,CAAC;AACnF,CAAC;;;;;AAWD,IAAa,OAAO,OAAO,OAAO;CAChC,IAAI;CACJ,OAAO,OAAO,SAAS,QAAQ;CAC/B,WAAW;CACX,YAAY;;CAEZ,YAAY,OAAO,SAAS,UAAU;CACtC,aAAa;;CAEb,YAAY,OAAO;CACnB,WAAW,OAAO,OAAO;EAAE,IAAI,OAAO;EAAQ,OAAO,OAAO;EAAQ,SAAS,OAAO;CAAO,CAAC;;CAE5F,YAAY,OAAO;;CAEnB,MAAM,OAAO,SAAS,OAAO,MAAM;;CAEnC,MAAM,OAAO,SAAS,OAAO,MAAM;;CAEnC,QAAQ,OAAO,SAAS,OAAO,MAAM;;CAErC,YAAY,OAAO,SAAS,OAAO,MAAM,QAAQ,CAAC;;CAElD,UAAU,OAAO,SAAS,OAAO,MAAM,QAAQ,CAAC;AAClD,CAAC;;AAaD,IAAa,OAAgC,OAAO,WAAW,IAAI;;AAGnE,IAAa,YAAY,UAAsC,MAAM,KAAK,SAAS,KAAK,IAAI,CAAC;;AAG7F,IAAa,SAAS,OAAO,kBAAkB,OAAO,MAAM,IAAI,CAAC;;AAOjE,IAAa,iBAAiB,OAAO,OAAO;CAC1C,KAAK,OAAO;;CAEZ,MAAM,OAAO;CACb,OAAO,OAAO;CACd,UAAU,OAAO,SAAS,OAAO,MAAM,OAAO,MAAM,CAAC;CACrD,aAAa,OAAO,SAAS,OAAO,MAAM;CAC1C,QAAQ,OAAO,SAAS,OAAO,MAAM;CACrC,OAAO,OAAO,SAAS,OAAO,MAAM;CACpC,SAAS,OAAO,SAAS,OAAO,MAAM;CACtC,aAAa,OAAO,SAAS,OAAO,MAAM,OAAO,MAAM,CAAC;CACxD,WAAW,OAAO,SAAS,OAAO,MAAM;CACxC,SAAS,OAAO,SAAS,OAAO,MAAM;CACtC,SAAS,OAAO,SAAS,OAAO,MAAM;CACtC,SAAS,OAAO,SAAS,OAAO,MAAM;CACtC,YAAY,OAAO,SAAS,OAAO,MAAM;AAC3C,CAAC;;AAQD,IAAM,kBAAkB;;AAGxB,IAAa,WAAW,SACtB,KAAK,SAAS,SAAS,KAAK,kBAAkB,mBAAmB,KAAK,EAAE,CAAC;;AAG3E,IAAa,cAAc,OAAO,SAAS;CAAC;CAAU;CAAc;AAAW,CAAC;;AAIhF,IAAa,eAAe,UAAuD;CACjF,MAAM,WAAW,IAAI,IAA2B,MAAM,KAAK,SAAS,CAAC,QAAQ,IAAI,GAAG,QAAQ,CAAC,CAAC;CAC9F,KAAK,MAAM,QAAQ,OACjB,KAAK,MAAM,cAAc,KAAK,cAAc,CAAC,GAC3C,IAAI,SAAS,IAAI,UAAU,MAAM,aAC/B,SAAS,IAAI,YAAY,YAAY;CAI3C,KAAK,MAAM,QAAQ,OACjB,KAAK,MAAM,aAAa,KAAK,YAAY,CAAC,GACxC,SAAS,IAAI,WAAW,WAAW;CAGvC,OAAO;AACT;;;;;AAMA,IAAa,gBAAgB,OAAwB,QAAwB;CAC3E,MAAM,WAAW,YAAY,KAAK;CAClC,MAAM,KAAK,KAAK,MAAM,GAAG;CACzB,OAAO,MAAM,QACV,SACC,KAAK,SAAS,KAAA,KAAa,SAAS,IAAI,QAAQ,IAAI,CAAC,MAAM,YAAY,QAAQ,KAAK,UAAU,SAAS,EAAE,CAC7G;AACF;;AAGA,IAAM,WAAW,SAA6B,QAAyB;CACrE,MAAM,QAAQ,YAAY,KAAA,IAAY,MAAa,KAAK,MAAM,OAAO;CACrE,OAAO,OAAO,MAAM,KAAK,KAAK,QAAQ;AACxC;;AAGA,IAAa,aAAa,SAAwB,KAAK,SAAS,WAAW,KAAK,SAAS,KAAK;;AAG9F,IAAa,YAAY,SAAwB,KAAK,SAAS,WAAY,KAAK,SAAS,KAAK,SAAU,KAAK;;AAG7G,IAAa,YAAY,SACvB,GAAG,KAAK,WAAW,aAAa,MAAM,UAAU,KAAK,SAAS,KAAK,UAAU,OAAO,EAAE,GAAG,KAAK,UAAU,UAAU,GAAG,SAAS,KAAK,UAAU,MAAM"}
@@ -0,0 +1,29 @@
1
+ import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
2
+ import { t as Batch } from "./chunk-RdfStore.mjs";
3
+ import * as Schema from "effect/Schema";
4
+ import { EntityId } from "@dxos/keys";
5
+ //#region src/FactFeed.ts
6
+ var FactFeed_exports = /* @__PURE__ */ __exportAll({
7
+ NAMESPACE: () => NAMESPACE,
8
+ decodeBlock: () => decodeBlock,
9
+ encodeBlock: () => encodeBlock,
10
+ feedId: () => feedId
11
+ });
12
+ /** The feed namespace a space's fact feed lives in (`FeedProtocol.WellKnownNamespaces.facts`). */
13
+ var NAMESPACE = "facts";
14
+ /** Seed of the id of a space's fact feed, which every replica derives the same way so the feed replicates as one. */
15
+ var FEED_SEED = "org.dxos.memory.facts";
16
+ /** The id of a space's fact feed. */
17
+ var feedId = (spaceId) => EntityId.deterministic(FEED_SEED, spaceId);
18
+ var encodeBatch = Schema.encodeSync(Batch);
19
+ var decodeBatch = Schema.decodeUnknownSync(Batch);
20
+ var textEncoder = new TextEncoder();
21
+ var textDecoder = new TextDecoder();
22
+ /** A batch as a block payload: the UTF-8 JSON of the encoded batch. */
23
+ var encodeBlock = (batch) => textEncoder.encode(JSON.stringify(encodeBatch(batch)));
24
+ /** Inverse of {@link encodeBlock}. */
25
+ var decodeBlock = (data) => decodeBatch(JSON.parse(textDecoder.decode(data)));
26
+ //#endregion
27
+ export { feedId as a, encodeBlock as i, NAMESPACE as n, decodeBlock as r, FactFeed_exports as t };
28
+
29
+ //# sourceMappingURL=chunk-FactFeed.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-FactFeed.mjs","names":["RdfStore.Batch"],"sources":["../../src/FactFeed.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport { EntityId, type SpaceId } from '@dxos/keys';\n\nimport * as RdfStore from './RdfStore.ts';\n\n//\n// A space's fact feed: the log a memory's shared part is written to before it is applied, replicated like any feed so\n// every replica of the space's memory (each device's, EDGE's) applies the same batches in the same order. It is the\n// only feed of facts; each block is one `RdfStore.Batch`.\n//\n\n/** The feed namespace a space's fact feed lives in (`FeedProtocol.WellKnownNamespaces.facts`). */\nexport const NAMESPACE = 'facts';\n\n/** Seed of the id of a space's fact feed, which every replica derives the same way so the feed replicates as one. */\nconst FEED_SEED = 'org.dxos.memory.facts';\n\n/** The id of a space's fact feed. */\nexport const feedId = (spaceId: SpaceId): EntityId => EntityId.deterministic(FEED_SEED, spaceId);\n\nconst encodeBatch = Schema.encodeSync(RdfStore.Batch);\nconst decodeBatch = Schema.decodeUnknownSync(RdfStore.Batch);\nconst textEncoder = new TextEncoder();\nconst textDecoder = new TextDecoder();\n\n/** A batch as a block payload: the UTF-8 JSON of the encoded batch. */\nexport const encodeBlock = (batch: RdfStore.Batch): Uint8Array =>\n textEncoder.encode(JSON.stringify(encodeBatch(batch)));\n\n/** Inverse of {@link encodeBlock}. */\nexport const decodeBlock = (data: Uint8Array): RdfStore.Batch => decodeBatch(JSON.parse(textDecoder.decode(data)));\n"],"mappings":";;;;;;;;;;;;AAmBA,IAAa,YAAY;;AAGzB,IAAM,YAAY;;AAGlB,IAAa,UAAU,YAA+B,SAAS,cAAc,WAAW,OAAO;AAE/F,IAAM,cAAc,OAAO,WAAWA,KAAc;AACpD,IAAM,cAAc,OAAO,kBAAkBA,KAAc;AAC3D,IAAM,cAAc,IAAI,YAAY;AACpC,IAAM,cAAc,IAAI,YAAY;;AAGpC,IAAa,eAAe,UAC1B,YAAY,OAAO,KAAK,UAAU,YAAY,KAAK,CAAC,CAAC;;AAGvD,IAAa,eAAe,SAAqC,YAAY,KAAK,MAAM,YAAY,OAAO,IAAI,CAAC,CAAC"}
@@ -0,0 +1,147 @@
1
+ import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
2
+ import { T as make, f as GraphIri } from "./chunk-Fact.mjs";
3
+ import { n as text } from "./chunk-Hash.mjs";
4
+ import { A as SIOC, P as SX, V as brainNamespaceOf, Y as graphIri, b as RDF, c as FACT, j as SKOS, k as SCHEMA, l as FOAF, m as OWL, n as DCTERMS, o as DX, p as ORG, s as ENTITY, t as BRAIN, u as GRAPH, x as RDFS, y as PROV, z as XSD } from "./chunk-Vocab.mjs";
5
+ import { d as nameFor, f as ontologyQuads, t as DEFAULT } from "./chunk-Ontology.mjs";
6
+ import { a as idInGraph, i as factToTriples, s as predicateOf } from "./chunk-Mapping.mjs";
7
+ import { n as write$1 } from "./chunk-Trig.mjs";
8
+ //#region src/Graph.ts
9
+ var Graph_exports = /* @__PURE__ */ __exportAll({
10
+ EXPORT_PREFIXES: () => EXPORT_PREFIXES,
11
+ PREFIXES: () => PREFIXES,
12
+ assign: () => assign,
13
+ mintedPredicates: () => mintedPredicates,
14
+ ontologyToTriG: () => ontologyToTriG,
15
+ toTriG: () => toTriG
16
+ });
17
+ /** Everything a graph states once for all its statements: facts that differ in any of it need separate graphs. */
18
+ var provenanceKey = (fact) => JSON.stringify([
19
+ fact.attribution.source,
20
+ fact.attribution.agent,
21
+ fact.attribution.agentLabel,
22
+ fact.attribution.generatedAtTime,
23
+ fact.attribution.wasDerivedFrom,
24
+ fact.attribution.span,
25
+ fact.assertion.quote,
26
+ fact.assertion.validFrom,
27
+ fact.assertion.validTo,
28
+ fact.factuality,
29
+ fact.illocution,
30
+ fact.recordedAt,
31
+ fact.extractor,
32
+ fact.sourceHash,
33
+ fact.pass,
34
+ fact.kind,
35
+ fact.origin,
36
+ fact.supersedes,
37
+ fact.retracts
38
+ ]);
39
+ /**
40
+ * Puts facts into named graphs: facts that share their provenance (source, speaker, time, quote, factuality,
41
+ * extraction pass, …) share a graph, and a fact that differs in any of it starts another. A fact that already names
42
+ * a graph keeps it. Each fact gets its predicate IRI, and the id it will have once stored; facts come in their plain
43
+ * form, since the ids they will have are only known here.
44
+ */
45
+ var assign = (facts, { name, ontology = DEFAULT } = {}) => facts.map((input) => {
46
+ const fact = make(input);
47
+ const label = name?.(fact) ?? fact.attribution.source;
48
+ const key = provenanceKey(fact);
49
+ const graph = fact.graph ?? GraphIri.make(graphIri(`${text(label)}-${text(key)}${text(`\u0000${key}`)}`).value);
50
+ const placed = {
51
+ ...fact,
52
+ graph,
53
+ assertion: {
54
+ ...fact.assertion,
55
+ predicateIri: predicateOf(fact, ontology)
56
+ }
57
+ };
58
+ return {
59
+ ...placed,
60
+ id: idInGraph(placed, graph, ontology)
61
+ };
62
+ });
63
+ /** Prefixes TriG output abbreviates. */
64
+ var PREFIXES = {
65
+ dx: DX,
66
+ sx: SX,
67
+ prov: PROV,
68
+ rdf: RDF,
69
+ rdfs: RDFS,
70
+ owl: OWL,
71
+ xsd: XSD,
72
+ skos: SKOS,
73
+ dcterms: DCTERMS,
74
+ schema: SCHEMA,
75
+ foaf: FOAF,
76
+ org: ORG,
77
+ entity: ENTITY,
78
+ fact: FACT,
79
+ graph: GRAPH
80
+ };
81
+ /** Prefixes a whole store's TriG export abbreviates: {@link PREFIXES}, the brain namespaces and SIOC. */
82
+ var EXPORT_PREFIXES = {
83
+ ...PREFIXES,
84
+ brain: BRAIN,
85
+ sioc: SIOC
86
+ };
87
+ var write = (quads, prefixes) => {
88
+ const seen = /* @__PURE__ */ new Set();
89
+ const unique = [];
90
+ for (const quad of quads) {
91
+ const key = `${quad.subject.value} ${quad.predicate.value} ${quad.object.termType}:${quad.object.value} ${quad.graph.value}`;
92
+ if (!seen.has(key)) {
93
+ seen.add(key);
94
+ unique.push(quad);
95
+ }
96
+ }
97
+ return write$1(unique, { prefixes });
98
+ };
99
+ /**
100
+ * The facts as TriG: each graph's statements, then its provenance. The brain's namespace reads as `brain:`, and the
101
+ * entities local to each graph as `g1:`, `g2:`, … so a graph-local entity is visibly not a shared one.
102
+ */
103
+ var toTriG = (facts, ontology = DEFAULT) => {
104
+ const quads = facts.flatMap((fact) => factToTriples(fact, ontology));
105
+ const locals = [...new Set(quads.flatMap((quad) => quad.graph.termType === "NamedNode" ? [quad.graph.value] : []))].filter((graph) => graph !== "https://dxos.org/semantic/graph/ontology" && quads.some((quad) => quad.subject.value.startsWith(`${graph}#`) || quad.object.value.startsWith(`${graph}#`)));
106
+ const usesBrain = quads.some((quad) => [
107
+ quad.subject,
108
+ quad.predicate,
109
+ quad.object
110
+ ].some((term) => term.value.startsWith(ontology.namespace)));
111
+ return write(quads, {
112
+ ...PREFIXES,
113
+ ...usesBrain ? { brain: ontology.namespace } : {},
114
+ ...Object.fromEntries(locals.map((graph, index) => [`g${index + 1}`, `${graph}#`]))
115
+ });
116
+ };
117
+ /** The ontology's predicates as TriG: each an `rdf:Property` described in the ontology graph. */
118
+ var ontologyToTriG = (ontology) => write(ontologyQuads(ontology), {
119
+ ...PREFIXES,
120
+ brain: ontology.namespace
121
+ });
122
+ /**
123
+ * The predicates the facts use that the ontology does not define, as entries minted in its namespace, so the next
124
+ * extraction can reuse them; the first quote that used one is kept as its example.
125
+ */
126
+ var mintedPredicates = (facts, ontology = DEFAULT) => {
127
+ const minted = /* @__PURE__ */ new Map();
128
+ for (const fact of facts) {
129
+ const iri = predicateOf(fact, ontology);
130
+ if (ontology.get(iri) || minted.has(iri)) continue;
131
+ minted.set(iri, {
132
+ iri,
133
+ name: nameFor(fact.assertion.predicate),
134
+ label: fact.assertion.predicate,
135
+ ...fact.assertion.predicateDescription ? { description: fact.assertion.predicateDescription } : {},
136
+ ...brainNamespaceOf(iri) ? { definedBy: brainNamespaceOf(iri) } : {},
137
+ created: fact.recordedAt,
138
+ creator: `${fact.extractor.id}/${fact.extractor.model}`,
139
+ ...fact.assertion.quote ? { example: fact.assertion.quote } : {}
140
+ });
141
+ }
142
+ return [...minted.values()];
143
+ };
144
+ //#endregion
145
+ export { mintedPredicates as a, assign as i, Graph_exports as n, ontologyToTriG as o, PREFIXES as r, toTriG as s, EXPORT_PREFIXES as t };
146
+
147
+ //# sourceMappingURL=chunk-Graph.mjs.map