@yaks/kernel 0.0.0-stage → 0.2.36

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 (65) hide show
  1. package/Comments.tsx +300 -0
  2. package/LICENSE +202 -0
  3. package/README.md +332 -2
  4. package/_dist/cites.d.ts +18 -0
  5. package/_dist/cites.d.ts.map +1 -0
  6. package/_dist/comment-host.d.ts +30 -0
  7. package/_dist/comment-host.d.ts.map +1 -0
  8. package/_dist/comments.d.ts +20 -0
  9. package/_dist/comments.d.ts.map +1 -0
  10. package/_dist/graph.d.ts +3 -0
  11. package/_dist/graph.d.ts.map +1 -0
  12. package/_dist/keywords.d.ts +9 -0
  13. package/_dist/keywords.d.ts.map +1 -0
  14. package/_dist/mod.d.ts +26 -0
  15. package/_dist/mod.d.ts.map +1 -0
  16. package/_dist/plugin.d.ts +6 -0
  17. package/_dist/plugin.d.ts.map +1 -0
  18. package/_dist/tools.d.ts +6 -0
  19. package/_dist/tools.d.ts.map +1 -0
  20. package/_dist/views.d.ts +8 -0
  21. package/_dist/views.d.ts.map +1 -0
  22. package/_dist/vocab.d.ts +16 -0
  23. package/_dist/vocab.d.ts.map +1 -0
  24. package/cites.js +61 -0
  25. package/cites.js.map +1 -0
  26. package/cites.ts +63 -0
  27. package/comment-host.js +11 -0
  28. package/comment-host.js.map +1 -0
  29. package/comment-host.ts +35 -0
  30. package/comments.js +51 -0
  31. package/comments.js.map +1 -0
  32. package/comments.ts +59 -0
  33. package/completion.js +33 -0
  34. package/completion.js.map +1 -0
  35. package/completion.ts +33 -0
  36. package/component-views.tsx +34 -0
  37. package/decision.js +17 -0
  38. package/decision.js.map +1 -0
  39. package/decision.ts +14 -0
  40. package/deno.json +1 -0
  41. package/graph.js +7 -0
  42. package/graph.js.map +1 -0
  43. package/graph.ts +8 -0
  44. package/keywords.js +31 -0
  45. package/keywords.js.map +1 -0
  46. package/keywords.ts +29 -0
  47. package/meta/kernel.vocab.json +20 -0
  48. package/mod.js +26 -0
  49. package/mod.js.map +1 -0
  50. package/mod.ts +26 -0
  51. package/package.json +56 -4
  52. package/plugin.js +33 -0
  53. package/plugin.js.map +1 -0
  54. package/plugin.ts +31 -0
  55. package/tools.js +34 -0
  56. package/tools.js.map +1 -0
  57. package/tools.ts +30 -0
  58. package/views.js +29 -0
  59. package/views.js.map +1 -0
  60. package/views.ts +29 -0
  61. package/views.tsx +3 -0
  62. package/vocab.js +34 -0
  63. package/vocab.js.map +1 -0
  64. package/vocab.json +765 -0
  65. package/vocab.ts +34 -0
package/README.md CHANGED
@@ -1,3 +1,333 @@
1
- # Temporary Holding Version
1
+ # @yaks/kernel
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Shared identity, marks and relationship components for graphs of work, with
4
+ vocabulary documents, a completion plugin, citation helpers and a comment tool.
5
+
6
+ The graph fills in a [mark](../vocab/README.md#vocabulary)'s stamped properties.
7
+ Callers supply the mark, not `at`, `by` or `via`.
8
+
9
+ This package uses
10
+ [entities, components, bundles, patches, actors and
11
+ plugins](../graph/README.md#data-model),
12
+ [vocabulary](../vocab/README.md#vocabulary) and [links](../edge/README.md).
13
+
14
+ ## Marks
15
+
16
+ For marks with `at`, `by` and `via`, the graph stamps when the write happened,
17
+ who wrote it and the instrument it came through. The calling application
18
+ supplies the actor. In the CLI composition,
19
+ [@yaks/process](../process/README.md) supplies the process entity for writes
20
+ that did not arrive through an authenticated HTTP or MCP request.
21
+
22
+ | Mark | Meaning |
23
+ | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
24
+ | **`opened`** | Somebody looked at the entity. |
25
+ | **`archived`** | Hidden from ordinary listings, without deleting history or stopping execution. |
26
+ | **`completed`** | The work was finished; removing the mark reopens it. |
27
+ | **`cancelled`** | Called off; records an optional reason. |
28
+ | **`failed`** | The work was tried and given up on; `reason` records why. Removing it permits another attempt. |
29
+ | **`broken`** | Something outside the graph stopped honoring the entity; `code` records the other side's answer. Removing it says the entity holds again. |
30
+ | **`interrupted`** | A request or call was cut off before finishing; `code` records why. Removing it allows a deliberate retry. |
31
+ | **`resolved`** | The problem is over; removing it says the problem is back. A problem can end without a task being completed. |
32
+ | **`verified`** | Somebody checked the entity against its claims and found they hold. Only checking writes this mark. |
33
+ | **`proposed`** | Put forward for a decision. |
34
+ | **`decided`** | A verdict or chosen answer; `verdict` is `approved` or `declined`, and `choice` is a chosen label or custom answer. |
35
+ | **`quarantined`** | Readable but set aside as harmful to act on; applications exclude it from guidance. |
36
+ | **`pending`** | Awaiting the first successful answer or confirmation. |
37
+ | **`admitted`** | A child holds a place under a concurrency bound; removing it gives up the place. |
38
+ | **`waiting`** | A child stepped aside while waiting for its own children; removing it queues the child again. |
39
+
40
+ These declarations record marks; applications implement listing filters,
41
+ concurrency bounds and other behavior associated with them. A status can be
42
+ computed from marks: [@yaks/task](../task/README.md) reads `completed` as done.
43
+ The stamps every write leaves, `created` and `updated`, are
44
+ [@yaks/provenance](../provenance/README.md)'s.
45
+
46
+ A **`favorite`** records that somebody marked the entity as a favorite. It
47
+ declares stamped `at` but has no `by` or `via`, so the graph does not stamp it
48
+ as a mark.
49
+
50
+ ## Use
51
+
52
+ ```ts
53
+ import { kernel, kernelDoc, kernelKeywords } from '@yaks/kernel'
54
+ import { graph } from '@yaks/graph'
55
+ import { ram } from '@yaks/ram'
56
+ import { loadVocab } from '@yaks/vocab'
57
+ import { equal } from '@yaks/testing'
58
+
59
+ let vocab = loadVocab([kernelDoc], [kernelKeywords])
60
+ let g = graph({ vocab, storage: ram(vocab), plugins: [kernel()] })
61
+ await g.apply([{ entity: { eid: 'work' }, completed: {}, favorite: {} }])
62
+ let [work] = await g.read('.completed&*')
63
+ equal(work.entity.eid, 'work')
64
+ equal(typeof work.completed?.at, 'string')
65
+ equal(work.favorite, {})
66
+ ```
67
+
68
+ ## Exports
69
+
70
+ | Import | Exports |
71
+ | -------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
72
+ | `@yaks/kernel` | `kernelDoc`, `spineDoc`, `marksDoc`, `kernelKeywords`, `KERNEL_URI`, `kernel()`, `CITES`, `content()`, `status()`, `verify()`, `Status` |
73
+ | `@yaks/kernel/vocab` | The vocabulary documents, `kernelKeywords`, `docs`, `keywords`, `description` |
74
+ | `@yaks/kernel/graph` | `plugins()`, returning `[kernel()]` |
75
+ | `@yaks/kernel/tools` | `runs()`, returning the `comment_new` implementation |
76
+
77
+ ## Vocabulary documents
78
+
79
+ `kernelDoc` declares all this package's components and its comment tool.
80
+ `spineDoc` selects `entity`; `marksDoc` selects `opened` and `archived`. Load
81
+ the subsets when the other declarations are unnecessary. `docs` contains
82
+ `kernelDoc`, `keywords` contains `kernelKeywords`, and `description` is the
83
+ manifest's summary. The `./vocab` entry point imports no storage or runtime API.
84
+
85
+ ```ts
86
+ import { marksDoc, spineDoc } from '@yaks/kernel/vocab'
87
+ import { graph } from '@yaks/graph'
88
+ import { ram } from '@yaks/ram'
89
+ import { loadVocab } from '@yaks/vocab'
90
+ import { equal } from '@yaks/testing'
91
+
92
+ let vocab = loadVocab([spineDoc, marksDoc])
93
+ let g = graph({ vocab, storage: ram(vocab) })
94
+ await g.apply([{ entity: { eid: 'note' }, opened: {}, archived: {} }])
95
+ let [note] = await g.read('.archived&*')
96
+ equal(note.entity.eid, 'note')
97
+ equal(typeof note.opened?.at, 'string')
98
+ ```
99
+
100
+ The `entity` declaration adds `archetype` to the identity component.
101
+ [@yaks/archetype](../archetype/README.md) maintains it; callers do not write it.
102
+ The component has `wire: false`, excluding it from ordinary component input.
103
+ [@yaks/id](../id/README.md) adds `num`, allocates numbers, formats human ids and
104
+ resolves them.
105
+
106
+ ### Completion
107
+
108
+ `kernel()` preserves `completed.by` across later writes of `completed`. Its
109
+ precondition hook runs before stamping. On the first completion it uses the
110
+ incoming `by`, if supplied by trusted server code, or the batch's actor; on
111
+ later writes it keeps the stored `by`. Removing `completed` permits a subsequent
112
+ completion to name another writer. `plugins()` installs the same plugin.
113
+
114
+ ```ts
115
+ import { kernelDoc } from '@yaks/kernel'
116
+ import { plugins } from '@yaks/kernel/graph'
117
+ import { graph } from '@yaks/graph'
118
+ import { ram } from '@yaks/ram'
119
+ import { loadVocab } from '@yaks/vocab'
120
+ import { equal } from '@yaks/testing'
121
+
122
+ let vocab = loadVocab([kernelDoc])
123
+ let g = graph({ vocab, storage: ram(vocab), plugins: plugins() })
124
+ await g.apply([
125
+ { entity: { eid: 'alice' }, favorite: {} },
126
+ { entity: { eid: 'bob' }, favorite: {} },
127
+ { entity: { eid: 'work' }, completed: {}, $actor: { by: 'alice' } },
128
+ ])
129
+ await g.apply([
130
+ { entity: { eid: 'work' }, completed: {}, $actor: { by: 'bob' } },
131
+ ])
132
+ let [work] = await g.read('.completed&*')
133
+ equal(work.completed?.by, 'alice')
134
+ ```
135
+
136
+ ### Other components and relations
137
+
138
+ A **`comment`** attaches text to an entity through `target`, with optional
139
+ `reply_to` naming the comment it answers. [@yaks/doc](../doc/README.md) owns the
140
+ `doc` component holding the text. A **`image`** records pixel dimensions as `w`
141
+ and `h`. A **`redaction`** records a replaced `title` or `body` property with
142
+ `target`, `prop` and a hash of the replaced content; its properties are stamped
143
+ and must be supplied by trusted server code.
144
+
145
+ The package declares [relations](../edge/README.md) with these component names:
146
+ **`about`** says the source is about the target; **`delegates`** says the source
147
+ handed work to the target; **`reads`** says the source reads the target;
148
+ **`references`** says the source refers to the target; **`supersedes`** says the
149
+ source replaces the target; **`supervises`** says the source oversees the
150
+ target; **`wants`** says the source wants the target; **`worked`** says the
151
+ source worked on the target. The query name is the component name except for
152
+ `references`, whose query name is `referenced`.
153
+
154
+ Add [@yaks/edge](../edge/README.md) for the `edge` component and link behavior.
155
+ Other packages own relations such as [@yaks/task](../task/README.md)'s
156
+ `contains` and `requires` and [@yaks/goal](../goal/README.md)'s `satisfies`.
157
+
158
+ ```ts
159
+ import { kernelDoc } from '@yaks/kernel'
160
+ import { edgeDoc, edgeKeywords } from '@yaks/edge'
161
+ import { graph } from '@yaks/graph'
162
+ import { ram } from '@yaks/ram'
163
+ import { loadVocab } from '@yaks/vocab'
164
+ import { equal } from '@yaks/testing'
165
+
166
+ let vocab = loadVocab([kernelDoc, edgeDoc], [edgeKeywords])
167
+ let g = graph({ vocab, storage: ram(vocab) })
168
+ await g.apply([
169
+ { entity: { eid: 'picture' }, image: { w: 640, h: 480 } },
170
+ { entity: { eid: 'subject' }, favorite: {} },
171
+ {
172
+ entity: { eid: 'relation' },
173
+ edge: { from: 'picture', to: 'subject' },
174
+ about: {},
175
+ },
176
+ ])
177
+ let [relation] = await g.read('.about&*')
178
+ equal(relation.edge?.to, 'subject')
179
+ await g.apply([{
180
+ entity: { eid: 'replacement' },
181
+ redaction: {
182
+ target: 'picture',
183
+ prop: 'body',
184
+ hash: 'digest-of-replaced-text',
185
+ },
186
+ }], { trusted: true })
187
+ let [replacement] = await g.read('.redaction&*')
188
+ equal(replacement.redaction?.prop, 'body')
189
+ ```
190
+
191
+ ## Citations
192
+
193
+ A **citation** is a link carrying `cites`, whose `hash` records the cited
194
+ entity's content when verified. `CITES` is the component name, `'cites'`.
195
+ `content(vocab)` hashes client-written properties in a fixed order, excluding
196
+ server stamps. `verify(cite, target, vocab)` returns a patch containing the hash
197
+ and `verified` mark; it refuses a deleted target. Apply that patch to store it.
198
+
199
+ `status(cite, target, vocab)` returns `current` when the hash matches, `moved`
200
+ when the content changed or the target was deleted, `unverified` without a
201
+ `verified` mark, or `unknown` when a verified citation has no hash.
202
+
203
+ ```ts
204
+ import { content, kernelDoc, status, verify } from '@yaks/kernel'
205
+ import { docDoc } from '@yaks/doc'
206
+ import { edgeDoc, edgeKeywords } from '@yaks/edge'
207
+ import { loadVocab } from '@yaks/vocab'
208
+ import { equal } from '@yaks/testing'
209
+
210
+ let vocab = loadVocab([kernelDoc, docDoc, edgeDoc], [edgeKeywords])
211
+ let target = { entity: { eid: 'note' }, doc: { body: 'oak' } }
212
+ let cite = {
213
+ entity: { eid: 'citation' },
214
+ edge: { from: 'claim', to: 'note' },
215
+ cites: {},
216
+ }
217
+ equal(status(cite, target, vocab), { state: 'unverified' })
218
+ let checked = verify(cite, target, vocab)
219
+ equal(status(checked, target, vocab), { state: 'current' })
220
+ equal(
221
+ content(vocab)({ ...target, updated: { at: '2026-01-01T00:00:00Z' } }),
222
+ content(vocab)(target),
223
+ )
224
+ equal(status(checked, { ...target, doc: { body: 'ash' } }, vocab), {
225
+ state: 'moved',
226
+ })
227
+ equal(status({ ...cite, verified: {} }, target, vocab).state, 'unknown')
228
+ ```
229
+
230
+ [@yaks/git](../git/README.md) answers file and symbol citations from the commit
231
+ and place they name.
232
+
233
+ ## Comment tool
234
+
235
+ `runs()` implements `comment_new`, returning a patch with `doc.body` and
236
+ `comment.target`, plus `comment.reply_to` when supplied. The tool runner applies
237
+ the patch as the caller; the implementation itself writes nothing. Load the
238
+ kernel and doc vocabulary documents before applying its result.
239
+
240
+ ```ts
241
+ import { kernelDoc } from '@yaks/kernel'
242
+ import { runs } from '@yaks/kernel/tools'
243
+ import { docDoc } from '@yaks/doc'
244
+ import { graph } from '@yaks/graph'
245
+ import { loadTools } from '@yaks/graph/tools'
246
+ import { ram } from '@yaks/ram'
247
+ import { loadVocab } from '@yaks/vocab'
248
+ import { equal } from '@yaks/testing'
249
+
250
+ let vocab = loadVocab([kernelDoc, docDoc])
251
+ let g = graph({ vocab, storage: ram(vocab) })
252
+ await g.apply([{ entity: { eid: 'work' }, favorite: {} }])
253
+ let [tool] = loadTools(kernelDoc, runs())
254
+ let patches = await tool.run({
255
+ entity: { eid: 'call' },
256
+ call: { args: { target: 'work', body: 'Looks good.' } },
257
+ }, g)
258
+ await g.apply(patches)
259
+ let [comment] = await g.read('.comment&*')
260
+ equal(comment.comment?.target, 'work')
261
+ equal(comment.doc?.body, 'Looks good.')
262
+ ```
263
+
264
+ ## Kernel keywords
265
+
266
+ The package registers three custom
267
+ [JSON Schema keywords](../vocab/README.md#extension-keywords): **`governed`**
268
+ says a project answers for entities carrying the component; **`lazy`** excludes
269
+ a component from the client's startup snapshot, so readers request it by
270
+ partition; **`well`** names a list of suggested values for a property. This
271
+ package retains these declarations; consumers implement their behavior.
272
+
273
+ Register `kernelKeywords` when loading documents that use these keywords, and
274
+ use `KERNEL_URI` in their `$vocabulary` declaration.
275
+
276
+ ```ts
277
+ import { KERNEL_URI, kernelKeywords } from '@yaks/kernel'
278
+ import { loadVocab } from '@yaks/vocab'
279
+ import { equal } from '@yaks/testing'
280
+
281
+ let vocab = loadVocab([{
282
+ $vocabulary: { 'https://yak.sh/vocab/core': true, [KERNEL_URI]: true },
283
+ $defs: {
284
+ note: {
285
+ component: true,
286
+ type: 'object',
287
+ governed: true,
288
+ lazy: true,
289
+ properties: { state: { type: 'string', well: 'states' } },
290
+ },
291
+ },
292
+ }], [kernelKeywords])
293
+ equal(vocab.comp('note')?.keywords.governed, true)
294
+ equal(vocab.comp('note')?.keywords.lazy, true)
295
+ equal(vocab.prop('note', 'state')?.keywords.well, 'states')
296
+ ```
297
+
298
+ ## Limits
299
+
300
+ The declarations and pure helpers use no platform APIs and work in Deno, Node
301
+ and browsers. This package provides no persistence; choose a
302
+ [storage adapter](../graph/README.md#data-model), such as
303
+ [@yaks/ram](../ram/README.md) for memory. Human ids belong to @yaks/id,
304
+ archetype maintenance to @yaks/archetype, and text to @yaks/doc.
305
+
306
+ ## Comment views
307
+
308
+ `./views` contributes `componentViews()`, an asynchronous accessor for
309
+ `Thread.Note` renderers for comments and commits. Browsers and terminal painters
310
+ load these components; portable text printers leave them deferred.
311
+ `./component-views` exports the component registry directly. `./Comments`
312
+ supplies `Comments`, `Branches`, `Composer` and `Reply`; every branch asks the
313
+ registry to draw its note. The composer uses the kit's `Say`, `Field`, `Button`
314
+ and `Choices`, and keeps words through [drafts](../draft/README.md).
315
+
316
+ An interface binds `configureComments` from `./comment-host` before mounting
317
+ these components. Its **comment host** supplies subscriptions, the page graph,
318
+ registry rendering, navigation and markdown; the domain imports no application.
319
+
320
+ The thread grouping function works on bundles without a host:
321
+
322
+ ```ts
323
+ import { branches } from '@yaks/kernel/comments'
324
+ import { equal } from '@yaks/testing'
325
+ let roots = branches([
326
+ {
327
+ entity: { eid: 'reply', num: 2 },
328
+ comment: { target: 'task', reply_to: 'ask' },
329
+ },
330
+ { entity: { eid: 'ask', num: 1 }, comment: { target: 'task' } },
331
+ ])
332
+ equal(roots[0].children[0].row.entity.eid, 'reply')
333
+ ```
@@ -0,0 +1,18 @@
1
+ import type { Bundle } from "@yaks/graph";
2
+ import type { Vocab } from "@yaks/vocab";
3
+ export declare let CITES: string;
4
+ /** SHA-256 over an entity's client-written properties, in a fixed order. */ export declare let content: (vocab: Vocab) => any;
5
+ export type Status = {
6
+ state: 'current';
7
+ } | {
8
+ state: 'moved';
9
+ changes?: string[];
10
+ } | {
11
+ state: 'unverified';
12
+ } | {
13
+ state: 'unknown';
14
+ why: string;
15
+ };
16
+ /** Whether the cited entity still says what was verified. */ export declare let status: (cite: Bundle, to: Bundle, vocab: Vocab) => Status;
17
+ /** The patch recording that somebody checked this citation's target. */ export declare let verify: (cite: Bundle, to: Bundle, vocab: Vocab) => Bundle;
18
+ //# sourceMappingURL=cites.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cites.d.ts","sources":["../cites.ts"],"names":[],"mappings":"AAKA,cAAc,MAAM,2BAAsC;AAI1D,cAAc,KAAK,2BAAgC;AAEnD,OAAO,YAAI,cAAe;AAQ1B,0EAA0E,GAC1E,OAAO,YAAI,UAAW,OAAO,cAU5B;AAED,YAAY;EACN,OAAO;;EACP,OAAO;EAAS,UAAU,MAAM;;EAChC,OAAO;;EACP,OAAO;EAAW,KAAK,MAAM;;AAEnC,2DAA2D,GAC3D,OAAO,YAAI,SAAU,MAAM,QAAQ,IAAI,QAAQ,OAAO,UAAQ,OAa7D;AAED,sEAAsE,GACtE,OAAO,YAAI,SAAU,MAAM,QAAQ,IAAI,QAAQ,OAAO,UAAQ,OAO7D"}
@@ -0,0 +1,30 @@
1
+ import type { Bundle } from "@yaks/graph";
2
+ import type { ReactNode } from "@types/react";
3
+ export type CommentHost = {
4
+ get: (eid: string) => Bundle;
5
+ id: (b: Bundle) => string;
6
+ useRows: (query: string) => Bundle[];
7
+ useModel: (eid: string) => string | undefined;
8
+ useRepo: (b: Bundle) => string | undefined;
9
+ usePage: (name: string, place: string) => {
10
+ value?: Record<string, unknown>;
11
+ set: (value: Record<string, unknown>) => void;
12
+ };
13
+ render: (b: Bundle, view: string) => ReactNode;
14
+ link: (b: Bundle) => Record<string, unknown>;
15
+ markdown: (text: string, repo?: string) => ReactNode;
16
+ pending: (b: Bundle) => boolean;
17
+ has: (comp: string) => boolean;
18
+ modelName: (model?: string) => string | undefined;
19
+ when: (at?: string) => string;
20
+ timestamp: (at?: string) => string;
21
+ command: (line: string) => boolean;
22
+ hints: (line: string) => {
23
+ name: string;
24
+ args: string;
25
+ about: string;
26
+ }[];
27
+ };
28
+ /** Bind the domain to an interface before mounting its views. */ export declare let configureComments: (host: CommentHost) => void;
29
+ export declare let commentHost: () => CommentHost;
30
+ //# sourceMappingURL=comment-host.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comment-host.d.ts","sources":["../comment-host.ts"],"names":[],"mappings":"AAEA,cAAc,MAAM,2BAAgC;AACV,cAAc,SAAS,uBAA0B;AAE3F,YAAY;EACV,MAAM,KAAK,MAAM,KAAK;EACtB,KAAK,GAAG,WAAW,MAAM;EACzB,UAAU,OAAO,MAAM,KAAK;EAC5B,WAAW,KAAK,MAAM,KAAK,MAAM,GAAG,SAAS;EAC7C,UAAU,GAAG,WAAW,MAAM,GAAG,SAAS;EAC1C,UAAU,MAAM,MAAM,EAAE,OAAO,MAAM;IACnC,QAAQ,OAAO,MAAM,EAAE,OAAO;IAC9B,MAAM,OAAO,OAAO,MAAM,EAAE,OAAO,MAAM,IAAI;;EAE/C,SAAS,GAAG,QAAQ,MAAM,MAAM,KAAK;EACrC,OAAO,GAAG,WAAW,OAAO,MAAM,EAAE,OAAO;EAC3C,WAAW,MAAM,MAAM,EAAE,OAAO,MAAM,KAAK;EAC3C,UAAU,GAAG,WAAW,OAAO;EAC/B,MAAM,MAAM,MAAM,KAAK,OAAO;EAC9B,YAAY,QAAQ,MAAM,KAAK,MAAM,GAAG,SAAS;EACjD,OAAO,KAAK,MAAM,KAAK,MAAM;EAC7B,YAAY,KAAK,MAAM,KAAK,MAAM;EAClC,UAAU,MAAM,MAAM,KAAK,OAAO;EAClC,QAAQ,MAAM,MAAM;IAAO,MAAM,MAAM;IAAE,MAAM,MAAM;IAAE,OAAO,MAAM;;;AAGtE,+DAA+D,GAC/D,OAAO,YAAI,oBAAqB,MAAM,gBAAc,IAAI,CAEvD;AACD,OAAO,YAAI,mBAAkB,YAG5B"}
@@ -0,0 +1,20 @@
1
+ import type { Bundle } from "@yaks/graph";
2
+ export type CommentRow = Bundle & {
3
+ created?: {
4
+ at?: string;
5
+ by?: string;
6
+ via?: string;
7
+ };
8
+ comment?: {
9
+ target: string;
10
+ reply_to?: string;
11
+ };
12
+ };
13
+ export type Branch = {
14
+ row: CommentRow;
15
+ children: Branch[];
16
+ };
17
+ export declare let branches: (rows: CommentRow[]) => Branch[];
18
+ /** Who a thread names in its bylines: each note's writer and the instrument
19
+ * it came through, once each, so a host can ask for them by name. */ export declare let writers: (rows: CommentRow[]) => string[];
20
+ //# sourceMappingURL=comments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comments.d.ts","sources":["../comments.ts"],"names":[],"mappings":"AAEA,cAAc,MAAM,2BAAgC;AAEpD,YAAY,aAAa;EACvB;IAAY,KAAK,MAAM;IAAE,KAAK,MAAM;IAAE,MAAM,MAAM;;EAClD;IAAY,QAAQ,MAAM;IAAE,WAAW,MAAM;;;AAG/C,YAAY;EAAW,KAAK;EAAY,UAAU;;AAElD,OAAO,YAAI,WAAY,MAAM,iBAAe,SAoC3C;AAED;mEACmE,GAGnE,OAAO,YAAI,UAAW,MAAM,iBAAe,MAAM,GAKhD"}
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from "@yaks/graph";
2
+ /** The kernel components, and the hook that records who completed something. */ export declare let plugins: () => Plugin[];
3
+ //# sourceMappingURL=graph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph.d.ts","sources":["../graph.ts"],"names":[],"mappings":"AAGA,cAAc,MAAM,2BAAgC;AAGpD,8EAA8E,GAC9E,OAAO,YAAI,eAAc,SAAsB"}
@@ -0,0 +1,9 @@
1
+ import type { Keywords } from "@yaks/vocab";
2
+ /** The URI a vocabulary file declares under `$vocabulary` to use these
3
+ * keywords. */ export declare let KERNEL_URI: string;
4
+ /**
5
+ * The kernel keyword vocabulary, ready to register: `loadVocab(docs,
6
+ * [kernelKeywords])` carries `governed` and `lazy` onto the components that
7
+ * declare them and `well` onto the properties that do.
8
+ */ export declare let kernelKeywords: Keywords;
9
+ //# sourceMappingURL=keywords.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keywords.d.ts","sources":["../keywords.ts"],"names":[],"mappings":"AAWA,cAAc,QAAQ,2BAAgC;AAGtD;aACa,GACb,OAAO,YAAI,mBAA0C;AAErD;;;;CAIC,GACD,OAAO,YAAI,gBAAgB,SAK1B"}
package/_dist/mod.d.ts ADDED
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The components most graphs of work need: the `entity` row every entity has,
3
+ * the marks recording what happened to a thing and who did it (`proposed`,
4
+ * `decided`, `quarantined`), the lifecycle marks a status is read from
5
+ * (`completed`, `failed`, `broken`, `resolved`, `verified`), the things that
6
+ * attach to an entity (`comment`, `image`, `favorite`), and the tags that give
7
+ * an edge its meaning (`about`, `reads`, `references`, `supersedes`, …). The
8
+ * stamps every write leaves, `created` and `updated`, are @yaks/provenance's.
9
+ *
10
+ * It ships the vocabulary, three keywords that describe what the core
11
+ * meta-model does not (see {@link kernelKeywords}), and the pure content hash
12
+ * and freshness answer for citations. The
13
+ * `entity` row is the identity row every entity has; what is KEPT beside the
14
+ * eid is each plugin's own — the archetype is @yaks/archetype's word and the
15
+ * number a human id is built from is @yaks/id's.
16
+ *
17
+ * Who a write is signed as is not here, and it is not a name out of a config
18
+ * file: a write that did not arrive through an authenticated HTTP or MCP
19
+ * request is signed as the `process` row this run wrote about itself
20
+ * (@yaks/process `started`), because a program that runs twice is two writers —
21
+ * two `yak` commands over one database file are two of them.
22
+ */ export { KERNEL_URI, kernelKeywords } from "./keywords.js";
23
+ export { kernelDoc, marksDoc, spineDoc } from "./vocab.js";
24
+ export { kernel } from "./plugin.js";
25
+ export * from "./cites.js";
26
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sources":["../mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;CAqBC,GACD,SAAS,UAAU,EAAE,cAAc,wBAAuB;AAC1D,SAAS,SAAS,EAAE,QAAQ,EAAE,QAAQ,qBAAoB;AAC1D,SAAS,MAAM,sBAAqB;AACpC,2BAA0B"}
@@ -0,0 +1,6 @@
1
+ import { type Plugin } from "@yaks/graph/plugin";
2
+ /**
3
+ * The kernel plugin: every component ./vocab.json declares, and a
4
+ * `precondition` hook that records completion and decision attribution.
5
+ */ export declare let kernel: () => Plugin;
6
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sources":["../plugin.ts"],"names":[],"mappings":"AAEA,SAAe,KAAK,MAAM,kCAAuC;AAKjE;;;CAGC,GAUD,OAAO,YAAI,cAAa,OAUtB"}
@@ -0,0 +1,6 @@
1
+ import type { Runs } from "@yaks/graph/tools";
2
+ /** The implementations of the tools ./vocab.json declares. A function that
3
+ * builds them, the way every entry point here is, though this one needs nothing
4
+ * from the server: what an implementation reads arrives on the call it is
5
+ * handed. */ export declare let runs: () => Runs;
6
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sources":["../tools.ts"],"names":[],"mappings":"AAWA,cAAc,IAAI,iCAAsC;AAExD;;;WAGW,GACX,OAAO,YAAI,YAAW,KAYpB"}
@@ -0,0 +1,8 @@
1
+ import type { Bundle } from "@yaks/graph";
2
+ import type { ComponentRenderer } from "@yaks/react";
3
+ import { type Registry } from "@yaks/render";
4
+ /** A comment's `Tile`. */ export declare let views: Registry;
5
+ export declare let componentViews: () => Promise<{
6
+ renderers: ComponentRenderer<Bundle>[];
7
+ }>;
8
+ //# sourceMappingURL=views.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"views.d.ts","sources":["../views.ts"],"names":[],"mappings":"AAIA,cAAc,MAAM,2BAAgC;AACpD,cAAc,iBAAiB,2BAAgC;AAE/D,SAAiB,KAAK,QAAQ,4BAAiC;AAM/D,wBAAwB,GACxB,OAAO,YAAI,OAAO,SAUf;AAEH,OAAO,YAAI,sBAAqB;EAC5B,WAAW,kBAAkB;GACwB"}
@@ -0,0 +1,16 @@
1
+ import { type Keywords, type VocabDoc } from "@yaks/vocab/runtime";
2
+ import { kernelKeywords } from "./keywords.js";
3
+ export { kernelKeywords };
4
+ /** The kernel vocabulary, as the document `loadVocab` takes. */ export declare let kernelDoc: VocabDoc;
5
+ /** Just `entity{archetype}`, for a program that loads it without the rest of
6
+ * the kernel's components. @yaks/provenance declares the stamps beside it,
7
+ * `created` and `updated`. */ export declare let spineDoc: VocabDoc;
8
+ /** The two marks anything at all can carry — `opened`, somebody looked at it,
9
+ * and `archived`, somebody put it away — for a program that loads `spineDoc`
10
+ * without the rest of the kernel's components and still wants listings to hide
11
+ * what was put away. */ export declare let marksDoc: VocabDoc;
12
+ /** What this package is: its manifest's description, the one place it is
13
+ * written, which a host stamps on each document here. */ export declare let description: string;
14
+ /** Every document this plugin declares. */ export declare let docs: VocabDoc[];
15
+ /** The JSON Schema keywords those documents use. */ export declare let keywords: Keywords[];
16
+ //# sourceMappingURL=vocab.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vocab.d.ts","sources":["../vocab.ts"],"names":[],"mappings":"AAIA,SAAS,KAAK,QAAQ,EAAQ,KAAK,QAAQ,mCAAwC;AACnF,SAAS,cAAc,wBAAuB;AAI9C,SAAS,cAAc,GAAE;AAEzB,8DAA8D,GAC9D,OAAO,YAAI,WAAW,SAA0B;AAEhD;;4BAE4B,GAC5B,OAAO,YAAI,UAAU,SAA+C;AAEpE;;;sBAGsB,GACtB,OAAO,YAAI,UAAU,SAA2D;AAEhF;uDACuD,GACvD,OAAO,YAAI,aAAa,MAAM,CAAuB;AAErD,yCAAyC,GACzC,OAAO,YAAI,MAAM,WAAwB;AAEzC,kDAAkD,GAClD,OAAO,YAAI,UAAU,WAA6B"}
package/cites.js ADDED
@@ -0,0 +1,61 @@
1
+ // A citation of a graph entity keeps the content it was checked against.
2
+ // The hash ignores server-owned stamps, so bookkeeping cannot make a claim
3
+ // stale. File and symbol citations have a narrower answer in @yaks/git.
4
+ import { cmp } from "@yaks/fp";
5
+ import { comps } from "@yaks/graph/bundle";
6
+ import { Refused } from "@yaks/graph/errors";
7
+ import { sha256 } from "@yaks/graph/sha256";
8
+ export let CITES = 'cites';
9
+ let written = (c, props)=>{
10
+ let out = {};
11
+ for (let p of props.toSorted())if (c[p] != null) out[p] = c[p];
12
+ return out;
13
+ };
14
+ /** SHA-256 over an entity's client-written properties, in a fixed order. */ export let content = (vocab)=>(b)=>{
15
+ let kept = [];
16
+ for (let [name, c] of comps(b)){
17
+ let info = vocab.comp(name);
18
+ if (!c || !info?.wire) continue;
19
+ if (!info.writable.length && info.stamped.length) continue;
20
+ kept.push([
21
+ name,
22
+ written(c, info.writable)
23
+ ]);
24
+ }
25
+ kept.sort(([a], [b])=>cmp(a, b));
26
+ return sha256(JSON.stringify(kept));
27
+ };
28
+ /** Whether the cited entity still says what was verified. */ export let status = (cite, to, vocab)=>{
29
+ if (!cite.verified) return {
30
+ state: 'unverified'
31
+ };
32
+ if (to.tombstone) return {
33
+ state: 'moved'
34
+ };
35
+ let row = cite[CITES];
36
+ let hash = row && typeof row == 'object' && 'hash' in row ? row.hash : undefined;
37
+ if (typeof hash != 'string' || !hash) {
38
+ return {
39
+ state: 'unknown',
40
+ why: 'verified against no content hash'
41
+ };
42
+ }
43
+ return hash == content(vocab)(to) ? {
44
+ state: 'current'
45
+ } : {
46
+ state: 'moved'
47
+ };
48
+ };
49
+ /** The patch recording that somebody checked this citation's target. */ export let verify = (cite, to, vocab)=>{
50
+ if (to.tombstone) throw new Refused('cannot verify a deleted entity');
51
+ return {
52
+ entity: {
53
+ eid: cite.entity.eid
54
+ },
55
+ verified: {},
56
+ [CITES]: {
57
+ hash: content(vocab)(to)
58
+ }
59
+ };
60
+ };
61
+ //# sourceMappingURL=cites.js.map
package/cites.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cites.js","sources":["./cites.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,2EAA2E;AAC3E,wEAAwE;AAExE,SAAS,GAAG,wBAA6B;AAEzC,SAAS,KAAK,kCAAuC;AACrD,SAAS,OAAO,kCAAuC;AACvD,SAAS,MAAM,kCAAuC;AAGtD,OAAO,IAAI,QAAQ,QAAO;AAE1B,IAAI,UAAU,CAAC,GAAS;EACtB,IAAI,MAAY,CAAC;EACjB,KAAK,IAAI,KAAK,MAAM,QAAQ,GAAI,IAAI,CAAC,CAAC,EAAE,IAAI,MAAM,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE;EAC/D,OAAO;AACT;AAEA,0EAA0E,GAC1E,OAAO,IAAI,UAAU,CAAC,QAAiB,CAAC;IACtC,IAAI,OAAyB,EAAE;IAC/B,KAAK,IAAI,CAAC,MAAM,EAAE,IAAI,MAAM,GAAI;MAC9B,IAAI,OAAO,MAAM,IAAI,CAAC;MACtB,IAAI,CAAC,KAAK,CAAC,MAAM,MAAM;MACvB,IAAI,CAAC,KAAK,QAAQ,CAAC,MAAM,IAAI,KAAK,OAAO,CAAC,MAAM,EAAE;MAClD,KAAK,IAAI,CAAC;QAAC;QAAM,QAAQ,GAAG,KAAK,QAAQ;OAAE;IAC7C;IACA,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,GAAK,IAAI,GAAG;IAC/B,OAAO,OAAO,KAAK,SAAS,CAAC;EAC/B,EAAC;AAQD,2DAA2D,GAC3D,OAAO,IAAI,SAAS,CAAC,MAAc,IAAY;EAC7C,IAAI,CAAC,KAAK,QAAQ,EAAE,OAAO;IAAE,OAAO;EAAa;EACjD,IAAI,GAAG,SAAS,EAAE,OAAO;IAAE,OAAO;EAAQ;EAC1C,IAAI,MAAM,IAAI,CAAC,MAAM;EACrB,IAAI,OAAO,OAAO,OAAO,OAAO,YAAY,UAAU,MAClD,IAAI,IAAI,GACR;EACJ,IAAI,OAAO,QAAQ,YAAY,CAAC,MAAM;IACpC,OAAO;MAAE,OAAO;MAAW,KAAK;IAAmC;EACrE;EACA,OAAO,QAAQ,QAAQ,OAAO,MAAM;IAAE,OAAO;EAAU,IAAI;IACzD,OAAO;EACT;AACF,EAAC;AAED,sEAAsE,GACtE,OAAO,IAAI,SAAS,CAAC,MAAc,IAAY;EAC7C,IAAI,GAAG,SAAS,EAAE,MAAM,IAAI,QAAQ;EACpC,OAAO;IACL,QAAQ;MAAE,KAAK,KAAK,MAAM,CAAC,GAAG;IAAC;IAC/B,UAAU,CAAC;IACX,CAAC,MAAM,EAAE;MAAE,MAAM,QAAQ,OAAO;IAAI;EACtC;AACF,EAAC"}